diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
commit | bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch) | |
tree | 1d1df72c0541a59a81439842f46d95396d3e7189 | |
parent | 8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff) | |
download | ydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz |
add ymake export to ydb
3323 files changed, 247098 insertions, 2058 deletions
diff --git a/.arcadia.root b/.arcadia.root new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/.arcadia.root diff --git a/build/conf/bison_lex.conf b/build/conf/bison_lex.conf new file mode 100644 index 00000000000..9e195c71388 --- /dev/null +++ b/build/conf/bison_lex.conf @@ -0,0 +1,147 @@ +# This defines macros and rules for Bison and Flex source processing +# +# This specilizes _SRC() macro, so should be imported after generic version definition +# Thus uses _ADD_HIDDEN_INPUTS() macro from ymake.core.conf + +LEX_FLAGS= +BISON_FLAGS=-v + +_BISON_DATA_DIR=contrib/tools/bison/bison/data +_CPP_BISON_SKELS=\ + ${_BISON_DATA_DIR}/bison.m4 \ + ${_BISON_DATA_DIR}/c++-skel.m4 \ + ${_BISON_DATA_DIR}/c++.m4 \ + ${_BISON_DATA_DIR}/c-like.m4 \ + ${_BISON_DATA_DIR}/c-skel.m4 \ + ${_BISON_DATA_DIR}/c.m4 \ + ${_BISON_DATA_DIR}/glr.cc \ + ${_BISON_DATA_DIR}/lalr1.cc \ + ${_BISON_DATA_DIR}/location.cc \ + ${_BISON_DATA_DIR}/m4sugar/foreach.m4 \ + ${_BISON_DATA_DIR}/m4sugar/m4sugar.m4 \ + ${_BISON_DATA_DIR}/stack.hh \ + ${_BISON_DATA_DIR}/variant.hh \ + ${_BISON_DATA_DIR}/yacc.c \ + +_BISON_GEN_EXT=.cpp +_FLEX_GEN_EXT=.cpp + +_BISON_HEADER=--defines=${nopath;noext;output;main;addincl;norel;suf=.h:SRC} +_BISON_PP=$YMAKE_PYTHON ${input:"build/scripts/preprocess.py"} $_ADD_HIDDEN_INPUTS($_CPP_BISON_SKELS) ${nopath;noext;tmp:SRC.h} + +_FLEX_TOOL=${tool:"contrib/tools/flex-old"} +_FLEX_TOOL_DIR=contrib/tools/flex-old +_FLEX_HEADER= + +### @usage: FLEX_FLAGS(<flags>) +### +### Set flags for Lex tool (flex) invocations. +macro FLEX_FLAGS(Flags...) { + SET_APPEND(LEX_FLAGS $Flags) +} + +### @usage: BISON_FLAGS(<flags>) +### +### Set flags for Bison tool invocations. +macro BISON_FLAGS(Flags...) { + SET_APPEND(BISON_FLAGS $Flags) +} + +### @usage: BISON_GEN_C() +### +### Generate C from Bison grammar. The C++ is generated by default. +macro BISON_GEN_C() { + SET(_BISON_GEN_EXT .c) + SET(_BISON_PP) +} + +### @usage: BISON_GEN_CPP() +### +### Generate C++ from Bison grammar. This is current default. +macro BISON_GEN_CPP() { + SET(_BISON_GEN_EXT .cpp) +} + + +### @usage: FLEX_GEN_C() +### +### Generate C from Lex grammar. The C++ is generated by default. +macro FLEX_GEN_C() { + SET(_FLEX_GEN_EXT .c) +} + +### @usage: FLEX_GEN_CPP() +### +### Generate C++ from Lex grammar. This is current default. +macro FLEX_GEN_CPP() { + SET(_FLEX_GEN_EXT .cpp) +} + +### @usage: BISON_HEADER(<header_suffix>) +### +### Use SUFF (including extension) to name Bison defines header file. The default is just `.h`. +macro BISON_HEADER(Suffix) { + SET(_BISON_HEADER --defines=\${nopath;noext;output;main;addincl;norel;suf=$Suffix:SRC}) +} + +### @usage: BISON_NO_HEADER() +### +### Don't emit Bison defines header file. +macro BISON_NO_HEADER() { + SET(_BISON_HEADER) +} + +### @usage: USE_MODERN_FLEX() +### +### Use `contrib/tools/flex` as flex tool. Default is `contrib/tools/flex-old`. +### @note: by default no header is emitted. Use `USE_MODERN_FLEX_WITH_HEADER` to add header emission. +macro USE_MODERN_FLEX() { + SET(_FLEX_TOOL \${tool:"contrib/tools/flex"} --m4=\${tool:"contrib/tools/bison/m4"}) + SET(_FLEX_TOOL_DIR contrib/tools/flex) +} + +### @usage: USE_MODERN_FLEX_WITH_HEADER(<header_suffix>) +### +### Use `contrib/tools/flex` as flex tool. Default is `contrib/tools/flex-old`. +### Additionally emit headers with suffix provided. Header suffix should include extension `.h`. +### +### @example: USE_MODERN_FLEX_WITH_HEADER(_lexer.h) +macro USE_MODERN_FLEX_WITH_HEADER(Suffix) { + SET(_FLEX_TOOL \${tool:"contrib/tools/flex"} --m4=\${tool:"contrib/tools/bison/m4"}) + SET(_FLEX_TOOL_DIR contrib/tools/flex) + SET(_FLEX_HEADER --header-file=\${nopath;noext;output;main;addincl;norel;suf=$Suffix:SRC}) +} + +### @usage: USE_OLD_FLEX() +### +### Use `contrib/tools/flex-old` as flex tool. This is current default. +macro USE_OLD_FLEX() { + SET(_FLEX_TOOL \${tool:"contrib/tools/flex-old"}) + SET(_FLEX_TOOL_DIR contrib/tools/flex-old) +} + +macro _SRC("y", SRC, SRCFLAGS...) { + .CMD=${tool:"contrib/tools/bison/bison"} $BISON_FLAGS --m4=${tool:"contrib/tools/bison/m4"} $_BISON_HEADER -o ${nopath;output;suf=$_BISON_GEN_EXT:SRC} ${input:SRC} ${SRCFLAGS} ${kv;hide:"p YC"} ${kv;hide:"pc light-green"} && $_BISON_PP + .SEM=target_bison_parser PRIVATE ${input:SRC} ${output;nopath;noext;hide;suf=${OBJ_SUF}.o:SRC} ${nopath;noext;output;hide:SRC.h} ${nopath;noext;output;addincl;hide:SRC.h} && set_global_flags BISON_FLAGS $BISON_FLAGS && conan_require_tool m4/1.4.19 && conan_import '"bin, m4* -> ./bin/m4/bin"' && conan_require_tool bison/3.5.3 && conan_import '"bin, bison* -> ./bin/bison/bin"' && conan_import '"res, * -> ./bin/bison/res"' +} + +macro _SRC("ypp", SRC, SRCFLAGS...) { + .CMD=$_SRC(y $SRC $SRCFLAGS) + .SEM=$_SRC(y $SRC $SRCFLAGS) +} + +macro _SRC("l", SRC, SRCFLAGS...) { + .CMD=$_FLEX_TOOL $LEX_FLAGS ${SRCFLAGS} $_FLEX_HEADER -o${output;suf=$_FLEX_GEN_EXT:SRC} ${output_include;hide:"util/system/compiler.h"} ${input:SRC} ${kv;hide:"p LX"} ${kv;hide:"pc yellow"} + .ADDINCL=$_FLEX_TOOL_DIR + .SEM=target_flex_lexers ${tool;hide:_FLEX_TOOL} ${output;hide;suf=${OBJ_SUF}.o:SRC} ${input:SRC} && set_global_flags LEX_FLAGS $LEX_FLAGS +} + +# tag:src-processing +macro _SRC("lex", SRC, SRCFLAGS...) { + .CMD=$_SRC(l $SRC $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("lpp", SRC, SRCFLAGS...) { + .CMD=$_SRC(l $SRC $SRCFLAGS) +} diff --git a/build/conf/compilers/gnu_compiler.conf b/build/conf/compilers/gnu_compiler.conf new file mode 100644 index 00000000000..97e6f94abc7 --- /dev/null +++ b/build/conf/compilers/gnu_compiler.conf @@ -0,0 +1,232 @@ +_OPTIMIZE_RELEASE= +when ($_BUILD_RELEASE == "yes") { + when ($_BUILD_SIZE_OPTIMIZED == "yes") { + # -Oz is clang's more size-aggressive version of -Os + # For ARM specifically, clang -Oz is on par with gcc -Os: + # https://github.com/android/ndk/issues/133#issuecomment-365763507 + when($CLANG == "yes") { + _OPTIMIZE_RELEASE=-Oz + } + otherwise { + _OPTIMIZE_RELEASE=-Os + } + } + otherwise { + _OPTIMIZE_RELEASE=-O3 + } +} + +_SFDL_FLAGS=-E -C -x c++ +when ($CLANG == "yes") { + _SFDL_FLAGS+=-Qunused-arguments +} + +_DEBUG_INFO_FLAGS=-g +when ($OS_LINUX == "yes") { + _DEBUG_INFO_FLAGS=-g -ggnu-pubnames +} + +_CROSS_SUFFIX=.pic +when ($FORCE_NO_PIC == "yes") { + _CROSS_SUFFIX= +} + +C_COMPILER=${quo:C_COMPILER_UNQUOTED} +OPTIMIZE=$_OPTIMIZE_RELEASE +FSTACK=-fstack-protector +DUMP_DEPS= +GCC_PREPROCESSOR_OPTS=$DUMP_DEPS $C_DEFINES + +# PIE is only valid for executables, while PIC implies a shared library +# `-pie` with a shared library is either ignored or fails to link +when ($PIC == "yes") { + CFLAGS+=-fPIC + LDFLAGS+=-fPIC +} +elsewhen ($PIE == "yes") { + CFLAGS+=-fPIE + LDFLAGS+=-fPIE -pie +} + +when ($ARCH_XTENSA == "yes") { + FSTACK= +} + +CFLAGS+=$_C_FLAGS $DEBUG_INFO_FLAGS $_C_FOPTIONS $C_WARNING_OPTS $GCC_PREPROCESSOR_OPTS $USER_CFLAGS $USER_CFLAGS_GLOBAL +CXXFLAGS+=$CFLAGS $_CXX_STD $CXX_WARNING_OPTS $USER_CXXFLAGS $USER_CXXFLAGS_GLOBAL +CONLYFLAGS+=$USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL +CXX_COMPILER=${quo:CXX_COMPILER_UNQUOTED} +NOGCCSTACKCHECK=yes +SFDL_FLAG=$_SFDL_FLAGS -o $SFDL_TMP_OUT +WERROR_FLAG=-Werror +DEBUG_INFO_FLAGS=$_DEBUG_INFO_FLAGS + +when ($NO_WSHADOW == "yes") { + C_WARNING_OPTS += -Wno-shadow +} +# Though -w is intended to switch off all the warnings, +# it does not switch at least -Wregister and -Wreserved-user-defined-literal under clang. +# +# Use -Wno-everything to force warning suppression. +when ($NO_COMPILER_WARNINGS == "yes") { + C_WARNING_OPTS = -w + CXX_WARNING_OPTS = -Wno-everything +} +when ($NO_OPTIMIZE == "yes") { + OPTIMIZE = -O0 +} +when ($SAVE_TEMPS == "yes") { + CXXFLAGS += -save-temps +} +when ($NOGCCSTACKCHECK != "yes") { + FSTACK += -fstack-check +} + +when ($FORCE_CONSISTENT_DEBUG == "yes") { + when ($CLANG == "yes") { + CL_DEBUG_INFO=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T -Xclang -fdebug-compilation-dir -Xclang /tmp + } + otherwise { + CL_DEBUG_INFO=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T + when ($ARCH_XTENSA == "yes") { + CL_DEBUG_INFO= + } + } + YASM_DEBUG_INFO=--replace=${ARCADIA_BUILD_ROOT}=/-B --replace=${ARCADIA_ROOT}=/-S --replace=$(TOOL_ROOT)=/-T ${env:"YASM_TEST_SUITE=1"} +} +elsewhen ($CONSISTENT_DEBUG == "yes") { + when ($CLANG == "yes") { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T -Xclang -fdebug-compilation-dir -Xclang /tmp + } + otherwise { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T + when ($ARCH_XTENSA == "yes") { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__= + } + } + YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=--replace=${ARCADIA_BUILD_ROOT}=/-B --replace=${ARCADIA_ROOT}=/-S --replace=$(TOOL_ROOT)=/-T ${env:"YASM_TEST_SUITE=1"} +} +elsewhen ($CONSISTENT_DEBUG_LIGHT == "yes") { + when ($CLANG == "yes") { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -Xclang -fdebug-compilation-dir -Xclang /tmp + } + otherwise { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B + when ($ARCH_XTENSA == "yes") { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__= + } + } + YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=--replace=${ARCADIA_BUILD_ROOT}=/-B ${env:"YASM_TEST_SUITE=1"} +} + +when ($FORCE_CONSISTENT_BUILD == "yes") { + CL_MACRO_INFO=-Wno-builtin-macro-redefined -D__DATE__=\""Sep 31 2019\"" -D__TIME__=\"00:00:00\" -fmacro-prefix-map=${ARCADIA_BUILD_ROOT}/= -fmacro-prefix-map=${ARCADIA_ROOT}/= -fmacro-prefix-map=$(TOOL_ROOT)/= +} +elsewhen ($CONSISTENT_BUILD == "yes") { + CL_MACRO_INFO_DISABLE_CACHE__NO_UID__=-Wno-builtin-macro-redefined -D__DATE__=\""Sep 31 2019\"" -D__TIME__=\"00:00:00\" -fmacro-prefix-map=${ARCADIA_BUILD_ROOT}/= -fmacro-prefix-map=${ARCADIA_ROOT}/= -fmacro-prefix-map=$(TOOL_ROOT)/= +} + +_CFLAGS_ARCH_I386= +when ($ARCH_I386 == "yes" && $ARCH_I686 != "yes") { + _CFLAGS_ARCH_I386=-march=pentiumpro -mtune=pentiumpro +} + +CFLAGS+=$_CFLAGS_ARCH_I386 + +BC_CFLAGS+=$CFLAGS +BC_CXXFLAGS+=$CXXFLAGS +C_DEFINES+=-D__LONG_LONG_SUPPORTED + +OBJ_CROSS_SUF=$OBJ_SUF$_CROSS_SUFFIX +OBJECT_SUF=$OBJ_SUF$_CROSS_SUFFIX.o +GCC_COMPILE_FLAGS=$EXTRA_C_FLAGS -c -o $_COMPILE_OUTPUTS ${pre=-I:_C__INCLUDE} +EXTRA_COVERAGE_OUTPUT=${output;noauto;hide;suf=${OBJECT_SUF}.gcno:SRC} +CLANG_TIDY_OUTPUT_FILE=${output;noauto;suf=${OBJECT_SUF}.tidyjson:SRC} +YNDEXER_OUTPUT_FILE=${output;noauto;suf=${OBJECT_SUF}${COMPILE_OUT_SUFFIX}.ydx.pb2:SRC} + +when ($DUMP_COMPILER_DEPS == "yes") { + DUMP_DEPS=-MD ${output;hide;noauto;suf=${OBJ_SUF}.o.d:SRC} +} +elsewhen ($DUMP_COMPILER_DEPS_FAST == "yes") { + DUMP_DEPS=-E -M -MF ${output;noauto;suf=${OBJ_SUF}.o.d:SRC} +} + +_COMPILER_TIME_TRACE_GRANULARITY=500 +when ($TIME_TRACE_GRANULARITY && $TIME_TRACE_GRANULARITY != "") { + _COMPILER_TIME_TRACE_GRANULARITY=$TIME_TRACE_GRANULARITY +} + +_COMPILER_TIME_TRACE_FLAGS= +_COMPILER_TIME_TRACE_POSTPROCESS= +when (($TIME_TRACE == "yes" || $COMPILER_TIME_TRACE == "yes") && $_HAS_TIME_TRACE == "yes") { + _COMPILER_TIME_TRACE_FLAGS=-ftime-trace -ftime-trace-granularity=$_COMPILER_TIME_TRACE_GRANULARITY + _COMPILER_TIME_TRACE_POSTPROCESS=$YMAKE_PYTHON ${input:"build/scripts/find_time_trace.py"} $_COMPILE_OUTPUTS $_COMPILE_TIME_TRACE_OUTPUTS +} + +_C_CPP_KV_STYLE=${hide;kv:"p CC"} ${hide;kv:"pc green"} +_CPP_ARGS=\ + $CLANG_TIDY_ARGS \ + $YNDEXER_ARGS \ + $RETRY_ARGS \ + $CXX_COMPILER \ + $C_FLAGS_PLATFORM \ + $GCC_COMPILE_FLAGS \ + $CXXFLAGS \ + $CL_MACRO_INFO \ + $CL_MACRO_INFO_DISABLE_CACHE__NO_UID__ \ + $_COMPILER_TIME_TRACE_FLAGS \ + $EXTRA_OUTPUT \ + $SRCFLAGS \ + $_LANG_CFLAGS_VALUE \ + ${input:SRC} \ + $TOOLCHAIN_ENV \ + $YNDEXER_OUTPUT \ + && $_COMPILER_TIME_TRACE_POSTPROCESS \ + $_C_CPP_KV_STYLE + +_C_ARGS=\ + $CLANG_TIDY_ARGS \ + $YNDEXER_ARGS \ + $RETRY_ARGS \ + $C_COMPILER \ + $C_FLAGS_PLATFORM \ + $GCC_COMPILE_FLAGS \ + $CFLAGS \ + $CL_MACRO_INFO \ + $CL_MACRO_INFO_DISABLE_CACHE__NO_UID__ \ + $_COMPILER_TIME_TRACE_FLAGS \ + $CONLYFLAGS \ + $EXTRA_OUTPUT \ + $SRCFLAGS \ + ${input:SRC} \ + $TOOLCHAIN_ENV \ + $YNDEXER_OUTPUT \ + $_C_CPP_KV_STYLE + +### _SRC_C_NODEPS_CMD is obtained from _C_ARGS by filtering the following elements: +### ${input:SRC} +### $CL_MACRO_INFO +### $CL_MACRO_INFO_DISABLE_CACHE__NO_UID__ +### $CLANG_TIDY_ARGS +### $EXTRA_OUTPUT +### $EXTRA_COVERAGE_OUTPUT +### $SRCFLAGS +### $YNDEXER_ARGS +### $YNDEXER_OUTPUT +### +### $GCC_COMPILE_FLAGS is substituted for $EXTRA_C_FLAGS -c -o ${OUTFILE} ${SRC} ${pre=-I:INC} +_SRC_C_NODEPS_CMD=\ + $C_COMPILER \ + $C_FLAGS_PLATFORM \ + $EXTRA_C_FLAGS -c -o ${OUTFILE} ${SRC} ${pre=-I:INC} \ + $CFLAGS \ + $CONLYFLAGS \ + $TOOLCHAIN_ENV \ + $_C_CPP_KV_STYLE + +_FORCE_CPP_FLAGS=-x c++ + +_SRC_CPP_CMD=$_CPP_ARGS +_SRC_C_CMD=$_C_ARGS +_SRC_M_CMD=$SRC_c($SRC $SRCFLAGS) +_SRC_MASM_CMD=$_EMPTY_CMD diff --git a/build/conf/compilers/msvc_compiler.conf b/build/conf/compilers/msvc_compiler.conf new file mode 100644 index 00000000000..a509b02348f --- /dev/null +++ b/build/conf/compilers/msvc_compiler.conf @@ -0,0 +1,90 @@ +MSVC_INLINE_OPTIMIZED=yes +when ($MSVC_INLINE_OPTIMIZED == "yes") { + MSVC_INLINE_FLAG=/Zc:inline +} +when ($MSVC_INLINE_OPTIMIZED == "no") { + MSVC_INLINE_FLAG=/Zc:inline- +} + +# Provide proper __cplusplus value +# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +_CXX_FLAGS=/Zc:__cplusplus + +_MSVC_ONLY_FLAGS= +DEBUG_INFO_FLAGS=/Z7 +when ($IDE_MSVS == "yes") { + when ($CLANG_CL != "yes") { + _MSVC_ONLY_FLAGS=/FD /MP + } + DEBUG_INFO_FLAGS=/Zi /FS +} + +# https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx +when ($DLL_RUNTIME == "yes") { + _FLAGS_DEBUG_RUNTIME=/MDd + _FLAGS_RELEASE_RUNTIME=/MD +} +otherwise { + _FLAGS_DEBUG_RUNTIME=/MTd + _FLAGS_RELEASE_RUNTIME=/MT +} +CFLAGS_DEBUG=/Ob0 /Od /D_DEBUG $_FLAGS_DEBUG_RUNTIME +CFLAGS_RELEASE=/Ox /Ob2 /Oi /DNDEBUG $_FLAGS_RELEASE_RUNTIME + +MASMFLAGS= +_MASM_IO=/nologo /c /Fo${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC} +when ($ARCH_ARMV7) { + _MASM_IO=-o ${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC} +} + +OBJ_CROSS_SUF=$OBJ_SUF +OBJECT_SUF=$OBJ_SUF.obj + +CFLAGS+=$_MSVC_FLAGS $_MSVC_ONLY_FLAGS $CFLAGS_PER_TYPE $DEBUG_INFO_FLAGS $C_WARNING_OPTS $C_DEFINES $USER_CFLAGS $USER_CFLAGS_GLOBAL +CXXFLAGS+=$CFLAGS $_STD_CXX $_CXX_FLAGS $_CXX_DEFINES $CXX_WARNING_OPTS $USER_CXXFLAGS $USER_CXXFLAGS_GLOBAL +CONLYFLAGS+=$USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL + +BC_CFLAGS+=$CFLAGS +BC_CXXFLAGS+=$BC_CFLAGS $CXXFLAGS + +CFLAGS+=$_CFLAGS_UCRT_VC_INCLUDES + +when ($NO_WSHADOW == "yes") { + C_WARNING_OPTS+=/wd4456 /wd4457 +} + +when ($NO_COMPILER_WARNINGS == "yes") { + C_WARNING_OPTS=/w + when ($CLANG_CL == "yes") { + # Though /w is intended to switch off all the warnings, + # it does not switch at least -Wregister and -Wreserved-user-defined-literal under clang-cl. + # + # Use -Wno-everything to force warning suppression. + CXX_WARNING_OPTS=-Wno-everything + } + otherwise { + CXX_WARNING_OPTS= + } +} + +when ($NO_OPTIMIZE == "yes") { + OPTIMIZE=/Od +} + +SFDL_FLAG=/E /C /P /TP /Fi$SFDL_TMP_OUT +WERROR_FLAG=/WX + +CL_WRAPPER=${FIX_MSVC_OUTPUT} cl +ML_WRAPPER=${FIX_MSVC_OUTPUT} ml +when ($_UNDER_WINE == "yes" && $CLANG_CL !="yes") { + CL_WRAPPER= + ML_WRAPPER= +} + +_FORCE_CPP_FLAGS=/TP + +_SRC_C_NODEPS_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${C_COMPILER} /c /Fo${OUTFILE} ${SRC} ${EXTRA_C_FLAGS} ${pre=/I :INC} ${CFLAGS} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"} +_SRC_CPP_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${CXX_COMPILER} /c /Fo$_COMPILE_OUTPUTS ${input;msvs_source:SRC} ${EXTRA_C_FLAGS} ${pre=/I :_C__INCLUDE} ${CXXFLAGS} ${SRCFLAGS} ${_LANG_CFLAGS_VALUE} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"} +_SRC_C_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${C_COMPILER} /c /Fo$_COMPILE_OUTPUTS ${input;msvs_source:SRC} ${EXTRA_C_FLAGS} ${pre=/I :_C__INCLUDE} ${CFLAGS} ${CONLYFLAGS} ${SRCFLAGS} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"} +_SRC_M_CMD=$_EMPTY_CMD +_SRC_MASM_CMD=${cwd:ARCADIA_BUILD_ROOT} ${TOOLCHAIN_ENV} ${ML_WRAPPER} ${MASM_COMPILER} ${MASMFLAGS} ${SRCFLAGS} $_MASM_IO ${kv;hide:"p AS"} ${kv;hide:"pc yellow"} diff --git a/build/conf/compilers/nvcc.conf b/build/conf/compilers/nvcc.conf new file mode 100644 index 00000000000..12ea72eaa92 --- /dev/null +++ b/build/conf/compilers/nvcc.conf @@ -0,0 +1,3 @@ +when ($NO_COMPILER_WARNINGS == "yes") { + CUDA_NVCC_FLAGS += -w +} diff --git a/build/conf/coverage_full_instrumentation.conf b/build/conf/coverage_full_instrumentation.conf new file mode 100644 index 00000000000..b87313e7d67 --- /dev/null +++ b/build/conf/coverage_full_instrumentation.conf @@ -0,0 +1,8 @@ +USE_SCU_VALUE="yes" + +macro POPULATE_CPP_COVERAGE_FLAGS() { + when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") { + CFLAGS+=-fprofile-instr-generate -fcoverage-mapping -DCLANG_COVERAGE + LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping + } +} diff --git a/build/conf/coverage_selective_instrumentation.conf b/build/conf/coverage_selective_instrumentation.conf new file mode 100644 index 00000000000..7039e194cea --- /dev/null +++ b/build/conf/coverage_selective_instrumentation.conf @@ -0,0 +1,5 @@ +USE_SCU_VALUE="no" + +macro POPULATE_CPP_COVERAGE_FLAGS() { + SET_CPP_COVERAGE_FLAGS() +} diff --git a/build/conf/docs.conf b/build/conf/docs.conf new file mode 100644 index 00000000000..8fe8ed34869 --- /dev/null +++ b/build/conf/docs.conf @@ -0,0 +1,402 @@ +# +# Documentation build support +# + +# tag:docs +TOUCH_DOCS=$YMAKE_PYTHON3 ${input:"build/scripts/touch.py"} ${kv;hide:"p DC"} ${kv;hide:"pc light-cyan"} $TARGET +TOUCH_DOCS_MF=$TOUCH_DOCS && $GENERATE_MF + +# tag:docs +### @usage: DOCS_COPY_FILES(FROM src_dir [NAMESPCE dst_dir] files...) +### +### Copy files from src_dir to $BINDIR/dst_dir +macro DOCS_COPY_FILES(FROM="${CURDIR}", NAMESPACE=".", FILES...) { + .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/copy_docs_files.py"} ${input;hide:"build/scripts/process_command_files.py"} --source-root $ARCADIA_ROOT --build-root $ARCADIA_BUILD_ROOT --src-dir $FROM --dst-dir $BINDIR/$NAMESPACE $FILES ${input;hide;context=TEXT;pre=${FROM}/:FILES} ${output;hide;pre=${NAMESPACE}/:FILES} +} + +# tag:docs +_DOCS_USE_PLANTUML=no +_DOCS_EXTRA_TOOLS= +_DOCS_EXTRA_INPUTS= +_DOCS_ENV= +_DOCS_KV=${kv;hide:"p DO"} ${kv;hide:"pc light-cyan"} ${kv;hide:"show_out yes"} + +_DOCS_PLANTUML_ENV=\ +${env:"JAVA_PATH=$JDK19_RESOURCE_GLOBAL/bin/java"} \ +${env:"PLANTUML_PATH=contrib/tools/plantuml/plantuml.run.cp.jar"} \ +${env:"_JAVA_OPTIONS='-Dsun.awt.fontconfig=contrib/java/openjdk-fontconfig/fontconfig.properties -Djava.awt.headless=true'"} \ +${env:"LANG=en_US.UTF-8"} \ +${env:"LC_ALL=C.UTF-8"} + +_DOCS_SRCS_VALUE= +_DOCS_VARS_FLAG= + +_DOCS_YFM_OUTPUT_FORMAT= +_DOCS_YFM_BOOK_OUTPUT_FORMAT=--output-format html --allowHTML +_DOCS_YFM_LIB_OUTPUT_FORMAT=--output-format md --add-map-file --allow-custom-resources + +_DOCS_YFM_CMDLINE=\ +${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/extract_docs.py"} ${input;hide:"build/scripts/process_command_files.py"} --skip-prefix $ARCADIA_BUILD_ROOT --dest-dir $BINDIR/__s ${rootrel:PEERS} \ +&& ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/stdout2stderr.py"} $YFM_TOOL_RESOURCE_GLOBAL/yfm-docs --input $BINDIR/__s --output $BINDIR/__docsbuild $_DOCS_VARS_FLAG $_DOCS_YFM_OUTPUT_FORMAT --config ${input:CONFIG} $_DOCS_EXTRA_TOOLS ${hide;input:EXTRA_INPUTS} $_DOCS_ENV \ +&& $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --output $TARGET --input $BINDIR/__docsbuild $_DOCS_KV + +# tag:internal tag:docs +macro _DOCS_YFM_CMD_IMPL(CONFIG, EXTRA_INPUTS[]) { + .CMD=$_DOCS_YFM_CMDLINE +} + +_DOCS_YFM_CMD=$_DOCS_YFM_CMD_IMPL($_DOCS_CONFIG_VALUE EXTRA_INPUTS $_DOCS_EXTRA_INPUTS) + +# tag:docs +### This module is intended for internal use only. Common parts for DOCS and MKDOCS multimodules +### should be defined here. +module _DOCS_BARE_UNIT: _BARE_UNIT { + .ALLOWED=DOCS_DIR DOCS_CONFIG DOCS_VARS + .CMD=TOUCH_DOCS_MF + .FINAL_TARGET=no + .NODE_TYPE=Bundle + .PEERDIR_POLICY=as_include + + ENABLE(_DOCS_BARE_UNIT) + + SET(MODULE_SUFFIX .tar.gz) + SET(MODULE_LANG DOCS) +} + +# tag:docs tag:internal +_DOCS_DIR_INTERNAL_NAMESPACE= + +# tag:internal tag:docs +_DOCS_LIBRARY_CMDLINE=\ +$YMAKE_PYTHON3 ${input:"build/scripts/copy_docs_files_to_dir.py"} ${input;hide:"build/scripts/process_command_files.py"} $_DOCS_SRCS_VALUE $_DOCS_DIR_VALUE $_DOCS_BIN_DIR_VALUE --dest-dir $BINDIR/__s --source-root $ARCADIA_ROOT --build-root $ARCADIA_BUILD_ROOT ${input;context=TEXT:INCLUDE_SRCS} \ +&& $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --output $TARGET --input $BINDIR/__s $_DOCS_KV + +# tag:internal tag:docs +macro _DOCS_LIBRARY_CMD_IMPL(INCLUDE_SRCS[], EXTRA_INPUTS[]) { + .CMD=$_DOCS_LIBRARY_CMDLINE +} + +_DOCS_LIBRARY_CMD=$_DOCS_LIBRARY_CMD_IMPL(INCLUDE_SRCS $_DOCS_INCLUDE_SOURCES_VALUE) + +# tag:docs +module DOCS_LIBRARY: _DOCS_BARE_UNIT { + .CMD=_DOCS_LIBRARY_CMD + .ALIASES=SRCS=_DOCS_SRCS DOCS_DIR=_YFM_DOCS_DIR + .EPILOGUE=_DOCS_LIBRARY_EPILOGUE + .NODE_TYPE=Library + + ENABLE(DOCS_LIBRARY) + + SET(MODULE_TYPE LIBRARY) + SET(MODULE_TAG DOCS_LIBRARY) + SET(PEERDIR_TAGS DOCS_LIBRARY) + + SET(MODULE_SUFFIX .docslib) +} + +# tag:docs +macro _DOCS_SRCS(SRCDIR=".", EXCLUDE[], INCLUDE...) { + SET(_VAR_DOCS_SRCS_SALT __SRCDIR__ $SRCDIR __EXCLUDE__ $EXCLUDE __INCLUDE__ $INCLUDE) + SET(_DOCS_SRCS_GLOB uniq_docs_${hash:_VAR_DOCS_SRCS_SALT}) + _GLOB(${_DOCS_SRCS_GLOB} ${pre=${SRCDIR}/:INCLUDE} EXCLUDE ${EXCLUDE}) + SET_APPEND(_DOCS_INCLUDE_SOURCES_VALUE ${input:$_DOCS_SRCS_GLOB}) + SET(_YFM_DOCS_DIR_DEFAULT_VALUE __dummy_dir__) +} + +# tag:docs +macro _DOCS_LIBRARY_EPILOGUE() { + _YFM_DOCS_DIR($_YFM_DOCS_DIR_DEFAULT_VALUE) + _SET_DOCS_BIN_DIR_FLAG($_DOCS_DIR_INTERNAL_NAMESPACE $MODDIR) +} + +# tag:docs +### This module is intended for internal use only. Common parts for submodules of DOCS multimodule +### should be defined here. +module _DOCS_BASE_UNIT: _DOCS_BARE_UNIT { + .ALIASES=DOCS_DIR=_YFM_DOCS_DIR + .NODE_TYPE=Library + + ENABLE(_DOCS_BASE_UNIT) + + PEERDIR+=build/platform/yfm + DOCS_CONFIG($_DOCS_YFM_DEFAULT_CONFIG) +} + +# tag:internal tag:docs +### _DOCS_YFM_USE_PLANTUML() # internal +### +### This macr sets appropriate dependencies for use of plantuml plugin +macro _DOCS_YFM_USE_PLANTUML() { + when ($DOCSLIB == "yes") { + PEERDIR+=build/platform/java/jdk/jdk19 contrib/java/openjdk-fontconfig + + _DOCS_ENV+=$_DOCS_PLANTUML_ENV + _DOCS_EXTRA_TOOLS+=${hide;tool:"contrib/tools/plantuml"} + } +} + +# tag:docs +### @usage: DOCS() +### +### Documentation project multimodule. +### +### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site. +### When PEERDIRed from other DOCS() module behaves like a UNION (supplying own content and dependencies to build target). +### Peerdirs from modules other than DOCS are not accepted. +### Most usual macros are not accepted, only used with the macros DOCS_DIR(), DOCS_CONFIG(), DOCS_VARS(). +### +### @see: [DOCS_DIR()](#macro_DOCS_DIR), [DOCS_CONFIG()](#macro_DOCS_CONFIG), [DOCS_VARS()](#macro_DOCS_VARS). +multimodule DOCS { + module DOCSBOOK: _DOCS_BASE_UNIT { + .CMD=_DOCS_YFM_CMD + .FINAL_TARGET=yes + .PEERDIR_POLICY=as_build_from + .IGNORED=DOCS_DIR DOCS_INCLUDE_SOURCES DOCS_COPY_FILES PEERDIR PYTHON RUN_PROGRAM RUN_PYTHON3 RUN_LUA RUN_JAVA_PROGRAM FROM_SANDBOX SRCS + .PEERDIRSELF=DOCSLIB + + ENABLE(DOCSBOOK) + + SET(MODULE_TAG DOCSBOOK) + SET(PEERDIR_TAGS DOCSLIB) + + _DOCS_YFM_OUTPUT_FORMAT=$_DOCS_YFM_BOOK_OUTPUT_FORMAT + + PROCESS_DOCS() + } + + module DOCSLIB: _DOCS_BASE_UNIT { + .CMD=_DOCS_YFM_CMD + .PEERDIR_POLICY=as_build_from + .IGNORED=DOCS_DIR DOCS_INCLUDE_SOURCES DOCS_COPY_FILES PEERDIR PYTHON RUN_PROGRAM RUN_PYTHON3 RUN_LUA RUN_JAVA_PROGRAM FROM_SANDBOX SRCS + .PEERDIRSELF=DOCSLIB_INTERNAL + .PROXY=yes + + ENABLE(DOCSLIB) + + SET(MODULE_TAG DOCSLIB) + SET(PEERDIR_TAGS DOCSLIB_INTERNAL) + + REALPRJNAME=preprocessed + + _DOCS_YFM_OUTPUT_FORMAT=$_DOCS_YFM_LIB_OUTPUT_FORMAT + + PROCESS_DOCS() + } + + module DOCSLIB_INTERNAL: DOCS_LIBRARY { + .IGNORED=DOCS_CONFIG + .EPILOGUE=_DOCS_LIBRARY_EPILOGUE + + ENABLE(DOCSLIB_INTERNAL) + DISABLE(START_TARGET) + + SET(MODULE_TAG DOCSLIB_INTERNAL) + SET(PEERDIR_TAGS DOCSLIB_EXTERNAL DOCS_LIBRARY) + # additional .fake extension make this output suppressed by ya-bin + SET(MODULE_SUFFIX .docslib.fake) + + SET(_DOCS_DIR_INTERNAL_NAMESPACE .) + + REALPRJNAME=__docs_internal + } + + module DOCSLIB_EXTERNAL: DOCS_LIBRARY { + .IGNORED=DOCS_CONFIG + .EPILOGUE=_DOCS_LIBRARY_EPILOGUE + + ENABLE(DOCSLIB_EXTERNAL) + DISABLE(START_TARGET) + + SET(MODULE_TAG DOCSLIB_EXTERNAL) + SET(PEERDIR_TAGS DOCSLIB_EXTERNAL DOCS_LIBRARY) + + REALPRJNAME=__docs_external + } +} + +_DOCS_FS_TOOLS=$YMAKE_PYTHON3 ${input:"build/scripts/fs_tools.py"} ${input;hide:"build/scripts/process_command_files.py"} + +_DOCS_MKDOCS_CMDLINE_SUFFIX= +_DOCS_MKDOCS_BOOK_CMDLINE_SUFFIX=${pre=--dep ;ext=preprocessed.tar.gz:PEERS} +_DOCS_MKDOCS_LIB_CMDLINE_SUFFIX=--preprocess-md-only + +_DOCS_MKDOCS_CMDLINE=\ +${cwd:ARCADIA_ROOT} $_DOCS_FS_TOOLS copy_all_files $_MKDOCS_DOCS_DIR_VALUE $BINDIR/__s $_DOCS_SRCS_VALUE \ +&& $YMAKE_PYTHON3 ${input:"build/scripts/copy_files_to_dir.py"} ${input;hide:"build/scripts/process_command_files.py"} --dest-dir $BINDIR/__s --skip-prefix $ARCADIA_ROOT --skip-prefix $ARCADIA_BUILD_ROOT ${input;context=TEXT:INCLUDE_SRCS} \ +&& ${cwd:BINDIR} $YMAKE_PYTHON3 ${input:"build/scripts/mkdocs_builder_wrapper.py"} $ARCADIA_BUILD_ROOT ${tool:"tools/mkdocs_builder"} --docs-dir $BINDIR/__s --output-tar $TARGET --config ${input:CONFIG} $_DOCS_VARS_FLAG $_DOCS_MKDOCS_CMDLINE_SUFFIX $_DOCS_EXTRA_TOOLS ${hide;input:EXTRA_INPUTS} $_DOCS_ENV $_DOCS_KV + +# tag:internal tag:docs +macro _DOCS_MKDOCS_CMD_IMPL(CONFIG, INCLUDE_SRCS[], EXTRA_INPUTS[]) { + .CMD=$_DOCS_MKDOCS_CMDLINE +} + +_DOCS_MKDOCS_CMD=$_DOCS_MKDOCS_CMD_IMPL($_DOCS_CONFIG_VALUE INCLUDE_SRCS $_DOCS_INCLUDE_SOURCES_VALUE) + +_DOCS_YFM_DEFAULT_CONFIG=$MODDIR/.yfm +_DOCS_MKDOCS_DEFAULT_CONFIG=$MODDIR/mkdocs.yml + +# tag:docs +### This module is intended for internal use only. Common parts for submodules of MKDOCS multimodule +### should be defined here. +module _MKDOCS_BASE_UNIT: _DOCS_BARE_UNIT { + .ALIASES=DOCS_DIR=_MKDOCS_DOCS_DIR + + ENABLE(_MKDOCS_BASE_UNIT) + + DOCS_CONFIG($_DOCS_MKDOCS_DEFAULT_CONFIG) +} + +# tag:internal tag:docs +### _MKDOCS_EPILOOGUE() # internal +### +### This macro executes macros which should be envoked after all user +### specified macros in the ya.make file +macro _MKDOCS_EPILOGUE() { + _LATE_GLOB(_DOCS_SRCS_GLOB ${pre=${ARCADIA_ROOT}/;suf=/**/*:_MKDOCS_DOCS_DIR_VALUE}) + SET(_DOCS_SRCS_VALUE \${input;hide:_DOCS_SRCS_GLOB}) +} + +# tag:docs +### @usage: MKDOCS() +### +### Documentation project multimodule. +### +### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site (using mkdocs as builder). +### When PEERDIRed from other MKDOCS() module behaves like a UNION (supplying own content and dependencies to build target). +### Peerdirs from modules other than MKDOCS are not accepted. +### Most usual macros are not accepted, only used with the macros DOCS_DIR(), DOCS_CONFIG(), DOCS_VARS(). +### +### @see: [DOCS_DIR()](#macro_DOCS_DIR), [DOCS_CONFIG()](#macro_DOCS_CONFIG), [DOCS_VARS()](#macro_DOCS_VARS). +multimodule MKDOCS { + module MKDOCSBOOK: _MKDOCS_BASE_UNIT { + .CMD=_DOCS_MKDOCS_CMD + .EPILOGUE=_MKDOCS_EPILOGUE + .FINAL_TARGET=yes + .PEERDIR_POLICY=as_build_from + + ENABLE(MKDOCSBOOK) + + SET(MODULE_TYPE PROGRAM) + SET(PEERDIR_TAGS MKDOCSLIB) + SET(MODULE_TAG MKDOCSBOOK) + + _DOCS_MKDOCS_CMDLINE_SUFFIX=$_DOCS_MKDOCS_BOOK_CMDLINE_SUFFIX + + PROCESS_MKDOCS() + } + + module MKDOCSLIB: _MKDOCS_BASE_UNIT { + .CMD=_DOCS_MKDOCS_CMD + .EPILOGUE=_MKDOCS_EPILOGUE + .PEERDIR_POLICY=as_include + + ENABLE(MKDOCSLIB) + + SET(MODULE_TYPE LIBRARY) + SET(PEERDIR_TAGS MKDOCSLIB) + SET(MODULE_TAG MKDOCSLIB) + + REALPRJNAME=preprocessed + + _DOCS_MKDOCS_CMDLINE_SUFFIX=$_DOCS_MKDOCS_LIB_CMDLINE_SUFFIX + + PROCESS_MKDOCS() + } +} + +# tag:docs +_DOCS_USE_PLANTUML= +### @usage: USE_PLANTUML() +### +### Use PlantUML plug-in for yfm builder to render UML diagrams into documentation +macro USE_PLANTUML() { + ENABLE(_DOCS_USE_PLANTUML) +} + +# tag:docs +_DOCS_DIR_VALUE= +_DOCS_BIN_DIR_VALUE= +### @usage: DOCS_DIR(path) +### +### Specify directory with source .md files for DOCS multimodule if it differs from project directory. +### Path must be Arcadia root relative. +### +### @see: [DOCS](#multimodule_DOCS) +macro DOCS_DIR(Dir) { + ENABLE(UNUSED_MACRO) +} + +# tag:docs tag:internal +macro _APPEND_DOCS_DIR_FLAG(DIR, NAMESPACE, DYMMY...) { + SET_APPEND(_DOCS_DIR_VALUE --docs-dir $DIR $NAMESPACE) +} + +# tag:docs tag:internal +macro _SET_DOCS_BIN_DIR_FLAG(NAMESPACE, DUMMY...) { + SET(_DOCS_BIN_DIR_VALUE --bin-dir $BINDIR $NAMESPACE $AUTO_INPUT) +} + +# tag:docs tag:internal +_YFM_DOCS_DIR_DEFAULT_VALUE=$MODDIR +_YFM_DEFAULT_NAMESPACE= +### @usage: DOCS_DIR(path) # internal +macro _YFM_DOCS_DIR(DIR) { + _APPEND_DOCS_DIR_FLAG($DIR $_DOCS_DIR_INTERNAL_NAMESPACE $DIR) + + SET(_VAR_DOCS_DIR_SALT __MODDIR__ $MODDIR __DIR__ $DIR) + SET(_DOCS_DIR_GLOB uniq_docs_dir_${hash:_VAR_DOCS_DIR_SALT}) + _LATE_GLOB(${_DOCS_DIR_GLOB} ${ARCADIA_ROOT}/$DIR/**/*) + SET_APPEND(_DOCS_SRCS_VALUE \${input;hide:$_DOCS_DIR_GLOB}) + + # We set the value of var _YFM_DOCS_DIR_DEFAULT_VALUE to some non-existing dir. This value + # will be used in _DOCS_LIBRARY_EPILOGUE calls. In case when this macro _YFM_DOCS_DIR is + # explicitly called in DOCS_LIBRARY module $MODDIR as default DOCS_DIR for DOCS_LIBRARY will + # be ignore. + SET(_YFM_DOCS_DIR_DEFAULT_VALUE __dummy_dir__) +} + +# tag:docs tag:internal +_MKDOCS_DOCS_DIR_VALUE=$MODDIR +### @usage: DOCS_DIR(path) # internal +macro _MKDOCS_DOCS_DIR(Dir) { + SET(_MKDOCS_DOCS_DIR_VALUE $Dir) +} + +# tag:docs +_DOCS_DEFAULT_CONFIG= +_DOCS_CONFIG_VALUE=$_DOCS_DEFAULT_CONFIG +### @usage: DOCS_CONFIG(path) +### +### Specify path to config file for DOCS multimodule if it differs from default path. +### If used for [MKDOCS](#multimodule_MKDOCS) multimodule the default path is "%%project_directory%%/mkdocs.yml". +### If used for [DOCS](#multimodule_DOCS) multimodule the default path is "%%project_directory%%/.yfm". +### Path must be either Arcadia root relative. +### +### @see: [DOCS](#multimodule_DOCS) +macro DOCS_CONFIG(File) { + SET(_DOCS_CONFIG_VALUE $File) +} + +# tag:docs +_DOCS_VARS_VALUE= +### @usage: DOCS_VARS(variable1=value1 variable2=value2 ...) +### +### Specify a set of default values of template variables for DOCS multimodule. +### There must be no spaces around "=". Values will be treated as strings. +### +### @see: [DOCS](#multimodule_DOCS) +macro DOCS_VARS(Args...) { + SET_APPEND(_DOCS_VARS_VALUE $Args) +} + +# tag:docs +_DOCS_INCLUDE_SOURCES_VALUE= +### @usage: DOCS_INCLUDE_SOURCES(path...) +### +### Specify a list of paths to source code files which will be used as text includes in a documentation project. +### Paths must be Arcadia root relative. +### +### @see: [DOCS](#multimodule_DOCS) +macro DOCS_INCLUDE_SOURCES(Args...) { + SET_APPEND(_DOCS_INCLUDE_SOURCES_VALUE $Args) +} diff --git a/build/conf/export_gradle.no.conf b/build/conf/export_gradle.no.conf new file mode 100644 index 00000000000..31eb5159b28 --- /dev/null +++ b/build/conf/export_gradle.no.conf @@ -0,0 +1,3 @@ +macro _WHEN_EXPORT_GRADLE() { + ENABLE(UNUSED) +} diff --git a/build/conf/export_gradle.yes.conf b/build/conf/export_gradle.yes.conf new file mode 100644 index 00000000000..e1c085526aa --- /dev/null +++ b/build/conf/export_gradle.yes.conf @@ -0,0 +1,3 @@ +macro _WHEN_EXPORT_GRADLE() { + _SETUP_PROJECT_COORDS_IF_NEEDED($MODDIR) +} diff --git a/build/conf/java.conf b/build/conf/java.conf new file mode 100644 index 00000000000..78ce874c7c0 --- /dev/null +++ b/build/conf/java.conf @@ -0,0 +1,241 @@ +macro _INPUT_WITH_FLAG(Flag, IN[]) { + .CMD=$_INPUT_WITH_FLAG_IMPL(${pre=$Flag :IN} IN $IN) +} + +macro _INPUT_WITH_FLAG_IMPL(IN{input}[], Args...) { + .CMD=$Args ${input;hide:IN} +} + +macro ACCELEO(XSD{input}[], MTL{input}[], MTL_ROOT="${MODDIR}", LANG{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], DEBUG?"stdout2stderr":"stderr2stdout") { + .PEERDIR=build/platform/java/jdk $JDK_RESOURCE_PEERDIR + .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input;pre=build/scripts/:DEBUG.py} $JDK_RESOURCE/bin/java -Dfile.encoding=utf8 -classpath ${RUN_JAR_PROG_CP_PRE}${tool:"tools/acceleo"}${RUN_JAR_PROG_CP_SUF} ru.yandex.se.logsng.tool.Cli $_INPUT_WITH_FLAG(--xsd IN $XSD) $_INPUT_WITH_FLAG(--mtl IN $MTL) $_INPUT_WITH_FLAG(--lang IN $LANG) --output-dir $BINDIR --build-root ${ARCADIA_BUILD_ROOT} --source-root ${ARCADIA_ROOT} --mtl-root $MTL_ROOT ${output_include;hide:OUTPUT_INCLUDES} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} +} + +### @usage: JAVA_LIBRARY() +### +### The module describing java library build. +### +### Documentation: https://wiki.yandex-team.ru/yatool/java/ +module JAVA_LIBRARY: JAR_LIBRARY { + .SEM=BUILD_JAR_SEM +} + +PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM=IGNORED + +### @usage: JAVA_PROGRAM() +### +### The module describing java programs build. +### Output artifacts: .jar and directory with all the jar to the classpath of the formation. +### +### Documentation: https://wiki.yandex-team.ru/yatool/java/ +multimodule JAVA_PROGRAM { + module JAR_RUNNABLE: _JAR_RUNNABLE { + .ALLOWED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE + .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM + # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle: + # * A -> B -> C -> lib-v1.4 + # | |-> DM(lib-v1.1) + # | |-> EXCLUDE(lib-v1.4) + # | |-> FORBID_CONFLICT_DM_RECENT = OK + # |-> DM(lib-v1.1) + # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path) + .IGNORED=RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION PROVIDES + .ALIASES=JAVA_RUNTIME_PEERDIR=PEERDIR JAVA_RUNTIME_EXCLUDE=EXCLUDE + .PEERDIRSELF=JAR_COMPILATION + + SET(MODULE_TYPE JAVA_PROGRAM) + } + module JAR_COMPILATION: JAR_LIBRARY { + .IGNORED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE + .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO + .SEM=BUILD_JAR_SEM + .FINAL_TARGET=no + SET(MODULE_TYPE JAVA_PROGRAM) + } +} + +BUILD_JUNIT5_JAR_SEM=$BUILD_JAR_SEM && junit5_test + +multimodule JUNIT5 { + # ATTENTION ya ide idea relies on this submodule name to find scope of `ya make` build before project generation + module JAR_TESTABLE: _JAR_TEST { + .ALLOWED=YT_SPEC + # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle: + # * A -> B -> C -> lib-v1.4 + # | |-> DM(lib-v1.1) + # | |-> EXCLUDE(lib-v1.4) + # | |-> FORBID_CONFLICT_DM_RECENT = OK + # |-> DM(lib-v1.1) + # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path) + .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION + .ALIASES=JAVA_TEST_PEERDIR=PEERDIR JAVA_TEST_EXCLUDE=EXCLUDE + .PEERDIRSELF=JAR_COMPILATION + .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM + + PEERDIR(devtools/jtest-annotations/junit5) + + SET(MODULE_TYPE JUNIT5) + } + module JAR_COMPILATION: JAR_LIBRARY { + .ALLOWED=YT_SPEC + .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO JAVA_TEST_EXCLUDE=_NOOP_MACRO + .FINAL_TARGET=no + .DEFAULT_NAME_GENERATOR=FullPath + .SEM=BUILD_JUNIT5_JAR_SEM + + PEERDIR+=devtools/junit5-runner + PEERDIR+=build/platform/java/jacoco-agent + + when ($OPENSOURCE != "yes") { + PEERDIR+=devtools/jtest-annotations/junit5 + } + SET(MODULE_TYPE JUNIT5) + } +} + +BUILD_JUNIT4_JAR_SEM=$BUILD_JAR_SEM && junit4_test + +multimodule JTEST { + # ATTENTION ya ide idea relies on this submodule name to find scope of `ya make` build before project generation + module JAR_TESTABLE: _JAR_TEST { + .ALLOWED=YT_SPEC + # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle: + # * A -> B -> C -> lib-v1.4 + # | |-> DM(lib-v1.1) + # | |-> EXCLUDE(lib-v1.4) + # | |-> FORBID_CONFLICT_DM_RECENT = OK + # |-> DM(lib-v1.1) + # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path) + .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION + .ALIASES=JAVA_TEST_PEERDIR=PEERDIR JAVA_TEST_EXCLUDE=EXCLUDE + .PEERDIRSELF=JAR_COMPILATION + .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM + + SET(MODULE_TYPE JTEST) + PEERDIR(devtools/junit-runner devtools/jtest-annotations/junit4) + DEPENDENCY_MANAGEMENT(contrib/java/com/google/code/gson/gson/2.8.6 contrib/java/com/beust/jcommander/1.72 contrib/java/junit/junit/4.12) + } + module JAR_COMPILATION: JAR_LIBRARY { + .ALLOWED=YT_SPEC + .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO JAVA_TEST_EXCLUDE=_NOOP_MACRO + .FINAL_TARGET=no + .DEFAULT_NAME_GENERATOR=FullPath + .SEM=BUILD_JUNIT4_JAR_SEM + + SET(MODULE_TYPE JTEST) + DEPENDS(contrib/java/org/sonarsource/scanner/cli/sonar-scanner-cli/2.8) + + PEERDIR+=build/platform/java/jacoco-agent + when ($OPENSOURCE != "yes") { + PEERDIR+=devtools/jtest-annotations/junit4 + } + } +} + +multimodule JTEST_FOR { + # ATTENTION ya ide idea relies on this submodule name to find scope of `ya make` build before project generation + module JAR_TESTABLE: _JAR_TEST { + .ALLOWED=YT_SPEC + # TODO(svidyuk) JAVA_DEPENDENCIES_CONFIGURATION must not be ignored here but there are diagnostics issues in case of ECLUDE in the middle: + # * A -> B -> C -> lib-v1.4 + # | |-> DM(lib-v1.1) + # | |-> EXCLUDE(lib-v1.4) + # | |-> FORBID_CONFLICT_DM_RECENT = OK + # |-> DM(lib-v1.1) + # |-> FORBID_CONFLICT_DM_RECENT = FAIL (because downgrade from v1.4 to v1.1 is detected before understanding that v1.4 was excuded on the examined path) + .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM JAVA_DEPENDENCIES_CONFIGURATION + .ALIASES=JAVA_TEST_PEERDIR=PEERDIR JAVA_TEST_EXCLUDE=EXCLUDE + .PEERDIRSELF=JAR_COMPILATION + .SEM=PROGRAM_AND_TESTS_CP_COLLECTING_NODES_SEM + + SET(MODULE_TYPE JTEST_FOR) + PEERDIR(${UNITTEST_DIR} devtools/junit-runner) + DEPENDENCY_MANAGEMENT(contrib/java/com/google/code/gson/gson/2.8.6 contrib/java/com/beust/jcommander/1.72 contrib/java/junit/junit/4.12) + } + module JAR_COMPILATION: JAR_LIBRARY { + .ALLOWED=YT_SPEC + .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO JAVA_TEST_EXCLUDE=_NOOP_MACRO + .FINAL_TARGET=no + .DEFAULT_NAME_GENERATOR=FullPath + .SEM=BUILD_JUNIT4_JAR_SEM + + SET(MODULE_TYPE JTEST_FOR) + DEPENDS(contrib/java/org/sonarsource/scanner/cli/sonar-scanner-cli/2.8) + PEERDIR(devtools/junit-runner build/platform/java/jacoco-agent ${UNITTEST_DIR}) + } +} + +multimodule JAVA_CONTRIB_PROGRAM { + module JAR_RUNNABLE: _JAR_RUNNABLE { + .IGNORED=JAVA_SRCS RUN_JAR_PROGRAM RUN_JAVA_PROGRAM JAR_RESOURCE SRC_RESOURCE LOCAL_JAR + .PEERDIRSELF=JAR_COMPILATION + + SET(MODULE_TYPE JAVA_PROGRAM) + ENABLE(DISABLE_SCRIPTGEN) + } + module JAR_COMPILATION: JAVA_CONTRIB { + .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO + .FINAL_TARGET=no + .SEM=BUILD_JAR_SEM + } +} + +_EXPLICIT_SWIG_JAVA_SOURCES= +_EXPLICIT_SWIG_IFACE_SOURCES= +macro _EXPORT_JAVA_BINDINGS(JavaSrcs...) { + SET_APPEND(_EXPLICIT_SWIG_JAVA_SOURCES ${input:JavaSrcs}) + .SEM=find_package SWIG COMPONENTS java && find_package Java && find_package JNI && include UseSWIG && include UseJava ${input;hide:JavaSrcs} ${output;hide;pre=$_HASH_HELPER($Args):".o"} +} +macro _EXPORT_SWIG_SOURCES(SwigSrcs...) { + SET_APPEND(_EXPLICIT_SWIG_IFACE_SOURCES ${input:SwigSrcs}) +} + +macro _JNI_CPP_SWIG_SRCS(Srcs...) { + SRCS(${ext=.cpp:Srcs} ${ext=.swg:Srcs}) + _EXPORT_JAVA_BINDINGS(${ext=.java:Srcs}) + _EXPORT_SWIG_SOURCES(${ext=.swg:Srcs}) +} +macro _JNI_JAVA_SWIG_SRCS(Srcs...) { + SRCS(${ext=.java:Srcs} ${ext=.swg:Srcs}) +} + +SWIG_JNI_BINDINGS_SEM= \ + add_swig_jni_library ${MODDIR} ${REALPRJNAME}-cpp GEN_JAVA_FILES_LIST ${"$"}{CMAKE_CURRENT_BINARY_DIR}/swig_gen_java.lst SOURCES ${_EXPLICIT_SWIG_IFACE_SOURCES} && \ + set_target_property OUTPUT_NAME $REALPRJNAME && \ + ${VCS_INFO_SEM} && \ + target_include_directories PUBLIC $_C__INCLUDE_GLOBAL && \ + target_include_directories PRIVATE $_C__INCLUDE_OWNED && \ + target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW && \ + target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE && \ + add_jar ${REALPRJNAME} SOURCES $_EXPLICIT_SWIG_JAVA_SOURCES @${"$"}{CMAKE_CURRENT_BINARY_DIR}/swig_gen_java.lst ${hide:TARGET} + +### @usage: DLL_JAVA() +### +### DLL built using swig for Java. Produces dynamic library and a .jar. +### Dynamic library is treated the same as in the case of PEERDIR from Java to DLL. +### .jar goes on the classpath. +### +### Documentation: https://wiki.yandex-team.ru/yatool/java/#integracijascpp/pythonsborkojj +multimodule DLL_JAVA { + module JNI_DLL: DLL { + .ALIASES=SRCS=_JNI_CPP_SWIG_SRCS + .FINAL_TARGET=no + .SEM=SWIG_JNI_BINDINGS_SEM + SWIG_LANG=jni_cpp + } + module JAR_COMPILATION: EXTERNAL_JAVA_LIBRARY { + .ARGS_PARSER=DLL + .ALIASES=SRCS=_JNI_JAVA_SWIG_SRCS PEERDIR=_NOOP_MACRO + .PEERDIRSELF=JNI_DLL + PEERDIR+=build/platform/java/jdk + PEERDIR+=$JDK_RESOURCE_PEERDIR + SET(DONT_RESOLVE_INCLUDES yes) + .FINAL_TARGET=yes + + SWIG_LANG=jni_java + _SWIG_CMD=$_SWIG_JNI_JAVA_CMD + _SWIG_ADDINCLS=$_SWIG_JNI_ADDINCLS + _SWIG_PEERDIR=$_SWIG_JNI_PEERDIR + _SWIG_SEM_TO_MODULE_LINK=${output;hide;suf=.jsrc:SRC} + } +} diff --git a/build/conf/license.conf b/build/conf/license.conf new file mode 100644 index 00000000000..ca66d38beb5 --- /dev/null +++ b/build/conf/license.conf @@ -0,0 +1,442 @@ +LICENSE_EXPRESSION_IMPLICIT_OR=yes +LICENSE_EXPRESSION_IMPLICIT_AND=yes +LICENSE_EXPRESSION= +LICENSE_NAMES= + +MODULE_LICENSES_RESTRICTIONS= +MODULE_LICENSES_RESTRICTION_EXCEPTIONS= +MODULE_LICENSES_RESTRICTION_TYPES= +DEFAULT_MODULE_LICENSE=YandexUncategorized +EXPLICIT_LICENSE_PREFIXES= + +# List of license properties which can be used to restrict transitive dependencies. There are three variables checked for each +# property: +# * LICENSES_<PROP_NAME>_STATIC: list of licenses which propagates this property when linking with code published by one of +# them statically. +# * LICENSES_<PROP_NAME>_DYNAMIC: list of licenses which propagates this property when linking with code published by one of +# them dyamically. +# * LICENSES_<PROP_NAME>: list of licenses which propagates this property regrdless of type of linking with code published by +# one of them. Putting some license into this list is equivalent to putting it into both +# LICENSES_<PROP_NAME>_STATIC and LICENSES_<PROP_NAME>_DYNAMIC lists. +LICENSE_PROPERTIES= \ + FORBIDDEN NDA REQUIRE_DISCLOSURE PERMISSIVE REQUIRE_CITATION SERVICE PROTESTWARE + + +# NB: Licenses lists below are sorted case-insensitively. Please, keep the list sorted. +LICENSES_UNATTRIBUTED= \ + AFL-2.0 \ + Amazon-SL \ + AML \ + APSL-1.0 \ + Artistic-1.0-Perl \ + Artistic-2.0 \ + ASM-BSD-3-Clause \ + BCL \ + Bison-Exception \ + Bison-exception-2.2 \ + BouncyCastle-MIT \ + BSD-3-Clause-Clear \ + BSD-3-Clause-Open-MPI \ + BSD-4-Clause-Shortened \ + Bsd-New-Tcpdump \ + Bsd-Original-Uc-1986 \ + BSLA \ + Carnegie-Mellon \ + Carnegie-Mellon-Contributors \ + CC-BY-1.0 \ + CC-BY-2.0 \ + CC-BY-2.5 \ + CC-BY-3.0 \ + CC-BY-4.0 \ + CC-BY-NC-1.0 \ + CC-BY-NC-2.0 \ + CC-BY-NC-2.5 \ + CC-BY-NC-3.0 \ + CC-BY-NC-ND-1.0 \ + CC-BY-NC-ND-2.0 \ + CC-BY-NC-ND-2.5 \ + CC-BY-NC-ND-3.0 \ + CC-BY-NC-SA-1.0 \ + CC-BY-NC-SA-2.0 \ + CC-BY-NC-SA-2.5 \ + CC-BY-NC-SA-3.0 \ + CC-BY-ND-1.0 \ + CC-BY-ND-2.0 \ + CC-BY-ND-2.5 \ + CC-BY-ND-3.0 \ + CC-BY-SA-1.0 \ + CC-BY-SA-2.0 \ + CC-BY-SA-2.5 \ + CC-BY-SA-3.0 \ + CC-BY-SA-4.0 \ + CDDL \ + CECILL-B \ + ClArtistic \ + Custom-fft2d \ + DOC \ + DSO-1.1 \ + Elastic-License-2.0 \ + Fftpack-2004 \ + FSFUL \ + FSFULLR \ + GCC-exception-3.1 \ + GDAL \ + GFDL-1.1-or-later \ + Go-License \ + Google-Patent-License-Webm \ + Google-Patent-License-Webrtc \ + GPL-2.0 WITH Classpath-exception-2.0 \ + GPL-2.0 WITH FOSS-exception \ + GPL-2.0-only WITH freertos-exception-2.0 \ + GPL-2.0-only WITH Mysql-Linking-Exception-2018 \ + GPL-2.0-only WITH Universal-FOSS-exception-1.0 \ + GPL-2.0-or-later WITH Avisynth-C-Interface-Exception \ + GPL-2.0-or-later WITH Bison-Exception-2.0 \ + GPL-2.0-or-later WITH Bison-exception-2.2 \ + GPL-2.0-or-later WITH C-Interface-Exception \ + GPL-2.0-or-later WITH freertos-exception-2.0 \ + GPL-2.0-or-later WITH Libtool-exception \ + GPL-2.0-or-later WITH mif-exception \ + GWT-Terms \ + Hdf5 \ + HPND \ + HPND-sell-variant \ + HPND-sell-variant \ + HSQLDB-BSD-3-Clause \ + Ibm-Dhcp \ + Ietf-trust \ + ImageMagick \ + Info-Zip \ + Intel-Material \ + IPL-1.0 \ + JAMon-BSD-3-Clause \ + jQuery-MIT \ + LGPL-2.0-or-later WITH Sdbus-C++-LGPL-exception-1.1 \ + LGPL-3.0-or-later WITH ZeroMQ-Exception \ + LicenseRef-scancode-afpl-9.0 \ + LicenseRef-scancode-amd-historical \ + LicenseRef-scancode-anu-license \ + LicenseRef-scancode-bsd-3-clause-jtag \ + LicenseRef-scancode-bsd-axis-nomod \ + LicenseRef-scancode-bsd-new-nomod \ + LicenseRef-scancode-bsd-no-disclaimer \ + LicenseRef-scancode-bsd-x11 \ + LicenseRef-scancode-bsla-no-advert \ + LicenseRef-scancode-cavium-malloc \ + LicenseRef-scancode-cc-by-2.0-uk \ + LicenseRef-scancode-cc-devnations-2.0 \ + LicenseRef-scancode-cc-sampling-1.0 \ + LicenseRef-scancode-cmu-simple \ + LicenseRef-scancode-commercial-license \ + LicenseRef-scancode-commons-clause \ + LicenseRef-scancode-delorie-historical \ + LicenseRef-scancode-flex-2.5 \ + LicenseRef-scancode-free-unknown \ + LicenseRef-scancode-gary-s-brown \ + LicenseRef-scancode-generic-cla \ + LicenseRef-scancode-generic-exception \ + LicenseRef-scancode-intel-osl-1993 \ + LicenseRef-scancode-mit-xfig \ + LicenseRef-scancode-newlib-historical \ + LicenseRef-scancode-nilsson-historical \ + LicenseRef-scancode-openssl \ + LicenseRef-scancode-openssl-exception-lgpl-3.0-plus \ + LicenseRef-scancode-openssl-nokia-psk-contribution \ + LicenseRef-scancode-osf-1990 \ + LicenseRef-scancode-other-copyleft \ + LicenseRef-scancode-other-permissive \ + LicenseRef-scancode-paul-mackerras \ + LicenseRef-scancode-paul-mackerras-binary \ + LicenseRef-scancode-paul-mackerras-new \ + LicenseRef-scancode-pcre \ + LicenseRef-scancode-ppp \ + LicenseRef-scancode-proprietary-license \ + LicenseRef-scancode-secret-labs-2011 \ + LicenseRef-scancode-ssleay-windows \ + LicenseRef-scancode-sun-source \ + LicenseRef-scancode-swig \ + LicenseRef-scancode-unknown \ + LicenseRef-scancode-unknown-license-reference \ + LicenseRef-scancode-unknown-spdx \ + LicenseRef-scancode-warranty-disclaimer \ + LicenseRef-scancode-xfree86-1.0 \ + LPL-1.02 \ + MirOS \ + Mit-Xfig \ + Mozilla-GC \ + NAIST-2003 \ + Nvidia-Gov \ + OFL-1.1 \ + Oracle \ + Oracle-technology \ + PSF-3.7.2 \ + Qhull \ + Quicklz \ + Ruby \ + Sendmail \ + Softsurfer \ + Spencer-99 \ + SSPL-1.0 \ + Stlport-4.5 \ + SZIP \ + TCL \ + TU-Berlin-1.0 \ + Unicode-TOU \ + Universal-FOSS-exception-1.0 \ + Unknown \ + Vcalendar \ + Vim \ + X11-Adobe-Dec \ + X11-Hanson \ + Xfree86-1.0 \ + Xnet + +LICENSES_PATCHES_FORBIDDEN= \ + Unicode + +LICENSES_FORBIDDEN= \ + AGPL-3.0-only \ + AGPL-3.0-or-later \ + Artistic-1.0 \ + Musl-Exception \ + confluent-community-1.0 \ + ${LICENSES_UNATTRIBUTED} + +# Group for proprietary code licenses +LICENSES_NDA= \ + Intel-NDA \ + mimepp \ + OracleOebs \ + Sophos-SDK \ + YandexUncategorized \ + YandexNDA + +# These licenses allow use with opensource code only +LICENSES_REQUIRE_DISCLOSURE= \ + CDDL-1.0 \ + CDDL-1.1 \ + CECILL-2.0 \ + CPL-1.0 \ + EPL-1.0 \ + EPL-2.0 \ + GPL \ + GPL-1.0-only \ + GPL-1.0-or-later \ + GPL-1.0-or-later WITH Linux-syscall-note \ + GPL-1.1 \ + GPL-2.0 \ + GPL-2.0-only \ + GPL-2.0-only WITH GCC-exception-2.0 \ + GPL-2.0-only WITH Linux-syscall-note \ + GPL-2.0-or-later \ + GPL-2.0-or-later WITH GCC-exception-2.0 \ + GPL-2.0-or-later WITH Linux-syscall-note \ + GPL-3.0-only \ + GPL-3.0-only WITH Bison-exception-2.2 \ + GPL-3.0-or-later \ + GPL-3.0-or-later WITH Bison-exception-2.2 \ + GPLv2+ + +LICENSES_REQUIRE_DISCLOSURE_STATIC= \ + LGPL \ + LGPL-1.0-or-later \ + LGPL-2.0-only \ + LGPL-2.0-or-later \ + LGPL-2.0-or-later WITH Libtool-exception \ + LGPL-2.0-or-later WITH Linux-syscall-note \ + LGPL-2.1-only \ + LGPL-2.1-only WITH Linux-syscall-note \ + LGPL-2.1-or-later \ + LGPL-2.1-or-later WITH Linux-syscall-note \ + LGPL-3.0-only \ + LGPL-3.0-or-later + +# These licenses allows any kind of linkage with proprietary code +LICENSES_PERMISSIVE= \ + 0BSD \ + Apache-1.0 \ + Apache-1.1 \ + Apache-2.0 \ + Apache-2.0 WITH LLVM-exception \ + APSL-2.0 \ + Beerware \ + blessing \ + BSD \ + BSD-1-Clause \ + BSD-2-Clause \ + BSD-2-Clause-Patent \ + BSD-2-Clause-Views \ + BSD-3-Clause \ + BSD-4-Clause \ + BSD-4-Clause-UC \ + BSD-derived \ + BSD-ORIGINAL-UC-1986 \ + Bsd-Simplified-Darwin \ + BSD-Source-Code \ + Bsd-Unchanged \ + Bsd-Unmodified \ + BSL-1.0 \ + bzip2-1.0.6 \ + CC-PDDC \ + CC0-1.0 \ + Cmu-Computing-Services \ + CUP-Parser \ + curl \ + Custom-punycode \ + Custom-wcwidth \ + EDL-1.0 \ + Facebook-SDK \ + FDK \ + FSFAP \ + FTL \ + H2 \ + IBM-pibs \ + ICU \ + Ietf \ + IJG \ + Intel-LLVM-SGA \ + Intel-Simplified \ + ISC \ + JSON \ + Khronos \ + Libpbm \ + Libpng \ + libpng-2.0 \ + libtiff \ + LicenseRef-scancode-ams-fonts \ + LicenseRef-scancode-bitstream \ + Linux-OpenIB \ + Martin-Birgmeier \ + Minpack \ + MIT \ + MIT-0 \ + MIT-CMU \ + MIT-Modern-Variant \ + MIT-Nagy \ + Mit-Old-Style \ + MIT-open-group \ + Mit-Veillard-Variant \ + MPL-1.0 \ + MPL-1.1 \ + MPL-2.0 \ + NCSA \ + Not-Applicable \ + NTP \ + Nvidia \ + OGC-1.0 \ + OLDAP-2.8 \ + OML \ + OpenSSL \ + PayPal-SDK \ + PCRE \ + PD \ + PHP-3.01 \ + PIL \ + Plexus \ + PostgreSQL \ + Protobuf-License \ + PSF \ + PSF-2.0 \ + Public-Domain \ + Public-Domain-US-Govt \ + Python-2.0 \ + Qhull \ + Red-Hat-Attribution \ + Repoze-public \ + RSA-1990 \ + RSA-MD \ + RSA-MD4 \ + SGI-B-2.0 \ + Sleepycat \ + SMLNJ \ + Snprintf \ + SSH-short \ + SSLeay \ + Sunpro \ + Unicode-DFS-2016 \ + Unicode-Icu-58 \ + Unicode-Mappings \ + Unlicense \ + Unrar \ + UPL-1.0 \ + Vertica \ + W3C \ + WTFPL \ + X11 \ + X11-Lucent \ + X11-XConsortium-Veillard \ + YandexOpen \ + Zlib \ + zlib-acknowledgement \ + ZPL-2.1 \ + ${CUSTOM_LICENSE_LINUX_SYSCALL_NOTE} \ + ${CUSTOM_LICENSE_MUSL_EXCEPTION} \ + ${LICENSES_PATCHES_FORBIDDEN} + +LICENSES_PERMISSIVE_DYNAMIC= \ + LGPL \ + LGPL-2.0-only \ + LGPL-2.0-or-later \ + LGPL-2.1-only \ + LGPL-2.1-or-later \ + LGPL-3.0-only \ + LGPL-3.0-or-later + +# https://st.yandex-team.ru/ARCADIAWGSUP-34 +CUSTOM_LICENSE_LIBSSH2_AGENT_WIN=Libssh2-Agent-Win +# Permissive if the code is used to declare and invoke syscalls +CUSTOM_LICENSE_LINUX_SYSCALL_NOTE=Linux-syscall-note-in-syscall-glue +# Permissive only in musllib +CUSTOM_LICENSE_MUSL_EXCEPTION=Musl-Exception-in-Musllib + +# TODO: this list is almost empty. needed for DEVRULES-151 +LICENSES_REQUIRE_CITATION= \ + Apache-2.0 \ + Brian-Gladman-3-Clause \ + Cmu-Computing-Services \ + Custom-Oasis-Pkcs11 \ + EDL-1.0 \ + OpenSSL \ + Spencer-94 \ + NetCDF \ + ${CUSTOM_LICENSE_LIBSSH2_AGENT_WIN} + +LICENSES_SERVICE= \ + Service-Dll-Harness \ + Service-Prebuilt-Tool \ + Service-Py23-Proxy + +LICENSES_PROTESTWARE= \ + Protestware + +macro _REQUIRE_EXPLICIT_LICENSE(Prefix...) { + SET(EXPLICIT_LICENSE_PREFIXES ${Prefix}) +} + +### @usage: LICENSE(licenses...) +### +### Specify the licenses of the module, separated by spaces. Specifying multiple licenses interpreted as permission to use this +### library satisfying all conditions of any of the listed licenses. +### +### A license must be prescribed for contribs +macro LICENSE(Flags...) { + SET(LICENSE_EXPRESSION $Flags) + SET(LICENSE_NAMES $Flags) +} + +### @usage RESTRICT_LICENSES(ALLOW_ONLY|DENY LicenseProperty...) +### +### Restrict licenses of direct and indirect module dependencies. +### +### ALLOW_ONLY restriction type requires dependent module to have at leas one license without propertis not listed in restrictions +### list. +### +### DENY restriction type forbids dependency on module with no license without any listed propery from the list. +### +### Note: Can be used multiple times on the same module all specified constraints will be checked. +### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY) +macro RESTRICT_LICENSES(TYPE, EXCEPT[], RESTRICTIONS...) { + SET_APPEND(MODULE_LICENSES_RESTRICTION_TYPES $TYPE) + SET_APPEND(MODULE_LICENSES_RESTRICTIONS $RESTRICTIONS) + SET_APPEND(MODULE_LICENSES_RESTRICTION_EXCEPTIONS $EXCEPT) +} diff --git a/build/conf/linkers/ld.conf b/build/conf/linkers/ld.conf new file mode 100644 index 00000000000..b1758c02f33 --- /dev/null +++ b/build/conf/linkers/ld.conf @@ -0,0 +1,351 @@ +LDFLAGS+=$USER_LDFLAGS $_LD_FLAGS +LDFLAGS_GLOBAL+= + +_START_GROUP= +_END_GROUP= +START_WHOLE_ARCHIVE_VALUE= +END_WHOLE_ARCHIVE_VALUE= +LD_STRIP_FLAG= +_SONAME_OPTION= +_LD_SRCS_GLOBALS=--start-wa ${rootrel;ext=.a:SRCS_GLOBAL} --end-wa ${rootrel;ext=.o:SRCS_GLOBAL} ${rootrel;ext=.supp:SRCS_GLOBAL} +when ($OS_LINUX == "yes" || $OS_ANDROID == "yes" || $OS_CYGWIN == "yes" || $OS_NONE == "yes") { + _START_GROUP=-Wl,--start-group + _END_GROUP=-Wl,--end-group + START_WHOLE_ARCHIVE_VALUE=-Wl,--whole-archive + END_WHOLE_ARCHIVE_VALUE=-Wl,--no-whole-archive + LD_STRIP_FLAG=-s + _SONAME_OPTION=-soname + _LD_SRCS_GLOBALS=-Wl,--whole-archive ${rootrel;ext=.a:SRCS_GLOBAL} -Wl,--no-whole-archive ${rootrel;ext=.o:SRCS_GLOBAL} ${rootrel;ext=.supp:SRCS_GLOBAL} +} + +when ($_LD_WHOLE_ARCHIVE == "yes") { +} + +when ($OS_DARWIN == "yes" || $OS_IOS == "yes") { + _SONAME_OPTION=-install_name +} + +_LD_LINKER_OUTPUT= +_LD_LINKER_OUTPUT_FLAG=--linker-output ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION.linker.txt:REALPRJNAME} + +# Enable section-level DCE (dead code elimination): +# remove whole unused code and data sections +# (needs `-ffunction-sections` and `-fdata-sections` to be useful) +# +# NOTE: CGO linker doesn't seem to support DCE, but shares common LDFLAGS +_LD_DCE_FLAG_GC_SECTIONS= +_LD_DCE_FLAG_PRINT_SECTIONS= +when ($OS_DARWIN == "yes") { + _LD_DCE_FLAG_GC_SECTIONS=-Wl,-dead_strip +} +elsewhen ($OS_LINUX == "yes" || $OS_ANDROID == "yes" || $OS_NONE == "yes") { + _LD_DCE_FLAG_GC_SECTIONS=-Wl,--gc-sections + when ($LINKER_DCE_PRINT_SECTIONS == "yes") { + _LD_DCE_FLAG_PRINT_SECTIONS=-Wl,--print-gc-sections + _LD_LINKER_OUTPUT=$_LD_LINKER_OUTPUT_FLAG + } +} +LD_DCE_FLAG = +LD_DCE_FLAG+=$_LD_DCE_FLAG_GC_SECTIONS +LD_DCE_FLAG+=$_LD_DCE_FLAG_PRINT_SECTIONS +DCE_FLAG= + +_LD_ICF_FLAG= +_LD_ICF_FLAG_PRINT_SECTIONS= +when ($_DEFAULT_LINKER_ID == "lld") { + # Enable ICF (identical code folding pass) in safe mode + # https://research.google/pubs/pub36912/ + _LD_ICF_FLAG=-Wl,-icf=safe + when ($LINKER_ICF_PRINT_SECTIONS == "yes") { + _LD_ICF_FLAG_PRINT_SECTIONS=-Wl,--print-icf-sections + _LD_LINKER_OUTPUT=$_LD_LINKER_OUTPUT_FLAG + } +} +LD_ICF_FLAG = +LD_ICF_FLAG+=$_LD_ICF_FLAG +LD_ICF_FLAG+=$_LD_ICF_FLAG_PRINT_SECTIONS +ICF_FLAG= + +STRIP_FLAG= + +C_LIBRARY_PATH= +C_SYSTEM_LIBRARIES_INTERCEPT= +when ($USEMPROF == "yes" || $USE_MPROF == "yes") { + C_SYSTEM_LIBRARIES_INTERCEPT+=-ldmalloc +} + +_LD_THREAD_LIBRARY= +when ($OS_LINUX == "yes" || $OS_DARWIN == "yes") { + _LD_THREAD_LIBRARY=-lpthread +} + +_LD_USE_STDLIB= +when ($_BUILD_COVERAGE == "yes" || $GCOV_COVERAGE == "yes" || $CLANG_COVERAGE == "yes" || $_BUILD_SANITIZED == "yes") { + _LD_USE_STDLIB= +} +elsewhen ($OS_ANDROID == "yes") { + when ($_ANDROID_NDK_VERSION_LESS_THEN_23 == "yes") { + # Preserve old behaviour: specify runtime libs manually + _LD_USE_STDLIB=-nodefaultlibs + } + otherwise { + # Use toolchain defaults to link with libunwind/clang_rt.builtins + _LD_USE_STDLIB=-nostdlib++ + } +} +elsewhen ($OS_LINUX == "yes" || $OS_DARWIN == "yes" || $OS_IOS == "yes") { + _LD_USE_STDLIB=-nodefaultlibs +} + +_C_SYSTEM_LIBRARIES=$_LD_USE_STDLIB $_LD_THREAD_LIBRARY $_LD_SYS_LIB -lc +when ($MUSL == "yes") { + _C_SYSTEM_LIBRARIES=-nostdlib +} +C_SYSTEM_LIBRARIES=$_C_SYSTEM_LIBRARIES + +OBJADDE= + +LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG= +when ($OS_LINUX == "yes" || $OS_ANDROID == "yes") { + LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG=-rdynamic +} + +NO_EXPORT_DYNAMIC_SYMBOLS= +EXPORTS_VALUE=$LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG +when ($EXPORTS_FILE) { + EXPORTS_VALUE=$LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG -Wl,--version-script=${input:EXPORTS_FILE} +} +when ($NO_EXPORT_DYNAMIC_SYMBOLS == "yes") { + EXPORTS_VALUE= +} + +LINKER_SCRIPT_VALUE=${ext=.ld;pre=-T:SRCS_GLOBAL} + +_LINKER_TIME_TRACE_GRANULARITY=500 +when ($TIME_TRACE_GRANULARITY && $TIME_TRACE_GRANULARITY != "") { + _LINKER_TIME_TRACE_GRANULARITY=$TIME_TRACE_GRANULARITY +} + +_LINKER_TIME_TRACE_FLAG= +when (($TIME_TRACE == "yes" || $LINKER_TIME_TRACE == "yes") && $_DEFAULT_LINKER_ID == "lld") { + _LINKER_TIME_TRACE_FLAG=\ + -Wl,--time-trace \ + -Wl,--time-trace-granularity=$_LINKER_TIME_TRACE_GRANULARITY \ + -Wl,--time-trace-file=${output;rootrel;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.time_trace.json:REALPRJNAME} +} + +_EXE_FLAGS=\ + $C_FLAGS_PLATFORM \ + $BEFORE_PEERS \ + $_START_GROUP \ + ${rootrel:PEERS} \ + $_END_GROUP \ + $AFTER_PEERS \ + $EXPORTS_VALUE \ + $LINKER_SCRIPT_VALUE \ + $LDFLAGS \ + $LDFLAGS_GLOBAL \ + $OBJADDE \ + $OBJADDE_LIB \ + $C_LIBRARY_PATH \ + $C_SYSTEM_LIBRARIES_INTERCEPT \ + $C_SYSTEM_LIBRARIES \ + $STRIP_FLAG \ + $DCE_FLAG \ + $ICF_FLAG \ + $_LINKER_TIME_TRACE_FLAG + +_SONAME_FLAG=-Wl,$_SONAME_OPTION,$_SONAME +_SHARED_FLAG=-shared +_EXEC_SHARED_FLAG= +when ($OS_LINUX == "yes") { + _EXEC_SHARED_FLAG=-pie -fPIE -Wl,--unresolved-symbols=ignore-all -rdynamic +} + +_LD_ENV_STYLE=${cwd:ARCADIA_BUILD_ROOT} $TOOLCHAIN_ENV ${kv;hide:"p LD"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + +# Program +GENERATE_MF_CMD=\ + $YMAKE_PYTHON ${input:"build/scripts/generate_mf.py"} ${input;hide:"build/scripts/process_command_files.py"} \ + --build-root $ARCADIA_BUILD_ROOT \ + --module-name $REALPRJNAME \ + -o ${output;rootrel;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mf:REALPRJNAME} \ + -t $MODULE_TYPE \ + --ya-start-command-file \ + -Ya,lics $LICENSE_NAMES \ + -Ya,peers ${rootrel:PEERS} \ + -Ya,credits ${input:CREDITS_TEXTS_FILE} $CREDITS_FLAGS \ + --ya-end-command-file + +LINK_SCRIPT_EXE_FLAGS= + +REAL_LINK_EXE_CMDLINE =\ + $YMAKE_PYTHON ${input:"build/scripts/link_exe.py"} \ + --source-root $ARCADIA_ROOT + REAL_LINK_EXE_CMDLINE+=$_LD_LINKER_OUTPUT + REAL_LINK_EXE_CMDLINE+=\ + ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ + ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ + $_LD_ARCH_FLAG \ + $LINK_SCRIPT_EXE_FLAGS \ + $CXX_COMPILER \ + $_LD_SRCS_GLOBALS \ + $VCS_C_OBJ $AUTO_INPUT -o $TARGET \ + $_EXE_FLAGS \ + $_PROCESS_WHOLE_ARCHIVE_SCRIPT \ + $_LD_ENV_STYLE + +REAL_LINK_EXE_TIDY=\ + $YMAKE_PYTHON ${input:"build/scripts/clang_tidy_arch.py"} \ + --build-root $ARCADIA_BUILD_ROOT \ + --source-root $ARCADIA_ROOT \ + --output-file $TARGET \ + $AUTO_INPUT \ + $_LD_ENV_STYLE + +# Executable Shared Library + +REAL_LINK_EXEC_DYN_LIB_CMDLINE =\ + $YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \ + --target $TARGET +REAL_LINK_EXEC_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT +REAL_LINK_EXEC_DYN_LIB_CMDLINE+=\ + ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ + ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ + $_LD_ARCH_FLAG \ + $LINK_DYN_LIB_FLAGS \ + $CXX_COMPILER \ + $_LD_SRCS_GLOBALS \ + $VCS_C_OBJ $AUTO_INPUT -o $TARGET \ + $_EXEC_SHARED_FLAG \ + $_SONAME_FLAG \ + $_EXE_FLAGS \ + $_PROCESS_WHOLE_ARCHIVE_SCRIPT \ + $_LD_ENV_STYLE + +REAL_LINK_EXEC_DYN_LIB=$REAL_LINK_EXEC_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +# Shared Library + +LINK_DYN_LIB_FLAGS= + +REAL_LINK_DYN_LIB_CMDLINE =\ + $YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \ + --target $TARGET +REAL_LINK_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT +REAL_LINK_DYN_LIB_CMDLINE+=\ + ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ + ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ + $_LD_ARCH_FLAG \ + $LINK_DYN_LIB_FLAGS \ + $CXX_COMPILER \ + $_LD_SRCS_GLOBALS \ + $VCS_C_OBJ $AUTO_INPUT -o $TARGET \ + $_SHARED_FLAG \ + $_SONAME_FLAG \ + $_EXE_FLAGS \ + $_PROCESS_WHOLE_ARCHIVE_SCRIPT \ + $_LD_ENV_STYLE + +REAL_LINK_DYN_LIB=$REAL_LINK_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +_DWARF_COMMAND= +when ($OS_DARWIN == "yes" && $NO_DEBUGINFO != "yes" && $SPLIT_DWARF_VALUE != "no" && $NO_SPLIT_DWARF != "yes") { + _DWARF_COMMAND=$DWARF_TOOL $TARGET -o ${output;pre=$MODULE_PREFIX$REALPRJNAME.dSYM/Contents/Resources/DWARF/$MODULE_PREFIX:REALPRJNAME} $_LD_ENV_STYLE +} +elsewhen ($OS_DARWIN == "yes" && $NO_DEBUGINFO != "yes") { + _EXE_FLAGS+=$DEBUG_INFO_FLAGS +} +otherwise { + _DWARF_COMMAND= +} +DWARF_COMMAND=$_DWARF_COMMAND + +_REAL_LINK_EXE=$REAL_LINK_EXE_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) +_LINK_EXE=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_LINK_EXE && $DWARF_COMMAND && $LINK_ADDITIONAL_SECTIONS_COMMAND && $PACK_IOS_CMD +_LINK_DYN_LIB=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_LINK_DYN_LIB && $DWARF_COMMAND && $LINK_ADDITIONAL_SECTIONS_COMMAND +when ($TIDY == "yes") { + _REAL_LINK_EXE=$REAL_LINK_EXE_TIDY + _LINK_EXE=$REAL_LINK_EXE + _LINK_DYN_LIB=$REAL_LINK_EXE +} +REAL_LINK_EXE=$_REAL_LINK_EXE +LINK_EXE=$_LINK_EXE +LINK_DYN_LIB=$_LINK_DYN_LIB + +LINK_EXEC_DYN_LIB=\ + $GENERATE_MF && \ + $GENERATE_VCS_C_INFO_NODEP && \ + $REAL_LINK_EXEC_DYN_LIB && \ + $DWARF_COMMAND && \ + $LINK_ADDITIONAL_SECTIONS_COMMAND + +SWIG_DLL_JAR_CMD=\ + $GENERATE_MF && \ + $GENERATE_VCS_C_INFO_NODEP && \ + $REAL_SWIG_DLL_JAR_CMD && \ + $DWARF_COMMAND + +_LD_TAIL_LINK_LIB=$AUTO_INPUT ${kv;hide:"p AR"} $TOOLCHAIN_ENV ${kv;hide:"pc light-red"} ${kv;hide:"show_out"} +_LD_ARCHIVER=$YMAKE_PYTHON ${input:"build/scripts/link_lib.py"} ${quo:AR_TOOL} $AR_TYPE $_LD_LLVM_AR_FORMAT $ARCADIA_BUILD_ROOT $_LD_AR_PLUGIN +_LD_LIB_GENERATE_MF=$GENERATE_MF && +when ($TIDY == "yes") { + _LD_ARCHIVER=$YMAKE_PYTHON ${input:"build/scripts/clang_tidy_arch.py"} --source-root $ARCADIA_ROOT --build-root $ARCADIA_BUILD_ROOT --output-file + _LD_LIB_GENERATE_MF= +} +LINK_LIB=$_LD_LIB_GENERATE_MF $_LD_ARCHIVER $TARGET $_LD_TAIL_LINK_LIB +GLOBAL_LINK_LIB=$_LD_ARCHIVER $GLOBAL_TARGET $_LD_TAIL_LINK_LIB + +# "Fat Object" : pre-linked global objects and static library with all dependencies +_LD_LINK_FAT_PREFIX=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $YMAKE_PYTHON ${input:"build/scripts/link_fat_obj.py"} --build-root $ARCADIA_BUILD_ROOT $_PROCESS_WHOLE_ARCHIVE_SCRIPT +_LD_LINK_FAT_SRCS_GLOBALS_WA=$_LD_SRCS_GLOBALS +_LD_LINK_FAT_SRCS_GLOBALS_NO_WA=${rootrel;ext=.a:SRCS_GLOBAL} ${rootrel;ext=.o:SRCS_GLOBAL} + +macro _FAT_OBJECT_ARGS_BASE(Flag, Lib) { + .CMD=$Flag=$Lib +} + +# FIXME: pre=lib here is weird legacy +_FAT_OBJECT_ARGS=--obj=${pre=lib;output:REALPRJNAME.o} +_LD_LINK_FAT_SRCS_GLOBALS=$_LD_LINK_FAT_SRCS_GLOBALS_WA + +macro PACK_GLOBALS_IN_LIBRARY() { + SET(_FAT_OBJECT_ARGS $_FAT_OBJECT_ARGS_BASE(--globals-lib, \${output;pre=$MODULE_PREFIX:REALPRJNAME.globals.a})) +} + +when ($OS_ANDROID == "yes") { + _FAT_OBJECT_ARGS= + _LD_LINK_FAT_SRCS_GLOBALS=$_LD_LINK_FAT_SRCS_GLOBALS_NO_WA +} + +_LD_LINK_FAT_SUFFIX1=$_LD_ARCH_FLAG \ + -Ya,input $AUTO_INPUT $VCS_C_OBJ \ + -Ya,global_srcs + +_LD_LINK_FAT_SUFFIX2=-Ya,peers $PEERS \ + -Ya,linker $CXX_COMPILER \ + $LDFLAGS_GLOBAL $C_FLAGS_PLATFORM $LD_SDK_VERSION \ + -Ya,archiver $_LD_ARCHIVER \ + $TOOLCHAIN_ENV ${kv;hide:"p LD"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + +LINK_FAT_OBJECT=\ + $_LD_LINK_FAT_PREFIX \ + --lib=$TARGET $_FAT_OBJECT_ARGS \ + $_LD_LINK_FAT_SUFFIX1 \ + $_LD_LINK_FAT_SRCS_GLOBALS \ + $_LD_LINK_FAT_SUFFIX2 + +LINK_RECURSIVE_LIBRARY=\ + $_LD_LINK_FAT_PREFIX \ + --lib=$TARGET --with-own-obj --with-global-srcs \ + $_LD_LINK_FAT_SUFFIX1 \ + $_LD_LINK_FAT_SRCS_GLOBALS_NO_WA \ + $_LD_LINK_FAT_SUFFIX2 + +LIBRT=-lrt +MD5LIB=-lcrypt +LIBRESOLV= +when ($OS_LINUX || $OS_DARWIN || $OS_ANDROID) { + LIBRESOLV=-lresolv +} +PROFFLAG=-pg diff --git a/build/conf/linkers/msvc_linker.conf b/build/conf/linkers/msvc_linker.conf new file mode 100644 index 00000000000..d6e267b6e7c --- /dev/null +++ b/build/conf/linkers/msvc_linker.conf @@ -0,0 +1,275 @@ +_MSVC_ARCH= +when ($ARCH_I386 == "yes" || $ARCH_I686 == "yes") { + _MSVC_ARCH=x86 +} +elsewhen ($ARCH_X86_64 == "yes") { + _MSVC_ARCH=x64 +} +elsewhen ($ARCH_ARM == "yes") { + _MSVC_ARCH=arm +} + +_FLAGS_MACHINE=/MACHINE:${toupper:_MSVC_ARCH} + +_FLAGS_IGNORE=/IGNORE:4221 + +_FLAGS_COMMON_IDE_MSVS= +when ($IDE_MSVS == "yes") { + _FLAGS_COMMON_IDE_MSVS=/INCREMENTAL +} +otherwise { + _FLAGS_COMMON_IDE_MSVS=/INCREMENTAL:NO +} + +# TODO(nslus): DEVTOOLS-1868 remove restriction. +_FLAGS_DEBUG_ONLY_DEBUG= +_FLAGS_RELEASE_ONLY_DEBUG= +_FLAGS_COMMON_DEBUG= +when (!$NO_DEBUGINFO || $NO_DEBUGINFO == "no" || $NO_DEBUGINFO == "0") { + when ($IDE_MSVS == "yes") { + when ($CLANG_CL == "yes") { + _FLAGS_DEBUG_ONLY_DEBUG=/DEBUG + } + otherwise { + _FLAGS_DEBUG_ONLY_DEBUG=/DEBUG:FASTLINK + } + _FLAGS_RELEASE_ONLY_DEBUG=/DEBUG + } + otherwise { + _FLAGS_COMMON_DEBUG=/DEBUG + } +} + +_FLAGS_COMMON_LIBPATHS= +when ($IDE_MSVS != "yes") { + _FLAGS_COMMON_LIBPATHS=\ + /LIBPATH:"$_MSVC_TC_KIT_LIBS/um/$_MSVC_ARCH" \ + /LIBPATH:"$_MSVC_TC_KIT_LIBS/ucrt/$_MSVC_ARCH" \ + /LIBPATH:"$_MSVC_TC_VC_ROOT/lib/$_MSVC_ARCH" +} + +_FLAGS_COMMON =/NOLOGO /ERRORREPORT:PROMPT /SUBSYSTEM:CONSOLE /TLBID:1 $MSVC_DYNAMICBASE /NXCOMPAT +_FLAGS_COMMON+=$_FLAGS_IGNORE +_FLAGS_COMMON+=$_FLAGS_MACHINE +_FLAGS_COMMON+=$_FLAGS_COMMON_IDE_MSVS +_FLAGS_COMMON+=$_FLAGS_COMMON_DEBUG +_FLAGS_COMMON+=$_FLAGS_COMMON_LIBPATHS + +_FLAGS_DEBUG_ONLY_CLANG_CL= +when ($CLANG_CL == "yes") { + _FLAGS_DEBUG_ONLY_CLANG_CL=/STACK:4194304 +} + +_FLAGS_DEBUG_ONLY =$_FLAGS_DEBUG_ONLY_CLANG_CL +_FLAGS_DEBUG_ONLY+=$_FLAGS_DEBUG_ONLY_DEBUG +_FLAGS_RELEASE_ONLY =$_FLAGS_RELEASE_ONLY_DEBUG + +LINK_EXE_FLAGS_DEBUG =$_FLAGS_COMMON +LINK_EXE_FLAGS_DEBUG+=$_FLAGS_DEBUG_ONLY + +LINK_EXE_FLAGS_RELEASE =$_FLAGS_COMMON +LINK_EXE_FLAGS_RELEASE+=$_FLAGS_RELEASE_ONLY + +LINK_LIB_FLAGS=$_FLAGS_IGNORE $_FLAGS_MACHINE + +LINK_STDLIBS=\ + advapi32.lib \ + comdlg32.lib \ + crypt32.lib \ + dnsapi.lib \ + gdi32.lib \ + iphlpapi.lib \ + kernel32.lib \ + mswsock.lib \ + ole32.lib \ + oleaut32.lib \ + psapi.lib \ + rpcrt4.lib \ + secur32.lib \ + shell32.lib \ + shlwapi.lib \ + user32.lib \ + userenv.lib \ + uuid.lib \ + version.lib \ + winmm.lib \ + winspool.lib \ + ws2_32.lib + +LDFLAGS_GLOBAL= +LDFLAGS= +OBJADDE= + +LINK_EXE_FLAGS=$LINK_EXE_FLAGS_PER_TYPE + +LINK_IMPLIB=/IMPLIB:${output;noext;rootrel;pre=$MODULE_PREFIX:REALPRJNAME.lib} +_LINK_EXTRA_OUTPUT= +when (!$NO_DEBUGINFO || $NO_DEBUGINFO == "no" || $NO_DEBUGINFO == "0") { + _LINK_EXTRA_OUTPUT=/PDB:${output;noext;rootrel;pre=$MODULE_PREFIX:REALPRJNAME.pdb} +} +LINK_EXTRA_OUTPUT=$_LINK_EXTRA_OUTPUT + +LIB_WRAPPER=${FIX_MSVC_OUTPUT} lib +LINK_WRAPPER=${FIX_MSVC_OUTPUT} link +when ($_UNDER_WINE == "yes") { + LIB_WRAPPER= + LINK_WRAPPER= +} + +LINK_WRAPPER_DYNLIB=${YMAKE_PYTHON} ${input:"build/scripts/link_dyn_lib.py"} --arch WINDOWS --target $TARGET + +EXPORTS_VALUE= +LINK_IMPLIB_VALUE= +when ($EXPORTS_FILE) { + LINK_IMPLIB_VALUE=$LINK_IMPLIB + EXPORTS_VALUE=/DEF:${input:EXPORTS_FILE} +} + +GENERATE_MF_CMD=\ + $YMAKE_PYTHON ${input:"build/scripts/generate_mf.py"} ${input;hide:"build/scripts/process_command_files.py"} \ + --build-root $ARCADIA_BUILD_ROOT \ + --module-name $REALPRJNAME \ + -o ${output;rootrel;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mf:REALPRJNAME} \ + -t $MODULE_TYPE \ + --ya-start-command-file \ + -Ya,lics $LICENSE_NAMES \ + -Ya,peers ${rootrel:PEERS} \ + -Ya,credits ${input:CREDITS_TEXTS_FILE} $CREDITS_FLAGS \ + --ya-end-command-file + +# we split srcs_global into two groups: libs and objs +# # each group can be in its own command file +# first group need /WHOLEARCHIVE: prefix which will be added in fix_msvc_output.py or run_msvc_wine.py +# the tail of link commands will be added in the third command file +_MSVC_SRCS_GLOBALS=\ +--start-wa --ya-start-command-file ${qe;rootrel;ext=.lib:SRCS_GLOBAL} --ya-end-command-file --end-wa \ +--ya-start-command-file ${qe;rootrel;ext=.obj:SRCS_GLOBAL} --ya-end-command-file + +REAL_LINK_DYN_LIB_CMDLINE=\ + ${TOOLCHAIN_ENV} \ + ${cwd:ARCADIA_BUILD_ROOT} \ + ${LINK_WRAPPER} \ + ${LINK_WRAPPER_DYNLIB} \ + ${LINK_EXE_CMD} \ + ${LINK_IMPLIB_VALUE} \ + /DLL \ + /OUT:${qe;rootrel:TARGET} \ + ${LINK_EXTRA_OUTPUT} \ + ${EXPORTS_VALUE} \ + ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ + ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ + $_MSVC_SRCS_GLOBALS \ + --ya-start-command-file \ + ${VCS_C_OBJ_RR} \ + ${qe;rootrel:AUTO_INPUT} \ + ${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \ + $LINK_EXE_FLAGS \ + $LINK_STDLIBS $LDFLAGS \ + $LDFLAGS_GLOBAL \ + $OBJADDE \ + --ya-end-command-file + +REAL_LINK_DYN_LIB=$REAL_LINK_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +SWIG_DLL_JAR_CMD=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_SWIG_DLL_JAR_CMD + +_MSVC_HEAD_LINK_LIB=${TOOLCHAIN_ENV} ${cwd:ARCADIA_BUILD_ROOT} ${LIB_WRAPPER} ${LINK_LIB_CMD} +_MSVC_TAIL_LINK_LIB=\ + --ya-start-command-file \ + ${qe;rootrel:AUTO_INPUT} \ + $LINK_LIB_FLAGS \ + --ya-end-command-file \ + ${hide;kv:"soe"} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"} + +LINK_LIB=${GENERATE_MF} && $_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:TARGET} $_MSVC_TAIL_LINK_LIB +GLOBAL_LINK_LIB=$_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:GLOBAL_TARGET} $_MSVC_TAIL_LINK_LIB + +LINK_EXE_CMDLINE=\ + ${GENERATE_MF} && \ + $GENERATE_VCS_C_INFO_NODEP && \ + ${TOOLCHAIN_ENV} \ + ${cwd:ARCADIA_BUILD_ROOT} \ + ${LINK_WRAPPER} \ + ${LINK_EXE_CMD} \ + /OUT:${qe;rootrel:TARGET} \ + ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ + ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ + ${LINK_EXTRA_OUTPUT} \ + $_MSVC_SRCS_GLOBALS \ + --ya-start-command-file \ + ${VCS_C_OBJ_RR} \ + ${qe;rootrel:AUTO_INPUT} \ + $LINK_EXE_FLAGS \ + $LINK_STDLIBS \ + $LDFLAGS \ + $LDFLAGS_GLOBAL \ + $OBJADDE \ + ${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \ + --ya-end-command-file \ + ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"} + +LINK_EXE=$LINK_EXE_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +LINK_DYN_LIB=${GENERATE_MF} && $GENERATE_VCS_C_INFO_NODEP && $REAL_LINK_DYN_LIB ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"} + +LINK_EXEC_DYN_LIB_CMDLINE=\ + ${GENERATE_MF} && \ + $GENERATE_VCS_C_INFO_NODEP && \ + ${TOOLCHAIN_ENV} \ + ${cwd:ARCADIA_BUILD_ROOT} \ + ${LINK_WRAPPER} \ + ${LINK_WRAPPER_DYNLIB} \ + ${LINK_EXE_CMD} \ + /OUT:${qe;rootrel:TARGET} \ + ${LINK_EXTRA_OUTPUT} \ + ${EXPORTS_VALUE} \ + ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ + ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ + $_MSVC_SRCS_GLOBALS \ + '--ya-start-command-file \ + ${VCS_C_OBJ_RR} \ + ${qe;rootrel:AUTO_INPUT} \ + ${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \ + $LINK_EXE_FLAGS \ + $LINK_STDLIBS \ + $LDFLAGS $LDFLAGS_GLOBAL \ + $OBJADDE \ + --ya-end-command-file \ + ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"} + +LINK_EXEC_DYN_LIB=$LINK_EXEC_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +macro PACK_GLOBALS_IN_LIBRARY() { + ENABLE(UNUSED_MACRO) +} + +LINK_GLOBAL_FAT_OBJECT=\ + ${TOOLCHAIN_ENV} \ + ${cwd:ARCADIA_BUILD_ROOT} \ + ${LIB_WRAPPER} \ + ${LINK_LIB_CMD} \ + /OUT:${output;qe;rootrel:REALPRJNAME.global.lib} \ + --ya-start-command-file \ + ${qe;rootrel;ext=.lib:SRCS_GLOBAL} \ + ${qe;rootrel;ext=.obj:SRCS_GLOBAL} \ + ${qe;rootrel:AUTO_INPUT} \ + $LINK_LIB_FLAGS \ + --ya-end-command-file + +LINK_PEERS_FAT_OBJECT=\ + ${TOOLCHAIN_ENV} \ + ${cwd:ARCADIA_BUILD_ROOT} \ + ${LIB_WRAPPER} \ + ${LINK_LIB_CMD} \ + /OUT:${qe;rootrel;output:TARGET} \ + --ya-start-command-file \ + ${qe;rootrel:PEERS} \ + $LINK_LIB_FLAGS \ + --ya-end-command-file + +LINK_FAT_OBJECT=\ + ${GENERATE_MF} && \ + $GENERATE_VCS_C_INFO_NODEP && \ + $LINK_GLOBAL_FAT_OBJECT && \ + $LINK_PEERS_FAT_OBJECT \ + ${kv;hide:"p LD"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} diff --git a/build/conf/opensource.conf b/build/conf/opensource.conf new file mode 100644 index 00000000000..408e45c8b97 --- /dev/null +++ b/build/conf/opensource.conf @@ -0,0 +1,84 @@ +EXPORT_CMAKE=no +EXPORT_GRADLE=no + +when ($OPENSOURCE == "yes" || $OPENSOURCE_PROJECT == "ymake" || $OPENSOURCE_PROJECT == "ya") { + YA_OPENSOURCE=yes +} + +when ($CATBOOST_OPENSOURCE == "yes") { + OPENSOURCE=yes + CFLAGS+=-DCATBOOST_OPENSOURCE=yes + CXXFLAGS+=-DCATBOOST_OPENSOURCE=yes +} + +when ($OPENSOURCE == "yes") { + LOCAL_YDB_DOCKER_PUBLIC_BUILD=yes + CATBOOST_OPENSOURCE=yes + GO_VET=no + USE_DYNAMIC_IDN=yes + USE_DYNAMIC_AIO=yes + USE_DYNAMIC_ICONV=yes + USE_ASMLIB=no + SO_OUTPUTS=yes + UDF_NO_PROBE=yes + HAVE_MKL=no + USE_MKL=no + USE_PREBUILT_TOOLS=no +} + +# Extra macros to control how gradle export works + +when ($OPENSOURCE == "yes" && $EXPORT_GRADLE == "yes") { + RECURSIVE_ADD_PEERS_TESTS=yes + EXPORT_SEM=yes +} + +# Extra macros to control how cmake export works + +when ($OPENSOURCE == "yes" && $EXPORT_CMAKE == "yes") { + # Python version is not acttually used in exported cmake's rigth now. + # The only reason to set it is to avoid any deps on contrib/python|contrib/libs/python when + # exporting PY_*_MODULE and force dependency to build/platform/python there. + USE_SYSTEM_PYTHON=3.10 + USE_ARCADIA_PYTHON=no + # YMAKE-477. yexport does not support USE_GLOBAL_CMD=no and crashes with OOM. + # USE_GLOBAL_CMD=yes does not work for Windows with ya make builds but works with exported CMake files: YMAKE-657. + USE_GLOBAL_CMD=yes + EXPORT_SEM=yes +} + +CMAKE_PACKAGE= +CMAKE_PACKAGE_COMPONENT= +CMAKE_PACKAGE_TARGET= +CONAN_REFERENCE= +CONAN_PKG_OPTS= +### @usage: OPENSOURCE_EXPORT_REPLACEMENT(CMAKE PkgName CMAKE_TARGET PkgName::PkgTarget CONAN ConanRef CMAKE_COMPONENT OptCmakePkgComponent) +### +### Use specified conan/system pacakcge when exporting cmake build scripts for arcadia C++ project +### for opensource publication. +macro OPENSOURCE_EXPORT_REPLACEMENT(CMAKE[], CMAKE_TARGET[], CMAKE_COMPONENT[], CONAN[], CONAN_OPTIONS[]) { + SET(CMAKE_PACKAGE $CMAKE) + SET(CMAKE_PACKAGE_COMPONENT $CMAKE_COMPONENT) + SET(CMAKE_LINK_TARGET $CMAKE_TARGET) + SET(CONAN_REFERENCE $CONAN) + SET(CONAN_PKG_OPTS $CONAN_OPTIONS) +} + +CMAKE_TARGET_NAME=$REALPRJNAME +CMAKE_TARGET_ARTEFACT_RENAME_RULES= +### @usage CMAKE_EXPORTED_TARGET_NAME(Name) +### +### Forces to use the name given as cmake target name without changing the name of output artefact. +### This macro should be used to resolve target name conflicts in exported cmake project when +### changing module name is not applicable. For example both CUDA and non-CUDA py modules for +### catboost should have same name lib_catboost.so and both of them are defined as PY_ANY_MODULE(_catboost). +### adding CMAKE_EXPORTED_TARGET_NAME(_catboost_non_cuda) to the non CUDA module ya.make file +### changes exported cmake target name but preserve generated artefact file name. +macro CMAKE_EXPORTED_TARGET_NAME(Name) { + SET(CMAKE_TARGET_NAME $Name) + SET(CMAKE_TARGET_ARTEFACT_RENAME_RULES && set_target_property OUTPUT_NAME $REALPRJNAME) +} + +macro ALLOCATOR_IMPL() { + SET(CPP_LIBRARY_INDUCED_SEM_PROPERTY target_allocator) +} diff --git a/build/conf/project_specific/esp.conf b/build/conf/project_specific/esp.conf new file mode 100644 index 00000000000..ce939d1629d --- /dev/null +++ b/build/conf/project_specific/esp.conf @@ -0,0 +1,136 @@ +ESP_KCONFIGS= +ESP_KCONFIGS_PROJBUILD= +ESP_LDFRAGMENTS= +ESP_SDKCONFIG_RENAMES= + +macro ESP_KCONFIG(Kconfig) { + SET_APPEND(ESP_KCONFIGS \${input;hide:$Kconfig}) + SET_APPEND(ESP_KCONFIGS_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Kconfig}) +} + +macro ESP_KCONFIG_PROJBUILD(Kconfig) { + SET_APPEND(ESP_KCONFIGS_PROJBUILD \${input;hide:$Kconfig}) + SET_APPEND(ESP_KCONFIGS_PROJBUILD_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Kconfig}) +} + +macro ESP_LDFRAGMENTS(Fragments...) { + SET_APPEND(ESP_LDFRAGMENTS ${pre=\$\{input\;hide\:\";suf=\"\}:Fragments}) + SET_APPEND(ESP_LDFRAGMENTS_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Fragments}) +} + +macro ESP_SDKCONFIG_RENAME(Rename) { + SET_APPEND(ESP_SDKCONFIG_RENAMES \${input;hide:$Rename}) + SET_APPEND(ESP_SDKCONFIG_RENAMES_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Rename}) +} + +ESP_LINK_LIB=$LINK_LIB $ESP_KCONFIGS $ESP_KCONFIGS_PROJBUILD $ESP_LDFRAGMENTS $ESP_SDKCONFIG_RENAMES + +ESP_CONFIG=contrib/libs/esp-idf/config + +module ESP_LIBRARY: LIBRARY { + .CMD=ESP_LINK_LIB + .GLOBAL=ESP_KCONFIGS ESP_KCONFIGS_PROJBUILD ESP_LDFRAGMENTS ESP_SDKCONFIG_RENAMES + + ADDINCL(GLOBAL $ESP_CONFIG) +} + +ESP_KCONFIGS_CMD=$WRITER_PY --file ${tmp:"kconfigs.in"} -m ${pre="source \"";suf="\"":ESP_KCONFIGS_GLOBAL} + +ESP_KCONFIGS_PROJBUILD_CMD=$WRITER_PY --file ${tmp:"kconfigs_projbuild.in"} -m ${pre="source \"";suf="\"":ESP_KCONFIGS_PROJBUILD_GLOBAL} + +ESP_SDKCONFIG_DEFAULTS=contrib/libs/esp-idf/sdkconfig.defaults + +macro _ESP_CONFGEN_DEFAULTS_HELPER(Defaults...) { + .CMD=${pre=--defaults :Defaults} +} + +macro _ESP_CONFGEN_DEFAULTS_ARGS(Defaults...) { + .CMD=$_ESP_CONFGEN_DEFAULTS_HELPER(${input:Defaults}) +} + +ESP_CONFGEN_CMD= \ + ${tool:"contrib/libs/esp-idf/tools/kconfig_new/confgen"} \ + $_ESP_CONFGEN_DEFAULTS_ARGS($ESP_SDKCONFIG_DEFAULTS) \ + --kconfig ${input:"contrib/libs/esp-idf/Kconfig"} \ + --sdkconfig-rename ${input:"contrib/libs/esp-idf/sdkconfig.rename"} \ + --env IDF_CMAKE=y \ + --env IDF_TARGET=esp32c3 \ + --env IDF_ENV_FPGA= \ + --env IDF_PATH=$ARCADIA_ROOT/contrib/libs/esp-idf \ + --env COMPONENT_KCONFIGS_SOURCE_FILE=${tmp:"kconfigs.in"} \ + --env COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${tmp:"kconfigs_projbuild.in"} \ + --env COMPONENT_SDKCONFIG_RENAMES=${join=" ":ESP_SDKCONFIG_RENAMES_GLOBAL} \ + --output config ${output:"sdkconfig"} \ + --output header ${output:"sdkconfig.h"} + +ESP_LIBRARIES_CMD=$WRITER_PY --file ${tmp:"ldgen_libraries"} -m $PEERS + +ESP_LDGEN_CMD= \ + ${tool:"contrib/libs/esp-idf/tools/ldgen"} \ + --config ${tmp:"sdkconfig"} \ + --fragments $ESP_LDFRAGMENTS_GLOBAL \ + --input ${input:"contrib/libs/esp-idf/components/esp_system/ld/esp32c3/sections.ld.in"} \ + --output ${output:"sections.ld"} \ + --kconfig ${input:"contrib/libs/esp-idf/Kconfig"} \ + --env IDF_CMAKE=y \ + --env IDF_TARGET=esp32c3 \ + --env IDF_ENV_FPGA= \ + --env IDF_PATH=$ARCADIA_ROOT/contrib/libs/esp-idf \ + --env COMPONENT_KCONFIGS_SOURCE_FILE=${tmp:"kconfigs.in"} \ + --env COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${tmp:"kconfigs_projbuild.in"} \ + --libraries-file ${tmp:"ldgen_libraries"} \ + --objdump $OBJDUMP_TOOL + +ESP_FLASH_SIZE=4MB + +macro _ESP_ELF2IMAGE(Elf, Args...) { + .CMD=${cwd:BINDIR} ${tool:"contrib/tools/esptool/esptool"} --chip esp32c3 elf2image $Args --flash_mode dio --flash_freq 80m --flash_size $ESP_FLASH_SIZE --min-rev 3 -o ${output;noext:Elf.bin} $Elf +} + +ESP_PARTITION_TABLE_OFFSET=0x8000 +ESP_PARTITION_TABLE=partitions.csv + +ESP_GEN_ESP32PART_CMD= \ + ${tool:"contrib/libs/esp-idf/components/partition_table/gen_esp32part"} \ + --flash-size $ESP_FLASH_SIZE \ + --offset $ESP_PARTITION_TABLE_OFFSET \ + --secure \ + ${input:ESP_PARTITION_TABLE} \ + ${output:"partition-table.bin"} + +ESP_LINK_EXE= \ + && $ESP_KCONFIGS_CMD \ + && $ESP_KCONFIGS_PROJBUILD_CMD \ + && $ESP_CONFGEN_CMD \ + && $ESP_LIBRARIES_CMD \ + && $ESP_LDGEN_CMD \ + && $ESP_GEN_ESP32PART_CMD \ + && $LINK_EXE \ + && $_ESP_ELF2IMAGE($MODULE_PREFIX$REALPRJNAME, "--secure-pad-v2") + +### @usage: ESP_PROGRAM([progname]) +### +### Program module for Espressif microcontrollers. +### Converts ELF to binary image file suitable for flashing. +### Currently, only ESP32-C3 is supported. +module ESP_PROGRAM: PROGRAM { + .CMD=ESP_LINK_EXE + .GLOBAL=ESP_KCONFIGS ESP_KCONFIGS_PROJBUILD ESP_LDFRAGMENTS ESP_SDKCONFIG_RENAMES + ALLOCATOR(FAKE) + NO_PLATFORM() + LINKER_SCRIPT_VALUE+=-T$ARCADIA_BUILD_ROOT/$MODDIR/sections.ld +} + +ESP_BOOTLOADER_LINK_EXE= \ + && $LINK_EXE \ + && $_ESP_ELF2IMAGE($MODULE_PREFIX$REALPRJNAME, "--pad-to-size", "4KB") + +module ESP_BOOTLOADER: PROGRAM { + .CMD=ESP_BOOTLOADER_LINK_EXE + ALLOCATOR(FAKE) + NO_PLATFORM() +} + +when ($ESP_BOOTLOADER_BUILD == "yes") { + CFLAGS+=-DBOOTLOADER_BUILD -fno-stack-protector +} diff --git a/build/conf/project_specific/maps/aar.conf b/build/conf/project_specific/maps/aar.conf new file mode 100644 index 00000000000..6f03e07c1f8 --- /dev/null +++ b/build/conf/project_specific/maps/aar.conf @@ -0,0 +1,338 @@ + +_GRADLE_FLAGS_VALUE= +### @usage: GRADLE_FLAGS(flags...) # internal +### +### SEt additional flags for gradle +macro GRADLE_FLAGS(FLAGS...) { + SET_APPEND(_GRADLE_FLAGS_VALUE $FLAGS) +} + +### @usage: PROGUARD_RULES(ProguardRuleFiles...) +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro PROGUARD_RULES(RULES...) { + SET_APPEND(_PROGUARD_RULES_GLOBAL $RULES) +} + +### @usage: AARS(Aars...) +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro AARS(DEPS...) { + SET_APPEND(_AARS_GLOBAL $DEPS) +} + +### @usage: MOBILE_DLL() # internal +module MOBILE_DLL: DLL { + .CMD=LINK_MOBILE_DLL + + PEERDIR(build/external_resources/android_sdk) + PEERDIR(build/external_resources/gradle) + PEERDIR(build/platform/java/jdk) + PEERDIR($JDK_RESOURCE_PEERDIR) + + SET(BIN_AAR_DIR $BINDIR/aar) + SET(BIN_TMP_DIR $BINDIR/tmp) +} + +_MOBILE_TEST_APK_AAR_MANIFEST_VALUE= +### @usage: MOBILE_TEST_APK_AAR_MANIFEST(file) # internal +macro MOBILE_TEST_APK_AAR_MANIFEST(FILE) { + SET(_MOBILE_TEST_APK_AAR_MANIFEST_VALUE $FILE) +} + +_MOBILE_TEST_APK_AAR_PROGUARD_RULES_VALUE= +### @usage: MOBILE_TEST_APK_AAR_PROGUARD_RULES(file) # internal +macro MOBILE_TEST_APK_AAR_PROGUARD_RULES(FILE) { + SET(_MOBILE_TEST_APK_AAR_PROGUARD_RULES_VALUE $FILE) +} + +_MOBILE_TEST_APK_AAR_AARS_VALUE= +### @usage: MOBILE_TEST_APK_AAR_AARS(filenames...) # internal +macro MOBILE_TEST_APK_AAR_AARS(AARS...) { + SET_APPEND(_MOBILE_TEST_APK_AAR_AARS_VALUE $AARS) +} + +_MOBILE_TEST_APK_AAR_BUNDLES_VALUE= +### @usage: MOBILE_TEST_APK_AAR_BUNDLES(filenames...) # internal +macro MOBILE_TEST_APK_AAR_BUNDLES(BUNDLES...) { + SET_APPEND(_MOBILE_TEST_APK_AAR_BUNDLES_VALUE $BUNDLES) + BUNDLE_EXTRA_INPUTS($BUNDLES) +} + +_MOBILE_TEST_APK_TEMPLATE_DIR= +### @usage: MOBILE_TEST_APK_TEMPLATE(dir filenames...) # internal +macro MOBILE_TEST_APK_TEMPLATE(TEMPLATE_DIR, INPUTS...) { + SET(_MOBILE_TEST_APK_TEMPLATE_DIR $TEMPLATE_DIR) + BUNDLE_EXTRA_INPUTS(${pre=$TEMPLATE_DIR/:INPUTS}) +} + +_MOBILE_TEST_APK_CMDLINE=\ +$FS_TOOLS md $BIN_TMP_DIR \ +&& $FS_TOOLS md $BINDIR/.android \ +&& $COPY_CMD $GRADLE_DEBUG_STORE_RESOURCE_GLOBAL/debug.keystore $BINDIR/.android/debug.keystore \ +&& $FS_TOOLS md $BINDIR/jni_libs/$ARCH_NAME \ +&& $YMAKE_PYTHON ${input:"build/scripts/extract_asrc.py"} --output $BIN_TMP_DIR --input ${suf=.asrc:PEERS} \ +&& $MOVE_FILE $OUTPUT $BINDIR/jni_libs/$ARCH_NAME/${pre=lib;suf=.so:_MOBILE_TEST_APK_LIBRARY_NAME} \ +&& $FS_TOOLS md $BIN_AAR_DIR \ +&& $YMAKE_PYTHON ${input:"build/scripts/gen_aar_gradle_script.py"} \ +${input;hide:EXTRA_INPUTS} \ +--aidl-dirs $BIN_TMP_DIR/aidl \ +--assets-dirs $BIN_TMP_DIR/assets \ +--java-dirs $BIN_TMP_DIR/src \ +--jni-libs-dirs $BINDIR/jni_libs \ +--res-dirs $BIN_TMP_DIR/res \ +--manifest ${input:_MOBILE_TEST_APK_AAR_MANIFEST_VALUE} \ +--proguard-rules ${input:_MOBILE_TEST_APK_AAR_PROGUARD_RULES_VALUE} ${input:_PROGUARD_RULES_GLOBAL} \ +--aars $_MOBILE_TEST_APK_AAR_AARS_VALUE $_AARS_GLOBAL \ +--bundles $_MOBILE_TEST_APK_AAR_BUNDLES_VALUE \ +--output-dir $BIN_AAR_DIR \ +--bundle-name unittest \ +--maven-repos ${MAPSMOBI_MAVEN_REPO_RESOURCE_GLOBAL} \ +&& ${cwd:BIN_AAR_DIR} ${GRADLE_RESOURCE_GLOBAL}/bin/gradle $_GRADLE_FLAGS_VALUE --no-daemon --offline -g $BIN_GRADLE_USER_HOME_DIR assemble${_BUNDLE_BUILD_TYPE} ${env:"ANDROID_HOME=$ANDROID_SDK_RESOURCE_GLOBAL/android_sdk"} ${env:"JAVA_HOME=$JDK_RESOURCE"} ${env:"ANDROID_SDK_HOME=$BINDIR"} \ +&& $FS_TOOLS md $BIN_APK_DIR \ +&& $FS_TOOLS md $BIN_APK_DIR/res \ +&& $COPY_CMD $_MOBILE_TEST_APK_TEMPLATE_DIR/Manifest.xml $BIN_APK_DIR/Manifest.xml \ +&& $YMAKE_PYTHON ${input:"build/scripts/gen_test_apk_gradle_script.py"} \ +${input;hide:EXTRA_INPUTS} \ +--app-id $REALPRJNAME \ +--assets-dirs $_MOBILE_TEST_APK_ASSETS_DIRS_VALUE \ +--java-dirs $_MOBILE_TEST_APK_TEMPLATE_DIR/java \ +--jni-libs-dirs \ +--res-dirs $BIN_APK_DIR/res $_MOBILE_TEST_APK_TEMPLATE_DIR/res $BIN_TMP_DIR/res \ +--manifest Manifest.xml \ +--aars \ +--output-dir $BIN_APK_DIR \ +--bundle-name $REALPRJNAME \ +--bundles $BIN_AAR_DIR/build/outputs/aar/unittest-${tolower:_BUNDLE_BUILD_TYPE}.aar $_MOBILE_TEST_APK_AAR_BUNDLES_VALUE \ +--library-name $_MOBILE_TEST_APK_LIBRARY_NAME \ +--maven-repos ${MAPSMOBI_MAVEN_REPO_RESOURCE_GLOBAL} \ +&& ${cwd:BIN_APK_DIR} ${GRADLE_RESOURCE_GLOBAL}/bin/gradle $_GRADLE_FLAGS_VALUE --no-daemon --offline -g $BIN_GRADLE_USER_HOME_DIR assembleDebug ${env:"ANDROID_HOME=$ANDROID_SDK_RESOURCE_GLOBAL/android_sdk"} ${env:"JAVA_HOME=$JDK_RESOURCE"} ${env:"ANDROID_SDK_HOME=$BINDIR"} \ +&& $COPY_CMD $BIN_APK_DIR/build/outputs/apk/${tolower:_BUNDLE_BUILD_TYPE}/$REALPRJNAME.apk ${OUTPUT} + +_MOBILE_TEST_APK_EXTRA_INPUTS_VALUE= + +macro _MOBILE_TEST_APK_CMD_IMPL(OUTPUT, EXTRA_INPUTS...) { + .CMD=$_MOBILE_TEST_APK_CMDLINE +} + +_MOBILE_TEST_APK_CMD=$_MOBILE_TEST_APK_CMD_IMPL($TARGET $_BUNDLE_EXTRA_INPUTS_VALUE) + +LINK_MOBILE_TEST_APK=$LINK_DYN_LIB && $_MOBILE_TEST_APK_CMD + +### @usage: MOBILE_TEST_APK() # internal +module MOBILE_TEST_APK: DLL { + .CMD=LINK_MOBILE_TEST_APK + .GLOBAL=_AARS _PROGUARD_RULES + + PEERDIR(build/external_resources/android_sdk) + PEERDIR(build/external_resources/gradle) + PEERDIR(build/platform/java/jdk) + PEERDIR($JDK_RESOURCE_PEERDIR) + + SET(MODULE_PREFIX) + SET(MODULE_SUFFIX .apk) + + SET(BIN_AAR_DIR $BINDIR/aar) + SET(BIN_APK_DIR $BINDIR/apk) + SET(BIN_TMP_DIR $BINDIR/tmp) + SET(BIN_GRADLE_USER_HOME_DIR $BINDIR/gradle) + + SET(_MOBILE_TEST_APK_LIBRARY_NAME unittests) + + when ($OS_ANDROID == "yes") { + when ($ARCH_ARM7 == "yes") { + ARCH_NAME=armeabi-v7a + } + elsewhen ($ARCH_ARM64 == "yes") { + ARCH_NAME=arm64-v8a + } + elsewhen ($ARCH_I386 == "yes") { + ARCH_NAME=x86 + } + elsewhen ($ARCH_X86_64 == "yes") { + ARCH_NAME=x86_64 + } + otherwise { + ARCH_NAME=unsupported + } + } +} + + +### @usage: MOBILE_BOOST_TEST_APK() # internal +module MOBILE_BOOST_TEST_APK: MOBILE_TEST_APK { + PEERDIR(devtools/dummy_arcadia/test/test_apk/template) + PEERDIR(build/external_resources/mapsmobi_maven_repo) + ADD_YTEST($MODULE_PREFIX$REALPRJNAME boost.test) + + MOBILE_TEST_APK_TEMPLATE(${ARCADIA_ROOT}/devtools/dummy_arcadia/test/test_apk/template Manifest.xml java/com/yandex/test/unittests/RunTestsActivity.java java/com/yandex/test/unittests/CrashHandler.java res/values/strings.xml) +} + +when ($BT_RELEASE) { + _BUNDLE_BUILD_TYPE=Release +} +otherwise { + _BUNDLE_BUILD_TYPE=Debug +} + +_AAR_EXTRA_INPUTS_VALUE= + +_AAR_MANIFEST_VALUE= +### @usage: AAR_MANIFEST(filename) # internal +macro AAR_MANIFEST(FILE) { + SET(_AAR_MANIFEST_VALUE $FILE) +} + +_AAR_PROGUARD_RULES_VALUE= +### @usage: AAR_PROGUARD_RULES(filename) # internal +macro AAR_PROGUARD_RULES(FILE) { + SET(_AAR_PROGUARD_RULES_VALUE $FILE) +} + +_AAR_AARS_VALUE= +### @usage: AAR_AARS(aars...) # internal +macro AAR_AARS(Aars...) { + SET_APPEND(_AAR_AARS_VALUE $Aars) +} + +_AAR_COMPILE_ONLY_AARS_VALUE= +### @usage: AAR_COMPILE_ONLY_AARS(compile_only_aars...) # internal +macro AAR_COMPILE_ONLY_AARS(Aars...) { + SET_APPEND(_AAR_COMPILE_ONLY_AARS_VALUE $Aars) +} + + +_AAR_AIDL_DIRS_VALUE= +### @usage: AAR_AIDL_SRCS(dir filenames...) # internal +macro AAR_AIDL_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_AAR_AIDL_DIRS_VALUE $PREFIX) + SET_APPEND(_AAR_EXTRA_INPUTS_VALUE ${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_AAR_ASSETS_DIRS_VALUE= +### @usage: AAR_ASSETS_SRCS(dir filenames...) # internal +macro AAR_ASSETS_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_AAR_ASSETS_DIRS_VALUE $PREFIX) + SET_APPEND(_AAR_EXTRA_INPUTS_VALUE ${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_AAR_BUNDLES_VALUE= +### @usage: AAR_BUNDLES(filenames...) # internal +macro AAR_BUNDLES(BUNDLES...) { + SET_APPEND(_AAR_BUNDLES_VALUE $BUNDLES) + SET_APPEND(_AAR_EXTRA_INPUTS_VALUE $BUNDLES) +} + +_AAR_JNI_LIB_DIRS_VALUE= +### @usage: AAR_JNI_LIBS(dir filenames...) # internal +macro AAR_JNI_LIBS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_AAR_JNI_LIB_DIRS_VALUE $PREFIX) + SET_APPEND(_AAR_EXTRA_INPUTS_VALUE ${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_AAR_JAVA_DIRS_VALUE= +### @usage: AAR_JAVA_SRCS(dir filenames...) # internal +macro AAR_JAVA_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_AAR_JAVA_DIRS_VALUE $PREFIX) + SET_APPEND(_AAR_EXTRA_INPUTS_VALUE ${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_AAR_RES_DIRS_VALUE= +### @usage: AAR_RES_SRCS(dir filenames...) # internal +macro AAR_RES_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_AAR_RES_DIRS_VALUE $PREFIX) + SET_APPEND(_AAR_EXTRA_INPUTS_VALUE ${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_AAR_LOCAL_MAVEN_REPO_VALUE= +### @usage: AAR_LOCAL_MAVEN_REPO(repo...) +macro AAR_LOCAL_MAVEN_REPO(REPO...) { + SET_APPEND(_AAR_LOCAL_MAVEN_REPO_VALUE $REPO) +} + +_AAR_GRADLE_SCRIPT_GENERATOR_VALUE= +### @usage: AAR_GRADLE_SCRIPT_GENERATOR(python_script) +macro AAR_GRADLE_SCRIPT_GENERATOR(GENERATOR) { + SET(_AAR_GRADLE_SCRIPT_GENERATOR_VALUE $GENERATOR) +} + +when ($AAR_NO_STRIP) { + _AAR_NO_STRIP_VALUE=--do-not-strip +} +otherwise { + _AAR_NO_STRIP_VALUE= +} + +_AAR_CMDLINE=\ +$FS_TOOLS md $BIN_TMP_DIR \ +&& $FS_TOOLS md $BINDIR/.android \ +&& $COPY_CMD $GRADLE_DEBUG_STORE_RESOURCE_GLOBAL/debug.keystore $BINDIR/.android/debug.keystore \ +&& $YMAKE_PYTHON ${input:"build/scripts/extract_asrc.py"} --output $BIN_TMP_DIR --input ${suf=.asrc:PEERS} \ +&& $YMAKE_PYTHON ${input:_AAR_GRADLE_SCRIPT_GENERATOR_VALUE} \ +${input;hide:EXTRA_INPUTS} \ +--aidl-dirs $_AAR_AIDL_DIRS_VALUE $BIN_TMP_DIR/aidl \ +--assets-dirs $_AAR_ASSETS_DIRS_VALUE $BIN_TMP_DIR/assets \ +--java-dirs $_AAR_JAVA_DIRS_VALUE $BIN_TMP_DIR/src \ +--jni-libs-dirs $_AAR_JNI_LIB_DIRS_VALUE $BIN_TMP_DIR/jni_libs \ +--res-dirs $_AAR_RES_DIRS_VALUE $BIN_TMP_DIR/res \ +--manifest ${input:_AAR_MANIFEST_VALUE} \ +--proguard-rules ${input:_AAR_PROGUARD_RULES_VALUE} ${input:_PROGUARD_RULES_GLOBAL} \ +--aars $_AAR_AARS_VALUE $_AARS_GLOBAL \ +--compile-only-aars $_AAR_COMPILE_ONLY_AARS_VALUE \ +--bundles $_AAR_BUNDLES_VALUE \ +--output-dir $BINDIR \ +--bundle-name $REALPRJNAME \ +--peers $PEERS \ +--maven-repos $_AAR_LOCAL_MAVEN_REPO_VALUE \ +$_AAR_NO_STRIP_VALUE \ +&& ${cwd:BINDIR} ${GRADLE_RESOURCE_GLOBAL}/bin/gradle $_GRADLE_FLAGS_VALUE --no-daemon --offline -g $BIN_GRADLE_USER_HOME_DIR bundle${_BUNDLE_BUILD_TYPE}Aar ${env:"ANDROID_HOME=$ANDROID_SDK_RESOURCE_GLOBAL/android_sdk"} ${env:"JAVA_HOME=$JDK_RESOURCE"} ${env:"ANDROID_SDK_HOME=$BINDIR"} $VCS_INFO_DISABLE_CACHE__NO_UID__ \ +&& ${cwd:BINDIR} $COPY_CMD build/outputs/aar/${REALPRJNAME}-${tolower:_BUNDLE_BUILD_TYPE}.aar $TARGET \ +&& ${cwd:BINDIR} $COPY_CMD build/${suf=-pom.xml:REALPRJNAME} ${output;suf=-pom.xml:REALPRJNAME} \ +&& ${cwd:BINDIR} $COPY_CMD build/libs/${suf=-sources.jar:REALPRJNAME} ${output;suf=-sources.jar:REALPRJNAME} + +macro _AAR_CMD_IMPL(EXTRA_INPUTS...) { + .CMD=$_AAR_CMDLINE && $GENERATE_MF +} + +AAR_CMD=$_AAR_CMD_IMPL($_AAR_EXTRA_INPUTS_VALUE) + +### @usage: AAR() # internal +module AAR: _BASE_UNIT { + .CMD=AAR_CMD + .GLOBAL=_AARS _PROGUARD_RULES + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=yes + + SET(MODULE_PREFIX) + SET(MODULE_SUFFIX .aar) + SET(DONT_RESOLVE_INCLUDES yes) + SET(NEED_PLATFORM_PEERDIRS no) + NO_PLATFORM() + + PEERDIR(build/external_resources/android_sdk) + PEERDIR(build/external_resources/gradle) + PEERDIR(build/platform/java/jdk) + PEERDIR($JDK_RESOURCE_PEERDIR) + + SET(BIN_TMP_DIR $BINDIR/tmp) + SET(BIN_GRADLE_USER_HOME_DIR $BINDIR/gradle) +} + +_SECONDARY_OUTPUT_VALUE= + +### @usage: SECONDARY_OUTPUT(filename) # internal +### +### The use of this macro is strictly prohibited!!! +macro SECONDARY_OUTPUT(OUTPUT) { + SET(_SECONDARY_OUTPUT_VALUE $OUTPUT) +} + +_AAR_PROXY_LIBRARY_CMD=$LINK_LIB && $COPY_CMD $_SECONDARY_OUTPUT_VALUE ${input;hide:_SECONDARY_OUTPUT_VALUE} ${output:REALPRJNAME.aar} + +### @usage: AAR_PROXY_LIBRARY() # internal +### +### The use of this module is strictly prohibited!!! +module AAR_PROXY_LIBRARY: _PROXY_LIBRARY { + .ALLOWED=SECONDARY_OUTPUT + .CMD=_AAR_PROXY_LIBRARY_CMD +} diff --git a/build/conf/project_specific/maps/asrc.conf b/build/conf/project_specific/maps/asrc.conf new file mode 100644 index 00000000000..c910e6abff6 --- /dev/null +++ b/build/conf/project_specific/maps/asrc.conf @@ -0,0 +1,121 @@ +_BUNDLE_DELIM_JAVA=__DELIM_JAVA__ +_BUNDLE_DELIM_RES=__DELIM_RES__ +_BUNDLE_DELIM_ASSETS=__DELIM_ASSETS__ +_BUNDLE_DELIM_AIDL=__DELIM_AIDL__ + +_BUNDLE_EXTRA_INPUTS_VALUE= +### @usage: BUNDLE_EXTRA_INPUTS(filenames...) # internal +macro BUNDLE_EXTRA_INPUTS(INPUTS...) { + SET_APPEND(_BUNDLE_EXTRA_INPUTS_VALUE $INPUTS) +} + +_BUNDLE_AIDL_SRCS_VALUE= +### @usage: BUNDLE_AIDL_SRCS(dirname filenames...) # internal +macro BUNDLE_AIDL_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_BUNDLE_AIDL_SRCS_VALUE $_BUNDLE_DELIM_AIDL $PREFIX ${pre=$PREFIX/:FILES} ${ABSOLUTE}) + BUNDLE_EXTRA_INPUTS(${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_BUNDLE_JAVA_SRCS_VALUE= +### @usage: BUNDLE_JAVA_SRCS(dirname filenames...) # internal +macro BUNDLE_JAVA_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_BUNDLE_JAVA_SRCS_VALUE $_BUNDLE_DELIM_JAVA $PREFIX ${pre=$PREFIX/:FILES} ${ABSOLUTE}) + BUNDLE_EXTRA_INPUTS(${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_BUNDLE_RES_SRCS_VALUE= +### @usage: BUNDLE_RES_SRCS(dirname filenames...) # internal +macro BUNDLE_RES_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_BUNDLE_RES_SRCS_VALUE $_BUNDLE_DELIM_RES $PREFIX ${pre=$PREFIX/:FILES} ${ABSOLUTE}) + BUNDLE_EXTRA_INPUTS(${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_BUNDLE_ASSETS_SRCS_VALUE= +### @usage: BUNDLE_ASSETS_SRCS(dirname filenames...) # internal +macro BUNDLE_ASSETS_SRCS(PREFIX, ABSOLUTE[], FILES...) { + SET_APPEND(_BUNDLE_ASSETS_SRCS_VALUE $_BUNDLE_DELIM_ASSETS $PREFIX ${pre=$PREFIX/:FILES} ${ABSOLUTE}) + BUNDLE_EXTRA_INPUTS(${pre=$PREFIX/:FILES} ${ABSOLUTE}) +} + +_BUNDLE_SRCS_VALUE=$_BUNDLE_AIDL_SRCS_VALUE $_BUNDLE_ASSETS_SRCS_VALUE $_BUNDLE_JAVA_SRCS_VALUE $_BUNDLE_RES_SRCS_VALUE + +macro _COMPILE_ASRC_IMPL(EXTRA_INPUTS...) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/link_asrc.py"} --work $BINDIR --input $_BUNDLE_SRCS_VALUE ${input;hide:EXTRA_INPUTS} --output $TARGET ${kv;hide:"p AC"} $kv;hide:"pc light-blue"} ${kv;hide:"show_out"} +} + +_COMPILE_ASRC=$_COMPILE_ASRC_IMPL($_ASRC_EXTRA_INPUTS_VALUE) + +COMPILE_ASRC_MF=$_COMPILE_ASRC && $GENERATE_MF + +### @usage: ASRC_LIBRARY() # internal +module ASRC_LIBRARY: _BASE_UNIT { + .CMD=COMPILE_ASRC_MF + .PEERDIR_POLICY=as_include + .FINAL_TARGET=no + PEERDIR_TAGS=JAVA_PROTO JAVA_IDL + MODULE_TYPE=LIBRARY + SET(MODULE_SUFFIX .asrc) + SET(DONT_RESOLVE_INCLUDES yes) + SET(NEED_PLATFORM_PEERDIRS no) + + NO_RUNTIME() +} + +macro _MOBILE_LIBRARY_PREREQUISITES_IMPL(OUTPUT, EXTRA_INPUTS...) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/link_asrc.py"} --work $BINDIR --input $_BUNDLE_SRCS_VALUE --output $OUTPUT ${kv;hide:"p AC"} ${kv;hide:"pc lite-blue"} ${kv;hide:"show_out"} +} + +macro _MOBILE_LIBRARY_PREREQUISITES_CMD(OUTPUT, EXTRA_INPUTS...) { + .CMD=${output;hide:OUTPUT} ${input;hide:EXTRA_INPUTS} ${kv;hide:"p AC"} ${kv;hide:"pc lite-blue"} ${kv;hide:"show_out"} $_MOBILE_LIBRARY_PREREQUISITES_IMPL($OUTPUT $EXTRA_INPUTS) +} + +when ($OS_ANDROID == "yes") { + LINK_MOBILE_LIB=$LINK_LIB && $_MOBILE_LIBRARY_PREREQUISITES_CMD(${BINDIR}/$MODULE_PREFIX$REALPRJNAME$MODULE_SUFFIX.asrc $_BUNDLE_EXTRA_INPUTS_VALUE) +} +otherwise { + LINK_MOBILE_LIB=$LINK_LIB +} + +### @usage: MOBILE_LIBRARY() # internal +module MOBILE_LIBRARY: LIBRARY { + .CMD=LINK_MOBILE_LIB + DISABLE(NEED_ADD_FAKE_SRC) +} + +_JSRC_PROXY_MOBILE_LIBRARY_CMDLINE=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/link_asrc.py"} --work $BINDIR --jsrcs ${ext=.jsrc;tags_in=local:PEERS} --input $_BUNDLE_SRCS_VALUE ${input;hide:EXTRA_INPUTS} --output ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.asrc:REALPRJNAME} ${kv;hide:"p AC"} ${kv;hide:"pc lite-blue"} ${kv;hide:"show_out"} + +macro _JSRC_PROXY_MOBILE_LIBRARY_CMD_IMPL(EXTRA_INPUTS...) { + .CMD=$_JSRC_PROXY_MOBILE_LIBRARY_CMDLINE +} + +JSRC_PROXY_MOBILE_LIBRARY_CMD=$LINK_LIB && $_JSRC_PROXY_MOBILE_LIBRARY_CMD_IMPL($_BUNDLE_EXTRA_INPUTS_VALUE) + +### @usage: JSRC_PROXY_MOBILE_LIBRARY() # internal +module JSRC_PROXY_MOBILE_LIBRARY: MOBILE_LIBRARY { + .CMD=JSRC_PROXY_MOBILE_LIBRARY_CMD + .PEERDIR_POLICY=as_build_from + .PROXY=yes + + SET(MODULE_TYPE LIBRARY) + DISABLE(NEED_ADD_FAKE_SRC) + + PEERDIR_TAGS=JAVA_PROTO JAVA_IDL + + SET(BIN_TMP_DIR ${BINDIR}/tmp) + + NO_UTIL() +} + +_MOBILE_DLL_PREREQUISITES_CMDLINE=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/link_asrc.py"} --work $BINDIR --asrcs ${PEERS.arcs} --input $_BUNDLE_SRCS_VALUE ${input;hide:EXTRA_INPUTS} --output ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.asrc:REALPRJNAME} ${kv;hide:"p AC"} ${kv;hide:"pc lite-blue"} ${kv;hide:"show_out"} + +macro _MOBILE_DLL_PREREQUISITES_CMD(EXTRA_INPUTS...) { + .CMD=$_MOBILE_DLL_PREREQUISITES_CMDLINE +} + +when ($OS_ANDROID == "yes") { + LINK_MOBILE_DLL=$LINK_DYN_LIB && $_MOBILE_DLL_PREREQUISITES_CMD($_BUNDLE_EXTRA_INPUTS_VALUE) +} +otherwise { + LINK_MOBILE_DLL=$LINK_DYN_LIB +} + diff --git a/build/conf/project_specific/maps/mapkit.conf b/build/conf/project_specific/maps/mapkit.conf new file mode 100644 index 00000000000..53455b2428d --- /dev/null +++ b/build/conf/project_specific/maps/mapkit.conf @@ -0,0 +1,350 @@ +MAPKIT_IDL_INCLUDES= +macro MAPKIT_ADDINCL(Dirs...) { + ADDINCL(${pre=FOR idl :Dirs}) + SET_APPEND(MAPKIT_IDL_INCLUDES $Dirs) +} + +### @usage: MAPS_IDL_ADDINCL(dirnames...) # internal +### +### Warpper for MAPKIT_ADDINCL macro which is used for mobile mapkit build +macro MAPS_IDL_ADDINCL(Dirs...) { + MAPKIT_ADDINCL($Dirs) +} + +### @usage: _MAPKITIDL_PROXY(args...) # internal +### +### Proxy macro for maps_mobile_idl plugin +macro _MAPKITIDL_PROXY(Args...) { + _PROCESS_MAPS_MOBILE_IDL($Args) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_TEXT_DEPS ${ext=idl:Args}) +} + +MAPS_IDL_FILTER= + +### @usage: MAPS_IDL_SRCS(filenames...) # internal +### +### Warpper for MAPKITIDL macro which is used for mobile mapkit build +macro MAPS_IDL_SRCS(Srcs...) { + _MAPKITIDL_PROXY($Srcs ${MAPS_IDL_FILTER}) +} + +### @usage: MAPS_IDL_GLOBAL_SRCS(filenames...) # internal +### +### Warpper for MAPKITIDL macro which is used for mobile mapkit build +macro MAPS_IDL_GLOBAL_SRCS(Srcs...) { + _MAPKITIDL_PROXY(GLOBAL_OUTPUTS $Srcs ${MAPS_IDL_FILTER}) +} + +### @usage: MAPSMOBI_SRCS(filenames...) # internal +### +### Make all source files listed as GLOBAL or not (depending on the value of +### MAPSMOBI_USE_SRCS_GLOBAL). Be careful since the value of +### MAPSMOBI_USE_SRCS_GLOBAL matters! If the value of this variable is equal to +### GLOBAL then call to MAPSMOBI_SRCS() macro behaves like call to +### GLOBAL_SRCS() macro otherwise the value of MAPSMOBI_USE_SRCS_GLOBAL is +### treated as a file name and a call to MAPSMOBI_SRCS() macro behaves like a +### call to SRCS() macro with additional argument which is the value of +### MAPSMOBI_USE_SRCS_GLOBAL variable +macro MAPSMOBI_SRCS(FILES...) { + ALL_SRCS(${MAPSMOBI_USE_SRCS_GLOBAL} $FILES) +} + +BEFORE_PEERS= +AFTER_PEERS= +when ($MAPKIT_WHOLE_ARCHIVE == "yes") { + when($OS_LINUX) { + BEFORE_PEERS += $START_WHOLE_ARCHIVE_VALUE + AFTER_PEERS += $END_WHOLE_ARCHIVE_VALUE + } + elsewhen($OS_DARWIN) { + LDFLAGS+=-Wl,-all_load + } +} + +### @usage: MAPKIT_ENABLE_WHOLE_ARCHIVE() # internal deprecated +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro MAPKIT_ENABLE_WHOLE_ARCHIVE() { + ENABLE(MAPKIT_WHOLE_ARCHIVE) +} + +### @usage: USE_IDL_CPP() +### +### This macro forces to use H_CPP_IDL (implementation library) variant of +### MAPS_IDL_LIBRARY multimodule instead of H_IDL (header only library) variant +### which is used by default +macro USE_IDL_CPP() { + SET(PEERDIR_TAGS __EMPTY__ CPP_PROTO H_CPP_IDL) +} + + +_LINK_JSRC=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/link_jsrc.py"} --input $AUTO_INPUT --output $TARGET ${kv;hide:"p JL"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} +_LINK_JSRC_MF=$_LINK_JSRC && $GENERATE_MF + +### @usage: MAPS_IDL_JSRC_LIBRARY +### +### Create .jsrc output - archive of megred .jsrc inputs +module MAPS_IDL_JSRC_LIBRARY: JSRC_LIBRARY { + .CMD=_LINK_JSRC_MF + .EXTS=.jsrc +} + +### _MAPS_IDL_LIBRARY_EPILOGUE() #internal +### +### This macro executes macros which should be invoked after all user specified macros in the ya.make file +macro _MAPS_IDL_LIBRARY_EPILOGUE() { + _GLOB(MAPKIT_IDL_FRAMEWORK_FILES ${ARCADIA_ROOT}/${MAPKIT_IDL_FRAMEWORK}/*.framework) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS $MAPKIT_IDL_FRAMEWORK_FILES) +} + +### @usage: MAPS_IDL_LIBRARY() +### +### Definition of multimodule that builds various variants of libraries. +### The particular variant is selected based on where PEERDIR to IDL_LIBRARY comes from. +### Now supported 2 variants: C++, Java +### Java version is not really a library but an archive of generated Java sources +multimodule MAPS_IDL_LIBRARY { + module H_IDL: LIBRARY { + .ALIASES=SRCS=MAPS_IDL_SRCS GLOBAL_SRCS=MAPS_IDL_GLOBAL_SRCS ADDINCL=MAPKIT_ADDINCL MAPSMOBI_SRCS=MAPS_IDL_SRCS + .EPILOGUE=_MAPS_IDL_LIBRARY_EPILOGUE + + ENABLE(H_IDL) + ENABLE(CPP_IDL) + SET(PEERDIR_TAGS H_IDL CPP_PROTO __EMPTY__) + SET(MAPS_IDL_FILTER FILTER .h) + + NO_UTIL() + + PROTO_ADDINCL(${MAPKIT_PROTO_ROOT}) + } + + module H_CPP_IDL: LIBRARY { + .ALIASES=SRCS=MAPS_IDL_SRCS GLOBAL_SRCS=MAPS_IDL_GLOBAL_SRCS ADDINCL=MAPKIT_ADDINCL MAPSMOBI_SRCS=MAPS_IDL_SRCS + .DEFAULT_NAME_GENERATOR=DirName + .PEERDIRSELF=H_IDL + .EPILOGUE=_MAPS_IDL_LIBRARY_EPILOGUE + + ENABLE(H_CPP_IDL) + ENABLE(CPP_IDL) + SET(PEERDIR_TAGS H_IDL CPP_PROTO __EMPTY__) + SET(MAPS_IDL_FILTER FILTER .cpp .m .mm .dart) + DISABLE(START_TARGET) + + NO_UTIL() + } + + module JAVA_IDL: MAPS_IDL_JSRC_LIBRARY { + .ALIASES=SRCS=MAPS_IDL_SRCS GLOBAL_SRCS=MAPS_IDL_SRCS ADDINCL=MAPKIT_ADDINCL MAPSMOBI_SRCS=MAPS_IDL_SRCS + .IGNORED=CPP_ADDINCL + .EPILOGUE=_MAPS_IDL_LIBRARY_EPILOGUE + SET(PEERDIR_TAGS JAVA_IDL JAVA_PROTO) + SET(MAPS_IDL_FILTER FILTER .java) + ENABLE(JAVA_IDL) + + PROTO_ADDINCL(${MAPKIT_PROTO_ROOT}) + } +} + +_IDL_TOOL_EXTRA_ARGS= +when ($MAPS_MOBILE_USE_STD_VARIANT == "yes") { + _IDL_TOOL_EXTRA_ARGS+=--use-std-variant +} +when ($MAPS_MOBILE_PUBLIC_API == "yes") { + _IDL_TOOL_EXTRA_ARGS+=--public +} +when ($MAPS_MOBILE_ENABLE_NAVI_SERIALIZATION == "yes") { + _IDL_TOOL_EXTRA_ARGS+=--enable-navi-serialization +} + +_IDL_TOOL_CMDLINE=$GENERATE_MF && ${cwd:ARCADIA_ROOT} ${tool:"tools/idl/bin"} --in-proto-root maps/doc/proto --base-proto-package yandex.maps.proto ${pre=--out-base-root :OUT_BASE_ROOT} ${pre=--out-android-root :OUT_ANDROID_ROOT} ${pre=--out-ios-root :OUT_IOS_ROOT} ${pre=--out-dart-root :OUT_BASE_ROOT} ${pre=--out-dart-cpp-root :OUT_BASE_ROOT} ${pre=-F :FRAMEWORK_DIRS} ${pre=-I :INCLUDES} ${_IDL_TOOL_EXTRA_ARGS} ${hide;input:IN} ${hide;output:OUT} ${hide;output;noauto:OUT_NOAUTO} ${hide;output_include:OUTPUT_INCLUDES} ${IDLS} ${kv;hide:"p ID"} ${kv;hide:"pc white"} ${hide:MAPSMOBI_FAKEID} ${hide;suf=filter_in;join=|:FILTER_IN} ${hide;suf=filter_out;join=|:FILTER_OUT} ${kv;hide:"show_out"} + +### @usage: _RUN_IDL_TOOL(...) # internal +### +### Run idl tool within non-JAVA_IDL submodule. This macro is called from _PROCESS_MAPS_MOBILE_IDL macro. +macro _RUN_IDL_TOOL(OUT_BASE_ROOT="", OUT_ANDROID_ROOT="", OUT_IOS_ROOT="", IN[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INCLUDES[], FRAMEWORK_DIRS[], IDLS[], FILTER_IN[], FILTER_OUT[]) { + .CMD=$_IDL_TOOL_CMDLINE +} + +### @usage: _RUN_IDL_TOOL(...) # internal +### +### Run idl tool within JAVA_IDL submodule. This macro is called from _PROCESS_MAPS_MOBILE_IDL macro. +macro _RUN_IDL_TOOL_JAVA(OUT_BASE_ROOT="", OUT_ANDROID_ROOT="", OUT_IOS_ROOT="", IN[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INCLUDES[], FRAMEWORK_DIRS[], IDLS[], FILTER_IN[], FILTER_OUT[]) { + .CMD=$_IDL_TOOL_CMDLINE && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --output ${output;suf=$_HASH_HELPER($IDLS).jsrc:"_"} --input $OUT_ANDROID_ROOT --exts .java +} + +### @usage: MAPSMOBI_COLLECT_ASSETS_FILES(varname [dir]) # internal +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro MAPSMOBI_COLLECT_ASSETS_FILES(VAR, DIR="") { + _GLOB($VAR ${suf=/:DIR}**/*) + RESTRICT_PATH(maps/mobile maps/automotive MSG This macro is for use in mapsmobi projects) +} + +### @usage: MAPSMOBI_COLLECT_AIDL_FILES(varname [dir]) # internal +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro MAPSMOBI_COLLECT_AIDL_FILES(VAR, DIR="") { + _GLOB($VAR ${suf=/:DIR}**/*.aidl) + RESTRICT_PATH(maps/mobile maps/automotive MSG This macro is for use in mapsmobi projects) +} + +### @usage: MAPSMOBI_COLLECT_JAVA_FILES(varname [dir]) # internal +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro MAPSMOBI_COLLECT_JAVA_FILES(VAR, DIR="") { + _GLOB($VAR ${suf=/:DIR}**/*.java) + RESTRICT_PATH(maps/mobile maps/automotive MSG This macro is for use in mapsmobi projects) +} + +### @usage: MAPSMOBI_COLLECT_JNI_LIBS_FILES(varname [dir]) # internal +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro MAPSMOBI_COLLECT_JNI_LIBS_FILES(VAR, DIR="") { + _GLOB($VAR ${suf=/:DIR}**/*.so) + RESTRICT_PATH(maps/mobile maps/automotive MSG This macro is for use in mapsmobi projects) +} + +### @usage: MAPSMOBI_COLLECT_RES_FILES(varname [dir]) # internal +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro MAPSMOBI_COLLECT_RES_FILES(VAR, DIR="") { + _GLOB($VAR ${suf=/:DIR}**/*.(xml|png)) + RESTRICT_PATH(maps/mobile maps/automotive MSG This macro is for use in mapsmobi projects) +} + +### @usage: MAPSMOBI_COLLECT_TPL_FILES(varname [dir]) # internal +### +### This macro is strictly prohibited to use outside of mapsmobi project +macro MAPSMOBI_COLLECT_TPL_FILES(VAR, DIR="") { + _GLOB($VAR ${suf=/:DIR}**/*.tpl) + RESTRICT_PATH(tools/idl MSG This macro is for use in mapsmobi projects) +} + +### @usage: MAPS_GARDEN_COLLECT_MODULE_TRAITS(varnamei dir) # internal +### +### This macro is strictly prohibited to use outside of maps/garden project +macro MAPS_GARDEN_COLLECT_MODULE_TRAITS(VAR, DIR) { + _GLOB($VAR $DIR/*/module_traits.json) + RESTRICT_PATH(maps/garden/sdk/module_traits/tests/module_traits_bundle MSG This macro is for use in maps/garden project) +} + +# mapsmobi build configuration + +MAPSMOBI_FAKEID=${FAKEID}_r9927169 +MAPSMOBI_BUILD= +YANDEX_EXPORT= +MAPSMOBI_CPP_PROTO_PLUGINS= +STATIC_STL= +EXPORT_ALL_SYMBOLS= +when ($MAPSMOBI_BUILD_HOST || $MAPSMOBI_BUILD_TARGET) { + MAPSMOBI_BUILD=yes +} +when ($MAPSMOBI_BUILD) { + CFLAGS+=-DMOBILE_BUILD ${hide:MAPSMOBI_FAKEID} + MAPKIT_BASE_PROTO_PACKAGE=yandex.maps.proto + MAPKIT_PROTO_ROOT=maps/doc/proto + MAPKIT_IDL_FRAMEWORK=maps/mobile/libs/idl_frameworks +} +when ($MAPSMOBI_BUILD_TARGET) { + ALLOCATOR=FAKE + USE_VANILLA_PROTOC=yes + PROTOBUF_LITE=yes + CPP_PROTO_PLUGINS=lite${pre=,:MAPSMOBI_CPP_PROTO_PLUGINS}: + when ($OPENSOURCE != "yes") { + SYSINCL+=build/yandex_specific/sysincl/mapsmobi.yml + } + + CFLAGS+=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DBOOST_CB_DISABLE_DEBUG -DBOOST_COROUTINES_NO_DEPRECATION_WARNING -DYANDEX_EXPORT=${YANDEX_EXPORT} +} +when ($MAPSMOBI_BUILD_TARGET && $OS_ANDROID) { + JDK_REAL_VERSION=11 + MAPSMOBI_CPP_PROTO_PLUGINS="dllexport_decl=YANDEX_EXPORT" + YANDEX_EXPORT=__attribute__((visibility(\"default\"))) + CFLAGS+=-fvisibility=hidden + + when ($MAPS_MOBILE_EXPORT_CPP_API) { + LDFLAGS+=-lc++_shared + CFLAGS+=-DZLIB_DLL + CFLAGS+=-DPROTOBUF_USE_DLLS -DLIBPROTOBUF_EXPORTS + CFLAGS+=-DPNG_IMPEXP=${YANDEX_EXPORT} + CFLAGS+=-DBOOST_ALL_DYN_LINK + CFLAGS+=-DBOOST_SYMBOL_EXPORT=${YANDEX_EXPORT} + DYNAMIC_BOOST=yes + } + otherwise { + STATIC_STL=yes + YANDEX_EXPORT= + CFLAGS+=-DBOOST_SYMBOL_EXPORT= + CFLAGS+=-DBOOST_SYMBOL_VISIBLE= + LDFLAGS+=-lc++_static -Wl,--exclude-libs,ALL -static-libstdc++ + USE_GLOBAL_CMD=no + } + + when ($EXPORT_ALL_SYMBOLS) { + CFLAGS+=-fvisibility=default + } + + when ($NO_DEBUGINFO != "yes" && $REDUCED_DEBUGINFO) { + CFLAGS+=-g1 + } + + CFLAGS+=-DANDROID -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -Wa,--noexecstack + CFLAGS+=-Qunused-arguments -Wno-unused-function -Wno-pessimizing-move -Wno-missing-field-initializers -Wno-missing-braces -Wno-unused-parameter -Wno-vexing-parse -Wno-sign-compare -Wno-deprecated-declarations + + LDFLAGS+=-lc -lm -llog -Bsymbolic -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined + + when ($BT_RELEASE || $BT_RELWITHDEBINFO) { + CFLAGS+=-fomit-frame-pointer -fvisibility-inlines-hidden -ffunction-sections -fdata-sections + LDFLAGS+=-Wl,--gc-sections -Wl,--build-id + } + + when ($ARCH_ARM7) { + CFLAGS+=-mfloat-abi=softfp + #Android clang overaligns some float types which causes NEON programs to fail on old Android versions. So we disable NEON. + #See https://github.com/android/ndk/issues/640 for more information + CFLAGS+=-mfpu=vfpv3-d16 + } + elsewhen ($ARCH_ARM64) { + } + elsewhen ($ARCH_I386) { + CFLAGS+=-fstrict-aliasing -mstackrealign -DBOOST_CONTEXT_TLS_STACK_PROTECTOR + } + elsewhen ($ARCH_X86_64) { + CFLAGS+=-fstrict-aliasing -mstackrealign -march=x86-64 -msse4.2 -mpopcnt -m64 -DBOOST_CONTEXT_TLS_STACK_PROTECTOR + } + otherwise { + PEERDIR+=__unsupported_architecture_for_android__ + } +} +when ($MAPSMOBI_BUILD_TARGET && $OS_DARWIN) { + QT_REQUIRED=yes + LDFLAGS+=-lc++ + CFLAGS+=-DBOOST_SYMBOL_EXPORT= + CFLAGS+=-DBOOST_SYMBOL_VISIBLE= +} +when ($MAPSMOBI_BUILD_TARGET && $OS_IOS) { + CFLAGS+=-DIOS -stdlib=libc++ -fvisibility=hidden + CFLAGS+=-DBOOST_SYMBOL_EXPORT= + CFLAGS+=-DBOOST_SYMBOL_VISIBLE= + when(!$MAPS_MOBILE_PUBLIC_API || $OS_IOSSIM) { + CFLAGS+=-DBUILDING_WITH_VULKAN_IOS + BUILDING_WITH_VULKAN_IOS=yes + } +} +when ($MAPSMOBI_BUILD_TARGET && $OS_LINUX) { + when ($NO_GRAPHICS != "yes") { + QT_REQUIRED=yes + OPENGL_REQUIRED=yes + } + OS_SDK=ubuntu-16 + PIC=yes + LDFLAGS+=-lstdc++ -lgcc_s + CFLAGS+=-DBOOST_SYMBOL_EXPORT= + CFLAGS+=-DBOOST_SYMBOL_VISIBLE= +} +when ($MAPSMOBI_BUILD_TARGET && $OS_YOCTO) { + QT_REQUIRED=yes + PIC=yes + CFLAGS+=-DBOOST_SYMBOL_EXPORT= + CFLAGS+=-DBOOST_SYMBOL_VISIBLE= +} diff --git a/build/conf/project_specific/maps/sproto.conf b/build/conf/project_specific/maps/sproto.conf new file mode 100644 index 00000000000..95234b5f75f --- /dev/null +++ b/build/conf/project_specific/maps/sproto.conf @@ -0,0 +1,21 @@ +### @usage: EXPORT_YMAPS_PROTO() # maps-specific +### +### Maps-specific .proto handling: IMPORT_YMAPS_PROTO() + maps protobuf namespace. +macro EXPORT_YMAPS_PROTO() { + PROTO_NAMESPACE(maps/doc/proto) +} + +macro _YMAPS_GENERATE_SPROTO_HEADER(File) { + .CMD=${cwd;rootdir;input:File} ${tool:"maps/libs/sproto/sprotoc"} -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH --sproto_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE ${input;rootrel:File} ${output;hide;norel;nopath;noext:File.sproto.h} ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} + .PEERDIR=maps/libs/sproto +} + +### @usage: YMAPS_SPROTO(ProtoFiles...) # maps-specific +### +### Maps-specific .proto handling: generate .sproto.h files using maps/libs/sproto/sprotoc. +macro YMAPS_SPROTO(FILES...) { + SET(PROTO_HEADER_EXTS .pb.h .sproto.h) + foreach (FILE : $FILES) { + [.proto]=$_YMAPS_GENERATE_SPROTO_HEADER($FILE) + } +} diff --git a/build/conf/project_specific/other.conf b/build/conf/project_specific/other.conf new file mode 100644 index 00000000000..d187e706c45 --- /dev/null +++ b/build/conf/project_specific/other.conf @@ -0,0 +1,11 @@ +# Catboost +BUILD_CATBOOST_SCRIPT=build/scripts/build_catboost.py +### @usage: BUILD_CATBOOST(cbmodel cbname) +### +### Generate catboost model and access code. +### cbmodel - CatBoost model file name (*.cmb). +### cbname - name for a variable (of NCatboostCalcer::TCatboostCalcer type) to be available in CPP code. +### CatBoost specific macro. +macro BUILD_CATBOOST(CbModel, CbName) { + .CMD=$YMAKE_PYTHON ${input:BUILD_CATBOOST_SCRIPT} build_cb_f $ARCADIA_ROOT $ARCH_TOOL ${input:CbModel} $CbName ${output;pre=cb.:CbName.cpp} ${output;hide;pre=CB_External_;suf=.rodata:CbName} ${output_include;hide:"kernel/catboost/catboost_calcer.h"} ${kv;hide:"p CB"} ${kv;hide:"pc yellow"} +} diff --git a/build/conf/project_specific/uservices.conf b/build/conf/project_specific/uservices.conf new file mode 100644 index 00000000000..5bb931744c9 --- /dev/null +++ b/build/conf/project_specific/uservices.conf @@ -0,0 +1,40 @@ +macro _MOVE(Src, OUT="", OUT_NOAUTO="", CPP_DEPS[], OUTPUT_INCLUDES[]) { + .CMD=$MOVE_FILE ${input:Src} ${output;norel:OUT} ${output;noauto;norel:OUT_NOAUTO} ${induced_deps=h+cpp;hide:CPP_DEPS} ${output_includes;hide:OUTPUT_INCLUDES} ${kv;hide:"p MV"} ${kv;hide:"pc light-cyan"} +} + +macro USRV_BUILD(FROM="Please specify generated .tar-file as FROM", DEPS_FILE="NO_DEPS", OUT_NOAUTO[], Files...) { + .CMD=${tool:"taxi/uservices/arc-gen/unpack-tar"} --source ${input:FROM} --target ${BINDIR} --suffix .usrv ${Files} ${OUT_NOAUTO} ${output;noauto;hide;suf=.usrv:OUT_NOAUTO} ${output;noauto;hide;suf=.usrv:Files} ${kv;hide:"p USB"} ${kv;hide:"pc light-cyan"} + _PROCESS_USRV_FILES(${DEPS_FILE} ${Files} OUT_NOAUTO ${OUT_NOAUTO}) +} + +macro _PROCESS_USRV_FILES(DepsFile, Files...) { + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${DepsFile}) +} + +macro _USRV_ALL_SRCS_HELPER(SUFFIX, RECURSIVE?"/**/*${SUFFIX}.(c|cc|cpp|h|hpp|hxx|make)":"/*${SUFFIX}.(c|cc|cpp|h|hpp|hxx|make)", DIRS[], EXCLUDE[]) { + _GLOB(_ALL_USRV_SOURCES ${suf=${RECURSIVE}:DIRS} EXCLUDE $EXCLUDE) + SRCS($_ALL_USRV_SOURCES) +} + + +### @usage: USRV_ALL_SRCS([RECURSIVE] [Dirs...] [EXCLUDE <globs...>]) +### +### SRCS for all C++ sources in current or given directories. +### C++ files are ones with following extensions: `.c`, `.cc`, `.cpp`, `.h`, `.hpp` and `.hxx`. +### +### If dirs are omitted the current one is used. +### +### @params: +### - `Dirs` - start directories for files lookup +### - `RECURSIVE`- makes lookup recursive with resprect to Dirs +### - `SUFFIX` - file name should end with the provided suffix +### - `EXCLUDE` - glob pattern to be excluded from results. In recursive mode use recursive pattern (`**`) to +### exclude files in subdirectories +### +### Note: Only one such macro per module is allowed +### Note: This macro is restricted to taxi/uservices +### Note: Macro is designed to reject any ya.make files in Dirs except current one +macro USRV_ALL_SRCS(RECURSIVE?"RECURSIVE":"", SUFFIX="", EXCLUDE[], Dirs...) { + RESTRICT_PATH(devtools/dummy_arcadia/models/macros/uservices taxi/uservices) + _USRV_ALL_SRCS_HELPER(${SUFFIX} ${RECURSIVE} DIRS ./${Dirs} EXCLUDE ya.make $EXCLUDE) +} diff --git a/build/conf/project_specific/yql_udf.conf b/build/conf/project_specific/yql_udf.conf new file mode 100644 index 00000000000..91ca0a33623 --- /dev/null +++ b/build/conf/project_specific/yql_udf.conf @@ -0,0 +1,247 @@ +when ($SANITIZER_TYPE || $USE_ARCADIA_PYTHON == "no" || $UDF_NO_PROBE == "yes" || $MUSL == "yes" || $TIDY == "yes") { + YQL_UDF_LINK_CMD=$LINK_DYN_LIB + YQL_UDF_LINK_PRG_CMD=$LINK_EXEC_DYN_LIB +} +otherwise { + YQL_UDF_LINK_CMD=$LINK_DYN_LIB && ${tool:"yql/tools/udf_probe"} $TARGET ${kv;hide:"p UD"} + YQL_UDF_LINK_PRG_CMD=$LINK_EXEC_DYN_LIB && ${tool:"yql/tools/udf_probe"} $TARGET ${kv;hide:"p UD"} +} + +### @usage: UDF_BASE(name [EXPORTS symlist_file] [PREFIX prefix]) #internal +### +### The base logic of all UDF extension modules (User-Defined Functions). +### Processing EXPORTS and PREFIX is the same as for DLL. +### +### https://wiki.yandex-team.ru/robot/manual/kiwi/userguide/#polzovatelskiefunkciiudftriggerykwcalc +module UDF_BASE: DLL_UNIT { + when ($MSVC != "yes" && $DARWIN != "yes") { + LDFLAGS+= -Wl,-Bsymbolic + } +} + +UDF_NO_PROBE="no" +### @usage: UDF_NO_PROBE() +### +### Disable UDF import check at build stage +macro UDF_NO_PROBE() { + ENABLE(UDF_NO_PROBE) +} + +### @usage: YQL_UDF_TEST([name]) +### +### The module to test YQL C++ UDF. +### +### Documentation: https://yql.yandex-team.ru/docs/yt/libraries/testing/ +### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/ +module YQL_UDF_TEST: PY3TEST_BIN { + PEERDIR(yql/library/udf_test) + PEERDIR(yt/python/client_lite) + + DEPENDS(yql/tools/astdiff) + DEPENDS(yql/tools/udf_resolver) + DEPENDS(yql/tools/yqlrun) + DATA(arcadia/ydb/library/yql/mount) + DATA(arcadia/yql/cfg/tests) +} + +### @usage: _ADD_YQL_UDF_DEPS() +### +### Add all needed PEERDIRs to a YQL_UDF. +### +### https://yql.yandex-team.ru/docs/yt/udf/cpp/ +macro _ADD_YQL_UDF_DEPS() { + PEERDIR(ydb/library/yql/public/udf) + PEERDIR(ydb/library/yql/public/udf/support) +} + +### @usage: _MAKE_YQL_UDF() +### +### Make module definition an YQL UDF: add all needed dependencies, properties and flags +### +### https://yql.yandex-team.ru/docs/yt/udf/cpp/ +macro _MAKE_YQL_UDF() { + _ADD_YQL_UDF_DEPS() + SET_APPEND(USER_CXXFLAGS -DBUILD_UDF) + # For Windows using declspecs + DEFAULT(YQL_UDF_EXPORT ${ARCADIA_ROOT}/ydb/library/yql/public/udf/udfs_exports.exports) + + when ($WINDOWS == "yes") { + YQL_UDF_EXPORT= + } + + SET(EXPORTS_FILE $YQL_UDF_EXPORT) +} + +### @usage: YQL_UDF_MODULE(name) +### +### The extension module for YQL with C++ UDF (User Defined Function YQL) +### +### https://yql.yandex-team.ru/docs/yt/udf/cpp/ +module YQL_UDF_MODULE: UDF_BASE { + .CMD=YQL_UDF_LINK_CMD + _MAKE_YQL_UDF() + PROVIDES(YqlServicePolicy) +} + +module _YQL_UDF_PROGRAM_BASE: SO_PROGRAM { + .CMD=YQL_UDF_LINK_PRG_CMD + _MAKE_YQL_UDF() +} + +UDF_SHARED_SEM=IGNORED + +### @usage: YQL_UDF(name) +### +### User-defined function for YQL +### +### Multimodule which is YQL_UDF_MODULE when built directly or referred by BUNDLE and DEPENDS macros. +### If used by PEERDIRs it is usual static LIBRARY with default YQL dependencies, allowing code reuse between UDFs. +### +### @see: [YQL_UDF_MODULE()](#module_YQL_UDF_MODULE) +multimodule YQL_UDF { + module YQL_UDF_SHARED: YQL_UDF_MODULE { + .SEM=UDF_SHARED_SEM + NO_CLANG_TIDY() + } + module YQL_UDF_STATIC: _DLL_COMPATIBLE_LIBRARY { + .ALIASES=SRCS=GLOBAL_SRCS + .SEM=CPP_LIBRARY_SEM + .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM + OBJ_SUF=.udfs + _ADD_YQL_UDF_DEPS() + # disable credits generation for static library + SET(CREDITS_FLAGS) + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_SUFFIX=.static.lib + } + } +} + +### @usage: YQL_ABI_VERSION(major minor release)) +### +### Specifying the supported ABI for YQL_UDF. +### +### @see: [YQL_UDF()](#multimodule_YQL_UDF) +macro YQL_ABI_VERSION(Major, Minor, Patch) { + YQL_ABI_FLAGS=-DUDF_ABI_VERSION_MAJOR=$Major -DUDF_ABI_VERSION_MINOR=$Minor -DUDF_ABI_VERSION_PATCH=$Patch + SET_APPEND(USER_CXXFLAGS $YQL_ABI_FLAGS) +} + +### @usage: YQL_LAST_ABI_VERSION() +### +### Use the last ABI for YQL_UDF +### +macro YQL_LAST_ABI_VERSION() { + YQL_ABI_FLAGS=-DUSE_CURRENT_UDF_ABI_VERSION + SET_APPEND(USER_CXXFLAGS $YQL_ABI_FLAGS) +} + +### @usage: YQL_PYTHON_UDF(name) +### +### Definition of the extension module for YQL with Python 2.x UDF (User Defined Function for YQL). +### Unlike YQL_UDF this is plain DLL module, so PEERDIRs to it are not allowed. +### +### https://yql.yandex-team.ru/docs/yt/udf/python/ +module YQL_PYTHON_UDF: YQL_UDF_MODULE { + .IGNORED=USE_PYTHON2 + .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL + + USE_PYTHON2() + _ARCADIA_PYTHON_ADDINCL() + PEERDIR(build/platform/python/ldflags) + PEERDIR(library/python/type_info) + + DEFAULT(YQL_PYTHON_UDF_EXPORT ${ARCADIA_ROOT}/yql/udfs/common/python/python_udf/python_udfs_exports.exports) + + when ($WINDOWS == "yes") { + YQL_PYTHON_UDF_EXPORT= + } + + ### FIXME: XXX the statement below uncoditionally set EXPORTS_FILE (due to incorrect behaviour of old ConfReader + ###when ($USE_ARCADIA_PYTHON == "yes") SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT) + SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT) +} + +### @usage: YQL_PYTHON_UDF_PROGRAM(name) +### +### Definition of the extension module for YQL with Python 2.x UDF (User Defined Function for YQL). +### Unlike YQL_UDF this is plain DLL module, so PEERDIRs to it are not allowed. +### +### https://yql.yandex-team.ru/docs/yt/udf/python/ +module YQL_PYTHON_UDF_PROGRAM: _YQL_UDF_PROGRAM_BASE { + .IGNORED=USE_PYTHON2 + .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL + USE_PYTHON2() + _ARCADIA_PYTHON_ADDINCL() + PEERDIR(build/platform/python/ldflags) + PEERDIR(library/python/type_info) + + DEFAULT(YQL_PYTHON_UDF_EXPORT ${ARCADIA_ROOT}/yql/udfs/common/python/python_udf/python_udfs_exports.exports) + + when ($WINDOWS == "yes") { + YQL_PYTHON_UDF_EXPORT= + } + + ### FIXME: XXX the statement below uncoditionally set EXPORTS_FILE (due to incorrect behaviour of old ConfReader + ###when ($USE_ARCADIA_PYTHON == "yes") SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT) + SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT) +} + +### @usage: YQL_PYTHON3_UDF(name) +### +### The extension module for YQL with Python 3.x UDF (User Defined Function for YQL). +### Unlike YQL_UDF this is plain DLL module, so PEERDIRs to it are not allowed. +### +### Documentation: https://yql.yandex-team.ru/docs/yt/udf/python/ +module YQL_PYTHON3_UDF: YQL_UDF_MODULE { + .RESTRICTED=PYTHON2_ADDINCL PYTHON3_ADDINCL USE_PYTHON2 USE_PYTHON3 + _ARCADIA_PYTHON3_ADDINCL() + PEERDIR(build/platform/python/ldflags) + PEERDIR(library/python/type_info) + + DEFAULT(YQL_PYTHON_UDF_EXPORT ${ARCADIA_ROOT}/yql/udfs/common/python/python_udf/python_udfs_exports.exports) + + when ($WINDOWS == "yes") { + YQL_PYTHON_UDF_EXPORT= + } + + ### FIXME: XXX the statement below uncoditionally set EXPORTS_FILE (due to incorrect behaviour of old ConfReader + ###when ($USE_ARCADIA_PYTHON == "yes") SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT) + SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT) +} + +macro _MAKE_YQL_PYTHON_UDF_TEST() { + PEERDIR(library/python/pytest) + DEPENDS(yql/tools/run_python_udf) + SETUP_PYTEST_BIN(RUNNER_BIN $(BUILD_ROOT)/yql/tools/run_python_udf/run_python_udf) +} + +### @usage: YQL_PYTHON_UDF_TEST(name) +### +### The Python test for Python YQL UDF (Python User Defined Function for YQL). The code should be a proper YQL_PYTHON_UDF. +### +### This module will basically build itself as UDF and run as test using yql/tools/run_python_udf/run_python_udf tool. +### +### Documentation: https://yql.yandex-team.ru/docs/yt/udf/python/ +### +### @example: https://a.yandex-team.ru/arc/trunk/arcadia/yql/udfs/test/simple/ya.make +### +### @see: [YQL_PYTHON_UDF()](#module_YQL_PYTHON_UDF) +module YQL_PYTHON_UDF_TEST: YQL_PYTHON_UDF { + _MAKE_YQL_PYTHON_UDF_TEST() + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) +} + +### @usage: YQL_PYTHON3_UDF_TEST(name) +### +### The Python test for Python 3.x YQL UDF (User Defined Function for YQL). The code should be a proper YQL_PYTHON3_UDF. +### +### This module will basically build itself as UDF and run as test using yql/tools/run_python_udf/run_python_udf tool. +### +### Documentation: https://yql.yandex-team.ru/docs/yt/udf/python/ +### +### @see: [YQL_PYTHON3_UDF()](#module_YQL_PYTHON3_UDF) +module YQL_PYTHON3_UDF_TEST: YQL_PYTHON3_UDF { + _MAKE_YQL_PYTHON_UDF_TEST() + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) +} diff --git a/build/conf/project_specific/yt.conf b/build/conf/project_specific/yt.conf new file mode 100644 index 00000000000..5bd292108fc --- /dev/null +++ b/build/conf/project_specific/yt.conf @@ -0,0 +1,5 @@ +macro GENERATE_YT_RECORD(Yaml, OUTPUT_INCLUDES[]) { + .CMD=${tool:"yt/yt/tools/record_codegen"} --input ${input:Yaml} --output-root $ARCADIA_BUILD_ROOT --output-cpp ${output;norel;noext;suf=.record.cpp:Yaml} ${output;hide;norel;noext;suf=.record.h:Yaml} ${pre=--output-include :OUTPUT_INCLUDES} ${output_include;hide:OUTPUT_INCLUDES} ${output_include;hide:"yt/yt/client/table_client/record_codegen_deps.h"} ${kv;hide:"p RC"} + .SEM=find_package Python3 && add_custom_command OUTPUT ${output;norel;noext;suf=.record.cpp:Yaml} ${output;norel;noext;suf=.record.h:Yaml} DEPENDS ${input:Yaml} ${input:"yt/yt/tools/record_codegen/__main__.py"} COMMAND Python3::Interpreter ${input:"yt/yt/tools/record_codegen/__main__.py"} --input ${input:Yaml} --output-root $ARCADIA_BUILD_ROOT --output-cpp ${output;norel;noext;suf=.record.cpp:Yaml} ${pre=--output-include :OUTPUT_INCLUDES} ${output;hide;norel;noext;suf=.record.h:Yaml} + PEERDIR(yt/yt/client) +} diff --git a/build/conf/rules.conf b/build/conf/rules.conf new file mode 100644 index 00000000000..8fd7167ece0 --- /dev/null +++ b/build/conf/rules.conf @@ -0,0 +1,75 @@ +when ($OPENSOURCE == "yes") { + PEERDIRS_RULES_PATH= +} +otherwise { + PEERDIRS_RULES_PATH=\ + build/rules/junk.policy \ + build/rules/go/contrib.policy \ + build/rules/go/vendor.policy \ + build/rules/base_layers.policy \ + build/rules/contrib_deprecated.policy \ + build/rules/contrib_java.policy \ + build/rules/contrib_python.policy \ + build/rules/contrib_restricted.policy \ + build/rules/contrib_deps.policy \ + build/rules/library_deps.policy \ + build/rules/library_deprecated.policy \ + build/rules/passport.policy \ + build/rules/yt.policy \ + build/rules/catboost.policy \ + build/rules/maps/maps.policy \ + build/rules/taxi.policy \ + build/rules/yp.policy \ + build/rules/alice.policy \ + build/rules/kikimr.policy \ + build/rules/market.policy \ + build/rules/yadi.policy +} + +CHECK_INTERNAL=yes +INTERNAL_EXCEPTIONS=\ + contrib \ + search/begemot/rules/internal \ + mssngr/router/lib/protos/internal \ + mssngr/router/lib/registry/method/internal \ + cv/imageproc/ocr/api/mobile_c/internal \ + kernel/ugc/security/lib/internal \ + maps/mobile/libs/mapkit/internal + +_BLACKLISTS= +when ($DISABLE_BLACKLIST == "yes" || $OPENSOURCE == "yes") { + _BLACKLISTS= +} +elsewhen ($CUSTOM_BLACKLIST != "") { + _BLACKLISTS=$CUSTOM_BLACKLIST +} +elsewhen ($AUTOCHECK == "yes" || $TEST_BLACKLIST_AUTOCHECK == "yes") { + _BLACKLISTS+=build/rules/autocheck.blacklist +} +otherwise { + _BLACKLISTS+=build/rules/local.blacklist +} + +_ISOLATED_PROJECTS= +when ($DISABLE_ISOLATED_PROJECTS == "yes" || $OPENSOURCE == "yes") { + _ISOLATED_PROJECTS= +} +elsewhen ($CUSTOM_ISOLATED_PROJECTS != "") { + _ISOLATED_PROJECTS=$CUSTOM_ISOLATED_PROJECTS +} +elsewhen ($AUTOCHECK == "yes" || $TEST_ISOLATED_PROJECTS_AUTOCHECK == "yes") { +## The block below is parsed by CI machinery to limit CI checks +## Please contact CI on any modification! Do not alter the block structure! +## - Keep one file per line with first line without file +## - Keep comments text and layout intact +## - Do not move or rename this file without CI team aggreement +## BEGIN AUTOCHECK ISOLATED PROJECTS -- DO NOT EDIT COMMENT AND KEEP THE CODE STRUCTURE! + _ISOLATED_PROJECTS=\ + build/rules/autocheck.isolated_projects \ + build/rules/taxi_backend_py3/taxi_backend_py3.isolated_projects \ + build/rules/taxi_uservices/taxi_uservices.isolated_projects +## END AUTOCHECK ISOLATED PROJECTS -- DO NOT EDIT COMMENT AND KEEP THE CODE STRUCTURE! +} +otherwise { + _ISOLATED_PROJECTS+=build/rules/local.isolated_projects +} diff --git a/build/conf/settings.conf b/build/conf/settings.conf new file mode 100644 index 00000000000..00cc3836643 --- /dev/null +++ b/build/conf/settings.conf @@ -0,0 +1,118 @@ +GLOBAL_SRCS_IN_RESULTS=yes +JSON_CACHE_IS_ATTACHED=yes +USE_ADDINCL_WITHOUT_FOR_AS_ADDINCL_FOR_C=yes +LANGS_REQUIRE_BUILD_AND_SRC_ROOTS=c asm cython proto flatc swig ydl nlg +CHECK_GO_INCORRECT_DEPS=yes +REPORT_RECURSE_NO_YAMAKE=yes +USE_PREBUILT_TOOLS=yes +RESOLVE_OUTPUT_INCLUDES_AS_INCLUDES=yes +CHKPEERS_GLOBAL_SRCS=yes +ENABLE_NODE_SELF_UID=yes +REPORT_CONFIGURE_PROGRESS=yes + +# NOTE! Only foldable vars should be listed here +_FOLDABLE_VARS=\ + CL_WRAPPER \ + END_WHOLE_ARCHIVE_VALUE \ + JDK_LATEST_VERSION \ + LD_SDK_VERSION \ + LD_STRIP_FLAG \ + LIB_WRAPPER \ + LINK_EXE_FLAGS_DEBUG \ + LINK_EXE_FLAGS_RELEASE \ + LINK_IMPLIB \ + LINK_LIB_FLAGS \ + LINK_STDLIBS \ + LINK_WRAPPER \ + LINK_WRAPPER_DYNLIB \ + ML_WRAPPER \ + START_WHOLE_ARCHIVE_VALUE \ + _CFLAGS_ARCH_I386 \ + _CFLAGS_UCRT_VC_INCLUDES \ + _COMPILER_TIME_TRACE_FLAGS \ + _COMPILER_TIME_TRACE_GRANULARITY \ + _COMPILER_TIME_TRACE_POSTPROCESS \ + _CPP_ARGS \ + _CROSS_SUFFIX \ + _CXX_DEFINES \ + _CXX_FLAGS \ + _CXX_STD \ + _C_ARGS \ + _C_CPP_KV_STYLE \ + _C_FLAGS \ + _C_FOPTIONS \ + _C_SYSTEM_LIBRARIES \ + _DEBUG_INFO_FLAGS \ + _END_GROUP \ + _EXEC_SHARED_FLAG \ + _EXE_FLAGS \ + _FLAGS_COMMON \ + _FLAGS_COMMON_DEBUG \ + _FLAGS_COMMON_IDE_MSVS \ + _FLAGS_COMMON_LIBPATHS \ + _FLAGS_DEBUG_ONLY \ + _FLAGS_DEBUG_ONLY_CLANG_CL \ + _FLAGS_DEBUG_ONLY_DEBUG \ + _FLAGS_DEBUG_RUNTIME \ + _FLAGS_IGNORE \ + _FLAGS_MACHINE \ + _FLAGS_RELEASE_ONLY \ + _FLAGS_RELEASE_ONLY_DEBUG \ + _FLAGS_RELEASE_RUNTIME \ + _LD_ARCHIVER \ + _LD_ARCH_FLAG \ + _LD_AR_PLUGIN \ + _LD_DCE_FLAG_GC_SECTIONS \ + _LD_DCE_FLAG_PRINT_SECTIONS \ + _LD_ENV_STYLE \ + _LD_FLAGS \ + _LD_ICF_FLAG \ + _LD_ICF_FLAG_PRINT_SECTIONS \ + _LD_LIB_GENERATE_MF \ + _LD_LINKER_OUTPUT\ + _LD_LINKER_OUTPUT_FLAG \ + _LD_LINK_FAT_PREFIX \ + _LD_LINK_FAT_SRCS_GLOBALS_NO_WA \ + _LD_LINK_FAT_SRCS_GLOBALS_WA \ + _LD_LINK_FAT_SUFFIX1 \ + _LD_LINK_FAT_SUFFIX2 \ + _LD_LLVM_AR_FORMAT \ + _LD_SRCS_GLOBALS \ + _LD_SYS_LIB \ + _LD_TAIL_LINK_LIB \ + _LD_THREAD_LIBRARY \ + _LD_USE_STDLIB \ + _LINKER_TIME_TRACE_FLAG \ + _LINKER_TIME_TRACE_GRANULARITY \ + _LINK_EXTRA_OUTPUT \ + _MASM_IO \ + _MSVC_ARCH \ + _MSVC_FLAGS \ + _MSVC_HEAD_LINK_LIB \ + _MSVC_SRCS_GLOBALS \ + _MSVC_TAIL_LINK_LIB \ + _MSVC_TC_KIT_LIBS \ + _MSVC_TC_VC_ROOT \ + _OPTIMIZE_RELEASE \ + _SFDL_FLAGS \ + _SHARED_FLAG \ + _SONAME_FLAG \ + _SONAME_OPTION \ + _START_GROUP \ + _STD_CXX \ + +# end of _FOLDABLE_VARS list + +_DUPSRC_IGNORE_LIST_ADS_BSYETI_SAMOGON=\ + $B/ads/bsyeti/samogon/buzzard/config/buzzard_config.py \ + $B/ads/bsyeti/samogon/caesar/config/caesar_config.py \ + $B/ads/bsyeti/samogon/caesar_resharder/config/resharder_config.py \ + $B/ads/bsyeti/samogon/eagle/config/eagle_config.py \ + $B/ads/bsyeti/samogon/eagle/datagram_receiver_config/datagram_receiver_config.py \ + $B/ads/bsyeti/samogon/eagle/lt_search_config/lt_search_config.py \ + $B/ads/bsyeti/samogon/eagle/searchpers_config/searchpers_config.py + +_DUPSRC_IGNORE_LIST=\ + $_DUPSRC_IGNORE_LIST_ADS_BSYETI_SAMOGON + +_FOLDABLE_VARS+=_DUPSRC_IGNORE_LIST_ADS_BSYETI_SAMOGON diff --git a/build/conf/sysincl.conf b/build/conf/sysincl.conf new file mode 100644 index 00000000000..6356dbd36a7 --- /dev/null +++ b/build/conf/sysincl.conf @@ -0,0 +1,74 @@ +SYSINCL= +SYSINCL+=build/sysincl/macro.yml +SYSINCL+=build/sysincl/libc-to-compat.yml +SYSINCL+=build/sysincl/libc-to-nothing.yml +SYSINCL+=build/sysincl/stl-to-nothing.yml +SYSINCL+=build/sysincl/linux.yml +SYSINCL+=build/sysincl/windows.yml +SYSINCL+=build/sysincl/darwin.yml +SYSINCL+=build/sysincl/intrinsic.yml +SYSINCL+=build/sysincl/nvidia.yml +SYSINCL+=build/sysincl/misc.yml +SYSINCL+=build/sysincl/unsorted.yml + +when ($USE_LOCAL_SWIG == "yes") { + SYSINCL+=build/sysincl/swig-to-nothing.yml +} +otherwise { + SYSINCL+=build/sysincl/swig.yml +} + +when ($USE_SYSTEM_JDK) { + SYSINCL+=build/sysincl/system-jdk.yml +} + +when ($OPENSOURCE == "yes") { + SYSINCL += build/sysincl/opensource.yml +} +otherwise { + SYSINCL+=build/yandex_specific/sysincl/speechkit.yml + SYSINCL+=build/yandex_specific/sysincl/sophos.yml + SYSINCL+=build/yandex_specific/sysincl/misc.yml + SYSINCL+=build/yandex_specific/sysincl/taxi.yml +} + +when ($MUSL == "yes") { + SYSINCL+=build/sysincl/libc-to-musl.yml + SYSINCL+=build/sysincl/linux-musl.yml +} + +when ($OS_WINDOWS == "yes") { + SYSINCL+=build/sysincl/misc-win.yml + when ($OPENSOURCE !="yes") { + SYSINCL+=build/yandex_specific/sysincl/misc-win.yml + } +} + +when ($OS_ANDROID == "yes") { + SYSINCL+=build/sysincl/android.yml +} + +when ($OS_LINUX != "yes") { + SYSINCL+=build/sysincl/linux-headers.yml +} + +when ($OS_LINUX != "yes" || $CATBOOST_OPENSOURCE == "yes") { + SYSINCL+=build/sysincl/ibdrv.yml +} + +when ($WITH_VALGRIND == "yes") { + SYSINCL+=build/sysincl/valgrind.yml +} + +when ($OS_LINUX == "yes" && $OS_SDK == "ubuntu-12") { + SYSINCL+=build/sysincl/linux-ubuntu-12.yml +} + +when ($ARCH_NDS32) { + SYSINCL+=build/sysincl/nds32.yml +} + +when ($ARCH_RISCV32) { + SYSINCL+=build/sysincl/newlib.yml + SYSINCL+=build/sysincl/esp-idf.yml +} diff --git a/build/conf/toolchains/gnu_toolchain.conf b/build/conf/toolchains/gnu_toolchain.conf new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/build/conf/toolchains/gnu_toolchain.conf diff --git a/build/conf/toolchains/msvc_toolchain.conf b/build/conf/toolchains/msvc_toolchain.conf new file mode 100644 index 00000000000..6b4d6b5c453 --- /dev/null +++ b/build/conf/toolchains/msvc_toolchain.conf @@ -0,0 +1,7 @@ +# TODO(somov): Заглушка для тех мест, где C_FLAGS_PLATFORM используется +# для любых платформ. Нужно унифицировать с GnuToolchain. +C_FLAGS_PLATFORM= + +when ($_UNDER_WINE == "yes") { + WINE_ENV=${env:"WINEPREFIX_SUFFIX=4.0"} +} diff --git a/build/conf/ts/node_modules.conf b/build/conf/ts/node_modules.conf new file mode 100644 index 00000000000..aa14b514a2d --- /dev/null +++ b/build/conf/ts/node_modules.conf @@ -0,0 +1,100 @@ +PNPM_ROOT= +PNPM_SCRIPT=$PNPM_ROOT/node_modules/pnpm/dist/pnpm.cjs +NPM_CONTRIBS_PATH=build/platform/yandex_specific/ts/contribs +NODE_MODULES_BUNDLE_AS_OUTPUT= +_NODE_MODULES_INS= +_NODE_MODULES_OUTS= + +# TOUCH_UNIT is required to create module identity file. +# we can "call" macro as `$_NODE_MODULES(...)`. in this case we will get .CMD from it. +# this is the only way to process a variable data as an array. +# ${output;hide:_NODE_MODULES_OUTS} does not produce list of paths, but a single value (space-separeted paths) +_NODE_MODULES_CMD=$TOUCH_UNIT && $_NODE_MODULES(IN $_NODE_MODULES_INS OUT $_NODE_MODULES_OUTS) + +module _NODE_MODULES_BASE: _BARE_UNIT { + .CMD=_NODE_MODULES_CMD + # ignore SRCS macro + .ALIASES=SRCS=_NOOP_MACRO + # Propagates peers to related modules + .PEERDIR_POLICY=as_build_from + .NODE_TYPE=Bundle + + # we have several modules in the same dir (.PEERDIRSELF=NODE_MODULES in BUILD) + # we need different names for module identity file + # .fake tells builder to not materialize it in results + SET(MODULE_SUFFIX .n_m.fake) + # .NODE_TYPE=Bundle is required for peers propagation, but it also affects + # how merging of pic/nopic graphs. Here we can override this merging behaviour + SET(MODULE_TYPE LIBRARY) + # define own tag + SET(MODULE_TAG NODE_MODULES) + # what modules it can PEERDIR to + SET(PEERDIR_TAGS TS NPM_CONTRIBS) + # do not include it into "results" of graph + DISABLE(START_TARGET) + + # we read package.json and erm-packages.json during configuration + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/package.json ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH) + + PEERDIR($NPM_CONTRIBS_PATH) + # PEERDIR to the right version of nodejs and pnpm + _PEERDIR_TS_RESOURCE(nodejs pnpm) + # setup toolchain vars + _SET_EXTERNAL_RESOURCES() + + # run py logic + _NODE_MODULES_CONFIGURE() +} + +# called in on_node_modules_configure +macro _SET_NODE_MODULES_INS_OUTS(IN{input}[], OUT{output}[]) { + SET(_NODE_MODULES_INS $IN) + SET(_NODE_MODULES_OUTS $OUT) +} + +macro _NODE_MODULES(IN{input}[], OUT{output}[]) { + .CMD=${cwd:BINDIR} $NOTS_TOOL create-node-modules $NOTS_TOOL_BASE_ARGS --pnpm-script $PNPM_SCRIPT --contribs $NPM_CONTRIBS_PATH ${input;hide:IN} ${output;hide:OUT} ${kv;hide:"p NOMO"} ${kv;hide:"pc magenta"} +} + + +### @usage: NPM_CONTRIBS() # internal +### +### Defines special module that provides contrib tarballs from internal npm registry. +### +### @see [FROM_NPM_LOCKFILES()](#macro_FROM_NPM_LOCKFILES) +module NPM_CONTRIBS: _BARE_UNIT { + .CMD=TOUCH_UNIT + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=no + .ALLOWED=FROM_NPM_LOCKFILES + .RESTRICTED=PEERDIR + .EXTS=_ # Ignore all files, so module is not affected by FROM_NPM output (.EXTS=* is inherited from _BARE_UNIT) + + SET(MODULE_TAG NPM_CONTRIBS) + + # .fake tells builder to not materialize it in results + SET(MODULE_SUFFIX .fake) +} + +### @usage: FROM_NPM_LOCKFILES(LOCKFILES...) # internal +### +### Defines lockfile list for `NPM_CONTRIBS` module. +### +### @see [NPM_CONTRIBS()](#module_NPM_CONTRIBS) +macro FROM_NPM_LOCKFILES(LOCKFILES...) { + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS $LOCKFILES) + # See implementation in build/plugins/nots.py + _FROM_NPM_LOCKFILES($LOCKFILES) +} + +FROM_NPM_CWD=$ARCADIA_BUILD_ROOT/$NPM_CONTRIBS_PATH +macro _FROM_NPM(NAME, VERSION, SKY_ID, INTEGRITY, INTEGRITY_ALGO, TARBALL_PATH) { + .CMD=${cwd:FROM_NPM_CWD} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_npm.py"} ${input;hide:"build/scripts/fetch_from.py"} ${input;hide:"build/scripts/sky.py"} --name $NAME --version $VERSION --sky-id $SKY_ID --integrity $INTEGRITY --integrity-algorithm $INTEGRITY_ALGO --copy-to ${output;noauto:TARBALL_PATH} ${requirements;hide:"network:full"} ${kv;hide:"p NPM"} ${kv;hide:"pc magenta"} + # we want output to be available for other modules without affecting NPM_CONTRIBS + # we need to expose it (some details in https://st.yandex-team.ru/YMAKE-34) + _EXPOSE($TARBALL_PATH) +} + +macro NODE_MODULES() { + MESSAGE(Remove NODE_MODULES()) +}
\ No newline at end of file diff --git a/build/conf/ts/ts.conf b/build/conf/ts/ts.conf new file mode 100644 index 00000000000..701761e5bd3 --- /dev/null +++ b/build/conf/ts/ts.conf @@ -0,0 +1,51 @@ +NODEJS_ROOT= +NODEJS_BIN=$NODEJS_ROOT/node + +NOTS_TOOL=${tool:"devtools/frontend_build_platform/nots/builder"} +NOTS_TOOL_BASE_ARGS=--build-root $ARCADIA_BUILD_ROOT --bindir $BINDIR --curdir $CURDIR --nodejs-bin $NODEJS_BIN +NOTS_TOOL_NODE_MODULES_BUNDLE=$BINDIR/node_modules.tar +ERM_PACKAGES_PATH=devtools/frontend_build_platform/nots/erm/erm-packages.json + +module _TS_BASE_UNIT: _BARE_UNIT { + # Propagates peers to related modules + .PEERDIR_POLICY=as_build_from + .NODE_TYPE=Bundle + # Needed for DEPENDS in tests to choose right submodule from multimodule + .FINAL_TARGET=yes + + # .NODE_TYPE=Bundle is required for peers propagation, but it also affects + # how merging of pic/nopic graphs. Here we can override this merging behaviour + SET(MODULE_TYPE LIBRARY) + # Include processor works only for TS tag + SET(MODULE_TAG TS) + # TS should peer to TS + SET(PEERDIR_TAGS TS) + # .fake tells builder to not materialize it in results + SET(MODULE_SUFFIX .ts.fake) + + # We read erm-packages.json during configuration, so we have to include it to configuration cache key + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH) + + # PEERDIR that reads required version of tool from package.json + _PEERDIR_TS_RESOURCE(nodejs pnpm typescript eslint) + # setup toolchain vars + _SET_EXTERNAL_RESOURCES() +} + + +# tag:test +ESLINT_CONFIG_PATH=.eslintrc.js +_TS_LINT_SRCS_VALUE= +### _TS_CONFIG_EPILOGUE() # internal +### +### This macro executes macros which should be invoked after all user specified macros in the ya.make file +macro _TS_CONFIG_EPILOGUE() { + _GLOB(_TS_LINT_SRCS_VALUE ${CURDIR}/**/*.(ts|tsx) EXCLUDE **/node_modules/**/*.(ts|tsx)) + _SETUP_EXTRACT_NODE_MODULES_RECIPE(${MODDIR}) +} + +@import "${CONF_ROOT}/conf/ts/node_modules.conf" +@import "${CONF_ROOT}/conf/ts/ts_bundle.conf" +@import "${CONF_ROOT}/conf/ts/ts_library.conf" +@import "${CONF_ROOT}/conf/ts/ts_next.conf" +@import "${CONF_ROOT}/conf/ts/ts_test.conf" diff --git a/build/conf/ts/ts_bundle.conf b/build/conf/ts/ts_bundle.conf new file mode 100644 index 00000000000..973b9ae40f5 --- /dev/null +++ b/build/conf/ts/ts_bundle.conf @@ -0,0 +1,46 @@ +# WEBPACK_ROOT is redefined in /build/plugins/nots.py _set_resource_vars() +WEBPACK_ROOT= +WEBPACK_CONFIG_PATH=webpack.config.js +TS_BUNDLE_WEBPACK=$TOUCH_UNIT \ + && ${cwd:BINDIR} $NOTS_TOOL bundle-webpack $NOTS_TOOL_BASE_ARGS --webpack-resource $WEBPACK_ROOT \ + --webpack-config ${input:WEBPACK_CONFIG_PATH} --ts-config ${input:TS_CONFIG_PATH} \ + --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ + ${input;hide:"./package.json"} ${TS_CONFIG_FILES} ${output;hide:"bundle.tar"} \ + ${output;hide:"package.json"} ${kv;hide:"p TSWP"} ${kv;hide:"pc magenta"} + +### @usage: TS_BUNDLE([name]) +### +### The Webpack bundle, bundles JavaScript code. +### Build results are bundle.tar (depending on local tsconfig.json settings). +### +### @example +### +### TS_BUNDLE() +### SRCS(src/index.ts) +### END() +### +multimodule TS_BUNDLE { + module BUILD: _TS_BASE_UNIT { + .CMD=TS_BUNDLE_WEBPACK + .PEERDIRSELF=NODE_MODULES + # epilogue is not inherited from TS_LIBRARY + .EPILOGUE=_TS_CONFIG_EPILOGUE + + # by default multimodule overrides inherited MODULE_TAG to submodule name (BUILD in this case) + # but we have to set it to TS for include processor to work + SET(MODULE_TAG TS) + + _PEERDIR_TS_RESOURCE(webpack) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json) + SET(TS_CONFIG_DEDUCE_OUT no) + + _TS_CONFIGURE($TS_CONFIG_PATH) + + # we should set NODE_MODULES_BUNDLE_AS_OUTPUT conditionally, + # based on whether module has deps or doesn't have + _SET_NODE_MODULES_BUNDLE_AS_OUTPUT() + } + + module NODE_MODULES: _NODE_MODULES_BASE { + } +} diff --git a/build/conf/ts/ts_library.conf b/build/conf/ts/ts_library.conf new file mode 100644 index 00000000000..10f19f06a26 --- /dev/null +++ b/build/conf/ts/ts_library.conf @@ -0,0 +1,45 @@ +# TYPESCRIPT_ROOT is redefined in /build/plugins/nots.py _set_resource_vars() +TYPESCRIPT_ROOT= +TS_CONFIG_PATH=tsconfig.json +TS_COMPILE=$TOUCH_UNIT \ + && ${cwd:BINDIR} $NOTS_TOOL compile-ts $NOTS_TOOL_BASE_ARGS --tsc-resource $TYPESCRIPT_ROOT \ + --ts-config ${input:TS_CONFIG_PATH} --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE \ + $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} ${input;hide:"./package.json"} ${TS_CONFIG_FILES} \ + ${output;hide:"package.json"} ${output;hide:TS_COMPILE_OUTPUT} ${kv;hide:"p TSC"} ${kv;hide:"pc magenta"} + +### @usage: TS_LIBRARY([name]) +### +### The TypeScript/JavaScript library module, compiles TypeScript sources to JavaScript. +### Build results are JavaScript files, typings and source mappings (depending on local tsconfig.json settings). +### +### @example +### +### TS_LIBRARY() +### SRCS(src/index.ts) +### END() +### +multimodule TS_LIBRARY { + module BUILD: _TS_BASE_UNIT { + .CMD=TS_COMPILE + .PEERDIRSELF=NODE_MODULES + # epilogue is not inherited from TS_LIBRARY + .EPILOGUE=_TS_CONFIG_EPILOGUE + + # by default multimodule overrides inherited MODULE_TAG to submodule name (BUILD in this case) + # but we have to set it to TS for include processor to work + SET(MODULE_TAG TS) + + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json) + + SET(TS_CONFIG_DEDUCE_OUT yes) + + # we should set NODE_MODULES_BUNDLE_AS_OUTPUT conditionally, + # based on whether module has deps or doesn't have + _SET_NODE_MODULES_BUNDLE_AS_OUTPUT() + + _TS_CONFIGURE($TS_CONFIG_PATH) + } + + module NODE_MODULES: _NODE_MODULES_BASE { + } +} diff --git a/build/conf/ts/ts_next.conf b/build/conf/ts/ts_next.conf new file mode 100644 index 00000000000..dd4945e1016 --- /dev/null +++ b/build/conf/ts/ts_next.conf @@ -0,0 +1,61 @@ +# NEXT_ROOT is redefined in /build/plugins/nots.py _set_resource_vars() +NEXT_ROOT= +TS_NEXT_CONFIG_PATH=next.config.js +TS_NEXT_SRC_FILES= + + +TS_NEXT_CMD=$TOUCH_UNIT \ + && ${cwd:BINDIR} $NOTS_TOOL build-nextjs $NOTS_TOOL_BASE_ARGS \ + --nextjs-resource $NEXT_ROOT \ + --nextjs-config ${input:TS_NEXT_CONFIG_PATH} --ts-config ${input:TS_CONFIG_PATH} \ + --node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \ + ${input;hide:"./package.json"} ${TS_CONFIG_FILES} ${output;hide:"bundle.tar"} \ + ${output;hide:"package.json"} ${kv;hide:"p TSNEXT"} ${kv;hide:"pc magenta"} + +### @usage: TS_NEXT() +### +### NextJS app, built with `next build`. Requires sources to be under /src folder. +### /pages and /app on the root level ar not supported. +### Build results are bundle.tar. +### +### @example +### +### TS_NEXT() +### END() +### +multimodule TS_NEXT { + module BUILD: _TS_BASE_UNIT { + .CMD=TS_NEXT_CMD + .PEERDIRSELF=NODE_MODULES + # epilogue is not inherited from TS_LIBRARY + .EPILOGUE=_TS_NEXT_EPILOG + + # by default multimodule overrides inherited MODULE_TAG to submodule name (BUILD in this case) + # but we have to set it to TS for include processor to work + SET(MODULE_TAG TS) + + _PEERDIR_TS_RESOURCE(next) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json) + SET(TS_CONFIG_DEDUCE_OUT no) + + _TS_CONFIGURE($TS_CONFIG_PATH) + + # we should set NODE_MODULES_BUNDLE_AS_OUTPUT conditionally, + # based on whether module has deps or doesn't have + _SET_NODE_MODULES_BUNDLE_AS_OUTPUT() + } + + module NODE_MODULES: _NODE_MODULES_BASE { + } +} + +macro TS_NEXT_CONFIG(Path) { + SET(TS_NEXT_CONFIG_PATH $Path) +} + +macro _TS_NEXT_EPILOG() { + _TS_CONFIG_EPILOGUE() + _GLOB(TS_NEXT_SRC_FILES ${CURDIR}/src/pages/**/* ${CURDIR}/pages/**/* ${CURDIR}/src/app/**/* ${CURDIR}/app/**/* ${CURDIR}/public/**/*) + SRCS($TS_NEXT_SRC_FILES) +} + diff --git a/build/conf/ts/ts_test.conf b/build/conf/ts/ts_test.conf new file mode 100644 index 00000000000..8c4cca245f8 --- /dev/null +++ b/build/conf/ts/ts_test.conf @@ -0,0 +1,115 @@ +TS_TEST_EXTENSION= +TS_TEST_EXTRA_SRCS_MASK= + +TS_TEST_CONFIG_PATH= +TS_TEST_FOR_MOD= +TS_TEST_NM= + +# We have to rename node_modules.tar to workspace_node_modules.tar, +# so TS_TEST_JEST module has it's own unique output. +# TS_TEST_JEST_FOR module has to output all files required for test run. +TS_TEST_JEST_CMD=$TOUCH_UNIT \ + && ${cwd:BINDIR} $MOVE_FILE ${input:TS_TEST_NM} ${output:"workspace_node_modules.tar"} \ + ${kv;hide:"p TSJEST"} ${kv;hide:"pc magenta"} + +### @usage: TS_TEST_JEST_FOR(Path) +### +### Defines testing module with jest test runner. +### +### @example +### +### TS_TEST_JEST_FOR(../) +### TS_TEST_SRCS(../src) +### TS_TEST_CONFIG(../jest.config.js) +### END() +### +module TS_TEST_JEST_FOR: _TS_TEST_BASE { + .CMD=TS_TEST_JEST_CMD + + # for multimodule peers we should choose NODE_MODULES + SET(PEERDIR_TAGS NODE_MODULES) + + # compatibility with old TS_TEST_SRCS + SET(TS_TEST_EXTENSION test.(ts|tsx|js|jsx)) + SET(TS_TEST_EXTRA_SRCS_MASK /**/__mocks__/*) + + _PEERDIR_TS_RESOURCE(nodejs pnpm jest) + _TS_TEST_FOR_CONFIGURE(jest jest.config.js) +} + +module _TS_TEST_BASE: _BARE_UNIT { + # ignore SRCS macro + .ALIASES=SRCS=_NOOP_MACRO + # use this parser to get module args in $MODULE_ARGS_RAW + .ARGS_PARSER=Raw + .NODE_TYPE=Program + + + # .fake tells builder to not materialize it in results + SET(MODULE_SUFFIX .ts_test.fake) + # include processor works only for TS tag + SET(MODULE_TAG TS) + # we read erm-packages.json during configuration, so we have to include it to configuration cache key + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH) + + # parse module args + _TS_TEST_FOR_ARGS($MODULE_ARGS_RAW) + # setup toolchain vars + _SET_EXTERNAL_RESOURCES() +} + +macro _TS_TEST_FOR_ARGS(FOR_MOD) { + SET(TS_TEST_FOR_MOD $FOR_MOD) + _SET_TS_TEST_FOR_VARS($FOR_MOD) +} + +macro _SETUP_EXTRACT_NODE_MODULES_RECIPE(FOR_PATH) { + DEPENDS(devtools/frontend_build_platform/nots/recipes/extract_node_modules) + USE_RECIPE(devtools/frontend_build_platform/nots/recipes/extract_node_modules/recipe $FOR_PATH workspace_node_modules.tar) +} + + +### @usage: TS_TEST_CONFIG(Path) +### +### Macro sets the path to configuration file of the test runner. +### +### - Path - path to the config file. +macro TS_TEST_CONFIG(Path) { + SET(TS_TEST_CONFIG_PATH $Path) +} + + +_TS_TEST_SRCS_VALUE= +_TS_TEST_EXTRA_SRCS_VALUE= +### @usage: TS_TEST_SRCS(DIRS...) +### +### Macro to define directories where the test source files should be located. +### +### - DIRS... - directories. +macro TS_TEST_SRCS(DIRS...) { + _GLOB(_TS_TEST_SRCS_VALUE ${suf=/**/*.$TS_TEST_EXTENSION:DIRS}) + SRCS($_TS_TEST_SRCS_VALUE) + + _GLOB(_TS_TEST_EXTRA_SRCS_VALUE ${suf=$TS_TEST_EXTRA_SRCS_MASK:DIRS}) + SRCS($_TS_TEST_EXTRA_SRCS_VALUE) +} + + +_TS_TEST_DATA_VALUE= +_TS_TEST_DATA_DIRS_RENAME_VALUE= +### @usage: TS_TEST_DATA([RENAME] GLOBS...) +### +### Macro to add tests data (i.e. snapshots) used in testing to a bindir from curdir. +### Creates symbolic links to directories of files found by the specified globs. +### +### Parameters: +### - RENAME - adds ability to rename paths for tests data from curdir to bindir. +### For example if your tested module located on "module" path and tests data in "module/tests_data". +### Then you can be able to rename "tests_data" folder to something else - `RENAME tests_data:example`. +### As a result in your bindir will be created folder - "module/example" which is a symbolic link on "module/tests_data" in curdir. +### It is possible to specify multiple renaming rules in the following format "dir1:dir2;dir3/foo:dir4/bar", where "dir1" and "dir3" folders in curdir. +### - GLOBS... - globs to tests data files, symbolic links will be created to their folders. For example - "tests_data/**/*". +macro TS_TEST_DATA(RENAME="", GLOBS...) { + _GLOB(_TS_TEST_DATA_VALUE $GLOBS) + SET(_TS_TEST_DATA_DIRS_RENAME_VALUE $RENAME) +}
\ No newline at end of file diff --git a/build/plugins/_common.py b/build/plugins/_common.py new file mode 100644 index 00000000000..7fc1593df0d --- /dev/null +++ b/build/plugins/_common.py @@ -0,0 +1,218 @@ +import sys +import hashlib +import base64 + + +class Result(object): + pass + + +def lazy(func): + result = Result() + + def wrapper(): + try: + return result._result + except AttributeError: + result._result = func() + + return result._result + + return wrapper + + +def pathid(path): + return base64.b32encode(hashlib.md5(path).digest()).lower().strip('=') + + +def listid(l): + return pathid(str(sorted(l))) + + +def unpair(lst): + for x, y in lst: + yield x + yield y + + +def iterpair(lst): + y = None + + for x in lst: + if y: + yield (y, x) + + y = None + else: + y = x + + +def stripext(fname): + return fname[: fname.rfind('.')] + + +def tobuilddir(fname): + if not fname: + return '$B' + if fname.startswith('$S'): + return fname.replace('$S', '$B', 1) + else: + return fname + + +def before(s, ss): + p = s.find(ss) + + if p == -1: + return s + + return s[:p] + + +def sort_by_keywords(keywords, args): + flat = [] + res = {} + + cur_key = None + limit = -1 + for arg in args: + if arg in keywords: + limit = keywords[arg] + if limit == 0: + res[arg] = True + cur_key = None + limit = -1 + else: + cur_key = arg + continue + if limit == 0: + cur_key = None + limit = -1 + if cur_key: + if cur_key in res: + res[cur_key].append(arg) + else: + res[cur_key] = [arg] + limit -= 1 + else: + flat.append(arg) + return (flat, res) + + +def get_norm_unit_path(unit, extra=None): + path = strip_roots(unit.path()) + if extra: + return '{}/{}'.format(path, extra) + return path + + +def resolve_common_const(path): + if path.startswith('${ARCADIA_ROOT}'): + return path.replace('${ARCADIA_ROOT}', '$S', 1) + if path.startswith('${ARCADIA_BUILD_ROOT}'): + return path.replace('${ARCADIA_BUILD_ROOT}', '$B', 1) + return path + + +def resolve_to_abs_path(path, source_root, build_root): + if path.startswith('$S') and source_root is not None: + return path.replace('$S', source_root, 1) + if path.startswith('$B') and build_root is not None: + return path.replace('$B', build_root, 1) + return path + + +def resolve_to_ymake_path(path): + return resolve_to_abs_path(path, '${ARCADIA_ROOT}', '${ARCADIA_BUILD_ROOT}') + + +def join_intl_paths(*args): + return '/'.join(args) + + +def get(fun, num): + return fun()[num][0] + + +def make_tuples(arg_list): + def tpl(): + for x in arg_list: + yield (x, []) + + return list(tpl()) + + +def resolve_includes(unit, src, paths): + return unit.resolve_include([src] + paths) if paths else [] + + +def rootrel_arc_src(src, unit): + if src.startswith('${ARCADIA_ROOT}/'): + return src[16:] + + if src.startswith('${ARCADIA_BUILD_ROOT}/'): + return src[22:] + + elif src.startswith('${CURDIR}/'): + return unit.path()[3:] + '/' + src[10:] + + else: + resolved = unit.resolve_arc_path(src) + + if resolved.startswith('$S/'): + return resolved[3:] + + return src # leave as is + + +def skip_build_root(x): + if x.startswith('${ARCADIA_BUILD_ROOT}'): + return x[len('${ARCADIA_BUILD_ROOT}') :].lstrip('/') + + return x + + +def get_interpreter_path(): + interpreter_path = [sys.executable] + if 'ymake' in interpreter_path[0]: + interpreter_path.append('--python') + return interpreter_path + + +def filter_out_by_keyword(test_data, keyword): + def _iterate(): + i = 0 + while i < len(test_data): + if test_data[i] == keyword: + i += 2 + else: + yield test_data[i] + i += 1 + + return list(_iterate()) + + +def generate_chunks(lst, chunk_size): + for i in xrange(0, len(lst), chunk_size): + yield lst[i : (i + chunk_size)] + + +def strip_roots(path): + for prefix in ["$B/", "$S/"]: + if path.startswith(prefix): + return path[len(prefix) :] + return path + + +def to_yesno(x): + return "yes" if x else "no" + + +def get_no_lint_value(unit): + import ymake + + supported_no_lint_values = ('none', 'none_internal', 'ktlint') + no_lint_value = unit.get('_NO_LINT_VALUE') + if no_lint_value and no_lint_value not in supported_no_lint_values: + ymake.report_configure_error('Unsupported value for NO_LINT macro: {}'.format(no_lint_value)) + return no_lint_value diff --git a/build/plugins/_requirements.py b/build/plugins/_requirements.py new file mode 100644 index 00000000000..40c50f87915 --- /dev/null +++ b/build/plugins/_requirements.py @@ -0,0 +1,176 @@ +import lib.test_const as consts +import re +import lib._metric_resolvers as mr + +CANON_SB_VAULT_REGEX = re.compile(r"\w+=(value|file):[-\w]+:\w+") +CANON_YAV_REGEX = re.compile(r"\w+=(value|file):sec-[a-z0-9]+:\w+") +VALID_DNS_REQUIREMENTS = ("default", "local", "dns64") +VALID_NETWORK_REQUIREMENTS = ("full", "restricted") + + +def check_cpu(suite_cpu_requirements, test_size, is_kvm=False): + min_cpu_requirements = consts.TestRequirementsConstants.MinCpu + max_cpu_requirements = consts.TestSize.get_max_requirements(test_size).get(consts.TestRequirements.Cpu) + if isinstance(suite_cpu_requirements, str): + if all( + consts.TestRequirementsConstants.is_all_cpu(req) for req in (max_cpu_requirements, suite_cpu_requirements) + ): + return None + return "Wrong 'cpu' requirements: {}, should be in [{}..{}] for {}-size tests".format( + suite_cpu_requirements, min_cpu_requirements, max_cpu_requirements, test_size + ) + + if not isinstance(suite_cpu_requirements, int): + return "Wrong 'cpu' requirements: {}, should be integer".format(suite_cpu_requirements) + + if ( + suite_cpu_requirements < min_cpu_requirements + or suite_cpu_requirements > consts.TestRequirementsConstants.get_cpu_value(max_cpu_requirements) + ): + return "Wrong 'cpu' requirement: {}, should be in [{}..{}] for {}-size tests".format( + suite_cpu_requirements, min_cpu_requirements, max_cpu_requirements, test_size + ) + + return None + + +# TODO: Remove is_kvm param when there will be guarantees on RAM +def check_ram(suite_ram_requirements, test_size, is_kvm=False): + if not isinstance(suite_ram_requirements, int): + return "Wrong 'ram' requirements: {}, should be integer".format(suite_ram_requirements) + min_ram_requirements = consts.TestRequirementsConstants.MinRam + max_ram_requirements = ( + consts.MAX_RAM_REQUIREMENTS_FOR_KVM + if is_kvm + else consts.TestSize.get_max_requirements(test_size).get(consts.TestRequirements.Ram) + ) + if suite_ram_requirements < min_ram_requirements or suite_ram_requirements > max_ram_requirements: + err_msg = "Wrong 'ram' requirements: {}, should be in [{}..{}] for {}-size tests".format( + suite_ram_requirements, min_ram_requirements, max_ram_requirements, test_size + ) + if is_kvm: + err_msg += ' with kvm requirements' + return err_msg + return None + + +def check_ram_disk(suite_ram_disk, test_size, is_kvm=False): + min_ram_disk = consts.TestRequirementsConstants.MinRamDisk + max_ram_disk = consts.TestSize.get_max_requirements(test_size).get(consts.TestRequirements.RamDisk) + if isinstance(suite_ram_disk, str): + if all(consts.TestRequirementsConstants.is_all_ram_disk(req) for req in (max_ram_disk, suite_ram_disk)): + return None + return "Wrong 'ram_disk' requirements: {}, should be in [{}..{}] for {}-size tests".format( + suite_ram_disk, 0, max_ram_disk, test_size + ) + + if not isinstance(suite_ram_disk, int): + return "Wrong 'ram_disk' requirements: {}, should be integer".format(suite_ram_disk) + + if suite_ram_disk < min_ram_disk or suite_ram_disk > consts.TestRequirementsConstants.get_ram_disk_value( + max_ram_disk + ): + return "Wrong 'ram_disk' requirement: {}, should be in [{}..{}] for {}-size tests".format( + suite_ram_disk, min_ram_disk, max_ram_disk, test_size + ) + + return None + + +def validate_sb_vault(name, value): + if not CANON_SB_VAULT_REGEX.match(value): + return "sb_vault value '{}' should follow pattern <ENV_NAME>=<value|file>:<owner>:<vault key>".format(value) + + +def validate_yav_vault(name, value): + if not CANON_YAV_REGEX.match(value): + return "yav value '{}' should follow pattern <ENV_NAME>=<value|file>:<sec-id>:<key>".format(value) + + +def validate_numerical_requirement(name, value): + if mr.resolve_value(value) is None: + return "Cannot convert [[imp]]{}[[rst]] to the proper [[imp]]{}[[rst]] requirement value".format(value, name) + + +def validate_choice_requirement(name, val, valid): + if val not in valid: + return "Unknown [[imp]]{}[[rst]] requirement: [[imp]]{}[[rst]], choose from [[imp]]{}[[rst]]".format( + name, val, ", ".join(valid) + ) + + +def validate_force_sandbox_requirement( + name, value, test_size, is_force_sandbox, in_autocheck, is_fuzzing, is_kvm, is_ytexec_run, check_func +): + if is_force_sandbox or not in_autocheck or is_fuzzing or is_ytexec_run: + if value == 'all': + return + return validate_numerical_requirement(name, value) + error_msg = validate_numerical_requirement(name, value) + if error_msg: + return error_msg + return check_func(mr.resolve_value(value), test_size, is_kvm) + + +def validate_ram_disk_requirement( + name, value, test_size, is_force_sandbox, in_autocheck, is_fuzzing, is_kvm, is_ytexec_run, ram +): + error_msg = validate_force_sandbox_requirement( + name, value, test_size, is_force_sandbox, in_autocheck, is_fuzzing, is_kvm, is_ytexec_run, check_ram_disk + ) + if error_msg: + return error_msg + if is_force_sandbox or not in_autocheck or test_size == consts.TestSize.Large: + return + if int(value) > int(ram): + return "Wrong 'ram_disk' value, 'ram_disk':{} should be no more than 'ram':{}".format(value, ram) + return None + + +# TODO: Remove is_kvm param when there will be guarantees on RAM +def validate_requirement( + req_name, value, test_size, is_force_sandbox, in_autocheck, is_fuzzing, is_kvm, is_ytexec_run, requirements +): + req_checks = { + 'container': validate_numerical_requirement, + 'cpu': lambda n, v: validate_force_sandbox_requirement( + n, v, test_size, is_force_sandbox, in_autocheck, is_fuzzing, is_kvm, is_ytexec_run, check_cpu + ), + 'disk_usage': validate_numerical_requirement, + 'dns': lambda n, v: validate_choice_requirement(n, v, VALID_DNS_REQUIREMENTS), + 'kvm': None, + 'network': lambda n, v: validate_choice_requirement(n, v, VALID_NETWORK_REQUIREMENTS), + 'ram': lambda n, v: validate_force_sandbox_requirement( + n, v, test_size, is_force_sandbox, in_autocheck, is_fuzzing, is_kvm, is_ytexec_run, check_ram + ), + 'ram_disk': lambda n, v: validate_ram_disk_requirement( + n, + v, + test_size, + is_force_sandbox, + in_autocheck, + is_fuzzing, + is_kvm, + is_ytexec_run, + requirements.get( + 'ram', consts.TestSize.get_default_requirements(test_size).get(consts.TestRequirements.Ram) + ), + ), + 'sb': None, + 'sb_vault': validate_sb_vault, + 'yav': validate_yav_vault, + } + + if req_name not in req_checks: + return "Unknown requirement: [[imp]]{}[[rst]], choose from [[imp]]{}[[rst]]".format( + req_name, ", ".join(sorted(req_checks)) + ) + + if req_name in ('container', 'disk') and not is_force_sandbox: + return "Only [[imp]]LARGE[[rst]] tests without [[imp]]ya:force_distbuild[[rst]] tag can have [[imp]]{}[[rst]] requirement".format( + req_name + ) + + check_func = req_checks[req_name] + if check_func: + return check_func(req_name, value) diff --git a/build/plugins/_xsyn_includes.py b/build/plugins/_xsyn_includes.py new file mode 100644 index 00000000000..d458679da01 --- /dev/null +++ b/build/plugins/_xsyn_includes.py @@ -0,0 +1,62 @@ +def get_include_callback(): + """ + .. function: get_include_callback returns function that processes each DOM element to get xsyn include from it, and it's aware of directory with all the xsyns. + + :param xsyn_dir directory with xsyns. + """ + + def get_include(element): + """ + .. function: get_include returns list of includes from this DOM element. + + :param element DOM element. + """ + res = [] + if element.nodeType == element.ELEMENT_NODE and element.nodeName == "parse:include": + attrs = element.attributes + for i in xrange(attrs.length): + attr = attrs.item(i) + if attr.nodeName == "path": + include_filename = attr.nodeValue + res.append(include_filename) + return res + + return get_include + + +def traverse_xsyn(element, on_element): + """ + .. function: traverse_xsyn traverses element and returns concatenated lists of calling on_element of each element. + + :param element element in DOM. + :param on_element callback on element that returns list of values. + """ + res = on_element(element) + for child in element.childNodes: + child_results = traverse_xsyn(child, on_element) + res += child_results + return res + + +def process_xsyn(filepath, on_element): + """ + .. function: process_xsyn processes xsyn file and return concatenated list of calling on_element on each DOM element. + + :param filepath path to xsyn file + :param on_element callback called on each element in xsyn that returns list of values. + + """ + + # keep a stack of filepathes if on_element calls process_xsyn recursively + with open(filepath) as xsyn_file: + from xml.dom.minidom import parse + + tree = parse(xsyn_file) + tree.normalize() + res = traverse_xsyn(tree, on_element) + return res + + +def get_all_includes(filepath): + callback = get_include_callback() + return process_xsyn(filepath, callback) diff --git a/build/plugins/build_mn_files.py b/build/plugins/build_mn_files.py new file mode 100644 index 00000000000..4da76f18528 --- /dev/null +++ b/build/plugins/build_mn_files.py @@ -0,0 +1,29 @@ +from os.path import basename, splitext + + +def on_build_mns_files(unit, *args): + files = [] + name = '' + ranking_suffix = '' + check = '' + index = 0 + fml_unused_tool = '' + while index < len(args): + if args[index] == 'NAME': + index += 1 + name = args[index] + elif args[index] == 'RANKING_SUFFIX': + index += 1 + ranking_suffix = args[index] + elif args[index] == 'CHECK': + check = 'CHECK' + fml_unused_tool = unit.get('FML_UNUSED_TOOL') or '$FML_UNUSED_TOOL' + else: + files.append(args[index]) + index += 1 + + for filename in files: + file_basename, _ = splitext(basename(filename)) + asmdataname = "staticMn{0}{1}Ptr".format(ranking_suffix, file_basename) + output_name = 'mn.staticMn{0}{1}Ptr.cpp'.format(ranking_suffix, file_basename) + unit.on_build_mns_file([filename, name, output_name, ranking_suffix, check, fml_unused_tool, asmdataname]) diff --git a/build/plugins/bundle.py b/build/plugins/bundle.py new file mode 100644 index 00000000000..69e3e016812 --- /dev/null +++ b/build/plugins/bundle.py @@ -0,0 +1,22 @@ +import os + + +def onbundle(unit, *args): + """ + @usage BUNDLE(<Dir [NAME Name]>...) + + Brings build artefact from module Dir under optional Name to the current module (e.g. UNION) + If NAME is not specified, the name of the Dir's build artefact will be preserved + It makes little sense to specify BUNDLE on non-final targets and so this may stop working without prior notice. + Bundle on multimodule will select final target among multimodule variants and will fail if there are none or more than one. + """ + i = 0 + while i < len(args): + if i + 2 < len(args) and args[i + 1] == "NAME": + target, name = args[i], args[i + 2] + i += 3 + else: + target, name = args[i], os.path.basename(args[i]) + i += 1 + + unit.on_bundle_target([target, name]) diff --git a/build/plugins/code_generator.py b/build/plugins/code_generator.py new file mode 100644 index 00000000000..396c2706d80 --- /dev/null +++ b/build/plugins/code_generator.py @@ -0,0 +1,45 @@ +import re +import os + +import ymake + +pattern = re.compile( + r"#include\s*[<\"](?P<INDUCED>[^>\"]+)[>\"]|(?:@|{@)\s*(?:import|include|from)\s*[\"'](?P<INCLUDE>[^\"']+)[\"']" +) + + +class CodeGeneratorTemplateParser(object): + def __init__(self, path, unit): + self._path = path + retargeted = os.path.join(unit.path(), os.path.relpath(path, unit.resolve(unit.path()))) + with open(path, 'rb') as f: + includes, induced = CodeGeneratorTemplateParser.parse_includes(f.readlines()) + self._includes = unit.resolve_include([retargeted] + includes) if includes else [] + self._induced = unit.resolve_include([retargeted] + induced) if induced else [] + + @staticmethod + def parse_includes(lines): + includes = [] + induced = [] + + for line in lines: + for match in pattern.finditer(line): + type = match.lastgroup + if type == 'INCLUDE': + includes.append(match.group(type)) + elif type == 'INDUCED': + induced.append(match.group(type)) + else: + raise Exception("Unexpected match! Perhaps it is a result of an error in pattern.") + return (includes, induced) + + def includes(self): + return self._includes + + def induced_deps(self): + return {'h+cpp': self._induced} + + +def init(): + ymake.addparser('markettemplate', CodeGeneratorTemplateParser) + ymake.addparser('macro', CodeGeneratorTemplateParser) diff --git a/build/plugins/container_layers.py b/build/plugins/container_layers.py new file mode 100644 index 00000000000..5fa15304744 --- /dev/null +++ b/build/plugins/container_layers.py @@ -0,0 +1,9 @@ +from _common import rootrel_arc_src + + +def oncheck_allowed_path(unit, *args): + module_path = rootrel_arc_src(unit.path(), unit) + if not (module_path.startswith("junk") or module_path.startswith("base_layers")): + unit.message( + ["error", "Cannot create container layer in this directory. See https://st.yandex-team.ru/DTCC-1123"] + ) diff --git a/build/plugins/coverage.py b/build/plugins/coverage.py new file mode 100644 index 00000000000..64e3bda9123 --- /dev/null +++ b/build/plugins/coverage.py @@ -0,0 +1,67 @@ +import re + +import _common +import lib.test_const as consts + + +def get_coverage_filter_regexp(pattern, cache={}): + return cache[pattern] if pattern in cache else cache.setdefault(pattern, re.compile(pattern)) + + +def should_be_covered(unit, filters): + if unit.get("FORCE_COVERAGE_DISABLED") == "yes": + return False + if unit.get("FORCE_COVERAGE_ENABLED") == "yes": + return True + unit_path = _common.get_norm_unit_path(unit) + return not any(pred(unit_path) for pred in filters) + + +def get_cpp_coverage_filters(unit, filters=[]): + # don`t calculate filters if it already was calculated + if filters: + return filters + + coverage_target_regexp = unit.get("COVERAGE_TARGET_REGEXP") or None + coverage_exclude_regexp = unit.get("COVERAGE_EXCLUDE_REGEXP") or None + if coverage_target_regexp: + cov_re = get_coverage_filter_regexp(coverage_target_regexp) + filters.append(lambda x: re.match(cov_re, x) is None) + if coverage_exclude_regexp: + cov_exclude_re = get_coverage_filter_regexp(coverage_exclude_regexp) + filters.append(lambda x: re.match(cov_exclude_re, x) is not None) + if unit.get("ENABLE_CONTRIB_COVERAGE") != "yes": + paths_to_exclude = ("contrib",) + filters.append(lambda x: x.startswith(paths_to_exclude)) + return filters + + +def add_cpp_coverage_ldflags(unit): + ldflags = unit.get("LDFLAGS") + changed = False + for flag in consts.COVERAGE_LDFLAGS: + if flag not in ldflags: + ldflags = ldflags + ' ' + flag + changed = True + if changed: + unit.set(["LDFLAGS", ldflags]) + + +def add_cpp_coverage_cflags(unit): + cflags = unit.get("CFLAGS") + changed = False + for flag in consts.COVERAGE_CFLAGS: + if flag not in cflags: + cflags = cflags + ' ' + flag + changed = True + if changed: + unit.set(["CFLAGS", cflags]) + + +def onset_cpp_coverage_flags(unit): + if unit.get("CLANG_COVERAGE") == "no": + return + filters = get_cpp_coverage_filters(unit) + if should_be_covered(unit, filters): + add_cpp_coverage_cflags(unit) + add_cpp_coverage_ldflags(unit) diff --git a/build/plugins/cp.py b/build/plugins/cp.py new file mode 100644 index 00000000000..5c663a3bdd9 --- /dev/null +++ b/build/plugins/cp.py @@ -0,0 +1,30 @@ +import os + +from _common import sort_by_keywords + + +def oncopy(unit, *args): + keywords = {'RESULT': 1, 'KEEP_DIR_STRUCT': 0, 'DESTINATION': 1, 'FROM': 1} + + flat_args, spec_args = sort_by_keywords(keywords, args) + + dest_dir = spec_args['DESTINATION'][0] if 'DESTINATION' in spec_args else '' + from_dir = spec_args['FROM'][0] if 'FROM' in spec_args else '' + keep_struct = 'KEEP_DIR_STRUCT' in spec_args + save_in_var = 'RESULT' in spec_args + targets = [] + + for source in flat_args: + rel_path = '' + path_list = source.split(os.sep) + filename = path_list[-1] + if keep_struct: + if path_list[:-1]: + rel_path = os.path.join(*path_list[:-1]) + source_path = os.path.join(from_dir, rel_path, filename) + target_path = os.path.join(dest_dir, rel_path, filename) + if save_in_var: + targets.append(target_path) + unit.oncopy_file([source_path, target_path]) + if save_in_var: + unit.set([spec_args["RESULT"][0], " ".join(targets)]) diff --git a/build/plugins/cpp_style.py b/build/plugins/cpp_style.py new file mode 100644 index 00000000000..6d59a1f0d48 --- /dev/null +++ b/build/plugins/cpp_style.py @@ -0,0 +1,19 @@ +import os + +from _common import sort_by_keywords + + +def on_style(unit, *args): + def it(): + yield 'DONT_PARSE' + + for f in args: + f = f[len('${ARCADIA_ROOT}') + 1 :] + + if '/generated/' in f: + continue + + yield f + yield '/cpp_style/files/' + f + + unit.onresource(list(it())) diff --git a/build/plugins/create_init_py.py b/build/plugins/create_init_py.py new file mode 100644 index 00000000000..c5fc119fc97 --- /dev/null +++ b/build/plugins/create_init_py.py @@ -0,0 +1,14 @@ +import os + +from _common import sort_by_keywords + + +def oncreate_init_py_structure(unit, *args): + if unit.get('DISTBUILD') or unit.get('AUTOCHECK'): + return + target_dir = unit.get('PY_PROTOS_FOR_DIR') + path_list = target_dir.split(os.path.sep)[1:] + inits = [os.path.join("${ARCADIA_BUILD_ROOT}", '__init__.py')] + for i in range(1, len(path_list) + 1): + inits.append(os.path.join("${ARCADIA_BUILD_ROOT}", os.path.join(*path_list[0:i]), '__init__.py')) + unit.ontouch(inits) diff --git a/build/plugins/credits.py b/build/plugins/credits.py new file mode 100644 index 00000000000..4b315186971 --- /dev/null +++ b/build/plugins/credits.py @@ -0,0 +1,23 @@ +from _common import rootrel_arc_src + + +def oncredits_disclaimer(unit, *args): + if unit.get('WITH_CREDITS'): + unit.message(["warn", "CREDITS WARNING: {}".format(' '.join(args))]) + + +def oncheck_contrib_credits(unit, *args): + module_path = rootrel_arc_src(unit.path(), unit) + excepts = set() + if 'EXCEPT' in args: + args = list(args) + except_pos = args.index('EXCEPT') + excepts = set(args[except_pos + 1 :]) + args = args[:except_pos] + for arg in args: + if module_path.startswith(arg) and not unit.get('CREDITS_TEXTS_FILE') and not unit.get('NO_CREDITS_TEXTS_FILE'): + for ex in excepts: + if module_path.startswith(ex): + break + else: + unit.message(["error", "License texts not found. See https://st.yandex-team.ru/DTCC-324"]) diff --git a/build/plugins/docs.py b/build/plugins/docs.py new file mode 100644 index 00000000000..92371a4c4fb --- /dev/null +++ b/build/plugins/docs.py @@ -0,0 +1,53 @@ +import json + + +def extract_macro_calls(unit, macro_value_name): + if not unit.get(macro_value_name): + return [] + + return filter(None, unit.get(macro_value_name).replace('$' + macro_value_name, '').split()) + + +def macro_calls_to_dict(unit, calls): + def split_args(arg): + if arg is None: + return None + + kv = filter(None, arg.split('=')) + if len(kv) != 2: + unit.message( + [ + 'error', + 'Invalid variables specification "{}": value expected to be in form %name%=%value% (with no spaces)'.format( + arg + ), + ] + ) + return None + + return kv + + return dict(filter(None, map(split_args, calls))) + + +def get_variables(unit): + orig_variables = macro_calls_to_dict(unit, extract_macro_calls(unit, '_DOCS_VARS_VALUE')) + return {k: unit.get(k) or v for k, v in orig_variables.items()} + + +def onprocess_docs(unit, *args): + if unit.enabled('_DOCS_USE_PLANTUML'): + unit.on_docs_yfm_use_plantuml([]) + + if unit.get('_DOCS_DIR_VALUE') == '': + unit.on_yfm_docs_dir([unit.get('_YFM_DOCS_DIR_DEFAULT_VALUE')]) + + variables = get_variables(unit) + if variables: + unit.set(['_DOCS_VARS_FLAG', '--vars {}'.format(json.dumps(json.dumps(variables, sort_keys=True)))]) + + +def onprocess_mkdocs(unit, *args): + variables = get_variables(unit) + if variables: + unit.set(['_DOCS_VARS_FLAG', ' '.join(['--var {}={}'.format(k, v) for k, v in variables.items()])]) diff --git a/build/plugins/files.py b/build/plugins/files.py new file mode 100644 index 00000000000..78a6fe6169d --- /dev/null +++ b/build/plugins/files.py @@ -0,0 +1,5 @@ +def onfiles(unit, *args): + args = list(args) + for arg in args: + if not arg.startswith('${ARCADIA_BUILD_ROOT}'): + unit.oncopy_file([arg, arg]) diff --git a/build/plugins/gobuild.py b/build/plugins/gobuild.py new file mode 100644 index 00000000000..39c4b032420 --- /dev/null +++ b/build/plugins/gobuild.py @@ -0,0 +1,320 @@ +import base64 +import itertools +import md5 +import os +from _common import rootrel_arc_src, tobuilddir +import ymake + + +runtime_cgo_path = os.path.join('runtime', 'cgo') +runtime_msan_path = os.path.join('runtime', 'msan') +runtime_race_path = os.path.join('runtime', 'race') +arc_project_prefix = 'a.yandex-team.ru/' +import_runtime_cgo_false = { + 'norace': (runtime_cgo_path, runtime_msan_path, runtime_race_path), + 'race': (runtime_cgo_path, runtime_msan_path), +} +import_syscall_false = { + 'norace': (runtime_cgo_path), + 'race': (runtime_cgo_path, runtime_race_path), +} + + +def get_import_path(unit): + # std_lib_prefix = unit.get('GO_STD_LIB_PREFIX') + # unit.get() doesn't evalutate the value of variable, so the line above doesn't really work + std_lib_prefix = unit.get('GOSTD') + '/' + arc_project_prefix = unit.get('GO_ARCADIA_PROJECT_PREFIX') + vendor_prefix = unit.get('GO_CONTRIB_PROJECT_PREFIX') + + module_path = rootrel_arc_src(unit.path(), unit) + assert len(module_path) > 0 + import_path = module_path.replace('\\', '/') + if import_path.startswith(std_lib_prefix): + import_path = import_path[len(std_lib_prefix) :] + elif import_path.startswith(vendor_prefix): + import_path = import_path[len(vendor_prefix) :] + else: + import_path = arc_project_prefix + import_path + assert len(import_path) > 0 + return import_path + + +def get_appended_values(unit, key): + value = [] + raw_value = unit.get(key) + if raw_value: + value = filter(lambda x: len(x) > 0, raw_value.split(' ')) + assert len(value) == 0 or value[0] == '$' + key + return value[1:] if len(value) > 0 else value + + +def compare_versions(version1, version2): + def last_index(version): + index = version.find('beta') + return len(version) if index < 0 else index + + v1 = tuple(x.zfill(8) for x in version1[: last_index(version1)].split('.')) + v2 = tuple(x.zfill(8) for x in version2[: last_index(version2)].split('.')) + if v1 == v2: + return 0 + return 1 if v1 < v2 else -1 + + +def need_compiling_runtime(import_path, gostd_version): + return ( + import_path in ('runtime', 'reflect', 'syscall') + or import_path.startswith('runtime/internal/') + or compare_versions('1.17', gostd_version) >= 0 + and import_path == 'internal/bytealg' + ) + + +def go_package_name(unit): + name = unit.get('GO_PACKAGE_VALUE') + if not name: + name = unit.get('GO_TEST_IMPORT_PATH') + if name: + name = os.path.basename(os.path.normpath(name)) + elif unit.get('MODULE_TYPE') == 'PROGRAM': + name = 'main' + else: + name = unit.get('REALPRJNAME') + return name + + +def need_lint(path): + return not path.startswith('$S/vendor/') and not path.startswith('$S/contrib/') + + +def on_go_process_srcs(unit): + """ + _GO_PROCESS_SRCS() macro processes only 'CGO' files. All remaining *.go files + and other input files are currently processed by a link command of the + GO module (GO_LIBRARY, GO_PROGRAM) + """ + + srcs_files = get_appended_values(unit, '_GO_SRCS_VALUE') + + asm_files = [] + c_files = [] + cxx_files = [] + ev_files = [] + fbs_files = [] + go_files = [] + in_files = [] + proto_files = [] + s_files = [] + syso_files = [] + + classifed_files = { + '.c': c_files, + '.cc': cxx_files, + '.cpp': cxx_files, + '.cxx': cxx_files, + '.ev': ev_files, + '.fbs': fbs_files, + '.go': go_files, + '.in': in_files, + '.proto': proto_files, + '.s': asm_files, + '.syso': syso_files, + '.C': cxx_files, + '.S': s_files, + } + + # Classify files specifed in _GO_SRCS() macro by extension and process CGO_EXPORT keyword + # which can preceed C/C++ files only + is_cgo_export = False + for f in srcs_files: + _, ext = os.path.splitext(f) + ext_files = classifed_files.get(ext) + if ext_files is not None: + if is_cgo_export: + is_cgo_export = False + if ext in ('.c', '.cc', '.cpp', '.cxx', '.C'): + unit.oncopy_file_with_context([f, f, 'OUTPUT_INCLUDES', '${BINDIR}/_cgo_export.h']) + f = '${BINDIR}/' + f + else: + ymake.report_configure_error('Unmatched CGO_EXPORT keyword in SRCS() macro') + ext_files.append(f) + elif f == 'CGO_EXPORT': + is_cgo_export = True + else: + # FIXME(snermolaev): We can report an unsupported files for _GO_SRCS here + pass + if is_cgo_export: + ymake.report_configure_error('Unmatched CGO_EXPORT keyword in SRCS() macro') + + for f in go_files: + if f.endswith('_test.go'): + ymake.report_configure_error('file {} must be listed in GO_TEST_SRCS() or GO_XTEST_SRCS() macros'.format(f)) + go_test_files = get_appended_values(unit, '_GO_TEST_SRCS_VALUE') + go_xtest_files = get_appended_values(unit, '_GO_XTEST_SRCS_VALUE') + for f in go_test_files + go_xtest_files: + if not f.endswith('_test.go'): + ymake.report_configure_error( + 'file {} should not be listed in GO_TEST_SRCS() or GO_XTEST_SRCS() macros'.format(f) + ) + + is_test_module = unit.enabled('GO_TEST_MODULE') + + # Add gofmt style checks + if unit.enabled('_GO_FMT_ADD_CHECK'): + resolved_go_files = [] + go_source_files = [] if is_test_module and unit.get(['GO_TEST_FOR_DIR']) else go_files + for path in itertools.chain(go_source_files, go_test_files, go_xtest_files): + if path.endswith('.go'): + resolved = unit.resolve_arc_path([path]) + if resolved != path and need_lint(resolved): + resolved_go_files.append(resolved) + if resolved_go_files: + basedirs = {} + for f in resolved_go_files: + basedir = os.path.dirname(f) + if basedir not in basedirs: + basedirs[basedir] = [] + basedirs[basedir].append(f) + for basedir in basedirs: + unit.onadd_check(['gofmt'] + basedirs[basedir]) + + unit_path = unit.path() + + # Go coverage instrumentation (NOTE! go_files list is modified here) + if is_test_module and unit.enabled('GO_TEST_COVER'): + cover_info = [] + + for f in go_files: + if f.endswith('_test.go'): + continue + cover_var = 'GoCover' + base64.b32encode(f).rstrip('=') + cover_file = unit.resolve_arc_path(f) + cover_file_output = '{}/{}'.format(unit_path, os.path.basename(f)) + unit.on_go_gen_cover_go([cover_file, cover_file_output, cover_var]) + if cover_file.startswith('$S/'): + cover_file = arc_project_prefix + cover_file[3:] + cover_info.append('{}:{}'.format(cover_var, cover_file)) + + # go_files should be empty now since the initial list shouldn't contain + # any non-go or go test file. The value of go_files list will be used later + # to update the value of _GO_SRCS_VALUE + go_files = [] + unit.set(['GO_COVER_INFO_VALUE', ' '.join(cover_info)]) + + # We have cleaned up the list of files from _GO_SRCS_VALUE var and we have to update + # the value since it is used in module command line + unit.set(['_GO_SRCS_VALUE', ' '.join(itertools.chain(go_files, asm_files, syso_files))]) + + # Add go vet check + if unit.enabled('_GO_VET_ADD_CHECK') and need_lint(unit_path): + vet_report_file_name = os.path.join(unit_path, '{}{}'.format(unit.filename(), unit.get('GO_VET_REPORT_EXT'))) + unit.onadd_check(["govet", '$(BUILD_ROOT)/' + tobuilddir(vet_report_file_name)[3:]]) + + for f in ev_files: + ev_proto_file = '{}.proto'.format(f) + unit.oncopy_file_with_context([f, ev_proto_file]) + proto_files.append(ev_proto_file) + + # Process .proto files + for f in proto_files: + unit.on_go_proto_cmd(f) + + # Process .fbs files + for f in fbs_files: + unit.on_go_flatc_cmd([f, go_package_name(unit)]) + + # Process .in files + for f in in_files: + unit.onsrc(f) + + # Generate .symabis for .s files (starting from 1.12 version) + if len(asm_files) > 0: + symabis_flags = [] + gostd_version = unit.get('GOSTD_VERSION') + if compare_versions('1.16', gostd_version) >= 0: + import_path = get_import_path(unit) + symabis_flags.extend(['FLAGS', '-p', import_path]) + if need_compiling_runtime(import_path, gostd_version): + symabis_flags.append('-compiling-runtime') + unit.on_go_compile_symabis(asm_files + symabis_flags) + + # Process cgo files + cgo_files = get_appended_values(unit, '_CGO_SRCS_VALUE') + + cgo_cflags = [] + if len(c_files) + len(cxx_files) + len(s_files) + len(cgo_files) > 0: + if is_test_module: + go_test_for_dir = unit.get('GO_TEST_FOR_DIR') + if go_test_for_dir and go_test_for_dir.startswith('$S/'): + unit.onaddincl(['FOR', 'c', go_test_for_dir[3:]]) + unit.onaddincl(['FOR', 'c', unit.get('MODDIR')]) + cgo_cflags = get_appended_values(unit, 'CGO_CFLAGS_VALUE') + + for f in itertools.chain(c_files, cxx_files, s_files): + unit.onsrc([f] + cgo_cflags) + + if len(cgo_files) > 0: + if not unit.enabled('CGO_ENABLED'): + ymake.report_configure_error('trying to build with CGO (CGO_SRCS is non-empty) when CGO is disabled') + import_path = get_import_path(unit) + if import_path != runtime_cgo_path: + go_std_root = unit.get('GOSTD') + unit.onpeerdir(os.path.join(go_std_root, runtime_cgo_path)) + race_mode = 'race' if unit.enabled('RACE') else 'norace' + import_runtime_cgo = 'false' if import_path in import_runtime_cgo_false[race_mode] else 'true' + import_syscall = 'false' if import_path in import_syscall_false[race_mode] else 'true' + args = ( + [import_path] + + cgo_files + + ['FLAGS', '-import_runtime_cgo=' + import_runtime_cgo, '-import_syscall=' + import_syscall] + ) + unit.on_go_compile_cgo1(args) + cgo2_cflags = get_appended_values(unit, 'CGO2_CFLAGS_VALUE') + for f in cgo_files: + if f.endswith('.go'): + unit.onsrc([f[:-2] + 'cgo2.c'] + cgo_cflags + cgo2_cflags) + else: + ymake.report_configure_error('file {} should not be listed in CGO_SRCS() macros'.format(f)) + args = [go_package_name(unit)] + cgo_files + if len(c_files) > 0: + args += ['C_FILES'] + c_files + if len(s_files) > 0: + args += ['S_FILES'] + s_files + if len(syso_files) > 0: + args += ['OBJ_FILES'] + syso_files + unit.on_go_compile_cgo2(args) + + +def on_go_resource(unit, *args): + args = list(args) + files = args[::2] + keys = args[1::2] + suffix_md5 = md5.new('@'.join(args)).hexdigest() + resource_go = os.path.join("resource.{}.res.go".format(suffix_md5)) + + unit.onpeerdir(["library/go/core/resource"]) + + if len(files) != len(keys): + ymake.report_configure_error("last file {} is missing resource key".format(files[-1])) + + for i, (key, filename) in enumerate(zip(keys, files)): + if not key: + ymake.report_configure_error("file key must be non empty") + return + + if filename == "-" and "=" not in key: + ymake.report_configure_error("key \"{}\" must contain = sign".format(key)) + return + + # quote key, to avoid automatic substitution of filename by absolute + # path in RUN_PROGRAM + args[2 * i + 1] = "notafile" + args[2 * i + 1] + + files = [file for file in files if file != "-"] + unit.onrun_program( + ["library/go/core/resource/cc", "-package", go_package_name(unit), "-o", resource_go] + + list(args) + + ["IN"] + + files + + ["OUT", resource_go] + ) diff --git a/build/plugins/ios_app_settings.py b/build/plugins/ios_app_settings.py new file mode 100644 index 00000000000..0d5b233eeae --- /dev/null +++ b/build/plugins/ios_app_settings.py @@ -0,0 +1,17 @@ +import _common as common +import ymake +import os + + +def onios_app_settings(unit, *args): + tail, kv = common.sort_by_keywords({'OS_VERSION': 1, 'DEVICES': -1}, args) + if tail: + ymake.report_configure_error('Bad IOS_COMMON_SETTINGS usage - unknown data: ' + str(tail)) + if kv.get('OS_VERSION', []): + unit.onios_app_common_flags(['--minimum-deployment-target', kv.get('OS_VERSION', [])[0]]) + unit.onios_app_assets_flags(['--filter-for-device-os-version', kv.get('OS_VERSION', [])[0]]) + devices_flags = [] + for device in kv.get('DEVICES', []): + devices_flags += ['--target-device', device] + if devices_flags: + unit.onios_app_common_flags(devices_flags) diff --git a/build/plugins/ios_assets.py b/build/plugins/ios_assets.py new file mode 100644 index 00000000000..16f58bda44f --- /dev/null +++ b/build/plugins/ios_assets.py @@ -0,0 +1,27 @@ +import _common as common +import ymake +import os + + +def onios_assets(unit, *args): + _, kv = common.sort_by_keywords({'ROOT': 1, 'CONTENTS': -1, 'FLAGS': -1}, args) + if not kv.get('ROOT', []) and kv.get('CONTENTS', []): + ymake.report_configure_error('Please specify ROOT directory for assets') + origin_root = kv.get('ROOT')[0] + destination_root = os.path.normpath(os.path.join('$BINDIR', os.path.basename(origin_root))) + rel_list = [] + for cont in kv.get('CONTENTS', []): + rel = os.path.relpath(cont, origin_root) + if rel.startswith('..'): + ymake.report_configure_error('{} is not subpath of {}'.format(cont, origin_root)) + rel_list.append(rel) + if not rel_list: + return + results_list = [os.path.join('$B', unit.path()[3:], os.path.basename(origin_root), i) for i in rel_list] + if len(kv.get('CONTENTS', [])) != len(results_list): + ymake.report_configure_error('IOS_ASSETTS content length is not equals results') + for s, d in zip(kv.get('CONTENTS', []), results_list): + unit.oncopy_file([s, d]) + if kv.get('FLAGS', []): + unit.onios_app_assets_flags(kv.get('FLAGS', [])) + unit.on_ios_assets([destination_root] + results_list) diff --git a/build/plugins/java.py b/build/plugins/java.py new file mode 100644 index 00000000000..32c083b5968 --- /dev/null +++ b/build/plugins/java.py @@ -0,0 +1,480 @@ +import _common as common +import ymake +import json +import os +import base64 + + +DELIM = '================================' +CONTRIB_JAVA_PREFIX = 'contrib/java/' + + +def split_args(s): # TODO quotes, escapes + return filter(None, s.split()) + + +def extract_macro_calls(unit, macro_value_name, macro_calls_delim): + if not unit.get(macro_value_name): + return [] + + return filter( + None, map(split_args, unit.get(macro_value_name).replace('$' + macro_value_name, '').split(macro_calls_delim)) + ) + + +def extract_macro_calls2(unit, macro_value_name): + if not unit.get(macro_value_name): + return [] + + calls = [] + for call_encoded_args in unit.get(macro_value_name).strip().split(): + call_args = json.loads(base64.b64decode(call_encoded_args), encoding='utf-8') + calls.append(call_args) + + return calls + + +def on_run_jbuild_program(unit, *args): + args = list(args) + """ + Custom code generation + @link: https://wiki.yandex-team.ru/yatool/java/#kodogeneracijarunjavaprogram + """ + + flat, kv = common.sort_by_keywords( + { + 'IN': -1, + 'IN_DIR': -1, + 'OUT': -1, + 'OUT_DIR': -1, + 'CWD': 1, + 'CLASSPATH': -1, + 'CP_USE_COMMAND_FILE': 1, + 'ADD_SRCS_TO_CLASSPATH': 0, + }, + args, + ) + depends = kv.get('CLASSPATH', []) + kv.get('JAR', []) + fake_out = None + if depends: + # XXX: hack to force ymake to build dependencies + fake_out = "fake.out.{}".format(hash(tuple(args))) + unit.on_run_java(['TOOL'] + depends + ["OUT", fake_out]) + + if not kv.get('CP_USE_COMMAND_FILE'): + args += ['CP_USE_COMMAND_FILE', unit.get(['JAVA_PROGRAM_CP_USE_COMMAND_FILE']) or 'yes'] + + if fake_out is not None: + args += ['FAKE_OUT', fake_out] + + prev = unit.get(['RUN_JAVA_PROGRAM_VALUE']) or '' + new_val = (prev + ' ' + base64.b64encode(json.dumps(list(args), encoding='utf-8'))).strip() + unit.set(['RUN_JAVA_PROGRAM_VALUE', new_val]) + + +def ongenerate_script(unit, *args): + """ + heretic@ promised to make tutorial here + Don't forget + Feel free to remind + """ + flat, kv = common.sort_by_keywords({'OUT': -1, 'TEMPLATE': -1, 'CUSTOM_PROPERTY': -1}, args) + if len(kv.get('TEMPLATE', [])) > len(kv.get('OUT', [])): + ymake.report_configure_error('To many arguments for TEMPLATE parameter') + prev = unit.get(['GENERATE_SCRIPT_VALUE']) or '' + new_val = (prev + ' ' + base64.b64encode(json.dumps(list(args), encoding='utf-8'))).strip() + unit.set(['GENERATE_SCRIPT_VALUE', new_val]) + + +def onjava_module(unit, *args): + args_delim = unit.get('ARGS_DELIM') + if unit.get('ADD_SRCDIR_TO_TEST_DATA') == "yes": + unit.ondata_files(common.strip_roots(unit.path())) + + if unit.get('YA_IDE_IDEA') != 'yes': + return + + data = { + 'BUNDLE_NAME': unit.name(), + 'PATH': unit.path(), + 'MODULE_TYPE': unit.get('MODULE_TYPE'), + 'MODULE_ARGS': unit.get('MODULE_ARGS'), + 'MANAGED_PEERS': '${MANAGED_PEERS}', + 'MANAGED_PEERS_CLOSURE': '${MANAGED_PEERS_CLOSURE}', + 'NON_NAMAGEABLE_PEERS': '${NON_NAMAGEABLE_PEERS}', + 'TEST_CLASSPATH_MANAGED': '${TEST_CLASSPATH_MANAGED}', + 'EXCLUDE': extract_macro_calls(unit, 'EXCLUDE_VALUE', args_delim), + 'JAVA_SRCS': extract_macro_calls(unit, 'JAVA_SRCS_VALUE', args_delim), + 'JAVAC_FLAGS': extract_macro_calls(unit, 'JAVAC_FLAGS_VALUE', args_delim), + 'ANNOTATION_PROCESSOR': extract_macro_calls(unit, 'ANNOTATION_PROCESSOR_VALUE', args_delim), + 'EXTERNAL_JAR': extract_macro_calls(unit, 'EXTERNAL_JAR_VALUE', args_delim), + 'RUN_JAVA_PROGRAM': extract_macro_calls2(unit, 'RUN_JAVA_PROGRAM_VALUE'), + 'RUN_JAVA_PROGRAM_MANAGED': '${RUN_JAVA_PROGRAM_MANAGED}', + 'MAVEN_GROUP_ID': extract_macro_calls(unit, 'MAVEN_GROUP_ID_VALUE', args_delim), + 'JAR_INCLUDE_FILTER': extract_macro_calls(unit, 'JAR_INCLUDE_FILTER_VALUE', args_delim), + 'JAR_EXCLUDE_FILTER': extract_macro_calls(unit, 'JAR_EXCLUDE_FILTER_VALUE', args_delim), + # TODO remove when java test dart is in prod + 'UNITTEST_DIR': unit.get('UNITTEST_DIR'), + 'SYSTEM_PROPERTIES': extract_macro_calls(unit, 'SYSTEM_PROPERTIES_VALUE', args_delim), + 'JVM_ARGS': extract_macro_calls(unit, 'JVM_ARGS_VALUE', args_delim), + 'TEST_CWD': extract_macro_calls(unit, 'TEST_CWD_VALUE', args_delim), + 'TEST_FORK_MODE': extract_macro_calls(unit, 'TEST_FORK_MODE', args_delim), + 'SPLIT_FACTOR': extract_macro_calls(unit, 'TEST_SPLIT_FACTOR', args_delim), + 'TIMEOUT': extract_macro_calls(unit, 'TEST_TIMEOUT', args_delim), + 'TAG': extract_macro_calls(unit, 'TEST_TAGS_VALUE', args_delim), + 'SIZE': extract_macro_calls(unit, 'TEST_SIZE_NAME', args_delim), + 'DEPENDS': extract_macro_calls(unit, 'TEST_DEPENDS_VALUE', args_delim), + 'IDEA_EXCLUDE': extract_macro_calls(unit, 'IDEA_EXCLUDE_DIRS_VALUE', args_delim), + 'IDEA_RESOURCE': extract_macro_calls(unit, 'IDEA_RESOURCE_DIRS_VALUE', args_delim), + 'IDEA_MODULE_NAME': extract_macro_calls(unit, 'IDEA_MODULE_NAME_VALUE', args_delim), + 'GENERATE_SCRIPT': extract_macro_calls2(unit, 'GENERATE_SCRIPT_VALUE'), + 'FAKEID': extract_macro_calls(unit, 'FAKEID', args_delim), + 'TEST_DATA': extract_macro_calls(unit, 'TEST_DATA_VALUE', args_delim), + 'JAVA_FORBIDDEN_LIBRARIES': extract_macro_calls(unit, 'JAVA_FORBIDDEN_LIBRARIES_VALUE', args_delim), + 'JDK_RESOURCE': 'JDK' + (unit.get('JDK_VERSION') or unit.get('JDK_REAL_VERSION') or '_DEFAULT'), + } + if unit.get('ENABLE_PREVIEW_VALUE') == 'yes' and (unit.get('JDK_VERSION') or unit.get('JDK_REAL_VERSION')) in ( + '15', + '16', + '17', + '18', + '19', + '20' + ): + data['ENABLE_PREVIEW'] = extract_macro_calls(unit, 'ENABLE_PREVIEW_VALUE', args_delim) + + if unit.get('SAVE_JAVAC_GENERATED_SRCS_DIR') and unit.get('SAVE_JAVAC_GENERATED_SRCS_TAR'): + data['SAVE_JAVAC_GENERATED_SRCS_DIR'] = extract_macro_calls(unit, 'SAVE_JAVAC_GENERATED_SRCS_DIR', args_delim) + data['SAVE_JAVAC_GENERATED_SRCS_TAR'] = extract_macro_calls(unit, 'SAVE_JAVAC_GENERATED_SRCS_TAR', args_delim) + + if unit.get('JAVA_ADD_DLLS_VALUE') == 'yes': + data['ADD_DLLS_FROM_DEPENDS'] = extract_macro_calls(unit, 'JAVA_ADD_DLLS_VALUE', args_delim) + + if unit.get('ERROR_PRONE_VALUE') == 'yes': + data['ERROR_PRONE'] = extract_macro_calls(unit, 'ERROR_PRONE_VALUE', args_delim) + + if unit.get('WITH_KOTLIN_VALUE') == 'yes': + data['WITH_KOTLIN'] = extract_macro_calls(unit, 'WITH_KOTLIN_VALUE', args_delim) + if unit.get('KOTLIN_JVM_TARGET'): + data['KOTLIN_JVM_TARGET'] = extract_macro_calls(unit, 'KOTLIN_JVM_TARGET', args_delim) + if unit.get('KOTLINC_FLAGS_VALUE'): + data['KOTLINC_FLAGS'] = extract_macro_calls(unit, 'KOTLINC_FLAGS_VALUE', args_delim) + if unit.get('KOTLINC_OPTS_VALUE'): + data['KOTLINC_OPTS'] = extract_macro_calls(unit, 'KOTLINC_OPTS_VALUE', args_delim) + + if unit.get('DIRECT_DEPS_ONLY_VALUE') == 'yes': + data['DIRECT_DEPS_ONLY'] = extract_macro_calls(unit, 'DIRECT_DEPS_ONLY_VALUE', args_delim) + + if unit.get('JAVA_EXTERNAL_DEPENDENCIES_VALUE'): + valid = [] + for dep in sum(extract_macro_calls(unit, 'JAVA_EXTERNAL_DEPENDENCIES_VALUE', args_delim), []): + if os.path.normpath(dep).startswith('..'): + ymake.report_configure_error( + '{}: {} - relative paths in JAVA_EXTERNAL_DEPENDENCIES is not allowed'.format(unit.path(), dep) + ) + elif os.path.isabs(dep): + ymake.report_configure_error( + '{}: {} absolute paths in JAVA_EXTERNAL_DEPENDENCIES is not allowed'.format(unit.path(), dep) + ) + else: + valid.append(dep) + if valid: + data['EXTERNAL_DEPENDENCIES'] = [valid] + + if unit.get('MAKE_UBERJAR_VALUE') == 'yes': + if unit.get('MODULE_TYPE') != 'JAVA_PROGRAM': + ymake.report_configure_error('{}: UBERJAR supported only for JAVA_PROGRAM module type'.format(unit.path())) + data['UBERJAR'] = extract_macro_calls(unit, 'MAKE_UBERJAR_VALUE', args_delim) + data['UBERJAR_PREFIX'] = extract_macro_calls(unit, 'UBERJAR_PREFIX_VALUE', args_delim) + data['UBERJAR_HIDE_EXCLUDE'] = extract_macro_calls(unit, 'UBERJAR_HIDE_EXCLUDE_VALUE', args_delim) + data['UBERJAR_PATH_EXCLUDE'] = extract_macro_calls(unit, 'UBERJAR_PATH_EXCLUDE_VALUE', args_delim) + data['UBERJAR_MANIFEST_TRANSFORMER_MAIN'] = extract_macro_calls( + unit, 'UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE', args_delim + ) + data['UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE'] = extract_macro_calls( + unit, 'UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE', args_delim + ) + data['UBERJAR_APPENDING_TRANSFORMER'] = extract_macro_calls( + unit, 'UBERJAR_APPENDING_TRANSFORMER_VALUE', args_delim + ) + data['UBERJAR_SERVICES_RESOURCE_TRANSFORMER'] = extract_macro_calls( + unit, 'UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE', args_delim + ) + + if unit.get('WITH_JDK_VALUE') == 'yes': + if unit.get('MODULE_TYPE') != 'JAVA_PROGRAM': + ymake.report_configure_error( + '{}: JDK export supported only for JAVA_PROGRAM module type'.format(unit.path()) + ) + data['WITH_JDK'] = extract_macro_calls(unit, 'WITH_JDK_VALUE', args_delim) + + if not data['EXTERNAL_JAR']: + has_processor = extract_macro_calls(unit, 'GENERATE_VCS_JAVA_INFO_NODEP', args_delim) + # IMPORTANT before switching vcs_info.py to python3 the value was always evaluated to $YMAKE_PYTHON but no + # code in java dart parser extracts its value only checks this key for existance. + data['EMBED_VCS'] = [['yes']] + # FORCE_VCS_INFO_UPDATE is responsible for setting special value of VCS_INFO_DISABLE_CACHE__NO_UID__ + macro_val = extract_macro_calls(unit, 'FORCE_VCS_INFO_UPDATE', args_delim) + macro_str = macro_val[0][0] if macro_val and macro_val[0] and macro_val[0][0] else '' + if macro_str and macro_str == 'yes': + data['VCS_INFO_DISABLE_CACHE__NO_UID__'] = macro_val + + for java_srcs_args in data['JAVA_SRCS']: + external = None + + for i in xrange(len(java_srcs_args)): + arg = java_srcs_args[i] + + if arg == 'EXTERNAL': + if not i + 1 < len(java_srcs_args): + continue # TODO configure error + + ex = java_srcs_args[i + 1] + + if ex in ('EXTERNAL', 'SRCDIR', 'PACKAGE_PREFIX', 'EXCLUDE'): + continue # TODO configure error + + if external is not None: + continue # TODO configure error + + external = ex + + if external: + unit.onpeerdir(external) + + for k, v in data.items(): + if not v: + data.pop(k) + + dart = 'JAVA_DART: ' + base64.b64encode(json.dumps(data)) + '\n' + DELIM + '\n' + unit.set_property(['JAVA_DART_DATA', dart]) + + +def on_add_java_style_checks(unit, *args): + if unit.get('LINT_LEVEL_VALUE') != "none" and common.get_no_lint_value(unit) != 'none': + unit.onadd_check(['JAVA_STYLE', unit.get('LINT_LEVEL_VALUE')] + list(args)) + + +def on_add_kotlin_style_checks(unit, *args): + """ + ktlint can be disabled using NO_LINT() and NO_LINT(ktlint) + """ + if unit.get('WITH_KOTLIN_VALUE') == 'yes': + if common.get_no_lint_value(unit) == '': + unit.onadd_check(['ktlint'] + list(args)) + + +def on_add_classpath_clash_check(unit, *args): + jdeps_val = (unit.get('CHECK_JAVA_DEPS_VALUE') or '').lower() + if jdeps_val and jdeps_val not in ('yes', 'no', 'strict'): + ymake.report_configure_error('CHECK_JAVA_DEPS: "yes", "no" or "strict" required') + if jdeps_val and jdeps_val != 'no': + unit.onjava_test_deps(jdeps_val) + + +# Ymake java modules related macroses + + +def onexternal_jar(unit, *args): + args = list(args) + flat, kv = common.sort_by_keywords({'SOURCES': 1}, args) + if not flat: + ymake.report_configure_error('EXTERNAL_JAR requires exactly one resource URL of compiled jar library') + res = flat[0] + resid = res[4:] if res.startswith('sbr:') else res + unit.set(['JAR_LIB_RESOURCE', resid]) + unit.set(['JAR_LIB_RESOURCE_URL', res]) + + +def on_check_java_srcdir(unit, *args): + args = list(args) + for arg in args: + if not '$' in arg: + arc_srcdir = os.path.join(unit.get('MODDIR'), arg) + abs_srcdir = unit.resolve(os.path.join("$S/", arc_srcdir)) + if not os.path.exists(abs_srcdir) or not os.path.isdir(abs_srcdir): + ymake.report_configure_error( + 'Trying to set a [[alt1]]JAVA_SRCS[[rst]] for a missing directory: [[imp]]$S/{}[[rst]]', + missing_dir=arc_srcdir, + ) + return + srcdir = unit.resolve_arc_path(arg) + if srcdir and not srcdir.startswith('$S'): + continue + abs_srcdir = unit.resolve(srcdir) if srcdir else unit.resolve(arg) + if not os.path.exists(abs_srcdir) or not os.path.isdir(abs_srcdir): + ymake.report_configure_error( + 'Trying to set a [[alt1]]JAVA_SRCS[[rst]] for a missing directory: [[imp]]{}[[rst]]', missing_dir=srcdir + ) + + +def on_fill_jar_copy_resources_cmd(unit, *args): + if len(args) == 4: + varname, srcdir, base_classes_dir, reslist = tuple(args) + package = '' + else: + varname, srcdir, base_classes_dir, package, reslist = tuple(args) + dest_dir = os.path.join(base_classes_dir, *package.split('.')) if package else base_classes_dir + var = unit.get(varname) + var += ' && $FS_TOOLS copy_files {} {} {}'.format( + srcdir if srcdir.startswith('"$') else '${CURDIR}/' + srcdir, dest_dir, reslist + ) + unit.set([varname, var]) + + +def on_fill_jar_gen_srcs(unit, *args): + varname, jar_type, srcdir, base_classes_dir, java_list, kt_list, groovy_list, res_list = tuple(args[0:8]) + resolved_srcdir = unit.resolve_arc_path(srcdir) + if not resolved_srcdir.startswith('$') or resolved_srcdir.startswith('$S'): + return + + exclude_pos = args.index('EXCLUDE') + globs = args[7:exclude_pos] + excludes = args[exclude_pos + 1 :] + var = unit.get(varname) + var += ' && ${{cwd:BINDIR}} $YMAKE_PYTHON ${{input:"build/scripts/resolve_java_srcs.py"}} --append -d {} -s {} -k {} -g {} -r {} --include-patterns {}'.format( + srcdir, java_list, kt_list, groovy_list, res_list, ' '.join(globs) + ) + if jar_type == 'SRC_JAR': + var += ' --all-resources' + if len(excludes) > 0: + var += ' --exclude-patterns {}'.format(' '.join(excludes)) + if unit.get('WITH_KOTLIN_VALUE') == 'yes': + var += ' --resolve-kotlin' + unit.set([varname, var]) + + +def on_check_run_java_prog_classpath(unit, *args): + if len(args) != 1: + ymake.report_configure_error( + 'multiple CLASSPATH elements in RUN_JAVA_PROGRAM invocation no more supported. Use JAVA_RUNTIME_PEERDIR on the JAVA_PROGRAM module instead' + ) + + +def extract_words(words, keys): + kv = {} + k = None + + for w in words: + if w in keys: + k = w + else: + if not k in kv: + kv[k] = [] + kv[k].append(w) + + return kv + + +def parse_words(words): + kv = extract_words(words, {'OUT', 'TEMPLATE'}) + if not 'TEMPLATE' in kv: + kv['TEMPLATE'] = ['template.tmpl'] + ws = [] + for item in ('OUT', 'TEMPLATE'): + for i, word in list(enumerate(kv[item])): + if word == 'CUSTOM_PROPERTY': + ws += kv[item][i:] + kv[item] = kv[item][:i] + templates = kv['TEMPLATE'] + outputs = kv['OUT'] + if len(outputs) < len(templates): + ymake.report_configure_error('To many arguments for TEMPLATE parameter') + return + if ws and ws[0] != 'CUSTOM_PROPERTY': + ymake.report_configure_error('''Can't parse {}'''.format(ws)) + custom_props = [] + for item in ws: + if item == 'CUSTOM_PROPERTY': + custom_props.append([]) + else: + custom_props[-1].append(item) + props = [] + for p in custom_props: + if not p: + ymake.report_configure_error('Empty CUSTOM_PROPERTY') + continue + props.append('-B') + if len(p) > 1: + props.append(base64.b64encode("{}={}".format(p[0], ' '.join(p[1:])))) + else: + ymake.report_configure_error('CUSTOM_PROPERTY "{}" value is not specified'.format(p[0])) + for i, o in enumerate(outputs): + yield o, templates[min(i, len(templates) - 1)], props + + +def on_ymake_generate_script(unit, *args): + for out, tmpl, props in parse_words(list(args)): + unit.on_add_gen_java_script([out, tmpl] + list(props)) + + +def on_jdk_version_macro_check(unit, *args): + if len(args) != 1: + unit.message(["error", "Invalid syntax. Single argument required."]) + jdk_version = args[0] + available_versions = ( + '10', + '11', + '15', + '16', + '17', + '18', + '19', + '20', + ) + if jdk_version not in available_versions: + ymake.report_configure_error( + "Invalid jdk version: {}. {} are available".format(jdk_version, available_versions) + ) + if int(jdk_version) >= 19 and unit.get('WITH_JDK_VALUE') != 'yes' and unit.get('MODULE_TAG') == 'JAR_RUNNABLE': + msg = ( + "Missing WITH_JDK() macro for JDK version >= 19" + # temporary link with additional explanation + ". For more info see https://clubs.at.yandex-team.ru/arcadia/28543" + ) + ymake.report_configure_error(msg) + + +def _maven_coords_for_project(unit, project_dir): + parts = project_dir.split('/') + + g = '.'.join(parts[2:-2]) + a = parts[-2] + v = parts[-1] + c = '' + + pom_path = unit.resolve(os.path.join('$S', project_dir, 'pom.xml')) + if os.path.exists(pom_path): + import xml.etree.ElementTree as et + + with open(pom_path) as f: + root = et.fromstring(f.read()) + for xpath in ('./{http://maven.apache.org/POM/4.0.0}artifactId', './artifactId'): + artifact = root.find(xpath) + if artifact is not None: + artifact = artifact.text + if a != artifact and a.startswith(artifact): + c = a[len(artifact) :].lstrip('-_') + a = artifact + break + + return '{}:{}:{}:{}'.format(g, a, v, c) + + +def on_setup_maven_export_coords_if_need(unit, *args): + if not unit.enabled('MAVEN_EXPORT'): + return + + unit.set(['MAVEN_EXPORT_COORDS_GLOBAL', _maven_coords_for_project(unit, args[0])]) + + +def on_setup_project_coords_if_needed(unit, *args): + if not unit.enabled('EXPORT_GRADLE'): + return + + project_dir = args[0] + if project_dir.startswith(CONTRIB_JAVA_PREFIX): + value = '\\"{}\\"'.format(_maven_coords_for_project(unit, project_dir).rstrip(':')) + else: + value = 'project(\\":{}\\")'.format(project_dir.replace('/', ':')) + unit.set(['_EXPORT_GRADLE_PROJECT_COORDS', value]) diff --git a/build/plugins/large_files.py b/build/plugins/large_files.py new file mode 100644 index 00000000000..568e2942538 --- /dev/null +++ b/build/plugins/large_files.py @@ -0,0 +1,40 @@ +import os +import ymake +from _common import strip_roots + +PLACEHOLDER_EXT = "external" + + +def onlarge_files(unit, *args): + """ + @usage LARGE_FILES([AUTOUPDATED] Files...) + + Use large file ether from working copy or from remote storage via placeholder <File>.external + If <File> is present locally (and not a symlink!) it will be copied to build directory. + Otherwise macro will try to locate <File>.external, parse it retrieve ot during build phase. + """ + args = list(args) + + if args and args[0] == 'AUTOUPDATED': + args = args[1:] + + for arg in args: + if arg == 'AUTOUPDATED': + unit.message(["warn", "Please set AUTOUPDATED argument before other file names"]) + continue + + src = unit.resolve_arc_path(arg) + if src.startswith("$S"): + msg = "Used local large file {}. Don't forget to run 'ya upload --update-external' and commit {}.{}".format( + src, src, PLACEHOLDER_EXT + ) + unit.message(["warn", msg]) + unit.oncopy_file([arg, arg]) + else: + out_file = strip_roots(os.path.join(unit.path(), arg)) + external = "{}.{}".format(arg, PLACEHOLDER_EXT) + from_external_cmd = [external, out_file, 'OUT_NOAUTO', arg] + if os.path.dirname(arg): + from_external_cmd.extend(("RENAME", os.path.basename(arg))) + unit.on_from_external(from_external_cmd) + unit.onadd_check(['check.external', external]) diff --git a/build/plugins/lib/__init__.py b/build/plugins/lib/__init__.py new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/build/plugins/lib/__init__.py diff --git a/build/plugins/lib/_metric_resolvers.py b/build/plugins/lib/_metric_resolvers.py new file mode 100644 index 00000000000..270eb78345c --- /dev/null +++ b/build/plugins/lib/_metric_resolvers.py @@ -0,0 +1,11 @@ +import re + +VALUE_PATTERN = re.compile(r"^\s*(?P<value>\d+)\s*$") + + +def resolve_value(val): + match = VALUE_PATTERN.match(val) + if not match: + return None + val = match.group('value') + return int(val) diff --git a/build/plugins/lib/nots/__init__.py b/build/plugins/lib/nots/__init__.py new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/build/plugins/lib/nots/__init__.py diff --git a/build/plugins/lib/nots/erm_json_lite.py b/build/plugins/lib/nots/erm_json_lite.py new file mode 100644 index 00000000000..dee76302a0a --- /dev/null +++ b/build/plugins/lib/nots/erm_json_lite.py @@ -0,0 +1,102 @@ +import json +from functools import cmp_to_key + +from lib.nots.semver import Version, VersionRange + + +class ErmJsonLite(object): + """ + Basic implementation to read `erm-packages.json`. + + It doesn't use any models, works with only raw JSON types: lists, dicts, strings + """ + + class ResourceType(object): + NPM_PACKAGE = "NPM_PACKAGE" + NODE_JS = "NODE_JS" + + data = None + + @staticmethod + def get_versions_of(er_resource): + # type: (dict) -> list[Version] + """ + Return all versions of the resource in ASC order (from older to latest) + """ + unsorted = er_resource.get("versions").keys() + # We have to sort because in python 2 the order of keys in a dict is not guaranteed + versions = sorted(unsorted, key=cmp_to_key(Version.cmp)) + + return [Version.from_str(v) for v in versions] + + @classmethod + def load(cls, path): + # type: (str) -> ErmJsonLite + erm_json = cls() + + with open(path) as f: + erm_json.data = dict() + for k, v in json.load(f).items(): + # Ignore comments (when key starts with `_`), used for banner + if not k.startswith("_"): + erm_json.data[k] = v + + return erm_json + + def get_resource(self, resource_name): + # type: (str) -> dict + """ + Return resource by his name + """ + er_resource = self.data.get(resource_name) + if not er_resource: + raise Exception("Requested resource {} is not a toolchain item".format(resource_name)) + + return er_resource + + def get_sb_resources(self, resource_name, version): + # type: (str, Version) -> list[dict] + """ + Return a list of SB resources for ER version + """ + er_resource = self.get_resource(resource_name) + + return er_resource.get("versions").get(str(version)).get("resources") + + def is_resource_multiplatform(self, resource_name): + # type: (str) -> bool + """ + Return True if resource is multiplatform, False otherwise + """ + er_resource = self.get_resource(resource_name) + + return er_resource.get("multiplatform", False) + + def list_npm_packages(self): + # type: () -> list[str] + """ + Returns a list of the names of the npm tools used in the toolchain + """ + result = [] + for resource_name, resource in self.data.items(): + if resource.get("type") == self.ResourceType.NPM_PACKAGE: + result.append(resource_name) + + return result + + def select_version_of(self, resource_name, range_str=None): + # type: (str, str|None) -> Version|None + er_resource = self.get_resource(resource_name) + + if range_str is None: + return Version.from_str(er_resource.get("default")) + + version_range = VersionRange.from_str(range_str) + + # assuming the version list is sorted from the lowest to the highest version, + # we stop the loop as early as possible and hence return the lowest compatible version + for version in self.get_versions_of(er_resource): + if version_range.is_satisfied_by(version): + return version + + return None diff --git a/build/plugins/lib/nots/package_manager/__init__.py b/build/plugins/lib/nots/package_manager/__init__.py new file mode 100644 index 00000000000..570231e1e94 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/__init__.py @@ -0,0 +1,7 @@ +from .pnpm import PnpmPackageManager +from .base import PackageJson, constants, utils, bundle_node_modules, extract_node_modules + + +manager = PnpmPackageManager + +__all__ = ["PackageJson", "constants", "utils", "bundle_node_modules", "extract_node_modules", "manager"] diff --git a/build/plugins/lib/nots/package_manager/base/__init__.py b/build/plugins/lib/nots/package_manager/base/__init__.py new file mode 100644 index 00000000000..022d4a960e2 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/__init__.py @@ -0,0 +1,20 @@ +from . import constants, utils +from .lockfile import BaseLockfile, LockfilePackageMeta, LockfilePackageMetaInvalidError +from .package_json import PackageJson +from .package_manager import BasePackageManager, PackageManagerError, PackageManagerCommandError +from .node_modules_bundler import bundle_node_modules, extract_node_modules + + +__all__ = [ + "constants", + "utils", + "BaseLockfile", + "LockfilePackageMeta", + "LockfilePackageMetaInvalidError", + "BasePackageManager", + "PackageManagerError", + "PackageManagerCommandError", + "PackageJson", + "bundle_node_modules", + "extract_node_modules", +] diff --git a/build/plugins/lib/nots/package_manager/base/constants.py b/build/plugins/lib/nots/package_manager/base/constants.py new file mode 100644 index 00000000000..d03df2a5709 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/constants.py @@ -0,0 +1,7 @@ +BUILD_DIRNAME = "build" +BUNDLE_DIRNAME = "bundle" +NODE_MODULES_BUNDLE_FILENAME = "node_modules.tar" +NODE_MODULES_DIRNAME = "node_modules" +NODE_MODULES_WORKSPACE_BUNDLE_FILENAME = "workspace_node_modules.tar" +NPM_REGISTRY_URL = "http://npm.yandex-team.ru" +PACKAGE_JSON_FILENAME = "package.json" diff --git a/build/plugins/lib/nots/package_manager/base/lockfile.py b/build/plugins/lib/nots/package_manager/base/lockfile.py new file mode 100644 index 00000000000..1d7cc6ad3e0 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/lockfile.py @@ -0,0 +1,69 @@ +import os + +from abc import ABCMeta, abstractmethod +from six import add_metaclass + + +class LockfilePackageMeta(object): + """ + Basic struct representing package meta from lockfile. + """ + + __slots__ = ("name", "version", "sky_id", "integrity", "integrity_algorithm", "tarball_path") + + @staticmethod + def from_str(s): + return LockfilePackageMeta(*s.strip().split(" ")) + + def __init__(self, name, version, sky_id, integrity, integrity_algorithm): + self.name = name + self.version = version + self.sky_id = sky_id + self.integrity = integrity + self.integrity_algorithm = integrity_algorithm + self.tarball_path = "{}-{}.tgz".format(name, version) + + def to_str(self): + return " ".join([self.name, self.version, self.sky_id, self.integrity, self.integrity_algorithm]) + + +class LockfilePackageMetaInvalidError(RuntimeError): + pass + + +@add_metaclass(ABCMeta) +class BaseLockfile(object): + @classmethod + def load(cls, path): + """ + :param path: lockfile path + :type path: str + :rtype: BaseLockfile + """ + pj = cls(path) + pj.read() + + return pj + + def __init__(self, path): + if not os.path.isabs(path): + raise TypeError("Absolute path required, given: {}".format(path)) + + self.path = path + self.data = None + + @abstractmethod + def read(self): + pass + + @abstractmethod + def write(self, path=None): + pass + + @abstractmethod + def get_packages_meta(self): + pass + + @abstractmethod + def update_tarball_resolutions(self, fn): + pass diff --git a/build/plugins/lib/nots/package_manager/base/node_modules_bundler.py b/build/plugins/lib/nots/package_manager/base/node_modules_bundler.py new file mode 100644 index 00000000000..c835c4d7ca3 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/node_modules_bundler.py @@ -0,0 +1,66 @@ +import os +import tarfile + +from io import BytesIO + +from .utils import build_nm_path + + +PEERS_DIR = ".peers" +PEERS_INDEX = "index" + + +def bundle_node_modules(build_root, peers, node_modules_path, bundle_path): + """ + Creates node_modules bundle. + Bundle contains node_modules directory, peers' node_modules directories, + and index file with the list of added peers (\\n delimited). + :param build_root: arcadia build root + :type build_root: str + :param peers: list of peers (arcadia root related) + :type peers: list of str + :param node_modules_path: node_modules path + :type node_modules_path: str + :param bundle_path: tarball path + :type bundle_path: str + """ + with tarfile.open(bundle_path, "w") as tf: + tf.add(node_modules_path, arcname=".") + + # Peers' node_modules. + added_peers = [] + for p in peers: + peer_nm_path = build_nm_path(os.path.join(build_root, p)) + peer_bundled_nm_path = build_nm_path(os.path.join(PEERS_DIR, p)) + if not os.path.isdir(peer_nm_path): + continue + tf.add(peer_nm_path, arcname=peer_bundled_nm_path) + added_peers.append(p) + + # Peers index. + peers_index = "\n".join(added_peers) + ti = tarfile.TarInfo(name=os.path.join(PEERS_DIR, PEERS_INDEX)) + ti.size = len(peers_index) + tf.addfile(ti, BytesIO(peers_index.encode())) + + +def extract_node_modules(build_root, node_modules_path, bundle_path): + """ + Extracts node_modules bundle. + :param build_root: arcadia build root + :type build_root: str + :param node_modules_path: node_modules path + :type node_modules_path: str + :param bundle_path: tarball path + :type bundle_path: str + """ + with tarfile.open(bundle_path) as tf: + tf.extractall(node_modules_path) + + peers = open(os.path.join(node_modules_path, PEERS_DIR, PEERS_INDEX)).read().split("\n") + for p in peers: + if not p: + continue + bundled_nm_path = build_nm_path(os.path.join(node_modules_path, PEERS_DIR, p)) + nm_path = build_nm_path(os.path.join(build_root, p)) + os.rename(bundled_nm_path, nm_path) diff --git a/build/plugins/lib/nots/package_manager/base/package_json.py b/build/plugins/lib/nots/package_manager/base/package_json.py new file mode 100644 index 00000000000..d99b1e82547 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/package_json.py @@ -0,0 +1,198 @@ +import json +import logging +import os + +from six import iteritems + +from .utils import build_pj_path + +logger = logging.getLogger(__name__) + + +class PackageJsonWorkspaceError(RuntimeError): + pass + + +class PackageJson(object): + DEP_KEY = "dependencies" + DEV_DEP_KEY = "devDependencies" + PEER_DEP_KEY = "peerDependencies" + OPT_DEP_KEY = "optionalDependencies" + DEP_KEYS = (DEP_KEY, DEV_DEP_KEY, PEER_DEP_KEY, OPT_DEP_KEY) + + WORKSPACE_SCHEMA = "workspace:" + + @classmethod + def load(cls, path): + """ + :param path: package.json path + :type path: str + :rtype: PackageJson + """ + pj = cls(path) + pj.read() + + return pj + + def __init__(self, path): + if not os.path.isabs(path): + raise TypeError("Absolute path required, given: {}".format(path)) + + self.path = path + self.data = None + + def read(self): + with open(self.path) as f: + self.data = json.load(f) + + def write(self, path=None): + """ + :param path: path to store package.json, defaults to original path + :type path: str + """ + if path is None: + path = self.path + + directory = os.path.dirname(path) + if not os.path.exists(directory): + os.mkdir(directory) + + with open(path, "w") as f: + json.dump(self.data, f, indent=2, ensure_ascii=False) + f.write('\n') # it's better for diff algorithm in arc + logger.debug("Written {}".format(path)) + + def get_name(self): + name = self.data.get("name") + + if not name: + name = self.path.replace("/", "-") + + return name + + def get_version(self): + return self.data["version"] + + def get_description(self): + return self.data.get("description") + + def get_nodejs_version(self): + return self.data.get("engines", {}).get("node") + + def get_dep_specifier(self, dep_name): + for name, spec in self.dependencies_iter(): + if dep_name == name: + return spec + return None + + def dependencies_iter(self): + for key in self.DEP_KEYS: + deps = self.data.get(key) + if not deps: + continue + + for name, spec in iteritems(deps): + yield (name, spec) + + def has_dependencies(self): + first_dep = next(self.dependencies_iter(), None) + return first_dep is not None + + def bins_iter(self): + bins = self.data.get("bin") + if isinstance(bins, str): + yield bins + elif isinstance(bins, dict): + for bin in bins.values(): + yield bin + + def get_workspace_dep_spec_paths(self): + """ + Returns names and paths from specifiers of the defined workspace dependencies. + :rtype: list of (str, str) + """ + spec_paths = [] + schema = self.WORKSPACE_SCHEMA + schema_len = len(schema) + + for name, spec in self.dependencies_iter(): + if not spec.startswith(schema): + continue + + spec_path = spec[schema_len:] + if not (spec_path.startswith(".") or spec_path.startswith("..")): + raise PackageJsonWorkspaceError( + "Expected relative path specifier for workspace dependency, but got '{}' for {} in {}".format( + spec, name, self.path + ) + ) + + spec_paths.append((name, spec_path)) + + return spec_paths + + def get_workspace_dep_paths(self, base_path=None): + """ + Returns paths of the defined workspace dependencies. + :param base_path: base path to resolve relative dep paths + :type base_path: str + :rtype: list of str + """ + if base_path is None: + base_path = os.path.dirname(self.path) + + return [os.path.normpath(os.path.join(base_path, p)) for _, p in self.get_workspace_dep_spec_paths()] + + def get_workspace_deps(self): + """ + :rtype: list of PackageJson + """ + ws_deps = [] + pj_dir = os.path.dirname(self.path) + + for name, rel_path in self.get_workspace_dep_spec_paths(): + dep_path = os.path.normpath(os.path.join(pj_dir, rel_path)) + dep_pj = PackageJson.load(build_pj_path(dep_path)) + + if name != dep_pj.get_name(): + raise PackageJsonWorkspaceError( + "Workspace dependency name mismatch, found '{}' instead of '{}' in {}".format( + name, dep_pj.get_name(), self.path + ) + ) + + ws_deps.append(dep_pj) + + return ws_deps + + def get_workspace_map(self, ignore_self=False): + """ + Returns absolute paths of the workspace dependencies (including transitive) mapped to package.json and depth. + :param ignore_self: whether path of the current module will be excluded + :type ignore_self: bool + :rtype: dict of (PackageJson, int) + """ + ws_deps = {} + # list of (pj, depth) + pj_queue = [(self, 0)] + + while len(pj_queue): + (pj, depth) = pj_queue.pop() + pj_dir = os.path.dirname(pj.path) + if pj_dir in ws_deps: + continue + + if not ignore_self or pj != self: + ws_deps[pj_dir] = (pj, depth) + + for dep_pj in pj.get_workspace_deps(): + pj_queue.append((dep_pj, depth + 1)) + + return ws_deps + + def get_dep_paths_by_names(self): + """ + Returns dict of {dependency_name: dependency_path} + """ + ws_map = self.get_workspace_map() + return {pj.get_name(): path for path, (pj, _) in ws_map.items()} diff --git a/build/plugins/lib/nots/package_manager/base/package_manager.py b/build/plugins/lib/nots/package_manager/base/package_manager.py new file mode 100644 index 00000000000..d594d4ea92e --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/package_manager.py @@ -0,0 +1,153 @@ +import os +import sys +import subprocess + +from abc import ABCMeta, abstractmethod +from six import add_metaclass + +from .constants import NPM_REGISTRY_URL +from .package_json import PackageJson +from .utils import build_nm_path, build_pj_path + + +class PackageManagerError(RuntimeError): + pass + + +class PackageManagerCommandError(PackageManagerError): + def __init__(self, cmd, code, stdout, stderr): + self.cmd = cmd + self.code = code + self.stdout = stdout + self.stderr = stderr + + msg = "package manager exited with code {} while running {}:\n{}\n{}".format(code, cmd, stdout, stderr) + super(PackageManagerCommandError, self).__init__(msg) + + +@add_metaclass(ABCMeta) +class BasePackageManager(object): + def __init__( + self, + build_root, + build_path, + sources_path, + nodejs_bin_path, + script_path, + contribs_path, + module_path=None, + sources_root=None, + ): + self.module_path = build_path[len(build_root) + 1 :] if module_path is None else module_path + self.build_path = build_path + self.sources_path = sources_path + self.build_root = build_root + self.sources_root = sources_path[: -len(self.module_path) - 1] if sources_root is None else sources_root + self.nodejs_bin_path = nodejs_bin_path + self.script_path = script_path + self.contribs_path = contribs_path + + @classmethod + def load_package_json(cls, path): + """ + :param path: path to package.json + :type path: str + :rtype: PackageJson + """ + return PackageJson.load(path) + + @classmethod + def load_package_json_from_dir(cls, dir_path): + """ + :param dir_path: path to directory with package.json + :type dir_path: str + :rtype: PackageJson + """ + return cls.load_package_json(build_pj_path(dir_path)) + + @classmethod + @abstractmethod + def load_lockfile(cls, path): + pass + + @classmethod + @abstractmethod + def load_lockfile_from_dir(cls, dir_path): + pass + + @abstractmethod + def create_node_modules(self): + pass + + @abstractmethod + def calc_node_modules_inouts(self): + pass + + @abstractmethod + def extract_packages_meta_from_lockfiles(self, lf_paths): + pass + + def get_local_peers_from_package_json(self): + """ + Returns paths of direct workspace dependencies (source root related). + :rtype: list of str + """ + return self.load_package_json_from_dir(self.sources_path).get_workspace_dep_paths(base_path=self.module_path) + + def get_peers_from_package_json(self): + """ + Returns paths of workspace dependencies (source root related). + :rtype: list of str + """ + pj = self.load_package_json_from_dir(self.sources_path) + prefix_len = len(self.sources_root) + 1 + + return [p[prefix_len:] for p in pj.get_workspace_map(ignore_self=True).keys()] + + def _exec_command(self, args, include_defaults=True): + if not self.nodejs_bin_path: + raise PackageManagerError("Unable to execute command: nodejs_bin_path is not configured") + + cmd = ( + [self.nodejs_bin_path, self.script_path] + args + (self._get_default_options() if include_defaults else []) + ) + p = subprocess.Popen( + cmd, + cwd=self.build_path, + stdin=None, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + stdout, stderr = p.communicate() + + if p.returncode != 0: + self._dump_debug_log() + + raise PackageManagerCommandError(cmd, p.returncode, stdout.decode("utf-8"), stderr.decode("utf-8")) + + def _nm_path(self, *parts): + return os.path.join(build_nm_path(self.build_path), *parts) + + def _contrib_tarball_path(self, pkg): + return os.path.join(self.contribs_path, pkg.tarball_path) + + def _contrib_tarball_url(self, pkg): + return "file:" + self._contrib_tarball_path(pkg) + + def _get_default_options(self): + return ["--registry", NPM_REGISTRY_URL] + + def _get_debug_log_path(self): + return None + + def _dump_debug_log(self): + log_path = self._get_debug_log_path() + + if not log_path: + return + + try: + with open(log_path) as f: + sys.stderr.write("Package manager log {}:\n{}\n".format(log_path, f.read())) + except Exception: + sys.stderr.write("Failed to dump package manager log {}.\n".format(log_path)) diff --git a/build/plugins/lib/nots/package_manager/base/tests/package_json.py b/build/plugins/lib/nots/package_manager/base/tests/package_json.py new file mode 100644 index 00000000000..ccf7d4f6072 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/tests/package_json.py @@ -0,0 +1,201 @@ +import os +import pytest + +from build.plugins.lib.nots.package_manager.base.package_json import PackageJson, PackageJsonWorkspaceError + + +def test_get_name_exist(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "name": "package-name", + } + + name = pj.get_name() + + assert name == "package-name" + + +def test_get_name_none(): + pj = PackageJson("/packages/foo/package.json") + pj.data = {} + + name = pj.get_name() + + assert name == "packages-foo" + + +def test_get_workspace_dep_spec_paths_ok(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "@yandex-int/bar": "workspace:../bar", + }, + "devDependencies": { + "@yandex-int/baz": "workspace:../baz", + }, + } + + ws_dep_spec_paths = pj.get_workspace_dep_spec_paths() + + assert ws_dep_spec_paths == [ + ("@yandex-int/bar", "../bar"), + ("@yandex-int/baz", "../baz"), + ] + + +def test_get_workspace_dep_spec_paths_invalid_path(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "@yandex-int/bar": "workspace:*", + }, + } + + with pytest.raises(PackageJsonWorkspaceError) as e: + pj.get_workspace_dep_spec_paths() + + assert ( + str(e.value) + == "Expected relative path specifier for workspace dependency, but got 'workspace:*' for @yandex-int/bar in /packages/foo/package.json" + ) + + +def test_get_workspace_dep_paths_ok(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "@yandex-int/bar": "workspace:../bar", + }, + "devDependencies": { + "@yandex-int/baz": "workspace:../baz", + }, + } + + ws_dep_paths = pj.get_workspace_dep_paths() + + assert ws_dep_paths == [ + "/packages/bar", + "/packages/baz", + ] + + +def test_get_dep_specifier(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "jestify": "0.0.1", + "eslint": ">= 7.27.0", + }, + "devDependencies": { + "jest": "27.1.0", + "eslinting": "0.0.2", + }, + } + + jest_spec = pj.get_dep_specifier("jest") + assert jest_spec == "27.1.0", "Got unexpected jest specifier: {}".format(jest_spec) + + eslint_spec = pj.get_dep_specifier("eslint") + assert eslint_spec == ">= 7.27.0", "Got unexpected eslint specifier: {}".format(eslint_spec) + + +def test_get_workspace_dep_paths_with_custom_base_path(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "@yandex-int/bar": "workspace:../bar", + }, + "devDependencies": { + "@yandex-int/baz": "workspace:../baz", + }, + } + + ws_dep_paths = pj.get_workspace_dep_paths(base_path="custom/dir") + + assert ws_dep_paths == [ + "custom/bar", + "custom/baz", + ] + + +def test_get_workspace_deps_ok(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "@yandex-int/bar": "workspace:../bar", + }, + "devDependencies": { + "@yandex-int/baz": "workspace:../baz", + }, + } + + def load_mock(cls, path): + p = PackageJson(path) + p.data = { + "name": "@yandex-int/{}".format(os.path.basename(os.path.dirname(path))), + } + return p + + PackageJson.load = classmethod(load_mock) + + ws_deps = pj.get_workspace_deps() + + assert len(ws_deps) == 2 + assert ws_deps[0].path == "/packages/bar/package.json" + assert ws_deps[1].path == "/packages/baz/package.json" + + +def test_get_workspace_deps_with_wrong_name(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "@yandex-int/bar": "workspace:../bar", + }, + } + + def load_mock(cls, path): + p = PackageJson(path) + p.data = { + "name": "@shouldbe/{}".format(os.path.basename(os.path.dirname(path))), + } + return p + + PackageJson.load = classmethod(load_mock) + + with pytest.raises(PackageJsonWorkspaceError) as e: + pj.get_workspace_deps() + + assert ( + str(e.value) + == "Workspace dependency name mismatch, found '@yandex-int/bar' instead of '@shouldbe/bar' in /packages/foo/package.json" + ) + + +def test_get_workspace_map_ok(): + pj = PackageJson("/packages/foo/package.json") + pj.data = { + "dependencies": { + "@yandex-int/bar": "workspace:../bar", + }, + } + + def load_mock(cls, path): + name = os.path.basename(os.path.dirname(path)) + p = PackageJson(path) + p.data = { + "name": "@yandex-int/{}".format(name), + "dependencies": ({"@yandex-int/qux": "workspace:../qux"} if name == "bar" else {}), + } + return p + + PackageJson.load = classmethod(load_mock) + + ws_map = pj.get_workspace_map() + + assert len(ws_map) == 3 + assert ws_map["/packages/foo"][0].path == "/packages/foo/package.json" + assert ws_map["/packages/foo"][1] == 0 + assert ws_map["/packages/bar"][0].path == "/packages/bar/package.json" + assert ws_map["/packages/bar"][1] == 1 + assert ws_map["/packages/qux"][0].path == "/packages/qux/package.json" + assert ws_map["/packages/qux"][1] == 2 diff --git a/build/plugins/lib/nots/package_manager/base/tests/utils.py b/build/plugins/lib/nots/package_manager/base/tests/utils.py new file mode 100644 index 00000000000..4287beec470 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/tests/utils.py @@ -0,0 +1,15 @@ +from build.plugins.lib.nots.package_manager.base import utils + + +def test_extract_package_name_from_path(): + happy_checklist = [ + ("@yandex-int/foo-bar-baz/some/path/inside/the/package", "@yandex-int/foo-bar-baz"), + ("@yandex-int/foo-bar-buzz", "@yandex-int/foo-bar-buzz"), + ("package-wo-scope", "package-wo-scope"), + ("p", "p"), + ("", ""), + ] + + for item in happy_checklist: + package_name = utils.extract_package_name_from_path(item[0]) + assert package_name == item[1] diff --git a/build/plugins/lib/nots/package_manager/base/tests/ya.make b/build/plugins/lib/nots/package_manager/base/tests/ya.make new file mode 100644 index 00000000000..1bece69c330 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/tests/ya.make @@ -0,0 +1,14 @@ +PY23_TEST() + +OWNER(g:frontend-build-platform) + +TEST_SRCS( + package_json.py + utils.py +) + +PEERDIR( + build/plugins/lib/nots/package_manager/base +) + +END() diff --git a/build/plugins/lib/nots/package_manager/base/utils.py b/build/plugins/lib/nots/package_manager/base/utils.py new file mode 100644 index 00000000000..017bf4ca41b --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/utils.py @@ -0,0 +1,29 @@ +import os + +from .constants import PACKAGE_JSON_FILENAME, NODE_MODULES_DIRNAME, NODE_MODULES_BUNDLE_FILENAME + + +def s_rooted(p): + return os.path.join("$S", p) + + +def b_rooted(p): + return os.path.join("$B", p) + + +def build_pj_path(p): + return os.path.join(p, PACKAGE_JSON_FILENAME) + + +def build_nm_path(p): + return os.path.join(p, NODE_MODULES_DIRNAME) + + +def build_nm_bundle_path(p): + return os.path.join(p, NODE_MODULES_BUNDLE_FILENAME) + + +def extract_package_name_from_path(p): + # if we have scope prefix then we are using the first two tokens, otherwise - only the first one + parts = p.split("/", 2) + return "/".join(parts[:2]) if p.startswith("@") else parts[0] diff --git a/build/plugins/lib/nots/package_manager/base/ya.make b/build/plugins/lib/nots/package_manager/base/ya.make new file mode 100644 index 00000000000..4b7f22f05a0 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/base/ya.make @@ -0,0 +1,23 @@ +PY23_LIBRARY() + +OWNER(g:frontend-build-platform) + +PY_SRCS( + __init__.py + constants.py + lockfile.py + node_modules_bundler.py + package_json.py + package_manager.py + utils.py +) + +PEERDIR( + contrib/python/six +) + +END() + +RECURSE_FOR_TESTS( + tests +) diff --git a/build/plugins/lib/nots/package_manager/pnpm/__init__.py b/build/plugins/lib/nots/package_manager/pnpm/__init__.py new file mode 100644 index 00000000000..b3a3c20c024 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/__init__.py @@ -0,0 +1,12 @@ +from . import constants +from .lockfile import PnpmLockfile +from .package_manager import PnpmPackageManager +from .workspace import PnpmWorkspace + + +__all__ = [ + "constants", + "PnpmLockfile", + "PnpmPackageManager", + "PnpmWorkspace", +] diff --git a/build/plugins/lib/nots/package_manager/pnpm/constants.py b/build/plugins/lib/nots/package_manager/pnpm/constants.py new file mode 100644 index 00000000000..e84a78c55e9 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/constants.py @@ -0,0 +1,2 @@ +PNPM_WS_FILENAME = "pnpm-workspace.yaml" +PNPM_LOCKFILE_FILENAME = "pnpm-lock.yaml" diff --git a/build/plugins/lib/nots/package_manager/pnpm/lockfile.py b/build/plugins/lib/nots/package_manager/pnpm/lockfile.py new file mode 100644 index 00000000000..79c351b7fad --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/lockfile.py @@ -0,0 +1,164 @@ +import base64 +import binascii +import yaml +import os + +from six.moves.urllib import parse as urlparse +from six import iteritems + +from ..base import PackageJson, BaseLockfile, LockfilePackageMeta, LockfilePackageMetaInvalidError + + +class PnpmLockfile(BaseLockfile): + IMPORTER_KEYS = PackageJson.DEP_KEYS + ("specifiers",) + + def read(self): + with open(self.path, "r") as f: + self.data = yaml.load(f, Loader=yaml.CSafeLoader) + + def write(self, path=None): + """ + :param path: path to store lockfile, defaults to original path + :type path: str + """ + if path is None: + path = self.path + + with open(path, "w") as f: + yaml.dump(self.data, f, Dumper=yaml.CSafeDumper) + + def get_packages_meta(self): + """ + Extracts packages meta from lockfile. + :rtype: list of LockfilePackageMeta + """ + packages = self.data.get("packages", {}) + + return map(lambda x: _parse_package_meta(*x), iteritems(packages)) + + def update_tarball_resolutions(self, fn): + """ + :param fn: maps `LockfilePackageMeta` instance to new `resolution.tarball` value + :type fn: lambda + """ + packages = self.data.get("packages", {}) + + for key, meta in iteritems(packages): + meta["resolution"]["tarball"] = fn(_parse_package_meta(key, meta)) + packages[key] = meta + + def get_importers(self): + """ + Returns "importers" section from the lockfile or creates similar structure from "dependencies" and "specifiers". + :rtype: dict of dict of dict of str + """ + importers = self.data.get("importers") + if importers is not None: + return importers + + importer = {k: self.data[k] for k in self.IMPORTER_KEYS if k in self.data} + + return {".": importer} if importer else {} + + def merge(self, lf): + """ + Merges two lockfiles: + 1. Converts the lockfile to monorepo-like lockfile with "importers" section instead of "dependencies" and "specifiers". + 2. Merges `lf`'s dependencies and specifiers to importers. + 3. Merges `lf`'s packages to the lockfile. + :param lf: lockfile to merge + :type lf: PnpmLockfile + """ + importers = self.get_importers() + build_path = os.path.dirname(self.path) + + for [importer, imports] in iteritems(lf.get_importers()): + importer_path = os.path.normpath(os.path.join(os.path.dirname(lf.path), importer)) + importer_rel_path = os.path.relpath(importer_path, build_path) + importers[importer_rel_path] = imports + + self.data["importers"] = importers + + for k in self.IMPORTER_KEYS: + self.data.pop(k, None) + + packages = self.data.get("packages", {}) + for k, v in iteritems(lf.data.get("packages", {})): + if k not in packages: + packages[k] = v + self.data["packages"] = packages + + +def _parse_package_meta(key, meta): + """ + :param key: uniq package key from lockfile + :type key: string + :param meta: package meta dict from lockfile + :type meta: dict + :rtype: LockfilePackageMetaInvalidError + """ + try: + name, version = _parse_package_key(key) + sky_id = _parse_sky_id_from_tarball_url(meta["resolution"]["tarball"]) + integrity_algorithm, integrity = _parse_package_integrity(meta["resolution"]["integrity"]) + except KeyError as e: + raise TypeError("Invalid package meta for key {}, missing {} key".format(key, e)) + except LockfilePackageMetaInvalidError as e: + raise TypeError("Invalid package meta for key {}, parse error: {}".format(key, e)) + + return LockfilePackageMeta(name, version, sky_id, integrity, integrity_algorithm) + + +def _parse_package_key(key): + """ + Returns tuple of scoped package name and version. + :param key: package key in format "/({scope}/)?{package_name}/{package_version}(_{peer_dependencies})?" + :type key: string + :rtype: (str, str) + """ + try: + tokens = key.split("/")[1:] + version = tokens.pop().split("_", 1)[0] + + if len(tokens) < 1 or len(tokens) > 2: + raise TypeError() + except (IndexError, TypeError): + raise LockfilePackageMetaInvalidError("Invalid package key") + + return ("/".join(tokens), version) + + +def _parse_sky_id_from_tarball_url(tarball_url): + """ + :param tarball_url: tarball url + :type tarball_url: string + :rtype: string + """ + if tarball_url.startswith("file:"): + return "" + + rbtorrent_param = urlparse.parse_qs(urlparse.urlparse(tarball_url).query).get("rbtorrent") + + if rbtorrent_param is None: + raise LockfilePackageMetaInvalidError("Missing rbtorrent param in tarball url {}".format(tarball_url)) + + return "rbtorrent:{}".format(rbtorrent_param[0]) + + +def _parse_package_integrity(integrity): + """ + Returns tuple of algorithm and hash (hex). + :param integrity: package integrity in format "{algo}-{base64_of_hash}" + :type integrity: string + :rtype: (str, str) + """ + algo, hash_b64 = integrity.split("-", 1) + + try: + hash_hex = binascii.hexlify(base64.b64decode(hash_b64)) + except TypeError as e: + raise LockfilePackageMetaInvalidError( + "Invalid package integrity encoding, integrity: {}, error: {}".format(integrity, e) + ) + + return (algo, hash_hex) diff --git a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py b/build/plugins/lib/nots/package_manager/pnpm/package_manager.py new file mode 100644 index 00000000000..3960f6498c8 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/package_manager.py @@ -0,0 +1,213 @@ +import os +import yaml + +from six import iteritems + +from ..base import BasePackageManager, PackageManagerError +from ..base.utils import build_pj_path, build_nm_path, build_nm_bundle_path, s_rooted, b_rooted +from ..base.node_modules_bundler import bundle_node_modules +from ..base.constants import NODE_MODULES_BUNDLE_FILENAME +from .lockfile import PnpmLockfile +from .workspace import PnpmWorkspace +from .utils import build_lockfile_path, build_ws_config_path + + +class PnpmPackageManager(BasePackageManager): + _STORE_NM_PATH = os.path.join(".pnpm", "store") + _VSTORE_NM_PATH = os.path.join(".pnpm", "virtual-store") + _STORE_VER = "v3" + + @classmethod + def load_lockfile(cls, path): + """ + :param path: path to lockfile + :type path: str + :rtype: PnpmLockfile + """ + return PnpmLockfile.load(path) + + @classmethod + def load_lockfile_from_dir(cls, dir_path): + """ + :param dir_path: path to directory with lockfile + :type dir_path: str + :rtype: PnpmLockfile + """ + return cls.load_lockfile(build_lockfile_path(dir_path)) + + def create_node_modules(self): + """ + Creates node_modules directory according to the lockfile. + """ + ws = self._prepare_workspace() + self._exec_command( + [ + "install", + "--offline", + "--frozen-lockfile", + "--store-dir", + self._nm_path(self._STORE_NM_PATH), + "--virtual-store-dir", + self._nm_path(self._VSTORE_NM_PATH), + "--no-verify-store-integrity", + "--package-import-method", + "hardlink", + "--ignore-pnpmfile", + "--ignore-scripts", + "--strict-peer-dependencies", + ] + ) + self._fix_stores_in_modules_yaml() + + bundle_node_modules( + build_root=self.build_root, + node_modules_path=self._nm_path(), + peers=ws.get_paths(base_path=self.module_path, ignore_self=True), + bundle_path=NODE_MODULES_BUNDLE_FILENAME, + ) + + def calc_node_modules_inouts(self): + """ + Returns input and output paths for command that creates `node_modules` bundle. + Inputs: + - source package.json and lockfile, + - built package.jsons of all deps, + - merged lockfiles and workspace configs of direct non-leave deps, + - tarballs. + Outputs: + - merged lockfile, + - generated workspace config, + - created node_modules bundle. + :rtype: (list of str, list of str) + """ + ins = [ + s_rooted(build_pj_path(self.module_path)), + s_rooted(build_lockfile_path(self.module_path)), + ] + outs = [ + b_rooted(build_lockfile_path(self.module_path)), + b_rooted(build_ws_config_path(self.module_path)), + b_rooted(build_nm_bundle_path(self.module_path)), + ] + + # Source lockfiles are used only to get tarballs info. + src_lf_paths = [build_lockfile_path(self.sources_path)] + pj = self.load_package_json_from_dir(self.sources_path) + + for [dep_src_path, (_, depth)] in iteritems(pj.get_workspace_map(ignore_self=True)): + dep_mod_path = dep_src_path[len(self.sources_root) + 1 :] + # pnpm requires all package.jsons. + ins.append(b_rooted(build_pj_path(dep_mod_path))) + + dep_lf_src_path = build_lockfile_path(dep_src_path) + if not os.path.isfile(dep_lf_src_path): + # It is ok for leaves. + continue + src_lf_paths.append(dep_lf_src_path) + + if depth == 1: + ins.append(b_rooted(build_ws_config_path(dep_mod_path))) + ins.append(b_rooted(build_lockfile_path(dep_mod_path))) + + for pkg in self.extract_packages_meta_from_lockfiles(src_lf_paths): + ins.append(b_rooted(self._contrib_tarball_path(pkg))) + + return (ins, outs) + + def extract_packages_meta_from_lockfiles(self, lf_paths): + """ + :type lf_paths: iterable of BaseLockfile + :rtype: iterable of LockfilePackageMeta + """ + tarballs = set() + + for lf_path in lf_paths: + try: + for pkg in self.load_lockfile(lf_path).get_packages_meta(): + if pkg.tarball_path not in tarballs: + tarballs.add(pkg.tarball_path) + yield pkg + except Exception as e: + raise PackageManagerError("Unable to process lockfile {}: {}".format(lf_path, e)) + + def _prepare_workspace(self): + """ + :rtype: PnpmWorkspace + """ + pj = self._build_package_json() + ws = PnpmWorkspace(build_ws_config_path(self.build_path)) + ws.set_from_package_json(pj) + dep_paths = ws.get_paths(ignore_self=True) + self._build_merged_workspace_config(ws, dep_paths) + self._build_merged_lockfile(dep_paths) + + return ws + + def _build_package_json(self): + """ + :rtype: PackageJson + """ + pj = self.load_package_json_from_dir(self.sources_path) + + if not os.path.exists(self.build_path): + os.makedirs(self.build_path, exist_ok=True) + + pj.path = build_pj_path(self.build_path) + pj.write() + + return pj + + def _build_merged_lockfile(self, dep_paths): + """ + :type dep_paths: list of str + :rtype: PnpmLockfile + """ + lf = self.load_lockfile_from_dir(self.sources_path) + # Change to the output path for correct path calcs on merging. + lf.path = build_lockfile_path(self.build_path) + + for dep_path in dep_paths: + lf_path = build_lockfile_path(dep_path) + if os.path.isfile(lf_path): + lf.merge(self.load_lockfile(lf_path)) + + lf.update_tarball_resolutions(lambda p: self._contrib_tarball_url(p)) + lf.write() + + def _build_merged_workspace_config(self, ws, dep_paths): + """ + NOTE: This method mutates `ws`. + :type ws: PnpmWorkspaceConfig + :type dep_paths: list of str + """ + for dep_path in dep_paths: + ws_config_path = build_ws_config_path(dep_path) + if os.path.isfile(ws_config_path): + ws.merge(PnpmWorkspace.load(ws_config_path)) + + ws.write() + + def _fix_stores_in_modules_yaml(self): + """ + Ensures that store paths are the same as would be after installing deps in the source dir. + This is required to reuse `node_modules` after build. + """ + with open(self._nm_path(".modules.yaml"), "r+") as f: + data = yaml.load(f, Loader=yaml.CSafeLoader) + # NOTE: pnpm requires absolute store path here. + data["storeDir"] = os.path.join(build_nm_path(self.sources_path), self._STORE_NM_PATH, self._STORE_VER) + data["virtualStoreDir"] = self._VSTORE_NM_PATH + f.seek(0) + yaml.dump(data, f, Dumper=yaml.CSafeDumper) + f.truncate() + + def _get_default_options(self): + return super(PnpmPackageManager, self)._get_default_options() + [ + "--stream", + "--reporter", + "append-only", + "--no-color", + ] + + def _get_debug_log_path(self): + return self._nm_path(".pnpm-debug.log") diff --git a/build/plugins/lib/nots/package_manager/pnpm/tests/lockfile.py b/build/plugins/lib/nots/package_manager/pnpm/tests/lockfile.py new file mode 100644 index 00000000000..5985f0261ec --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/tests/lockfile.py @@ -0,0 +1,326 @@ +import pytest + +from build.plugins.lib.nots.package_manager.pnpm.lockfile import PnpmLockfile + + +def test_lockfile_get_packages_meta_ok(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = { + "packages": { + "/@babel/cli/7.6.2_@babel+core@7.6.2": { + "resolution": { + "integrity": "sha512-JDZ+T/br9pPfT2lmAMJypJDTTTHM9ePD/ED10TRjRzJVdEVy+JB3iRlhzYmTt5YkNgHvxWGlUVnLtdv6ruiDrQ==", + "tarball": "@babel%2fcli/-/cli-7.6.2.tgz?rbtorrent=cb1849da3e4947e56a8f6bde6a1ec42703ddd187", + }, + }, + }, + } + + packages = list(lf.get_packages_meta()) + pkg = packages[0] + + assert len(packages) == 1 + assert pkg.name == "@babel/cli" + assert pkg.version == "7.6.2" + assert pkg.sky_id == "rbtorrent:cb1849da3e4947e56a8f6bde6a1ec42703ddd187" + assert ( + pkg.integrity + == b"24367e4ff6ebf693df4f696600c272a490d34d31ccf5e3c3fc40f5d13463473255744572f89077891961cd8993b796243601efc561a55159cbb5dbfaaee883ad" + ) + assert pkg.integrity_algorithm == "sha512" + + +def test_lockfile_get_packages_empty(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = {} + + assert len(list(lf.get_packages_meta())) == 0 + + +def test_package_meta_invalid_key(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = { + "packages": { + "in/valid": {}, + }, + } + + with pytest.raises(TypeError) as e: + list(lf.get_packages_meta()) + + assert str(e.value) == "Invalid package meta for key in/valid, parse error: Invalid package key" + + +def test_package_meta_missing_resolution(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = { + "packages": { + "/valid/1.2.3": {}, + }, + } + + with pytest.raises(TypeError) as e: + list(lf.get_packages_meta()) + + assert str(e.value) == "Invalid package meta for key /valid/1.2.3, missing 'resolution' key" + + +def test_package_meta_missing_tarball(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = { + "packages": { + "/valid/1.2.3": { + "resolution": {}, + }, + }, + } + + with pytest.raises(TypeError) as e: + list(lf.get_packages_meta()) + + assert str(e.value) == "Invalid package meta for key /valid/1.2.3, missing 'tarball' key" + + +def test_package_meta_missing_rbtorrent(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = { + "packages": { + "/valid/1.2.3": { + "resolution": { + "tarball": "valid-1.2.3.tgz", + }, + }, + }, + } + + with pytest.raises(TypeError) as e: + list(lf.get_packages_meta()) + + assert ( + str(e.value) + == "Invalid package meta for key /valid/1.2.3, parse error: Missing rbtorrent param in tarball url valid-1.2.3.tgz" + ) + + +def test_lockfile_meta_file_tarball(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = { + "packages": { + "/@babel/cli/7.6.2": { + "resolution": { + "integrity": "sha512-JDZ+T/br9pPfT2lmAMJypJDTTTHM9ePD/ED10TRjRzJVdEVy+JB3iRlhzYmTt5YkNgHvxWGlUVnLtdv6ruiDrQ==", + "tarball": "file:/some/abs/path.tgz", + }, + }, + }, + } + + packages = list(lf.get_packages_meta()) + pkg = packages[0] + + assert len(packages) == 1 + assert pkg.name == "@babel/cli" + assert pkg.version == "7.6.2" + assert pkg.sky_id == "" + + +def test_lockfile_update_tarball_resolutions_ok(): + lf = PnpmLockfile(path="/pnpm-lock.yaml") + lf.data = { + "packages": { + "/@babel/cli/7.6.2_@babel+core@7.6.2": { + "resolution": { + "integrity": "sha512-JDZ+T/br9pPfT2lmAMJypJDTTTHM9ePD/ED10TRjRzJVdEVy+JB3iRlhzYmTt5YkNgHvxWGlUVnLtdv6ruiDrQ==", + "tarball": "@babel%2fcli/-/cli-7.6.2.tgz?rbtorrent=cb1849da3e4947e56a8f6bde6a1ec42703ddd187", + }, + }, + }, + } + + lf.update_tarball_resolutions(lambda p: p.name) + + assert lf.data["packages"]["/@babel/cli/7.6.2_@babel+core@7.6.2"]["resolution"]["tarball"] == "@babel/cli" + + +def test_lockfile_merge(): + lf1 = PnpmLockfile(path="/foo/pnpm-lock.yaml") + lf1.data = { + "dependencies": { + "a": "1.0.0", + }, + "specifiers": { + "a": "1.0.0", + }, + "packages": { + "/a/1.0.0": {}, + }, + } + + lf2 = PnpmLockfile(path="/bar/pnpm-lock.yaml") + lf2.data = { + "dependencies": { + "b": "1.0.0", + }, + "specifiers": { + "b": "1.0.0", + }, + "packages": { + "/b/1.0.0": {}, + }, + } + + lf3 = PnpmLockfile(path="/another/baz/pnpm-lock.yaml") + lf3.data = { + "importers": { + ".": { + "dependencies": { + "@a/qux": "link:../qux", + "a": "1.0.0", + }, + "specifiers": { + "@a/qux": "workspace:../qux", + "a": "1.0.0", + }, + }, + "../qux": { + "dependencies": { + "b": "1.0.1", + }, + "specifiers": { + "b": "1.0.1", + }, + }, + }, + "packages": { + "/a/1.0.0": {}, + "/b/1.0.1": {}, + }, + } + + lf4 = PnpmLockfile(path="/another/quux/pnpm-lock.yaml") + lf4.data = { + "dependencies": { + "@a/bar": "link:../../bar", + }, + "specifiers": { + "@a/bar": "workspace:../../bar", + }, + } + + lf1.merge(lf2) + lf1.merge(lf3) + lf1.merge(lf4) + + assert lf1.data == { + "importers": { + ".": { + "dependencies": { + "a": "1.0.0", + }, + "specifiers": { + "a": "1.0.0", + }, + }, + "../bar": { + "dependencies": { + "b": "1.0.0", + }, + "specifiers": { + "b": "1.0.0", + }, + }, + "../another/baz": { + "dependencies": { + "@a/qux": "link:../qux", + "a": "1.0.0", + }, + "specifiers": { + "@a/qux": "workspace:../qux", + "a": "1.0.0", + }, + }, + "../another/qux": { + "dependencies": { + "b": "1.0.1", + }, + "specifiers": { + "b": "1.0.1", + }, + }, + "../another/quux": { + "dependencies": { + "@a/bar": "link:../../bar", + }, + "specifiers": { + "@a/bar": "workspace:../../bar", + }, + }, + }, + "packages": { + "/a/1.0.0": {}, + "/b/1.0.0": {}, + "/b/1.0.1": {}, + }, + } + + +def test_lockfile_merge_dont_overrides_packages(): + lf1 = PnpmLockfile(path="/foo/pnpm-lock.yaml") + lf1.data = { + "dependencies": { + "a": "1.0.0", + }, + "specifiers": { + "a": "1.0.0", + }, + "packages": { + "/a/1.0.0": {}, + }, + } + + lf2 = PnpmLockfile(path="/bar/pnpm-lock.yaml") + lf2.data = { + "dependencies": { + "a": "1.0.0", + "b": "1.0.0", + }, + "specifiers": { + "a": "1.0.0", + "b": "1.0.0", + }, + "packages": { + "/a/1.0.0": { + "overriden": True, + }, + "/b/1.0.0": {}, + }, + } + + lf1.merge(lf2) + + assert lf1.data == { + "importers": { + ".": { + "dependencies": { + "a": "1.0.0", + }, + "specifiers": { + "a": "1.0.0", + }, + }, + "../bar": { + "dependencies": { + "a": "1.0.0", + "b": "1.0.0", + }, + "specifiers": { + "a": "1.0.0", + "b": "1.0.0", + }, + }, + }, + "packages": { + "/a/1.0.0": {}, + "/b/1.0.0": {}, + }, + } diff --git a/build/plugins/lib/nots/package_manager/pnpm/tests/workspace.py b/build/plugins/lib/nots/package_manager/pnpm/tests/workspace.py new file mode 100644 index 00000000000..ffc010de882 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/tests/workspace.py @@ -0,0 +1,68 @@ +from build.plugins.lib.nots.package_manager.base import PackageJson +from build.plugins.lib.nots.package_manager.pnpm.workspace import PnpmWorkspace + + +def test_workspace_get_paths(): + ws = PnpmWorkspace(path="/packages/foo/pnpm-workspace.yaml") + ws.packages = set([".", "../bar", "../../another/baz"]) + + assert sorted(ws.get_paths()) == [ + "/another/baz", + "/packages/bar", + "/packages/foo", + ] + + +def test_workspace_get_paths_with_custom_base_path_without_self(): + ws = PnpmWorkspace(path="/packages/foo/pnpm-workspace.yaml") + ws.packages = set([".", "../bar", "../../another/baz"]) + + assert sorted(ws.get_paths(base_path="some/custom/dir", ignore_self=True)) == [ + "some/another/baz", + "some/custom/bar", + ] + + +def test_workspace_set_from_package_json(): + ws = PnpmWorkspace(path="/packages/foo/pnpm-workspace.yaml") + pj = PackageJson(path="/packages/foo/package.json") + pj.data = { + "dependencies": { + "@a/bar": "workspace:../bar", + }, + "devDependencies": { + "@a/baz": "workspace:../../another/baz", + }, + "peerDependencies": { + "@a/qux": "workspace:../../another/qux", + }, + "optionalDependencies": { + "@a/quux": "workspace:../../another/quux", + }, + } + + ws.set_from_package_json(pj) + + assert sorted(ws.get_paths()) == [ + "/another/baz", + "/another/quux", + "/another/qux", + "/packages/bar", + "/packages/foo", + ] + + +def test_workspace_merge(): + ws1 = PnpmWorkspace(path="/packages/foo/pnpm-workspace.yaml") + ws1.packages = set([".", "../bar", "../../another/baz"]) + ws2 = PnpmWorkspace(path="/another/baz/pnpm-workspace.yaml") + ws2.packages = set([".", "../qux"]) + + ws1.merge(ws2) + + assert sorted(ws1.get_paths()) == [ + "/another/baz", + "/another/qux", + "/packages/bar", + "/packages/foo", + ] diff --git a/build/plugins/lib/nots/package_manager/pnpm/tests/ya.make b/build/plugins/lib/nots/package_manager/pnpm/tests/ya.make new file mode 100644 index 00000000000..44877dfc1b8 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/tests/ya.make @@ -0,0 +1,15 @@ +PY23_TEST() + +OWNER(g:frontend-build-platform) + +TEST_SRCS( + lockfile.py + workspace.py +) + +PEERDIR( + build/plugins/lib/nots/package_manager/base + build/plugins/lib/nots/package_manager/pnpm +) + +END() diff --git a/build/plugins/lib/nots/package_manager/pnpm/utils.py b/build/plugins/lib/nots/package_manager/pnpm/utils.py new file mode 100644 index 00000000000..1fa4291b9d3 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/utils.py @@ -0,0 +1,11 @@ +import os + +from .constants import PNPM_LOCKFILE_FILENAME, PNPM_WS_FILENAME + + +def build_lockfile_path(p): + return os.path.join(p, PNPM_LOCKFILE_FILENAME) + + +def build_ws_config_path(p): + return os.path.join(p, PNPM_WS_FILENAME) diff --git a/build/plugins/lib/nots/package_manager/pnpm/workspace.py b/build/plugins/lib/nots/package_manager/pnpm/workspace.py new file mode 100644 index 00000000000..e596e20a18b --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/workspace.py @@ -0,0 +1,81 @@ +import os +import yaml + + +class PnpmWorkspace(object): + @classmethod + def load(cls, path): + ws = cls(path) + ws.read() + + return ws + + def __init__(self, path): + if not os.path.isabs(path): + raise TypeError("Absolute path required, given: {}".format(path)) + + self.path = path + # NOTE: pnpm requires relative workspace paths. + self.packages = set() + + def read(self): + with open(self.path) as f: + self.packages = set(yaml.load(f, Loader=yaml.CSafeLoader).get("packages", [])) + + def write(self, path=None): + if not path: + path = self.path + + with open(path, "w") as f: + data = { + "packages": list(self.packages), + } + yaml.dump(data, f, Dumper=yaml.CSafeDumper) + + def get_paths(self, base_path=None, ignore_self=False): + """ + Returns absolute paths of the workspace packages. + :param base_path: base path to resolve relative dep paths + :type base_path: str + :param ignore_self: whether path of the current module will be excluded (if present) + :type ignore_self: bool + :rtype: list of str + """ + if base_path is None: + base_path = os.path.dirname(self.path) + + return [ + os.path.normpath(os.path.join(base_path, pkg_path)) + for pkg_path in self.packages + if not ignore_self or pkg_path != "." + ] + + def set_from_package_json(self, package_json): + """ + Sets packages to "workspace" deps from given package.json. + :param package_json: package.json of workspace + :type package_json: PackageJson + """ + if os.path.dirname(package_json.path) != os.path.dirname(self.path): + raise TypeError( + "package.json should be in workspace directory {}, given: {}".format( + os.path.dirname(self.path), package_json.path + ) + ) + + self.packages = set(path for _, path in package_json.get_workspace_dep_spec_paths()) + # Add relative path to self. + self.packages.add(".") + + def merge(self, ws): + """ + Adds `ws`'s packages to the workspace. + :param ws: workspace to merge + :type ws: PnpmWorkspace + """ + dir_path = os.path.dirname(self.path) + ws_dir_path = os.path.dirname(ws.path) + + for p_rel_path in ws.packages: + p_path = os.path.normpath(os.path.join(ws_dir_path, p_rel_path)) + self.packages.add(os.path.relpath(p_path, dir_path)) diff --git a/build/plugins/lib/nots/package_manager/pnpm/ya.make b/build/plugins/lib/nots/package_manager/pnpm/ya.make new file mode 100644 index 00000000000..f57ae4a2ba8 --- /dev/null +++ b/build/plugins/lib/nots/package_manager/pnpm/ya.make @@ -0,0 +1,24 @@ +PY23_LIBRARY() + +OWNER(g:frontend-build-platform) + +PY_SRCS( + __init__.py + constants.py + lockfile.py + package_manager.py + workspace.py + utils.py +) + +PEERDIR( + build/plugins/lib/nots/package_manager/base + contrib/python/PyYAML + contrib/python/six +) + +END() + +RECURSE_FOR_TESTS( + tests +) diff --git a/build/plugins/lib/nots/package_manager/ya.make b/build/plugins/lib/nots/package_manager/ya.make new file mode 100644 index 00000000000..3ac1ea9103e --- /dev/null +++ b/build/plugins/lib/nots/package_manager/ya.make @@ -0,0 +1,14 @@ +PY23_LIBRARY() + +OWNER(g:frontend-build-platform) + +PY_SRCS( + __init__.py +) + +PEERDIR( + build/plugins/lib/nots/package_manager/base + build/plugins/lib/nots/package_manager/pnpm +) + +END() diff --git a/build/plugins/lib/nots/semver/__init__.py b/build/plugins/lib/nots/semver/__init__.py new file mode 100644 index 00000000000..be4319f9f30 --- /dev/null +++ b/build/plugins/lib/nots/semver/__init__.py @@ -0,0 +1,7 @@ +from .semver import Version, Operator, VersionRange + +__all__ = [ + "Version", + "Operator", + "VersionRange", +] diff --git a/build/plugins/lib/nots/semver/semver.py b/build/plugins/lib/nots/semver/semver.py new file mode 100644 index 00000000000..1398da8586f --- /dev/null +++ b/build/plugins/lib/nots/semver/semver.py @@ -0,0 +1,244 @@ +import re + + +class Version: + """ + This class is intended to provide utility methods to work with semver ranges. + Right now it is limited to the simplest case: a ">=" operator followed by an exact version with no prerelease or build specification. + Example: ">= 1.2.3" + """ + + @classmethod + def from_str(cls, input): + """ + :param str input: save exact formatted version e.g. 1.2.3 + :rtype: Version + :raises: ValueError + """ + parts = input.strip().split(".", 2) + major = int(parts[0]) + minor = int(parts[1]) + patch = int(parts[2]) + + return cls(major, minor, patch) + + STABLE_VERSION_RE = re.compile(r'^\d+\.\d+\.\d+$') + + @classmethod + def is_stable(cls, v): + """ + Verifies that the version is in a supported format. + + :param v:string with the version + :return: bool + """ + return cls.STABLE_VERSION_RE.match(v) is not None + + @classmethod + def cmp(cls, a, b): + """ + Compare two versions. Should be used with "cmp_to_key" wrapper in sorted(), min(), max()... + + For example: + sorted(["1.2.3", "2.4.2", "1.2.7"], key=cmp_to_key(Version.cmp)) + + :param a:string with version or Version instance + :param b:string with version or Version instance + :return: int + :raises: ValueError + """ + a_version = a if isinstance(a, cls) else cls.from_str(a) + b_version = b if isinstance(b, cls) else cls.from_str(b) + + if a_version > b_version: + return 1 + elif a_version < b_version: + return -1 + else: + return 0 + + __slots__ = "_values" + + def __init__(self, major, minor, patch): + """ + :param int major + :param int minor + :param int patch + :raises ValueError + """ + version_parts = { + "major": major, + "minor": minor, + "patch": patch, + } + + for name, value in version_parts.items(): + value = int(value) + version_parts[name] = value + if value < 0: + raise ValueError("{!r} is negative. A version can only be positive.".format(name)) + + self._values = (version_parts["major"], version_parts["minor"], version_parts["patch"]) + + def __str__(self): + return "{}.{}.{}".format(self._values[0], self._values[1], self._values[2]) + + def __repr__(self): + return '<Version({})>'.format(self) + + def __eq__(self, other): + """ + :param Version|str other + :rtype: bool + """ + if isinstance(other, str): + if self.is_stable(other): + other = self.from_str(other) + else: + return False + + return self.as_tuple() == other.as_tuple() + + def __ne__(self, other): + return not self == other + + def __gt__(self, other): + """ + :param Version other + :rtype: bool + """ + return self.as_tuple() > other.as_tuple() + + def __ge__(self, other): + """ + :param Version other + :rtype: bool + """ + return self.as_tuple() >= other.as_tuple() + + def __lt__(self, other): + """ + :param Version other + :rtype: bool + """ + return self.as_tuple() < other.as_tuple() + + def __le__(self, other): + """ + :param Version other + :rtype: bool + """ + return self.as_tuple() <= other.as_tuple() + + @property + def major(self): + """The major part of the version (read-only).""" + return self._values[0] + + @major.setter + def major(self, value): + raise AttributeError("Attribute 'major' is readonly") + + @property + def minor(self): + """The minor part of the version (read-only).""" + return self._values[1] + + @minor.setter + def minor(self, value): + raise AttributeError("Attribute 'minor' is readonly") + + @property + def patch(self): + """The patch part of the version (read-only).""" + return self._values[2] + + @patch.setter + def patch(self, value): + raise AttributeError("Attribute 'patch' is readonly") + + def as_tuple(self): + """ + :rtype: tuple + """ + return self._values + + +class Operator: + EQ = "=" + GT = ">" + GE = ">=" + LT = "<" + LE = "<=" + + +class VersionRange: + @classmethod + def operator_is_ok(self, operator): + return [Operator.GE, Operator.EQ, None].count(operator) + + @classmethod + def from_str(cls, input): + """ + :param str input + :rtype: VersionRange + :raises: ValueError + """ + m = re.match(r"^\s*([<>=]+)?\s*(\d+\.\d+\.\d+)\s*$", input) + res = m.groups() if m else None + if not res or not cls.operator_is_ok(res[0]): + raise ValueError( + "Unsupported version range: '{}'. Currently we only support ranges with stable versions and GE / EQ: '>= 1.2.3' / '= 1.2.3' / '1.2.3'".format( + input + ) + ) + + version = Version.from_str(res[1]) + + return cls(res[0], version) + + __slots__ = ("_operator", "_version") + + def __init__(self, operator, version): + """ + :param str operator + :raises: ValueError + """ + if not self.operator_is_ok(operator): + raise ValueError("Unsupported range operator '{}'".format(operator)) + + # None defaults to Operator.EQ + self._operator = operator or Operator.EQ + self._version = version + + @property + def operator(self): + """The comparison operator to be used (read-only).""" + return self._operator + + @operator.setter + def operator(self, value): + raise AttributeError("Attribute 'operator' is readonly") + + @property + def version(self): + """Version to be used with the operator (read-only).""" + return self._version + + @version.setter + def version(self, value): + raise AttributeError("Attribute 'version' is readonly") + + def is_satisfied_by(self, version): + """ + :param Version version + :rtype: bool + :raises: ValueError + """ + if self._operator == Operator.GE: + return version >= self._version + + if self._operator == Operator.EQ: + return version == self._version + + raise ValueError("Unsupported operator '{}'".format(self._operator)) diff --git a/build/plugins/lib/nots/semver/tests/test_version.py b/build/plugins/lib/nots/semver/tests/test_version.py new file mode 100644 index 00000000000..e6c0e44225d --- /dev/null +++ b/build/plugins/lib/nots/semver/tests/test_version.py @@ -0,0 +1,269 @@ +from functools import cmp_to_key + +from build.plugins.lib.nots.semver import Version + + +def test_from_str(): + # arrange + version_str = "1.2.3" + + # act + version = Version.from_str(version_str) + + # assert + assert version.major == 1 + assert version.minor == 2 + assert version.patch == 3 + + +def test_from_str_bad_version(): + # arrange + version_str = "best version imaginable" + error = None + + # act + try: + Version.from_str(version_str) + except Exception as exception: + error = exception + + # assert + assert error is not None + + +def test_is_stable_true(): + # arrange + version_str = "1.2.3" + + # act + assert + assert Version.is_stable(version_str) + + +def test_is_stable_false(): + # arrange + version_str = "1.2.3-beta1" + + # act + assert + assert not Version.is_stable(version_str) + + +def test_is_stable_incorrect(): + # arrange + version_str = "v1.2.3" + + # act + assert + assert not Version.is_stable(version_str) + + +def test_cmp_lt(): + # arrange + a = Version.from_str("1.2.3") + b = Version.from_str("1.2.5") + + # act + assert + assert Version.cmp(a, b) == -1 + + +def test_cmp_gt(): + # arrange + a = Version.from_str("1.2.3") + b = Version.from_str("1.2.2") + + # act + assert + assert Version.cmp(a, b) == 1 + + +def test_cmp_eq(): + # arrange + a = Version.from_str("1.2.3") + b = Version.from_str("1.2.3") + + # act + assert + assert Version.cmp(a, b) == 0 + + +def test_cmp_lt_str(): + # arrange + a = "1.2.3" + b = "1.2.5" + + # act + assert + assert Version.cmp(a, b) == -1 + + +def test_cmp_gt_str(): + # arrange + a = "1.2.3" + b = "1.2.2" + + # act + assert + assert Version.cmp(a, b) == 1 + + +def test_cmp_eq_str(): + # arrange + a = "1.2.3" + b = "1.2.3" + + # act + assert + assert Version.cmp(a, b) == 0 + + +def test_cmp_usage_in_sorted_asc(): + # arrange + unsorted = ["1.2.3", "2.4.2", "1.2.7"] + + # act + assert + assert sorted(unsorted, key=cmp_to_key(Version.cmp)) == ["1.2.3", "1.2.7", "2.4.2"] + + +def test_cmp_usage_in_sorted_desc(): + # arrange + unsorted = ["1.2.3", "2.4.2", "1.2.7"] + + # act + assert + assert sorted(unsorted, key=cmp_to_key(Version.cmp), reverse=True) == ["2.4.2", "1.2.7", "1.2.3"] + + +def test_init_negative_numbers(): + # arrange + major = 1 + minor = -2 + patch = 3 + + error = None + + # act + try: + Version(major, minor, patch) + except Exception as exception: + error = exception + + # assert + assert isinstance(error, ValueError) + assert str(error) == "'minor' is negative. A version can only be positive." + + +def test_eq(): + # arrange + version_a = Version.from_str("1.2.3") + version_b = Version.from_str("1.2.3") + + # act + assert + assert version_a == version_b + + +def test_eq_negative(): + # arrange + version_a = Version.from_str("1.2.3") + version_b = Version.from_str("3.2.1") + + # act + assert + assert not version_a == version_b + + +def test_eq_with_str(): + # arrange + version = Version.from_str("1.2.3") + + # act + assert + assert version == "1.2.3" + assert not version == "1.2.4" + + +def test_eq_with_invalid_str(): + # arrange + version = Version.from_str("1.2.3") + + # act + assert + assert not version == "bla-bla" + assert not version == "1.2.3-beta" + + +def test_ne(): + # arrange + version_a = Version.from_str("3.2.1") + version_b = Version.from_str("1.2.3") + + # act + assert + assert version_a != version_b + + +def test_ne_negative(): + # arrange + version_a = Version.from_str("1.2.3") + version_b = Version.from_str("1.2.3") + + # act + assert + assert not version_a != version_b + + +def test_ne_with_str(): + # arrange + version = Version.from_str("1.2.3") + + # act + assert + assert version != "1.2.4" + assert not version != "1.2.3" + + +def test_gt(): + # arrange + version_a = Version.from_str("3.2.1") + version_b = Version.from_str("1.2.3") + + # act + assert + assert version_a > version_b + + +def test_ge_equals(): + # arrange + version_a = Version.from_str("1.2.3") + version_b = Version.from_str("1.2.3") + + # act + assert + assert version_a >= version_b + + +def test_ge_exceeds(): + # arrange + version_a = Version.from_str("3.2.1") + version_b = Version.from_str("1.2.3") + + # act + assert + assert version_a >= version_b + + +def test_lt(): + # arrange + version_a = Version.from_str("1.2.3") + version_b = Version.from_str("3.2.1") + + # act + assert + assert version_a < version_b + + +def test_le_equals(): + # arrange + version_a = Version.from_str("1.2.3") + version_b = Version.from_str("1.2.3") + + # act + assert + assert version_a <= version_b + + +def test_le_is_less(): + # arrange + version_a = Version.from_str("1.2.3") + version_b = Version.from_str("3.2.1") + + # act + assert + assert version_a <= version_b + + +def test_to_tuple(): + # arrange + version = Version.from_str("1.2.3") + + # act + assert + assert version.as_tuple() == (1, 2, 3) diff --git a/build/plugins/lib/nots/semver/tests/test_version_range.py b/build/plugins/lib/nots/semver/tests/test_version_range.py new file mode 100644 index 00000000000..e0833b6dba2 --- /dev/null +++ b/build/plugins/lib/nots/semver/tests/test_version_range.py @@ -0,0 +1,107 @@ +from build.plugins.lib.nots.semver import Version, Operator, VersionRange + + +def test_from_str(): + checklist = [ + (">= 1.2.3", VersionRange, Operator.GE), + (">=1.2.3", VersionRange, Operator.GE), + (">= 1.2.3", VersionRange, Operator.GE), + (" >= 1.2.3 ", VersionRange, Operator.GE), + ("= 1.2.3", VersionRange, Operator.EQ), + ("=1.2.3", VersionRange, Operator.EQ), + ("= 1.2.3", VersionRange, Operator.EQ), + (" = 1.2.3 ", VersionRange, Operator.EQ), + (" 1.2.3", VersionRange, Operator.EQ), + ("1.2.3", VersionRange, Operator.EQ), + (" 1.2.3", VersionRange, Operator.EQ), + (" 1.2.3 ", VersionRange, Operator.EQ), + ] + + for range_str, expected_class, expected_operator in checklist: + range = VersionRange.from_str(range_str) + + assert isinstance(range, expected_class), f"unexpected class for '{range_str}': '{type(range)}'" + assert range.operator == expected_operator, f"unexpected operator for '{range_str}': '{range.operator}'" + + +def test_from_str_error(): + error_template = "Unsupported version range: '{}'. Currently we only support ranges with stable versions and GE / EQ: '>= 1.2.3' / '= 1.2.3' / '1.2.3'" + checklist = [ + (r"¯\_(ツ)_/¯", ValueError, error_template), + ("<= 1.2.3", ValueError, error_template), + ("<=1.2.3", ValueError, error_template), + ("<= 1.2.3", ValueError, error_template), + (" <= 1.2.3 ", ValueError, error_template), + ("< 1.2.3", ValueError, error_template), + ("<1.2.3", ValueError, error_template), + ("< 1.2.3", ValueError, error_template), + (" < 1.2.3 ", ValueError, error_template), + ("> 1.2.3", ValueError, error_template), + (">1.2.3", ValueError, error_template), + ("> 1.2.3", ValueError, error_template), + (" > 1.2.3 ", ValueError, error_template), + ("0.0.1-beta", ValueError, error_template), + ] + + for range_str, expected_class, expected_msg_template in checklist: + try: + VersionRange.from_str(range_str) + except Exception as exception: + error = exception + + assert isinstance(error, expected_class), f"unexpected error class for '{range_str}': '{type(error)}'" + assert str(error) == expected_msg_template.format( + range_str + ), f"unexpected error message for '{range_str}': '{error}'" + + +def test_init(): + checklist = [ + (Operator.GE, "1.2.3", Operator.GE, Version(1, 2, 3)), + (Operator.GE, " 1.2.3 ", Operator.GE, Version(1, 2, 3)), + (Operator.GE, "0.0.1", Operator.GE, Version(0, 0, 1)), + (Operator.EQ, "1.2.3", Operator.EQ, Version(1, 2, 3)), + (Operator.EQ, " 1.2.3 ", Operator.EQ, Version(1, 2, 3)), + (Operator.EQ, "0.0.1", Operator.EQ, Version(0, 0, 1)), + (None, "1.2.3", Operator.EQ, Version(1, 2, 3)), + (None, " 1.2.3 ", Operator.EQ, Version(1, 2, 3)), + (None, "0.0.1", Operator.EQ, Version(0, 0, 1)), + ] + + for operator_provided, version_provided, expected_operator, expected_version in checklist: + range = VersionRange(operator_provided, Version.from_str(version_provided)) + + assert ( + range.operator == expected_operator + ), f"unexpected operator for '{operator_provided}', '{version_provided}': '{range.operator}'" + assert ( + range.version == expected_version + ), f"unexpected result version for '{operator_provided}', '{version_provided}': '{range.version}'" + + +def test_is_satisfied(): + checklist = [ + (">= 1.2.3", "1.2.3", True), + (">= 1.2.3", "1.2.4", True), + (">= 1.2.3", "1.3.0", True), + (">= 1.2.3", "2.0.0", True), + (">= 1.2.3", "5.8.2", True), + (">= 1.2.3", "1.2.2", False), + (">= 1.2.3", "0.100.200", False), + ("= 1.2.3", "1.2.3", True), + ("1.2.3", "1.2.3", True), + ("1.2.3", "1.2.2", False), + ("1.2.3", "1.3.3", False), + ("1.2.3", "2.2.3", False), + ("12345.45634.456234", "12345.45634.456234", True), + ("0.0.0", "0.0.0", True), + ] + + for range_provided, version_provided, expected_result in checklist: + + version = Version.from_str(version_provided) + range = VersionRange.from_str(range_provided) + + assert ( + range.is_satisfied_by(version) == expected_result + ), f"Unexpected is_satisfied_by result for '{range_provided}', '{version_provided}': {(not expected_result)}" diff --git a/build/plugins/lib/nots/semver/tests/ya.make b/build/plugins/lib/nots/semver/tests/ya.make new file mode 100644 index 00000000000..b7605505f3d --- /dev/null +++ b/build/plugins/lib/nots/semver/tests/ya.make @@ -0,0 +1,14 @@ +PY3TEST() + +OWNER(g:frontend-build-platform) + +PEERDIR( + build/plugins/lib/nots/semver +) + +TEST_SRCS( + test_version_range.py + test_version.py +) + +END() diff --git a/build/plugins/lib/nots/semver/ya.make b/build/plugins/lib/nots/semver/ya.make new file mode 100644 index 00000000000..7d2be228f26 --- /dev/null +++ b/build/plugins/lib/nots/semver/ya.make @@ -0,0 +1,14 @@ +PY23_LIBRARY() + +OWNER(g:frontend-build-platform) + +PY_SRCS( + __init__.py + semver.py +) + +END() + +RECURSE_FOR_TESTS( + tests +) diff --git a/build/plugins/lib/nots/typescript/__init__.py b/build/plugins/lib/nots/typescript/__init__.py new file mode 100644 index 00000000000..e0b3ee901cf --- /dev/null +++ b/build/plugins/lib/nots/typescript/__init__.py @@ -0,0 +1,10 @@ +from .ts_config import DEFAULT_TS_CONFIG_FILE, TsConfig +from .ts_errors import TsError, TsValidationError + + +__all__ = [ + "DEFAULT_TS_CONFIG_FILE", + "TsConfig", + "TsError", + "TsValidationError", +] diff --git a/build/plugins/lib/nots/typescript/tests/ts_config.py b/build/plugins/lib/nots/typescript/tests/ts_config.py new file mode 100644 index 00000000000..4b8fd675b34 --- /dev/null +++ b/build/plugins/lib/nots/typescript/tests/ts_config.py @@ -0,0 +1,86 @@ +import pytest + +from build.plugins.lib.nots.typescript import TsConfig, TsValidationError + + +def test_ts_config_validate_valid(): + cfg = TsConfig(path="/tsconfig.json") + cfg.data = { + "compilerOptions": { + "rootDir": "./src", + "outDir": "./build", + }, + } + + cfg.validate() + + +def test_ts_config_validate_empty(): + cfg = TsConfig(path="/tsconfig.json") + + with pytest.raises(TsValidationError) as e: + cfg.validate() + + assert e.value.errors == [ + "'rootDir' option is required", + "'outDir' option is required", + ] + + +def test_ts_config_validate_invalid_common(): + cfg = TsConfig(path="/tsconfig.json") + cfg.data = { + "compilerOptions": { + "preserveSymlinks": True, + "rootDirs": [], + "outFile": "./foo.js", + }, + "references": [], + "files": [], + "include": [], + "exclude": [], + } + + with pytest.raises(TsValidationError) as e: + cfg.validate() + + assert e.value.errors == [ + "'rootDir' option is required", + "'outDir' option is required", + "'outFile' option is not supported", + "'preserveSymlinks' option is not supported due to pnpm limitations", + "'rootDirs' option is not supported, relative imports should have single root", + "'files' option is not supported, use 'include'", + "composite builds are not supported, use peerdirs in ya.make instead of 'references' option", + ] + + +def test_ts_config_validate_invalid_subdirs(): + cfg = TsConfig(path="/foo/tsconfig.json") + cfg.data = { + "compilerOptions": { + "rootDir": "/bar/src", + "outDir": "../bar/build", + }, + } + + with pytest.raises(TsValidationError) as e: + cfg.validate() + + assert e.value.errors == [ + "'outDir' should be a subdirectory of the module", + ] + + +def test_ts_config_compiler_options(): + cfg = TsConfig(path="/tsconfig.json") + + assert cfg.compiler_option("invalid") is None + + cfg.data = { + "compilerOptions": { + "rootDir": "src", + }, + } + + assert cfg.compiler_option("rootDir") == "src" diff --git a/build/plugins/lib/nots/typescript/tests/ya.make b/build/plugins/lib/nots/typescript/tests/ya.make new file mode 100644 index 00000000000..44798138bca --- /dev/null +++ b/build/plugins/lib/nots/typescript/tests/ya.make @@ -0,0 +1,13 @@ +PY23_TEST() + +OWNER(g:frontend-build-platform) + +TEST_SRCS( + ts_config.py +) + +PEERDIR( + build/plugins/lib/nots/typescript +) + +END() diff --git a/build/plugins/lib/nots/typescript/ts_config.py b/build/plugins/lib/nots/typescript/ts_config.py new file mode 100644 index 00000000000..c54121a9d1f --- /dev/null +++ b/build/plugins/lib/nots/typescript/ts_config.py @@ -0,0 +1,251 @@ +import copy +import os +import json + +from .ts_errors import TsError, TsValidationError + +from ..package_manager.base import utils + +DEFAULT_TS_CONFIG_FILE = "tsconfig.json" + + +def merge_dicts(d1, d2): + """ + Merges two dicts recursively assuming that both have similar structure. + If d1.x.y.z has different type than d2.x.y.z then d2 will override d1 and result value res.x.y.z == d2.x.y.z. + If corresponding values are lists then the result will have a sum of those lists. + """ + if isinstance(d1, dict) and isinstance(d2, dict): + for k in d2: + d1[k] = merge_dicts(d1[k], d2[k]) if k in d1 else d2[k] + else: + if isinstance(d1, list) and isinstance(d2, list): + return d1 + d2 + else: + return d2 + return d1 + + +class TsConfig(object): + @classmethod + def load(cls, path): + """ + :param path: tsconfig.json path + :type path: str + :rtype: TsConfig + """ + tsconfig = cls(path) + tsconfig.read() + + return tsconfig + + def __init__(self, path): + if not os.path.isabs(path): + raise TypeError("Absolute path required, given: {}".format(path)) + + self.path = path + self.data = {} + + def read(self): + try: + with open(self.path) as f: + self.data = json.load(f) + except Exception as e: + raise TsError("Failed to read tsconfig {}: {}".format(self.path, e)) + + def merge(self, rel_path, base_tsconfig): + """ + :param rel_path: relative path to the configuration file we are merging in. + It is required to set the relative paths correctly. + :type rel_path: str + :param base_tsconfig: base TsConfig we are merging with our TsConfig instance + :type base_tsconfig: dict + """ + if not base_tsconfig.data: + return + + def relative_path(p): + return os.path.normpath(os.path.join(rel_path, p)) + + base_config_data = copy.deepcopy(base_tsconfig.data) + + parameter_section_labels = ["compilerOptions", "typeAcquisition", "watchOptions"] + for opt_label in parameter_section_labels: + base_options = base_config_data.get(opt_label) + if not base_options: + continue + + new_options = self.data.get(opt_label) + for key in base_options: + val = base_options[key] + + # lists of paths + if key in ["extends", "outDir", "rootDir", "baseUrl", "include"]: + val = relative_path(val) + + # path string + elif key in ["rootDirs", "excludeDirectories", "excludeFiles"]: + val = map(relative_path, val) + + # dicts having paths as values + elif key in ["paths"]: + new_paths = new_options.get(key) + val = map(relative_path, val) + (new_paths if new_paths else []) + + base_options[key] = val + + if new_options and base_options: + base_options.update(new_options) + self.data[opt_label] = base_options + + base_config_data.update(self.data) + self.data = base_config_data + + def inline_extend(self, dep_paths): + """ + Merges the tsconfig parameters from configuration file referred by "extends" if any. + Relative paths are adjusted, current parameter values are prioritized higer than + those coming from extension file (according to TSC mergin rules). + Returns list of file paths for config files merged into the current configuration + :param dep_paths: dict of dependency names to their paths + :type dep_paths: dict + :rtype: list of str + """ + ext_value = self.data.get("extends") + if not ext_value: + return [] + + if ext_value.startswith("."): + base_config_path = ext_value + + else: + dep_name = utils.extract_package_name_from_path(ext_value) + # the rest part is the ext config path + file_path_start = len(dep_name) + 1 + file_path = ext_value[file_path_start:] + dep_path = dep_paths.get(dep_name) + if dep_path is None: + raise Exception( + "referenceing from {}, data: {}\n: Dependency '{}' not found in dep_paths: {}".format( + self.path, str(self.data), dep_name, dep_paths + ) + ) + base_config_path = os.path.join(dep_path, file_path) + + rel_path = os.path.dirname(base_config_path) + tsconfig_curdir_path = os.path.join(os.path.dirname(self.path), base_config_path) + if os.path.isdir(tsconfig_curdir_path): + base_config_path = os.path.join(base_config_path, DEFAULT_TS_CONFIG_FILE) + + # processing the base file recursively + base_config = TsConfig.load(os.path.join(os.path.dirname(self.path), base_config_path)) + paths = [base_config_path] + base_config.inline_extend(dep_paths) + + self.merge(rel_path, base_config) + del self.data["extends"] + + return paths + + def get_or_create_compiler_options(self): + """ + Returns ref to the "compilerOptions" dict. + :rtype: dict + """ + opts = self.data.get("compilerOptions") + if opts is None: + opts = {} + self.data["compilerOptions"] = opts + + return opts + + def prepend_include(self, value): + """ + Prepends `value` to `include` list + :param value: value to prepend + :type value: str + """ + includeList = self.data.get("include") + self.data["include"] = [value] + includeList + + def compiler_option(self, name, default=None): + """ + :param name: option key + :type name: str + :param default: default value + :type default: mixed + :rtype: mixed + """ + return self.get_or_create_compiler_options().get(name, default) + + def add_to_compiler_option(self, name, add_value): + """ + Merges the existing value with add_value for the option with label=name. + Merge is done recursively if the value is of a dict instance. + :param name: option key + :type name: str + :param value: option value to set + :type value: mixed + """ + default_value = {} if isinstance(add_value, dict) else [] + opts = self.get_or_create_compiler_options() + opts[name] = merge_dicts(opts.get(name, default_value), add_value) + + def inject_plugin(self, plugin): + """ + :param plugin: plugin dict (ts-patch compatible, see https://github.com/nonara/ts-patch) + :type plugin: dict of str + """ + opts = self.get_or_create_compiler_options() + if not opts.get("plugins"): + opts["plugins"] = [] + opts["plugins"].append(plugin) + + def validate(self): + """ + Checks whether the config is compatible with current toolchain. + """ + opts = self.get_or_create_compiler_options() + errors = [] + root_dir = opts.get("rootDir") + out_dir = opts.get("outDir") + config_dir = os.path.dirname(self.path) + + def is_mod_subdir(p): + return not os.path.isabs(p) and os.path.normpath(os.path.join(config_dir, p)).startswith(config_dir) + + if root_dir is None: + errors.append("'rootDir' option is required") + + if out_dir is None: + errors.append("'outDir' option is required") + elif not is_mod_subdir(out_dir): + errors.append("'outDir' should be a subdirectory of the module") + + if opts.get("outFile") is not None: + errors.append("'outFile' option is not supported") + + if opts.get("preserveSymlinks"): + errors.append("'preserveSymlinks' option is not supported due to pnpm limitations") + + if opts.get("rootDirs") is not None: + errors.append("'rootDirs' option is not supported, relative imports should have single root") + + if self.data.get("files") is not None: + errors.append("'files' option is not supported, use 'include'") + + if self.data.get("references") is not None: + errors.append("composite builds are not supported, use peerdirs in ya.make instead of 'references' option") + + if len(errors): + raise TsValidationError(self.path, errors) + + def write(self, path=None, indent=None): + """ + :param path: tsconfig path, defaults to original path + :type path: str + """ + if path is None: + path = self.path + + with open(path, "w") as f: + json.dump(self.data, f, indent=indent) diff --git a/build/plugins/lib/nots/typescript/ts_errors.py b/build/plugins/lib/nots/typescript/ts_errors.py new file mode 100644 index 00000000000..105851d9ec4 --- /dev/null +++ b/build/plugins/lib/nots/typescript/ts_errors.py @@ -0,0 +1,10 @@ +class TsError(RuntimeError): + pass + + +class TsValidationError(TsError): + def __init__(self, path, errors): + self.path = path + self.errors = errors + + super(TsValidationError, self).__init__("Invalid tsconfig {}:\n{}".format(path, "\n".join(errors))) diff --git a/build/plugins/lib/nots/typescript/ya.make b/build/plugins/lib/nots/typescript/ya.make new file mode 100644 index 00000000000..8847f9bbd30 --- /dev/null +++ b/build/plugins/lib/nots/typescript/ya.make @@ -0,0 +1,19 @@ +PY23_LIBRARY() + +OWNER(g:frontend-build-platform) + +PY_SRCS( + __init__.py + ts_errors.py + ts_config.py +) + +PEERDIR( + build/plugins/lib/nots/package_manager +) + +END() + +RECURSE_FOR_TESTS( + tests +) diff --git a/build/plugins/lib/nots/ya.make b/build/plugins/lib/nots/ya.make new file mode 100644 index 00000000000..b24c534033d --- /dev/null +++ b/build/plugins/lib/nots/ya.make @@ -0,0 +1,15 @@ +PY23_LIBRARY() + +OWNER(g:frontend-build-platform) + +PY_SRCS( + __init__.py +) + +PEERDIR( + build/plugins/lib/nots/package_manager + build/plugins/lib/nots/semver + build/plugins/lib/nots/typescript +) + +END() diff --git a/build/plugins/lib/test_const/__init__.py b/build/plugins/lib/test_const/__init__.py new file mode 100644 index 00000000000..a9cf8b2e74f --- /dev/null +++ b/build/plugins/lib/test_const/__init__.py @@ -0,0 +1,521 @@ +# coding: utf-8 +import re + + +RESTART_TEST_INDICATOR = '##restart-test##' +INFRASTRUCTURE_ERROR_INDICATOR = '##infrastructure-error##' + +RESTART_TEST_INDICATORS = [ + RESTART_TEST_INDICATOR, + "network error", +] + +UID_PREFIX_DELIMITER = '-' + +# testing +BIN_DIRECTORY = 'bin' +CANON_DATA_DIR_NAME = "canondata" +CANON_RESULT_FILE_NAME = "result.json" +CANONIZATION_RESULT_FILE_NAME = "canonization_res.json" +COMMON_CONTEXT_FILE_NAME = "common_test.context" +CONSOLE_SNIPPET_LIMIT = 5000 +FAKE_OUTPUT_EXTS = frozenset([".mf", ".fake", ".cpf", ".cpsf"]) +LIST_NODE_LOG_FILE = "test_list.log" +LIST_NODE_RESULT_FILE = "test_list.json" +LIST_RESULT_NODE_LOG_FILE = "list_result.log" +LIST_TRACE_FILE_NAME = "ytest_list.report.trace" +MAX_FILE_SIZE = 1024 * 1024 * 2 # 2 MB +MAX_TEST_RESTART_COUNT = 3 +NO_LISTED_TESTS = "NO_LISTED_TESTS" +REPORT_SNIPPET_LIMIT = 12000 +SANITIZER_ERROR_RC = 100 +SUITE_CONTEXT_FILE_NAME = "test.context" +TEST_LIST_FILE = "test_names_list.json" +TEST_SUBTEST_SEPARATOR = '::' +TESTING_OUT_DIR_NAME = "testing_out_stuff" +TESTING_OUT_RAM_DRIVE_DIR_NAME = "ram_drive_output" +TESTING_OUT_TAR_NAME = TESTING_OUT_DIR_NAME + ".tar.zstd" +TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S.%f" +TRACE_FILE_NAME = "ytest.report.trace" +TRUNCATING_IGNORE_FILE_LIST = {TRACE_FILE_NAME, SUITE_CONTEXT_FILE_NAME, "run_test.log"} +YT_RUN_TEST_DIR_NAME = "yt_run_test" +YT_RUN_TEST_TAR_NAME = "yt_run_test.tar" +COVERAGE_CFLAGS = ["-fprofile-instr-generate", "-fcoverage-mapping", "-DCLANG_COVERAGE"] +COVERAGE_LDFLAGS = ["-fprofile-instr-generate", "-fcoverage-mapping"] + +MANDATORY_ENV_VAR_NAME = 'YA_MANDATORY_ENV_VARS' + +BUILD_FLAGS_ALLOWED_IN_CONTEXT = { + 'AUTOCHECK', + # Required for local test runs + 'TESTS_REQUESTED', + 'USE_ARCADIA_PYTHON', + 'USE_SYSTEM_PYTHON', +} + +STYLE_TEST_TYPES = [ + "classpath.clash", + "clang_tidy", + "eslint", + "gofmt", + "govet", + "java.style", + "ktlint", + "custom_lint", +] + +REGULAR_TEST_TYPES = [ + "benchmark", + "boost_test", + "exectest", + "fuzz", + "g_benchmark", + "go_bench", + "go_test", + "gtest", + "hermione", + "hermione_beta", + "java", + "jest", + "py2test", + "py3test", + "pytest", + "unittest", +] + +TEST_NODE_OUTPUT_RESULTS = [TESTING_OUT_TAR_NAME, YT_RUN_TEST_TAR_NAME] + +# kvm +DEFAULT_RAM_REQUIREMENTS_FOR_KVM = 4 +MAX_RAM_REQUIREMENTS_FOR_KVM = 16 + +# distbuild +DISTBUILD_STATUS_REPORT_ENV_NAME = 'NODE_EXTENDED_STATUS_FILE_PATH' +DEFAULT_TEST_NODE_TIMEOUT = 15 * 60 +TEST_NODE_FINISHING_TIME = 5 * 60 + +# coverage +COVERAGE_FUNCTION_ENTRIES_LIMIT = 2 +COVERAGE_PYTHON_EXTS = (".py", ".pyx", ".pxi", ".pxd") + +COVERAGE_RESOLVED_FILE_NAME_PATTERN = "coverage_resolved.{}.json" +CPP_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("cpp") +GO_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("go") +JAVA_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("java") +NLG_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("nlg") +PYTHON2_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("py2") +PYTHON3_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("py3") +TS_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("ts") + +COVERAGE_CLANG_ENV_NAME = 'LLVM_PROFILE_FILE' +COVERAGE_GCOV_ENV_NAME = 'GCOV_PREFIX' +COVERAGE_GO_ENV_NAME = 'GO_COVERAGE_PREFIX' +COVERAGE_PYTHON_ENV_NAME = 'PYTHON_COVERAGE_PREFIX' +COVERAGE_TS_ENV_NAME = 'TS_COVERAGE_PREFIX' +COVERAGE_NLG_ENV_NAME = 'NLG_COVERAGE_FILENAME' +COVERAGE_ENV_VARS = ( + COVERAGE_CLANG_ENV_NAME, + COVERAGE_GCOV_ENV_NAME, + COVERAGE_GO_ENV_NAME, + COVERAGE_NLG_ENV_NAME, + COVERAGE_PYTHON_ENV_NAME, + COVERAGE_TS_ENV_NAME, +) +PYTHON_COVERAGE_PREFIX_FILTER_ENV_NAME = 'PYTHON_COVERAGE_PREFIX_FILTER' +PYTHON_COVERAGE_EXCLUDE_REGEXP_ENV_NAME = 'PYTHON_COVERAGE_EXCLUDE_REGEXP' + +CLANG_COVERAGE_TEST_TYPES = ( + "boost_test", + "coverage_extractor", + "exectest", + "gtest", + # java tests might use shared libraries + "java", + "py2test", + "py3test", + "pytest", + "unittest", +) +COVERAGE_TABLE_CHUNKS = 20 +COVERAGE_TESTS_TIMEOUT_FACTOR = 1.5 +COVERAGE_YT_PROXY = "hahn.yt.yandex.net" +COVERAGE_YT_ROOT_PATH = "//home/codecoverage" +COVERAGE_YT_TABLE_PREFIX = "datatable" + +# fuzzing +CORPUS_DATA_FILE_NAME = 'corpus.json' +CORPUS_DATA_ROOT_DIR = 'fuzzing' +CORPUS_DIR_NAME = 'corpus' +FUZZING_COVERAGE_ARGS = ['--sanitize-coverage=trace-div,trace-gep'] +FUZZING_COMPRESSION_COEF = 1.1 +FUZZING_DEFAULT_TIMEOUT = 3600 +FUZZING_FINISHING_TIME = 600 +FUZZING_TIMEOUT_RE = re.compile(r'(^|\s)-max_total_time=(?P<max_time>\d+)') +GENERATED_CORPUS_DIR_NAME = 'mined_corpus' +MAX_CORPUS_RESOURCES_ALLOWED = 5 + +# hermione +HERMIONE_REPORT_DIR_NAME = "hermione-report" +HERMIONE_REPORT_TAR_NAME = HERMIONE_REPORT_DIR_NAME + ".tar" +HERMIONE_REPORT_INDEX_FILE_NAME = "index.html" +HERMIONE_REPORT_DB_URLS_FILE_NAME = "databaseUrls.json" +HERMIONE_TESTS_READ_FILE_NAME = "tests.json" +HERMIONE_TESTS_READ_STDOUT_FILE_NAME = "read_tests.out" +HERMIONE_TESTS_READ_STDERR_FILE_NAME = "read_tests.err" +HERMIONE_TESTS_RUN_FILE_NAME = "test_results.jsonl" +HERMIONE_TESTS_RUN_STDOUT_FILE_NAME = "run_tests.out" +HERMIONE_TESTS_RUN_STDERR_FILE_NAME = "run_tests.err" + +# yt +YT_OPERATION_ID_SUBSTITUTION = '$OPERATION_ID' +YT_SANDBOX_ROOT_PREFIX = '$(YT_SANDBOX_ROOT)' + +# sandbox +SANDBOX_RUN_TEST_YT_TOKEN_VALUE_NAME = 'YA_MAKE_SANDBOX_RUN_TEST_YT_TOKEN' + +# global resources +ANDROID_AVD_ROOT = 'ANDROID_AVD_RESOURCE_GLOBAL' +ANDROID_SDK_ROOT = 'ANDROID_SDK_RESOURCE_GLOBAL' +COVERAGE_PUSH_TOOL_LOCAL = 'USE_SYSTEM_COVERAGE_PUSH_TOOL' +COVERAGE_PUSH_TOOL_RESOURCE = 'COVERAGE_PUSH_TOOL_RESOURCE_GLOBAL' +COVERAGE_PUSH_TOOL_LB_LOCAL = 'USE_SYSTEM_COVERAGE_PUSH_TOOL_LB' +COVERAGE_PUSH_TOOL_LB_RESOURCE = 'COVERAGE_PUSH_TOOL_LB_RESOURCE_GLOBAL' +FLAKE8_PY2_RESOURCE = 'FLAKE8_PY2_RESOURCE_GLOBAL' +FLAKE8_PY3_RESOURCE = 'FLAKE8_PY3_RESOURCE_GLOBAL' +GO_TOOLS_RESOURCE = 'GO_TOOLS_RESOURCE_GLOBAL' +JSTYLE_RUNNER_LIB = 'JSTYLE_LIB_RESOURCE_GLOBAL' +NODEJS_RESOURCE = 'NODEJS_RESOURCE_GLOBAL' +NYC_RESOURCE = 'NYC_RESOURCE_GLOBAL' +TEST_TOOL3_HOST = 'TEST_TOOL3_HOST_RESOURCE_GLOBAL' +TEST_TOOL3_HOST_LOCAL = 'TEST_TOOL3_HOST_LOCAL' +TEST_TOOL_HOST = 'TEST_TOOL_HOST_RESOURCE_GLOBAL' +TEST_TOOL_HOST_LOCAL = 'TEST_TOOL_HOST_LOCAL' +TEST_TOOL_TARGET = 'TEST_TOOL_TARGET_RESOURCE_GLOBAL' +TEST_TOOL_TARGET_LOCAL = 'TEST_TOOL_TARGET_LOCAL' +XCODE_TOOLS_RESOURCE = 'XCODE_TOOLS_ROOT_RESOURCE_GLOBAL' +WINE_TOOL = 'WINE_TOOL_RESOURCE_GLOBAL' +WINE32_TOOL = 'WINE32_TOOL_RESOURCE_GLOBAL' + + +class Enum(object): + @classmethod + def enumerate(cls): + return [v for k, v in cls.__dict__.items() if not k.startswith("_")] + + +class TestRequirements(Enum): + Container = 'container' + Cpu = 'cpu' + DiskUsage = 'disk_usage' + Dns = 'dns' + Kvm = 'kvm' + Network = 'network' + Ram = 'ram' + RamDisk = 'ram_disk' + SbVault = 'sb_vault' + YavSecret = 'yav' + + +class TestRequirementsConstants(Enum): + All = 'all' + AllCpuValue = 50 + AllRamDiskValue = 50 + MinCpu = 1 + MinRam = 1 + MinRamDisk = 0 + + @classmethod + def is_all_cpu(cls, value): + return value == cls.All + + @classmethod + def get_cpu_value(cls, value): + return cls.AllCpuValue if cls.is_all_cpu(value) else value + + @classmethod + def is_all_ram_disk(cls, value): + return value == cls.All + + @classmethod + def get_ram_disk_value(cls, value): + return cls.AllRamDiskValue if cls.is_all_ram_disk(value) else value + + +class TestSize(Enum): + Small = 'small' + Medium = 'medium' + Large = 'large' + + DefaultTimeouts = { + Small: 60, + Medium: 600, + Large: 3600, + } + + DefaultPriorities = { + Small: -1, + Medium: -2, + Large: -3, + } + + DefaultRequirements = { + Small: { + TestRequirements.Cpu: 1, + TestRequirements.Ram: 8, + # TestRequirements.Ram: 2, + TestRequirements.RamDisk: 0, + }, + Medium: { + TestRequirements.Cpu: 1, + TestRequirements.Ram: 8, + # TestRequirements.Ram: 4, + TestRequirements.RamDisk: 0, + }, + Large: { + TestRequirements.Cpu: 1, + TestRequirements.Ram: 8, + # TestRequirements.Ram: 8, + TestRequirements.RamDisk: 0, + }, + } + + MaxRequirements = { + Small: { + TestRequirements.Cpu: 4, + TestRequirements.Ram: 32, + # TestRequirements.Ram: 4, + TestRequirements.RamDisk: 32, + }, + Medium: { + TestRequirements.Cpu: 4, + # TestRequirements.Cpu: 8, + TestRequirements.Ram: 32, + # TestRequirements.Ram: 16, + TestRequirements.RamDisk: 32, + }, + Large: { + TestRequirements.Cpu: 4, + TestRequirements.Ram: 32, + TestRequirements.RamDisk: 32, + }, + } + + LargeMarker = "TL" + MediumMarker = "TM" + SmallMarker = "TS" + SizeMarkers = (LargeMarker, MediumMarker, SmallMarker) + + SizeShorthandMap = { + Large: LargeMarker, + Medium: MediumMarker, + Small: SmallMarker, + } + + @classmethod + def sizes(cls): + return cls.DefaultTimeouts.keys() + + @classmethod + def get_shorthand(cls, size): + return cls.SizeShorthandMap[size] + + @classmethod + def is_test_shorthand(cls, name): + return name in cls.SizeMarkers + + @classmethod + def get_default_timeout(cls, size): + if size in cls.DefaultTimeouts: + return cls.DefaultTimeouts[size] + raise Exception("Unknown test size '{}'".format(size)) + + @classmethod + def get_default_priorities(cls, size): + if size in cls.DefaultPriorities: + return cls.DefaultPriorities[size] + raise Exception("Unknown test size '{}'".format(size)) + + @classmethod + def get_default_requirements(cls, size): + if size in cls.DefaultRequirements: + return cls.DefaultRequirements[size] + raise Exception("Unknown test size '{}'".format(size)) + + @classmethod + def get_max_requirements(cls, size): + if size in cls.MaxRequirements: + return cls.MaxRequirements[size] + raise Exception("Unknown test size '{}'".format(size)) + + +class TestRunExitCode(Enum): + Skipped = 2 + Failed = 3 + TimeOut = 10 + InfrastructureError = 12 + + +class YaTestTags(Enum): + AlwaysMinimize = "ya:always_minimize" + Dirty = "ya:dirty" + DumpNodeEnvironment = "ya:dump_node_env" + DumpTestEnvironment = "ya:dump_test_env" + ExoticPlatform = "ya:exotic_platform" + External = "ya:external" + Fat = "ya:fat" + ForceDistbuild = "ya:force_distbuild" + ForceSandbox = "ya:force_sandbox" + GoNoSubtestReport = "ya:go_no_subtest_report" + GoTotalReport = "ya:go_total_report" + HugeLogs = "ya:huge_logs" + Manual = "ya:manual" + MapRootUser = "ya:map_root_user" + NoFuse = "ya:nofuse" + NoGracefulShutdown = "ya:no_graceful_shutdown" + Norestart = "ya:norestart" + Noretries = "ya:noretries" + NotAutocheck = "ya:not_autocheck" + Notags = "ya:notags" + PerfTest = "ya:perftest" + Privileged = "ya:privileged" + ReportChunks = "ya:report_chunks" + RunWithAsserts = "ya:relwithdebinfo" + SandboxCoverage = "ya:sandbox_coverage" + SequentialRun = "ya:sequential_run" + TraceOutput = "ya:trace_output" + YtRunner = "ya:yt" + + +class ServiceTags(Enum): + AnyTag = "ya:__any_tag" + + +class Status(object): + GOOD, XFAIL, FAIL, XPASS, MISSING, CRASHED, TIMEOUT = range(1, 8) + SKIPPED = -100 + NOT_LAUNCHED = -200 + CANON_DIFF = -300 + DESELECTED = -400 + INTERNAL = -int(2**31 - 1) # maxint + FLAKY = -50 + # XFAILDIFF is internal status and should be replaced + # with XFAIL or XPASS during verification stage of canon data + XFAILDIFF = -90 + + BY_NAME = { + 'crashed': CRASHED, + 'deselected': DESELECTED, + 'diff': CANON_DIFF, + 'fail': FAIL, + 'flaky': FLAKY, + 'good': GOOD, + 'internal': INTERNAL, + 'missing': MISSING, + 'not_launched': NOT_LAUNCHED, + 'skipped': SKIPPED, + 'timeout': TIMEOUT, + 'xfail': XFAIL, + 'xfaildiff': XFAILDIFF, + 'xpass': XPASS, + } + TO_STR = { + CANON_DIFF: 'diff', + CRASHED: 'crashed', + DESELECTED: 'deselected', + FAIL: 'fail', + FLAKY: 'flaky', + GOOD: 'good', + INTERNAL: 'internal', + MISSING: 'missing', + NOT_LAUNCHED: 'not_launched', + SKIPPED: 'skipped', + TIMEOUT: 'timeout', + XFAIL: 'xfail', + XFAILDIFF: 'xfaildiff', + XPASS: 'xpass', + } + + +class _Colors(object): + + _NAMES = [ + "blue", + "cyan", + "default", + "green", + "grey", + "magenta", + "red", + "white", + "yellow", + ] + _PREFIXES = ["", "light", "dark"] + + def __init__(self): + self._table = {} + for prefix in self._PREFIXES: + for value in self._NAMES: + name = value + if prefix: + name = "{}_{}".format(prefix, value) + value = "{}-{}".format(prefix, value) + self.__add_color(name.upper(), value) + + def __add_color(self, name, value): + self._table[name] = value + self.__setattr__(name, value) + + +Colors = _Colors() + + +class _Highlight(object): + + _MARKERS = { + # special + "RESET": "rst", + "IMPORTANT": "imp", + "UNIMPORTANT": "unimp", + "BAD": "bad", + "WARNING": "warn", + "GOOD": "good", + "PATH": "path", + "ALTERNATIVE1": "alt1", + "ALTERNATIVE2": "alt2", + "ALTERNATIVE3": "alt3", + } + + def __init__(self): + # setting attributes because __getattr__ is much slower + for attr, value in self._MARKERS.items(): + self.__setattr__(attr, value) + + +Highlight = _Highlight() + + +class _StatusColorMap(object): + # There should be no XFAILDIFF, because it's internal status. + # It should be replaced with XFAIL or XPASS during verification of canon data. + + _MAP = { + 'crashed': Highlight.WARNING, + 'deselected': Highlight.UNIMPORTANT, + 'diff': Highlight.BAD, + 'fail': Highlight.BAD, + 'flaky': Highlight.ALTERNATIVE3, + 'good': Highlight.GOOD, + 'internal': Highlight.BAD, + 'missing': Highlight.ALTERNATIVE1, + 'not_launched': Highlight.BAD, + 'skipped': Highlight.UNIMPORTANT, + 'timeout': Highlight.BAD, + 'xfail': Highlight.WARNING, + 'xpass': Highlight.WARNING, + } + + def __getitem__(self, item): + return self._MAP[item] + + +StatusColorMap = _StatusColorMap() diff --git a/build/plugins/lib/test_const/ya.make b/build/plugins/lib/test_const/ya.make new file mode 100644 index 00000000000..60f4867e46a --- /dev/null +++ b/build/plugins/lib/test_const/ya.make @@ -0,0 +1,9 @@ +OWNER(g:ymake) + +PY23_LIBRARY() + +PY_SRCS( + __init__.py +) + +END() diff --git a/build/plugins/lib/ya.make b/build/plugins/lib/ya.make new file mode 100644 index 00000000000..7e61d12080b --- /dev/null +++ b/build/plugins/lib/ya.make @@ -0,0 +1,7 @@ +OWNER(g:ymake)
+
+PY23_LIBRARY()
+ PY_SRCS(
+ _metric_resolvers.py
+ )
+END()
diff --git a/build/plugins/linker_script.py b/build/plugins/linker_script.py new file mode 100644 index 00000000000..a5432884c1c --- /dev/null +++ b/build/plugins/linker_script.py @@ -0,0 +1,12 @@ +def onlinker_script(unit, *args): + """ + @usage: LINKER_SCRIPT(Files...) + + Specify files to be used as a linker script + """ + for arg in args: + if not arg.endswith(".ld") and not arg.endswith(".ld.in"): + unit.message(['error', "Invalid linker script extension: {}".format(arg)]) + return + + unit.onglobal_srcs(list(args)) diff --git a/build/plugins/lj_archive.py b/build/plugins/lj_archive.py new file mode 100644 index 00000000000..9f071f3d87f --- /dev/null +++ b/build/plugins/lj_archive.py @@ -0,0 +1,46 @@ +def onlj_archive(unit, *args): + """ + @usage: LJ_ARCHIVE(NAME Name LuaFiles...) + Precompile .lua files using LuaJIT and archive both sources and results using sources names as keys + """ + + def iter_luas(l): + for a in l: + if a.endswith('.lua'): + yield a + + def iter_objs(l): + for a in l: + s = a[:-3] + 'raw' + unit.on_luajit_objdump(['OUT', s, a]) + yield s + + luas = list(iter_luas(args)) + objs = list(iter_objs(luas)) + + unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaScripts.inc', 'KEYS', ':'.join(luas)] + objs) + unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaSources.inc', 'KEYS', ':'.join(luas)] + luas) + + +def onlj_21_archive(unit, *args): + """ + @usage: LJ_21_ARCHIVE(NAME Name LuaFiles...) # deprecated + Precompile .lua files using LuaJIT 2.1 and archive both sources and results using sources names as keys + """ + + def iter_luas(l): + for a in l: + if a.endswith('.lua'): + yield a + + def iter_objs(l): + for a in l: + s = a[:-3] + 'raw' + unit.on_luajit_21_objdump(['OUT', s, a]) + yield s + + luas = list(iter_luas(args)) + objs = list(iter_objs(luas)) + + unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaScripts.inc', 'KEYS', ':'.join(luas)] + objs) + unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaSources.inc', 'KEYS', ':'.join(luas)] + luas) diff --git a/build/plugins/llvm_bc.py b/build/plugins/llvm_bc.py new file mode 100644 index 00000000000..afe46fa3861 --- /dev/null +++ b/build/plugins/llvm_bc.py @@ -0,0 +1,36 @@ +import sys + +from _common import rootrel_arc_src, sort_by_keywords, skip_build_root, stripext + + +def onllvm_bc(unit, *args): + free_args, kwds = sort_by_keywords({'SYMBOLS': -1, 'NAME': 1, 'GENERATE_MACHINE_CODE': 0, 'NO_COMPILE': 0}, args) + name = kwds['NAME'][0] + symbols = kwds.get('SYMBOLS') + obj_suf = unit.get('OBJ_SUF') + skip_compile_step = 'NO_COMPILE' in kwds + merged_bc = name + '_merged' + obj_suf + '.bc' + out_bc = name + '_optimized' + obj_suf + '.bc' + bcs = [] + for x in free_args: + rel_path = rootrel_arc_src(x, unit) + bc_path = '${ARCADIA_BUILD_ROOT}/' + skip_build_root(rel_path) + obj_suf + '.bc' + if not skip_compile_step: + if x.endswith('.c'): + llvm_compile = unit.onllvm_compile_c + elif x.endswith('.ll'): + llvm_compile = unit.onllvm_compile_ll + else: + llvm_compile = unit.onllvm_compile_cxx + llvm_compile([rel_path, bc_path]) + bcs.append(bc_path) + unit.onllvm_link([merged_bc] + bcs) + opt_opts = ['-O2', '-globalopt', '-globaldce'] + if symbols: + # XXX: '#' used instead of ',' to overcome ymake tendency to split everything by comma + opt_opts += ['-internalize', '-internalize-public-api-list=' + '#'.join(symbols)] + unit.onllvm_opt([merged_bc, out_bc] + opt_opts) + if 'GENERATE_MACHINE_CODE' in kwds: + unit.onllvm_llc([out_bc, '-O2']) + else: + unit.onresource([out_bc, '/llvm_bc/' + name]) diff --git a/build/plugins/macros_with_error.py b/build/plugins/macros_with_error.py new file mode 100644 index 00000000000..eceb8b9c421 --- /dev/null +++ b/build/plugins/macros_with_error.py @@ -0,0 +1,32 @@ +import sys + +import _common + +import ymake + + +def onmacros_with_error(unit, *args): + print >> sys.stderr, 'This macros will fail' + raise Exception('Expected fail in MACROS_WITH_ERROR') + + +def onrestrict_path(unit, *args): + if args: + if 'MSG' in args: + pos = args.index('MSG') + paths, msg = args[:pos], args[pos + 1 :] + msg = ' '.join(msg) + else: + paths, msg = args, 'forbidden' + if not _common.strip_roots(unit.path()).startswith(paths): + error_msg = "Path '[[imp]]{}[[rst]]' is restricted - [[bad]]{}[[rst]]. Valid path prefixes are: [[unimp]]{}[[rst]]".format( + unit.path(), msg, ', '.join(paths) + ) + ymake.report_configure_error(error_msg) + + +def onassert(unit, *args): + val = unit.get(args[0]) + if val and val.lower() == "no": + msg = ' '.join(args[1:]) + ymake.report_configure_error(msg) diff --git a/build/plugins/maps_mobile_idl.py b/build/plugins/maps_mobile_idl.py new file mode 100644 index 00000000000..1964e191927 --- /dev/null +++ b/build/plugins/maps_mobile_idl.py @@ -0,0 +1,1081 @@ +import os +import re +from collections import namedtuple + +from _common import sort_by_keywords + +Framework = namedtuple( + 'Framework', ['cpp_namespace_tokens', 'java_class_path', 'objc_framework_name', 'objc_framework_prefix'] +) + + +def _get_proto_header_file(proto_file_name): + return proto_file_name.split('.')[0] + '.pb.h' + + +def _get_appended_values(unit, key): + value = [] + raw_value = unit.get(key) + if raw_value: + value = filter(lambda x: len(x) > 0, raw_value.split(' ')) + assert len(value) == 0 or value[0] == '$' + key + return value[1:] if len(value) > 0 else value + + +def _load_framework_file_list(unit): + frameworks = [ + unit.resolve(unit.resolve_arc_path(os.sep.join(path.split(os.sep)[1:]))) + for path in unit.get('MAPKIT_IDL_FRAMEWORK_FILES').split(' ') + ] + return frameworks + + +def _require_framework_entry(entry, framework): + if entry not in framework: + raise Exception('No {} entry in {} framework'.format(entry, framework)) + + +def _read_framework(unit, framework_file): + file_path = unit.resolve(framework_file) + result = {} + with open(file_path, 'r') as f: + lineId = 0 + for line in f: + lineId += 1 + tokens = line.split('=') + if len(tokens) != 2: + raise Exception('Malformed idl framework file {} line {}'.format(framework_file, lineId)) + result[tokens[0].strip()] = tokens[1].strip() + + _require_framework_entry('CPP_NAMESPACE', result) + _require_framework_entry('JAVA_PACKAGE', result) + _require_framework_entry('OBJC_FRAMEWORK', result) + _require_framework_entry('OBJC_FRAMEWORK_PREFIX', result) + return Framework( + result['CPP_NAMESPACE'].split('.'), + result['JAVA_PACKAGE'], + result['OBJC_FRAMEWORK'], + result['OBJC_FRAMEWORK_PREFIX'], + ) + + +def _read_frameworks(unit): + framework_file_list = _load_framework_file_list(unit) + result = {} + for file_name in framework_file_list: + name = file_name.split(os.sep)[-1].split('.')[0] + result[name] = _read_framework(unit, file_name) + return result + + +def _extract_by_regexp(line, regexp): + re_match = regexp.search(line) + if not re_match: + return None + return re_match.group(1) + + +class RegExp: + OBJC_INFIX = r'\bobjc_infix\s*([^\s]+);' + + IMPORT = r'^import\s+"([^"]+)"' + + WEAK_INTERFACE = r'\bweak_ref\s+interface\b' + SHARED_INTERFACE = r'\bshared_ref\s+interface\b' + STRONG_INTERFACE = r'^\s*interface\b' + NATIVE_LISTENER = r'\bnative\s+listener\b' + STATIC_INTERFACE = r'\bstatic\s+interface\b' + VIEW_DELEGATE = r'\bview_delegate\b' + + CUSTOM_PROTO_HEADER = r'^\s*protoconv\s+"([^"]+)"\s*$' + BASED_ON_PROTO_START = r'\bbased\s+on(\s|$)' + BASED_ON_PROTO = r'\bbased\s+on\s+"([^"]+)"\s*:' + + CUSTOM_CPP_HEADER = r'^\s*cpp\s+"([^"]+)"\s*$' + STRUCT = r'\bstruct\b' + + LITE_STRUCT = r'\blite\s+struct\b' + BRIDGED_STRUCT = r'^(\s*options|\s*(navi_)?serializable|\s*abstract)*\s*struct\s+' + + LAMBDA_LISTENER = r'\blambda\s+listener\b' + LISTENER = r'^\s*listener\s+' + PLATFORM_INTERFACE = r'platform\s+interface' + + VARIANT = r'\bvariant\b' + + OPTIONAL = r'\boptional\b' + INT_64 = r'\bint64\b' + STRING = r'\bstring\b' + POINT = r'\bpoint\b' + BYTES = r'\bbytes\b' + VECTOR = r'\bvector\b' + DICTIONARY = r'\bdictionary\b' + ANY = r'\bany[^_]' + ENUM = r'\benum\b' + TIME = r'\b(time_interval|abs_timestamp|rel_timestamp)\b' + BITMAP = r'\bbitmap\b' + VIEW_PROVIDER = r'\bview_provider\b' + IMAGE_PROVIDER = r'\bimage_provider\b' + ANIMATED_IMAGE_PROVIDER = r'\banimated_image_provider\b' + MODEL_PROVIDER = r'\bmodel_provider\b' + ANIMATED_MODEL_PROVIDER = r'\banimated_model_provider\b' + COLOR = r'\bcolor\b' + PLATFORM_VIEW = r'\bplatform_view\b' + ERROR = r'\b(runtime\.)?Error\b' + TYPE_DICTIONARY = r'\btype_dictionary\b' + + SERIALIZABLE = r'\bserializable\b' + NAVI_SERIALIZABLE = r'\bnavi_serializable\b' + + +class OutputType: + BASE_HEADER = 1 + STRUCT_SOURCE = 2 + PROTOCONV_HEADER = 3 + PROTOCONV_SOURCE = 4 + ANDROID_HEADER = 5 + ANDROID_SOURCE = 6 + IOS_HEADER = 7 + IOS_SOURCE = 8 + IOS_PRIVATE_HEADER = 9 + IOS_BINDING_SOURCE = 10 + DART_CPP_HEADER = 11 + DART_CPP_SOURCE = 12 + DART_SOURCE = 13 + DART_SOURCE_PRIVATE = 14 + + +class OutputNameGenerator: + def __init__(self, file_path, frameworks): + path_tokens = file_path.split(os.sep) + framework_name = path_tokens[0] + self._framework = frameworks[framework_name] + self._cpp_namespace_tokens = self._framework.cpp_namespace_tokens + path_tokens[1:-1] + file_name = path_tokens[-1] + self._cpp_name = file_name.split('.')[0] + + name_tokens = self._cpp_name.split('_') + self._objc_name_core = ''.join((self._capitalize(token) for token in name_tokens)) + self._objc_name = self._framework.objc_framework_prefix + self._objc_name_core + + def set_objc_infix(self, objc_infix): + self._objc_name = self._framework.objc_framework_prefix + objc_infix + self._objc_name_core + + def is_header(self, output_type): + return output_type in [ + OutputType.BASE_HEADER, + OutputType.PROTOCONV_HEADER, + OutputType.ANDROID_HEADER, + OutputType.IOS_HEADER, + OutputType.IOS_PRIVATE_HEADER, + OutputType.DART_CPP_HEADER + ] + + def _cpp_file_name(self, extension, additional_tokens=[]): + path_tokens = self._cpp_namespace_tokens + additional_tokens + [self._cpp_name + extension] + return os.path.join(*path_tokens) + + def _dart_public_file_name(self, extension): + return self._cpp_file_name(extension) + + def _dart_private_file_name(self, extension): + path_tokens = ['src'] + self._cpp_namespace_tokens + [self._cpp_name + '_private' + extension] + return os.path.join(*path_tokens) + + def _objc_file_name(self, extension, additional_tokens=[]): + path_tokens = [self._framework.objc_framework_name] + additional_tokens + [self._objc_name + extension] + return os.path.join(*path_tokens) + + def _capitalize(self, word): + return word[:1].upper() + word[1:] + + def generate_name(self, output_type): + if output_type is OutputType.BASE_HEADER: + return self._cpp_file_name('.h') + + if output_type is OutputType.STRUCT_SOURCE: + return self._cpp_file_name('.cpp') + + if output_type is OutputType.PROTOCONV_HEADER: + return self._cpp_file_name('.conv.h') + + if output_type is OutputType.PROTOCONV_SOURCE: + return self._cpp_file_name('.conv.cpp') + + if output_type is OutputType.ANDROID_HEADER: + return self._cpp_file_name('_binding.h', ['internal', 'android']) + + if output_type is OutputType.ANDROID_SOURCE: + return self._cpp_file_name('_binding.cpp', ['internal', 'android']) + + if output_type is OutputType.IOS_HEADER: + return self._objc_file_name('.h') + + if output_type is OutputType.IOS_SOURCE: + return self._objc_file_name('.m') + + if output_type is OutputType.IOS_PRIVATE_HEADER: + return self._objc_file_name('_Private.h', ['Internal']) + + if output_type is OutputType.IOS_BINDING_SOURCE: + return self._objc_file_name('_Binding.mm') + + if output_type is OutputType.DART_CPP_SOURCE: + return self._cpp_file_name('_dart_binding.cpp') + + if output_type is OutputType.DART_SOURCE: + return self._dart_public_file_name('.dart') + + if output_type is OutputType.DART_CPP_HEADER: + return self._cpp_file_name('_dart_binding.h') + + if output_type is OutputType.DART_SOURCE_PRIVATE: + return self._dart_private_file_name('.dart') + + def generate_path(self, output_type): + name = self.generate_name(output_type) + + if self.is_header(output_type): + return os.path.join('include', name) + + return os.path.join('impl', name) + + +class ProcessContext: + def __init__(self, unit, frameworks, file_paths): + self.unit = unit + self.frameworks = frameworks + self.file_paths = file_paths + self.is_dart = unit.enabled("MAPKIT_DART_IDL") + self.is_ios = unit.enabled("OS_IOS") and not self.is_dart + self.is_android = unit.enabled("OS_ANDROID") and not self.is_dart + self.output_name_generator = None + self.add_generated_output_includes = unit.enabled("H_CPP_IDL") + + def runtime_include(self, include_name): + name_tokens = self.frameworks['runtime'].cpp_namespace_tokens + [include_name] + return os.path.join(*name_tokens) + + def runtime_objc_import(self, import_name): + return os.path.join( + self.frameworks['runtime'].objc_framework_name, + self.frameworks['runtime'].objc_framework_prefix + import_name, + ) + + +class BaseRule: + def __init__(self, context): + self.context = context + + def start_file(self, file_path): + pass + + def process_line(self, line): + pass + + def get_output_types(self): + return set() + + def get_output_includes(self): + return set() + + +class ObjcInfixRule(BaseRule): + def __init__(self, context): + BaseRule.__init__(self, context) + self._found_infix = False + self._reg_exp = re.compile(RegExp.OBJC_INFIX) + + def start_file(self, file_path): + BaseRule.start_file(self, file_path) + self.context.output_name_generator.set_objc_infix('') + self._found_infix = False + + def process_line(self, line): + BaseRule.process_line(self, line) + if self._found_infix: + return + + infix = _extract_by_regexp(line, self._reg_exp) + if infix: + self._found_infix = True + self.context.output_name_generator.set_objc_infix(infix) + + +class ImportRule(BaseRule): + def __init__(self, context): + BaseRule.__init__(self, context) + self._imports = set() + self._import_reg_exp = re.compile(RegExp.IMPORT) + + def start_file(self, file_path): + self._imports = set() + + def process_line(self, line): + BaseRule.process_line(self, line) + idl_import = _extract_by_regexp(line, self._import_reg_exp) + if idl_import: + self._imports.add(idl_import) + + def get_output_includes(self): + result = set() + for idl_import in self._imports: + if idl_import in self.context.file_paths: + continue + + name_generator = OutputNameGenerator(idl_import, self.context.frameworks) + result.add(name_generator.generate_name(OutputType.BASE_HEADER)) + + return result + + +class DefaultRule(BaseRule): + def __init__(self, context): + BaseRule.__init__(self, context) + + def get_output_types(self): + result = set() + result.add(OutputType.BASE_HEADER) + + if self.context.is_dart: + result.add(OutputType.DART_SOURCE) + result.add(OutputType.DART_CPP_SOURCE) + result.add(OutputType.DART_CPP_HEADER) + result.add(OutputType.DART_SOURCE_PRIVATE) + return result + + if self.context.is_ios: + result.add(OutputType.IOS_HEADER) + result.add(OutputType.IOS_SOURCE) + + return result + + def get_output_includes(self): + result = set() + + if self.context.is_dart: + result.add(self.context.runtime_include('bindings/traits.h')) + result.add(self.context.runtime_include('assert.h')) + result.add(self.context.runtime_include('bindings/flutter/base_types.h')) + result.add(self.context.runtime_include('bindings/flutter/exception.h')) + result.add(self.context.runtime_include('bindings/flutter/export.h')) + result.add(self.context.runtime_include('bindings/flutter/to_native.h')) + result.add(self.context.runtime_include('bindings/flutter/to_platform.h')) + return result + + result.add('yandex/maps/export.h') + result.add(self.context.runtime_include('assert.h')) + result.add(self.context.runtime_include('exception.h')) + result.add(self.context.runtime_include('bindings/traits.h')) + + if self.context.is_ios: + result.add(self.context.runtime_include('bindings/platform.h')) + result.add('Foundation/Foundation.h') + result.add(self.context.runtime_include('ios/object.h')) + result.add(self.context.runtime_include('bindings/ios/to_native.h')) + result.add(self.context.runtime_include('bindings/ios/to_platform.h')) + result.add(self.context.runtime_include('ios/exception.h')) + result.add(self.context.runtime_objc_import('Subscription.h')) + + if self.context.is_android: + result.add(self.context.runtime_include('bindings/platform.h')) + result.add(self.context.runtime_include('android/object.h')) + result.add(self.context.runtime_include('bindings/android/to_native.h')) + result.add(self.context.runtime_include('bindings/android/to_platform.h')) + result.add(self.context.runtime_include('exception.h')) + + return result + + +class CheckRule(BaseRule): + def __init__( + self, + context, + output_types=set(), + output_includes=set(), + ios_output_types=set(), + ios_output_includes=set(), + android_output_types=set(), + android_output_includes=set(), + ): + BaseRule.__init__(self, context) + self._output_types = output_types + self._output_includes = output_includes + self._ios_output_types = ios_output_types + self._ios_output_includes = ios_output_includes + self._android_output_types = android_output_types + self._android_output_includes = android_output_includes + + def triggered_on_file(self): + pass + + def get_output_types(self): + result = set() + if self.triggered_on_file(): + result.update(self._output_types) + + if self.context.is_ios: + result.update(self._ios_output_types) + + if self.context.is_android: + result.update(self._android_output_types) + + return result + + def get_output_includes(self): + result = set() + + if self.triggered_on_file(): + result.update(self._output_includes) + + if self.context.is_ios: + result.update(self._ios_output_includes) + + if self.context.is_android: + result.update(self._android_output_includes) + + return result + + +class OrRule(CheckRule): + def __init__(self, check_rules, *args, **kwargs): + CheckRule.__init__(self, *args, **kwargs) + self._rules = check_rules + + def triggered_on_file(self): + return any((rule.triggered_on_file() for rule in self._rules)) + + +class AndRule(CheckRule): + def __init__(self, check_rules, *args, **kwargs): + CheckRule.__init__(self, *args, **kwargs) + self._rules = check_rules + + def triggered_on_file(self): + return all((rule.triggered_on_file() for rule in self._rules)) + + +class RegExpRule(CheckRule): + def __init__(self, reg_exp_string, *args, **kwargs): + CheckRule.__init__(self, *args, **kwargs) + self._reg_exp = re.compile(reg_exp_string) + self._reg_exp_found_file = False + + def start_file(self, file_path): + CheckRule.start_file(self, file_path) + self._reg_exp_found_file = False + + def process_line(self, line): + CheckRule.process_line(self, line) + if self._reg_exp_found_file: + return + + if self._reg_exp.search(line) is not None: + self._reg_exp_found_file = True + + def triggered_on_file(self): + return self._reg_exp_found_file + + +class ProtoRule(BaseRule): + def __init__(self, context): + BaseRule.__init__(self, context) + self._file_has_non_custom_proto = False + self._currently_custom_proto = False + self._currently_based_on = False + self._running_line = '' + self._custom_proto_headers = set() + self._proto_files = set() + + self._custom_proto_reg_exp = re.compile(RegExp.CUSTOM_PROTO_HEADER) + self._based_on_proto_start_reg_exp = re.compile(RegExp.BASED_ON_PROTO_START) + self._based_on_proto_reg_exp = re.compile(RegExp.BASED_ON_PROTO) + + def start_file(self, file_path): + BaseRule.start_file(self, file_path) + self._currently_custom_proto = False + self._file_has_non_custom_proto = False + self._currently_based_on = False + self._running_line = '' + + def process_line(self, line): + BaseRule.process_line(self, line) + proto_header = _extract_by_regexp(line, self._custom_proto_reg_exp) + if proto_header: + self._custom_proto_headers.add(proto_header) + self._currently_based_on = False + self._running_line = '' + + self._currently_custom_proto = True + return + + if self._based_on_proto_start_reg_exp.search(line) is not None: + self._currently_based_on = True + self._running_line = '' + + if self._currently_based_on: + self._running_line += '\n' + line + proto_file = _extract_by_regexp(self._running_line, self._based_on_proto_reg_exp) + if proto_file: + self._currently_based_on = False + self._running_line = '' + self._proto_files.add(proto_file) + + if self._currently_custom_proto: + self._currently_custom_proto = False + else: + self._file_has_non_custom_proto = True + + def get_output_types(self): + if self._file_has_non_custom_proto: + return {OutputType.PROTOCONV_HEADER, OutputType.PROTOCONV_SOURCE} + return set() + + def get_output_includes(self): + result = set() + result.update(self._custom_proto_headers) + result.update((proto_file.split('.')[0] + '.pb.h' for proto_file in self._proto_files)) + + if self._file_has_non_custom_proto: + result.update({'vector'}) + + return result + + +class StructImplementationRule(BaseRule): + def __init__(self, context): + BaseRule.__init__(self, context) + self._file_has_non_custom_struct = False + self._custom_cpp_headers = set() + self._currently_custom_struct = False + + self._custom_cpp_header_reg_exp = re.compile(RegExp.CUSTOM_CPP_HEADER) + self._struct_reg_exp = re.compile(RegExp.STRUCT) + + def start_file(self, file_path): + BaseRule.start_file(self, file_path) + self._currently_custom_struct = False + self._file_has_non_custom_struct = False + + def process_line(self, line): + BaseRule.process_line(self, line) + + cpp_header = _extract_by_regexp(line, self._custom_cpp_header_reg_exp) + if cpp_header: + self._custom_cpp_headers.add(cpp_header) + self._currently_custom_struct = True + return + + if not self._file_has_non_custom_struct: + if self._struct_reg_exp.search(line) is not None: + if self._currently_custom_struct: + self._currently_custom_struct = False + else: + self._file_has_non_custom_struct = True + + def get_output_types(self): + result = set() + if self._file_has_non_custom_struct: + result.add(OutputType.STRUCT_SOURCE) + if self.context.is_ios: + result.add(OutputType.IOS_BINDING_SOURCE) + + return result + + def get_output_includes(self): + return self._custom_cpp_headers + + +class IdlFileProcessor: + def __init__(self, unit, frameworks, file_paths): + self._context = ProcessContext(unit, frameworks, file_paths) + self._resolved_idl_dir = unit.resolve(unit.resolve_arc_path(unit.path())) + self._outputs = set() + self._output_includes = set() + + self._rules = set() + + self._rules.add(ObjcInfixRule(self._context)) + self._rules.add(DefaultRule(self._context)) + self._rules.add(ImportRule(self._context)) + self._rules.add(ProtoRule(self._context)) + self._rules.add(StructImplementationRule(self._context)) + + view_delegate_rule = self._create_reg_exp_rule( + RegExp.VIEW_DELEGATE, output_includes={self._context.runtime_include('view/view_delegate.h')} + ) + + weak_interface_rule = self._create_or_rule( + rules={ + self._create_reg_exp_rule(RegExp.WEAK_INTERFACE), + view_delegate_rule, + }, + output_includes={'boost/any.hpp', 'memory', self._context.runtime_include('platform_holder.h')}, + ) + + strong_interface_rule = self._create_or_rule( + rules={ + self._create_reg_exp_rule(RegExp.STRONG_INTERFACE), + self._create_reg_exp_rule(RegExp.NATIVE_LISTENER), + } + ) + + non_static_interface_rule = self._create_or_rule( + rules={self._create_reg_exp_rule(RegExp.SHARED_INTERFACE), strong_interface_rule, weak_interface_rule}, + ios_output_types={OutputType.IOS_PRIVATE_HEADER}, + ) + + # interface rule + self._create_or_rule( + rules={self._create_reg_exp_rule(RegExp.STATIC_INTERFACE), non_static_interface_rule}, + ios_output_types={OutputType.IOS_BINDING_SOURCE}, + android_output_types={OutputType.ANDROID_SOURCE}, + ios_output_includes={'memory'}, + ) + + bridged_struct_rule = self._create_reg_exp_rule( + RegExp.BRIDGED_STRUCT, + output_includes={'memory', self._context.runtime_include('bindings/platform.h')}, + android_output_includes={self._context.runtime_include('bindings/android/internal/new_serialization.h')}, + ) + + # struct rule + self._create_or_rule( + rules={self._create_reg_exp_rule(RegExp.LITE_STRUCT), bridged_struct_rule}, + ios_output_types={OutputType.IOS_PRIVATE_HEADER}, + android_output_types={OutputType.ANDROID_HEADER, OutputType.ANDROID_SOURCE}, + ios_output_includes={self._context.runtime_objc_import('NativeObject.h')}, + ) + + lambda_listener_rule = self._create_reg_exp_rule( + RegExp.LAMBDA_LISTENER, + output_includes={'functional'}, + android_output_includes={self._context.runtime_include('verify_and_run.h')}, + ios_output_includes={self._context.runtime_include('verify_and_run.h')}, + ) + + # listener rule + self._create_or_rule( + rules={ + self._create_reg_exp_rule(RegExp.PLATFORM_INTERFACE), + self._create_reg_exp_rule(RegExp.LISTENER), + lambda_listener_rule, + }, + ios_output_types={OutputType.IOS_PRIVATE_HEADER, OutputType.IOS_BINDING_SOURCE}, + android_output_types={OutputType.ANDROID_HEADER, OutputType.ANDROID_SOURCE}, + output_includes={'memory'}, + android_output_includes={'string', self._context.runtime_include('verify_and_run.h')}, + ios_output_includes={self._context.runtime_include('verify_and_run.h')}, + ) + + if self._context.unit.enabled("MAPS_MOBILE_USE_STD_VARIANT"): + variant_header = 'variant' + variant_serialization_header = self.context.runtime_include('serialization/variant.hpp') + else: + variant_header = 'boost/variant.hpp' + variant_serialization_header = 'boost/serialization/variant.hpp' + + variant_rule = self._create_reg_exp_rule( + RegExp.VARIANT, + ios_output_types={OutputType.IOS_PRIVATE_HEADER, OutputType.IOS_BINDING_SOURCE}, + output_includes={variant_header, 'boost/variant/recursive_wrapper.hpp'}, + ios_output_includes={ + self._context.runtime_include('bindings/ios/to_platform_fwd.h'), + self._context.runtime_include('bindings/ios/to_native_fwd.h'), + 'type_traits', + }, + ) + + optional_rule = self._create_reg_exp_rule(RegExp.OPTIONAL, output_includes={'optional'}) + # int64 rule + self._create_reg_exp_rule(RegExp.INT_64, output_includes={'cstdint'}) + + string_rule = self._create_reg_exp_rule( + RegExp.STRING, output_includes={'string', self._context.runtime_include('bindings/platform.h')} + ) + + point_rule = self._create_reg_exp_rule( + RegExp.POINT, + output_includes={'Eigen/Geometry', self._context.runtime_include('bindings/point_traits.h')}, + android_output_includes={ + self._context.runtime_include('bindings/android/point_to_native.h'), + self._context.runtime_include('bindings/android/point_to_platform.h'), + }, + ios_output_includes={ + self._context.runtime_include('bindings/ios/point_to_native.h'), + self._context.runtime_include('bindings/ios/point_to_platform.h'), + 'UIKit/UIKit.h', + }, + ) + + bytes_rule = self._create_reg_exp_rule(RegExp.BYTES, output_includes={'cstdint', 'vector'}) + + vector_rule = self._create_reg_exp_rule( + RegExp.VECTOR, + output_includes={'memory', self._context.runtime_include('bindings/platform.h')}, + android_output_includes={ + self._context.runtime_include('bindings/android/vector_to_native.h'), + self._context.runtime_include('bindings/android/vector_to_platform.h'), + }, + ios_output_includes={ + self._context.runtime_include('bindings/ios/vector_to_native.h'), + self._context.runtime_include('bindings/ios/vector_to_platform.h'), + }, + ) + + dictionary_rule = self._create_reg_exp_rule( + RegExp.DICTIONARY, + output_includes={'memory', self._context.runtime_include('bindings/platform.h')}, + android_output_includes={ + self._context.runtime_include('bindings/android/dictionary_to_native.h'), + self._context.runtime_include('bindings/android/dictionary_to_platform.h'), + }, + ios_output_includes={ + self._context.runtime_include('bindings/ios/dictionary_to_native.h'), + self._context.runtime_include('bindings/ios/dictionary_to_platform.h'), + }, + ) + + # any rule + self._create_reg_exp_rule( + RegExp.ANY, output_includes={'boost/any.hpp', self._context.runtime_include('bindings/platform.h')} + ) + + time_rule = self._create_reg_exp_rule(RegExp.TIME, output_includes={self._context.runtime_include('time.h')}) + + # bitmap rule + self._create_reg_exp_rule( + RegExp.BITMAP, + output_includes={self._context.runtime_include('platform_bitmap.h')}, + ios_output_includes={'UIKit/UIKit.h'}, + ) + + # image_provider rule + self._create_reg_exp_rule( + RegExp.IMAGE_PROVIDER, + output_includes={self._context.runtime_include('image/image_provider.h')}, + android_output_includes={self._context.runtime_include('image/android/image_provider_binding.h')}, + ios_output_includes={self._context.runtime_include('image/ios/image_provider_binding.h'), 'UIKit/UIKit.h'}, + ) + + # animated_image_provider rule + self._create_reg_exp_rule( + RegExp.ANIMATED_IMAGE_PROVIDER, + output_includes={self._context.runtime_include('image/animated_image_provider.h')}, + android_output_includes={self._context.runtime_include('image/android/animated_image_provider_binding.h')}, + ios_output_includes={ + self._context.runtime_include('image/ios/animated_image_provider_binding.h'), + self._context.runtime_objc_import('AnimatedImageProvider.h'), + }, + ) + + # model_provider and animated_model_provider rules + model_provider_rule = self._create_reg_exp_rule( + RegExp.MODEL_PROVIDER, output_includes={self._context.runtime_include('model/model_provider.h')} + ) + animated_model_provider_rule = self._create_reg_exp_rule( + RegExp.ANIMATED_MODEL_PROVIDER, + output_includes={self._context.runtime_include('model/animated_model_provider.h')}, + ) + if not unit.enabled('MAPS_MOBILE_PUBLIC_API'): + self._create_or_rule( + rules={model_provider_rule}, + android_output_includes={self._context.runtime_include('model/android/model_provider_binding.h')}, + ios_output_includes={ + self._context.runtime_include('model/ios/model_provider_binding.h'), + self._context.runtime_objc_import('ModelProvider.h'), + }, + ) + + self._create_or_rule( + rules={animated_model_provider_rule}, + android_output_includes={ + self._context.runtime_include('model/android/animated_model_provider_binding.h') + }, + ios_output_includes={ + self._context.runtime_include('model/ios/animated_model_provider_binding.h'), + self._context.runtime_objc_import('AnimatedModelProvider.h'), + }, + ) + + # view_provider rule + self._create_reg_exp_rule( + RegExp.VIEW_PROVIDER, + output_includes={self._context.runtime_include('ui_view/view_provider.h')}, + android_output_includes={self._context.runtime_include('ui_view/android/view_provider_binding.h')}, + ios_output_includes={ + self._context.runtime_include('ui_view/ios/view_provider_binding.h'), + self._context.runtime_objc_import('ViewProvider.h'), + }, + ) + + # platform_view rule + self._create_reg_exp_rule( + RegExp.PLATFORM_VIEW, + output_includes={self._context.runtime_include('view/platform_view.h')}, + android_output_includes={self._context.runtime_include('view/android/to_native.h')}, + ios_output_includes={ + self._context.runtime_include('view/ios/to_native.h'), + self._context.runtime_objc_import('PlatformView_Fwd.h'), + self._context.runtime_objc_import('PlatformView_Private.h'), + }, + ) + + # type_dictionary rule + self._create_reg_exp_rule( + RegExp.TYPE_DICTIONARY, + output_includes={ + self._context.runtime_include('bindings/platform.h'), + self._context.runtime_include('bindings/type_dictionary.h'), + }, + android_output_includes={ + self._context.runtime_include('bindings/android/type_dictionary_to_native.h'), + self._context.runtime_include('bindings/android/type_dictionary_to_platform.h'), + }, + ios_output_includes={ + self._context.runtime_include('bindings/ios/type_dictionary_to_native.h'), + self._context.runtime_include('bindings/ios/type_dictionary_to_platform.h'), + self._context.runtime_objc_import('TypeDictionary.h'), + }, + ) + + # color rule + self._create_reg_exp_rule( + RegExp.COLOR, + output_includes={self._context.runtime_include('color.h')}, + ios_output_includes={'UIKit/UIKit.h'}, + ) + + # error rule + self._create_reg_exp_rule( + RegExp.ERROR, + android_output_includes={self._context.runtime_include('android/make_error.h')}, + ios_output_includes={self._context.runtime_include('ios/make_error.h')}, + ) + + navi_serialization = self._context.unit.enabled('MAPS_MOBILE_ENABLE_NAVI_SERIALIZATION') + if navi_serialization: + serialization_rule = self._create_or_rule( + {self._create_reg_exp_rule(RegExp.SERIALIZABLE), self._create_reg_exp_rule(RegExp.NAVI_SERIALIZABLE)} + ) + else: + serialization_rule = self._create_reg_exp_rule(RegExp.SERIALIZABLE) + + self._serialization_rule = self._create_or_rule( + rules={serialization_rule, variant_rule}, + output_includes={ + 'boost/serialization/nvp.hpp', + self._context.runtime_include('serialization/ptr.h'), + self._context.runtime_include('bindings/internal/archive_generator.h'), + self._context.runtime_include('bindings/internal/archive_reader.h'), + self._context.runtime_include('bindings/internal/archive_writer.h'), + }, + ) + + # point serialization rule + self._create_serialization_rule(point_rule, self._context.runtime_include('serialization/math.h')) + + # optional serialization rule + self._create_serialization_rule( + optional_rule, self._context.runtime_include('serialization/serialization_std.h') + ) + + # bridged struct serialization rule + self._create_serialization_rule(bridged_struct_rule, self._context.runtime_include('bindings/export.h')) + + # time serialization rule + self._create_serialization_rule(time_rule, self._context.runtime_include('serialization/chrono.h')) + + # string serialization rule + self._create_serialization_rule(string_rule, 'boost/serialization/string.hpp') + + # bytes serialization rule + self._create_serialization_rule(bytes_rule, 'boost/serialization/vector.hpp') + + # vector serialization rule + self._create_serialization_rule(vector_rule, 'boost/serialization/vector.hpp') + + # dictionary serialization rule + self._create_serialization_rule(dictionary_rule, 'boost/serialization/map.hpp') + + # variant serialization rule + self._create_serialization_rule(variant_rule, variant_serialization_header) + + def _create_reg_exp_rule(self, reg_exp_string, *args, **kwargs): + rule = RegExpRule(reg_exp_string, self._context, *args, **kwargs) + self._rules.add(rule) + return rule + + def _create_or_rule(self, rules, *args, **kwargs): + rule = OrRule(rules, self._context, *args, **kwargs) + self._rules.add(rule) + return rule + + def _create_and_rule(self, rules, *args, **kwargs): + rule = AndRule(rules, self._context, *args, **kwargs) + self._rules.add(rule) + return rule + + def _create_serialization_rule(self, additional_rule, serialization_header): + rule = self._create_and_rule( + rules={self._serialization_rule, additional_rule}, output_includes={serialization_header} + ) + return rule + + def _split_and_remove_comments(self, input_file): + inside_comment = False + for line in input_file: + current_line = line + + if inside_comment: + closing_index = current_line.find("*/") + if closing_index == -1: + continue + current_line = current_line[closing_index + 2 :] + inside_comment = False + + oneline_index = current_line.find("//") + if oneline_index != -1: + current_line = current_line[:oneline_index] + + opening_index = current_line.find("/*") + while opening_index != -1: + closing_index = current_line.find("*/") + if closing_index == -1: + current_line = current_line[:opening_index] + inside_comment = True + else: + current_line = current_line[:opening_index] + current_line[closing_index + 2 :] + opening_index = current_line.find("/*") + + yield current_line + + def _should_add_to_output_includes(self, output_type): + return self._context.add_generated_output_includes and self._context.output_name_generator.is_header( + output_type + ) + + def process_files(self): + for file_path in self._context.file_paths: + self._context.output_name_generator = OutputNameGenerator(file_path, self._context.frameworks) + + for rule in self._rules: + rule.start_file(file_path) + + with open(os.path.join(self._resolved_idl_dir, file_path), 'r') as f: + for line in self._split_and_remove_comments(f): + for rule in self._rules: + rule.process_line(line) + + for rule in self._rules: + for output_type in rule.get_output_types(): + self._outputs.add(self._context.output_name_generator.generate_path(output_type)) + + if self._should_add_to_output_includes(output_type): + self._output_includes.add(self._context.output_name_generator.generate_name(output_type)) + + self._output_includes.update(rule.get_output_includes()) + + def get_outputs(self): + return self._outputs + + def get_output_includes(self): + return self._output_includes + + +def process_files(unit, file_paths): + frameworks = _read_frameworks(unit) + + processor = IdlFileProcessor(unit, frameworks, file_paths) + processor.process_files() + outputs = processor.get_outputs() + output_includes = processor.get_output_includes() + + return (outputs, output_includes) + + +def on_process_maps_mobile_idl(unit, *args): + if not unit.enabled('MAPSMOBI_BUILD_TARGET'): + return + + idl_files, kwds = sort_by_keywords({'FILTER': -1, 'FILTER_OUT': -1, 'GLOBAL_OUTPUTS': 0}, args) + + if len(idl_files) == 0: + return + + is_global_outputs = 'GLOBAL_OUTPUTS' in kwds + filter_in = kwds.get('FILTER', []) + filter_out = kwds.get('FILTER_OUT', []) + + is_java_idl = unit.enabled("JAVA_IDL") + is_dart_idl = unit.enabled("MAPKIT_DART_IDL") + + outputs, output_includes = process_files(unit, idl_files) + + if filter_in: + outputs = [o for o in outputs if any([o.endswith(x) for x in filter_in])] + if filter_out: + outputs = [o for o in outputs if not any([o.endswith(x) for x in filter_out])] + + if len(outputs) == 0 and not is_java_idl: + return + + base_out_dir = '${{ARCADIA_BUILD_ROOT}}/{}'.format(unit.path()[3:]) + unit.onaddincl(['GLOBAL', '{}/include'.format(base_out_dir)]) + + include_dirs = _get_appended_values(unit, 'MAPKIT_IDL_INCLUDES') + include_dirs.append(unit.path()[3:]) + + framework_dir = unit.get('MAPKIT_IDL_FRAMEWORK') + + extra_inputs = unit.get('MAPKIT_IDL_EXTRA_INPUTS').split(' ') + + idl_args = [] + idl_args.extend(['OUT_BASE_ROOT', base_out_dir, 'OUT_ANDROID_ROOT', base_out_dir, 'OUT_IOS_ROOT', base_out_dir]) + + if framework_dir: + idl_args.extend(['FRAMEWORK_DIRS', framework_dir]) + + if include_dirs: + idl_args.append('INCLUDES') + idl_args.extend(include_dirs) + + idl_args.append('IN') + idl_args.extend(idl_files) + if extra_inputs: + idl_args.extend(extra_inputs) + + sorted_outputs = sorted(outputs) + dart_outputs = [] + global_outputs = [] + + if is_dart_idl: + dart_outputs = [x for x in sorted_outputs if x.endswith('.dart')] + if is_global_outputs: + global_outputs = [x for x in sorted_outputs if x.endswith('.cpp')] + elif not is_java_idl: + if is_global_outputs: + global_outputs = [x for x in sorted_outputs if x.endswith(('.cpp', '.m', '.mm'))] + + if not is_java_idl: + non_global_outputs = sorted(set(outputs) - set(global_outputs) - set(dart_outputs)) + + if global_outputs: + idl_args.append('OUT_NOAUTO') + idl_args.extend(global_outputs + dart_outputs) + unit.onglobal_srcs(global_outputs) + + if non_global_outputs: + idl_args.append('OUT') + idl_args.extend(non_global_outputs) + + idl_args.append('OUTPUT_INCLUDES') + idl_args.extend(sorted(set(output_includes) - set(outputs))) + + idl_args.append('IDLS') + idl_args.extend(idl_files) + + if is_java_idl: + unit.on_run_idl_tool_java(idl_args) + else: + unit.on_run_idl_tool(idl_args) diff --git a/build/plugins/mx_archive.py b/build/plugins/mx_archive.py new file mode 100644 index 00000000000..76b785fcde7 --- /dev/null +++ b/build/plugins/mx_archive.py @@ -0,0 +1,17 @@ +def onmx_formulas(unit, *args): + """ + @usage: MX_FORMULAS(BinFiles...) # deprecated, matrixnet + Create MatrixNet formulas archive + """ + + def iter_infos(): + for a in args: + if a.endswith('.bin'): + unit.on_mx_bin_to_info([a]) + yield a[:-3] + 'info' + else: + yield a + + infos = list(iter_infos()) + unit.onarchive_asm(['NAME', 'MxFormulas'] + infos) + unit.on_mx_gen_table(infos) diff --git a/build/plugins/nots.py b/build/plugins/nots.py new file mode 100644 index 00000000000..5157afc5263 --- /dev/null +++ b/build/plugins/nots.py @@ -0,0 +1,509 @@ +import fnmatch +import os +import re + +import ymake +import ytest +from _common import get_norm_unit_path, rootrel_arc_src, to_yesno + + +class PluginLogger(object): + def __init__(self): + self.unit = None + self.prefix = "" + + def reset(self, unit, prefix=""): + self.unit = unit + self.prefix = prefix + + def get_state(self): + return (self.unit, self.prefix) + + def _stringify_messages(self, messages): + parts = [] + for m in messages: + if m is None: + parts.append("None") + else: + parts.append(m if isinstance(m, str) else repr(m)) + + # cyan color (code 36) for messages + return "\033[0;32m{}\033[0;49m \033[0;36m{}\033[0;49m".format(self.prefix, " ".join(parts)) + + def info(self, *messages): + if self.unit: + self.unit.message(["INFO", self._stringify_messages(messages)]) + + def warn(self, *messages): + if self.unit: + self.unit.message(["WARN", self._stringify_messages(messages)]) + + def error(self, *messages): + if self.unit: + self.unit.message(["ERROR", self._stringify_messages(messages)]) + + def print_vars(self, *variables): + if self.unit: + values = ["{}={}".format(v, self.unit.get(v)) for v in variables] + self.info(values) + + +logger = PluginLogger() + + +def _with_report_configure_error(fn): + def _wrapper(*args, **kwargs): + last_state = logger.get_state() + unit = args[0] + logger.reset(unit if unit.get("TS_LOG") == "yes" else None, fn.__name__) + try: + fn(*args, **kwargs) + except Exception as exc: + ymake.report_configure_error(str(exc)) + if unit.get("TS_RAISE") == "yes": + raise + else: + unit.message(["WARN", "Configure error is reported. Add -DTS_RAISE to see actual exception"]) + finally: + logger.reset(*last_state) + + return _wrapper + + +def _canonize_resource_name(name): + # type: (str) -> str + return re.sub(r"\W+", "_", name).strip("_").upper() + + +def _build_cmd_input_paths(paths, hide=False): + # type: (list[str], bool) -> str + return " ".join(["${{input{}:\"{}\"}}".format(";hide" if hide else "", p) for p in paths]) + + +def _create_pm(unit): + from lib.nots.package_manager import manager + + sources_path = unit.path() + module_path = unit.get("MODDIR") + if unit.get("TS_TEST_FOR"): + sources_path = unit.get("TS_TEST_FOR_DIR") + module_path = unit.get("TS_TEST_FOR_PATH") + + return manager( + sources_path=unit.resolve(sources_path), + build_root="$B", + build_path=unit.path().replace("$S", "$B", 1), + contribs_path=unit.get("NPM_CONTRIBS_PATH"), + nodejs_bin_path=None, + script_path=None, + module_path=module_path, + ) + + +def _create_erm_json(unit): + from lib.nots.erm_json_lite import ErmJsonLite + + erm_packages_path = unit.get("ERM_PACKAGES_PATH") + path = unit.resolve(unit.resolve_arc_path(erm_packages_path)) + + return ErmJsonLite.load(path) + + +@_with_report_configure_error +def on_from_npm_lockfiles(unit, *args): + pm = _create_pm(unit) + lf_paths = [] + + for lf_path in args: + abs_lf_path = unit.resolve(unit.resolve_arc_path(lf_path)) + if abs_lf_path: + lf_paths.append(abs_lf_path) + elif unit.get("TS_STRICT_FROM_NPM_LOCKFILES") == "yes": + ymake.report_configure_error("lockfile not found: {}".format(lf_path)) + + for pkg in pm.extract_packages_meta_from_lockfiles(lf_paths): + unit.on_from_npm([pkg.name, pkg.version, pkg.sky_id, pkg.integrity, pkg.integrity_algorithm, pkg.tarball_path]) + + +@_with_report_configure_error +def on_peerdir_ts_resource(unit, *resources): + pm = _create_pm(unit) + pj = pm.load_package_json_from_dir(pm.sources_path) + erm_json = _create_erm_json(unit) + dirs = [] + + nodejs_version = _select_matching_version(erm_json, "nodejs", pj.get_nodejs_version()) + + for tool in resources: + if tool == "nodejs": + dirs.append(os.path.join("build", "platform", tool, str(nodejs_version))) + elif erm_json.is_resource_multiplatform(tool): + v = _select_matching_version(erm_json, tool, pj.get_dep_specifier(tool)) + sb_resources = [ + sbr for sbr in erm_json.get_sb_resources(tool, v) if sbr.get("nodejs") == nodejs_version.major + ] + nodejs_dir = "NODEJS_{}".format(nodejs_version.major) + if len(sb_resources) > 0: + dirs.append(os.path.join("build", "external_resources", tool, str(v), nodejs_dir)) + else: + unit.message(["WARN", "Missing {}@{} for {}".format(tool, str(v), nodejs_dir)]) + else: + v = _select_matching_version(erm_json, tool, pj.get_dep_specifier(tool)) + dirs.append(os.path.join("build", "external_resources", tool, str(v))) + + unit.onpeerdir(dirs) + + +@_with_report_configure_error +def on_ts_configure(unit, tsconfig_path): + from lib.nots.package_manager.base import PackageJson + from lib.nots.package_manager.base.utils import build_pj_path + from lib.nots.typescript import TsConfig + + abs_tsconfig_path = unit.resolve(unit.resolve_arc_path(tsconfig_path)) + if not abs_tsconfig_path: + raise Exception("tsconfig not found: {}".format(tsconfig_path)) + + tsconfig = TsConfig.load(abs_tsconfig_path) + cur_dir = unit.get("TS_TEST_FOR_PATH") if unit.get("TS_TEST_FOR") else unit.get("MODDIR") + pj_path = build_pj_path(unit.resolve(unit.resolve_arc_path(cur_dir))) + dep_paths = PackageJson.load(pj_path).get_dep_paths_by_names() + config_files = tsconfig.inline_extend(dep_paths) + + mod_dir = unit.get("MODDIR") + config_files = _resolve_module_files(unit, mod_dir, config_files) + tsconfig.validate() + + unit.set(["TS_CONFIG_FILES", _build_cmd_input_paths(config_files, hide=True)]) + unit.set(["TS_CONFIG_ROOT_DIR", tsconfig.compiler_option("rootDir")]) + unit.set(["TS_CONFIG_OUT_DIR", tsconfig.compiler_option("outDir")]) + unit.set(["TS_CONFIG_SOURCE_MAP", to_yesno(tsconfig.compiler_option("sourceMap"))]) + unit.set(["TS_CONFIG_DECLARATION", to_yesno(tsconfig.compiler_option("declaration"))]) + unit.set(["TS_CONFIG_DECLARATION_MAP", to_yesno(tsconfig.compiler_option("declarationMap"))]) + unit.set(["TS_CONFIG_PRESERVE_JSX", to_yesno(tsconfig.compiler_option("jsx") == "preserve")]) + + _setup_eslint(unit) + + +@_with_report_configure_error +def on_set_external_resources(unit): + _setup_external_resources(unit) + + +def _get_ts_test_data_dirs(unit): + return list( + set( + [ + os.path.dirname(rootrel_arc_src(p, unit)) + for p in (ytest.get_values_list(unit, "_TS_TEST_DATA_VALUE") or []) + ] + ) + ) + + +def _resolve_config_path(unit, test_runner, rel_to): + config_path = ( + unit.get("ESLINT_CONFIG_PATH") if test_runner == "eslint" else unit.get("TS_TEST_CONFIG_PATH") + ) + arc_config_path = unit.resolve_arc_path(config_path) + abs_config_path = unit.resolve(arc_config_path) + if not abs_config_path: + raise Exception("{} config not found: {}".format(test_runner, config_path)) + + unit.onsrcs([arc_config_path]) + abs_rel_to = unit.resolve(unit.resolve_arc_path(unit.get(rel_to))) + return os.path.relpath(abs_config_path, start=abs_rel_to) + + +def _is_tests_enabled(unit): + if unit.get("TIDY") == "yes": + return False + + return True + + +def _get_test_runner_handlers(): + return { + "jest": _add_jest_ts_test, + "hermione": _add_hermione_ts_test, + } + + +def _add_jest_ts_test(unit, test_runner, test_files, deps, test_record): + test_record.update( + { + "CONFIG-PATH": _resolve_config_path(unit, test_runner, rel_to="TS_TEST_FOR_PATH"), + } + ) + _add_test(unit, test_runner, test_files, deps, test_record) + + +def _add_hermione_ts_test(unit, test_runner, test_files, deps, test_record): + unit.on_ts_configure(unit.get("TS_CONFIG_PATH")) + test_tags = list(set(["ya:fat", "ya:external"] + ytest.get_values_list(unit, "TEST_TAGS_VALUE"))) + test_requirements = list(set(["network:full"] + ytest.get_values_list(unit, "TEST_REQUIREMENTS_VALUE"))) + + test_record.update( + { + "TS-ROOT-DIR": unit.get("TS_CONFIG_ROOT_DIR"), + "TS-OUT-DIR": unit.get("TS_CONFIG_OUT_DIR"), + "SIZE": "LARGE", + "TAG": ytest.serialize_list(test_tags), + "REQUIREMENTS": ytest.serialize_list(test_requirements), + "CONFIG-PATH": _resolve_config_path(unit, test_runner, rel_to="MODDIR"), + } + ) + + if not len(test_record["TS-TEST-DATA-DIRS"]): + _add_default_hermione_test_data(unit, test_record) + + _add_test(unit, test_runner, test_files, deps, test_record) + + +def _add_default_hermione_test_data(unit, test_record): + mod_dir = unit.get("MODDIR") + root_dir = test_record["TS-ROOT-DIR"] + out_dir = test_record["TS-OUT-DIR"] + test_for_path = test_record["TS-TEST-FOR-PATH"] + + abs_root_dir = os.path.normpath(os.path.join(unit.resolve(unit.path()), root_dir)) + file_paths = _find_file_paths(abs_root_dir, "**/screens/*/*/*.png") + file_dirs = [os.path.dirname(f) for f in file_paths] + + rename_from, rename_to = [ + os.path.relpath(os.path.normpath(os.path.join(mod_dir, d)), test_for_path) for d in [root_dir, out_dir] + ] + + test_record.update( + { + "TS-TEST-DATA-DIRS": ytest.serialize_list(_resolve_module_files(unit, mod_dir, file_dirs)), + "TS-TEST-DATA-DIRS-RENAME": "{}:{}".format(rename_from, rename_to), + } + ) + + +def _setup_eslint(unit): + if not _is_tests_enabled(unit): + return + + if unit.get("_NO_LINT_VALUE") == "none": + return + + lint_files = ytest.get_values_list(unit, "_TS_LINT_SRCS_VALUE") + if not lint_files: + return + + mod_dir = unit.get("MODDIR") + lint_files = _resolve_module_files(unit, mod_dir, lint_files) + deps = _create_pm(unit).get_peers_from_package_json() + test_record = { + "ESLINT-ROOT-VAR-NAME": unit.get("ESLINT-ROOT-VAR-NAME"), + "ESLINT_CONFIG_PATH": _resolve_config_path(unit, "eslint", rel_to="MODDIR"), + } + + _add_test(unit, "eslint", lint_files, deps, test_record, mod_dir) + + +def _resolve_module_files(unit, mod_dir, file_paths): + resolved_files = [] + + for path in file_paths: + resolved = rootrel_arc_src(path, unit) + if resolved.startswith(mod_dir): + mod_dir_with_sep_len = len(mod_dir) + 1 + resolved = resolved[mod_dir_with_sep_len:] + resolved_files.append(resolved) + + return resolved_files + + +def _find_file_paths(abs_path, pattern): + file_paths = [] + _, ext = os.path.splitext(pattern) + + for root, _, filenames in os.walk(abs_path): + if not any(f.endswith(ext) for f in filenames): + continue + + abs_file_paths = [os.path.join(root, f) for f in filenames] + + for file_path in fnmatch.filter(abs_file_paths, pattern): + file_paths.append(file_path) + + return file_paths + + +def _add_test(unit, test_type, test_files, deps=None, test_record=None, test_cwd=None): + from lib.nots.package_manager import constants + + def sort_uniq(text): + return list(sorted(set(text))) + + if deps: + unit.ondepends(sort_uniq(deps)) + + test_dir = get_norm_unit_path(unit) + full_test_record = { + "TEST-NAME": test_type.lower(), + "TEST-TIMEOUT": unit.get("TEST_TIMEOUT") or "", + "TEST-ENV": ytest.prepare_env(unit.get("TEST_ENV_VALUE")), + "TESTED-PROJECT-NAME": os.path.splitext(unit.filename())[0], + "TEST-RECIPES": ytest.prepare_recipes(unit.get("TEST_RECIPES_VALUE")), + "SCRIPT-REL-PATH": test_type, + "SOURCE-FOLDER-PATH": test_dir, + "BUILD-FOLDER-PATH": test_dir, + "BINARY-PATH": os.path.join(test_dir, unit.filename()), + "SPLIT-FACTOR": unit.get("TEST_SPLIT_FACTOR") or "", + "FORK-MODE": unit.get("TEST_FORK_MODE") or "", + "SIZE": unit.get("TEST_SIZE_NAME") or "", + "TEST-FILES": ytest.serialize_list(test_files), + "TEST-CWD": test_cwd or "", + "TAG": ytest.serialize_list(ytest.get_values_list(unit, "TEST_TAGS_VALUE")), + "REQUIREMENTS": ytest.serialize_list(ytest.get_values_list(unit, "TEST_REQUIREMENTS_VALUE")), + "NODEJS-ROOT-VAR-NAME": unit.get("NODEJS-ROOT-VAR-NAME"), + "NODE-MODULES-BUNDLE-FILENAME": constants.NODE_MODULES_WORKSPACE_BUNDLE_FILENAME, + "CUSTOM-DEPENDENCIES": " ".join(sort_uniq((deps or []) + ytest.get_values_list(unit, "TEST_DEPENDS_VALUE"))), + } + + for k, v in full_test_record.items(): + if not isinstance(v, str): + unit.message(["WARN", k]) + + if test_record: + full_test_record.update(test_record) + + data = ytest.dump_test(unit, full_test_record) + if data: + unit.set_property(["DART_DATA", data]) + + +def _setup_external_resources(unit): + pm = _create_pm(unit) + pj = pm.load_package_json_from_dir(pm.sources_path) + erm_json = _create_erm_json(unit) + + nodejs_version = _select_matching_version(erm_json, "nodejs", pj.get_nodejs_version()) + + # Add NodeJS vars + _set_resource_vars(unit, erm_json, "nodejs", pj.get_nodejs_version()) + + # Add NPM-packages vars + for tool in erm_json.list_npm_packages(): + version_range = pj.get_dep_specifier(tool) + _set_resource_vars(unit, erm_json, tool, version_range, nodejs_version.major) + + +def _set_resource_vars(unit, erm_json, resource_name, version_range, nodejs_major=None): + # type: (any, ErmJsonLite, str, str|None, int|None) -> None + + # example: Version(12, 18, 4) | Version(7, 0, 4) + version = _select_matching_version(erm_json, resource_name, version_range) + + # example: hermione -> HERMIONE, super-package -> SUPER_PACKAGE + canon_resource_name = _canonize_resource_name(resource_name) + + # example: NODEJS_12_18_4 | HERMIONE_7_0_4_NODEJS_18 + version_str = str(version).replace(".", "_") + yamake_resource_name = "{}_{}".format(canon_resource_name, version_str) + + if erm_json.is_resource_multiplatform(resource_name): + yamake_resource_name += "_NODEJS_{}".format(nodejs_major) + + yamake_resource_var = "{}_RESOURCE_GLOBAL".format(yamake_resource_name) + + unit.set(["{}_ROOT".format(canon_resource_name), "${}".format(yamake_resource_var)]) + unit.set(["{}-ROOT-VAR-NAME".format(canon_resource_name), yamake_resource_var]) + + +def _select_matching_version(erm_json, resource_name, range_str): + # type: (ErmJsonLite, str, str) -> Version + try: + version = erm_json.select_version_of(resource_name, range_str) + if version: + return version + + raise ValueError("There is no allowed version to satisfy this range: '{}'".format(range_str)) + except Exception as error: + toolchain_versions = erm_json.get_versions_of(erm_json.get_resource(resource_name)) + + raise Exception( + "Requested {} version range '{}' could not be satisfied. \n" + "Please use a range that would include one of the following: {}. \n" + "For further details please visit the link: {} \nOriginal error: {} \n".format( + resource_name, + range_str, + map(str, toolchain_versions), + "https://nda.ya.ru/t/ulU4f5Ru5egzHV", + str(error), + ) + ) + + +@_with_report_configure_error +def on_node_modules_configure(unit): + pm = _create_pm(unit) + pj = pm.load_package_json_from_dir(pm.sources_path) + + if pj.has_dependencies(): + unit.onpeerdir(pm.get_local_peers_from_package_json()) + ins, outs = pm.calc_node_modules_inouts() + unit.on_set_node_modules_ins_outs(["IN"] + sorted(ins) + ["OUT"] + sorted(outs)) + else: + # default "noop" command + unit.set(["_NODE_MODULES_CMD", "$TOUCH_UNIT"]) + + +@_with_report_configure_error +def on_set_node_modules_bundle_as_output(unit): + pm = _create_pm(unit) + pj = pm.load_package_json_from_dir(pm.sources_path) + if pj.has_dependencies(): + unit.set(["NODE_MODULES_BUNDLE_AS_OUTPUT", '${output;hide:"workspace_node_modules.tar"}']) + + +@_with_report_configure_error +def on_ts_test_for_configure(unit, test_runner, default_config): + if not _is_tests_enabled(unit): + return + + for_mod_path = unit.get("TS_TEST_FOR_PATH") + unit.onpeerdir([for_mod_path]) + unit.on_setup_extract_node_modules_recipe([for_mod_path]) + + unit.set(["TS_TEST_NM", os.path.join(("$B"), for_mod_path, "node_modules.tar")]) + + config_path = unit.get("TS_TEST_CONFIG_PATH") + if not config_path: + config_path = os.path.join(for_mod_path, default_config) + unit.set(["TS_TEST_CONFIG_PATH", config_path]) + + test_record = _add_ts_resources_to_test_record(unit, { + "TS-TEST-FOR-PATH": for_mod_path, + "TS-TEST-DATA-DIRS": ytest.serialize_list(_get_ts_test_data_dirs(unit)), + "TS-TEST-DATA-DIRS-RENAME": unit.get("_TS_TEST_DATA_DIRS_RENAME_VALUE"), + }) + + test_files = ytest.get_values_list(unit, "_TS_TEST_SRCS_VALUE") + test_files = _resolve_module_files(unit, unit.get("MODDIR"), test_files) + if not test_files: + ymake.report_configure_error("No tests found") + return + + deps = _create_pm(unit).get_peers_from_package_json() + add_ts_test = _get_test_runner_handlers()[test_runner] + add_ts_test(unit, test_runner, test_files, deps, test_record) + +@_with_report_configure_error +def on_set_ts_test_for_vars(unit, for_mod): + unit.set(["TS_TEST_FOR", "yes"]) + unit.set(["TS_TEST_FOR_DIR", unit.resolve_arc_path(for_mod)]) + unit.set(["TS_TEST_FOR_PATH", rootrel_arc_src(for_mod, unit)]) + +def _add_ts_resources_to_test_record(unit, test_record): + erm_json = _create_erm_json(unit) + for tool in erm_json.list_npm_packages(): + tool_resource_label = "{}-ROOT-VAR-NAME".format(tool.upper()) + tool_resource_value = unit.get(tool_resource_label) + if tool_resource_value: + test_record[tool_resource_label] = tool_resource_value + return test_record diff --git a/build/plugins/pybuild.py b/build/plugins/pybuild.py new file mode 100644 index 00000000000..ae30fd897e0 --- /dev/null +++ b/build/plugins/pybuild.py @@ -0,0 +1,742 @@ +import os +import collections +from hashlib import md5 + +import ymake +from _common import stripext, rootrel_arc_src, listid, pathid, lazy, get_no_lint_value + + +YA_IDE_VENV_VAR = 'YA_IDE_VENV' +PY_NAMESPACE_PREFIX = 'py/namespace' +BUILTIN_PROTO = 'builtin_proto' +DEFAULT_FLAKE8_FILE_PROCESSING_TIME = "1.5" # in seconds + + +def is_arc_src(src, unit): + return ( + src.startswith('${ARCADIA_ROOT}/') + or src.startswith('${CURDIR}/') + or unit.resolve_arc_path(src).startswith('$S/') + ) + + +def is_extended_source_search_enabled(path, unit): + if not is_arc_src(path, unit): + return False + if unit.get('NO_EXTENDED_SOURCE_SEARCH') == 'yes': + return False + return True + + +def to_build_root(path, unit): + if is_arc_src(path, unit): + return '${ARCADIA_BUILD_ROOT}/' + rootrel_arc_src(path, unit) + return path + + +def uniq_suffix(path, unit): + upath = unit.path() + if '/' not in path: + return '' + return '.{}'.format(pathid(upath)[:4]) + + +def pb2_arg(suf, path, mod, unit): + return '{path}__int__{suf}={mod}{modsuf}'.format( + path=stripext(to_build_root(path, unit)), suf=suf, mod=mod, modsuf=stripext(suf) + ) + + +def proto_arg(path, mod, unit): + return '{}.proto={}'.format(stripext(to_build_root(path, unit)), mod) + + +def pb_cc_arg(suf, path, unit): + return '{}{suf}'.format(stripext(to_build_root(path, unit)), suf=suf) + + +def ev_cc_arg(path, unit): + return '{}.ev.pb.cc'.format(stripext(to_build_root(path, unit))) + + +def ev_arg(path, mod, unit): + return '{}__int___ev_pb2.py={}_ev_pb2'.format(stripext(to_build_root(path, unit)), mod) + + +def mangle(name): + if '.' not in name: + return name + return ''.join('{}{}'.format(len(s), s) for s in name.split('.')) + + +def parse_pyx_includes(filename, path, source_root, seen=None): + normpath = lambda *x: os.path.normpath(os.path.join(*x)) + + abs_path = normpath(source_root, filename) + seen = seen or set() + if abs_path in seen: + return + seen.add(abs_path) + + if not os.path.exists(abs_path): + # File might be missing, because it might be generated + return + + with open(abs_path, 'rb') as f: + # Don't parse cimports and etc - irrelevant for cython, it's linker work + includes = ymake.parse_cython_includes(f.read()) + + abs_dirname = os.path.dirname(abs_path) + # All includes are relative to the file which include + path_dirname = os.path.dirname(path) + file_dirname = os.path.dirname(filename) + + for incfile in includes: + abs_path = normpath(abs_dirname, incfile) + if os.path.exists(abs_path): + incname, incpath = normpath(file_dirname, incfile), normpath(path_dirname, incfile) + yield (incname, incpath) + # search for includes in the included files + for e in parse_pyx_includes(incname, incpath, source_root, seen): + yield e + else: + # There might be arcadia root or cython relative include. + # Don't treat such file as missing, because there must be PEERDIR on py_library + # which contains it. + for path in [ + source_root, + source_root + "/contrib/tools/cython/Cython/Includes", + ]: + if os.path.exists(normpath(path, incfile)): + break + else: + ymake.report_configure_error("'{}' includes missing file: {} ({})".format(path, incfile, abs_path)) + + +def has_pyx(args): + return any(arg.endswith('.pyx') for arg in args) + + +def get_srcdir(path, unit): + return rootrel_arc_src(path, unit)[: -len(path)].rstrip('/') + + +def add_python_lint_checks(unit, py_ver, files): + @lazy + def get_resolved_files(): + resolved_files = [] + for path in files: + resolved = unit.resolve_arc_path([path]) + if resolved.startswith('$S'): # path was resolved as source file. + resolved_files.append(resolved) + return resolved_files + + no_lint_value = get_no_lint_value(unit) + if no_lint_value == "none": + + no_lint_allowed_paths = ( + "contrib/", + "devtools/", + "junk/", + # temporary allowed, TODO: remove + "taxi/uservices/", + "travel/", + "market/report/lite/", # MARKETOUT-38662, deadline: 2021-08-12 + "passport/backend/oauth/", # PASSP-35982 + "testenv/", # CI-3229 + ) + + upath = unit.path()[3:] + + if not upath.startswith(no_lint_allowed_paths): + ymake.report_configure_error("NO_LINT() is allowed only in " + ", ".join(no_lint_allowed_paths)) + + if files and no_lint_value not in ("none", "none_internal"): + resolved_files = get_resolved_files() + if resolved_files: + flake8_cfg = 'build/config/tests/flake8/flake8.conf' + resource = "build/external_resources/flake8_py{}".format(py_ver) + lint_name = "py{}_flake8".format(py_ver) + params = [lint_name, "tools/flake8_linter/flake8_linter"] + params += ["FILES"] + resolved_files + params += ["GLOBAL_RESOURCES", resource] + params += ["CONFIGS", flake8_cfg, "build/rules/flake8/migrations.yaml"] + params += [ + "FILE_PROCESSING_TIME", + unit.get("FLAKE8_FILE_PROCESSING_TIME") or DEFAULT_FLAKE8_FILE_PROCESSING_TIME, + ] + extra_params = [] + if unit.get("DISABLE_FLAKE8_MIGRATIONS") == "yes": + extra_params.append("DISABLE_FLAKE8_MIGRATIONS=yes") + if extra_params: + params += ["EXTRA_PARAMS"] + extra_params + unit.on_add_linter_check(params) + + if files and unit.get('STYLE_PYTHON_VALUE') == 'yes' and is_py3(unit): + resolved_files = get_resolved_files() + if resolved_files: + black_cfg = ( + unit.get('STYLE_PYTHON_PYPROJECT_VALUE') or 'devtools/ya/handlers/style/python_style_config.toml' + ) + params = ['black', 'tools/black_linter/black_linter'] + params += ['FILES'] + resolved_files + params += ['CONFIGS', black_cfg] + unit.on_add_linter_check(params) + + +def is_py3(unit): + return unit.get("PYTHON3") == "yes" + + +def on_py_program(unit, *args): + py_program(unit, is_py3(unit)) + + +def py_program(unit, py3): + """ + Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/#modulpyprogramimakrospymain + """ + if py3: + peers = ['library/python/runtime_py3/main'] + if unit.get('PYTHON_SQLITE3') != 'no': + peers.append('contrib/tools/python3/src/Modules/_sqlite') + else: + peers = ['library/python/runtime/main'] + if unit.get('PYTHON_SQLITE3') != 'no': + peers.append('contrib/tools/python/src/Modules/_sqlite') + unit.onpeerdir(peers) + if unit.get('MODULE_TYPE') == 'PROGRAM': # can not check DLL + unit.onadd_check_py_imports() + + +def onpy_srcs(unit, *args): + """ + @usage PY_SRCS({| CYTHONIZE_PY} {| CYTHON_C} { | TOP_LEVEL | NAMESPACE ns} Files...) + + PY_SRCS() - is rule to build extended versions of Python interpreters and containing all application code in its executable file. It can be used to collect only the executables but not shared libraries, and, in particular, not to collect the modules that are imported using import directive. + The main disadvantage is the lack of IDE support; There is also no readline yet. + The application can be collect from any of the sources from which the C library, and with the help of PY_SRCS .py , .pyx,.proto and .swg files. + At the same time extensions for Python on C language generating from .pyx and .swg, will be registered in Python's as built-in modules, and sources on .py are stored as static data: when the interpreter starts, the initialization code will add a custom loader of these modules to sys.meta_path. + You can compile .py files as Cython sources with CYTHONIZE_PY directive (Use carefully, as build can get too slow). However, with it you won't have profiling info by default. To enable it, add "# cython: profile=True" line to the beginning of every cythonized source. + By default .pyx files are collected as C++-extensions. To collect them as C (similar to BUILDWITH_CYTHON_C, but with the ability to specify namespace), you must specify the Directive CYTHON_C. + Building with pyx automatically registers modules, you do not need to call PY_REGISTER for them + __init__.py never required, but if present (and specified in PY_SRCS), it will be imported when you import package modules with __init__.py Oh. + + Example of library declaration with PY_SRCS(): + PY2_LIBRARY(mymodule) + PY_SRCS(a.py sub/dir/b.py e.proto sub/dir/f.proto c.pyx sub/dir/d.pyx g.swg sub/dir/h.swg) + END() + + PY_REGISTER honors Python2 and Python3 differences and adjusts itself to Python version of a current module + Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs/#modulipylibrarypy3libraryimakrospysrcs + """ + # Each file arg must either be a path, or "${...}/buildpath=modname", where + # "${...}/buildpath" part will be used as a file source in a future macro, + # and "modname" will be used as a module name. + + upath = unit.path()[3:] + py3 = is_py3(unit) + py_main_only = unit.get('PROCESS_PY_MAIN_ONLY') + with_py = not unit.get('PYBUILD_NO_PY') + with_pyc = not unit.get('PYBUILD_NO_PYC') + in_proto_library = unit.get('PY_PROTO') or unit.get('PY3_PROTO') + venv = unit.get(YA_IDE_VENV_VAR) + need_gazetteer_peerdir = False + trim = 0 + + if ( + not upath.startswith('contrib/tools/python') + and not upath.startswith('library/python/runtime') + and unit.get('NO_PYTHON_INCLS') != 'yes' + ): + unit.onpeerdir(['contrib/libs/python']) + + unit_needs_main = unit.get('MODULE_TYPE') in ('PROGRAM', 'DLL') + if unit_needs_main: + py_program(unit, py3) + + py_namespace_value = unit.get('PY_NAMESPACE_VALUE') + if py_namespace_value == ".": + ns = "" + else: + ns = (unit.get('PY_NAMESPACE_VALUE') or upath.replace('/', '.')) + '.' + + cython_coverage = unit.get('CYTHON_COVERAGE') == 'yes' + cythonize_py = False + optimize_proto = unit.get('OPTIMIZE_PY_PROTOS_FLAG') == 'yes' + + cython_directives = [] + if cython_coverage: + cython_directives += ['-X', 'linetrace=True'] + + pyxs_c = [] + pyxs_c_h = [] + pyxs_c_api_h = [] + pyxs_cpp = [] + pyxs_cpp_h = [] + pyxs = pyxs_cpp + swigs_c = [] + swigs_cpp = [] + swigs = swigs_cpp + pys = [] + protos = [] + evs = [] + fbss = [] + py_namespaces = {} + + dump_dir = unit.get('PYTHON_BUILD_DUMP_DIR') + dump_output = None + if dump_dir: + import thread + + pid = os.getpid() + tid = thread.get_ident() + dump_name = '{}-{}.dump'.format(pid, tid) + dump_output = open(os.path.join(dump_dir, dump_name), 'a') + + args = iter(args) + for arg in args: + # Namespace directives. + if arg == 'TOP_LEVEL': + ns = '' + elif arg == 'NAMESPACE': + ns = next(args) + '.' + # Cython directives. + elif arg == 'CYTHON_C': + pyxs = pyxs_c + elif arg == 'CYTHON_C_H': + pyxs = pyxs_c_h + elif arg == 'CYTHON_C_API_H': + pyxs = pyxs_c_api_h + elif arg == 'CYTHON_CPP': + pyxs = pyxs_cpp + elif arg == 'CYTHON_CPP_H': + pyxs = pyxs_cpp_h + elif arg == 'CYTHON_DIRECTIVE': + cython_directives += ['-X', next(args)] + elif arg == 'CYTHONIZE_PY': + cythonize_py = True + # SWIG. + elif arg == 'SWIG_C': + swigs = swigs_c + elif arg == 'SWIG_CPP': + swigs = swigs_cpp + # Unsupported but legal PROTO_LIBRARY arguments. + elif arg == 'GLOBAL' or not in_proto_library and arg.endswith('.gztproto'): + pass + elif arg == '_MR': + # GLOB support: convert arcadia-root-relative paths to module-relative + # srcs are assumed to start with ${ARCADIA_ROOT} + trim = len(unit.path()) + 14 + # Sources. + else: + main_mod = arg == 'MAIN' + if main_mod: + arg = next(args) + + if '=' in arg: + main_py = False + path, mod = arg.split('=', 1) + else: + if trim: + arg = arg[trim:] + if arg.endswith('.gztproto'): + need_gazetteer_peerdir = True + path = '{}.proto'.format(arg[:-9]) + else: + path = arg + main_py = path == '__main__.py' or path.endswith('/__main__.py') + if not py3 and unit_needs_main and main_py: + mod = '__main__' + else: + if arg.startswith('../'): + ymake.report_configure_error('PY_SRCS item starts with "../": {!r}'.format(arg)) + if arg.startswith('/'): + ymake.report_configure_error('PY_SRCS item starts with "/": {!r}'.format(arg)) + continue + mod_name = stripext(arg).replace('/', '.') + if py3 and path.endswith('.py') and is_extended_source_search_enabled(path, unit): + # Dig out real path from the file path. Unit.path is not enough because of SRCDIR and ADDINCL + root_rel_path = rootrel_arc_src(path, unit) + mod_root_path = root_rel_path[: -(len(path) + 1)] + py_namespaces.setdefault(mod_root_path, set()).add(ns if ns else '.') + mod = ns + mod_name + + if main_mod: + py_main(unit, mod + ":main") + elif py3 and unit_needs_main and main_py: + py_main(unit, mod) + + if py_main_only: + continue + + if py3 and mod == '__main__': + ymake.report_configure_error('TOP_LEVEL __main__.py is not allowed in PY3_PROGRAM') + + pathmod = (path, mod) + + if dump_output is not None: + dump_output.write( + '{path}\t{module}\t{py3}\n'.format( + path=rootrel_arc_src(path, unit), module=mod, py3=1 if py3 else 0 + ) + ) + + if path.endswith('.py'): + if cythonize_py: + pyxs.append(pathmod) + else: + pys.append(pathmod) + elif path.endswith('.pyx'): + pyxs.append(pathmod) + elif path.endswith('.proto'): + protos.append(pathmod) + elif path.endswith('.ev'): + evs.append(pathmod) + elif path.endswith('.swg'): + swigs.append(pathmod) + # Allow pyi files in PY_SRCS for autocomplete in IDE, but skip it during building + elif path.endswith('.pyi'): + pass + elif path.endswith('.fbs'): + fbss.append(pathmod) + else: + ymake.report_configure_error('in PY_SRCS: unrecognized arg {!r}'.format(path)) + + if dump_output is not None: + dump_output.close() + + if pyxs: + py_files2res = set() + cpp_files2res = set() + # Include map stores files which were included in the processing pyx file, + # to be able to find source code of the included file inside generated file + # for currently processing pyx file. + include_map = collections.defaultdict(set) + + if cython_coverage: + + def process_pyx(filename, path, out_suffix, with_ext): + # skip generated files + if not is_arc_src(path, unit): + return + # source file + py_files2res.add((filename, path)) + # generated + if with_ext is None: + cpp_files2res.add( + (os.path.splitext(filename)[0] + out_suffix, os.path.splitext(path)[0] + out_suffix) + ) + else: + cpp_files2res.add((filename + with_ext + out_suffix, path + with_ext + out_suffix)) + # used includes + for entry in parse_pyx_includes(filename, path, unit.resolve('$S')): + py_files2res.add(entry) + include_arc_rel = entry[0] + include_map[filename].add(include_arc_rel) + + else: + + def process_pyx(filename, path, out_suffix, with_ext): + pass + + obj_suff = unit.get('OBJ_SUF') + assert obj_suff is not None + for pyxs, cython, out_suffix, with_ext in [ + (pyxs_c, unit.on_buildwith_cython_c_dep, ".c", obj_suff), + (pyxs_c_h, unit.on_buildwith_cython_c_h, ".c", None), + (pyxs_c_api_h, unit.on_buildwith_cython_c_api_h, ".c", None), + (pyxs_cpp, unit.on_buildwith_cython_cpp_dep, ".cpp", obj_suff), + (pyxs_cpp_h, unit.on_buildwith_cython_cpp_h, ".cpp", None), + ]: + for path, mod in pyxs: + filename = rootrel_arc_src(path, unit) + cython_args = [path] + + dep = path + if path.endswith('.py'): + pxd = '/'.join(mod.split('.')) + '.pxd' + if unit.resolve_arc_path(pxd): + dep = pxd + cython_args.append(dep) + + cython_args += [ + '--module-name', + mod, + '--init-suffix', + mangle(mod), + '--source-root', + '${ARCADIA_ROOT}', + # set arcadia root relative __file__ for generated modules + '-X', + 'set_initial_path={}'.format(filename), + ] + cython_directives + + cython(cython_args) + py_register(unit, mod, py3) + process_pyx(filename, path, out_suffix, with_ext) + + if cythonize_py: + # Lint checks are not added for cythonized files by default, so we must add it here + # as we are doing for regular pys. + _23 = 3 if py3 else 2 + add_python_lint_checks( + unit, + _23, + [path for path, mod in pyxs if path.endswith(".py")] + + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split(), + ) + + if py_files2res: + # Compile original and generated sources into target for proper cython coverage calculation + for files2res in (py_files2res, cpp_files2res): + unit.onresource_files([x for name, path in files2res for x in ('DEST', name, path)]) + + if include_map: + data = [] + prefix = 'resfs/cython/include' + for line in sorted( + '{}/{}={}'.format(prefix, filename, ':'.join(sorted(files))) + for filename, files in include_map.iteritems() + ): + data += ['-', line] + unit.onresource(data) + + for swigs, on_swig_python in [ + (swigs_c, unit.on_swig_python_c), + (swigs_cpp, unit.on_swig_python_cpp), + ]: + for path, mod in swigs: + # Make output prefix basename match swig module name. + prefix = path[: path.rfind('/') + 1] + mod.rsplit('.', 1)[-1] + swg_py = '{}/{}/{}.py'.format('${ARCADIA_BUILD_ROOT}', upath, prefix) + on_swig_python([path, prefix]) + onpy_register(unit, mod + '_swg') + onpy_srcs(unit, swg_py + '=' + mod) + + if pys: + pys_seen = set() + pys_dups = {m for _, m in pys if (m in pys_seen or pys_seen.add(m))} + if pys_dups: + ymake.report_configure_error('Duplicate(s) is found in the PY_SRCS macro: {}'.format(pys_dups)) + + res = [] + + if py3: + mod_list_md5 = md5() + for path, mod in pys: + mod_list_md5.update(mod) + if not (venv and is_extended_source_search_enabled(path, unit)): + dest = 'py/' + mod.replace('.', '/') + '.py' + if with_py: + res += ['DEST', dest, path] + if with_pyc: + root_rel_path = rootrel_arc_src(path, unit) + dst = path + uniq_suffix(path, unit) + unit.on_py3_compile_bytecode([root_rel_path + '-', path, dst]) + res += ['DEST', dest + '.yapyc3', dst + '.yapyc3'] + + if py_namespaces: + # Note: Add md5 to key to prevent key collision if two or more PY_SRCS() used in the same ya.make + ns_res = [] + for path, ns in sorted(py_namespaces.items()): + key = '{}/{}/{}'.format(PY_NAMESPACE_PREFIX, mod_list_md5.hexdigest(), path) + namespaces = ':'.join(sorted(ns)) + ns_res += ['-', '{}="{}"'.format(key, namespaces)] + unit.onresource(ns_res) + + unit.onresource_files(res) + add_python_lint_checks( + unit, 3, [path for path, mod in pys] + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split() + ) + else: + for path, mod in pys: + root_rel_path = rootrel_arc_src(path, unit) + if with_py: + key = '/py_modules/' + mod + res += [ + path, + key, + '-', + 'resfs/src/{}={}'.format(key, root_rel_path), + ] + if with_pyc: + src = unit.resolve_arc_path(path) or path + dst = path + uniq_suffix(path, unit) + unit.on_py_compile_bytecode([root_rel_path + '-', src, dst]) + res += [dst + '.yapyc', '/py_code/' + mod] + + unit.onresource(res) + add_python_lint_checks( + unit, 2, [path for path, mod in pys] + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split() + ) + + use_vanilla_protoc = unit.get('USE_VANILLA_PROTOC') == 'yes' + if use_vanilla_protoc: + cpp_runtime_path = 'contrib/libs/protobuf_std' + py_runtime_path = 'contrib/python/protobuf_std' + builtin_proto_path = cpp_runtime_path + '/' + BUILTIN_PROTO + else: + cpp_runtime_path = 'contrib/libs/protobuf' + py_runtime_path = 'contrib/python/protobuf' + builtin_proto_path = cpp_runtime_path + '/' + BUILTIN_PROTO + + if protos: + if not upath.startswith(py_runtime_path) and not upath.startswith(builtin_proto_path): + unit.onpeerdir(py_runtime_path) + + unit.onpeerdir(unit.get("PY_PROTO_DEPS").split()) + + proto_paths = [path for path, mod in protos] + unit.on_generate_py_protos_internal(proto_paths) + unit.onpy_srcs( + [ + pb2_arg(py_suf, path, mod, unit) + for path, mod in protos + for py_suf in unit.get("PY_PROTO_SUFFIXES").split() + ] + ) + + if optimize_proto and need_gazetteer_peerdir: + unit.onpeerdir(['kernel/gazetteer/proto']) + + if evs: + unit.onpeerdir([cpp_runtime_path]) + unit.on_generate_py_evs_internal([path for path, mod in evs]) + unit.onpy_srcs([ev_arg(path, mod, unit) for path, mod in evs]) + + if fbss: + unit.onpeerdir(unit.get('_PY_FBS_DEPS').split()) + pysrc_base_name = listid(fbss) + unit.onfbs_to_pysrc([pysrc_base_name] + [path for path, _ in fbss]) + unit.onsrcs(['GLOBAL', '{}.fbs.pysrc'.format(pysrc_base_name)]) + + +def _check_test_srcs(*args): + used = set(args) & {"NAMESPACE", "TOP_LEVEL", "__main__.py"} + if used: + param = list(used)[0] + ymake.report_configure_error( + 'in TEST_SRCS: you cannot use {} here - it would broke testing machinery'.format(param) + ) + + +def ontest_srcs(unit, *args): + _check_test_srcs(*args) + if unit.get('PY3TEST_BIN' if is_py3(unit) else 'PYTEST_BIN') != 'no': + unit.onpy_srcs(["NAMESPACE", "__tests__"] + list(args)) + + +def onpy_doctests(unit, *args): + """ + @usage PY_DOCTESTS(Packages...) + + Add to the test doctests for specified Python packages + The packages should be part of a test (listed as sources of the test or its PEERDIRs). + """ + if unit.get('PY3TEST_BIN' if is_py3(unit) else 'PYTEST_BIN') != 'no': + unit.onresource(['-', 'PY_DOCTEST_PACKAGES="{}"'.format(' '.join(args))]) + + +def py_register(unit, func, py3): + if py3: + unit.on_py3_register([func]) + else: + unit.on_py_register([func]) + + +def onpy_register(unit, *args): + """ + @usage: PY_REGISTER([package.]module_name) + + Python knows about which built-ins can be imported, due to their registration in the Assembly or at the start of the interpreter. + All modules from the sources listed in PY_SRCS() are registered automatically. + To register the modules from the sources in the SRCS(), you need to use PY_REGISTER(). + + PY_REGISTER(module_name) initializes module globally via call to initmodule_name() + PY_REGISTER(package.module_name) initializes module in the specified package + It renames its init function with CFLAGS(-Dinitmodule_name=init7package11module_name) + or CFLAGS(-DPyInit_module_name=PyInit_7package11module_name) + + Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs/#makrospyregister + """ + + py3 = is_py3(unit) + + for name in args: + assert '=' not in name, name + py_register(unit, name, py3) + if '.' in name: + shortname = name.rsplit('.', 1)[1] + if py3: + unit.oncflags(['-DPyInit_{}=PyInit_{}'.format(shortname, mangle(name))]) + else: + unit.oncflags(['-Dinit{}=init{}'.format(shortname, mangle(name))]) + + +def py_main(unit, arg): + if unit.get('IGNORE_PY_MAIN'): + return + unit_needs_main = unit.get('MODULE_TYPE') in ('PROGRAM', 'DLL') + if unit_needs_main: + py_program(unit, is_py3(unit)) + unit.onresource(['-', 'PY_MAIN={}'.format(arg)]) + + +def onpy_main(unit, arg): + """ + @usage: PY_MAIN(package.module[:func]) + + Specifies the module or function from which to start executing a python program + + Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs/#modulipyprogrampy3programimakrospymain + """ + + arg = arg.replace('/', '.') + + if ':' not in arg: + arg += ':main' + + py_main(unit, arg) + + +def onpy_constructor(unit, arg): + """ + @usage: PY_CONSTRUCTOR(package.module[:func]) + + Specifies the module or function which will be started before python's main() + init() is expected in the target module if no function is specified + Can be considered as __attribute__((constructor)) for python + """ + if ':' not in arg: + arg = arg + '=init' + else: + arg[arg.index(':')] = '=' + unit.onresource(['-', 'py/constructors/{}'.format(arg)]) + + +def onpy_enums_serialization(unit, *args): + ns = '' + args = iter(args) + for arg in args: + # Namespace directives. + if arg == 'NAMESPACE': + ns = next(args) + else: + unit.on_py_enum_serialization_to_json(arg) + unit.on_py_enum_serialization_to_py(arg) + filename = arg.rsplit('.', 1)[0] + '.py' + if len(ns) != 0: + onpy_srcs(unit, 'NAMESPACE', ns, filename) + else: + onpy_srcs(unit, filename) + + +def oncpp_enums_serialization(unit, *args): + args = iter(args) + for arg in args: + # Namespace directives. + if arg == 'NAMESPACE': + next(args) + else: + unit.ongenerate_enum_serialization_with_header(arg) diff --git a/build/plugins/res.py b/build/plugins/res.py new file mode 100644 index 00000000000..31f9d77c10a --- /dev/null +++ b/build/plugins/res.py @@ -0,0 +1,138 @@ +import json +import os +import six +from _common import iterpair, listid, pathid, rootrel_arc_src, tobuilddir, filter_out_by_keyword +import ymake + + +def split(lst, limit): + # paths are specified with replaceable prefix + # real length is unknown at the moment, that why we use root_lenght + # as a rough estimation + root_lenght = 200 + filepath = None + lenght = 0 + bucket = [] + + for item in lst: + if filepath: + lenght += root_lenght + len(filepath) + len(item) + if lenght > limit and bucket: + yield bucket + bucket = [] + lenght = 0 + + bucket.append(filepath) + bucket.append(item) + filepath = None + else: + filepath = item + + if bucket: + yield bucket + + +def remove_prefix(text, prefix): + if text.startswith(prefix): + return text[len(prefix) :] + return text + + +def onresource_files(unit, *args): + """ + @usage: RESOURCE_FILES([PREFIX {prefix}] [STRIP prefix_to_strip] {path}) + + This macro expands into + RESOURCE(DONT_PARSE {path} resfs/file/{prefix}{path} + - resfs/src/resfs/file/{prefix}{remove_prefix(path, prefix_to_strip)}={rootrel_arc_src(path)} + ) + + resfs/src/{key} stores a source root (or build root) relative path of the + source of the value of the {key} resource. + + resfs/file/{key} stores any value whose source was a file on a filesystem. + resfs/src/resfs/file/{key} must store its path. + + DONT_PARSE disables parsing for source code files (determined by extension) + Please don't abuse: use separate DONT_PARSE macro call only for files subject to parsing + + This form is for use from other plugins: + RESOURCE_FILES([DEST {dest}] {path}) expands into RESOURCE({path} resfs/file/{dest}) + + @see: https://wiki.yandex-team.ru/devtools/commandsandvars/resourcefiles/ + """ + prefix = '' + prefix_to_strip = None + dest = None + res = [] + + if args and not unit.enabled('_GO_MODULE'): + # GO_RESOURCE currently doesn't support DONT_PARSE + res.append('DONT_PARSE') + + args = iter(args) + for arg in args: + if arg == 'PREFIX': + prefix, dest = next(args), None + elif arg == 'DEST': + dest, prefix = next(args), None + elif arg == 'STRIP': + prefix_to_strip = next(args) + else: + path = arg + key = 'resfs/file/' + ( + dest or (prefix + (path if not prefix_to_strip else remove_prefix(path, prefix_to_strip))) + ) + src = 'resfs/src/{}={}'.format(key, rootrel_arc_src(path, unit)) + res += ['-', src, path, key] + + if unit.enabled('_GO_MODULE'): + unit.on_go_resource(res) + else: + unit.onresource(res) + + +def onall_resource_files(unit, *args): + # This is only validation, actual work is done in ymake.core.conf implementation + for arg in args: + if '*' in arg or '?' in arg: + ymake.report_configure_error('Wildcards in [[imp]]ALL_RESOURCE_FILES[[rst]] are not allowed') + + +def on_ya_conf_json(unit, conf_file): + conf_abs_path = unit.resolve('$S/' + conf_file) + if not os.path.exists(conf_abs_path): + ymake.report_configure_error('File "{}" not found'.format(conf_abs_path)) + return + + # conf_file should be passed to the RESOURCE_FILES macro without path. + # To resolve it later by name only we must add it's path to SRCDIR(). + conf_dir = os.path.dirname(conf_file) + if conf_dir: + unit.onsrcdir(conf_dir) + unit.onresource_files(os.path.basename(conf_file)) + + with open(conf_abs_path) as f: + conf = json.load(f) + formulas = set() + for bottle_name, bottle in conf['bottles'].items(): + formula = bottle['formula'] + if isinstance(formula, six.string_types): + if formula.startswith(conf_dir): + abs_path = unit.resolve('$S/' + formula) + if os.path.exists(abs_path): + formulas.add(formula) + else: + ymake.report_configure_error( + 'File "{}" (referenced from bottle "{}" in "{}") is not found'.format( + abs_path, bottle_name, conf_abs_path + ) + ) + else: + ymake.report_configure_error( + 'File "{}" (referenced from bottle "{}" in "{}") must be located in "{}" file tree'.format( + formula, bottle_name, conf_file, conf_dir + ) + ) + for formula in formulas: + unit.onresource_files(formula) diff --git a/build/plugins/sandbox_registry.py b/build/plugins/sandbox_registry.py new file mode 100644 index 00000000000..dc1be399b32 --- /dev/null +++ b/build/plugins/sandbox_registry.py @@ -0,0 +1,21 @@ +import os + +import ymake + + +def onregister_sandbox_import(unit, *args): + args = iter(args) + for path in args: + path = os.path.normpath(path) + source = unit.resolve_arc_path(path) + abs_source = unit.resolve(source) + if not os.path.exists(abs_source): + ymake.report_configure_error('REGISTER_SANDBOX_IMPORT: File or directory {} does not exists'.format(path)) + splited_path = path.split(os.sep) + l, r = 0, len(splited_path) + if splited_path[-1] == "__init__.py": + r -= 1 + if not splited_path[0]: + l += 1 + path = ".".join(splited_path[l:r]) + unit.onresource(["-", "{}.{}={}".format("SANDBOX_TASK_REGISTRY", path, path)]) diff --git a/build/plugins/split_codegen.py b/build/plugins/split_codegen.py new file mode 100644 index 00000000000..4c3fe5cf2aa --- /dev/null +++ b/build/plugins/split_codegen.py @@ -0,0 +1,43 @@ +from _common import sort_by_keywords + +# This hard-coded many times in CppParts in various codegens +_DEFAULT_CPP_PARTS = 20 +# See TCodegenParams::MethodStream usage in factor codegen +_ADDITIONAL_STREAM_COUNT = 5 + + +def onsplit_codegen(unit, *args): + ''' + @usage: SPLIT_CODEGEN(tool prefix opts... [OUT_NUM num] [OUTPUT_INCLUDES output_includes...]) + + Generator of a certain number of parts of the .cpp file + one header .h file from .in + + Supports keywords: + 1. OUT_NUM <the number of generated Prefix.N.cpp default 25 (N varies from 0 to 24)> + 2. OUTPUT_INCLUDES <path to files that will be included in generalnyj of macro files> + ''' + keywords = {"OUT_NUM": 1} + flat_args, spec_args = sort_by_keywords(keywords, args) + + num_outputs = _DEFAULT_CPP_PARTS + _ADDITIONAL_STREAM_COUNT + if "OUT_NUM" in spec_args: + num_outputs = int(spec_args["OUT_NUM"][0]) + + tool = flat_args[0] + prefix = flat_args[1] + + cmd = [tool, prefix, 'OUT'] + for num in range(num_outputs): + cmd.append('{}.{}.cpp'.format(prefix, num)) + + cpp_parts = int(num_outputs) - _ADDITIONAL_STREAM_COUNT + cpp_parts_args = ['--cpp-parts', str(cpp_parts)] + + if len(flat_args) > 2: + if flat_args[2] != 'OUTPUT_INCLUDES': + cmd.append('OPTS') + cmd += cpp_parts_args + flat_args[2:] + else: + cmd += ['OPTS'] + cpp_parts_args + + unit.on_split_codegen_base(cmd) diff --git a/build/plugins/ssqls.py b/build/plugins/ssqls.py new file mode 100644 index 00000000000..35461851de8 --- /dev/null +++ b/build/plugins/ssqls.py @@ -0,0 +1,41 @@ +from os.path import splitext + +import ymake +from _common import resolve_includes + + +class SSQLSParser(object): + def __init__(self, path, unit): + s = unit.resolve_arc_path(path) + assert s.startswith('$S/') and s.endswith('.ssqls'), s + h = '$B/' + s[3:-6] + '.h' + + import xml.etree.cElementTree as ET + + try: + doc = ET.parse(path) + except ET.ParseError as e: + unit.message(['error', 'malformed XML {}: {}'.format(path, e)]) + doc = ET.Element('DbObject') + xmls, headers = self.parse_doc(doc) + self._includes = resolve_includes(unit, s, xmls) + self._induced = {'cpp': [h], 'h': resolve_includes(unit, h, headers)} + + @staticmethod + def parse_doc(doc): + paths = lambda nodes: filter(None, (e.get('path') for e in nodes)) + includes = doc.findall('include') + ancestors = paths(doc.findall('ancestors/ancestor')) + headers = [e.text.strip('<>""') for e in includes] + headers += [splitext(s)[0] + '.h' for s in ancestors] + return paths(includes) + ancestors, headers + + def includes(self): + return self._includes + + def induced_deps(self): + return self._induced + + +def init(): + ymake.addparser('ssqls', SSQLSParser) diff --git a/build/plugins/suppressions.py b/build/plugins/suppressions.py new file mode 100644 index 00000000000..db5037646df --- /dev/null +++ b/build/plugins/suppressions.py @@ -0,0 +1,24 @@ +def onsuppressions(unit, *args): + """ + SUPPRESSIONS() - allows to specify files with suppression notation which will be used by + address, leak or thread sanitizer runtime by default. + Use asan.supp filename for address sanitizer, lsan.supp for leak sanitizer + and tsan.supp for thread sanitizer suppressions respectively. + See https://clang.llvm.org/docs/AddressSanitizer.html#suppressing-memory-leaks + for details. + """ + import os + + valid = ("asan.supp", "tsan.supp", "lsan.supp") + + if unit.get("SANITIZER_TYPE") in ("leak", "address", "thread"): + for x in args: + if os.path.basename(x) not in valid: + unit.message( + [ + 'error', + "Invalid suppression filename: {} (any of the following is expected: {})".format(x, valid), + ] + ) + return + unit.onsrcs(["GLOBAL"] + list(args)) diff --git a/build/plugins/tests/fake_ymake.py b/build/plugins/tests/fake_ymake.py new file mode 100644 index 00000000000..a20d28525a8 --- /dev/null +++ b/build/plugins/tests/fake_ymake.py @@ -0,0 +1,2 @@ +def addparser(): + pass diff --git a/build/plugins/tests/test_code_generator.py b/build/plugins/tests/test_code_generator.py new file mode 100644 index 00000000000..7f3267a55e6 --- /dev/null +++ b/build/plugins/tests/test_code_generator.py @@ -0,0 +1,25 @@ +import sys +from build.plugins.tests import fake_ymake + +sys.modules['ymake'] = fake_ymake + +from build.plugins import code_generator + + +def test_include_parser(): + template_file = """ + @ from 'util/namespace.macro' import namespace, change_namespace, close_namespaces + @ import 'market/tools/code_generator/templates/serialization/json.macro' as json + @ import 'market/tools/code_generator/templates/serialization/request_parameters.macro' as rp + #include <sss/abcdefg.h> + #include<fff/asd> + #include "hhh/quququ.h" + """ + + includes, induced = code_generator.CodeGeneratorTemplateParser.parse_includes(template_file.split('\n')) + assert includes == [ + 'util/namespace.macro', + 'market/tools/code_generator/templates/serialization/json.macro', + 'market/tools/code_generator/templates/serialization/request_parameters.macro', + ] + assert induced == ['sss/abcdefg.h', 'fff/asd', 'hhh/quququ.h'] diff --git a/build/plugins/tests/test_common.py b/build/plugins/tests/test_common.py new file mode 100644 index 00000000000..e1780354f89 --- /dev/null +++ b/build/plugins/tests/test_common.py @@ -0,0 +1,49 @@ +import pytest + +import build.plugins._common as pc + + +def test_sort_by_keywords(): + keywords = {'KEY1': 2, 'KEY2': 0, 'KEY3': 1} + args = 'aaaa bbbb KEY2 KEY1 kkk10 kkk11 ccc ddd KEY3 kkk3 eee'.split() + flat, spec = pc.sort_by_keywords(keywords, args) + assert flat == ['aaaa', 'bbbb', 'ccc', 'ddd', 'eee'] + assert spec == {'KEY1': ['kkk10', 'kkk11'], 'KEY2': True, 'KEY3': ['kkk3']} + + keywords = {'KEY1': 0, 'KEY2': 4} + args = 'aaaa KEY2 eee'.split() + flat, spec = pc.sort_by_keywords(keywords, args) + assert flat == ['aaaa'] + assert spec == {'KEY2': ['eee']} + + keywords = {'KEY1': 2, 'KEY2': 2} + args = 'KEY1 k10 KEY2 k20 KEY1 k11 KEY2 k21 KEY1 k13'.split() + flat, spec = pc.sort_by_keywords(keywords, args) + assert flat == [] + assert spec == {'KEY1': ['k10', 'k11', 'k13'], 'KEY2': ['k20', 'k21']} + + +def test_filter_out_by_keyword(): + assert pc.filter_out_by_keyword([], 'A') == [] + assert pc.filter_out_by_keyword(['x'], 'A') == ['x'] + assert pc.filter_out_by_keyword(['x', 'A'], 'A') == ['x'] + assert pc.filter_out_by_keyword(['x', 'A', 'B'], 'A') == ['x'] + assert pc.filter_out_by_keyword(['x', 'A', 'B', 'y'], 'A') == ['x', 'y'] + assert pc.filter_out_by_keyword(['x', 'A', 'A', 'y'], 'A') == ['x', 'y'] + assert pc.filter_out_by_keyword(['x', 'A', 'A', 'A'], 'A') == ['x'] + assert pc.filter_out_by_keyword(['x', 'A', 'A', 'A', 'B', 'y'], 'A') == ['x', 'y'] + assert pc.filter_out_by_keyword(['x', 'A', 'A', 'A', 'B', 'y', 'A'], 'A') == ['x', 'y'] + assert pc.filter_out_by_keyword(['x', 'A', 'A', 'A', 'B', 'y', 'A', 'F', 'z'], 'A') == ['x', 'y', 'z'] + + +test_data = [ + [[1, 2, 3], 1, [[1], [2], [3]]], + [[1, 2, 3], 2, [[1, 2], [3]]], + [[1, 2, 3, 4], 2, [[1, 2], [3, 4]]], + [[1], 5, [[1]]], +] + + +@pytest.mark.parametrize('lst, chunk_size, expected', test_data, ids=[str(num + 1) for num in range(len(test_data))]) +def test_generate_chunks(lst, chunk_size, expected): + assert list(pc.generate_chunks(lst, chunk_size)) == expected diff --git a/build/plugins/tests/test_requirements.py b/build/plugins/tests/test_requirements.py new file mode 100644 index 00000000000..0c41fbaad0c --- /dev/null +++ b/build/plugins/tests/test_requirements.py @@ -0,0 +1,91 @@ +import pytest + +import build.plugins._requirements as requirements +import build.plugins.lib.test_const as consts + + +class TestRequirements(object): + @pytest.mark.parametrize('test_size', consts.TestSize.sizes()) + def test_cpu(self, test_size): + max_cpu = consts.TestSize.get_max_requirements(test_size).get(consts.TestRequirements.Cpu) + min_cpu = consts.TestRequirementsConstants.MinCpu + assert requirements.check_cpu(-1, test_size) + assert requirements.check_cpu(min_cpu - 1, test_size) + assert requirements.check_cpu("unknown", test_size) + assert not requirements.check_cpu(1, test_size) + assert not requirements.check_cpu(3, test_size) + assert requirements.check_cpu(1000, test_size) + if max_cpu != consts.TestRequirementsConstants.All: + assert requirements.check_cpu(max_cpu + 1, test_size) + assert requirements.check_cpu(max_cpu + 4, test_size) + assert requirements.check_cpu(consts.TestRequirementsConstants.All, test_size) + else: + assert not requirements.check_cpu(consts.TestRequirementsConstants.All, test_size) + + @pytest.mark.parametrize('test_size', consts.TestSize.sizes()) + def test_ram(self, test_size): + max_ram = consts.TestSize.get_max_requirements(test_size).get(consts.TestRequirements.Ram) + min_ram = consts.TestRequirementsConstants.MinRam + assert requirements.check_ram(-1, test_size) + assert requirements.check_ram(min_ram - 1, test_size) + assert requirements.check_ram(max_ram + 1, test_size) + assert not requirements.check_ram(1, test_size) + assert not requirements.check_ram(4, test_size) + assert not requirements.check_ram(5, test_size) + assert not requirements.check_ram(32, consts.TestSize.Large) + assert requirements.check_ram(48, consts.TestSize.Large) + + assert not requirements.check_ram(1, test_size, is_kvm=True) + assert not requirements.check_ram(4, test_size, is_kvm=True) + assert not requirements.check_ram(16, test_size, is_kvm=True) + assert requirements.check_ram(32, test_size, is_kvm=True) + + @pytest.mark.parametrize('test_size', consts.TestSize.sizes()) + def test_ram_disk(self, test_size): + max_ram_disk = consts.TestSize.get_max_requirements(test_size).get(consts.TestRequirements.RamDisk) + min_ram_disk = consts.TestRequirementsConstants.MinRamDisk + assert requirements.check_ram_disk(-1, test_size) + assert requirements.check_ram_disk(min_ram_disk - 1, test_size) + assert requirements.check_ram_disk(max_ram_disk + 1, test_size) + assert requirements.check_ram_disk(33, test_size) + assert not requirements.check_ram_disk(32, test_size) + assert not requirements.check_ram_disk(1, test_size) + assert not requirements.check_ram_disk(4, test_size) + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '0', test_size, False, True, False, False, False, 1 + ) + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, False, False, False, 1 + ) + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, True, True, False, False, False, 0 + ) + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, False, False, False, False, 0 + ) + if test_size != consts.TestSize.Large: + assert requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, False, False, False, 0 + ) + assert requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, True, False, False, 0 + ) + assert requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, False, True, False, 0 + ) + assert requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, False, False, True, 0 + ) + else: + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, False, False, False, 0 + ) + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, True, False, False, 0 + ) + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, False, True, False, 0 + ) + assert not requirements.validate_ram_disk_requirement( + 'ram_disk', '1', test_size, False, True, False, False, True, 0 + ) diff --git a/build/plugins/tests/test_ssqls.py b/build/plugins/tests/test_ssqls.py new file mode 100644 index 00000000000..e5daae3a574 --- /dev/null +++ b/build/plugins/tests/test_ssqls.py @@ -0,0 +1,28 @@ +import sys +from build.plugins.tests import fake_ymake + +sys.modules['ymake'] = fake_ymake + +import xml.etree.cElementTree as ET + +from build.plugins import ssqls + + +example = '''\ +<?xml version="1.0" encoding="utf-8"?> +<DbObject> + <include path="A.ssqls"><a.h></include> + <include>"b.h"</include> + + <ancestors> + <ancestor path="C.ssqls"/> + </ancestors> +</DbObject> +''' + + +def test_include_parser(): + doc = ET.fromstring(example) + xmls, headers = ssqls.SSQLSParser.parse_doc(doc) + assert headers == ['a.h', 'b.h', 'C.h'] + assert xmls == ['A.ssqls', 'C.ssqls'] diff --git a/build/plugins/tests/ya.make b/build/plugins/tests/ya.make new file mode 100644 index 00000000000..0c54899cc98 --- /dev/null +++ b/build/plugins/tests/ya.make @@ -0,0 +1,25 @@ +PY2TEST() + +OWNER(g:yatool) + +PEERDIR( + build/plugins +) + +PY_SRCS( + fake_ymake.py +) + +TEST_SRCS( + test_code_generator.py + test_common.py + test_requirements.py + test_ssqls.py +) + +NO_CHECK_IMPORTS( + build.plugins.code_generator + build.plugins.ssqls +) + +END() diff --git a/build/plugins/uservices.py b/build/plugins/uservices.py new file mode 100644 index 00000000000..69dffd325e2 --- /dev/null +++ b/build/plugins/uservices.py @@ -0,0 +1,37 @@ +import json +import ymake + + +def on_process_usrv_files(unit, *args): + mode = None + if args[0] == 'NO_DEPS': + for f in args[1:]: + if f == 'OUT_NOAUTO': + mode = f + continue + if mode is not None: + unit.on_move([f + '.usrv', mode, f]) + elif f.endswith('.cpp'): + unit.on_move([f + '.usrv', 'OUT', f]) + else: + unit.on_move([f + '.usrv', 'OUT_NOAUTO', f]) + return + + deps_file = unit.resolve(unit.resolve_arc_path(args[0])) + try: + all_deps = json.load(open(deps_file, 'r')) + except Exception as e: + ymake.report_configure_error('Malformed dependencies JSON `{}`: {}'.format(args[0], e.__repr__())) + return + mode = 'OUT' + for f in args[1:]: + if f == 'OUT_NOAUTO': + mode = f + continue + try: + deps = all_deps[f] + except KeyError: + ymake.report_configure_error('Dependencies for {} not found in {}'.format(f, args[0])) + unit.on_usrv_mv_with_deps([f]) + return + unit.on_move([f + '.usrv', mode, f, 'CPP_DEPS'] + deps) diff --git a/build/plugins/ya.make b/build/plugins/ya.make new file mode 100644 index 00000000000..e9ca97626dc --- /dev/null +++ b/build/plugins/ya.make @@ -0,0 +1,24 @@ +OWNER(g:ymake) + +PY2_LIBRARY() + +PY_SRCS( + code_generator.py + ssqls.py + maps_mobile_idl.py + + _common.py + _requirements.py +) + +PEERDIR( + build/plugins/lib + build/plugins/lib/test_const +) + +END() + +RECURSE( + tests + lib/test_const +) diff --git a/build/plugins/yabs_generate_conf.py b/build/plugins/yabs_generate_conf.py new file mode 100644 index 00000000000..ad416aaa0bc --- /dev/null +++ b/build/plugins/yabs_generate_conf.py @@ -0,0 +1,62 @@ +from _common import sort_by_keywords + + +def get_or_default(kv, name, default): + if name in kv: + return kv[name][0] + return default + + +def onyabs_generate_conf(unit, *args): + flat, kv = sort_by_keywords({'MODE': 1, 'SCRIPT': 1, 'SRC': 1, 'TOOL': 1, 'CONF_DIR': 1, 'DEST': 1}, args) + src = get_or_default(kv, 'SRC', 'yabs/server/phantom') + mode = get_or_default(kv, 'MODE', 'production') + + script = src + "/" + get_or_default(kv, 'SCRIPT', 'mkconf.py') + conf = src + "/" + get_or_default(kv, 'CONF_DIR', 'conf-tmpl') + tool = src + "/" + get_or_default(kv, 'TOOL', 'yabs_conf') + + for name in flat: + filename = "/".join([conf, name]) + unit.onpython( + [ + script, + "--cluster-conf-binary", + tool, + "--mode", + mode, + "--dest-dir", + "${BINDIR}", + filename, + "IN", + filename, + "OUT_NOAUTO", + "${BINDIR}/%s" % name, + "TOOL", + tool, + ] + ) + + +def onyabs_generate_phantom_conf_patch(unit, *args): + flat, kv = sort_by_keywords({'SRC': 1, 'DST': 1}, args) + src = '${ARCADIA_BUILD_ROOT}/' + get_or_default(kv, 'SRC', 'yabs/server/phantom/conf') + dst = '${ARCADIA_BUILD_ROOT}/' + get_or_default(kv, 'DST', 'yabs/server/phantom/conf-test') + for f in flat: + lhs = src + '/' + f + rhs = dst + '/' + f + unit.onpython(['mkdiff.py', lhs, rhs, 'IN', lhs, 'IN', rhs, 'STDOUT', f + ".patch"]) + + +def onyabs_generate_phantom_conf_test_check(unit, *args): + yabs_path = args[0] + for name in args[1:]: + unit.onpython( + """ + build/scripts/wrapper.py mkcheckconf.sh ${{ARCADIA_BUILD_ROOT}}/{yabs_path}/phantom/conf-test/yabs-{role}.conf yabs-check-{role}.conf + IN mkcheckconf.sh ${{ARCADIA_BUILD_ROOT}}/{yabs_path}/phantom/conf-test/yabs-{role}.conf + OUT yabs-check-{role}.conf +""".format( + yabs_path=yabs_path, role=name + ).split() # noqa + ) diff --git a/build/plugins/yql_python_udf.py b/build/plugins/yql_python_udf.py new file mode 100644 index 00000000000..b0f95700902 --- /dev/null +++ b/build/plugins/yql_python_udf.py @@ -0,0 +1,60 @@ +from _common import sort_by_keywords + + +def get_or_default(kv, name, default): + if name in kv: + return kv[name][0] + return default + + +def onregister_yql_python_udf(unit, *args): + flat, kv = sort_by_keywords({'NAME': 1, 'RESOURCE_NAME': 1, 'ADD_LIBRA_MODULES': 1}, args) + assert len(flat) == 0 + name = get_or_default(kv, 'NAME', 'CustomPython') + resource_name = get_or_default(kv, 'RESOURCE_NAME', name) + add_libra_modules = get_or_default(kv, 'ADD_LIBRA_MODULES', 'no') == 'yes' + + use_arcadia_python = unit.get('USE_ARCADIA_PYTHON') == 'yes' + py3 = unit.get('PYTHON3') == 'yes' + + unit.onyql_abi_version(['2', '27', '0']) + unit.onpeerdir(['yql/udfs/common/python/python_udf']) + unit.onpeerdir(['ydb/library/yql/public/udf']) + + if add_libra_modules: + unit.onpeerdir(['quality/user_sessions/libra_arc/noyql']) + unit.onpeerdir(['yql/udfs/quality/libra/module']) + + if use_arcadia_python: + flavor = 'Arcadia' + unit.onpeerdir( + ['library/python/runtime', 'yql/udfs/common/python/main'] + if not py3 + else ['library/python/runtime_py3', 'yql/udfs/common/python/main_py3'] + ) + else: + flavor = 'System' + + output_includes = [ + 'yql/udfs/common/python/python_udf/python_udf.h', + 'ydb/library/yql/public/udf/udf_registrator.h', + ] + if add_libra_modules: + output_includes.append('yql/udfs/quality/libra/module/module.h') + + path = name + '.yql_python_udf.cpp' + libra_flag = '1' if add_libra_modules else '0' + unit.onpython( + [ + 'build/scripts/gen_yql_python_udf.py', + flavor, + name, + resource_name, + path, + libra_flag, + 'OUT', + path, + 'OUTPUT_INCLUDES', + ] + + output_includes + ) diff --git a/build/plugins/ytest.py b/build/plugins/ytest.py new file mode 100644 index 00000000000..79db740ca03 --- /dev/null +++ b/build/plugins/ytest.py @@ -0,0 +1,1300 @@ +import os +import re +import sys +import json +import copy +import base64 +import shlex +import _common +import lib.test_const as consts +import _requirements as reqs +import StringIO +import subprocess +import collections + +import ymake + + +MDS_URI_PREFIX = 'https://storage.yandex-team.ru/get-devtools/' +MDS_SCHEME = 'mds' +CANON_DATA_DIR_NAME = 'canondata' +CANON_OUTPUT_STORAGE = 'canondata_storage' +CANON_RESULT_FILE_NAME = 'result.json' +CANON_MDS_RESOURCE_REGEX = re.compile(re.escape(MDS_URI_PREFIX) + r'(.*?)($|#)') +CANON_SBR_RESOURCE_REGEX = re.compile(r'(sbr:/?/?(\d+))') + +BLOCK_SEPARATOR = '=============================================================' +SPLIT_FACTOR_MAX_VALUE = 1000 +SPLIT_FACTOR_TEST_FILES_MAX_VALUE = 4250 +PARTITION_MODS = ('SEQUENTIAL', 'MODULO') +DEFAULT_TIDY_CONFIG = "build/config/tests/clang_tidy/config.yaml" +DEFAULT_TIDY_CONFIG_MAP_PATH = "build/yandex_specific/config/clang_tidy/tidy_default_map.json" +PROJECT_TIDY_CONFIG_MAP_PATH = "build/yandex_specific/config/clang_tidy/tidy_project_map.json" + + +tidy_config_map = None + + +def ontest_data(unit, *args): + ymake.report_configure_error("TEST_DATA is removed in favour of DATA") + + +def prepare_recipes(data): + data = data.replace('"USE_RECIPE_DELIM"', "\n") + data = data.replace("$TEST_RECIPES_VALUE", "") + return base64.b64encode(data or "") + + +def prepare_env(data): + data = data.replace("$TEST_ENV_VALUE", "") + return serialize_list(shlex.split(data)) + + +def is_yt_spec_contain_pool_info(filename): # XXX switch to yson in ymake + perf test for configure + pool_re = re.compile(r"""['"]*pool['"]*\s*?=""") + cypress_root_re = re.compile(r"""['"]*cypress_root['"]*\s*=""") + with open(filename, 'r') as afile: + yt_spec = afile.read() + return pool_re.search(yt_spec) and cypress_root_re.search(yt_spec) + + +def validate_test(unit, kw): + def get_list(key): + return deserialize_list(kw.get(key, "")) + + valid_kw = copy.deepcopy(kw) + errors = [] + warnings = [] + + if valid_kw.get('SCRIPT-REL-PATH') == 'boost.test': + project_path = valid_kw.get('BUILD-FOLDER-PATH', "") + if not project_path.startswith( + ("contrib", "mail", "maps", "tools/idl", "metrika", "devtools", "mds", "yandex_io", "smart_devices") + ): + errors.append("BOOSTTEST is not allowed here") + elif valid_kw.get('SCRIPT-REL-PATH') == 'gtest': + project_path = valid_kw.get('BUILD-FOLDER-PATH', "") + if not project_path.startswith(("contrib", "devtools", "mds")): + errors.append("GTEST_UGLY is not allowed here, use GTEST instead") + + size_timeout = collections.OrderedDict(sorted(consts.TestSize.DefaultTimeouts.items(), key=lambda t: t[1])) + + size = valid_kw.get('SIZE', consts.TestSize.Small).lower() + tags = set(get_list("TAG")) + requirements_orig = get_list("REQUIREMENTS") + in_autocheck = consts.YaTestTags.NotAutocheck not in tags and consts.YaTestTags.Manual not in tags + is_fat = consts.YaTestTags.Fat in tags + is_force_sandbox = consts.YaTestTags.ForceDistbuild not in tags and is_fat + is_ytexec_run = consts.YaTestTags.YtRunner in tags + is_fuzzing = valid_kw.get("FUZZING", False) + is_kvm = 'kvm' in requirements_orig + requirements = {} + secret_requirements = ('sb_vault', 'yav') + list_requirements = secret_requirements + for req in requirements_orig: + if req in ('kvm',): + requirements[req] = str(True) + continue + + if ":" in req: + req_name, req_value = req.split(":", 1) + if req_name in list_requirements: + requirements[req_name] = ",".join(filter(None, [requirements.get(req_name), req_value])) + else: + if req_name in requirements: + if req_value in ["0"]: + warnings.append( + "Requirement [[imp]]{}[[rst]] is dropped [[imp]]{}[[rst]] -> [[imp]]{}[[rst]]".format( + req_name, requirements[req_name], req_value + ) + ) + del requirements[req_name] + elif requirements[req_name] != req_value: + warnings.append( + "Requirement [[imp]]{}[[rst]] is redefined [[imp]]{}[[rst]] -> [[imp]]{}[[rst]]".format( + req_name, requirements[req_name], req_value + ) + ) + requirements[req_name] = req_value + else: + requirements[req_name] = req_value + else: + errors.append("Invalid requirement syntax [[imp]]{}[[rst]]: expect <requirement>:<value>".format(req)) + + if not errors: + for req_name, req_value in requirements.items(): + error_msg = reqs.validate_requirement( + req_name, + req_value, + size, + is_force_sandbox, + in_autocheck, + is_fuzzing, + is_kvm, + is_ytexec_run, + requirements, + ) + if error_msg: + errors += [error_msg] + + invalid_requirements_for_distbuild = [ + requirement for requirement in requirements.keys() if requirement not in ('ram', 'ram_disk', 'cpu', 'network') + ] + sb_tags = [tag for tag in tags if tag.startswith('sb:')] + + if is_fat: + if size != consts.TestSize.Large: + errors.append("Only LARGE test may have ya:fat tag") + + if in_autocheck and not is_force_sandbox: + if invalid_requirements_for_distbuild: + errors.append( + "'{}' REQUIREMENTS options can be used only for FAT tests without ya:force_distbuild tag. Remove TAG(ya:force_distbuild) or an option.".format( + invalid_requirements_for_distbuild + ) + ) + if sb_tags: + errors.append( + "You can set sandbox tags '{}' only for FAT tests without ya:force_distbuild. Remove TAG(ya:force_sandbox) or sandbox tags.".format( + sb_tags + ) + ) + if consts.YaTestTags.SandboxCoverage in tags: + errors.append("You can set 'ya:sandbox_coverage' tag only for FAT tests without ya:force_distbuild.") + if is_ytexec_run: + errors.append( + "Running LARGE tests over YT (ya:yt) on Distbuild (ya:force_distbuild) is forbidden. Consider removing TAG(ya:force_distbuild)." + ) + else: + if is_force_sandbox: + errors.append('ya:force_sandbox can be used with LARGE tests only') + if consts.YaTestTags.NoFuse in tags: + errors.append('ya:nofuse can be used with LARGE tests only') + if consts.YaTestTags.Privileged in tags: + errors.append("ya:privileged can be used with LARGE tests only") + if in_autocheck and size == consts.TestSize.Large: + errors.append("LARGE test must have ya:fat tag") + + if consts.YaTestTags.Privileged in tags and 'container' not in requirements: + errors.append("Only tests with 'container' requirement can have 'ya:privileged' tag") + + if size not in size_timeout: + errors.append( + "Unknown test size: [[imp]]{}[[rst]], choose from [[imp]]{}[[rst]]".format( + size.upper(), ", ".join([sz.upper() for sz in size_timeout.keys()]) + ) + ) + else: + try: + timeout = int(valid_kw.get('TEST-TIMEOUT', size_timeout[size]) or size_timeout[size]) + script_rel_path = valid_kw.get('SCRIPT-REL-PATH') + if timeout < 0: + raise Exception("Timeout must be > 0") + if size_timeout[size] < timeout and in_autocheck and script_rel_path != 'java.style': + suggested_size = None + for s, t in size_timeout.items(): + if timeout <= t: + suggested_size = s + break + + if suggested_size: + suggested_size = ", suggested size: [[imp]]{}[[rst]]".format(suggested_size.upper()) + else: + suggested_size = "" + errors.append( + "Max allowed timeout for test size [[imp]]{}[[rst]] is [[imp]]{} sec[[rst]]{}".format( + size.upper(), size_timeout[size], suggested_size + ) + ) + except Exception as e: + errors.append("Error when parsing test timeout: [[bad]]{}[[rst]]".format(e)) + + requirements_list = [] + for req_name, req_value in requirements.iteritems(): + requirements_list.append(req_name + ":" + req_value) + valid_kw['REQUIREMENTS'] = serialize_list(requirements_list) + + # Mark test with ya:external tag if it requests any secret from external storages + # It's not stable and nonreproducible by definition + for x in secret_requirements: + if x in requirements: + tags.add(consts.YaTestTags.External) + + if valid_kw.get("FUZZ-OPTS"): + for option in get_list("FUZZ-OPTS"): + if not option.startswith("-"): + errors.append( + "Unrecognized fuzzer option '[[imp]]{}[[rst]]'. All fuzzer options should start with '-'".format( + option + ) + ) + break + eqpos = option.find("=") + if eqpos == -1 or len(option) == eqpos + 1: + errors.append( + "Unrecognized fuzzer option '[[imp]]{}[[rst]]'. All fuzzer options should obtain value specified after '='".format( + option + ) + ) + break + if option[eqpos - 1] == " " or option[eqpos + 1] == " ": + errors.append("Spaces are not allowed: '[[imp]]{}[[rst]]'".format(option)) + break + if option[:eqpos] in ("-runs", "-dict", "-jobs", "-workers", "-artifact_prefix", "-print_final_stats"): + errors.append( + "You can't use '[[imp]]{}[[rst]]' - it will be automatically calculated or configured during run".format( + option + ) + ) + break + + if valid_kw.get("YT-SPEC"): + if not is_ytexec_run: + errors.append("You can use YT_SPEC macro only tests marked with ya:yt tag") + else: + for filename in get_list("YT-SPEC"): + filename = unit.resolve('$S/' + filename) + if not os.path.exists(filename): + errors.append("File '{}' specified in the YT_SPEC macro doesn't exist".format(filename)) + continue + if not is_yt_spec_contain_pool_info(filename): + tags.add(consts.YaTestTags.External) + tags.add("ya:yt_research_pool") + + if valid_kw.get("USE_ARCADIA_PYTHON") == "yes" and valid_kw.get("SCRIPT-REL-PATH") == "py.test": + errors.append("PYTEST_SCRIPT is deprecated") + + partition = valid_kw.get('TEST_PARTITION', 'SEQUENTIAL') + if partition not in PARTITION_MODS: + raise ValueError('partition mode should be one of {}, detected: {}'.format(PARTITION_MODS, partition)) + + if valid_kw.get('SPLIT-FACTOR'): + if valid_kw.get('FORK-MODE') == 'none': + errors.append('SPLIT_FACTOR must be use with FORK_TESTS() or FORK_SUBTESTS() macro') + + value = 1 + try: + value = int(valid_kw.get('SPLIT-FACTOR')) + if value <= 0: + raise ValueError("must be > 0") + if value > SPLIT_FACTOR_MAX_VALUE: + raise ValueError("the maximum allowed value is {}".format(SPLIT_FACTOR_MAX_VALUE)) + except ValueError as e: + errors.append('Incorrect SPLIT_FACTOR value: {}'.format(e)) + + if valid_kw.get('FORK-TEST-FILES') and size != consts.TestSize.Large: + nfiles = count_entries(valid_kw.get('TEST-FILES')) + if nfiles * value > SPLIT_FACTOR_TEST_FILES_MAX_VALUE: + errors.append( + 'Too much chunks generated:{} (limit: {}). Remove FORK_TEST_FILES() macro or reduce SPLIT_FACTOR({}).'.format( + nfiles * value, SPLIT_FACTOR_TEST_FILES_MAX_VALUE, value + ) + ) + + if tags: + valid_kw['TAG'] = serialize_list(tags) + + unit_path = _common.get_norm_unit_path(unit) + if ( + not is_fat + and consts.YaTestTags.Noretries in tags + and not is_ytexec_run + and not unit_path.startswith("devtools/dummy_arcadia/test/noretries") + ): + errors.append("Only LARGE tests can have 'ya:noretries' tag") + + if errors: + return None, warnings, errors + + return valid_kw, warnings, errors + + +def dump_test(unit, kw): + valid_kw, warnings, errors = validate_test(unit, kw) + for w in warnings: + unit.message(['warn', w]) + for e in errors: + ymake.report_configure_error(e) + if valid_kw is None: + return None + string_handler = StringIO.StringIO() + for k, v in valid_kw.iteritems(): + print >> string_handler, k + ': ' + v + print >> string_handler, BLOCK_SEPARATOR + data = string_handler.getvalue() + string_handler.close() + return data + + +def serialize_list(lst): + lst = filter(None, lst) + return '\"' + ';'.join(lst) + '\"' if lst else '' + + +def deserialize_list(val): + return filter(None, val.replace('"', "").split(";")) + + +def get_correct_expression_for_group_var(varname): + return "\"${join=\;:" + varname + "}\"" + + +def count_entries(x): + # see (de)serialize_list + assert x is None or isinstance(x, str), type(x) + if not x: + return 0 + return x.count(";") + 1 + + +def get_values_list(unit, key): + res = map(str.strip, (unit.get(key) or '').replace('$' + key, '').strip().split()) + return [r for r in res if r and r not in ['""', "''"]] + + +def get_norm_paths(unit, key): + # return paths without trailing (back)slash + return [x.rstrip('\\/').replace('${ARCADIA_ROOT}/', '') for x in get_values_list(unit, key)] + + +def get_unit_list_variable(unit, name): + items = unit.get(name) + if items: + items = items.split(' ') + assert items[0] == "${}".format(name), (items, name) + return items[1:] + return [] + + +def implies(a, b): + return bool((not a) or b) + + +def match_coverage_extractor_requirements(unit): + # we shouldn't add test if + return all( + [ + # tests are not requested + unit.get("TESTS_REQUESTED") == "yes", + # build doesn't imply clang coverage, which supports segment extraction from the binaries + unit.get("CLANG_COVERAGE") == "yes", + # contrib wasn't requested + implies( + _common.get_norm_unit_path(unit).startswith("contrib/"), unit.get("ENABLE_CONTRIB_COVERAGE") == "yes" + ), + ] + ) + + +def get_tidy_config_map(unit, map_path): + config_map_path = unit.resolve(os.path.join("$S", map_path)) + config_map = {} + try: + with open(config_map_path, 'r') as afile: + config_map = json.load(afile) + except ValueError: + ymake.report_configure_error("{} is invalid json".format(map_path)) + except Exception as e: + ymake.report_configure_error(str(e)) + return config_map + + +def get_default_tidy_config(unit): + unit_path = _common.get_norm_unit_path(unit) + tidy_default_config_map = get_tidy_config_map(unit, DEFAULT_TIDY_CONFIG_MAP_PATH) + for project_prefix, config_path in tidy_default_config_map.items(): + if unit_path.startswith(project_prefix): + return config_path + return DEFAULT_TIDY_CONFIG + + +ordered_tidy_map = None + + +def get_project_tidy_config(unit): + global ordered_tidy_map + if ordered_tidy_map is None: + ordered_tidy_map = list(reversed(sorted(get_tidy_config_map(unit, PROJECT_TIDY_CONFIG_MAP_PATH).items()))) + unit_path = _common.get_norm_unit_path(unit) + + for project_prefix, config_path in ordered_tidy_map: + if unit_path.startswith(project_prefix): + return config_path + else: + return get_default_tidy_config(unit) + + +def onadd_ytest(unit, *args): + keywords = { + "DEPENDS": -1, + "DATA": -1, + "TIMEOUT": 1, + "FORK_MODE": 1, + "SPLIT_FACTOR": 1, + "FORK_SUBTESTS": 0, + "FORK_TESTS": 0, + } + flat_args, spec_args = _common.sort_by_keywords(keywords, args) + if unit.get('ADD_SRCDIR_TO_TEST_DATA') == "yes": + unit.ondata_files(_common.get_norm_unit_path(unit)) + + test_data = sorted( + _common.filter_out_by_keyword( + spec_args.get('DATA', []) + get_norm_paths(unit, 'TEST_DATA_VALUE'), 'AUTOUPDATED' + ) + ) + + if flat_args[1] == "fuzz.test": + unit.ondata("arcadia/fuzzing/{}/corpus.json".format(_common.get_norm_unit_path(unit))) + elif flat_args[1] == "go.test": + data, _ = get_canonical_test_resources(unit) + test_data += data + elif flat_args[1] == "coverage.extractor" and not match_coverage_extractor_requirements(unit): + # XXX + # Current ymake implementation doesn't allow to call macro inside the 'when' body + # that's why we add ADD_YTEST(coverage.extractor) to every PROGRAM entry and check requirements later + return + elif flat_args[1] == "clang_tidy" and unit.get("TIDY_ENABLED") != "yes": + # Graph is not prepared + return + elif unit.get("TIDY") == "yes" and unit.get("TIDY_ENABLED") != "yes": + # clang_tidy disabled for module + return + elif flat_args[1] == "no.test": + return + test_size = ''.join(spec_args.get('SIZE', [])) or unit.get('TEST_SIZE_NAME') or '' + test_tags = serialize_list(_get_test_tags(unit, spec_args)) + test_timeout = ''.join(spec_args.get('TIMEOUT', [])) or unit.get('TEST_TIMEOUT') or '' + test_requirements = spec_args.get('REQUIREMENTS', []) + get_values_list(unit, 'TEST_REQUIREMENTS_VALUE') + + if flat_args[1] != "clang_tidy" and unit.get("TIDY_ENABLED") == "yes": + # graph changed for clang_tidy tests + if flat_args[1] in ("unittest.py", "gunittest", "g_benchmark"): + flat_args[1] = "clang_tidy" + test_size = 'SMALL' + test_tags = '' + test_timeout = "60" + test_requirements = [] + unit.set(["TEST_YT_SPEC_VALUE", ""]) + else: + return + + if flat_args[1] == "clang_tidy" and unit.get("TIDY_ENABLED") == "yes": + if unit.get("TIDY_CONFIG"): + default_config_path = unit.get("TIDY_CONFIG") + project_config_path = unit.get("TIDY_CONFIG") + else: + default_config_path = get_default_tidy_config(unit) + project_config_path = get_project_tidy_config(unit) + + unit.set(["DEFAULT_TIDY_CONFIG", default_config_path]) + unit.set(["PROJECT_TIDY_CONFIG", project_config_path]) + + fork_mode = [] + if 'FORK_SUBTESTS' in spec_args: + fork_mode.append('subtests') + if 'FORK_TESTS' in spec_args: + fork_mode.append('tests') + fork_mode = fork_mode or spec_args.get('FORK_MODE', []) or unit.get('TEST_FORK_MODE').split() + fork_mode = ' '.join(fork_mode) if fork_mode else '' + + unit_path = _common.get_norm_unit_path(unit) + + test_record = { + 'TEST-NAME': flat_args[0], + 'SCRIPT-REL-PATH': flat_args[1], + 'TESTED-PROJECT-NAME': unit.name(), + 'TESTED-PROJECT-FILENAME': unit.filename(), + 'SOURCE-FOLDER-PATH': unit_path, + # TODO get rid of BUILD-FOLDER-PATH + 'BUILD-FOLDER-PATH': unit_path, + 'BINARY-PATH': "{}/{}".format(unit_path, unit.filename()), + 'GLOBAL-LIBRARY-PATH': unit.global_filename(), + 'CUSTOM-DEPENDENCIES': ' '.join(spec_args.get('DEPENDS', []) + get_values_list(unit, 'TEST_DEPENDS_VALUE')), + 'TEST-RECIPES': prepare_recipes(unit.get("TEST_RECIPES_VALUE")), + 'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")), + # 'TEST-PRESERVE-ENV': 'da', + 'TEST-DATA': serialize_list(test_data), + 'TEST-TIMEOUT': test_timeout, + 'FORK-MODE': fork_mode, + 'SPLIT-FACTOR': ''.join(spec_args.get('SPLIT_FACTOR', [])) or unit.get('TEST_SPLIT_FACTOR') or '', + 'SIZE': test_size, + 'TAG': test_tags, + 'REQUIREMENTS': serialize_list(test_requirements), + 'TEST-CWD': unit.get('TEST_CWD_VALUE') or '', + 'FUZZ-DICTS': serialize_list( + spec_args.get('FUZZ_DICTS', []) + get_unit_list_variable(unit, 'FUZZ_DICTS_VALUE') + ), + 'FUZZ-OPTS': serialize_list(spec_args.get('FUZZ_OPTS', []) + get_unit_list_variable(unit, 'FUZZ_OPTS_VALUE')), + 'YT-SPEC': serialize_list(spec_args.get('YT_SPEC', []) + get_unit_list_variable(unit, 'TEST_YT_SPEC_VALUE')), + 'BLOB': unit.get('TEST_BLOB_DATA') or '', + 'SKIP_TEST': unit.get('SKIP_TEST_VALUE') or '', + 'TEST_IOS_DEVICE_TYPE': unit.get('TEST_IOS_DEVICE_TYPE_VALUE') or '', + 'TEST_IOS_RUNTIME_TYPE': unit.get('TEST_IOS_RUNTIME_TYPE_VALUE') or '', + 'ANDROID_APK_TEST_ACTIVITY': unit.get('ANDROID_APK_TEST_ACTIVITY_VALUE') or '', + 'TEST_PARTITION': unit.get("TEST_PARTITION") or 'SEQUENTIAL', + 'GO_BENCH_TIMEOUT': unit.get('GO_BENCH_TIMEOUT') or '', + } + + if flat_args[1] == "go.bench": + if "ya:run_go_benchmark" not in test_record["TAG"]: + return + else: + test_record["TEST-NAME"] += "_bench" + + if flat_args[1] == 'fuzz.test' and unit.get('FUZZING') == 'yes': + test_record['FUZZING'] = '1' + # use all cores if fuzzing requested + test_record['REQUIREMENTS'] = serialize_list( + filter(None, deserialize_list(test_record['REQUIREMENTS']) + ["cpu:all", "ram:all"]) + ) + + data = dump_test(unit, test_record) + if data: + unit.set_property(["DART_DATA", data]) + + +def java_srcdirs_to_data(unit, var): + extra_data = [] + for srcdir in (unit.get(var) or '').replace('$' + var, '').split(): + if srcdir == '.': + srcdir = unit.get('MODDIR') + if srcdir.startswith('${ARCADIA_ROOT}/') or srcdir.startswith('$ARCADIA_ROOT/'): + srcdir = srcdir.replace('${ARCADIA_ROOT}/', '$S/') + srcdir = srcdir.replace('$ARCADIA_ROOT/', '$S/') + if srcdir.startswith('${CURDIR}') or srcdir.startswith('$CURDIR'): + srcdir = srcdir.replace('${CURDIR}', os.path.join('$S', unit.get('MODDIR'))) + srcdir = srcdir.replace('$CURDIR', os.path.join('$S', unit.get('MODDIR'))) + srcdir = unit.resolve_arc_path(srcdir) + if not srcdir.startswith('$'): + srcdir = os.path.join('$S', unit.get('MODDIR'), srcdir) + if srcdir.startswith('$S'): + extra_data.append(srcdir.replace('$S', 'arcadia')) + return serialize_list(extra_data) + + +def onadd_check(unit, *args): + if unit.get("TIDY") == "yes": + # graph changed for clang_tidy tests + return + flat_args, spec_args = _common.sort_by_keywords( + { + "DEPENDS": -1, + "TIMEOUT": 1, + "DATA": -1, + "TAG": -1, + "REQUIREMENTS": -1, + "FORK_MODE": 1, + "SPLIT_FACTOR": 1, + "FORK_SUBTESTS": 0, + "FORK_TESTS": 0, + "SIZE": 1, + }, + args, + ) + check_type = flat_args[0] + + if check_type in ("check.data", "check.resource") and unit.get('VALIDATE_DATA') == "no": + return + + test_dir = _common.get_norm_unit_path(unit) + + test_timeout = '' + fork_mode = '' + extra_test_data = '' + extra_test_dart_data = {} + ymake_java_test = unit.get('YMAKE_JAVA_TEST') == 'yes' + use_arcadia_python = unit.get('USE_ARCADIA_PYTHON') + uid_ext = '' + script_rel_path = check_type + test_files = flat_args[1:] + + if check_type in ["check.data", "check.resource"]: + uid_ext = unit.get("SBR_UID_EXT").split(" ", 1)[-1] # strip variable name + + if check_type in ["flake8.py2", "flake8.py3", "black"]: + fork_mode = unit.get('TEST_FORK_MODE') or '' + elif check_type == "JAVA_STYLE": + if ymake_java_test and not unit.get('ALL_SRCDIRS') or '': + return + if len(flat_args) < 2: + raise Exception("Not enough arguments for JAVA_STYLE check") + check_level = flat_args[1] + allowed_levels = { + 'base': '/yandex_checks.xml', + 'strict': '/yandex_checks_strict.xml', + 'extended': '/yandex_checks_extended.xml', + 'library': '/yandex_checks_library.xml', + } + if check_level not in allowed_levels: + raise Exception("'{}' is not allowed in LINT(), use one of {}".format(check_level, allowed_levels.keys())) + test_files[0] = allowed_levels[check_level] # replace check_level with path to config file + script_rel_path = "java.style" + test_timeout = '240' + fork_mode = unit.get('TEST_FORK_MODE') or '' + if ymake_java_test: + extra_test_data = java_srcdirs_to_data(unit, 'ALL_SRCDIRS') + + # jstyle should use the latest jdk + unit.onpeerdir([unit.get('JDK_LATEST_PEERDIR')]) + extra_test_dart_data['JDK_LATEST_VERSION'] = unit.get('JDK_LATEST_VERSION') + # TODO remove when ya-bin will be released (https://st.yandex-team.ru/DEVTOOLS-9611) + extra_test_dart_data['JDK_RESOURCE'] = 'JDK' + ( + unit.get('JDK_VERSION') or unit.get('JDK_REAL_VERSION') or '_DEFAULT' + ) + elif check_type == "gofmt": + if test_files: + test_dir = os.path.dirname(test_files[0]).lstrip("$S/") + elif check_type == "check.data": + data_re = re.compile(r"sbr:/?/?(\d+)=?.*") + data = flat_args[1:] + resources = [] + for f in data: + matched = re.match(data_re, f) + if matched: + resources.append(matched.group(1)) + if resources: + test_files = resources + else: + return + + serialized_test_files = serialize_list(test_files) + + test_record = { + 'TEST-NAME': check_type.lower(), + 'TEST-TIMEOUT': test_timeout, + 'SCRIPT-REL-PATH': script_rel_path, + 'TESTED-PROJECT-NAME': os.path.basename(test_dir), + 'SOURCE-FOLDER-PATH': test_dir, + 'CUSTOM-DEPENDENCIES': " ".join(spec_args.get('DEPENDS', [])), + 'TEST-DATA': extra_test_data, + 'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")), + 'SBR-UID-EXT': uid_ext, + 'SPLIT-FACTOR': '', + 'TEST_PARTITION': 'SEQUENTIAL', + 'FORK-MODE': fork_mode, + 'FORK-TEST-FILES': '', + 'SIZE': 'SMALL', + 'TAG': '', + 'REQUIREMENTS': " ".join(spec_args.get('REQUIREMENTS', [])), + 'USE_ARCADIA_PYTHON': use_arcadia_python or '', + 'OLD_PYTEST': 'no', + 'PYTHON-PATHS': '', + # TODO remove FILES, see DEVTOOLS-7052 + 'FILES': serialized_test_files, + 'TEST-FILES': serialized_test_files, + } + test_record.update(extra_test_dart_data) + + data = dump_test(unit, test_record) + if data: + unit.set_property(["DART_DATA", data]) + + +def on_register_no_check_imports(unit): + s = unit.get('NO_CHECK_IMPORTS_FOR_VALUE') + if s not in ('', 'None'): + unit.onresource(['-', 'py/no_check_imports/{}="{}"'.format(_common.pathid(s), s)]) + + +def onadd_check_py_imports(unit, *args): + if unit.get("TIDY") == "yes": + # graph changed for clang_tidy tests + return + if unit.get('NO_CHECK_IMPORTS_FOR_VALUE').strip() == "": + return + unit.onpeerdir(['library/python/testing/import_test']) + check_type = "py.imports" + test_dir = _common.get_norm_unit_path(unit) + + use_arcadia_python = unit.get('USE_ARCADIA_PYTHON') + test_files = serialize_list([_common.get_norm_unit_path(unit, unit.filename())]) + test_record = { + 'TEST-NAME': "pyimports", + 'TEST-TIMEOUT': '', + 'SCRIPT-REL-PATH': check_type, + 'TESTED-PROJECT-NAME': os.path.basename(test_dir), + 'SOURCE-FOLDER-PATH': test_dir, + 'CUSTOM-DEPENDENCIES': '', + 'TEST-DATA': '', + 'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")), + 'SPLIT-FACTOR': '', + 'TEST_PARTITION': 'SEQUENTIAL', + 'FORK-MODE': '', + 'FORK-TEST-FILES': '', + 'SIZE': 'SMALL', + 'TAG': '', + 'USE_ARCADIA_PYTHON': use_arcadia_python or '', + 'OLD_PYTEST': 'no', + 'PYTHON-PATHS': '', + # TODO remove FILES, see DEVTOOLS-7052 + 'FILES': test_files, + 'TEST-FILES': test_files, + } + if unit.get('NO_CHECK_IMPORTS_FOR_VALUE') != "None": + test_record["NO-CHECK"] = serialize_list(get_values_list(unit, 'NO_CHECK_IMPORTS_FOR_VALUE') or ["*"]) + else: + test_record["NO-CHECK"] = '' + data = dump_test(unit, test_record) + if data: + unit.set_property(["DART_DATA", data]) + + +def onadd_pytest_script(unit, *args): + if unit.get("TIDY") == "yes": + # graph changed for clang_tidy tests + return + unit.set(["PYTEST_BIN", "no"]) + custom_deps = get_values_list(unit, 'TEST_DEPENDS_VALUE') + timeout = filter(None, [unit.get(["TEST_TIMEOUT"])]) + if unit.get('ADD_SRCDIR_TO_TEST_DATA') == "yes": + unit.ondata_files(_common.get_norm_unit_path(unit)) + + if timeout: + timeout = timeout[0] + else: + timeout = '0' + test_type = args[0] + fork_mode = unit.get('TEST_FORK_MODE').split() or '' + split_factor = unit.get('TEST_SPLIT_FACTOR') or '' + test_size = unit.get('TEST_SIZE_NAME') or '' + + test_files = get_values_list(unit, 'TEST_SRCS_VALUE') + tags = _get_test_tags(unit) + requirements = get_values_list(unit, 'TEST_REQUIREMENTS_VALUE') + test_data = get_norm_paths(unit, 'TEST_DATA_VALUE') + data, data_files = get_canonical_test_resources(unit) + test_data += data + python_paths = get_values_list(unit, 'TEST_PYTHON_PATH_VALUE') + binary_path = os.path.join(_common.get_norm_unit_path(unit), unit.filename()) + test_cwd = unit.get('TEST_CWD_VALUE') or '' + _dump_test( + unit, + test_type, + test_files, + timeout, + _common.get_norm_unit_path(unit), + custom_deps, + test_data, + python_paths, + split_factor, + fork_mode, + test_size, + tags, + requirements, + binary_path, + test_cwd=test_cwd, + data_files=data_files, + ) + + +def onadd_pytest_bin(unit, *args): + if unit.get("TIDY") == "yes": + # graph changed for clang_tidy tests + return + flat, kws = _common.sort_by_keywords({'RUNNER_BIN': 1}, args) + if flat: + ymake.report_configure_error('Unknown arguments found while processing add_pytest_bin macro: {!r}'.format(flat)) + + runner_bin = kws.get('RUNNER_BIN', [None])[0] + test_type = 'py3test.bin' if (unit.get("PYTHON3") == 'yes') else "pytest.bin" + + add_test_to_dart(unit, test_type, runner_bin=runner_bin) + + +def add_test_to_dart(unit, test_type, binary_path=None, runner_bin=None): + if unit.get("TIDY") == "yes": + # graph changed for clang_tidy tests + return + if unit.get('ADD_SRCDIR_TO_TEST_DATA') == "yes": + unit.ondata_files(_common.get_norm_unit_path(unit)) + custom_deps = get_values_list(unit, 'TEST_DEPENDS_VALUE') + timeout = filter(None, [unit.get(["TEST_TIMEOUT"])]) + if timeout: + timeout = timeout[0] + else: + timeout = '0' + fork_mode = unit.get('TEST_FORK_MODE').split() or '' + split_factor = unit.get('TEST_SPLIT_FACTOR') or '' + test_size = unit.get('TEST_SIZE_NAME') or '' + test_cwd = unit.get('TEST_CWD_VALUE') or '' + + unit_path = unit.path() + test_files = get_values_list(unit, 'TEST_SRCS_VALUE') + tags = _get_test_tags(unit) + requirements = get_values_list(unit, 'TEST_REQUIREMENTS_VALUE') + test_data = get_norm_paths(unit, 'TEST_DATA_VALUE') + data, data_files = get_canonical_test_resources(unit) + test_data += data + python_paths = get_values_list(unit, 'TEST_PYTHON_PATH_VALUE') + yt_spec = get_values_list(unit, 'TEST_YT_SPEC_VALUE') + if not binary_path: + binary_path = os.path.join(unit_path, unit.filename()) + _dump_test( + unit, + test_type, + test_files, + timeout, + _common.get_norm_unit_path(unit), + custom_deps, + test_data, + python_paths, + split_factor, + fork_mode, + test_size, + tags, + requirements, + binary_path, + test_cwd=test_cwd, + runner_bin=runner_bin, + yt_spec=yt_spec, + data_files=data_files, + ) + + +def extract_java_system_properties(unit, args): + if len(args) % 2: + return [], 'Wrong use of SYSTEM_PROPERTIES in {}: odd number of arguments'.format(unit.path()) + + props = [] + for x, y in zip(args[::2], args[1::2]): + if x == 'FILE': + if y.startswith('${BINDIR}') or y.startswith('${ARCADIA_BUILD_ROOT}') or y.startswith('/'): + return [], 'Wrong use of SYSTEM_PROPERTIES in {}: absolute/build file path {}'.format(unit.path(), y) + + y = _common.rootrel_arc_src(y, unit) + if not os.path.exists(unit.resolve('$S/' + y)): + return [], 'Wrong use of SYSTEM_PROPERTIES in {}: can\'t resolve {}'.format(unit.path(), y) + + y = '${ARCADIA_ROOT}/' + y + props.append({'type': 'file', 'path': y}) + else: + props.append({'type': 'inline', 'key': x, 'value': y}) + + return props, None + + +def onjava_test(unit, *args): + if unit.get("TIDY") == "yes": + # graph changed for clang_tidy tests + return + + assert unit.get('MODULE_TYPE') is not None + + if unit.get('MODULE_TYPE') == 'JTEST_FOR': + if not unit.get('UNITTEST_DIR'): + ymake.report_configure_error('skip JTEST_FOR in {}: no args provided'.format(unit.path())) + return + + java_cp_arg_type = unit.get('JAVA_CLASSPATH_CMD_TYPE_VALUE') or 'MANIFEST' + if java_cp_arg_type not in ('MANIFEST', 'COMMAND_FILE', 'LIST'): + ymake.report_configure_error( + '{}: TEST_JAVA_CLASSPATH_CMD_TYPE({}) are invalid. Choose argument from MANIFEST, COMMAND_FILE or LIST)'.format( + unit.path(), java_cp_arg_type + ) + ) + return + + unit_path = unit.path() + path = _common.strip_roots(unit_path) + if unit.get('ADD_SRCDIR_TO_TEST_DATA') == "yes": + unit.ondata_files(_common.get_norm_unit_path(unit)) + + test_data = get_norm_paths(unit, 'TEST_DATA_VALUE') + test_data.append('arcadia/build/scripts/run_junit.py') + test_data.append('arcadia/build/scripts/unpacking_jtest_runner.py') + + data, data_files = get_canonical_test_resources(unit) + test_data += data + + props, error_mgs = extract_java_system_properties(unit, get_values_list(unit, 'SYSTEM_PROPERTIES_VALUE')) + if error_mgs: + ymake.report_configure_error(error_mgs) + return + for prop in props: + if prop['type'] == 'file': + test_data.append(prop['path'].replace('${ARCADIA_ROOT}', 'arcadia')) + + props = base64.b64encode(json.dumps(props, encoding='utf-8')) + + test_cwd = unit.get('TEST_CWD_VALUE') or '' # TODO: validate test_cwd value + + if unit.get('MODULE_TYPE') == 'JUNIT5': + script_rel_path = 'junit5.test' + else: + script_rel_path = 'junit.test' + + ymake_java_test = unit.get('YMAKE_JAVA_TEST') == 'yes' + test_record = { + 'SOURCE-FOLDER-PATH': path, + 'TEST-NAME': '-'.join([os.path.basename(os.path.dirname(path)), os.path.basename(path)]), + 'SCRIPT-REL-PATH': script_rel_path, + 'TEST-TIMEOUT': unit.get('TEST_TIMEOUT') or '', + 'TESTED-PROJECT-NAME': path, + 'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")), + # 'TEST-PRESERVE-ENV': 'da', + 'TEST-DATA': serialize_list(sorted(_common.filter_out_by_keyword(test_data, 'AUTOUPDATED'))), + 'FORK-MODE': unit.get('TEST_FORK_MODE') or '', + 'SPLIT-FACTOR': unit.get('TEST_SPLIT_FACTOR') or '', + 'CUSTOM-DEPENDENCIES': ' '.join(get_values_list(unit, 'TEST_DEPENDS_VALUE')), + 'TAG': serialize_list(_get_test_tags(unit)), + 'SIZE': unit.get('TEST_SIZE_NAME') or '', + 'REQUIREMENTS': serialize_list(get_values_list(unit, 'TEST_REQUIREMENTS_VALUE')), + 'TEST-RECIPES': prepare_recipes(unit.get("TEST_RECIPES_VALUE")), + # JTEST/JTEST_FOR only + 'MODULE_TYPE': unit.get('MODULE_TYPE'), + 'UNITTEST_DIR': unit.get('UNITTEST_DIR') or '', + 'JVM_ARGS': serialize_list(get_values_list(unit, 'JVM_ARGS_VALUE')), + 'SYSTEM_PROPERTIES': props, + 'TEST-CWD': test_cwd, + 'SKIP_TEST': unit.get('SKIP_TEST_VALUE') or '', + 'JAVA_CLASSPATH_CMD_TYPE': java_cp_arg_type, + 'JDK_RESOURCE': 'JDK' + (unit.get('JDK_VERSION') or unit.get('JDK_REAL_VERSION') or '_DEFAULT'), + 'JDK_FOR_TESTS': 'JDK' + (unit.get('JDK_VERSION') or unit.get('JDK_REAL_VERSION') or '_DEFAULT') + '_FOR_TESTS', + 'YT-SPEC': serialize_list(get_unit_list_variable(unit, 'TEST_YT_SPEC_VALUE')), + } + test_classpath_origins = unit.get('TEST_CLASSPATH_VALUE') + if test_classpath_origins: + test_record['TEST_CLASSPATH_ORIGINS'] = test_classpath_origins + test_record['TEST_CLASSPATH'] = '${TEST_CLASSPATH_MANAGED}' + elif ymake_java_test: + test_record['TEST_CLASSPATH'] = '${DART_CLASSPATH}' + test_record['TEST_CLASSPATH_DEPS'] = '${DART_CLASSPATH_DEPS}' + if unit.get('UNITTEST_DIR'): + test_record['TEST_JAR'] = '${UNITTEST_MOD}' + else: + test_record['TEST_JAR'] = '{}/{}.jar'.format(unit.get('MODDIR'), unit.get('REALPRJNAME')) + + data = dump_test(unit, test_record) + if data: + unit.set_property(['DART_DATA', data]) + + +def onjava_test_deps(unit, *args): + if unit.get("TIDY") == "yes": + # graph changed for clang_tidy tests + return + + assert unit.get('MODULE_TYPE') is not None + assert len(args) == 1 + mode = args[0] + + path = _common.get_norm_unit_path(unit) + ymake_java_test = unit.get('YMAKE_JAVA_TEST') == 'yes' + + test_record = { + 'SOURCE-FOLDER-PATH': path, + 'TEST-NAME': '-'.join([os.path.basename(os.path.dirname(path)), os.path.basename(path), 'dependencies']).strip( + '-' + ), + 'SCRIPT-REL-PATH': 'java.dependency.test', + 'TEST-TIMEOUT': '', + 'TESTED-PROJECT-NAME': path, + 'TEST-DATA': '', + 'TEST_PARTITION': 'SEQUENTIAL', + 'FORK-MODE': '', + 'SPLIT-FACTOR': '', + 'CUSTOM-DEPENDENCIES': ' '.join(get_values_list(unit, 'TEST_DEPENDS_VALUE')), + 'TAG': '', + 'SIZE': 'SMALL', + 'IGNORE_CLASSPATH_CLASH': ' '.join(get_values_list(unit, 'JAVA_IGNORE_CLASSPATH_CLASH_VALUE')), + # JTEST/JTEST_FOR only + 'MODULE_TYPE': unit.get('MODULE_TYPE'), + 'UNITTEST_DIR': '', + 'SYSTEM_PROPERTIES': '', + 'TEST-CWD': '', + } + if mode == 'strict': + test_record['STRICT_CLASSPATH_CLASH'] = 'yes' + + if ymake_java_test: + test_record['CLASSPATH'] = '$B/{}/{}.jar ${{DART_CLASSPATH}}'.format( + unit.get('MODDIR'), unit.get('REALPRJNAME') + ) + + data = dump_test(unit, test_record) + unit.set_property(['DART_DATA', data]) + + +def _get_test_tags(unit, spec_args=None): + if spec_args is None: + spec_args = {} + tags = spec_args.get('TAG', []) + get_values_list(unit, 'TEST_TAGS_VALUE') + tags = set(tags) + if unit.get('EXPORT_SEM') == 'yes': + filter_only_tags = sorted(t for t in tags if ':' not in t) + unit.set(['FILTER_ONLY_TEST_TAGS', ' '.join(filter_only_tags)]) + # DEVTOOLS-7571 + if unit.get('SKIP_TEST_VALUE') and consts.YaTestTags.Fat in tags: + tags.add(consts.YaTestTags.NotAutocheck) + + return tags + + +def _dump_test( + unit, + test_type, + test_files, + timeout, + test_dir, + custom_deps, + test_data, + python_paths, + split_factor, + fork_mode, + test_size, + tags, + requirements, + binary_path='', + old_pytest=False, + test_cwd=None, + runner_bin=None, + yt_spec=None, + data_files=None, +): + + if test_type == "PY_TEST": + script_rel_path = "py.test" + else: + script_rel_path = test_type + + unit_path = unit.path() + fork_test_files = unit.get('FORK_TEST_FILES_MODE') + fork_mode = ' '.join(fork_mode) if fork_mode else '' + use_arcadia_python = unit.get('USE_ARCADIA_PYTHON') + if test_cwd: + test_cwd = test_cwd.replace("$TEST_CWD_VALUE", "").replace('"MACRO_CALLS_DELIM"', "").strip() + test_name = os.path.basename(binary_path) + test_record = { + 'TEST-NAME': os.path.splitext(test_name)[0], + 'TEST-TIMEOUT': timeout, + 'SCRIPT-REL-PATH': script_rel_path, + 'TESTED-PROJECT-NAME': test_name, + 'SOURCE-FOLDER-PATH': test_dir, + 'CUSTOM-DEPENDENCIES': " ".join(custom_deps), + 'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")), + # 'TEST-PRESERVE-ENV': 'da', + 'TEST-DATA': serialize_list(sorted(_common.filter_out_by_keyword(test_data, 'AUTOUPDATED'))), + 'TEST-RECIPES': prepare_recipes(unit.get("TEST_RECIPES_VALUE")), + 'SPLIT-FACTOR': split_factor, + 'TEST_PARTITION': unit.get('TEST_PARTITION') or 'SEQUENTIAL', + 'FORK-MODE': fork_mode, + 'FORK-TEST-FILES': fork_test_files, + 'TEST-FILES': serialize_list(test_files), + 'SIZE': test_size, + 'TAG': serialize_list(tags), + 'REQUIREMENTS': serialize_list(requirements), + 'USE_ARCADIA_PYTHON': use_arcadia_python or '', + 'OLD_PYTEST': 'yes' if old_pytest else 'no', + 'PYTHON-PATHS': serialize_list(python_paths), + 'TEST-CWD': test_cwd or '', + 'SKIP_TEST': unit.get('SKIP_TEST_VALUE') or '', + 'BUILD-FOLDER-PATH': _common.strip_roots(unit_path), + 'BLOB': unit.get('TEST_BLOB_DATA') or '', + 'CANONIZE_SUB_PATH': unit.get('CANONIZE_SUB_PATH') or '', + } + if binary_path: + test_record['BINARY-PATH'] = _common.strip_roots(binary_path) + if runner_bin: + test_record['TEST-RUNNER-BIN'] = runner_bin + if yt_spec: + test_record['YT-SPEC'] = serialize_list(yt_spec) + data = dump_test(unit, test_record) + if data: + unit.set_property(["DART_DATA", data]) + + +def onsetup_pytest_bin(unit, *args): + use_arcadia_python = unit.get('USE_ARCADIA_PYTHON') == "yes" + if use_arcadia_python: + unit.onresource(['-', 'PY_MAIN={}'.format("library.python.pytest.main:main")]) # XXX + unit.onadd_pytest_bin(list(args)) + else: + unit.onno_platform() + unit.onadd_pytest_script(["PY_TEST"]) + + +def onrun(unit, *args): + exectest_cmd = unit.get(["EXECTEST_COMMAND_VALUE"]) or '' + exectest_cmd += "\n" + subprocess.list2cmdline(args) + unit.set(["EXECTEST_COMMAND_VALUE", exectest_cmd]) + + +def onsetup_exectest(unit, *args): + command = unit.get(["EXECTEST_COMMAND_VALUE"]) + if command is None: + ymake.report_configure_error("EXECTEST must have at least one RUN macro") + return + command = command.replace("$EXECTEST_COMMAND_VALUE", "") + if "PYTHON_BIN" in command: + unit.ondepends('contrib/tools/python') + unit.set(["TEST_BLOB_DATA", base64.b64encode(command)]) + add_test_to_dart(unit, "exectest", binary_path=os.path.join(unit.path(), unit.filename()).replace(".pkg", "")) + + +def onsetup_run_python(unit): + if unit.get("USE_ARCADIA_PYTHON") == "yes": + unit.ondepends('contrib/tools/python') + + +def get_canonical_test_resources(unit): + unit_path = unit.path() + canon_data_dir = os.path.join(unit.resolve(unit_path), CANON_DATA_DIR_NAME, unit.get('CANONIZE_SUB_PATH') or '') + + try: + _, dirs, files = next(os.walk(canon_data_dir)) + except StopIteration: + # path doesn't exist + return [], [] + + if CANON_RESULT_FILE_NAME in files: + return _get_canonical_data_resources_v2(os.path.join(canon_data_dir, CANON_RESULT_FILE_NAME), unit_path) + return [], [] + + +def _load_canonical_file(filename, unit_path): + try: + with open(filename) as results_file: + return json.load(results_file) + except Exception as e: + print >> sys.stderr, "malformed canonical data in {}: {} ({})".format(unit_path, e, filename) + return {} + + +def _get_resource_from_uri(uri): + m = CANON_MDS_RESOURCE_REGEX.match(uri) + if m: + res_id = m.group(1) + return "{}:{}".format(MDS_SCHEME, res_id) + + m = CANON_SBR_RESOURCE_REGEX.match(uri) + if m: + # There might be conflict between resources, because all resources in sandbox have 'resource.tar.gz' name + # That's why we use notation with '=' to specify specific path for resource + uri = m.group(1) + res_id = m.group(2) + return "{}={}".format(uri, '/'.join([CANON_OUTPUT_STORAGE, res_id])) + + +def _get_external_resources_from_canon_data(data): + # Method should work with both canonization versions: + # result.json: {'uri':X 'checksum':Y} + # result.json: {'testname': {'uri':X 'checksum':Y}} + # result.json: {'testname': [{'uri':X 'checksum':Y}]} + # Also there is a bug - if user returns {'uri': 1} from test - machinery will fail + # That's why we check 'uri' and 'checksum' fields presence + # (it's still a bug - user can return {'uri':X, 'checksum': Y}, we need to unify canonization format) + res = set() + + if isinstance(data, dict): + if 'uri' in data and 'checksum' in data: + resource = _get_resource_from_uri(data['uri']) + if resource: + res.add(resource) + else: + for k, v in data.iteritems(): + res.update(_get_external_resources_from_canon_data(v)) + elif isinstance(data, list): + for e in data: + res.update(_get_external_resources_from_canon_data(e)) + + return res + + +def _get_canonical_data_resources_v2(filename, unit_path): + return (_get_external_resources_from_canon_data(_load_canonical_file(filename, unit_path)), [filename]) + + +def on_add_linter_check(unit, *args): + if unit.get("TIDY") == "yes": + return + source_root_from_prefix = '${ARCADIA_ROOT}/' + source_root_to_prefix = '$S/' + unlimited = -1 + + no_lint_value = _common.get_no_lint_value(unit) + if no_lint_value in ("none", "none_internal"): + return + + if unit.get("OPENSOURCE") == "yes": + return + + keywords = { + "DEPENDS": unlimited, + "FILES": unlimited, + "CONFIGS": unlimited, + "GLOBAL_RESOURCES": unlimited, + "FILE_PROCESSING_TIME": 1, + "EXTRA_PARAMS": unlimited, + } + flat_args, spec_args = _common.sort_by_keywords(keywords, args) + if len(flat_args) != 2: + unit.message(['ERROR', '_ADD_LINTER_CHECK params: expected 2 free parameters']) + return + + configs = [] + for cfg in spec_args.get('CONFIGS', []): + filename = unit.resolve(source_root_to_prefix + cfg) + if not os.path.exists(filename): + unit.message(['ERROR', 'Configuration file {} is not found'.format(filename)]) + return + configs.append(cfg) + deps = [] + + lint_name, linter = flat_args + deps.append(os.path.dirname(linter)) + + test_files = [] + for path in spec_args.get('FILES', []): + if path.startswith(source_root_from_prefix): + test_files.append(path.replace(source_root_from_prefix, source_root_to_prefix, 1)) + elif path.startswith(source_root_to_prefix): + test_files.append(path) + if not test_files: + unit.message(['WARN', 'No files to lint for {}'.format(lint_name)]) + return + for arg in spec_args.get('EXTRA_PARAMS', []): + if '=' not in arg: + unit.message(['WARN', 'Wrong EXTRA_PARAMS value: "{}". Values must have format "name=value".'.format(arg)]) + return + + deps += spec_args.get('DEPENDS', []) + + for dep in deps: + unit.ondepends(dep) + + for resource in spec_args.get('GLOBAL_RESOURCES', []): + unit.onpeerdir(resource) + + test_record = { + 'TEST-NAME': lint_name, + 'SCRIPT-REL-PATH': 'custom_lint', + 'TESTED-PROJECT-NAME': unit.name(), + 'SOURCE-FOLDER-PATH': _common.get_norm_unit_path(unit), + 'CUSTOM-DEPENDENCIES': " ".join(deps), + 'TEST-DATA': '', + 'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")), + 'TEST-TIMEOUT': '', + 'SPLIT-FACTOR': '', + 'TEST_PARTITION': 'SEQUENTIAL', + 'FORK-MODE': '', + 'FORK-TEST-FILES': '', + 'SIZE': 'SMALL', + 'TAG': '', + 'USE_ARCADIA_PYTHON': unit.get('USE_ARCADIA_PYTHON') or '', + 'OLD_PYTEST': 'no', + 'PYTHON-PATHS': '', + # TODO remove FILES, see DEVTOOLS-7052 + 'FILES': serialize_list(test_files), + 'TEST-FILES': serialize_list(test_files), + # Linter specific parameters + # TODO Add configs to DATA. See YMAKE-427 + 'LINT-CONFIGS': serialize_list(configs), + 'LINT-NAME': lint_name, + 'LINT-FILE-PROCESSING-TIME': spec_args.get('FILE_PROCESSING_TIME', [''])[0], + 'LINT-EXTRA-PARAMS': serialize_list(spec_args.get('EXTRA_PARAMS', [])), + 'LINTER': linter, + } + data = dump_test(unit, test_record) + if data: + unit.set_property(["DART_DATA", data]) diff --git a/build/plugins/ytest2.py b/build/plugins/ytest2.py new file mode 100644 index 00000000000..f395ce2475b --- /dev/null +++ b/build/plugins/ytest2.py @@ -0,0 +1,58 @@ +import os +import _common + + +def dir_stmts(unit, dir): + unit.onpeerdir(dir) + unit.onsrcdir(os.sep.join([dir, 'tests'])) + + +def pytest_base(unit, args): + related_prj_dir = args[0] + related_prj_name = args[1] + dir_stmts(unit, related_prj_dir) + ytest_base(unit, related_prj_dir, related_prj_name, args[2:]) + unit.set(['ADDITIONAL_PATH', '--test-related-path ${ARCADIA_ROOT}/test']) + + +def ytest_base(unit, related_prj_dir, related_prj_name, args): + keywords = {"DEPENDS": -1, "DATA": -1} + flat_args, spec_args = _common.sort_by_keywords(keywords, args) + unit.set(['TEST-NAME', os.path.basename(flat_args[0])]) + unit.set(['SCRIPT-REL-PATH', flat_args[1]]) + unit.set(['SOURCE-FOLDER-PATH', related_prj_dir]) + unit.set(['BUILD-FOLDER-PATH', os.path.join('$B', related_prj_dir)]) + unit.set(['TESTED-BINARY-PATH', flat_args[0]]) + + custom_deps = ' '.join(spec_args["DEPENDS"]) if "DEPENDS" in spec_args else '' + unit.set(['CUSTOM-DEPENDENCIES', custom_deps]) + data_lst = spec_args.get('DATA', []) + (unit.get(['__test_data']) or '').split(' ') + data_lst.sort() + data = '\"' + ';'.join(data_lst) + '\"' if data_lst else '' + unit.set(['TEST-DATA', data]) + + related_dirs_list = [ + '{ARCADIA_ROOT}/devtools/${YA_ROOT}', + '${ARCADIA_ROOT}/devtools/${YA_ROOT}', + '$RELATED_TARGET_SRCDIR', + ] + related_dirs_value = [] + for rel in related_dirs_list: + related_dirs_value.extend(['--test-related-path', rel]) + unit.set(['RELATED_DIRS', ' '.join(related_dirs_value)]) + unit.set(['TEST_KV', '${{kv;hide:"test_related_dirs {}"}}'.format(' '.join(related_dirs_list))]) + + +def on_unittest(unit, *args): + related_prj_name = args[0] + related_prj_dir = args[1][3:] + unit.set(['TEST_TYPE', '${kv;hide:"test-type unittest"}']) + ytest_base(unit, related_prj_dir, related_prj_name, args) + + +def on_ytest(unit, *args): + pytest_base(unit, args) + + +def on_py_test(unit, *args): + pytest_base(unit, args) diff --git a/build/scripts/__pycache__/process_command_files.cpython-310.pyc b/build/scripts/__pycache__/process_command_files.cpython-310.pyc Binary files differnew file mode 100644 index 00000000000..bc379d64a65 --- /dev/null +++ b/build/scripts/__pycache__/process_command_files.cpython-310.pyc diff --git a/build/scripts/__pycache__/process_whole_archive_option.cpython-310.pyc b/build/scripts/__pycache__/process_whole_archive_option.cpython-310.pyc Binary files differnew file mode 100644 index 00000000000..fd67bee5b93 --- /dev/null +++ b/build/scripts/__pycache__/process_whole_archive_option.cpython-310.pyc diff --git a/build/scripts/_check_compiler.cpp b/build/scripts/_check_compiler.cpp new file mode 100644 index 00000000000..53c5fdf1799 --- /dev/null +++ b/build/scripts/_check_compiler.cpp @@ -0,0 +1 @@ +#include <stdio.h> diff --git a/build/scripts/_fake_src.cpp b/build/scripts/_fake_src.cpp new file mode 100644 index 00000000000..139597f9cb0 --- /dev/null +++ b/build/scripts/_fake_src.cpp @@ -0,0 +1,2 @@ + + diff --git a/build/scripts/append_file.py b/build/scripts/append_file.py new file mode 100644 index 00000000000..1413cec3523 --- /dev/null +++ b/build/scripts/append_file.py @@ -0,0 +1,9 @@ +import sys + + +if __name__ == "__main__": + + file_path = sys.argv[1] + with open(file_path, "a") as f: + for text in sys.argv[2:]: + f.write('{}\n'.format(text)) diff --git a/build/scripts/autotar_gendirs.py b/build/scripts/autotar_gendirs.py new file mode 100644 index 00000000000..a1228108aa1 --- /dev/null +++ b/build/scripts/autotar_gendirs.py @@ -0,0 +1,70 @@ +from __future__ import print_function + +import os +import sys +import argparse +import tarfile +import subprocess + + +def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + +def pack_dir(dir_path, dest_path): + dir_path = os.path.abspath(dir_path) + for tar_exe in ('/usr/bin/tar', '/bin/tar'): + if is_exe(tar_exe): + subprocess.check_call([tar_exe, '-cf', dest_path, '-C', os.path.dirname(dir_path), os.path.basename(dir_path)]) + break + else: + with tarfile.open(dest_path, 'w') as out: + out.add(dir_path, arcname=os.path.basename(dir_path)) + + +def unpack_dir(tared_dir, dest_path): + tared_dir = os.path.abspath(tared_dir) + if not os.path.exists(dest_path): + os.makedirs(dest_path) + for tar_exe in ('/usr/bin/tar', '/bin/tar'): + if is_exe(tar_exe): + subprocess.check_call([tar_exe, '-xf', tared_dir, '-C', dest_path]) + break + else: + with tarfile.open(tared_dir, 'r') as tar_file: + tar_file.extractall(dest_path) + + +# Must only be used to pack directories in build root +# Must silently accept empty list of dirs and do nothing in such case (workaround for ymake.core.conf limitations) +def main(args): + parser = argparse.ArgumentParser() + parser.add_argument('--pack', action='store_true', default=False) + parser.add_argument('--unpack', action='store_true', default=False) + parser.add_argument('--ext') + parser.add_argument('--outs', nargs='*', default=[]) + parser.add_argument('dirs', nargs='*') + args = parser.parse_args(args) + + if args.pack: + if len(args.dirs) != len(args.outs): + print("Number and oder of dirs to pack must match to the number and order of outs", file=sys.stderr) + return 1 + for dir, dest in zip(args.dirs, args.outs): + pack_dir(dir, dest) + elif args.unpack: + for tared_dir in args.dirs: + if not tared_dir.endswith(args.ext): + print("Requested to unpack '{}' which do not have required extension '{}'".format(tared_dir, args.ext), file=sys.stderr) + return 1 + dest = os.path.dirname(tared_dir) + unpack_dir(tared_dir, dest) + else: + print("Neither --pack nor --unpack specified. Don't know what to do.", file=sys.stderr) + return 1 + + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/build/scripts/build_catboost.py b/build/scripts/build_catboost.py new file mode 100755 index 00000000000..78334fc5f76 --- /dev/null +++ b/build/scripts/build_catboost.py @@ -0,0 +1,71 @@ +import sys +import os +import shutil +import re +import subprocess + +def get_value(val): + dct = val.split('=', 1) + if len(dct) > 1: + return dct[1] + return '' + + +class BuildCbBase(object): + def run(self, cbmodel, cbname, cb_cpp_path): + + data_prefix = "CB_External_" + data = data_prefix + cbname + datasize = data + "Size" + + cbtype = "const NCatboostCalcer::TCatboostCalcer" + cbload = "(ReadModel({0}, {1}, EModelType::CatboostBinary))".format(data, datasize) + + cb_cpp_tmp_path = cb_cpp_path + ".tmp" + cb_cpp_tmp = open(cb_cpp_tmp_path, 'w') + + cb_cpp_tmp.write("#include <kernel/catboost/catboost_calcer.h>\n") + + ro_data_path = os.path.dirname(cb_cpp_path) + "/" + data_prefix + cbname + ".rodata" + cb_cpp_tmp.write("namespace{\n") + cb_cpp_tmp.write(" extern \"C\" {\n") + cb_cpp_tmp.write(" extern const unsigned char {1}{0}[];\n".format(cbname, data_prefix)) + cb_cpp_tmp.write(" extern const ui32 {1}{0}Size;\n".format(cbname, data_prefix)) + cb_cpp_tmp.write(" }\n") + cb_cpp_tmp.write("}\n") + archiverCall = subprocess.Popen([self.archiver, "-q", "-p", "-o", ro_data_path, cbmodel], stdout=None, stderr=subprocess.PIPE) + archiverCall.wait() + cb_cpp_tmp.write("extern {0} {1};\n".format(cbtype, cbname)) + cb_cpp_tmp.write("{0} {1}{2};".format(cbtype, cbname, cbload)) + cb_cpp_tmp.close() + shutil.move(cb_cpp_tmp_path, cb_cpp_path) + +class BuildCb(BuildCbBase): + def run(self, argv): + if len(argv) < 5: + print >>sys.stderr, "BuildCb.Run(<ARCADIA_ROOT> <archiver> <mninfo> <mnname> <cppOutput> [params...])" + sys.exit(1) + + self.SrcRoot = argv[0] + self.archiver = argv[1] + cbmodel = argv[2] + cbname = argv[3] + cb_cpp_path = argv[4] + + super(BuildCb, self).run(cbmodel, cbname, cb_cpp_path) + + +def build_cb_f(argv): + build_cb = BuildCb() + build_cb.run(argv) + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print >>sys.stderr, "Usage: build_cb.py <funcName> <args...>" + sys.exit(1) + + if (sys.argv[2:]): + globals()[sys.argv[1]](sys.argv[2:]) + else: + globals()[sys.argv[1]]() diff --git a/build/scripts/build_dll_and_java.py b/build/scripts/build_dll_and_java.py new file mode 100644 index 00000000000..b9d8aff4df7 --- /dev/null +++ b/build/scripts/build_dll_and_java.py @@ -0,0 +1,47 @@ +import os +import subprocess +import sys + + +def just_do_it(argv): + delim = argv[0] + args = [] + for item in argv: + if item == delim: + args.append([]) + else: + args[-1].append(item) + dll_cmd, java_cmd, inputs, dll_out, java_out, jsrs_out, roots = args + dll_out, java_out, jsrs_out, build_root, source_root = dll_out[0], java_out[0], jsrs_out[0], roots[0], roots[1] + for inp in inputs: + origin_inp = inp + if os.path.isabs(inp): + if os.path.relpath(inp, build_root).startswith('..'): + inp = os.path.relpath(inp, source_root) + else: + inp = os.path.relpath(inp, build_root) + ext = os.path.splitext(inp)[1] + if ext in ('.o', '.obj'): + if os.path.join(build_root, inp) in java_cmd: + inp = os.path.join(build_root, inp) + if sys.platform == 'win32': + inp = inp.replace('\\', '/') + if inp not in java_cmd: + inp = build_root + '/' + inp + java_cmd.remove(inp) + if ext in ('.java', '.jsrc'): + if origin_inp in dll_cmd: + inp = origin_inp + elif os.path.join(build_root, inp) in dll_cmd: + inp = os.path.join(build_root, inp) + if sys.platform == 'win32': + inp = inp.replace('\\', '/') + dll_cmd.remove(inp) + java_cmd.insert(java_cmd.index(dll_out), java_out) + java_cmd.remove(dll_out) + subprocess.check_call(java_cmd) + subprocess.check_call(dll_cmd) + + +if __name__ == '__main__': + just_do_it(sys.argv[1:]) diff --git a/build/scripts/build_java_codenav_index.py b/build/scripts/build_java_codenav_index.py new file mode 100644 index 00000000000..d7ac4f3213f --- /dev/null +++ b/build/scripts/build_java_codenav_index.py @@ -0,0 +1,49 @@ +import sys +import re +import os +import subprocess + +FAKE_ARCADIA_ROOT = 'fake_arcadia_root' +FAKE_BUILD_ROOT = 'fake_build_root' + + +def modify_sources_file(origin, target, source_roots_map): + def _cut_source_root(src): + for pref, fake_root in source_roots_map.items(): + if src.startswith(pref): + return os.path.join(fake_root, os.path.relpath(src, pref)) + return src + + with open(origin) as o: + srcs = [i for line in o for i in re.split('\\s+', line) if i] + new_srcs = map(_cut_source_root, srcs) + with open(target, 'w') as t: + t.write(' '.join(new_srcs)) + + +def just_do_it(argv): + corpus_name, build_root, arcadia_root, sources_file, javac_tail_cmd = argv[0], argv[1], argv[2], argv[3], argv[4:] + fake_arcadia_root = os.path.join(build_root, FAKE_ARCADIA_ROOT) + fake_build_root = os.path.join(build_root, FAKE_BUILD_ROOT) + fake_source_roots = { + arcadia_root: fake_arcadia_root, + build_root: fake_build_root, + } + modify_sources_file(sources_file, os.path.join(os.path.dirname(sources_file), '_' + os.path.basename(sources_file)), fake_source_roots) + kindex_data_root = '{}/kindex'.format(os.path.join(build_root, os.path.dirname(corpus_name))) + if not os.path.exists(kindex_data_root): + os.makedirs(kindex_data_root) + env = os.environ.copy() + env['KYTHE_ROOT_DIRECTORY'] = build_root + env['KYTHE_OUTPUT_DIRECTORY'] = kindex_data_root + env['KYTHE_CORPUS'] = os.path.relpath(corpus_name, build_root) + os.symlink(arcadia_root, fake_arcadia_root) + os.symlink(build_root, fake_build_root) + try: + subprocess.check_call(javac_tail_cmd, env=env) + finally: + os.unlink(fake_arcadia_root) + os.unlink(fake_build_root) + +if __name__ == '__main__': + just_do_it(sys.argv[1:]) diff --git a/build/scripts/build_java_with_error_prone.py b/build/scripts/build_java_with_error_prone.py new file mode 100644 index 00000000000..910443552e9 --- /dev/null +++ b/build/scripts/build_java_with_error_prone.py @@ -0,0 +1,36 @@ +import sys +import os + +ERROR_PRONE_FLAGS = [ + '-Xep:FunctionalInterfaceMethodChanged:WARN', + '-Xep:ReturnValueIgnored:WARN', +] + +JAVA10_EXPORTS = [ + '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' +] + + +def just_do_it(argv): + java, error_prone_tool, javac_cmd = argv[0], argv[1], argv[2:] + if java.endswith('javac') or java.endswith('javac.exe'): + for f in javac_cmd: + if f.startswith('-Xep'): + ERROR_PRONE_FLAGS.append(f) + for f in ERROR_PRONE_FLAGS: + if f in javac_cmd: + javac_cmd.remove(f) + os.execv(java, [java] + JAVA10_EXPORTS + ['-processorpath', error_prone_tool, '-XDcompilePolicy=byfile'] + [(' '.join(['-Xplugin:ErrorProne'] + ERROR_PRONE_FLAGS))] + javac_cmd) + else: + os.execv(java, [java, '-Xbootclasspath/p:' + error_prone_tool, 'com.google.errorprone.ErrorProneCompiler'] + ERROR_PRONE_FLAGS + javac_cmd) + + +if __name__ == '__main__': + just_do_it(sys.argv[1:]) diff --git a/build/scripts/build_java_with_error_prone2.py b/build/scripts/build_java_with_error_prone2.py new file mode 100644 index 00000000000..ddf1ccbfc1c --- /dev/null +++ b/build/scripts/build_java_with_error_prone2.py @@ -0,0 +1,87 @@ +import sys +import os +import re +import subprocess +import platform + + +ERROR_PRONE_FLAGS = [ + '-Xep:FunctionalInterfaceMethodChanged:WARN', + '-Xep:ReturnValueIgnored:WARN', +] + +JAVA10_EXPORTS = [ + '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED', +] + + +def get_java_version(exe): + p = subprocess.Popen([exe, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + for line in (out or '').strip().split("\n") + (err or '').strip().split("\n"): + m = re.match(r'java version "(.+)"', line) + if m: + parts = m.groups()[0].split(".") + return parts[1] if parts[0] == "1" else parts[0] + m = re.match(r'openjdk version "(\d+).*"', line) + if m: + parts = m.groups()[0].split(".") + return parts[0] + return None + + +def get_classpath(cmd): + for i, part in enumerate(cmd): + if part == '-classpath': + i += 1 + if i < len(cmd): + return cmd[i] + else: + return None + return None + + +def parse_args(argv): + parsed = [] + for i in range(len(argv)): + if not argv[i].startswith('-'): + parsed.append(argv[i]) + if len(parsed) >= 3: + break + return parsed + [argv[i + 1:]] + + +def just_do_it(argv): + java, javac, error_prone_tool, javac_cmd = parse_args(argv) + ver = get_java_version(java) + if not ver: + raise Exception("Can't determine java version") + if int(ver) >= 10: + for f in javac_cmd: + if f.startswith('-Xep'): + ERROR_PRONE_FLAGS.append(f) + for f in ERROR_PRONE_FLAGS: + if f in javac_cmd: + javac_cmd.remove(f) + if '-processor' in javac_cmd: + classpath = get_classpath(javac_cmd) + if classpath: + error_prone_tool = error_prone_tool + os.pathsep + classpath + cmd = [javac] + JAVA10_EXPORTS + ['-processorpath', error_prone_tool, '-XDcompilePolicy=byfile'] + [(' '.join(['-Xplugin:ErrorProne'] + ERROR_PRONE_FLAGS))] + javac_cmd + else: + cmd = [java, '-Xbootclasspath/p:' + error_prone_tool, 'com.google.errorprone.ErrorProneCompiler'] + ERROR_PRONE_FLAGS + javac_cmd + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(cmd).wait()) + else: + os.execv(cmd[0], cmd) + + +if __name__ == '__main__': + just_do_it(sys.argv[1:]) diff --git a/build/scripts/build_mn.py b/build/scripts/build_mn.py new file mode 100755 index 00000000000..5bb03c247c9 --- /dev/null +++ b/build/scripts/build_mn.py @@ -0,0 +1,330 @@ +#!/usr/bin/env python +# Ymake MatrixNet support + +import sys +import os +import shutil +import re +import subprocess + + +def get_value(val): + dct = val.split('=', 1) + if len(dct) > 1: + return dct[1] + return '' + + +class BuildMnBase(object): + def Run(self, mninfo, mnname, mnrankingSuffix, mncppPath, check=False, ptr=False, multi=False): + self.mninfo = mninfo + self.mnname = mnname + self.mnrankingSuffix = mnrankingSuffix + self.mncppPath = mncppPath + self.check = check + self.ptr = ptr + self.multi = multi + dataprefix = "MN_External_" + mninfoName = os.path.basename(self.mninfo) + data = dataprefix + mnname + datasize = data + "Size" + + if self.multi: + if self.ptr: + mntype = "const NMatrixnet::TMnMultiCategPtr" + mnload = "(new NMatrixnet::TMnMultiCateg( {1}, {2}, \"{0}\"))".format(mninfoName, data, datasize) + else: + mntype = "const NMatrixnet::TMnMultiCateg" + mnload = "({1}, {2}, \"{0}\")".format(mninfoName, data, datasize) + else: + if self.ptr: + mntype = "const NMatrixnet::TMnSsePtr" + mnload = "(new NMatrixnet::TMnSseInfo({1}, {2}, \"{0}\"))".format(mninfoName, data, datasize) + else: + mntype = "const NMatrixnet::TMnSseInfo" + mnload = "({1}, {2}, \"{0}\")".format(mninfoName, data, datasize) + + if self.check: + self.CheckMn() + + mncpptmpPath = self.mncppPath + ".tmp" + mncpptmp = open(mncpptmpPath, 'w') + + if self.multi: + mncpptmp.write("#include <kernel/matrixnet/mn_multi_categ.h>\n") + else: + mncpptmp.write("#include <kernel/matrixnet/mn_sse.h>\n") + + rodatapath = os.path.dirname(self.mncppPath) + "/" + dataprefix + self.mnname + ".rodata" + mncpptmp.write("namespace{\n") + mncpptmp.write(" extern \"C\" {\n") + mncpptmp.write(" extern const unsigned char {1}{0}[];\n".format(self.mnname, dataprefix)) + mncpptmp.write(" extern const ui32 {1}{0}Size;\n".format(self.mnname, dataprefix)) + mncpptmp.write(" }\n") + mncpptmp.write("}\n") + archiverCall = subprocess.Popen([self.archiver, "-q", "-p", "-o", rodatapath, self.mninfo], stdout=None, stderr=subprocess.PIPE) + archiverCall.wait() + mncpptmp.write("extern {0} {1};\n".format(mntype, self.mnname)) + mncpptmp.write("{0} {1}{2};".format(mntype, self.mnname, mnload)) + mncpptmp.close() + shutil.move(mncpptmpPath, self.mncppPath) + + def CheckMn(self): + if not self.fml_unused_tool: + print >>sys.stderr, "fml_unused_tool undefined!" + failed_msg = "fml_unused_tool failed: {0} -A {1} -e -r {2}".format(self.fml_unused_tool, self.SrcRoot, self.mninfo) + assert not subprocess.call([self.fml_unused_tool, "-A", self.SrcRoot, "-e", "-r", self.mninfo]), failed_msg + + +class BuildMn(BuildMnBase): + def Run(self, argv): + if len(argv) < 6: + print >>sys.stderr, "BuildMn.Run(<ARCADIA_ROOT> <archiver> <mninfo> <mnname> <mnrankingSuffix> <cppOutput> [params...])" + sys.exit(1) + + self.SrcRoot = argv[0] + self.archiver = argv[1] + + mninfo = argv[2] + mnname = argv[3] + mnrankingSuffix = argv[4] + mncppPath = argv[5] + check = False + ptr = False + multi = False + self.fml_unused_tool = '' + for param in argv[6:]: + if param == "CHECK": + check = True + elif param == "PTR": + ptr = True + elif param == "MULTI": + multi = True + elif param.startswith('fml_tool='): + self.fml_unused_tool = get_value(param) + else: + print >>sys.stdout, "Unknown param: {0}".format(param) + super(BuildMn, self).Run(mninfo, mnname, mnrankingSuffix, mncppPath, check=check, ptr=ptr, multi=multi) + + +class BuildMns(BuildMnBase): + def InitBase(self, listname, mnrankingSuffix): + self.autogen = '// DO NOT EDIT THIS FILE DIRECTLY, AUTOGENERATED!\n' + self.mnrankingSuffix = mnrankingSuffix + self.mnlistname = listname + mnrankingSuffix + self.mnlistelem = "const NMatrixnet::TMnSsePtr*" + mnlisttype = "TMap< TString, {0} >".format(self.mnlistelem) + self.mnlist = "const {0} {1}".format(mnlisttype, self.mnlistname) + + self.mnmultilistname = "{0}{1}Multi".format(listname, self.mnrankingSuffix) + self.mnmultilistelem = "const NMatrixnet::TMnMultiCategPtr*" + mnmultilisttype = "TMap< TString, {0} >".format(self.mnmultilistelem) + self.mnmultilist = "const {0} {1}".format(mnmultilisttype, self.mnmultilistname) + + def InitForAll(self, argv): + if len(argv) < 8: + print >>sys.stderr, "BuildMns.InitForAll(<ARCADIA_ROOT> <BINDIR> <archiver> <listname> <mnranking_suffix> <hdrfile> <srcfile> <mninfos> [fml_tool=<fml_unused_tool> CHECK])" + sys.exit(1) + + bmns_args = [] + self.check = False + self.fml_unused_tool = '' + for arg in argv: + if arg == "CHECK": + self.check = True + elif arg.startswith('fml_tool='): + self.fml_unused_tool = get_value(arg) + else: + bmns_args.append(arg) + + self.SrcRoot = bmns_args[0] + self.BINDIR = bmns_args[1] + self.archiver = bmns_args[2] + self.listname = bmns_args[3] + self.mnrankingSuffix = get_value(bmns_args[4]) + self.hdrfile = bmns_args[5] + self.srcfile = bmns_args[6] + self.mninfos = bmns_args[7:] + + self.InitBase(self.listname, self.mnrankingSuffix) + + def InitForHeader(self, argv): + if len(argv) < 4: + print >>sys.stderr, "BuildMns.InitForHeader(<listname> <rankingSuffix> <hdrfile> <mninfos...>)" + sys.exit(1) + + self.listname = argv[0] + self.mnrankingSuffix = get_value(argv[1]) + self.hdrfile = argv[2] + self.mninfos = argv[3:] + + self.InitBase(self.listname, self.mnrankingSuffix) + + def InitForCpp(self, argv): + if len(argv) < 5: + print >>sys.stderr, "BuildMns.InitForCpp(<listname> <rankingSuffix> <hdrfile> <srcfile> <mninfos...>)" + sys.exit(1) + + self.listname = argv[0] + self.mnrankingSuffix = get_value(argv[1]) + self.hdrfile = argv[2] + self.srcfile = argv[3] + self.mninfos = argv[4:] + + self.InitBase(self.listname, self.mnrankingSuffix) + + def InitForFiles(self, argv): + if len(argv) < 7: + print >>sys.stderr, "BuildMns.InitForFiles(<ARCADIA_ROOT> <BINDIR> <archiver> <fml_unused_tool> <listname> <rankingSuffix> <mninfos...> [CHECK])" + sys.exit(1) + + bmns_args = [] + self.check = False + self.fml_unused_tool = '' + for arg in argv: + if arg == "CHECK": + self.check = True + elif arg.startswith('fml_tool='): + self.fml_unused_tool = get_value(arg) + else: + bmns_args.append(arg) + + self.SrcRoot = bmns_args[0] + self.BINDIR = bmns_args[1] + self.archiver = bmns_args[2] + self.listname = bmns_args[3] + self.mnrankingSuffix = get_value(bmns_args[4]) + self.mninfos = bmns_args[5:] + + def BuildMnsHeader(self): + if self.mninfos: + self.mninfos = sorted(set(self.mninfos)) + + tmpHdrPath = self.hdrfile + ".tmp" + tmpHdrFile = open(tmpHdrPath, 'w') + + tmpHdrFile.write(self.autogen) + tmpHdrFile.write("#include <kernel/matrixnet/mn_sse.h>\n") + tmpHdrFile.write("#include <kernel/matrixnet/mn_multi_categ.h>\n\n") + tmpHdrFile.write("extern {0};\n".format(self.mnlist)) + tmpHdrFile.write("extern {0};\n".format(self.mnmultilist)) + + for item in self.mninfos: + mnfilename = os.path.basename(item) + mnfilename, ext = os.path.splitext(mnfilename) + + mnname = re.sub("[^-a-zA-Z0-9_]", "_", mnfilename) + + if ext == ".info": + mnname = "staticMn{0}{1}Ptr".format(self.mnrankingSuffix, mnname) + tmpHdrFile.write("extern const NMatrixnet::TMnSsePtr {0};\n".format(mnname)) + elif ext == ".mnmc": + mnname = "staticMnMulti{0}{1}Ptr".format(self.mnrankingSuffix, mnname) + tmpHdrFile.write("extern const NMatrixnet::TMnMultiCategPtr {0};\n".format(mnname)) + + tmpHdrFile.close() + shutil.move(tmpHdrPath, self.hdrfile) + + def BuildMnFiles(self): + for item in self.mninfos: + mnfilename = os.path.basename(item) + mnfilename, ext = os.path.splitext(mnfilename) + + mnname = re.sub("[^-a-zA-Z0-9_]", "_", mnfilename) + + if ext == ".info": + mnname = "staticMn{0}{1}Ptr".format(self.mnrankingSuffix, mnname) + super(BuildMns, self).Run(item, mnname, self.mnrankingSuffix, self.BINDIR + "/mn.{0}.cpp".format(mnname), check=self.check, ptr=True, multi=False) + elif ext == ".mnmc": + mnname = "staticMnMulti{0}{1}Ptr".format(self.mnrankingSuffix, mnname) + # BUILD_MN_PTR_MULTI + super(BuildMns, self).Run(item, mnname, self.mnrankingSuffix, self.BINDIR + "/mnmulti.{0}.cpp".format(mnname), check=False, ptr=True, multi=True) + + def BuildMnsCpp(self): + if self.mninfos: + self.mninfos = sorted(set(self.mninfos)) + + tmpSrcPath = self.srcfile + ".tmp" + tmpSrcFile = open(tmpSrcPath, 'w') + hdrrel = os.path.basename(self.hdrfile) + + mnnames = [] + mnmultinames = [] + for item in self.mninfos: + mnfilename = os.path.basename(item) + mnfilename, ext = os.path.splitext(mnfilename) + + if ext == ".info": + mnnames.append(mnfilename) + elif ext == ".mnmc": + mnmultinames.append(mnfilename) + + tmpSrcFile.write(self.autogen) + tmpSrcFile.write("#include \"{0}\"\n\n".format(hdrrel)) + + if mnnames: + mndata = self.mnlistname + "_data" + tmpSrcFile.write("static const std::pair< TString, {0} > {1}[] = {{\n".format(self.mnlistelem, mndata)) + for item in mnnames: + mnname = re.sub("[^-a-zA-Z0-9_]", "_", item) + tmpSrcFile.write(" std::make_pair(TString(\"{0}\"), &staticMn{1}{2}Ptr),\n".format(item, self.mnrankingSuffix, mnname)) + tmpSrcFile.write("};\n") + tmpSrcFile.write("{0}({1},{1} + sizeof({1}) / sizeof({1}[0]));\n\n".format(self.mnlist, mndata)) + else: + tmpSrcFile.write("{0};\n\n".format(self.mnlist)) + + if mnmultinames: + mnmultidata = self.mnmultilistname + "_data" + tmpSrcFile.write("static const std::pair< TString, {0} > {1}[] = {{\n".format(self.mnmultilistelem, mnmultidata)) + for item in mnmultinames: + mnname = re.sub("[^-a-zA-Z0-9_]", "_", item) + tmpSrcFile.write(" std::make_pair(TString(\"{0}\"), &staticMnMulti{1}{2}Ptr),\n".format(item, self.mnrankingSuffix, mnname)) + tmpSrcFile.write("};\n") + tmpSrcFile.write("{0}({1},{1} + sizeof({1}) / sizeof({1}[0]));\n".format(self.mnmultilist, mnmultidata)) + else: + tmpSrcFile.write("{0};\n".format(self.mnmultilist)) + + tmpSrcFile.close() + shutil.move(tmpSrcPath, self.srcfile) + + +def BuildMnsAllF(argv): + bldMns = BuildMns() + bldMns.InitForAll(argv) + bldMns.BuildMnsCpp() + bldMns.BuildMnsHeader() + bldMns.BuildMnFiles() + + +def BuildMnsCppF(argv): + bldMns = BuildMns() + bldMns.InitForCpp(argv) + bldMns.BuildMnsCpp() + + +def BuildMnsHeaderF(argv): + bldMns = BuildMns() + bldMns.InitForHeader(argv) + bldMns.BuildMnsHeader() + + +def BuildMnsFilesF(argv): + bldMns = BuildMns() + bldMns.InitForFiles(argv) + bldMns.BuildMnFiles() + + +def BuildMnF(argv): + bldMn = BuildMn() + bldMn.Run(argv) + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print >>sys.stderr, "Usage: build_mn.py <funcName> <args...>" + sys.exit(1) + + if (sys.argv[2:]): + globals()[sys.argv[1]](sys.argv[2:]) + else: + globals()[sys.argv[1]]() diff --git a/build/scripts/build_pln_header.py b/build/scripts/build_pln_header.py new file mode 100755 index 00000000000..c73693f444a --- /dev/null +++ b/build/scripts/build_pln_header.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import sys +import os + + +def BuildPlnHeader(): + if len(sys.argv) < 2: + print >>sys.stderr, "Usage: build_pln_header.py <absolute/path/to/OutFile>" + sys.exit(1) + + print >>sys.stdout, "Build Pln Header..." + outPath = sys.argv[1] + tmpPath = outPath + '.tmp' + tmpFile = open(tmpPath, 'w') + + tmpFile.write('#include <library/cpp/sse/sse.h>\n') + tmpFile.write('#include <kernel/relevfml/relev_fml.h>\n') + for path in sys.argv[2:]: + name = os.path.basename(path).split(".")[0] # name without extensions + tmpFile.write('\nextern SRelevanceFormula fml{0};\n'.format(name)) + tmpFile.write('float {0}(const float* f);\n'.format(name)) + tmpFile.write('void {0}SSE(const float* const* factors, float* result);\n'.format(name)) + tmpFile.close() + try: + os.remove(outPath) + except: + pass + try: + os.rename(tmpPath, outPath) + except: + print >>sys.stdout, 'Error: Failed to rename ' + tmpPath + ' to ' + outPath + +if __name__ == '__main__': + BuildPlnHeader() diff --git a/build/scripts/c_templates/README.md b/build/scripts/c_templates/README.md new file mode 100644 index 00000000000..96265c7fece --- /dev/null +++ b/build/scripts/c_templates/README.md @@ -0,0 +1,3 @@ +### Usage + +Не используйте эту библиотеку напрямую. Следует пользоваться `library/cpp/svnversion/svnversion.h`. diff --git a/build/scripts/c_templates/ya.make b/build/scripts/c_templates/ya.make new file mode 100644 index 00000000000..b395e11021a --- /dev/null +++ b/build/scripts/c_templates/ya.make @@ -0,0 +1,7 @@ +OWNER(g:ymake) + +LIBRARY(dummy-vcs) +NO_PLATFORM() + +SRCS(svn_interface.c) +END() diff --git a/build/scripts/cat.py b/build/scripts/cat.py new file mode 100755 index 00000000000..0c3f73d96f6 --- /dev/null +++ b/build/scripts/cat.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import sys +from shutil import copyfileobj as copy +import os.path + +if __name__ == '__main__': + for filename in sys.argv[1:] or ["-"]: + if filename == "-": + copy(sys.stdin, sys.stdout) + else: + if os.path.exists(filename): + with open(filename, 'rb') as file: + copy(file, sys.stdout) + else: + sys.stderr.write('cat.py: {0}: No such file or directory\n'.format(filename)) diff --git a/build/scripts/cgo1_wrapper.py b/build/scripts/cgo1_wrapper.py new file mode 100644 index 00000000000..986082f7e94 --- /dev/null +++ b/build/scripts/cgo1_wrapper.py @@ -0,0 +1,45 @@ +import argparse +import shutil +import subprocess +import sys + + +CGO1_SUFFIX='.cgo1.go' + + +def call(cmd, cwd, env=None): + # sys.stderr.write('{}\n'.format(' '.join(cmd))) + return subprocess.call(cmd, stdin=None, stderr=sys.stderr, stdout=sys.stdout, cwd=cwd, env=env) + + +def process_file(source_root, source_prefix, build_root, build_prefix, src_path, comment_prefix): + dst_path = '{}.tmp'.format(src_path) + with open(src_path, 'r') as src_file, open(dst_path, 'w') as dst_file: + for line in src_file: + if line.startswith(comment_prefix): + dst_file.write(line.replace(source_root, source_prefix).replace(build_root, build_prefix)) + else: + dst_file.write(line) + shutil.move(dst_path, src_path) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--build-prefix', default='__ARCADIA_BUILD_ROOT_PREFIX__') + parser.add_argument('--build-root', required=True) + parser.add_argument('--cgo1-files', nargs='+', required=True) + parser.add_argument('--cgo2-files', nargs='+', required=True) + parser.add_argument('--source-prefix', default='__ARCADIA_SOURCE_ROOT_PREFIX__') + parser.add_argument('--source-root', required=True) + parser.add_argument('cgo1_cmd', nargs='*') + args = parser.parse_args() + + exit_code = call(args.cgo1_cmd, args.source_root) + if exit_code != 0: + sys.exit(exit_code) + + for src_path in args.cgo1_files: + process_file(args.source_root, args.source_prefix, args.build_root, args.build_prefix, src_path, '//') + + for src_path in args.cgo2_files: + process_file(args.source_root, args.source_prefix, args.build_root, args.build_prefix, src_path, '#line') diff --git a/build/scripts/check_config_h.py b/build/scripts/check_config_h.py new file mode 100644 index 00000000000..07bc12e2308 --- /dev/null +++ b/build/scripts/check_config_h.py @@ -0,0 +1,89 @@ +import sys + +data = """ +#if defined(SIZEOF_LONG) +static_assert(sizeof(long) == SIZEOF_LONG, "fixme 1"); +#endif + +#if defined(SIZEOF_PTHREAD_T) +#include <pthread.h> + +static_assert(sizeof(pthread_t) == SIZEOF_PTHREAD_T, "fixme 2"); +#endif + +#if defined(SIZEOF_SIZE_T) +#include <stddef.h> + +static_assert(sizeof(size_t) == SIZEOF_SIZE_T, "fixme 3"); +#endif + +#if defined(SIZEOF_TIME_T) +#include <time.h> + +static_assert(sizeof(time_t) == SIZEOF_TIME_T, "fixme 4"); +#endif + +#if defined(SIZEOF_UINTPTR_T) +#include <stdint.h> + +static_assert(sizeof(uintptr_t) == SIZEOF_UINTPTR_T, "fixme 5"); +#endif + +#if defined(SIZEOF_VOID_P) +static_assert(sizeof(void*) == SIZEOF_VOID_P, "fixme 6"); +#endif + +#if defined(SIZEOF_FPOS_T) +#include <stdio.h> + +static_assert(sizeof(fpos_t) == SIZEOF_FPOS_T, "fixme 7"); +#endif + +#if defined(SIZEOF_DOUBLE) +static_assert(sizeof(double) == SIZEOF_DOUBLE, "fixme 8"); +#endif + +#if defined(SIZEOF_LONG_DOUBLE) +static_assert(sizeof(long double) == SIZEOF_LONG_DOUBLE, "fixme 9"); +#endif + +#if defined(SIZEOF_FLOAT) +static_assert(sizeof(float) == SIZEOF_FLOAT, "fixme 10"); +#endif + +#if defined(SIZEOF_INT) +static_assert(sizeof(int) == SIZEOF_INT, "fixme 11"); +#endif + +#if defined(SIZEOF_LONG_LONG) +static_assert(sizeof(long long) == SIZEOF_LONG_LONG, "fixme 12"); +#endif + +#if defined(SIZEOF_OFF_T) +#include <stdio.h> + +static_assert(sizeof(off_t) == SIZEOF_OFF_T, "fixme 13"); +#endif + +#if defined(SIZEOF_PID_T) +#include <unistd.h> + +static_assert(sizeof(pid_t) == SIZEOF_PID_T, "fixme 14"); +#endif + +#if defined(SIZEOF_SHORT) +static_assert(sizeof(short) == SIZEOF_SHORT, "fixme 15"); +#endif + +#if defined(SIZEOF_WCHAR_T) +static_assert(sizeof(wchar_t) == SIZEOF_WCHAR_T, "fixme 16"); +#endif + +#if defined(SIZEOF__BOOL) +//TODO +#endif +""" +if __name__ == '__main__': + with open(sys.argv[2], 'w') as f: + f.write('#include <' + sys.argv[1] + '>\n\n') + f.write(data) diff --git a/build/scripts/clang_tidy.py b/build/scripts/clang_tidy.py new file mode 100644 index 00000000000..c0c23b490ad --- /dev/null +++ b/build/scripts/clang_tidy.py @@ -0,0 +1,185 @@ +import argparse +import json +import os +import re +import shutil +import sys + +import subprocess + +import yaml + + +def setup_script(args): + global tidy_config_validation + sys.path.append(os.path.dirname(args.config_validation_script)) + import tidy_config_validation + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--testing-src", required=True) + parser.add_argument("--clang-tidy-bin", required=True) + parser.add_argument("--config-validation-script", required=True) + parser.add_argument("--ymake-python", required=True) + parser.add_argument("--tidy-json", required=True) + parser.add_argument("--source-root", required=True) + parser.add_argument("--build-root", required=True) + parser.add_argument("--default-config-file", required=True) + parser.add_argument("--project-config-file", required=True) + parser.add_argument("--export-fixes", required=True) + parser.add_argument("--checks", required=False, default="") + parser.add_argument("--header-filter", required=False, default=None) + return parser.parse_known_args() + + +def generate_compilation_database(clang_cmd, source_root, filename, path): + compile_database = [ + { + "file": filename, + "command": subprocess.list2cmdline(clang_cmd), + "directory": source_root, + } + ] + compilation_database_json = os.path.join(path, "compile_commands.json") + with open(compilation_database_json, "w") as afile: + json.dump(compile_database, afile) + return compilation_database_json + + +def load_profile(path): + if os.path.exists(path): + files = os.listdir(path) + if len(files) == 1: + with open(os.path.join(path, files[0])) as afile: + return json.load(afile)["profile"] + elif len(files) > 1: + return { + "error": "found several profile files: {}".format(files), + } + return { + "error": "profile file is missing", + } + + +def load_fixes(path): + if os.path.exists(path): + with open(path, 'r') as afile: + return afile.read() + else: + return "" + + +def is_generated(testing_src, build_root): + return testing_src.startswith(build_root) + + +def generate_outputs(output_json): + output_obj = os.path.splitext(output_json)[0] + ".o" + open(output_obj, "w").close() + open(output_json, "w").close() + + +def filter_configs(result_config, filtered_config): + with open(result_config, 'r') as afile: + input_config = yaml.safe_load(afile) + result_config = tidy_config_validation.filter_config(input_config) + with open(filtered_config, 'w') as afile: + yaml.safe_dump(result_config, afile) + + +def filter_cmd(cmd): + skip = True + + for x in cmd: + if not skip: + yield x + + if '/wrapcc.py' in x: + skip = False + + +def main(): + args, clang_cmd = parse_args() + if '/wrapcc.py' in str(clang_cmd): + clang_cmd = list(filter_cmd(clang_cmd)) + setup_script(args) + clang_tidy_bin = args.clang_tidy_bin + output_json = args.tidy_json + generate_outputs(output_json) + if is_generated(args.testing_src, args.build_root): + return + if args.header_filter is None: + # .pb.h files will be excluded because they are not in source_root + header_filter = r"^" + re.escape(os.path.dirname(args.testing_src)) + r".*" + else: + header_filter = r"^(" + args.header_filter + r").*" + + def ensure_clean_dir(path): + path = os.path.join(args.build_root, path) + if os.path.exists(path): + shutil.rmtree(path) + os.makedirs(path) + return path + + profile_tmpdir = ensure_clean_dir("profile_tmpdir") + db_tmpdir = ensure_clean_dir("db_tmpdir") + fixes_file = "fixes.txt" + config_dir = ensure_clean_dir("config_dir") + result_config_file = args.default_config_file + if args.project_config_file != args.default_config_file: + result_config = os.path.join(config_dir, "result_tidy_config.yaml") + filtered_config = os.path.join(config_dir, "filtered_tidy_config.yaml") + filter_configs(args.project_config_file, filtered_config) + result_config_file = tidy_config_validation.merge_tidy_configs( + base_config_path=args.default_config_file, + additional_config_path=filtered_config, + result_config_path=result_config, + ) + compile_command_path = generate_compilation_database(clang_cmd, args.source_root, args.testing_src, db_tmpdir) + + cmd = [ + clang_tidy_bin, + args.testing_src, + "-p", + compile_command_path, + "--warnings-as-errors", + "*", + "--config-file", + result_config_file, + "--header-filter", + header_filter, + "--use-color", + "--enable-check-profile", + "--store-check-profile={}".format(profile_tmpdir), + ] + if args.export_fixes == "yes": + cmd += ["--export-fixes", fixes_file] + + if args.checks: + cmd += ["--checks", args.checks] + + print("cmd: {}".format(' '.join(cmd))) + res = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = res.communicate() + out = out.replace(args.source_root, "$(SOURCE_ROOT)") + profile = load_profile(profile_tmpdir) + testing_src = os.path.relpath(args.testing_src, args.source_root) + tidy_fixes = load_fixes(fixes_file) + + with open(output_json, "wb") as afile: + json.dump( + { + "file": testing_src, + "exit_code": res.returncode, + "profile": profile, + "stderr": err, + "stdout": out, + "fixes": tidy_fixes, + }, + afile, + ) + + +if __name__ == "__main__": + main() diff --git a/build/scripts/clang_tidy_arch.py b/build/scripts/clang_tidy_arch.py new file mode 100644 index 00000000000..7caf623a3d8 --- /dev/null +++ b/build/scripts/clang_tidy_arch.py @@ -0,0 +1,33 @@ +import os +import argparse +import json + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--output-file") + parser.add_argument("--build-root") + parser.add_argument("--source-root") + return parser.parse_known_args() + + +def main(): + args, unknown_args = parse_args() + inputs = unknown_args + result_json = {} + for inp in inputs: + if os.path.exists(inp) and inp.endswith("tidyjson"): + with open(inp, 'r') as afile: + file_content = afile.read().strip() + if not file_content: + continue + errors = json.loads(file_content) + testing_src = errors["file"] + result_json[testing_src] = errors + + with open(args.output_file, 'w') as afile: + json.dump(result_json, afile, indent=4) # TODO remove indent + + +if __name__ == "__main__": + main() diff --git a/build/scripts/clang_wrapper.py b/build/scripts/clang_wrapper.py new file mode 100644 index 00000000000..af3869f7890 --- /dev/null +++ b/build/scripts/clang_wrapper.py @@ -0,0 +1,53 @@ +import subprocess +import sys + + +def fix(s): + # disable dbg DEVTOOLS-2744 + if s == '-g': + return None + if s == '/Z7' or s == '/Od' or s == '/Ob0' or s == '/D_DEBUG': + return None + + # disable sanitizers for generated code + if s.startswith('-fsanitize') or s == '-Dmemory_sanitizer_enabled' or s.startswith('-fsanitize-blacklist'): + return None + + # strip gcc toolchain flags (appear when crosscompiling) + if s.startswith('-fabi-version'): + return None + + # remove arguments unknown to clang-cl + if s == '-fcase-insensitive-paths': # or s == '-fno-lto': # DEVTOOLSSUPPORT-3966 + return None + + # Paths under .ya/tools/v3/.../msvc/include are divided with '\' + return s.replace('\\', '/') + + +def fix_path(p): + try: + i = p.rfind('/bin/clang') + p = p[:i] + '/bin/clang-cl' + except ValueError: + pass + return p + + +if __name__ == '__main__': + is_on_win = sys.argv[1] == 'yes' + path = sys.argv[2] + args = filter(None, [fix(s) for s in sys.argv[3:]]) + if is_on_win: + path = fix_path(path) + try: + i = args.index('-emit-llvm') + args[i:i+1] = ['-Xclang', '-emit-llvm'] + except ValueError: + pass + args.append('-fms-compatibility-version=19') + + cmd = [path] + args + + rc = subprocess.call(cmd, shell=False, stderr=sys.stderr, stdout=sys.stdout) + sys.exit(rc) diff --git a/build/scripts/collect_java_srcs.py b/build/scripts/collect_java_srcs.py new file mode 100644 index 00000000000..170002520a5 --- /dev/null +++ b/build/scripts/collect_java_srcs.py @@ -0,0 +1,51 @@ +import os +import sys +import contextlib +import tarfile +import zipfile + + +if __name__ == '__main__': + build_root = sys.argv[1] + root = os.path.normpath(sys.argv[2]) + dest = os.path.normpath(sys.argv[3]) + srcs = sys.argv[4:] + + for src in srcs: + src = os.path.normpath(src) + if src.endswith('.java') or src.endswith('.kt'): + src_rel_path = os.path.relpath(src, root) + + if os.path.join(root, src_rel_path) == src: + # Inside root + dst = os.path.join(dest, src_rel_path) + + else: + # Outside root + print>>sys.stderr, 'External src file "{}" is outside of srcdir {}, ignore'.format( + os.path.relpath(src, build_root), + os.path.relpath(root, build_root), + ) + continue + + if os.path.exists(dst): + print>>sys.stderr, 'Duplicate external src file {}, choice is undefined'.format( + os.path.relpath(dst, root) + ) + + else: + destdir = os.path.dirname(dst) + if destdir and not os.path.exists(destdir): + os.makedirs(destdir) + os.rename(src, dst) + + elif src.endswith('.jsr'): + with contextlib.closing(tarfile.open(src, 'r')) as tf: + tf.extractall(dst) + + elif src.endswith('-sources.jar'): + with zipfile.ZipFile(src) as zf: + zf.extractall(dst) + + else: + print>>sys.stderr, 'Unrecognized file type', os.path.relpath(src, build_root) diff --git a/build/scripts/compile_cuda.py b/build/scripts/compile_cuda.py new file mode 100644 index 00000000000..f8e1fa2b6d6 --- /dev/null +++ b/build/scripts/compile_cuda.py @@ -0,0 +1,168 @@ +import sys +import subprocess +import os +import collections +import re +import tempfile + + +def is_clang(command): + for word in command: + if '--compiler-bindir' in word and 'clang' in word: + return True + + return False + + +def main(): + try: + sys.argv.remove('--y_skip_nocxxinc') + skip_nocxxinc = True + except ValueError: + skip_nocxxinc = False + + spl = sys.argv.index('--cflags') + cmd = 1 + mtime0 = None + if sys.argv[1] == '--mtime': + mtime0 = sys.argv[2] + cmd = 3 + command = sys.argv[cmd: spl] + cflags = sys.argv[spl + 1:] + + dump_args = False + if '--y_dump_args' in command: + command.remove('--y_dump_args') + dump_args = True + + executable = command[0] + if not os.path.exists(executable): + print >> sys.stderr, '{} not found'.format(executable) + sys.exit(1) + + if is_clang(command): + # nvcc concatenates the sources for clang, and clang reports unused + # things from .h files as if they they were defined in a .cpp file. + cflags += ['-Wno-unused-function', '-Wno-unused-parameter'] + + if not is_clang(command) and '-fopenmp=libomp' in cflags: + cflags.append('-fopenmp') + cflags.remove('-fopenmp=libomp') + + skip_list = [ + '-gline-tables-only', + # clang coverage + '-fprofile-instr-generate', + '-fcoverage-mapping', + '/Zc:inline', # disable unreferenced functions (kernel registrators) remove + '-Wno-c++17-extensions', + '-flto', + '-faligned-allocation', + '-fsized-deallocation', + # While it might be reasonable to compile host part of .cu sources with these optimizations enabled, + # nvcc passes these options down towards cicc which lacks x86_64 extensions support. + '-msse2', + '-msse3', + '-mssse3', + '-msse4.1', + '-msse4.2', + ] + + if skip_nocxxinc: + skip_list.append('-nostdinc++') + + for flag in skip_list: + if flag in cflags: + cflags.remove(flag) + + skip_prefix_list = [ + '-fsanitize=', + '-fsanitize-coverage=', + '-fsanitize-blacklist=', + '--system-header-prefix', + ] + new_cflags = [] + for flag in cflags: + if all(not flag.startswith(skip_prefix) for skip_prefix in skip_prefix_list): + if flag.startswith('-fopenmp-version='): + new_cflags.append('-fopenmp-version=45') # Clang 11 only supports OpenMP 4.5, but the default is 5.0, so we need to forcefully redefine it. + else: + new_cflags.append(flag) + cflags = new_cflags + + if not is_clang(command): + def good(arg): + if arg.startswith('--target='): + return False + return True + cflags = filter(good, cflags) + + cpp_args = [] + compiler_args = [] + + # NVCC requires particular MSVC versions which may differ from the version + # used to compile regular C++ code. We have a separate MSVC in Arcadia for + # the CUDA builds and pass it's root in $Y_VC_Root. + # The separate MSVC for CUDA may absent in Yandex Open Source builds. + vc_root = os.environ.get('Y_VC_Root') + + cflags_queue = collections.deque(cflags) + while cflags_queue: + + arg = cflags_queue.popleft() + if arg == '-mllvm': + compiler_args.append(arg) + compiler_args.append(cflags_queue.popleft()) + continue + if arg[:2].upper() in ('-I', '/I', '-B'): + value = arg[2:] + if not value: + value = cflags_queue.popleft() + if arg[1] == 'I': + cpp_args.append('-I{}'.format(value)) + elif arg[1] == 'B': # todo: delete "B" flag check when cuda stop to use gcc + pass + continue + + match = re.match(r'[-/]D(.*)', arg) + if match: + define = match.group(1) + # We have C++ flags configured for the regular C++ build. + # There is Y_MSVC_INCLUDE define with a path to the VC header files. + # We need to change the path accordingly when using a separate MSVC for CUDA. + if vc_root and define.startswith('Y_MSVC_INCLUDE'): + define = os.path.expandvars('Y_MSVC_INCLUDE={}/include'.format(vc_root)) + cpp_args.append('-D' + define.replace('\\', '/')) + continue + + compiler_args.append(arg) + + command += cpp_args + if compiler_args: + command += ['--compiler-options', ','.join(compiler_args)] + + # --keep is necessary to prevent nvcc from embedding nvcc pid in generated + # symbols. It makes nvcc use the original file name as the prefix in the + # generated files (otherwise it also prepends tmpxft_{pid}_00000000-5), and + # cicc derives the module name from its {input}.cpp1.ii file name. + command += ['--keep', '--keep-dir', tempfile.mkdtemp(prefix='compile_cuda.py.')] + # nvcc generates symbols like __fatbinwrap_{len}_{basename}_{hash} where + # {basename} is {input}.cpp1.ii with non-C chars translated to _, {len} is + # {basename} length, and {hash} is the hash of first exported symbol in + # {input}.cpp1.ii if there is one, otherwise it is based on its modification + # time (converted to string in the local timezone) and the current working + # directory. To stabilize the names of these symbols we need to fix mtime, + # timezone, and cwd. + if mtime0: + os.environ['LD_PRELOAD'] = mtime0 + os.environ['TZ'] = 'UTC0' # POSIX fixed offset format. + os.environ['TZDIR'] = '/var/empty' # Against counterfeit /usr/share/zoneinfo/$TZ. + + if dump_args: + sys.stdout.write('\n'.join(command)) + else: + sys.exit(subprocess.Popen(command, stdout=sys.stderr, stderr=sys.stderr, cwd='/').wait()) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/compile_java.py b/build/scripts/compile_java.py new file mode 100644 index 00000000000..7b6455ebf0d --- /dev/null +++ b/build/scripts/compile_java.py @@ -0,0 +1,122 @@ +import argparse +import contextlib +from distutils import dir_util +import os +import shutil +import subprocess as sp +import tarfile +import zipfile +import sys + + +def parse_args(args): + parser = argparse.ArgumentParser(description='Wrapper to invoke Java compilation from ya make build') + parser.add_argument('--javac-bin', help='path to javac') + parser.add_argument('--jar-bin', help='path to jar tool') + parser.add_argument('--java-bin', help='path to java binary') + parser.add_argument('--kotlin-compiler', help='path to kotlin compiler jar file') + parser.add_argument('--vcs-mf', help='path to VCS info manifest snippet') + parser.add_argument('--package-prefix', help='package prefix for resource files') + parser.add_argument('--jar-output', help='jar file with compiled classes destination path') + parser.add_argument('--srcs-jar-output', help='jar file with sources destination path') + parser.add_argument('srcs', nargs="*") + args = parser.parse_args(args) + return args, args.srcs + + +def mkdir_p(directory): + if not os.path.exists(directory): + os.makedirs(directory) + + +def split_cmd_by_delim(cmd, delim='DELIM'): + result = [[]] + for arg in cmd: + if arg == delim: + result.append([]) + else: + result[-1].append(arg) + return result + + +def main(): + cmd_parts = split_cmd_by_delim(sys.argv[1:]) + assert len(cmd_parts) == 4 + args, javac_opts, peers, ktc_opts = cmd_parts + opts, jsrcs = parse_args(args) + + jsrcs += list(filter(lambda x: x.endswith('.jsrc'), peers)) + peers = list(filter(lambda x: not x.endswith('.jsrc'), peers)) + + sources_dir = 'src' + mkdir_p(sources_dir) + for s in jsrcs: + if s.endswith('.jsrc'): + with contextlib.closing(tarfile.open(s, 'r')) as tf: + tf.extractall(sources_dir) + + srcs = [] + for r, _, files in os.walk(sources_dir): + for f in files: + srcs.append(os.path.join(r, f)) + srcs += jsrcs + ktsrcs = list(filter(lambda x: x.endswith('.kt'), srcs)) + srcs = list(filter(lambda x: x.endswith('.java'), srcs)) + + classes_dir = 'cls' + mkdir_p(classes_dir) + classpath = os.pathsep.join(peers) + + if srcs: + temp_sources_file = 'temp.sources.list' + with open(temp_sources_file, 'w') as ts: + ts.write(' '.join(srcs)) + + if ktsrcs: + temp_kt_sources_file = 'temp.kt.sources.list' + with open(temp_kt_sources_file, 'w') as ts: + ts.write(' '.join(ktsrcs + srcs)) + kt_classes_dir = 'kt_cls' + mkdir_p(kt_classes_dir) + sp.check_call([opts.java_bin, '-jar', opts.kotlin_compiler, '-classpath', classpath, '-d', kt_classes_dir] + ktc_opts + ['@' + temp_kt_sources_file]) + classpath = os.pathsep.join([kt_classes_dir, classpath]) + + if srcs: + sp.check_call([opts.javac_bin, '-nowarn', '-g', '-classpath', classpath, '-encoding', 'UTF-8', '-d', classes_dir] + javac_opts + ['@' + temp_sources_file]) + + for s in jsrcs: + if s.endswith('-sources.jar'): + with zipfile.ZipFile(s) as zf: + zf.extractall(sources_dir) + + elif s.endswith('.jar'): + with zipfile.ZipFile(s) as zf: + zf.extractall(classes_dir) + + if ktsrcs: + dir_util.copy_tree(kt_classes_dir, classes_dir) + + if opts.vcs_mf: + sp.check_call([opts.jar_bin, 'cfm', opts.jar_output, opts.vcs_mf, os.curdir], cwd=classes_dir) + else: + sp.check_call([opts.jar_bin, 'cfM', opts.jar_output, os.curdir], cwd=classes_dir) + + if opts.srcs_jar_output: + for s in jsrcs: + if s.endswith('.java'): + if opts.package_prefix: + d = os.path.join(sources_dir, *(opts.package_prefix.split('.') + [os.path.basename(s)])) + + else: + d = os.path.join(sources_dir, os.path.basename(s)) + + shutil.copyfile(s, d) + + if opts.vcs_mf: + sp.check_call([opts.jar_bin, 'cfm', opts.srcs_jar_output, opts.vcs_mf, os.curdir], cwd=sources_dir) + else: + sp.check_call([opts.jar_bin, 'cfM', opts.srcs_jar_output, os.curdir], cwd=sources_dir) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/compile_jsrc.py b/build/scripts/compile_jsrc.py new file mode 100644 index 00000000000..8760e5eee90 --- /dev/null +++ b/build/scripts/compile_jsrc.py @@ -0,0 +1,24 @@ +import argparse +import os +import tarfile + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--input', nargs='*', required=True) + parser.add_argument('--output', required=True) + parser.add_argument('--prefix', required=True) + + return parser.parse_args() + + +def main(): + args = parse_args() + + with tarfile.open(args.output, 'w') as out: + for f in args.input: + out.add(f, arcname=os.path.relpath(f, args.prefix)) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/compile_pysrc.py b/build/scripts/compile_pysrc.py new file mode 100644 index 00000000000..e3637e18e2e --- /dev/null +++ b/build/scripts/compile_pysrc.py @@ -0,0 +1,101 @@ +import argparse +import os +import shutil +import subprocess +import tarfile + + +LIMIT = 6000 + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--input', required=True) + parser.add_argument('--output', required=True) + parser.add_argument('--rescompiler', required=True) + subparsers = parser.add_subparsers(dest='mode') + + parser_py2 = subparsers.add_parser('py2') + parser_py2.add_argument('--py_compile', required=True) + parser_py2.add_argument('--python', required=True) + + parser_py3 = subparsers.add_parser('py3') + parser_py3.add_argument('--pycc', required=True) + + return parser.parse_args() + + +def call(cmd, cwd=None, env=None): + return subprocess.check_output(cmd, stdin=None, stderr=subprocess.STDOUT, cwd=cwd, env=env) + + +def iterate_py2_resource_params(py_files): + for py in py_files: + mod = py[:-3].replace('/', '.') + key = '/py_modules/{}'.format(mod) + yield py, key + yield '-', 'resfs/src/{}={}'.format(key, py) + yield '{}.yapyc'.format(py), '/py_code/{}'.format(mod) + + +def iterate_py3_resource_params(py_files): + for py in py_files: + for ext in ('', '.yapyc3'): + path = '{}{}'.format(py, ext) + dest = 'py/{}'.format(path) + key = 'resfs/file/{}'.format(dest) + src = 'resfs/src/{}={}'.format(key, os.path.basename(path)) + yield '-', src + yield path, key + + +def main(): + args = parse_args() + + names = [] + with tarfile.open(args.input, 'r') as tar: + names = tar.getnames() + tar.extractall() + + if args.mode == 'py3': + pycc_cmd = [args.pycc] + pycc_ext = '.yapyc3' + iterate_resource_params = iterate_py3_resource_params + else: + pycc_cmd = [args.python, args.py_compile] + pycc_ext = '.yapyc' + iterate_resource_params = iterate_py2_resource_params + + py_files = sorted(names) + + for py in py_files: + cmd = pycc_cmd + ['{}-'.format(os.path.basename(py)), py, '{}{}'.format(py, pycc_ext)] + call(cmd) + + outputs = [] + cmd = [args.rescompiler, '{}.0'.format(args.output)] + size = 0 + for path, key in iterate_resource_params(py_files): + addendum = len(path) + len(key) + if size + addendum > LIMIT and len(cmd) > 2: + call(cmd) + outputs.append(cmd[1]) + cmd[1] = '{}.{}'.format(args.output, len(outputs)) + cmd = cmd[0:2] + size = 0 + cmd.extend([path, key]) + size += addendum + if len(outputs) == 0: + cmd[1] = args.output + call(cmd) + else: + call(cmd) + outputs.append(cmd[1]) + with open(args.output, 'w') as fout: + for fname in outputs: + with open(fname, 'r') as fin: + shutil.copyfileobj(fin, fout) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/configure_file.py b/build/scripts/configure_file.py new file mode 100755 index 00000000000..193ad7ec9e6 --- /dev/null +++ b/build/scripts/configure_file.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python2.7 + +import sys +import os.path +import re + +cmakeDef01 = "#cmakedefine01" +cmakeDef = "#cmakedefine" + + +def replaceLine(l, varDict, define): + words = l.split() + if words: + if words[0] == cmakeDef: + sPos = l.find(cmakeDef) + ePos = sPos + len(cmakeDef) + l = l[:sPos] + define + l[ePos:] + '\n' + if words[0] == cmakeDef01: + var = words[1] + cmakeValue = varDict.get(var) + if cmakeValue == 'yes': + val = '1' + else: + val = '0' + sPos = l.find(cmakeDef01) + ePos = l.find(var) + len(var) + l = l[:sPos] + define + ' ' + var + ' ' + val + l[ePos + 1:] + '\n' + + finder = re.compile(".*?(@[a-zA-Z0-9_]+@).*") + while True: + re_result = finder.match(l) + if not re_result: + return l + key = re_result.group(1)[1:-1] + l = l[:re_result.start(1)] + varDict.get(key, '') + l[re_result.end(1):] + + +def main(inputPath, outputPath, varDict): + define = '#define' if os.path.splitext(outputPath)[1] != '.asm' else '%define' + with open(outputPath, 'w') as output: + with open(inputPath, 'r') as input: + for l in input: + output.write(replaceLine(l, varDict, define)) + + +def usage(): + print("usage: configure_file.py inputPath outputPath key1=value1 ...") + exit(1) + + +if __name__ == "__main__": + if len(sys.argv) < 3: + usage() + varDict = {} + for x in sys.argv[3:]: + key, value = str(x).split('=', 1) + varDict[key] = value + + main(sys.argv[1], sys.argv[2], varDict) diff --git a/build/scripts/container.py b/build/scripts/container.py new file mode 100644 index 00000000000..27e6f921f38 --- /dev/null +++ b/build/scripts/container.py @@ -0,0 +1,30 @@ +import subprocess +import os +import shutil + + +class ContainerError(Exception): + pass + + +def join_layers(input_paths, output_path, squashfs_path): + + if len(input_paths) == 1: + shutil.copy2(input_paths[0], output_path) + + else: + # We cannot use appending here as it doesn't allow replacing files + for input_path in input_paths: + unpack_cmd = [ os.path.join(squashfs_path, 'unsquashfs') ] + unpack_cmd.extend([ '-f', input_path ]) + subprocess.run(unpack_cmd) + + pack_cmd = [ os.path.join(squashfs_path, 'mksquashfs') ] + pack_cmd.append(os.path.join(os.curdir, 'squashfs-root')) + pack_cmd.append(output_path) + pack_cmd.append('-all-root') + subprocess.run(pack_cmd) + + shutil.rmtree(os.path.join(os.curdir, 'squashfs-root')) + + return 0 diff --git a/build/scripts/copy_docs_files.py b/build/scripts/copy_docs_files.py new file mode 100644 index 00000000000..c444dd509d6 --- /dev/null +++ b/build/scripts/copy_docs_files.py @@ -0,0 +1,102 @@ +import argparse +import codecs +import errno +import os +import process_command_files as pcf +import shutil +import sys + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--build-root', required=True) + parser.add_argument('--dst-dir', required=True) + parser.add_argument('--existing', choices=('skip', 'overwrite'), default='overwrite') + parser.add_argument('--source-root', required=True) + parser.add_argument('--src-dir', required=None) + parser.add_argument('files', nargs='*') + return parser.parse_args(pcf.get_args(sys.argv[1:])) + + +def makedirs(dirname): + try: + os.makedirs(dirname) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(dirname): + pass + else: + raise + + +def copy_file(src, dst, overwrite=False, orig_path=None, generated=False): + if os.path.exists(dst) and not overwrite: + return + + makedirs(os.path.dirname(dst)) + + with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: + if (orig_path or generated) and src.endswith('.md'): + out = b'' + buf = fsrc.readline() + bom_length = len(codecs.BOM_UTF8) + if buf[:bom_length] == codecs.BOM_UTF8: + out += codecs.BOM_UTF8 + buf = buf[bom_length:] + info = 'generated: true\n' if generated else 'vcsPath: {}\n'.format(orig_path) + if buf.startswith(b'---') and b'\n' in buf[3:] and buf[3:].rstrip(b'\r\n') == b'': + content = b'' + found = False + while True: + line = fsrc.readline() + if len(line) == 0: + break + content += line + if line.startswith(b'---') and line[3:].rstrip(b'\r\n') == b'': + found = True + break + out += buf + if found: + out += info.encode('utf-8') + out += content + else: + out += '---\n{}---\n'.format(info).encode('utf-8') + out += buf + fdst.write(out) + shutil.copyfileobj(fsrc, fdst) + + +def main(): + args = parse_args() + + source_root = os.path.normpath(args.source_root) + os.path.sep + build_root = os.path.normpath(args.build_root) + os.path.sep + + dst_dir = os.path.normpath(args.dst_dir) + assert dst_dir.startswith(build_root) + makedirs(dst_dir) + + src_dir = os.path.normpath(args.src_dir) + os.path.sep + assert src_dir.startswith(source_root) + + if src_dir.startswith(source_root): + root = source_root + is_from_source_root = True + elif src_dir.startswith(build_root): + root = build_root + is_from_source_root = False + else: + assert False, 'src_dir [{}] should start with [{}] or [{}]'.format(src_dir, source_root, build_root) + + is_overwrite_existing = args.existing == 'overwrite' + + for f in [os.path.normpath(f) for f in args.files]: + src_file = os.path.join(src_dir, f) + dst_file = os.path.join(dst_dir, f) + if src_file == dst_file: + continue + rel_path = src_file[len(root):] if is_from_source_root else None + copy_file(src_file, dst_file, overwrite=is_overwrite_existing, orig_path=rel_path) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/copy_docs_files_to_dir.py b/build/scripts/copy_docs_files_to_dir.py new file mode 100644 index 00000000000..bfd3c65698d --- /dev/null +++ b/build/scripts/copy_docs_files_to_dir.py @@ -0,0 +1,164 @@ +import argparse +import codecs +import errno +import os +import process_command_files as pcf +import shutil +import sys + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--bin-dir', nargs='*') + parser.add_argument('--build-root', required=True) + parser.add_argument('--dest-dir', required=True) + parser.add_argument('--docs-dir', action='append', nargs=2, dest='docs_dirs', default=None) + parser.add_argument('--existing', choices=('skip', 'overwrite'), default='overwrite') + parser.add_argument('--source-root', required=True) + parser.add_argument('--src-dir', action='append', nargs='*', dest='src_dirs', default=None) + parser.add_argument('files', nargs='*') + return parser.parse_args(pcf.get_args(sys.argv[1:])) + + +def makedirs(dirname): + try: + os.makedirs(dirname) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(dirname): + pass + else: + raise + + +def copy_file(src, dst, overwrite=False, orig_path=None): + if os.path.exists(dst) and not overwrite: + return + + makedirs(os.path.dirname(dst)) + + with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: + if orig_path and src.endswith('.md'): + out = b'' + buf = fsrc.readline() + bom_length = len(codecs.BOM_UTF8) + if buf[:bom_length] == codecs.BOM_UTF8: + out += codecs.BOM_UTF8 + buf = buf[bom_length:] + info = 'vcsPath: {}\n'.format(orig_path) + if buf.startswith(b'---') and b'\n' in buf[3:] and buf[3:].rstrip(b'\r\n') == b'': + content = b'' + found = False + while True: + line = fsrc.readline() + if len(line) == 0: + break + content += line + if line.startswith(b'---') and line[3:].rstrip(b'\r\n') == b'': + found = True + break + out += buf + if found: + out += info.encode('utf-8') + out += content + else: + out += '---\n{}---\n'.format(info).encode('utf-8') + out += buf + fdst.write(out) + shutil.copyfileobj(fsrc, fdst) + + +def main(): + args = parse_args() + + dest_dir = os.path.normpath(args.dest_dir) + makedirs(dest_dir) + + source_root = os.path.normpath(args.source_root) + os.path.sep + build_root = os.path.normpath(args.build_root) + os.path.sep + + is_overwrite_existing = args.existing == 'overwrite' + + if args.docs_dirs: + for item in args.docs_dirs: + assert len(item) == 2 + docs_dir, nm = item[0], item[1] + assert not os.path.isabs(docs_dir) + if nm and nm != '.': + assert not os.path.isabs(nm) + dst = os.path.join(dest_dir, nm) + else: + dst = dest_dir + + abs_docs_dir = os.path.join(args.source_root, docs_dir) + + for root, _, files in os.walk(abs_docs_dir): + for f in files: + if os.path.islink(os.path.join(root, f)): + continue + file_src = os.path.join(root, f) + assert file_src.startswith(source_root) + file_dst = os.path.join(dst, os.path.relpath(root, abs_docs_dir), f) + copy_file(file_src, file_dst, overwrite=is_overwrite_existing, orig_path=file_src[len(source_root):]) + + if args.src_dirs: + for item in args.src_dirs: + assert len(item) > 1 + src_dir, nm = os.path.normpath(item[0]), item[1] + assert os.path.isabs(src_dir) + if nm and nm != '.': + assert not os.path.isabs(nm) + dst = os.path.join(dest_dir, nm) + else: + dst = dest_dir + + if src_dir.startswith(source_root): + root = source_root + is_from_source_root = True + else: + assert src_dir.startswith(build_root) + root = build_root + is_from_source_root = False + + for f in item[2:]: + file_src = os.path.normpath(f) + assert file_src.startswith(root) + rel_path = file_src[len(root):] if is_from_source_root else None + file_dst = os.path.join(dst, file_src[len(src_dir):]) + copy_file(file_src, file_dst, overwrite=is_overwrite_existing, orig_path=rel_path) + + if args.bin_dir: + assert len(args.bin_dir) > 1 + bin_dir, bin_dir_namespace = os.path.normpath(args.bin_dir[0]) + os.path.sep, args.bin_dir[1] + assert bin_dir.startswith(build_root) + if bin_dir_namespace and bin_dir_namespace != '.': + assert not os.path.isabs(bin_dir_namespace) + dst = os.path.join(dest_dir, bin_dir_namespace) + else: + dst = dest_dir + + for file_src in args.bin_dir[2:]: + assert os.path.isfile(file_src) + assert file_src.startswith(bin_dir) + file_dst = os.path.join(dst, file_src[len(bin_dir):]) + copy_file(file_src, file_dst, overwrite=is_overwrite_existing, orig_path=None) + + for src in args.files: + file_src = os.path.normpath(src) + assert os.path.isfile(file_src), 'File [{}] does not exist...'.format(file_src) + rel_path = file_src + orig_path = None + if file_src.startswith(source_root): + rel_path = file_src[len(source_root):] + orig_path = rel_path + elif file_src.startswith(build_root): + rel_path = file_src[len(build_root):] + else: + raise Exception('Unexpected file path [{}].'.format(file_src)) + assert not os.path.isabs(rel_path) + file_dst = os.path.join(args.dest_dir, rel_path) + if file_dst != file_src: + copy_file(file_src, file_dst, is_overwrite_existing, orig_path) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/copy_files_to_dir.py b/build/scripts/copy_files_to_dir.py new file mode 100644 index 00000000000..ead57ba16e2 --- /dev/null +++ b/build/scripts/copy_files_to_dir.py @@ -0,0 +1,59 @@ +import argparse +import errno +import os +import process_command_files as pcf +import shutil +import sys + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--dest-dir', required=True) + parser.add_argument('--existing', choices=('skip', 'overwrite'), default='overwrite') + parser.add_argument('--flat', action='store_true') + parser.add_argument('--skip-prefix', dest='skip_prefixes', action='append', default=[]) + parser.add_argument('files', nargs='*') + return parser.parse_args(pcf.get_args(sys.argv[1:])) + + +def makedirs(dirname): + try: + os.makedirs(dirname) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(dirname): + pass + else: + raise + + +def main(): + args = parse_args() + + dest_dir = os.path.normpath(args.dest_dir) + os.pathsep + makedirs(dest_dir) + + prefixes = ['{}{}'.format(os.path.normpath(p), os.path.sep) for p in args.skip_prefixes] + + for src in args.files: + src = os.path.normpath(src) + assert os.path.isfile(src) + if args.flat: + rel_dst = os.path.basename(src) + else: + rel_dst = src + for prefix in prefixes: + if src.startswith(prefix): + rel_dst = src[len(prefix):] + break + assert not os.path.isabs(rel_dst) + dst = os.path.join(args.dest_dir, rel_dst) + if os.path.isfile(dst) and args.existing == 'skip': + break + + makedirs(os.path.dirname(dst)) + + shutil.copyfile(src, dst) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/copy_to_dir.py b/build/scripts/copy_to_dir.py new file mode 100644 index 00000000000..9baeb5ffacf --- /dev/null +++ b/build/scripts/copy_to_dir.py @@ -0,0 +1,75 @@ +import errno +import sys +import os +import shutil +import optparse +import tarfile + + +def parse_args(): + parser = optparse.OptionParser() + parser.add_option('--build-root') + parser.add_option('--dest-dir') + parser.add_option('--dest-arch') + return parser.parse_args() + + +def ensure_dir_exists(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise + + +def hardlink_or_copy(src, dst): + if os.name == 'nt': + shutil.copy(src, dst) + else: + try: + os.link(src, dst) + except OSError as e: + if e.errno == errno.EEXIST: + return + elif e.errno == errno.EXDEV: + sys.stderr.write("Can't make cross-device hardlink - fallback to copy: {} -> {}\n".format(src, dst)) + shutil.copy(src, dst) + else: + raise + + +def main(): + opts, args = parse_args() + assert opts.build_root + assert opts.dest_dir + + dest_arch = None + if opts.dest_arch: + if opts.dest_arch.endswith('.tar'): + dest_arch = tarfile.open(opts.dest_arch, 'w', dereference=True) + elif opts.dest_arch.endswith('.tar.gz') or opts.dest_arch.endswith('.tgz'): + dest_arch = tarfile.open(opts.dest_arch, 'w:gz', dereference=True) + else: + # TODO: move check to graph generation stage + raise Exception('Unsopported archive type for {}. Use one of: tar, tar.gz, tgz.'.format(os.path.basename(opts.dest_arch))) + + for arg in args: + dst = arg + if dst.startswith(opts.build_root): + dst = dst[len(opts.build_root) + 1:] + + if dest_arch and not arg.endswith('.pkg.fake'): + dest_arch.add(arg, arcname=dst) + + dst = os.path.join(opts.dest_dir, dst) + ensure_dir_exists(os.path.dirname(dst)) + hardlink_or_copy(arg, dst) + + if dest_arch: + dest_arch.close() + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/build/scripts/coverage-info.py b/build/scripts/coverage-info.py new file mode 100644 index 00000000000..94491d92564 --- /dev/null +++ b/build/scripts/coverage-info.py @@ -0,0 +1,282 @@ +import argparse +import os +import sys +import tarfile +import collections +import subprocess +import re + + +GCDA_EXT = '.gcda' +GCNO_EXT = '.gcno' + + +def suffixes(path): + """ + >>> list(suffixes('/a/b/c')) + ['c', 'b/c', '/a/b/c'] + >>> list(suffixes('/a/b/c/')) + ['c', 'b/c', '/a/b/c'] + >>> list(suffixes('/a')) + ['/a'] + >>> list(suffixes('/a/')) + ['/a'] + >>> list(suffixes('/')) + [] + """ + path = os.path.normpath(path) + + def up_dirs(cur_path): + while os.path.dirname(cur_path) != cur_path: + cur_path = os.path.dirname(cur_path) + yield cur_path + + for x in up_dirs(path): + yield path.replace(x + os.path.sep, '') + + +def recast(in_file, out_file, probe_path, update_stat): + PREFIX = 'SF:' + + probed_path = None + + any_payload = False + + with open(in_file, 'r') as input, open(out_file, 'w') as output: + active = True + for line in input: + line = line.rstrip('\n') + if line.startswith('TN:'): + output.write(line + '\n') + elif line.startswith(PREFIX): + path = line[len(PREFIX):] + probed_path = probe_path(path) + if probed_path: + output.write(PREFIX + probed_path + '\n') + active = bool(probed_path) + else: + if active: + update_stat(probed_path, line) + output.write(line + '\n') + any_payload = True + + return any_payload + + +def print_stat(da, fnda, teamcity_stat_output): + lines_hit = sum(map(bool, da.values())) + lines_total = len(da.values()) + lines_coverage = 100.0 * lines_hit / lines_total if lines_total else 0 + + func_hit = sum(map(bool, fnda.values())) + func_total = len(fnda.values()) + func_coverage = 100.0 * func_hit / func_total if func_total else 0 + + print >>sys.stderr, '[[imp]]Lines[[rst]] {: >16} {: >16} {: >16.1f}%'.format(lines_hit, lines_total, lines_coverage) + print >>sys.stderr, '[[imp]]Functions[[rst]] {: >16} {: >16} {: >16.1f}%'.format(func_hit, func_total, func_coverage) + + if teamcity_stat_output: + with open(teamcity_stat_output, 'w') as tc_file: + tc_file.write("##teamcity[blockOpened name='Code Coverage Summary']\n") + tc_file.write("##teamcity[buildStatisticValue key=\'CodeCoverageAbsLTotal\' value='{}']\n".format(lines_total)) + tc_file.write("##teamcity[buildStatisticValue key=\'CodeCoverageAbsLCovered\' value='{}']\n".format(lines_hit)) + tc_file.write("##teamcity[buildStatisticValue key=\'CodeCoverageAbsMTotal\' value='{}']\n".format(func_total)) + tc_file.write("##teamcity[buildStatisticValue key=\'CodeCoverageAbsMCovered\' value='{}']\n".format(func_hit)) + tc_file.write("##teamcity[blockClosed name='Code Coverage Summary']\n") + + +def chunks(l, n): + """ + >>> list(chunks(range(10), 3)) + [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]] + >>> list(chunks(range(10), 5)) + [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] + """ + for i in xrange(0, len(l), n): + yield l[i:i + n] + + +def combine_info_files(lcov, files, out_file): + chunk_size = 50 + files = list(set(files)) + + for chunk in chunks(files, chunk_size): + combine_cmd = [lcov] + if os.path.exists(out_file): + chunk.append(out_file) + for trace in chunk: + assert os.path.exists(trace), "Trace file does not exist: {} (cwd={})".format(trace, os.getcwd()) + combine_cmd += ["-a", os.path.abspath(trace)] + print >>sys.stderr, '## lcov', ' '.join(combine_cmd[1:]) + out_file_tmp = "combined.tmp" + with open(out_file_tmp, "w") as stdout: + subprocess.check_call(combine_cmd, stdout=stdout) + if os.path.exists(out_file): + os.remove(out_file) + os.rename(out_file_tmp, out_file) + + +def probe_path_global(path, source_root, prefix_filter, exclude_files): + if path.endswith('_ut.cpp'): + return None + + for suff in reversed(list(suffixes(path))): + if (not prefix_filter or suff.startswith(prefix_filter)) and (not exclude_files or not exclude_files.match(suff)): + full_path = source_root + os.sep + suff + if os.path.isfile(full_path): + return full_path + + return None + + +def update_stat_global(src_file, line, fnda, da): + if line.startswith("FNDA:"): + visits, func_name = line[len("FNDA:"):].split(',') + fnda[src_file + func_name] += int(visits) + + if line.startswith("DA"): + line_number, visits = line[len("DA:"):].split(',') + if visits == '=====': + visits = 0 + + da[src_file + line_number] += int(visits) + + +def gen_info_global(cmd, cov_info, probe_path, update_stat, lcov_args): + print >>sys.stderr, '## geninfo', ' '.join(cmd) + subprocess.check_call(cmd) + if recast(cov_info + '.tmp', cov_info, probe_path, update_stat): + lcov_args.append(cov_info) + + +def init_all_coverage_files(gcno_archive, fname2gcno, fname2info, geninfo_executable, gcov_tool, gen_info, prefix_filter, exclude_files): + with tarfile.open(gcno_archive) as gcno_tf: + for gcno_item in gcno_tf: + if gcno_item.isfile() and gcno_item.name.endswith(GCNO_EXT): + gcno_tf.extract(gcno_item) + + gcno_name = gcno_item.name + source_fname = gcno_name[:-len(GCNO_EXT)] + if prefix_filter and not source_fname.startswith(prefix_filter): + sys.stderr.write("Skipping {} (doesn't match prefix '{}')\n".format(source_fname, prefix_filter)) + continue + if exclude_files and exclude_files.search(source_fname): + sys.stderr.write("Skipping {} (matched exclude pattern '{}')\n".format(source_fname, exclude_files.pattern)) + continue + + fname2gcno[source_fname] = gcno_name + + if os.path.getsize(gcno_name) > 0: + coverage_info = source_fname + '.' + str(len(fname2info[source_fname])) + '.info' + fname2info[source_fname].append(coverage_info) + geninfo_cmd = [ + geninfo_executable, + '--gcov-tool', gcov_tool, + '-i', gcno_name, + '-o', coverage_info + '.tmp' + ] + gen_info(geninfo_cmd, coverage_info) + + +def process_all_coverage_files(gcda_archive, fname2gcno, fname2info, geninfo_executable, gcov_tool, gen_info): + with tarfile.open(gcda_archive) as gcda_tf: + for gcda_item in gcda_tf: + if gcda_item.isfile() and gcda_item.name.endswith(GCDA_EXT): + gcda_name = gcda_item.name + source_fname = gcda_name[:-len(GCDA_EXT)] + for suff in suffixes(source_fname): + if suff in fname2gcno: + gcda_new_name = suff + GCDA_EXT + gcda_item.name = gcda_new_name + gcda_tf.extract(gcda_item) + if os.path.getsize(gcda_new_name) > 0: + coverage_info = suff + '.' + str(len(fname2info[suff])) + '.info' + fname2info[suff].append(coverage_info) + geninfo_cmd = [ + geninfo_executable, + '--gcov-tool', gcov_tool, + gcda_new_name, + '-o', coverage_info + '.tmp' + ] + gen_info(geninfo_cmd, coverage_info) + + +def gen_cobertura(tool, output, combined_info): + cmd = [ + tool, + combined_info, + '-b', '#hamster#', + '-o', output + ] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if p.returncode: + raise Exception('lcov_cobertura failed with exit code {}\nstdout: {}\nstderr: {}'.format(p.returncode, out, err)) + + +def main(source_root, output, gcno_archive, gcda_archive, gcov_tool, prefix_filter, exclude_regexp, teamcity_stat_output, coverage_report_path, gcov_report, lcov_cobertura): + exclude_files = re.compile(exclude_regexp) if exclude_regexp else None + + fname2gcno = {} + fname2info = collections.defaultdict(list) + lcov_args = [] + geninfo_executable = os.path.join(source_root, 'devtools', 'lcov', 'geninfo') + + def probe_path(path): + return probe_path_global(path, source_root, prefix_filter, exclude_files) + + fnda = collections.defaultdict(int) + da = collections.defaultdict(int) + + def update_stat(src_file, line): + update_stat_global(src_file, line, da, fnda) + + def gen_info(cmd, cov_info): + gen_info_global(cmd, cov_info, probe_path, update_stat, lcov_args) + + init_all_coverage_files(gcno_archive, fname2gcno, fname2info, geninfo_executable, gcov_tool, gen_info, prefix_filter, exclude_files) + process_all_coverage_files(gcda_archive, fname2gcno, fname2info, geninfo_executable, gcov_tool, gen_info) + + if coverage_report_path: + output_dir = coverage_report_path + else: + output_dir = output + '.dir' + + if not os.path.exists(output_dir): + os.makedirs(output_dir) + + teamcity_stat_file = None + if teamcity_stat_output: + teamcity_stat_file = os.path.join(output_dir, 'teamcity.out') + print_stat(da, fnda, teamcity_stat_file) + + if lcov_args: + output_trace = "combined.info" + combine_info_files(os.path.join(source_root, 'devtools', 'lcov', 'lcov'), lcov_args, output_trace) + cmd = [os.path.join(source_root, 'devtools', 'lcov', 'genhtml'), '-p', source_root, '--ignore-errors', 'source', '-o', output_dir, output_trace] + print >>sys.stderr, '## genhtml', ' '.join(cmd) + subprocess.check_call(cmd) + if lcov_cobertura: + gen_cobertura(lcov_cobertura, gcov_report, output_trace) + + with tarfile.open(output, 'w') as tar: + tar.add(output_dir, arcname='.') + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--source-root', action='store') + parser.add_argument('--output', action='store') + parser.add_argument('--gcno-archive', action='store') + parser.add_argument('--gcda-archive', action='store') + parser.add_argument('--gcov-tool', action='store') + parser.add_argument('--prefix-filter', action='store') + parser.add_argument('--exclude-regexp', action='store') + parser.add_argument('--teamcity-stat-output', action='store_const', const=True) + parser.add_argument('--coverage-report-path', action='store') + parser.add_argument('--gcov-report', action='store') + parser.add_argument('--lcov-cobertura', action='store') + + args = parser.parse_args() + main(**vars(args)) diff --git a/build/scripts/cpp_flatc_wrapper.py b/build/scripts/cpp_flatc_wrapper.py new file mode 100644 index 00000000000..9f74b655709 --- /dev/null +++ b/build/scripts/cpp_flatc_wrapper.py @@ -0,0 +1,30 @@ +import os +import subprocess +import sys + + +def main(): + cmd = sys.argv[1:] + h_file = None + try: + index = cmd.index('-o') + h_file = cmd[index+1] + cmd[index+1] = os.path.dirname(h_file) + except (ValueError, IndexError): + pass + p = subprocess.run(cmd, capture_output=True, text=True) + if p.returncode: + if p.stdout: + sys.stderr.write('stdout:\n{}\n'.format(p.stdout)) + if p.stderr: + sys.stderr.write('stderr:\n{}\n'.format(p.stderr)) + sys.exit(p.returncode) + if h_file and h_file.endswith(('.fbs.h', '.fbs64.h')): + cpp_file = '{}.cpp'.format(h_file[:-2]) + with open(cpp_file, 'w') as f: + f.write('#include "{}"\n'.format(os.path.basename(h_file))) + sys.exit(0) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/create_jcoverage_report.py b/build/scripts/create_jcoverage_report.py new file mode 100644 index 00000000000..45083ff4f7e --- /dev/null +++ b/build/scripts/create_jcoverage_report.py @@ -0,0 +1,112 @@ +import argparse +import tarfile +import zipfile +import os +import sys +import time +import subprocess + + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError: + pass + + +class Timer(object): + + def __init__(self): + self.start = time.time() + + def step(self, msg): + sys.stderr.write("{} ({}s)\n".format(msg, int(time.time() - self.start))) + self.start = time.time() + + +def main(source, output, java, prefix_filter, exclude_filter, jars_list, output_format, tar_output, agent_disposition, runners_paths): + timer = Timer() + reports_dir = 'jacoco_reports_dir' + mkdir_p(reports_dir) + with tarfile.open(source) as tf: + tf.extractall(reports_dir) + timer.step("Coverage data extracted") + reports = [os.path.join(reports_dir, fname) for fname in os.listdir(reports_dir)] + + with open(jars_list) as f: + jars = f.read().strip().split() + if jars and runners_paths: + for r in runners_paths: + try: + jars.remove(r) + except ValueError: + pass + + src_dir = 'sources_dir' + cls_dir = 'classes_dir' + + mkdir_p(src_dir) + mkdir_p(cls_dir) + + for jar in jars: + if jar.endswith('devtools-jacoco-agent.jar'): + agent_disposition = jar + + # Skip java contrib - it's irrelevant coverage + if jar.startswith('contrib/java'): + continue + + with zipfile.ZipFile(jar) as jf: + for entry in jf.infolist(): + if entry.filename.endswith('.java'): + dest = src_dir + + elif entry.filename.endswith('.class'): + dest = cls_dir + + else: + continue + + entry.filename = entry.filename.encode('utf-8') + jf.extract(entry, dest) + timer.step("Jar files extracted") + + if not agent_disposition: + print>>sys.stderr, 'Can\'t find jacoco agent. Will not generate html report for java coverage.' + + if tar_output: + report_dir = 'java.report.temp' + else: + report_dir = output + mkdir_p(report_dir) + + if agent_disposition: + agent_cmd = [java, '-jar', agent_disposition, src_dir, cls_dir, prefix_filter or '.', exclude_filter or '__no_exclude__', report_dir, output_format] + agent_cmd += reports + subprocess.check_call(agent_cmd) + timer.step("Jacoco finished") + + if tar_output: + with tarfile.open(output, 'w') as outf: + outf.add(report_dir, arcname='.') + + +if __name__ == '__main__': + if 'LC_ALL' in os.environ: + if os.environ['LC_ALL'] == 'C': + os.environ['LC_ALL'] = 'en_GB.UTF-8' + + parser = argparse.ArgumentParser() + + parser.add_argument('--source', action='store') + parser.add_argument('--output', action='store') + parser.add_argument('--java', action='store') + parser.add_argument('--prefix-filter', action='store') + parser.add_argument('--exclude-filter', action='store') + parser.add_argument('--jars-list', action='store') + parser.add_argument('--output-format', action='store', default="html") + parser.add_argument('--raw-output', dest='tar_output', action='store_false', default=True) + parser.add_argument('--agent-disposition', action='store') + parser.add_argument('--runner-path', dest='runners_paths', action='append', default=[]) + args = parser.parse_args() + main(**vars(args)) diff --git a/build/scripts/custom_link_green_mysql.py b/build/scripts/custom_link_green_mysql.py new file mode 100644 index 00000000000..13bb9e4ac77 --- /dev/null +++ b/build/scripts/custom_link_green_mysql.py @@ -0,0 +1,97 @@ +import os +import shutil +import subprocess +import sys +import tempfile + + +SYMBOLS_TO_PATCH = ( + 'connect', + 'poll', + 'recv', + 'recvfrom', + 'send', + 'sendto', +) + +class Error(Exception): + pass + + +def find_compiler(args): + for arg in args: + if os.path.basename(arg) in ('clang', 'clang++'): + return arg + raise Error('No known compiler found in the command line') + + +def find_libraries(project, args): + if not project.endswith('/'): + project = project + '/' + + for arg in args: + if arg.startswith(project): + yield arg + + +def rename_symbol(symbol): + return 'green_{}'.format(symbol) + + +def patch_object(object_path, objcopy): + args = [objcopy] + for symbol in SYMBOLS_TO_PATCH: + args.extend(('--redefine-sym', '{}={}'.format(symbol, rename_symbol(symbol)))) + args.append(object_path) + subprocess.check_call(args) + + +def patch_library(library_path, ar, objcopy): + tmpdir = tempfile.mkdtemp(dir=os.path.dirname(library_path)) + try: + subprocess.check_call((ar, 'x', library_path), cwd=tmpdir) + names = os.listdir(tmpdir) + for name in names: + patch_object(os.path.join(tmpdir, name), objcopy=objcopy) + + new_library_path = os.path.join(tmpdir, 'library.a') + subprocess.check_call([ar, 'rcs', new_library_path] + names, cwd=tmpdir) + + os.rename(new_library_path, library_path) + + finally: + shutil.rmtree(tmpdir) + + +def main(): + try: + args = sys.argv[1:] + compiler = find_compiler(args) + compiler_dir = os.path.dirname(compiler) + + def get_tool(name): + path = os.path.join(compiler_dir, name) + if not os.path.exists(path): + raise Error('No {} found alongside the compiler'.format(name)) + return path + + ar = get_tool('llvm-ar') + objcopy = get_tool('llvm-objcopy') + + libraries = tuple(find_libraries('contrib/libs/libmysql_r', args)) + for library in libraries: + library_path = os.path.abspath(library) + if not os.path.exists(library_path): + raise Error('No {} file exists'.format(library)) + + patch_library(library_path, ar=ar, objcopy=objcopy) + + except Exception as error: + name = os.path.basename(sys.argv[0]) + command = ' '.join(args) + message = '{name} failed: {error}\nCommand line: {command}' + print >> sys.stderr, message.format(**locals()) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/decimal_md5.py b/build/scripts/decimal_md5.py new file mode 100644 index 00000000000..e70ca80a09f --- /dev/null +++ b/build/scripts/decimal_md5.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import hashlib +import struct +import sys +import os +import argparse + + +def print_code(checksum, func_name): + if len(func_name) == 0: # safe fallback for old ya.make files + func_name = "DecimalMD5" + print 'const char* ' + func_name + '() {return "' + checksum + '";}' + + +def ensure_paths_exist(paths): + bad_paths = sorted( + path for path in paths + if not os.path.exists(path) + ) + if bad_paths: + print >> sys.stderr, "decimal_md5 inputs do not exist:" + for path in bad_paths: + print >> sys.stderr, path + sys.exit(1) + + +def _update_digest_with_file_contents(digest, path, block_size=65535): + with open(path) as f: + while True: + block = f.read(block_size) + if not block: + break + digest.update(block) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--fixed-output", help="don not calculate md5, use this value instead") + parser.add_argument("--lower-bits", help="use specified count of lower bits", type=int, default=32) + parser.add_argument("--source-root", help="arcadia source root") + parser.add_argument("--func-name", help="custom function name to be defined", default="DecimalMD5") + parser.add_argument("targets", nargs='*', default=['.']) + + args = parser.parse_args() + + abs_paths = [ + os.path.join(args.source_root, target) + for target in args.targets + ] + ensure_paths_exist(abs_paths) + + if args.fixed_output: + try: + bitmask = (1 << args.lower_bits) - 1 + fmt = '{:0%dd}' % len(str(bitmask)) + checksum = fmt.format(int(args.fixed_output) & bitmask) + except ValueError: + raise ValueError("decimal_md5: bad value passed via --fixed-output: %s" % args.fixed_output) + print_code(str(checksum), func_name=args.func_name) + return + + md5 = hashlib.md5() + for path in abs_paths: + _update_digest_with_file_contents(md5, path) + + md5_parts = struct.unpack('IIII', md5.digest()) + md5_int = sum(part << (32 * n) for n, part in enumerate(md5_parts)) + bitmask = (1 << args.lower_bits) - 1 + fmt = '{:0%dd}' % len(str(bitmask)) + + checksum_str = fmt.format(md5_int & bitmask) + print_code(checksum_str, func_name=args.func_name) + + +if __name__ == "__main__": + main() + diff --git a/build/scripts/error.py b/build/scripts/error.py new file mode 100644 index 00000000000..f7d8ecb2cc0 --- /dev/null +++ b/build/scripts/error.py @@ -0,0 +1,77 @@ +# Sync content of this file with devtools/ya/core/error/__init__.py + +TEMPORARY_ERROR_MESSAGES = [ + 'Connection reset by peer', + 'Connection timed out', + 'Function not implemented', + 'I/O operation on closed file', + 'Internal Server Error', + 'Network connection closed unexpectedly', + 'Network is unreachable', + 'No route to host', + 'No space left on device', + 'Not enough space', + 'Temporary failure in name resolution', + 'The read operation timed out', + 'timeout: timed out', +] + + +# Node exit codes +class ExitCodes(object): + TEST_FAILED = 10 + COMPILATION_FAILED = 11 + INFRASTRUCTURE_ERROR = 12 + NOT_RETRIABLE_ERROR = 13 + YT_STORE_FETCH_ERROR = 14 + + +def merge_exit_codes(exit_codes): + return max(e if e >= 0 else 1 for e in exit_codes) if exit_codes else 0 + + +def is_temporary_error(exc): + import logging + logger = logging.getLogger(__name__) + + if getattr(exc, 'temporary', False): + logger.debug("Exception has temporary attribute: %s", exc) + return True + + import errno + err = getattr(exc, 'errno', None) + + if err == errno.ECONNREFUSED or err == errno.ENETUNREACH: + logger.debug("Exception has errno attribute: %s (errno=%s)", exc, err) + return True + + import socket + + if isinstance(exc, socket.timeout) or isinstance(getattr(exc, 'reason', None), socket.timeout): + logger.debug("Socket timeout exception: %s", exc) + return True + + if isinstance(exc, socket.gaierror): + logger.debug("Getaddrinfo exception: %s", exc) + return True + + import urllib2 + + if isinstance(exc, urllib2.HTTPError) and exc.code in (429, ): + logger.debug("urllib2.HTTPError: %s", exc) + return True + + import httplib + + if isinstance(exc, httplib.IncompleteRead): + logger.debug("IncompleteRead exception: %s", exc) + return True + + exc_str = str(exc) + + for message in TEMPORARY_ERROR_MESSAGES: + if message in exc_str: + logger.debug("Found temporary error pattern (%s): %s", message, exc_str) + return True + + return False diff --git a/build/scripts/extract_asrc.py b/build/scripts/extract_asrc.py new file mode 100644 index 00000000000..89892ddf2de --- /dev/null +++ b/build/scripts/extract_asrc.py @@ -0,0 +1,23 @@ +import argparse +import os +import tarfile + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--input', nargs='*', required=True) + parser.add_argument('--output', required=True) + + return parser.parse_args() + + +def main(): + args = parse_args() + + for asrc in filter(lambda x: x.endswith('.asrc') and os.path.exists(x), args.input): + with tarfile.open(asrc, 'r') as tar: + tar.extractall(path=args.output) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/extract_docs.py b/build/scripts/extract_docs.py new file mode 100644 index 00000000000..20e83113460 --- /dev/null +++ b/build/scripts/extract_docs.py @@ -0,0 +1,43 @@ +import argparse +import os +import process_command_files as pcf +import tarfile +import sys + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--dest-dir', required=True) + parser.add_argument('--skip-prefix', dest='skip_prefixes', action='append', default=[]) + parser.add_argument('docs', nargs='*') + return parser.parse_args(pcf.get_args(sys.argv[1:])) + + +def main(): + args = parse_args() + + prefixes = ['{}{}'.format(os.path.normpath(p), os.path.sep) for p in args.skip_prefixes] + + def _valid_docslib(path): + base = os.path.basename(path) + return base.endswith(('.docslib', '.docslib.fake')) or base == 'preprocessed.tar.gz' + + for src in [p for p in args.docs if _valid_docslib(p)]: + if src == 'preprocessed.tar.gz': + rel_dst = os.path.dirname(os.path.normpath(src)) + for prefix in prefixes: + if src.startswith(prefix): + rel_dst = rel_dst[len(prefix):] + continue + assert not os.path.isabs(rel_dst) + dest_dir = os.path.join(args.dest_dir, rel_dst) + else: + dest_dir = args.dest_dir + if not os.path.exists(dest_dir): + os.makedirs(dest_dir) + with tarfile.open(src, 'r') as tar_file: + tar_file.extractall(dest_dir) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/extract_jacoco_report.py b/build/scripts/extract_jacoco_report.py new file mode 100644 index 00000000000..02e4ba9f13a --- /dev/null +++ b/build/scripts/extract_jacoco_report.py @@ -0,0 +1,29 @@ +import argparse +import os +import re +import tarfile + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--archive', action='store') + parser.add_argument('--source-re', action='store') + parser.add_argument('--destination', action='store') + + args = parser.parse_args() + + with tarfile.open(args.archive) as tf: + open(args.destination, 'wb').close() + extract_list = [] + matcher = re.compile(args.source_re) + temp_dir = os.path.join(os.path.dirname(args.destination), 'temp_profiles') + if not os.path.exists(temp_dir): + os.makedirs(temp_dir) + for f in [i for i in tf if matcher.match(i.name)]: + tf.extract(f, path=temp_dir) + for directory, _, srcs in os.walk(temp_dir): + for f in srcs: + with open(args.destination, 'ab') as dst: + with open(os.path.join(temp_dir, directory, f), 'rb') as src: + dst.write(src.read()) diff --git a/build/scripts/f2c.py b/build/scripts/f2c.py new file mode 100644 index 00000000000..7021e1391f1 --- /dev/null +++ b/build/scripts/f2c.py @@ -0,0 +1,58 @@ +import sys +import subprocess +import argparse +import os + + +header = '''\ +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wmissing-braces" +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wreturn-type" +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +''' + +footer = ''' +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +''' + + +def mkdir_p(directory): + if not os.path.exists(directory): + os.makedirs(directory) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('-t', '--tool') + parser.add_argument('-c', '--input') + parser.add_argument('-o', '--output') + + args = parser.parse_args() + tmpdir = args.output + '.f2c' + mkdir_p(tmpdir) + # should parse includes, really + p = subprocess.Popen( + [args.tool, '-w', '-R', '-a', '-I' + os.path.dirname(args.input), '-T' + tmpdir], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + stdout, stderr = p.communicate(input=open(args.input).read()) + ret = p.wait() + + if ret: + print >>sys.stderr, 'f2c failed: %s, %s' % (stderr, ret) + sys.exit(ret) + + if 'Error' in stderr: + print >>sys.stderr, stderr + + with open(args.output, 'w') as f: + f.write(header) + f.write(stdout) + f.write(footer) diff --git a/build/scripts/fail_module_cmd.py b/build/scripts/fail_module_cmd.py new file mode 100644 index 00000000000..fa14c0d8516 --- /dev/null +++ b/build/scripts/fail_module_cmd.py @@ -0,0 +1,7 @@ +import sys + + +if __name__ == '__main__': + assert len(sys.argv) == 2, 'Unexpected number of arguments...' + sys.stderr.write('Error: module command for target [[bad]]{}[[rst]] was not executed due to build graph configuration errors...\n'.format(sys.argv[1])) + sys.exit(1) diff --git a/build/scripts/fetch_from.py b/build/scripts/fetch_from.py new file mode 100755 index 00000000000..b6ea7cefa15 --- /dev/null +++ b/build/scripts/fetch_from.py @@ -0,0 +1,396 @@ +import datetime as dt +import errno +import hashlib +import json +import logging +import os +import platform +import random +import shutil +import socket +import string +import sys +import tarfile +import urllib2 + +import retry + + +def make_user_agent(): + return 'fetch_from: {host}'.format(host=socket.gethostname()) + + +def add_common_arguments(parser): + parser.add_argument('--copy-to') # used by jbuild in fetch_resource + parser.add_argument('--rename-to') # used by test_node in inject_mds_resource_to_graph + parser.add_argument('--copy-to-dir') + parser.add_argument('--untar-to') + parser.add_argument('--rename', action='append', default=[], metavar='FILE', help='rename FILE to the corresponding output') + parser.add_argument('--executable', action='store_true', help='make outputs executable') + parser.add_argument('--log-path') + parser.add_argument('-v', '--verbose', action='store_true', default=os.environ.get('YA_VERBOSE_FETCHER'), help='increase stderr verbosity') + parser.add_argument('outputs', nargs='*', default=[]) + + +def ensure_dir(path): + if not (path == '' or os.path.isdir(path)): + os.makedirs(path) + + +# Reference code: library/python/fs/__init__.py +def hardlink_or_copy(src, dst): + ensure_dir(os.path.dirname(dst)) + + if os.name == 'nt': + shutil.copy(src, dst) + else: + try: + os.link(src, dst) + except OSError as e: + if e.errno == errno.EEXIST: + return + elif e.errno in (errno.EXDEV, errno.EMLINK, errno.EINVAL, errno.EACCES): + sys.stderr.write("Can't make hardlink (errno={}) - fallback to copy: {} -> {}\n".format(e.errno, src, dst)) + shutil.copy(src, dst) + else: + sys.stderr.write("src: {} dst: {}\n".format(src, dst)) + raise + + +def rename_or_copy_and_remove(src, dst): + ensure_dir(os.path.dirname(dst)) + + try: + os.rename(src, dst) + except OSError: + shutil.copy(src, dst) + os.remove(src) + + +class BadChecksumFetchError(Exception): + pass + + +class IncompleteFetchError(Exception): + pass + + +class ResourceUnpackingError(Exception): + pass + + +class ResourceIsDirectoryError(Exception): + pass + + +class OutputIsDirectoryError(Exception): + pass + + +class OutputNotExistError(Exception): + pass + + +def setup_logging(args, base_name): + def makedirs(path): + try: + os.makedirs(path) + except OSError: + pass + + if args.log_path: + log_file_name = args.log_path + else: + log_file_name = base_name + ".log" + + args.abs_log_path = os.path.abspath(log_file_name) + makedirs(os.path.dirname(args.abs_log_path)) + logging.basicConfig(filename=args.abs_log_path, level=logging.DEBUG) + if args.verbose: + logging.getLogger().addHandler(logging.StreamHandler(sys.stderr)) + + +def is_temporary(e): + + def is_broken(e): + return isinstance(e, urllib2.HTTPError) and e.code in (410, 404) + + if is_broken(e): + return False + + if isinstance(e, (BadChecksumFetchError, IncompleteFetchError, urllib2.URLError, socket.error)): + return True + + import error + + return error.is_temporary_error(e) + + +def uniq_string_generator(size=6, chars=string.ascii_lowercase + string.digits): + return ''.join(random.choice(chars) for _ in range(size)) + + +def report_to_snowden(value): + def inner(): + body = { + 'namespace': 'ygg', + 'key': 'fetch-from-sandbox', + 'value': json.dumps(value), + } + + urllib2.urlopen( + 'https://back-snowden.qloud.yandex-team.ru/report/add', + json.dumps([body, ]), + timeout=5, + ) + + try: + inner() + except Exception as e: + logging.warning('report_to_snowden failed: %s', e) + + +def copy_stream(read, *writers, **kwargs): + chunk_size = kwargs.get('size', 1024*1024) + while True: + data = read(chunk_size) + if not data: + break + for write in writers: + write(data) + + +def md5file(fname): + res = hashlib.md5() + with open(fname, 'rb') as f: + copy_stream(f.read, res.update) + return res.hexdigest() + + +def git_like_hash_with_size(filepath): + """ + Calculate git like hash for path + """ + sha = hashlib.sha1() + + file_size = 0 + + with open(filepath, 'rb') as f: + while True: + block = f.read(2 ** 16) + + if not block: + break + + file_size += len(block) + sha.update(block) + + sha.update('\0') + sha.update(str(file_size)) + + return sha.hexdigest(), file_size + + +def size_printer(display_name, size): + sz = [0] + last_stamp = [dt.datetime.now()] + + def printer(chunk): + sz[0] += len(chunk) + now = dt.datetime.now() + if last_stamp[0] + dt.timedelta(seconds=10) < now: + if size: + print >>sys.stderr, "##status##{} - [[imp]]{:.1f}%[[rst]]".format(display_name, 100.0 * sz[0] / size if size else 0) + last_stamp[0] = now + + return printer + + +def fetch_url(url, unpack, resource_file_name, expected_md5=None, expected_sha1=None, tries=10, writers=None): + logging.info('Downloading from url %s name %s and expected md5 %s', url, resource_file_name, expected_md5) + tmp_file_name = uniq_string_generator() + + request = urllib2.Request(url, headers={'User-Agent': make_user_agent()}) + req = retry.retry_func(lambda: urllib2.urlopen(request, timeout=30), tries=tries, delay=5, backoff=1.57079) + logging.debug('Headers: %s', req.headers.headers) + expected_file_size = int(req.headers.get('Content-Length', 0)) + real_md5 = hashlib.md5() + real_sha1 = hashlib.sha1() + + with open(tmp_file_name, 'wb') as fp: + copy_stream( + req.read, + fp.write, + real_md5.update, + real_sha1.update, + size_printer(resource_file_name, expected_file_size), + *([] if writers is None else writers) + ) + + real_md5 = real_md5.hexdigest() + real_file_size = os.path.getsize(tmp_file_name) + real_sha1.update('\0') + real_sha1.update(str(real_file_size)) + real_sha1 = real_sha1.hexdigest() + + if unpack: + tmp_dir = tmp_file_name + '.dir' + os.makedirs(tmp_dir) + with tarfile.open(tmp_file_name, mode="r|gz") as tar: + tar.extractall(tmp_dir) + tmp_file_name = os.path.join(tmp_dir, resource_file_name) + if expected_md5: + real_md5 = md5file(tmp_file_name) + + logging.info('File size %s (expected %s)', real_file_size, expected_file_size or "UNKNOWN") + logging.info('File md5 %s (expected %s)', real_md5, expected_md5) + logging.info('File sha1 %s (expected %s)', real_sha1, expected_sha1) + + if expected_md5 and real_md5 != expected_md5: + report_to_snowden( + { + 'headers': req.headers.headers, + 'expected_md5': expected_md5, + 'real_md5': real_md5 + } + ) + + raise BadChecksumFetchError( + 'Downloaded {}, but expected {} for {}'.format( + real_md5, + expected_md5, + url, + ) + ) + + if expected_sha1 and real_sha1 != expected_sha1: + report_to_snowden( + { + 'headers': req.headers.headers, + 'expected_sha1': expected_sha1, + 'real_sha1': real_sha1 + } + ) + + raise BadChecksumFetchError( + 'Downloaded {}, but expected {} for {}'.format( + real_sha1, + expected_sha1, + url, + ) + ) + + if expected_file_size and expected_file_size != real_file_size: + report_to_snowden({'headers': req.headers.headers, 'file_size': real_file_size}) + + raise IncompleteFetchError( + 'Downloaded {}, but expected {} for {}'.format( + real_file_size, + expected_file_size, + url, + ) + ) + + return tmp_file_name + + +def chmod(filename, mode): + if platform.system().lower() == 'windows': + # https://docs.microsoft.com/en-us/windows/win32/fileio/hard-links-and-junctions: + # hard to reset read-only attribute for removal if there are multiple hardlinks + return + stat = os.stat(filename) + if stat.st_mode & 0o777 != mode: + try: + os.chmod(filename, mode) + except OSError: + import pwd + sys.stderr.write("{} st_mode: {} pwuid: {}\n".format(filename, stat.st_mode, pwd.getpwuid(os.stat(filename).st_uid))) + raise + + +def process(fetched_file, file_name, args, remove=True): + assert len(args.rename) <= len(args.outputs), ( + 'too few outputs to rename', args.rename, 'into', args.outputs) + + fetched_file_is_dir = os.path.isdir(fetched_file) + if fetched_file_is_dir and not args.untar_to: + raise ResourceIsDirectoryError('Resource may be directory only with untar_to option: ' + fetched_file) + + # make all read only + if fetched_file_is_dir: + for root, _, files in os.walk(fetched_file): + for filename in files: + chmod(os.path.join(root, filename), 0o444) + else: + chmod(fetched_file, 0o444) + + + if args.copy_to: + hardlink_or_copy(fetched_file, args.copy_to) + if not args.outputs: + args.outputs = [args.copy_to] + + if args.rename_to: + args.rename.append(fetched_file) + if not args.outputs: + args.outputs = [args.rename_to] + + if args.copy_to_dir: + hardlink_or_copy(fetched_file, os.path.join(args.copy_to_dir, file_name)) + + if args.untar_to: + ensure_dir(args.untar_to) + inputs = set(map(os.path.normpath, args.rename + args.outputs[len(args.rename):])) + if fetched_file_is_dir: + for member in inputs: + base, name = member.split('/', 1) + src = os.path.normpath(os.path.join(fetched_file, name)) + dst = os.path.normpath(os.path.join(args.untar_to, member)) + hardlink_or_copy(src, dst) + else: + # Extract only requested files + try: + with tarfile.open(fetched_file, mode='r:*') as tar: + members = [entry for entry in tar if os.path.normpath(os.path.join(args.untar_to, entry.name)) in inputs] + tar.extractall(args.untar_to, members=members) + except tarfile.ReadError as e: + logging.exception(e) + raise ResourceUnpackingError('File {} cannot be untared'.format(fetched_file)) + + # Forbid changes to the loaded resource data + for root, _, files in os.walk(args.untar_to): + for filename in files: + chmod(os.path.join(root, filename), 0o444) + + + for src, dst in zip(args.rename, args.outputs): + if src == 'RESOURCE': + src = fetched_file + if os.path.abspath(src) == os.path.abspath(fetched_file): + logging.info('Copying %s to %s', src, dst) + hardlink_or_copy(src, dst) + else: + logging.info('Renaming %s to %s', src, dst) + if os.path.exists(dst): + raise ResourceUnpackingError("Target file already exists ({} -> {})".format(src, dst)) + if remove: + rename_or_copy_and_remove(src, dst) + else: + hardlink_or_copy(src, dst) + + for path in args.outputs: + if not os.path.exists(path): + raise OutputNotExistError('Output does not exist: %s' % os.path.abspath(path)) + if not os.path.isfile(path): + raise OutputIsDirectoryError('Output must be a file, not a directory: %s' % os.path.abspath(path)) + if args.executable: + chmod(path, os.stat(path).st_mode | 0o111) + if os.path.abspath(path) == os.path.abspath(fetched_file): + remove = False + + if remove: + if fetched_file_is_dir: + shutil.rmtree(fetched_file) + else: + os.remove(fetched_file) diff --git a/build/scripts/fetch_from_archive.py b/build/scripts/fetch_from_archive.py new file mode 100644 index 00000000000..57aff91b5e5 --- /dev/null +++ b/build/scripts/fetch_from_archive.py @@ -0,0 +1,36 @@ +import os +import sys +import logging +import argparse + +import fetch_from + + +def parse_args(): + parser = argparse.ArgumentParser() + fetch_from.add_common_arguments(parser) + parser.add_argument('--file-name', required=True) + parser.add_argument('--archive', required=True) + + return parser.parse_args() + +def main(args): + archive = args.archive + file_name = args.file_name.rstrip('-') + + fetch_from.process(archive, file_name, args, remove=False) + + +if __name__ == '__main__': + args = parse_args() + fetch_from.setup_logging(args, os.path.basename(__file__)) + + try: + main(args) + except Exception as e: + logging.exception(e) + print >>sys.stderr, open(args.abs_log_path).read() + sys.stderr.flush() + + import error + sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1) diff --git a/build/scripts/fetch_from_external.py b/build/scripts/fetch_from_external.py new file mode 100644 index 00000000000..d4ed6f4221b --- /dev/null +++ b/build/scripts/fetch_from_external.py @@ -0,0 +1,60 @@ +import sys +import json +import os.path +import fetch_from +import argparse +import logging + + +def parse_args(): + parser = argparse.ArgumentParser() + fetch_from.add_common_arguments(parser) + parser.add_argument('--external-file', required=True) + parser.add_argument('--custom-fetcher') + parser.add_argument('--resource-file') + return parser.parse_args() + + +def main(args): + external_file = args.external_file.rstrip('.external') + if os.path.isfile(args.resource_file): + fetch_from.process(args.resource_file, os.path.basename(args.resource_file), args, False) + return + + error = None + try: + with open(args.external_file) as f: + js = json.load(f) + + if js['storage'] == 'SANDBOX': + import fetch_from_sandbox as ffsb + del args.external_file + args.resource_id = js['resource_id'] + ffsb.main(args) + elif js['storage'] == 'MDS': + import fetch_from_mds as fmds + del args.external_file + args.key = js['resource_id'] + fmds.main(args) + else: + error = 'Unsupported storage in {}'.format(external_file) + except: + logging.error('Invalid external file: {}'.format(external_file)) + raise + if error: + raise Exception(error) + + +if __name__ == '__main__': + args = parse_args() + fetch_from.setup_logging(args, os.path.basename(__file__)) + + try: + main(args) + except Exception as e: + logging.exception(e) + print >>sys.stderr, open(args.abs_log_path).read() + sys.stderr.flush() + + import error + sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1) diff --git a/build/scripts/fetch_from_mds.py b/build/scripts/fetch_from_mds.py new file mode 100644 index 00000000000..5e4e6563944 --- /dev/null +++ b/build/scripts/fetch_from_mds.py @@ -0,0 +1,50 @@ +import os +import sys +import logging +import argparse + +import fetch_from + +MDS_PREFIX = "https://storage.yandex-team.ru/get-devtools/" + + +def parse_args(): + parser = argparse.ArgumentParser() + fetch_from.add_common_arguments(parser) + + parser.add_argument('--key', required=True) + + return parser.parse_args() + + +def fetch(key): + parts = key.split("/") + if len(parts) != 3: + raise ValueError("Invalid MDS key '{}'".format(key)) + + _, sha1, file_name = parts + + fetched_file = fetch_from.fetch_url(MDS_PREFIX + key, False, file_name, expected_sha1=sha1) + + return fetched_file, file_name + + +def main(args): + fetched_file, resource_file_name = fetch(args.key) + + fetch_from.process(fetched_file, resource_file_name, args) + + +if __name__ == '__main__': + args = parse_args() + fetch_from.setup_logging(args, os.path.basename(__file__)) + + try: + main(args) + except Exception as e: + logging.exception(e) + print >>sys.stderr, open(args.abs_log_path).read() + sys.stderr.flush() + + import error + sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1) diff --git a/build/scripts/fetch_from_npm.py b/build/scripts/fetch_from_npm.py new file mode 100644 index 00000000000..3f87c1fefa8 --- /dev/null +++ b/build/scripts/fetch_from_npm.py @@ -0,0 +1,109 @@ +import os +import sys +import time +import logging +import argparse +import hashlib + +import sky +import fetch_from + + +NPM_BASEURL = "http://npm.yandex-team.ru/" + + +def parse_args(): + parser = argparse.ArgumentParser() + fetch_from.add_common_arguments(parser) + + parser.add_argument("--name", required=True) + parser.add_argument("--version", required=True) + parser.add_argument("--sky-id", required=True) + parser.add_argument("--integrity", required=True) + parser.add_argument("--integrity-algorithm", required=True) + + return parser.parse_args() + + +def fetch(name, version, sky_id, integrity, integrity_algorithm, file_name, tries=5): + """ + :param name: package name + :type name: str + :param version: package version + :type version: str + :param sky_id: sky id of tarball + :type sky_id: str + :param integrity: tarball integrity (hex) + :type integrity: str + :param integrity_algorithm: integrity algorithm (known for openssl) + :type integrity_algorithm: str + :param tries: tries count + :type tries: int + :return: path to fetched file + :rtype: str + """ + # if sky.is_avaliable() and 'NOTS_FETCH_FROM_HTTP_ONLY' not in os.environ: + # fetcher = lambda: sky.fetch(sky_id, file_name) + # else: + # Отключаем походы через скай + # TODO: https://st.yandex-team.ru/FBP-351 + if 'NOTS_FETCH_FROM_SKY' in os.environ and sky.is_avaliable(): + fetcher = lambda: sky.fetch(sky_id, file_name) + else: + fetcher = lambda: _fetch_via_http(name, version, integrity, integrity_algorithm, file_name) + + fetched_file = None + exc_info = None + + for i in range(0, tries): + try: + fetched_file = fetcher() + exc_info = None + break + except Exception as e: + logging.exception(e) + exc_info = exc_info or sys.exc_info() + time.sleep(i) + + if exc_info: + raise exc_info[0], exc_info[1], exc_info[2] + + return fetched_file + + +def _fetch_via_http(name, version, integrity, integrity_algorithm, file_name): + # Example: "http://npm.yandex-team.ru/@scope/name/-/name-0.0.1.tgz" for @scope/name v0.0.1. + url = NPM_BASEURL + "/".join([name, "-", "{}-{}.tgz".format(name.split("/").pop(), version)]) + + hashobj = hashlib.new(integrity_algorithm) + fetched_file = fetch_from.fetch_url(url, False, file_name, tries=1, writers=[hashobj.update]) + + if hashobj.hexdigest() != integrity: + raise fetch_from.BadChecksumFetchError("Expected {}, but got {} for {}".format( + integrity, + hashobj.hexdigest(), + file_name, + )) + + return fetched_file + + +def main(args): + file_name = os.path.basename(args.copy_to) + fetched_file = fetch(args.name, args.version, args.sky_id, args.integrity, args.integrity_algorithm, file_name) + fetch_from.process(fetched_file, file_name, args) + + +if __name__ == "__main__": + args = parse_args() + fetch_from.setup_logging(args, os.path.basename(__file__)) + + try: + main(args) + except Exception as e: + logging.exception(e) + print >>sys.stderr, open(args.abs_log_path).read() + sys.stderr.flush() + + import error + sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1) diff --git a/build/scripts/fetch_from_sandbox.py b/build/scripts/fetch_from_sandbox.py new file mode 100755 index 00000000000..6af180b4b0f --- /dev/null +++ b/build/scripts/fetch_from_sandbox.py @@ -0,0 +1,272 @@ +import itertools +import json +import logging +import argparse +import os +import random +import subprocess +import sys +import time +import urllib2 +import uuid + +import fetch_from + + +ORIGIN_SUFFIX = '?origin=fetch-from-sandbox' +MDS_PREFIX = 'http://storage-int.mds.yandex.net/get-sandbox/' +TEMPORARY_ERROR_CODES = (429, 500, 503, 504) + + +def parse_args(): + parser = argparse.ArgumentParser() + fetch_from.add_common_arguments(parser) + parser.add_argument('--resource-id', type=int, required=True) + parser.add_argument('--custom-fetcher') + parser.add_argument('--resource-file') + return parser.parse_args() + + +class ResourceInfoError(Exception): + pass + + +class UnsupportedProtocolException(Exception): + pass + + +def _sky_path(): + return "/usr/local/bin/sky" + + +def _is_skynet_avaliable(): + if not os.path.exists(_sky_path()): + return False + try: + subprocess.check_output([_sky_path(), "--version"]) + return True + except subprocess.CalledProcessError: + return False + except OSError: + return False + + +def download_by_skynet(resource_info, file_name): + def sky_get(skynet_id, target_dir, timeout=None): + cmd_args = [_sky_path(), 'get', "-N", "Backbone", "--user", "--wait", "--dir", target_dir, skynet_id] + if timeout is not None: + cmd_args += ["--timeout", str(timeout)] + logging.info('Call skynet with args: %s', cmd_args) + stdout = subprocess.check_output(cmd_args).strip() + logging.debug('Skynet call with args %s is finished, result is %s', cmd_args, stdout) + return stdout + + if not _is_skynet_avaliable(): + raise UnsupportedProtocolException("Skynet is not available") + + skynet_id = resource_info.get("skynet_id") + if not skynet_id: + raise ValueError("Resource does not have skynet_id") + + temp_dir = os.path.abspath(fetch_from.uniq_string_generator()) + os.mkdir(temp_dir) + sky_get(skynet_id, temp_dir) + return os.path.join(temp_dir, file_name) + + +def _urlopen(url, data=None, headers=None): + n = 10 + tout = 30 + started = time.time() + reqid = uuid.uuid4() + + request = urllib2.Request(url, data=data, headers=headers or {}) + request.add_header('X-Request-Timeout', str(tout)) + request.add_header('X-Request-Id', str(reqid)) + request.add_header('User-Agent', 'fetch_from_sandbox.py') + for i in xrange(n): + retry_after = i + try: + request.add_header('X-Request-Duration', str(int(time.time() - started))) + return urllib2.urlopen(request, timeout=tout).read() + + except urllib2.HTTPError as e: + logging.warning('failed to fetch URL %s with HTTP code %d: %s', url, e.code, e) + retry_after = int(e.headers.get('Retry-After', str(retry_after))) + + if e.code not in TEMPORARY_ERROR_CODES: + raise + + except Exception as e: + logging.warning('failed to fetch URL %s: %s', url, e) + + if i + 1 == n: + raise e + + time.sleep(retry_after) + + +def _query(url): + return json.loads(_urlopen(url)) + + +_SANDBOX_BASE_URL = 'https://sandbox.yandex-team.ru/api/v1.0' + + +def get_resource_info(resource_id, touch=False, no_links=False): + url = ''.join((_SANDBOX_BASE_URL, '/resource/', str(resource_id))) + headers = {} + if touch: + headers.update({'X-Touch-Resource': '1'}) + if no_links: + headers.update({'X-No-Links': '1'}) + return _query(url) + + +def get_resource_http_links(resource_id): + url = ''.join((_SANDBOX_BASE_URL, '/resource/', str(resource_id), '/data/http')) + return [r['url'] + ORIGIN_SUFFIX for r in _query(url)] + + +def fetch_via_script(script, resource_id): + return subprocess.check_output([script, str(resource_id)]).rstrip() + + +def fetch(resource_id, custom_fetcher): + try: + resource_info = get_resource_info(resource_id, touch=True, no_links=True) + except Exception as e: + sys.stderr.write( + "Failed to fetch resource {}: {}\n".format(resource_id, str(e)) + ) + raise + + if resource_info.get('state', 'DELETED') != 'READY': + raise ResourceInfoError("Resource {} is not READY".format(resource_id)) + + logging.info('Resource %s info %s', str(resource_id), json.dumps(resource_info)) + + is_multifile = resource_info.get('multifile', False) + resource_file_name = os.path.basename(resource_info["file_name"]) + expected_md5 = resource_info.get('md5') + + proxy_link = resource_info['http']['proxy'] + ORIGIN_SUFFIX + if is_multifile: + proxy_link += '&stream=tgz' + + mds_id = resource_info.get('attributes', {}).get('mds') + mds_link = MDS_PREFIX + mds_id if mds_id else None + + def get_storage_links(): + storage_links = get_resource_http_links(resource_id) + random.shuffle(storage_links) + return storage_links + + skynet = _is_skynet_avaliable() + + if not skynet: + logging.info("Skynet is not available, will try other protocols") + + def iter_tries(): + if skynet: + yield lambda: download_by_skynet(resource_info, resource_file_name) + + if custom_fetcher: + yield lambda: fetch_via_script(custom_fetcher, resource_id) + + # Don't try too hard here: we will get back to proxy later on + yield lambda: fetch_from.fetch_url(proxy_link, False, resource_file_name, expected_md5, tries=2) + for x in get_storage_links(): + # Don't spend too much time connecting single host + yield lambda: fetch_from.fetch_url(x, False, resource_file_name, expected_md5, tries=1) + if mds_link is not None: + # Don't try too hard here: we will get back to MDS later on + yield lambda: fetch_from.fetch_url(mds_link, True, resource_file_name, expected_md5, tries=2) + yield lambda: fetch_from.fetch_url(proxy_link, False, resource_file_name, expected_md5) + if mds_link is not None: + yield lambda: fetch_from.fetch_url(mds_link, True, resource_file_name, expected_md5) + + if resource_info.get('attributes', {}).get('ttl') != 'inf': + sys.stderr.write('WARNING: resource {} ttl is not "inf".\n'.format(resource_id)) + + exc_info = None + for i, action in enumerate(itertools.islice(iter_tries(), 0, 10)): + try: + fetched_file = action() + break + except UnsupportedProtocolException: + pass + except subprocess.CalledProcessError as e: + logging.warning('failed to fetch resource %s with subprocess: %s', resource_id, e) + time.sleep(i) + except urllib2.HTTPError as e: + logging.warning('failed to fetch resource %s with HTTP code %d: %s', resource_id, e.code, e) + if e.code not in TEMPORARY_ERROR_CODES: + exc_info = exc_info or sys.exc_info() + time.sleep(i) + except Exception as e: + logging.exception(e) + exc_info = exc_info or sys.exc_info() + time.sleep(i) + else: + if exc_info: + raise exc_info[0], exc_info[1], exc_info[2] + else: + raise Exception("No available protocol and/or server to fetch resource") + + return fetched_file, resource_info['file_name'] + + +def _get_resource_info_from_file(resource_file): + if resource_file is None or not os.path.exists(resource_file): + return None + + RESOURCE_INFO_JSON = "resource_info.json" + RESOURCE_CONTENT_FILE_NAME = "resource" + + resource_dir, resource_file = os.path.split(resource_file) + if resource_file != RESOURCE_CONTENT_FILE_NAME: + return None + + resource_json = os.path.join(resource_dir, RESOURCE_INFO_JSON) + if not os.path.isfile(resource_json): + return None + + try: + with open(resource_json, 'r') as j: + resource_info = json.load(j) + resource_info['file_name'] # check consistency + return resource_info + except: + logging.debug('Invalid %s in %s', RESOURCE_INFO_JSON, resource_dir) + + return None + + +def main(args): + custom_fetcher = os.environ.get('YA_CUSTOM_FETCHER') + + resource_info = _get_resource_info_from_file(args.resource_file) + if resource_info: + fetched_file = args.resource_file + file_name = resource_info['file_name'] + else: + # This code should be merged to ya and removed. + fetched_file, file_name = fetch(args.resource_id, custom_fetcher) + + fetch_from.process(fetched_file, file_name, args, remove=not custom_fetcher and not resource_info) + + +if __name__ == '__main__': + args = parse_args() + fetch_from.setup_logging(args, os.path.basename(__file__)) + + try: + main(args) + except Exception as e: + logging.exception(e) + print >>sys.stderr, open(args.abs_log_path).read() + sys.stderr.flush() + + import error + sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1) diff --git a/build/scripts/fetch_resource.py b/build/scripts/fetch_resource.py new file mode 100644 index 00000000000..d5af311e5d8 --- /dev/null +++ b/build/scripts/fetch_resource.py @@ -0,0 +1,43 @@ +import urllib2 +import argparse +import xmlrpclib + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('-r', '--resource-id', type=int, required=True) + parser.add_argument('-o', '--output', required=True) + return parser.parse_args() + + +def fetch(url, retries=4, timeout=5): + for i in xrange(retries): + try: + return urllib2.urlopen(url, timeout=timeout).read() + + except Exception: + if i + 1 < retries: + continue + + else: + raise + + +def fetch_resource(id_): + urls = xmlrpclib.ServerProxy("https://sandbox.yandex-team.ru/sandbox/xmlrpc").get_resource_http_links(id_) + + for u in urls: + try: + return fetch(u) + + except Exception: + continue + + raise Exception('Cannot fetch resource {}'.format(id_)) + + +if __name__ == '__main__': + args = parse_args() + + with open(args.output, 'wb') as f: + f.write(fetch_resource(int(args.resource_id))) diff --git a/build/scripts/filter_zip.py b/build/scripts/filter_zip.py new file mode 100644 index 00000000000..b2121b9c9ed --- /dev/null +++ b/build/scripts/filter_zip.py @@ -0,0 +1,71 @@ +import argparse +import os +import re +import uuid +import zipfile + + +def pattern_to_regexp(p): + return re.compile( + '^' + + re.escape(p) + .replace(r'\*\*\/', '[_DIR_]') + .replace(r'\*', '[_FILE_]') + .replace('[_DIR_]', '(.*/)?') + .replace('[_FILE_]', '([^/]*)') + + '$' + ) + + +def is_deathman(positive_filter, negative_filter, candidate): + remove = positive_filter + for pf in positive_filter: + if pf.match(candidate): + remove = False + break + if not negative_filter or remove: + return remove + for nf in negative_filter: + if nf.match(candidate): + remove = True + break + return remove + + +def just_do_it(): + parser = argparse.ArgumentParser() + parser.add_argument('--positive', action='append', default=[]) + parser.add_argument('--negative', action='append', default=[]) + parser.add_argument('--file', action='store', required=True) + args = parser.parse_args() + if not args.positive and not args.negative: + return + pos = [pattern_to_regexp(i) for i in args.positive] + neg = [pattern_to_regexp(i) for i in args.negative] + temp_dirname = None + for _ in range(10): + candidate = '__unpacked_{}__'.format(uuid.uuid4()) + if not os.path.exists(candidate): + temp_dirname = candidate + os.makedirs(temp_dirname) + if not temp_dirname: + raise Exception("Can't generate name for temp dir") + + with zipfile.ZipFile(args.file, 'r') as zip_ref: + zip_ref.extractall(temp_dirname) + + for root, _, files in os.walk(temp_dirname): + for f in files: + candidate = os.path.join(root, f).replace('\\', '/') + if is_deathman(pos, neg, os.path.relpath(candidate, temp_dirname)): + os.remove(candidate) + + with zipfile.ZipFile(args.file, 'w') as zip_ref: + for root, _, files in os.walk(temp_dirname): + for f in files: + realname = os.path.join(root, f) + zip_ref.write(realname, os.path.sep.join(os.path.normpath(realname).split(os.path.sep, 2)[1:])) + + +if __name__ == '__main__': + just_do_it() diff --git a/build/scripts/find_and_tar.py b/build/scripts/find_and_tar.py new file mode 100644 index 00000000000..f251623c68c --- /dev/null +++ b/build/scripts/find_and_tar.py @@ -0,0 +1,22 @@ +import os +import sys +import tarfile + + +def find_gcno(dirname, tail): + for cur, _dirs, files in os.walk(dirname): + for f in files: + if f.endswith(tail): + yield os.path.relpath(os.path.join(cur, f)) + + +def main(args): + output = args[0] + tail = args[1] if len(args) > 1 else '' + with tarfile.open(output, 'w:') as tf: + for f in find_gcno(os.getcwd(), tail): + tf.add(f) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/build/scripts/find_time_trace.py b/build/scripts/find_time_trace.py new file mode 100644 index 00000000000..954d203caaf --- /dev/null +++ b/build/scripts/find_time_trace.py @@ -0,0 +1,17 @@ +import os +import sys + +# /scripts/find_time_trace.py <object_file> <destination> +# clang generates `-ftime-trace` output file path based on main output file path + + +def main(): + assert len(sys.argv) == 3 + obj_path = sys.argv[1] + trace_path = sys.argv[2] + orig_trace_path = obj_path.rpartition('.o')[0] + '.json' + os.rename(orig_trace_path, trace_path) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/fix_java_command_file_cp.py b/build/scripts/fix_java_command_file_cp.py new file mode 100644 index 00000000000..fc87048c327 --- /dev/null +++ b/build/scripts/fix_java_command_file_cp.py @@ -0,0 +1,34 @@ +import sys +import os +import argparse +import subprocess +import platform + + +def fix_files(args): + args = args[:] + parser = argparse.ArgumentParser() + parser.add_argument('--build-root', default=None) + args, tail = parser.parse_known_args(args) + for idx, arg in list(enumerate(tail)): + if arg.startswith('@') and os.path.isfile(arg[1:]): + with open(arg[1:]) as f: + fixed = [i.strip() for i in f] + if args.build_root: + fixed = [os.path.join(args.build_root, i) for ln in fixed for i in ln.split(os.path.pathsep)] + fixed = os.pathsep.join([i.strip() for i in fixed]) + fixed_name = list(os.path.splitext(arg)) + fixed_name[0] += '_fixed' + fixed_name = ''.join(fixed_name) + with open(fixed_name[1:], 'w') as f: + f.write(fixed) + tail[idx:idx + 1] = [fixed_name] + return tail + + +if __name__ == '__main__': + args = fix_files(sys.argv[1:]) + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(args).wait()) + else: + os.execv(args[0], args) diff --git a/build/scripts/fix_msvc_output.py b/build/scripts/fix_msvc_output.py new file mode 100644 index 00000000000..183a442e1fc --- /dev/null +++ b/build/scripts/fix_msvc_output.py @@ -0,0 +1,43 @@ +import subprocess +import sys + +import process_command_files as pcf +import process_whole_archive_option as pwa + + +def out2err(cmd): + return subprocess.Popen(cmd, stdout=sys.stderr).wait() + + +def decoding_needed(strval): + if sys.version_info >= (3, 0, 0): + return isinstance(strval, bytes) + else: + return False + + +def out2err_cut_first_line(cmd): + p = subprocess.Popen(cmd, stdout=subprocess.PIPE) + first_line = True + while True: + line = p.stdout.readline() + line = line.decode('utf-8') if decoding_needed(line) else line + if not line: + break + if first_line: + sys.stdout.write(line) + first_line = False + else: + sys.stderr.write(line) + return p.wait() + + +if __name__ == '__main__': + mode = sys.argv[1] + args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(sys.argv[2:])) + cmd = pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(args) + run = out2err + if mode in ('cl', 'ml'): + # First line of cl.exe and ml64.exe stdout is useless: it prints input file + run = out2err_cut_first_line + sys.exit(run(cmd)) diff --git a/build/scripts/fs_tools.py b/build/scripts/fs_tools.py new file mode 100644 index 00000000000..63ca00932e2 --- /dev/null +++ b/build/scripts/fs_tools.py @@ -0,0 +1,117 @@ +from __future__ import print_function + +import os +import platform +import sys +import shutil +import errno + +import process_command_files as pcf + + +def link_or_copy(src, dst, trace={}): + if dst not in trace: + trace[dst] = src + + try: + if platform.system().lower() == 'windows': + shutil.copy(src, dst) + else: + os.link(src, dst) + except OSError as e: + if e.errno == errno.EEXIST: + if dst in trace: + print( + '[[bad]]link_or_copy: copy collision found - tried to copy {} to {} which was copied earlier from {}[[rst]]'.format( + src, dst, trace[dst] + ), + file=sys.stderr, + ) + else: + print('[[bad]]link_or_copy: destination file already exists: {}[[rst]]'.format(dst), file=sys.stderr) + if e.errno == errno.ENOENT: + print('[[bad]]link_or_copy: source file doesn\'t exists: {}[[rst]]'.format(src), file=sys.stderr) + raise + + +if __name__ == '__main__': + mode = sys.argv[1] + args = pcf.get_args(sys.argv[2:]) + + if mode == 'copy': + shutil.copy(args[0], args[1]) + elif mode == 'copy_tree_no_link': + dst = args[1] + shutil.copytree( + args[0], dst, ignore=lambda dirname, names: [n for n in names if os.path.islink(os.path.join(dirname, n))] + ) + elif mode == 'copy_files': + src = args[0] + dst = args[1] + files = open(args[2]).read().strip().split() + for f in files: + s = os.path.join(src, f) + d = os.path.join(dst, f) + if os.path.exists(d): + continue + try: + os.makedirs(os.path.dirname(d)) + except OSError: + pass + shutil.copy(s, d) + elif mode == 'copy_all_files': + src = args[0] + dst = args[1] + for root, _, files in os.walk(src): + for f in files: + if os.path.islink(os.path.join(root, f)): + continue + file_dst = os.path.join(dst, os.path.relpath(root, src), f) + if os.path.exists(file_dst): + continue + try: + os.makedirs(os.path.dirname(file_dst)) + except OSError: + pass + shutil.copy(os.path.join(root, f), file_dst) + elif mode == 'rename_if_exists': + if os.path.exists(args[0]): + shutil.move(args[0], args[1]) + elif mode == 'rename': + targetdir = os.path.dirname(args[1]) + if targetdir and not os.path.exists(targetdir): + os.makedirs(os.path.dirname(args[1])) + shutil.move(args[0], args[1]) + elif mode == 'remove': + for f in args: + try: + if os.path.isfile(f) or os.path.islink(f): + os.remove(f) + else: + shutil.rmtree(f) + except OSError: + pass + elif mode == 'link_or_copy': + link_or_copy(args[0], args[1]) + elif mode == 'link_or_copy_to_dir': + assert len(args) > 1 + start = 0 + if args[0] == '--no-check': + if args == 2: + sys.exit() + start = 1 + dst = args[-1] + for src in args[start:-1]: + link_or_copy(src, os.path.join(dst, os.path.basename(src))) + elif mode == 'cat': + with open(args[0], 'w') as dst: + for input_name in args[1:]: + with open(input_name) as src: + dst.write(src.read()) + elif mode == 'md': + try: + os.makedirs(args[0]) + except OSError: + pass + else: + raise Exception('unsupported tool %s' % mode) diff --git a/build/scripts/gen_aar_gradle_script.py b/build/scripts/gen_aar_gradle_script.py new file mode 100644 index 00000000000..67c3ac2ef3b --- /dev/null +++ b/build/scripts/gen_aar_gradle_script.py @@ -0,0 +1,284 @@ +import argparse +import os +import tarfile + +FLAT_DIRS_REPO_TEMPLATE='flatDir {{ dirs {dirs} }}\n' +MAVEN_REPO_TEMPLATE='maven {{ url "{repo}" }}\n' +KEYSTORE_TEMLATE='signingConfigs {{ debug {{ storeFile file("{keystore}") }} }}\n' + +DO_NOT_STRIP = '''\ + packagingOptions { + doNotStrip "*/arm64-v8a/*.so" + doNotStrip "*/armeabi-v7a/*.so" + doNotStrip "*/x86_64/*.so" + doNotStrip "*/x86/*.so" + } +''' + +AAR_TEMPLATE = """\ +ext.jniLibsDirs = [ + {jni_libs_dirs} +] + +ext.resDirs = [ + {res_dirs} +] + +ext.assetsDirs = [ + {assets_dirs} +] + +ext.javaDirs = [ + {java_dirs} +] + +def aidlDirs = [ + {aidl_dirs} +] + +ext.bundles = [ + {bundles} +] + +ext.androidArs = [ + {aars} +] + +ext.compileOnlyAndroidArs = [ + {compile_only_aars} +] + +def minVersion = 21 +def compileVersion = 30 +def targetVersion = 30 +def buildVersion = '30.0.3' + +import com.android.build.gradle.LibraryPlugin +import java.nio.file.Files +import java.nio.file.Paths +import java.util.regex.Matcher +import java.util.regex.Pattern +import java.util.zip.ZipFile + + +apply plugin: 'com.github.dcendents.android-maven' + +buildDir = "$projectDir/build" + +if (!ext.has("packageSuffix")) + ext.packageSuffix = "" + +buildscript {{ +// repositories {{ +// jcenter() +// mavenCentral() +// }} + + repositories {{ + {maven_repos} + }} + + dependencies {{ + classpath 'com.android.tools.build:gradle:4.0.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + }} +}} + +apply plugin: LibraryPlugin + +repositories {{ +// flatDir {{ +// dirs System.env.PKG_ROOT + '/bundle' +// }} +// maven {{ +// url "http://maven.google.com/" +// }} +// maven {{ +// url "http://artifactory.yandex.net/artifactory/public/" +// }} + + {flat_dirs_repo} + + {maven_repos} +}} + +android {{ + {keystore} + + compileSdkVersion compileVersion + buildToolsVersion buildVersion + + defaultConfig {{ + minSdkVersion minVersion + targetSdkVersion targetVersion + consumerProguardFiles '{proguard_rules}' + }} + + sourceSets {{ + main {{ + manifest.srcFile '{manifest}' + jniLibs.srcDirs = jniLibsDirs + res.srcDirs = resDirs + assets.srcDirs = assetsDirs + java.srcDirs = javaDirs + aidl.srcDirs = aidlDirs + }} + // We don't use this feature, so we set it to nonexisting directory + androidTest.setRoot('bundle/tests') + }} + + {do_not_strip} + + dependencies {{ + for (bundle in bundles) + compile("$bundle") {{ + transitive = true + }} + for (bundle in androidArs) + compile(bundle) {{ + transitive = true + }} + for (bundle in compileOnlyAndroidArs) + compileOnly(bundle) + }} + + android.libraryVariants.all {{ variant -> + def suffix = variant.buildType.name.capitalize() + + def sourcesJarTask = project.tasks.create(name: "sourcesJar${{suffix}}", type: Jar) {{ + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + include '**/*.java' + eachFile {{ fcd -> + def segments = fcd.relativePath.segments + if (segments[0] == 'impl') {{ + fcd.relativePath = new RelativePath(true, segments.drop(1)) + }} + }} + includeEmptyDirs = false + }} + + def manifestFile = android.sourceSets.main.manifest.srcFile + def manifestXml = new XmlParser().parse(manifestFile) + + def packageName = manifestXml['@package'] + def groupName = packageName.tokenize('.')[0..-2].join('.') + + def androidNs = new groovy.xml.Namespace("http://schemas.android.com/apk/res/android") + def packageVersion = manifestXml.attributes()[androidNs.versionName] + + def writePomTask = project.tasks.create(name: "writePom${{suffix}}") {{ + pom {{ + project {{ + groupId groupName + version packageVersion + packaging 'aar' + }} + }}.writeTo("$buildDir/${{rootProject.name}}$packageSuffix-pom.xml") + }} + + tasks["bundle${{suffix}}Aar"].dependsOn sourcesJarTask + tasks["bundle${{suffix}}Aar"].dependsOn writePomTask + }} +}} + +""" + + +def gen_build_script(args): + + def wrap(items): + return ',\n '.join('"{}"'.format(x) for x in items) + + bundles = [] + bundles_dirs = set(args.flat_repos) + for bundle in args.bundles: + dir_name, base_name = os.path.split(bundle) + assert(len(dir_name) > 0 and len(base_name) > 0) + name, ext = os.path.splitext(base_name) + assert(len(name) > 0 and ext == '.aar') + bundles_dirs.add(dir_name) + bundles.append('com.yandex:{}@aar'.format(name)) + + if len(bundles_dirs) > 0: + flat_dirs_repo = FLAT_DIRS_REPO_TEMPLATE.format(dirs=wrap(bundles_dirs)) + else: + flat_dirs_repo = '' + + maven_repos = ''.join(MAVEN_REPO_TEMPLATE.format(repo=repo) for repo in args.maven_repos) + + if args.keystore: + keystore = KEYSTORE_TEMLATE.format(keystore=args.keystore) + else: + keystore = '' + + if args.do_not_strip: + do_not_strip = DO_NOT_STRIP + else: + do_not_strip = '' + + return AAR_TEMPLATE.format( + aars=wrap(args.aars), + compile_only_aars=wrap(args.compile_only_aars), + aidl_dirs=wrap(args.aidl_dirs), + assets_dirs=wrap(args.assets_dirs), + bundles=wrap(bundles), + do_not_strip=do_not_strip, + flat_dirs_repo=flat_dirs_repo, + java_dirs=wrap(args.java_dirs), + jni_libs_dirs=wrap(args.jni_libs_dirs), + keystore=keystore, + manifest=args.manifest, + maven_repos=maven_repos, + proguard_rules=args.proguard_rules, + res_dirs=wrap(args.res_dirs), + ) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--aars', nargs='*', default=[]) + parser.add_argument('--compile-only-aars', nargs='*', default=[]) + parser.add_argument('--aidl-dirs', nargs='*', default=[]) + parser.add_argument('--assets-dirs', nargs='*', default=[]) + parser.add_argument('--bundle-name', nargs='?', default='default-bundle-name') + parser.add_argument('--bundles', nargs='*', default=[]) + parser.add_argument('--do-not-strip', action='store_true') + parser.add_argument('--flat-repos', nargs='*', default=[]) + parser.add_argument('--java-dirs', nargs='*', default=[]) + parser.add_argument('--jni-libs-dirs', nargs='*', default=[]) + parser.add_argument('--keystore', default=None) + parser.add_argument('--manifest', required=True) + parser.add_argument('--maven-repos', nargs='*', default=[]) + parser.add_argument('--output-dir', required=True) + parser.add_argument('--peers', nargs='*', default=[]) + parser.add_argument('--proguard-rules', nargs='?', default=None) + parser.add_argument('--res-dirs', nargs='*', default=[]) + args = parser.parse_args() + + if args.proguard_rules is None: + args.proguard_rules = os.path.join(args.output_dir, 'proguard-rules.txt') + with open(args.proguard_rules, 'w') as f: + pass + + for index, jsrc in enumerate(filter(lambda x: x.endswith('.jsrc'), args.peers)): + jsrc_dir = os.path.join(args.output_dir, 'jsrc_{}'.format(str(index))) + os.makedirs(jsrc_dir) + with tarfile.open(jsrc, 'r') as tar: + tar.extractall(path=jsrc_dir) + args.java_dirs.append(jsrc_dir) + + args.build_gradle = os.path.join(args.output_dir, 'build.gradle') + args.settings_gradle = os.path.join(args.output_dir, 'settings.gradle') + args.gradle_properties = os.path.join(args.output_dir, 'gradle.properties') + + content = gen_build_script(args) + with open(args.build_gradle, 'w') as f: + f.write(content) + + with open(args.gradle_properties, 'w') as f: + f.write('android.useAndroidX=true') + + if args.bundle_name: + with open(args.settings_gradle, 'w') as f: + f.write('rootProject.name = "{}"'.format(args.bundle_name)) diff --git a/build/scripts/gen_java_codenav_entry.py b/build/scripts/gen_java_codenav_entry.py new file mode 100644 index 00000000000..ff0a5c737d6 --- /dev/null +++ b/build/scripts/gen_java_codenav_entry.py @@ -0,0 +1,57 @@ +import argparse +import datetime +import os +import subprocess +import sys +import tarfile + + +def extract_kindexes(kindexes): + for kindex in kindexes: + with tarfile.TarFile(kindex) as tf: + for fname in [i for i in tf.getnames() if i.endswith('.kzip')]: + tf.extract(fname) + yield fname + + +def just_do_it(java, kythe, kythe_to_proto, out_name, binding_only, kindexes): + temp_out_name = out_name + '.temp' + kindex_inputs = list(extract_kindexes(kindexes)) + open(temp_out_name, 'w').close() + start = datetime.datetime.now() + for kindex in kindex_inputs: + print >> sys.stderr, '[INFO] Processing:', kindex + indexer_start = datetime.datetime.now() + p = subprocess.Popen([java, '-jar', os.path.join(kythe, 'indexers/java_indexer.jar'), kindex], stdout=subprocess.PIPE) + indexer_out, _ = p.communicate() + print >> sys.stderr, '[INFO] Indexer execution time:', (datetime.datetime.now() - indexer_start).total_seconds(), 'seconds' + if p.returncode: + raise Exception('java_indexer failed with exit code {}'.format(p.returncode)) + dedup_start = datetime.datetime.now() + p = subprocess.Popen([os.path.join(kythe, 'tools/dedup_stream')], stdin=subprocess.PIPE, stdout=subprocess.PIPE) + dedup_out, _ = p.communicate(indexer_out) + print >> sys.stderr, '[INFO] Dedup execution time:', (datetime.datetime.now() - dedup_start).total_seconds(), 'seconds' + if p.returncode: + raise Exception('dedup_stream failed with exit code {}'.format(p.returncode)) + entrystream_start = datetime.datetime.now() + p = subprocess.Popen([os.path.join(kythe, 'tools/entrystream'), '--write_json'], stdin=subprocess.PIPE, stdout=open(temp_out_name, 'a')) + p.communicate(dedup_out) + if p.returncode: + raise Exception('entrystream failed with exit code {}'.format(p.returncode)) + print >> sys.stderr, '[INFO] Entrystream execution time:', (datetime.datetime.now() - entrystream_start).total_seconds(), 'seconds' + preprocess_start = datetime.datetime.now() + subprocess.check_call([kythe_to_proto, '--preprocess-entry', '--entries', temp_out_name, '--out', out_name] + (['--only-binding-data'] if binding_only else [])) + print >> sys.stderr, '[INFO] Preprocessing execution time:', (datetime.datetime.now() - preprocess_start).total_seconds(), 'seconds' + print >> sys.stderr, '[INFO] Total execution time:', (datetime.datetime.now() - start).total_seconds(), 'seconds' + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument("--java", help="java path") + parser.add_argument("--kythe", help="kythe path") + parser.add_argument("--kythe-to-proto", help="kythe_to_proto tool path") + parser.add_argument("--out-name", help="entries json out name") + parser.add_argument("--binding-only", action="store_true", default=False, help="filter only binding data") + parser.add_argument("kindexes", nargs='*') + args = parser.parse_args() + just_do_it(args.java, args.kythe, args.kythe_to_proto, args.out_name, args.binding_only, args.kindexes) diff --git a/build/scripts/gen_java_codenav_protobuf.py b/build/scripts/gen_java_codenav_protobuf.py new file mode 100644 index 00000000000..aee8cfe6c3a --- /dev/null +++ b/build/scripts/gen_java_codenav_protobuf.py @@ -0,0 +1,22 @@ +import argparse +import os + + +def just_do_it(kythe_to_proto, entries, out_name, build_file, source_root): + with open(build_file) as f: + classpath = os.pathsep.join([line.strip() for line in f]) + os.execv( + kythe_to_proto, + [kythe_to_proto, '--sources-rel-root', 'fake_arcadia_root', '--entries', entries, '--out', out_name, '--classpath', classpath, '--arcadia-root', source_root] + ) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument("--kythe-to-proto", help="kythe_to_proto tool path") + parser.add_argument("--entries", help="entries json path") + parser.add_argument("--out-name", help="protbuf out name") + parser.add_argument("--build-file", help="build file( containing classpath )") + parser.add_argument("--source-root", help="source root") + args = parser.parse_args() + just_do_it(args.kythe_to_proto, args.entries, args.out_name, args.build_file, args.source_root) diff --git a/build/scripts/gen_mx_table.py b/build/scripts/gen_mx_table.py new file mode 100644 index 00000000000..187c21c539f --- /dev/null +++ b/build/scripts/gen_mx_table.py @@ -0,0 +1,75 @@ +import sys + +tmpl = """ +#include "yabs_mx_calc_table.h" + +#include <kernel/matrixnet/mn_sse.h> + +#include <library/cpp/archive/yarchive.h> + +#include <util/memory/blob.h> +#include <util/generic/hash.h> +#include <util/generic/ptr.h> +#include <util/generic/singleton.h> + +using namespace NMatrixnet; + +extern "C" { + extern const unsigned char MxFormulas[]; + extern const ui32 MxFormulasSize; +} + +namespace { + struct TFml: public TBlob, public TMnSseInfo { + inline TFml(const TBlob& b) + : TBlob(b) + , TMnSseInfo(Data(), Size()) + { + } + }; + + struct TFormulas: public THashMap<size_t, TAutoPtr<TFml>> { + inline TFormulas() { + TBlob b = TBlob::NoCopy(MxFormulas, MxFormulasSize); + TArchiveReader ar(b); + %s + } + + inline const TMnSseInfo& at(size_t n) const noexcept { + return *find(n)->second; + } + }; + + %s + + static func_descr_t yabs_funcs[] = { + %s + }; +} + +yabs_mx_calc_table_t yabs_mx_calc_table = {YABS_MX_CALC_VERSION, 10000, 0, yabs_funcs}; +""" + +if __name__ == '__main__': + init = [] + body = [] + defs = {} + + for i in sys.argv[1:]: + name = i.replace('.', '_') + num = long(name.split('_')[1]) + + init.append('(*this)[%s] = new TFml(ar.ObjectBlobByKey("%s"));' % (num, '/' + i)) + + f1 = 'static void yabs_%s(size_t count, const float** args, double* res) {Singleton<TFormulas>()->at(%s).DoCalcRelevs(args, res, count);}' % (name, num) + f2 = 'static size_t yabs_%s_factor_count() {return Singleton<TFormulas>()->at(%s).MaxFactorIndex() + 1;}' % (name, num) + + body.append(f1) + body.append(f2) + + d1 = 'yabs_%s' % name + d2 = 'yabs_%s_factor_count' % name + + defs[num] = '{%s, %s}' % (d1, d2) + + print tmpl % ('\n'.join(init), '\n\n'.join(body), ',\n'.join((defs.get(i, '{nullptr, nullptr}') for i in range(0, 10000)))) diff --git a/build/scripts/gen_py3_reg.py b/build/scripts/gen_py3_reg.py new file mode 100644 index 00000000000..149c0948980 --- /dev/null +++ b/build/scripts/gen_py3_reg.py @@ -0,0 +1,34 @@ +import sys + +template = ''' +struct PyObject; +extern "C" int PyImport_AppendInittab(const char* name, PyObject* (*initfunc)()); +extern "C" PyObject* {1}(); + +namespace { + struct TRegistrar { + inline TRegistrar() { + // TODO Collect all modules and call PyImport_ExtendInittab once + PyImport_AppendInittab("{0}", {1}); + } + } REG; +} +''' + + +def mangle(name): + if '.' not in name: + return name + return ''.join('{}{}'.format(len(s), s) for s in name.split('.')) + +if __name__ == '__main__': + if len(sys.argv) != 3: + print >>sys.stderr, 'Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>' + print >>sys.stderr, 'Passed: ' + ' '.join(sys.argv) + sys.exit(1) + + with open(sys.argv[2], 'w') as f: + modname = sys.argv[1] + initname = 'PyInit_' + mangle(modname) + code = template.replace('{0}', modname).replace('{1}', initname) + f.write(code) diff --git a/build/scripts/gen_py_protos.py b/build/scripts/gen_py_protos.py new file mode 100644 index 00000000000..08397472f9d --- /dev/null +++ b/build/scripts/gen_py_protos.py @@ -0,0 +1,67 @@ +import os +from os import path +import shutil +import subprocess +import sys +import tempfile +import argparse +import re + + +OUT_DIR_ARG = '--python_out=' + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--suffixes", nargs="*", default=[]) + parser.add_argument("protoc_args", nargs=argparse.REMAINDER) + script_args = parser.parse_args() + + args = script_args.protoc_args + + if args[0] == "--": + args = args[1:] + + out_dir_orig = None + out_dir_temp = None + plugin_out_dirs_orig = {} + for i in range(len(args)): + if args[i].startswith(OUT_DIR_ARG): + assert not out_dir_orig, 'Duplicate "{0}" param'.format(OUT_DIR_ARG) + out_dir_orig = args[i][len(OUT_DIR_ARG):] + out_dir_temp = tempfile.mkdtemp(dir=out_dir_orig) + args[i] = OUT_DIR_ARG + out_dir_temp + continue + + match = re.match(r"^(--(\w+)_out=).*", args[i]) + if match: + plugin_out_dir_arg = match.group(1) + plugin = match.group(2) + assert plugin not in plugin_out_dirs_orig, 'Duplicate "{0}" param'.format(plugin_out_dir_arg) + plugin_out_dirs_orig[plugin] = args[i][len(plugin_out_dir_arg):] + assert plugin_out_dirs_orig[plugin] == out_dir_orig, 'Params "{0}" and "{1}" expected to have the same value'.format(OUT_DIR_ARG, plugin_out_dir_arg) + args[i] = plugin_out_dir_arg + out_dir_temp + + assert out_dir_temp, 'Param "{0}" not found'.format(OUT_DIR_ARG) + + retcode = subprocess.call(args) + assert not retcode, 'Protoc failed for command {}'.format(' '.join(args)) + + for root_temp, dirs, files in os.walk(out_dir_temp): + sub_dir = path.relpath(root_temp, out_dir_temp) + root_orig = path.join(out_dir_orig, sub_dir) + for d in dirs: + d_orig = path.join(root_orig, d) + if not path.exists(d_orig): + os.mkdir(d_orig) + for f in files: + f_orig = f + for suf in script_args.suffixes: + if f.endswith(suf): + f_orig = f[:-len(suf)] + "__int__" + suf + break + os.rename(path.join(root_temp, f), path.join(root_orig, f_orig)) + shutil.rmtree(out_dir_temp) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/gen_py_reg.py b/build/scripts/gen_py_reg.py new file mode 100644 index 00000000000..1560135ae81 --- /dev/null +++ b/build/scripts/gen_py_reg.py @@ -0,0 +1,32 @@ +import sys + +template = ''' +extern "C" void PyImport_AppendInittab(const char* name, void (*fn)(void)); +extern "C" void {1}(); + +namespace { + struct TRegistrar { + inline TRegistrar() { + PyImport_AppendInittab("{0}", {1}); + } + } REG; +} +''' + + +def mangle(name): + if '.' not in name: + return name + return ''.join('{}{}'.format(len(s), s) for s in name.split('.')) + +if __name__ == '__main__': + if len(sys.argv) != 3: + print >>sys.stderr, 'Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>' + print >>sys.stderr, 'Passed: ' + ' '.join(sys.argv) + sys.exit(1) + + with open(sys.argv[2], 'w') as f: + modname = sys.argv[1] + initname = 'init' + mangle(modname) + code = template.replace('{0}', modname).replace('{1}', initname) + f.write(code) diff --git a/build/scripts/gen_swiftc_output_map.py b/build/scripts/gen_swiftc_output_map.py new file mode 100644 index 00000000000..01ce85f2563 --- /dev/null +++ b/build/scripts/gen_swiftc_output_map.py @@ -0,0 +1,15 @@ +import json +import sys + + +def just_do_it(args): + source_root, build_root, out_file, srcs = args[0], args[1], args[2], args[3:] + assert(len(srcs)) + result_obj = {} + for src in srcs: + result_obj[src] = {'object': src.replace(source_root, build_root) + '.o'} + with open(out_file, 'w') as of: + of.write(json.dumps(result_obj)) + +if __name__ == '__main__': + just_do_it(sys.argv[1:]) diff --git a/build/scripts/gen_tasklet_reg.py b/build/scripts/gen_tasklet_reg.py new file mode 100644 index 00000000000..0f7f66ad51e --- /dev/null +++ b/build/scripts/gen_tasklet_reg.py @@ -0,0 +1,51 @@ +import argparse + +TEMPLATE = '''\ +{includes}\ +#include <tasklet/v1/runtime/lib/{language}_wrapper.h> +#include <tasklet/v1/runtime/lib/registry.h> + +static const NTasklet::TRegHelper REG( + "{name}", + new NTasklet::{wrapper} +); +''' + +WRAPPER = { + 'cpp': 'TCppWrapper<{impl}>()', + 'js': 'TJsWrapper("{impl}")', + 'go': 'TGoWrapper("{impl}")', + 'py': 'TPythonWrapper("{impl}")', + 'java': 'TJavaWrapper("{impl}", "{py_wrapper}")', +} + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('name') + parser.add_argument('output') + parser.add_argument('-l', '--lang', choices=WRAPPER, required=True) + parser.add_argument('-i', '--impl', required=True) + parser.add_argument('-w', '--wrapper', required=False) + parser.add_argument('includes', nargs='*') + + return parser.parse_args() + + +if __name__ == '__main__': + args = parse_args() + + includes = ''.join( + '#include <{}>\n'.format(include) + for include in args.includes + ) + + code = TEMPLATE.format( + includes=includes, + language=args.lang, + name=args.name, + wrapper=WRAPPER[args.lang].format(impl=args.impl, py_wrapper=args.wrapper), + ) + + with open(args.output, 'w') as f: + f.write(code) diff --git a/build/scripts/gen_test_apk_gradle_script.py b/build/scripts/gen_test_apk_gradle_script.py new file mode 100644 index 00000000000..b3a4f89e46d --- /dev/null +++ b/build/scripts/gen_test_apk_gradle_script.py @@ -0,0 +1,193 @@ +import argparse +import os +import tarfile +import xml.etree.ElementTree as etree + +FLAT_DIRS_REPO_TEMPLATE='flatDir {{ dirs {dirs} }}\n' +MAVEN_REPO_TEMPLATE='maven {{ url "{repo}" }}\n' +KEYSTORE_TEMLATE='signingConfigs {{ debug {{ storeFile file("{keystore}") }} }}\n' + +TEST_APK_TEMPLATE = """\ +ext.jniLibsDirs = [ + {jni_libs_dirs} +] +ext.resDirs = [ + {res_dirs} +] +ext.javaDirs = [ + {java_dirs} +] +ext.bundles = [ + {bundles} +] + +buildscript {{ +// repositories {{ +// jcenter() +// }} + + repositories {{ + {maven_repos} + }} + + dependencies {{ + classpath 'com.android.tools.build:gradle:3.5.3' + }} +}} + +apply plugin: 'com.android.application' + +repositories {{ +// maven {{ +// url "http://maven.google.com/" +// }} +// maven {{ +// url "http://artifactory.yandex.net/artifactory/public/" +// }} +// flatDir {{ +// dirs System.env.PKG_ROOT + '/bundle' +// }} + + {flat_dirs_repo} + + {maven_repos} +}} + +dependencies {{ + for (bundle in bundles) {{ + compile("$bundle") + }} +}} + +android {{ + {keystore} + + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + + defaultConfig {{ + minSdkVersion 21 + targetSdkVersion 30 + applicationId "{app_id}" + }} + + sourceSets {{ + main {{ + manifest.srcFile 'Manifest.xml' + jniLibs.srcDirs = jniLibsDirs + res.srcDirs = resDirs + java.srcDirs = javaDirs + }} + }} + + applicationVariants.all {{ variant -> + variant.outputs.each {{ output -> + def fileName = "$projectDir/output/{app_id}.apk" + output.outputFileName = new File(output.outputFile.parent, fileName).getName() + }} + }} + + dependencies {{ + implementation 'com.google.android.gms:play-services-location:21.0.1' + implementation 'com.google.android.gms:play-services-gcm:17.0.0' + implementation 'com.evernote:android-job:1.2.6' + implementation 'androidx.annotation:annotation:1.1.0' + implementation 'androidx.core:core:1.1.0' + }} +}} +""" + + +def create_native_properties(output_dir, library_name): + native_properties_file = os.path.join(output_dir, 'native_library_name.xml') + resources = etree.Element('resources') + name = etree.SubElement(resources, 'item', dict(name='native_library_name', type='string')) + name.text = library_name + etree.ElementTree(resources).write(native_properties_file, xml_declaration=True, encoding='utf-8') + + +def gen_build_script(args): + def wrap(items): + return ',\n '.join('"{}"'.format(x) for x in items) + + bundles = [] + bundles_dirs = set(args.flat_repos) + for bundle in args.bundles: + dir_name, base_name = os.path.split(bundle) + assert(len(dir_name) > 0 and len(base_name) > 0) + name, ext = os.path.splitext(base_name) + assert(len(name) > 0 and ext == '.aar') + bundles_dirs.add(dir_name) + bundles.append('com.yandex:{}@aar'.format(name)) + + if len(bundles_dirs) > 0: + flat_dirs_repo = FLAT_DIRS_REPO_TEMPLATE.format(dirs=wrap(bundles_dirs)) + else: + flat_dirs_repo = '' + + maven_repos = ''.join(MAVEN_REPO_TEMPLATE.format(repo=repo) for repo in args.maven_repos) + + if args.keystore: + keystore = KEYSTORE_TEMLATE.format(keystore=args.keystore) + else: + keystore = '' + + return TEST_APK_TEMPLATE.format( + app_id=args.app_id, + jni_libs_dirs=wrap(args.jni_libs_dirs), + res_dirs=wrap(args.res_dirs), + java_dirs=wrap(args.java_dirs), + maven_repos=maven_repos, + bundles=wrap(bundles), + flat_dirs_repo=flat_dirs_repo, + keystore=keystore, + ) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--aars', nargs='*', default=[]) + parser.add_argument('--app-id', required=True) + parser.add_argument('--assets-dirs', nargs='*', default=[]) + parser.add_argument('--bundles', nargs='*', default=[]) + parser.add_argument('--bundle-name', nargs='?', default=None) + parser.add_argument('--java-dirs', nargs='*', default=[]) + parser.add_argument('--jni-libs-dirs', nargs='*', default=[]) + parser.add_argument('--library-name', required=True) + parser.add_argument('--manifest', required=True) + parser.add_argument('--flat-repos', nargs='*', default=[]) + parser.add_argument('--maven-repos', nargs='*', default=[]) + parser.add_argument('--output-dir', required=True) + parser.add_argument('--peers', nargs='*', default=[]) + parser.add_argument('--keystore', default=None) + parser.add_argument('--res-dirs', nargs='*', default=[]) + args = parser.parse_args() + + for index, jsrc in enumerate(filter(lambda x: x.endswith('.jsrc'), args.peers)): + jsrc_dir = os.path.join(args.output_dir, 'jsrc_{}'.format(str(index))) + os.makedirs(jsrc_dir) + with tarfile.open(jsrc, 'r') as tar: + tar.extractall(path=jsrc_dir) + args.java_dirs.append(jsrc_dir) + + args.build_gradle = os.path.join(args.output_dir, 'build.gradle') + args.settings_gradle = os.path.join(args.output_dir, 'settings.gradle') + args.gradle_properties = os.path.join(args.output_dir, 'gradle.properties') + + content = gen_build_script(args) + with open(args.build_gradle, 'w') as f: + f.write(content) + + with open(args.gradle_properties, 'w') as f: + f.write('''android.enableJetifier=true + android.useAndroidX=true + org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=512m''') + + if args.bundle_name: + with open(args.settings_gradle, 'w') as f: + f.write('rootProject.name = "{}"'.format(args.bundle_name)) + + values_dir = os.path.join(args.output_dir, 'res', 'values') + os.makedirs(values_dir) + create_native_properties(values_dir, args.library_name) diff --git a/build/scripts/gen_yql_python_udf.py b/build/scripts/gen_yql_python_udf.py new file mode 100644 index 00000000000..13b58981170 --- /dev/null +++ b/build/scripts/gen_yql_python_udf.py @@ -0,0 +1,55 @@ +import sys + +TEMPLATE=""" +#include <yql/udfs/common/python/python_udf/python_udf.h> + +#include <ydb/library/yql/public/udf/udf_registrator.h> + +#if @WITH_LIBRA@ +#include <yql/udfs/quality/libra/module/module.h> +#endif + +using namespace NKikimr::NUdf; + +#ifdef BUILD_UDF + +#if @WITH_LIBRA@ +LIBRA_MODULE(TLibraModule, "Libra@MODULE_NAME@"); +#endif + +extern "C" UDF_API void Register(IRegistrator& registrator, ui32 flags) { + RegisterYqlPythonUdf(registrator, flags, TStringBuf("@MODULE_NAME@"), TStringBuf("@PACKAGE_NAME@"), EPythonFlavor::@FLAVOR@); +#if @WITH_LIBRA@ + RegisterHelper<TLibraModule>(registrator); +#endif +} + +extern "C" UDF_API ui32 AbiVersion() { + return CurrentAbiVersion(); +} + +extern "C" UDF_API void SetBackTraceCallback(TBackTraceCallback callback) { + SetBackTraceCallbackImpl(callback); +} + +#endif +""" + + +def main(): + assert len(sys.argv) == 6 + flavor, module_name, package_name, path, libra_flag = sys.argv[1:] + with open(path, 'w') as f: + f.write( + TEMPLATE + .strip() + .replace('@MODULE_NAME@', module_name) + .replace('@PACKAGE_NAME@', package_name) + .replace('@FLAVOR@', flavor) + .replace('@WITH_LIBRA@', libra_flag) + ) + f.write('\n') + + +if __name__ == "__main__": + main() diff --git a/build/scripts/generate_mf.py b/build/scripts/generate_mf.py new file mode 100644 index 00000000000..a44a9699801 --- /dev/null +++ b/build/scripts/generate_mf.py @@ -0,0 +1,113 @@ +import json +import logging +import optparse +import os +import sys +import io + +import process_command_files as pcf + +class BadMfError(Exception): + pass + + +class GplNotAllowed(Exception): + pass + + +def process_quotes(s): + for quote_char in '\'"': + if s.startswith(quote_char) and s.endswith(quote_char): + return s[1:-1] + return s + + +def parse_args(): + args = pcf.get_args(sys.argv[1:]) + lics, peers, free_args, credits = [], [], [], [] + current_list = free_args + for a in args: + if a == '-Ya,lics': + current_list = lics + elif a == '-Ya,peers': + current_list = peers + elif a == '-Ya,credits': + current_list = credits + elif a and a.startswith('-'): + current_list = free_args + current_list.append(a) + else: + current_list.append(a) + + parser = optparse.OptionParser() + parser.add_option('--build-root') + parser.add_option('--module-name') + parser.add_option('-o', '--output') + parser.add_option('-c', '--credits-output') + parser.add_option('-t', '--type') + opts, _ = parser.parse_args(free_args) + return lics, peers, credits, opts, + + +def generate_header(meta): + return '-' * 20 + meta.get('path', 'Unknown module') + '-' * 20 + + +def generate_mf(): + lics, peers, credits, options = parse_args() + + meta = { + 'module_name': options.module_name, + 'path': os.path.dirname(options.output), + 'licenses': lics, + 'dependencies': [], + 'license_texts': '' + } + + build_root = options.build_root + file_name = os.path.join(build_root, options.output) + + if options.type != 'LIBRARY': + for rel_filename in peers: + with open(os.path.join(build_root, rel_filename + '.mf')) as peer_file: + peer_meta = json.load(peer_file) + meta['dependencies'].append(peer_meta) + + if credits: + union_texts = [] + for texts_file in credits: + with open(process_quotes(texts_file)) as f: + union_texts.append(f.read()) + meta['license_texts'] = '\n\n'.join(union_texts) + + if options.credits_output: + final_credits = [] + if meta['license_texts']: + final_credits.append(generate_header(meta) + '\n' + meta['license_texts']) + for peer in peers: + candidate = os.path.join(build_root, peer + '.mf') + with open(candidate) as src: + data = json.loads(src.read()) + texts = data.get('license_texts') + if texts: + candidate_text = generate_header(data) + '\n' + texts + if isinstance(candidate_text, unicode): + candidate_text = candidate_text.encode('utf-8') + final_credits.append(candidate_text) + + with io.open(options.credits_output, 'w', encoding='utf-8') as f: + data = '\n\n'.join(final_credits) + if isinstance(data, str): + data = data.decode('utf-8') + f.write(data) + + with open(file_name, 'w') as mf_file: + json.dump(meta, mf_file, indent=4) + + +if __name__ == '__main__': + try: + generate_mf() + except Exception as e: + sys.stderr.write(str(e) + '\n') + sys.exit(1) diff --git a/build/scripts/generate_pom.py b/build/scripts/generate_pom.py new file mode 100644 index 00000000000..d91bce6249e --- /dev/null +++ b/build/scripts/generate_pom.py @@ -0,0 +1,336 @@ +from __future__ import print_function + +import sys +import xml.etree.ElementTree as et +import argparse +import os +import json +import base64 +import re + + +DEFAULT_YANDEX_GROUP_ID = 'ru.yandex' +DEFAULT_NAMESPACE = 'http://maven.apache.org/POM/4.0.0' +XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance' +SCHEMA_LOCATION = 'http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd' +MODEL_VERSION = '4.0.0' + +MAVEN_PLUGIN_GROUP_ID = 'org.apache.maven.plugins' +MAVEN_PLUGIN_ARTIFACT_ID = 'maven-compiler-plugin' +MAVEN_PLUGIN_VERSION = '3.3' +JAVA_LANGUAGE_LEVEL = '1.8' + +MAVEN_BUILD_HELPER_GROUP_ID = 'org.codehaus.mojo' +MAVEN_BUILD_HELPER_ARTIFACT_ID = 'build-helper-maven-plugin' +MAVEN_BUILD_HELPER_VERSION = '1.9.1' + +MAVEN_EXEC_GROUP_ID = 'org.codehaus.mojo' +MAVEN_EXEC_ARTIFACT_ID = 'exec-maven-plugin' +MAVEN_EXEC_VERSION = '1.5.0' + +MAVEN_SUREFIRE_GROUP_ID = 'org.apache.maven.plugins' +MAVEN_SUREFIRE_ARTIFACT_ID = 'maven-surefire-plugin' +MAVEN_SUREFIRE_VERSION = '2.12.2' + + +def target_from_contrib(target_path): + return target_path.startswith('contrib') + + +def split_artifacts(s): + m = re.match('^([^:]*:[^:]*:[^:]*:[^:]*)(.*)$', s) + if not m or not m.groups(): + return [] + if not m.groups()[1].startswith('::'): + return [m.groups()[0]] + return [m.groups()[0]] + m.groups()[1].split('::')[1:] + + +def parse_coord_file(target_coords): + deps = set() + excludes = set() + target = None + + with open(target_coords, 'r') as f: + for ln in f: + ln = ln.strip('\n') + if ln.startswith('D='): + if target is None: + target = ln[2:] + else: + group, artifact = ln[2:].split(':')[0:2] + deps.add('{}:{}'.format(group, artifact)) + elif ln.startswith('E='): + group, artifact = ln[2:].split(':')[0:2] + excludes.add('{}:{}'.format(group, artifact)) + return target, deps, excludes + + +def applied_excludes(deps, excludes): + return sorted(list(deps & excludes)) + + +def build_pom_and_export_to_maven(**kwargs): + target_path = kwargs.get('target_path') + target = kwargs.get('target') + pom_path = kwargs.get('pom_path') + source_dirs = kwargs.get('source_dirs') + output_dir = kwargs.get('output_dir') + final_name = kwargs.get('final_name') + packaging = kwargs.get('packaging') + test_target_dependencies = kwargs.get('test_target_dependencies') + test_target_dependencies_exclude = kwargs.get('test_target_dependencies_exclude') + modules_path = kwargs.get('modules_path') + base64_prop_vars = kwargs.get('properties') + prop_vars = kwargs.get('property') + external_jars = kwargs.get('external_jars') + resources = kwargs.get('resources') + run_java_programs = [json.loads(base64.b64decode(i)) for i in kwargs.get('run_java_programs')] + test_source_dirs = kwargs.get('test_source_dirs') + test_resource_dirs = kwargs.get('test_resource_dirs') + + from_coord_files = kwargs.get('from_coord_files') + deps_coords = kwargs.get('deps_coords') + target_coords = kwargs.get('target_coords') + if from_coord_files: + target, _, all_excludes = parse_coord_file(target_coords) + # TODO: ymake java -> jbuild java values format conversion must be removed + target = ':'.join(target.split(':')[:3]) + target_dependencies = [] + for dep in deps_coords: + dep_coord, dep_deps, _ = parse_coord_file(dep) + excluded = applied_excludes(dep_deps, all_excludes) + if len(excluded) > 0: + target_dependencies.append('{}::{}'.format(dep_coord, '::'.join(excluded))) + else: + target_dependencies.append(dep_coord) + else: + target_dependencies = kwargs.get('target_dependencies') + + if kwargs.get('vcs_info') is not None: + with open(kwargs.get('vcs_info'), 'r') as vcs_json: + vcs_revision = json.load(vcs_json).get('ARCADIA_SOURCE_LAST_CHANGE') + target = target.format(vcs_revision=vcs_revision) + target_dependencies = [dep.format(vcs_revision=vcs_revision) for dep in target_dependencies] + + modules = [] + + def _indent(elem, level=0): + ind = "\n" + level * " " + if len(elem): + if not elem.text or not elem.text.strip(): + elem.text = ind + " " + if not elem.tail or not elem.tail.strip(): + elem.tail = ind + for elem in elem: + _indent(elem, level + 1) + if not elem.tail or not elem.tail.strip(): + elem.tail = ind + else: + if level and (not elem.tail or not elem.tail.strip()): + elem.tail = ind + + project = et.Element( + '{}{}{}project'.format('{', DEFAULT_NAMESPACE, '}'), + attrib={'{}{}{}schemaLocation'.format('{', XSI_NAMESPACE, '}'): SCHEMA_LOCATION} + ) + + group_id, artifact_id, version = target.split(':') + + et.SubElement(project, 'modelVersion').text = MODEL_VERSION + et.SubElement(project, 'groupId').text = group_id + et.SubElement(project, 'artifactId').text = artifact_id + et.SubElement(project, 'version').text = version + et.SubElement(project, 'packaging').text = packaging + + properties = et.SubElement(project, 'properties') + et.SubElement(properties, 'project.build.sourceEncoding').text = 'UTF-8' + + if base64_prop_vars: + for property, value in json.loads(base64.b64decode(base64_prop_vars)).items(): + et.SubElement(properties, property).text = value + for rawprop in prop_vars: + property, sep, value = rawprop.partition('=') + if sep != '=': + print("Can't find propertyr name and property value in {}. No '=' symbol found".format(rawprop)) + sys.exit(1) + et.SubElement(properties, property).text = value + + if modules_path: + with open(modules_path) as f: + modules = [i.strip() for i in f if i.strip()] + + if modules: + modules_el = et.SubElement(project, 'modules') + for module in modules: + et.SubElement(modules_el, 'module').text = module + + build = et.SubElement(project, 'build') + if source_dirs: + et.SubElement(build, 'sourceDirectory').text = source_dirs[0] + source_dirs = source_dirs[1:] + if test_source_dirs: + et.SubElement(build, 'testSourceDirectory').text = test_source_dirs[0] + test_source_dirs = test_source_dirs[1:] + if output_dir: + et.SubElement(build, 'outputDirectory').text = output_dir + if final_name: + et.SubElement(build, 'finalName').text = final_name + if resources: + resource_element = et.SubElement(et.SubElement(build, 'resources'), 'resource') + et.SubElement(resource_element, 'directory').text = '${basedir}' + includes = et.SubElement(resource_element, 'includes') + for resource in resources: + et.SubElement(includes, 'include').text = resource + if test_resource_dirs: + test_resource_element = et.SubElement(build, 'testResources') + for test_resource_dir in test_resource_dirs: + et.SubElement(et.SubElement(test_resource_element, 'testResource'), 'directory').text = '${basedir}' + (('/' + test_resource_dir) if test_resource_dir != '.' else '') + + plugins = et.SubElement(build, 'plugins') + + if packaging != 'pom': + maven_plugin = et.SubElement(plugins, 'plugin') + et.SubElement(maven_plugin, 'groupId').text = MAVEN_PLUGIN_GROUP_ID + et.SubElement(maven_plugin, 'artifactId').text = MAVEN_PLUGIN_ARTIFACT_ID + et.SubElement(maven_plugin, 'version').text = MAVEN_PLUGIN_VERSION + configuration = et.SubElement(maven_plugin, 'configuration') + et.SubElement(configuration, 'source').text = JAVA_LANGUAGE_LEVEL + et.SubElement(configuration, 'target').text = JAVA_LANGUAGE_LEVEL + + if source_dirs or external_jars or test_source_dirs: + build_helper_plugin = et.SubElement(plugins, 'plugin') + et.SubElement(build_helper_plugin, 'groupId').text = MAVEN_BUILD_HELPER_GROUP_ID + et.SubElement(build_helper_plugin, 'artifactId').text = MAVEN_BUILD_HELPER_ARTIFACT_ID + et.SubElement(build_helper_plugin, 'version').text = MAVEN_BUILD_HELPER_VERSION + executions = et.SubElement(build_helper_plugin, 'executions') + if source_dirs: + execution = et.SubElement(executions, 'execution') + et.SubElement(execution, 'id').text = 'add-source' + et.SubElement(execution, 'phase').text = 'generate-sources' + et.SubElement(et.SubElement(execution, 'goals'), 'goal').text = 'add-source' + sources = et.SubElement(et.SubElement(execution, 'configuration'), 'sources') + for source_dir in source_dirs: + et.SubElement(sources, 'source').text = source_dir + if external_jars: + execution = et.SubElement(executions, 'execution') + et.SubElement(execution, 'id').text = 'attach-artifacts' + et.SubElement(execution, 'phase').text = 'generate-sources' + et.SubElement(et.SubElement(execution, 'goals'), 'goal').text = 'attach-artifact' + artifacts = et.SubElement(et.SubElement(execution, 'configuration'), 'artifacts') + for external_jar in external_jars: + external_artifact = et.SubElement(artifacts, 'artifact') + et.SubElement(external_artifact, 'file').text = '${basedir}/' + external_jar + et.SubElement(external_artifact, 'type').text = 'jar' + if test_source_dirs: + execution = et.SubElement(executions, 'execution') + et.SubElement(execution, 'id').text = 'add-test-source' + et.SubElement(execution, 'phase').text = 'generate-test-sources' + et.SubElement(et.SubElement(execution, 'goals'), 'goal').text = 'add-test-source' + sources = et.SubElement(et.SubElement(execution, 'configuration'), 'sources') + for source_dir in source_dirs: + et.SubElement(sources, 'source').text = source_dir + + if run_java_programs: + exec_plugin = et.SubElement(plugins, 'plugin') + et.SubElement(exec_plugin, 'groupId').text = MAVEN_EXEC_GROUP_ID + et.SubElement(exec_plugin, 'artifactId').text = MAVEN_EXEC_ARTIFACT_ID + et.SubElement(exec_plugin, 'version').text = MAVEN_EXEC_VERSION + jp_dependencies = et.SubElement(exec_plugin, 'dependencies') + executions = et.SubElement(exec_plugin, 'executions') + for java_program in run_java_programs: + execution = et.SubElement(executions, 'execution') + et.SubElement(execution, 'phase').text = 'generate-sources' + et.SubElement(et.SubElement(execution, 'goals'), 'goal').text = 'java' + jp_configuration = et.SubElement(execution, 'configuration') + main_cls, args = None, [] + for word in java_program['cmd']: + if not main_cls and not word.startswith('-'): + main_cls = word + else: + args.append(word) + et.SubElement(jp_configuration, 'mainClass').text = main_cls + et.SubElement(jp_configuration, 'includePluginDependencies').text = 'true' + et.SubElement(jp_configuration, 'includeProjectDependencies').text = 'false' + if args: + jp_arguments = et.SubElement(jp_configuration, 'arguments') + for arg in args: + et.SubElement(jp_arguments, 'argument').text = arg + if java_program['deps']: + for jp_dep in java_program['deps']: + jp_dependency = et.SubElement(jp_dependencies, 'dependency') + jp_g, jp_a, jp_v = jp_dep.split(':') + et.SubElement(jp_dependency, 'groupId').text = jp_g + et.SubElement(jp_dependency, 'artifactId').text = jp_a + et.SubElement(jp_dependency, 'version').text = jp_v + et.SubElement(jp_dependency, 'type').text = 'jar' + + if target_dependencies + test_target_dependencies: + dependencies = et.SubElement(project, 'dependencies') + for target_dependency in target_dependencies + test_target_dependencies: + dependency = et.SubElement(dependencies, 'dependency') + dependency_info = split_artifacts(target_dependency) + + group_id, artifact_id, version, classifier = dependency_info[0].split(':') + + et.SubElement(dependency, 'groupId').text = group_id + et.SubElement(dependency, 'artifactId').text = artifact_id + et.SubElement(dependency, 'version').text = version + if classifier: + et.SubElement(dependency, 'classifier').text = classifier + if target_dependency in test_target_dependencies: + et.SubElement(dependency, 'scope').text = 'test' + + if len(dependency_info) > 1: + exclusions = et.SubElement(dependency, 'exclusions') + for exclude in dependency_info[1:]: + group_id, artifact_id = exclude.split(':') + exclusion_el = et.SubElement(exclusions, 'exclusion') + et.SubElement(exclusion_el, 'groupId').text = group_id + et.SubElement(exclusion_el, 'artifactId').text = artifact_id + + if test_target_dependencies_exclude: + surefire_plugin = et.SubElement(plugins, 'plugin') + et.SubElement(surefire_plugin, 'groupId').text = MAVEN_SUREFIRE_GROUP_ID + et.SubElement(surefire_plugin, 'artifactId').text = MAVEN_SUREFIRE_ARTIFACT_ID + et.SubElement(surefire_plugin, 'version').text = MAVEN_SUREFIRE_VERSION + classpath_excludes = et.SubElement(et.SubElement(surefire_plugin, 'configuration'), 'classpathDependencyExcludes') + for classpath_exclude in test_target_dependencies_exclude: + et.SubElement(classpath_excludes, 'classpathDependencyExclude').text = classpath_exclude + + et.register_namespace('', DEFAULT_NAMESPACE) + et.register_namespace('xsi', XSI_NAMESPACE) + + _indent(project) + + et.ElementTree(project).write(pom_path) + sys.stderr.write("[MAVEN EXPORT] Generated {} file for target {}\n".format(os.path.basename(pom_path), target_path)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--from-coord-files', action='store_true') + parser.add_argument('--deps-coords', action='append', default=[]) + parser.add_argument('--target-coords', action='store') + parser.add_argument('--target-path', action='store', default='') + parser.add_argument('--target', action='store') + parser.add_argument('--pom-path', action='store') + parser.add_argument('--source-dirs', action='append', default=[]) + parser.add_argument('--external-jars', action='append', default=[]) + parser.add_argument('--resources', action='append', default=[]) + parser.add_argument('--run-java-programs', action='append', default=[]) + parser.add_argument('--output-dir') + parser.add_argument('--final-name') + parser.add_argument('--packaging', default='jar') + parser.add_argument('--target-dependencies', action='append', default=[]) + parser.add_argument('--test-target-dependencies', action='append', default=[]) + parser.add_argument('--test-target-dependencies-exclude', action='append', default=[]) + parser.add_argument('--modules-path', action='store') + parser.add_argument('--properties') + parser.add_argument('--property', action='append', default=[]) + parser.add_argument('--test-source-dirs', action='append', default=[]) + parser.add_argument('--test-resource-dirs', action='append', default=[]) + parser.add_argument('--vcs-info', action='store', default=None) + args = parser.parse_args() + + build_pom_and_export_to_maven(**vars(args)) diff --git a/build/scripts/go_fake_include/go_asm.h b/build/scripts/go_fake_include/go_asm.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/build/scripts/go_fake_include/go_asm.h diff --git a/build/scripts/go_proto_wrapper.py b/build/scripts/go_proto_wrapper.py new file mode 100644 index 00000000000..159bd42c934 --- /dev/null +++ b/build/scripts/go_proto_wrapper.py @@ -0,0 +1,81 @@ +from __future__ import absolute_import, unicode_literals +import os +import re +import shutil +import subprocess +import sys +import tempfile + + +OUT_DIR_FLAG_PATTERN = re.compile(r'^(--go(([-_]\w+))*_out=)') + + +def move_tree(src_root, dst_root): + for root, _, files in os.walk(src_root): + rel_dir = os.path.relpath(root, src_root) + dst_dir = os.path.join(dst_root, rel_dir) + if not os.path.exists(dst_dir): + os.mkdir(dst_dir) + for file in files: + os.rename(os.path.join(root, file), os.path.join(dst_dir, file)) + + +def main(arcadia_prefix, contrib_prefix, proto_namespace, args): + out_dir_orig = None + out_dir_temp = None + for i in range(len(args)): + m = re.match(OUT_DIR_FLAG_PATTERN, args[i]) + if m: + out_dir_flag = m.group(1) + index = max(len(out_dir_flag), args[i].rfind(':')+1) + out_dir = args[i][index:] + if out_dir_orig: + assert out_dir_orig == out_dir, 'Output directories do not match: [{}] and [{}]'.format(out_dir_orig, out_dir) + else: + out_dir_orig = out_dir + out_dir_temp = tempfile.mkdtemp(dir=out_dir_orig) + args[i] = (args[i][:index] + out_dir_temp).replace('|', ',') + assert out_dir_temp is not None, 'Output directory is not specified' + + try: + subprocess.check_output(args, stdin=None, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + sys.stderr.write('{} returned non-zero exit code {}.\n{}\n'.format(' '.join(e.cmd), e.returncode, e.output.decode('utf-8'))) + return e.returncode + + # All Arcadia GO projects should have 'a.yandex-team.ru/' namespace prefix. + # If the namespace doesn't start with 'a.yandex-team.ru/' prefix then this + # project is from vendor directory under the root of Arcadia. + out_dir_src = os.path.normpath(os.path.join(out_dir_temp, arcadia_prefix, proto_namespace)) + out_dir_dst = out_dir_orig + is_from_contrib = False + if not os.path.isdir(out_dir_src): + is_from_contrib = True + out_dir_src = out_dir_temp + out_dir_dst = os.path.join(out_dir_orig, contrib_prefix) + + if not os.path.exists(out_dir_src) or is_from_contrib: + protos = [x for x in args if x.endswith('.proto')] + if not is_from_contrib or not all(x.startswith(contrib_prefix) for x in protos): + proto_list = [] + option_re = re.compile(r'^\s*option\s+go_package\s*=\s*') + for arg in protos: + with open(arg, 'r') as f: + if not any([re.match(option_re, line) for line in f]): + proto_list.append(arg) + if proto_list: + sys.stderr.write( + '\nError: Option go_package is not specified in the following proto files: {}\n' + '\nNOTE! You can find detailed description of how to properly set go_package ' + 'option here https://wiki.yandex-team.ru/devrules/Go/#protobufigrpc'.format(', '.join(proto_list))) + return 1 + + move_tree(out_dir_src, out_dir_dst) + + shutil.rmtree(out_dir_temp) + + return 0 + + +if __name__ == '__main__': + sys.exit(main(os.path.normpath(sys.argv[1]), os.path.normpath(sys.argv[2]), os.path.normpath(sys.argv[3]), sys.argv[4:])) diff --git a/build/scripts/go_tool.py b/build/scripts/go_tool.py new file mode 100644 index 00000000000..e57a12cc0fa --- /dev/null +++ b/build/scripts/go_tool.py @@ -0,0 +1,891 @@ +import argparse +import copy +import json +import os +import re +import shutil +import subprocess +import sys +import tarfile +import tempfile +import threading +import traceback +from contextlib import contextmanager +from functools import reduce + +import process_command_files as pcf +import process_whole_archive_option as pwa + +arc_project_prefix = 'a.yandex-team.ru/' +# FIXME: make version-independent +std_lib_prefix = 'contrib/go/_std_1.19/src/' +vendor_prefix = 'vendor/' +vet_info_ext = '.vet.out' +vet_report_ext = '.vet.txt' + +FIXED_CGO1_SUFFIX='.fixed.cgo1.go' + +COMPILE_OPTIMIZATION_FLAGS=('-N',) + + +def get_trimpath_args(args): + return ['-trimpath', args.trimpath] if args.trimpath else [] + + +def preprocess_cgo1(src_path, dst_path, source_root): + with open(src_path, 'r') as f: + content = f.read() + content = content.replace('__ARCADIA_SOURCE_ROOT_PREFIX__', source_root) + with open(dst_path, 'w') as f: + f.write(content) + + +def preprocess_args(args): + # Temporary work around for noauto + if args.cgo_srcs and len(args.cgo_srcs) > 0: + cgo_srcs_set = set(args.cgo_srcs) + args.srcs = [x for x in args.srcs if x not in cgo_srcs_set] + + args.pkg_root = os.path.join(args.toolchain_root, 'pkg') + toolchain_tool_root = os.path.join(args.pkg_root, 'tool', '{}_{}'.format(args.host_os, args.host_arch)) + args.go_compile = os.path.join(toolchain_tool_root, 'compile') + args.go_cgo = os.path.join(toolchain_tool_root, 'cgo') + args.go_link = os.path.join(toolchain_tool_root, 'link') + args.go_asm = os.path.join(toolchain_tool_root, 'asm') + args.go_pack = os.path.join(toolchain_tool_root, 'pack') + args.go_vet = os.path.join(toolchain_tool_root, 'vet') if args.vet is True else args.vet + args.output = os.path.normpath(args.output) + args.vet_report_output = vet_report_output_name(args.output, args.vet_report_ext) + args.trimpath = None + if args.debug_root_map: + roots = {'build': args.build_root, 'source': args.source_root, 'tools': args.tools_root} + replaces = [] + for root in args.debug_root_map.split(';'): + src, dst = root.split('=', 1) + assert src in roots + replaces.append('{}=>{}'.format(roots[src], dst)) + del roots[src] + assert len(replaces) > 0 + args.trimpath = ';'.join(replaces) + args.build_root = os.path.normpath(args.build_root) + args.build_root_dir = args.build_root + os.path.sep + args.source_root = os.path.normpath(args.source_root) + args.source_root_dir = args.source_root + os.path.sep + args.output_root = os.path.normpath(args.output_root) + args.import_map = {} + args.module_map = {} + if args.cgo_peers: + args.cgo_peers = [x for x in args.cgo_peers if not x.endswith('.fake.pkg')] + + srcs = [] + for f in args.srcs: + if f.endswith('.gosrc'): + with tarfile.open(f, 'r') as tar: + srcs.extend(os.path.join(args.output_root, src) for src in tar.getnames()) + tar.extractall(path=args.output_root) + else: + srcs.append(f) + args.srcs = srcs + + assert args.mode == 'test' or args.test_srcs is None and args.xtest_srcs is None + # add lexical oreder by basename for go sources + args.srcs.sort(key=lambda x: os.path.basename(x)) + if args.test_srcs: + args.srcs += sorted(args.test_srcs, key=lambda x: os.path.basename(x)) + del args.test_srcs + if args.xtest_srcs: + args.xtest_srcs.sort(key=lambda x: os.path.basename(x)) + + # compute root relative module dir path + assert args.output is None or args.output_root == os.path.dirname(args.output) + assert args.output_root.startswith(args.build_root_dir) + args.module_path = args.output_root[len(args.build_root_dir):] + args.source_module_dir = os.path.join(args.source_root, args.test_import_path or args.module_path) + os.path.sep + assert len(args.module_path) > 0 + args.import_path, args.is_std = get_import_path(args.module_path) + + assert args.asmhdr is None or args.word == 'go' + + srcs = [] + for f in args.srcs: + if f.endswith(FIXED_CGO1_SUFFIX) and f.startswith(args.build_root_dir): + path = os.path.join(args.output_root, '{}.cgo1.go'.format(os.path.basename(f[:-len(FIXED_CGO1_SUFFIX)]))) + srcs.append(path) + preprocess_cgo1(f, path, args.source_root) + else: + srcs.append(f) + args.srcs = srcs + + if args.extldflags: + args.extldflags = pwa.ProcessWholeArchiveOption(args.targ_os).construct_cmd(args.extldflags) + + classify_srcs(args.srcs, args) + + +def compare_versions(version1, version2): + def last_index(version): + index = version.find('beta') + return len(version) if index < 0 else index + + v1 = tuple(x.zfill(8) for x in version1[:last_index(version1)].split('.')) + v2 = tuple(x.zfill(8) for x in version2[:last_index(version2)].split('.')) + if v1 == v2: + return 0 + return 1 if v1 < v2 else -1 + + +def get_symlink_or_copyfile(): + os_symlink = getattr(os, 'symlink', None) + if os_symlink is None or os.name == 'nt': + os_symlink = shutil.copyfile + return os_symlink + + +def copy_args(args): + return copy.copy(args) + + +def get_vendor_index(import_path): + index = import_path.rfind('/' + vendor_prefix) + if index < 0: + index = 0 if import_path.startswith(vendor_prefix) else index + else: + index = index + 1 + return index + + +def get_import_path(module_path): + assert len(module_path) > 0 + import_path = module_path.replace('\\', '/') + is_std_module = import_path.startswith(std_lib_prefix) + if is_std_module: + import_path = import_path[len(std_lib_prefix):] + elif import_path.startswith(vendor_prefix): + import_path = import_path[len(vendor_prefix):] + else: + import_path = arc_project_prefix + import_path + assert len(import_path) > 0 + return import_path, is_std_module + + +def call(cmd, cwd, env=None): + # sys.stderr.write('{}\n'.format(' '.join(cmd))) + return subprocess.check_output(cmd, stdin=None, stderr=subprocess.STDOUT, cwd=cwd, env=env, text=True) + + +def classify_srcs(srcs, args): + args.go_srcs = [x for x in srcs if x.endswith('.go')] + args.asm_srcs = [x for x in srcs if x.endswith('.s')] + args.objects = [x for x in srcs if x.endswith('.o') or x.endswith('.obj')] + args.symabis = [x for x in srcs if x.endswith('.symabis')] + args.sysos = [x for x in srcs if x.endswith('.syso')] + + +def get_import_config_info(peers, gen_importmap, import_map={}, module_map={}): + info = {'importmap': [], 'packagefile': [], 'standard': {}} + if gen_importmap: + for key, value in import_map.items(): + info['importmap'].append((key, value)) + for peer in peers: + peer_import_path, is_std = get_import_path(os.path.dirname(peer)) + if gen_importmap: + index = get_vendor_index(peer_import_path) + if index >= 0: + index += len(vendor_prefix) + info['importmap'].append((peer_import_path[index:], peer_import_path)) + info['packagefile'].append((peer_import_path, os.path.join(args.build_root, peer))) + if is_std: + info['standard'][peer_import_path] = True + for key, value in module_map.items(): + info['packagefile'].append((key, value)) + return info + + +def create_import_config(peers, gen_importmap, import_map={}, module_map={}): + lines = [] + info = get_import_config_info(peers, gen_importmap, import_map, module_map) + for key in ('importmap', 'packagefile'): + for item in info[key]: + lines.append('{} {}={}'.format(key, *item)) + if len(lines) > 0: + lines.append('') + content = '\n'.join(lines) + # sys.stderr.writelines('{}\n'.format(l) for l in lines) + with tempfile.NamedTemporaryFile(delete=False) as f: + f.write(content.encode('UTF-8')) + return f.name + return None + + +def create_embed_config(args): + data = { + 'Patterns': {}, + 'Files': {}, + } + for info in args.embed: + pattern = info[0] + if pattern.endswith('/**/*'): + pattern = pattern[:-3] + files = {os.path.relpath(f, args.source_module_dir).replace('\\', '/'): f for f in info[1:]} + data['Patterns'][pattern] = list(files.keys()) + data['Files'].update(files) + # sys.stderr.write('{}\n'.format(json.dumps(data, indent=4))) + with tempfile.NamedTemporaryFile(delete=False, suffix='.embedcfg') as f: + f.write(json.dumps(data).encode('UTF-8')) + return f.name + + +def vet_info_output_name(path, ext=None): + return '{}{}'.format(path, ext or vet_info_ext) + + +def vet_report_output_name(path, ext=None): + return '{}{}'.format(path, ext or vet_report_ext) + + +def get_source_path(args): + return args.test_import_path or args.module_path + + +def gen_vet_info(args): + import_path = args.real_import_path if hasattr(args, 'real_import_path') else args.import_path + info = get_import_config_info(args.peers, True, args.import_map, args.module_map) + + import_map = dict(info['importmap']) + # FIXME(snermolaev): it seems that adding import map for 'fake' package + # does't make any harm (it needs to be revised later) + import_map['unsafe'] = 'unsafe' + + for (key, _) in info['packagefile']: + if key not in import_map: + import_map[key] = key + + data = { + 'ID': import_path, + 'Compiler': 'gc', + 'Dir': os.path.join(args.source_root, get_source_path(args)), + 'ImportPath': import_path, + 'GoFiles': [x for x in args.go_srcs if x.endswith('.go')], + 'NonGoFiles': [x for x in args.go_srcs if not x.endswith('.go')], + 'ImportMap': import_map, + 'PackageFile': dict(info['packagefile']), + 'Standard': dict(info['standard']), + 'PackageVetx': dict((key, vet_info_output_name(value)) for key, value in info['packagefile']), + 'VetxOnly': False, + 'VetxOutput': vet_info_output_name(args.output), + 'SucceedOnTypecheckFailure': False + } + # sys.stderr.write('{}\n'.format(json.dumps(data, indent=4))) + return data + + +def create_vet_config(args, info): + with tempfile.NamedTemporaryFile(delete=False, suffix='.cfg') as f: + f.write(json.dumps(info).encode('UTF-8')) + return f.name + + +def decode_vet_report(json_report): + report = '' + if json_report: + try: + full_diags = json.JSONDecoder().decode(json_report.decode('UTF-8')) + except ValueError: + report = json_report + else: + messages = [] + for _, module_diags in full_diags.items(): + for _, type_diags in module_diags.items(): + for diag in type_diags: + messages.append('{}: {}'.format(diag['posn'], json.dumps(diag['message']))) + report = '\n'.join(messages) + + return report + + +def dump_vet_report(args, report): + if report: + report = report.replace(args.build_root, '$B') + report = report.replace(args.source_root, '$S') + with open(args.vet_report_output, 'w') as f: + f.write(report) + + +def read_vet_report(args): + assert args + report = '' + if os.path.exists(args.vet_report_output): + with open(args.vet_report_output, 'r') as f: + report += f.read() + return report + + +def dump_vet_report_for_tests(args, *test_args_list): + dump_vet_report(args, reduce(lambda x, y: x + read_vet_report(y), [_f for _f in test_args_list if _f], '')) + + +def do_vet(args): + assert args.vet + info = gen_vet_info(args) + vet_config = create_vet_config(args, info) + cmd = [args.go_vet, '-json'] + if args.vet_flags: + cmd.extend(args.vet_flags) + cmd.append(vet_config) + # sys.stderr.write('>>>> [{}]\n'.format(' '.join(cmd))) + p_vet = subprocess.Popen(cmd, stdin=None, stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=args.source_root) + vet_out, vet_err = p_vet.communicate() + report = decode_vet_report(vet_out) if vet_out else '' + dump_vet_report(args, report) + if p_vet.returncode: + raise subprocess.CalledProcessError(returncode=p_vet.returncode, cmd=cmd, output=vet_err) + + +def _do_compile_go(args): + import_path, is_std_module = args.import_path, args.is_std + cmd = [ + args.go_compile, + '-o', + args.output, + '-p', + import_path if import_path != "unsafe" else "", + '-D', + '""', + ] + if args.lang: + cmd.append('-lang=go{}'.format(args.lang)) + cmd.extend(get_trimpath_args(args)) + compiling_runtime = False + if is_std_module: + cmd.append('-std') + if import_path in ('runtime', 'internal/abi', 'internal/bytealg', 'internal/cpu') or import_path.startswith('runtime/internal/'): + cmd.append('-+') + compiling_runtime = True + import_config_name = create_import_config(args.peers, True, args.import_map, args.module_map) + if import_config_name: + cmd += ['-importcfg', import_config_name] + else: + if import_path == 'unsafe' or len(args.objects) > 0 or args.asmhdr: + pass + else: + cmd.append('-complete') + # if compare_versions('1.16', args.goversion) >= 0: + if args.embed: + embed_config_name = create_embed_config(args) + cmd.extend(['-embedcfg', embed_config_name]) + if args.asmhdr: + cmd += ['-asmhdr', args.asmhdr] + # Use .symabis (starting from 1.12 version) + if args.symabis: + cmd += ['-symabis'] + args.symabis + # If 1.12 <= version < 1.13 we have to pass -allabis for 'runtime' and 'runtime/internal/atomic' + # if compare_versions('1.13', args.goversion) >= 0: + # pass + # elif import_path in ('runtime', 'runtime/internal/atomic'): + # cmd.append('-allabis') + compile_workers = '4' + if args.compile_flags: + if compiling_runtime: + cmd.extend(x for x in args.compile_flags if x not in COMPILE_OPTIMIZATION_FLAGS) + else: + cmd.extend(args.compile_flags) + if any([x in ('-race', '-shared') for x in args.compile_flags]): + compile_workers = '1' + cmd += ['-pack', '-c={}'.format(compile_workers)] + cmd += args.go_srcs + call(cmd, args.build_root) + + +class VetThread(threading.Thread): + + def __init__(self, target, args): + super(VetThread, self).__init__(target=target, args=args) + self.exc_info = None + + def run(self): + try: + super(VetThread, self).run() + except: + self.exc_info = sys.exc_info() + + def join_with_exception(self, reraise_exception): + self.join() + if reraise_exception and self.exc_info: + raise self.exc_info[0].with_traceback(self.exc_info[1], self.exc_info[2]) + + +def do_compile_go(args): + raise_exception_from_vet = False + if args.vet: + run_vet = VetThread(target=do_vet, args=(args,)) + run_vet.start() + try: + _do_compile_go(args) + raise_exception_from_vet = True + finally: + if args.vet: + run_vet.join_with_exception(raise_exception_from_vet) + + +def do_compile_asm(args): + def need_compiling_runtime(import_path): + return import_path in ('runtime', 'reflect', 'syscall') or \ + import_path.startswith('runtime/internal/') or \ + compare_versions('1.17', args.goversion) >= 0 and import_path == 'internal/bytealg' + + assert(len(args.srcs) == 1 and len(args.asm_srcs) == 1) + cmd = [args.go_asm] + cmd += get_trimpath_args(args) + cmd += ['-I', args.output_root, '-I', os.path.join(args.pkg_root, 'include')] + cmd += ['-D', 'GOOS_' + args.targ_os, '-D', 'GOARCH_' + args.targ_arch, '-o', args.output] + + # if compare_versions('1.16', args.goversion) >= 0: + cmd += ['-p', args.import_path] + if need_compiling_runtime(args.import_path): + cmd += ['-compiling-runtime'] + + if args.asm_flags: + cmd += args.asm_flags + cmd += args.asm_srcs + call(cmd, args.build_root) + + +def do_link_lib(args): + if len(args.asm_srcs) > 0: + asmargs = copy_args(args) + asmargs.asmhdr = os.path.join(asmargs.output_root, 'go_asm.h') + do_compile_go(asmargs) + for src in asmargs.asm_srcs: + asmargs.srcs = [src] + asmargs.asm_srcs = [src] + asmargs.output = os.path.join(asmargs.output_root, os.path.basename(src) + '.o') + do_compile_asm(asmargs) + args.objects.append(asmargs.output) + else: + do_compile_go(args) + if args.objects or args.sysos: + cmd = [args.go_pack, 'r', args.output] + args.objects + args.sysos + call(cmd, args.build_root) + + +def do_link_exe(args): + assert args.extld is not None + assert args.non_local_peers is not None + compile_args = copy_args(args) + compile_args.output = os.path.join(args.output_root, 'main.a') + compile_args.real_import_path = compile_args.import_path + compile_args.import_path = 'main' + + if args.vcs and os.path.isfile(compile_args.vcs): + build_info = os.path.join('library', 'go', 'core', 'buildinfo') + if any([x.startswith(build_info) for x in compile_args.peers]): + compile_args.go_srcs.append(compile_args.vcs) + + do_link_lib(compile_args) + cmd = [args.go_link, '-o', args.output] + import_config_name = create_import_config(args.peers + args.non_local_peers, False, args.import_map, args.module_map) + if import_config_name: + cmd += ['-importcfg', import_config_name] + if args.link_flags: + cmd += args.link_flags + + if args.buildmode: + cmd.append('-buildmode={}'.format(args.buildmode)) + elif args.mode in ('exe', 'test'): + cmd.append('-buildmode=exe') + elif args.mode == 'dll': + cmd.append('-buildmode=c-shared') + else: + assert False, 'Unexpected mode: {}'.format(args.mode) + cmd.append('-extld={}'.format(args.extld)) + + extldflags = [] + if args.extldflags is not None: + filter_musl = bool + if args.musl: + cmd.append('-linkmode=external') + extldflags.append('-static') + filter_musl = lambda x: x not in ('-lc', '-ldl', '-lm', '-lpthread', '-lrt') + extldflags += [x for x in args.extldflags if filter_musl(x)] + cgo_peers = [] + if args.cgo_peers is not None and len(args.cgo_peers) > 0: + is_group = args.targ_os == 'linux' + if is_group: + cgo_peers.append('-Wl,--start-group') + cgo_peers.extend(args.cgo_peers) + if is_group: + cgo_peers.append('-Wl,--end-group') + try: + index = extldflags.index('--cgo-peers') + extldflags = extldflags[:index] + cgo_peers + extldflags[index+1:] + except ValueError: + extldflags.extend(cgo_peers) + if len(extldflags) > 0: + cmd.append('-extldflags={}'.format(' '.join(extldflags))) + cmd.append(compile_args.output) + call(cmd, args.build_root) + + +def gen_cover_info(args): + lines = [] + lines.extend([ + """ +var ( + coverCounters = make(map[string][]uint32) + coverBlocks = make(map[string][]testing.CoverBlock) +) + """, + 'func init() {', + ]) + for var, file in (x.split(':') for x in args.cover_info): + lines.append(' coverRegisterFile("{file}", _cover0.{var}.Count[:], _cover0.{var}.Pos[:], _cover0.{var}.NumStmt[:])'.format(file=file, var=var)) + lines.extend([ + '}', + """ +func coverRegisterFile(fileName string, counter []uint32, pos []uint32, numStmts []uint16) { + if 3*len(counter) != len(pos) || len(counter) != len(numStmts) { + panic("coverage: mismatched sizes") + } + if coverCounters[fileName] != nil { + // Already registered. + return + } + coverCounters[fileName] = counter + block := make([]testing.CoverBlock, len(counter)) + for i := range counter { + block[i] = testing.CoverBlock{ + Line0: pos[3*i+0], + Col0: uint16(pos[3*i+2]), + Line1: pos[3*i+1], + Col1: uint16(pos[3*i+2]>>16), + Stmts: numStmts[i], + } + } + coverBlocks[fileName] = block +} + """, + ]) + return lines + + +def filter_out_skip_tests(tests, skip_tests): + skip_set = set() + star_skip_set = set() + for t in skip_tests: + work_set = star_skip_set if '*' in t else skip_set + work_set.add(t) + + re_star_tests = None + if len(star_skip_set) > 0: + re_star_tests = re.compile(re.sub(r'(\*)+', r'.\1', '^({})$'.format('|'.join(star_skip_set)))) + + return [x for x in tests if not (x in skip_tests or re_star_tests and re_star_tests.match(x))] + + +@contextmanager +def create_strip_symlink(): + # This function creates symlink of llvm-strip as strip for golink needs. + # We believe that cc-binaries path is a first element in PATH enviroment variable. + tmpdir = None + if os.getenv("CC") == "clang": + tmpdir = tempfile.mkdtemp() + cc_path = os.getenv("PATH").split(os.pathsep)[0] + os.environ["PATH"] += os.pathsep + tmpdir + src_strip_path = os.path.join(cc_path, 'llvm-strip') + dst_strip_path = os.path.join(tmpdir, 'strip') + os.symlink(src_strip_path, dst_strip_path) + try: + yield + finally: + if tmpdir: + shutil.rmtree(tmpdir) + + +def gen_test_main(args, test_lib_args, xtest_lib_args): + assert args and (test_lib_args or xtest_lib_args) + test_miner = args.test_miner + test_module_path = test_lib_args.import_path if test_lib_args else xtest_lib_args.import_path + is_cover = args.cover_info and len(args.cover_info) > 0 + + # Prepare GOPATH + # $BINDIR + # |- __go__ + # |- src + # |- pkg + # |- ${TARGET_OS}_${TARGET_ARCH} + go_path_root = os.path.join(args.output_root, '__go__') + test_src_dir = os.path.join(go_path_root, 'src') + target_os_arch = '_'.join([args.targ_os, args.targ_arch]) + test_pkg_dir = os.path.join(go_path_root, 'pkg', target_os_arch, os.path.dirname(test_module_path)) + os.makedirs(test_pkg_dir) + + my_env = os.environ.copy() + my_env['GOROOT'] = '' + my_env['GOPATH'] = go_path_root + my_env['GOARCH'] = args.targ_arch + my_env['GOOS'] = args.targ_os + + tests = [] + xtests = [] + os_symlink = get_symlink_or_copyfile() + + # Get the list of "internal" tests + if test_lib_args: + os.makedirs(os.path.join(test_src_dir, test_module_path)) + os_symlink(test_lib_args.output, os.path.join(test_pkg_dir, os.path.basename(test_module_path) + '.a')) + cmd = [test_miner, '-benchmarks', '-tests', test_module_path] + tests = [x for x in (call(cmd, test_lib_args.output_root, my_env) or '').strip().split('\n') if len(x) > 0] + if args.skip_tests: + tests = filter_out_skip_tests(tests, args.skip_tests) + test_main_found = '#TestMain' in tests + + # Get the list of "external" tests + if xtest_lib_args: + xtest_module_path = xtest_lib_args.import_path + os.makedirs(os.path.join(test_src_dir, xtest_module_path)) + os_symlink(xtest_lib_args.output, os.path.join(test_pkg_dir, os.path.basename(xtest_module_path) + '.a')) + cmd = [test_miner, '-benchmarks', '-tests', xtest_module_path] + xtests = [x for x in (call(cmd, xtest_lib_args.output_root, my_env) or '').strip().split('\n') if len(x) > 0] + if args.skip_tests: + xtests = filter_out_skip_tests(xtests, args.skip_tests) + xtest_main_found = '#TestMain' in xtests + + test_main_package = None + if test_main_found and xtest_main_found: + assert False, 'multiple definition of TestMain' + elif test_main_found: + test_main_package = '_test' + elif xtest_main_found: + test_main_package = '_xtest' + + shutil.rmtree(go_path_root) + + lines = ['package main', '', 'import ('] + if test_main_package is None: + lines.append(' "os"') + lines.extend([' "testing"', ' "testing/internal/testdeps"']) + + if len(tests) > 0: + lines.append(' _test "{}"'.format(test_module_path)) + elif test_lib_args: + lines.append(' _ "{}"'.format(test_module_path)) + + if len(xtests) > 0: + lines.append(' _xtest "{}"'.format(xtest_module_path)) + elif xtest_lib_args: + lines.append(' _ "{}"'.format(xtest_module_path)) + + if is_cover: + lines.append(' _cover0 "{}"'.format(test_module_path)) + lines.extend([')', '']) + + if compare_versions('1.18', args.goversion) < 0: + kinds = ['Test', 'Benchmark', 'Example'] + else: + kinds = ['Test', 'Benchmark', 'FuzzTarget', 'Example'] + + var_names = [] + for kind in kinds: + var_name = '{}s'.format(kind.lower()) + var_names.append(var_name) + lines.append('var {} = []testing.Internal{}{{'.format(var_name, kind)) + for test in [x for x in tests if x.startswith(kind)]: + lines.append(' {{"{test}", _test.{test}}},'.format(test=test)) + for test in [x for x in xtests if x.startswith(kind)]: + lines.append(' {{"{test}", _xtest.{test}}},'.format(test=test)) + lines.extend(['}', '']) + + if is_cover: + lines.extend(gen_cover_info(args)) + + lines.append('func main() {') + if is_cover: + lines.extend([ + ' testing.RegisterCover(testing.Cover{', + ' Mode: "set",', + ' Counters: coverCounters,', + ' Blocks: coverBlocks,', + ' CoveredPackages: "",', + ' })', + ]) + lines.extend([ + ' m := testing.MainStart(testdeps.TestDeps{{}}, {})'.format(', '.join(var_names)), + '', + ]) + + if test_main_package: + lines.append(' {}.TestMain(m)'.format(test_main_package)) + else: + lines.append(' os.Exit(m.Run())') + lines.extend(['}', '']) + + content = '\n'.join(lines) + # sys.stderr.write('{}\n'.format(content)) + return content + + +def do_link_test(args): + assert args.srcs or args.xtest_srcs + assert args.test_miner is not None + + test_module_path = get_source_path(args) + test_import_path, _ = get_import_path(test_module_path) + + test_lib_args = copy_args(args) if args.srcs else None + xtest_lib_args = copy_args(args) if args.xtest_srcs else None + if xtest_lib_args is not None: + xtest_lib_args.embed = args.embed_xtest if args.embed_xtest else None + + ydx_file_name = None + xtest_ydx_file_name = None + need_append_ydx = test_lib_args and xtest_lib_args and args.ydx_file and args.vet_flags + if need_append_ydx: + def find_ydx_file_name(name, flags): + for i, elem in enumerate(flags): + if elem.endswith(name): + return (i, elem) + assert False, 'Unreachable code' + + idx, ydx_file_name = find_ydx_file_name(xtest_lib_args.ydx_file, xtest_lib_args.vet_flags) + xtest_ydx_file_name = '{}_xtest'.format(ydx_file_name) + xtest_lib_args.vet_flags = copy.copy(xtest_lib_args.vet_flags) + xtest_lib_args.vet_flags[idx] = xtest_ydx_file_name + + if test_lib_args: + test_lib_args.output = os.path.join(args.output_root, 'test.a') + test_lib_args.vet_report_output = vet_report_output_name(test_lib_args.output) + test_lib_args.module_path = test_module_path + test_lib_args.import_path = test_import_path + do_link_lib(test_lib_args) + + if xtest_lib_args: + xtest_lib_args.srcs = xtest_lib_args.xtest_srcs + classify_srcs(xtest_lib_args.srcs, xtest_lib_args) + xtest_lib_args.output = os.path.join(args.output_root, 'xtest.a') + xtest_lib_args.vet_report_output = vet_report_output_name(xtest_lib_args.output) + xtest_lib_args.module_path = test_module_path + '_test' + xtest_lib_args.import_path = test_import_path + '_test' + if test_lib_args: + xtest_lib_args.module_map[test_import_path] = test_lib_args.output + need_append_ydx = args.ydx_file and args.srcs and args.vet_flags + do_link_lib(xtest_lib_args) + + if need_append_ydx: + with open(os.path.join(args.build_root, ydx_file_name), 'ab') as dst_file: + with open(os.path.join(args.build_root, xtest_ydx_file_name), 'rb') as src_file: + dst_file.write(src_file.read()) + + test_main_content = gen_test_main(args, test_lib_args, xtest_lib_args) + test_main_name = os.path.join(args.output_root, '_test_main.go') + with open(test_main_name, "w") as f: + f.write(test_main_content) + test_args = copy_args(args) + test_args.embed = None + test_args.srcs = [test_main_name] + if test_args.test_import_path is None: + # it seems that we can do it unconditionally, but this kind + # of mangling doesn't really looks good to me and we leave it + # for pure GO_TEST module + test_args.module_path = test_args.module_path + '___test_main__' + test_args.import_path = test_args.import_path + '___test_main__' + classify_srcs(test_args.srcs, test_args) + if test_lib_args: + test_args.module_map[test_lib_args.import_path] = test_lib_args.output + if xtest_lib_args: + test_args.module_map[xtest_lib_args.import_path] = xtest_lib_args.output + + if args.vet: + dump_vet_report_for_tests(test_args, test_lib_args, xtest_lib_args) + test_args.vet = False + + do_link_exe(test_args) + + +if __name__ == '__main__': + args = pcf.get_args(sys.argv[1:]) + + parser = argparse.ArgumentParser(prefix_chars='+') + parser.add_argument('++mode', choices=['dll', 'exe', 'lib', 'test'], required=True) + parser.add_argument('++buildmode', choices=['c-shared', 'exe', 'pie']) + parser.add_argument('++srcs', nargs='*', required=True) + parser.add_argument('++cgo-srcs', nargs='*') + parser.add_argument('++test_srcs', nargs='*') + parser.add_argument('++xtest_srcs', nargs='*') + parser.add_argument('++cover_info', nargs='*') + parser.add_argument('++output', nargs='?', default=None) + parser.add_argument('++source-root', default=None) + parser.add_argument('++build-root', required=True) + parser.add_argument('++tools-root', default=None) + parser.add_argument('++output-root', required=True) + parser.add_argument('++toolchain-root', required=True) + parser.add_argument('++host-os', choices=['linux', 'darwin', 'windows'], required=True) + parser.add_argument('++host-arch', choices=['amd64', 'arm64'], required=True) + parser.add_argument('++targ-os', choices=['linux', 'darwin', 'windows'], required=True) + parser.add_argument('++targ-arch', choices=['amd64', 'x86', 'arm64'], required=True) + parser.add_argument('++peers', nargs='*') + parser.add_argument('++non-local-peers', nargs='*') + parser.add_argument('++cgo-peers', nargs='*') + parser.add_argument('++asmhdr', nargs='?', default=None) + parser.add_argument('++test-import-path', nargs='?') + parser.add_argument('++test-miner', nargs='?') + parser.add_argument('++arc-project-prefix', nargs='?', default=arc_project_prefix) + parser.add_argument('++std-lib-prefix', nargs='?', default=std_lib_prefix) + parser.add_argument('++vendor-prefix', nargs='?', default=vendor_prefix) + parser.add_argument('++extld', nargs='?', default=None) + parser.add_argument('++extldflags', nargs='+', default=None) + parser.add_argument('++goversion', required=True) + parser.add_argument('++lang', nargs='?', default=None) + parser.add_argument('++asm-flags', nargs='*') + parser.add_argument('++compile-flags', nargs='*') + parser.add_argument('++link-flags', nargs='*') + parser.add_argument('++vcs', nargs='?', default=None) + parser.add_argument('++vet', nargs='?', const=True, default=False) + parser.add_argument('++vet-flags', nargs='*', default=None) + parser.add_argument('++vet-info-ext', default=vet_info_ext) + parser.add_argument('++vet-report-ext', default=vet_report_ext) + parser.add_argument('++musl', action='store_true') + parser.add_argument('++skip-tests', nargs='*', default=None) + parser.add_argument('++ydx-file', default='') + parser.add_argument('++debug-root-map', default=None) + parser.add_argument('++embed', action='append', nargs='*') + parser.add_argument('++embed_xtest', action='append', nargs='*') + args = parser.parse_args(args) + + arc_project_prefix = args.arc_project_prefix + std_lib_prefix = args.std_lib_prefix + vendor_prefix = args.vendor_prefix + vet_info_ext = args.vet_info_ext + vet_report_ext = args.vet_report_ext + + preprocess_args(args) + + try: + os.unlink(args.output) + except OSError: + pass + + # We are going to support only 'lib', 'exe' and 'cgo' build modes currently + # and as a result we are going to generate only one build node per module + # (or program) + dispatch = { + 'exe': do_link_exe, + 'dll': do_link_exe, + 'lib': do_link_lib, + 'test': do_link_test + } + + exit_code = 1 + try: + with create_strip_symlink(): + dispatch[args.mode](args) + exit_code = 0 + except KeyError: + sys.stderr.write('Unknown build mode [{}]...\n'.format(args.mode)) + except subprocess.CalledProcessError as e: + sys.stderr.write('{} returned non-zero exit code {}.\n{}\n'.format(' '.join(e.cmd), e.returncode, e.output)) + exit_code = e.returncode + except AssertionError as e: + traceback.print_exc(file=sys.stderr) + except Exception as e: + sys.stderr.write('Unhandled exception [{}]...\n'.format(str(e))) + sys.exit(exit_code) diff --git a/build/scripts/ios_wrapper.py b/build/scripts/ios_wrapper.py new file mode 100644 index 00000000000..d3aa48387af --- /dev/null +++ b/build/scripts/ios_wrapper.py @@ -0,0 +1,180 @@ +import errno +import json +import os +import shutil +import subprocess +import sys +import tarfile +import plistlib + + +def ensure_dir(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno != errno.EEXIST or not os.path.isdir(path): + raise + + +def just_do_it(args): + if not args: + raise Exception('Not enough args!') + parts = [[]] + for arg in args: + if arg == '__DELIM__': + parts.append([]) + else: + parts[-1].append(arg) + if len(parts) != 3 or len(parts[0]) != 5: + raise Exception('Bad call') + bin_name, ibtool_path, main_out, app_name, module_dir = parts[0] + bin_name = os.path.basename(bin_name) + inputs, storyboard_user_flags = parts[1:] + plists, storyboards, signs, nibs, resources, signed_resources, plist_jsons, strings = [], [], [], [], [], [], [], [] + for i in inputs: + if i.endswith('.plist') or i.endswith('.partial_plist'): + plists.append(i) + elif i.endswith('.compiled_storyboard_tar'): + storyboards.append(i) + elif i.endswith('.xcent'): + signs.append(i) + elif i.endswith('.nib'): + nibs.append(i) + elif i.endswith('.resource_tar'): + resources.append(i) + elif i.endswith('.signed_resource_tar'): + signed_resources.append(i) + elif i.endswith('.plist_json'): + plist_jsons.append(i) + elif i.endswith('.strings_tar'): + strings.append(i) + else: + print >> sys.stderr, 'Unknown input:', i, 'ignoring' + if not plists: + raise Exception("Can't find plist files") + if not plists[0].endswith('.plist'): + print >> sys.stderr, "Main plist file can be defined incorretly" + if not storyboards: + print >> sys.stderr, "Storyboards list are empty" + if len(signs) > 1: + raise Exception("Too many .xcent files") + app_dir = os.path.join(module_dir, app_name + '.app') + ensure_dir(app_dir) + copy_nibs(nibs, module_dir, app_dir) + replaced_parameters = { + 'DEVELOPMENT_LANGUAGE': 'en', + 'EXECUTABLE_NAME': bin_name, + 'PRODUCT_BUNDLE_IDENTIFIER': 'Yandex.' + app_name, + 'PRODUCT_NAME': app_name, + } + replaced_templates = {} + for plist_json in plist_jsons: + with open(plist_json) as jsonfile: + for k, v in json.loads(jsonfile.read()).items(): + replaced_parameters[k] = v + for k, v in replaced_parameters.items(): + replaced_templates['$(' + k + ')'] = v + replaced_templates['${' + k + '}'] = v + make_main_plist(plists, os.path.join(app_dir, 'Info.plist'), replaced_templates) + link_storyboards(ibtool_path, storyboards, app_name, app_dir, storyboard_user_flags) + if resources: + extract_resources(resources, app_dir) + if signed_resources: + extract_resources(signed_resources, app_dir, sign=True) + if strings: + extract_resources(strings, app_dir, strings=True) + if not signs: + sign_file = os.path.join(module_dir, app_name + '.xcent') + with open(sign_file, 'w') as f: + f.write('''<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>com.apple.security.get-task-allow</key> + <true/> +</dict> +</plist> + ''') + else: + sign_file = signs[0] + sign_application(sign_file, app_dir) + make_archive(app_dir, main_out) + + +def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + +def copy_nibs(nibs, module_dir, app_dir): + for nib in nibs: + dst = os.path.join(app_dir, os.path.relpath(nib, module_dir)) + ensure_dir(os.path.dirname(dst)) + shutil.copyfile(nib, dst) + + +def make_main_plist(inputs, out, replaced_parameters): + united_data = {} + for i in inputs: + united_data.update(plistlib.readPlist(i)) + + def scan_n_replace(root): + if not isinstance(root, dict): + raise Exception('Invalid state') + for k in root: + if isinstance(root[k], list): + for i in xrange(len(root[k])): + if isinstance(root[k][i], dict): + scan_n_replace(root[k][i]) + elif root[k][i] in replaced_parameters: + root[k][i] = replaced_parameters[root[k][i]] + elif isinstance(root[k], dict): + scan_n_replace(root[k]) + else: + if root[k] in replaced_parameters: + root[k] = replaced_parameters[root[k]] + scan_n_replace(united_data) + plistlib.writePlist(united_data, out) + subprocess.check_call(['/usr/bin/plutil', '-convert', 'binary1', out]) + + +def link_storyboards(ibtool, archives, app_name, app_dir, flags): + unpacked = [] + for arc in archives: + unpacked.append(os.path.splitext(arc)[0] + 'c') + ensure_dir(unpacked[-1]) + with tarfile.open(arc) as a: + a.extractall(path=unpacked[-1]) + flags += [ + '--module', app_name, + '--link', app_dir, + ] + subprocess.check_call([ibtool] + flags + + ['--errors', '--warnings', '--notices', '--output-format', 'human-readable-text'] + + unpacked) + + +def sign_application(xcent, app_dir): + subprocess.check_call(['/usr/bin/codesign', '--force', '--sign', '-', '--entitlements', xcent, '--timestamp=none', app_dir]) + + +def extract_resources(resources, app_dir, strings=False, sign=False): + for res in resources: + with tarfile.open(res) as tf: + for tfinfo in tf: + tf.extract(tfinfo.name, app_dir) + if strings: + subprocess.check_call(['/usr/bin/plutil', '-convert', 'binary1', os.path.join(app_dir, tfinfo.name)]) + if sign: + subprocess.check_call(['/usr/bin/codesign', '--force', '--sign', '-', os.path.join(app_dir, tfinfo.name)]) + + +def make_archive(app_dir, output): + with tarfile.open(output, "w") as tar_handle: + for root, _, files in os.walk(app_dir): + for f in files: + tar_handle.add(os.path.join(root, f), arcname=os.path.join(os.path.basename(app_dir), + os.path.relpath(os.path.join(root, f), app_dir))) + + +if __name__ == '__main__': + just_do_it(sys.argv[1:]) diff --git a/build/scripts/java_pack_to_file.py b/build/scripts/java_pack_to_file.py new file mode 100644 index 00000000000..c8ab7c311b4 --- /dev/null +++ b/build/scripts/java_pack_to_file.py @@ -0,0 +1,43 @@ +import os +import re +import optparse + +JAVA_PACKAGE_REGEX = re.compile(r'^\s*package\s+(.*?);', flags=re.MULTILINE | re.DOTALL) +KOTLIN_PACKAGE_REGEX = re.compile(r'^\s*package\s+(.*?)^', flags=re.MULTILINE | re.DOTALL) + + +def parse_args(): + parser = optparse.OptionParser() + parser.add_option('-o', '--output') + parser.add_option('-a', '--source-root', dest='source_root') + return parser.parse_args() + + +def get_package_name(filename): + with open(filename) as afile: + content = afile.read() + if filename.endswith(".kt"): + match = KOTLIN_PACKAGE_REGEX.search(content) + if match: + return match.group(1).strip().replace('.', '/') + else: + match = JAVA_PACKAGE_REGEX.search(content) + if match: + return match.group(1).replace('\n\t ', '').replace('.', '/') + return '' + + +def write_coverage_sources(output, srcroot, files): + with open(output, 'w') as afile: + for filename in files: + pname = get_package_name(os.path.join(srcroot, filename)) + afile.write(os.path.join(pname, os.path.basename(filename)) + ':' + filename + '\n') + + +def main(): + opts, files = parse_args() + write_coverage_sources(opts.output, opts.source_root, files) + + +if __name__ == '__main__': + exit(main()) diff --git a/build/scripts/jni_swig.py b/build/scripts/jni_swig.py new file mode 100644 index 00000000000..4b2220430b1 --- /dev/null +++ b/build/scripts/jni_swig.py @@ -0,0 +1,46 @@ +import argparse +import subprocess +import re +import os +import tarfile + +def parse_args(): + parser = argparse.ArgumentParser(description='Wrapper script to invoke swig.') + parser.add_argument('--swig', help='path to the swig executable') + parser.add_argument('--default-module', type=str, help='swig -module argument value for inputs without %module statement') + parser.add_argument('--package-by-file', help='path to file which dir must be converted to swig -package argument') + parser.add_argument('--jsrc', help='jsrc output archive filename') + parser.add_argument('--src', help='input .swg file path') + parser.add_argument('--out-header', help='header file which must exist even if it was not generated by swig') + parser.add_argument('args', nargs="*", help='regular swig arguments') + + return parser.parse_args() + + +def path2pkg(path): + return path.replace('/', '.').replace('-', '_') + + +def main(args): + package = path2pkg(os.path.dirname(args.package_by_file)) + outdir = None + if args.jsrc: + outdir = package.replace('.', '/') + outdir_abs = os.path.join(os.path.dirname(args.jsrc), outdir) + if not os.path.exists(outdir_abs): + os.makedirs(outdir_abs) + cmd = [args.swig, '-c++', '-java', '-package', package] + (['-outdir', outdir_abs] if outdir is not None else []) + args.args + if '-module' not in args.args and args.default_module: + with open(args.src, 'r') as f: + if not re.search(r'(?m)^%module\b', f.read()): + cmd += ['-module', args.default_module] + subprocess.check_call(cmd + [args.src]) + if args.out_header and not os.path.exists(args.out_header): + open(args.out_header, 'w').close() + if args.jsrc: + with tarfile.open(args.jsrc, 'a') as tf: + tf.add(outdir_abs, arcname=outdir) + + +if __name__ == '__main__': + main(parse_args()) diff --git a/build/scripts/kt_copy.py b/build/scripts/kt_copy.py new file mode 100644 index 00000000000..f833c24ef41 --- /dev/null +++ b/build/scripts/kt_copy.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +import sys + +if __name__ == '__main__': + source = sys.argv[1] + destination = sys.argv[2] + source_root = sys.argv[3] + build_root = sys.argv[4] + with open(source, 'r') as afile: + src_content = afile.read() + src_content = src_content.replace(source_root + '/', "") + result_srcs = "" + for line in src_content.split("\n"): + if not line.startswith(build_root): + result_srcs += line + "\n" + with open(destination, 'w') as afile: + afile.write(result_srcs) diff --git a/build/scripts/link_asrc.py b/build/scripts/link_asrc.py new file mode 100644 index 00000000000..eec5fe09a87 --- /dev/null +++ b/build/scripts/link_asrc.py @@ -0,0 +1,84 @@ +import argparse +import itertools +import os +import tarfile + + +DELIM_JAVA = '__DELIM_JAVA__' +DELIM_RES = '__DELIM_RES__' +DELIM_ASSETS = '__DELIM_ASSETS__' +DELIM_AIDL = '__DELIM_AIDL__' + +DELIMS = ( + DELIM_JAVA, + DELIM_RES, + DELIM_ASSETS, + DELIM_AIDL, +) + +DESTS = { + DELIM_JAVA: 'src', + DELIM_RES: 'res', + DELIM_ASSETS: 'assets', + DELIM_AIDL: 'aidl', +} + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--asrcs', nargs='*') + parser.add_argument('--input', nargs='*') + parser.add_argument('--jsrcs', nargs='*') + parser.add_argument('--output', required=True) + parser.add_argument('--work', required=True) + + return parser.parse_args() + + +def main(): + args = parse_args() + + files = [] + parts = [] + + if args.input and len(args.input) > 0: + for x in args.input: + if x in DELIMS: + assert(len(parts) == 0 or len(parts[-1]) > 1) + parts.append([x]) + else: + assert(len(parts) > 0) + parts[-1].append(x) + assert(len(parts[-1]) > 1) + + if args.jsrcs and len(args.jsrcs): + src_dir = os.path.join(args.work, DESTS[DELIM_JAVA]) + os.makedirs(src_dir) + + for jsrc in filter(lambda x: x.endswith('.jsrc'), args.jsrcs): + with tarfile.open(jsrc, 'r') as tar: + names = tar.getnames() + if names and len(names) > 0: + parts.append([DELIM_JAVA, src_dir]) + parts[-1].extend(itertools.imap(lambda x: os.path.join(src_dir, x), names)) + tar.extractall(path=src_dir) + + if args.asrcs and len(args.asrcs): + for asrc in filter(lambda x: x.endswith('.asrc') and os.path.exists(x), args.asrcs): + with tarfile.open(asrc, 'r') as tar: + files.extend(tar.getnames()) + tar.extractall(path=args.work) + + with tarfile.open(args.output, 'w') as out: + for part in parts: + dest = DESTS[part[0]] + prefix = part[1] + for f in part[2:]: + out.add(f, arcname=os.path.join(dest, os.path.relpath(f, prefix))) + + for f in files: + out.add(os.path.join(args.work, f), arcname=f) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/link_dyn_lib.py b/build/scripts/link_dyn_lib.py new file mode 100644 index 00000000000..00215dfcaef --- /dev/null +++ b/build/scripts/link_dyn_lib.py @@ -0,0 +1,353 @@ +import sys +import os +import subprocess +import tempfile +import collections +import optparse +import pipes + +from process_whole_archive_option import ProcessWholeArchiveOption + + +def shlex_join(cmd): + # equivalent to shlex.join() in python 3 + return ' '.join( + pipes.quote(part) + for part in cmd + ) + + +def parse_export_file(p): + with open(p, 'r') as f: + for l in f: + l = l.strip() + + if l and '#' not in l: + words = l.split() + if len(words) == 2 and words[0] == 'linux_version': + yield {'linux_version': words[1]} + elif len(words) == 2: + yield {'lang': words[0], 'sym': words[1]} + elif len(words) == 1: + yield {'lang': 'C', 'sym': words[0]} + else: + raise Exception('unsupported exports line: ' + l) + + +def to_c(sym): + symbols = collections.deque(sym.split('::')) + c_prefixes = [ # demangle prefixes for c++ symbols + '_ZN', # namespace + '_ZTIN', # typeinfo for + '_ZTSN', # typeinfo name for + '_ZTTN', # VTT for + '_ZTVN', # vtable for + '_ZNK', # const methods + ] + c_sym = '' + while symbols: + s = symbols.popleft() + if s == '*': + c_sym += '*' + break + if '*' in s and len(s) > 1: + raise Exception('Unsupported format, cannot guess length of symbol: ' + s) + c_sym += str(len(s)) + s + if symbols: + raise Exception('Unsupported format: ' + sym) + if c_sym[-1] != '*': + c_sym += 'E*' + return ['{prefix}{sym}'.format(prefix=prefix, sym=c_sym) for prefix in c_prefixes] + + +def fix_darwin_param(ex): + for item in ex: + if item.get('linux_version'): + continue + + if item['lang'] == 'C': + yield '-Wl,-exported_symbol,_' + item['sym'] + elif item['lang'] == 'C++': + for sym in to_c(item['sym']): + yield '-Wl,-exported_symbol,_' + sym + else: + raise Exception('unsupported lang: ' + item['lang']) + + +def fix_gnu_param(arch, ex): + d = collections.defaultdict(list) + version = None + for item in ex: + if item.get('linux_version'): + if not version: + version = item.get('linux_version') + else: + raise Exception('More than one linux_version defined') + elif item['lang'] == 'C++': + d['C'].extend(to_c(item['sym'])) + else: + d[item['lang']].append(item['sym']) + + with tempfile.NamedTemporaryFile(mode='wt', delete=False) as f: + if version: + f.write('{} {{\nglobal:\n'.format(version)) + else: + f.write('{\nglobal:\n') + + for k, v in d.items(): + f.write(' extern "' + k + '" {\n') + + for x in v: + f.write(' ' + x + ';\n') + + f.write(' };\n') + + f.write('local: *;\n};\n') + + ret = ['-Wl,--version-script=' + f.name] + + if arch == 'ANDROID': + ret += ['-Wl,--export-dynamic'] + + return ret + + +def fix_windows_param(ex): + with tempfile.NamedTemporaryFile(delete=False) as def_file: + exports = [] + for item in ex: + if item.get('lang') == 'C': + exports.append(item.get('sym')) + def_file.write('EXPORTS\n') + for export in exports: + def_file.write(' {}\n'.format(export)) + return ['/DEF:{}'.format(def_file.name)] + + +MUSL_LIBS = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil' + +CUDA_LIBRARIES = { + '-lcublas_static': '-lcublas', + '-lcublasLt_static': '-lcublasLt', + '-lcudart_static': '-lcudart', + '-lcudnn_static': '-lcudnn', + '-lcufft_static_nocallback': '-lcufft', + '-lcurand_static': '-lcurand', + '-lcusolver_static': '-lcusolver', + '-lcusparse_static': '-lcusparse', + '-lmyelin_compiler_static': '-lmyelin', + '-lmyelin_executor_static': '-lnvcaffe_parser', + '-lmyelin_pattern_library_static': '', + '-lmyelin_pattern_runtime_static': '', + '-lnvinfer_static': '-lnvinfer', + '-lnvinfer_plugin_static': '-lnvinfer_plugin', + '-lnvonnxparser_static': '-lnvonnxparser', + '-lnvparsers_static': '-lnvparsers' +} + + +def fix_cmd(arch, c): + if arch == 'WINDOWS': + prefix = '/DEF:' + f = fix_windows_param + else: + prefix = '-Wl,--version-script=' + if arch in ('DARWIN', 'IOS', 'IOSSIM'): + f = fix_darwin_param + else: + f = lambda x: fix_gnu_param(arch, x) + + def do_fix(p): + if p.startswith(prefix) and p.endswith('.exports'): + fname = p[len(prefix):] + + return list(f(list(parse_export_file(fname)))) + + if p.endswith('.supp'): + return [] + + if p.endswith('.pkg.fake'): + return [] + + return [p] + + return sum((do_fix(x) for x in c), []) + + +def fix_cmd_for_musl(cmd): + flags = [] + for flag in cmd: + if flag not in MUSL_LIBS: + flags.append(flag) + return flags + + +def fix_cmd_for_dynamic_cuda(cmd): + flags = [] + for flag in cmd: + if flag in CUDA_LIBRARIES: + flags.append(CUDA_LIBRARIES[flag]) + else: + flags.append(flag) + return flags + + +def fix_blas_resolving(cmd): + # Intel mkl comes as a precompiled static library and thus can not be recompiled with sanitizer runtime instrumentation. + # That's why we prefer to use cblas instead of Intel mkl as a drop-in replacement under sanitizers. + # But if the library has dependencies on mkl and cblas simultaneously, it will get a linking error. + # Hence we assume that it's probably compiling without sanitizers and we can easily remove cblas to prevent multiple definitions of the same symbol at link time. + for arg in cmd: + if arg.startswith('contrib/libs') and arg.endswith('mkl-lp64.a'): + return [arg for arg in cmd if not arg.endswith('libcontrib-libs-cblas.a')] + return cmd + + +def parse_args(): + parser = optparse.OptionParser() + parser.disable_interspersed_args() + parser.add_option('--arch') + parser.add_option('--target') + parser.add_option('--soname') + parser.add_option('--fix-elf') + parser.add_option('--linker-output') + parser.add_option('--musl', action='store_true') + parser.add_option('--dynamic-cuda', action='store_true') + parser.add_option('--whole-archive-peers', action='append') + parser.add_option('--whole-archive-libs', action='append') + parser.add_option('--custom-step') + parser.add_option('--python') + return parser.parse_args() + + +if __name__ == '__main__': + opts, args = parse_args() + + assert opts.arch + assert opts.target + + cmd = fix_blas_resolving(args) + cmd = fix_cmd(opts.arch, cmd) + + if opts.musl: + cmd = fix_cmd_for_musl(cmd) + if opts.dynamic_cuda: + cmd = fix_cmd_for_dynamic_cuda(cmd) + + cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) + + if opts.custom_step: + assert opts.python + subprocess.check_call([opts.python] + [opts.custom_step] + cmd) + + if opts.linker_output: + stdout = open(opts.linker_output, 'w') + else: + stdout = sys.stdout + + proc = subprocess.Popen(cmd, shell=False, stderr=sys.stderr, stdout=stdout) + proc.communicate() + + if proc.returncode: + print >>sys.stderr, 'linker has failed with retcode:', proc.returncode + print >>sys.stderr, 'linker command:', shlex_join(cmd) + sys.exit(proc.returncode) + + if opts.fix_elf: + cmd = [opts.fix_elf, opts.target] + proc = subprocess.Popen(cmd, shell=False, stderr=sys.stderr, stdout=sys.stdout) + proc.communicate() + + if proc.returncode: + print >>sys.stderr, 'fix_elf has failed with retcode:', proc.returncode + print >>sys.stderr, 'fix_elf command:', shlex_join(cmd) + sys.exit(proc.returncode) + + if opts.soname and opts.soname != opts.target: + if os.path.exists(opts.soname): + os.unlink(opts.soname) + os.link(opts.target, opts.soname) + + +# -----------------Test---------------- # +def write_temp_file(content): + import yatest.common as yc + filename = yc.output_path('test.exports') + with open(filename, 'w') as f: + f.write(content) + return filename + + +def test_fix_cmd_darwin(): + export_file_content = """ +C++ geobase5::details::lookup_impl::* +C++ geobase5::hardcoded_service +""" + filename = write_temp_file(export_file_content) + args = ['-Wl,--version-script={}'.format(filename)] + assert fix_cmd('DARWIN', args) == [ + '-Wl,-exported_symbol,__ZN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTIN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTSN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTTN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTVN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZNK8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTIN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTSN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTTN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTVN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZNK8geobase517hardcoded_serviceE*', + ] + + +def run_fix_gnu_param(export_file_content): + filename = write_temp_file(export_file_content) + result = fix_gnu_param('LINUX', list(parse_export_file(filename)))[0] + version_script_path = result[len('-Wl,--version-script='):] + with open(version_script_path) as f: + content = f.read() + return content + + +def test_fix_gnu_param(): + export_file_content = """ +C++ geobase5::details::lookup_impl::* +C getFactoryMap +""" + assert run_fix_gnu_param(export_file_content) == """{ +global: + extern "C" { + _ZN8geobase57details11lookup_impl*; + _ZTIN8geobase57details11lookup_impl*; + _ZTSN8geobase57details11lookup_impl*; + _ZTTN8geobase57details11lookup_impl*; + _ZTVN8geobase57details11lookup_impl*; + _ZNK8geobase57details11lookup_impl*; + getFactoryMap; + }; +local: *; +}; +""" + + +def test_fix_gnu_param_with_linux_version(): + export_file_content = """ +C++ geobase5::details::lookup_impl::* +linux_version ver1.0 +C getFactoryMap +""" + assert run_fix_gnu_param(export_file_content) == """ver1.0 { +global: + extern "C" { + _ZN8geobase57details11lookup_impl*; + _ZTIN8geobase57details11lookup_impl*; + _ZTSN8geobase57details11lookup_impl*; + _ZTTN8geobase57details11lookup_impl*; + _ZTVN8geobase57details11lookup_impl*; + _ZNK8geobase57details11lookup_impl*; + getFactoryMap; + }; +local: *; +}; +""" diff --git a/build/scripts/link_exe.py b/build/scripts/link_exe.py new file mode 100644 index 00000000000..eec8b20e1d9 --- /dev/null +++ b/build/scripts/link_exe.py @@ -0,0 +1,186 @@ +import sys +import subprocess +import optparse + +from process_whole_archive_option import ProcessWholeArchiveOption + + +def get_leaks_suppressions(cmd): + supp, newcmd = [], [] + for arg in cmd: + if arg.endswith(".supp"): + supp.append(arg) + else: + newcmd.append(arg) + return supp, newcmd + + +MUSL_LIBS = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil' + + +CUDA_LIBRARIES = { + '-lcublas_static': '-lcublas', + '-lcublasLt_static': '-lcublasLt', + '-lcudart_static': '-lcudart', + '-lcudnn_static': '-lcudnn', + '-lcufft_static_nocallback': '-lcufft', + '-lcurand_static': '-lcurand', + '-lcusolver_static': '-lcusolver', + '-lcusparse_static': '-lcusparse', + '-lmyelin_compiler_static': '-lmyelin', + '-lmyelin_executor_static': '-lnvcaffe_parser', + '-lmyelin_pattern_library_static': '', + '-lmyelin_pattern_runtime_static': '', + '-lnvinfer_static': '-lnvinfer', + '-lnvinfer_plugin_static': '-lnvinfer_plugin', + '-lnvonnxparser_static': '-lnvonnxparser', + '-lnvparsers_static': '-lnvparsers' +} + + +def remove_excessive_flags(cmd): + flags = [] + for flag in cmd: + if not flag.endswith('.ios.interface') and not flag.endswith('.pkg.fake'): + flags.append(flag) + return flags + + +def fix_sanitize_flag(cmd): + """ + Remove -fsanitize=address flag if sanitazers are linked explicitly for linux target. + """ + for flag in cmd: + if flag.startswith('--target') and 'linux' not in flag.lower(): + # use toolchained sanitize libraries + return cmd + + CLANG_RT = 'contrib/libs/clang14-rt/lib/' + sanitize_flags = { + '-fsanitize=address': CLANG_RT + 'asan', + '-fsanitize=memory': CLANG_RT + 'msan', + '-fsanitize=leak': CLANG_RT + 'lsan', + '-fsanitize=undefined': CLANG_RT + 'ubsan', + '-fsanitize=thread': CLANG_RT + 'tsan' + } + + used_sanitize_libs = [] + aux = [] + for flag in cmd: + if flag.startswith('-fsanitize-coverage='): + # do not link sanitizer libraries from clang + aux.append('-fno-sanitize-link-runtime') + if flag in sanitize_flags and any(s.startswith(sanitize_flags[flag]) for s in cmd): + # exclude '-fsanitize=' if appropriate library is linked explicitly + continue + if any(flag.startswith(lib) for lib in sanitize_flags.values()): + used_sanitize_libs.append(flag) + continue + aux.append(flag) + + # move sanitize libraries out of the repeatedly searched group of archives + flags = [] + for flag in aux: + if flag == '-Wl,--start-group': + flags += ['-Wl,--whole-archive'] + used_sanitize_libs + ['-Wl,--no-whole-archive'] + flags.append(flag) + + return flags + + +def fix_cmd_for_musl(cmd): + flags = [] + for flag in cmd: + if flag not in MUSL_LIBS: + flags.append(flag) + return flags + + +def fix_cmd_for_dynamic_cuda(cmd): + flags = [] + for flag in cmd: + if flag in CUDA_LIBRARIES: + flags.append(CUDA_LIBRARIES[flag]) + else: + flags.append(flag) + return flags + + +def gen_default_suppressions(inputs, output, source_root): + import collections + import os + + supp_map = collections.defaultdict(set) + for filename in inputs: + sanitizer = os.path.basename(filename).split('.', 1)[0] + with open(os.path.join(source_root, filename)) as src: + for line in src: + line = line.strip() + if not line or line.startswith('#'): + continue + supp_map[sanitizer].add(line) + + with open(output, "wb") as dst: + for supp_type, supps in supp_map.items(): + dst.write('extern "C" const char *__%s_default_suppressions() {\n' % supp_type) + dst.write(' return "{}";\n'.format('\\n'.join(sorted(supps)))) + dst.write('}\n') + + +def fix_blas_resolving(cmd): + # Intel mkl comes as a precompiled static library and thus can not be recompiled with sanitizer runtime instrumentation. + # That's why we prefer to use cblas instead of Intel mkl as a drop-in replacement under sanitizers. + # But if the library has dependencies on mkl and cblas simultaneously, it will get a linking error. + # Hence we assume that it's probably compiling without sanitizers and we can easily remove cblas to prevent multiple definitions of the same symbol at link time. + for arg in cmd: + if arg.startswith('contrib/libs') and arg.endswith('mkl-lp64.a'): + return [arg for arg in cmd if not arg.endswith('libcontrib-libs-cblas.a')] + return cmd + + +def parse_args(): + parser = optparse.OptionParser() + parser.disable_interspersed_args() + parser.add_option('--musl', action='store_true') + parser.add_option('--custom-step') + parser.add_option('--python') + parser.add_option('--source-root') + parser.add_option('--dynamic-cuda', action='store_true') + parser.add_option('--arch') + parser.add_option('--linker-output') + parser.add_option('--whole-archive-peers', action='append') + parser.add_option('--whole-archive-libs', action='append') + return parser.parse_args() + + +if __name__ == '__main__': + opts, args = parse_args() + + cmd = fix_blas_resolving(args) + cmd = remove_excessive_flags(cmd) + if opts.musl: + cmd = fix_cmd_for_musl(cmd) + + cmd = fix_sanitize_flag(cmd) + + if opts.dynamic_cuda: + cmd = fix_cmd_for_dynamic_cuda(cmd) + cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) + + if opts.custom_step: + assert opts.python + subprocess.check_call([opts.python] + [opts.custom_step] + args) + + supp, cmd = get_leaks_suppressions(cmd) + if supp: + src_file = "default_suppressions.cpp" + gen_default_suppressions(supp, src_file, opts.source_root) + cmd += [src_file] + + if opts.linker_output: + stdout = open(opts.linker_output, 'w') + else: + stdout = sys.stdout + + rc = subprocess.call(cmd, shell=False, stderr=sys.stderr, stdout=stdout) + sys.exit(rc) diff --git a/build/scripts/link_fat_obj.py b/build/scripts/link_fat_obj.py new file mode 100644 index 00000000000..45df247d107 --- /dev/null +++ b/build/scripts/link_fat_obj.py @@ -0,0 +1,97 @@ +import argparse +import subprocess +import sys + +from process_whole_archive_option import ProcessWholeArchiveOption + +YA_ARG_PREFIX = '-Ya,' + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--obj') + parser.add_argument('--globals-lib') + parser.add_argument('--lib', required=True) + parser.add_argument('--arch', required=True) + parser.add_argument('--build-root', default=None) + parser.add_argument('--with-own-obj', action='store_true', default=False) + parser.add_argument('--with-global-srcs', action='store_true', default=False) + + groups = {} + args_list = groups.setdefault('default', []) + for arg in sys.argv[1:]: + if arg == '--with-own-obj': + groups['default'].append(arg) + elif arg == '--globals-lib': + groups['default'].append(arg) + elif arg == '--with-global-srcs': + groups['default'].append(arg) + elif arg.startswith(YA_ARG_PREFIX): + group_name = arg[len(YA_ARG_PREFIX):] + args_list = groups.setdefault(group_name, []) + else: + args_list.append(arg) + + return parser.parse_args(groups['default']), groups + + +def strip_suppression_files(srcs): + return [s for s in srcs if not s.endswith('.supp')] + + +def strip_forceload_prefix(srcs): + force_load_prefix = '-Wl,-force_load,' + return list(map(lambda lib: lib[lib.startswith(force_load_prefix) and len(force_load_prefix):], srcs)) + + +def main(): + args, groups = get_args() + + # Inputs + auto_input = groups['input'] + + # Outputs + lib_output = args.lib + obj_output = args.obj + + # Dependencies + global_srcs = groups['global_srcs'] + global_srcs = strip_suppression_files(global_srcs) + global_srcs = ProcessWholeArchiveOption(args.arch).construct_cmd(global_srcs) + global_srcs = strip_forceload_prefix(global_srcs) + peers = groups['peers'] + + # Tools + linker = groups['linker'] + archiver = groups['archiver'] + + do_link = linker + ['-o', obj_output, '-Wl,-r', '-nodefaultlibs', '-nostartfiles'] + global_srcs + auto_input + do_archive = archiver + [lib_output] + peers + do_globals = None + if args.globals_lib: + do_globals = archiver + [args.globals_lib] + auto_input + global_srcs + if args.with_own_obj: + do_archive += auto_input + if args.with_global_srcs: + do_archive += global_srcs + + def call(c): + proc = subprocess.Popen(c, shell=False, stderr=sys.stderr, stdout=sys.stdout, cwd=args.build_root) + proc.communicate() + return proc.returncode + + if obj_output: + link_res = call(do_link) + if link_res: + sys.exit(link_res) + + if do_globals: + glob_res = call(do_globals) + if glob_res: + sys.exit(glob_res) + + sys.exit(call(do_archive)) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/link_jsrc.py b/build/scripts/link_jsrc.py new file mode 100644 index 00000000000..feae72fe4e3 --- /dev/null +++ b/build/scripts/link_jsrc.py @@ -0,0 +1,27 @@ +import argparse +import tarfile + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--input', nargs='*') + parser.add_argument('--output', required=True) + + return parser.parse_args() + + +def main(): + args = parse_args() + + with tarfile.open(args.output, 'w') as dest: + for jsrc in [j for j in args.input if j.endswith('.jsrc')]: + with tarfile.open(jsrc, 'r') as src: + for item in [m for m in src.getmembers() if m.name != '']: + if item.isdir(): + dest.addfile(item) + else: + dest.addfile(item, src.extractfile(item)) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/link_lib.py b/build/scripts/link_lib.py new file mode 100644 index 00000000000..e73c02027aa --- /dev/null +++ b/build/scripts/link_lib.py @@ -0,0 +1,101 @@ +import sys +import subprocess +import tempfile +import os +import shutil + + +class Opts(object): + def __init__(self, args): + self.archiver = args[0] + self.arch_type = args[1] + self.llvm_ar_format = args[2] + self.build_root = args[3] + self.plugin = args[4] + self.output = args[5] + auto_input = args[6:] + + self.need_modify = False + self.extra_args = [] + + if self.arch_type.endswith('_AR'): + if self.arch_type == 'GNU_AR': + self.create_flags = ['rcs'] + self.modify_flags = ['-M'] + elif self.arch_type == 'LLVM_AR': + self.create_flags = ['rcs', '--format=%s' % self.llvm_ar_format] + self.modify_flags = ['-M'] + self.need_modify = any(item.endswith('.a') for item in auto_input) + if self.need_modify: + self.objs = list( filter(lambda x: x.endswith('.o'), auto_input) ) + self.libs = list( filter(lambda x: x.endswith('.a'), auto_input) ) + else: + self.objs = auto_input + self.libs = [] + self.output_opts = [self.output] + elif self.arch_type == 'LIBTOOL': + self.create_flags = ['-static'] + self.objs = auto_input + self.libs = [] + self.output_opts = ['-o', self.output] + elif self.arch_type == 'LIB': + self.create_flags = [] + self.extra_args = list( filter(lambda x: x.startswith('/'), auto_input) ) + self.objs = list( filter(lambda x: not x.startswith('/'), auto_input) ) + self.libs = [] + self.output_opts = ['/OUT:' + self.output] + + self.plugin_flags = ['--plugin', self.plugin] if self.plugin != 'None' else [] + + +def get_opts(args): + return Opts(args) + + +if __name__ == "__main__": + opts = get_opts(sys.argv[1:]) + + # There is a bug in llvm-ar. Some files with size slightly greater 2^32 + # still have GNU format instead of GNU64 and cause link problems. + # Workaround just lowers llvm-ar's GNU64 threshold to 2^31. + if opts.arch_type == 'LLVM_AR': + os.environ['SYM64_THRESHOLD'] = '31' + + def call(): + try: + p = subprocess.Popen(cmd, stdin=stdin, cwd=opts.build_root) + rc = p.wait() + return rc + except OSError as e: + raise Exception('while running %s: %s' % (' '.join(cmd), e)) + + try: + os.unlink(opts.output) + except OSError: + pass + + if not opts.need_modify: + cmd = [opts.archiver] + opts.create_flags + opts.plugin_flags + opts.extra_args + opts.output_opts + opts.objs + stdin = None + exit_code = call() + elif len(opts.objs) == 0 and len(opts.libs) == 1: + shutil.copy(opts.libs[0], opts.output) + exit_code = 0 + else: + temp = tempfile.NamedTemporaryFile(dir=os.path.dirname(opts.output), delete=False) + + with open(temp.name, 'w') as tmp: + tmp.write('CREATE {0}\n'.format(opts.output)) + for lib in opts.libs: + tmp.write('ADDLIB {0}\n'.format(lib)) + for obj in opts.objs: + tmp.write('ADDMOD {0}\n'.format(obj)) + tmp.write('SAVE\n') + tmp.write('END\n') + cmd = [opts.archiver] + opts.modify_flags + opts.plugin_flags + stdin = open(temp.name) + exit_code = call() + os.remove(temp.name) + + if exit_code != 0: + raise Exception('{0} returned non-zero exit code {1}. Stop.'.format(' '.join(cmd), exit_code)) diff --git a/build/scripts/list.py b/build/scripts/list.py new file mode 100644 index 00000000000..7c3b2ae6950 --- /dev/null +++ b/build/scripts/list.py @@ -0,0 +1,4 @@ +import sys
+
+if __name__ == "__main__":
+ print(' '.join(sys.argv[1:]))
diff --git a/build/scripts/llvm_opt_wrapper.py b/build/scripts/llvm_opt_wrapper.py new file mode 100644 index 00000000000..38ca3004afc --- /dev/null +++ b/build/scripts/llvm_opt_wrapper.py @@ -0,0 +1,18 @@ +import subprocess +import sys + + +def fix(s): + # we use '#' instead of ',' because ymake always splits args by comma + if 'internalize' in s: + return s.replace('#', ',') + + return s + + +if __name__ == '__main__': + path = sys.argv[1] + args = [fix(s) for s in [path] + sys.argv[2:]] + + rc = subprocess.call(args, shell=False, stderr=sys.stderr, stdout=sys.stdout) + sys.exit(rc) diff --git a/build/scripts/make_container.py b/build/scripts/make_container.py new file mode 100644 index 00000000000..a485baffdda --- /dev/null +++ b/build/scripts/make_container.py @@ -0,0 +1,94 @@ +import os +import shutil +import stat +import struct +import subprocess +import sys + +import container # 1 + + +def main(output_path, entry_path, input_paths, squashfs_path): + output_tmp_path = output_path + '.tmp' + shutil.copy2(entry_path, output_tmp_path) + st = os.stat(output_tmp_path) + os.chmod(output_tmp_path, st.st_mode | stat.S_IWUSR) + + layer_paths = [] + other_paths = [] + for input_path in input_paths: + (layer_paths if input_path.endswith('.container_layer') else other_paths).append(input_path) + + if len(other_paths) == 0: + raise Exception('No program in container dependencies') + + if len(other_paths) > 1: + raise Exception('Multiple non-layer inputs') + + program_path = other_paths[0] + program_container_path = os.path.basename(program_path) + + os.symlink(program_container_path, 'entry') + add_cmd = [ os.path.join(squashfs_path, 'mksquashfs') ] + add_cmd.extend([program_path, 'entry', 'program_layer']) + subprocess.run(add_cmd) + + layer_paths.append('program_layer') + + container.join_layers(layer_paths, 'container_data', squashfs_path) + + size = 0 + block_size = 1024 * 1024 + + with open(output_tmp_path, 'ab') as output: + with open('container_data', 'rb') as input_: + while True: + data = input_.read(block_size) + output.write(data) + size += len(data) + + if len(data) < block_size: + break + + with open(os.path.join(squashfs_path, 'unsquashfs'), 'rb') as input_: + while True: + data = input_.read(block_size) + output.write(data) + size += len(data) + + if len(data) == 0: + break + + + output.write(struct.pack('<Q', size)) + + os.rename(output_tmp_path, output_path) + + +def entry(): + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument('-o', '--output', required=True) + parser.add_argument('-s', '--squashfs-path', required=True) + parser.add_argument('input', nargs='*') + + args = parser.parse_args() + + def is_container_entry(path): + return os.path.basename(path) == '_container_entry' + + input_paths = [] + entry_paths = [] + + for input_path in args.input: + (entry_paths if is_container_entry(input_path) else input_paths).append(input_path) + + if len(entry_paths) != 1: + raise Exception('Could not select container entry from {}'.format(entry_paths)) + + return main(args.output, entry_paths[0], input_paths, args.squashfs_path) + + +if __name__ == '__main__': + sys.exit(entry()) diff --git a/build/scripts/make_container_layer.py b/build/scripts/make_container_layer.py new file mode 100644 index 00000000000..4f61f5a2e5a --- /dev/null +++ b/build/scripts/make_container_layer.py @@ -0,0 +1,24 @@ +import sys + +import container # 1 + + +class UserError(Exception): + pass + + +def entry(): + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument('-o', '--output', required=True) + parser.add_argument('-s', '--squashfs-path', required=True) + parser.add_argument('input', nargs='*') + + args = parser.parse_args() + + return container.join_layers(args.input, args.output, args.squashfs_path) + + +if __name__ == '__main__': + sys.exit(entry()) diff --git a/build/scripts/make_java_classpath_file.py b/build/scripts/make_java_classpath_file.py new file mode 100644 index 00000000000..c70a7876d73 --- /dev/null +++ b/build/scripts/make_java_classpath_file.py @@ -0,0 +1,26 @@ +import os +import sys + +import process_command_files as pcf + + +def make_cp_file(args): + source = args[0] + destination = args[1] + with open(source) as src: + lines = [l.strip() for l in src if l.strip()] + with open(destination, 'w') as dst: + dst.write(os.pathsep.join(lines)) + +def make_cp_file_from_args(args): + destination = args[0] + with open(destination, 'w') as dst: + dst.write(os.pathsep.join(args[1:])) + + +if __name__ == '__main__': + args = pcf.get_args(sys.argv[1:]) + if sys.argv[1] != '--from-args': + make_cp_file(args) + else: + make_cp_file_from_args(args[1:]) diff --git a/build/scripts/make_java_srclists.py b/build/scripts/make_java_srclists.py new file mode 100644 index 00000000000..65174bafd7a --- /dev/null +++ b/build/scripts/make_java_srclists.py @@ -0,0 +1,128 @@ +import os +import sys +import argparse + +import process_command_files as pcf +import java_pack_to_file as jcov + + +def writelines(f, rng): + f.writelines(item + '\n' for item in rng) + + +def add_rel_src_to_coverage(coverage, src, source_root): + rel = os.path.relpath(src, source_root) + if not rel.startswith('..' + os.path.sep): + coverage.append(rel) + + +def main(): + args = pcf.get_args(sys.argv[1:]) + parser = argparse.ArgumentParser() + parser.add_argument('--moddir') + parser.add_argument('--java') + parser.add_argument('--groovy') + parser.add_argument('--kotlin') + parser.add_argument('--coverage') + parser.add_argument('--source-root') + args, remaining_args = parser.parse_known_args(args) + + java = [] + kotlin = [] + groovy = [] + coverage = [] + + cur_resources_list_file = None + cur_jsources_list_file = None + cur_srcdir = None + cur_resources = [] + cur_jsources = [] + + FILE_ARG = 1 + RESOURCES_DIR_ARG = 2 + SRCDIR_ARG = 3 + JSOURCES_DIR_ARG = 4 + + next_arg=FILE_ARG + + for src in remaining_args: + if next_arg == RESOURCES_DIR_ARG: + assert cur_resources_list_file is None + cur_resources_list_file = src + next_arg = FILE_ARG + continue + elif next_arg == JSOURCES_DIR_ARG: + assert cur_jsources_list_file is None + cur_jsources_list_file = src + next_arg = FILE_ARG + continue + elif next_arg == SRCDIR_ARG: + assert cur_srcdir is None + cur_srcdir = src if os.path.isabs(src) else os.path.join(args.moddir, src) + next_arg = FILE_ARG + continue + + if src.endswith(".java"): + java.append(src) + kotlin.append(src) + if args.coverage and args.source_root: + add_rel_src_to_coverage(coverage, src, args.source_root) + elif args.kotlin and src.endswith(".kt"): + kotlin.append(src) + if args.coverage and args.source_root: + add_rel_src_to_coverage(coverage, src, args.source_root) + elif args.groovy and src.endswith(".groovy"): + groovy.append(src) + else: + if src == '--resources': + if cur_resources_list_file is not None: + with open(cur_resources_list_file, 'w') as f: + writelines(f, cur_resources) + cur_resources_list_file = None + cur_srcdir = None + cur_resources = [] + next_arg = RESOURCES_DIR_ARG + continue + if src == '--jsources': + if cur_jsources_list_file is not None: + with open(cur_jsources_list_file, 'w') as f: + writelines(f, cur_jsources) + cur_jsources_list_file = None + cur_jsources = [] + next_arg = JSOURCES_DIR_ARG + continue + elif src == '--srcdir': + next_arg = SRCDIR_ARG + continue + else: + assert cur_srcdir is not None and cur_resources_list_file is not None + cur_resources.append(os.path.relpath(src, cur_srcdir)) + + if cur_jsources_list_file is not None: + assert cur_srcdir is not None + cur_jsources.append(os.path.relpath(src, cur_srcdir)) + + if cur_resources_list_file is not None: + with open(cur_resources_list_file, 'w') as f: + writelines(f, cur_resources) + if cur_jsources_list_file is not None: + with open(cur_jsources_list_file, 'w') as f: + writelines(f, cur_jsources) + + if args.java: + with open(args.java, 'w') as f: + writelines(f, java) + if args.kotlin: + with open(args.kotlin, 'w') as f: + writelines(f, kotlin) + if args.groovy: + with open(args.groovy, 'w') as f: + writelines(f, groovy) + if args.coverage: + jcov.write_coverage_sources(args.coverage, args.source_root, coverage) + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/build/scripts/make_manifest_from_bf.py b/build/scripts/make_manifest_from_bf.py new file mode 100644 index 00000000000..bfea3ba3de1 --- /dev/null +++ b/build/scripts/make_manifest_from_bf.py @@ -0,0 +1,28 @@ +import sys +import zipfile +import os +import re + + +def prepare_path(path): + return ('file:/' + path.lstrip('/')) if os.path.isabs(path) else path + + +def main(args): + bf, mf = args[0], args[1] + if not os.path.exists(os.path.dirname(mf)): + os.makedirs(os.path.dirname(mf)) + with open(bf) as f: + class_path = f.read().strip() + class_path = ' '.join(map(prepare_path, class_path.split('\n'))) + with zipfile.ZipFile(mf, 'w') as zf: + lines = [] + while class_path: + lines.append(class_path[:60]) + class_path = class_path[60:] + if lines: + zf.writestr('META-INF/MANIFEST.MF', 'Manifest-Version: 1.0\nClass-Path: \n ' + '\n '.join(lines) + ' \n\n') + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/build/scripts/mangle_typeinfo_names.py b/build/scripts/mangle_typeinfo_names.py new file mode 100755 index 00000000000..8f30a465523 --- /dev/null +++ b/build/scripts/mangle_typeinfo_names.py @@ -0,0 +1,317 @@ +#!/usr/bin/env python + +import base64 +import hashlib +import io +import os +import struct +import subprocess +import sys +from collections import namedtuple + + +""" +ELF-64 Object File Format: https://uclibc.org/docs/elf-64-gen.pdf +ELF-32: https://uclibc.org/docs/elf.pdf +""" + + +MANGLED_HASH_SIZE = 15 + +# len(base64(sha1(name)[:MANGLED_HASH_SIZE]) + '\x00') +MANGLED_NAME_SIZE = 21 + + +ArObject = namedtuple('ArObject', ['header', 'data']) + +ElfSection = namedtuple('ElfSection', ['header_offset', 'name', 'data_offset', 'size', 'link', 'entry_size']) + + +def find(it, pred): + return next(iter(filter(pred, it)), None) + + +def mangle_name(name_bytes): + sha1 = hashlib.sha1() + sha1.update(name_bytes) + dgst = sha1.digest() + return base64.b64encode(dgst[:MANGLED_HASH_SIZE]) + + +def unpack(format, buffer, offset=0): + return struct.unpack(format, buffer[offset : offset + struct.calcsize(format)]) + + +def unpack_section_header(buffer, offset, elf64): + # read sh_name, sh_offset, sh_size, sh_link, sh_entsize from section headers (Elf64_Shdr/Elf32_Shdr): + # + # typedef struct + # { + # Elf64_Word sh_name; /* Section name */ + # Elf64_Word sh_type; /* Section type */ + # Elf64_Xword sh_flags; /* Section attributes */ + # Elf64_Addr sh_addr; /* Virtual address in memory */ + # Elf64_Off sh_offset; /* Offset in file */ + # Elf64_Xword sh_size; /* Size of section */ + # Elf64_Word sh_link; /* Link to other section */ + # Elf64_Word sh_info; /* Miscellaneous information */ + # Elf64_Xword sh_addralign; /* Address alignment boundary */ + # Elf64_Xword sh_entsize; /* Size of entries, if section has table */ + # } Elf64_Shdr; + # + # typedef struct { + # Elf32_Word sh_name; + # Elf32_Word sh_type; + # Elf32_Word sh_flags; + # Elf32_Addr sh_addr; + # Elf32_Off sh_offset; + # Elf32_Word sh_size; + # Elf32_Word sh_link; + # Elf32_Word sh_info; + # Elf32_Word sh_addralign; + # Elf32_Word sh_entsize; + # } Elf32_Shdr; + + section_header_format = '< L 20x Q Q L 12x Q' if elf64 else '< L 12x L L L 8x L' + return ElfSection(offset, *unpack(section_header_format, buffer, offset)) + + +def read_elf_sections(elf_data, elf64): + # read e_shoff, e_shentsize, e_shnum, e_shstrndx from elf header (Elf64_Ehdr/Elf32_Ehdr): + # + # typedef struct + # { + # unsigned char e_ident[16]; /* ELF identification */ + # Elf64_Half e_type; /* Object file type */ + # Elf64_Half e_machine; /* Machine type */ + # Elf64_Word e_version; /* Object file version */ + # Elf64_Addr e_entry; /* Entry point address */ + # Elf64_Off e_phoff; /* Program header offset */ + # Elf64_Off e_shoff; /* Section header offset */ + # Elf64_Word e_flags; /* Processor-specific flags */ + # Elf64_Half e_ehsize; /* ELF header size */ + # Elf64_Half e_phentsize; /* Size of program header entry */ + # Elf64_Half e_phnum; /* Number of program header entries */ + # Elf64_Half e_shentsize; /* Size of section header entry */ + # Elf64_Half e_shnum; /* Number of section header entries */ + # Elf64_Half e_shstrndx; /* Section name string table index */ + # } Elf64_Ehdr; + # + # #define EI_NIDENT 16 + # + # typedef struct { + # unsigned char e_ident[EI_NIDENT]; + # Elf32_Half e_type; + # Elf32_Half e_machine; + # Elf32_Word e_version; + # Elf32_Addr e_entry; + # Elf32_Off e_phoff; + # Elf32_Off e_shoff; + # Elf32_Word e_flags; + # Elf32_Half e_ehsize; + # Elf32_Half e_phentsize; + # Elf32_Half e_phnum; + # Elf32_Half e_shentsize; + # Elf32_Half e_shnum; + # Elf32_Half e_shstrndx; + # } Elf32_Ehdr; + + section_header_offset, section_header_entry_size, section_header_entries_number,\ + section_name_string_table_index = unpack('< Q 10x 3H', elf_data, 40) if elf64 else unpack('< L 10x 3H', elf_data, 32) + + # https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.sheader.html + # If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), e_shnum has the value SHN_UNDEF (0) + # and the actual number of section header table entries is contained in the sh_size field of the section header + # at index 0 (otherwise, the sh_size member of the initial entry contains 0). + if section_header_entries_number == 0: + section_header_entries_number = unpack_section_header(elf_data, section_header_offset, elf64).size + + sections = [unpack_section_header(elf_data, section_header_offset + i * section_header_entry_size, elf64) + for i in range(section_header_entries_number)] + + # section names data + section_names_section = sections[section_name_string_table_index] + section_names_data = elf_data[section_names_section.data_offset : section_names_section.data_offset + section_names_section.size] + + # read section names + for i, section in enumerate(sections): + sections[i] = section._replace( + name=section_names_data[section.name : section_names_data.find(b'\x00', section.name)].decode()) + + return sections + + +def mangle_elf_typeinfo_names(elf_data, elf64, sections): + symbol_sizes = {} + + for sect_i, section in enumerate(sections): + if not section.name.startswith('.rodata._ZTS') or section.size <= MANGLED_NAME_SIZE: + continue + + typeinfo_name = elf_data[section.data_offset : section.data_offset + section.size] + mangled = mangle_name(typeinfo_name.rstrip(b'\x00')) + b'\x00' + if len(mangled) >= len(typeinfo_name): + continue + + # patch section data + elf_data[section.data_offset : section.data_offset + len(mangled)] = mangled + # patch section size (sh_size in Elf64_Shdr/Elf32_Shdr) + if elf64: + elf_data[section.header_offset + 32 : section.header_offset + 40] = struct.pack('< Q', len(mangled)) + else: + elf_data[section.header_offset + 20 : section.header_offset + 24] = struct.pack('< L', len(mangled)) + + symbol_sizes[section.name[len('.rodata.'):]] = len(mangled) + + return symbol_sizes + + +def patch_elf_symbol_sizes(elf_data, elf64, sections, symbol_sizes): + symtab = find(sections, lambda s: s.name == '.symtab') + if not symtab: + return + + for sym_i in range(symtab.size / symtab.entry_size): + symtab_entry_offset = symtab.data_offset + symtab.entry_size * sym_i + symtab_entry = elf_data[symtab_entry_offset : symtab_entry_offset + symtab.entry_size] + + # unpack symbol name offset in symbols name section (st_name) from Elf64_Sym/Elf32_Sym: + # + # typedef struct + # { + # Elf64_Word st_name; /* Symbol name */ + # unsigned char st_info; /* Type and Binding attributes */ + # unsigned char st_other; /* Reserved */ + # Elf64_Half st_shndx; /* Section table index */ + # Elf64_Addr st_value; /* Symbol value */ + # Elf64_Xword st_size; /* Size of object (e.g., common) */ + # } Elf64_Sym; + # + # typedef struct { + # Elf32_Word st_name; + # Elf32_Addr st_value; + # Elf32_Word st_size; + # unsigned char st_info; + # unsigned char st_other; + # Elf32_Half st_shndx; + # } Elf32_Sym; + symbol_name_offset = unpack('< L', symtab_entry)[0] + + # symbol name offset from start of elf file + global_name_offset = sections[symtab.link].data_offset + symbol_name_offset + + name = elf_data[global_name_offset : elf_data.find(b'\x00', global_name_offset)].decode() + symbol_size = symbol_sizes.get(name) + if symbol_size: + # patch st_size in Elf64_Sym/Elf32_Sym + if elf64: + elf_data[symtab_entry_offset + 16 : symtab_entry_offset + 24] = struct.pack('< Q', symbol_size) + else: + elf_data[symtab_entry_offset + 8 : symtab_entry_offset + 12] = struct.pack('< L', symbol_size) + + +def mangle_elf(elf_data): + elf_data = bytearray(elf_data) + + ei_mag, ei_class = unpack('4s B', elf_data) + assert ei_mag == b'\x7fELF' + if ei_class == 1: # ELFCLASS32 + elf64 = False + elif ei_class == 2: # ELFCLASS64 + elf64 = True + else: + raise Exception('unknown ei_class: ' + str(ei_class)) + + sections = read_elf_sections(elf_data, elf64) + + symbol_sizes = mangle_elf_typeinfo_names(elf_data, elf64, sections) + + if len(symbol_sizes) != 0: + patch_elf_symbol_sizes(elf_data, elf64, sections, symbol_sizes) + + return elf_data + + +def read_ar_object(ar): + # ar format: https://docs.oracle.com/cd/E36784_01/html/E36873/ar.h-3head.html + # + # #define ARFMAG "`\n" /* header trailer string */ + # + # struct ar_hdr /* file member header */ + # { + # char ar_name[16]; /* '/' terminated file member name */ + # char ar_date[12]; /* file member date */ + # char ar_uid[6] /* file member user identification */ + # char ar_gid[6] /* file member group identification */ + # char ar_mode[8] /* file member mode (octal) */ + # char ar_size[10]; /* file member size */ + # char ar_fmag[2]; /* header trailer string */ + # }; + + header = ar.read(60) + if len(header) == 0: + return None + assert header[58:] == b'`\n' + + size = int(bytes(header[48:58]).decode().rstrip(' ')) + data = ar.read(size) + return ArObject(header, data) + + +def is_elf_data(data): + return data[:4] == b'\x7fELF' + + +def mangle_ar_impl(ar, out): + ar_magic = ar.read(8) + if ar_magic != b'!<arch>\n': + raise Exception('bad ar magic: {}'.format(ar_magic)) + + out.write(ar_magic) + + string_table = None + + while True: + obj = read_ar_object(ar) + if not obj: + break + + data = mangle_elf(obj.data) if is_elf_data(obj.data) else obj.data + + out.write(obj.header) + out.write(data) + + +def mangle_ar(path): + out_path = path + '.mangled' + with open(path, 'rb') as ar: + try: + with open(out_path, 'wb') as out: + mangle_ar_impl(ar, out) + except: + os.unlink(out_path) + raise + + os.rename(out_path, path) + + +def main(): + for arg in sys.argv[1:]: + if not ((arg.endswith('.o') or arg.endswith('.a')) and os.path.exists(arg)): + continue + + if arg.endswith('.o'): + with open(arg, 'rb') as o: + data = o.read() + mangled = mangle_elf(data) if is_elf_data(data) else None + + if mangled: + os.unlink(arg) + with open(arg, 'wb') as o: + o.write(mangled) + elif arg.endswith('.a'): + mangle_ar(arg) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/merge_coverage_data.py b/build/scripts/merge_coverage_data.py new file mode 100644 index 00000000000..b7fa3c6a86b --- /dev/null +++ b/build/scripts/merge_coverage_data.py @@ -0,0 +1,32 @@ +import sys +import tarfile +import copy +import os +import uuid + + +def main(args): + output_file, args = args[0], args[1:] + # heretic@: Splits files on which could be merged( files ) and which should not be merged( expendables ) + # expendables will be in output_file in form {name}{ordinal number of archive in args[]}.{extension} + try: + split_i = args.index('-no-merge') + except ValueError: + split_i = len(args) + files, expendables = args[:split_i], args[split_i + 1:] + + with tarfile.open(output_file, 'w') as outf: + for x in files: + with tarfile.open(x) as tf: + for tarinfo in tf: + new_tarinfo = copy.deepcopy(tarinfo) + if new_tarinfo.name in expendables: + dirname, basename = os.path.split(new_tarinfo.name) + basename_parts = basename.split('.', 1) + new_basename = '.'.join([basename_parts[0] + str(uuid.uuid4())] + basename_parts[1:]) + new_tarinfo.name = os.path.join(dirname, new_basename) + outf.addfile(new_tarinfo, tf.extractfile(tarinfo)) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/build/scripts/merge_files.py b/build/scripts/merge_files.py new file mode 100644 index 00000000000..d42d6a21392 --- /dev/null +++ b/build/scripts/merge_files.py @@ -0,0 +1,8 @@ +import sys + + +if __name__ == "__main__": + with open(sys.argv[1], "w") as f: + for appended in sys.argv[2:]: + with open(appended) as a: + f.write(a.read()) diff --git a/build/scripts/mkdir.py b/build/scripts/mkdir.py new file mode 100755 index 00000000000..a326b293008 --- /dev/null +++ b/build/scripts/mkdir.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +import os +import sys + + +def mkdir_p(directory): + if not os.path.exists(directory): + os.makedirs(directory) + +if __name__ == "__main__": + for directory in sys.argv[1:]: + mkdir_p(directory) diff --git a/build/scripts/mkdocs_builder_wrapper.py b/build/scripts/mkdocs_builder_wrapper.py new file mode 100644 index 00000000000..7a0df041903 --- /dev/null +++ b/build/scripts/mkdocs_builder_wrapper.py @@ -0,0 +1,36 @@ +from __future__ import unicode_literals +import os +import subprocess +import sys + + +def main(): + cmd = [] + build_root = sys.argv[1] + length = len(build_root) + is_dep = False + for arg in sys.argv[2:]: + if is_dep: + is_dep = False + if not arg.endswith('.tar.gz'): + continue + basename = os.path.basename(arg) + assert arg.startswith(build_root) and len(arg) > length + len(basename) and arg[length] in ('/', '\\') + cmd.extend([str('--dep'), str('{}:{}:{}'.format(build_root, os.path.dirname(arg[length+1:]), basename))]) + elif arg == '--dep': + is_dep = True + else: + cmd.append(arg) + assert not is_dep + p = subprocess.Popen(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if p.returncode: + if out: + sys.stderr.write('stdout:\n{}\n'.format(out.decode('utf-8'))) + if err: + sys.stderr.write('stderr:\n{}\n'.format(err.decode('utf-8'))) + sys.exit(p.returncode) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/mkver.py b/build/scripts/mkver.py new file mode 100755 index 00000000000..321cdaade16 --- /dev/null +++ b/build/scripts/mkver.py @@ -0,0 +1,12 @@ +import sys + +if __name__ == '__main__': + with open(sys.argv[1], 'r') as f: + data = f.readline() + + beg = data.find('(') + 1 + end = data.find(')') + version = data[beg:end] + + print '#pragma once' + print '#define DEBIAN_VERSION "%s"' % version diff --git a/build/scripts/move.py b/build/scripts/move.py new file mode 100644 index 00000000000..3f611fbc2e3 --- /dev/null +++ b/build/scripts/move.py @@ -0,0 +1,15 @@ +import os +import sys + +# /script/move.py <src-1> <tgt-1> <src-2> <tgt-2> ... <src-n> <tgt-n> +# renames src-1 to tgt-1, src-2 to tgt-2, ..., src-n to tgt-n. + + +def main(): + assert len(sys.argv) % 2 == 1 + for index in range(1, len(sys.argv), 2): + os.rename(sys.argv[index], sys.argv[index + 1]) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/pack_ios.py b/build/scripts/pack_ios.py new file mode 100644 index 00000000000..37c36d1f957 --- /dev/null +++ b/build/scripts/pack_ios.py @@ -0,0 +1,48 @@ +import argparse +import os +import shutil +import subprocess +import sys +import tarfile + + +def just_do_it(): + parser = argparse.ArgumentParser() + parser.add_argument("--binary", required=True, help="executable file") + parser.add_argument("--target", required=True, help="target archive path") + parser.add_argument("--temp-dir", required=True, help="temp dir") + parser.add_argument("peers", nargs='*') + args = parser.parse_args() + app_tar = [p for p in args.peers if p.endswith('.ios.interface')] + if not app_tar: + print >> sys.stderr, 'No one IOS_INTERFACE module found' + shutil.copyfile(args.binary, os.path.join(args.temp_dir, 'bin')) + if os.path.exists(args.target): + os.remove(args.target) + with tarfile.open(args.target, 'w') as tf: + tf.add(os.path.join(args.temp_dir, 'bin'), arcname=os.path.join(os.path.basename(args.binary) + '.app', 'bin')) + return + if len(app_tar) > 1: + app_tar = [p for p in args.peers if not p.endswith('.default.ios.interface')] + if len(app_tar) > 1: + print >> sys.stderr, 'Many IOS_INTERFACE modules found, {} will be used'.format(app_tar[-1]) + app_tar = app_tar[-1] + with tarfile.open(app_tar) as tf: + tf.extractall(args.temp_dir) + tar_suffix = '.default.ios.interface' if app_tar.endswith('.default.ios.interface') else '.ios.interface' + app_unpacked_path = os.path.join(args.temp_dir, os.path.basename(app_tar)[:-len(tar_suffix)] + '.app') + if not os.path.exists(app_unpacked_path): + raise Exception('Bad IOS_INTERFACE resource: {}'.format(app_tar)) + shutil.copyfile(args.binary, os.path.join(app_unpacked_path, 'bin')) + subprocess.check_call(['/usr/bin/codesign', '--force', '--sign', '-', app_unpacked_path]) + if os.path.exists(args.target): + os.remove(args.target) + binary_origin_name = os.path.basename(args.binary) + while os.path.splitext(binary_origin_name)[1]: + binary_origin_name = os.path.splitext(binary_origin_name)[0] + with tarfile.open(args.target, 'w') as tf: + tf.add(app_unpacked_path, arcname=binary_origin_name + '.app', recursive=True) + + +if __name__ == '__main__': + just_do_it() diff --git a/build/scripts/pack_jcoverage_resources.py b/build/scripts/pack_jcoverage_resources.py new file mode 100644 index 00000000000..f6e181067a2 --- /dev/null +++ b/build/scripts/pack_jcoverage_resources.py @@ -0,0 +1,24 @@ +import sys +import tarfile +import os +import subprocess + + +def main(args): + output_file = args[0] + report_file = args[1] + + res = subprocess.call(args[args.index('-end') + 1:]) + + if not os.path.exists(report_file): + print>>sys.stderr, 'Can\'t find jacoco exec file' + return res + + with tarfile.open(output_file, 'w') as outf: + outf.add(report_file, arcname=os.path.basename(report_file)) + + return res + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/build/scripts/perl_wrapper.py b/build/scripts/perl_wrapper.py new file mode 100644 index 00000000000..cb4027f1d36 --- /dev/null +++ b/build/scripts/perl_wrapper.py @@ -0,0 +1,24 @@ +import os +import sys +import shutil + +if __name__ == '__main__': + path = sys.argv[1] + to = sys.argv[-1] + fr = sys.argv[-2] + to_dir = os.path.dirname(to) + + os.chdir(to_dir) + + f1 = os.path.basename(fr) + fr_ = os.path.dirname(fr) + f2 = os.path.basename(fr_) + fr_ = os.path.dirname(fr_) + + os.makedirs(f2) + shutil.copyfile(fr, os.path.join(f2, f1)) + + if path[0] != '/': + path = os.path.join(os.path.dirname(__file__), path) + + os.execv(path, [path] + sys.argv[2:]) diff --git a/build/scripts/postprocess_go_fbs.py b/build/scripts/postprocess_go_fbs.py new file mode 100644 index 00000000000..e6d5184a5e1 --- /dev/null +++ b/build/scripts/postprocess_go_fbs.py @@ -0,0 +1,72 @@ +import argparse +import re +import os + + +# very simple regexp to find go import statement in the source code +# NOTE! only one-line comments are somehow considered +IMPORT_DECL=re.compile(r''' + \bimport + ( + \s+((\.|\w+)\s+)?"[^"]+" ( \s+//[^\n]* )? + | \s* \( \s* ( ( \s+ ((\.|\w+)\s+)? "[^"]+" )? ( \s* //[^\n]* )? )* \s* \) + )''', re.MULTILINE | re.DOTALL | re.VERBOSE) + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--input-dir', required=True) + parser.add_argument('--map', nargs='*', default=None) + + return parser.parse_args() + + +def process_go_file(file_name, import_map): + content = '' + with open(file_name, 'r') as f: + content = f.read() + + start = -1 + end = -1 + for it in IMPORT_DECL.finditer(content): + if start < 0: + start = it.start() + end = it.end() + + if start < 0: + return + + imports = content[start:end] + for namespace, path in import_map.items(): + ns = namespace.split('.') + name = '__'.join(ns) + import_path = '/'.join(ns) + imports = imports.replace('{} "{}"'.format(name, import_path), '{} "a.yandex-team.ru/{}"'.format(name, path)) + + if imports != content[start:end]: + with open(file_name, 'w') as f: + f.write(content[:start]) + f.write(imports) + f.write(content[end:]) + + +def main(): + args = parse_args() + + if not args.map: + return + + raw_import_map = sorted(set(args.map)) + import_map = dict(z.split('=', 1) for z in raw_import_map) + if len(raw_import_map) != len(import_map): + for k, v in (z.split('=', 1) for z in raw_import_map): + if v != import_map[k]: + raise Exception('import map [{}] contains different values for key [{}]: [{}] and [{}].'.format(args.map, k, v, import_map[k])) + + for root, _, files in os.walk(args.input_dir): + for src in (f for f in files if f.endswith('.go')): + process_go_file(os.path.join(root, src), import_map) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/preprocess.py b/build/scripts/preprocess.py new file mode 100644 index 00000000000..4657bef732e --- /dev/null +++ b/build/scripts/preprocess.py @@ -0,0 +1,48 @@ +import sys +import os + + +def load_file(p): + with open(p, 'r') as f: + return f.read() + + +def step(base, data, hh): + def flt(): + for l in data.split('\n'): + if l in hh: + pp = os.path.join(base, hh[l]) + + yield '\n\n' + load_file(pp) + '\n\n' + + os.unlink(pp) + else: + yield l + + return '\n'.join(flt()) + + +def subst_headers(path, headers): + hh = dict() + + for h in headers: + hh['# include "' + h + '"'] = h + + data = load_file(path) + prev = data + + while True: + ret = step(os.path.dirname(path), prev, hh) + + if ret == prev: + break + + prev = ret + + if data != prev: + with open(path, 'w') as f: + f.write(prev) + + +if __name__ == '__main__': + subst_headers(sys.argv[1], ['stack.hh', 'position.hh', 'location.hh']) diff --git a/build/scripts/process_command_files.pyc b/build/scripts/process_command_files.pyc Binary files differnew file mode 100644 index 00000000000..7ea813740a2 --- /dev/null +++ b/build/scripts/process_command_files.pyc diff --git a/build/scripts/process_whole_archive_option.py b/build/scripts/process_whole_archive_option.py new file mode 100644 index 00000000000..84d29869e90 --- /dev/null +++ b/build/scripts/process_whole_archive_option.py @@ -0,0 +1,183 @@ +import os + +import process_command_files as pcf + + +class ProcessWholeArchiveOption(): + def __init__(self, arch, peers=None, libs=None): + self.arch = arch.upper() + self.peers = { x : 0 for x in peers } if peers else None + self.libs = { x : 0 for x in libs } if libs else None + self.start_wa_marker = '--start-wa' + self.end_wa_marker = '--end-wa' + + def _match_peer_lib(self, arg, ext): + key = None + if arg.endswith(ext): + key = os.path.dirname(arg) + return key if key and self.peers and key in self.peers else None + + def _match_lib(self, arg): + return arg if self.libs and arg in self.libs else None + + def _process_arg(self, arg, ext='.a'): + peer_key = self._match_peer_lib(arg, ext) + lib_key = self._match_lib(arg) + if peer_key: + self.peers[peer_key] += 1 + if lib_key: + self.libs[lib_key] += 1 + return peer_key if peer_key else lib_key + + def _check_peers(self): + if self.peers: + for key, value in self.peers.items(): + assert value > 0, '"{}" specified in WHOLE_ARCHIVE() macro is not used on link command'.format(key) + + def _construct_cmd_apple(self, args): + force_load_flag = '-Wl,-force_load,' + is_inside_wa_markers = False + + cmd = [] + for arg in args: + if arg.startswith(force_load_flag): + cmd.append(arg) + elif arg == self.start_wa_marker: + is_inside_wa_markers = True + elif arg == self.end_wa_marker: + is_inside_wa_markers = False + elif is_inside_wa_markers: + cmd.append(force_load_flag + arg) + else: + key = self._process_arg(arg) + cmd.append(force_load_flag + arg if key else arg) + + self._check_peers() + + return cmd + + def _construct_cmd_win(self, args): + whole_archive_prefix = '/WHOLEARCHIVE:' + is_inside_wa_markers = False + + def add_prefix(arg, need_check_peers_and_libs): + key = self._process_arg(arg, '.lib') if need_check_peers_and_libs else arg + return whole_archive_prefix + arg if key else arg + + def add_whole_archive_prefix(arg, need_check_peers_and_libs): + if not pcf.is_cmdfile_arg(arg): + return add_prefix(arg, need_check_peers_and_libs) + + cmd_file_path = pcf.cmdfile_path(arg) + cf_args = pcf.read_from_command_file(cmd_file_path) + with open(cmd_file_path, 'w') as afile: + for cf_arg in cf_args: + afile.write(add_prefix(cf_arg, need_check_peers_and_libs) + "\n") + return arg + + cmd = [] + for arg in args: + if arg == self.start_wa_marker: + is_inside_wa_markers = True + elif arg == self.end_wa_marker: + is_inside_wa_markers = False + elif is_inside_wa_markers: + cmd.append(add_whole_archive_prefix(arg, False)) + continue + elif self.peers or self.libs: + cmd.append(add_whole_archive_prefix(arg, True)) + else: + cmd.append(arg) + + self._check_peers() + + return cmd + + def _construct_cmd_linux(self, args): + whole_archive_flag = '-Wl,--whole-archive' + no_whole_archive_flag = '-Wl,--no-whole-archive' + + def replace_markers(arg): + if arg == self.start_wa_marker: + return whole_archive_flag + if arg == self.end_wa_marker: + return no_whole_archive_flag + return arg + + args = [replace_markers(arg) for arg in args] + + cmd = [] + is_inside_whole_archive = False + is_whole_archive = False + # We are trying not to create excessive sequences of consecutive flags + # -Wl,--no-whole-archive -Wl,--whole-archive ('externally' specified + # flags -Wl,--[no-]whole-archive are not taken for consideration in this + # optimization intentionally) + for arg in args: + if arg == whole_archive_flag: + is_inside_whole_archive = True + is_whole_archive = False + elif arg == no_whole_archive_flag: + is_inside_whole_archive = False + is_whole_archive = False + else: + key = self._process_arg(arg) + if not is_inside_whole_archive: + if key: + if not is_whole_archive: + cmd.append(whole_archive_flag) + is_whole_archive = True + elif is_whole_archive: + cmd.append(no_whole_archive_flag) + is_whole_archive = False + + cmd.append(arg) + + if is_whole_archive: + cmd.append(no_whole_archive_flag) + + # There can be an empty sequence of archive files between + # -Wl, --whole-archive and -Wl, --no-whole-archive flags. + # As a result an unknown option error may occur, therefore to + # prevent this case we need to remove both flags from cmd. + # These flags affects only on subsequent archive files. + if len(cmd) == 2: + return [] + + self._check_peers() + + return cmd + + def construct_cmd(self, args): + if self.arch in ('DARWIN', 'IOS', 'IOSSIM'): + return self._construct_cmd_apple(args) + + if self.arch == 'WINDOWS': + return self._construct_cmd_win(args) + + return self._construct_cmd_linux(args) + + +def get_whole_archive_peers_and_libs(args): + remaining_args = [] + peers = [] + libs = [] + peers_flag = '--whole-archive-peers' + libs_flag = '--whole-archive-libs' + + next_is_peer = False + next_is_lib = False + for arg in args: + if arg == peers_flag: + next_is_peer = True + elif arg == libs_flag: + next_is_lib = True + elif next_is_peer: + peers.append(arg) + next_is_peer = False + elif next_is_lib: + libs.append(arg) + next_is_lib = False + else: + remaining_args.append(arg) + return remaining_args, peers, libs diff --git a/build/scripts/process_whole_archive_option.pyc b/build/scripts/process_whole_archive_option.pyc Binary files differnew file mode 100644 index 00000000000..318f50bc36b --- /dev/null +++ b/build/scripts/process_whole_archive_option.pyc diff --git a/build/scripts/py_compile.py b/build/scripts/py_compile.py new file mode 100755 index 00000000000..936dbe8816b --- /dev/null +++ b/build/scripts/py_compile.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import print_function, absolute_import, division + +import marshal +import sys + + +def main(): + srcpathx, in_fname, out_fname = sys.argv[1:] + srcpath = srcpathx[:-1] + + with open(in_fname, 'r') as in_file: + source = in_file.read() + + code = compile(source, srcpath, 'exec', dont_inherit=True) + + with open(out_fname, 'wb') as out_file: + marshal.dump(code, out_file) + + +if __name__ == "__main__": + main() diff --git a/build/scripts/python_yndexer.py b/build/scripts/python_yndexer.py new file mode 100644 index 00000000000..3180665387d --- /dev/null +++ b/build/scripts/python_yndexer.py @@ -0,0 +1,53 @@ +import os +import sys +import threading +import subprocess + + +def _try_to_kill(process): + try: + process.kill() + except Exception: + pass + + +def touch(path): + if not os.path.exists(path): + with open(path, 'w') as _: + pass + + +class Process(object): + def __init__(self, args): + self._process = subprocess.Popen(args) + self._event = threading.Event() + self._result = None + thread = threading.Thread(target=self._run) + thread.setDaemon(True) + thread.start() + + def _run(self): + self._process.communicate() + self._result = self._process.returncode + self._event.set() + + def wait(self, timeout): + self._event.wait(timeout=timeout) + _try_to_kill(self._process) + return self._result + + +if __name__ == '__main__': + yndexer = sys.argv[1] + timeout = int(sys.argv[2]) + output_file = sys.argv[3] + input_file = sys.argv[4] + partition_count = sys.argv[5] + partition_index = sys.argv[6] + + process = Process([yndexer, '-f', input_file, '-y', output_file, '-c', partition_count, '-i', partition_index]) + result = process.wait(timeout=timeout) + + if result != 0: + print >> sys.stderr, 'Yndexing process finished with code', result + touch(output_file) diff --git a/build/scripts/resolve_java_srcs.py b/build/scripts/resolve_java_srcs.py new file mode 100644 index 00000000000..a2e6c200129 --- /dev/null +++ b/build/scripts/resolve_java_srcs.py @@ -0,0 +1,106 @@ +import os +import argparse +import re +import sys + + +def list_all_files(directory, prefix='/', hidden_files=False): + result = [] + if os.path.exists(directory): + for i in os.listdir(directory): + abs_path = os.path.join(directory, i) + result += list_all_files(os.path.join(directory, abs_path), prefix + i + '/', hidden_files) \ + if os.path.isdir(abs_path) else ([prefix + i] if (hidden_files or not i.startswith('.')) else []) + return result + + +def pattern_to_regexp(p): + return '^' + \ + ('/' if not p.startswith('**') else '') + \ + re.escape(p).replace( + r'\*\*\/', '[_DIR_]' + ).replace( + r'\*', '[_FILE_]' + ).replace( + '[_DIR_]', '(.*/)?' + ).replace( + '[_FILE_]', '([^/]*)' + ) + '$' + + +def resolve_java_srcs(srcdir, include_patterns, exclude_patterns, all_resources, resolve_kotlin=False, resolve_groovy=False): + result = {'java': [], 'not_java': [], 'kotlin': [], 'groovy': []} + include_patterns_normal, include_patterns_hidden, exclude_patterns_normal, exclude_patterns_hidden = [], [], [], [] + for vis, hid, patterns in ((include_patterns_normal, include_patterns_hidden, include_patterns), (exclude_patterns_normal, exclude_patterns_hidden, exclude_patterns),): + for pattern in patterns: + if (pattern if pattern.find('/') == -1 else pattern.rsplit('/', 1)[1]).startswith('.'): + hid.append(pattern) + else: + vis.append(pattern) + re_patterns = map(pattern_to_regexp, vis + hid) + if sys.platform in ('win32', 'darwin'): + re_patterns = [re.compile(i, re.IGNORECASE) for i in re_patterns] + else: + re_patterns = [re.compile(i) for i in re_patterns] + vis[:], hid[:] = re_patterns[:len(vis)], re_patterns[len(vis):] + + for inc_patterns, exc_patterns, with_hidden_files in ( + (include_patterns_normal, exclude_patterns_normal, False), + (include_patterns_hidden, exclude_patterns_hidden, True), + ): + for f in list_all_files(srcdir, hidden_files=with_hidden_files): + excluded = False + + for exc_re in exc_patterns: + if exc_re.match(f): + excluded = True + break + + if excluded: + continue + + for inc_re in inc_patterns: + if inc_re.match(f): + s = os.path.normpath(f[1:]) + if all_resources or not (f.endswith('.java') or f.endswith('.kt') or f.endswith('.groovy')): + result['not_java'].append(s) + elif f.endswith('.java'): + result['java'].append(os.path.join(srcdir, s)) + elif f.endswith('.kt') and resolve_kotlin: + result['kotlin'].append(os.path.join(srcdir, s)) + elif f.endswith('.groovy') and resolve_groovy: + result['groovy'].append(os.path.join(srcdir, s)) + else: + result['not_java'].append(s) + break + + return sorted(result['java']), sorted(result['not_java']), sorted(result['kotlin']), sorted(result['groovy']) + + +def do_it(directory, sources_file, resources_file, kotlin_sources_file, groovy_sources_file, include_patterns, exclude_patterns, resolve_kotlin, resolve_groovy, append, all_resources): + j, r, k, g = resolve_java_srcs(directory, include_patterns, exclude_patterns, all_resources, resolve_kotlin, resolve_groovy) + mode = 'a' if append else 'w' + open(sources_file, mode).writelines(i + '\n' for i in j) + open(resources_file, mode).writelines(i + '\n' for i in r) + if kotlin_sources_file: + open(kotlin_sources_file, mode).writelines(i + '\n' for i in k + j) + if groovy_sources_file: + open(groovy_sources_file, mode).writelines(i + '\n' for i in g + j) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('-d', '--directory', required=True) + parser.add_argument('-s', '--sources-file', required=True) + parser.add_argument('-r', '--resources-file', required=True) + parser.add_argument('-k', '--kotlin-sources-file', default=None) + parser.add_argument('-g', '--groovy-sources-file', default=None) + parser.add_argument('--append', action='store_true', default=False) + parser.add_argument('--all-resources', action='store_true', default=False) + parser.add_argument('--resolve-kotlin', action='store_true', default=False) + parser.add_argument('--resolve-groovy', action='store_true', default=False) + parser.add_argument('--include-patterns', nargs='*', default=[]) + parser.add_argument('--exclude-patterns', nargs='*', default=[]) + args = parser.parse_args() + + do_it(**vars(args)) diff --git a/build/scripts/retry.py b/build/scripts/retry.py new file mode 100644 index 00000000000..d14170bfec1 --- /dev/null +++ b/build/scripts/retry.py @@ -0,0 +1,29 @@ +import time +import functools + + +# Partly copy-pasted from contrib/python/retry +def retry_func(f, exceptions=Exception, tries=-1, delay=1, max_delay=None, backoff=1): + _tries, _delay = tries, delay + while _tries: + try: + return f() + except exceptions as e: + _tries -= 1 + if not _tries: + raise + + time.sleep(_delay) + _delay *= backoff + + if max_delay is not None: + _delay = min(_delay, max_delay) + + +def retry(**retry_kwargs): + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + return retry_func(lambda: func(*args, **kwargs), **retry_kwargs) + return wrapper + return decorator diff --git a/build/scripts/rodata2asm.py b/build/scripts/rodata2asm.py new file mode 100644 index 00000000000..555639499f2 --- /dev/null +++ b/build/scripts/rodata2asm.py @@ -0,0 +1,31 @@ +import os +import argparse + + +def main(): + parser = argparse.ArgumentParser(description='Convert rodata into asm source with embedded file content') + parser.add_argument('symbol', help='symvol name exported from generated filr') + parser.add_argument('rodata', help='input .rodata file path') + parser.add_argument('asm', type=argparse.FileType('w', encoding='UTF-8'), help='destination .asm file path') + parser.add_argument('--elf', action='store_true') + + args = parser.parse_args() + + file_size = os.path.getsize(args.rodata) + + args.asm.write('global ' + args.symbol + '\n') + args.asm.write('global ' + args.symbol + 'Size' + '\n') + args.asm.write('SECTION .rodata ALIGN=16\n') + args.asm.write(args.symbol + ':\nincbin "' + args.rodata + '"\n') + args.asm.write('align 4, db 0\n') + args.asm.write(args.symbol + 'Size:\ndd ' + str(file_size) + '\n') + + if args.elf: + args.asm.write('size ' + args.symbol + ' ' + str(file_size) + '\n') + args.asm.write('size ' + args.symbol + 'Size 4\n') + + args.asm.close() + + +if __name__ == '__main__': + main() diff --git a/build/scripts/run_ios_simulator.py b/build/scripts/run_ios_simulator.py new file mode 100644 index 00000000000..052c855b773 --- /dev/null +++ b/build/scripts/run_ios_simulator.py @@ -0,0 +1,79 @@ +import argparse +import json +import os +import subprocess +import sys + + +def just_do_it(): + parser = argparse.ArgumentParser() + parser.add_argument("--action", choices=["create", "spawn", "kill"]) + parser.add_argument("--simctl", help="simctl binary path") + parser.add_argument("--profiles", help="profiles path") + parser.add_argument("--device-dir", help="devices directory") + parser.add_argument("--device-name", help="temp device name") + args, tail = parser.parse_known_args() + if args.action == 'create': + action_create(args.simctl, args.profiles, args.device_dir, args.device_name, tail) + elif args.action == "spawn": + action_spawn(args.simctl, args.profiles, args.device_dir, args.device_name, tail) + elif args.action == "kill": + action_kill(args.simctl, args.profiles, args.device_dir, args.device_name) + + +def action_create(simctl, profiles, device_dir, name, args): + parser = argparse.ArgumentParser() + parser.add_argument("--device-type", default="com.apple.CoreSimulator.SimDeviceType.iPhone-X") + parser.add_argument("--device-runtime", default="com.apple.CoreSimulator.SimRuntime.iOS-12-1") + args = parser.parse_args(args) + all_devices = list(get_all_devices(simctl, profiles, device_dir)) + if filter(lambda x: x["name"] == name, all_devices): + raise Exception("Device named {} already exists".format(name)) + subprocess.check_call([simctl, "--profiles", profiles, "--set", device_dir, "create", name, args.device_type, args.device_runtime]) + created = filter(lambda x: x["name"] == name, get_all_devices(simctl, profiles, device_dir)) + if not created: + raise Exception("Creation error: temp device named {} not found".format(name)) + created = created[0] + if created["availability"] != "(available)": + raise Exception("Creation error: temp device {} status is {} ((available) expected)".format(name, created["availability"])) + + +def action_spawn(simctl, profiles, device_dir, name, args): + device = filter(lambda x: x["name"] == name, get_all_devices(simctl, profiles, device_dir)) + if not device: + raise Exception("Can't spawn process: device named {} not found".format(name)) + if len(device) > 1: + raise Exception("Can't spawn process: too many devices named {} found".format(name)) + device = device[0] + os.execv(simctl, [simctl, "--profiles", profiles, "--set", device_dir, "spawn", device["udid"]] + args) + + +def action_kill(simctl, profiles, device_dir, name): + device = filter(lambda x: x["name"] == name, get_all_devices(simctl, profiles, device_dir)) + if not device: + print >> sys.stderr, "Device named {} not found; do nothing".format(name) + return + if len(device) > 1: + raise Exception("Can't remove: too many devices named {}:\n{}".format(name, '\n'.join(i for i in device))) + device = device[0] + os.execv(simctl, [simctl, "--profiles", profiles, "--set", device_dir, "delete", device["udid"]]) + + +def get_all_devices(simctl, profiles, device_dir): + p = subprocess.Popen([simctl, "--profiles", profiles, "--set", device_dir, "list", "--json", "devices"], stdout=subprocess.PIPE) + out, _ = p.communicate() + rc = p.wait() + if rc: + raise Exception("Devices list command return code is {}\nstdout:\n{}".format(rc, out)) + raw_object = json.loads(out) + if "devices" not in raw_object: + raise Exception("Devices not found in\n{}".format(json.dumps(raw_object))) + raw_object = raw_object["devices"] + for os_name, devices in raw_object.items(): + for device in devices: + device["os_name"] = os_name + yield device + + +if __name__ == '__main__': + just_do_it() diff --git a/build/scripts/run_javac.py b/build/scripts/run_javac.py new file mode 100644 index 00000000000..c35546e0fef --- /dev/null +++ b/build/scripts/run_javac.py @@ -0,0 +1,122 @@ +import sys +import subprocess +import optparse +import re + + +def parse_args(): + parser = optparse.OptionParser() + parser.disable_interspersed_args() + parser.add_option('--sources-list') + parser.add_option('--verbose', default=False, action='store_true') + parser.add_option('--remove-notes', default=False, action='store_true') + parser.add_option('--ignore-errors', default=False, action='store_true') + parser.add_option('--kotlin', default=False, action='store_true') + return parser.parse_args() + + +COLORING = { + r'^(?P<path>.*):(?P<line>\d*): error: (?P<msg>.*)': lambda m: '[[unimp]]{path}[[rst]]:[[alt2]]{line}[[rst]]: [[c:light-red]]error[[rst]]: [[bad]]{msg}[[rst]]'.format( + path=m.group('path'), + line=m.group('line'), + msg=m.group('msg'), + ), + r'^(?P<path>.*):(?P<line>\d*): warning: (?P<msg>.*)': lambda m: '[[unimp]]{path}[[rst]]:[[alt2]]{line}[[rst]]: [[c:light-yellow]]warning[[rst]]: {msg}'.format( + path=m.group('path'), + line=m.group('line'), + msg=m.group('msg'), + ), + r'^warning: ': lambda m: '[[c:light-yellow]]warning[[rst]]: ', + r'^error: (?P<msg>.*)': lambda m: '[[c:light-red]]error[[rst]]: [[bad]]{msg}[[rst]]'.format(msg=m.group('msg')), + r'^Note: ': lambda m: '[[c:light-cyan]]Note[[rst]]: ', +} + + +def colorize(err): + for regex, sub in COLORING.iteritems(): + err = re.sub(regex, sub, err, flags=re.MULTILINE) + return err + + +def remove_notes(err): + return '\n'.join([line for line in err.split('\n') if not line.startswith('Note:')]) + + +def find_javac(cmd): + if not cmd: + return None + if cmd[0].endswith('javac') or cmd[0].endswith('javac.exe'): + return cmd[0] + if len(cmd) > 2 and cmd[1].endswith('build_java_with_error_prone.py'): + for javas in ('java', 'javac'): + if cmd[2].endswith(javas) or cmd[2].endswith(javas + '.exe'): + return cmd[2] + return None + + +# temporary, for jdk8/jdk9+ compatibility +def fix_cmd(cmd): + if not cmd: + return cmd + javac = find_javac(cmd) + if not javac: + return cmd + p = subprocess.Popen([javac, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + out, err = out.strip(), err.strip() + for prefix in ('javac 1.8', 'java version "1.8'): + for raw_out in ((out or ''), (err or '')): + for line in raw_out.split('\n'): + if line.startswith(prefix): + res = [] + i = 0 + while i < len(cmd): + for option in ('--add-exports', '--add-modules'): + if cmd[i] == option: + i += 1 + break + elif cmd[i].startswith(option + '='): + break + else: + res.append(cmd[i]) + i += 1 + return res + return cmd + + +def main(): + opts, cmd = parse_args() + + with open(opts.sources_list) as f: + input_files = f.read().strip().split() + + if opts.kotlin: + input_files = [i for i in input_files if i.endswith('.kt')] + + if not input_files: + if opts.verbose: + sys.stderr.write('No files to compile, javac is not launched.\n') + + else: + p = subprocess.Popen(fix_cmd(cmd), stderr=subprocess.PIPE) + _, err = p.communicate() + rc = p.wait() + + if opts.remove_notes: + err = remove_notes(err) + + try: + err = colorize(err) + + except Exception: + pass + + if opts.ignore_errors and rc: + sys.stderr.write('error: javac actually failed with exit code {}\n'.format(rc)) + rc = 0 + sys.stderr.write(err) + sys.exit(rc) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/run_junit.py b/build/scripts/run_junit.py new file mode 100644 index 00000000000..089f149f723 --- /dev/null +++ b/build/scripts/run_junit.py @@ -0,0 +1,65 @@ +import os +import sys + +SHUTDOWN_SIGNAL = 'SIGUSR1' + + +class SignalInterruptionError(Exception): + pass + + +def on_shutdown(s, f): + raise SignalInterruptionError() + + +def main(): + args = sys.argv[1:] + + def execve(): + os.execve(args[0], args, os.environ) + + jar_binary = args[args.index('--jar-binary') + 1] + java_bin_dir = os.path.dirname(jar_binary) + jstack_binary = os.path.join(java_bin_dir, 'jstack') + + if not os.path.exists(jstack_binary): + sys.stderr.write("jstack is missing: {}\n".format(jstack_binary)) + execve() + + import signal + + signum = getattr(signal, SHUTDOWN_SIGNAL, None) + + if signum is None: + execve() + + import subprocess + + proc = subprocess.Popen(args) + signal.signal(signum, on_shutdown) + timeout = False + + try: + proc.wait() + except SignalInterruptionError: + sys.stderr.write("\nGot {} signal: going to shutdown junit\n".format(signum)) + # Dump stack traces + subprocess.call([jstack_binary, str(proc.pid)], stdout=sys.stderr) + # Kill junit - for more info see DEVTOOLS-7636 + os.kill(proc.pid, signal.SIGKILL) + proc.wait() + timeout = True + + if proc.returncode: + sys.stderr.write('java exit code: {}\n'.format(proc.returncode)) + if timeout: + # In case of timeout return specific exit code + # https://a.yandex-team.ru/arc/trunk/arcadia/devtools/ya/test/const/__init__.py?rev=r8578188#L301 + proc.returncode = 10 + sys.stderr.write('java exit code changed to {}\n'.format(proc.returncode)) + + return proc.returncode + + +if __name__ == '__main__': + exit(main()) diff --git a/build/scripts/run_llvm_dsymutil.py b/build/scripts/run_llvm_dsymutil.py new file mode 100644 index 00000000000..4f43362ad98 --- /dev/null +++ b/build/scripts/run_llvm_dsymutil.py @@ -0,0 +1,11 @@ +import os +import sys +import subprocess + + +if __name__ == '__main__': + with open(os.devnull, 'w') as fnull: + p = subprocess.Popen(sys.argv[1:], shell=False, stderr=fnull, stdout=sys.stdout) + + p.communicate() + sys.exit(p.returncode) diff --git a/build/scripts/run_msvc_wine.py b/build/scripts/run_msvc_wine.py new file mode 100644 index 00000000000..eb5ed3eba53 --- /dev/null +++ b/build/scripts/run_msvc_wine.py @@ -0,0 +1,586 @@ +import sys +import os +import re +import subprocess +import signal +import time +import json +import argparse +import errno + +import process_command_files as pcf +import process_whole_archive_option as pwa + + +procs = [] +build_kekeke = 45 + + +def stringize(s): + return s.encode('utf-8') if isinstance(s, unicode) else s + + +def run_subprocess(*args, **kwargs): + if 'env' in kwargs: + kwargs['env'] = {stringize(k): stringize(v) for k, v in kwargs['env'].iteritems()} + + p = subprocess.Popen(*args, **kwargs) + + procs.append(p) + + return p + + +def run_subprocess_with_timeout(timeout, args): + attempts_remaining = 5 + delay = 1 + p = None + while True: + try: + p = run_subprocess(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = p.communicate(timeout=timeout) + return p, stdout, stderr + except subprocess.TimeoutExpired as e: + print >>sys.stderr, 'timeout running {0}, error {1}, delay {2} seconds'.format(args, str(e), delay) + if p is not None: + try: + p.kill() + p.wait(timeout=1) + except Exception: + pass + attempts_remaining -= 1 + if attempts_remaining == 0: + raise + time.sleep(delay) + delay = min(2 * delay, 4) + + +def terminate_slaves(): + for p in procs: + try: + p.terminate() + except Exception: + pass + + +def sig_term(sig, fr): + terminate_slaves() + sys.exit(sig) + + +def subst_path(l): + if len(l) > 3: + if l[:3].lower() in ('z:\\', 'z:/'): + return l[2:].replace('\\', '/') + + return l + + +def call_wine_cmd_once(wine, cmd, env, mode): + p = run_subprocess(wine + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env, close_fds=True, shell=False) + + output = find_cmd_out(cmd) + error = None + if output is not None and os.path.exists(output): + try: + os.remove(output) + except OSError as e: + if e.errno != errno.ENOENT: + error = e + except Exception as e: + error = e + + if error is not None: + print >> sys.stderr, 'Output {} already exists and we have failed to remove it: {}'.format(output, error) + + # print >>sys.stderr, cmd, env, wine + + stdout_and_stderr, _ = p.communicate() + + return_code = p.returncode + if not stdout_and_stderr: + if return_code != 0: + raise Exception('wine did something strange') + + return return_code + elif ' : fatal error ' in stdout_and_stderr: + return_code = 1 + elif ' : error ' in stdout_and_stderr: + return_code = 2 + + lines = [x.strip() for x in stdout_and_stderr.split('\n')] + + prefixes = [ + 'Microsoft (R)', + 'Copyright (C)', + 'Application tried to create a window', + 'The graphics driver is missing', + 'Could not load wine-gecko', + 'wine: configuration in', + 'wine: created the configuration directory', + 'libpng warning:' + ] + + suffixes = [ + '.c', + '.cxx', + '.cc', + '.cpp', + '.masm', + ] + + substrs = [ + 'Creating library Z:', + 'err:heap', + 'err:menubuilder:', + 'err:msvcrt', + 'err:ole:', + 'err:wincodecs:', + 'err:winediag:', + ] + + def good_line(l): + for x in prefixes: + if l.startswith(x): + return False + + for x in suffixes: + if l.endswith(x): + return False + + for x in substrs: + if x in l: + return False + + return True + + def filter_lines(): + for l in lines: + if good_line(l): + yield subst_path(l.strip()) + + stdout_and_stderr = '\n'.join(filter_lines()).strip() + + if stdout_and_stderr: + print >>sys.stderr, stdout_and_stderr + + return return_code + + +def prepare_vc(fr, to): + for p in os.listdir(fr): + fr_p = os.path.join(fr, p) + to_p = os.path.join(to, p) + + if not os.path.exists(to_p): + print >>sys.stderr, 'install %s -> %s' % (fr_p, to_p) + + os.link(fr_p, to_p) + + +def run_slave(): + args = json.loads(sys.argv[3]) + wine = sys.argv[1] + + signal.signal(signal.SIGTERM, sig_term) + + if args.get('tout', None): + signal.signal(signal.SIGALRM, sig_term) + signal.alarm(args['tout']) + + tout = 0.1 + + while True: + try: + return call_wine_cmd_once([wine], args['cmd'], args['env'], args['mode']) + except Exception as e: + print >>sys.stderr, '%s, will retry in %s' % (str(e), tout) + + time.sleep(tout) + tout = min(2 * tout, 4) + + +def find_cmd_out(args): + for arg in args: + if arg.startswith('/Fo'): + return arg[3:] + + if arg.startswith('/OUT:'): + return arg[5:] + + +def calc_zero_cnt(data): + zero_cnt = 0 + + for ch in data: + if ch == chr(0): + zero_cnt += 1 + + return zero_cnt + + +def is_good_file(p): + if not os.path.isfile(p): + return False + + if os.path.getsize(p) < 300: + return False + + asm_pattern = re.compile(r'asm(\.\w+)?\.obj$') + if asm_pattern.search(p): + pass + elif p.endswith('.obj'): + with open(p, 'rb') as f: + prefix = f.read(200) + + if ord(prefix[0]) != 0: + return False + + if ord(prefix[1]) != 0: + return False + + if ord(prefix[2]) != 0xFF: + return False + + if ord(prefix[3]) != 0xFF: + return False + + if calc_zero_cnt(prefix) > 195: + return False + + f.seek(-100, os.SEEK_END) + last = f.read(100) + + if calc_zero_cnt(last) > 95: + return False + + if last[-1] != chr(0): + return False + elif p.endswith('.lib'): + with open(p, 'rb') as f: + if f.read(7) != '!<arch>': + return False + + return True + + +RED = '\x1b[31;1m' +GRAY = '\x1b[30;1m' +RST = '\x1b[0m' +MGT = '\x1b[35m' +YEL = '\x1b[33m' +GRN = '\x1b[32m' +CYA = '\x1b[36m' + + +def colorize_strings(l): + p = l.find("'") + + if p >= 0: + yield l[:p] + + l = l[p + 1:] + + p = l.find("'") + + if p >= 0: + yield CYA + "'" + subst_path(l[:p]) + "'" + RST + + for x in colorize_strings(l[p + 1:]): + yield x + else: + yield "'" + l + else: + yield l + + +def colorize_line(l): + lll = l + + try: + parts = [] + + if l.startswith('(compiler file'): + return ''.join(colorize_strings(l)) + + if l.startswith('/'): + p = l.find('(') + parts.append(GRAY + l[:p] + RST) + l = l[p:] + + if l and l.startswith('('): + p = l.find(')') + parts.append(':' + MGT + l[1:p] + RST) + l = l[p + 1:] + + if l: + if l.startswith(' : '): + l = l[1:] + + if l.startswith(': error'): + parts.append(': ' + RED + 'error' + RST) + l = l[7:] + elif l.startswith(': warning'): + parts.append(': ' + YEL + 'warning' + RST) + l = l[9:] + elif l.startswith(': note'): + parts.append(': ' + GRN + 'note' + RST) + l = l[6:] + elif l.startswith('fatal error'): + parts.append(RED + 'fatal error' + RST) + l = l[11:] + + if l: + parts.extend(colorize_strings(l)) + + return ''.join(parts) + except Exception: + return lll + + +def colorize(out): + return '\n'.join(colorize_line(l) for l in out.split('\n')) + + +def trim_path(path, winepath): + p1, p1_stdout, p1_stderr = run_subprocess_with_timeout(60, [winepath, '-w', path]) + win_path = p1_stdout.strip() + + if p1.returncode != 0 or not win_path: + # Fall back to only winepath -s + win_path = path + + p2, p2_stdout, p2_stderr = run_subprocess_with_timeout(60, [winepath, '-s', win_path]) + short_path = p2_stdout.strip() + + check_path = short_path + if check_path.startswith(('Z:', 'z:')): + check_path = check_path[2:] + + if not check_path[1:].startswith((path[1:4], path[1:4].upper())): + raise Exception( + 'Cannot trim path {}; 1st winepath exit code: {}, stdout:\n{}\n stderr:\n{}\n 2nd winepath exit code: {}, stdout:\n{}\n stderr:\n{}'.format( + path, p1.returncode, p1_stdout, p1_stderr, p2.returncode, p2_stdout, p2_stderr + )) + + return short_path + + +def downsize_path(path, short_names): + flag = '' + if path.startswith('/Fo'): + flag = '/Fo' + path = path[3:] + + for full_name, short_name in short_names.items(): + if path.startswith(full_name): + path = path.replace(full_name, short_name) + + return flag + path + + +def make_full_path_arg(arg, bld_root, short_root): + if arg[0] != '/' and len(os.path.join(bld_root, arg)) > 250: + return os.path.join(short_root, arg) + return arg + + +def fix_path(p): + topdirs = ['/%s/' % d for d in os.listdir('/')] + + def abs_path_start(path, pos): + if pos < 0: + return False + return pos == 0 or path[pos - 1] == ':' + + pp = None + for pr in topdirs: + pp2 = p.find(pr) + if abs_path_start(p, pp2) and (pp is None or pp > pp2): + pp = pp2 + if pp is not None: + return p[:pp] + 'Z:' + p[pp:].replace('/', '\\') + if p.startswith('/Fo'): + return '/Fo' + p[3:].replace('/', '\\') + return p + + +def process_free_args(args, wine, bld_root, mode): + whole_archive_prefix = '/WHOLEARCHIVE:' + short_names = {} + winepath = os.path.join(os.path.dirname(wine), 'winepath') + short_names[bld_root] = trim_path(bld_root, winepath) + # Slow for no benefit. + # arc_root = args.arcadia_root + # short_names[arc_root] = trim_path(arc_root, winepath) + + free_args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(args)) + + process_link = lambda x: make_full_path_arg(x, bld_root, short_names[bld_root]) if mode in ('link', 'lib') else x + + def process_arg(arg): + with_wa_prefix = arg.startswith(whole_archive_prefix) + prefix = whole_archive_prefix if with_wa_prefix else '' + without_prefix_arg = arg[len(prefix):] + return prefix + fix_path(process_link(downsize_path(without_prefix_arg, short_names))) + + result = [] + for arg in free_args: + if pcf.is_cmdfile_arg(arg): + cmd_file_path = pcf.cmdfile_path(arg) + cf_args = pcf.read_from_command_file(cmd_file_path) + with open(cmd_file_path, 'w') as afile: + for cf_arg in cf_args: + afile.write(process_arg(cf_arg) + "\n") + result.append(arg) + else: + result.append(process_arg(arg)) + return pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(result) + + +def run_main(): + parser = argparse.ArgumentParser() + parser.add_argument('wine', action='store') + parser.add_argument('-v', action='store', dest='version', default='120') + parser.add_argument('-I', action='append', dest='incl_paths') + parser.add_argument('mode', action='store') + parser.add_argument('arcadia_root', action='store') + parser.add_argument('arcadia_build_root', action='store') + parser.add_argument('binary', action='store') + parser.add_argument('free_args', nargs=argparse.REMAINDER) + # By now just unpack. Ideally we should fix path and pack arguments back into command file + args = parser.parse_args() + + wine = args.wine + mode = args.mode + binary = args.binary + version = args.version + incl_paths = args.incl_paths + bld_root = args.arcadia_build_root + free_args = args.free_args + + wine_dir = os.path.dirname(os.path.dirname(wine)) + bin_dir = os.path.dirname(binary) + tc_dir = os.path.dirname(os.path.dirname(os.path.dirname(bin_dir))) + if not incl_paths: + incl_paths = [tc_dir + '/VC/include', tc_dir + '/include'] + + cmd_out = find_cmd_out(free_args) + + env = os.environ.copy() + + env.pop('DISPLAY', None) + + env['WINEDLLOVERRIDES'] = 'msvcr{}=n'.format(version) + env['WINEDEBUG'] = 'fixme-all' + env['INCLUDE'] = ';'.join(fix_path(p) for p in incl_paths) + env['VSINSTALLDIR'] = fix_path(tc_dir) + env['VCINSTALLDIR'] = fix_path(tc_dir + '/VC') + env['WindowsSdkDir'] = fix_path(tc_dir) + env['LIBPATH'] = fix_path(tc_dir + '/VC/lib/amd64') + env['LIB'] = fix_path(tc_dir + '/VC/lib/amd64') + env['LD_LIBRARY_PATH'] = ':'.join(wine_dir + d for d in ['/lib', '/lib64', '/lib64/wine']) + + cmd = [binary] + process_free_args(free_args, wine, bld_root, mode) + + for x in ('/NOLOGO', '/nologo', '/FD'): + try: + cmd.remove(x) + except ValueError: + pass + + def run_process(sleep, tout): + if sleep: + time.sleep(sleep) + + args = { + 'cmd': cmd, + 'env': env, + 'mode': mode, + 'tout': tout + } + + slave_cmd = [sys.executable, sys.argv[0], wine, 'slave', json.dumps(args)] + p = run_subprocess(slave_cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=False) + out, _ = p.communicate() + return p.wait(), out + + def print_err_log(log): + if not log: + return + if mode == 'cxx': + log = colorize(log) + print >>sys.stderr, log + + tout = 200 + + while True: + rc, out = run_process(0, tout) + + if rc in (-signal.SIGALRM, signal.SIGALRM): + print_err_log(out) + print >>sys.stderr, '##append_tag##time out' + elif out and ' stack overflow ' in out: + print >>sys.stderr, '##append_tag##stack overflow' + elif out and 'recvmsg: Connection reset by peer' in out: + print >>sys.stderr, '##append_tag##wine gone' + elif out and 'D8037' in out: + print >>sys.stderr, '##append_tag##repair wine' + + try: + os.unlink(os.path.join(os.environ['WINEPREFIX'], '.update-timestamp')) + except Exception as e: + print >>sys.stderr, e + + else: + print_err_log(out) + + # non-zero return code - bad, return it immediately + if rc: + print >>sys.stderr, '##win_cmd##' + ' '.join(cmd) + print >>sys.stderr, '##args##' + ' '.join(free_args) + return rc + + # check for output existence(if we expect it!) and real length + if cmd_out: + if is_good_file(cmd_out): + return 0 + else: + # retry! + print >>sys.stderr, '##append_tag##no output' + else: + return 0 + + tout *= 3 + + +def main(): + prefix_suffix = os.environ.pop('WINEPREFIX_SUFFIX', None) + if prefix_suffix is not None: + prefix = os.environ.pop('WINEPREFIX', None) + if prefix is not None: + os.environ['WINEPREFIX'] = os.path.join(prefix, prefix_suffix) + + # just in case + signal.alarm(2000) + + if sys.argv[2] == 'slave': + func = run_slave + else: + func = run_main + + try: + try: + sys.exit(func()) + finally: + terminate_slaves() + except KeyboardInterrupt: + sys.exit(4) + except Exception as e: + print >>sys.stderr, str(e) + + sys.exit(3) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/run_sonar.py b/build/scripts/run_sonar.py new file mode 100644 index 00000000000..761cc34b788 --- /dev/null +++ b/build/scripts/run_sonar.py @@ -0,0 +1,121 @@ +import os +import sys +import zipfile +import tarfile +import subprocess as sp +import optparse +import shutil +import xml.etree.ElementTree as et + + +def parse_args(): + parser = optparse.OptionParser() + parser.add_option( + '--classes-jar-path', + dest='classes_jar_paths', + action='append', + default=[], + ) + parser.add_option('--sources-jar-path') + parser.add_option('--sonar-scanner-jar-path') + parser.add_option('--sonar-scanner-main-class') + parser.add_option('--java-coverage-merged-tar') + parser.add_option('--java-binary-path') + parser.add_option('--log-path') + parser.add_option('--gcov-report-path') + parser.add_option('--source-root') + parser.add_option('--java-args', action='append', default=[]) + return parser.parse_args() + + +def extract_zip_file(zip_file_path, dest_dir): + with zipfile.ZipFile(zip_file_path) as arch: + arch.extractall(dest_dir) + + +def get_source_real_path(source_root, path): + parts = os.path.normpath(path).split(os.path.sep) + for i in xrange(len(parts)): + if os.path.exists(os.path.join(source_root, *parts[i:])): + return os.path.join(*parts[i:]) + return None + + +def collect_cpp_sources(report, source_root, destination): + sources = set() + with open(report) as f: + root = et.fromstring(f.read()) + for f in root.findall('.//class[@filename]'): + real_filename = get_source_real_path(source_root, f.attrib['filename']) + if real_filename: + f.attrib['filename'] = real_filename + sources.add(real_filename) + with open(report, 'w') as f: + pref = '''<?xml version="1.0" ?> +<!DOCTYPE coverage + SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>\n''' + f.write(pref + et.tostring(root, encoding='utf-8') + '\n\n') + for src in sources: + dst = os.path.join(destination, src) + src = os.path.join(source_root, src) + if os.path.isfile(src): + if not os.path.exists(os.path.dirname(dst)): + os.makedirs(os.path.dirname(dst)) + os.link(src, dst) + + +def main(opts, props_args): + sources_dir = os.path.abspath('src') + base_props_args = ['-Dsonar.sources=' + sources_dir] + os.mkdir(sources_dir) + if opts.sources_jar_path: + extract_zip_file(opts.sources_jar_path, sources_dir) + if opts.gcov_report_path: + collect_cpp_sources(opts.gcov_report_path, opts.source_root, sources_dir) + base_props_args += ['-Dsonar.projectBaseDir=' + sources_dir, '-Dsonar.cxx.coverage.reportPath=' + opts.gcov_report_path] + + if opts.classes_jar_paths: + classes_dir = os.path.abspath('cls') + os.mkdir(classes_dir) + + for classes_jar_path in opts.classes_jar_paths: + extract_zip_file(classes_jar_path, classes_dir) + + base_props_args.append('-Dsonar.java.binaries=' + classes_dir) + + if opts.java_coverage_merged_tar: + jacoco_report_path = os.path.abspath('jacoco.exec') + with open(jacoco_report_path, 'w') as dest: + with tarfile.open(opts.java_coverage_merged_tar) as tar: + for src in tar: + extracted = tar.extractfile(src) + if extracted is not None: + shutil.copyfileobj(extracted, dest) + + base_props_args += [ + '-Dsonar.core.codeCoveragePlugin=jacoco', + '-Dsonar.jacoco.reportPath=' + jacoco_report_path + ] + java_args = ['-{}'.format(i) for i in opts.java_args] + ['-Djava.net.preferIPv6Addresses=true', '-Djava.net.preferIPv4Addresses=false'] + + sonar_cmd = [ + opts.java_binary_path, + ] + java_args + [ + '-classpath', + opts.sonar_scanner_jar_path, + ] + base_props_args + props_args + [opts.sonar_scanner_main_class, '-X'] + + p = sp.Popen(sonar_cmd, stdout=sp.PIPE, stderr=sp.STDOUT) + out, _ = p.communicate() + + sys.stderr.write(out) + with open(opts.log_path, 'a') as f: + f.write(out) + + sys.exit(p.returncode) + + +if __name__ == '__main__': + opts, args = parse_args() + props_args = ['-D' + arg for arg in args] + main(opts, props_args) diff --git a/build/scripts/setup_java_tmpdir.py b/build/scripts/setup_java_tmpdir.py new file mode 100644 index 00000000000..e478d4aa96f --- /dev/null +++ b/build/scripts/setup_java_tmpdir.py @@ -0,0 +1,40 @@ +import os +import sys +import platform +import subprocess + + +def fix_tmpdir(cmd): + if not cmd: + return cmd + java_id, option_name = None, None + for i, java in enumerate(cmd): + if java.endswith('java') or java.endswith('java.exe'): + java_id = i + option_name = '-Djava.io.tmpdir=' + break + if java.endswith('javac') or java.endswith('javac.exe'): + java_id = i + option_name = '-J-Djava.io.tmpdir=' + break + if java_id is None: + return cmd + for arg in cmd[java_id:]: + if arg.startswith(option_name): + return cmd + tmpdir = os.environ.get('TMPDIR') or os.environ.get('TEMPDIR') + if not tmpdir: + return cmd + return cmd[:java_id + 1] + ['{}{}'.format(option_name, tmpdir)] + cmd[java_id + 1:] + + +def just_do_it(): + args = fix_tmpdir(sys.argv[1:]) + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(args).wait()) + else: + os.execv(args[0], args) + + +if __name__ == '__main__': + just_do_it() diff --git a/build/scripts/sky.py b/build/scripts/sky.py new file mode 100644 index 00000000000..b703af7ed1e --- /dev/null +++ b/build/scripts/sky.py @@ -0,0 +1,43 @@ +import logging +import os +import subprocess + +import fetch_from + + +class UnsupportedProtocolException(Exception): + pass + + +def executable_path(): + return "/usr/local/bin/sky" + + +def is_avaliable(): + if not os.path.exists(executable_path()): + return False + try: + subprocess.check_output([executable_path(), "--version"]) + return True + except subprocess.CalledProcessError: + return False + except OSError: + return False + + +def fetch(skynet_id, file_name, timeout=None): + if not is_avaliable(): + raise UnsupportedProtocolException("Skynet is not available") + + target_dir = os.path.abspath(fetch_from.uniq_string_generator()) + os.mkdir(target_dir) + + cmd_args = [executable_path(), "get", "-N", "Backbone", "--user", "--wait", "--dir", target_dir, skynet_id] + if timeout is not None: + cmd_args += ["--timeout", str(timeout)] + + logging.info("Call skynet with args: %s", cmd_args) + stdout = subprocess.check_output(cmd_args).strip() + logging.debug("Skynet call with args %s is finished, result is %s", cmd_args, stdout) + + return os.path.join(target_dir, file_name) diff --git a/build/scripts/stderr2stdout.py b/build/scripts/stderr2stdout.py new file mode 100644 index 00000000000..0e510da3733 --- /dev/null +++ b/build/scripts/stderr2stdout.py @@ -0,0 +1,6 @@ +import subprocess +import sys + +if __name__ == '__main__': + assert len(sys.argv) > 1 + sys.exit(subprocess.Popen(sys.argv[1:], stderr=sys.stdout).wait()) diff --git a/build/scripts/stdout2stderr.py b/build/scripts/stdout2stderr.py new file mode 100644 index 00000000000..d7861fdda32 --- /dev/null +++ b/build/scripts/stdout2stderr.py @@ -0,0 +1,6 @@ +import subprocess +import sys + +if __name__ == '__main__': + assert len(sys.argv) > 1 + sys.exit(subprocess.Popen(sys.argv[1:], stdout=sys.stderr).wait()) diff --git a/build/scripts/symlink.py b/build/scripts/symlink.py new file mode 100755 index 00000000000..9e30a25065e --- /dev/null +++ b/build/scripts/symlink.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import sys +import os +import platform +from subprocess import call + + +def symlink(): + if len(sys.argv) < 3: + print >>sys.stderr, "Usage: symlink.py <source> <target>" + sys.exit(1) + + source = sys.argv[1] + target = sys.argv[2] + + print("Making a symbolic link from {0} to {1}".format(source, target)) + + sysName = platform.system() + if sysName == "Windows": # and not os.path.exists(target) + if os.path.isdir(source): + call(["mklink", "/D", target, source], shell=True) + else: + call(["mklink", target, source], shell=True) + else: + call(["ln", "-f", "-s", "-n", source, target]) + +if __name__ == '__main__': + symlink() diff --git a/build/scripts/tar_directory.py b/build/scripts/tar_directory.py new file mode 100644 index 00000000000..a91889fa22f --- /dev/null +++ b/build/scripts/tar_directory.py @@ -0,0 +1,45 @@ +import os +import sys +import tarfile + + +def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + +def main(args): + if len(args) < 2 or len(args) > 3: + raise Exception("Illegal usage: `tar_directory.py archive.tar directory [skip prefix]` or `tar_directory.py archive.tar output_directory --extract`") + tar, directory, prefix, extract = args[0], args[1], None, False + if len(args) == 3: + if args[2] == '--extract': + extract = True + else: + prefix = args[2] + for tar_exe in ('/usr/bin/tar', '/bin/tar'): + if not is_exe(tar_exe): + continue + if extract: + dest = os.path.abspath(directory) + if not os.path.exists(dest): + os.makedirs(dest) + os.execv(tar_exe, [tar_exe, '-xf', tar, '-C', dest]) + else: + source = os.path.relpath(directory, prefix) if prefix else directory + os.execv(tar_exe, [tar_exe, '-cf', tar] + (['-C', prefix] if prefix else []) + [source]) + break + else: + if extract: + dest = os.path.abspath(directory) + if not os.path.exists(dest): + os.makedirs(dest) + with tarfile.open(tar, 'r') as tar_file: + tar_file.extractall(dest) + else: + source = directory + with tarfile.open(tar, 'w') as out: + out.add(os.path.abspath(source), arcname=os.path.relpath(source, prefix) if prefix else source) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/build/scripts/tar_sources.py b/build/scripts/tar_sources.py new file mode 100644 index 00000000000..d7e650e4ac4 --- /dev/null +++ b/build/scripts/tar_sources.py @@ -0,0 +1,41 @@ +import argparse +import os +import tarfile + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--exts', nargs='*', default=None) + parser.add_argument('--flat', action='store_true') + parser.add_argument('--input', required=True) + parser.add_argument('--output', required=True) + parser.add_argument('--prefix', default=None) + + return parser.parse_args() + + +def main(): + args = parse_args() + + srcs = [] + for root, _, files in os.walk(args.input): + for f in files: + if not args.exts or f.endswith(tuple(args.exts)): + srcs.append(os.path.join(root, f)) + + compression_mode = '' + if args.output.endswith(('.tar.gz', '.tgz')): + compression_mode = 'gz' + elif args.output.endswith('.bzip2'): + compression_mode = 'bz2' + + with tarfile.open(args.output, 'w:{}'.format(compression_mode)) as out: + for f in srcs: + arcname = os.path.basename(f) if args.flat else os.path.relpath(f, args.input) + if args.prefix: + arcname = os.path.join(args.prefix, arcname) + out.add(f, arcname=arcname) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/tared_protoc.py b/build/scripts/tared_protoc.py new file mode 100644 index 00000000000..7643e1dbfe4 --- /dev/null +++ b/build/scripts/tared_protoc.py @@ -0,0 +1,31 @@ +import os +import optparse +import tarfile +import contextlib +import subprocess as sp + + +def parse_args(): + parser = optparse.OptionParser() + parser.disable_interspersed_args() + parser.add_option('--tar-output') + parser.add_option('--protoc-out-dir') + return parser.parse_args() + + +def main(): + opts, args = parse_args() + assert opts.tar_output + assert opts.protoc_out_dir + + if not os.path.exists(opts.protoc_out_dir): + os.makedirs(opts.protoc_out_dir) + + sp.check_call(args) + + with contextlib.closing(tarfile.open(opts.tar_output, 'w')) as tf: + tf.add(opts.protoc_out_dir, arcname='') + + +if __name__ == '__main__': + main() diff --git a/build/scripts/touch.py b/build/scripts/touch.py new file mode 100755 index 00000000000..e01ba7f86b3 --- /dev/null +++ b/build/scripts/touch.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +import optparse +import os +import sys +import time + + +def main(argv): + parser = optparse.OptionParser(add_help_option=False) + parser.disable_interspersed_args() + + parser.add_option('-?', '--help', dest='help', + action='store_true', default=None, help='print help') + parser.add_option('-t', dest='t', action='store', default=None) + + opts, argv_rest = parser.parse_args(argv) + if getattr(opts, 'help', False): + parser.print_help() + return 0 + + tspec = opts.t + if tspec is None: + times = None + else: + head, sep, tail = tspec.partition('.') + if 8 > len(head): + raise Exception("time spec must follow format [[CC]YY]MMDDhhmm[.SS]: " + tspec + '; ' + head) + tfmt = '' + if 12 == len(head): + tfmt += '%Y' + elif 10 == len(head): + tfmt += '%y' + tfmt += '%m%d%H%M' + if 2 == len(tail): + tfmt += '.%S' + mtime = time.mktime(time.strptime(tspec, tfmt)) + times = (mtime, mtime) + + for file in argv_rest: + try: + os.utime(file, times) + except: + open(file, 'w').close() + if times is not None: + os.utime(file, times) + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/build/scripts/unpacking_jtest_runner.py b/build/scripts/unpacking_jtest_runner.py new file mode 100644 index 00000000000..9730dcd7116 --- /dev/null +++ b/build/scripts/unpacking_jtest_runner.py @@ -0,0 +1,148 @@ +import io +import json +import optparse +import os +import sys +import subprocess +import time +import zipfile +import platform + +# This script changes test run classpath by unpacking tests.jar -> tests-dir. The goal +# is to launch tests with the same classpath as maven does. + + +def parse_args(): + parser = optparse.OptionParser() + parser.disable_interspersed_args() + parser.add_option('--trace-file') + parser.add_option('--jar-binary') + parser.add_option('--tests-jar-path') + parser.add_option('--classpath-option-type', choices=('manifest', 'command_file', 'list'), default='manifest') + return parser.parse_args() + + +# temporary, for jdk8/jdk9+ compatibility +def fix_cmd(cmd): + if not cmd: + return cmd + java = cmd[0] + if not java.endswith('java') and not java.endswith('java.exe'): + return cmd + p = subprocess.Popen([java, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + out, err = out.strip(), err.strip() + if ((out or '').strip().startswith('java version "1.8') or (err or '').strip().startswith('java version "1.8')): + res = [] + i = 0 + while i < len(cmd): + for option in ('--add-exports', '--add-modules'): + if cmd[i] == option: + i += 1 + break + elif cmd[i].startswith(option + '='): + break + else: + res.append(cmd[i]) + i += 1 + return res + return cmd + + +def dump_event(etype, data, filename): + event = { + 'timestamp': time.time(), + 'value': data, + 'name': etype, + } + + with io.open(filename, 'a', encoding='utf8') as afile: + afile.write(unicode(json.dumps(event) + '\n')) + + +def dump_chunk_event(data, filename): + return dump_event('chunk-event', data, filename) + + +def extract_jars(dest, archive): + os.makedirs(dest) + with zipfile.ZipFile(archive) as zf: + zf.extractall(dest) + + +def make_bfg_from_cp(class_path, out): + class_path = ' '.join( + map(lambda path: ('file:/' + path.lstrip('/')) if os.path.isabs(path) else path, class_path) + ) + with zipfile.ZipFile(out, 'w') as zf: + lines = [] + while class_path: + lines.append(class_path[:60]) + class_path = class_path[60:] + if lines: + zf.writestr('META-INF/MANIFEST.MF', 'Manifest-Version: 1.0\nClass-Path: \n ' + '\n '.join(lines) + ' \n\n') + + +def make_command_file_from_cp(class_path, out): + with open(out, 'w') as cp_file: + cp_file.write(os.pathsep.join(class_path)) + + +def main(): + s = time.time() + opts, args = parse_args() + + # unpack tests jar + try: + build_root = args[args.index('--build-root') + 1] + dest = os.path.join(build_root, 'test-classes') + except Exception: + build_root = '' + dest = os.path.abspath('test-classes') + + extract_jars(dest, opts.tests_jar_path) + + metrics = { + 'suite_jtest_extract_jars_(seconds)': time.time() - s, + } + + s = time.time() + # fix java classpath + cp_idx = args.index('-classpath') + if args[cp_idx + 1].startswith('@'): + real_name = args[cp_idx + 1][1:] + mf = os.path.join(os.path.dirname(real_name), 'fixed.bfg.jar') + with open(real_name) as origin: + class_path = [os.path.join(build_root, i.strip()) for i in origin] + if opts.tests_jar_path in class_path: + class_path.remove(opts.tests_jar_path) + if opts.classpath_option_type == 'manifest': + make_bfg_from_cp(class_path, mf) + mf = os.pathsep.join([dest, mf]) + elif opts.classpath_option_type == 'command_file': + mf = os.path.splitext(mf)[0] + '.txt' + make_command_file_from_cp([dest] + class_path, mf) + mf = "@" + mf + elif opts.classpath_option_type == 'list': + mf = os.pathsep.join([dest] + class_path) + else: + raise Exception("Unexpected classpath option type: " + opts.classpath_option_type) + args = fix_cmd(args[:cp_idx + 1]) + [mf] + args[cp_idx + 2:] + else: + args[cp_idx + 1] = args[cp_idx + 1].replace(opts.tests_jar_path, dest) + args = fix_cmd(args[:cp_idx]) + args[cp_idx:] + + metrics['suite_jtest_fix_classpath_(seconds)'] = time.time() - s + + if opts.trace_file: + dump_chunk_event({'metrics': metrics}, opts.trace_file) + + # run java cmd + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(args).wait()) + else: + os.execv(args[0], args) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/with_coverage.py b/build/scripts/with_coverage.py new file mode 100644 index 00000000000..d62435c3b8f --- /dev/null +++ b/build/scripts/with_coverage.py @@ -0,0 +1,40 @@ +# TODO prettyboy remove after ya-bin release + +import os +import sys +import subprocess +import tarfile +import random +import shutil + + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError: + pass + + +def main(args): + coverage_path = os.path.abspath(args[0]) + coverage_dir = coverage_path + '.' + str(random.getrandbits(64)) + + mkdir_p(coverage_dir) + + env = os.environ.copy() + env['GCOV_PREFIX'] = coverage_dir + + subprocess.check_call(args[1:], env=env) + + arch_path = coverage_dir + '.archive' + + with tarfile.open(arch_path, 'w:') as tar: + tar.add(coverage_dir, arcname='.') + + os.rename(arch_path, coverage_path) + + shutil.rmtree(coverage_dir) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/build/scripts/with_crash_on_timeout.py b/build/scripts/with_crash_on_timeout.py new file mode 100644 index 00000000000..bde864ed29c --- /dev/null +++ b/build/scripts/with_crash_on_timeout.py @@ -0,0 +1,22 @@ +# TODO prettyboy remove after ya-bin release + +import os +import sys +import subprocess +import json + + +def main(args): + meta_path = os.path.abspath(args[0]) + timeout_code = int(args[1]) + subprocess.check_call(args[2:]) + with open(meta_path) as f: + meta_info = json.loads(f.read()) + if meta_info["exit_code"] == timeout_code: + print >> sys.stderr, meta_info["project"], 'crashed by timeout, use --test-disable-timeout option' + return 1 + return 0 + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/build/scripts/with_kapt_args.py b/build/scripts/with_kapt_args.py new file mode 100644 index 00000000000..eb7438a4c9f --- /dev/null +++ b/build/scripts/with_kapt_args.py @@ -0,0 +1,35 @@ +import sys +import os +import subprocess +import platform +import argparse +import re + + +def parse_args(args): + parser = argparse.ArgumentParser() + parser.add_argument('--ap-classpath', nargs='*', type=str, dest='classpath') + cmd_start = args.index('--') + return parser.parse_args(args[:cmd_start]), args[cmd_start+1:] + + +def get_ap_classpath(directory): + jar_re = re.compile(r'.*(?<!-sources)\.jar') + found_jars = [os.path.join(address, name) for address, dirs, files in os.walk(directory) for name in files if jar_re.match(name)] + if len(found_jars) != 1: + raise Exception("found %d JAR files in directory %s" % (len(found_jars), directory)) + arg = 'plugin:org.jetbrains.kotlin.kapt3:apclasspath=' + found_jars[0] + return '-P', arg + + +def create_extra_args(args): + cp_opts = [arg for d in args.classpath for arg in get_ap_classpath(d)] + return cp_opts + +if __name__ == '__main__': + args, cmd = parse_args(sys.argv[1:]) + res = cmd + create_extra_args(args) + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(res).wait()) + else: + os.execv(res[0], res) diff --git a/build/scripts/with_pathsep_resolve.py b/build/scripts/with_pathsep_resolve.py new file mode 100644 index 00000000000..37c8c598ae8 --- /dev/null +++ b/build/scripts/with_pathsep_resolve.py @@ -0,0 +1,23 @@ +import sys +import os +import subprocess +import platform + + +def fix_args(args): + just_replace_it = False + for arg in args: + if arg == '--fix-path-sep': + just_replace_it = True + continue + if just_replace_it: + arg = arg.replace('::', os.pathsep) + just_replace_it = False + yield arg + +if __name__ == '__main__': + res = list(fix_args(sys.argv[1:])) + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(res).wait()) + else: + os.execv(res[0], res) diff --git a/build/scripts/wrap_groovyc.py b/build/scripts/wrap_groovyc.py new file mode 100644 index 00000000000..068b73fd87a --- /dev/null +++ b/build/scripts/wrap_groovyc.py @@ -0,0 +1,23 @@ +import platform +import sys +import os +import subprocess + + +def fix_windows(args): + for arg in args: + if os.path.basename(arg) == 'groovyc' and os.path.basename(os.path.dirname(arg)) == 'bin': + yield arg + '.bat' + else: + yield arg + + +if __name__ == '__main__': + env = os.environ.copy() + jdk = sys.argv[1] + env['JAVA_HOME'] = jdk + args = sys.argv[2:] + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(list(fix_windows(args)), env=env).wait()) + else: + os.execve(args[0], args, env) diff --git a/build/scripts/wrapcc.py b/build/scripts/wrapcc.py new file mode 100644 index 00000000000..88a9e6a4fc7 --- /dev/null +++ b/build/scripts/wrapcc.py @@ -0,0 +1,45 @@ +from __future__ import print_function + +import os +import sys +import time +import subprocess + + +def need_retry(text): + return 'Stack dump' in text + + +def retry_inf(cmd): + while True: + try: + yield subprocess.check_output(cmd, stderr=subprocess.STDOUT), None + except subprocess.CalledProcessError as e: + yield e.output, e + + +def retry(cmd): + for n, (out, err) in enumerate(retry_inf(cmd)): + if out: + sys.stderr.write(out) + + if n > 5: + raise Exception('all retries failed') + elif need_retry(out): + time.sleep(1 + n) + elif err: + raise err + else: + return + + +if __name__ == '__main__': + cmd = sys.argv[1:] + + if '-c' in cmd: + try: + retry(cmd) + except subprocess.CalledProcessError as e: + sys.exit(e.returncode) + else: + os.execv(cmd[0], cmd) diff --git a/build/scripts/wrapper.py b/build/scripts/wrapper.py new file mode 100644 index 00000000000..1e9d7955a52 --- /dev/null +++ b/build/scripts/wrapper.py @@ -0,0 +1,11 @@ +import os +import sys + + +if __name__ == '__main__': + path = sys.argv[1] + + if path[0] != '/': + path = os.path.join(os.path.dirname(__file__), path) + + os.execv(path, [path] + sys.argv[2:]) diff --git a/build/scripts/write_file_size.py b/build/scripts/write_file_size.py new file mode 100644 index 00000000000..880fb90644b --- /dev/null +++ b/build/scripts/write_file_size.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import sys +import os.path + +if __name__ == '__main__': + output = sys.argv[1] + size_sum = 0 + for filename in sys.argv[2:]: + if os.path.exists(filename): + size_sum += os.path.getsize(filename) + else: + sys.stderr.write('write_file_size.py: {0}: No such file or directory\n'.format(filename)) + sys.exit(1) + with open(output, 'w') as f: + f.write(str(size_sum)) diff --git a/build/scripts/writer.py b/build/scripts/writer.py new file mode 100644 index 00000000000..21bb3006e58 --- /dev/null +++ b/build/scripts/writer.py @@ -0,0 +1,40 @@ +import sys +import argparse + +import process_command_files as pcf + + +def parse_args(): + args = pcf.get_args(sys.argv[1:]) + parser = argparse.ArgumentParser() + parser.add_argument('-f', '--file', dest='file_path') + parser.add_argument('-a', '--append', action='store_true', default=False) + parser.add_argument('-Q', '--quote', action='store_true', default=False) + parser.add_argument('-s', '--addspace', action='store_true', default=False) + parser.add_argument('-c', '--content', action='append', dest='content') + parser.add_argument('-m', '--content-multiple', nargs='*', dest='content') + parser.add_argument('-P', '--path-list', action='store_true', default=False) + return parser.parse_args(args) + + +def smart_shell_quote(v): + if v is None: + return None + if ' ' in v or '"' in v or "'" in v: + return "\"{0}\"".format(v.replace('"', '\\"')) + return v + +if __name__ == '__main__': + args = parse_args() + open_type = 'a' if args.append else 'w' + + content = args.content + if args.quote: + content = [smart_shell_quote(ln) for ln in content] if content is not None else None + content = '\n'.join(content) + + with open(args.file_path, open_type) as f: + if args.addspace: + f.write(' ') + if content is not None: + f.write(content) diff --git a/build/scripts/xargs.py b/build/scripts/xargs.py new file mode 100644 index 00000000000..5d68929eccd --- /dev/null +++ b/build/scripts/xargs.py @@ -0,0 +1,18 @@ +import sys +import os +import subprocess + +if __name__ == '__main__': + pos = sys.argv.index('--') + fname = sys.argv[pos + 1] + cmd = sys.argv[pos + 2:] + + with open(fname, 'r') as f: + args = [x.strip() for x in f] + + os.remove(fname) + + p = subprocess.Popen(cmd + args, shell=False, stderr=sys.stderr, stdout=sys.stdout) + p.communicate() + + sys.exit(p.returncode) diff --git a/build/scripts/ya.make b/build/scripts/ya.make new file mode 100644 index 00000000000..837f0e04942 --- /dev/null +++ b/build/scripts/ya.make @@ -0,0 +1,110 @@ +OWNER(g:ymake) + +PY23_TEST() + +IF (PY2) + TEST_SRCS( + build_dll_and_java.py + build_java_codenav_index.py + build_java_with_error_prone.py + build_java_with_error_prone2.py + build_mn.py + build_pln_header.py + cat.py + cgo1_wrapper.py + check_config_h.py + collect_java_srcs.py + compile_cuda.py + compile_java.py + compile_jsrc.py + compile_pysrc.py + configure_file.py + copy_docs_files.py + copy_docs_files_to_dir.py + copy_files_to_dir.py + copy_to_dir.py + coverage-info.py + cpp_flatc_wrapper.py + create_jcoverage_report.py + extract_asrc.py + extract_docs.py + extract_jacoco_report.py + f2c.py + fail_module_cmd.py + fetch_from.py + fetch_from_external.py + fetch_from_mds.py + fetch_from_npm.py + fetch_from_sandbox.py + fetch_resource.py + filter_zip.py + find_and_tar.py + fix_msvc_output.py + fs_tools.py + gen_aar_gradle_script.py + gen_java_codenav_entry.py + gen_java_codenav_protobuf.py + gen_mx_table.py + gen_py3_reg.py + gen_py_reg.py + gen_test_apk_gradle_script.py + gen_ub.py + generate_pom.py + go_proto_wrapper.py + go_tool.py + ios_wrapper.py + java_pack_to_file.py + link_asrc.py + link_dyn_lib.py + link_exe.py + link_fat_obj.py + link_lib.py + llvm_opt_wrapper.py + merge_coverage_data.py + merge_files.py + mkdir.py + mkdocs_builder_wrapper.py + mkver.py + pack_ios.py + pack_jcoverage_resources.py + perl_wrapper.py + postprocess_go_fbs.py + preprocess.py + py_compile.py + run_ios_simulator.py + run_javac.py + run_junit.py + run_llvm_dsymutil.py + run_msvc_wine.py + run_tool.py + sky.py + stdout2stderr.py + symlink.py + tar_directory.py + tar_sources.py + tared_protoc.py + touch.py + unpacking_jtest_runner.py + vcs_info.py + with_coverage.py + with_crash_on_timeout.py + with_pathsep_resolve.py + wrap_groovyc.py + wrapper.py + writer.py + write_file_size.py + xargs.py + yield_line.py + yndexer.py + ) +ELSEIF(PY3) + TEST_SRCS( + build_info_gen.py + ) +ENDIF() + +PEERDIR( + ydb/library/yql/public/udf +) + +END() diff --git a/build/scripts/yield_line.py b/build/scripts/yield_line.py new file mode 100644 index 00000000000..c7087e521e7 --- /dev/null +++ b/build/scripts/yield_line.py @@ -0,0 +1,8 @@ +import sys + + +if __name__ == '__main__': + pos = sys.argv.index('--') + + with open(sys.argv[pos + 1], 'a') as f: + f.write(' '.join(sys.argv[pos + 2:]) + '\n') diff --git a/build/scripts/yndexer.py b/build/scripts/yndexer.py new file mode 100644 index 00000000000..a38e28ba99f --- /dev/null +++ b/build/scripts/yndexer.py @@ -0,0 +1,79 @@ +import sys +import subprocess +import threading +import os +import re + + +rx_resource_dir = re.compile(r'libraries: =([^:]*)') + + +def _try_to_kill(process): + try: + process.kill() + except Exception: + pass + + +def touch(path): + if not os.path.exists(path): + with open(path, 'w'): + pass + + +class Process(object): + def __init__(self, args): + self._process = subprocess.Popen(args) + self._event = threading.Event() + self._result = None + thread = threading.Thread(target=self._run) + thread.setDaemon(True) + thread.start() + + def _run(self): + self._process.communicate() + self._result = self._process.returncode + self._event.set() + + def wait(self, timeout): + self._event.wait(timeout=timeout) + _try_to_kill(self._process) + return self._result + + +if __name__ == '__main__': + args = sys.argv + + yndexer = args[1] + timeout = int(args[2]) + arc_root = args[3] + build_root = args[4] + input_file = args[5] + output_file = args[-1] + tail_args = args[6:-1] + + subprocess.check_call(tail_args) + + clang = tail_args[0] + out = subprocess.check_output([clang, '-print-search-dirs']) + resource_dir = rx_resource_dir.search(out).group(1) + + yndexer_args = [ + yndexer, input_file, + '-pb2', + '-i', 'arc::{}'.format(arc_root), + '-i', 'build::{}'.format(build_root), + '-i', '.IGNORE::/', + '-o', os.path.dirname(output_file), + '-n', os.path.basename(output_file).rsplit('.ydx.pb2', 1)[0], + '--' + ] + tail_args + [ + '-resource-dir', resource_dir, + ] + + process = Process(yndexer_args) + result = process.wait(timeout=timeout) + + if result != 0: + print >> sys.stderr, 'Yndexing process finished with code', result + touch(output_file) diff --git a/build/sysincl.lst b/build/sysincl.lst new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/build/sysincl.lst diff --git a/build/sysincl/android.yml b/build/sysincl/android.yml new file mode 100644 index 00000000000..9a82c0218be --- /dev/null +++ b/build/sysincl/android.yml @@ -0,0 +1,32 @@ +- includes: + - aaudio/AAudio.h + - android/asset_manager.h + - android/asset_manager_jni.h + - android/dlext.h + - android/log.h + - android/native_window_jni.h + - cpu-features.h: contrib/libs/android_cpufeatures/cpu-features.h + - ifaddrs.h: contrib/libs/libc_compat/include/ifaddrs/ifaddrs.h + - jni.h + - vulkan/vulkan.h + - vulkan/vk_sdk_platform.h + - EGL/egl.h + - EGL/eglext.h + - GLES2/gl2.h + - GLES2/gl2ext.h + - GLES3/gl31.h + - GLES3/gl32.h + - SLES/OpenSLES.h + - SLES/OpenSLES_Android.h + - SLES/OpenSLES_AndroidConfiguration.h + - SLES/OpenSLES_AndroidMetadata.h + - SLES/OpenSLES_Platform.h + - linux/ashmem.h + +- source_filter: "^contrib/libs/breakpad/src" + includes: + - elf.h: contrib/libs/breakpad/src/common/android/include/elf.h + - link.h: contrib/libs/breakpad/src/common/android/include/link.h + - sys/procfs.h: contrib/libs/breakpad/src/common/android/include/sys/procfs.h + - sys/signal.h: contrib/libs/breakpad/src/common/android/include/sys/signal.h + - sys/user.h: contrib/libs/breakpad/src/common/android/include/sys/user.h diff --git a/build/sysincl/check/cxx.c b/build/sysincl/check/cxx.c new file mode 100644 index 00000000000..2945560f8ee --- /dev/null +++ b/build/sysincl/check/cxx.c @@ -0,0 +1,20 @@ +#include <complex.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fenv.h>
+#include <float.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <locale.h>
+#include <math.h>
+#include <setjmp.h>
+#include <stdatomic.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <tgmath.h>
+#include <wchar.h>
+#include <wctype.h>
diff --git a/build/sysincl/check/ya.make b/build/sysincl/check/ya.make new file mode 100644 index 00000000000..af09f4695d6 --- /dev/null +++ b/build/sysincl/check/ya.make @@ -0,0 +1,11 @@ +OWNER(g:ymake)
+
+LIBRARY()
+
+# This library if configured independently will show issues with C++ resolving in pure C modules
+
+NO_RUNTIME()
+
+SRCS(cxx.c)
+
+END()
\ No newline at end of file diff --git a/build/sysincl/darwin.yml b/build/sysincl/darwin.yml new file mode 100644 index 00000000000..72f2d409717 --- /dev/null +++ b/build/sysincl/darwin.yml @@ -0,0 +1,245 @@ +- includes: + # These headers actually exist in arcadia, so we either should use them and + # add proper PEERDIR, or should #error them if they are not really used: + # - bzlib.h + # - db.h + # - expat.h + # - expat_external.h + # - libunwind.h + # - libxslt/documents.h + # - libxslt/extensions.h + # - libxslt/transform.h + # - libxslt/xsltutils.h + # - pcap-bpf.h + # - pcap-namedb.h + # - pcap.h + # - pcap/bpf.h + # - pcap/namedb.h + # - pcap/pcap.h + # - sasl/sasl.h + # - sasl/saslutil.h + # - uuid/uuid.h + # - zconf.h + + - Availability.h + - AvailabilityMacros.h + - Block.h + - CommonCrypto/CommonCrypto.h + - CommonCrypto/CommonCryptoError.h + - CommonCrypto/CommonCryptor.h + - CommonCrypto/CommonDigest.h + - CommonCrypto/CommonHMAC.h + - CommonCrypto/CommonKeyDerivation.h + - CommonCrypto/CommonRandom.h + - ConditionalMacros.h + - DiskArbitration/DiskArbitration.h + - Endian.h + - MacTypes.h + - TargetConditionals.h + - architecture/byte_order.h + - asl.h + - copyfile.h + - crt_externs.h + - curses.h + - dispatch/dispatch.h + - editline/readline.h + - ffi/ffi.h + - form.h + - gssapi.h + - gssapi/gssapi.h + - gssapi/gssapi_generic.h + - gssapi/gssapi_krb5.h + - histedit.h + - krb5.h + - launch.h + - libkern/OSAtomic.h + - libkern/OSByteOrder.h + - libkern/OSCacheControl.h + - libproc.h + - mach-o/dyld.h + - mach-o/fixup-chains.h + - mach-o/getsect.h + - mach-o/loader.h + - mach/clock.h + - mach/clock_types.h + - mach/error.h + - mach/host_info.h + - mach/kern_return.h + - mach/mach.h + - mach/mach_error.h + - mach/mach_host.h + - mach/mach_init.h + - mach/mach_port.h + - mach/mach_time.h + - mach/mach_traps.h + - mach/mach_types.h + - mach/mach_vm.h + - mach/machine.h + - mach/machine/vm_param.h + - mach/processor_info.h + - mach/semaphore.h + - mach/shared_memory_server.h + - mach/shared_region.h + - mach/task.h + - mach/thread_act.h + - mach/thread_info.h + - mach/thread_policy.h + - mach/vm_map.h + - mach/vm_page_size.h + - mach/vm_param.h + - mach/vm_statistics.h + - machine/_limits.h + - machine/_types.h + - machine/byte_order.h + - machine/endian.h + - machine/limits.h + - machine/param.h + - machine/signal.h + - machine/vmparam.h + - malloc/malloc.h + - menu.h + - ndbm.h + - net/bpf.h + - net/if_dl.h + - net/if_media.h + - net/if_types.h + - net/if_var.h + - netinet/in_pcb.h + - netinet/ip_var.h + - netinet/tcp_fsm.h + - netinet/tcp_timer.h + - netinet/tcp_var.h + - netinet/tcpip.h + - netinet/udp_var.h + - netinet6/in6.h + - nlist.h + - objc/objc-sync.h + - objc/runtime.h + - os/lock.h + - os/log.h + - os/proc.h + - os/signpost.h + - os/trace.h + - panel.h + - pthread/qos.h + - pthread_spis.h + - readline/history.h + - readline/readline.h + - readpassphrase.h + - runetype.h + - simd/simd.h + - strhash.h + - sys/_types.h + - sys/acl.h + - sys/aio.h + - sys/attr.h + - sys/clonefile.h + - sys/dirent.h + - sys/disk.h + - sys/domain.h + - sys/event.h + - sys/filio.h + - sys/ioccom.h + - sys/kauth.h + - sys/kern_control.h + - sys/lock.h + - sys/malloc.h + - sys/mbuf.h + - sys/msgbuf.h + - sys/paths.h + - sys/posix_shm.h + - sys/proc.h + - sys/proc_info.h + - sys/protosw.h + - sys/sdt.h + - sys/sockio.h + - sys/sys_domain.h + - sys/syslimits.h + - sys/ttycom.h + - sys/ucred.h + - sys/unpcb.h + - sys/vmmeter.h + - sys/vnode.h + - tcl.h + - term.h + - termcap.h + - timeconv.h + - tzfile.h + - util.h + - vis.h + - xpc/xpc.h + + # OSX frameworks + - Accelerate/Accelerate.h + - AppKit/AppKit.h + - AppKit/NSView.h + - ApplicationServices/ApplicationServices.h + - AudioToolbox/AudioToolbox.h + - AVFoundation/AVFoundation.h + - CFNetwork/CFNetwork.h + - Cocoa/Cocoa.h + - CoreFoundation/CFArray.h + - CoreFoundation/CFBase.h + - CoreFoundation/CFBundle.h + - CoreFoundation/CFData.h + - CoreFoundation/CFDictionary.h + - CoreFoundation/CFLocale.h + - CoreFoundation/CFNumber.h + - CoreFoundation/CFPreferences.h + - CoreFoundation/CFRunLoop.h + - CoreFoundation/CFString.h + - CoreFoundation/CFTimeZone.h + - CoreFoundation/CFUUID.h + - CoreFoundation/CoreFoundation.h + - CoreGraphics/CoreGraphics.h + - CoreLocation/CoreLocation.h + - CoreMedia/CoreMedia.h + - CoreMotion/CoreMotion.h + - CoreServices/CoreServices.h + - CoreTelephony/CTCarrier.h + - CoreTelephony/CTTelephonyNetworkInfo.h + - CoreText/CoreText.h + - CoreVideo/CoreVideo.h + - Foundation/Foundation.h + - Foundation/NSException.h + - Foundation/NSString.h + - Foundation/NSKeyValueObserving.h + - Foundation/NSObject.h + - GLKit/GLKit.h + - IOKit/IOBSD.h + - IOKit/IOKitLib.h + - IOKit/kext/KextManager.h + - IOKit/ps/IOPSKeys.h + - IOKit/ps/IOPSKeys.h + - IOKit/ps/IOPowerSources.h + - IOKit/ps/IOPowerSources.h + - IOKit/ps/IOPowerSources.h + - IOKit/storage/IOBlockStorageDriver.h + - IOKit/storage/IOMedia.h + - IOSurface/IOSurfaceRef.h + - Metal/Metal.h + - metal_stdlib + - OpenCL/cl.h + - OpenCL/cl_gl.h + - OpenCL/opencl.h + - OpenGLES/ES2/gl.h + - Speech/Speech.h + - QuartzCore/QuartzCore.h + - QuartzCore/CAEAGLLayer.h + - QuartzCore/CAMetalLayer.h + - Security/SecCertificate.h + - Security/SecKey.h + - Security/SecRandom.h + - Security/SecureTransport.h + - Security/Security.h + - SystemConfiguration/SystemConfiguration.h + - SystemConfiguration/SCDynamicStoreCopySpecific.h + - UIKit/UIImage.h + - UIKit/UIKit.h + - UIKit/UIScreen.h + - UIKit/UIWebView.h + - UIKit/UIView.h + - VideoDecodeAcceleration/VDADecoder.h + - VideoToolbox/VideoToolbox.h + - XCTest/XCTest.h + - CoreFoundation/CFByteOrder.h diff --git a/build/sysincl/esp-idf.yml b/build/sysincl/esp-idf.yml new file mode 100644 index 00000000000..736166396ee --- /dev/null +++ b/build/sysincl/esp-idf.yml @@ -0,0 +1,55 @@ +- includes: + # freertos + - freertos/FreeRTOS.h: contrib/libs/esp-idf/components/freertos/include/freertos/FreeRTOS.h + - freertos/semphr.h: contrib/libs/esp-idf/components/freertos/include/freertos/semphr.h + - freertos/task.h: contrib/libs/esp-idf/components/freertos/include/freertos/task.h + # lwip + - lwip/def.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/def.h + - lwip/err.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/err.h + - lwip/inet.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/inet.h + - lwip/init.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/init.h + - lwip/ip4_addr.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/ip4_addr.h + - lwip/ip_addr.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/ip_addr.h + - lwip/mem.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/mem.h + - lwip/memp.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/memp.h + - lwip/netif.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/netif.h + - lwip/opt.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/opt.h + - lwip/pbuf.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/pbuf.h + - lwip/stats.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/stats.h + - lwip/sys.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/sys.h + - lwip/tcpip.h: contrib/libs/esp-idf/components/lwip/lwip/src/include/lwip/tcpip.h + # newlib + - assert.h: contrib/libs/esp-idf/components/newlib/platform_include/assert.h + - endian.h: contrib/libs/esp-idf/components/newlib/platform_include/endian.h + - errno.h: contrib/libs/esp-idf/components/newlib/platform_include/errno.h + - esp_newlib.h: contrib/libs/esp-idf/components/newlib/platform_include/esp_newlib.h + - net/if.h: contrib/libs/esp-idf/components/newlib/platform_include/net/if.h + - pthread.h: contrib/libs/esp-idf/components/newlib/platform_include/pthread.h + - sys/dirent.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/dirent.h + - sys/ioctl.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/ioctl.h + - sys/lock.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/lock.h + - sys/poll.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/poll.h + - sys/random.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/random.h + - sys/reent.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/reent.h + - sys/select.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/select.h + - sys/termios.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/termios.h + - sys/time.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/time.h + - sys/uio.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/uio.h + - sys/un.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/un.h + - sys/unistd.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/unistd.h + - sys/utime.h: contrib/libs/esp-idf/components/newlib/platform_include/sys/utime.h + - time.h: contrib/libs/esp-idf/components/newlib/platform_include/time.h + # wpa_supplicant + - byteswap.h: contrib/libs/esp-idf/components/wpa_supplicant/port/include/byteswap.h + - endian.h: contrib/libs/esp-idf/components/wpa_supplicant/port/include/endian.h + # espcoredump + - elf.h: contrib/libs/esp-idf/components/espcoredump/include_core_dump/elf.h + +- source_filter: "^contrib/libs/esp-idf(?!/components/cbor)|contrib/libs/connectedhomeip" + includes: + # lwip + - arpa/inet.h: contrib/libs/esp-idf/components/lwip/port/esp32/include/arpa/inet.h + - netinet/in.h: contrib/libs/esp-idf/components/lwip/port/esp32/include/netinet/in.h + - netinet/tcp.h: contrib/libs/esp-idf/components/lwip/port/esp32/include/netinet/tcp.h + - sys/socket.h: contrib/libs/esp-idf/components/lwip/port/esp32/include/sys/socket.h + - netdb.h: contrib/libs/esp-idf/components/lwip/port/esp32/include/netdb.h diff --git a/build/sysincl/ibdrv.yml b/build/sysincl/ibdrv.yml new file mode 100644 index 00000000000..5cf2c360780 --- /dev/null +++ b/build/sysincl/ibdrv.yml @@ -0,0 +1,12 @@ +# This file is conditionally included from ymake.core.conf to ensure +# that contrib/libs/ibdrv/include/{infiniband/verbs.h,rdma/rdma_cma.h} +# are the only ibdrv headers needed for opensource catboost +# (transitively from library/cpp/netliba). They are replaced by empty +# files in put_arcadia_to_git.sh. + +- source_filter: "^contrib/libs/ibdrv" + includes: + - infiniband/sa.h + - infiniband/verbs.h + - infiniband/verbs_api.h + - rdma/rdma_cma.h diff --git a/build/sysincl/intrinsic.yml b/build/sysincl/intrinsic.yml new file mode 100644 index 00000000000..3b72142b222 --- /dev/null +++ b/build/sysincl/intrinsic.yml @@ -0,0 +1,57 @@ +- includes: + - Intrin.h + - ammintrin.h + - arm_acle.h + - arm_fp16.h + - arm_neon.h + - arm64_neon.h + - armintr.h + - avx2intrin.h + - avx512fintrin.h + - avx512dqintrin.h + - avx512cdintrin.h + - avx512bwintrin.h + - avx512vlintrin.h + - avx512vbmiintrin.h + - avx512vbmi2intrin.h + - avx512vpopcntdqintrin.h + - avxintrin.h + - bmi2intrin.h + - bmiintrin.h + - cmnintrin.h + - e2kbuiltin.h + - emmintrin.h + - f16cintrin.h + - fma4intrin.h + - fmaintrin.h + - ia32intrin.h + - ia64intrin.h + - immintrin.h + - intrin.h + - intrin0.h + - intrinsics.h + - lzcntintrin.h + - mm3dnow.h + - mmintrin.h + - msa.h + - nmmintrin.h + - pmmintrin.h + - popcntintrin.h + - prfchwintrin.h + - rdseedintrin.h + - rtmintrin.h + - s390intrin.h + - sanitizer/asan_interface.h: contrib/libs/clang14-rt/include/sanitizer/asan_interface.h + - sanitizer/common_interface_defs.h: contrib/libs/clang14-rt/include/sanitizer/common_interface_defs.h + - sanitizer/coverage_interface.h: contrib/libs/clang14-rt/include/sanitizer/coverage_interface.h + - sanitizer/lsan_interface.h: contrib/libs/clang14-rt/include/sanitizer/lsan_interface.h + - sanitizer/msan_interface.h: contrib/libs/clang14-rt/include/sanitizer/msan_interface.h + - sanitizer/tsan_interface.h: contrib/libs/clang14-rt/include/sanitizer/tsan_interface.h + - sanitizer/tsan_interface_atomic.h: contrib/libs/clang14-rt/include/sanitizer/tsan_interface_atomic.h + - smmintrin.h + - tbmintrin.h + - tmmintrin.h + - wmmintrin.h + - x86intrin.h + - xmmintrin.h + - xopintrin.h diff --git a/build/sysincl/libc-musl-libcxx.yml b/build/sysincl/libc-musl-libcxx.yml new file mode 100644 index 00000000000..539ce8e9aa4 --- /dev/null +++ b/build/sysincl/libc-musl-libcxx.yml @@ -0,0 +1,6 @@ +- source_filter: "^contrib/libs/musl" + includes: + - inttypes.h: contrib/libs/cxxsupp/libcxx/include/inttypes.h + - string.h: contrib/libs/cxxsupp/libcxx/include/string.h + - stddef.h: contrib/libs/cxxsupp/libcxx/include/stddef.h + - stdint.h: contrib/libs/cxxsupp/libcxx/include/stdint.h diff --git a/build/sysincl/libc-to-compat.yml b/build/sysincl/libc-to-compat.yml new file mode 100644 index 00000000000..19ec9a2d09d --- /dev/null +++ b/build/sysincl/libc-to-compat.yml @@ -0,0 +1,6 @@ +# We want musl to resolve itself without these sysincls, but its test must have them +- source_filter: "^(?!contrib/libs/musl).*|^contrib/libs/musl/tests" + includes: + - sys/random.h: "contrib/libs/libc_compat/random/sys/random.h" + - readpassphrase.h: "contrib/libs/libc_compat/include/readpassphrase/readpassphrase.h" + - stdlib.h: "contrib/libs/libc_compat/reallocarray/stdlib.h" diff --git a/build/sysincl/libc-to-musl.yml b/build/sysincl/libc-to-musl.yml new file mode 100644 index 00000000000..5778acefdd9 --- /dev/null +++ b/build/sysincl/libc-to-musl.yml @@ -0,0 +1,253 @@ +# libc & stl common headers should be resolved to either +# * system libc (e.g. nothing in our repo) +# * system libc++ (e.g. nothing in our repo) +# * libcxx +# * musl +# or some combination of them depending on the build flags. + +# Musl has some internal header replacements. We will just resolve to both. +- source_filter: "^(contrib/libs/musl|contrib/libs/cxxsupp/libcxx/include/__config)" + includes: + - arpa/inet.h: + - contrib/libs/musl/include/arpa/inet.h + - contrib/libs/musl/src/include/arpa/inet.h + - crypt.h: + - contrib/libs/musl/include/crypt.h + - contrib/libs/musl/src/include/crypt.h + - errno.h: + - contrib/libs/musl/include/errno.h + - contrib/libs/musl/src/include/errno.h + - features.h: + - contrib/libs/musl/include/features.h + - contrib/libs/musl/src/include/features.h + - langinfo.h: + - contrib/libs/musl/include/langinfo.h + - contrib/libs/musl/src/include/langinfo.h + - pthread.h: + - contrib/libs/musl/include/pthread.h + - contrib/libs/musl/src/include/pthread.h + - resolv.h: + - contrib/libs/musl/include/resolv.h + - contrib/libs/musl/src/include/resolv.h + - signal.h: + - contrib/libs/musl/include/signal.h + - contrib/libs/musl/src/include/signal.h + - stdio.h: + - contrib/libs/musl/include/stdio.h + - contrib/libs/musl/src/include/stdio.h + - stdlib.h: + - contrib/libs/musl/include/stdlib.h + - contrib/libs/musl/src/include/stdlib.h + - string.h: + - contrib/libs/musl/include/string.h + - contrib/libs/musl/src/include/string.h + - sys/auxv.h: + - contrib/libs/musl/include/sys/auxv.h + - contrib/libs/musl/src/include/sys/auxv.h + - sys/membarrier.h: + - contrib/libs/musl/include/sys/membarrier.h + - contrib/libs/musl/src/include/sys/membarrier.h + - sys/mman.h: + - contrib/libs/musl/include/sys/mman.h + - contrib/libs/musl/src/include/sys/mman.h + - sys/sysinfo.h: + - contrib/libs/musl/include/sys/sysinfo.h + - contrib/libs/musl/src/include/sys/sysinfo.h + - sys/time.h: + - contrib/libs/musl/include/sys/time.h + - contrib/libs/musl/src/include/sys/time.h + - time.h: + - contrib/libs/musl/include/time.h + - contrib/libs/musl/src/include/time.h + - unistd.h: + - contrib/libs/musl/include/unistd.h + - contrib/libs/musl/src/include/unistd.h + - wchar.h: + - contrib/libs/musl/include/wchar.h + - contrib/libs/musl/src/include/wchar.h + + - inttypes.h: contrib/libs/musl/include/inttypes.h + - stddef.h: contrib/libs/musl/include/stddef.h + - stdint.h: contrib/libs/musl/include/stdint.h + + +# We want musl to resolve itself without these sysincls, but its test must have them +- source_filter: "^(?!contrib/libs/musl)|^contrib/libs/musl/tests" + includes: + # libc & stl common headers + - complex.h: contrib/libs/musl/include/complex.h + - ctype.h: contrib/libs/musl/include/ctype.h + - errno.h: contrib/libs/musl/include/errno.h + - float.h: contrib/libs/musl/include/float.h + - inttypes.h: contrib/libs/musl/include/inttypes.h + - limits.h: contrib/libs/musl/include/limits.h + - locale.h: contrib/libs/musl/include/locale.h + - math.h: contrib/libs/musl/include/math.h + - setjmp.h: contrib/libs/musl/include/setjmp.h + - stdbool.h: contrib/libs/musl/include/stdbool.h + - stddef.h: contrib/libs/musl/include/stddef.h + - stdint.h: contrib/libs/musl/include/stdint.h + - stdio.h: contrib/libs/musl/include/stdio.h + - stdlib.h: contrib/libs/musl/include/stdlib.h + - string.h: contrib/libs/musl/include/string.h + - tgmath.h: contrib/libs/musl/include/tgmath.h + - threads.h: contrib/libs/musl/include/threads.h + - wchar.h: contrib/libs/musl/include/wchar.h + - wctype.h: contrib/libs/musl/include/wctype.h + + # Rest of libc headers + - aio.h: contrib/libs/musl/include/aio.h + - alloca.h: contrib/libs/musl/include/alloca.h + - ar.h: contrib/libs/musl/include/ar.h + - arpa/inet.h: contrib/libs/musl/include/arpa/inet.h + - arpa/nameser_compat.h: contrib/libs/musl/include/arpa/nameser_compat.h + - arpa/nameser.h: contrib/libs/musl/include/arpa/nameser.h + - arpa/telnet.h: contrib/libs/musl/include/arpa/telnet.h + - arpa/tftp.h: contrib/libs/musl/include/arpa/tftp.h + - assert.h: contrib/libs/musl/include/assert.h + - byteswap.h: contrib/libs/musl/include/byteswap.h + - cpio.h: contrib/libs/musl/include/cpio.h + - crypt.h: contrib/libs/musl/include/crypt.h + - dirent.h: contrib/libs/musl/include/dirent.h + - dlfcn.h: contrib/libs/musl/include/dlfcn.h + - elf.h: contrib/libs/musl/include/elf.h + - endian.h: contrib/libs/musl/include/endian.h + - err.h: contrib/libs/musl/include/err.h + - fcntl.h: contrib/libs/musl/include/fcntl.h + - features.h: contrib/libs/musl/include/features.h + - fenv.h: contrib/libs/musl/include/fenv.h + - fmtmsg.h: contrib/libs/musl/include/fmtmsg.h + - fnmatch.h: contrib/libs/musl/include/fnmatch.h + - ftw.h: contrib/libs/musl/include/ftw.h + - getopt.h: contrib/libs/musl/include/getopt.h + - glob.h: contrib/libs/musl/include/glob.h + - grp.h: contrib/libs/musl/include/grp.h + - ifaddrs.h: contrib/libs/musl/include/ifaddrs.h + - iso646.h: contrib/libs/musl/include/iso646.h + - langinfo.h: contrib/libs/musl/include/langinfo.h + - lastlog.h: contrib/libs/musl/include/lastlog.h + - libgen.h: contrib/libs/musl/include/libgen.h + - libintl.h: contrib/libs/musl/include/libintl.h + - link.h: contrib/libs/musl/include/link.h + - malloc.h: contrib/libs/musl/include/malloc.h + - memory.h: contrib/libs/musl/include/memory.h + - mntent.h: contrib/libs/musl/include/mntent.h + - monetary.h: contrib/libs/musl/include/monetary.h + - mqueue.h: contrib/libs/musl/include/mqueue.h + - netdb.h: contrib/libs/musl/include/netdb.h + - net/ethernet.h: contrib/libs/musl/include/net/ethernet.h + - net/if_arp.h: contrib/libs/musl/include/net/if_arp.h + - net/if.h: contrib/libs/musl/include/net/if.h + - netinet/ether.h: contrib/libs/musl/include/netinet/ether.h + - netinet/icmp6.h: contrib/libs/musl/include/netinet/icmp6.h + - netinet/if_ether.h: contrib/libs/musl/include/netinet/if_ether.h + - netinet/igmp.h: contrib/libs/musl/include/netinet/igmp.h + - netinet/in.h: contrib/libs/musl/include/netinet/in.h + - netinet/in_systm.h: contrib/libs/musl/include/netinet/in_systm.h + - netinet/ip6.h: contrib/libs/musl/include/netinet/ip6.h + - netinet/ip.h: contrib/libs/musl/include/netinet/ip.h + - netinet/ip_icmp.h: contrib/libs/musl/include/netinet/ip_icmp.h + - netinet/tcp.h: contrib/libs/musl/include/netinet/tcp.h + - netinet/udp.h: contrib/libs/musl/include/netinet/udp.h + - netpacket/packet.h: contrib/libs/musl/include/netpacket/packet.h + - net/route.h: contrib/libs/musl/include/net/route.h + - nl_types.h: contrib/libs/musl/include/nl_types.h + - paths.h: contrib/libs/musl/include/paths.h + - poll.h: contrib/libs/musl/include/poll.h + - pthread.h: contrib/libs/musl/include/pthread.h + - pty.h: contrib/libs/musl/include/pty.h + - pwd.h: contrib/libs/musl/include/pwd.h + - regex.h: contrib/libs/musl/include/regex.h + - resolv.h: contrib/libs/musl/include/resolv.h + - sched.h: contrib/libs/musl/include/sched.h + - scsi/scsi.h: contrib/libs/musl/include/scsi/scsi.h + - search.h: contrib/libs/musl/include/search.h + - semaphore.h: contrib/libs/musl/include/semaphore.h + - shadow.h: contrib/libs/musl/include/shadow.h + - signal.h: contrib/libs/musl/include/signal.h + - spawn.h: contrib/libs/musl/include/spawn.h + - stdalign.h: contrib/libs/musl/include/stdalign.h + - stdarg.h: contrib/libs/musl/include/stdarg.h + - stdio_ext.h: contrib/libs/musl/include/stdio_ext.h + - stdnoreturn.h: contrib/libs/musl/include/stdnoreturn.h + - strings.h: contrib/libs/musl/include/strings.h + - stropts.h: contrib/libs/musl/include/stropts.h + - sys/acct.h: contrib/libs/musl/include/sys/acct.h + - sys/auxv.h: contrib/libs/musl/include/sys/auxv.h + - sys/cachectl.h: contrib/libs/musl/include/sys/cachectl.h + - syscall.h: contrib/libs/musl/include/syscall.h + - sys/dir.h: contrib/libs/musl/include/sys/dir.h + - sys/epoll.h: contrib/libs/musl/include/sys/epoll.h + - sys/errno.h: contrib/libs/musl/include/sys/errno.h + - sys/eventfd.h: contrib/libs/musl/include/sys/eventfd.h + - sysexits.h: contrib/libs/musl/include/sysexits.h + - sys/fcntl.h: contrib/libs/musl/include/sys/fcntl.h + - sys/file.h: contrib/libs/musl/include/sys/file.h + - sys/fsuid.h: contrib/libs/musl/include/sys/fsuid.h + - sys/inotify.h: contrib/libs/musl/include/sys/inotify.h + - sys/ioctl.h: contrib/libs/musl/include/sys/ioctl.h + - sys/io.h: contrib/libs/musl/include/sys/io.h + - sys/ipc.h: contrib/libs/musl/include/sys/ipc.h + - sys/kd.h: contrib/libs/musl/include/sys/kd.h + - syslog.h: contrib/libs/musl/include/syslog.h + - sys/mman.h: contrib/libs/musl/include/sys/mman.h + - sys/mount.h: contrib/libs/musl/include/sys/mount.h + - sys/msg.h: contrib/libs/musl/include/sys/msg.h + - sys/mtio.h: contrib/libs/musl/include/sys/mtio.h + - sys/param.h: contrib/libs/musl/include/sys/param.h + - sys/personality.h: contrib/libs/musl/include/sys/personality.h + - sys/poll.h: contrib/libs/musl/include/sys/poll.h + - sys/prctl.h: contrib/libs/musl/include/sys/prctl.h + - sys/procfs.h: contrib/libs/musl/include/sys/procfs.h + - sys/ptrace.h: contrib/libs/musl/include/sys/ptrace.h + - sys/quota.h: contrib/libs/musl/include/sys/quota.h + - sys/random.h: contrib/libs/musl/include/sys/random.h + - sys/reboot.h: contrib/libs/musl/include/sys/reboot.h + - sys/resource.h: contrib/libs/musl/include/sys/resource.h + - sys/select.h: contrib/libs/musl/include/sys/select.h + - sys/sem.h: contrib/libs/musl/include/sys/sem.h + - sys/sendfile.h: contrib/libs/musl/include/sys/sendfile.h + - sys/shm.h: contrib/libs/musl/include/sys/shm.h + - sys/signalfd.h: contrib/libs/musl/include/sys/signalfd.h + - sys/signal.h: contrib/libs/musl/include/sys/signal.h + - sys/socket.h: contrib/libs/musl/include/sys/socket.h + - sys/soundcard.h: contrib/libs/musl/include/sys/soundcard.h + - sys/statfs.h: contrib/libs/musl/include/sys/statfs.h + - sys/stat.h: contrib/libs/musl/include/sys/stat.h + - sys/statvfs.h: contrib/libs/musl/include/sys/statvfs.h + - sys/stropts.h: contrib/libs/musl/include/sys/stropts.h + - sys/syscall.h: contrib/libs/musl/include/sys/syscall.h + - sys/sysinfo.h: contrib/libs/musl/include/sys/sysinfo.h + - sys/syslog.h: contrib/libs/musl/include/sys/syslog.h + - sys/sysmacros.h: contrib/libs/musl/include/sys/sysmacros.h + - sys/termios.h: contrib/libs/musl/include/sys/termios.h + - sys/timeb.h: contrib/libs/musl/include/sys/timeb.h + - sys/time.h: contrib/libs/musl/include/sys/time.h + - sys/timerfd.h: contrib/libs/musl/include/sys/timerfd.h + - sys/times.h: contrib/libs/musl/include/sys/times.h + - sys/timex.h: contrib/libs/musl/include/sys/timex.h + - sys/ttydefaults.h: contrib/libs/musl/include/sys/ttydefaults.h + - sys/types.h: contrib/libs/musl/include/sys/types.h + - sys/ucontext.h: contrib/libs/musl/include/sys/ucontext.h + - sys/uio.h: contrib/libs/musl/include/sys/uio.h + - sys/un.h: contrib/libs/musl/include/sys/un.h + - sys/user.h: contrib/libs/musl/include/sys/user.h + - sys/utsname.h: contrib/libs/musl/include/sys/utsname.h + - sys/vfs.h: contrib/libs/musl/include/sys/vfs.h + - sys/vt.h: contrib/libs/musl/include/sys/vt.h + - sys/wait.h: contrib/libs/musl/include/sys/wait.h + - sys/xattr.h: contrib/libs/musl/include/sys/xattr.h + - tar.h: contrib/libs/musl/include/tar.h + - termios.h: contrib/libs/musl/include/termios.h + - threads.h: contrib/libs/musl/include/threads.h + - time.h: contrib/libs/musl/include/time.h + - uchar.h: contrib/libs/musl/include/uchar.h + - ucontext.h: contrib/libs/musl/include/ucontext.h + - ulimit.h: contrib/libs/musl/include/ulimit.h + - unistd.h: contrib/libs/musl/include/unistd.h + - utime.h: contrib/libs/musl/include/utime.h + - utmp.h: contrib/libs/musl/include/utmp.h + - utmpx.h: contrib/libs/musl/include/utmpx.h + - values.h: contrib/libs/musl/include/values.h + - wait.h: contrib/libs/musl/include/wait.h + - wordexp.h: contrib/libs/musl/include/wordexp.h diff --git a/build/sysincl/libc-to-nothing.yml b/build/sysincl/libc-to-nothing.yml new file mode 100644 index 00000000000..ad4ef9375dd --- /dev/null +++ b/build/sysincl/libc-to-nothing.yml @@ -0,0 +1,161 @@ +# We want musl to resolve itself without these sysincls, but its test must have them +- source_filter: "^(?!contrib/libs/musl).*|^contrib/libs/musl/tests" + includes: + - aio.h + - alloca.h + - ar.h + - arpa/inet.h + - arpa/nameser_compat.h + - arpa/nameser.h + - arpa/telnet.h + - arpa/tftp.h + - assert.h + - byteswap.h + - cpio.h + - crypt.h + - dirent.h + - dlfcn.h + - elf.h + - endian.h + - err.h + - fcntl.h + - features.h + - fenv.h + - fmtmsg.h + - fnmatch.h + - ftw.h + - getopt.h + - glob.h + - grp.h + - iconv.h + - ifaddrs.h + - iso646.h + - langinfo.h + - lastlog.h + - libgen.h + - libintl.h + - link.h + - malloc.h + - memory.h + - mntent.h + - monetary.h + - mqueue.h + - netdb.h + - net/ethernet.h + - net/if_arp.h + - net/if_ppp.h + - net/if.h + - netinet/ether.h + - netinet/icmp6.h + - netinet/if_ether.h + - netinet/igmp.h + - netinet/in.h + - netinet/in_systm.h + - netinet/ip6.h + - netinet/ip.h + - netinet/ip_icmp.h + - netinet/tcp.h + - netinet/udp.h + - netpacket/packet.h + - netrom/netrom.h + - net/route.h + - nl_types.h + - paths.h + - poll.h + - pthread.h + - pty.h + - pwd.h + - regex.h + - resolv.h + - sched.h + - scsi/scsi.h + - search.h + - semaphore.h + - shadow.h + - signal.h + - spawn.h + - stdalign.h + - stdarg.h + - stdatomic.h + - stdio_ext.h + - stdnoreturn.h + - strings.h + - stropts.h + - sys/acct.h + - sys/auxv.h + - sys/cachectl.h + - syscall.h + - sys/dir.h + - sys/epoll.h + - sys/errno.h + - sys/eventfd.h + - sysexits.h + - sys/fcntl.h + - sys/file.h + - sys/fsuid.h + - sys/inotify.h + - sys/ioctl.h + - sys/io.h + - sys/ipc.h + - sys/kd.h + - syslog.h + - sys/mman.h + - sys/mount.h + - sys/msg.h + - sys/mtio.h + - sys/param.h + - sys/personality.h + - sys/poll.h + - sys/prctl.h + - sys/procfs.h + - sys/ptrace.h + - sys/quota.h + - sys/reboot.h + - sys/resource.h + - sys/select.h + - sys/sem.h + - sys/sendfile.h + - sys/shm.h + - sys/signalfd.h + - sys/signal.h + - sys/socket.h + - sys/soundcard.h + - sys/statfs.h + - sys/stat.h + - sys/statvfs.h + - sys/stropts.h + - sys/syscall.h + - sys/sysinfo.h + - sys/syslog.h + - sys/sysmacros.h + - sys/termios.h + - sys/timeb.h + - sys/time.h + - sys/timerfd.h + - sys/times.h + - sys/timex.h + - sys/ttydefaults.h + - sys/types.h + - sys/ucontext.h + - sys/uio.h + - sys/un.h + - sys/user.h + - sys/utsname.h + - sys/vfs.h + - sys/vt.h + - sys/wait.h + - sys/xattr.h + - tar.h + - termios.h + - threads.h + - time.h + - uchar.h + - ucontext.h + - ulimit.h + - unistd.h + - utime.h + - utmp.h + - utmpx.h + - values.h + - wait.h + - wordexp.h diff --git a/build/sysincl/linux-headers.yml b/build/sysincl/linux-headers.yml new file mode 100644 index 00000000000..2b1d5481755 --- /dev/null +++ b/build/sysincl/linux-headers.yml @@ -0,0 +1,1122 @@ +# Generated by devtools/yamaker. +- includes: + - asm-generic/auxvec.h + - asm-generic/bitsperlong.h + - asm-generic/bpf_perf_event.h + - asm-generic/errno-base.h + - asm-generic/errno.h + - asm-generic/fcntl.h + - asm-generic/hugetlb_encode.h + - asm-generic/int-l64.h + - asm-generic/int-ll64.h + - asm-generic/ioctl.h + - asm-generic/ioctls.h + - asm-generic/ipcbuf.h + - asm-generic/kvm_para.h + - asm-generic/mman-common.h + - asm-generic/mman.h + - asm-generic/msgbuf.h + - asm-generic/param.h + - asm-generic/poll.h + - asm-generic/posix_types.h + - asm-generic/resource.h + - asm-generic/sembuf.h + - asm-generic/setup.h + - asm-generic/shmbuf.h + - asm-generic/siginfo.h + - asm-generic/signal-defs.h + - asm-generic/signal.h + - asm-generic/socket.h + - asm-generic/sockios.h + - asm-generic/stat.h + - asm-generic/statfs.h + - asm-generic/swab.h + - asm-generic/termbits.h + - asm-generic/termios.h + - asm-generic/types.h + - asm-generic/ucontext.h + - asm-generic/unistd.h + - asm/a.out.h + - asm/a.out_x86.h + - asm/auxvec.h + - asm/auxvec_arm.h + - asm/auxvec_arm64.h + - asm/auxvec_powerpc.h + - asm/auxvec_x86.h + - asm/bitsperlong.h + - asm/bitsperlong_arm.h + - asm/bitsperlong_arm64.h + - asm/bitsperlong_powerpc.h + - asm/bitsperlong_x86.h + - asm/boot.h + - asm/boot_x86.h + - asm/bootparam.h + - asm/bootparam_x86.h + - asm/bootx.h + - asm/bootx_powerpc.h + - asm/bpf_perf_event.h + - asm/bpf_perf_event_arm.h + - asm/bpf_perf_event_arm64.h + - asm/bpf_perf_event_powerpc.h + - asm/bpf_perf_event_x86.h + - asm/byteorder.h + - asm/byteorder_arm.h + - asm/byteorder_arm64.h + - asm/byteorder_powerpc.h + - asm/byteorder_x86.h + - asm/cputable.h + - asm/cputable_powerpc.h + - asm/debugreg.h + - asm/debugreg_x86.h + - asm/e820.h + - asm/e820_x86.h + - asm/eeh.h + - asm/eeh_powerpc.h + - asm/elf.h + - asm/elf_powerpc.h + - asm/epapr_hcalls.h + - asm/epapr_hcalls_powerpc.h + - asm/errno.h + - asm/errno_arm.h + - asm/errno_arm64.h + - asm/errno_powerpc.h + - asm/errno_x86.h + - asm/fcntl.h + - asm/fcntl_arm.h + - asm/fcntl_arm64.h + - asm/fcntl_powerpc.h + - asm/fcntl_x86.h + - asm/hw_breakpoint.h + - asm/hw_breakpoint_x86.h + - asm/hwcap.h + - asm/hwcap2.h + - asm/hwcap2_x86.h + - asm/hwcap_arm.h + - asm/hwcap_arm64.h + - asm/ioctl.h + - asm/ioctl_arm.h + - asm/ioctl_arm64.h + - asm/ioctl_powerpc.h + - asm/ioctl_x86.h + - asm/ioctls.h + - asm/ioctls_arm.h + - asm/ioctls_arm64.h + - asm/ioctls_powerpc.h + - asm/ioctls_x86.h + - asm/ipcbuf.h + - asm/ipcbuf_arm.h + - asm/ipcbuf_arm64.h + - asm/ipcbuf_powerpc.h + - asm/ipcbuf_x86.h + - asm/ist.h + - asm/ist_x86.h + - asm/kvm.h + - asm/kvm_arm64.h + - asm/kvm_para.h + - asm/kvm_para_arm.h + - asm/kvm_para_arm64.h + - asm/kvm_para_powerpc.h + - asm/kvm_para_x86.h + - asm/kvm_perf.h + - asm/kvm_perf_x86.h + - asm/kvm_powerpc.h + - asm/kvm_x86.h + - asm/ldt.h + - asm/ldt_x86.h + - asm/mce.h + - asm/mce_x86.h + - asm/mman.h + - asm/mman_arm.h + - asm/mman_arm64.h + - asm/mman_powerpc.h + - asm/mman_x86.h + - asm/msgbuf.h + - asm/msgbuf_arm.h + - asm/msgbuf_arm64.h + - asm/msgbuf_powerpc.h + - asm/msgbuf_x86.h + - asm/msr.h + - asm/msr_x86.h + - asm/mtrr.h + - asm/mtrr_x86.h + - asm/nvram.h + - asm/nvram_powerpc.h + - asm/opal-prd.h + - asm/opal-prd_powerpc.h + - asm/param.h + - asm/param_arm.h + - asm/param_arm64.h + - asm/param_powerpc.h + - asm/param_x86.h + - asm/perf_event.h + - asm/perf_event_powerpc.h + - asm/perf_regs.h + - asm/perf_regs_arm.h + - asm/perf_regs_arm64.h + - asm/perf_regs_powerpc.h + - asm/perf_regs_x86.h + - asm/poll.h + - asm/posix_types.h + - asm/posix_types_32.h + - asm/posix_types_32_x86.h + - asm/posix_types_64.h + - asm/posix_types_64_x86.h + - asm/posix_types_arm.h + - asm/posix_types_arm64.h + - asm/posix_types_powerpc.h + - asm/posix_types_x32.h + - asm/posix_types_x32_x86.h + - asm/posix_types_x86.h + - asm/prctl.h + - asm/prctl_x86.h + - asm/processor-flags.h + - asm/processor-flags_x86.h + - asm/ps3fb.h + - asm/ps3fb_powerpc.h + - asm/ptrace-abi.h + - asm/ptrace-abi_x86.h + - asm/ptrace.h + - asm/ptrace_arm.h + - asm/ptrace_arm64.h + - asm/ptrace_powerpc.h + - asm/ptrace_x86.h + - asm/resource.h + - asm/sembuf.h + - asm/sembuf_arm.h + - asm/sembuf_arm64.h + - asm/sembuf_powerpc.h + - asm/sembuf_x86.h + - asm/setup.h + - asm/setup_arm.h + - asm/setup_arm64.h + - asm/setup_powerpc.h + - asm/setup_x86.h + - asm/shmbuf.h + - asm/shmbuf_arm.h + - asm/shmbuf_arm64.h + - asm/shmbuf_powerpc.h + - asm/shmbuf_x86.h + - asm/sigcontext.h + - asm/sigcontext32.h + - asm/sigcontext32_x86.h + - asm/sigcontext_arm.h + - asm/sigcontext_arm64.h + - asm/sigcontext_powerpc.h + - asm/sigcontext_x86.h + - asm/siginfo.h + - asm/siginfo_arm.h + - asm/siginfo_arm64.h + - asm/siginfo_powerpc.h + - asm/siginfo_x86.h + - asm/signal.h + - asm/signal_arm.h + - asm/signal_arm64.h + - asm/signal_powerpc.h + - asm/signal_x86.h + - asm/socket.h + - asm/socket_arm.h + - asm/socket_arm64.h + - asm/socket_powerpc.h + - asm/socket_x86.h + - asm/sockios.h + - asm/spu_info.h + - asm/spu_info_powerpc.h + - asm/stat.h + - asm/stat_arm.h + - asm/stat_arm64.h + - asm/stat_powerpc.h + - asm/stat_x86.h + - asm/statfs.h + - asm/statfs_arm.h + - asm/statfs_arm64.h + - asm/statfs_powerpc.h + - asm/statfs_x86.h + - asm/sve_context.h + - asm/sve_context_arm64.h + - asm/svm.h + - asm/svm_x86.h + - asm/swab.h + - asm/swab_arm.h + - asm/swab_arm64.h + - asm/swab_powerpc.h + - asm/swab_x86.h + - asm/termbits.h + - asm/termbits_arm.h + - asm/termbits_arm64.h + - asm/termbits_powerpc.h + - asm/termbits_x86.h + - asm/termios.h + - asm/termios_arm.h + - asm/termios_arm64.h + - asm/termios_powerpc.h + - asm/termios_x86.h + - asm/tm.h + - asm/tm_powerpc.h + - asm/types.h + - asm/types_arm.h + - asm/types_arm64.h + - asm/types_powerpc.h + - asm/types_x86.h + - asm/ucontext.h + - asm/ucontext_arm64.h + - asm/ucontext_powerpc.h + - asm/ucontext_x86.h + - asm/unistd-common.h + - asm/unistd-common_arm.h + - asm/unistd-eabi.h + - asm/unistd-eabi_arm.h + - asm/unistd-oabi.h + - asm/unistd-oabi_arm.h + - asm/unistd.h + - asm/unistd_32.h + - asm/unistd_32_powerpc.h + - asm/unistd_32_x86.h + - asm/unistd_64.h + - asm/unistd_64_powerpc.h + - asm/unistd_64_x86.h + - asm/unistd_arm.h + - asm/unistd_arm64.h + - asm/unistd_powerpc.h + - asm/unistd_x32.h + - asm/unistd_x32_x86.h + - asm/unistd_x86.h + - asm/vm86.h + - asm/vm86_x86.h + - asm/vmx.h + - asm/vmx_x86.h + - asm/vsyscall.h + - asm/vsyscall_x86.h + - drm/amdgpu_drm.h + - drm/armada_drm.h + - drm/drm.h + - drm/drm_fourcc.h + - drm/drm_mode.h + - drm/drm_sarea.h + - drm/etnaviv_drm.h + - drm/exynos_drm.h + - drm/i810_drm.h + - drm/i915_drm.h + - drm/lima_drm.h + - drm/mga_drm.h + - drm/msm_drm.h + - drm/nouveau_drm.h + - drm/omap_drm.h + - drm/panfrost_drm.h + - drm/qxl_drm.h + - drm/r128_drm.h + - drm/radeon_drm.h + - drm/savage_drm.h + - drm/sis_drm.h + - drm/tegra_drm.h + - drm/v3d_drm.h + - drm/vc4_drm.h + - drm/vgem_drm.h + - drm/via_drm.h + - drm/virtgpu_drm.h + - drm/vmwgfx_drm.h + - linux/a.out.h + - linux/a.out_x86.h + - linux/acct.h + - linux/adb.h + - linux/adfs_fs.h + - linux/affs_hardblocks.h + - linux/agpgart.h + - linux/aio_abi.h + - linux/am437x-vpfe.h + - linux/android/binder.h + - linux/android/binderfs.h + - linux/apm_bios.h + - linux/arcfb.h + - linux/arm_sdei.h + - linux/aspeed-lpc-ctrl.h + - linux/aspeed-p2a-ctrl.h + - linux/atalk.h + - linux/atm.h + - linux/atm_eni.h + - linux/atm_he.h + - linux/atm_idt77105.h + - linux/atm_nicstar.h + - linux/atm_tcp.h + - linux/atm_zatm.h + - linux/atmapi.h + - linux/atmarp.h + - linux/atmbr2684.h + - linux/atmclip.h + - linux/atmdev.h + - linux/atmioc.h + - linux/atmlec.h + - linux/atmmpc.h + - linux/atmppp.h + - linux/atmsap.h + - linux/atmsvc.h + - linux/audit.h + - linux/auto_dev-ioctl.h + - linux/auto_fs.h + - linux/auto_fs4.h + - linux/auxvec.h + - linux/ax25.h + - linux/batadv_packet.h + - linux/batman_adv.h + - linux/baycom.h + - linux/bcache.h + - linux/bcm933xx_hcs.h + - linux/bfs_fs.h + - linux/binfmts.h + - linux/blkpg.h + - linux/blktrace_api.h + - linux/blkzoned.h + - linux/bpf.h + - linux/bpf_common.h + - linux/bpf_perf_event.h + - linux/bpfilter.h + - linux/bpqether.h + - linux/bsg.h + - linux/bt-bmc.h + - linux/btf.h + - linux/btrfs.h + - linux/btrfs_tree.h + - linux/byteorder/big_endian.h + - linux/byteorder/little_endian.h + - linux/caif/caif_socket.h + - linux/caif/if_caif.h + - linux/can.h + - linux/can/bcm.h + - linux/can/error.h + - linux/can/gw.h + - linux/can/j1939.h + - linux/can/netlink.h + - linux/can/raw.h + - linux/can/vxcan.h + - linux/capability.h + - linux/capi.h + - linux/cciss_defs.h + - linux/cciss_ioctl.h + - linux/cdrom.h + - linux/cec-funcs.h + - linux/cec.h + - linux/cgroupstats.h + - linux/chio.h + - linux/cifs/cifs_mount.h + - linux/cm4000_cs.h + - linux/cn_proc.h + - linux/coda.h + - linux/coff.h + - linux/connector.h + - linux/const.h + - linux/coresight-stm.h + - linux/cramfs_fs.h + - linux/cryptouser.h + - linux/cuda.h + - linux/cyclades.h + - linux/cycx_cfm.h + - linux/dcbnl.h + - linux/dccp.h + - linux/devlink.h + - linux/dlm.h + - linux/dlm_device.h + - linux/dlm_netlink.h + - linux/dlm_plock.h + - linux/dlmconstants.h + - linux/dm-ioctl.h + - linux/dm-log-userspace.h + - linux/dma-buf.h + - linux/dma-heap.h + - linux/dn.h + - linux/dns_resolver.h + - linux/dqblk_xfs.h + - linux/dvb/audio.h + - linux/dvb/ca.h + - linux/dvb/dmx.h + - linux/dvb/frontend.h + - linux/dvb/net.h + - linux/dvb/osd.h + - linux/dvb/version.h + - linux/dvb/video.h + - linux/edd.h + - linux/efs_fs_sb.h + - linux/elf-em.h + - linux/elf-fdpic.h + - linux/elf.h + - linux/elfcore.h + - linux/errno.h + - linux/errqueue.h + - linux/erspan.h + - linux/ethtool.h + - linux/ethtool_netlink.h + - linux/eventpoll.h + - linux/fadvise.h + - linux/falloc.h + - linux/fanotify.h + - linux/fb.h + - linux/fcntl.h + - linux/fd.h + - linux/fdreg.h + - linux/fib_rules.h + - linux/fiemap.h + - linux/filter.h + - linux/firewire-cdev.h + - linux/firewire-constants.h + - linux/fou.h + - linux/fpga-dfl.h + - linux/fs.h + - linux/fscrypt.h + - linux/fsi.h + - linux/fsl_hypervisor.h + - linux/fsmap.h + - linux/fsverity.h + - linux/fuse.h + - linux/futex.h + - linux/gameport.h + - linux/gen_stats.h + - linux/genetlink.h + - linux/genwqe/genwqe_card.h + - linux/gfs2_ondisk.h + - linux/gpio.h + - linux/gsmmux.h + - linux/gtp.h + - linux/hash_info.h + - linux/hdlc.h + - linux/hdlc/ioctl.h + - linux/hdlcdrv.h + - linux/hdreg.h + - linux/hid.h + - linux/hiddev.h + - linux/hidraw.h + - linux/hpet.h + - linux/hsi/cs-protocol.h + - linux/hsi/hsi_char.h + - linux/hsr_netlink.h + - linux/hw_breakpoint.h + - linux/hyperv.h + - linux/i2c-dev.h + - linux/i2c.h + - linux/i2o-dev.h + - linux/i8k.h + - linux/icmp.h + - linux/icmpv6.h + - linux/idxd.h + - linux/if.h + - linux/if_addr.h + - linux/if_addrlabel.h + - linux/if_alg.h + - linux/if_arcnet.h + - linux/if_arp.h + - linux/if_bonding.h + - linux/if_bridge.h + - linux/if_cablemodem.h + - linux/if_eql.h + - linux/if_ether.h + - linux/if_fc.h + - linux/if_fddi.h + - linux/if_frad.h + - linux/if_hippi.h + - linux/if_infiniband.h + - linux/if_link.h + - linux/if_ltalk.h + - linux/if_macsec.h + - linux/if_packet.h + - linux/if_phonet.h + - linux/if_plip.h + - linux/if_ppp.h + - linux/if_pppol2tp.h + - linux/if_pppox.h + - linux/if_slip.h + - linux/if_team.h + - linux/if_tun.h + - linux/if_tunnel.h + - linux/if_vlan.h + - linux/if_x25.h + - linux/if_xdp.h + - linux/ife.h + - linux/igmp.h + - linux/iio/events.h + - linux/iio/types.h + - linux/ila.h + - linux/in.h + - linux/in6.h + - linux/in_route.h + - linux/inet_diag.h + - linux/inotify.h + - linux/input-event-codes.h + - linux/input.h + - linux/io_uring.h + - linux/ioctl.h + - linux/iommu.h + - linux/ip.h + - linux/ip6_tunnel.h + - linux/ip_vs.h + - linux/ipc.h + - linux/ipmi.h + - linux/ipmi_bmc.h + - linux/ipmi_msgdefs.h + - linux/ipsec.h + - linux/ipv6.h + - linux/ipv6_route.h + - linux/ipx.h + - linux/irqnr.h + - linux/isdn/capicmd.h + - linux/iso_fs.h + - linux/isst_if.h + - linux/ivtv.h + - linux/ivtvfb.h + - linux/jffs2.h + - linux/joystick.h + - linux/kcm.h + - linux/kcmp.h + - linux/kcov.h + - linux/kd.h + - linux/kdev_t.h + - linux/kernel-page-flags.h + - linux/kernel.h + - linux/kernelcapi.h + - linux/kexec.h + - linux/keyboard.h + - linux/keyctl.h + - linux/kfd_ioctl.h + - linux/kvm.h + - linux/kvm_arm64.h + - linux/kvm_para.h + - linux/kvm_powerpc.h + - linux/kvm_x86.h + - linux/l2tp.h + - linux/libc-compat.h + - linux/lightnvm.h + - linux/limits.h + - linux/lirc.h + - linux/llc.h + - linux/loop.h + - linux/lp.h + - linux/lwtunnel.h + - linux/magic.h + - linux/major.h + - linux/map_to_7segment.h + - linux/matroxfb.h + - linux/max2175.h + - linux/mdio.h + - linux/media-bus-format.h + - linux/media.h + - linux/mei.h + - linux/membarrier.h + - linux/memfd.h + - linux/mempolicy.h + - linux/meye.h + - linux/mic_common.h + - linux/mic_ioctl.h + - linux/mii.h + - linux/minix_fs.h + - linux/mman.h + - linux/mmc/ioctl.h + - linux/mmtimer.h + - linux/module.h + - linux/mount.h + - linux/mpls.h + - linux/mpls_iptunnel.h + - linux/mptcp.h + - linux/mqueue.h + - linux/mroute.h + - linux/mroute6.h + - linux/msdos_fs.h + - linux/msg.h + - linux/mtio.h + - linux/n_r3964.h + - linux/nbd-netlink.h + - linux/nbd.h + - linux/ncsi.h + - linux/ndctl.h + - linux/neighbour.h + - linux/net.h + - linux/net_dropmon.h + - linux/net_namespace.h + - linux/net_tstamp.h + - linux/netconf.h + - linux/netdevice.h + - linux/netfilter.h + - linux/netfilter/ipset/ip_set.h + - linux/netfilter/ipset/ip_set_bitmap.h + - linux/netfilter/ipset/ip_set_hash.h + - linux/netfilter/ipset/ip_set_list.h + - linux/netfilter/nf_conntrack_common.h + - linux/netfilter/nf_conntrack_ftp.h + - linux/netfilter/nf_conntrack_sctp.h + - linux/netfilter/nf_conntrack_tcp.h + - linux/netfilter/nf_conntrack_tuple_common.h + - linux/netfilter/nf_log.h + - linux/netfilter/nf_nat.h + - linux/netfilter/nf_synproxy.h + - linux/netfilter/nf_tables.h + - linux/netfilter/nf_tables_compat.h + - linux/netfilter/nfnetlink.h + - linux/netfilter/nfnetlink_acct.h + - linux/netfilter/nfnetlink_compat.h + - linux/netfilter/nfnetlink_conntrack.h + - linux/netfilter/nfnetlink_cthelper.h + - linux/netfilter/nfnetlink_cttimeout.h + - linux/netfilter/nfnetlink_log.h + - linux/netfilter/nfnetlink_osf.h + - linux/netfilter/nfnetlink_queue.h + - linux/netfilter/x_tables.h + - linux/netfilter/xt_AUDIT.h + - linux/netfilter/xt_CHECKSUM.h + - linux/netfilter/xt_CLASSIFY.h + - linux/netfilter/xt_CONNMARK.h + - linux/netfilter/xt_CONNSECMARK.h + - linux/netfilter/xt_CT.h + - linux/netfilter/xt_DSCP.h + - linux/netfilter/xt_HMARK.h + - linux/netfilter/xt_IDLETIMER.h + - linux/netfilter/xt_LED.h + - linux/netfilter/xt_LOG.h + - linux/netfilter/xt_MARK.h + - linux/netfilter/xt_NFLOG.h + - linux/netfilter/xt_NFQUEUE.h + - linux/netfilter/xt_RATEEST.h + - linux/netfilter/xt_SECMARK.h + - linux/netfilter/xt_SYNPROXY.h + - linux/netfilter/xt_TCPMSS.h + - linux/netfilter/xt_TCPOPTSTRIP.h + - linux/netfilter/xt_TEE.h + - linux/netfilter/xt_TPROXY.h + - linux/netfilter/xt_addrtype.h + - linux/netfilter/xt_bpf.h + - linux/netfilter/xt_cgroup.h + - linux/netfilter/xt_cluster.h + - linux/netfilter/xt_comment.h + - linux/netfilter/xt_connbytes.h + - linux/netfilter/xt_connlabel.h + - linux/netfilter/xt_connlimit.h + - linux/netfilter/xt_connmark.h + - linux/netfilter/xt_conntrack.h + - linux/netfilter/xt_cpu.h + - linux/netfilter/xt_dccp.h + - linux/netfilter/xt_devgroup.h + - linux/netfilter/xt_dscp.h + - linux/netfilter/xt_ecn.h + - linux/netfilter/xt_esp.h + - linux/netfilter/xt_hashlimit.h + - linux/netfilter/xt_helper.h + - linux/netfilter/xt_ipcomp.h + - linux/netfilter/xt_iprange.h + - linux/netfilter/xt_ipvs.h + - linux/netfilter/xt_l2tp.h + - linux/netfilter/xt_length.h + - linux/netfilter/xt_limit.h + - linux/netfilter/xt_mac.h + - linux/netfilter/xt_mark.h + - linux/netfilter/xt_multiport.h + - linux/netfilter/xt_nfacct.h + - linux/netfilter/xt_osf.h + - linux/netfilter/xt_owner.h + - linux/netfilter/xt_physdev.h + - linux/netfilter/xt_pkttype.h + - linux/netfilter/xt_policy.h + - linux/netfilter/xt_quota.h + - linux/netfilter/xt_rateest.h + - linux/netfilter/xt_realm.h + - linux/netfilter/xt_recent.h + - linux/netfilter/xt_rpfilter.h + - linux/netfilter/xt_sctp.h + - linux/netfilter/xt_set.h + - linux/netfilter/xt_socket.h + - linux/netfilter/xt_state.h + - linux/netfilter/xt_statistic.h + - linux/netfilter/xt_string.h + - linux/netfilter/xt_tcpmss.h + - linux/netfilter/xt_tcpudp.h + - linux/netfilter/xt_time.h + - linux/netfilter/xt_u32.h + - linux/netfilter_arp.h + - linux/netfilter_arp/arp_tables.h + - linux/netfilter_arp/arpt_mangle.h + - linux/netfilter_bridge.h + - linux/netfilter_bridge/ebt_802_3.h + - linux/netfilter_bridge/ebt_among.h + - linux/netfilter_bridge/ebt_arp.h + - linux/netfilter_bridge/ebt_arpreply.h + - linux/netfilter_bridge/ebt_ip.h + - linux/netfilter_bridge/ebt_ip6.h + - linux/netfilter_bridge/ebt_limit.h + - linux/netfilter_bridge/ebt_log.h + - linux/netfilter_bridge/ebt_mark_m.h + - linux/netfilter_bridge/ebt_mark_t.h + - linux/netfilter_bridge/ebt_nat.h + - linux/netfilter_bridge/ebt_nflog.h + - linux/netfilter_bridge/ebt_pkttype.h + - linux/netfilter_bridge/ebt_redirect.h + - linux/netfilter_bridge/ebt_stp.h + - linux/netfilter_bridge/ebt_vlan.h + - linux/netfilter_bridge/ebtables.h + - linux/netfilter_decnet.h + - linux/netfilter_ipv4.h + - linux/netfilter_ipv4/ip_tables.h + - linux/netfilter_ipv4/ipt_CLUSTERIP.h + - linux/netfilter_ipv4/ipt_ECN.h + - linux/netfilter_ipv4/ipt_LOG.h + - linux/netfilter_ipv4/ipt_REJECT.h + - linux/netfilter_ipv4/ipt_TTL.h + - linux/netfilter_ipv4/ipt_ah.h + - linux/netfilter_ipv4/ipt_ecn.h + - linux/netfilter_ipv4/ipt_ttl.h + - linux/netfilter_ipv6.h + - linux/netfilter_ipv6/ip6_tables.h + - linux/netfilter_ipv6/ip6t_HL.h + - linux/netfilter_ipv6/ip6t_LOG.h + - linux/netfilter_ipv6/ip6t_NPT.h + - linux/netfilter_ipv6/ip6t_REJECT.h + - linux/netfilter_ipv6/ip6t_ah.h + - linux/netfilter_ipv6/ip6t_frag.h + - linux/netfilter_ipv6/ip6t_hl.h + - linux/netfilter_ipv6/ip6t_ipv6header.h + - linux/netfilter_ipv6/ip6t_mh.h + - linux/netfilter_ipv6/ip6t_opts.h + - linux/netfilter_ipv6/ip6t_rt.h + - linux/netfilter_ipv6/ip6t_srh.h + - linux/netlink.h + - linux/netlink_diag.h + - linux/netrom.h + - linux/nexthop.h + - linux/nfc.h + - linux/nfs.h + - linux/nfs2.h + - linux/nfs3.h + - linux/nfs4.h + - linux/nfs4_mount.h + - linux/nfs_fs.h + - linux/nfs_idmap.h + - linux/nfs_mount.h + - linux/nfsacl.h + - linux/nfsd/cld.h + - linux/nfsd/debug.h + - linux/nfsd/export.h + - linux/nfsd/nfsfh.h + - linux/nfsd/stats.h + - linux/nilfs2_api.h + - linux/nilfs2_ondisk.h + - linux/nl80211.h + - linux/nsfs.h + - linux/nubus.h + - linux/nvme_ioctl.h + - linux/nvram.h + - linux/omap3isp.h + - linux/omapfb.h + - linux/oom.h + - linux/openat2.h + - linux/openvswitch.h + - linux/packet_diag.h + - linux/param.h + - linux/parport.h + - linux/patchkey.h + - linux/pci.h + - linux/pci_regs.h + - linux/pcitest.h + - linux/perf_event.h + - linux/personality.h + - linux/pfkeyv2.h + - linux/pg.h + - linux/phantom.h + - linux/phonet.h + - linux/pkt_cls.h + - linux/pkt_sched.h + - linux/pktcdvd.h + - linux/pmu.h + - linux/poll.h + - linux/posix_acl.h + - linux/posix_acl_xattr.h + - linux/posix_types.h + - linux/ppdev.h + - linux/ppp-comp.h + - linux/ppp-ioctl.h + - linux/ppp_defs.h + - linux/pps.h + - linux/pr.h + - linux/prctl.h + - linux/psample.h + - linux/psci.h + - linux/psp-sev.h + - linux/ptp_clock.h + - linux/ptrace.h + - linux/qemu_fw_cfg.h + - linux/qnx4_fs.h + - linux/qnxtypes.h + - linux/qrtr.h + - linux/quota.h + - linux/radeonfb.h + - linux/raid/md_p.h + - linux/raid/md_u.h + - linux/random.h + - linux/raw.h + - linux/rds.h + - linux/reboot.h + - linux/reiserfs_fs.h + - linux/reiserfs_xattr.h + - linux/resource.h + - linux/rfkill.h + - linux/rio_cm_cdev.h + - linux/rio_mport_cdev.h + - linux/romfs_fs.h + - linux/rose.h + - linux/route.h + - linux/rpl.h + - linux/rpl_iptunnel.h + - linux/rpmsg.h + - linux/rseq.h + - linux/rtc.h + - linux/rtnetlink.h + - linux/rxrpc.h + - linux/scc.h + - linux/sched.h + - linux/sched/types.h + - linux/scif_ioctl.h + - linux/screen_info.h + - linux/sctp.h + - linux/sdla.h + - linux/seccomp.h + - linux/securebits.h + - linux/sed-opal.h + - linux/seg6.h + - linux/seg6_genl.h + - linux/seg6_hmac.h + - linux/seg6_iptunnel.h + - linux/seg6_local.h + - linux/selinux_netlink.h + - linux/sem.h + - linux/serial.h + - linux/serial_core.h + - linux/serial_reg.h + - linux/serio.h + - linux/shm.h + - linux/signal.h + - linux/signalfd.h + - linux/smc.h + - linux/smc_diag.h + - linux/smiapp.h + - linux/snmp.h + - linux/sock_diag.h + - linux/socket.h + - linux/sockios.h + - linux/sonet.h + - linux/sonypi.h + - linux/sound.h + - linux/soundcard.h + - linux/spi/spidev.h + - linux/stat.h + - linux/stddef.h + - linux/stm.h + - linux/string.h + - linux/sunrpc/debug.h + - linux/suspend_ioctls.h + - linux/swab.h + - linux/switchtec_ioctl.h + - linux/sync_file.h + - linux/synclink.h + - linux/sysctl.h + - linux/sysinfo.h + - linux/target_core_user.h + - linux/taskstats.h + - linux/tc_act/tc_bpf.h + - linux/tc_act/tc_connmark.h + - linux/tc_act/tc_csum.h + - linux/tc_act/tc_ct.h + - linux/tc_act/tc_ctinfo.h + - linux/tc_act/tc_defact.h + - linux/tc_act/tc_gact.h + - linux/tc_act/tc_ife.h + - linux/tc_act/tc_ipt.h + - linux/tc_act/tc_mirred.h + - linux/tc_act/tc_mpls.h + - linux/tc_act/tc_nat.h + - linux/tc_act/tc_pedit.h + - linux/tc_act/tc_sample.h + - linux/tc_act/tc_skbedit.h + - linux/tc_act/tc_skbmod.h + - linux/tc_act/tc_tunnel_key.h + - linux/tc_act/tc_vlan.h + - linux/tc_ematch/tc_em_cmp.h + - linux/tc_ematch/tc_em_ipt.h + - linux/tc_ematch/tc_em_meta.h + - linux/tc_ematch/tc_em_nbyte.h + - linux/tc_ematch/tc_em_text.h + - linux/tcp.h + - linux/tcp_metrics.h + - linux/tee.h + - linux/termios.h + - linux/thermal.h + - linux/time.h + - linux/time_types.h + - linux/timerfd.h + - linux/times.h + - linux/timex.h + - linux/tiocl.h + - linux/tipc.h + - linux/tipc_config.h + - linux/tipc_netlink.h + - linux/tipc_sockets_diag.h + - linux/tls.h + - linux/toshiba.h + - linux/tty.h + - linux/tty_flags.h + - linux/types.h + - linux/udf_fs_i.h + - linux/udmabuf.h + - linux/udp.h + - linux/uhid.h + - linux/uinput.h + - linux/uio.h + - linux/uleds.h + - linux/ultrasound.h + - linux/um_timetravel.h + - linux/un.h + - linux/unistd.h + - linux/unix_diag.h + - linux/usb/audio.h + - linux/usb/cdc-wdm.h + - linux/usb/cdc.h + - linux/usb/ch11.h + - linux/usb/ch9.h + - linux/usb/charger.h + - linux/usb/functionfs.h + - linux/usb/g_printer.h + - linux/usb/g_uvc.h + - linux/usb/gadgetfs.h + - linux/usb/midi.h + - linux/usb/raw_gadget.h + - linux/usb/tmc.h + - linux/usb/video.h + - linux/usbdevice_fs.h + - linux/usbip.h + - linux/userfaultfd.h + - linux/userio.h + - linux/utime.h + - linux/utsname.h + - linux/uuid.h + - linux/uvcvideo.h + - linux/v4l2-common.h + - linux/v4l2-controls.h + - linux/v4l2-dv-timings.h + - linux/v4l2-mediabus.h + - linux/v4l2-subdev.h + - linux/vbox_err.h + - linux/vbox_vmmdev_types.h + - linux/vboxguest.h + - linux/version.h + - linux/veth.h + - linux/vfio.h + - linux/vfio_ccw.h + - linux/vhost.h + - linux/vhost_types.h + - linux/videodev2.h + - linux/virtio_9p.h + - linux/virtio_balloon.h + - linux/virtio_blk.h + - linux/virtio_config.h + - linux/virtio_console.h + - linux/virtio_crypto.h + - linux/virtio_fs.h + - linux/virtio_gpu.h + - linux/virtio_ids.h + - linux/virtio_input.h + - linux/virtio_iommu.h + - linux/virtio_mmio.h + - linux/virtio_net.h + - linux/virtio_pci.h + - linux/virtio_pmem.h + - linux/virtio_ring.h + - linux/virtio_rng.h + - linux/virtio_scsi.h + - linux/virtio_types.h + - linux/virtio_vsock.h + - linux/vm_sockets.h + - linux/vm_sockets_diag.h + - linux/vmcore.h + - linux/vsockmon.h + - linux/vt.h + - linux/vtpm_proxy.h + - linux/wait.h + - linux/watchdog.h + - linux/wimax.h + - linux/wimax/i2400m.h + - linux/wireguard.h + - linux/wireless.h + - linux/wmi.h + - linux/x25.h + - linux/xattr.h + - linux/xdp_diag.h + - linux/xfrm.h + - linux/xilinx-v4l2-controls.h + - linux/zorro.h + - linux/zorro_ids.h + - misc/cxl.h + - misc/fastrpc.h + - misc/habanalabs.h + - misc/ocxl.h + - misc/pvpanic.h + - misc/uacce/hisi_qm.h + - misc/uacce/uacce.h + - misc/xilinx_sdfec.h + - mtd/inftl-user.h + - mtd/mtd-abi.h + - mtd/mtd-user.h + - mtd/nftl-user.h + - mtd/ubi-user.h + - rdma/bnxt_re-abi.h + - rdma/cxgb4-abi.h + - rdma/efa-abi.h + - rdma/hfi/hfi1_ioctl.h + - rdma/hfi/hfi1_user.h + - rdma/hns-abi.h + - rdma/i40iw-abi.h + - rdma/ib_user_ioctl_cmds.h + - rdma/ib_user_ioctl_verbs.h + - rdma/ib_user_mad.h + - rdma/ib_user_sa.h + - rdma/ib_user_verbs.h + - rdma/mlx4-abi.h + - rdma/mlx5-abi.h + - rdma/mlx5_user_ioctl_cmds.h + - rdma/mlx5_user_ioctl_verbs.h + - rdma/mthca-abi.h + - rdma/ocrdma-abi.h + - rdma/qedr-abi.h + - rdma/rdma_netlink.h + - rdma/rdma_user_cm.h + - rdma/rdma_user_ioctl.h + - rdma/rdma_user_ioctl_cmds.h + - rdma/rdma_user_rxe.h + - rdma/rvt-abi.h + - rdma/siw-abi.h + - rdma/vmw_pvrdma-abi.h + - scsi/cxlflash_ioctl.h + - scsi/fc/fc_els.h + - scsi/fc/fc_fs.h + - scsi/fc/fc_gs.h + - scsi/fc/fc_ns.h + - scsi/scsi_bsg_fc.h + - scsi/scsi_bsg_ufs.h + - scsi/scsi_netlink.h + - scsi/scsi_netlink_fc.h + - sound/asequencer.h + - sound/asoc.h + - sound/asound.h + - sound/asound_fm.h + - sound/compress_offload.h + - sound/compress_params.h + - sound/emu10k1.h + - sound/firewire.h + - sound/hdsp.h + - sound/hdspm.h + - sound/sb16_csp.h + - sound/sfnt_info.h + - sound/skl-tplg-interface.h + - sound/snd_sst_tokens.h + - sound/sof/abi.h + - sound/sof/fw.h + - sound/sof/header.h + - sound/sof/tokens.h + - sound/tlv.h + - sound/usb_stream.h + - video/edid.h + - video/sisfb.h + - video/uvesafb.h + - xen/evtchn.h + - xen/gntalloc.h + - xen/gntdev.h + - xen/privcmd.h diff --git a/build/sysincl/linux-musl.yml b/build/sysincl/linux-musl.yml new file mode 100644 index 00000000000..2c7a11bf064 --- /dev/null +++ b/build/sysincl/linux-musl.yml @@ -0,0 +1,18 @@ +- includes: + - bits/alltypes.h: contrib/libs/musl/arch/x86_64/bits/alltypes.h + - bits/errno.h: contrib/libs/musl/arch/generic/bits/errno.h + - bits/fenv.h: contrib/libs/musl/arch/x86_64/bits/fenv.h + - bits/limits.h: + - contrib/libs/musl/arch/generic/bits/limits.h + - contrib/libs/musl/arch/x86_64/bits/limits.h + - bits/posix.h: contrib/libs/musl/arch/x86_64/bits/posix.h + - bits/reg.h: contrib/libs/musl/arch/x86_64/bits/reg.h + - bits/stat.h: contrib/libs/musl/arch/x86_64/bits/stat.h + - bits/stdint.h: contrib/libs/musl/arch/x86_64/bits/stdint.h + - sys/cdefs.h: contrib/libs/musl/extra/sys/cdefs.h + - sys/sysctl.h: contrib/libs/musl/extra/sys/sysctl.h + - xlocale.h: contrib/libs/musl/extra/xlocale.h + +- source_filter: "^contrib/restricted/boost" + includes: + - ../include/fenv.h: contrib/libs/musl/include/fenv.h diff --git a/build/sysincl/linux-ubuntu-12.yml b/build/sysincl/linux-ubuntu-12.yml new file mode 100644 index 00000000000..b310250e6bb --- /dev/null +++ b/build/sysincl/linux-ubuntu-12.yml @@ -0,0 +1,3 @@ +- source_filter: "^contrib/libs/systemd" + includes: + - uchar.h: contrib/libs/libc_compat/include/uchar/uchar.h diff --git a/build/sysincl/linux.yml b/build/sysincl/linux.yml new file mode 100644 index 00000000000..c98d7100fa7 --- /dev/null +++ b/build/sysincl/linux.yml @@ -0,0 +1,66 @@ +- includes: + - _G_config.h + - a.out.h + - aliases.h + - ansidecl.h + - argp.h + - argz.h + - bfd.h + - bits/endian.h + - bits/fenv.h + - bits/libc-lock.h + - bits/reg.h + - bits/types.h + - bits/wordsize.h + - error.h + - execinfo.h + - fpu_control.h + - fstab.h + - fts.h + - gconv.h + - gnu-versions.h + - gnu/libc-version.h + - gshadow.h + - ieee754.h + - libio.h + - linux/compiler.h + - linux/irda.h + - linux/smb.h + - mcheck.h + - netash/ash.h + - netatalk/at.h + - netax25/ax25.h + - neteconet/ec.h + - netipx/ipx.h + - netrose/rose.h + - nss.h + - obstack.h + - printf.h + - regexp.h + - rpcsvc/yp_prot.h + - rpcsvc/ypclnt.h + - sgtty.h + - sys/bitypes.h + - sys/cdefs.h + - sys/memfd.h + - sys/queue.h + - sys/platform/ppc.h + - sys/socketvar.h + - sys/sysctl.h + - sys/unistd.h + - termio.h + - ttyent.h + - ustat.h + - xlocale.h + +- source_filter: "^contrib/libs/webrtc/modules" + includes: + - jni.h + - aaudio/AAudio.h + - SLES/OpenSLES.h + - SLES/OpenSLES_Android.h + - SLES/OpenSLES_AndroidConfiguration.h + +- source_filter: "^contrib/python/(coverage|gevent|greenlet)" + includes: + - internal/pycore_frame.h: contrib/libs/python/Include/internal/pycore_frame.h diff --git a/build/sysincl/macro.yml b/build/sysincl/macro.yml new file mode 100644 index 00000000000..b0828f3ca19 --- /dev/null +++ b/build/sysincl/macro.yml @@ -0,0 +1,713 @@ +# This file contains the most frequently used macros from the whole arcadia +- includes: + + # libc++ uses include_next statement to include headers from libc and / or compiler-provided headers. + # As MSVC compiler does not support this setting, we emulate it via these macro-defines. + # + # These includes are used in contrib/libs/cxxsupp/libcxx and contrib/libs/libc_compat, + # hence source_filter setting is intentionally omitted. + - Y_MSVC_INCLUDE_NEXT(eh.h) + - Y_MSVC_INCLUDE_NEXT(initializer_list) + - Y_MSVC_INCLUDE_NEXT(limits.h) + - Y_MSVC_INCLUDE_NEXT(math.h) + - Y_MSVC_INCLUDE_NEXT(setjmp.h) + - Y_MSVC_INCLUDE_NEXT(stdbool.h) + - Y_MSVC_INCLUDE_NEXT(stdint.h) + - Y_MSVC_INCLUDE_NEXT(yvals.h) + + - Y_UCRT_INCLUDE_NEXT(coMPlex.h) + - Y_UCRT_INCLUDE_NEXT(ctype.h) + - Y_UCRT_INCLUDE_NEXT(errno.h) + - Y_UCRT_INCLUDE_NEXT(fenv.h) + - Y_UCRT_INCLUDE_NEXT(float.h) + - Y_UCRT_INCLUDE_NEXT(inttypes.h) + - Y_UCRT_INCLUDE_NEXT(locale.h) + - Y_UCRT_INCLUDE_NEXT(math.h) + - Y_UCRT_INCLUDE_NEXT(stddef.h) + - Y_UCRT_INCLUDE_NEXT(stdio.h) + - Y_UCRT_INCLUDE_NEXT(stdlib.h) + - Y_UCRT_INCLUDE_NEXT(string.h) + - Y_UCRT_INCLUDE_NEXT(wchar.h) + - Y_UCRT_INCLUDE_NEXT(wctype.h) + + # BOOST_PP_INCLUDE_SELF() SHOULD be always be resolved into the same file it is included from. + # Hence this file was already parsed and empty resolving is equivalent to providing the actual resolution for it. + - BOOST_PP_INCLUDE_SELF() + + # libfreetype officially insists on using macros to include its headers: + # https://freetype.org/freetype2/docs/tutorial/step1.html#section-1 + # + # Many contribs follow this recommendation, so these sysincls intentionally lack source_filter setting. + - FT_ADVANCES_H: contrib/libs/freetype/include/freetype/ftadvanc.h + - FT_BBOX_H: contrib/libs/freetype/include/freetype/ftbbox.h + - FT_BDF_H: contrib/libs/freetype/include/freetype/ftbdf.h + - FT_BITMAP_H: contrib/libs/freetype/include/freetype/ftbitmap.h + - FT_BZIP2_H: contrib/libs/freetype/include/freetype/ftbzip2.h + - FT_CACHE_H: contrib/libs/freetype/include/freetype/ftcache.h + - FT_CID_H: contrib/libs/freetype/include/freetype/ftcid.h + - FT_COLOR_H: contrib/libs/freetype/include/freetype/ftcolor.h + - FT_CONFIG_CONFIG_H: contrib/libs/freetype/include/freetype/config/ftconfig.h + - FT_CONFIG_MODULES_H: contrib/libs/freetype/include/freetype/config/ftmodule.h + - FT_CONFIG_OPTIONS_H: contrib/libs/freetype/include/freetype/config/ftoption.h + - FT_CONFIG_STANDARD_LIBRARY_H: contrib/libs/freetype/include/freetype/config/ftstdlib.h + - FT_ERRORS_H: contrib/libs/freetype/include/freetype/fterrors.h + - FT_FONT_FORMATS_H: contrib/libs/freetype/include/freetype/ftfntfmt.h + - FT_FREETYPE_H: contrib/libs/freetype/include/freetype/freetype.h + - FT_GASP_H: contrib/libs/freetype/include/freetype/ftgasp.h + - FT_GLYPH_H: contrib/libs/freetype/include/freetype/ftglyph.h + - FT_GX_VALIDATE_H: contrib/libs/freetype/include/freetype/ftgxval.h + - FT_GZIP_H: contrib/libs/freetype/include/freetype/ftgzip.h + - FT_IMAGE_H: contrib/libs/freetype/include/freetype/ftimage.h + - FT_INCREMENTAL_H: contrib/libs/freetype/include/freetype/ftincrem.h + - FT_LCD_FILTER_H: contrib/libs/freetype/include/freetype/ftlcdfil.h + - FT_LIST_H: contrib/libs/freetype/include/freetype/ftlist.h + - FT_LZW_H: contrib/libs/freetype/include/freetype/ftlzw.h + - FT_MAC_H: contrib/libs/freetype/include/freetype/ftmac.h + - FT_MODULE_ERRORS_H: contrib/libs/freetype/include/freetype/ftmoderr.h + - FT_MODULE_H: contrib/libs/freetype/include/freetype/ftmodapi.h + - FT_MULTIPLE_MASTERS_H: contrib/libs/freetype/include/freetype/ftmm.h + - FT_OPENTYPE_VALIDATE_H: contrib/libs/freetype/include/freetype/ftotval.h + - FT_OTSVG_H: contrib/libs/freetype/include/freetype/otsvg.h + - FT_OUTLINE_H: contrib/libs/freetype/include/freetype/ftoutln.h + - FT_PFR_H: contrib/libs/freetype/include/freetype/ftpfr.h + - FT_RENDER_H: contrib/libs/freetype/include/freetype/ftrender.h + - FT_SFNT_NAMES_H: contrib/libs/freetype/include/freetype/ftsnames.h + - FT_SIZES_H: contrib/libs/freetype/include/freetype/ftsizes.h + - FT_STROKER_H: contrib/libs/freetype/include/freetype/ftstroke.h + - FT_SYNTHESIS_H: contrib/libs/freetype/include/freetype/ftsynth.h + - FT_SYSTEM_H: contrib/libs/freetype/include/freetype/ftsystem.h + - FT_TRIGONOMETRY_H: contrib/libs/freetype/include/freetype/fttrigon.h + - FT_TRUETYPE_IDS_H: contrib/libs/freetype/include/freetype/ttnameid.h + - FT_TRUETYPE_TABLES_H: contrib/libs/freetype/include/freetype/tttables.h + - FT_TRUETYPE_TAGS_H: contrib/libs/freetype/include/freetype/tttags.h + - FT_TYPE1_TABLES_H: contrib/libs/freetype/include/freetype/t1tables.h + - FT_TYPES_H: contrib/libs/freetype/include/freetype/fttypes.h + - FT_WINFONTS_H: contrib/libs/freetype/include/freetype/ftwinfnt.h + - FT_XFREE86_H: contrib/libs/freetype/include/freetype/ftfntfmt.h + +- source_filter: "^contrib/libs/openssl" + includes: + - OPENSSL_UNISTD: $U/unistd.h + +- source_filter: "^contrib/libs/ctemplate" + includes: + - HASH_MAP_H: $U/unordered_map + - HASH_SET_H: $U/unordered_set + +- source_filter: "^contrib/libs/llvm(\\d+)" + includes: + - BACKTRACE_HEADER: $U/execinfo.h + +- source_filter: "^contrib/libs/pycxx" + includes: + - STR_STREAM: $U/sstream + +- source_filter: "^contrib/restricted/abseil-cpp-tstring/y_absl/debugging" + includes: + - Y_ABSL_STACKTRACE_INL_HEADER: + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_win32-inl.inc + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_generic-inl.inc + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_emscripten-inl.inc + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_x86-inl.inc + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_powerpc-inl.inc + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_aarch64-inl.inc + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_riscv-inl.inc + - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_unimplemented-inl.inc + +- source_filter: "^contrib/restricted/abseil-cpp/absl/debugging" + includes: + - ABSL_STACKTRACE_INL_HEADER: + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc + - contrib/restricted/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc + +- source_filter: "^contrib/restricted/boost" + includes: + - BOOST_COMPILER_CONFIG: + - contrib/restricted/boost/config/include/boost/config/compiler/intel.hpp + - contrib/restricted/boost/config/include/boost/config/compiler/clang.hpp + - contrib/restricted/boost/config/include/boost/config/compiler/gcc.hpp + - BOOST_PLATFORM_CONFIG: + - contrib/restricted/boost/config/include/boost/config/platform/linux.hpp + - contrib/restricted/boost/config/include/boost/config/platform/bsd.hpp + - contrib/restricted/boost/config/include/boost/config/platform/solaris.hpp + - contrib/restricted/boost/config/include/boost/config/platform/irix.hpp + - contrib/restricted/boost/config/include/boost/config/platform/hpux.hpp + - contrib/restricted/boost/config/include/boost/config/platform/cygwin.hpp + - contrib/restricted/boost/config/include/boost/config/platform/win32.hpp + - contrib/restricted/boost/config/include/boost/config/platform/haiku.hpp + - contrib/restricted/boost/config/include/boost/config/platform/beos.hpp + - contrib/restricted/boost/config/include/boost/config/platform/macos.hpp + - contrib/restricted/boost/config/include/boost/config/platform/zos.hpp + - contrib/restricted/boost/config/include/boost/config/platform/aix.hpp + - contrib/restricted/boost/config/include/boost/config/platform/amigaos.hpp + - contrib/restricted/boost/config/include/boost/config/platform/qnxnto.hpp + - contrib/restricted/boost/config/include/boost/config/platform/symbian.hpp + - contrib/restricted/boost/config/include/boost/config/platform/cray.hpp + - contrib/restricted/boost/config/include/boost/config/platform/vms.hpp + - contrib/restricted/boost/config/include/boost/config/platform/cloudabi.hpp + - contrib/restricted/boost/config/include/boost/config/platform/wasm.hpp + - BOOST_STDLIB_CONFIG: + - contrib/restricted/boost/config/include/boost/config/stdlib/stlport.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/libcomo.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/roguewave.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/libcpp.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/libstdcpp3.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/sgi.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/msl.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/xlcpp_zos.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/vacpp.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/modena.hpp + - contrib/restricted/boost/config/include/boost/config/stdlib/dinkumware.hpp + - BOOST_FT_cc_file: + - contrib/restricted/boost/function_types/include/boost/function_types/detail/pp_variate_loop/preprocessed.hpp + - contrib/restricted/boost/function_types/include/boost/function_types/detail/pp_tags/cc_tag.hpp + - BOOST_MATH_MAX_POLY_ORDER: + - contrib/restricted/boost/math/include/boost/math/tools/detail/polynomial_horner1_20.hpp + - contrib/restricted/boost/math/include/boost/math/tools/detail/polynomial_horner2_20.hpp + - contrib/restricted/boost/math/include/boost/math/tools/detail/polynomial_horner3_20.hpp + - BOOST_ABI_PREFIX: contrib/restricted/boost/config/include/boost/config/abi/msvc_prefix.hpp + - BOOST_ABI_SUFFIX: contrib/restricted/boost/config/include/boost/config/abi/msvc_suffix.hpp + - BOOST_GRAPH_MPI_INCLUDE(<boost/graph/distributed/connected_components.hpp>): contrib/restricted/boost/graph/include/boost/graph/detail/empty_header.hpp + - BOOST_GRAPH_MPI_INCLUDE(<boost/graph/distributed/depth_first_search.hpp>): contrib/restricted/boost/graph/include/boost/graph/detail/empty_header.hpp + - BOOST_GRAPH_MPI_INCLUDE(<boost/graph/distributed/dijkstra_shortest_paths.hpp>): contrib/restricted/boost/graph/include/boost/graph/detail/empty_header.hpp + - BOOST_GRAPH_MPI_INCLUDE(<boost/graph/distributed/strong_components.hpp>): contrib/restricted/boost/graph/include/boost/graph/detail/empty_header.hpp + - BOOST_GRAPH_MPI_INCLUDE(<boost/graph/distributed/graphviz.hpp>): contrib/restricted/boost/graph/include/boost/graph/detail/empty_header.hpp + - BOOST_FT_loop: contrib/restricted/boost/function_types/include/boost/function_types/detail/pp_cc_loop/master.hpp + - BOOST_FT_variate_file: contrib/restricted/boost/function_types/include/boost/function_types/detail/pp_arity_loop.hpp + - BOOST_PP_ASSIGN_SLOT(1): contrib/restricted/boost/preprocessor/include/boost/preprocessor/slot/detail/slot1.hpp + - BOOST_PP_INCLUDE_SELF(): contrib/restricted/boost/preprocessor/include/boost/preprocessor/iteration/detail/self.hpp + - BOOST_PP_LOCAL_ITERATE(): contrib/restricted/boost/preprocessor/include/boost/preprocessor/iteration/detail/local.hpp + - BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP(): contrib/restricted/boost/typeof/include/boost/typeof/incr_registration_group.hpp + - BOOST_REGEX_USER_CONFIG: contrib/restricted/boost/regex/include/boost/regex/user.hpp + - BOOST_USER_CONFIG: contrib/restricted/boost/config/include/boost/config/user.hpp + +- source_filter: "^contrib/restricted/boost/atomic" + includes: + - BOOST_ATOMIC_DETAIL_FP_BACKEND_HEADER(boost/atomic/detail/fp_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fp_ops_emulated.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fp_ops_generic.hpp + - BOOST_ATOMIC_DETAIL_BACKEND_HEADER(boost/atomic/detail/caps_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_aarch32.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_aarch64.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_alpha.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_ppc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_sparc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_msvc_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_msvc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_gcc_atomic.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_gcc_sync.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_linux_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_windows.hpp + - BOOST_ATOMIC_DETAIL_EXTRA_FP_BACKEND_HEADER(boost/atomic/detail/extra_fp_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_fp_operations.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_fp_operations_fwd.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_fp_ops_emulated.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_fp_ops_generic.hpp + - BOOST_ATOMIC_DETAIL_EXTRA_BACKEND_HEADER(boost/atomic/detail/extra_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_emulated.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_gcc_aarch32.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_gcc_aarch64.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_gcc_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_gcc_ppc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_gcc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_generic.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_msvc_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/extra_ops_msvc_x86.hpp + - BOOST_ATOMIC_DETAIL_BACKEND_HEADER(boost/atomic/detail/ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/ops_gcc_aarch32_common.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/ops_gcc_aarch64_common.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/ops_gcc_arm_common.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/ops_gcc_ppc_common.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/ops_msvc_common.hpp + - BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND_HEADER(boost/atomic/detail/caps_arch_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_aarch64.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_aarch32.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_ppc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_sparc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_gcc_alpha.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_msvc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_arch_msvc_arm.hpp + - BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND_HEADER(boost/atomic/detail/core_arch_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_gcc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_gcc_aarch64.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_gcc_aarch32.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_gcc_ppc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_gcc_sparc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_gcc_alpha.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_msvc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_arch_ops_msvc_arm.hpp + - BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND_HEADER(boost/atomic/detail/fence_arch_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_gcc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_gcc_aarch64.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_gcc_aarch32.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_gcc_ppc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_gcc_sparc.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_gcc_alpha.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_msvc_x86.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_arch_ops_msvc_arm.hpp + - BOOST_ATOMIC_DETAIL_CORE_BACKEND_HEADER(boost/atomic/detail/caps_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_gcc_atomic.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_gcc_sync.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_linux_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/caps_windows.hpp + - BOOST_ATOMIC_DETAIL_CORE_BACKEND_HEADER(boost/atomic/detail/core_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_ops_gcc_atomic.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_ops_gcc_sync.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_ops_linux_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/core_ops_windows.hpp + - BOOST_ATOMIC_DETAIL_CORE_BACKEND_HEADER(boost/atomic/detail/fence_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_ops_gcc_atomic.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_ops_gcc_sync.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_ops_linux_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/fence_ops_windows.hpp + - BOOST_ATOMIC_DETAIL_CORE_BACKEND_HEADER(boost/atomic/detail/wait_caps_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_caps_gcc_atomic.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_caps_gcc_sync.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_caps_linux_arm.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_caps_windows.hpp + - BOOST_ATOMIC_DETAIL_WAIT_BACKEND_HEADER(boost/atomic/detail/wait_ops_): + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_ops_windows.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_ops_futex.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_ops_darwin_ulock.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_ops_freebsd_umtx.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_ops_dragonfly_umtx.hpp + - contrib/restricted/boost/atomic/include/boost/atomic/detail/wait_ops_generic.hpp + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/atomic/src/lock_pool_init1.ipp + - contrib/restricted/boost/atomic/src/lock_pool_init256.ipp + +- source_filter: "^contrib/restricted/boost/function/" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/function/include/boost/function/detail/function_iterate.hpp + +# FIXME thegeorg@: +# boost/function_types/detail/pp_arity_loop.hpp does some extremely magical preprocessor magic +# which I have failed to compile and evalute. +# +# Corresponding includes will not be resolved by ymake +- source_filter: "^contrib/restricted/boost/function_types" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/function_types/include/boost/function_types/detail/pp_cc_loop/master.hpp + +- source_filter: "^contrib/restricted/boost/functional" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/functional/include/boost/functional/forward_adapter.hpp + - contrib/restricted/boost/functional/include/boost/functional/lightweight_forward_adapter.hpp + - contrib/restricted/boost/functional/include/boost/functional/overloaded_function.hpp + - contrib/restricted/boost/functional/include/boost/functional/overloaded_function/detail/base.hpp + +- source_filter: "^contrib/restricted/boost/fusion" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/fusion/include/boost/fusion/algorithm/transformation/zip.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/deque/detail/cpp03/as_deque.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/deque/detail/cpp03/deque_forward_ctor.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/deque/detail/cpp03/deque_keyed_values_call.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_deque_tie.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_list_tie.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_make_deque.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_make_list.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_make_map.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_make_set.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_make_vector.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_map_tie.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/generation/detail/pp_vector_tie.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/list/detail/cpp03/list_forward_ctor.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/list/detail/cpp03/list_to_cons_call.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/map/detail/cpp03/as_map.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/map/detail/cpp03/map_forward_ctor.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/set/detail/cpp03/as_set.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/set/detail/cpp03/set_forward_ctor.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/as_vector.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector10_fwd.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector20_fwd.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector30_fwd.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector40_fwd.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector50_fwd.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector_forward_ctor.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector_n.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/container/vector/detail/cpp03/vector_n_chooser.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/functional/adapter/unfused_typed.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/functional/invocation/invoke.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/tuple/detail/make_tuple.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/tuple/detail/tuple_expand.hpp + - contrib/restricted/boost/fusion/include/boost/fusion/tuple/detail/tuple_tie.hpp + +- source_filter: "^contrib/restricted/boost/mpl" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/mpl/include/boost/mpl/apply.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/apply_fwd.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/apply_wrap.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/arg.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/advance_backward.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/advance_forward.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/fold_impl_body.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/full_lambda.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/lambda_no_ctps.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/numeric_op.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/reverse_fold_impl_body.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/sequence_wrapper.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/aux_/template_arity.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/bind.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/bind_fwd.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/inherit.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/list/aux_/numbered.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/list/aux_/numbered_c.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/map/aux_/numbered.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/placeholders.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/quote.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/set/aux_/numbered.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/set/aux_/numbered_c.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/unpack_args.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/vector/aux_/numbered.hpp + - contrib/restricted/boost/mpl/include/boost/mpl/vector/aux_/numbered_c.hpp + +- source_filter: "^contrib/restricted/boost/numeric_conversion" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/numeric_conversion/include/boost/numeric/conversion/detail/numeric_cast_traits.hpp + +- source_filter: "^contrib/restricted/boost/parameter" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/parameter/include/boost/parameter/aux_/preprocessor/overloads.hpp + +- source_filter: "^contrib/restricted/boost/phoenix" + includes: + - BOOST_PHOENIX_UNORDERED_MAP_HEADER: $U/unordered_map + - BOOST_PHOENIX_UNORDERED_SET_HEADER: $U/unordered_set + - BOOST_PHOENIX_ITERATE(): contrib/restricted/boost/phoenix/include/boost/phoenix/support/detail/iterate.hpp + - BOOST_PP_ITERATE(): contrib/restricted/boost/phoenix/include/boost/phoenix/support/detail/iterate.hpp + +- source_filter: "^contrib/restricted/boost/proto" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/proto/include/boost/proto/context/detail/callable_eval.hpp + - contrib/restricted/boost/proto/include/boost/proto/context/detail/default_eval.hpp + - contrib/restricted/boost/proto/include/boost/proto/context/detail/null_eval.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/and_n.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/args.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/basic_expr.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/class_member_traits.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/deduce_domain_n.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/deep_copy.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/expr.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/funop.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/generate_by_value.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/lambda_matches.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/make_expr.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/make_expr_.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/make_expr_funop.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/matches_.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/memfun_funop.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/or_n.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/poly_function_funop.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/poly_function_traits.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/template_arity_helper.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/traits.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/unpack_expr_.hpp + - contrib/restricted/boost/proto/include/boost/proto/detail/vararg_matches_impl.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/call.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/construct_funop.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/construct_pod_funop.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/default_function_impl.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/expand_pack.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/fold_impl.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/lazy.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/make.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/make_gcc_workaround.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/pack_impl.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/pass_through_impl.hpp + - contrib/restricted/boost/proto/include/boost/proto/transform/detail/when.hpp + +- source_filter: "^contrib/restricted/boost/python" + includes: + # Almost every case of BOOST_PP_ITERATE() invocation in boost/python will include the same header it is being invoked from. + # The only exception from this rule is <boost/python/tuple.hpp> which will include <boost/python/detail/make_tuple.hpp>. + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/python/include/boost/python/call.hpp + - contrib/restricted/boost/python/include/boost/python/call_method.hpp + - contrib/restricted/boost/python/include/boost/python/detail/caller.hpp + - contrib/restricted/boost/python/include/boost/python/detail/defaults_def.hpp + - contrib/restricted/boost/python/include/boost/python/detail/invoke.hpp + - contrib/restricted/boost/python/include/boost/python/detail/result.hpp + - contrib/restricted/boost/python/include/boost/python/detail/target.hpp + - contrib/restricted/boost/python/include/boost/python/detail/signature.hpp + - contrib/restricted/boost/python/include/boost/python/detail/type_list_impl.hpp + - contrib/restricted/boost/python/include/boost/python/object/make_holder.hpp + - contrib/restricted/boost/python/include/boost/python/object_core.hpp + - contrib/restricted/boost/python/include/boost/python/object/pointer_holder.hpp + - contrib/restricted/boost/python/include/boost/python/override.hpp + - contrib/restricted/boost/python/include/boost/python/signature.hpp + - contrib/restricted/boost/python/include/boost/python/object/value_holder.hpp + - contrib/restricted/boost/python/include/boost/python/detail/make_tuple.hpp + +- source_filter: "^contrib/restricted/boost/signals2" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/signals2/include/boost/signals2/detail/preprocessed_arg_type_template.hpp + - contrib/restricted/boost/signals2/include/boost/signals2/detail/signal_template.hpp + - contrib/restricted/boost/signals2/include/boost/signals2/detail/slot_template.hpp + +- source_filter: "^contrib/restricted/boost/spirit" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/spirit/include/boost/spirit/home/karma/generate_attr.hpp + - contrib/restricted/boost/spirit/include/boost/spirit/home/karma/nonterminal/detail/fcall.hpp + - contrib/restricted/boost/spirit/include/boost/spirit/home/karma/stream/format_manip_attr.hpp + - contrib/restricted/boost/spirit/include/boost/spirit/home/lex/tokenize_and_parse_attr.hpp + - contrib/restricted/boost/spirit/include/boost/spirit/home/qi/nonterminal/detail/fcall.hpp + - contrib/restricted/boost/spirit/include/boost/spirit/home/qi/parse_attr.hpp + - contrib/restricted/boost/spirit/include/boost/spirit/home/qi/stream/match_manip_attr.hpp + - contrib/restricted/boost/spirit/include/boost/spirit/home/support/detail/as_variant.hpp + +- source_filter: "^contrib/restricted/boost/type_erasure" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/callable.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/check_match.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/call.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/constructible.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/adapt_to_vtable.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/check_call.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/get_placeholders.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/instantiate.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/extract_concept.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/normalize_deduced.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/vtable.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/construct.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/tuple.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/null.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/require_match.hpp + - contrib/restricted/boost/type_erasure/include/boost/type_erasure/detail/rebind_placeholders.hpp + +- source_filter: "^contrib/restricted/boost/type_traits" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/type_traits/include/boost/type_traits/detail/is_function_ptr_helper.hpp + - contrib/restricted/boost/type_traits/include/boost/type_traits/detail/is_function_ptr_tester.hpp + - contrib/restricted/boost/type_traits/include/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp + - contrib/restricted/boost/type_traits/include/boost/type_traits/detail/is_mem_fun_pointer_tester.hpp + +- source_filter: "^contrib/restricted/boost/typeof" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/typeof/include/boost/typeof/register_functions_iterate.hpp + +- source_filter: "^contrib/restricted/boost/utility" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/utility/include/boost/utility/in_place_factory.hpp + - contrib/restricted/boost/utility/include/boost/utility/detail/result_of_iterate.hpp + - contrib/restricted/boost/utility/include/boost/utility/typed_in_place_factory.hpp + +- source_filter: "^contrib/restricted/boost/variant" + includes: + - BOOST_PP_ITERATE(): + - contrib/restricted/boost/variant/include/boost/variant/detail/substitute.hpp + +- source_filter: "^contrib/libs/gperftools" + includes: + - STACKTRACE_INL_HEADER: + - contrib/libs/gperftools/srcstacktrace_win32-inl.inc + - contrib/libs/gperftools/srcstacktrace_generic-inl.inc + - contrib/libs/gperftools/srcstacktrace_emscripten-inl.inc + - contrib/libs/gperftools/srcstacktrace_x86-inl.inc + - contrib/libs/gperftools/srcstacktrace_powerpc-inl.inc + - contrib/libs/gperftools/srcstacktrace_aarch64-inl.inc + - contrib/libs/gperftools/srcstacktrace_riscv-inl.inc + - contrib/libs/gperftools/srcstacktrace_unimplemented-inl.inc + +- source_filter: "^contrib/libs/lzo2" + includes: + - LZO_CODE_MATCH_INCLUDE_FILE: + - contrib/libs/lzo2/lzo1_cm.ch + - contrib/libs/lzo2/lzo1a_cm.ch + - contrib/libs/lzo2/lzo1b_cm.ch + - LZO_CODE_RUN_INCLUDE_FILE: contrib/libs/lzo2/lzo1b_cr.ch + - LZO_SEARCH_MATCH_INCLUDE_FILE: contrib/libs/lzo2/lzo1b_sm.ch + - LZO_TEST_MATCH_INCLUDE_FILE: contrib/libs/lzo2/lzo1b_tm.ch + +- source_filter: "^contrib/libs/msgpack" + includes: + - _msgpack_atomic_counter_header: + - $U/windows.h + - contrib/libs/msgpack/include/msgpack/gcc_atomic.hpp + - contrib/libs/msgpack/include/msgpack/gcc_atomic.h + +- source_filter: "^contrib/tools/fluent-bit-full" + includes: + - _msgpack_atomic_counter_header: + - $U/windows.h + - $U/ntddk.h + - contrib/tools/fluent-bit-full/lib/msgpack-c/include/msgpack/gcc_atomic.h + +- source_filter: "^contrib/libs/opencv/modules/calib3d" + includes: + - CV_CPU_SIMD_FILENAME: contrib/libs/opencv/modules/calib3d/src/undistort.simd.hpp + +- source_filter: "^contrib/libs/opencv/modules/core" + includes: + - CV_CPU_SIMD_FILENAME: + - contrib/libs/opencv/modules/core/src/arithm.simd.hpp + - contrib/libs/opencv/modules/core/src/convert.simd.hpp + - contrib/libs/opencv/modules/core/src/convert_scale.simd.hpp + - contrib/libs/opencv/modules/core/src/count_non_zero.simd.hpp + - contrib/libs/opencv/modules/core/src/mathfuncs_core.simd.hpp + - contrib/libs/opencv/modules/core/src/matmul.simd.hpp + - contrib/libs/opencv/modules/core/src/mean.simd.hpp + - contrib/libs/opencv/modules/core/src/merge.simd.hpp + - contrib/libs/opencv/modules/core/src/split.simd.hpp + - contrib/libs/opencv/modules/core/src/stat.simd.hpp + - contrib/libs/opencv/modules/core/src/sum.simd.hpp + - contrib/libs/opencv/modules/core/test/test_intrin128.simd.hpp + - contrib/libs/opencv/modules/core/test/test_intrin256.simd.hpp + - contrib/libs/opencv/modules/core/test/test_intrin512.simd.hpp + +- source_filter: "^contrib/libs/opencv/modules/imgproc" + includes: + - CV_CPU_SIMD_FILENAME: + - contrib/libs/opencv/modules/imgproc/src/accum.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/bilateral_filter.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/box_filter.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/color_hsv.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/color_rgb.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/color_yuv.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/filter.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/median_blur.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/morph.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/smooth.simd.hpp + - contrib/libs/opencv/modules/imgproc/src/sumpixels.simd.hpp + +- source_filter: "^contrib/libs/opencv/modules/features2d" + includes: + - CV_CPU_SIMD_FILENAME: contrib/libs/opencv/modules/features2d/src/sift.simd.hpp + +- source_filter: "^contrib/libs/openmpi" + includes: + - MCA_event_IMPLEMENTATION_HEADER: contrib/libs/openmpi/opal/mca/event/external/external.h + - MCA_hwloc_external_header: contrib/libs/hwloc/include/hwloc.h + - MCA_hwloc_external_shmem_header: contrib/libs/hwloc/include/hwloc/shmem.h + - MCA_hwloc_IMPLEMENTATION_HEADER: contrib/libs/openmpi/opal/mca/hwloc/external/external.h + - MCA_memory_IMPLEMENTATION_HEADER: contrib/libs/openmpi/opal/mca/memory/base/empty.h + - MCA_rte_IMPLEMENTATION_HEADER: contrib/libs/openmpi/ompi/mca/rte/orte/rte_orte.h + - MCA_timer_IMPLEMENTATION_HEADER: contrib/libs/openmpi/opal/mca/timer/linux/timer_linux.h + - PMIX_EVENT2_THREAD_HEADER: contrib/libs/openmpi/opal/mca/event/external/external.h + - PMIX_EVENT_HEADER: contrib/libs/openmpi/opal/mca/event/external/external.h + - PMIX_HWLOC_HEADER: contrib/libs/openmpi/opal/mca/hwloc/external/external.h + +- source_filter: "^contrib/libs/pugixml" + includes: + - PUGIXML_SOURCE: contrib/libs/pugixml/pugixml.cpp + +- source_filter: "^contrib/libs/unixodbc" + includes: + - LT_CONFIG_H: $U/config.h + +- source_filter: "^contrib/libs/xpdf-3.04/splash" + includes: + - FT_CFF_DRIVER_H: contrib/libs/freetype/include/freetype/ftdriver.h + +- source_filter: "^contrib/libs/nvidia/thrust" + includes: + - __THRUST_DEVICE_SYSTEM_TAG_HEADER: + - contrib/libs/nvidia/thrust/thrust/system/cpp/detail/execution_policy.h + - contrib/libs/nvidia/thrust/thrust/system/cuda/detail/execution_policy.h + - contrib/libs/nvidia/thrust/thrust/system/omp/detail/execution_policy.h + - contrib/libs/nvidia/thrust/thrust/system/tbb/detail/execution_policy.h + +- source_filter: "^contrib/python/mercurial" + includes: + - SHA1DC_CUSTOM_INCLUDE_SHA1_C: contrib/libs/libgit2/src/util/git2_util.h + - SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C: contrib/libs/libgit2/src/util/git2_util.h + +- source_filter: "^contrib/libs/unixodbc/libltdl" + includes: + - LT_CONFIG_H: $U/config.h + +- source_filter: "^contrib/libs/esp-idf" + includes: + - MBEDTLS_CONFIG_FILE: contrib/libs/esp-idf/components/mbedtls/port/include/mbedtls/esp_config.h + +- source_filter: "^contrib/libs/sparsehash/src/sparsehash" + includes: + - HASH_FUN_H: util/generic/hash.h + +- source_filter: "^contrib/libs/cbc/Cbc/src/OsiCbc" + includes: + - OSICBC_DFLT_SOLVER_HPP: contrib/libs/cbc/Clp/src/OsiClp/OsiClpSolverInterface.hpp + +- source_filter: "^contrib/libs/glog/sources/src" + includes: + - STACKTRACE_H: + - contrib/libs/glog/sources/src/stacktrace_x86-inl.h + - contrib/libs/glog/sources/src/stacktrace_x86_64-inl.h + - contrib/libs/glog/sources/src/stacktrace_powerpc-inl.h + - contrib/libs/glog/sources/src/stacktrace_generic-inl.h + +- source_filter: "^contrib/libs/hdf5/src" + includes: + - H5_ZLIB_HEADER: contrib/libs/zlib/include/zlib.h + +- source_filter: "^contrib/libs/libgit2/src/util/hash/sha1dc" + includes: + - SHA1DC_CUSTOM_INCLUDE_SHA1_C: contrib/libs/libgit2/src/util/git2_util.h + - SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C: contrib/libs/libgit2/src/util/git2_util.h + +- source_filter: "^contrib/libs/libyang" + includes: + - IETF_DATASTORES: contrib/libs/libyang/models/ietf-datastores@2018-02-14.h + - IETF_INET_TYPES_PATH: contrib/libs/libyang/models/ietf-inet-types@2013-07-15.h + - IETF_YANG_LIB_PATH: contrib/libs/libyang/models/ietf-yang-library@2019-01-04.h + - IETF_YANG_METADATA_PATH: contrib/libs/libyang/models/ietf-yang-metadata@2016-08-05.h + - IETF_YANG_TYPES_PATH: contrib/libs/libyang/models/ietf-yang-types@2013-07-15.h + - YANG_PATH: contrib/libs/libyang/models/yang@2017-02-20.h + +# adfox/amacs and mds/cocaine are legacy projects which is set to removal from the repo. +# Resolve macro includes into nothing as nobody needs sandboxed build to be functional in these places. +- source_filter: "^adfox/amacs/deps/luabind" + includes: + - BOOST_PP_ITERATE() + +- source_filter: "^mds/cocaine/core" + includes: + - BOOST_PP_ITERATE() + +# Connectedhomeip contrib uses a special type of imports for third-party includes https://github.com/project-chip/connectedhomeip/issues/4354 +# Also empty MACROs here defined for Linux and ESP32 platforms, but esp32 files use third-party library esp-idf +# So there are some problems to resolve imports especially in contrib/libs/connectedhomeip/src/app, +# after resolving a problem via ADDINCL there will be much more errors. So currently these types of errors hide under empty resolving +- source_filter: "^contrib/libs/connectedhomeip/src" + includes: + - CHIP_SYSTEM_LAYER_IMPL_CONFIG_FILE: + - contrib/libs/connectedhomeip/src/system/SystemLayerImplSelect.h + - contrib/libs/connectedhomeip/src/system/SystemLayerImplFreeRTOS.h + - CHIP_PROJECT_CONFIG_INCLUDE: contrib/libs/connectedhomeip/config/standalone/CHIPProjectConfig.h + - SYSTEM_PROJECT_CONFIG_INCLUDE: contrib/libs/connectedhomeip/config/standalone/SystemProjectConfig.h + - CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER: contrib/libs/connectedhomeip/src/lib/address_resolve/AddressResolve_DefaultImpl.h + - CONFIGURATION_HEADER: contrib/libs/connectedhomeip/src/app/util/config.h + - BLE_PLATFORM_CONFIG_INCLUDE + - CHIP_PLATFORM_CONFIG_INCLUDE + - INET_PLATFORM_CONFIG_INCLUDE + - SYSTEM_PLATFORM_CONFIG_INCLUDE + - CHIPDEVICEPLATFORMEVENT_HEADER + - CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE + - CONFIGURATIONMANAGERIMPL_HEADER + - CONNECTIVITYMANAGERIMPL_HEADER + - KEYVALUESTOREMANAGERIMPL_HEADER + - PLATFORMMANAGERIMPL_HEADER + - THREADSTACKMANAGERIMPL_HEADER + - BLEMANAGERIMPL_HEADER diff --git a/build/sysincl/misc-win.yml b/build/sysincl/misc-win.yml new file mode 100644 index 00000000000..e0567f28f9a --- /dev/null +++ b/build/sysincl/misc-win.yml @@ -0,0 +1,72 @@ +- source_filter: "^(contrib/libs/(ImageMagick|ffmpeg-3|libraw|pthreads_win32|zookeeper))|^contrib/restricted/boost" + includes: + - pthread.h: contrib/libs/pthreads_win32/include/pthread.h + - sched.h: contrib/libs/pthreads_win32/include/sched.h + +- source_filter: "^contrib/libs/jemalloc" + includes: + - strings.h: contrib/libs/jemalloc/include/msvc_compat/strings.h + +- source_filter: "^contrib/libs/libpq/src" + includes: + - arpa/inet.h: contrib/libs/libpq/src/include/port/win32/arpa/inet.h + - netdb.h: contrib/libs/libpq/src/include/port/win32/netdb.h + - netinet/in.h: contrib/libs/libpq/src/include/port/win32/netinet/in.h + - pwd.h: contrib/libs/libpq/src/include/port/win32/pwd.h + - sys/file.h: contrib/libs/libpq/src/include/port/win32_msvc/sys/file.h + - sys/param.h: contrib/libs/libpq/src/include/port/win32_msvc/sys/param.h + - sys/socket.h: contrib/libs/libpq/src/include/port/win32/sys/socket.h + - sys/time.h: contrib/libs/libpq/src/include/port/win32_msvc/sys/time.h + - unistd.h: contrib/libs/libpq/src/include/port/win32_msvc/unistd.h + +- source_filter: "^contrib/libs/postgresql/src|^ydb/library/yql/parser/pg_wrapper/postgresql/src" + includes: + - arpa/inet.h: contrib/libs/postgresql/src/include/port/win32/arpa/inet.h + - dirent.h: contrib/libs/postgresql/src/include/port/win32_msvc/dirent.h + - grp.h: contrib/libs/postgresql/src/include/port/win32/grp.h + - netdb.h: contrib/libs/postgresql/src/include/port/win32/netdb.h + - netinet/in.h: contrib/libs/postgresql/src/include/port/win32/netinet/in.h + - pwd.h: contrib/libs/postgresql/src/include/port/win32/pwd.h + - sys/file.h: contrib/libs/postgresql/src/include/port/win32_msvc/sys/file.h + - sys/param.h: contrib/libs/postgresql/src/include/port/win32_msvc/sys/param.h + - sys/socket.h: contrib/libs/postgresql/src/include/port/win32/sys/socket.h + - sys/time.h: contrib/libs/postgresql/src/include/port/win32_msvc/sys/time.h + - sys/wait.h: contrib/libs/postgresql/src/include/port/win32/sys/wait.h + - unistd.h: contrib/libs/postgresql/src/include/port/win32_msvc/unistd.h + - utime.h: contrib/libs/postgresql/src/include/port/win32_msvc/utime.h + +- source_filter: "^contrib/libs/libx264" + includes: + - inttypes.h: contrib/libs/libx264/extras/inttypes.h + - stdint.h: contrib/libs/libx264/extras/stdint.h + +- source_filter: "^contrib/tools/bison" + includes: + - alloca.h: contrib/tools/bison/gnulib/platform/win64/alloca.h + - getopt.h: contrib/tools/bison/gnulib/platform/win64/getopt.h + - fcntl.h: contrib/tools/bison/gnulib/platform/win64/fcntl.h + - langinfo.h: contrib/tools/bison/gnulib/platform/win64/langinfo.h + - locale.h: contrib/tools/bison/gnulib/platform/win64/locale.h + - math.h: contrib/tools/bison/gnulib/platform/win64/math.h + - sched.h: contrib/tools/bison/gnulib/platform/win64/sched.h + - signal.h: contrib/tools/bison/gnulib/platform/win64/signal.h + - spawn.h: contrib/tools/bison/gnulib/platform/win64/spawn.h + - stdbool.h: contrib/tools/bison/gnulib/platform/win64/stdbool.h + - sys/stat.h: contrib/tools/bison/gnulib/platform/win64/sys/stat.h + - sys/time.h: contrib/tools/bison/gnulib/platform/win64/sys/time.h + - sys/wait.h: contrib/tools/bison/gnulib/platform/win64/sys/wait.h + - unistd.h: contrib/tools/bison/gnulib/platform/win64/unistd.h + +- source_filter: "^contrib/libs/libpq" + includes: + - dirent.h: contrib/libs/libpq/src/include/port/win32_msvc/dirent.h + - sys/wait.h: contrib/libs/libpq/src/include/port/win32/sys/wait.h + - win32.h: contrib/libs/libpq/src/include/port/win32.h + +- source_filter: "^contrib/libs/curl" + includes: + - nghttp2/nghttp2.h + +- includes: + - sys/queue.h: contrib/libs/libc_compat/include/windows/sys/queue.h + - sys/uio.h: contrib/libs/libc_compat/include/windows/sys/uio.h diff --git a/build/sysincl/misc.yml b/build/sysincl/misc.yml new file mode 100644 index 00000000000..23071ce4676 --- /dev/null +++ b/build/sysincl/misc.yml @@ -0,0 +1,637 @@ +- includes: + # Valgrind PEERDIR and ADDINCL are added only in --valgrind builds, + # but we should resolve headers anyway. + - valgrind/callgrind.h + - valgrind/memcheck.h + - valgrind/valgrind.h + # DB2_ODBC_CLI + - sqlcli1.h + + +- includes: + - gelf.h: contrib/restricted/libelf/include/libelf/gelf.h + - libelf.h: contrib/restricted/libelf/include/libelf/libelf.h + - libelf/libelf.h: contrib/restricted/libelf/include/libelf/libelf.h + - libelf/sys_elf.h: contrib/restricted/libelf/include/libelf/sys_elf.h + +# We have lots of ADDINCLs to contrib/libs/libiconv all around the repo +# so we need to add it to sysincl for consistent resolving. +# We can go the other way here and remove iconv.h from all sysincl configs +# and try to fix all places where we really need iconv.h from libc +# Btw: seems that this ADDINCL should be made global and removed from projects +# that use this header +- includes: + - iconv.h: contrib/libs/libiconv/include/iconv.h + +- includes: + - cudnn.h: contrib/libs/nvidia/cudnn/cudnn.h + +# _cgo_export.h is generated into build dir of go package which uses cgo +# and we are unable to resolve it correctly to whcih build dir to resolve +# in the case when tests are also built for this package +- includes: + - _cgo_export.h + +# Resolve jni.h from swig/Lib/java/javahead.swg when building non-java .swg +# since they do not peerdir contrib/libs/jdk. +# Resolve Python.h from swig/Lib/python/pyruntime.swg when building non-python .swg +# since they do not peerdir contrib/libs/python. +- source_filter: "[.]swg([.](h|c(c|pp|xx)?))?$" + includes: + - jni.h: contrib/libs/jdk/include/jni.h + - Python.h: contrib/libs/python/Include/Python.h +- source_filter: "^contrib/libs/jdk/include/jni[.]h$" + includes: + - jni_md.h: + - contrib/libs/jdk/include/darwin/jni_md.h + - contrib/libs/jdk/include/linux/jni_md.h + - contrib/libs/jdk/include/win32/jni_md.h + +# libunistring, libidn and libidn2 +# have its own libc header wrappers that are added to ADDINCL +# and need to be added here for consistensy between ADDINCL and sysincl resolving. +# Btw: we don't parse include_next, so we might lose real dependency to musl, +# but sysincl resolving will save us here, as it will resolve to both of them. +- source_filter: "^contrib/libs/libunistring" + includes: + - alloca.h: contrib/libs/libunistring/alloca.h + - langinfo.h: contrib/libs/libunistring/langinfo.h + - minmax.h: contrib/libs/libunistring/minmax.h + +- source_filter: "^contrib/libs/libidn/" + includes: + - alloca.h: contrib/libs/libidn/gl/alloca.h + - error.h: contrib/libs/libidn/gl/error.h + - iconv.h: contrib/libs/libidn/lib/gl/iconv.h + +- source_filter: "^contrib/libs/libidn2/" + includes: + - alloca.h: contrib/libs/libidn2/gl/alloca.h + - error.h: contrib/libs/libidn2/gl/error.h + +# Same as libunistring - lftp has own libc header wrappers/replacements. +# However here we have GLOBAL ADDINCL to contrib/libs/lftp{,/trio,/lib} +# that can poison resolving in PEERDIRing projects. +# Fortunately lftp is used only in contrib/tools/lftp. +# Probably we should add PEERDIR restriction rule to it. +- source_filter: "^contrib/libs/lftp" + includes: + - alloca.h: contrib/libs/lftp/alloca.h + - error.h: contrib/libs/lftp/lib/error.h + - fnmatch.h: contrib/libs/lftp/lib/fnmatch.h + - regex.h: contrib/libs/lftp/lib/regex.h + - sys/socket.h: contrib/libs/lftp/lib/sys/socket.h + - sys/stat.h: contrib/libs/lftp/lib/sys/stat.h + - sys/time.h: contrib/libs/lftp/lib/sys/time.h + +# Another sysincl/addincl clash. Here we also have GLOBAL ADDINCL that will +# produce sysincl/addincl mismatch configure errors when someone writes +# #include <math.h> and enables USE_ARCADIA_LIBM. Now we have no instances of this. +- source_filter: "^contrib/libs/libm/.*\\.c" + includes: + - complex.h: contrib/libs/libm/include/complex.h + - math.h: contrib/libs/libm/include/math.h + +# Some more sysincl/addincl clashes. +- source_filter: "^contrib/tools/bison/(bison|gnulib|m4)/src" + includes: + - error.h: contrib/tools/bison/gnulib/src/error.h + - fcntl.h: contrib/tools/bison/gnulib/platform/posix/fcntl.h + - getopt.h: contrib/tools/bison/gnulib/platform/posix/getopt.h + - obstack.h: contrib/tools/bison/gnulib/src/obstack.h + - regex.h: contrib/tools/bison/gnulib/src/regex.h + - system.h + - unlocked-io.h: contrib/tools/bison/gnulib/src/unlocked-io.h +- source_filter: "^contrib/tools/make" + includes: + - fnmatch.h: contrib/tools/make/glob/fnmatch.h + - glob.h: contrib/tools/make/glob/glob.h +- source_filter: "^contrib/tools/tre" + includes: + - regex.h: contrib/tools/tre/lib/regex.h + +- source_filter: "^contrib/libs/cppkafka" + includes: + - error.h: contrib/libs/cppkafka/include/cppkafka/error.h + +- source_filter: "^contrib/libs/llvm" + includes: + - plugin-api.h # GNU linker plugin API. + +- source_filter: "^contrib/libs/musl" + includes: + - atomic.h: contrib/libs/musl/src/internal/atomic.h + - bits/fenv.h: contrib/libs/musl/arch/x86_64/bits/fenv.h + +- source_filter: "^contrib/libs/zbar" + includes: + - error.h: contrib/libs/zbar/zbar/error.h + +- source_filter: "^contrib/libs/curl" + includes: + - http.h: contrib/libs/curl/lib/http.h + - inet_ntop.h: contrib/libs/curl/lib/inet_ntop.h + - share.h: contrib/libs/curl/lib/share.h + +- source_filter: "^contrib/libs/zeromq" + includes: + - atomic.h: contrib/libs/zeromq/missing_includes/atomic.h + - Mstcpip.h: contrib/libs/zeromq/missing_includes/Mstcpip.h + +- source_filter: "^contrib/restricted/openal-soft" + includes: + - atomic.h: contrib/restricted/openal-soft/common/atomic.h + +- source_filter: "^contrib/libs/ffmpeg-3/" + includes: + - fontconfig/fontconfig.h + - fribidi.h + - stdatomic.h: contrib/libs/ffmpeg-3/compat/atomics/win32/stdatomic.h + - atomic.h: contrib/libs/ffmpeg-3/libavutil/atomic.h + +- source_filter: "^contrib/libs/ffmpeg-3.4.1/" + includes: + - fontconfig/fontconfig.h + - fribidi.h + - stdatomic.h: contrib/libs/ffmpeg-3.4.1/compat/atomics/win32/stdatomic.h + - atomic.h: contrib/libs/ffmpeg-3.4.1/libavutil/atomic.h + +- source_filter: "^contrib/libs/glog" + includes: + - port.h: contrib/libs/glog/missing_includes/port.h + +- source_filter: "^contrib/libs/postgresql" + includes: + - port.h: contrib/libs/postgresql/src/include/port.h + +- source_filter: "^contrib/(deprecated/onednn|libs/intel/onednn)" + + includes: + - mkl_cblas.h: contrib/libs/intel/mkl/include/mkl_cblas.h + - mkl_version.h: contrib/libs/intel/mkl/include/mkl_version.h + - mkl_vml_defines.h: contrib/libs/intel/mkl/include/mkl_vml_defines.h + - mkl_vml_functions.h: contrib/libs/intel/mkl/include/mkl_vml_functions.h + +- source_filter: "^contrib/libs/nsync" + includes: + - atomic.h: contrib/libs/nsync/platform/c++11/atomic.h + +- source_filter: "^contrib/python/numpy/py3" + includes: + - numpy/random.pxd + - alloc.h: contrib/python/numpy/include/numpy/core/src/multiarray/alloc.h + +- source_filter: "^contrib/tools/python/src/Objects/exceptions.c" + includes: + - errmap.h: contrib/tools/python/src/PC/errmap.h + +- source_filter: "^contrib/libs/speex" + includes: + - mkl.h: contrib/libs/intel/mkl/include/mkl.h + +# deprecated contrib with ADDINCL to libintl +- source_filter: "^contrib/(deprecated/glib/glib|libs/gdk-pixbuf)" + includes: + - libintl.h: contrib/deprecated/libintl/libintl.h + +- source_filter: "^contrib/libs/poco/Data/ODBC" + includes: + - sql.h: contrib/libs/unixodbc/include/sql.h + - sqlext.h: contrib/libs/unixodbc/include/sqlext.h + - sqltypes.h: contrib/libs/unixodbc/include/sqltypes.h + - sqlucode.h: contrib/libs/unixodbc/include/sqlucode.h + +- source_filter: "^contrib/libs/icu" + includes: + - util.h: contrib/libs/icu/common/util.h + +- source_filter: "^contrib/tools/yasm" + includes: + - util.h: contrib/tools/yasm/util.h + +- source_filter: "^contrib/libs/libgit2" + includes: + - alloc.h: contrib/libs/libgit2/src/util/alloc.h + - thread.h: contrib/libs/libgit2/src/util/thread.h + - regexp.h: contrib/libs/libgit2/src/util/regexp.h + - util.h: contrib/libs/libgit2/src/util/util.h + +- source_filter: "^contrib/libs/nodejs_12" + includes: + - util.h: contrib/libs/nodejs_12/src/util.h + +- source_filter: "^contrib/libs/numa" + includes: + - util.h: contrib/libs/numa/internal/util.h + +- source_filter: "^contrib/libs/systemd" + includes: + - util.h: contrib/libs/systemd/src/basic/util.h + +- source_filter: "^contrib/libs/nvidia/nccl" + includes: + - alloc.h: contrib/libs/nvidia/nccl/src/include/alloc.h + - socket.h: contrib/libs/nvidia/nccl/src/include/socket.h + +- source_filter: "^contrib/deprecated/tf/tensorflow" + includes: + - cuda.h: contrib/deprecated/tf/tensorflow/core/platform/cuda.h + +# unused legacy include in boost +- source_filter: "^contrib/restricted/boost" + includes: + - fstream.h + - ../include/fenv.h + +# windows sdk includes that we do not want to apply for whole arcadia +- source_filter: "^contrib" + includes: + - process.h +- source_filter: "^contrib/tools/tpce-benchmark" + includes: + - sql.h + - sqlext.h + - sqltypes.h + - sqlucode.h + +- source_filter: "^contrib/libs/libmemcached" + includes: + - sasl/sasl.h + - sasl/saslutil.h + +- source_filter: "^contrib/libs/(apache/apr|httpd|llvm)" + includes: + - uuid.h + - uuid/uuid.h + +- source_filter: "^contrib/libs/(kenlm|libxml|re2|sqlite3)" + includes: + - unicode/ucnv.h + - unicode/ucol.h + - unicode/uniset.h + - unicode/unistr.h + - unicode/ustring.h + - unicode/utf16.h + - unicode/utypes.h + - unicode/uversion.h + +- source_filter: "^contrib/deprecated/glib" + includes: + - configmake.h + +- source_filter: "^contrib/libs/authparser" + includes: + - settings.h + +- source_filter: "^contrib/libs/ceres-solver" + includes: + - tbb/tbb_stddef.h + +- source_filter: "^contrib/libs/deprecated" + includes: + - hdf5.h + +- source_filter: "^contrib/libs/freetype" + includes: + - hb-ot.h + - hb-ft.h + - hb.h + +- source_filter: "^contrib/libs/httpd" + includes: + - nginx.h + - ngx_config.h + - ngx_core.h + - ngx_http.h + - ngx_log.h + +- source_filter: "^contrib/libs/leptonica-1.70" + includes: + - gif_lib.h + - webp/decode.h + - webp/encode.h + +- source_filter: "^contrib/libs/libpcap" + includes: + - strerror.h + +- source_filter: "^contrib/libs/libxml" + includes: + - lzma.h + - win32config.h + +- source_filter: "^contrib/libs/mod_perl2" + includes: + - config.h + +- source_filter: "^contrib/libs/(apache/apr|httpd|openssl)" + includes: + - netinet/sctp.h + +- source_filter: "^contrib/libs/subversion" + includes: + - magic.h + - xmlparse.h + +- source_filter: "^contrib/python/scipy" + includes: + - matrix.h + +- source_filter: "^contrib/python/uWSGI" + includes: + - libxml/parser.h + - libxml/tree.h + - uuid/uuid.h + +- source_filter: "^contrib/tools/python" + includes: + - ioctl.h + - utils.h + +- source_filter: "^(contrib/libs/cxxsupp/openmp|catboost/cuda/cuda_lib)" + includes: + - hwloc.h + - hwloc/cudart.h + +- source_filter: "^contrib/libs/(aws-sdk-cpp|c-ares|proj)" + includes: + - jni.h + +- source_filter: "^contrib/(libs/(ffmpeg-3|kyotocabinet)|tools/ag)" + includes: + - lzma.h + +- source_filter: "^contrib/libs/(kyotocabinet|minilzo)" + includes: + - lzo/lzo1x.h + +- source_filter: "^contrib/libs/(gtest|libpng|opencv)" + includes: + - mem.h + +- source_filter: "^contrib/libs/(authparser|libcoro-perl|libev-perl|libevent-perl)" + includes: + - patchlevel.h + +- source_filter: "^metrika/uatraits" + includes: + - note.h + - could_not_find_Perl_patchlevel.h + - patchlevel.h + +- source_filter: "^contrib/libs/(freetype|leptonica-1.70|libtheora|zbar)" + includes: + - png.h + +- source_filter: "^(contrib/restricted/boost/boost/mpi|catboost/cuda/cuda_lib/mpi)" + includes: + - mpi.h + +- source_filter: "^contrib/libs/libf2c" + includes: + - local.h + +- source_filter: "^contrib/libs/libpq" + includes: + - local.h + +- source_filter: "^contrib/libs/breakpad" + includes: + - stab.h + +- source_filter: "^contrib/tools/fluent-bit-(full|minimal)" + includes: + - backtrace.h: contrib/libs/backtrace/backtrace.h + +- source_filter: "^contrib/restricted/boost/stacktrace/include/boost/stacktrace/detail" + includes: + - backtrace.h: contrib/libs/backtrace/backtrace.h + +- source_filter: "^contrib/restricted/libelf" + includes: + - byteswap.h: contrib/restricted/libelf/lib/byteswap.h + - gelf.h: contrib/restricted/libelf/lib/gelf.h + - libelf.h: contrib/restricted/libelf/lib/libelf.h + - nlist.h: contrib/restricted/libelf/lib/nlist.h + - sys_elf.h: contrib/restricted/libelf/lib/sys_elf.h + +- source_filter: "^contrib/libs/dpdk/" + includes: + - process.h: contrib/libs/dpdk/drivers/bus/dpaa/include/process.h + +- source_filter: "^contrib/libs/dpdk_arm64/" + includes: + - process.h: contrib/libs/dpdk_arm64/drivers/bus/dpaa/include/process.h + +- source_filter: "^contrib/libs/usrsctp/" + includes: + - netinet/sctp_uio.h: contrib/libs/usrsctp/usrsctplib/netinet/sctp_uio.h + +- source_filter: "^contrib/libs/libsrtp/" + includes: + - alloc.h: contrib/libs/libsrtp/crypto/include/alloc.h + - err.h: contrib/libs/libsrtp/crypto/include/err.h + - stat.h: contrib/libs/libsrtp/crypto/include/stat.h + +- source_filter: "^contrib/restricted/openal-soft" + includes: + - threads.h: contrib/restricted/openal-soft/common/threads.h + +- source_filter: "^contrib/python/pymqi" + includes: + # IBM MQ + - cmqc.h + - cmqxc.h + - cmqcfc.h + - cmqbc.h + +- source_filter: "^contrib/libs/h3" + includes: + - alloc.h: contrib/libs/h3/h3lib/include/alloc.h +- source_filter: "^cloud/iam/token_agent/daemon" + includes: + - contrib/libs/grpc/include/grpcpp/impl/codegen/server_context_impl.h + +- source_filter: "^contrib/libs/libyang" + includes: + - in.h: contrib/libs/libyang/libyang/in.h + +- source_filter: "^contrib/restricted/noc/frr" + includes: + - bfd.h: contrib/restricted/noc/frr/lib/bfd.h + - getopt.h: contrib/restricted/noc/frr/lib/getopt.h + - filter.h: contrib/restricted/noc/frr/lib/filter.h + - memory.h: contrib/restricted/noc/frr/lib/memory.h + - thread.h: contrib/restricted/noc/frr/lib/thread.h + +- source_filter: "^contrib/libs/cxxsupp/libcxxrt" + includes: + - atomic.h: contrib/libs/cxxsupp/libcxxrt/atomic.h + +- source_filter: "^contrib/libs/util-linux" + includes: + - procfs.h: contrib/libs/util-linux/include/procfs.h + +- source_filter: "^contrib/libs/gdal" + includes: + - io.h: contrib/libs/gdal/ogr/ogrsf_frmts/cad/libopencad/dwg/io.h + +# disable checks for Python 3.11-specific files +# needed to allow to use Arcadia's Cython with non-Arcadia python in open source builds +- source_filter: "^contrib/tools/cython/Cython/Utility" + includes: + - internal/pycore_frame.h: contrib/libs/python/Include/internal/pycore_frame.h + +- source_filter: "^contrib/libs/connectedhomeip" + includes: + - freertos/FreeRTOS.h + - freertos/semphr.h + - freertos/task.h + - lwip/def.h + - lwip/err.h + - lwip/inet.h + - lwip/init.h + - lwip/ip4_addr.h + - lwip/ip_addr.h + - lwip/mem.h + - lwip/memp.h + - lwip/netif.h + - lwip/opt.h + - lwip/pbuf.h + - lwip/stats.h + - lwip/sys.h + - lwip/tcpip.h + +- source_filter: "^contrib/libs/glibcasm" + includes: + - alloca.h: contrib/libs/glibcasm/glibc/include/alloca.h + - assert.h: contrib/libs/glibcasm/glibc/include/assert.h + - bits/atomic_wide_counter.h: + - contrib/libs/glibcasm/glibc/bits/atomic_wide_counter.h + - contrib/libs/glibcasm/glibc/include/bits/atomic_wide_counter.h + - bits/dl_find_object.h: + - contrib/libs/glibcasm/glibc/include/bits/dl_find_object.h + - contrib/libs/glibcasm/glibc/sysdeps/x86/bits/dl_find_object.h + - bits/endian.h: contrib/libs/glibcasm/glibc/include/bits/endian.h + - bits/libc-header-start.h: contrib/libs/glibcasm/glibc/bits/libc-header-start.h + - bits/long-double.h: contrib/libs/glibcasm/glibc/sysdeps/ieee754/ldbl-96/bits/long-double.h + - bits/sigstack.h: + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/bits/sigstack.h + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/x86/include/bits/sigstack.h + - contrib/libs/glibcasm/glibc/include/bits/sigstack.h + - bits/stdint-intn.h: contrib/libs/glibcasm/glibc/bits/stdint-intn.h + - bits/stdint-uintn.h: contrib/libs/glibcasm/glibc/bits/stdint-uintn.h + - bits/time64.h: contrib/libs/glibcasm/glibc/bits/time64.h + - bits/timesize.h: contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/x86/bits/timesize.h + - bits/typesizes.h: contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/x86/bits/typesizes.h + - bits/types.h: contrib/libs/glibcasm/glibc/include/bits/types.h + - bits/unistd_ext.h: + - contrib/libs/glibcasm/glibc/include/bits/unistd_ext.h + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/bits/unistd_ext.h + - bits/wchar.h: contrib/libs/glibcasm/glibc/bits/wchar.h + - bits/wordsize.h: contrib/libs/glibcasm/glibc/sysdeps/x86/bits/wordsize.h + - cpu-features.h: contrib/libs/glibcasm/glibc/sysdeps/x86/include/cpu-features.h + - dl-lookupcfg.h: + - contrib/libs/glibcasm/glibc/sysdeps/generic/dl-lookupcfg.h + - contrib/libs/glibcasm/glibc/sysdeps/x86/dl-lookupcfg.h + - dl-sysdep.h: + - contrib/libs/glibcasm/glibc/sysdeps/generic/dl-sysdep.h + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/dl-sysdep.h + - dlfcn.h: contrib/libs/glibcasm/glibc/include/dlfcn.h + - elf.h: contrib/libs/glibcasm/glibc/include/elf.h + - endian.h: contrib/libs/glibcasm/glibc/include/endian.h + - errno.h: contrib/libs/glibcasm/glibc/include/errno.h + - features.h: contrib/libs/glibcasm/glibc/include/features.h + - features-time64.h: + - contrib/libs/glibcasm/glibc/include/features-time64.h + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/features-time64.h + - fpu_control.h: + - contrib/libs/glibcasm/glibc/include/fpu_control.h + - contrib/libs/glibcasm/glibc/sysdeps/x86/fpu_control.h + - hp-timing.h: contrib/libs/glibcasm/glibc/sysdeps/x86/hp-timing.h + - inttypes.h: contrib/libs/glibcasm/glibc/include/inttypes.h + - kernel-features.h: + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/x86_64/kernel-features.h + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/kernel-features.h + - ldsodefs.h: + - contrib/libs/glibcasm/glibc/sysdeps/generic/ldsodefs.h + - contrib/libs/glibcasm/glibc/sysdeps/gnu/ldsodefs.h + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/ldsodefs.h + - contrib/libs/glibcasm/glibc/sysdeps/x86/ldsodefs.h + - limits.h: contrib/libs/glibcasm/glibc/include/limits.h + - link.h: contrib/libs/glibcasm/glibc/include/link.h + - locale.h: contrib/libs/glibcasm/glibc/include/locale.h + - misc/sys/cdefs.h: contrib/libs/glibcasm/glibc/misc/sys/cdefs.h + - netinet/in.h: contrib/libs/glibcasm/glibc/include/netinet/in.h + - posix/bits/types.h: contrib/libs/glibcasm/glibc/posix/bits/types.h + - pthread.h: contrib/libs/glibcasm/glibc/include/pthread.h + - single-thread.h: + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/x86_64/single-thread.h + - contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/single-thread.h + - sched.h: contrib/libs/glibcasm/glibc/include/sched.h + - setjmp.h: contrib/libs/glibcasm/glibc/include/setjmp.h + - shlib-compat.h: contrib/libs/glibcasm/glibc/include/shlib-compat.h + - signal.h: contrib/libs/glibcasm/glibc/include/signal.h + - stdint.h: + - contrib/libs/glibcasm/glibc/include/stdint.h + - contrib/libs/cxxsupp/libcxx/include/stdint.h + - stdlib.h: contrib/libs/glibcasm/glibc/include/stdlib.h + - stackinfo.h: + - contrib/libs/glibcasm/glibc/include/stackinfo.h + - contrib/libs/glibcasm/glibc/sysdeps/x86_64/stackinfo.h + - stdlib.h: contrib/libs/glibcasm/glibc/include/stdlib.h + - stdlib/stdint.h: contrib/libs/glibcasm/glibc/stdlib/stdint.h + - string.h: contrib/libs/glibcasm/glibc/include/string.h + - strings.h: contrib/libs/glibcasm/glibc/include/strings.h + - sys/cdefs.h: contrib/libs/glibcasm/glibc/include/sys/cdefs.h + - sys/mman.h: contrib/libs/glibcasm/glibc/include/sys/mman.h + - sys/param.h: contrib/libs/glibcasm/glibc/include/sys/param.h + - sys/procfs.h: contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/sys/procfs.h + - sys/select.h: contrib/libs/glibcasm/glibc/include/sys/select.h + - sys/socket.h: contrib/libs/glibcasm/glibc/include/sys/socket.h + - sys/stat.h: contrib/libs/glibcasm/glibc/include/sys/stat.h + - sys/syscall.h: contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/include/sys/syscall.h + - sys/time.h: contrib/libs/glibcasm/glibc/include/sys/time.h + - sys/types.h: contrib/libs/glibcasm/glibc/include/sys/types.h + - sys/ucontext.h: contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/x86/sys/ucontext.h + - sys/user.h: contrib/libs/glibcasm/glibc/sysdeps/unix/sysv/linux/x86/sys/user.h + - time.h: contrib/libs/glibcasm/glibc/include/time.h + - tls.h: contrib/libs/glibcasm/glibc/sysdeps/x86_64/nptl/tls.h + - unistd.h: contrib/libs/glibcasm/glibc/include/unistd.h + - unwind.h: contrib/libs/glibcasm/glibc/sysdeps/generic/unwind.h + # includes under ifdef + - bits/select2.h: contrib/libs/glibcasm/dummy.h + - bits/setjmp2.h: contrib/libs/glibcasm/dummy.h + - bits/socket2.h: contrib/libs/glibcasm/dummy.h + - bits/socket-constants.h: contrib/libs/glibcasm/dummy.h + - bits/stdlib.h: contrib/libs/glibcasm/dummy.h + - bits/stdlib-ldbl.h: contrib/libs/glibcasm/dummy.h + - bits/string_fortified.h: contrib/libs/glibcasm/dummy.h + - bits/strings_fortified.h: contrib/libs/glibcasm/dummy.h + - bits/struct_stat_time64_helper.h: contrib/libs/glibcasm/dummy.h + - bits/unistd.h: contrib/libs/glibcasm/dummy.h + - dl-cet.h: contrib/libs/glibcasm/dummy.h + - dl-mman.h: contrib/libs/glibcasm/dummy.h + - dl-unistd.h: contrib/libs/glibcasm/dummy.h + - elf/dl-tunables.h: contrib/libs/glibcasm/dummy.h + - linux/close_range.h: contrib/libs/glibcasm/dummy.h + - sysdeps/i386/dl-procinfo.c: contrib/libs/glibcasm/dummy.h + - sysdeps/generic/hp-timing.h: contrib/libs/glibcasm/dummy.h + - sysdeps/unix/sysv/linux/bits/pthread_stack_min-dynamic.h: contrib/libs/glibcasm/dummy.h + - sysdeps/unix/sysv/linux/sys/syscall.h: contrib/libs/glibcasm/dummy.h + +- source_filter: "^contrib/libs/libunwind/include/unwind.h" + includes: + - stdint.h: + - contrib/libs/glibcasm/glibc/include/stdint.h + - contrib/libs/cxxsupp/libcxx/include/stdint.h + +- source_filter: "^contrib/libs/cxxsupp/libcxx/include/inttypes.h" + includes: + - stdint.h: + - contrib/libs/glibcasm/glibc/include/stdint.h + - contrib/libs/cxxsupp/libcxx/include/stdint.h + +- source_filter: "^contrib/tools/bison/bison/data" + includes: + - position.hh diff --git a/build/sysincl/nds32.yml b/build/sysincl/nds32.yml new file mode 100644 index 00000000000..c8842c993dc --- /dev/null +++ b/build/sysincl/nds32.yml @@ -0,0 +1,2 @@ +- includes: + - nds_intrinsic.h diff --git a/build/sysincl/newlib.yml b/build/sysincl/newlib.yml new file mode 100644 index 00000000000..f141075339f --- /dev/null +++ b/build/sysincl/newlib.yml @@ -0,0 +1,5 @@ +- includes: + - _ansi.h + - bits/functexcept.h + - reent.h + - sys/features.h diff --git a/build/sysincl/nvidia.yml b/build/sysincl/nvidia.yml new file mode 100644 index 00000000000..9a185594d4e --- /dev/null +++ b/build/sysincl/nvidia.yml @@ -0,0 +1,69 @@ +# build/platform/cuda (include/ and extras/CUPTI/include/) +- includes: + - cooperative_groups.h + - cooperative_groups/reduce.h + - cuComplex.h + # Though cub is provided as a part of CUDA HPC SDK, + # we would like to be updatable independently. + # Hence we are using it directly from Arcadia. + # This sysincl enforces such usage. + - cub/cub.cuh: contrib/libs/nvidia/cub/cub/cub.cuh + - cublas.h + - cublasLt.h + - cublas_v2.h + - cuda.h + - cudaProfiler.h + - cudaTypedefs.h + - cuda_bf16.h + - cuda_fp16.h + - cuda_gl_interop.h + - cuda_occupancy.h + - cuda_profiler_api.h + - cuda_runtime.h + - cuda_runtime_api.h + - cufft.h + - cufftXt.h + - cupti.h + - curand.h + - curand_kernel.h + - curand_mtgp32_host.h + - curand_mtgp32dc_p_11213.h + - cusolverDn.h + - cusolverSp.h + - cusparse.h + - cusparseLt.h + - device_atomic_functions.h + - device_types.h + - driver_types.h + - host_defines.h + - library_types.h + - math_constants.h + - nvrtc.h + - nvToolsExtCuda.h + - npp.h + - nppi.h + - nvToolsExt.h + - surface_types.h + - texture_types.h + - vector_types.h + # Though thrust is provided as a part of CUDA HPC SDK, + # we would like to be updatable independently. + # Hence we are using it directly from Arcadia. + # This sysincl enforces such usage. + - thrust/iterator/iterator_traits.h: contrib/libs/nvidia/thrust/thrust/iterator/iterator_traits.h + - thrust/iterator/iterator_facade.h: contrib/libs/nvidia/thrust/thrust/iterator/iterator_facade.h + - thrust/system/cuda/detail/core/triple_chevron_launch.h: contrib/libs/nvidia/thrust/thrust/system/cuda/detail/core/triple_chevron_launch.h + - thrust/version.h: contrib/libs/nvidia/thrust/thrust/version.h +# These headers should be provided by TensorRT. +# Proper solution must be found in DTCC-171 +- source_filter: "^contrib/libs/tf/.*" + includes: + - NvInfer.h + - NvInferPlugin.h +# Add support nvrtc +- source_filter: "^contrib/libs/nvidia/cutlass/.*" + includes: + - cuda/std/cassert + - cuda/std/cmath + - cuda/std/cstdint + - mma.h diff --git a/build/sysincl/opensource.yml b/build/sysincl/opensource.yml new file mode 100644 index 00000000000..b7f35276483 --- /dev/null +++ b/build/sysincl/opensource.yml @@ -0,0 +1,5 @@ +# libimagequant is GPL-licensed. +# We would like to prevent our open source projects from depending on GPL-licensed software. +- source_filter: "^contrib/python/Pillow/py3" + includes: + - libimagequant.h diff --git a/build/sysincl/python.yml b/build/sysincl/python.yml new file mode 100644 index 00000000000..32e8d7ff765 --- /dev/null +++ b/build/sysincl/python.yml @@ -0,0 +1,104 @@ +- source_filter: "^(?!(contrib/tools/python|library/python/runtime|library/python/symbols))" + includes: + - Python-ast.h + - Python.h + - abstract.h + - accu.h + - asdl.h + - bltinmodule.h + - boolobject.h + - bufferobject.h + - bytearrayobject.h + - bytes_methods.h + - bytesobject.h + - cStringIO.h + - cellobject.h + - ceval.h + - classobject.h + - cobject.h + - codecs.h + - compile.h + - complexobject.h + - config_platform.h + - datetime.h + - descrobject.h + - dictobject.h + - dtoa.h + - dynamic_annotations.h + - enumobject.h + - errcode.h + - fileobject.h + - floatobject.h + - frameobject.h + - funcobject.h + - genobject.h + - graminit.h + - grammar.h + - import.h + - intobject.h + - intrcheck.h + - iterobject.h + - listobject.h + - longintrepr.h + - longobject.h + - marshal.h + - memoryobject.h + - metagrammar.h + - methodobject.h + - modsupport.h + - moduleobject.h + - namespaceobject.h + - object.h + - objimpl.h + - odictobject.h + - opcode.h + - osdefs.h + - osmodule.h + - parsetok.h + - patchlevel.h + - pgen.h + - pgenheaders.h + - py_curses.h + - pyarena.h + - pyatomic.h + - pycapsule.h + - pyconfig.h + - pyctype.h + - pydebug.h + - pydtrace.h + - pyerrors.h + - pyexpat.h + - pyfpe.h + - pygetopt.h + - pyhash.h + - pylifecycle.h + - pymacconfig.h + - pymacro.h + - pymactoolbox.h + - pymath.h + - pymem.h + - pyport.h + - pystate.h + - pystrcmp.h + - pystrhex.h + - pystrtod.h + - pythonrun.h + - pythread.h + - pytime.h + - rangeobject.h + - setobject.h + - sliceobject.h + - stringobject.h + - structmember.h + - structseq.h + - symtable.h + - sysmodule.h + - timefuncs.h + - token.h + - traceback.h + - tupleobject.h + - typeslots.h + - ucnhash.h + - unicodeobject.h + - warnings.h + - weakrefobject.h diff --git a/build/sysincl/stl-to-libcxx.yml b/build/sysincl/stl-to-libcxx.yml new file mode 100644 index 00000000000..bb91701fbad --- /dev/null +++ b/build/sysincl/stl-to-libcxx.yml @@ -0,0 +1,449 @@ +# libc & stl common headers should be resolved to either +# * system libc (e.g. nothing in our repo) +# * system libc++ (e.g. nothing in our repo) +# * libcxx +# * musl +# or some combination of them depending on the build flags. + +# We want musl to resolve itself without these sysincls, but its test must have them +# When these resolved in pure C modules, their own includes should be also resolved via sysincl (the list at the bottom) +# If you add something here, please also add include to it into build/sysincl/check/cxx.c for proper testing +- source_filter: "^(?!(contrib/libs/musl|contrib/tools/yasm)).*|^contrib/libs/musl/tests" + includes: + - complex.h: contrib/libs/cxxsupp/libcxx/include/complex.h + - ctype.h: contrib/libs/cxxsupp/libcxx/include/ctype.h + - errno.h: contrib/libs/cxxsupp/libcxx/include/errno.h + - fenv.h: contrib/libs/cxxsupp/libcxx/include/fenv.h + - float.h: contrib/libs/cxxsupp/libcxx/include/float.h + - inttypes.h: contrib/libs/cxxsupp/libcxx/include/inttypes.h + - limits.h: contrib/libs/cxxsupp/libcxx/include/limits.h + - locale.h: contrib/libs/cxxsupp/libcxx/include/locale.h + - math.h: contrib/libs/cxxsupp/libcxx/include/math.h + - stdatomic.h: contrib/libs/cxxsupp/libcxx/include/stdatomic.h + - setjmp.h: contrib/libs/cxxsupp/libcxx/include/setjmp.h + - stdbool.h: contrib/libs/cxxsupp/libcxx/include/stdbool.h + - stddef.h: contrib/libs/cxxsupp/libcxx/include/stddef.h + - stdint.h: contrib/libs/cxxsupp/libcxx/include/stdint.h + - stdio.h: contrib/libs/cxxsupp/libcxx/include/stdio.h + - stdlib.h: contrib/libs/cxxsupp/libcxx/include/stdlib.h + - string.h: contrib/libs/cxxsupp/libcxx/include/string.h + - tgmath.h: contrib/libs/cxxsupp/libcxx/include/tgmath.h + - wchar.h: contrib/libs/cxxsupp/libcxx/include/wchar.h + - wctype.h: contrib/libs/cxxsupp/libcxx/include/wctype.h + +- includes: + - cxxabi.h: + - contrib/libs/cxxsupp/libcxxrt/include/cxxabi.h + - omp.h: + - contrib/libs/cxxsupp/openmp/omp.h + - unwind.h: + - contrib/libs/cxxsupp/libcxx/include/unwind.h + - contrib/libs/cxxsupp/libcxxrt/unwind.h + - contrib/libs/libunwind/include/unwind.h + +- source_filter: "^contrib/libs/cxxsupp/libcxxabi/" + includes: + - cxxabi.h: contrib/libs/cxxsupp/libcxxabi/include/cxxabi.h + +- includes: + - algorithm: contrib/libs/cxxsupp/libcxx/include/algorithm + - any: contrib/libs/cxxsupp/libcxx/include/any + - array: contrib/libs/cxxsupp/libcxx/include/array + - atomic: contrib/libs/cxxsupp/libcxx/include/atomic + - bit: contrib/libs/cxxsupp/libcxx/include/bit + - bitset: contrib/libs/cxxsupp/libcxx/include/bitset + - cassert: contrib/libs/cxxsupp/libcxx/include/cassert + - ccomplex: contrib/libs/cxxsupp/libcxx/include/ccomplex + - cctype: contrib/libs/cxxsupp/libcxx/include/cctype + - cerrno: contrib/libs/cxxsupp/libcxx/include/cerrno + - cfenv: contrib/libs/cxxsupp/libcxx/include/cfenv + - cfloat: contrib/libs/cxxsupp/libcxx/include/cfloat + - charconv: contrib/libs/cxxsupp/libcxx/include/charconv + - chrono: contrib/libs/cxxsupp/libcxx/include/chrono + - cinttypes: contrib/libs/cxxsupp/libcxx/include/cinttypes + - ciso646: contrib/libs/cxxsupp/libcxx/include/ciso646 + - climits: contrib/libs/cxxsupp/libcxx/include/climits + - clocale: contrib/libs/cxxsupp/libcxx/include/clocale + - cmath: contrib/libs/cxxsupp/libcxx/include/cmath + - codecvt: contrib/libs/cxxsupp/libcxx/include/codecvt + - compare: contrib/libs/cxxsupp/libcxx/include/compare + - complex: contrib/libs/cxxsupp/libcxx/include/complex + - concepts: contrib/libs/cxxsupp/libcxx/include/concepts + - condition_variable: contrib/libs/cxxsupp/libcxx/include/condition_variable + - coroutine: contrib/libs/cxxsupp/libcxx/include/coroutine + - csetjmp: contrib/libs/cxxsupp/libcxx/include/csetjmp + - csignal: contrib/libs/cxxsupp/libcxx/include/csignal + - cstdarg: contrib/libs/cxxsupp/libcxx/include/cstdarg + - cstdbool: contrib/libs/cxxsupp/libcxx/include/cstdbool + - cstddef: contrib/libs/cxxsupp/libcxx/include/cstddef + - cstdint: contrib/libs/cxxsupp/libcxx/include/cstdint + - cstdio: contrib/libs/cxxsupp/libcxx/include/cstdio + - cstdlib: contrib/libs/cxxsupp/libcxx/include/cstdlib + - cstring: contrib/libs/cxxsupp/libcxx/include/cstring + - ctgmath: contrib/libs/cxxsupp/libcxx/include/ctgmath + - ctime: contrib/libs/cxxsupp/libcxx/include/ctime + - cwchar: contrib/libs/cxxsupp/libcxx/include/cwchar + - cwctype: contrib/libs/cxxsupp/libcxx/include/cwctype + - deque: contrib/libs/cxxsupp/libcxx/include/deque + - exception: contrib/libs/cxxsupp/libcxx/include/exception + - filesystem: contrib/libs/cxxsupp/libcxx/include/filesystem + - forward_list: contrib/libs/cxxsupp/libcxx/include/forward_list + - fstream: contrib/libs/cxxsupp/libcxx/include/fstream + - functional: contrib/libs/cxxsupp/libcxx/include/functional + - future: contrib/libs/cxxsupp/libcxx/include/future + - initializer_list: contrib/libs/cxxsupp/libcxx/include/initializer_list + - iomanip: contrib/libs/cxxsupp/libcxx/include/iomanip + - ios: contrib/libs/cxxsupp/libcxx/include/ios + - iosfwd: contrib/libs/cxxsupp/libcxx/include/iosfwd + - iostream: contrib/libs/cxxsupp/libcxx/include/iostream + - istream: contrib/libs/cxxsupp/libcxx/include/istream + - iterator: contrib/libs/cxxsupp/libcxx/include/iterator + - limits: contrib/libs/cxxsupp/libcxx/include/limits + - list: contrib/libs/cxxsupp/libcxx/include/list + - locale: contrib/libs/cxxsupp/libcxx/include/locale + - map: contrib/libs/cxxsupp/libcxx/include/map + - memory: contrib/libs/cxxsupp/libcxx/include/memory + - mutex: contrib/libs/cxxsupp/libcxx/include/mutex + - new: contrib/libs/cxxsupp/libcxx/include/new + - numbers: contrib/libs/cxxsupp/libcxx/include/numbers + - numeric: contrib/libs/cxxsupp/libcxx/include/numeric + - optional: contrib/libs/cxxsupp/libcxx/include/optional + - ostream: contrib/libs/cxxsupp/libcxx/include/ostream + - queue: contrib/libs/cxxsupp/libcxx/include/queue + - random: contrib/libs/cxxsupp/libcxx/include/random + - ranges: contrib/libs/cxxsupp/libcxx/include/ranges + - ratio: contrib/libs/cxxsupp/libcxx/include/ratio + - regex: contrib/libs/cxxsupp/libcxx/include/regex + - scoped_allocator: contrib/libs/cxxsupp/libcxx/include/scoped_allocator + - set: contrib/libs/cxxsupp/libcxx/include/set + - shared_mutex: contrib/libs/cxxsupp/libcxx/include/shared_mutex + - span: contrib/libs/cxxsupp/libcxx/include/span + - sstream: contrib/libs/cxxsupp/libcxx/include/sstream + - stack: contrib/libs/cxxsupp/libcxx/include/stack + - stdexcept: contrib/libs/cxxsupp/libcxx/include/stdexcept + - stlfwd: contrib/libs/cxxsupp/libcxx/include/stlfwd + - streambuf: contrib/libs/cxxsupp/libcxx/include/streambuf + - string: contrib/libs/cxxsupp/libcxx/include/string + - string_view: contrib/libs/cxxsupp/libcxx/include/string_view + - strstream: contrib/libs/cxxsupp/libcxx/include/strstream + - system_error: contrib/libs/cxxsupp/libcxx/include/system_error + - thread: contrib/libs/cxxsupp/libcxx/include/thread + - tuple: contrib/libs/cxxsupp/libcxx/include/tuple + - typeindex: contrib/libs/cxxsupp/libcxx/include/typeindex + - typeinfo: contrib/libs/cxxsupp/libcxx/include/typeinfo + - type_traits: contrib/libs/cxxsupp/libcxx/include/type_traits + - unordered_map: contrib/libs/cxxsupp/libcxx/include/unordered_map + - unordered_set: contrib/libs/cxxsupp/libcxx/include/unordered_set + - use_ansi.h: contrib/libs/cxxsupp/libcxx/include/use_ansi.h + - utility: contrib/libs/cxxsupp/libcxx/include/utility + - valarray: contrib/libs/cxxsupp/libcxx/include/valarray + - variant: contrib/libs/cxxsupp/libcxx/include/variant + - vector: contrib/libs/cxxsupp/libcxx/include/vector + - version: contrib/libs/cxxsupp/libcxx/include/version + +# Though these are headers provided by libcxx, we do not want to allow them to be included. +# We are using non-existent filename to generate error instead, as there is no specific syntax for this case. +- includes: + - ext/hash_map: DO_NOT_INCLUDE_NON_STANDARD_EXT_HASH_MAP + - ext/hash_set: DO_NOT_INCLUDE_NON_STANDARD_EXT_HASH_SET + - experimental/any: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_ANY + - experimental/chrono: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_CHRONO + - experimental/filesystem: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_FILESYSTEM + - experimental/numeric: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_NUMERIC + - experimental/optional: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_OPTIONAL + - experimental/ratio: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_RATIO + - experimental/source_location: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_SOURCE_LOCATION + - experimental/string_view: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_STRING_VIEW + - experimental/system_error: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_SYSTEM_ERROR + - experimental/tuple: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_TUPLE + + # TODO: Forbid including <experimental/coroutine> upon migration to clang14 + - experimental/coroutine: contrib/libs/cxxsupp/libcxx/include/experimental/coroutine + +- source_filter: "^contrib/restricted/boost" + includes: + - ../include/fenv.h: contrib/libs/cxxsupp/libcxx/include/fenv.h + +# This includes all headers needed to resolve includes in c-headers from libcxx listed avove +- includes: + - __assert: contrib/libs/cxxsupp/libcxx/include/__assert + - __availability: contrib/libs/cxxsupp/libcxx/include/__availability + - __bsd_locale_fallbacks.h: contrib/libs/cxxsupp/libcxx/include/__bsd_locale_fallbacks.h + - __locale: contrib/libs/cxxsupp/libcxx/include/__locale + - __bit_reference: contrib/libs/cxxsupp/libcxx/include/__bit_reference + - __bits: contrib/libs/cxxsupp/libcxx/include/__bits + - __config: contrib/libs/cxxsupp/libcxx/include/__config + - __debug: contrib/libs/cxxsupp/libcxx/include/__debug + - __errc: contrib/libs/cxxsupp/libcxx/include/__errc + - __locale: contrib/libs/cxxsupp/libcxx/include/__locale + - __mbstate_t.h: contrib/libs/cxxsupp/libcxx/include/__mbstate_t.h + - __mutex_base: contrib/libs/cxxsupp/libcxx/include/__mutex_base + - __string: contrib/libs/cxxsupp/libcxx/include/__string + - __threading_support: contrib/libs/cxxsupp/libcxx/include/__threading_support + - __tuple: contrib/libs/cxxsupp/libcxx/include/__tuple + - __undef_macros: contrib/libs/cxxsupp/libcxx/include/__undef_macros + - __wrappers_config: contrib/libs/cxxsupp/libcxx/include/__wrappers_config + - __algorithm/adjacent_find.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/adjacent_find.h + - __algorithm/all_of.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/all_of.h + - __algorithm/any_of.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/any_of.h + - __algorithm/binary_search.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h + - __algorithm/clamp.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/clamp.h + - __algorithm/comp.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/comp.h + - __algorithm/comp_ref_type.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/comp_ref_type.h + - __algorithm/copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h + - __algorithm/copy_backward.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h + - __algorithm/copy_if.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_if.h + - __algorithm/copy_n.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h + - __algorithm/count.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h + - __algorithm/count_if.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/count_if.h + - __algorithm/equal.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/equal.h + - __algorithm/equal_range.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/equal_range.h + - __algorithm/fill.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/fill.h + - __algorithm/fill_n.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/fill_n.h + - __algorithm/find.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h + - __algorithm/find_end.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h + - __algorithm/find_first_of.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/find_first_of.h + - __algorithm/find_if.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if.h + - __algorithm/find_if_not.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if_not.h + - __algorithm/for_each.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/for_each.h + - __algorithm/for_each_n.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/for_each_n.h + - __algorithm/generate.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/generate.h + - __algorithm/generate_n.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/generate_n.h + - __algorithm/half_positive.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/half_positive.h + - __algorithm/in_fun_result.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/in_fun_result.h + - __algorithm/in_in_out_result.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/in_in_out_result.h + - __algorithm/in_in_result.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/in_in_result.h + - __algorithm/in_out_out_result.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/in_out_out_result.h + - __algorithm/in_out_result.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/in_out_result.h + - __algorithm/includes.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/includes.h + - __algorithm/inplace_merge.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h + - __algorithm/is_heap.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h + - __algorithm/is_heap_until.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h + - __algorithm/is_partitioned.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/is_partitioned.h + - __algorithm/is_permutation.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/is_permutation.h + - __algorithm/is_sorted.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h + - __algorithm/is_sorted_until.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h + - __algorithm/iter_swap.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/iter_swap.h + - __algorithm/lexicographical_compare.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/lexicographical_compare.h + - __algorithm/lower_bound.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/lower_bound.h + - __algorithm/make_heap.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/make_heap.h + - __algorithm/max.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h + - __algorithm/max_element.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h + - __algorithm/merge.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/merge.h + - __algorithm/min.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h + - __algorithm/min_element.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h + - __algorithm/minmax.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h + - __algorithm/minmax_element.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h + - __algorithm/mismatch.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/mismatch.h + - __algorithm/move.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h + - __algorithm/move_backward.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/move_backward.h + - __algorithm/next_permutation.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/next_permutation.h + - __algorithm/none_of.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/none_of.h + - __algorithm/nth_element.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/nth_element.h + - __algorithm/partial_sort.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/partial_sort.h + - __algorithm/partial_sort_copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/partial_sort_copy.h + - __algorithm/partition.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/partition.h + - __algorithm/partition_copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/partition_copy.h + - __algorithm/partition_point.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/partition_point.h + - __algorithm/pop_heap.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/pop_heap.h + - __algorithm/prev_permutation.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/prev_permutation.h + - __algorithm/push_heap.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/push_heap.h + - __algorithm/ranges_min_element.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min_element.h + - __algorithm/ranges_swap_ranges.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_swap_ranges.h + - __algorithm/remove.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/remove.h + - __algorithm/remove_copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/remove_copy.h + - __algorithm/remove_copy_if.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/remove_copy_if.h + - __algorithm/remove_if.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/remove_if.h + - __algorithm/replace.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/replace.h + - __algorithm/replace_copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/replace_copy.h + - __algorithm/replace_copy_if.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/replace_copy_if.h + - __algorithm/replace_if.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/replace_if.h + - __algorithm/reverse.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/reverse.h + - __algorithm/reverse_copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/reverse_copy.h + - __algorithm/rotate.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/rotate.h + - __algorithm/rotate_copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/rotate_copy.h + - __algorithm/sample.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/sample.h + - __algorithm/search.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h + - __algorithm/search_n.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h + - __algorithm/set_difference.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/set_difference.h + - __algorithm/set_intersection.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/set_intersection.h + - __algorithm/set_symmetric_difference.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/set_symmetric_difference.h + - __algorithm/set_union.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/set_union.h + - __algorithm/shift_left.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/shift_left.h + - __algorithm/shift_right.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/shift_right.h + - __algorithm/shuffle.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h + - __algorithm/sift_down.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/sift_down.h + - __algorithm/sort.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h + - __algorithm/sort_heap.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/sort_heap.h + - __algorithm/stable_partition.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h + - __algorithm/stable_sort.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h + - __algorithm/swap_ranges.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/swap_ranges.h + - __algorithm/transform.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/transform.h + - __algorithm/unique.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/unique.h + - __algorithm/unique_copy.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/unique_copy.h + - __algorithm/unwrap_iter.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_iter.h + - __algorithm/upper_bound.h: contrib/libs/cxxsupp/libcxx/include/__algorithm/upper_bound.h + - __bit/bit_cast.h: contrib/libs/cxxsupp/libcxx/include/__bit/bit_cast.h + - __bit/byteswap.h: contrib/libs/cxxsupp/libcxx/include/__bit/byteswap.h + - __chrono/calendar.h: contrib/libs/cxxsupp/libcxx/include/__chrono/calendar.h + - __chrono/convert_to_timespec.h: contrib/libs/cxxsupp/libcxx/include/__chrono/convert_to_timespec.h + - __chrono/duration.h: contrib/libs/cxxsupp/libcxx/include/__chrono/duration.h + - __chrono/file_clock.h: contrib/libs/cxxsupp/libcxx/include/__chrono/file_clock.h + - __chrono/high_resolution_clock.h: contrib/libs/cxxsupp/libcxx/include/__chrono/high_resolution_clock.h + - __chrono/steady_clock.h: contrib/libs/cxxsupp/libcxx/include/__chrono/steady_clock.h + - __chrono/system_clock.h: contrib/libs/cxxsupp/libcxx/include/__chrono/system_clock.h + - __chrono/time_point.h: contrib/libs/cxxsupp/libcxx/include/__chrono/time_point.h + - __compare/common_comparison_category.h: contrib/libs/cxxsupp/libcxx/include/__compare/common_comparison_category.h + - __compare/compare_partial_order_fallback.h: contrib/libs/cxxsupp/libcxx/include/__compare/compare_partial_order_fallback.h + - __compare/compare_strong_order_fallback.h: contrib/libs/cxxsupp/libcxx/include/__compare/compare_strong_order_fallback.h + - __compare/compare_three_way.h: contrib/libs/cxxsupp/libcxx/include/__compare/compare_three_way.h + - __compare/compare_three_way_result.h: contrib/libs/cxxsupp/libcxx/include/__compare/compare_three_way_result.h + - __compare/compare_weak_order_fallback.h: contrib/libs/cxxsupp/libcxx/include/__compare/compare_weak_order_fallback.h + - __compare/is_eq.h: contrib/libs/cxxsupp/libcxx/include/__compare/is_eq.h + - __compare/ordering.h: contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h + - __compare/partial_order.h: contrib/libs/cxxsupp/libcxx/include/__compare/partial_order.h + - __compare/strong_order.h: contrib/libs/cxxsupp/libcxx/include/__compare/strong_order.h + - __compare/synth_three_way.h: contrib/libs/cxxsupp/libcxx/include/__compare/synth_three_way.h + - __compare/three_way_comparable.h: contrib/libs/cxxsupp/libcxx/include/__compare/three_way_comparable.h + - __compare/weak_order.h: contrib/libs/cxxsupp/libcxx/include/__compare/weak_order.h + - __concepts/arithmetic.h: contrib/libs/cxxsupp/libcxx/include/__concepts/arithmetic.h + - __concepts/assignable.h: contrib/libs/cxxsupp/libcxx/include/__concepts/assignable.h + - __concepts/boolean_testable.h: contrib/libs/cxxsupp/libcxx/include/__concepts/boolean_testable.h + - __concepts/class_or_enum.h: contrib/libs/cxxsupp/libcxx/include/__concepts/class_or_enum.h + - __concepts/common_reference_with.h: contrib/libs/cxxsupp/libcxx/include/__concepts/common_reference_with.h + - __concepts/common_with.h: contrib/libs/cxxsupp/libcxx/include/__concepts/common_with.h + - __concepts/constructible.h: contrib/libs/cxxsupp/libcxx/include/__concepts/constructible.h + - __concepts/convertible_to.h: contrib/libs/cxxsupp/libcxx/include/__concepts/convertible_to.h + - __concepts/copyable.h: contrib/libs/cxxsupp/libcxx/include/__concepts/copyable.h + - __concepts/derived_from.h: contrib/libs/cxxsupp/libcxx/include/__concepts/derived_from.h + - __concepts/destructible.h: contrib/libs/cxxsupp/libcxx/include/__concepts/destructible.h + - __concepts/different_from.h: contrib/libs/cxxsupp/libcxx/include/__concepts/different_from.h + - __concepts/equality_comparable.h: contrib/libs/cxxsupp/libcxx/include/__concepts/equality_comparable.h + - __concepts/invocable.h: contrib/libs/cxxsupp/libcxx/include/__concepts/invocable.h + - __concepts/movable.h: contrib/libs/cxxsupp/libcxx/include/__concepts/movable.h + - __concepts/predicate.h: contrib/libs/cxxsupp/libcxx/include/__concepts/predicate.h + - __concepts/regular.h: contrib/libs/cxxsupp/libcxx/include/__concepts/regular.h + - __concepts/relation.h: contrib/libs/cxxsupp/libcxx/include/__concepts/relation.h + - __concepts/same_as.h: contrib/libs/cxxsupp/libcxx/include/__concepts/same_as.h + - __concepts/semiregular.h: contrib/libs/cxxsupp/libcxx/include/__concepts/semiregular.h + - __concepts/swappable.h: contrib/libs/cxxsupp/libcxx/include/__concepts/swappable.h + - __concepts/totally_ordered.h: contrib/libs/cxxsupp/libcxx/include/__concepts/totally_ordered.h + - __functional/binary_function.h: contrib/libs/cxxsupp/libcxx/include/__functional/binary_function.h + - __functional/binary_negate.h: contrib/libs/cxxsupp/libcxx/include/__functional/binary_negate.h + - __functional/bind.h: contrib/libs/cxxsupp/libcxx/include/__functional/bind.h + - __functional/bind_back.h: contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h + - __functional/bind_front.h: contrib/libs/cxxsupp/libcxx/include/__functional/bind_front.h + - __functional/binder1st.h: contrib/libs/cxxsupp/libcxx/include/__functional/binder1st.h + - __functional/binder2nd.h: contrib/libs/cxxsupp/libcxx/include/__functional/binder2nd.h + - __functional/compose.h: contrib/libs/cxxsupp/libcxx/include/__functional/compose.h + - __functional/default_searcher.h: contrib/libs/cxxsupp/libcxx/include/__functional/default_searcher.h + - __functional/function.h: contrib/libs/cxxsupp/libcxx/include/__functional/function.h + - __functional/hash.h: contrib/libs/cxxsupp/libcxx/include/__functional/hash.h + - __functional/identity.h: contrib/libs/cxxsupp/libcxx/include/__functional/identity.h + - __functional/invoke.h: contrib/libs/cxxsupp/libcxx/include/__functional/invoke.h + - __functional/mem_fn.h: contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h + - __functional/mem_fun_ref.h: contrib/libs/cxxsupp/libcxx/include/__functional/mem_fun_ref.h + - __functional/not_fn.h: contrib/libs/cxxsupp/libcxx/include/__functional/not_fn.h + - __functional/operations.h: contrib/libs/cxxsupp/libcxx/include/__functional/operations.h + - __functional/perfect_forward.h: contrib/libs/cxxsupp/libcxx/include/__functional/perfect_forward.h + - __functional/pointer_to_binary_function.h: contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_binary_function.h + - __functional/pointer_to_unary_function.h: contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_unary_function.h + - __functional/ranges_operations.h: contrib/libs/cxxsupp/libcxx/include/__functional/ranges_operations.h + - __functional/reference_wrapper.h: contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h + - __functional/unary_function.h: contrib/libs/cxxsupp/libcxx/include/__functional/unary_function.h + - __functional/unary_negate.h: contrib/libs/cxxsupp/libcxx/include/__functional/unary_negate.h + - __functional/unwrap_ref.h: contrib/libs/cxxsupp/libcxx/include/__functional/unwrap_ref.h + - __functional/weak_result_type.h: contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h + - __ios/fpos.h: contrib/libs/cxxsupp/libcxx/include/__ios/fpos.h + - __iterator/access.h: contrib/libs/cxxsupp/libcxx/include/__iterator/access.h + - __iterator/advance.h: contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h + - __iterator/back_insert_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/back_insert_iterator.h + - __iterator/common_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h + - __iterator/concepts.h: contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h + - __iterator/counted_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h + - __iterator/data.h: contrib/libs/cxxsupp/libcxx/include/__iterator/data.h + - __iterator/default_sentinel.h: contrib/libs/cxxsupp/libcxx/include/__iterator/default_sentinel.h + - __iterator/distance.h: contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h + - __iterator/empty.h: contrib/libs/cxxsupp/libcxx/include/__iterator/empty.h + - __iterator/erase_if_container.h: contrib/libs/cxxsupp/libcxx/include/__iterator/erase_if_container.h + - __iterator/front_insert_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/front_insert_iterator.h + - __iterator/incrementable_traits.h: contrib/libs/cxxsupp/libcxx/include/__iterator/incrementable_traits.h + - __iterator/indirectly_comparable.h: contrib/libs/cxxsupp/libcxx/include/__iterator/indirectly_comparable.h + - __iterator/insert_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/insert_iterator.h + - __iterator/istream_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/istream_iterator.h + - __iterator/istreambuf_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/istreambuf_iterator.h + - __iterator/iter_move.h: contrib/libs/cxxsupp/libcxx/include/__iterator/iter_move.h + - __iterator/iter_swap.h: contrib/libs/cxxsupp/libcxx/include/__iterator/iter_swap.h + - __iterator/iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/iterator.h + - __iterator/iterator_traits.h: contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h + - __iterator/move_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/move_iterator.h + - __iterator/next.h: contrib/libs/cxxsupp/libcxx/include/__iterator/next.h + - __iterator/ostream_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/ostream_iterator.h + - __iterator/ostreambuf_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h + - __iterator/permutable.h: contrib/libs/cxxsupp/libcxx/include/__iterator/permutable.h + - __iterator/prev.h: contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h + - __iterator/projected.h: contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h + - __iterator/readable_traits.h: contrib/libs/cxxsupp/libcxx/include/__iterator/readable_traits.h + - __iterator/reverse_access.h: contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_access.h + - __iterator/reverse_iterator.h: contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h + - __iterator/size.h: contrib/libs/cxxsupp/libcxx/include/__iterator/size.h + - __iterator/unreachable_sentinel.h: contrib/libs/cxxsupp/libcxx/include/__iterator/unreachable_sentinel.h + - __iterator/wrap_iter.h: contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h + - __memory/addressof.h: contrib/libs/cxxsupp/libcxx/include/__memory/addressof.h + - __memory/allocation_guard.h: contrib/libs/cxxsupp/libcxx/include/__memory/allocation_guard.h + - __memory/allocator.h: contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h + - __memory/allocator_arg_t.h: contrib/libs/cxxsupp/libcxx/include/__memory/allocator_arg_t.h + - __memory/allocator_traits.h: contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h + - __memory/auto_ptr.h: contrib/libs/cxxsupp/libcxx/include/__memory/auto_ptr.h + - __memory/compressed_pair.h: contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h + - __memory/concepts.h: contrib/libs/cxxsupp/libcxx/include/__memory/concepts.h + - __memory/construct_at.h: contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h + - __memory/pointer_traits.h: contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h + - __memory/ranges_construct_at.h: contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h + - __memory/ranges_uninitialized_algorithms.h: contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h + - __memory/raw_storage_iterator.h: contrib/libs/cxxsupp/libcxx/include/__memory/raw_storage_iterator.h + - __memory/shared_ptr.h: contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h + - __memory/temporary_buffer.h: contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h + - __memory/uninitialized_algorithms.h: contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h + - __memory/unique_ptr.h: contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h + - __memory/uses_allocator.h: contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h + - __memory/voidify.h: contrib/libs/cxxsupp/libcxx/include/__memory/voidify.h + - __random/log2.h: contrib/libs/cxxsupp/libcxx/include/__random/log2.h + - __random/uniform_int_distribution.h: contrib/libs/cxxsupp/libcxx/include/__random/uniform_int_distribution.h + - __ranges/access.h: contrib/libs/cxxsupp/libcxx/include/__ranges/access.h + - __ranges/concepts.h: contrib/libs/cxxsupp/libcxx/include/__ranges/concepts.h + - __ranges/dangling.h: contrib/libs/cxxsupp/libcxx/include/__ranges/dangling.h + - __ranges/data.h: contrib/libs/cxxsupp/libcxx/include/__ranges/data.h + - __ranges/enable_borrowed_range.h: contrib/libs/cxxsupp/libcxx/include/__ranges/enable_borrowed_range.h + - __ranges/enable_view.h: contrib/libs/cxxsupp/libcxx/include/__ranges/enable_view.h + - __ranges/size.h: contrib/libs/cxxsupp/libcxx/include/__ranges/size.h + - __support/ibm/locale_mgmt_zos.h: contrib/libs/cxxsupp/libcxx/include/__support/ibm/locale_mgmt_zos.h + - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h + - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h + - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h + - __support/xlocale/__nop_locale_mgmt.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__nop_locale_mgmt.h + - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h + - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h + - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h + - __support/xlocale/__posix_l_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h + - __support/xlocale/__strtonum_fallback.h: contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h + - __thread/poll_with_backoff.h: contrib/libs/cxxsupp/libcxx/include/__thread/poll_with_backoff.h + - __thread/timed_backoff_policy.h: contrib/libs/cxxsupp/libcxx/include/__thread/timed_backoff_policy.h + - __utility/as_const.h: contrib/libs/cxxsupp/libcxx/include/__utility/as_const.h + - __utility/auto_cast.h: contrib/libs/cxxsupp/libcxx/include/__utility/auto_cast.h + - __utility/cmp.h: contrib/libs/cxxsupp/libcxx/include/__utility/cmp.h + - __utility/declval.h: contrib/libs/cxxsupp/libcxx/include/__utility/declval.h + - __utility/exchange.h: contrib/libs/cxxsupp/libcxx/include/__utility/exchange.h + - __utility/forward.h: contrib/libs/cxxsupp/libcxx/include/__utility/forward.h + - __utility/in_place.h: contrib/libs/cxxsupp/libcxx/include/__utility/in_place.h + - __utility/integer_sequence.h: contrib/libs/cxxsupp/libcxx/include/__utility/integer_sequence.h + - __utility/move.h: contrib/libs/cxxsupp/libcxx/include/__utility/move.h + - __utility/pair.h: contrib/libs/cxxsupp/libcxx/include/__utility/pair.h + - __utility/piecewise_construct.h: contrib/libs/cxxsupp/libcxx/include/__utility/piecewise_construct.h + - __utility/priority_tag.h: contrib/libs/cxxsupp/libcxx/include/__utility/priority_tag.h + - __utility/rel_ops.h: contrib/libs/cxxsupp/libcxx/include/__utility/rel_ops.h + - __utility/swap.h: contrib/libs/cxxsupp/libcxx/include/__utility/swap.h + - __utility/to_underlying.h: contrib/libs/cxxsupp/libcxx/include/__utility/to_underlying.h + - __utility/transaction.h: contrib/libs/cxxsupp/libcxx/include/__utility/transaction.h + - __utility/unreachable.h: contrib/libs/cxxsupp/libcxx/include/__utility/unreachable.h + - __variant/monostate.h: contrib/libs/cxxsupp/libcxx/include/__variant/monostate.h diff --git a/build/sysincl/stl-to-nothing.yml b/build/sysincl/stl-to-nothing.yml new file mode 100644 index 00000000000..2d03265c863 --- /dev/null +++ b/build/sysincl/stl-to-nothing.yml @@ -0,0 +1,148 @@ +# libc & stl common headers should be resolved to either +# * system libc (e.g. nothing in our repo) +# * system libc++ (e.g. nothing in our repo) +# * libcxx +# * musl +# or some combination of them depending on the build flags. + +# We want musl to resolve itself without these sysincls, but its test must have them +- source_filter: "^(?!contrib/libs/musl).*|^contrib/libs/musl/tests" + includes: + - complex.h + - ctype.h + - errno.h + - float.h + - inttypes.h + - limits.h + - locale.h + - math.h + - setjmp.h + - stdbool.h + - stddef.h + - stdint.h + - stdio.h + - stdlib.h + - string.h + - tgmath.h + - wchar.h + - wctype.h + +- includes: + - __config + - __undef_macros + - algorithm + - any + - array + - atomic + - bit + - bitset + - cassert + - ccomplex + - cctype + - cerrno + - cfenv + - cfloat + - charconv + - chrono + - cinttypes + - ciso646 + - climits + - clocale + - cmath + - codecvt + - compare + - complex + - concepts + - condition_variable + - coroutine + - csetjmp + - csignal + - cstdarg + - cstdbool + - cstddef + - cstdint + - cstdio + - cstdlib + - cstring + - ctgmath + - ctime + - cwchar + - cwctype + - cxxabi.h + - deque + - exception + - filesystem + - forward_list + - fstream + - functional + - future + - initializer_list + - iomanip + - ios + - iosfwd + - iostream + - istream + - iterator + - limits + - list + - locale + - map + - memory + - mutex + - new + - numbers + - numeric + - optional + - ostream + - queue + - random + - ranges + - ratio + - regex + - scoped_allocator + - set + - shared_mutex + - span + - sstream + - stack + - stdexcept + - streambuf + - string + - string_view + - strstream + - system_error + - thread + - tuple + - typeindex + - typeinfo + - type_traits + - unordered_map + - unordered_set + - use_ansi.h + - utility + - valarray + - variant + - vector + - version + - unwind.h: + - contrib/libs/libunwind/include/unwind.h + + +# Though these are headers provided by libcxx, we do not want to allow them to be included. +# We are using non-existent filename to generate error instead, as there is no specific syntax for this case. +- includes: + - ext/hash_map: DO_NOT_INCLUDE_NON_STANDARD_EXT_HASH_MAP + - ext/hash_set: DO_NOT_INCLUDE_NON_STANDARD_EXT_HASH_SET + - experimental/any: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_ANY + - experimental/chrono: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_CHRONO + - experimental/filesystem: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_FILESYSTEM + - experimental/numeric: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_NUMERIC + - experimental/optional: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_OPTIONAL + - experimental/ratio: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_RATIO + - experimental/source_location: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_SOURCE_LOCATION + - experimental/string_view: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_STRING_VIEW + - experimental/system_error: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_SYSTEM_ERROR + - experimental/tuple: DO_NOT_INCLUDE_NON_STANDARD_EXPERIMENTAL_TUPLE + + # TODO: Forbid including <experimental/coroutine> upon migration to clang14 + - experimental/coroutine diff --git a/build/sysincl/swig-to-nothing.yml b/build/sysincl/swig-to-nothing.yml new file mode 100644 index 00000000000..1d3f9873716 --- /dev/null +++ b/build/sysincl/swig-to-nothing.yml @@ -0,0 +1,235 @@ +- includes: +# (cd $S/contrib/tools/swig/Lib; find * '(' -not -path '*/*' -or -path 'typemaps/*' ')' -and '(' -name '*.i' -or -name '*.swg' ')' ) | awk '{print " - "$0}' + - allkw.swg + - attribute.i + - carrays.i + - cdata.i + - cmalloc.i + - constraints.i + - cpointer.i + - cstring.i + - cwstring.i + - director_common.swg + - exception.i + - intrusive_ptr.i + - inttypes.i + - math.i + - pointer.i + - runtime.swg + - shared_ptr.i + - std_except.i + - stdint.i + - stl.i + - swigarch.i + - swigerrors.swg + - swigfragments.swg + - swiginit.swg + - swiglabels.swg + - swigrun.i + - swigrun.swg + - swig.swg + - swigwarnings.swg + - swigwarn.swg + - typemaps/attribute.swg + - typemaps/carrays.swg + - typemaps/cdata.swg + - typemaps/cmalloc.swg + - typemaps/cpointer.swg + - typemaps/cstring.swg + - typemaps/cstrings.swg + - typemaps/cwstring.swg + - typemaps/enumint.swg + - typemaps/exception.swg + - typemaps/factory.swg + - typemaps/fragments.swg + - typemaps/implicit.swg + - typemaps/inoutlist.swg + - typemaps/misctypes.swg + - typemaps/primtypes.swg + - typemaps/ptrtypes.swg + - typemaps/std_except.swg + - typemaps/std_string.swg + - typemaps/std_strings.swg + - typemaps/std_wstring.swg + - typemaps/string.swg + - typemaps/strings.swg + - typemaps/swigmacros.swg + - typemaps/swigobject.swg + - typemaps/swigtype.swg + - typemaps/swigtypemaps.swg + - typemaps/typemaps.swg + - typemaps/valtypes.swg + - typemaps/void.swg + - typemaps/wstring.swg + - wchar.i + - windows.i +# (cd $S/contrib/tools/swig/Lib/python; find * '(' -not -path '*/*' -or -path 'typemaps/*' ')' -and '(' -name '*.i' -or -name '*.swg' ')' ) | awk '{print " - "$0}' + - argcargv.i + - attribute.i + - boost_shared_ptr.i + - builtin.swg + - carrays.i + - ccomplex.i + - cdata.i + - cmalloc.i + - complex.i + - cpointer.i + - cstring.i + - cwstring.i + - defarg.swg + - director.swg + - embed.i + - exception.i + - factory.i + - file.i + - implicit.i + - pyabc.i + - pyapi.swg + - pybackward.swg + - pybuffer.i + - pyclasses.swg + - pycomplex.swg + - pycontainer.swg + - pydocs.swg + - pyerrors.swg + - pyfragments.swg + - pyhead.swg + - pyinit.swg + - pyiterators.swg + - pymacros.swg + - pyname_compat.i + - pyopers.swg + - pyprimtypes.swg + - pyrun.swg + - pyruntime.swg + - pystdcommon.swg + - pystrings.swg + - pythonkw.swg + - python.swg + - pythreads.swg + - pytuplehlp.swg + - pytypemaps.swg + - pyuserdir.swg + - pywstrings.swg + - std_alloc.i + - std_array.i + - std_auto_ptr.i + - std_basic_string.i + - std_carray.i + - std_char_traits.i + - std_common.i + - std_complex.i + - std_container.i + - std_deque.i + - std_except.i + - std_ios.i + - std_iostream.i + - std_list.i + - std_map.i + - std_multimap.i + - std_multiset.i + - std_pair.i + - std_set.i + - std_shared_ptr.i + - std_sstream.i + - std_streambuf.i + - std_string.i + - std_unordered_map.i + - std_unordered_multimap.i + - std_unordered_multiset.i + - std_unordered_set.i + - std_vectora.i + - std_vector.i + - std_wios.i + - std_wiostream.i + - std_wsstream.i + - std_wstreambuf.i + - std_wstring.i + - stl.i + - typemaps.i + - wchar.i +# (cd $S/contrib/tools/swig/Lib/java; find * '(' -not -path '*/*' -or -path 'typemaps/*' ')' -and '(' -name '*.i' -or -name '*.swg' ')' ) | awk '{print " - "$0}' + - arrays_java.i + - boost_intrusive_ptr.i + - boost_shared_ptr.i + - director.swg + - enumsimple.swg + - enums.swg + - enumtypesafe.swg + - enumtypeunsafe.swg + - javahead.swg + - javakw.swg + - java.swg + - std_array.i + - std_auto_ptr.i + - std_common.i + - std_deque.i + - std_except.i + - std_list.i + - std_map.i + - std_pair.i + - std_set.i + - std_shared_ptr.i + - std_string.i + - std_unordered_map.i + - std_unordered_set.i + - std_vector.i + - std_wstring.i + - stl.i + - swiginterface.i + - typemaps.i + - various.i +# (cd $S/contrib/tools/swig/Lib/go; find * '(' -not -path '*/*' -or -path 'typemaps/*' ')' -and '(' -name '*.i' -or -name '*.swg' ')' ) | awk '{print " - "$0}' + - cdata.i + - director.swg + - exception.i + - gokw.swg + - goruntime.swg + - gostring.swg + - go.swg + - std_common.i + - std_deque.i + - std_except.i + - std_list.i + - std_map.i + - std_pair.i + - std_string.i + - std_vector.i + - stl.i + - typemaps.i +# (cd $S/contrib/tools/swig/Lib/perl5; find * '(' -not -path '*/*' -or -path 'typemaps/*' ')' -and '(' -name '*.i' -or -name '*.swg' ')' ) | awk '{print " - "$0}' + - attribute.i + - carrays.i + - cdata.i + - cmalloc.i + - cpointer.i + - cstring.i + - director.swg + - exception.i + - factory.i + - perl5.swg + - perlerrors.swg + - perlfragments.swg + - perlhead.swg + - perlinit.swg + - perlkw.swg + - perlmacros.swg + - perlmain.i + - perlopers.swg + - perlprimtypes.swg + - perlrun.swg + - perlruntime.swg + - perlstrings.swg + - perltypemaps.swg + - perluserdir.swg + - reference.i + - std_common.i + - std_deque.i + - std_except.i + - std_list.i + - std_map.i + - std_pair.i + - std_string.i + - std_vector.i + - stl.i + - typemaps.i diff --git a/build/sysincl/swig.yml b/build/sysincl/swig.yml new file mode 100644 index 00000000000..9931a15e3c0 --- /dev/null +++ b/build/sysincl/swig.yml @@ -0,0 +1,292 @@ +# Generated by devtools/yamaker. +- includes: + - argcargv.i: + - contrib/tools/swig/Lib/python/argcargv.i + - arrays_java.i: + - contrib/tools/swig/Lib/java/arrays_java.i + - attribute.i: + - contrib/tools/swig/Lib/attribute.i + - contrib/tools/swig/Lib/perl5/attribute.i + - contrib/tools/swig/Lib/python/attribute.i + - boost_intrusive_ptr.i: + - contrib/tools/swig/Lib/java/boost_intrusive_ptr.i + - boost_shared_ptr.i: + - contrib/tools/swig/Lib/java/boost_shared_ptr.i + - contrib/tools/swig/Lib/python/boost_shared_ptr.i + - builtin.swg: + - contrib/tools/swig/Lib/python/builtin.swg + - carrays.i: + - contrib/tools/swig/Lib/carrays.i + - contrib/tools/swig/Lib/perl5/carrays.i + - contrib/tools/swig/Lib/python/carrays.i + - ccomplex.i: + - contrib/tools/swig/Lib/python/ccomplex.i + - cdata.i: + - contrib/tools/swig/Lib/cdata.i + - contrib/tools/swig/Lib/go/cdata.i + - contrib/tools/swig/Lib/perl5/cdata.i + - contrib/tools/swig/Lib/python/cdata.i + - cmalloc.i: + - contrib/tools/swig/Lib/cmalloc.i + - contrib/tools/swig/Lib/perl5/cmalloc.i + - contrib/tools/swig/Lib/python/cmalloc.i + - complex.i: + - contrib/tools/swig/Lib/python/complex.i + - cpointer.i: + - contrib/tools/swig/Lib/cpointer.i + - contrib/tools/swig/Lib/perl5/cpointer.i + - contrib/tools/swig/Lib/python/cpointer.i + - cstring.i: + - contrib/tools/swig/Lib/cstring.i + - contrib/tools/swig/Lib/perl5/cstring.i + - contrib/tools/swig/Lib/python/cstring.i + - cwstring.i: + - contrib/tools/swig/Lib/cwstring.i + - contrib/tools/swig/Lib/python/cwstring.i + - defarg.swg: + - contrib/tools/swig/Lib/python/defarg.swg + - director.swg: + - contrib/tools/swig/Lib/go/director.swg + - contrib/tools/swig/Lib/java/director.swg + - contrib/tools/swig/Lib/perl5/director.swg + - contrib/tools/swig/Lib/python/director.swg + - embed.i: + - contrib/tools/swig/Lib/python/embed.i + - enums.swg: + - contrib/tools/swig/Lib/java/enums.swg + - enumsimple.swg: + - contrib/tools/swig/Lib/java/enumsimple.swg + - enumtypesafe.swg: + - contrib/tools/swig/Lib/java/enumtypesafe.swg + - enumtypeunsafe.swg: + - contrib/tools/swig/Lib/java/enumtypeunsafe.swg + - exception.i: + - contrib/tools/swig/Lib/exception.i + - contrib/tools/swig/Lib/go/exception.i + - contrib/tools/swig/Lib/perl5/exception.i + - contrib/tools/swig/Lib/python/exception.i + - factory.i: + - contrib/tools/swig/Lib/perl5/factory.i + - contrib/tools/swig/Lib/python/factory.i + - file.i: + - contrib/tools/swig/Lib/python/file.i + - go.swg: + - contrib/tools/swig/Lib/go/go.swg + - gokw.swg: + - contrib/tools/swig/Lib/go/gokw.swg + - goruntime.swg: + - contrib/tools/swig/Lib/go/goruntime.swg + - gostring.swg: + - contrib/tools/swig/Lib/go/gostring.swg + - implicit.i: + - contrib/tools/swig/Lib/python/implicit.i + - java.swg: + - contrib/tools/swig/Lib/java/java.swg + - javahead.swg: + - contrib/tools/swig/Lib/java/javahead.swg + - javakw.swg: + - contrib/tools/swig/Lib/java/javakw.swg + - perl5.swg: + - contrib/tools/swig/Lib/perl5/perl5.swg + - perlerrors.swg: + - contrib/tools/swig/Lib/perl5/perlerrors.swg + - perlfragments.swg: + - contrib/tools/swig/Lib/perl5/perlfragments.swg + - perlhead.swg: + - contrib/tools/swig/Lib/perl5/perlhead.swg + - perlinit.swg: + - contrib/tools/swig/Lib/perl5/perlinit.swg + - perlkw.swg: + - contrib/tools/swig/Lib/perl5/perlkw.swg + - perlmacros.swg: + - contrib/tools/swig/Lib/perl5/perlmacros.swg + - perlmain.i: + - contrib/tools/swig/Lib/perl5/perlmain.i + - perlopers.swg: + - contrib/tools/swig/Lib/perl5/perlopers.swg + - perlprimtypes.swg: + - contrib/tools/swig/Lib/perl5/perlprimtypes.swg + - perlrun.swg: + - contrib/tools/swig/Lib/perl5/perlrun.swg + - perlruntime.swg: + - contrib/tools/swig/Lib/perl5/perlruntime.swg + - perlstrings.swg: + - contrib/tools/swig/Lib/perl5/perlstrings.swg + - perltypemaps.swg: + - contrib/tools/swig/Lib/perl5/perltypemaps.swg + - perluserdir.swg: + - contrib/tools/swig/Lib/perl5/perluserdir.swg + - pyabc.i: + - contrib/tools/swig/Lib/python/pyabc.i + - pyapi.swg: + - contrib/tools/swig/Lib/python/pyapi.swg + - pybackward.swg: + - contrib/tools/swig/Lib/python/pybackward.swg + - pybuffer.i: + - contrib/tools/swig/Lib/python/pybuffer.i + - pyclasses.swg: + - contrib/tools/swig/Lib/python/pyclasses.swg + - pycomplex.swg: + - contrib/tools/swig/Lib/python/pycomplex.swg + - pycontainer.swg: + - contrib/tools/swig/Lib/python/pycontainer.swg + - pydocs.swg: + - contrib/tools/swig/Lib/python/pydocs.swg + - pyerrors.swg: + - contrib/tools/swig/Lib/python/pyerrors.swg + - pyfragments.swg: + - contrib/tools/swig/Lib/python/pyfragments.swg + - pyhead.swg: + - contrib/tools/swig/Lib/python/pyhead.swg + - pyinit.swg: + - contrib/tools/swig/Lib/python/pyinit.swg + - pyiterators.swg: + - contrib/tools/swig/Lib/python/pyiterators.swg + - pymacros.swg: + - contrib/tools/swig/Lib/python/pymacros.swg + - pyname_compat.i: + - contrib/tools/swig/Lib/python/pyname_compat.i + - pyopers.swg: + - contrib/tools/swig/Lib/python/pyopers.swg + - pyprimtypes.swg: + - contrib/tools/swig/Lib/python/pyprimtypes.swg + - pyrun.swg: + - contrib/tools/swig/Lib/python/pyrun.swg + - pyruntime.swg: + - contrib/tools/swig/Lib/python/pyruntime.swg + - pystdcommon.swg: + - contrib/tools/swig/Lib/python/pystdcommon.swg + - pystrings.swg: + - contrib/tools/swig/Lib/python/pystrings.swg + - python.swg: + - contrib/tools/swig/Lib/python/python.swg + - pythonkw.swg: + - contrib/tools/swig/Lib/python/pythonkw.swg + - pythreads.swg: + - contrib/tools/swig/Lib/python/pythreads.swg + - pytuplehlp.swg: + - contrib/tools/swig/Lib/python/pytuplehlp.swg + - pytypemaps.swg: + - contrib/tools/swig/Lib/python/pytypemaps.swg + - pyuserdir.swg: + - contrib/tools/swig/Lib/python/pyuserdir.swg + - pywstrings.swg: + - contrib/tools/swig/Lib/python/pywstrings.swg + - reference.i: + - contrib/tools/swig/Lib/perl5/reference.i + - std_alloc.i: + - contrib/tools/swig/Lib/python/std_alloc.i + - std_array.i: + - contrib/tools/swig/Lib/java/std_array.i + - contrib/tools/swig/Lib/python/std_array.i + - std_auto_ptr.i: + - contrib/tools/swig/Lib/java/std_auto_ptr.i + - contrib/tools/swig/Lib/python/std_auto_ptr.i + - std_basic_string.i: + - contrib/tools/swig/Lib/python/std_basic_string.i + - std_carray.i: + - contrib/tools/swig/Lib/python/std_carray.i + - std_char_traits.i: + - contrib/tools/swig/Lib/python/std_char_traits.i + - std_common.i: + - contrib/tools/swig/Lib/go/std_common.i + - contrib/tools/swig/Lib/java/std_common.i + - contrib/tools/swig/Lib/perl5/std_common.i + - contrib/tools/swig/Lib/python/std_common.i + - std_complex.i: + - contrib/tools/swig/Lib/python/std_complex.i + - std_container.i: + - contrib/tools/swig/Lib/python/std_container.i + - std_deque.i: + - contrib/tools/swig/Lib/go/std_deque.i + - contrib/tools/swig/Lib/java/std_deque.i + - contrib/tools/swig/Lib/perl5/std_deque.i + - contrib/tools/swig/Lib/python/std_deque.i + - std_except.i: + - contrib/tools/swig/Lib/go/std_except.i + - contrib/tools/swig/Lib/java/std_except.i + - contrib/tools/swig/Lib/perl5/std_except.i + - contrib/tools/swig/Lib/python/std_except.i + - std_ios.i: + - contrib/tools/swig/Lib/python/std_ios.i + - std_iostream.i: + - contrib/tools/swig/Lib/python/std_iostream.i + - std_list.i: + - contrib/tools/swig/Lib/go/std_list.i + - contrib/tools/swig/Lib/java/std_list.i + - contrib/tools/swig/Lib/perl5/std_list.i + - contrib/tools/swig/Lib/python/std_list.i + - std_map.i: + - contrib/tools/swig/Lib/go/std_map.i + - contrib/tools/swig/Lib/java/std_map.i + - contrib/tools/swig/Lib/perl5/std_map.i + - contrib/tools/swig/Lib/python/std_map.i + - std_multimap.i: + - contrib/tools/swig/Lib/python/std_multimap.i + - std_multiset.i: + - contrib/tools/swig/Lib/python/std_multiset.i + - std_pair.i: + - contrib/tools/swig/Lib/go/std_pair.i + - contrib/tools/swig/Lib/java/std_pair.i + - contrib/tools/swig/Lib/perl5/std_pair.i + - contrib/tools/swig/Lib/python/std_pair.i + - std_set.i: + - contrib/tools/swig/Lib/java/std_set.i + - contrib/tools/swig/Lib/python/std_set.i + - std_shared_ptr.i: + - contrib/tools/swig/Lib/java/std_shared_ptr.i + - contrib/tools/swig/Lib/python/std_shared_ptr.i + - std_sstream.i: + - contrib/tools/swig/Lib/python/std_sstream.i + - std_streambuf.i: + - contrib/tools/swig/Lib/python/std_streambuf.i + - std_string.i: + - contrib/tools/swig/Lib/go/std_string.i + - contrib/tools/swig/Lib/java/std_string.i + - contrib/tools/swig/Lib/perl5/std_string.i + - contrib/tools/swig/Lib/python/std_string.i + - std_unordered_map.i: + - contrib/tools/swig/Lib/java/std_unordered_map.i + - contrib/tools/swig/Lib/python/std_unordered_map.i + - std_unordered_multimap.i: + - contrib/tools/swig/Lib/python/std_unordered_multimap.i + - std_unordered_multiset.i: + - contrib/tools/swig/Lib/python/std_unordered_multiset.i + - std_unordered_set.i: + - contrib/tools/swig/Lib/java/std_unordered_set.i + - contrib/tools/swig/Lib/python/std_unordered_set.i + - std_vector.i: + - contrib/tools/swig/Lib/go/std_vector.i + - contrib/tools/swig/Lib/java/std_vector.i + - contrib/tools/swig/Lib/perl5/std_vector.i + - contrib/tools/swig/Lib/python/std_vector.i + - std_vectora.i: + - contrib/tools/swig/Lib/python/std_vectora.i + - std_wios.i: + - contrib/tools/swig/Lib/python/std_wios.i + - std_wiostream.i: + - contrib/tools/swig/Lib/python/std_wiostream.i + - std_wsstream.i: + - contrib/tools/swig/Lib/python/std_wsstream.i + - std_wstreambuf.i: + - contrib/tools/swig/Lib/python/std_wstreambuf.i + - std_wstring.i: + - contrib/tools/swig/Lib/java/std_wstring.i + - contrib/tools/swig/Lib/python/std_wstring.i + - stl.i: + - contrib/tools/swig/Lib/go/stl.i + - contrib/tools/swig/Lib/java/stl.i + - contrib/tools/swig/Lib/perl5/stl.i + - contrib/tools/swig/Lib/python/stl.i + - swiginterface.i: + - contrib/tools/swig/Lib/java/swiginterface.i + - typemaps.i: + - contrib/tools/swig/Lib/go/typemaps.i + - contrib/tools/swig/Lib/java/typemaps.i + - contrib/tools/swig/Lib/perl5/typemaps.i + - contrib/tools/swig/Lib/python/typemaps.i + - various.i: + - contrib/tools/swig/Lib/java/various.i + - wchar.i: + - contrib/tools/swig/Lib/python/wchar.i + - contrib/tools/swig/Lib/wchar.i diff --git a/build/sysincl/system-jdk.yml b/build/sysincl/system-jdk.yml new file mode 100644 index 00000000000..d894941ad48 --- /dev/null +++ b/build/sysincl/system-jdk.yml @@ -0,0 +1,2 @@ +- includes: + - jni.h
\ No newline at end of file diff --git a/build/sysincl/unsorted.yml b/build/sysincl/unsorted.yml new file mode 100644 index 00000000000..2aba1ff1578 --- /dev/null +++ b/build/sysincl/unsorted.yml @@ -0,0 +1,975 @@ +- source_filter: "^contrib(?!/restricted/gstreamer/gst/parse)" + includes: + - types.h + - stat.h + +- source_filter: ".*contrib.*" + includes: + - stat.h + - libutf8.h + #if defined(_OS_QNX) && CONTRIB + - devctl.h + #endif + - CrashReporterClient.h + - Eigen/Array + - Errors.h + - ICSupport.h + - LPdir.h + - LzFindMt.h + - MD5.h + - SIOUX.h + - TFileSpec.h + - TLS.h + - XMP.incl_cpp + - XMPSDK.hpp + - _mingw.h + - abi_mutex.h + - afxcmn.h + - afxdao.h + - afxdb.h + - afxdisp.h + - afxext.h + - afxodlgs.h + - afxole.h + - afxwin.h + - alpha/builtins.h + - apr_iconv.h + - atheos/atomic.h + - atheos/semaphore.h + - atheos/threads.h + - atomic_ops.h + - auth-client-parser/parser.h + - bluetooth/bluetooth.h + - bluetooth/hci.h + - bluetooth/l2cap.h + - bluetooth/rfcomm.h + - bluetooth/sco.h + - bstring.h + - builtins.h + - c_asm.h + - config-mac.h + - console.h + - could_not_find_Perl_patchlevel.h + - cpml.h + - crtl.h + - cthreads.h + - ctime.h + - db_provider.h + - dbmalloc.h + - dir.h + - dither.h + - dl.h + - doc/doc_dynamic.h + - doc/doc_nan.h + - doc/doc_printf.h + - doc/doc_register.h + - doc/doc_scanf.h + - doc/doc_static.h + - dvidef.h + - fastmath.h + - fcntl--.h + - fftw3.h + - file.h + - flags.h + - floatingpoint.h + - fp.h + - fp_class.h + - fsio.h + - fwriteerror.h + - gdbm.h + - ghostscript/iapi.h + - ghostscript/ierrors.h + - glibtop.h + - glibtop/close.h + - glibtop/open.h + - glibtop/parameter.h + - glibtop/sysdeps.h + - glibtop/union.h + - glibtop/xmalloc.h + - gmp.h + - gnutls/x509.h + - hp-timing.h + - httpd_wrap.h + - i86.h + - ieeedef.h + - in.h + - inet.h + - intl.h + - iperlsys.h + - ipl.h + - ipl/ipl.h + - ipp.h + - ippcp.h + - kfuncs.h + - l12_integer_tables.h + - l3_integer_tables.h + - lcms.h + - libavcodec/aacps_tables.h + - libavcodec/cbrt_tables.h + - libavcodec/dv_tables.h + - libavcodec/motionpixels_tables.h + - libavcodec/mpegaudio_tables.h + - libavcodec/pcm_tables.h + - libavcodec/qdm2_tables.h + - libavcodec/sinewin_tables.h + - libio/iolibio.h + - libio/libioP.h + - libs/regex/test/config_info/regex_config_info.cpp + - locale/coll-lookup.h + - locale/elem-hash.h + - locale/localeinfo.h + - locale/weight.h + - locale/weightwc.h + - lqr.h + - lwp/lwp.h + - lwp/stackdep.h + - m68881.h + - mach/cthreads.h + - mathimf.h + - matrixos.h + - mfx/mfxvideo.h + - mingw.h + - mips64/sysarch.h + - ms/uplink.h + - msl_utility + - namdef.h + - ncurses/curses.h + - ncurses/term.h + - ndir.h + - net/netdb.h + - net/socket.h + - net/uio.h + - nks/dirio.h + - nks/plat.h + - nks/thread.h + - nonblocking.h + - note.h + - opcdef.h + - openssl/applink.c + - os2def.h + - oslib/osfscontrol.h + - paper.h + - pcre_printint.src + - pire/config.h + - pngusr.h + - probes_mysql_dtrace.h + - pth.h + - relocatable.h + - rtl.h + - semLib.h + - shlib-compat.h + - sigsegv.h + - sockLib.h + - socket.h + - socketshr.h + - socklib.h + - socks.h + - strdef.h + - streams/un.h + - stropts + - swill.h + - sysLib.h + - taskLib.h + - tcp.h + - tdep-ia64/dwarf-config.h + - thread.h + - thread_plan9.h + - tickLib.h + - ttdef.h + - type_traits.h + - udplite.h + - ulocks.h + - unchecked.h + - unixlib.h + - unixstuff.h + - validator/validator.h + - vasnwprintf.h + - vld.h + - win32lib.h + - wincecompat.h + - wprintf-parse.h + - wsockcompat.h + - xdelta3-python.h + - xml/xmlparse.h + - xmlparse/xmlparse.h + - xmltok/xmlparse.h + - yca/yca.h + - zzip-1.h + - zzip-2.h + - zzip-3.h + - zzip-4.h + - zzip-5.h + #if CONTRIB && defined(_HAVE_LIBIDSA) + - idsa.h + #endif + - ../lib/memdebug.h + - ../../VC/include/math.h + - ../../VC/include/cfloat + - ../extra/yassl/taocrypt/include/sha.hpp + - prof.h + - ll_alloc_hook.c + - cpptl/config.h + - cpptl/conststring.h + - cpptl/forwards.h + - cpptl/smallmap.h + - forwards.h + - json_valueiterator.inl + - value.h + - pthread/mit/sys/timers.h + - sljit/sljitLir.c + - pcre_printint.c + #ifdef defined(emacs) && CONTRIB && TRASH + - blockinput.h + #endif + #if defined(__atmos__) && CONTRIB + - kernel.h + #endif + #if defined(_LIBC) && CONTRIB && TRASH + - not-cancel.h + - local-setxid.h + - vasprintf.h + #endif + +- case_sensitive: false + includes: + #if defined(WINDOWS) && CONTRIB && TRASH + - ../include/locale.h + - ../include/signal.h + - ../include/sys/stat.h + - ../include/fcntl.h + - ../include/math.h + - vcruntime_exception.h + - vcruntime_new.h + - vcruntime_typeinfo.h + #endif + - PowrProf.h + - BaseTsd.h + - iphlpapi.h + +- source_filter: "^contrib/(libs/(apache|httpd|libuv)|python/uWSGI)" + includes: + - port.h + +- source_filter: "^contrib/libs/poco" + includes: + - timers.h + +- source_filter: "^(contrib/libs/curl|taxi/external/curl)" + includes: + - lwip/init.h + - lwip/netdb.h + - lwip/sockets.h + +- includes: + - cpu-features.h + - cuda/include/cuComplex.h + - cuda/include/cublas_v2.h + - cuda/include/cuda.h + - cuda/include/cudnn.h + - cuda/include/cufft.h + - cuda/include/curand.h + - cpuid.h + - nan.h + - omp.h + - unlocked-io.h + - cygwin/version.h + - zircon/syscalls.h + - zircon/types.h + - zircon/process.h + - sys/linux-syscalls.h + - tr1/memory + - android/log.h + - ompt.h + # vvvvv ____ because in [geobase/perl/dynamic] does not work ignoring via "// Y_IGNORE" + - geobase6/service_getter.hpp + - geobase6/timezone_getter.hpp + # ^^^^^ ---- + #if defined(__FreeBSD__) + - bluetooth.h + - bsdxml.h + - devstat.h + - ieeefp.h + - jail.h + - kvm.h + - libutil.h + - machine/atomic.h + - machine/cpu.h + - machine/fpu.h + - malloc_np.h + - netinet/sctp_uio.h + - netinet/ip_options.h + - netinet/sctp_kdtrace.h + - netinet/sctp_lock_bsd.h + - netinet/sctp_lock_empty.h + - netinet/sctp_os_bsd.h + - netinet6/in6_pcb.h + - netinet6/ip6_var.h + - netinet6/ip6protosw.h + - netinet6/scope6_var.h + - netipsec/ipsec.h + - netipsec/ipsec6.h + - netipsec/key.h + - opie.h + - osreldate.h + - opt_sctp.h + - pthread_np.h + - ripemd.h + - sys/cpuctl.h + - sys/cpuset.h + - sys/disklabel.h + - sys/endian.h + - sys/eventhandler.h + - sys/exec.h + - sys/extattr.h + - sys/filedesc.h + - sys/gsb_crc32.h + - sys/jail.h + - sys/ktrace.h + - sys/machine.h + - sys/module.h + - sys/mpctl.h + - sys/mutex.h + - sys/rwlock.h + - sys/semaphore.h + - sys/smp.h + - sys/stdint.h + - sys/systm.h + - sys/thr.h + - sys/timespec.h + - sys/umtx.h + - sys/uuid.h + - ucred.h + - varargs.h + - vm/vm_param.h + #endif + #if defined(__GNUC__) + - varargs.h + - stdfix.h + - mm_malloc.h + - quadmath.h + #endif + #if defined(_MSC_VER) + - comdef.h + - comutil.h + - concrt.h + - crtdefs.h + - crtversion.h + - eh.h + - excpt.h + - ppl.h + - ppltasks.h + - rtcapi.h + - vadefs.h + - varargs.h + - xlocinfo.h + - xstddef + - xutility + - ymath.h + - crtassem.h + #endif + #if defined(_unix_) && TODO + - bits/types/mbstate_t.h + - sys/atomic.h + - sys/atomic_op.h + - sys/bsdskt.h + - sys/bsdtty.h + - sys/builtin.h + - sys/cygwin.h + - sys/dcmd_blk.h + - sys/devpoll.h + - sys/fmutex.h + - sys/int_types.h + - sys/loadavg.h + - sys/localedef.h + - sys/machlock.h + - sys/mkdev.h + - sys/modem.h + - sys/ndir.h + - sys/port_impl.h + - sys/processor.h + - sys/pstat.h + - sys/system_properties.h + - sys/termio.h + - sys/timeval.h + - machine/bswap.h + - machine/sys/inline.h + #endif + #if defined(_PERL_) + - EXTERN.h + - perl.h + - XSUB.h + #endif + #if defined(_darwin_) + - AEObjects.h + - AEPackObject.h + - AERegistry.h + - AppleEvents.h + - Files.h + - Gestalt.h + - ImageCompression.h + - Palettes.h + - PictUtils.h + - Processes.h + - QDOffscreen.h + - QuickDraw.h + - TextUtils.h + - Types.h + - sys/_types/_mbstate_t.h + #endif + #if defined(_OS2_) + - os2.h + #endif + #if defined(_arm_) + - arm/limits.h + #endif + #if defined(_VMS_) && TODO + - atrdef.h + - dcdef.h + - descrip.h + - dvsdef.h + - fab.h + - fibdef.h + - gen64def.h + - iledef.h + - iodef.h + - lib$routines.h + - libfildef.h + - libfisdef.h + - lnmdef.h + - nam.h + - rms.h + - rmsdef.h + - ssdef.h + - starlet.h + - str$routines.h + - stsdef.h + - syidef.h + - times.h + - unixio.h + - tcpSocketVaxRoutines.h + #endif + #if defined(_SOLARIS_) && TODO + - synch.h + - sys/byteorder.h + #endif + #if defined(__MSL__) && TODO && WTF + - unix.h + #endif + #if defined(__sgi) + - sgidefs.h + #endif + #if defined(__BEOS__) + - ByteOrder.h + - OS.h + - support/SupportDefs.h + - kernel/OS.h + - kernel/image.h + #endif + #if defined(_sun_) + - procfs.h + #endif + #if defined(__sun) + - sys/port.h + #endif + #if defined(__sun__) + - sys/isa_defs.h + #endif + #if defined(__X11__) + - X11/XKBlib.h + - X11/keysym.h + - X11/extensions/shape.h + - X11/extensions/XShm.h + - X11/cursorfont.h + - X11/Xutil.h + - X11/Xresource.h + - X11/Xproto.h + - X11/Xos.h + - X11/Xlocale.h + - X11/Xlib.h + - X11/Xatom.h + - X11/Intrinsic.h + #endif + #if defined(HAVE_DMALLOC) + - dmalloc.h + #endif + #if defined(HAVE_ALTIVEC) + - altivec.h + #endif + #if defined(__vxWorks__) + - vxCpuLib.h + - vxWorks.h + - sockLib.h + - hostLib.h + - ioLib.h + - iosLib.h + - resolvLib.h + - rtpLib.h + - pipeDrv.h + - selectLib.h + #endif + #if defined(_LIBC) && TRASH + - ../locale/localeinfo.h + - ../locale/elem-hash.h + - ../locale/coll-lookup.h + #endif + #if defined(_LINUX_ANDROID) + - android/api-level.h + - android/ndk-version.h + #endif + #if defined(HAVE_CONFIG_H) && TODO + - config_auto.h + #endif + #if defined(_TRASH_) && TODO + - openssl/fips.h + - tr1/unordered_map + - tr1/unordered_set + - tr1/type_traits + - ext/atomicity.h + - bits/c++config.h + - bits/atomicity.h + - gcrypt.h + - gnutls/gnutls.h + - gdwmfapi.h + - winmmap.h + - sf_unistd.h + #endif + #if defined(__TURBOC__) || defined(__BORLANDC__) + - alloc.h + #endif + #if defined (__DECC) || defined (__DECCXX) + - machine/builtins.h + #endif + #if defined(USE_PERL) && TODO + - perliol.h + #endif + #if defined(__NetBSD__) + - lwp.h + - perfuse.h + #endif + #if V8_OS_QNX + - sys/syspage.h + #endif + #if V8_OS_AIX + - sys/systemcfg.h + - sys/thread.h + #endif + - iostream.h + - streambuf.h + - ostream.h + - nacl/nacl_random.h + - jemalloc/jemalloc.h + - tr1/tuple + - sys/inttypes.h + - lockdep.h + - memfault.h + - memcheck.h + - msvc.h + - sqlite3userauth.h + - linenoise.h + - sunmath.h + - sys/fpu.h + - win32.h + - bsd/stdlib.h + - bsd/unistd.h + - sys/videoio.h + - libv4l2.h + - soundcard.h + - ../ucrt/fcntl.h + - ../ucrt/locale.h + - ../ucrt/math.h + - ../ucrt/signal.h + - ../ucrt/sys/stat.h + #if defined (CUDA) + - math_constants.h + #endif + #if defined(BUILDING_LIBCURL) + - amitcp/socketbasetags.h + - clib.h + - exec/execbase.h + - exec/types.h + - extra/strdup.h + - extra/stricmp.h + - fabdef.h + - floss.h + - gnutls/crypto.h + - gskssl.h + - gss.h + - hasht.h + - ldap_ssl.h + - librtmp/rtmp.h + - nettle/des.h + - nettle/md4.h + - nettle/md5.h + - pk11pub.h + - proto/dos.h + - proto/exec.h + - qsoasync.h + - stabs.h + - tpf/sysapi.h + #endif + - asm/page.h + - asm/sgidefs.h + - wrl\client.h + - wrl\event.h + - wrl\wrappers\corewrappers.h + - wrl\ftm.h + - bits/char_traits.h + - bits/stl_algobase.h + - bits/stl_move.h + - bits/stl_pair.h + - bits/stl_function.h + - bits/move.h + - ndir.h + - ext/rope + - sunmedia_types.h + - clidef.h + - credef.h + - dos/dos.h + - lbrdef.h + - lbr$routines.h + - libclidef.h + - libguile.h + - mhddef.h + - pathstuff.h + - perror.h + - processes.h + - sub_proc.h + - w32err.h + - procinfo.h + #if defined(__HAIKU__) + - FindDirectory.h + - StorageDefs.h + #endif + - fpxcp.h + - fptrap.h + - fortran.h + - agg_allocator.h + - SIOUX.h + - sys/siginfo.h + #ifdef HAVE_LIBGIMLI_H + - libgimli.h + #endif + #if MATLAB_MEX_FILE + - mex.h + #else + - lzmalib.h + # ICU + - uconfig_local.h + - ucln_local_hook.c + - unistrm.h + - udbgutil.h + - dll.h + - ascii_a.h + - qusec.h + - qusrjobi.h + - qliept.h + - mih/testptr.h + - sys/neutrino.h + - cics.h + - tr1/cmath + - tr1/complex + - tbb/scalable_allocator.h + - libmemcached/dtrace_probes.h + # unknown + - win_stdint.h + - probes.h + - thread.h + # mongoc-driver unused includes + - tls.h + #if metrika then skip bad includes from metrika + - boost/thread/detail/lock.hpp + #endif metrika + - xti.h + # libgit2 unused includes + - proto/timer.h + - mbsupport.h + # end of libgit2 unused includes + - attr/xattr.h + - fshelp.h + - mlib_image.h + - selinux/selinux.h + - sys/mntctl.h + - sys/mnttab.h + - sys/systeminfo.h + - sys/vfstab.h + - sys/vmount.h + - CL/sycl.hpp + # libpcap files + - os-proto.h + - pc.h + - pharlap.h + - msdos/pm_drvr/lock.h + - TcApi.h + - net/pfvar.h + - net/if_pflog.h + - netdnet/dnetdb.h + - sys/ethernet.h + - sys/stream.h + - netlink/genl/genl.h + - netlink/genl/family.h + - netlink/genl/ctrl.h + - netlink/msg.h + - netlink/attr.h + # end libpcap files + +# These includes are not used in autocheck builds, but might be necessary for +# some external builds with exotic settings + +- case_sensitive: false + includes: + - bemapiset.h + - cor.h + - fusion.h + - IPHlpApi.h + - metahost.h + #if defined(WINDOWS) && defined (_USE_MFC_) + - afx.h + #endif + #if defined(WINDOWS) && CONTRIB && TRASH + - ../include/stdint.h + #endif + +- source_filter: ".*contrib.*" + includes: + #if defined (__OpenBSD__) && CONTRIB + - spinlock.h + #endif + #if CONTRIB && TODO + - MSTcpIP.h + - MacSocket.h + - WinIoCtl.h + - WinPDFCore.h + - Winsock2.h + - Xm/XmAll.h + - aep.h + - atalla.h + - crypto/cryptodev.h + - cswift.h + - cxcore.h + - efndef + - exiv2/types.hpp + - hw_4758_cca.h + - hw_ubsec.h + - hwcryptohook.h + - jpidef.h + - lckdef.h + - libdtdef.h + - novsock2.h + - openssl/fips_rand.h + - openssl/fipssyms.h + - openssl/jpake.h + - rld_interface.h + - screen.h + - sureware.h + - t_ctype.h + - tr1/unordered_map.hpp + - typedefs.h + - winmain.h + - wintext.h + - yandex/http/curl_wrapper.hpp + - yandex/threads/boost_threaded.hpp + - yasm-plugin.h + #endif + #if CONTRIB && TRASH + - macconfig.h + - amigaconfig.h + - json_batchallocator.h + - json_internalarray.inl + - json_internalmap.inl + - mysql/mysql_version.h + - libiberty.h + #endif + +- includes: + - Aclapi.h + - tr1/functional + - time64.h + - extern.h + #if defined(__FreeBSD__) + - _ctype.h + - alias.h + - calendar.h + - fetch.h + - gelf.h + - gnuregex.h + - kafs.h + - login_cap.h + - machine/_inttypes.h + - machine/_stdint.h + - machine/asm.h + - machine/in_cksum.h + - machine/sigframe.h + - machine/sysarch.h + - machine/trap.h + - md2.h + - md4.h + - mp.h + - pcap-int.h + - sys/_iovec.h + - sys/_null.h + - sys/_pthreadtypes.h + - sys/_sigset.h + - sys/_timeval.h + - sys/devicestat.h + - sys/fnv_hash.h + - sys/limits.h + - sys/priv.h + - sys/sched.h + - sys/sema.h + - sys/stack.h + - sys/timers.h + - sys/tree.h + - tcpd.h + - ypclnt.h + #endif + #if defined (__linux__) + - asm/fpu.h + - i386/fpu_control.h + - zlibdefs.h + #endif + #if defined(_MSC_VER) + - agents.h + - allocators + - amp.h + - collection.h + - ConcurrencySal.h + - concurrent_priority_queue.h + - concurrent_queue.h + - concurrent_unordered_map.h + - concurrent_unordered_set.h + - concurrent_vector.h + - vcruntime_new_debug.h + - dvec.h + - setjmpex.h + - srv.h + - typeinfo.h + - xcomplex + - xdebug + - xhash + - xiosbase + - xkeycheck.h + - xlocale + - xlocinfo + - xlocnum + - xmemory + - xmemory0 + - xstring + - xtr1common + - xtree + - yvals.h + #endif + #if defined(_unix_) && TODO + - sys/feature_tests.h + #endif + #if defined(_darwin_) + - libkern/version.h + - System/pthread_machdep.h + #endif + #if defined(_VMS_) && TODO + - chfdef.h + - libdef.h + #endif + #if defined(__sgi) + - sigfpe.h + #endif + #if defined(__MWERKS__) + - nwfileio.h + - nwthread.h + #endif + #if defined(_TRASH_) && TODO + - google/profiler.h + #endif + #if defined(__QNXNTO__) + - sys/cpuinline.h + #endif + - yabs_mx_calc_table.h + - net/errno.h + - sys/mode.h + - nwstdio.h + - os2ish.h + - vmsish.h + - ./plan9/plan9ish.h + - ./vos/vosish.h + - vos/vosish.h + - symbian/symbianish.h + - haiku/haikuish.h + - nw5thread.h + - os2thread.h + - netware.h + - perldtrace.h + - win32thread.h + - wince.h + - symbian/symbian_proto.h + - xconfig.h + - bsd/ctypes.h + - objc/NXCType.h + - appkit/NXCType.h + - sfio.h + - vmesa/vmesaish.h + - sys\stat.h + - mpeix/mpeixish.h + - epocish.h + - beos/beosish.h + - WinNT.h + - ../../VC/include/stdio.h + - ../ucrt/stdio.h + #if defined(BUILDING_LIBCURL) + - axTLS/ssl.h + - certdb.h + - cert.h + - cyassl/error.h + - cyassl/openssl/ssl.h + - cyassl/ssl.h + - nspr.h + - polarssl/certs.h + - polarssl/ctr_drbg.h + - polarssl/entropy.h + - polarssl/error.h + - polarssl/havege.h + - polarssl/net.h + - polarssl/ssl.h + - polarssl/version.h + - polarssl/x509.h + - prerror.h + - prio.h + - prtypes.h + - qsossl.h + - secerr.h + - secitem.h + - secmod.h + - secport.h + - spnegohelp.h + - sslerr.h + - sslproto.h + #endif + - Activation.h + - android/native_window.h + - Windows.System.Threading.h + #if defined(__MINGW32__) || defined(_MSC_VER) + - inet_net_pton.h + - inet_ntop.h + #endif + #if EV_USE_IOCP + - ev_iocp.c + #endif + - zend_exceptions.h + #if MATLAB_MEX_FILE + # unknown + - GL/glx.h + - CL/va_ext.h + - sys/sysconf.h + - ivx.hpp + - clAmdBlas.h + - clAmdFft.h + - va/va.h + #if metrika then skip bad includes from metrika + - yandex/lbs/LBSLocator.hpp + #endif metrika + # libpcap files + - sys/sysconfig.h + - sys/device.h + - sys/cfgodm.h + - cf.h + - zone.h + - netpacket/if_packet.h + # end libpcap files diff --git a/build/sysincl/valgrind.yml b/build/sysincl/valgrind.yml new file mode 100644 index 00000000000..de9c6b9f5d2 --- /dev/null +++ b/build/sysincl/valgrind.yml @@ -0,0 +1,4 @@ +- includes: + - valgrind/callgrind.h: contrib/libs/valgrind/valgrind/callgrind.h + - valgrind/memcheck.h: contrib/libs/valgrind/valgrind/memcheck.h + - valgrind/valgrind.h: contrib/libs/valgrind/valgrind/valgrind.h diff --git a/build/sysincl/windows.yml b/build/sysincl/windows.yml new file mode 100644 index 00000000000..ad30b7d3bb1 --- /dev/null +++ b/build/sysincl/windows.yml @@ -0,0 +1,318 @@ +- case_sensitive: false + includes: + - accctrl.h + - aclapi.h + - activation.h + - activscp.h + - adhoc.h + - apiset.h + - apisetcconv.h + - atltime.h + - audioclient.h + - authz.h + - basetyps.h + - bcrypt.h + - bits.h + - capi.h + - cet.h + - cfg.h + - comdef.h + - commctrl.h + - commdlg.h + - common.ver + - compressapi.h + - concurrencysal.h + - conio.h + - consoleapi.h + - corecrt.h + - corecrt_terminate.h + - cpl.h + - crtdbg.h + - cryptuiapi.h + - d2d1.h + - d2d1_2.h + - d3d10.h + - d3d10_1.h + - d3d11.h + - d3d11_1.h + - d3d9.h + - d3dcompiler.h + - datetimeapi.h + - dbgeng.h + - dbghelp.h + - dbt.h + - dcomp.h + - debugapi.h + - devguid.h + - direct.h + - dispex.h + - dos.h + - downloadmgr.h + - driverspecs.h + - dshow.h + - dsound.h + - dsparse.h + - dv.h + - dvdmedia.h + - dwrite.h + - dxgi.h + - dxgi1_2.h + - dxgi1_3.h + - dxgidebug.h + - dxprogrammablecapture.h + - dxva.h + - dxva2api.h + - effects.h + - encdec.h + - errhandlingapi.h + - eventtoken.h + - evntprov.h + - evntrace.h + - exdisp.h + - exdispid.h + - fci.h + - fibersapi.h + - fileapi.h + - filter.h + - fltuser.h + - fltuserstructures.h + - fttypes.h + - fwpmu.h + - gb18030.h + - gdiplus.h + - gdiplusimagecodec.h + - gl/gl.h + - gl/glu.h + - guiddef.h + - handleapi.h + - heapapi.h + - htmlhelp.h + - http.h + - imagehlp.h + - ime_cmodes.h + - imm.h + - in6addr.h + - inaddr.h + - initguid.h + - inspectable.h + - instance.h + - interlockedapi.h + - intsafe.h + - io.h + - ioapiset.h + - ipexport.h + - ipifcons.h + - iptypes.h + - iwscapi.h + - jobapi.h + - journal.h + - kbd.h + - kernelspecs.h + - ksmedia.h + - ktmtypes.h + - libloaderapi.h + - lm.h + - lmcons.h + - lmerr.h + - lmstats.h + - mbctype.h + - mbstring.h + - mcx.h + - memoryapi.h + - mfapi.h + - mi.h + - minmax.h + - minwinbase.h + - minwindef.h + - mlang.h + - mmdeviceapi.h + - mmsystem.h + - mq.h + - mshtmdid.h + - mshtmhst.h + - mshtml.h + - msi.h + - msidefs.h + - msiquery.h + - msp.h + - msputils.h + - mstcpip.h + - mswsock.h + - mtx.h + - namedpipeapi.h + - namespaceapi.h + - netioapi.h + - new.h + - npapi.h + - ntdddisk.h + - ntddk.h + - ntddndis.h + - ntdef.h + - ntsecapi.h + - ntstatus.h + - ntverp.h + - oaidl.idl + - objbase.h + - objectarray.h + - objidl.h + - objsafe.h + - ocidl.h + - ocidl.idl + - odbcss.h + - ole.h + - ole2.h + - oleacc.h + - oleauto.h + - olectl.h + - packon.h + - packoff.h + - pathcch.h + - p2p.h + - pdh.h + - pdhmsg.h + - perflib.h + - persist.h + - poppack.h + - powerbase.h + - process.h + - processenv.h + - processsnapshot.h + - processthreadsapi.h + - processtopologyapi.h + - profileapi.h + - provider.h + - psapi.h + - pshpack1.h + - pshpack2.h + - pshpack4.h + - pshpack8.h + - qos.h + - ratings.h + - realtimeapiset.h + - reason.h + - richedit.h + - roapi.h + - robuffer.h + - rpc.h + - rpcdce.h + - rpcndr.h + - safeint.h + - sal.h + - sapi.h + - schannel.h + - schedule.h + - schnlsp.h + - scsi.h + - sddl.h + - sdkddkver.h + - sdv_driverspecs.h + - security.h + - securityappcontainer.h + - securitybaseapi.h + - sensors.h + - sfc.h + - share.h + - shellapi.h + - shlguid.h + - shlobj.h + - shlwapi.h + - shobjidl.h + - specstrings.h + - specstrings_strict.h + - specstrings_undef.h + - spellcheck.h + - sperror.h + - sspi.h + - stralign.h + - stringapiset.h + - strsafe.h + - suppress.h + - synchapi.h + - sys/locking.h + - sys/utime.h + - sysinfoapi.h + - systemtopologyapi.h + - tbs.h + - tchar.h + - tdi.h + - threadpoolapiset.h + - threadpoollegacyapiset.h + - timezoneapi.h + - tlhelp32.h + - traffic.h + - tune.h + - tvout.h + - unknwn.h + - unknwn.idl + - upnp.h + - urlmon.h + - urlmon.idl + - usb.h + - userenv.h + - usp10.h + - utilapiset.h + - uxtheme.h + - verrsrc.h + - versionhelpers.h + - vfw.h + - wbemidl.h + - websocket.h + - winapifamily.h + - winbase.h + - winber.h + - wincon.h + - wincrypt.h + - windef.h + - windns.h + - windows.applicationmodel.core.h + - windows.graphics.display.h + - windows.h + - windows.storage.h + - windows.storage.streams.h + - windows.system.threading.h + - windows.ui.xaml.h + - windows.ui.xaml.media.dxinterop.h + - windowsx.h + - winerror.h + - wingdi.h + - winhttp.h + - wininet.h + - winioctl.h + - winldap.h + - winnetwk.h + - winnls.h + - winnt.h + - winperf.h + - winreg.h + - winres.h + - winresrc.h + - winsdkver.h + - winsock.h + - winsock2.h + - winstring.h + - winsvc.h + - winternl.h + - winuser.h + - winver.h + - winwlx.h + - wnnc.h + - wow64apiset.h + - wrl.h + - wrl/async.h + - wrl/client.h + - wrl/event.h + - wrl/ftm.h + - wrl/implements.h + - wrl/wrappers/corewrappers.h + - ws2bth.h + - ws2def.h + - ws2ipdef.h + - ws2spi.h + - ws2tcpip.h + - wscapi.h + - wspiapi.h + - wtsapi32.h + - wtypes.h + - xa.h + - xaudio2.h + - xmllite.h diff --git a/build/ymake.core.conf b/build/ymake.core.conf new file mode 100644 index 00000000000..58b43fe2e5d --- /dev/null +++ b/build/ymake.core.conf @@ -0,0 +1,10553 @@ +# !!! DISCLAIMER! PLEASE DON'T IGNORE !!! +# The FAKEID value is huge hammer. It affects UIDs of all nodes in build graph including, but not limited to +# any resource fetch (think java contrib), build on any language (C++, Python, Java, Go), any code generation. +# Any build after this change will pay the price: +# - Local builds and Sandbox builds will reload all resources from Sandbox and cached data from YT (if ready). +# - Distributed (YT) cache warmup will take significant time to catch up and will need to recache everything. +# - Autocheck will rebuild and recache everything. +# Use this with extreme care and only change if it is ultimately needed. Consider more specific XXX_FAKEIDs below instead. +FAKEID=31415926535 + +SANDBOX_FAKEID=${FAKEID}.7600000 +CPP_FAKEID=2023-06-06 +GO_FAKEID=11100371 +ANDROID_FAKEID=2023-05-17 +CLANG_TIDY_FAKEID=2023-06-06 +CYTHON_FAKE_ID=10784829 +JAVA_FAKEID=10849009 + +# Change of this value will invalidate some parts of configure cache +# but will not affect builds anyhow (except tests referring build/ directory) +JSON_CACHE_FAKE_ID=11215402 + +REPORT_ALL_DUPSRC=yes + +CURDIR=. +MODDIR=. +BINDIR=bin:/ +SRCDIR= +YMAKE=ymake +ECHO=echo +INCLUDE_EXTS=.h .hh .hpp .rli .cuh .inc .i .ipp .ixx .ya_exposed +CPP_EXT=.cpp +OBJ_SUF= +CFLAGS= +EXTRA_C_FLAGS= +SFLAGS= +FORCE_COVERAGE_ENABLED= +FORCE_COVERAGE_DISABLED= + +AUTOCHECK_BALANCING_OPTIONS= +SO_OUTPUTS=no + +@import "${CONF_ROOT}/conf/settings.conf" +@import "${CONF_ROOT}/conf/opensource.conf" +@import "${CONF_ROOT}/conf/rules.conf" +@import "${CONF_ROOT}/conf/sysincl.conf" +@import "${CONF_ROOT}/conf/license.conf" +@import "${CONF_ROOT}/conf/ts/ts.conf" +@import "${CONF_ROOT}/conf/docs.conf" +@import "${CONF_ROOT}/conf/java.conf" + +@import "${CONF_ROOT}/conf/project_specific/other.conf" +@import "${CONF_ROOT}/conf/project_specific/uservices.conf" +@import "${CONF_ROOT}/conf/project_specific/yt.conf" + +USE_GLOBAL_CMD=no +when ($OS_WINDOWS != "yes") { + USE_GLOBAL_CMD=yes +} + +when ($USE_PYTHON) { + C_DEFINES+= -DUSE_PYTHON +} + +__COMMA__=${comma:""} + +ARCADIA_TEST_ROOT=../arcadia_tests_data/ +DEFAULT_REQUIREMENTS=network:restricted cpu:1 ram:32 + +FAIL_PY2=no + +_PREBUILT_TOOLS_ROOT=build/prebuilt +_TOOL_PROTOC_GEN_GO=vendor/github.com/golang/protobuf/protoc-gen-go +_TOOL_RESCOMPILER=tools/rescompiler +_TOOL_RESCOMPRESSOR=tools/rescompressor +_TOOL_RORESCOMPILER=tools/rorescompiler + +when ($DISABLE_SEPARATE_AUX_CPP != "yes") { + SEPARATE_AUX_CPP=yes +} + +when ($HOST_ARCH_X86_64 == "yes") { + when ($HOST_OS_DARWIN == "yes" || $HOST_OS_LINUX == "yes" || $HOST_OS_WINDOWS == "yes") { + VALID_HOST_PLATFORM_FOR_COMMON_PREBUILT_TOOLS=yes + + when ($USE_PREBUILT_TOOLS == "yes" && $ARCH_X86_64 == "yes") { + _TOOL_PROTOC_GEN_GO=${_PREBUILT_TOOLS_ROOT}/vendor/github.com/golang/protobuf/protoc-gen-go + } + } +} + +FAIL_MODULE_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/fail_module_cmd.py"} $TARGET ${kv;hide:"p ER"} ${kv;hide:"pc red"} +DEFAULT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml +PROJECT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml +TIDY= +TIDY_ENABLED= +when($TIDY == "yes") { + TIDY_ENABLED=yes +} + +when ($TIDY_ENABLED == "yes") { + when ($TIDY_EXPORT_FIXES=="") { + TIDY_EXPORT_FIXES="no" + } + + CLANG_TIDY_ARGS=${hide:CLANG_TIDY_FAKEID} $YMAKE_PYTHON ${input:"build/scripts/clang_tidy.py"} "--ymake-python" $YMAKE_PYTHON "--clang-tidy-bin" "$(CLANG_TIDY_BIN)/bin/clang-tidy" "--config-validation-script" ${input:"build/tests/config/clang_tidy/tidy_config_validation.py"} "--testing-src" ${input:SRC} "--source-root" $(SOURCE_ROOT) "--build-root" $(BUILD_ROOT) "--tidy-json" ${output;noauto;suf=${COMPILE_OUT_SUFFIX}${OBJ_CROSS_SUF}.tidyjson:SRC} "--export-fixes" $TIDY_EXPORT_FIXES + CLANG_TIDY_ARGS+="--default-config-file" ${input:DEFAULT_TIDY_CONFIG} + CLANG_TIDY_ARGS+="--project-config-file" ${input:PROJECT_TIDY_CONFIG} + when ($TIDY_CHECKS) { + CLANG_TIDY_ARGS+="--checks=$TIDY_CHECKS" + } + + when ($TIDY_HEADER_FILTER) { + CLANG_TIDY_ARGS+="--header-filter=$TIDY_HEADER_FILTER" + } + + TIDY_VALUE=USE_CONDITIONAL_SRCS +} +otherwise { + CLANG_TIDY_ARGS= + TIDY_VALUE= +} + +# tag:codenav +when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") { + PY_PROGRAM_LINK_EXE=$LINK_EXE ${kv;hide:"pyndex $TARGET"} + YNDEXER_ARGS=$YMAKE_PYTHON ${input:"build/scripts/yndexer.py"} $CPPYNDEXER_RESOURCE_GLOBAL/yndexer 1500 $(SOURCE_ROOT) $ARCADIA_BUILD_ROOT ${input:SRC} + YNDEXER_OUTPUT=${output;noauto;suf=${OBJ_CROSS_SUF}${COMPILE_OUT_SUFFIX}.ydx.pb2:SRC} +} +otherwise { + PY_PROGRAM_LINK_EXE=$LINK_EXE + YNDEXER_ARGS= + YNDEXER_OUTPUT= +} + +when ($RETRY == "yes") { + RETRY_ARGS=$YMAKE_PYTHON ${input:"build/scripts/wrapcc.py"} +} +otherwise { + RETRY_ARGS= +} + +COVERAGE_FLAGS= +EXTRA_OUTPUT= +when ($CLANG == "yes" || $GCC == "yes") { + when ($BUILD_TYPE == "COVERAGE" || $GCOV_COVERAGE) { + COVERAGE_FLAGS=-fprofile-arcs -ftest-coverage + EXTRA_OUTPUT=${output;noauto;hide;suf=${COMPILE_OUT_SUFFIX}${_CROSS_SUFFIX}.gcno:SRC} + } +} + +when ($OS_CYGWIN == "yes") { + CFLAGS+=-D_LDBL_EQ_DBL=1 -U__STRICT_ANSI__ + USE_ASMLIB=no + FSTACK= +} + +CFLAGS+=$COVERAGE_FLAGS +LDFLAGS+=$COVERAGE_FLAGS + +CHECKFLAG= +NO_MAPREDUCE= + +when ($NO_MAPREDUCE == "yes") { + C_DEFINES+=-DNO_MAPREDUCE +} + +when ($OS_ANDROID == "yes") { + PIE=yes +} + +# TODO: extract to conf/maps/maps.conf +when ($MAPSMOBI_BUILD_TARGET == "yes" && $OS_LINUX != "yes") { + USE_STL_SYSTEM=yes + ARCADIA_CURL_DNS_RESOLVER=MULTITHREADED +} +when ($MAPSMOBI_BUILD_TARGET == "yes" && $OS_IOS == "yes") { + BUILD_IOS_APP=yes + when ($ARCH_ARM7 || $ARCH_ARM64) { + BOOSTTEST_IS_FAT_OBJECT=yes + } +} + +when ($CLANG && $OS_DARWIN && $SANITIZER_TYPE && $SANITIZER_TYPE != "no") { + SO_OUTPUTS=yes +} + +when ($OS_NONE == "yes") { + USE_STL_SYSTEM=yes +} + +# USE_INTERNAL_STL is an internal flag (set on by default) but may be used externally to +# select system standard C++ library when USE_INTERNAL_STL=no is set. +# +# USE_STL_SYSTEM=yes is a regular way to select system standard C++ library. +# +when ($USE_STL_SYSTEM == "yes") { + USE_INTERNAL_STL=no +} + +when ($USE_INTERNAL_STL == "no") { + USE_STL_SYSTEM=yes +} +otherwise { + USE_INTERNAL_STL=yes + # TODO: Extract to conf/sysincl.conf + # This trigger doesn't work for module level since SYSINCL is processed at + # configuration stage (This means that NO_RUNTIME() macro called in ya.make + # won't affect SYSINCL and the only way to make this trigger work correctly + # is to define configuration variable NORUNTIME (-DNORUNTIME) on the command + # line when `ya make ...` is invoked. + when ($NORUNTIME != "yes") { + SYSINCL+=build/sysincl/stl-to-libcxx.yml + when ($MUSL == "yes") { + SYSINCL+=build/sysincl/libc-musl-libcxx.yml + } + } +} + +# tag:linux-specific +when ($OS_LINUX && $OS_SDK == "ubuntu-14" && $MUSL != "yes") { + USE_UBUNTU_COMPATIBILITY=yes +} + +USE_ARCADIA_PYTHON=yes +USE_ARCADIA_LIBM=no +USE_EAT_MY_DATA=no + +HAVE_MKL= +when ($HAVE_MKL == "") { + when ($OS_LINUX && $ARCH_X86_64 && !$SANITIZER_TYPE) { + HAVE_MKL=yes + } + otherwise { + HAVE_MKL=no + } +} + +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"} + +# tag:tool-specific tag:proto +PROTOC=${tool:"contrib/tools/protoc"} +PROTOC_STYLEGUIDE_OUT=--cpp_styleguide_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE +PROTOC_PLUGIN_STYLEGUIDE=--plugin=protoc-gen-cpp_styleguide=${tool:"contrib/tools/protoc/plugins/cpp_styleguide"} +PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf/src +USE_VANILLA_PROTOC=no +PROTOC_TRANSITIVE_HEADERS=yes +_PROTOC_FLAGS= + +# tag:tool-specific +FML_TOOL=${tool:"tools/relev_fml_codegen"} +FML_UNUSED_TOOL=${tool:"tools/relev_fml_unused"} +LUA_TOOL=${tool:"tools/lua"} +ENUM_PARSER_TOOL=${tool:"tools/enum_parser/enum_parser"} + +# tag:python-specific tag:cython-specific +CYTHON_SCRIPT=${input:"${ARCADIA_ROOT}/contrib/tools/cython/cython.py"} ${hide:CYTHON_FAKE_ID} $CYTHON_PREDEFINED_INCLUDES +RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT +RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT +PYTHON_TYPE_FOR_CYTHON=PY2 +CYTHON_OUTPUT_INCLUDES=\ +${output_include;hide:"contrib/libs/python/Include/compile.h"} \ +${output_include;hide:"contrib/libs/python/Include/frameobject.h"} \ +${output_include;hide:"contrib/libs/python/Include/longintrepr.h"} \ +${output_include;hide:"contrib/libs/python/Include/pyconfig.h"} \ +${output_include;hide:"contrib/libs/python/Include/Python.h"} \ +${output_include;hide:"contrib/libs/python/Include/pythread.h"} \ +${output_include;hide:"contrib/libs/python/Include/structmember.h"} \ +${output_include;hide:"contrib/libs/python/Include/traceback.h"} \ +${output_include;hide:"contrib/tools/cython/generated_c_headers.h"} \ +${output_include;hide:"omp.h"} + +# tag:cython-specific +CYTHON_CPP_OUTPUT_INCLUDES=${output_include;hide:"contrib/tools/cython/generated_cpp_headers.h"} + +# tag:cython-specific +CYTHON_PREDEFINED_INCLUDES=\ + ${input;hide:"contrib/tools/cython/Cython/Utility/Buffer.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Builtins.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/CMath.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Capsule.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/CommonTypes.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Complex.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Coroutine.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/CythonFunction.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Embed.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Exceptions.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/ExtensionTypes.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/FunctionArguments.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/ImportExport.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/MemoryView_C.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/ModuleSetupCode.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/ObjectHandling.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Optimize.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Overflow.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Printing.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/Profile.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/StringTools.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/TestUtilityLoader.c"} \ + ${input;hide:"contrib/tools/cython/Cython/Utility/TypeConversion.c"} + +# tag:cython-specific +CYTHON_PREDEFINED_INDUCED=\ + contrib/libs/python/Include/Python.h + +# tag:cython-specific +CYTHON_OPTIONS= +when ($OS_LINUX) { + CYTHON_OPTIONS += -E UNAME_SYSNAME=Linux +} +elsewhen ($OS_DARWIN) { + CYTHON_OPTIONS += -E UNAME_SYSNAME=Darwin +} +elsewhen ($OS_WINDOWS) { + CYTHON_OPTIONS += -E UNAME_SYSNAME=Windows +} + +when ($USE_LOCAL_SWIG != "yes") { + _SWIG_TOOL=${tool:"contrib/tools/swig"} + _SWIG_LIBRARY=contrib/tools/swig/Lib + _SWIG_LIBRARY_ABS=$ARCADIA_ROOT/$_SWIG_LIBRARY +} +otherwise { + _SWIG_TOOL=$SWIG_TOOL + _SWIG_LIBRARY=$SWIG_LIBRARY + _SWIG_LIBRARY_ABS=$SWIG_LIBRARY +} +SWIG_IMPLICIT_INCLUDES = swig.swg go.swg java.swg perl5.swg python.swg + +FATAL_ERROR_MODULE=no +FATAL_ERROR_MESSAGE= + +# tag:python-specific +# PYTHON_DISTR={ "default" | "macos-brew" } determine python system supply +# see build/platform/python/ya.make +PYTHON_DISTR="default" +when ($USE_SYSTEM_PYTHON) { + USE_ARCADIA_PYTHON=no + select ($USE_SYSTEM_PYTHON) { + "2.7" ? { + _SYSTEM_PYTHON27=yes + PY_VERSION=2.7 + PY_FRAMEWORK_VERSION=2.7 + } + "3.4" ? { + _SYSTEM_PYTHON34=yes + PY_VERSION=3.4m + PY_FRAMEWORK_VERSION=3.4 + } + "3.5" ? { + _SYSTEM_PYTHON35=yes + PY_VERSION=3.5m + PY_FRAMEWORK_VERSION=3.5 + } + "3.6" ? { + _SYSTEM_PYTHON36=yes + PY_VERSION=3.6m + PY_FRAMEWORK_VERSION=3.6 + } + "3.7" ? { + _SYSTEM_PYTHON37=yes + PY_VERSION=3.7m + PY_FRAMEWORK_VERSION=3.7 + } + "3.8" ? { + _SYSTEM_PYTHON38=yes + PY_VERSION=3.8 + PY_FRAMEWORK_VERSION=3.8 + } + "3.9" ? { + _SYSTEM_PYTHON39=yes + PY_VERSION=3.9 + PY_FRAMEWORK_VERSION=3.9 + } + "3.10" ? { + _SYSTEM_PYTHON310=yes + PY_VERSION=3.10 + PY_FRAMEWORK_VERSION=3.10 + } + "3.11" ? { + _SYSTEM_PYTHON311=yes + PY_VERSION=3.11 + PY_FRAMEWORK_VERSION=3.11 + } + default ? { + FATAL_ERROR_MESSAGE+=invalid USE_SYSTEM_PYTHON value + } + } +} + +ANTLR_PYTHON=Python2 + +### @usage: NO_LTO() +### +### Disable any lto (link-time optimizations) for the module. +### This will compile module source files as usual (without LTO) but will not prevent lto-enabled +### linking of entire program if global settings say so. +macro NO_LTO() { + DISABLE(USE_LTO) + DISABLE(USE_THINLTO) +} + +when ($BUILD_PYTHON3_BIN) { + YMAKE_PYTHON3=${BUILD_PYTHON3_BIN} + YMAKE_PYTHON3_PEERDIR= +} +otherwise { + YMAKE_PYTHON3=${YMAKE_PYTHON3_RESOURCE_GLOBAL}/python3 +} + +# tag:python-specific +when ($USE_ARCADIA_PYTHON == "no") { + SYSINCL+=build/sysincl/python.yml +} + +# tag:allocator +DEFAULT_ALLOCATOR=LF + +# tag:allocator +when ($OS_ANDROID == "yes" || $MSVC == "yes" || $ARCH_TYPE_32 == "yes" || $ARCH_AARCH64 == "yes") { + DEFAULT_ALLOCATOR=J +} + +# tag:allocator +when ($OS_CYGWIN == "yes" || $ARCH_PPC64LE == "yes") { + DEFAULT_ALLOCATOR=SYSTEM +} + +# tag:allocator +when ($OS_DARWIN == "yes") { + DEFAULT_ALLOCATOR=SYSTEM +} + +# tag:allocator +when ($OS_LINUX == "yes") { + when ($GCC) { + # tcmalloc broken build + } + elsewhen ($SANDBOXING) { + # broken + } + elsewhen ($ARCH_X86_64) { + DEFAULT_ALLOCATOR=TCMALLOC_TC + } +} + +# tag:allocator +when ($SANITIZER_TYPE) { + when ($SANITIZER_TYPE != "no") { + DEFAULT_ALLOCATOR=SYSTEM + } +} + +# tag:allocator +when ($ARCH_XTENSA == "yes") { + DEFAULT_ALLOCATOR=FAKE +} + +# tag:internal +### @usage: CHECK_CONFIG_H(<conf_header>) # internal +### +### This internal macro adds checking code for configuration header in external (contrib) library. +### The check is needed to avoid conflicts on certain types and functions available in arcadia. +### +### @see https://a.yandex-team.ru/arc/trunk/arcadia/build/scripts/check_config_h.py for exact details +macro CHECK_CONFIG_H(Conf) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/check_config_h.py"} ${input;rootrel:Conf} ${output;nopath;noext:Conf.config.cpp} ${kv;hide:"p CH"} ${kv;hide:"pc yellow"} + OUTPUT_INCLUDES=$Conf +} + +REQUIRED_TRANSITIVE_PEERS= +### @usage REQUIRES(dirs...) +### +### Specify list of dirs which this module must depend on indirectly. +### +### This macro can be used if module depends on the directories specified but they can't be listed +### as direct PEERDIR dependencies (due to public include order or link order issues). +macro REQUIRES(DIRS[]) { + SET_APPEND(REQUIRED_TRANSITIVE_PEERS $DIRS) +} + +CHECK_DEPENDENT_DIRS_TYPES= +CHECK_DEPENDENT_DIRS_RESTRICTIONS= +### @usage CHECK_DEPENDENT_DIRS(DENY|ALLOW_ONLY ([ALL|PEERDIRS|GLOB] dir)...) +### +### Specify project transitive dependencies constraints. +### +### @params: +### 1. DENY: current module can not depend on module from any specified directory neither directly nor transitively. +### 2. ALLOW_ONLY: current module can not depend on module from a dir not specified in the directory list neither directly nor transitively. +### 3. ALL: directory constraints following after this modifier are applied to both transitive PEERDIR dependencies and tool dependencies. +### 4. PEERDIRS: directory constraints following after this modifier are applied to transitive PEERDIR dependencies only. +### 5. GLOB: next directory constraint is an ANT glob pattern. +### 6. EXCEPT: next constraint is an exception for the rest of other rules. +### +### Directory constraints added before either ALL or PEERDIRS modifier is used are treated as ALL directory constraints. +### +### Note: Can be used multiple times on the same module all specified constraints will be checked. +### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY) +macro CHECK_DEPENDENT_DIRS(TYPE, ALL?"UNUSED":"", PEERDIRS?"PEERDIRS":"ALL", RESTRICTIONS...) { + SET_APPEND(CHECK_DEPENDENT_DIRS_RESTRICTIONS $PEERDIRS $RESTRICTIONS) + SET_APPEND(CHECK_DEPENDENT_DIRS_TYPES $TYPE) +} + +# tag:proto +PY_PROTOS_FOR=no +BUILD_PROTO_AS_EVLOG=no + +# tag:proto +PROTO_NAMESPACE= + +# tag:proto tag:python-specific +GEN_PY_PROTOS=$YMAKE_PYTHON ${input:"build/scripts/gen_py_protos.py"} + +# tag:proto tag:cpp-specific +PROTO_HEADER_EXTS=.pb.h +CPP_PROTO_CMDLINE= +CPP_PROTO_OPTS= +CPP_PROTO_OUTS= +CPP_PROTO_OUTS_SEM= +CPP_PROTO_SUFFIXES=.pb.h .pb.cc +CPP_PROTO_PLUGINS= + +# tag:proto tag:cpp-specific +CPP_EV_OPTS=--plugin=protoc-gen-event2cpp=${tool:"tools/event2cpp"} --event2cpp_out=$ARCADIA_BUILD_ROOT -I=$ARCADIA_ROOT/library/cpp/eventlog +CPP_EV_OUTS= +CPP_EV_OUTS_SEM= + +# tag:proto tag:python-specific +PY_PROTO_OPTS= +PY_PROTO_OUTS= +PY_PROTO_OUTS_INTERNAL= +PY_PROTO_DEPS= +PY_PROTO_SUFFIXES=_pb2.py +PY_EVLOG_SUFFIXES=_ev_pb2.py + +# tag:proto tag:java-specific +JAVA_PROTO_ARGS= + +# tag:proto tag:python-specific +OPTIMIZE_PY_PROTOS_FLAG=no + +macro _RESOURCE_SEM(INPUTS[], KEYS[]) { + SET(RESOURCE_OUTPUT ${hash:INPUTS}.cpp) + .SEM=resources ${output;global:RESOURCE_OUTPUT} INPUTS ${input:INPUTS} KEYS $KEYS ${tool;hide:"tools/rescompiler/bin"} +} + +# tag:built-in +### @usage: RESOURCE([FORCE_TEXT ][Src Key]* [- Key=Value]*) # built-in +### Add data (resources, random files, strings) to the program) +### The common usage is to place Src file into binary. The Key is used to access it using library/cpp/resource or library/python/resource. +### Alternative syntax with '- Key=Value' allows placing Value string as resource data into binary and make it accessible by Key. +### +### This is a simpler but less flexible option than ARCHIVE(), because in the case of ARCHIVE(), you have to use the data explicitly, +### and in the case of RESOURCE(), the data will fall through SRCS() or SRCS(GLOBAL) to binary linking. +### +### Use the FORCE_TEXT parameter to explicitly mark all Src files as text files: they will not be parsed unless used elsewhere. +### +### @example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a2ispolzujjtekomanduresource +### +### @example: +### +### LIBRARY() +### OWNER(user1) +### +### RESOURCE( +### path/to/file1 /key/in/program/1 +### path/to/file2 /key2 +### ) +### END() +### +macro RESOURCE(Args...) { + PEERDIR(library/cpp/resource) +} + +# tag:internal +### @usage: _ORDER_ADDINCL([BUILD ...] [SOURCE ...] Args...) # internal +### +### Order and filter ADDINCLs (Args - is intentionally omitted in ADDINCL macro) +macro _ORDER_ADDINCL(BUILD[], SOURCE[], ARGS...) { + ADDINCL($BUILD $SOURCE) +} + +# tag:proto +### @usage: PROTO_ADDINCL([GLOBAL] [WITH_GEN] Path) +### +### This macro introduces proper ADDINCLs for .proto-files found in sources and +### .cpp/.h generated files, supplying them to appropriate commands and allowing +### proper dependency resolution at configure-time. +### +### Note: you normally shouldn't use this macro. ADDINCLs should be sent to user +### from dependency via PROTO_NAMESPACE macro +macro PROTO_ADDINCL(GLOBAL?"GLOBAL":"", Path, WITH_GEN?"BUILD":"") { + _ORDER_ADDINCL($WITH_GEN $GLOBAL FOR proto ${ARCADIA_BUILD_ROOT}/$Path SOURCE $GLOBAL FOR proto ${ARCADIA_ROOT}/$Path) + ADDINCL($GLOBAL ${ARCADIA_BUILD_ROOT}/$Path) +} + +# tag:proto +### @usage: PROTO_NAMESPACE([WITH_GEN] Namespace) +### +### Defines protobuf namespace (import/export path prefix) which should be used for imports and +### which defines output path for .proto generation. +### +### For proper importing and configure-time dependency management it sets ADDINCLs +### for both .cpp headers includes and .proto imports. If .proto expected to be used outside of the +### processing module use GLOBAL to send proper ADDINCLs to all (transitive) users. PEERDIR to +### PROTO_LIBRARY with PROTO_NAMESPACE() is enough at user side to correctly use the library. +### If generated .proto files are going to be used for building a module than use of WITH_GEN +### parameter will add appropriate dir from the build root for .proto files search. +macro PROTO_NAMESPACE(GLOBAL?"GLOBAL":"", WITH_GEN?"WITH_GEN":"", Namespace) { + SET(PROTO_NAMESPACE $Namespace) + PROTO_ADDINCL(GLOBAL $WITH_GEN $Namespace) +} + +# tag:proto +### @usage PROTOC_FATAL_WARNINGS() +### +### Treat protoc warnings as fatal errors that break the build, for example, unused imports +### Adds `--fatal_warnings` argument to protoc +macro PROTOC_FATAL_WARNINGS() { + SET_APPEND(_PROTOC_FLAGS --fatal_warnings) +} + +# tag:proto tag:internal tag:python-specific +### @usage: OPTIMIZE_PY_PROTOS() # internal +### +### Enable Python proto optimization by embedding corresponding C++ code into binary. +### Python protobuf runtime will use C++ implementation instead of Python one if former is available. +### This is default mode for most PROTO_LIBRARY's and PY2_LIBRARY's, some system ones being exceptions. +macro OPTIMIZE_PY_PROTOS() { + SET(OPTIMIZE_PY_PROTOS_FLAG yes) +} + +# tag:proto tag:python-specific +### @usage: NO_OPTIMIZE_PY_PROTOS() +### +### Disable Python proto optimization using embedding corresponding C++ code into binary. +### Python protobuf runtime will use C++ implementation instead of Python one if former is available. +### This is default mode only for some system libraries. +macro NO_OPTIMIZE_PY_PROTOS() { + SET(OPTIMIZE_PY_PROTOS_FLAG no) +} + +# tag:proto tag:python-specific +macro _PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) { + .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$ARCADIA_BUILD_ROOT/\$PROTO_NAMESPACE ${pre=--${Name}_opt=:OutParm} + .SEM=IGNORED +} + +# tag:proto tag:python-specific +macro _ADD_PY_PROTO_OUT(Suf) { + SET_APPEND(PY_PROTO_OUTS \${output;hide;noauto;norel;nopath;noext;suf=$Suf:File}) + SET_APPEND(PY_PROTO_OUTS_INTERNAL \${output;hide;noauto;norel;nopath;noext;suf=__int__$Suf:File} \${hide;kv:"ext_out_name_for_\${nopath;noext;suf=__int__$Suf:File} \${nopath;noext;suf=$Suf:File}"}) + # XXX fix variable expansion in plugins + SET(PY_PROTO_SUFFIXES $PY_PROTO_SUFFIXES $Suf) +} + +# tag:proto tag:python-specific +### @usage: PY_PROTO_PLUGIN(Name Ext Tool DEPS <Dependencies>) +### +### Define protoc plugin for python with given Name that emits extra output with provided Extension +### using Tool. Extra dependencies are passed via DEPS +macro PY_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) { + SET_APPEND(PY_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL)) + _ADD_PY_PROTO_OUT($EXT) + # XXX fix variable expansion in plugins + SET(PY_PROTO_DEPS $PY_PROTO_DEPS $DEPS) +} + +# tag:proto tag:python-specific +### @usage: PY_PROTO_PLUGIN2(Name Ext1 Ext2 Tool DEPS <Dependencies>) +### +### Define protoc plugin for python with given Name that emits 2 extra outputs with provided Extensions +### using Tool. Extra dependencies are passed via DEPS +macro PY_PROTO_PLUGIN2(NAME, EXT1, EXT2, TOOL, DEPS[]) { + PY_PROTO_PLUGIN($NAME $EXT1 $TOOL DEPS $DEPS) + _ADD_PY_PROTO_OUT($EXT2) +} + +# tag:proto tag:java-specific +macro _JAVA_PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) { + .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$ARCADIA_BUILD_ROOT/java_out +} + +# tag:proto tag:java-specific +### @usage: JAVA_PROTO_PLUGIN(Name Tool DEPS <Dependencies>) +### +### Define protoc plugin for Java with given Name that emits extra outputs +### using Tool. Extra dependencies are passed via DEPS +macro JAVA_PROTO_PLUGIN(NAME, TOOL, DEPS[]) { + SET_APPEND(JAVA_PROTO_ARGS $_JAVA_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL)) + # XXX fix variable expansion in plugins + SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS $DEPS) +} + +macro _ADD_SEM_PROP_IF_NON_EMPTY(Prop, Args...) { + .SEM=${pre=&& set_target_property $Prop :Args} +} + +# tag:proto tag:cpp-specific +macro _ADD_CPP_PROTO_OUT(Suf) { + .SEM=append_target_property PROTOC_EXTRA_OUTS $Suf ${output;hide;suf=.o:Suf} $_ADD_SEM_PROP_IF_NON_EMPTY(PROTO_NAMESPACE $PROTO_NAMESPACE) + SET_APPEND(CPP_PROTO_OUTS \${output;hide;norel;nopath;noext;suf=$Suf:File}) + + # XXX fix variable expansion in plugins + SET(CPP_PROTO_SUFFIXES $CPP_PROTO_SUFFIXES $Suf) +} + +# tag:proto tag:cpp-specific +HAS_CPP_PROTOBUF_PEERS=no +CPP_PROTOBUF_PEERS= + +# tag:proto tag:cpp-specific +### @usage: CPP_PROTO_PLUGIN0(Name Tool DEPS <Dependencies>) +### +### Define protoc plugin for C++ with given Name that emits code into regular outputs +### using Tool. Extra dependencies are passed via DEPS. +macro CPP_PROTO_PLUGIN0(NAME, TOOL, DEPS[]) { + .SEM=target_proto_plugin $NAME ${tool;rootrel:TOOL} ${output;hide;suf=.fake.o:NAME} + SET_APPEND(CPP_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL)) + + # XXX fix variable expansion in plugins + ENABLE(HAS_CPP_PROTOBUF_PEERS) + SET(CPP_PROTOBUF_PEERS $CPP_PROTOBUF_PEERS $DEPS) +} + +# tag:proto tag:cpp-specific +### @usage: CPP_PROTO_PLUGIN(Name Tool Suf DEPS <Dependencies>) +### +### Define protoc plugin for C++ with given Name that emits code into 1 extra output +### using Tool. Extra dependencies are passed via DEPS. +macro CPP_PROTO_PLUGIN(NAME, TOOL, SUF, DEPS[]) { + CPP_PROTO_PLUGIN0($NAME $TOOL DEPS $DEPS) + + _ADD_CPP_PROTO_OUT($SUF) +} + +# tag:proto tag:cpp-specific +### @usage: CPP_PROTO_PLUGIN2(Name Tool Suf1 Suf2 DEPS <Dependencies>) +### +### Define protoc plugin for C++ with given Name that emits code into 2 extra outputs +### using Tool. Extra dependencies are passed via DEPS. +macro CPP_PROTO_PLUGIN2(NAME, TOOL, SUF1, SUF2, DEPS[]) { + CPP_PROTO_PLUGIN($NAME $TOOL $SUF1 DEPS $DEPS) + + _ADD_CPP_PROTO_OUT($SUF2) + SET_APPEND(CPP_PROTO_OUTS_SEM \${output;hide;norel;nopath;noext;suf=$SUF2:File}) +} + +# tag:proto +### @usage: USE_SKIFF() #wip, do not use +### +### Use mapreduce/yt/skiff_proto/plugin for C++ +macro USE_SKIFF() { + # Move extra includes to INDUCED_DEPS macro in mapreduce/yt/skiff_proto/plugin/ya.make + CPP_PROTO_PLUGIN0(skiff mapreduce/yt/skiff_proto/plugin DEPS mapreduce/yt/skiff_proto/lib) +} + +# tag:go-specific +_GO_COMMON_GOOGLE_APIS = \ +vendor/google.golang.org/genproto/googleapis/api/annotations \ +vendor/google.golang.org/genproto/googleapis/api/configchange \ +vendor/google.golang.org/genproto/googleapis/api/distribution \ +vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1 \ +vendor/google.golang.org/genproto/googleapis/api/expr/v1beta1 \ +vendor/google.golang.org/genproto/googleapis/api/httpbody \ +vendor/google.golang.org/genproto/googleapis/api/label \ +vendor/google.golang.org/genproto/googleapis/api/metric \ +vendor/google.golang.org/genproto/googleapis/api/monitoredres \ +vendor/google.golang.org/genproto/googleapis/api/serviceconfig \ +vendor/google.golang.org/genproto/googleapis/api/servicecontrol/v1 \ +vendor/google.golang.org/genproto/googleapis/api/servicemanagement/v1 \ +vendor/google.golang.org/genproto/googleapis/iam/admin/v1 \ +vendor/google.golang.org/genproto/googleapis/iam/credentials/v1 \ +vendor/google.golang.org/genproto/googleapis/iam/v1 \ +vendor/google.golang.org/genproto/googleapis/iam/v1/logging \ +vendor/google.golang.org/genproto/googleapis/logging/type \ +vendor/google.golang.org/genproto/googleapis/logging/v2 \ +vendor/google.golang.org/genproto/googleapis/rpc/code \ +vendor/google.golang.org/genproto/googleapis/rpc/errdetails \ +vendor/google.golang.org/genproto/googleapis/rpc/status \ +vendor/google.golang.org/genproto/googleapis/type/calendarperiod \ +vendor/google.golang.org/genproto/googleapis/type/color \ +vendor/google.golang.org/genproto/googleapis/type/date \ +vendor/google.golang.org/genproto/googleapis/type/dayofweek \ +vendor/google.golang.org/genproto/googleapis/type/expr \ +vendor/google.golang.org/genproto/googleapis/type/fraction \ +vendor/google.golang.org/genproto/googleapis/type/latlng \ +vendor/google.golang.org/genproto/googleapis/type/money \ +vendor/google.golang.org/genproto/googleapis/type/postaladdress \ +vendor/google.golang.org/genproto/googleapis/type/quaternion \ +vendor/google.golang.org/genproto/googleapis/type/timeofday + +# tag:go-specific +_COMMON_GOOGLE_APIS=None + +# tag:go-specific +### @usage: USE_COMMON_GOOGLE_APIS([apis...]) +### +### Use common-google-apis library set. Pass optional apis list to be used or use them all. +### This macro is properly handled for all languages including Go, where apis come in +## pregenerated form. In other languages apis are generated from sources in Arcadia. +macro USE_COMMON_GOOGLE_APIS(APIS...) { + SET(_COMMON_GOOGLE_APIS ${pre=vendor/google.golang.org/genproto/googleapis/:APIS}) +} + +# tag:go-specific tag:proto +GO_PROTO_GEN_PLUGINS= +GO_PROTO_OPTS= +GO_PROTO_OUTS= + +# tag:go-specific tag:proto +GO_PROTOBUF_IMPORTS=\ + ${GOSTD}/sync \ + ${GOSTD}/reflect \ + ${GOSTD}/fmt \ + ${GOSTD}/math \ + vendor/github.com/golang/protobuf/proto \ + vendor/google.golang.org/protobuf/types/descriptorpb \ + vendor/google.golang.org/protobuf/runtime/protoimpl \ + vendor/google.golang.org/protobuf/runtime/protoiface \ + vendor/google.golang.org/protobuf/reflect/protoreflect + +# tag:go-specific tag:proto +GO_PROTOBUF_WELLKNOWN_TYPES=\ + vendor/google.golang.org/protobuf/types/known/anypb \ + vendor/google.golang.org/protobuf/types/known/apipb \ + vendor/google.golang.org/protobuf/types/known/durationpb \ + vendor/google.golang.org/protobuf/types/known/emptypb \ + vendor/google.golang.org/protobuf/types/known/fieldmaskpb \ + vendor/google.golang.org/protobuf/types/known/sourcecontextpb \ + vendor/google.golang.org/protobuf/types/known/structpb \ + vendor/google.golang.org/protobuf/types/known/timestamppb \ + vendor/google.golang.org/protobuf/types/known/typepb \ + vendor/google.golang.org/protobuf/types/known/wrapperspb + +# tag:go-specific tag:proto +### @usage: GO_PROTO_PLUGIN(Name Ext Tool [DEPS dependencies...]) +### +### Define protoc plugin for GO with given Name that emits extra output with provided extension +### Ext using Tool. Extra dependencies are passed via DEPS. +macro GO_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) { + SET_APPEND(GO_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL)) + SET_APPEND(GO_PROTO_OUTS \${output;hide;noauto;norel;nopath;noext;suf=$EXT:File}) + PEERDIR(${DEPS}) +} + +# tag:go-specific tag:proto +GO_PROTO_CMDLINE=${cwd;rootdir;input:File} $YMAKE_PYTHON3 ${input:"build/scripts/go_proto_wrapper.py"} $GO_ARCADIA_PROJECT_PREFIX $GO_CONTRIB_PROJECT_PREFIX ./$PROTO_NAMESPACE $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH $_PROTOC_FLAGS ${input;rootrel:File} + +# tag:go-specific tag:proto +macro _GO_PROTO_CMD_IMPL(File, OPTS...) { + .CMD=$GO_PROTO_CMDLINE $OPTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} + .PEERDIR=${GO_PROTOBUF_IMPORTS} ${GO_PROTOBUF_WELLKNOWN_TYPES} + .ADDINCL=FOR proto contrib/libs/protobuf/src +} + +# tag:go-specific tag:proto +macro _GO_PROTO_CMD(File) { + .CMD=$_GO_PROTO_CMD_IMPL($File $GO_PROTO_OPTS $GO_PROTO_OUTS) +} + +# tag:proto +### @usage: YP_PROTO_YSON(Files... OUT_OPTS Opts...) +### +### Generate .yson.go from .proto using yp/go/yson/internal/proto-yson-gen/cmd/proto-yson-gen +macro YP_PROTO_YSON(OUT_OPTS[], Files...) { + .CMD=${cwd:BINDIR} $PROTOC --plugin=protoc-gen-custom=${tool:"yp/go/yson/internal/proto-yson-gen/cmd/proto-yson-gen"} -I=${ARCADIA_ROOT}/${PROTO_NAMESPACE} ${pre=-I=:_PROTO__INCLUDE} -I=${ARCADIA_ROOT} --custom_out="$OUT_OPTS paths=base_name:." --custom_opt="goroot=${GO_TOOLS_ROOT}" $_PROTOC_FLAGS ${input:Files} ${output;hide;noauto;nopath;noext;suf=.yson.go:Files} + .ADDINCL=FOR proto ${ARCADIA_ROOT}/${MODDIR} FOR proto ${ARCADIA_ROOT}/${GO_TEST_IMPORT_PATH} FOR proto yt ${ARCADIA_BUILD_ROOT}/yt FOR proto contrib/libs/protobuf/src + .PEERDIR=$GOSTD/strings $GOSTD/fmt $GOSTD/errors $GOSTD/encoding/json library/go/core/xerrors yt/go/yson yt/go/yterrors yp/go/yson/ytypes contrib/libs/protobuf + +} + +_SEM_CPP_PROTO_CMD=target_proto_messages PRIVATE ${input:File} $CPP_PROTO_OUTS_SEM ${output;hide;suf=${OBJ_SUF}.pb.o:File} ${hide;tool:"contrib/tools/protoc/bin"} ${hide;tool:"contrib/tools/protoc/plugins/cpp_styleguide"} \ + && set_global_flags COMMON_PROTOC_FLAGS \ + && target_proto_outs --cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT \ + && target_proto_addincls ./$PROTO_NAMESPACE $ARCADIA_ROOT/$PROTO_NAMESPACE ${_PROTO__INCLUDE} $ARCADIA_BUILD_ROOT $PROTOBUF_PATH + +# tag:proto +macro _CPP_PROTO_CMD(File) { + .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} + .SEM=$_SEM_CPP_PROTO_CMD + .PEERDIR=contrib/libs/protobuf +} + +# tag:proto +macro _CPP_VANILLA_PROTO_CMD(File) { + .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} + .PEERDIR=contrib/libs/protobuf_std +} + +_SEM_CPP_EV_CMD=target_ev_messages PRIVATE ${input:File} $CPP_EV_OUTS_SEM ${output;hide;suf=${OBJ_SUF}.pb.o:File} ${hide;tool:"tools/event2cpp/bin"} ${hide;tool:"contrib/tools/protoc/bin"} ${hide;tool:"contrib/tools/protoc/plugins/cpp_styleguide"} \ + && set_global_flags COMMON_PROTOC_FLAGS \ + && target_proto_outs --cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT --event2cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE \ + && target_proto_addincls ./$PROTO_NAMESPACE $ARCADIA_ROOT/$PROTO_NAMESPACE ${_PROTO__INCLUDE} $ARCADIA_BUILD_ROOT $PROTOBUF_PATH $ARCADIA_ROOT/library/cpp/eventlog + +# tag:proto +macro _CPP_EVLOG_CMD(File) { + .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS $CPP_EV_OUTS ${kv;hide:"p EV"} ${kv;hide:"pc yellow"} + .SEM=$_SEM_CPP_EV_CMD + .PEERDIR=library/cpp/eventlog contrib/libs/protobuf +} + +# tag:proto +macro _CPP_PROTO_EVLOG_CMD(File) { + # process .proto as .ev + .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} + .PEERDIR=library/cpp/eventlog contrib/libs/protobuf +} + +# tag:proto +macro _CPP_CFGPROTO_CMD(File) { + # keep extension in output just as in EV: this is hard-coded behaviour of protoc for non-.proto extensions + .CMD=$CPP_PROTO_CMDLINE --plugin=protoc-gen-config=${tool:"library/cpp/proto_config/plugin"} --config_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $CPP_EV_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} + .PEERDIR=library/cpp/proto_config/codegen library/cpp/proto_config/protos contrib/libs/protobuf +} + +# tag:proto +PY_PROTO_MYPY_ENABLED=yes +PY_PROTO_MYPY_PLUGIN_BASE=--plugin=protoc-gen-mypy=${tool:"contrib/python/mypy-protobuf/bin/protoc-gen-mypy"} --mypy_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE + +# tag:proto tag:python-specific +PY_PROTO_MYPY_SUFFIX= +PY_PROTO_MYPY_PLUGIN= +PY_PROTO_MYPY_PLUGIN_INTERNAL= + +# tag:proto tag:python-specific +macro NO_MYPY() { + DISABLE(PY_PROTO_MYPY_ENABLED) +} + +# tag:proto tag:python-specific +macro _PY_PROTO_CMD_BASE(File, Suf, Args...) { + .CMD=$PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH --python_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $_PROTOC_FLAGS ${input;rootrel:File} ${output;hide;noauto;norel;nopath;noext;suf=$Suf:File} ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} $Args +} + +# tag:proto tag:python-specific +macro _PY_PROTO_CMD(File) { + .CMD=${cwd;rootdir;input:File} $_PY_PROTO_CMD_BASE($File _pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS $PY_PROTO_MYPY_PLUGIN) +} + +# tag:proto tag:python-specific +macro _PY_PROTO_CMD_INTERNAL(File) { + .CMD=${cwd;rootdir;input:File} $GEN_PY_PROTOS --suffixes $PY_PROTO_SUFFIXES $PY_PROTO_MYPY_SUFFIX -- $_PY_PROTO_CMD_BASE($File __int___pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS_INTERNAL ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___pb2.py:File} ${nopath;noext;suf=_pb2.py:File}"} $PY_PROTO_MYPY_PLUGIN_INTERNAL) +} + +# tag:proto tag:java-specific +JAVA_PROTO_RUNTIME= + +# tag:proto tag:java-specific +### @usage: USE_JAVALITE() +### Use protobuf-javalite for Java +macro USE_JAVALITE() { + SET(JAVA_PROTO_RUNTIME javalite) +} + +# tag:proto tag:java-specific +JAVA_PROTO_RUNTIME_VERSION = 3.21.12 +JAVA_PROTO_COMMON_VERSION = 1.12.0 +KOTLIN_PROTO=no +KOTLIN_PROTO_PEERS= +when ($JAVA_PROTO_RUNTIME == "javalite") { + _JAVA_PROTO_LITE_ARG=lite: + JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS} + JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/1.43.2 + JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/1.43.2 +} +otherwise { + _JAVA_PROTO_LITE_ARG= + JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS} + JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/1.43.2 + JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/1.43.2 +} + +KOTLIN_PROTO_FLAGS= +# tag:proto tag:java-specific +macro _JAVA_PROTO_CMD(File) { + .CMD=${cwd;rootdir;input:File} $YMAKE_PYTHON ${input:"build/scripts/tared_protoc.py"} --tar-output ${output;norel;nopath;noext;suf=.jsrc:File} --protoc-out-dir $ARCADIA_BUILD_ROOT/java_out $PROTOC -I=./$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_ROOT --java_out=${_JAVA_PROTO_LITE_ARG}$ARCADIA_BUILD_ROOT/java_out ${KOTLIN_PROTO_FLAGS} $_PROTOC_FLAGS ${input;rootrel:File} ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} $JAVA_PROTO_ARGS + .SEM=proto_files ${input;rootrel:File} ${hide;output:File.jsrc} +} + + +# tag:proto tag:perl-specific tag:deprecated +### @usage: XS_PROTO(InputProto Dir Outputs...) # deprecated +### +### Generate Perl code from protobuf. +### In order to use this macro one should predict all outputs protoc will emit from input_proto file and enlist those as outputs. +macro XS_PROTO(File, Dir, Outputs...) { + .CMD=$PROTOC -I=${ARCADIA_ROOT}/${Dir} ${pre=-I=:_PROTO__INCLUDE} -I=${ARCADIA_ROOT} -I=${PROTOBUF_PATH} --perlxs_out=${BINDIR} $_PROTOC_FLAGS ${input:File} ${hide;output:Outputs} ${induced_deps=h+cpp;hide;nopath;noext;suf=.pb.h:File} + PEERDIR(${Dir}) + ADDINCL(${ARCADIA_BUILD_ROOT}/${Dir}) +} + +# tag:proto tag:fbs +### @usage: PROTO2FBS(InputProto) +### +### Produce flatbuf schema out of protobuf description. +macro PROTO2FBS(File) { + .CMD=${cwd:BINDIR} ${tool:"contrib/tools/flatc"} -I . -I ${ARCADIA_ROOT} --proto ${input:File} ${output;hide;norel;noext:File.fbs} ${kv;hide:"p FBS"} ${kv;hide:"pc yellow"} && $MOVE_FILE ${BINDIR}/${nopath;noext:File.fbs} ${output;norel;noext:File.fbs} +} + +# tag:proto tag:python-specific +when ($PY_PROTOS_FOR == "yes") { + PEERDIR+=contrib/libs/protobuf/python +} + +# tag:python-specific +macro _PY_EVLOG_CMD_BASE(File, Suf, Args...) { + .CMD=$_PY_PROTO_CMD_BASE($File $Suf $Args) + .PEERDIR=library/cpp/eventlog/proto +} + +# tag:python-specific tag:proto +macro _PY_EVLOG_CMD(File) { + .CMD=${cwd;rootdir;input:File} $_PY_EVLOG_CMD_BASE($File _ev_pb2.py) +} + +# tag:python-specific tag:proto +macro _PY_EVLOG_CMD_INTERNAL(File) { + .CMD=${cwd;rootdir;input:File} $GEN_PY_PROTOS --suffixes $PY_EVLOG_SUFFIXES -- $_PY_EVLOG_CMD_BASE($File __int___ev_pb2.py ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___ev_pb2.py:File} ${nopath;noext;suf=_ev_pb2.py:File}"}) +} + +# tag:java-specific tag:proto +macro _JAVA_EVLOG_CMD(File) { + .CMD=$COPY_CMD ${input:File} ${output;nopath;noext;norel;suf=_ev.proto:File} ${kv;hide:"p EV"} ${kv;hide:"pc yellow"} + .PEERDIR=library/cpp/eventlog/proto +} + +# tag:sanitize +RUN_NO_SANITIZE=$YMAKE_PYTHON ${input:"build/scripts/run_tool.py"} -- + +# tag:sanitize +when ($IS_CROSS_SANITIZE) { + RUN_NO_SANITIZE= +} + +YIELD=$YMAKE_PYTHON ${input:"build/scripts/yield_line.py"} -- ${BINDIR}/__args +XARGS=$YMAKE_PYTHON ${input:"build/scripts/xargs.py"} -- ${BINDIR}/__args + +WRITER_PY=$YMAKE_PYTHON ${input:"build/scripts/writer.py"} ${input;hide:"build/scripts/process_command_files.py"} +FS_TOOLS=$YMAKE_PYTHON ${input:"build/scripts/fs_tools.py"} ${input;hide:"build/scripts/process_command_files.py"} +FIX_MSVC_OUTPUT=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} ${input;hide:"build/scripts/process_command_files.py"} +_PROCESS_WHOLE_ARCHIVE_SCRIPT=${input;hide:"build/scripts/process_command_files.py"} ${input;hide:"build/scripts/process_whole_archive_option.py"} + +COPY_CMD=$FS_TOOLS copy +LINK_OR_COPY_CMD=$FS_TOOLS link_or_copy +REMOVE_FILE=$FS_TOOLS remove +MOVE_FILE=$FS_TOOLS rename + +# tag:allocator tag:windows-specific +MSVC_DYNAMICBASE=/DYNAMICBASE +when ($ALLOCATOR == "LF") { + MSVC_DYNAMICBASE=/DYNAMICBASE:NO +} + +# tag:sanitize +SANITIZE_HEADERS=yes +SANITIZER_CFLAGS= + +# tag:proto tag:grpc +_GRPC_ENABLED=no + +# tag:proto tag:grpc +### @usage: GRPC() +### +### Emit GRPC code for all .proto files in a PROTO_LIBRARY. +### This works for all available PROTO_LIBRARY versions (C++, Python 2.x, Python 3.x, Java and Go). +macro GRPC() { + ENABLE(_GRPC_ENABLED) + + # C++ + CPP_PROTO_PLUGIN2(grpc_cpp contrib/tools/protoc/plugins/grpc_cpp .grpc.pb.cc .grpc.pb.h DEPS contrib/libs/grpc) + + # Python + PY_PROTO_PLUGIN(grpc_py _pb2_grpc.py contrib/tools/protoc/plugins/grpc_python DEPS contrib/python/grpcio) + + # Java + JAVA_PROTO_PLUGIN(grpc_java contrib/tools/protoc/plugins/grpc_java DEPS $JAVA_GRPC_STUB $JAVA_GRPC_PROTOBUF) + SET_APPEND(JAVA_PROTOBUF_PEERS contrib/java/javax/annotation/javax.annotation-api/1.3.1) +} + +# tag:fbs +FLATC_FLAGS_VALUE= +### @usage: FLATC_FLAGS(flags...) +### +### Add flags to flatc command line +macro FLATC_FLAGS(FLAGS...) { + SET_APPEND(FLATC_FLAGS_VALUE $FLAGS) +} + +# tag:fbs +_PY_FBS_DEPS=contrib/python/flatbuffers + +# tag:fbs tag:internal +### @usage: FBS_TO_PYSRC(output_base_name fbs_files...) # internal +### +### Create a tar archive of .py files generated by flatc for Python. Output tar +### archive will have .fbs.pysrc extension. This .fbs.pysrc extension is specially +### processed when --add-flatbuf-result flag is specified on the command line +### for 'ya make ...' (tar archive is extracted to output directory). +macro FBS_TO_PYSRC(OUT_NAME, IN_FBS_FILES...) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --python --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:IN_FBS_FILES} && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --exts .py --input $BINDIR --output ${output;noauto;tared:OUT_NAME.fbs.pysrc} ${kv;hide:"p FP"} ${kv;hide:"pc light-green"} ${kv;hide:"tared_kind nodir"} +} + +# tag:fbs tag:go-specific +# Implicit dependencies of generated code for Go +_GO_FLATC_IMPORTS=\ + ${GOSTD}/strconv \ + vendor/github.com/google/flatbuffers/go + +# tag:fbs tag:cpp-specific +macro _CPP_FLATC_CMD(SRC, SRCFLAGS...) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:"contrib/tools/flatc"} --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --yandex-maps-iter --gen-object-api --filename-suffix .fbs ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${output;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${input:SRC} ${output;hide;noext;norel:SRC.iter.fbs.h} ${output;noauto;hide;noext;norel:SRC.bfbs} ${kv;hide:"p FL"} ${kv;hide:"pc light-green"} + .SEM=target_fbs_source PRIVATE ${input:SRC} ${pre=-I :_FLATC__INCLUDE} ${output;hide;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${output;hide;noext;norel:SRC.iter.fbs.h} ${output;noauto;hide;noext;norel:SRC.bfbs} ${hide;tool:"contrib/tools/flatc/bin"} && set_global_flags FBS_CPP_FLAGS --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --yandex-maps-iter --gen-object-api --filename-suffix .fbs ${FLATC_FLAGS_VALUE} ${input;hide:"build/scripts/cpp_flatc_wrapper.py"} + .PEERDIR=contrib/libs/flatbuffers +} + +# tag:fbs tag:cpp-specific +macro _CPP_FLATC64_CMD(SRC, SRCFLAGS...) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:"contrib/tools/flatc64"} --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --filename-suffix .fbs64 ${FLATC_FLAGS_VALUE} -I ${ARCADIA_ROOT} -I ${ARCADIA_BUILD_ROOT} -o ${output;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${input:SRC} ${output;noauto;hide;noext;norel:SRC.bfbs64} ${kv;hide:"p FL64"} ${kv;hide:"pc light-green"} + .PEERDIR=contrib/libs/flatbuffers64 +} + +# tag:fbs tag:go-specific tag:internal +### @usage: _GO_FLATC_CMD(fbs_file flags...) # internal +### +### Create a tar archive of .go files generated by flatc for Go. Output tar archive +### will have .fbs.gosrc extension. This .fbs.gosrc is specially processed when +### --add-protobuf-result flag is specified on the command line for 'ya make ...' +### (tar archive is extracted to output directory). +macro _GO_FLATC_CMD(SRC, PACKAGE_NAME) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --go --gen-mutable --go-namespace ${PACKAGE_NAME} ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR}/_generated ${input:SRC} && $YMAKE_PYTHON3 ${input:"build/scripts/postprocess_go_fbs.py"} --input-dir ${BINDIR} --map $_FBS_NAMESPACE_MAP_GLOBAL && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --flat --input ${BINDIR}/_generated --output ${output;noext;tared:SRC.fbs.gosrc} --exts .go ${kv;hide:"p FG"} ${kv;hide:"pc light-green"} ${kv;hide:"tared_kind nodir"} + .PEERDIR=${_GO_FLATC_IMPORTS} +} + +# tag:fbs tag:java-specific tag:internal +### @usage: _JAVA_FLATC_CMD(fbs_file) # internal +### +### Create a tar archive of .java files generated by flatc for Java. Output tar +### acrchive will have .fbs.jsrc extension. Files with .fbs.jsrc extension will +### be added to results when --add-flatbuf-result flag is specified on the command +### line for 'ya make ...' +macro _JAVA_FLATC_CMD(SRC) { + .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --java --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:SRC} && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --input $BINDIR --output ${output;nopath;noext:SRC.fbs.jsrc} --exts .java ${kv;hide:"p FJ"} ${kv;hide:"pc light-green"} + .PEERDIR=contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION} +} + +# variables must be defined for all module types to make generate_mf.py work +MODULE_PREFIX= +MODULE_SUFFIX= +NEED_PLATFORM_PEERDIRS=yes +PEERDIR_TEST_TOOL=yes + +# tag:python-specific +PYTHON2=no +PYTHON3=no + +# tag:python-specific +when (!$ARCADIA_PYTHON_UNICODE_SIZE) { + when ($OS_WINDOWS) { + ARCADIA_PYTHON_UNICODE_SIZE=2 + } + otherwise { + ARCADIA_PYTHON_UNICODE_SIZE=4 + } +} + +YMAKE_PYTHON3_PEERDIR=build/platform/python/ymake_python3 +macro NO_YMAKE_PYTHON3() { + SET(YMAKE_PYTHON3_PEERDIR) +} + +### @usage: _BARE_UNIT # internal +### +### The base of all modules describing default bare minimum for all modules. +### To avoid surprises, all buildable modules are better to be inherited from it or its descendants. +module _BARE_UNIT { + .EXTS=.* + .CMD=TOUCH_UNIT + .IGNORED=GO_PROTO_PLUGIN + .NODE_TYPE=Bundle + .PEERDIR_POLICY=as_include + .RESTRICTED=GRPC USE_SKIFF INDUCED_DEPS FUZZ_DICTS FUZZ_OPTS PACK EXPLICIT_OUTPUTS DOCS_DIR DOCS_CONFIG DOCS_VARS YT_SPEC USE_CXX USE_UTIL WHOLE_ARCHIVE PRIMARY_OUTPUT SECONDARY_OUTPUT DEPENDENCY_MANAGEMENT EXCLUDE NO_DOCTESTS EMBED_JAVA_VCS_INFO RESOURCE_FILES PACK_GLOBALS_IN_LIBRARY _EXPOSE GLOBAL_DEPS LIST_PROTO + .FINAL_TARGET=no + + PEERDIR_TAGS=__EMPTY__ + PEERDIR+=$YMAKE_PYTHON3_PEERDIR + + when ($FATAL_ERROR_MESSAGE && $FATAL_ERROR_MODULE != "yes") { + PEERDIR+=build/conf_fatal_error + } + + DEFAULT(MODULE_VERSION) + DEFAULT(MODULE_PREFIX) + DEFAULT(MODULE_SUFFIX) +} + +### @usage: GEN_LIBRARY() +### +### Definition of a module that brings generated artefacts. This module can PEERDIRed +### from any module. The resulted module is empty and cleaned up during construction +### of the build graph. +### +### NOTE! SRCS macro is not supported for this library. +module GEN_LIBRARY: _BARE_UNIT { + .PROXY=yes + .RESTRICTED=SRCS SRC + .SEM=IGNORED + + # ENABLE(_FAKE_MODULE) + SET(MODULE_SUFFIX .pkg.fake) +} + +### @usage: _BASE_UNIT # internal +### +### The base of all LIBRARY/PROGRAM modules describing common logic for all modules. +### To avoid surprises, all buildable modules are better to be inherited from it or its descendants. +module _BASE_UNIT: _BARE_UNIT { + .GLOBAL=_FBS_NAMESPACE_MAP + + PEERDIR_TAGS=CPP_PROTO CPP_FBS CPP_SSQLS H_IDL PY2 PY2_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB + + CPP_PROTO_CMDLINE=${cwd;rootdir;input:File} $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH --cpp_out=${CPP_PROTO_PLUGINS}$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $_PROTOC_FLAGS $PROTOC_STYLEGUIDE_OUT $PROTOC_PLUGIN_STYLEGUIDE ${input;rootrel:File} + CPP_PROTO_OUTS+=${output;hide;norel;nopath;noext:File.pb.cc} ${output;main;hide;norel;nopath;noext:File.pb.h} + CPP_PROTO_OUTS_SEM+=${output;main;hide;norel;nopath;noext:File.pb.h} + CPP_EV_OUTS+=${output;hide;norel:File.pb.cc} ${output;hide;norel:File.pb.h} + CPP_EV_OUTS_SEM+=${output;hide;norel:File.pb.h} + + when ($SWIG_LANG == "perl") { + _SWIG_CMD=$_SWIG_PERL_CMD + _SWIG_ADDINCLS=$_SWIG_PERL_ADDINCLS + _SWIG_PEERDIR=$_SWIG_PERL_PEERDIR + } + elsewhen ($SWIG_LANG == "python") { + _SWIG_CMD=$_SWIG_PYTHON_CMD + _SWIG_ADDINCLS=$_SWIG_PYTHON_ADDINCLS + _SWIG_PEERDIR=$_SWIG_PYTHON_PEERDIR + } + elsewhen ($SWIG_LANG == "jni_cpp") { + _SWIG_CMD=$_SWIG_JNI_CPP_CMD + _SWIG_ADDINCLS=$_SWIG_JNI_ADDINCLS + _SWIG_PEERDIR=$_SWIG_JNI_PEERDIR + } + elsewhen ($SWIG_LANG == "java") { + _SWIG_CMD=$_SWIG_JNI_CMD + _SWIG_ADDINCLS=$_SWIG_JNI_ADDINCLS + _SWIG_PEERDIR=$_SWIG_JNI_PEERDIR + } + + when ($PY_PROTOS_FOR == "yes") { + MACRO_ALIAS(EVLOG_CMD _PY_EVLOG_CMD) + MACRO_ALIAS(PROTO_CMD _PY_PROTO_CMD) + } + otherwise { + MACRO_ALIAS(EVLOG_CMD _CPP_EVLOG_CMD) + MACRO_ALIAS(FBS_CMD _CPP_FLATC_CMD) + when ($BUILD_PROTO_AS_EVLOG == "yes") { + MACRO_ALIAS(PROTO_CMD _CPP_PROTO_EVLOG_CMD) + } + otherwise { + MACRO_ALIAS(PROTO_CMD _CPP_PROTO_CMD) + } + when ($USE_VANILLA_PROTOC == "yes") { + PROTOC=${tool:"contrib/tools/protoc_std"} + PROTOC_STYLEGUIDE_OUT= + PROTOC_PLUGIN_STYLEGUIDE= + PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf_std + MACRO_ALIAS(PROTO_CMD _CPP_VANILLA_PROTO_CMD) + } + when ($PROTOC_TRANSITIVE_HEADERS == "no") { + CPP_PROTO_PLUGINS=transitive_pb_h=false:${CPP_PROTO_PLUGINS} + } + } + + SANITIZER_DEFINED=no + + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") { + CFLAGS+=-fsanitize=$SANITIZER_TYPE -D${SANITIZER_TYPE}_sanitizer_enabled $SANITIZER_CFLAGS -fno-omit-frame-pointer + LDFLAGS+=-fsanitize=$SANITIZER_TYPE + SANITIZER_DEFINED=yes + + when ($CLANG) { + CFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime + LDFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime + } + } + + when ($SANITIZE_COVERAGE && $SANITIZE_COVERAGE != "no") { + CFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE + LDFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE + } + + POPULATE_CPP_COVERAGE_FLAGS() + + when ($NLG_COVERAGE && $NLG_COVERAGE != "no") { + CFLAGS+=-DNLG_COVERAGE + } + + when ($GCC) { + select ($SANITIZER_TYPE) { + "address" ? { + LDFLAGS+=-static-libasan + } + "undefined" ? { + LDFLAGS+=-static-libubsan + } + "thread" ? { + PIE=yes + LDFLAGS+=-static-libtsan + } + } + } + + when ($HARDENING == "yes") { + when ($CLANG) { + CFLAGS+=-fstack-protector-all -D_hardening_enabled_ + LDFLAGS+=-z relro -z now -z noexecstack + PIE=yes + } + } + + when ($USE_LTO == "yes") { + when ($GCC) { + CFLAGS+=-flto -fno-fat-lto-objects + LDFLAGS+=-flto + NO_LTO_CFLAGS=-fno-lto + } + when ($CLANG) { + CFLAGS+=-flto + LDFLAGS+=-flto + NO_LTO_CFLAGS=-fno-lto + } + } + + when ($USE_THINLTO == "yes") { + when ($GCC) { + CFLAGS+=-flto=thin + LDFLAGS+=-flto=thin + NO_LTO_CFLAGS=-fno-lto + } + when ($CLANG) { + CFLAGS+=-flto=thin + LDFLAGS+=-flto=thin + NO_LTO_CFLAGS=-fno-lto + } + } + + + when ($CLANG) { + when ($PGO_ADD == "yes") { + CFLAGS+=-fprofile-instr-generate + LDFLAGS+=-fprofile-instr-generate + } + when ($PGO_PATH) { + CFLAGS+=-fprofile-instr-use=$PGO_PATH -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date + LDFLAGS+=-fprofile-instr-use=$PGO_PATH + } + } + + when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") { + PEERDIR+=$COMPILER_PLATFORM + } + + when ($OS_LINUX && $NEED_PLATFORM_PEERDIRS == "yes") { + PEERDIR+=contrib/libs/linux-headers + } + + # Adding PEERDIR from trigger doesn't always work. In this case it + # cause troubles in contrib/libs/libc_compat/ubuntu_14 under musl + # Workaround this issue by setting variable with PEERDIR in trigger + # and then adding PEERDIR to it's value unconditionally. + when ($USE_UBUNTU_COMPATIBILITY == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") { + _UBUNTU_COMPAT_PEERDIR=contrib/libs/libc_compat/ubuntu_14 + } + otherwise { + _UBUNTU_COMPAT_PEERDIR= + } + PEERDIR+=$_UBUNTU_COMPAT_PEERDIR + + when ($NORUNTIME != "yes") { + PEERDIR+=contrib/libs/cxxsupp + when ($MAPSMOBI_BUILD_TARGET == "yes") { + PEERDIR+=build/platform/mapkit + } + } + + when ($NOUTIL != "yes") { + PEERDIR+=util + } + + when ($MUSL == "yes") { + CFLAGS += -D_musl_ + LINK_DYN_LIB_FLAGS += --musl + LINK_SCRIPT_EXE_FLAGS += --musl + PEERDIR+=contrib/libs/musl/include + } + + # g++ has proxy C-headers which are incompatible with libc++ proxy C-headers. + # The same problem exists for clang toolchain. On the other hand, the problem + # doesn't affect cl since it has united C/C++ library and doesn't need + # proxy C-headers. + # Disable all C++ headers including proxy C-headers when we use libc++. + when ($USE_INTERNAL_STL == "yes" && $MSVC != "yes") { + CXXFLAGS += -nostdinc++ + } + otherwise { + CFLAGS += -DUSE_STL_SYSTEM + } + + when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") { + PEERDIR += build/external_resources/codenavigation + } + + when ($CYTHON_COVERAGE && $CYTHON_COVERAGE == "yes") { + CFLAGS+=-DCYTHON_TRACE=1 -DCYTHON_TRACE_NOGIL=1 + } + + DEFAULT(USE_SSE4 yes) + + when ($NOSSE != "yes") { + CFLAGS+=$SSE_CFLAGS + C_DEFINES+=$SSE_DEFINES + when ($USE_SSE4 == "yes") { + CFLAGS+=$SSE4_CFLAGS + C_DEFINES+=$SSE4_DEFINES + } + } + elsewhen ($MSVC != "yes") { + CFLAGS += -mno-sse + } + + POPULATE_CPP_COVERAGE_FLAGS() + _REGISTER_NO_CHECK_IMPORTS() + + DEFAULT(PACKAGE_PREFIX_ARGS) + + DEFAULT(SWIG_LANG python) + DEFAULT(GP_FLAGS -CtTLANSI-C -Dk* -c) + + when ($NEED_BINUTILS_PEERDIR && $BINUTILS_USED && $NEED_PLATFORM_PEERDIRS == "yes") { + PEERDIR+=build/platform/binutils + } +} + +_LINKER_ID= +# GCC does not support -fuse-ld with an executable path, +# only -fuse-ld=gold or -fuse-ld=lld. +when ($_LINKER_ID != "" && $_DEFAULT_LINKER_ID != "" && $CLANG == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") { + when ($_LINKER_ID in [ "gold", "lld" ]) { + PEERDIR+=build/platform/${_LINKER_ID} + } +} + +macro _USE_LINKER_IMPL(LINKER_ID...) { + SET(_LINKER_ID $LINKER_ID) +} + +macro _USE_LINKER() { + _USE_LINKER_IMPL($_DEFAULT_LINKER_ID) +} + +### @usage: USE_LINKER_GOLD() +### Use gold linker for a program. This doesn't work in libraries +macro USE_LINKER_GOLD() { + _USE_LINKER_IMPL(gold) +} + +COMMON_LINK_SETTINGS= +LINK_ADDITIONAL_SECTIONS= +LINK_ADDITIONAL_SECTIONS_COMMAND= + +when ($COMMON_LINK_SETTINGS == "yes") { + when ($_LINKER_ID == "lld" && ($OS_LINUX == "yes" || $OS_ANDROID == "yes")) { + LDFLAGS += -Wl,--gdb-index + } + + when ($EMBED_LINKER_CREF == "yes") { + LDFLAGS+=-Wl,--cref ${tmp;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle + LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_cref=${tmp;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} + } + elsewhen ($DUMP_LINKER_CREF == "yes") { + LDFLAGS+=-Wl,--cref ${output;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle + } + + when ($EMBED_LINKER_MAP == "yes") { + LDFLAGS+=-Wl,-Map=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME} + LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_map.${_LINKER_ID}=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME} + } + elsewhen ($DUMP_LINKER_MAP == "yes") { + LDFLAGS+=-Wl,-Map=${output;rootrel;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME} + } + + when ($USE_MKL == "yes") { + NOPLATFORM=yes + } + + when (($USE_EAT_MY_DATA == "yes") && ($WIN32 != "yes") && ($DARWIN != "yes") && ($OS_ANDROID != "yes") && ($OS_IOS != "yes")) { + PEERDIR+=contrib/libs/libeatmydata/autocheck_wrapper + } + + when ($USE_ARCADIA_LIBM == "yes") { + PEERDIR+=contrib/libs/libm + } + when ($USE_ARCADIA_LIBM == "no") { + C_SYSTEM_LIBRARIES+=-lm + } + + when (($MUSL != "yes" && $WITH_VALGRIND == "yes") || $SANITIZER_DEFINED == "yes") { + when ($ALLOCATOR in [ "TCMALLOC", "TCMALLOC_SMALL_BUT_SLOW", "TCMALLOC_NUMA_256K", "TCMALLOC_NUMA_LARGE_PAGES", "TCMALLOC_256K", "TCMALLOC_TC", "GOOGLE", "J", "LF", "LF_YT", "LF_DBG", "B", "BM", "C", "LOCKLESS", "YT", "MIM", "HU", "PROFILED_HU" ]) { + PEERDIR+=library/cpp/malloc/system + } + } + otherwise { + select ($ALLOCATOR) { + "MIM" ? { + PEERDIR+=library/cpp/malloc/mimalloc + } + "HU" ? { + PEERDIR+=library/cpp/malloc/hu + } + "PROFILED_HU" ? { + PEERDIR+=library/cpp/malloc/profiled_hu + } + "TCMALLOC_256K" ? { + PEERDIR+=library/cpp/malloc/tcmalloc + PEERDIR+=contrib/libs/tcmalloc + } + "TCMALLOC_SMALL_BUT_SLOW" ? { + PEERDIR+=library/cpp/malloc/tcmalloc + PEERDIR+=contrib/libs/tcmalloc/small_but_slow + } + "TCMALLOC_NUMA_256K" ? { + PEERDIR+=library/cpp/malloc/tcmalloc + PEERDIR+=contrib/libs/tcmalloc/numa_256k + } + "TCMALLOC_NUMA_LARGE_PAGES" ? { + PEERDIR+=library/cpp/malloc/tcmalloc + PEERDIR+=contrib/libs/tcmalloc/numa_large_pages + } + "TCMALLOC" ? { + PEERDIR+=library/cpp/malloc/tcmalloc + PEERDIR+=contrib/libs/tcmalloc/default + } + "TCMALLOC_TC" ? { + PEERDIR+=library/cpp/malloc/tcmalloc + PEERDIR+=contrib/libs/tcmalloc/no_percpu_cache + } + "GOOGLE" ? { + PEERDIR+=library/cpp/malloc/galloc + } + "J" ? { + when ($WIN32 == "yes") { + PEERDIR+=library/cpp/malloc/system + } + otherwise { + PEERDIR+=library/cpp/malloc/jemalloc + } + } + "LF" ? { + PEERDIR+=library/cpp/lfalloc + } + "LF_YT" ? { + PEERDIR+=library/cpp/lfalloc/yt + } + "LF_DBG" ? { + PEERDIR+=library/cpp/lfalloc/dbg + } + "B" ? { + PEERDIR+=library/cpp/balloc + } + "BM" ? { + PEERDIR+=library/cpp/balloc_market + } + "C" ? { + PEERDIR+=library/cpp/malloc/calloc + } + "LOCKLESS" ? { + PEERDIR+=library/cpp/malloc/lockless + } + "YT" ? { + PEERDIR+=library/cpp/ytalloc/impl + } + } + } + + when ($ALLOCATOR == "SYSTEM") { + PEERDIR+=library/cpp/malloc/system + } + when ($WERROR != "no") { + when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) { + C_WARNING_OPTS += $WERROR_FLAG + } + } + + when ($ICC == "yes") { + PEERDIR+=contrib/libs/intel/core + } + when ($WITH_VALGRIND == "yes") { + PEERDIR+=contrib/libs/valgrind + # https://st.yandex-team.ru/DTCC-122 + CFLAGS+=-fdebug-default-version=4 + } +} + +when ($EMBED_LINKER_MAP == "yes" || $EMBED_LINKER_CREF == "yes") { + LINK_ADDITIONAL_SECTIONS_COMMAND+= \ + $OBJCOPY_TOOL $LINK_ADDITIONAL_SECTIONS $TARGET +} + +_SO_EXT_FILTER=${ext=.so:PEERS} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/:PEERS} +when ($OS_WINDOWS == "yes") { + _SO_EXT_FILTER=${ext=.dll:PEERS} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/:PEERS} +} +elsewhen ($OS_DARWIN == "yes" || $OS_IOS == "yes") { + _SO_EXT_FILTER=${ext=.dylib:PEERS} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/:PEERS} +} + +LINK_OR_COPY_SO_CMD= +RPATH_GLOBAL= +when ($SO_OUTPUTS == "yes") { + LINK_OR_COPY_SO_CMD=$FS_TOOLS link_or_copy_to_dir --no-check $_SO_EXT_FILTER ${BINDIR} + LDFLAGS+=$RPATH_GLOBAL +} + +# tag:restricted tag:DLL +### $usage: WITH_DYNAMIC_LIBS() # restricted +### +### Include dynamic libraries as extra PROGRAM/DLL outputs +macro WITH_DYNAMIC_LIBS() { + ENABLE(SO_OUTPUTS) +} + +# tag:internal +### $usage: REAL_LINK_EXE_IMPL(peers...) # internal +macro REAL_LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) { + .CMD=$REAL_LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD +} + +# tag:internal +### $usage: REAL_LINK_EXEC_DYN_LIB_IMPL(peers...) # internal +macro REAL_LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) { + .CMD=$REAL_LINK_EXEC_DYN_LIB_CMDLINE +} + +# tag:internal +### $usage: REAL_LINK_DYN_LIB_IMPL(peers...) # internal +macro REAL_LINK_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) { + .CMD=$REAL_LINK_DYN_LIB_CMDLINE && $LINK_OR_COPY_SO_CMD +} + +# tag:internal +### $usage: LINK_EXE_IMPL(peers...) # internal +macro LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) { + .CMD=$LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD +} + +# tag:internal +### $usage: LINK_EXEC_DYN_LIB_IMPL(peers...) # internal +macro LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) { + .CMD=$LINK_EXEC_DYN_LIB_CMDLINE +} + +# tag:internal +### @usage: _LINK_UNIT # internal +### +### The base of all linkable modules: programs, DLLs etc. Describes common linking logic. +module _LINK_UNIT: _BASE_UNIT { + .EXTS=.o .obj .supp .tidyjson .ld + .CMD=LINK_EXE + .ALLOWED=EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES + .NODE_TYPE=Program + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=yes + .DEFAULT_NAME_GENERATOR=DirName + .ARGS_PARSER=Base + + DEFAULT(ALLOCATOR $DEFAULT_ALLOCATOR) + _USE_LINKER() + + #link with libunwind manually + when ($DARWIN == "yes" && $NOPLATFORM != "yes") { + PEERDIR += contrib/libs/cxxsupp + } + + when ($USE_LIBCXXRT == "yes") { + PEERDIR += contrib/libs/cxxsupp/libcxxrt + } + + when ($USE_DYNAMIC_CUDA == "yes") { + LINK_DYN_LIB_FLAGS += --dynamic-cuda + LINK_SCRIPT_EXE_FLAGS += --dynamic-cuda + } + + ENABLE(COMMON_LINK_SETTINGS) + CHECK_PROVIDES() +} + +MODULE_TYPE=UNKNOWN + +macro ADD_CLANG_TIDY() { + ADD_YTEST($MODULE_PREFIX$REALPRJNAME clang_tidy) + when ($TIDY_ENABLED == "yes") { + _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_project_map.json + _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_default_map.json + } +} + +# tag:internal +### @usage: _BASE_PROGRAM # internal +### +### The base of all programs. It adds dependencies to make final artefact complete and runnable. +module _BASE_PROGRAM: _LINK_UNIT { + .SYMLINK_POLICY=EXE + .ALLOWED=INDUCED_DEPS WHOLE_ARCHIVE + .GLOBAL=LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH + SET(MODULE_TYPE PROGRAM) + SET(MODULE_LANG CPP) + FORCE_COVERAGE_ENABLED=yes + + when ($OS_IOS == "yes") { + EXTS+=.ios.interface + } + + when ($WIN32 == "yes" || $OS_CYGWIN == "yes") { + MODULE_SUFFIX=.exe + } + + when ($TIDY_ENABLED == "yes") { + MODULE_SUFFIX=.tidyjson + } + + when ($MSVC != "yes" && $NOPLATFORM != "yes" && $WITH_VALGRIND != "yes" && $USE_ASMLIB != "no" && $MIC_ARCH != "yes" && $PIC != "yes" && $PIE != "yes") { + when ($OS_LINUX == "yes" && $ARCH_X86_64 == "yes" && $MUSL != "yes" && $SANITIZER_DEFINED != "yes" && $USE_THINLTO != "yes") { + PEERDIR+=contrib/libs/glibcasm + } + otherwise { + PEERDIR+=contrib/libs/asmlib + } + } + + when ($MUSL == "yes") { + when ($MUSL_LITE == "yes") { + PEERDIR += contrib/libs/musl + } + otherwise { + PEERDIR += contrib/libs/musl/full + } + } + + DEFAULT(CPU_CHECK yes) + when ($USE_SSE4 != "yes" || $NOUTIL == "yes" || $ALLOCATOR == "FAKE") { + CPU_CHECK = no + } + + when ($CPU_CHECK == "yes") { + PEERDIR += library/cpp/cpuid_check + } + + when ($USE_ARC_PROFILE == "yes" && $NOUTIL != "yes") { + PEERDIR += library/cpp/execprofile/autostart + } + + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") { + PEERDIR += contrib/libs/cxxsupp/libsan + when ($CLANG) { + select ($TARGET_PLATFORM) { + "LINUX" ? { + PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/static + } + "DARWIN" ? { + # Memory sanitizer is not supported for darwin platform. + # https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms + when ($SANITIZER_TYPE != "memory") { + PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/dynamic + } + } + default ? { + FATAL_ERROR_MESSAGE+=Unsupported platform for sanitizer + } + } + } + when ($SANITIZE_HEADERS && $SANITIZE_HEADERS != "no") { + PEERDIR += library/cpp/sanitizer/include + } + } + + when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") { + PEERDIR+=library/cpp/testing/dump_clang_coverage + } + + when ($IDE_MSVS == "yes") { + PEERDIR+=build/scripts/c_templates + } + + when ($_CUSTOM_LINK_STEP_SCRIPT) { + LINK_SCRIPT_EXE_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT} + } +} + +VCS_INFO_SEM=vcs_info ${input;hide:"build/scripts/vcs_info.py"} ${input;hide:"build/scripts/c_templates/svn_interface.c"} ${input;hide:"build/scripts/c_templates/svnversion.h"} +CPP_PROGRAM_SEM=add_executable $MODDIR $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \ + && ${VCS_INFO_SEM} \ + && target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE \ + && target_include_directories PRIVATE $_C__INCLUDE_OWNED \ + && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \ + && target_compile_options PRIVATE $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW +### @usage: PROGRAM([progname]) +### +### Regular program module. +### If name is not specified it will be generated from the name of the containing project directory. +module PROGRAM: _BASE_PROGRAM { + .SEM=CPP_PROGRAM_SEM + + ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor) + ADD_CLANG_TIDY() +} + +# tag:python-specific tag:deprecated tag:internal +module _PY2_PROGRAM: _BASE_PY_PROGRAM { + SET(MODULE_LANG PY2) + + # Looks like we cannot avoid copy-paste util ymake supports multiple inheritance + # We need to attach coverage.extractor to every py_program target, except pytest targets + ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor) +} + +# tag:python-specific tag:deprecated +### @usage: PY2_PROGRAM([progname]) # deprecated +### +### Deprecated. Use PY3_PROGRAM instead. +### Python 2.x binary program. Links all Python 2.x libraries and Python 2.x interpreter into itself to form regular executable. +### If name is not specified it will be generated from the name of the containing project directory. +### This only compatible with PYTHON2-tagged modules and selects those from multimodules. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module PY2_PROGRAM: _PY2_PROGRAM { + .RESTRICTED=STYLE_PYTHON + when ($FAIL_PY2 == "yes") { + _OK=no + } + elsewhen ($OPENSOURCE != "yes") { + PEERDIR+=build/rules/py2_deprecation + } + ASSERT(_OK You are using deprecated Python2-only code (PY2_PROGRAM). Please consider rewriting to Python 3.) +} + +# tag:python-specific +### @usage: NO_EXTENDED_SOURCE_SEARCH() +### +### Prevent module using in extended python source search. +### Use the macro if module contains python2-only files (or other python sources which shouldn't be imported by python3 interpreter) +### which resides in the same directories with python 3 useful code. contrib/python/future is a example. +### Anyway, preferred way is to move such files into separate dir and don't use this macro at all. +### +### Also see: https://docs.yandex-team.ru/ya-make/manual/python/vars#y_python_extended_source_search for details +macro NO_EXTENDED_SOURCE_SEARCH() { + SET(NO_EXTENDED_SOURCE_SEARCH yes) +} + +# tag:python-specific +### @usage: PY3_PROGRAM([progname]) +### +### Python 3.x binary program. Links all Python 3.x libraries and Python 3.x interpreter into itself to form regular executable. +### If name is not specified it will be generated from the name of the containing project directory. +### This only compatible with PYTHON3-tagged modules and selects those from multimodules. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +multimodule PY3_PROGRAM { + module PY3_BIN: PY3_PROGRAM_BIN { + .PEERDIRSELF=PY3_BIN_LIB + .IGNORED=RESOURCE RESOURCE_FILES PEERDIR TASKLET_REG RUN_ANTLR4_PYTHON BUILDWITH_CYTHON_CPP _BUILDWITH_CYTHON_CPP_DEP _BUILDWITH_CYTHON_CPP_H BUILDWITH_CYTHON_C _BUILDWITH_CYTHON_C_DEP _BUILDWITH_CYTHON_C_H _BUILDWITH_CYTHON_C_API_H + # Notify pybuild to skip almost all PY_SRCS arguments except MAIN + ENABLE(PROCESS_PY_MAIN_ONLY) + _PY_PROGRAM() + } + + module PY3_BIN_LIB: PY3_LIBRARY { + .IGNORED=RESTRICT_LICENSES + # Notify pybuild to skip all python main function definitions + ENABLE(IGNORE_PY_MAIN) + _REQUIRE_EXPLICIT_LICENSE() + } +} + +### @usage: EXPORTS_SCRIPT(exports_file) +### +### Specify exports script within PROGRAM, DLL and DLL-derived modules. +### This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files. +### The other option use EXPORTS parameter of the DLL module itself. +### +### @see: [DLL](#module_DLL) +macro EXPORTS_SCRIPT(Arg) { + SET(EXPORTS_FILE $Arg) +} + +### @usage: NO_EXPORT_DYNAMIC_SYMBOLS() +### +### Disable exporting all non-hidden symbols as dynamic when linking a PROGRAM. +macro NO_EXPORT_DYNAMIC_SYMBOLS() { + ENABLE(NO_EXPORT_DYNAMIC_SYMBOLS) +} + +### @usage: EXPORT_ALL_DYNAMIC_SYMBOLS() +### +### Export all non-hidden symbols as dynamic when linking a PROGRAM. +macro EXPORT_ALL_DYNAMIC_SYMBOLS() { + # Dummy: default behaviour + ENABLE(EXPORT_ALL_DYNAMIC_SYMBOLS) +} + +### @usage: USE_DYNAMIC_CUDA() +### +### Enable linking of PROGRAM with dynamic CUDA. By default CUDA uses static linking +macro USE_DYNAMIC_CUDA() { + LDFLAGS(-Wl,-rpath,$ORIGIN) + ENABLE(USE_DYNAMIC_CUDA) +} + +### @usage: CUSTOM_LINK_STEP_SCRIPT(name) +### +### Specifies name of a script for custom link step. The scripts +### should be placed in the build/scripts directory and are subject to +### review by devtools@. +macro CUSTOM_LINK_STEP_SCRIPT(Name) { + SET(_CUSTOM_LINK_STEP_SCRIPT build/scripts/$Name) +} + +### @usage: _BASE_UNITTEST # internal +### +### Module with base logic for all unit-test modules: it makes code runnable as unit-test by Arcadia testing machinery. +module _BASE_UNITTEST: _BASE_PROGRAM { + .FINAL_TARGET=no + .NODE_TYPE=Program + .ALLOWED=YT_SPEC + when ($UT_SKIP_EXCEPTIONS == "yes") { + C_DEFINES+=-DUT_SKIP_EXCEPTIONS + } + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) +} + +_TEST_SPLIT_FACTOR_SEM=1 +_TEST_TIMEOUT_SEM= +_TEST_PARTITION_SEM= +UNITTEST_SEM=$CPP_PROGRAM_SEM \ + && set_property TARGET $REALPRJNAME PROPERTY SPLIT_FACTOR $_TEST_SPLIT_FACTOR_SEM \ + $_TEST_PARTITION_SEM \ + && add_yunittest NAME $REALPRJNAME TEST_TARGET $REALPRJNAME TEST_ARG --print-before-suite --print-before-test --fork-tests --print-times --show-fails \ + && set_yunittest_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \ + && add_ytest_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \ + $_TEST_TIMEOUT_SEM + +# tag:test +### @usage: UNITTEST([name]) +### +### Unit test module based on library/cpp/testing/unittest. +### It is recommended not to specify the name. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/#opisanievya.make1 +module UNITTEST: _BASE_UNITTEST { + .SEM=UNITTEST_SEM + .DEFAULT_NAME_GENERATOR=FullPath + .ARGS_PARSER=Base + PEERDIR(library/cpp/testing/unittest_main) + ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py) + + when ($TEST_FORK_MODE != "none") { + when ($TEST_SPLIT_FACTOR) { + _TEST_SPLIT_FACTOR_SEM=$TEST_SPLIT_FACTOR + } + otherwise { + _TEST_SPLIT_FACTOR_SEM=10 + } + when ($TEST_PARTITION == "MODULO") { + _TEST_PARTITION_SEM=&& set_property TARGET $REALPRJNAME PROPERTY SPLIT_TYPE $TEST_PARTITION \ + } + } + when ($TEST_TIMEOUT) { + _TEST_TIMEOUT_SEM=&& set_yunittest_property TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT + } +} + +# tag:yt-specific tag:test +### @usage: YT_UNITTEST([name]) +### +### YT Unit test module based on library/cpp/testing/unittest with NYT::Initialize hook +module YT_UNITTEST: _BASE_UNITTEST { + PEERDIR(library/cpp/testing/unittest_main mapreduce/yt/tests/yt_initialize_hook) + ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py) +} + +# tag:test +### @usage: UNITTEST_WITH_CUSTOM_ENTRY_POINT([name]) +### +### Generic unit test module. +module UNITTEST_WITH_CUSTOM_ENTRY_POINT: _BASE_UNITTEST { + ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py) +} + +GTEST_SEM=$CPP_PROGRAM_SEM \ + && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME \ + && set_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \ + && add_test_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \ + $_TEST_TIMEOUT_SEM + +# tag:cpp-specific tag:test +### @usage: GTEST([name]) +### +### Unit test module based on library/cpp/testing/gtest. +### It is recommended not to specify the name. +### +### Documentation: https://docs.yandex-team.ru/arcadia-cpp/cpp_test +module GTEST: _BASE_UNITTEST { + .SEM=GTEST_SEM + .DEFAULT_NAME_GENERATOR=FullPath + .ARGS_PARSER=Base + PEERDIR(library/cpp/testing/gtest library/cpp/testing/gtest_main) + ADD_YTEST($MODULE_PREFIX$REALPRJNAME gunittest) + + when ($TEST_TIMEOUT) { + _TEST_TIMEOUT_SEM=&& set_property TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT + } +} + +USE_AFL=no + +# tag:fuzzing +### @usage: FUZZ() +### +### In order to start using Fuzzing in Arcadia, you need to create a FUZZ module with the implementation of the function LLVMFuzzerTestOneInput(). +### This module should be reachable by RECURSE from /autocheck project in order for the corpus to be regularly updated. +### AFL and Libfuzzer are supported in Arcadia via a single interface, but the automatic fuzzing still works only through Libfuzzer. +### +### Example: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/re2/re2/fuzzing/re2_fuzzer.cc?rev=2919463#L58 +### +### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/ +module FUZZ: _BASE_PROGRAM { + .NODE_TYPE=Program + .FINAL_TARGET=no + .ALLOWED=FUZZ_DICTS FUZZ_OPTS + + SET(LIBFUZZER_PATH contrib/libs/libfuzzer) + when ($USE_AFL == "no") { + PEERDIR+=$LIBFUZZER_PATH + } + when ($USE_AFL == "yes") { + PEERDIR+=$LIBFUZZER_PATH/afl + } + + when (!$SANITIZER_TYPE || $SANITIZER_TYPE == "no") { + PEERDIR+=devtools/nofuzz + } + + ADD_YTEST($MODULE_PREFIX$REALPRJNAME fuzz.test) +} + +# tag:ios-specific +PACK_IOS_CMD= +when ($OS_IOS && $BUILD_IOS_APP) { + PACK_IOS_CMD=$YMAKE_PYTHON ${input:"build/scripts/pack_ios.py"} --binary $TARGET --target $TARGET --temp-dir $BINDIR $PEERS +} + +LINK_BOOSTTEST_CMD= +BOOST_TEST_TYPE_STRING= + +when ($BOOSTTEST_IS_FAT_OBJECT) { + LINK_BOOSTTEST_CMD=$LINK_RECURSIVE_LIBRARY + BOOST_TEST_TYPE_STRING=no.test +} +otherwise { + LINK_BOOSTTEST_CMD=$LINK_EXE + BOOST_TEST_TYPE_STRING=boost.test +} + +# tag:deprecated +### @usage: BOOSTTEST([name]) #deprecated +### +### Test module based on boost/test/unit_test.hpp. +### As with entire boost library usage of this technology is deprecated in Arcadia and restricted with configuration error in most of projects. +### No new module of this type should be introduced unless it is explicitly approved by C++ committee. +module BOOSTTEST: _BASE_PROGRAM { + .NODE_TYPE=Program + .FINAL_TARGET=no + .CMD=LINK_BOOSTTEST_CMD + PEERDIR(library/cpp/testing/boost_test) + when ($BOOSTTEST_IS_FAT_OBJECT) { + MODULE_SUFFIX=.a + } + elsewhen ($OS_IOS && $BUILD_IOS_APP) { + PEERDIR+=devtools/boosttest_ios_wrapper/library + MODULE_SUFFIX=.ios.tar + } + ADD_YTEST($MODULE_PREFIX$REALPRJNAME $BOOST_TEST_TYPE_STRING) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) +} + +# tag:deprecated +### @usage BOOSTTEST_WITH_MAIN([name]) #deprecated +### +### Same as BOOSTTEST (see above), but comes with builtin int main(argc, argv) implementation +module BOOSTTEST_WITH_MAIN: BOOSTTEST { + PEERDIR(library/cpp/testing/boost_test_main) +} + +FUZZ_DICTS_VALUE= +### @usage: FUZZ_DICTS(path1 [path2...]) +### +### Allows you to specify dictionaries, relative to the root of Arcadia, which will be used in Fuzzing. +### Libfuzzer and AFL use a single syntax for dictionary descriptions. +### Should only be used in FUZZ modules. +### +### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/ +macro FUZZ_DICTS(Data...) { + SET_APPEND(FUZZ_DICTS_VALUE $Data) +} + +FUZZ_OPTS_VALUE= +### @usage: FUZZ_OPTS(opt1 [Opt2...]) +### +### Overrides or adds options to the corpus mining and fuzzer run. +### Currently supported only Libfuzzer, so you should use the options for it. +### Should only be used in FUZZ modules. +### +### @example: +### +### FUZZ_OPTS ( +### -max_len=1024 +### -rss_limit_mb=8192 +### ) +### +### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/ +macro FUZZ_OPTS(Data...) { + SET_APPEND(FUZZ_OPTS_VALUE $Data) +} + +# tag:yt-specific tag:test +TEST_YT_SPEC_VALUE= +### @usage: YT_SPEC(path1 [path2...]) +### +### Allows you to specify json-files with YT task and operation specs, +### which will be used to run test node in the YT. +### Test must be marked with ya:yt tag. +### Files must be relative to the root of Arcadia. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/ +macro YT_SPEC(Data...) { + SET_APPEND(TEST_YT_SPEC_VALUE $Data) +} + +# tag:test +TEST_SRCS_VALUE= +### @usage: TEST_SRCS(Files...) +### +### In PY2TEST, PY3TEST and PY*_LIBRARY modules used as PY_SRCS macro and additionally used to mine test cases to be executed by testing framework. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/#testynapytest +macro TEST_SRCS(Tests...) { + SET_APPEND(TEST_SRCS_VALUE $Tests) +} + +macro DISABLE_DATA_VALIDATION() { + DISABLE(VALIDATE_DATA) +} + +# tag:test +TEST_DATA_VALUE= +### @usage: DATA([path...]) +### +### Specifies the path to the data necessary test. +### Valid values are: arcadia/<path> , arcadia_tests_data/<path> and sbr://<resource_id>. +### In the latter case resource will be brought to the working directory of the test before it is started +### +### Used only inside TEST modules. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/#dannyeizrepozitorija +macro DATA(Data...) { + SET_APPEND(TEST_DATA_VALUE $Data) + ADD_CHECK(check.data $Data) +} + +# tag:test +### @usage: DATA_FILES([path...]) +### +### Specifies the path to the arcadia source data necessary test. +### Used only inside TEST modules. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/#dannyeizrepozitorija +macro DATA_FILES(Paths...) { + SET_APPEND(TEST_DATA_VALUE ${pre=arcadia/:Paths}) + _DATA_FILES($Paths) +} + +# tag:test +### @usage: EXPLICIT_DATA() +### +### Disables implicit macro DATA(<module_path>). +ADD_SRCDIR_TO_TEST_DATA=yes +macro EXPLICIT_DATA() { + SET(ADD_SRCDIR_TO_TEST_DATA no) +} + +# tag:test +TEST_TAGS_VALUE= +### @usage: TAG ([tag...]) +### +### Each test can have one or more tags used to filter tests list for running. +### There are also special tags affecting test behaviour, for example ya:external, sb:ssd. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/#obshhieponjatija +macro TAG(Tags...) { + SET_APPEND(TEST_TAGS_VALUE $Tags) +} + +# tag:test +TEST_REQUIREMENTS_VALUE= +### @usage: REQUIREMENTS([cpu:<count>] [disk_usage:<size>] [ram:<size>] [ram_disk:<size>] [container:<id>] [network:<restricted|full>] [dns:dns64]) +### +### Allows you to specify the requirements of the test. +### +### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/ +macro REQUIREMENTS(Tags...) { + SET_APPEND(TEST_REQUIREMENTS_VALUE $Tags) +} + +# tag:test +TEST_ENV_VALUE= +### @usage: ENV(key[=value]) +### +### Sets env variable key to value (gets value from system env by default). +macro ENV(Data...) { + SET_APPEND(TEST_ENV_VALUE ${quo:Data}) +} + +### @usage: CONFTEST_LOAD_POLICY_LOCAL() +### +### Loads conftest.py files in a way that pytest does it +macro CONFTEST_LOAD_POLICY_LOCAL() { + SET_APPEND(TEST_ENV_VALUE "CONFTEST_LOAD_POLICY=LOCAL") +} + +# tag:test +TEST_RECIPES_VALUE= +### @usage: USE_RECIPE(path [arg1 arg2...]) +### +### Provides prepared environment via recipe for test. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/recipes +macro USE_RECIPE(Data...) { + SET_APPEND(TEST_RECIPES_VALUE $Data) + SET_APPEND(TEST_RECIPES_VALUE "USE_RECIPE_DELIM") +} + +# tag:python-specific tag:test +TEST_PYTHON_PATH_VALUE= + +# tag:python-specific tag:test +### @usage: PYTHON_PATH(Path) +### +### Set path to Python that will be used to runs scripts in tests +macro PYTHON_PATH(Path) { + SET(TEST_PYTHON_PATH_VALUE $Path) +} + +# tag:test +SKIP_TEST_VALUE= +### @usage: SKIP_TEST(Reason) +### +### Skip the suite defined by test module. Provide a reason to be output in test execution report. +macro SKIP_TEST(Reason...) { + SET(SKIP_TEST_VALUE $Reason) +} + +# tag:test +LINT_LEVEL_VALUE=extended +_NO_LINT_VALUE= +### @usage: NO_LINT([ktlint]) +### +### Do not check for style files included in PY_SRCS, TEST_SRCS, JAVA_SRCS. +### Ktlint can be disabled using NO_LINT(ktlint) explicitly. +macro NO_LINT(ktlint?"ktlint":"none") { + SET(_NO_LINT_VALUE ${ktlint}) +} + +### @usage: LINT(<none|base|strict>) +### +### Set linting level for sources of the module +macro LINT(level) { + SET(LINT_LEVEL_VALUE $level) +} + +# tag:python-specific tag:test +STYLE_PYTHON_VALUE=no +STYLE_PYTHON_PYPROJECT_VALUE= +### @usage: STYLE_PYTHON([pyproject]) +### +### Check python3 sources for style issues using black. +macro STYLE_PYTHON(pyproject...) { + SET(STYLE_PYTHON_VALUE yes) + SET(STYLE_PYTHON_PYPROJECT_VALUE ${pyproject}) +} + +# tag:python-specific tag:test +### @usage: NO_DOCTESTS() +### +### Disable doctests in PY[|3|23_]TEST +macro NO_DOCTESTS() { + ENV(YA_PYTEST_DISABLE_DOCTEST="yes") +} + +# tag:python-specific tag:test +### @usage: _BASE_PYTEST # internal +### +### Base logic of Python 2.x py.test modules: common module properties and dependencies. +module _BASE_PYTEST: _BASE_PY_PROGRAM { + .NODE_TYPE=Program + .FINAL_TARGET=no + .ALLOWED=YT_SPEC NO_DOCTESTS + when ($USE_ARCADIA_PYTHON == "yes") { + PEERDIR+=library/python/pytest + } + when ($USE_ARCADIA_PYTHON == "no") { + MODULE_SUFFIX=.pkg.fake + PEERDIR+=library/python/pytest/empty + } + + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) +} + +# tag:python-specific tag:deprecated tag:test +### @usage: PYTEST_BIN() #deprecated +### +### Same as PY2TEST. Don't use this, use PY2TEST instead. +module PYTEST_BIN: _BASE_PYTEST { + .NODE_TYPE=Program + .DEFAULT_NAME_GENERATOR=FullPath + .ARGS_PARSER=Base + SETUP_PYTEST_BIN() +} + +# tag:python-specific tag:test +### @usage: PY2TEST([name]) +### +### The test module for Python 2.x based on py.test +### +### This module is compatible only with PYTHON2-tagged modules and selects peers from multimodules accordingly. +### This module is compatible with non-Arcadia Python builds. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/#python +### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/ +module PY2TEST: PYTEST_BIN { + .RESTRICTED=STYLE_PYTHON + .DEFAULT_NAME_GENERATOR=FullPath + .ARGS_PARSER=Base + when ($FAIL_PY2 == "yes") { + _OK=no + } + elsewhen ($OPENSOURCE != "yes") { + PEERDIR+=build/rules/py2_deprecation + } + SET(MODULE_LANG PY2) + ASSERT(_OK You are using deprecated Python2-only code (PY2TEST). Please consider rewriting to Python 3.) +} + +# tag:python-specific tag:deprecated tag:test +### @usage: PY3TEST_BIN() #deprecated +### +### Same as PY3TEST. Don't use this, use PY3TEST instead. +module PY3TEST_BIN: _BASE_PY3_PROGRAM { + .NODE_TYPE=Program + .FINAL_TARGET=no + .ALLOWED=YT_SPEC NO_DOCTESTS + .DEFAULT_NAME_GENERATOR=FullPath + .ARGS_PARSER=Base + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) + SET(MODULE_LANG PY3) + SETUP_PYTEST_BIN() + PEERDIR+=library/python/pytest +} + +# tag:python-specific tag:test +### Disable submodules with the specified name(s). +### Unlike EXCLUDE_TAGS this variable: +### - affects all projects in the build; +### - filter by module name and ignore MODULE_TAG. +EXCLUDE_SUBMODULES=PY3TEST_LIBRARY + +# tag:python-specific tag:test +### @usage: PY3TEST([name]) +### +### The test module for Python 3.x based on py.test +### +### This module is compatible only with PYTHON3-tagged modules and selects peers from multimodules accordingly. +### This module is only compatible with Arcadia Python build (to avoid tests duplication from Python2/3-tests). For non-Arcadia python use PYTEST. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/#testynapytest +### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/ +multimodule PY3TEST { + module PY3TEST_PROGRAM: PY3TEST_BIN { + .IGNORED=RUN_ANTLR4_PYTHON + .FINAL_TARGET=yes + } + + module PY3TEST_LIBRARY: PY3_LIBRARY { + PEERDIR+=library/python/pytest + _REQUIRE_EXPLICIT_LICENSE() + } +} + +# tag:cpp-specific tag:test +module CPP_STYLE_TEST_14: PY3TEST_BIN { + DEPENDS(contrib/libs/clang14/tools/clang-format) + PEERDIR+=library/python/cpp_test +} + +macro STYLE(Globs...) { + _GLOB(STYLE_SRCS_GLOB ${pre=${ARCADIA_ROOT}:Globs}) + _STYLE(${STYLE_SRCS_GLOB}) +} + +# tag:cpp-specific tag:deprecated tag:test +### @usage: GTEST_UGLY([name]) +### +### Deprecated, do not use in new projects. Use GTEST instead. +### +### The test module based on gtest (contrib/libs/gtest contrib/libs/gmock). +### Use public documentation on gtest for details. +### +### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/ +module GTEST_UGLY: _BASE_PROGRAM { + .NODE_TYPE=Program + .FINAL_TARGET=no + PEERDIR(contrib/restricted/googletest/googlemock contrib/restricted/googletest/googletest) + ADD_YTEST($MODULE_PREFIX$REALPRJNAME gtest) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) +} + +# tag:test +### @usage: EXECTEST() +### +### Module definition of generic test that executes a binary. +### Use macro RUN to specify binary to run. +### +### @example: +### +### EXECTEST() +### OWNER(g:yatool) +### +### RUN( +### cat input.txt +### ) +### DATA( +### arcadia/devtools/ya/test/tests/exectest/data +### ) +### DEPENDS( +### devtools/dummy_arcadia/cat +### ) +### TEST_CWD(devtools/ya/test/tests/exectest/data) +### END() +### +### More examples: https://wiki.yandex-team.ru/yatool/test/#exec-testy +### +### @see: [RUN()](#macro_RUN) +module EXECTEST: _BARE_UNIT { + .NODE_TYPE=Program + .FINAL_TARGET=no + .ALLOWED=YT_SPEC + .RESTRICTED=FORK_TEST_FILES + .DEFAULT_NAME_GENERATOR=FullPath + .ARGS_PARSER=Base + SET(MODULE_SUFFIX .pkg.fake) + SETUP_EXECTEST() + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json) +} + +# tag:cpp-specific tag:test +### @usage: Y_BENCHMARK([benchmarkname]) +### +### Benchmark test based on the library/cpp/testing/benchmark. +### +### For more details see: https://wiki.yandex-team.ru/yatool/test/#zapuskbenchmark +module Y_BENCHMARK: PROGRAM { + .SEM=CPP_PROGRAM_SEM + PEERDIR(library/cpp/testing/benchmark/main) +} + +GBENCH_SEM=$CPP_PROGRAM_SEM \ + && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME \ + && set_property TEST $REALPRJNAME PROPERTY LABELS SMALL $FILTER_ONLY_TEST_TAGS \ + && add_test_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \ + $_TEST_TIMEOUT_SEM + +# tag:cpp-specific tag:test +### @usage: G_BENCHMARK([benchmarkname]) +### +### Benchmark test based on the google benchmark. +### +### For more details see: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/benchmark/README.md +module G_BENCHMARK: _BASE_PROGRAM { + .SEM=GBENCH_SEM + PEERDIR(library/cpp/testing/gbenchmark) + ADD_YTEST($MODULE_PREFIX$REALPRJNAME g_benchmark) +} + +# tag:test +TEST_ROOT=$(TESTS_DATA_ROOT) +RESULT_MAX_FILE=0 +STRIP_FILES=--dont-strip-files +VERIFY_RESULTS=--verify-results +ADDITIONAL_PATH= + +# set for tests variables to fill it by YA_DEV or YA +YA_ROOT=ya +when ($YA_DEV == "yes") { + YA_ROOT=ya-dev +} + + +# tag:test +### @usage: UNITTEST_FOR(path/to/lib) +### +### Convenience extension of UNITTEST module. +### The UNINTTEST module with additional SRCDIR + ADDINCL + PEERDIR on path/to/lib. +### path/to/lib is the path to the directory with the LIBRARY project. +### +### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/ +module UNITTEST_FOR: UNITTEST { + .SEM=UNITTEST_SEM + PEERDIR(ADDINCL $UNITTEST_DIR) + SRCDIR($UNITTEST_DIR) +} + +### @usage: _LIBRARY # internal +### +### Base module definition for all libraries. +### Contains basic logic like module properties, default variable values etc. +### All libraries similar to C++-libraries should be inherited from it. +module _LIBRARY: _BASE_UNIT { + .CMD=LINK_LIB + .NODE_TYPE=Library + .PEERDIR_POLICY=as_include + .EXTS=.o .obj .a .mf .supp .tidyjson .ld .lib + .ALLOWED=GRPC USE_SKIFF EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES + .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS SRCS _WHOLE_ARCHIVE_LIBS_VALUE RPATH + .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SPLIT_DWARF + .FINAL_TARGET=no + .GLOBAL_CMD=GLOBAL_LINK_LIB + .GLOBAL_EXTS=.o .obj .tidyjson + + GLOBAL_SUFFIX=.global$MODULE_SUFFIX + #TODO: Remove this hack (really we do not need add fake src at all) + ENABLE(NEED_ADD_FAKE_SRC) + _REQUIRE_EXPLICIT_LICENSE(contrib/deprecated contrib/libs contrib/restricted contrib/python) + CHECK_CONTRIB_CREDITS(contrib/clickhouse contrib/libs contrib/deprecated EXCEPT contrib/deprecated/python) + + when ($USE_MKL == "yes") { + NOPLATFORM=yes + } + + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX= + MODULE_SUFFIX=.lib + } + otherwise { + when ($TIDY_ENABLED == "yes") { + MODULE_PREFIX= + MODULE_SUFFIX=.tidyjson + } + otherwise { + MODULE_PREFIX=lib + MODULE_SUFFIX=.a + } + } + + when ($WERROR != "no") { + when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) { + C_WARNING_OPTS += $WERROR_FLAG + } + } + + when ($WITH_VALGRIND == "yes") { + PEERDIR+=contrib/libs/valgrind + # https://st.yandex-team.ru/DTCC-1227 + CFLAGS+=-fdebug-default-version=4 + } + + when ($USE_ARCADIA_LIBM == "yes") { + PEERDIR+=contrib/libs/libm + } +} + +CPP_LIBRARY_INDUCED_SEM_PROPERTY=consumer_link_library +CPP_LIBRARY_SEM=add_library ${MODDIR} $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \ + && library_fake_marker FAKE_MODULE ${FAKE_MODULE} \ + && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET \ + && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \ + && target_include_directories PRIVATE $_C__INCLUDE_OWNED \ + && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \ + && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \ + && target_link_options INTERFACE $LDFLAGS_GLOBAL_RAW \ + && add_language C && add_language CXX +CPP_OBJ_LIBRARY_SEM=add_global_library_for ${MODDIR} ${suf=.global:CMAKE_TARGET_NAME} $CMAKE_TARGET_NAME ${hide:GLOBAL_TARGET} ${hide:AUTO_INPUT} \ + && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \ + && target_include_directories PRIVATE $_C__INCLUDE_OWNED \ + && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \ + && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW + +CMAKE_FIND_PKG= +CMAKE_LINK_TARGET=$REALPRJNAME +CMAKE_FIND_PKG_COMP= +CONAN_REQUIRE= +CONAN_OPTS_SEM= + +### @usage: LIBRARY() +### +### The regular static library module. +### +### The LIBRARY() is intermediate module, so when built directly it won't build its dependencies. +### It transitively provides its PEERDIRs to ultimate final target, where all LIBRARY() modules are built and linked together. +### +### This is C++ library, and it selects peers from multimodules accordingly. +### +### It makes little sense to mention LIBRARY in DEPENDS or BUNDLE, package and deploy it since it is not a standalone entity. +### In order to use library in tests PEERDIR it to link into tests. +### If you think you need to distribute static library please contact devtools@ for assistance. +module LIBRARY: _LIBRARY { + .GLOBAL=_AARS _PROGUARD_RULES + .SEM=CPP_LIBRARY_SEM + .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM + .DEFAULT_NAME_GENERATOR=ThreeDirNames + .ARGS_PARSER=Base + + when ($CMAKE_PACKAGE_COMPONENT != "") { + CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT + } + when ($CMAKE_PACKAGE != "") { + CMAKE_FIND_PKG=find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP + CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED + } + when ($CONAN_REFERENCE != "") { + CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE + CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED + } + when ($CONAN_PKG_OPTS != "") { + CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS + } + when ($OPENSOURCE_EXPORT == "no") { + CPP_LIBRARY_SEM=IGNORED + } + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no" && $SANITIZE_HEADERS && $SANITIZE_HEADERS != "no") { + PEERDIR += library/cpp/sanitizer/include + } + + when ($HAS_CPP_PROTOBUF_PEERS == "yes") { + PEERDIR+=$CPP_PROTOBUF_PEERS + } + SET(MODULE_TYPE LIBRARY) + SET(MODULE_LANG CPP) + + ADD_CLANG_TIDY() +} + +# tag:internal +### @usage: _BARE_MODULE() # internal +### +### Remove unwanted dependencies for "empty" library module +macro _BARE_MODULE() { + SET(NEED_PLATFORM_PEERDIRS no) + SET(PEERDIR_TEST_TOOL no) + DISABLE(WITH_VALGRIND) + NO_CODENAVIGATION() + NO_PLATFORM() + NO_RUNTIME() + NO_UTIL() + NO_CLANG_TIDY() +} + +# tag:internal +### @usage: _BARE_LINK_MODULE() # internal +### +### Remove unwanted dependencies for "empty" link module +macro _BARE_LINK_MODULE() { + _BARE_MODULE() + DISABLE(COMMON_LINK_SETTINGS) + ALLOCATOR(FAKE) +} + +# tag:internal +### @usage: _CONDITIONAL_SRCS([USE_CONDITIONAL_SRCS] Files...) # internal +### +### Adds Files... to SRCS if first word is `USE_CONDITIONAL_SRCS` +### To be used with some variable which is set to `USE_CONDITIONAL_SRCS` under condition +macro _CONDITIONAL_SRCS(USE_CONDITIONAL_SRCS[], DYMMY...) { + SRCS($USE_CONDITIONAL_SRCS) +} + +# XXX: dirty hack for correct LDFLAGS passing +RESOURCES_LIBRARY_LINK=$TOUCH_UNIT +RESOURCES_LIBRARY_SEM=IGNORED + +### @usage: RESOURCES_LIBRARY() +### +### Definition of a module that brings its content from external source (Sandbox) via DECLARE_EXTERNAL_RESOURCE macro. +### This can participate in PEERDIRs of others as library but it cannot have own sources and PEERDIRs. +### +### @see: [DECLARE_EXTERNAL_RESOURCE()](#macro_DECLARE_EXTERNAL_RESOURCE) +module RESOURCES_LIBRARY: _BARE_UNIT { + .CMD=RESOURCES_LIBRARY_LINK + .SEM=RESOURCES_LIBRARY_SEM + .ALLOWED=DECLARE_EXTERNAL_RESOURCE EXTRALIBS OBJADDE_GLOBAL + .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SRC SRCS PEERDIR SPLIT_DWARF + .NODE_TYPE=Library + .PEERDIR_POLICY=as_include + .EXTS=.o .obj .a .mf .supp .tidyjson .ld .lib + .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH + + when ($CMAKE_PACKAGE_COMPONENT != "") { + CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT + } + when ($CMAKE_PACKAGE != "") { + CMAKE_FIND_PKG=find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP + RESOURCES_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED + } + when ($CONAN_REFERENCE != "") { + CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE + RESOURCES_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED + } + when ($CONAN_PKG_OPTS != "") { + CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS + } + + MODULE_SUFFIX=.pkg.fake + ENABLE(NEED_ADD_FAKE_SRC) + WITHOUT_LICENSE_TEXTS() +} + +FAT_OBJECT_SEM=add_fat_object ${MODDIR} ${CMAKE_TARGET_NAME} ${hide:TARGET} ${hide:AUTO_INPUT} ${CMAKE_TARGET_ARTEFACT_RENAME_RULES} \ + && target_include_directories PRIVATE $_C__INCLUDE_OWNED \ + && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \ + && set_global_flags FAT_OBJECT_PREFIX ${MODULE_PREFIX} \ + && set_global_flags FAT_OBJECT_SUFFIX ${MODULE_SUFFIX} + +### Do not turn visibility=hidden symbos into static symbos of partially linked object file +### +### Note: This variable do not have any effect on platforms other than MacOS and iOS. +KEEP_FAT_OBJECT_SYMBOLS=no + +### @usage: FAT_OBJECT() +### +### The "fat" object module. It will contain all its transitive dependencies reachable by PEERDIRs: +### static libraries, local (from own SRCS) and global (from peers') object files. +### +### Designed for use in XCode projects for iOS. +module FAT_OBJECT: LIBRARY { + .ALLOWED=PACK_GLOBALS_IN_LIBRARY + .CMD=LINK_FAT_OBJECT + .SEM=FAT_OBJECT_SEM + .PEERDIR_POLICY=as_build_from + + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_SUFFIX=.lib + } + otherwise { + MODULE_SUFFIX=.a + } + + when (($OS_DARWIN == "yes" || $OS_IOS == "yes") && $KEEP_FAT_OBJECT_SYMBOLS == "yes") { + LDFLAGS_GLOBAL += -keep_private_externs + } + + # FIXME: This is weird legacy + when ($OS_ANDROID == "yes") { + MODULE_PREFIX=lib + } + otherwise { + MODULE_PREFIX= + } + + _USE_LINKER() + + # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS + # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation + DISABLE(NEED_ADD_FAKE_SRC) + SRCS(build/scripts/_fake_src.cpp) +} + +RECURSIVE_LIBRARY_SEM=add_recursive_library ${MODDIR} ${CMAKE_TARGET_NAME} ${hide:TARGET} ${hide:AUTO_INPUT} ${CMAKE_TARGET_ARTEFACT_RENAME_RULES} \ + && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \ + && target_include_directories PRIVATE $_C__INCLUDE_OWNED \ + && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \ + && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \ + && target_link_options INTERFACE $LDFLAGS_GLOBAL_RAW + +### @usage: RECURSIVE_LIBRARY() +### +### The recursive ("fat") library module. It will contain all its transitive dependencies reachable by PEERDIRs: +### from static libraries, local (from own SRCS) and global (from peers') object files. +### +### Designed for use in XCode projects for iOS. +module RECURSIVE_LIBRARY: LIBRARY { + .CMD=LINK_RECURSIVE_LIBRARY + .SEM=RECURSIVE_LIBRARY_SEM + .PEERDIR_POLICY=as_build_from + + # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS + # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation + DISABLE(NEED_ADD_FAKE_SRC) + SRCS(build/scripts/_fake_src.cpp) +} + +_SONAME= +_EXPORT_SCRIPT_SEM= +_CLEAN_TEXTREL= +macro _ADD_DYNLYB_SEM(Libname) { + .SEM=add_library ${MODDIR} ${Libname} SHARED ${hide:TARGET} ${hide:AUTO_INPUT} && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL && target_include_directories PRIVATE $_C__INCLUDE_OWNED && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW && target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE && ${VCS_INFO_SEM} $_EXPORT_SCRIPT_SEM +} +CPP_DYN_LIBRARY_SEM=$_ADD_DYNLYB_SEM($CMAKE_TARGET_NAME) $CMAKE_TARGET_ARTEFACT_RENAME_RULES + +macro CLEAN_TEXTREL() { + SET(_CLEAN_TEXTREL yes) +} +### @usage: DLL_UNIT # internal +### +### Base module for all dynamically linked libraries as final artifacts. +### Contains all general logic for such kind of modules. Supports versioning and export files. +### Cannot participate in linking to programs, intended to be used as final artifact (packaged and deployed). +module DLL_UNIT: _LINK_UNIT { + .CMD=LINK_DYN_LIB + .SEM=CPP_DYN_LIBRARY_SEM + .NODE_TYPE=Library + .SYMLINK_POLICY=SO + .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH + .ALLOWED=WHOLE_ARCHIVE + .DEFAULT_NAME_GENERATOR=TwoDirNames + .ARGS_PARSER=DLL + DYNAMIC_LINK=yes + ALLOCATOR(FAKE) + SET(MODULE_TYPE DLL) + SET(MODULE_TAG DLL) + SET(MODULE_LANG CPP) + ADD_CLANG_TIDY() + + when ($EXPORTS_FILE) { + _EXPORT_SCRIPT_SEM=&& use_export_script ${input:EXPORTS_FILE} + } + + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_SUFFIX=.dll + } + elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") { + MODULE_PREFIX=lib + MODULE_SUFFIX=.dylib + } + elsewhen ($TIDY_ENABLED == "yes") { + MODULE_PREFIX= + MODULE_SUFFIX=.tidyjson + } + otherwise { + MODULE_PREFIX=lib + MODULE_SUFFIX=.so + } + + # This by now replicates ymake's behavior. We'll get rid of SONAME setting in ymake and fix this code altogether + SONAME=${pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX:REALPRJNAME} + when ($MODULE_VERSION) { + LINK_DYN_LIB_FLAGS=--soname ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION:REALPRJNAME} + } + _SONAME=$SONAME$MODULE_VERSION + + when ($LINUX == "yes") { + # '-z notext' is needed for linking mkl into shared libraries + when ($_CLEAN_TEXTREL != "yes") { + LDFLAGS += -Wl,-z,notext + } + } + + when ($OS_LINUX == "yes" && $ARCH_X86_64 == "yes") { + when ($_NO_FIX_ELF != "yes") { + LINK_DYN_LIB_FLAGS+=--fix-elf ${tool:"tools/fix_elf"} + } + } + + when ($DARWIN == "yes") { + LDFLAGS += -undefined dynamic_lookup + } + + when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") { + PEERDIR+=library/cpp/testing/dump_clang_coverage + } + + when ($IDE_MSVS == "yes") { + PEERDIR+=build/scripts/c_templates + } + + when ($_CUSTOM_LINK_STEP_SCRIPT) { + LINK_DYN_LIB_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT} + } +} + +# tag:python-specific +### @usage: PY_ANY_MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix]) +### +### The Python external module for any versio of Arcadia or system Python. +### 1. major_ver and minor_ver must be integers. +### 2. The resulting .so will have the prefix "lib". +### 3. Processing EXPORTS and PREFIX is the same as for DLL module +### This is native DLL, so it will select C++ version from PROTO_LIBRARY. +### +### Note: Use PYTHON2_MODULE()/PYTHON3_MODULE() in order to PEERDIR proper version of PY23_NATIVE_LIBRARY. +### Do not PEERDIR any PY*_LIBRARY: this will link Python in and render artifact unusable as Python module. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module PY_ANY_MODULE: DLL_UNIT { + .SEM=CPP_DYN_LIBRARY_SEM + when ($MSVC != "yes" && $DARWIN != "yes") { + LDFLAGS+= -Wl,-Bsymbolic + } + + when ($USE_ARCADIA_PYTHON == "no") { + when ($USE_SYSTEM_PYTHON) { + PEERDIR+=build/platform/python + } + otherwise { + when ($MSVC == "yes" || $CYGWIN == "yes") { + LDFLAGS+=$PYTHON_LIBRARIES + } + } + } + + # This by now replicates ymake's behavior. We'll get rid of SONAME setting in ymake and fix this code altogether + SONAME=${pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX:REALPRJNAME} + when ($MODULE_VERSION) { + LINK_DYN_LIB_FLAGS=--soname ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION:REALPRJNAME} + } + _SONAME=$SONAME$MODULE_VERSION + + # -bundle + when ($DARWIN == "yes") { + LDFLAGS+=-flat_namespace + } + + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX= + MODULE_SUFFIX=.pyd + } + otherwise { + MODULE_PREFIX= + MODULE_SUFFIX=.so + } + .RESTRICTED=USE_PYTHON2 USE_PYTHON3 PY_SRCS PY_MAIN +} + +# tag:python-specific +### @usage: PY2MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix]) +### +### The Python external module for Python2 and any system Python +### 1. major_ver and minor_ver must be integers. +### 2. The resulting .so will have the prefix "lib". +### 3. Processing EXPORTS and PREFIX is the same as for DLL module +### This is native DLL, so it will select C++ version from PROTO_LIBRARY. +### +### Note: this module will always PEERDIR Python2 version of PY23_NATIVE_LIBRARY. +### Do not PEERDIR PY2_LIBRARY or PY23_LIBRARY: this will link Python in and render artifact unusable as Python module. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module PY2MODULE: PY_ANY_MODULE { + PYTHON2_MODULE() + SET(MODULE_LANG PY2) + .RESTRICTED=PYTHON3_MODULE PYTHON3_ADDINCL +} + +# tag:python-specific +### @usage: PY3MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix]) +### +### The Python external module for Python3 and any system Python +### 1. major_ver and minor_ver must be integers. +### 2. The resulting .so will have the prefix "lib". +### 3. Processing EXPORTS and PREFIX is the same as for DLL module +### This is native DLL, so it will select C++ version from PROTO_LIBRARY. +### +### Note: this module will always PEERDIR Python3 version of PY23_NATIVE_LIBRARY. +### Do not PEERDIR PY3_LIBRARY or PY23_LIBRARY: this will link Python in and render artifact unusable as Python module. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module PY3MODULE: PY_ANY_MODULE { + PYTHON3_MODULE() + SET(MODULE_LANG PY3) + .RESTRICTED=PYTHON2_MODULE PYTHON2_ADDINCL +} + +# tag:python-specific +### @usage: PYTHON2_MODULE() +### +### Use in PY_ANY_MODULE to set it up for Python 2.x. +macro PYTHON2_MODULE() { + when ($USE_ARCADIA_PYTHON == "yes" && $MSVC == "yes" || $IS_CROSS_TOOLS == "yes") { + PEERDIR+=contrib/tools/python/lib + } + SET(ANTLR_PYTHON Python2) + PYTHON2_ADDINCL() +} + +# tag:python-specific +### @usage: PYTHON3_MODULE() +### +### Use in PY_ANY_MODULE to set it up for Python 3.x. +macro PYTHON3_MODULE() { + when ($USE_ARCADIA_PYTHON == "yes" && $MSVC == "yes" || $IS_CROSS_TOOLS == "yes") { + PEERDIR+=contrib/tools/python3/lib + } + + SET(ANTLR_PYTHON Python3) + PYTHON3_ADDINCL() +} + +# tag:r-specific +### @usage: R_MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix]) +### +### The external module for R language. +### 1. major_ver and minor_ver must be integers. +### 2. The resulting .so will have the prefix "lib". +### 3. Processing EXPORTS and PREFIX is the same as for DLL module +### This is native DLL, so it will select C++ version from PROTO_LIBRARY. +module R_MODULE: DLL_UNIT { + .SEM=CPP_DYN_LIBRARY_SEM + when ($DARWIN == "yes") { + LDFLAGS+=-flat_namespace -dynamiclib + } + + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=lib + MODULE_SUFFIX=.dll + } + + ADDINCL(contrib/libs/r-lang) +} + +### @usage: DYNAMIC_LIBRARY_FROM(Paths) +### +### Use specified libraries as sources of DLL +macro DYNAMIC_LIBRARY_FROM(Path...) { + PEERDIR($Path) + WHOLE_ARCHIVE($Path) +} + + +### @usage: DLL(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix]) +### +### Dynamic library module definition. +### 1. major_ver and minor_ver must be integers. +### 2. EXPORTS allows you to explicitly specify the list of exported functions. This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files +### 3. PREFIX allows you to change the prefix of the output file (default DLL has the prefix "lib"). +### +### DLL cannot participate in linking to programs but can be used from Java or as final artifact (packaged and deployed). +module DLL: DLL_UNIT { + .SEM=CPP_DYN_LIBRARY_SEM + SET(MAKE_ONLY_SHARED_LIB yes) + when ($OS_WINDOWS) { + MODULE_SUFFIX=.dll + } + + # TODO: Make it possible to use this syntax + # DEFAULT(DLL_FOR_DIR no) + ### FIXME: XXX + ###when ($DLL_FOR_DIR != "no") { + ### SRCDIR($DLL_FOR_DIR) + ### ADDINCL($DLL_FOR_DIR) + ###} +} + +### DLL_TOOL is a DLL that can be used as a LD_PRELOAD tool. +module DLL_TOOL: DLL { + .SEM=CPP_DYN_LIBRARY_SEM + # ymake resolves only program nodes as tools. + .NODE_TYPE=Program +} + +### @usage: SO_PROGRAM(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix]) +### +### Executable dynamic library module definition. +### 1. major_ver and minor_ver must be integers. +### 2. EXPORTS allows you to explicitly specify the list of exported functions. This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files +### 3. PREFIX allows you to change the prefix of the output file. +module SO_PROGRAM: DLL { + .CMD=LINK_EXEC_DYN_LIB + SET(MODULE_TYPE PROGRAM) + + MODULE_PREFIX= + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_SUFFIX=.exe + } + otherwise { + MODULE_SUFFIX= + } +} + +DLL_PROXY_CMD_MF=$GENERATE_MF && $COPY_CMD $AUTO_INPUT $TARGET + +# tag:internal +### @usage: DEV_DLL_PROXY() # internal +### +### The use of this module is strictly prohibited!!! +### This is a temporary and project-specific solution. +module DEV_DLL_PROXY: _BARE_UNIT { + .NODE_TYPE=Library + .EXTS=.so .dll .dylib .mf + .CMD=DLL_PROXY_CMD_MF + DYNAMIC_LINK=yes + + when ($OS_WINDOWS == "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 + } +} + +# tag:internal +### @usage: DLL_PROXY() # internal +### +### The use of this module is strictly prohibited!!! +### This is a temporary and project-specific solution. +module DLL_PROXY: DEV_DLL_PROXY { + .EXTS=.so .dylib .lib .mf + .PROXY=yes + .PEERDIR_POLICY=as_build_from + SET(PEERDIR_TAGS DLL __EMPTY__) + + when ($OS_WINDOWS == "yes") { + MODULE_SUFFIX=.lib + } +} + +# tag:internal +### @usage: DYNAMIC_DEPS(Path...) # internal, temporary +### +### Enlist paths to all DYNAMIC_LIBRARY dependencies of the DYNAMIC_LIBRARY +### This it needed to transfer their outputs through the library to PROGRAM +### or dependent DLL/DYNAMIC_LIBRARY. +### +### Note: this is temporary solution until support of `super-global` variables come +### which will enable transfer of some properties though final targets like DLLs. +macro DYNAMIC_DEPS(Path...) { + # PEERDIR as macro completely ignored in place where this macro applies + SET_APPEND(PEERDIR $Path) +} + +# tag:internal +### @usage: DYNAMIC_LIBRARY() # internal +### +### The use of this module is strictly prohibited except LGPL-related opensourcing +### This provides linkable DLL module which brings its results to programs and tests +### for seamless testing and packaging +multimodule DYNAMIC_LIBRARY { + module DLL_BIN: DLL { + .PROXY=yes + .IGNORED=PROVIDES + SET(MODULE_TAG DLL) + } + module DLL_LIB: _DLL_COMPATIBLE_LIBRARY { + .CMD=TOUCH_UNIT_MF + .PEERDIRSELF=DLL_BIN + .IGNORED=SRCS PEERDIR RUN_PROGRAM PYTHON DYNAMIC_LIBRARY_FROM GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2 USE_PYTHON3 + .ALLOWED=DYNAMIC_DEPS + + SET(PEERDIR_TAGS DLL_LIB __EMPTY__) + + _BARE_MODULE() + DYNAMIC_LINK=yes + MODULE_SUFFIX=.pkg.fake + PEERDIR+=build/platform/local_so + + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no" && $SANITIZE_HEADERS && $SANITIZE_HEADERS != "no") { + PEERDIR += library/cpp/sanitizer/include + } + + # disable credits generation for static library + SET(CREDITS_FLAGS) + } +} + +### @usage: GLOBAL_SRCS(filenames...) +### +### Make all source files listed as GLOBAL. +### Call to GLOBAL_SRCS macro is equivalent to call to SRCS macro when each source file is marked with GLOBAL keyword. +### Arcadia root relative or project dir relative paths are supported for filenames arguments. GLOBAL keyword is not +### recognized for GLOBAL_SRCS in contrast to SRCS macro. +### +### @example: +### Consider the file to ya.make: +### +### LIBRARY() +### GLOBAL_SRCS(foo.cpp bar.cpp) +### END() +### +### @see: [SRCS()](#macro_SRCS) +macro GLOBAL_SRCS(Files...) { + SRCS(${pre=GLOBAL :Files}) +} + +### @usage: ALL_SRCS([GLOBAL] filenames...) +### +### Make all source files listed as GLOBAL or not depending on the keyword GLOBAL +### Call to ALL_SRCS macro is equivalent to call to GLOBAL_SRCS macro when GLOBAL keyword is specified +### as the first argument and is equivalent to call to SRCS macro otherwise. +### +### @example: +### +### LIBRARY() +### SET(MAKE_IT_GLOBAL GLOBAL) +### ALL_SRCS(${MAKE_IT_GLOBAL} foo.cpp bar.cpp) +### END() +### +### @see: [GLOBAL_SRCS()](#macro_GLOBAL_SRCS), [SRCS()](#macro_SRCS) +macro ALL_SRCS(GLOBAL?"GLOBAL":"", Files...) { + SRCS(${pre=$GLOBAL :Files}) +} + +### @usage: _DLL_COMPATIBLE_LIBRARY # internal +### +### Base module to place DLLs into multimodules back to back with libraries. +### In order to function properly all modules in multimodule shall have the +### same set of arguments. So this module is just library that accepts but +### ignores all DLL arguments. +module _DLL_COMPATIBLE_LIBRARY: LIBRARY { + .DEFAULT_NAME_GENERATOR=TwoDirNames + .ARGS_PARSER=DLL +} + +@import "${CONF_ROOT}/conf/project_specific/yql_udf.conf" + +# as SRCS in packages use macro BUNDLE_SRCS! + +PACKED_PACKAGE_ARGS= +PACKED_PACKAGE_EXT= +### @usage: PACK(archive_type) +### +### When placed inside the PACKAGE module, packs the build results tree to the archive with specified extension. Currently supported extensions are `tar` and `tar.gz` +### +### Is not allowed other module types than PACKAGE(). +### +### @see: [PACKAGE()](#module_PACKAGE) +macro PACK(Ext) { + SET(PACKED_PACKAGE_EXT $Ext) +} + +PACKAGE_STRICT_VALUE= +macro PACKAGE_STRICT() { + SET(PACKAGE_STRICT_VALUE yes) +} + +### @usage: PACKAGE(name) +### +### Module collects what is described directly inside it, builds and collects all its transitively available PEERDIRs. +### As a result, build directory of the project gets the structure of the accessible part of Arcadia, where the build result of each PEERDIR is placed to relevant Arcadia subpath. +### The data can be optionally packed if macro PACK() is used. +### +### Is only used together with the macros FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a PACKAGE. +### +### Documentation: https://wiki.yandex-team.ru/yatool/large-data/ +### +### @see: [PACK()](#macro_PACK) +multimodule PACKAGE { + module PACKAGE_FINAL: _BASE_UNIT { + .CMD=TOUCH_PACKAGE_MF + .ALIASES=SRCS=FILES + .ALLOWED=PACK + .PEERDIRSELF=PACKAGE_UNION + .USE_PEERS_LATE_OUTS=yes + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=yes + SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2 PY3 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE PY3_BIN PY3TEST_PROGRAM DLL GO_PROGRAM PACKAGE_UNION) + + SET(MODULE_SUFFIX .final.pkg.fake) + SET(DONT_RESOLVE_INCLUDES yes) + NO_PLATFORM() + when ($PACKED_PACKAGE_EXT) { + PACKED_PACKAGE_ARGS+=--dest-arch ${output;pre=$MODULE_PREFIX;suf=.$PACKED_PACKAGE_EXT:REALPRJNAME} + } + SET(NEED_PLATFORM_PEERDIRS no) + } + module PACKAGE_UNION: UNION { + .CMD=UNION_CMD + .FINAL_TARGET=no + .ALLOWED=PACK + + SET(MODULE_SUFFIX .pkg.fake) + SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2 PY3 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE PY3_BIN PY3TEST_PROGRAM DLL GO_PROGRAM PACKAGE_UNION) + + DISABLE(START_TARGET) + } +} + +TOUCH_GROUP=$TOUCH_PACKAGE ${kv;hide:"p CI"} + +### @usage: CI_GROUP() +### +### Module collects what is described directly inside it transitively by PEERDIRs. +### No particular layout of built artifacts is implied. This module is needed primarily for CI dependency analysis and may not trigger builds at all. +### +### Is only used together with the macro PEERDIR() and FILES(). Don't use SRCS inside CI_GROUP(). +module CI_GROUP: _BARE_UNIT { + .CMD=TOUCH_GROUP + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=yes + .RESTRICTED=SRCS + .USE_PEERS_LATE_OUTS=yes + MODULE_SUFFIX=.ci.pkg.fake + PEERDIR_TAGS=CPP_PROTO PY3 PY3_NATIVE PY3_BIN PY3TEST_PROGRAM YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE DLL +} + +# tag:generic tag:internal +TOUCH_UNIT_MF=$TOUCH_UNIT && $GENERATE_MF + +# tag:proto +### @usage: RESOLVE_PROTO() +### +### Enable include resolving within UNIONs and let system .proto being resolved +### among .proto/.gztproto imports +### +### Note: it is currently impossible to enable resolving only for .proto, so resolving is enabled for all supported files +### also we only add ADDINCL for stock protobuf. So use this macro with care: it may cause resolving problems those are +### to be addressed by either ADDINCLs or marking them as TEXT. Please contact devtools for details. +macro RESOLVE_PROTO() { + SET(DONT_RESOLVE_INCLUDES no) + ADDINCL(FOR proto $PROTOBUF_PATH) +} + +### @usage: UNION(name) +### +### Collection of PEERDIR dependencies, files and artifacts. +### UNION doesn't build its peers, just provides those to modules depending on it. +### When specified in DEPENDS() macro the UNION is transitively closed, building all its peers and providing those by own paths (without adding this module path like PACKAGE does). +### +### Is only used together with the macros like FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a UNION. +### +### Documentation: https://wiki.yandex-team.ru/yatool/large-data/ +module UNION: _BASE_UNIT { + .CMD=UNION_CMD_MF + .FINAL_TARGET=no + .ALIASES=SRCS=FILES + .ALLOWED=EXPLICIT_OUTPUTS + NO_PLATFORM() + SET(MODULE_SUFFIX .pkg.fake) + SET(DONT_RESOLVE_INCLUDES yes) + SET(NEED_PLATFORM_PEERDIRS no) + PEERDIR_TAGS=CPP_PROTO CPP_FBS PY2 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE PY3_BIN DLL PACKAGE_UNION +} + +# tag:python-specific +module _PY_PACKAGE: UNION { + .EXTS=.py + .ALLOWED=GRPC USE_SKIFF + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER + ENABLE(PY_PROTOS_FOR) + SET(PEERDIR_TAGS PY_PROTO) + SET(DONT_RESOLVE_INCLUDES no) +} + +# tag:python-specific tag:deprecated tag:internal +### @usage: PY_PACKAGE(name) # internal, deprecated +### +### This is module created via PY_PROTOS_FOR() macro +module PY_PACKAGE: _PY_PACKAGE { + .ALIASES=SRCS=SRCS + .FINAL_TARGET=yes +} + +# tag:internal +### @usage: _SET_FIRST_VALUE(name args...) # internal +### +### This macro sets the value of `name` variable to the value of next argument +macro _SET_FIRST_VALUE(NAME, VALUE, OTHER...) { + SET($NAME $VALUE) +} + +# tag:python-specific +PY_NAMESPACE_VALUE= + +# tag:python-specific +### @usage: PY_NAMESPACE(prefix) +### +### Sets default Python namespace for all python sources in the module. +### Especially suitable in PROTO_LIBRARY where Python sources are generated and there is no PY_SRCS to place NAMESPACE parameter. +macro PY_NAMESPACE(Arg) { + SET(PY_NAMESPACE_VALUE $Arg) +} + +# tag:internal +### @usage: _SRCS_NO_GLOBAL(files...) # internal +### +### Proxy macro to SRCS macro which filters out GLOBAL keyword from the list of source files. +### Useful for modules like EXTERNAL_JAVA_LIBRARY, where GLOBAL keyword cannot be applied properly. +### Note: this macro changes order of source files. +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 + + 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}", 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"} $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 + + 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} && IGNORED +# tag:java-specific +module JAVA_CONTRIB: _JAR_BASE { + .CMD=FETCH_CONTRIB_JAR + .SEM=JAVA_CONTRIB_SEM + .FINAL_TARGET=yes + .GLOBAL=MAVEN_EXPORT_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 $APPLIED_EXCLUDES && 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 + 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() +} + +# tag:java-specific +multimodule JUNIT5_YMAKE { + module JAR_TESTABLE: _JAR_TEST { + .ALLOWED=JAVA_TEST_PEERDIR + .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM + .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_TEST_PEERDIR=PEERDIR + .PEERDIRSELF=JAR_COMPILATION + + SET(MODULE_TYPE JUNIT5) + } + module JAR_COMPILATION: JAR_LIBRARY { + .IGNORED=JAVA_TEST_PEERDIR + .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO + .FINAL_TARGET=no + + PEERDIR(devtools/junit5-runner build/platform/java/jacoco-agent) + } +} + +# tag:java-specific +multimodule JTEST_YMAKE { + module JAR_TESTABLE: _JAR_TEST { + .ALLOWED=YT_SPEC + .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM + .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_TEST_PEERDIR=PEERDIR + .PEERDIRSELF=JAR_COMPILATION + + SET(MODULE_TYPE JTEST) + PEERDIR(devtools/junit-runner) + DEPENDENCY_MANAGEMENT(contrib/java/org/hamcrest/hamcrest-core/1.3 contrib/java/com/google/code/gson/gson/2.8.6 contrib/java/com/beust/jcommander/1.72 contrib/java/junit/junit/4.12) + } + module JAR_COMPILATION: JAR_LIBRARY { + .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO + .ALLOWED=YT_SPEC + .FINAL_TARGET=no + + DEPENDS(contrib/java/org/sonarsource/scanner/cli/sonar-scanner-cli/2.8) + PEERDIR(build/platform/java/jacoco-agent) + } +} + +# tag:python-specific tag:deprecated +### @usage: PY2_LIBRARY() # deprecated +### +### Deprecated. Use PY23_LIBRARY or PY3_LIBRARY instead. +### Python 2.x binary built library. Builds sources from PY_SRCS to data suitable for PY2_PROGRAM. +### Adds dependencies to Python 2.x runtime library from Arcadia. +### This module is only compatible with PYTHON2-tagged modules and selects those from multimodules. +### This module is only compatible with Arcadia Python build. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module PY2_LIBRARY: _LIBRARY { + _ARCADIA_PYTHON_ADDINCL() + + when ($NO_PYTHON_INCLS != "yes") { + PEERDIR+=contrib/libs/python + } + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=py + } + otherwise { + MODULE_PREFIX=libpy + } + .ALLOWED=FORK_TESTS + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2 + .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS STYLE_PYTHON + USE_GLOBAL_CMD=yes + + when ($PY_PROTO_MYPY_ENABLED == "yes") { + PY_PROTO_MYPY_SUFFIX=_pb2.pyi + PY_PROTO_MYPY_PLUGIN=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=_pb2.pyi:File} + PY_PROTO_MYPY_PLUGIN_INTERNAL=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=__int___pb2.pyi:File} ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___pb2.pyi:File} ${nopath;noext;suf=_pb2.pyi:File}"}) + } + SET(MODULE_LANG PY2) + ADD_CLANG_TIDY() +} + + +# tag:python-specific +### @usage: PY3_LIBRARY() +### +### Python 3.x binary library. Builds sources from PY_SRCS to data suitable for PY2_PROGRAM +### Adds dependencies to Python 2.x runtime library from Arcadia. +### This module is only compatible with PYTHON3-tagged modules and selects those from multimodules. +### This module is only compatible with Arcadia Python build. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module PY3_LIBRARY: _LIBRARY { + _ARCADIA_PYTHON3_ADDINCL() + + when ($NO_PYTHON_INCLS != "yes") { + PEERDIR+=contrib/libs/python + } + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=py + } + otherwise { + MODULE_PREFIX=libpy + } + .ALLOWED=FORK_TESTS + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER + .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL USE_PYTHON2 OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS + USE_GLOBAL_CMD=yes + + RUN_CYTHON_SCRIPT=$YMAKE_PYTHON3 $CYTHON_SCRIPT + RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON3 $CYTHON_SCRIPT + PYTHON_TYPE_FOR_CYTHON=PY3 + ANTLR_PYTHON=Python3 + + when ($PY_PROTO_MYPY_ENABLED == "yes") { + PY_PROTO_MYPY_SUFFIX=_pb2.pyi + PY_PROTO_MYPY_PLUGIN=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=_pb2.pyi:File} + PY_PROTO_MYPY_PLUGIN_INTERNAL=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=__int___pb2.pyi:File} ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___pb2.pyi:File} ${nopath;noext;suf=_pb2.pyi:File}"}) + } + SET(MODULE_LANG PY3) + ADD_CLANG_TIDY() +} + + +# tag:python-specific +### @usage: _BASE_PY_PROGRAM #internal +### +### The base module for all Python 2.x binary programs. Adds linking logic, relevant module properties and +### dependency on Python 2.x interpreter. Also adds import tests on all sources including PEERDIR'ed libraries. +### Links all Python 2.x libraries and Python 2.x interpreter into itself to form regular executable. +### This only compatible with PYTHON2-tagged modules and selects those from multimodules. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module _BASE_PY_PROGRAM: _BASE_PROGRAM { + .CMD=PY_PROGRAM_LINK_EXE + _ARCADIA_PYTHON_ADDINCL() + + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") { + NO_CHECK_IMPORTS_FOR_VALUE= + } + ADD_CHECK_PY_IMPORTS() + + when ($NO_PYTHON_INCLS != "yes") { + PEERDIR += contrib/libs/python + } + when ($USE_ARCADIA_PYTHON == "yes") { + PEERDIR += library/python/runtime/main + PEERDIR += contrib/deprecated/python/subprocess32 + when ($PYTHON_SQLITE3 != "no") { + PEERDIR += contrib/tools/python/src/Modules/_sqlite + } + } + when ($PYTHON_COVERAGE == "yes") { + PEERDIR+=library/python/coverage + } + + when ($ARCH_PPC64LE == "yes") { + _MY_ALLOCATOR=SYSTEM + } + otherwise { + _MY_ALLOCATOR=J + } + ALLOCATOR($_MY_ALLOCATOR) + STRIP() + + when ($BUILD_TYPE == "DEBUG") { + NO_STRIP=yes + } + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") { + NO_STRIP=yes + } + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2 + .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS + SET(MODULE_LANG PY2) +} + +# tag:python-specific tag:codenav +when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") { + PY3_PROGRAM_LINK_EXE=$LINK_EXE ${kv;hide:"py3yndex $TARGET"} +} +otherwise { + PY3_PROGRAM_LINK_EXE=$LINK_EXE +} + + +# tag:python-specific +### @usage: _BASE_PY_PROGRAM #internal +### +### The base module for all Python 3.x binary programs. Adds linking logic, relevant module properties and +### dependency on Python 3.x interpreter. Also adds import tests on all sources including libraries. +### Links all Python 3.x libraries and Python 3.x interpreter into itself to form regular executable. +### This only compatible with PYTHON3-tagged modules and selects those from multimodules +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/ +module _BASE_PY3_PROGRAM: _BASE_PROGRAM { + .CMD=PY3_PROGRAM_LINK_EXE + _ARCADIA_PYTHON3_ADDINCL() + RUN_CYTHON_SCRIPT=$YMAKE_PYTHON3 $CYTHON_SCRIPT + RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON3 $CYTHON_SCRIPT + PYTHON_TYPE_FOR_CYTHON=PY3 + PEERDIR(library/python/runtime_py3/main) + when ($PYTHON_SQLITE3 != "no") { + PEERDIR += contrib/tools/python3/src/Modules/_sqlite + } + + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") { + NO_CHECK_IMPORTS_FOR_VALUE= + } + ADD_CHECK_PY_IMPORTS() + + when ($ARCH_PPC64LE == "yes") { + _MY_ALLOCATOR=SYSTEM + } + otherwise { + _MY_ALLOCATOR=J + } + ALLOCATOR($_MY_ALLOCATOR) + STRIP() + + when ($NO_PYTHON_INCLS != "yes") { + PEERDIR+=contrib/libs/python + } + when ($BUILD_TYPE == "DEBUG") { + NO_STRIP=yes + } + when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") { + NO_STRIP=yes + } + when ($PYTHON_COVERAGE == "yes") { + PEERDIR+=library/python/coverage + } + when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") { + PEERDIR += contrib/python/six + } + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER + .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL USE_PYTHON2 + SET(MODULE_LANG PY3) + SET(ANTLR_PYTHON Python3) +} + +# tag:python-specific +### @usage: PY3_PROGRAM_BIN([progname]) +### Use instead of PY3_PROGRAM only if ya.make with PY3_PROGRAM() included in another ya.make +### In all other cases use PY3_PROGRAM +module PY3_PROGRAM_BIN: _BASE_PY3_PROGRAM { + # Look's like we cannot avoid copy-paste util ymake supports multiple inheritance + # We need to attach coverage.extractor to every py_program target, except pytest targets + ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor) +} + +# tag:java-specific +JAVA_SWIG_DELIM=JAVA_SWIG_DELIM + +# tag:java-specific +JDK_REAL_VERSION= +JDK_VERSION= + +when ($JDK_VERSION == "20") { + JDK_REAL_VERSION=20 +} +elsewhen ($JDK_VERSION == "19") { + JDK_REAL_VERSION=19 +} +elsewhen ($JDK_VERSION == "18") { + JDK_REAL_VERSION=18 +} +elsewhen ($JDK_VERSION == "17") { + JDK_REAL_VERSION=17 +} +elsewhen ($JDK_VERSION == "16") { + JDK_REAL_VERSION=16 +} +elsewhen ($JDK_VERSION == "15") { + JDK_REAL_VERSION=15 +} +elsewhen ($JDK_VERSION == "11") { + JDK_REAL_VERSION=11 +} +elsewhen ($JDK_VERSION == "10") { + JDK_REAL_VERSION=10 +} +elsewhen ($JDK_VERSION == "8") { + JDK_REAL_VERSION=8 +} +elsewhen ($MAPSMOBI_BUILD_TARGET && $OS_ANDROID) { + JDK_REAL_VERSION=11 +} +otherwise { + JDK_REAL_VERSION=17 +} + + +# tag:java-specific +# remove extra peerdir to jdk11 after https://st.yandex-team.ru/DEVTOOLS-8851 is done +when ($USE_SYSTEM_JDK) { + JDK_RESOURCE_PEERDIR= +} +otherwise { + when ($JDK_REAL_VERSION == "20") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk20 build/platform/java/jdk/jdk17 + } + when ($JDK_REAL_VERSION == "19") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk19 build/platform/java/jdk/jdk17 + } + when ($JDK_REAL_VERSION == "18") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk18 build/platform/java/jdk/jdk17 + } + when ($JDK_REAL_VERSION == "17") { + # need jdk11 for spare parts in "host" platform + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk17 build/platform/java/jdk/jdk11 + } + when ($JDK_REAL_VERSION == "16") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk16 build/platform/java/jdk/jdk17 + } + when ($JDK_REAL_VERSION == "15") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk15 build/platform/java/jdk/jdk17 + } + when ($JDK_REAL_VERSION == "11") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk11 build/platform/java/jdk/jdk17 + } + when ($JDK_REAL_VERSION == "10") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk10 build/platform/java/jdk/jdk17 + } + when ($JDK_REAL_VERSION == "8") { + JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk8 build/platform/java/jdk/jdk17 + } +} + +# tag:java-specific +when ($JDK_REAL_VERSION == "20") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar20 +} +when ($JDK_REAL_VERSION == "19") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar18 +} +when ($JDK_REAL_VERSION == "18") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar18 +} +when ($JDK_REAL_VERSION == "17") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar17 +} +when ($JDK_REAL_VERSION == "16") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar16 +} +when ($JDK_REAL_VERSION == "15") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar15 +} +when ($JDK_REAL_VERSION == "11") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar11 +} +when ($JDK_REAL_VERSION == "10") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar10 +} +when ($JDK_REAL_VERSION == "8") { + UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar8 +} + +# tag:java-specific +JAVAC_OPTS= +when ($USE_SYSTEM_JDK) { + JDK_RESOURCE=$USE_SYSTEM_JDK +} +otherwise { + when ($JDK_REAL_VERSION == "20") { + JDK_RESOURCE=$JDK20_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "19") { + JDK_RESOURCE=$JDK19_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "18") { + JDK_RESOURCE=$JDK18_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "17") { + JDK_RESOURCE=$JDK17_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "16") { + JDK_RESOURCE=$JDK16_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "15") { + JDK_RESOURCE=$JDK15_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "11") { + JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "10") { + JDK_RESOURCE=$JDK10_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "8") { + JDK_RESOURCE=$JDK8_RESOURCE_GLOBAL + } +} + +# tag:java-specific +when (!$USE_SYSTEM_ERROR_PRONE) { + # Still not done: DTCC-667 + when ($JDK_REAL_VERSION == "8" || $JDK_REAL_VERSION == "10") { + ERROR_PRONE_VERSION=2.3.1 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.3.1 + ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_3_1_RESOURCE_GLOBAL + } + elsewhen ($JDK_REAL_VERSION == "11" || $JDK_REAL_VERSION == "15" || $JDK_REAL_VERSION == "16") { + ERROR_PRONE_VERSION=2.7.1 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.7.1 + ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_7_1_RESOURCE_GLOBAL + } + elsewhen ($JDK_REAL_VERSION == "17") { + ERROR_PRONE_VERSION=2.10.0 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.10.0 + ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_10_0_RESOURCE_GLOBAL + } + elsewhen ($JDK_REAL_VERSION == "18") { + ERROR_PRONE_VERSION=2.14.0 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.14.0 + ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_14_0_RESOURCE_GLOBAL + } + elsewhen ($JDK_REAL_VERSION == "19") { + ERROR_PRONE_VERSION=2.18.0 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.18.0 + ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_18_0_RESOURCE_GLOBAL + } + elsewhen ($JDK_REAL_VERSION == "20") { + ERROR_PRONE_VERSION=2.18.0 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.18.0 + ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_18_0_RESOURCE_GLOBAL + } + otherwise { + ERROR_PRONE_VERSION=2.7.1 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone + ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL + } +} +otherwise { + ERROR_PRONE_VERSION=2.7.1 + ERROR_PRONE_PEERDIR=build/platform/java/error_prone + ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL +} + +# tag:java-specific +when ($USE_SYSTEM_UBERJAR) { + UBERJAR_RESOURCE=$USE_SYSTEM_UBERJAR +} +otherwise { + when ($JDK_REAL_VERSION == "20") { + UBERJAR_RESOURCE=$UBERJAR20_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "19") { + UBERJAR_RESOURCE=$UBERJAR18_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "18") { + UBERJAR_RESOURCE=$UBERJAR18_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "17") { + UBERJAR_RESOURCE=$UBERJAR17_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "16") { + UBERJAR_RESOURCE=$UBERJAR16_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "15") { + UBERJAR_RESOURCE=$UBERJAR15_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "11") { + UBERJAR_RESOURCE=$UBERJAR11_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "10") { + UBERJAR_RESOURCE=$UBERJAR10_RESOURCE_GLOBAL + } + when ($JDK_REAL_VERSION == "8") { + UBERJAR_RESOURCE=$UBERJAR8_RESOURCE_GLOBAL + } +} + +# tag:java-specific +when ($JDK_REAL_VERSION == "20") { + WITH_JDK_RESOURCE=$WITH_JDK20_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "19") { + WITH_JDK_RESOURCE=$WITH_JDK19_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "18") { + WITH_JDK_RESOURCE=$WITH_JDK18_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "17") { + WITH_JDK_RESOURCE=$WITH_JDK17_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "16") { + WITH_JDK_RESOURCE=$WITH_JDK16_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "15") { + WITH_JDK_RESOURCE=$WITH_JDK15_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "11") { + WITH_JDK_RESOURCE=$WITH_JDK11_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "10") { + WITH_JDK_RESOURCE=$WITH_JDK10_RESOURCE_GLOBAL +} +when ($JDK_REAL_VERSION == "8") { + WITH_JDK_RESOURCE=$WITH_JDK8_RESOURCE_GLOBAL +} + +# tag:java-specific +EXTERNAL_JAVA_JDK_RESOURCE= +EXTERNAL_JAVA_EXTRA_PEERDIR= +when ($USE_SYSTEM_JDK) { + EXTERNAL_JAVA_EXTRA_PEERDIR= + EXTERNAL_JAVA_JDK_RESOURCE=$USE_SYSTEM_JDK +} +elsewhen ($JDK_VERSION == "") { + EXTERNAL_JAVA_JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL + EXTERNAL_JAVA_EXTRA_PEERDIR=build/platform/java/jdk/jdk11 +} +otherwise { + EXTERNAL_JAVA_JDK_RESOURCE=$JDK_RESOURCE +} +COMPILE_JAVA=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/compile_java.py"} --java-bin $EXTERNAL_JAVA_JDK_RESOURCE/bin/java --javac-bin $EXTERNAL_JAVA_JDK_RESOURCE/bin/javac --jar-bin $JDK_RESOURCE/bin/jar --kotlin-compiler $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar $JAVA_VCS_MF_ARG $PACKAGE_PREFIX_ARGS --jar-output $TARGET --srcs-jar-output ${output;suf=-sources.jar:REALPRJNAME} $AUTO_INPUT DELIM $JAVAC_OPTS DELIM $MANAGED_PEERS_CLOSURE DELIM -no-stdlib -module-name $REALPRJNAME -jvm-target ${KOTLIN_JVM_TARGET} ${KOTLINC_OPTS_VALUE} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} ${requirements;hide:"cpu:2"} +REAL_SWIG_DLL_JAR_CMD=$GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/build_dll_and_java.py"} $JAVA_SWIG_DELIM $REAL_LINK_DYN_LIB $JAVA_SWIG_DELIM $COMPILE_JAVA $JAVA_SWIG_DELIM $AUTO_INPUT $JAVA_SWIG_DELIM $TARGET $JAVA_SWIG_DELIM ${output;suf=.jar:REALPRJNAME} $JAVA_SWIG_DELIM ${output;suf=-sources.jar:REALPRJNAME} $JAVA_SWIG_DELIM $ARCADIA_BUILD_ROOT $ARCADIA_ROOT + +ARGS_DELIM="MACRO_CALLS_DELIM" + +SYSTEM_PROPERTIES_VALUE= +### @usage: SYSTEM_PROPERTIES([<Key Value>...] [<File Path>...]) +### +### List of Key,Value pairs that will be available to test via System.getProperty(). +### FILE means that parst should be read from file specifies as Path. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/ +macro SYSTEM_PROPERTIES(Args...) { + SET_APPEND(SYSTEM_PROPERTIES_VALUE $Args) +} + +# tag:java-specific +JVM_ARGS_VALUE= +### @usage: JVM_ARGS(Args...) +### +### Arguments to run Java programs in tests. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/ +macro JVM_ARGS(Args...) { + SET_APPEND(JVM_ARGS_VALUE $Args) +} + +# tag:java-specific +CHECK_JAVA_DEPS_VALUE= +### @usage: CHECK_JAVA_DEPS(<yes|no>) +### +### Check for different classes with duplicate name in classpath. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/ +macro CHECK_JAVA_DEPS(Arg) { + SET(CHECK_JAVA_DEPS_VALUE $Arg) +} + +ERROR_PRONE_VALUE= +### @usage: USE_ERROR_PRONE() +### +### Use errorprone instead of javac for .java compilation. +macro USE_ERROR_PRONE() { + SET(ERROR_PRONE_VALUE yes) +} + +TEST_CWD_VALUE= +### @usage: TEST_CWD(path) +### +### Defines working directory for test runs. Often used in conjunction with DATA() macro. +### Is only used inside of the TEST modules. +### +### Documentation: https://wiki.yandex-team.ru/yatool/test/ +macro TEST_CWD(Arg) { + SET(TEST_CWD_VALUE $Arg) +} + +# tag:java-specific +MAKE_UBERJAR_VALUE= +### @usage: UBERJAR() +### +### UBERJAR is a single all-in-one jar-archive that includes all its Java dependencies (reachable PEERDIR). +### It also supports shading classes inside the archive by moving them to a different package (similar to the maven-shade-plugin). +### Use UBERJAR inside JAVA_PROGRAM module. +### +### You can use the following macros to configure the archive: +### 1. UBERJAR_HIDING_PREFIX prefix for classes to shade (classes remain in their packages by default) +### 2. UBERJAR_HIDE_EXCLUDE_PATTERN exclude classes matching this patterns from shading (if enabled). +### 3. UBERJAR_PATH_EXCLUDE_PREFIX the prefix for classes that should not get into the jar archive (all classes are placed into the archive by default) +### 4. UBERJAR_MANIFEST_TRANSFORMER_MAIN add ManifestResourceTransformer class to uberjar processing and specify main-class +### 5. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE add ManifestResourceTransformer class to uberjar processing and specify some attribute +### 6. UBERJAR_APPENDING_TRANSFORMER add AppendingTransformer class to uberjar processing +### 7. UBERJAR_SERVICES_RESOURCE_TRANSFORMER add ServicesResourceTransformer class to uberjar processing +### +### Documentation: https://wiki.yandex-team.ru/yatool/java/ +### +### @see: [JAVA_PROGRAM](#module_JAVA_PROGRAM), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX), [UBERJAR_HIDE_EXCLUDE_PATTERN](#macro_UBERJAR_HIDE_EXCLUDE_PATTERN), [UBERJAR_PATH_EXCLUDE_PREFIX](#macro_UBERJAR_PATH_EXCLUDE_PREFIX) +macro UBERJAR() { + SET(MAKE_UBERJAR_VALUE yes) + DISABLE(PASS_PEERS) +} + +# tag:java-specific +UBERJAR_PREFIX_VALUE= +UBERJAR_PREFIX_FLAG= +### @usage: UBERJAR_HIDING_PREFIX(Arg) +### +### Set prefix for classes to shade. All classes in UBERJAR will be moved into package prefixed with Arg. +### Classes remain in their packages by default. +### +### @see: [UBERJAR](#macro_UBERJAR) +macro UBERJAR_HIDING_PREFIX(Arg) { + SET(UBERJAR_PREFIX_VALUE $Arg) + SET(UBERJAR_PREFIX_FLAG ${pre=--shade-prefix :Arg}) +} + +# tag:java-specific +UBERJAR_HIDE_EXCLUDE_VALUE= +UBERJAR_HIDE_EXCLUDE_FLAGS= +### @usage: UBERJAR_HIDE_EXCLUDE_PATTERN(Args...) +### +### Exclude classes matching this patterns from shading (if enabled). +### Pattern may contain '*' and '**' globs. +### Shading is enabled for UBERJAR program using UBERJAR_HIDING_PREFIX macro. If this macro is not specified all classes are shaded. +### +### @see: [UBERJAR](#macro_UBERJAR), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX) +macro UBERJAR_HIDE_EXCLUDE_PATTERN(Args...) { + SET_APPEND(UBERJAR_HIDE_EXCLUDE_VALUE $ARGS_DELIM $Args) + SET_APPEND(UBERJAR_HIDE_EXCLUDE_FLAGS ${pre=--shade-exclude :Args}) +} + +# tag:java-specific +UBERJAR_PATH_EXCLUDES= +UBERJAR_PATH_EXCLUDE_VALUE= +### @usage: UBERJAR_PATH_EXCLUDE_PREFIX(Args...) +### +### Exclude classes matching this patterns from UBERJAR. +### By default all dependencies of UBERJAR program will lend in a .jar archive. +### +### @see: [UBERJAR](#macro_UBERJAR) +macro UBERJAR_PATH_EXCLUDE_PREFIX(Args...) { + SET_APPEND(UBERJAR_PATH_EXCLUDE_VALUE $ARGS_DELIM $Args) + SET_APPEND(UBERJAR_PATH_EXCLUDES ${pre=--uber-exclude :Args}) +} + +# tag:java-specific +UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE= +UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG= +### @usage: UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main) +### +### Transform manifest.mf for UBERJAR() java programs, set main-class attribute +### +### @see: [UBERJAR](#macro_UBERJAR) +macro UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main) { + SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE $Main) + SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG --manifest-main $Main) +} + +# tag:java-specific +UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE= +UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS= +### @usage: UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value) +### +### Transform manifest.mf for UBERJAR() java programs, set attribute +### +### @see: [UBERJAR](#macro_UBERJAR) +macro UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value) { + SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE $ARGS_DELIM $Key : $Value) + SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS --manifest-attribute ${Key}:${Value}) +} + +# tag:java-specific +UBERJAR_APPENDING_TRANSFORMER_VALUE= +UBERJAR_APPENDING_TRANSFORMER_FLAGS= +### @usage: UBERJAR_APPENDING_TRANSFORMER(Resource) +### +### Add AppendingTransformer for UBERJAR() java programs +### +### Parameters: +### - Resource - Resource name +### +### @see: [UBERJAR](#macro_UBERJAR) +macro UBERJAR_APPENDING_TRANSFORMER(Resources...) { + SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_VALUE $ARGS_DELIM $Resources) + SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_FLAGS ${pre=--append-transformer :Resources}) +} + +# tag:java-specific +UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE= +UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG= +### @usage: UBERJAR_SERVICES_RESOURCE_TRANSFORMER() +### +### Add ServicesResourceTransformer for UBERJAR() java programs +### +### @see: [UBERJAR](#macro_UBERJAR) +macro UBERJAR_SERVICES_RESOURCE_TRANSFORMER() { + SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE yes) + SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG --service-transformer) +} + +# tag:idea-specific +IDEA_EXCLUDE_DIRS_VALUE= +### @usage: IDEA_EXCLUDE_DIRS(<excluded dirs>) +### +### Exclude specified directories from an idea project generated by ya ide idea +### Have no effect on regular build. +macro IDEA_EXCLUDE_DIRS(Args...) { + SET_APPEND(IDEA_EXCLUDE_DIRS_VALUE $Args) +} + +# tag:idea-specific +IDEA_RESOURCE_DIRS_VALUE= +### @usage: IDEA_RESOURCE_DIRS(<additional dirs>) +### +### Set specified resource directories in an idea project generated by ya ide idea +### Have no effect on regular build. +macro IDEA_RESOURCE_DIRS(Args...) { + SET_APPEND(IDEA_RESOURCE_DIRS_VALUE $Args) +} + +# tag:idea-specific +IDEA_MODULE_NAME_VALUE= +### @usage: IDEA_MODULE_NAME(module_name) +### +### Set module name in an idea project generated by ya ide idea +### Have no effect on regular build. +macro IDEA_MODULE_NAME(Name) { + SET(IDEA_MODULE_NAME_VALUE $Name) +} + +# tag:java-specific +JAVAC_FLAGS_VALUE= +### @usage: JAVAC_FLAGS(Args...) +### +### Set additional Java compilation flags. +macro JAVAC_FLAGS(Args...) { + SET_APPEND(JAVAC_OPTS $Args) + SET_APPEND(JAVAC_FLAGS_VALUE $ARGS_DELIM $Args) +} + +# tag:java-specific +ENABLE_PREVIEW_VALUE= +### @usage: ENABLE_PREVIEW() +### +### Enable java preview features. +macro ENABLE_PREVIEW() { + SET_APPEND(JVM_ARGS_VALUE --enable-preview) + SET_APPEND(JAVAC_OPTS --enable-preview --release $JDK_REAL_VERSION) + SET_APPEND(JAVAC_FLAGS_VALUE --enable-preview --release $JDK_REAL_VERSION) + SET(ENABLE_PREVIEW_VALUE yes) +} + +# tag:java-specific +SAVE_JAVAC_GENERATED_SRCS= +SAVE_JAVAC_GENERATED_SRCS_DIR= +SAVE_JAVAC_GENERATED_SRCS_TAR= +when ($SAVE_JAVAC_GENERATED_SRCS) { + SAVE_JAVAC_GENERATED_SRCS_DIR=${BINDIR}/__javac_generated_srcs__ + SAVE_JAVAC_GENERATED_SRCS_TAR=${BINDIR}/javac_generated.tar + JAVAC_FLAGS_VALUE+=-s $SAVE_JAVAC_GENERATED_SRCS_DIR +} + +# tag:java-specific +# TODO: MAVEN_GROUP_ID_VALUE is only used by jbuild remove it after YMAKE-45 and YMAKE-46 +MAVEN_GROUP_ID_VALUE= +MAVEN_EXPORT_GOUP_ID=ru.yandex +### @usage: MAVEN_GROUP_ID(group_id_for_maven_export) +### +### Set maven export group id for JAVA_PROGRAM() and JAVA_LIBRARY(). +### Have no effect on regular build. +macro MAVEN_GROUP_ID(Arg, VERSION="no") { + SET(MAVEN_GROUP_ID_VALUE $Arg) + SET(MAVEN_EXPORT_GOUP_ID $Arg) + SET(PUBLISH_MAVEN_VERSION $VERSION) +} + +# tag:java-specific +ANNOTATION_PROCESSOR_VALUE= +### @usage: ANNOTATION_PROCESSOR(processors...) +### +### The macro is in development. +### Used to specify annotation processors to build JAVA_PROGRAM() and JAVA_LIBRARY(). +macro ANNOTATION_PROCESSOR(Args...) { + SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Args) +} + +EXCLUDE_VALUE= +### EXCLUDE(prefixes) +### +### The macro is in development. +### Specifies which libraries should be excluded from the classpath. +macro EXCLUDE(Args...) { + SET_APPEND(EXCLUDE_VALUE $ARGS_DELIM $Args) +} + +# tag:java-specific +JAVA_SRCS_VALUE= +### @usage: JAVA_SRCS(srcs) +### +### Specify java source files and resources. A macro can be contained in any of four java modules. +### Keywords: +### 1. X SRCDIR - specify the directory x is performed relatively to search the source code for these patterns. If there is no SRCDIR, the source will be searched relative to the module directory. +### 2. PACKAGE_PREFIX x - use if source paths relative to the SRCDIR does not coincide with the full class names. For example, if all sources of module are in the same package, you can create a directory package/name , and just put the source code in the SRCDIR and specify PACKAGE_PREFIX package.name. +### +### @example: +### - example/ya.make +### +### JAVA_PROGRAM() +### JAVA_SRCS(SRCDIR src/main/java **/*) +### END() +### +### - example/src/main/java/ru/yandex/example/HelloWorld.java +### +### package ru.yandex.example; +### public class HelloWorld { +### public static void main(String[] args) { +### System.out.println("Hello, World!"); +### } +### } +### +### Documentation: https://wiki.yandex-team.ru/yatool/java/#javasrcs +macro JAVA_SRCS(Args...) { + SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $Args) +} + +# tag:java-specific +JAVA_ADD_DLLS_VALUE=no +macro ADD_DLLS_TO_JAR() { + SET(JAVA_ADD_DLLS_VALUE yes) +} + +# tag:java-specific +MANAGED_PEERS= +MANAGED_PEERS_CLOSURE= +RUN_JAVA_PROGRAM_MANAGED= +MANAGEABLE_PEERS_ROOTS=contrib/java +HAS_MANAGEABLE_PEERS=no +PROPAGATES_MANAGEABLE_PEERS=no +# All items of this list must be PEERS, GHOST PEERS or TOOLS of the test module or module itself. +# All items of this list must has at least one of HAS_MANAGEABLE_PEERS or PROPAGATES_MANAGEABLE_PEERS flags set yes. +# This variable is used by JUnit tests but not TestNG. +TEST_CLASSPATH_VALUE= +# Calculated and replaced by ymake can be used in DART DATA +TEST_CLASSPATH_MANAGED= + +# tag:java-specific +DEPENDENCY_MANAGEMENT_VALUE= +### @usage: DEPENDENCY_MANAGEMENT(path/to/lib1 path/to/lib2 ...) +### +### Lock version of the library from the contrib/java at some point, so that all unversioned PEERDIRs to this library refer to the specified version. +### +### For example, if the module has PEERDIR (contrib/java/junit/junit), and +### 1. specifies DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12), +### the PEERDIR is automatically replaced by contrib/java/junit/junit/4.12; +### 2. doesn't specify DEPENDENCY_MANAGEMENT, PEERDIR automatically replaced +### with the default from contrib/java/junit/junit/ya.make. +### These defaults are always there and are supported by maven-import, which puts +### there the maximum version available in contrib/java. +### +### The property is transitive. That is, if module A PEERDIRs module B, and B has PEERDIR(contrib/java/junit/junit), and this junit was replaced by junit-4.12, then junit-4.12 will come to A through B. +### +### If some module has both DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12) and PERDIR(contrib/java/junit/junit/4.11), the PEERDIR wins. +### +### Documentation: https://wiki.yandex-team.ru/yatool/java/ +macro DEPENDENCY_MANAGEMENT(Args...) { + SET_APPEND(DEPENDENCY_MANAGEMENT_VALUE $ARGS_DELIM $Args) + _GHOST_PEERDIR($Args) +} + +# tag:java-specific +WITH_JDK_VALUE= +### @usage: WITH_JDK() +### +### Add directory with JDK to JAVA_PROGRAM output +macro WITH_JDK() { + SET(WITH_JDK_VALUE yes) +} + +# tag:kotlin-specific +WITH_KOTLIN_VALUE= +### @usage: WITH_KOTLIN() +### +### Compile kotlin source code in this java module +macro WITH_KOTLIN() { + SET(WITH_KOTLIN_VALUE yes) +} + +# tag:kotlin-specific +WITH_KAPT_VALUE= +### @usage: WITH_KAPT() +### +### Use kapt for as annotation processor +macro WITH_KAPT() { + SET(WITH_KAPT_VALUE yes) +} + +# tag:java-specific +WITH_GROOVY_VALUE= +### @usage: WITH_GROOVY() +### +### Compile groovy source code in this java module +macro WITH_GROOVY() { + SET(WITH_GROOVY_VALUE yes) +} + +# tag:kotlin-specific +KOTLINC_FLAGS_VALUE=-Xjvm-default=all +### @usage: KOTLINC_FLAGS(-flags) +### +### Set additional Kotlin compilation flags. +macro KOTLINC_FLAGS(Args...) { + SET_APPEND(KOTLINC_OPTS_VALUE $Args) +} + + +# tag:kotlin-sppecific +WITH_KOTLINC_PLUGIN_ALLOPEN= +macro _WITH_KOTLINC_ALLOPEN(Options...) { + SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.allopen\::Options}) + SET(WITH_KOTLINC_PLUGIN_ALLOPEN yes) +} + +# tag:kotlin-specific +### @usage: WITH_KOTLINC_ALLOPEN(-flags) +### +### Enable allopen kotlin compiler plugin https://kotlinlang.org/docs/all-open-plugin.html +macro WITH_KOTLINC_ALLOPEN(HEAD, TAIL...) { + _WITH_KOTLINC_ALLOPEN($HEAD $TAIL) +} + + +# tag:kotlin-specific +WITH_KOTLINC_PLUGIN_LOMBOK= +### @usage: WITH_KOTLINC_LOMBOK(-flags) +### +### Enable lombok kotlin compiler plugin https://kotlinlang.org/docs/lombok.html +macro WITH_KOTLINC_LOMBOK(Options...) { + SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.lombok\::Options}) + SET(WITH_KOTLINC_PLUGIN_LOMBOK yes) +} + +# tag:kotlin-specific +WITH_KOTLINC_PLUGIN_NOARG= +### @usage: WITH_KOTLINC_NOARG(-flags) +### +### Enable noarg kotlin compiler plugin https://kotlinlang.org/docs/no-arg-plugin.html +macro WITH_KOTLINC_NOARG(Options...) { + SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.noarg\::Options}) + SET(WITH_KOTLINC_PLUGIN_NOARG yes) +} + +# tag:kotlin-specific +WITH_KOTLINC_PLUGIN_SERIALIZATION= +### @usage: WITH_KOTLINC_SERIALIZATION() +### +### Enable serialization kotlin compiler plugin https://kotlinlang.org/docs/serialization.html +macro WITH_KOTLINC_SERIALIZATION() { + SET(WITH_KOTLINC_PLUGIN_SERIALIZATION yes) +} + +# tag:kotlin-specific +### Also search for _KAPT_OPTS and change version there +KOTLIN_VERSION=1.8.20 +KOTLIN_BOM_FILE=${ARCADIA_ROOT}/contrib/java/org/jetbrains/kotlin/kotlin-bom/1.8.20/ya.dependency_management.inc +GROOVY_VERSION=3.0.5 + +# tag:java-specific +DIRECT_DEPS_ONLY_VALUE= +### @usage: DIRECT_DEPS_ONLY +### +### Add direct PEERDIR's only in java compile classpath +macro DIRECT_DEPS_ONLY() { + SET(DIRECT_DEPS_ONLY_VALUE yes) +} + +# tag:java-specific +JAVA_EXTERNAL_DEPENDENCIES_VALUE= +### @usage: JAVA_EXTERNAL_DEPENDENCIES(file1 file2 ...) +### +### Add non-source java external build dependency (like lombok config file) +macro JAVA_EXTERNAL_DEPENDENCIES(Args...) { + SET_APPEND(JAVA_EXTERNAL_DEPENDENCIES_VALUE $Args) +} + +# tag:java-specific +JAVA_CLASSPATH_CMD_TYPE_VALUE= + +# tag:java-specific +### @usage:TEST_JAVA_CLASSPATH_CMD_TYPE(Type) +### Available types: MANIFEST(default), COMMAND_FILE, LIST +### Method for passing a classpath value to a java command line +### MANIFEST via empty jar file with manifest that contains Class-Path attribute +### COMMAND_FILE via @command_file +### LIST via flat args +macro TEST_JAVA_CLASSPATH_CMD_TYPE(Type) { + SET(JAVA_CLASSPATH_CMD_TYPE_VALUE $Type) +} + +# tag:java-specific +IGNORE_JAVA_DEPENDENCIES_CONFIGURATION=no +JAVA_DEPENDENCIES_CONFIGURATION_VALUE= + +# tag:java-specific +### @usage JAVA_DEPENDENCIES_CONFIGURATION(Vetos...) +### Validate contrib/java dependencies +### Valid arguments +### FORBID_DIRECT_PEERDIRS - fail when module have direct PEERDIR (with version) (non-transitive) +### FORBID_CONFLICT - fail when module have resolved without DEPENDENCY_MANAGEMENT version conflict (transitive) +### FORBID_CONFLICT_DM - fail when module have resolved with DEPENDENCY_MANAGEMENT version conflict (transitive) +### FORBID_CONFLICT_DM_RECENT - like FORBID_CONFLICT_DM but fail only when dependency have more recent version than specified in DEPENDENCY_MANAGEMENT +### REQUIRE_DM - all dependencies must be specified in DEPENDENCY_MANAGEMENT (transitive) +macro JAVA_DEPENDENCIES_CONFIGURATION(Args...) { + SET_APPEND(JAVA_DEPENDENCIES_CONFIGURATION_VALUE $Args) +} + +# tag:java-specific +# TODO(DEVTOOLS-6901): remove this variable when there are no more references to it in jbuild +JAVA_FORBIDDEN_LIBRARIES_VALUE= + +# tag:java-specific +JAR_INCLUDE_FILTER_VALUE= +JAR_EXCLUDE_FILTER_VALUE= + +# tag:java-specific +### @usage:JAR_INCLUDE(Filters...) +### Filter .jar file content: keep only matched files +### * and ** patterns are supported (like JAVA_SRCS) +macro JAR_INCLUDE(Filters...) { + SET_APPEND(JAR_INCLUDE_FILTER_VALUE $Filters) +} + +# tag:java-specific +### @usage:JAR_EXCLUDE(Filters...) +### Filter .jar file content: remove matched files +### * and ** patterns are supported (like JAVA_SRCS) +macro JAR_EXCLUDE(Filters...) { + SET_APPEND(JAR_EXCLUDE_FILTER_VALUE $Filters) +} + +# tag:sandbox-specific +### @usage: SANDBOX_TASK([Name]) +### +### Multimodule describing Sandbox task (Python code that can be executed by Sandbox system). +### +### When being a final target, this multimodule builds Sandbox binary task. It may PEERDIR other SANDBOX_TASKs as libraries. +### The final artifact is provided when SANDBOX_TASK is referred to by DEPENDS and BUNDLE macros. +### As PEERDIR target, it works like regular PY2_LIBRARY with predefined dependencies on Sandbox SDK to allow code reuse among SANDBOX_TASKs. +### +### Currently Sandbox supports only Python 2.x, so both variants will be compatible only with Python 2.x modules +### and will select multimodule variants accordingly. +### +### Documentation: https://wiki.yandex-team.ru/sandbox/tasks/binary +multimodule SANDBOX_TASK { + module SB_TASK_BIN: _PY2_PROGRAM { + PY_MAIN(sandbox.taskbox.binary) + PEERDIR(sandbox/bin sandbox/sdk2 sandbox/sandboxsdk sandbox/taskbox/worker) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*) + REGISTER_SANDBOX_IMPORT(${MODDIR}) + when ($FAIL_PY2 == "yes") { + _OK=no + } + elsewhen ($OPENSOURCE != "yes") { + PEERDIR+=build/rules/py2_deprecation + } + + ASSERT(_OK You are using deprecated Python2-only code (SANDBOX_TASK). Please consider rewriting to 2/3-compatible code.) + } + module PY2: PY2_LIBRARY { + PEERDIR(sandbox/sdk2 sandbox/sandboxsdk) + REGISTER_SANDBOX_IMPORT(${MODDIR}) + } +} + +# tag:sandbox-specific +multimodule SANDBOX_PY23_TASK { + module SB_TASK_BIN: _PY2_PROGRAM { + .RESTRICTED=RUN_ANTLR4_PYTHON + PY_MAIN(sandbox.taskbox.binary) + PEERDIR(sandbox/bin sandbox/sdk2 sandbox/sandboxsdk sandbox/taskbox/worker) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*) + REGISTER_SANDBOX_IMPORT(${MODDIR}) + } + module PY2: PY2_LIBRARY { + .RESTRICTED=RUN_ANTLR4_PYTHON + PEERDIR(sandbox/sdk2 sandbox/sandboxsdk) + REGISTER_SANDBOX_IMPORT(${MODDIR}) + OBJ_SUF=.py2 + } + module PY3: PY3_LIBRARY { + .RESTRICTED=RUN_ANTLR4_PYTHON + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=py3 + } + otherwise { + MODULE_PREFIX=libpy3 + } + OBJ_SUF=.py3 + RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT + PEERDIR(sandbox/sdk2) + REGISTER_SANDBOX_IMPORT(${MODDIR}) + } +} + +# tag:sandbox-specific +### @usage: SANDBOX_PY3_TASK([Name]) +### +### Multimodule describing Sandbox task (Python3 code that can be executed by Sandbox system). +### +### When being a final target, this multimodule builds Sandbox binary task. It may PEERDIR other SANDBOX_PY3_TASKs as libraries. +### The final artifact is provided when SANDBOX_PY3_TASK is referred to by DEPENDS and BUNDLE macros. +### As PEERDIR target, it works like regular PY3_LIBRARY with predefined dependencies on Sandbox SDK to allow code reuse among SANDBOX_PY3_TASKs. +### +### Currently Sandbox supports Python 3.x only in binary tasks, both variants will be compatible only with Python 3.x and py23 libraries +### and will select multimodule variants accordingly. +### +### Documentation: https://wiki.yandex-team.ru/sandbox/tasks/binary +multimodule SANDBOX_PY3_TASK { + module SB_TASK_BIN: PY3_PROGRAM_BIN { + .IGNORED=RUN_ANTLR4_PYTHON + PY_MAIN(sandbox.taskbox.binary) + PEERDIR(sandbox/bin sandbox/sdk2 sandbox/taskbox/worker) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*) + SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*) + REGISTER_SANDBOX_IMPORT(${MODDIR}) + } + module PY3: PY3_LIBRARY { + PEERDIR(sandbox/sdk2) + REGISTER_SANDBOX_IMPORT(${MODDIR}) + } +} + +# tag:python-specific tag:internal +NO_PYTHON_INCLS=no +### @usage: NO_PYTHON_INCLUDES() # internal +### +### Disable dependencies on libraries providing Python headers. +### This is only used in Python libraries themselves to avoid PEERDIR loops. +macro NO_PYTHON_INCLUDES() { + ENABLE(NO_PYTHON_INCLS) +} + +# tag:python-specific +### @usage: PYTHON2_ADDINCL() +### +### This macro adds include path for Python headers (Python 2.x variant) without PEERDIR. +### This should be used in 2 cases only: +### - In PY2MODULE since it compiles into .so and uses external Python runtime; +### - In system Python libraries themselves since proper PEERDIR there may create a loop; +### In all other cases use USE_PYTHON2 macro instead. +### +### Never use this macro in PY2_PROGRAM, PY2_LIBRARY and PY23_LIBRARY: they have everything needed by default. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs +macro PYTHON2_ADDINCL() { + _PYTHON_ADDINCL() + SET(MODULE_TAG PY2_NATIVE) + SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB) +} + +# tag:python-specific tag:internal +### @usage: _ARCADIA_PYTHON_ADDINCL() # internal +### This macro sets up Python headers for modules with Arcadia python (e.g. PY2_LIBRARY) and configures module as Python 2.x. +macro _ARCADIA_PYTHON_ADDINCL() { + _PYTHON_ADDINCL() + SET(MODULE_TAG PY2) + SET(PEERDIR_TAGS PY2 PY2_NATIVE PY_PROTO PY2_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB) +} + +# tag:python-specific tag:internal +### @usage: _PYTHON_ADDINCL() # internal +### This macro sets up Python 2.x headers for both Arcadia and non-Arcadia python. +macro _PYTHON_ADDINCL() { + SET(PYTHON2 yes) + SET(PYTHON3 no) + when ($USE_ARCADIA_PYTHON == "yes") { + ADDINCL+=GLOBAL contrib/libs/python/Include + CFLAGS+=-DARCADIA_PYTHON_UNICODE_SIZE=$ARCADIA_PYTHON_UNICODE_SIZE + } + otherwise { + when ($USE_SYSTEM_PYTHON) { + PEERDIR+=build/platform/python + } + otherwise { + CFLAGS+=$PYTHON_INCLUDE + } + } +} + +# tag:python-specific +### @usage: PYTHON3_ADDINCL() +### +### This macro adds include path for Python headers (Python 3.x variant). +### This should be used in 2 cases only: +### - In PY2MODULE since it compiles into .so and uses external Python runtime; +### - In system Python libraries themselves since peerdir there may create a loop; +### In all other cases use USE_PYTHON3() macro instead. +### +### Never use this macro in PY3_PROGRAM and PY3_LIBRARY and PY23_LIBRARY: they have everything by default. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs +macro PYTHON3_ADDINCL() { + _PYTHON3_ADDINCL() + SET(MODULE_TAG PY3_NATIVE) + SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY3_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB) +} + +# tag:python-specific tag:internal +### @usage: _ARCADIA_PYTHON3_ADDINCL() # internal +### +### This macro sets up Python3 headers for modules with Arcadia python (e.g. PY3_LIBRARY) and configures module as Python 3.x. +macro _ARCADIA_PYTHON3_ADDINCL() { + _PYTHON3_ADDINCL() + SET(MODULE_TAG PY3) + SET(MODULE_LANG PY3) + SET(PEERDIR_TAGS PY3 PY3_BIN_LIB PY3TEST_LIBRARY PY3_NATIVE PY3_PROTO PY3_FBS PY3_SSQLS YQL_UDF_STATIC __EMPTY__ DLL_LIB) +} + +# tag:python-specific tag:internal +### @usage: _PYTHON_ADDINCL() # internal +### +### This macro sets up Python 3.x headers for both Arcadia and non-Arcadia python. +macro _PYTHON3_ADDINCL() { + SET(PYTHON3 yes) + SET(PYTHON2 no) + when ($USE_ARCADIA_PYTHON == "yes") { + CFLAGS+=-DUSE_PYTHON3 + ADDINCL+=GLOBAL contrib/libs/python/Include + } + otherwise { + when ($USE_SYSTEM_PYTHON) { + PEERDIR+=build/platform/python + } + otherwise { + CFLAGS+=$PYTHON_INCLUDE + } + } +} + +# tag:python-specific +### @usage: USE_PYTHON2() +### +### This adds Python 2.x runtime library to your LIBRARY and makes it Python2-compatible. +### Compatibility means proper PEERDIRs, ADDINCLs and variant selection on PEERDIRs to multimodules. +### +### If you'd like to use #include <Python.h> with Python2 specify USE_PYTHON2 or better make it PY2_LIBRARY. +### If you'd like to use #include <Python.h> with Python3 specify USE_PYTHON3 or better make it PY3_LIBRARY. +### If you'd like to use #include <Python.h> with both Python2 and Python3 convert your LIBRARY to PY23_LIBRARY. +### +### @see: [PY2_LIBRARY](#module_PY2_LIBRARY), [PY3_LIBRARY](#module_PY3_LIBRARY), [PY23_LIBRARY](#multimodule_PY23_LIBRARY) +macro USE_PYTHON2() { + _ARCADIA_PYTHON_ADDINCL() + SET(PEERDIR_TAGS PY2 PY2_NATIVE CPP_PROTO CPP_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB) + PEERDIR(contrib/libs/python) +} + +# tag:python-specific +### @usage: USE_PYTHON3() +### +### This adds Python3 library to your LIBRARY and makes it Python3-compatible. +### Compatibility means proper PEERDIRs, ADDINCLs and variant selection on PEERDIRs to multimodules. +### +### If you'd like to use #include <Python.h> with Python3 specify USE_PYTHON3 or better make it PY3_LIBRARY. +### If you'd like to use #include <Python.h> with Python2 specify USE_PYTHON2 or better make it PY2_LIBRARY. +### If you'd like to use #include <Python.h> with both Python2 and Python3 convert your LIBRARY to PY23_LIBRARY. +### +### @see: [PY2_LIBRARY](#module_PY2_LIBRARY), [PY3_LIBRARY](#module_PY3_LIBRARY), [PY23_LIBRARY](#multimodule_PY23_LIBRARY) +macro USE_PYTHON3() { + _ARCADIA_PYTHON3_ADDINCL() + SET(PEERDIR_TAGS PY3 PY3_BIN_LIB PY3TEST_LIBRARY PY3_NATIVE CPP_PROTO CPP_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB) + PEERDIR(contrib/libs/python) + + when ($USE_ARCADIA_PYTHON == "yes") { + PEERDIR+=library/python/runtime_py3 + } +} + +# tag:python-specific +when ($PERL_DEFAULT_PEERDIR == "yes") { + when (($PERLXS == "yes") || ($PERLXSCPP == "yes") || ($USE_PERL == "yes")) { + PEERDIR+=build/platform/perl + } +} + +# tag:perl-specific +### @usage: USE_PERL_LIB() +### Add dependency on Perl to your LIBRARY +macro USE_PERL_LIB() { + PEERDIR(build/platform/perl) +} + +# tag:perl-specific +### @usage: USE_PERL_514_LIB() +### Add dependency on Perl 5.14 to your LIBRARY +macro USE_PERL_514_LIB() { + SET(PERL_SDK ubuntu-12) + SET(PERL_DEFAULT_PEERDIR no) + PEERDIR(build/platform/perl/5.14) +} + +# tag:perl-specific +### @usage: ADD_PERL_MODULE(Dir ModuleName) +### Add dependency on specified Perl module to the library +macro ADD_PERL_MODULE(Dir, Module) { + PEERDIR($Dir) + SET_APPEND(modules $Module) +} + +# tag:allocator +### @usage: ALLOCATOR(Alloc) # Default: LF +### +### Set memory allocator implementation for the PROGRAM()/DLL() module. +### This may only be specified for programs and dlls, use in other modules leads to configuration errors. +### +### Available allocators are: "LF", "LF_YT", "LF_DBG", "YT", "J", "B", "BM", "C", "TCMALLOC", "GOOGLE", "LOCKLESS", "SYSTEM", "FAKE", "MIM", "HU", "PROFILED_HU". +### - LF - lfalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc) +### - LF_YT - Allocator selection for YT (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/yt/ya.make) +### - LF_DBG - Debug allocator selection (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/dbg/ya.make) +### - YT - The YTAlloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/ytalloc/impl/ya.make) +### - J - The JEMalloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/jemalloc) +### - B - The balloc allocator named Pyotr Popov and Anton Samokhvalov +### - Discussion: https://ironpeter.at.yandex-team.ru/replies.xml?item_no=126 +### - Code: https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/balloc +### - BM - The balloc for market (agri@ commits from july 2018 till November 2018 saved) +### - C - Like B, but can be disabled for each thread to LF or SYSTEM one (B can be disabled only to SYSTEM) +### - MIM - Microsoft's mimalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/mimalloc) +### - TCMALLOC - Google TCMalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/tcmalloc) +### - GOOGLE - Google TCMalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/galloc) +### - LOCKLESS - Allocator based upon lockless queues (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/lockless) +### - SYSTEM - Use target system allocator +### - FAKE - Don't link with any allocator +### - HU - Huge page allocator by @gulin. +### - PROFILED_HU - patched HU. It is a bit slower but has metrics of memory consumption. +### +### More about allocators in Arcadia: https://wiki.yandex-team.ru/arcadia/allocators/ +macro ALLOCATOR(Alloc) { + SET(ALLOCATOR $Alloc) + + when ($ALLOCATOR in [ "LF", "LF_YT", "LF_DBG", "YT", "J", "B", "BM", "C", "TCMALLOC", "TCMALLOC_SMALL_BUT_SLOW", "TCMALLOC_NUMA_256K", "TCMALLOC_NUMA_LARGE_PAGES", "TCMALLOC_256K", "TCMALLOC_TC", "GOOGLE", "LOCKLESS", "SYSTEM", "FAKE", "MIM", "HU", "PROFILED_HU" ]) { + } + otherwise { + PEERDIR+=___configure_error___unknown_allocator_type___$ALLOCATOR + } +} + +when ($MIC_ARCH == "yes") { + CFLAGS+=-mmic + LDFLAGS+=-mmic +} +when ($USE_OPENMP == "yes") { + PEERDIR+=contrib/libs/openmp +} + +when ($STRIP == "yes" && $NO_STRIP != "yes") { + STRIP_FLAG=$LD_STRIP_FLAG + DWARF_COMMAND= + GO_LINK_FLAGS_VALUE+=-s +} + +when ($NO_LINKER_DCE != "yes") { + DCE_FLAG=$LD_DCE_FLAG +} + +when ($BT_MINSIZEREL == "yes" || $LINKER_ICF == "yes") { + ICF_FLAG=$LD_ICF_FLAG +} + +OBJCOPY_TOOL=$OBJCOPY_TOOL_VENDOR +OBJDUMP_TOOL=$OBJDUMP_TOOL_VENDOR +STRIP_TOOL=$STRIP_TOOL_VENDOR +NEED_BINUTILS_PEERDIR= +BINUTILS_USED= + +when (!$OBJCOPY_TOOL_VENDOR) { + OBJCOPY_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/objcopy + NEED_BINUTILS_PEERDIR=yes +} +when (!$OBJDUMP_TOOL_VENDOR) { + OBJDUMP_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/objdump + NEED_BINUTILS_PEERDIR=yes +} +when (!$STRIP_TOOL_VENDOR) { + STRIP_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/strip + NEED_BINUTILS_PEERDIR=yes +} + +SPLIT_DWARF_VALUE=no +NO_SPLIT_DWARF=no + +when ($OS_DARWIN) { + SPLIT_DWARF_VALUE=yes +} + +when ($STRIP_DEBUG_INFO) { + SPLIT_DWARF_VALUE=yes + NO_SPLIT_DWARF=no +} + +### @usage: SPLIT_DWARF() +### +### Emit debug info for the PROGRAM/DLL as a separate file <module_name>.debug. +### NB: It does not help you to save process RSS but can add problems (see e.g. BEGEMOT-2147). +macro SPLIT_DWARF() { + SET(SPLIT_DWARF_VALUE yes) +} + +### @usage: NO_SPLIT_DWARF() +### +### Do NOT emit debug info for the PROGRAM/DLL as a separate file. +### On macOS this also means do NOT generate dSym files (faster linkage) +macro NO_SPLIT_DWARF() { + SET(SPLIT_DWARF_VALUE no) +} + +SPLIT_DWARF_OUTPUT=${output;tobindir;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.debug:REALPRJNAME} +when ($SPLIT_DWARF_VALUE == "yes" && $NO_SPLIT_DWARF != "yes" && $NO_DEBUGINFO != "yes" && $HOST_OS_LINUX == "yes" && $TARGET_PLATFORM == "LINUX") { + DWARF_COMMAND+= \ + $OBJCOPY_TOOL --only-keep-debug $TARGET $SPLIT_DWARF_OUTPUT && \ + $STRIP_TOOL --strip-debug $TARGET && \ + $OBJCOPY_TOOL --remove-section=.gnu_debuglink --add-gnu-debuglink $SPLIT_DWARF_OUTPUT $TARGET + BINUTILS_USED=yes +} + +### @usage: EXTRALIBS_STATIC(Libs...) +### +### Add the specified external static libraries to the program link +macro EXTRALIBS_STATIC(Args...) { + LDFLAGS(-Wl,-Bstatic ${Args} -Wl,-Bdynamic) +} + +### @usage ADD_COMPILABLE_TRANSLATE(Dict Name Options...) +### +### Generate translation dictionary code to transdict.LOWER(Name).cpp that will than be compiled into library +macro ADD_COMPILABLE_TRANSLATE(Dict, Name, MakeTransDictOptions...) { + __translatename_lower=${tolower:Name} + __translate_dict=${BINDIR}/transdict.${__translatename_lower}.cpp + RUN_PROGRAM(dict/tools/maketransdict -i ${Dict} ${MakeTransDictOptions} ${Name} STDOUT_NOAUTO ${__translate_dict} IN ${Dict}) +} + +### @usage ADD_COMPILABLE_TRANSLIT(TranslitTable NGrams Name Options...) +### +### Generate transliteration dictionary code +### This will emit both translit, untranslit and ngrams table codes those will be than further compiled into library +macro ADD_COMPILABLE_TRANSLIT(TranslitTable, NGrams, Name, Options...) { + __translitname_lower=${tolower:Name} + __translit_table=${BINDIR}/translit_trie_${__translitname_lower}.cpp + __untranslit_table=${BINDIR}/untranslit_trie_${__translitname_lower}.cpp + __ngrams_table=${BINDIR}/ngr_arr_${__translitname_lower}.cpp + __gentrie_dir=dict/tools/make_untranslit_trie + + RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__untranslit_table}) + RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} -n ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__translit_table}) + RUN_PROGRAM(dict/tools/make_ngrams -i ${NGrams} ${Options} ${__translitname_lower} IN ${NGrams} STDOUT ${__ngrams_table}) +} + + +# tag:python-specific tag:proto tag:deprecated +### @usage GENERATE_PY_PROTOS(ProtoFiles...) # deprecated +### +### Generate python bindings for protobuf files. +### Macro is obsolete and not recommended for use! +macro GENERATE_PY_PROTOS(FILES...) { + foreach (FILE : $FILES) { + _PY_PROTO_CMD($FILE) + } +} + +# tag:python-specific tag:proto +macro _GENERATE_PY_PROTOS_INTERNAL(FILES...) { + foreach (FILE : $FILES) { + _PY_PROTO_CMD_INTERNAL($FILE) + } +} + +# tag:python-specific +macro _GENERATE_PY_EVS_INTERNAL(FILES...) { + foreach (FILE : $FILES) { + _PY_EVLOG_CMD_INTERNAL($FILE) + } +} + +macro _COPY_FILE_IMPL(FILE, AUTO_DST="", NOAUTO_DST="", OUTPUT_INCLUDES[], INDUCED_DEPS[], OUTPUT_INCLUDES_INP[]) { + .CMD=$COPY_CMD ${input:FILE} ${output:AUTO_DST} ${output;noauto:NOAUTO_DST} ${output_include;hide:OUTPUT_INCLUDES} ${output_include;from_input;hide:OUTPUT_INCLUDES_INP} $INDUCED_DEPS ${kv;hide:"p CP"} ${kv;hide:"pc light-cyan"} + .SEM=copy_file ${input:FILE} ${output:AUTO_DST} ${output;noauto:NOAUTO_DST} +} + +### @usage: COPY_FILE(File Destination [AUTO] [OUTPUT_INCLUDES Deps...]) +### +### Copy file to build root. It is possible to change both location and the name. +### +### Parameters: +### - File - Source file name. +### - Destination - Output file name. +### - AUTO - Consider copied file for further processing automatically. +### - OUTPUT_INCLUDES output_includes... - Output file dependencies. +### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain. +### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) +### and set of dependencies +### +### The file will be just copied if AUTO boolean parameter is not specified. You should explicitly +### mention it in SRCS under new name (or specify AUTO boolean parameter) for further processing. +macro COPY_FILE(File, Destination, AUTO?"AUTO_DST":"NOAUTO_DST", OUTPUT_INCLUDES[], INDUCED_DEPS[]) { + .CMD=$_COPY_FILE_IMPL($File $AUTO $Destination OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS) + .SEM=$_COPY_FILE_IMPL($File $AUTO $Destination) +} + +### @usage: COPY_FILE_WITH_CONTEXT(FILE DEST [AUTO] [OUTPUT_INCLUDES DEPS...]) +### +### Copy file to build root the same way as it is done for COPY_FILE, but also +### propagates the context of the source file. +macro COPY_FILE_WITH_CONTEXT(FILE, DEST, AUTO?"AUTO_DST":"NOAUTO_DST", OUTPUT_INCLUDES[], INDUCED_DEPS[]) { + .CMD=$_COPY_FILE_IMPL($FILE $AUTO $DEST OUTPUT_INCLUDES_INP $FILE OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS) +} + +### This is to join $ALL_RES_ and $EXT +macro _ARF_HELPER(Args...) { + RESOURCE_FILES($Args) +} + +### @usage ALL_RESOURCE_FILES(Ext [PREFIX {prefix}] [STRIP {strip}] Dirs...) +### +### This macro collects all files with extension `Ext` and +### Passes them to `RESOURCE_FILES` macro as relative to current directory +### +### `PREFIX` and `STRIP` have the same meaning as in `ROURCES_FILES`, both are applied over moddir-relative paths +### +### Note: This macro can be used multiple times per ya.make, but only once for each Ext value +### Note: Wildcards are not allowed neither as Ext nor in Dirs +macro ALL_RESOURCE_FILES(EXT, PREFIX="", STRIP="", DIRS...) { + _GLOB(ALL_RES_$EXT ${suf=/*.$EXT:DIRS}) + _ARF_HELPER(${pre=PREFIX :PREFIX} STRIP ${ARCADIA_ROOT}/${MODDIR}/${STRIP} ${pre=$ALL_RES_:EXT}) +} + + +macro _BUNDLE_TARGET(Target, Destination) { + .CMD=$MOVE_FILE ${result:Target} ${output;noauto:Destination} ${kv;hide:"p BN"} ${kv;hide:"pc light-cyan"} $VCS_INFO_DISABLE_CACHE__NO_UID__ +} + +### @usage: TIMEOUT(TIMEOUT) +### +### Sets a timeout on test execution +### +### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/ +macro TIMEOUT(Time) { + SET(TEST_TIMEOUT $Time) +} + +SBR_UID_EXT="" +# tag:test +### @usage: VALIDATE_DATA_RESTART(ext) +### +### Change uid for resource validation tests. May be useful when sandbox resource ttl is changed, but test status is cached in CI. +### You can change ext to change test's uid. For example VALIDATE_DATA_RESTART(X), where is X is current revision. +macro VALIDATE_DATA_RESTART(Ext) { + SET(SBR_UID_EXT $Ext) +} + +# tag:test +TEST_FORK_MODE=none +TEST_PARTITION=SEQUENTIAL + +# tag:test +### @usage: FORK_TESTS() +### +### Splits a test run on chunks by test classes. +### The number of chunks can be overridden using the macro SPLIT_FACTOR. +### +### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules. +### +### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/ +macro FORK_TESTS(MODE...) { + SET(TEST_FORK_MODE tests) + SET(TEST_PARTITION $MODE) +} + +# tag:test +### @usage: FORK_SUBTESTS() +### +### Splits the test run in chunks on subtests. +### The number of chunks can be overridden using the macro SPLIT_FACTOR. +### +### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules. +### +### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/ +macro FORK_SUBTESTS(MODE...) { + SET(TEST_FORK_MODE subtests) + SET(TEST_PARTITION $MODE) +} + +# tag:test +### @usage: SPLIT_FACTOR(x) +### +### Sets the number of chunks for parallel run tests when used in test module with FORK_TESTS() or FORK_SUBTESTS(). +### If none of those is specified this macro implies FORK_TESTS(). +### +### Supports C++ ut and PyTest. +### +### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/ +macro SPLIT_FACTOR(Factor) { + SET(TEST_SPLIT_FACTOR $Factor) +} + +# tag:test +FORK_TEST_FILES_MODE= +### @usage: FORK_TEST_FILES() +### +### Only for PY2TEST and PY3TEST: splits a file executable with the tests on chunks in the files listed in TEST_SRCS +### Compatible with FORK_(SUB)TESTS. +### +### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/ +macro FORK_TEST_FILES() { + SET(FORK_TEST_FILES_MODE on) +} + +# tag:test +TEST_SIZE_NAME=SMALL +### @usage: SIZE(SMALL/MEDIUM/LARGE) +### +### Set the 'size' for the test. Each 'size' has own set of resrtictions, SMALL bein the most restricted and LARGE being the list. +### See documentation on test system for more details. +### +### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/ +macro SIZE(Type) { + SET(TEST_SIZE_NAME $Type) +} + +### @usage: JOIN_SRCS(Out Src...) +### +### Join set of sources into single file named Out and send it for further processing. +### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only. +### You should specify file name with the extension as Out. Further processing will be done according this extension. +macro JOIN_SRCS(Out, Src...) { + .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/gen_join_srcs.py"} ${input;hide:"build/scripts/process_command_files.py"} ${output:Out} --ya-start-command-file ${input;rootrel:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"} + .SEM=target_joined_source $Out ${input:Src} ${output;hide;suf=.o:Out} ${input;hide:"build/scripts/gen_join_srcs.py"} ${input;hide:"build/scripts/process_command_files.py"} + _CONDITIONAL_SRCS($TIDY_VALUE $Src) +} + +### @usage: JOIN_SRCS_GLOBAL(Out Src...) +### +### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out). +### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only. +### You should specify file name with the extension as Out. Further processing will be done according to this extension. +macro JOIN_SRCS_GLOBAL(Out, Src...) { + .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/gen_join_srcs.py"} ${input;hide:"build/scripts/process_command_files.py"} ${output;noauto:Out} --ya-start-command-file ${input;rootrel:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"} + SRCS(GLOBAL $Out) +} + +### @usage: FLAT_JOIN_SRCS_GLOBAL(Out Src...) +### +### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out). +### This macro places all files into single file, so will work with any sources. +### You should specify file name with the extension as Out. Further processing will be done according to this extension. +macro FLAT_JOIN_SRCS_GLOBAL(Out, Src...) { + .CMD=$FS_TOOLS cat ${output;noauto:Out} --ya-start-command-file ${input:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"} + SRCS(GLOBAL $Out) +} + +# tag:cpu +PIC_CFLAGS= +SSE2_CFLAGS= +SSE3_CFLAGS= +SSSE3_CFLAGS= +SSE41_CFLAGS= +SSE42_CFLAGS= +POPCNT_CFLAGS= +PCLMUL_CFLAGS= +CX16_FLAGS= +AVX_CFLAGS= +AVX2_CFLAGS= +AVX512_CFLAGS= +AMX_CFLAGS= + +# tag:cpu +SSE_DEFINES= +SSE_CFLAGS= +SSE4_DEFINES= +SSE4_CFLAGS= +XOP_CFLAGS= + +NO_LTO_CFLAGS= + +# tag:cpu +when (($ARCH_X86_64 || $ARCH_I386) && $DISABLE_INSTRUCTION_SETS != "yes") { + when ($CLANG || $CLANG_CL || $GCC) { + PIC_CFLAGS=-fPIC + SSE2_CFLAGS=-msse2 + SSE3_CFLAGS=-msse3 + SSSE3_CFLAGS=-mssse3 + SSE41_CFLAGS=-msse4.1 + SSE42_CFLAGS=-msse4.2 + XOP_CFLAGS=-mxop + POPCNT_CFLAGS=-mpopcnt + PCLMUL_CFLAGS=-mpclmul + AVX_CFLAGS=-mavx + + # On Intel BMI1, BMI2 and FMA3 instruction sets come together with AVX-2 extension starting with Broadwell / Haswell. + # See: + # https://en.wikipedia.org/wiki/FMA_instruction_set + # https://en.wikipedia.org/wiki/X86_Bit_manipulation_instruction_set + # + # AMD implemented FMA3 in Piledriver architecture over AVX (that is, prior to AVX-2 which was introduced in Zen). + # BMI2 implementation was released by AMD along with AVX-2 support. + # See: + # https://en.wikipedia.org/wiki/Template:AMD_x86_CPU_features + # + # Due to the above, it looks safe to enable all three extensions whenever AVX-2 is enabled. + AVX2_CFLAGS=-mavx2 -mfma -mbmi -mbmi2 + + # All Intel CPUS with AVX-512 have these instructions except for the Knights Landing / Knights Mill + # (these are Xeon Phi) + # See: + # https://en.wikichip.org/wiki/x86/avx-512 + AVX512_CFLAGS=-mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl + + # AMX stands Advanced Matrix Extension supported by modern Intel architectures + # See: + # https://en.wikipedia.org/wiki/Advanced_Matrix_Extensions + # https://en.wikichip.org/wiki/x86/amx + AMX_CFLAGS=-mamx-tile -mamx-int8 ${AVX512_CFLAGS} + + when ($ARCH_X86_64 && $OS_ANDROID != "yes") { + CX16_FLAGS=-mcx16 + } + SSE_DEFINES=-DSSE_ENABLED=1 -DSSE3_ENABLED=1 -DSSSE3_ENABLED=1 + SSE4_DEFINES=-DSSE41_ENABLED=1 -DSSE42_ENABLED=1 -DPOPCNT_ENABLED=1 -DCX16_ENABLED=1 + } + elsewhen ($MSVC) { + SSE2_CFLAGS=/D__SSE2__=1 + SSE3_CFLAGS=/D__SSE3__=1 + SSSE3_CFLAGS=/D__SSSE3__=1 + SSE41_CFLAGS=/D__SSE4_1__=1 + SSE42_CFLAGS=/D__SSE4_2__=1 + POPCNT_CFLAGS=/D__POPCNT__=1 + PCLMUL_CFLAGS=/D__PCLMUL__=1 + AVX_CFLAGS=/arch:AVX /DAVX_ENABLED=1 + AVX2_CFLAGS=/arch:AVX2 /DAVX2_ENABLED=1 + AVX512_CFLAGS=/arch:AVX512 /DAVX512_ENABLED=1 + SSE_DEFINES=/DSSE_ENABLED=1 /DSSE3_ENABLED=1 /DSSSE3_ENABLED=1 + SSE4_DEFINES=/DSSE41_ENABLED=1 /DSSE42_ENABLED=1 /DPOPCNT_ENABLED=1 /DCX16_ENABLED=1 + } + SSE_CFLAGS=$SSE2_CFLAGS $SSE3_CFLAGS $SSSE3_CFLAGS + SSE4_CFLAGS=$SSE41_CFLAGS $SSE42_CFLAGS $POPCNT_CFLAGS $CX16_FLAGS + when ($ARCH_I386 && $OS_ANDROID == "yes") { + USE_SSE4=no + } +} +otherwise { + USE_SSE4=no + CPU_CHECK=no +} + +# tag:cpu +when ($NOSSE == "yes") { + USE_SSE4=no +} + +# tag:cpu +### @usage: NO_SSE4() +### +### Compile module without SSE4 +macro NO_SSE4() { + SET(USE_SSE4 no) +} + +# tag:cpu +### @usage: NO_CPU_CHECK() +### +### Compile module without startup CPU features check +macro NO_CPU_CHECK() { + SET(CPU_CHECK no) +} + +### @usage: ADDINCLSELF() +### +### The macro adds the -I<project source path> flag to the source compilation flags of the current project. +macro ADDINCLSELF(FOR="") { + when($FOR) { + ADDINCL+=FOR $FOR ${MODDIR} + } + otherwise { + ADDINCL+=${MODDIR} + } +} + +COMPILE_OUT_SUFFIX= +_COMPILE_OUTPUTS=${output;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}:SRC} +_COMPILE_TIME_TRACE_OUTPUTS=${output;noauto;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}.time_trace.json:SRC} + +macro SET_COMPILE_OUTPUTS_MODIFIERS(NOREL?";norel":"") { + SET(_COMPILE_OUTPUTS \${output;suf=\${OBJECT_SUF}$NOREL:SRC}) + SET(_COMPILE_TIME_TRACE_OUTPUTS \${output;noauto;suf=\${OBJECT_SUF}.time_trace.json$NOREL:SRC}) +} + +# tag:internal +### @usage: _ADD_EXTRA_FLAGS_IMPL([GENERATE] Args...) # internal +### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " before $Args when GENERATE +### is specified in the list of actual arguments +macro _ADD_EXTRA_FLAGS_IMPL(GENERATE?" && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS ":"", Args...) { + .SEM=$GENERATE $Args +} + +# tag:internal +### @usage: _ADD_EXTRA_FLAGS([GENERATE] Args...) # internal +### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " if Args is not empty +macro _ADD_EXTRA_FLAGS(COMPILE_OUT_SUFFIX="", Args...) { + .SEM=$_ADD_EXTRA_FLAGS_IMPL(${pre=GENERATE :Args}) +} + +_EMPTY_CMD= + +# tag:src-processing tag:internal +### @usage: _SRC(Ext Src Flags) # internal +### +### Basic building block of extension-based command dispatching +### To enable specific extension processing define _SRC() macro with fixed first argument (Ext). +### Internal logic will apply this macro to all files with this Ext listed in SRC/SRCS macros or outputs +### of other commands (except ones marked as noauto) +macro _SRC(EXT, SRC, SRCFLAGS...) { + # Generic macro definition for _SRC (just a placeholder, it does nothing) +} + +_SWIG_CMD=$_SWIG_PYTHON_CMD +_SWIG_ADDINCLS=$_SWIG_PYTHON_ADDINCLS +_SWIG_PEERDIR=$_SWIG_PYTHON_PEERDIR +_SWIG_SEM_TO_MODULE_LINK=${output;hide;suf=.o:SRC} + +_SWIG_PYTHON_CMD=${_SWIG_TOOL} -module ${REALPRJNAME} -cpperraswarn -c++ -python -interface ${MODULE_PREFIX}${REALPRJNAME} -o ${output;noext;main;suf=_wrap.swg.cpp:SRC} ${output;noauto;add_to_outs;hide;tobindir;suf=.py:REALPRJNAME} -outdir ${BINDIR} ${pre=-I:_SWIG__INCLUDE} ${input:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"} +_SWIG_PYTHON_ADDINCLS=FOR swig ${_SWIG_LIBRARY}/python FOR swig ${_SWIG_LIBRARY} +_SWIG_PYTHON_PEERDIR= + +_SWIG_PERL_CMD=${_SWIG_TOOL} -c++ -cpperraswarn -module ${REALPRJNAME} -shadow -perl -o ${output;noext;main;suf=_wrap.swg.cpp:SRC} ${output;noauto;add_to_outs;hide;tobindir;suf=.pm:REALPRJNAME} -outdir ${ARCADIA_BUILD_ROOT}/${MODDIR} ${pre=-I:_SWIG__INCLUDE} ${input:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"} +_SWIG_PERL_ADDINCLS=FOR swig ${_SWIG_LIBRARY}/perl5 FOR swig ${_SWIG_LIBRARY} +_SWIG_PERL_PEERDIR=build/platform/perl + +_SWIG_JNI_CPP_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --out-header ${output;main;noext;suf=_wrap.swg.h:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${output;noext;suf=_wrap.swg.cpp:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"} +_SWIG_JNI_JAVA_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} --jsrc ${output;main;suf=.jsrc:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${BINDIR}/unused.cpp ${kv;hide:"p SW"} ${kv;hide:"pc yellow"} +_SWIG_JNI_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --out-header ${output;main;noext;suf=_wrap.swg.h:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} --jsrc ${output;suf=.jsrc:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${output;noext;suf=_wrap.swg.cpp:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"} +_SWIG_JNI_ADDINCLS=FOR swig ${_SWIG_LIBRARY}/java FOR swig $_SWIG_LIBRARY +_SWIG_JNI_PEERDIR=contrib/libs/jdk + +when ($USE_LOCAL_SWIG == "yes") { + _SWIG_JNI_ADDINCLS= +} +when ($USE_SYSTEM_JDK == "yes" || $OS_ANDROID == "yes") { + _SWIG_JNI_PEERDIR= +} + +# tag:src-processing +macro _SRC("swg", SRC, SRCFLAGS...) { + .CMD=${_SWIG_CMD} + .ADDINCL=${_SWIG_ADDINCLS} + .PEERDIR=${_SWIG_PEERDIR} + .SEM=conan_require_tool swig/4.0.2 && conan_import '"bin, *swig* -> ./bin"' ${input;hide:SRC} ${_SWIG_SEM_TO_MODULE_LINK} +} + +RODATA_SYMBOL_PREFIX= +when ($DARWIN == "yes" || $IOS == "yes" || ($WINDOWS == "yes" && $ARCH_TYPE_32 == "yes")) { + RODATA_SYMBOL_PREFIX=_ +} + +RODATA_ELF_FLAGS= +when($LINUX == "yes" || $ANDROID == "yes") { + RODATA_ELF_FLAGS=--elf +} + +RODATA_COMPILE=$YMAKE_PYTHON3 ${input:"build/scripts/rodata2asm.py"} $RODATA_ELF_FLAGS ${RODATA_SYMBOL_PREFIX}${noext;nopath:SRC} ${input:SRC} ${tmp;suf=.asm:SRC} ${hide:OBJECT_SUF} && $_SRC_yasm_helper(${tmp;suf=.asm:SRC}) +when (($ARCH_AARCH64 || $ARCH_ARM || $ARCH_PPC64LE) == "yes") { + RODATA_COMPILE=$YMAKE_PYTHON3 ${input:"build/scripts/rodata2cpp.py"} ${noext;nopath:SRC} ${input:SRC} ${output;suf=.cpp:SRC} +} + +# tag:src-processing +macro _SRC("rodata", SRC, SRCFLAGS...) { + .CMD=$RODATA_COMPILE ${hide;kv:"p RD"} ${hide;kv:"pc light-green"} + .SEM=target_rodata_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} ${input;hide:"build/scripts/rodata2cpp.py"} +} + +# tag:src-processing +macro _SRC("S", SRC, SRCFLAGS...) { + .CMD=$C_COMPILER $C_FLAGS_PLATFORM $CFLAGS $SFLAGS $SRCFLAGS -c -o ${output:SRC.o} ${input:SRC} ${pre=-I:_C__INCLUDE} + .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS) && add_language ASM +} + +# tag:src-processing +macro _SRC("s", SRC, SRCFLAGS...) { + .CMD=$_SRC(S, $SRC $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("s79", SRC, SRCFLAGS...) { + .CMD=$_SRC(S, $SRC $SRCFLAGS -x assembler-with-cpp) +} + +# tag:src-processing +macro _SRC("mm", SRC, SRCFLAGS...) { + .CMD=$C_COMPILER $C_FLAGS_PLATFORM -x objective-c++ -fobjc-arc -fobjc-abi-version=2 -c -o ${output:SRC.o} ${input:SRC} $CXXFLAGS ${pre=-I:_C__INCLUDE} ${SRCFLAGS} ${kv;hide:"p CC"} ${kv;hide:"pc light-green"} $TOOLCHAIN_ENV +} + +# tag:src-processing +macro _SRC("fml", SRC, SRCFLAGS...) { + .CMD=$FML_TOOL $CHECKFLAG -b -o ${output:SRC.inc} -T ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("fml2", SRC, SRCFLAGS...) { + .CMD=$FML_TOOL $CHECKFLAG -b -o ${output;nopath;noext:SRC.fml.inc} -2 -O ${output;nopath;noext:SRC.fml.cpp} -T ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("fml3", SRC, SRCFLAGS...) { + .CMD=$FML_TOOL $CHECKFLAG -b -o ${output;nopath;noext:SRC.fml.inc} -3 -O ${output;nopath;noext:SRC.fml.cpp} -L ${input;nopath;noext:SRC.list} -P ${nopath;noext:SRC} -T ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("sfdl", SRC, SRCFLAGS...) { + .CMD=$CXX_COMPILER $C_FLAGS_PLATFORM $CXXFLAGS $SFDL_FLAG ${SRCFLAGS} ${input:SRC} && ${tool:"tools/calcstaticopt"} -i ${tmp:SRC.tmp} -a $ARCADIA_ROOT ${output;stdout;nopath;noext;defext=.inc:SRC} ${kv;hide:"p SF"} ${kv;hide:"pc yellow"} $TOOLCHAIN_ENV +} + +macro _XS_SRCS(SRC, TYPEMAPS[], SRCFLAGS...) { + .CMD=$PERL_LD_LIBRARY_PATH $PERL $PERL_INCLUDE ${suf=/ExtUtils/xsubpp:PERL_PRIVLIB} -typemap ${suf=/ExtUtils/typemap:PERL_PRIVLIB} $PERLSUFFIX $XSUBPPFLAGS ${pre=-typemap :TYPEMAPS} ${input;hide:TYPEMAPS} ${SRCFLAGS} ${input:SRC} ${PERLOUTPUT} ${kv;hide:"p XS"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("xs", SRC, SRCFLAGS...) { + .CMD=$_XS_SRCS($SRC TYPEMAPS $_XSTYPEMAPS $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("gperf", SRC, SRCFLAGS...) { + .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/gperf"} $GP_FLAGS ${SRCFLAGS} ${pre=-Nin_;suf=_set;nopath;noallext:SRC} ${input:SRC} ${output;stdout;nopath;noext;defext=.gperf.cpp:SRC} ${kv;hide:"p GP"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("rl", SRC, SRCFLAGS...) { + .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/ragel5/ragel"} $RAGEL_FLAGS ${SRCFLAGS} -o ${tmp:SRC.tmp} ${input:SRC} && $RUN_NO_SANITIZE ${tool:"contrib/tools/ragel5/rlgen-cd"} $RLGEN_FLAGS -o ${output;nopath;noext;defext=.rl5.cpp:SRC} ${tmp:SRC.tmp} ${kv;hide:"p R5"} ${kv;hide:"pc yellow"} +} + +macro _SRC("xsyn", SRC, SRCFLAGS...) { + .CMD=$YMAKE_PYTHON ${input:"library/cpp/xml/parslib/xsyn2ragel.py"} ${input:SRC} ${input:"library/cpp/xml/parslib/xmlpars.xh"} dontuse ${output;stdout;suf=.h.rl5:SRC} ${kv;hide:"p XN"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("rl5", SRC, SRCFLAGS...) { + .CMD=$_SRC(rl $SRC $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("asp", SRC, SRCFLAGS...) { + .CMD=$RUN_NO_SANITIZE ${tool:"tools/html2cpp"} ${input:SRC} ${output:SRC.cpp} ${kv;hide:"p HT"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("rl6", SRC, SRCFLAGS...) { + .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/ragel6"} $RAGEL6_FLAGS ${SRCFLAGS} -L -I${ARCADIA_ROOT} -o ${output;nopath;noext;defext=.rl6.cpp:SRC} ${input:SRC} ${kv;hide:"p R6"} ${kv;hide:"pc yellow"} + .SEM=target_ragel_lexers PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $RAGEL6_FLAGS ${SRCFLAGS} && set_global_flags RAGEL_FLAGS -L -I $S/ && conan_require_tool ragel/6.10 && conan_import '"bin, ragel* -> ./bin"' ${input;hide:"build/scripts/run_tool.py"} +} + +# tag:src-processing +macro _SRC("pln", SRC, SRCFLAGS...) { + .CMD=$FML_TOOL -b -o ${output;pre=pln.;nopath;noext:SRC.cpp} -f ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("xsyn", SRC, SRCFLAGS...) { + .CMD=$YMAKE_PYTHON ${input:"library/cpp/xml/parslib/xsyn2ragel.py"} ${input:SRC} ${input:"library/cpp/xml/parslib/xmlpars.xh"} dontuse ${output;stdout:SRC.h.rl5} ${kv;hide:"p XN"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("ev", SRC, SRCFLAGS...) { + .CMD=$EVLOG_CMD($SRC) + .SEM=$EVLOG_CMD($SRC) +} + +# tag:src-processing +macro _SRC("proto", SRC, SRCFLAGS...) { + .CMD=$PROTO_CMD($SRC) + .SEM=$PROTO_CMD($SRC) +} + +# tag:src-processing +macro _SRC("gztproto", SRC, SRCFLAGS...) { + # _PROTO__INCLUDE is before ARCADIA_ROOT in includes because in gazetteer we don't use builtins now and paths' canonization (resolving) depends on order of roots. + # descriptor.proto must be resolved as google/protobuf/descriptor.proto + .CMD=${tool:"dict/gazetteer/converter"} -I$PROTOBUF_PATH ${pre="-I":_PROTO__INCLUDE} -I$ARCADIA_ROOT ${SRCFLAGS} ${input:SRC} ${output;nopath;noext;norel:SRC.proto} ${kv;hide:"p GZ"} ${kv;hide:"pc yellow"} + .PEERDIR=kernel/gazetteer/proto +} + +# tag:src-processing +macro _SRC("cfgproto", SRC, SRCFLAGS...) { + .CMD=$_CPP_CFGPROTO_CMD($SRC) +} + +# tag:src-processing +macro _SRC("pyx", SRC, SRCFLAGS...) { + # Copy-paste from BUILDWITH_CYTHON + .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:SRC} -o ${output;tobindir;suf=${OBJ_SUF}.cpp:SRC} $CYTHON_OUTPUT_INCLUDES ${SRCFLAGS} ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + .SEM=target_cython_sources PRIVATE ${input:Src} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS --cplus ${SRCFLAGS} ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON + .ADDINCL=FOR cython contrib/tools/cython/Cython/Includes +} + +# tag:src-processing +macro _SRC("in", SRC, SRCFLAGS...) { + .CMD=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC}) + .SEM=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC}) +} + +macro MANUAL_GENERATION(Outs...) { + .SEM=IGNORED ${output;hide;noauto:Outs} +} + +# tag:src-processing +macro _SRC("sc", SRC, SRCFLAGS...) { + .CMD=${tool:"tools/domschemec"} --in ${input:SRC} --out ${output;norel:SRC.h} ${output_include;hide:"util/generic/strbuf.h"} ${output_include;hide:"array"} ${output_include;hide:"util/generic/string.h"} ${output_include;hide:"util/generic/vector.h"} ${output_include;hide:"util/string/cast.h"} ${SRCFLAGS} ${kv;hide:"p SC"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("ssqls", SRC, SRCFLAGS...) { + .CMD=${tool:"metrika/core/tools/ssqls"} ${input;notransformbuilddir:SRC} -S $ARCADIA_ROOT -B $ARCADIA_BUILD_ROOT $SRCFLAGS ${output;noext;hide:SRC.cpp} ${output;noext;hide:SRC.h} ${kv;hide:"p SS"} ${kv;hide:"pc yellow"} +} + +# tag:src-processing +macro _SRC("f", SRC, SRCFLAGS...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/f2c.py"} -t ${tool:"contrib/tools/f2c"} -c ${input:SRC} -o ${output:SRC.c} ${kv;hide:"p FT"} ${kv;hide:"pc light-green"} + .PEERDIR=contrib/libs/libf2c + .ADDINCL=contrib/libs/libf2c +} + +# tag:src-processing +macro _SRC("cpp", SRC, SRCFLAGS...) { + .CMD=$_SRC_cpp($SRC $SRCFLAGS) + .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS) +} + +# tag:src-processing +macro _SRC("cxx", SRC, SRCFLAGS...) { + .CMD=$_SRC(cpp $SRC $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("cc", SRC, SRCFLAGS...) { + .CMD=$_SRC(cpp $SRC $SRCFLAGS) + .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS) +} + +# tag:src-processing +macro _SRC("auxcpp", SRC, SRCFLAGS...) { + .CMD=$_SRC_cpp($SRC $_FORCE_CPP_FLAGS $SRCFLAGS) + .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($_FORCE_CPP_FLAGS $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("C", SRC, SRCFLAGS...) { + .CMD=$_SRC(cpp $SRC $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("c", SRC, SRCFLAGS...) { + .CMD=$_SRC_c($SRC $SRCFLAGS) + .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL) +} + +# tag:src-processing +macro _SRC("m", SRC, SRCFLAGS...) { + .CMD=$_SRC(c $SRC $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("masm", SRC, SRCFLAGS...) { + .CMD=$_SRC_masm($SRC $SRCFLAGS) +} + +YASM_SEM=target_yasm_source PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${pre=-P :PREINCLUDES} ${input;hide:"build/scripts/run_tool.py"} \ + && set_global_flags YASM_FLAGS -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} $_YASM_PLATFORM_FLAGS_VALUE -D ${pre=_;suf=_:HARDWARE_TYPE} -D_YASM_ $ASM_PREFIX_VALUE $_YASM_PREDEFINED_FLAGS_VALUE \ + && add_language ASM \ + && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"' +ASM_SEM=target_yasm_source PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${input;hide:"build/scripts/run_tool.py"} \ + && set_global_flags YASM_FLAGS -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} $_YASM_PLATFORM_FLAGS_VALUE -D ${pre=_;suf=_:HARDWARE_TYPE} -D_YASM_ $ASM_PREFIX_VALUE $_YASM_PREDEFINED_FLAGS_VALUE \ + && add_language ASM \ + && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"' +# tag:src-processing +macro _SRC("yasm", SRC, SRCFLAGS...) { + .CMD=$_SRC_yasm($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE) + .SEM=$YASM_SEM +} + +# tag:src-processing +macro _SRC("asm", SRC, SRCFLAGS...) { + .CMD=$_SRC_ASM($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE) + .SEM=$ASM_SEM +} + +# tag:src-processing +macro _SRC("lua", SRC, SRCFLAGS...) { + .CMD=${cwd:LUAJIT_PATH} ${tool:"contrib/libs/luajit/compiler"} -b -g ${input:SRC} ${SRCFLAGS} ${global;output;suf=.o:SRC} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"} + .PEERDIR=$LUAJIT_PATH +} + +NVCC_CFLAGS= +when ($IDE_MSVS_CALL == "yes") { + # This is to avoid issues with .pdb from MSVC calling nvcc calling cl + NVCC_CFLAGS+=/Fd$(TEMP) +} + +NVCC_STD_VER=14 +when ($MSVC == "yes") { + NVCC_STD=/std:c++${NVCC_STD_VER} +} +otherwise { + NVCC_STD=-std=c++${NVCC_STD_VER} +} + +# tag:src-processing +macro _SRC("cu", SRC, SRCFLAGS...) { + .CMD=$_SRC_CU_CMD + .SEM=target_cuda_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} && set_global_flags CMAKE_CUDA_STANDARD ${NVCC_STD_VER} && target_cuda_flags $CUDA_NVCC_FLAGS && target_cuda_cflags $USER_CXXFLAGS $SRCFLAGS $_SEM_EXTRA_CXX_FLAGS + .PEERDIR=$_SRC_CU_PEERDIR +} + +# tag:src-processing +macro _SRC("fbs", SRC, SRCFLAGS...) { + .CMD=$FBS_CMD($SRC, $SRCFLAGS) + .SEM=$FBS_CMD($SRC, $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("fbs64", SRC, SRCFLAGS...) { + .CMD=$_CPP_FLATC64_CMD($SRC, $SRCFLAGS) +} + +# tag:src-processing +macro _SRC("pysrc", SRC, SRCFLAGS...) { + .CMD=$_SRC_PYSRC($SRC, $SRCFLAGS) +} + +# tag:src-processing +# This triggers configure error in attempt to add `ya.make` to SRCS macro or apply automatic processing by extension from codegen +macro _SRC("make", SRC, SRCFLAGS...) { + .CMD= +} + +@import "${CONF_ROOT}/conf/bison_lex.conf" + +# tag:src-processing +macro _SRC_py2src(SRC, SRCFLAGS...) { + .CMD=${cwd:BINDIR} $YMAKE_PYTHON3 ${input:"build/scripts/compile_pysrc.py"} --input ${input:SRC} --output ${output;noext;suf=.py2_raw.cpp:SRC} --rescompiler ${tool:"tools/rescompiler"} py2 --python $(PYTHON)/python --py_compile ${input:"build/scripts/py_compile.py"} ${kv;hide:"p P2"} ${kv;hide:"pc light-green"} +} + +# tag:src-processing +macro _SRC_py3src(SRC, SRCFLAGS...) { + .CMD=${cwd:BINDIR} $YMAKE_PYTHON3 ${input:"build/scripts/compile_pysrc.py"} --input ${input:SRC} --output ${output;noext;suf=.py3_raw.cpp:SRC} --rescompiler ${tool:"tools/rescompiler"} py3 --pycc ${tool:"contrib/tools/python3/pycc"} ${kv;hide:"p P3"} ${kv;hide:"pc light-green"} +} + +# tag:src-processing python-specific +when ($PYTHON3 == "yes") { + MACRO_ALIAS(_SRC_PYSRC _SRC_py3src) +} +otherwise { + MACRO_ALIAS(_SRC_PYSRC _SRC_py2src) +} + +# tag:src-processing +macro _SRC_c_nodeps(SRC, OUTFILE, INC...) { + .CMD=$_SRC_C_NODEPS_CMD +} + +# Custom flags for generated cpp-files. To support another generator: +# - insert additional file extension before .cpp into generated cpp-file name +# - update _LANG_CFLAGS_FILTER variable. Don't forget to add ' SKIP ' after flag list +# +# ragel5 and ragel6 generated terrible code which makes use of goto's in switch statements. +# This triggers -Werror-implicit-fallthrough due to `unannotated fall-through between switch labels`. +# +# cython generated code also fails to pass this diagnostics due to `fallthrough annotation in unreachable code`. +# We use cython==0.29.26 at the time. This issue might be fixed in further versions. + +## tag:src-processing +_LANG_CFLAGS_FILTER=\ + ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl5:SRC} \ + ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl6:SRC} \ + ${pre=-Wno-implicit-fallthrough SKIP ;ext=.pyx:SRC} + +# tag:src-processing +# Magic macro for removing file name from result (file name is passed as unused SKIP parameter) +macro _FILTER_EXTS(SKIP="", FLAGS...) { + .CMD=$FLAGS +} + +# tag:src-processing +macro _LANG_CFLAGS(SRC) { + .CMD=$_FILTER_EXTS($_LANG_CFLAGS_FILTER) +} + +# tag:src-processing +# ymake bug workaround: variables followed a macros call in .CMD are not substituted and are placed in result as is +# Pack macro call into a variable and use it in _SRC_CPP_CMD instead of macro call +_LANG_CFLAGS_VALUE= +when ($CLANG == "yes" || $CLANG_CL == "yes" || $GCC == "yes") { + _LANG_CFLAGS_VALUE=$_LANG_CFLAGS(${noext:SRC}) +} + +# Allows to add single compilation unit name to the node's 'kv' section. +# This is used by the coverage machinery to instrument only the necessary sources +# when --coverage-prefix-filter <rootrelpath> is specified. For more info see DEVTOOLSSUPPORT-16891 +SCU_NAME_KV= +when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no" && $USE_SCU_VALUE == "yes") { + SCU_NAME_KV=${hide;kv:"scu_name $KV_VAL"} +} + +macro _ADD_SCU_NAME(KV_VAL) { + .CMD=$SCU_NAME_KV +} + +# tag:src-processing +macro _SRC_cpp(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) { + .CMD=$_SRC_CPP_CMD $_ADD_SCU_NAME(${input:SRC}) +} + +# tag:src-processing +macro _SRC_c(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) { + .CMD=$_SRC_C_CMD $_ADD_SCU_NAME(${input:SRC}) +} + +# tag:src-processing +macro _SRC_m(SRC, SRCFLAGS...) { + .CMD=$_SRC_M_CMD +} + +# tag:src-processing +macro _SRC_masm(SRC, SRCFLAGS...) { + .CMD=$_SRC_MASM_CMD +} + +# tag:lua-specific +### @usage: COMPILE_LUA(Src, [NAME <import_name>]) +### +### Compile LUA source file to object code using LUA 2.0 +### Optionally override import name which is by default reflects Src name +macro COMPILE_LUA(Src, NAME="") { + .CMD=$_SRC(lua, $Src, ${pre=-n :NAME}) +} + +# tag:lua-specific +### @usage: _SRC_lua_21(SRC [SRCFLAGS...]) # internal +### +### Compile LUA source file to object code using LUA 2.1 +macro _SRC_lua_21(SRC, SRCFLAGS...) { + .CMD=${cwd:LUAJIT_21_PATH} ${tool:"contrib/libs/luajit_21/compiler"} -b -g ${input:SRC} ${SRCFLAGS} ${global;output;suf=.o:SRC} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"} + .PEERDIR=$LUAJIT_21_PATH +} + +# tag:lua-specific +### @usage: COMPILE_LUA_21(Src, [NAME <import_name>]) +### +### Compile LUA source file to object code using LUA 2.1 +### Optionally override import name which is by default reflects Src name +macro COMPILE_LUA_21(Src, NAME="") { + .CMD=$_SRC_lua_21($Src, ${pre=-n :NAME}) +} + +GETTEXT_KEEP_PATH=no +_MO_OUTPUT= +when ($GETTEXT_KEEP_PATH == "yes") { + _MO_OUTPUT=${output;noauto;norel;noext:SRC.mo} +} +otherwise { + _MO_OUTPUT=${output;noauto;nopath;noext;tobindir:SRC.mo} +} + +# tag:src-processing +macro _SRC("po", SRC, SRCFLAGS...) { + .CMD=$YMAKE_PYTHON ${input:"contrib/tools/python/src/Tools/i18n/msgfmt.py"} -o $_MO_OUTPUT ${input:SRC} +} + +# tag:ydl-specific +YDL_FLAGS= --force-color -I ${ARCADIA_ROOT} +YDL_DESC_FLAGS= + +# tag:src-processing tag:ydl-specific +macro _SRC("ydl", SRC, SRCFLAGS...) { + .CMD=${tool:"statbox/ydl/compiler/tooling/ydl/bin"} c $YDL_FLAGS --cpp-output-header ${output;suf=.h:SRC} --cpp-output-source ${output;suf=.cpp:SRC} ${input:SRC} ${output_include;hide:"statbox/ydl/runtime/cpp/gen_support/standard_includes.h"} ${kv;hide:"p YDL"} ${kv;hide:"pc yellow"} + .PEERDIR+=statbox/ydl/runtime/cpp +} + +# tag:ydl-specific +### @usage BUILD_YDL_DESC(Input Symbol Output) +### +### Generate a descriptor for a Symbol located in a ydl module Input, and put it to the file Output. +### +### @example: +### +### PACKAGE() +### BUILD_YDL_DESC(../types.ydl Event Event.ydld) +### END() +### +### This will parse file ../types.ydl, generate a descriptor for a symbol Event defined in the said file, and put the descriptor to the Event.ydld. +macro BUILD_YDL_DESC(Input, Symbol, Output) { + .CMD=${tool:"statbox/ydl/compiler/tooling/ydl/bin"} ti $YDL_FLAGS $YDL_DESC_FLAGS -o ${output;noauto:Output} ${input:Input} ${Symbol} ${kv;hide:"p YDL"} ${kv;hide:"pc yellow"} +} + +# tag:ydl-specific +### @usage: YDL_DESC_USE_BINARY() +### +### Used in conjunction with BUILD_YDL_DESC. When enabled, all generated descriptors are binary. +### +### @example: +### +### PACKAGE() +### YDL_DESC_USE_BINARY() +### BUILD_YDL_DESC(../types.ydl Event Event.ydld) +### END() +### +### This will generate descriptor Event.ydld in a binary format. +macro YDL_DESC_USE_BINARY() { + YDL_DESC_FLAGS_BINARY= --binary + SET_APPEND(YDL_DESC_FLAGS $YDL_DESC_FLAGS_BINARY) +} + +### @usage SRC(File Flags...) +### +### Compile single file with extra Flags. +### Compilation is driven by the last extension of the File and Flags are specific to corresponding compilation command +macro SRC(FILE, FLAGS...) { + _SRC(${lastext:FILE} $FILE $FLAGS) +} + +### @usage: SRCS(<[GLOBAL] File> ...) +### +### Source files of the project. Files are built according to their extension and put int module output or fed to ultimate PROGRAM/DLL depending on GLOBAL presence. +### Arcadia Paths from the root and is relative to the project's LIST are supported +### +### GLOBAL marks next file as direct input to link phase of the program/shared library project built into. This prevents symbols of the file to be excluded by linker as unused. +### The scope of the GLOBAL keyword is the following file (that is, in the case of SRCS(GLOBAL foo.cpp bar.cpp) global will be only foo.cpp) +### +### @example: +### +### LIBRARY(test_global) +### SRCS(GLOBAL foo.cpp) +### END() +### +### This will produce foo.o and feed it to any PROGRAM/DLL module transitively depending on test_global library. The library itself will be empty and won't produce .a file. +macro SRCS(FILES...) { + foreach (FILE : $FILES) { + _SRC(${lastext:FILE} $FILE) + } +} + +# tag:c-specific +macro _SRC_C_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) { + .CMD=$_SRC_c($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS}) + .SEM=target_sources_custom $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL +} + +macro _SRC_CPP_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) { + .CMD=$_SRC_cpp($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS}) + .SEM=target_sources_custom $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS +} + + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal +### +### Defenition of generic macro. Report an error that the File with Ext is not +### supported by macro MacroName if no appropriate macro specialization is found. +macro _SRC_CUSTOM_C_CPP(EXT, MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) { + MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single C file (with .c extension) +macro _SRC_CUSTOM_C_CPP("c", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) { + _SRC_C_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cpp extension) +macro _SRC_CUSTOM_C_CPP("cpp", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) { + _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cxx extension) +macro _SRC_CUSTOM_C_CPP("cxx", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) { + _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cc extension) +macro _SRC_CUSTOM_C_CPP("cc", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) { + _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .C extension) +macro _SRC_CUSTOM_C_CPP("C", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) { + _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_SSE2(File Flags...) +### +### Compile a single C/C++ file with SSE2 and additional Flags +macro SRC_C_SSE2(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE2 $FILE .sse2 $SSE2_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_SSE3(File Flags...) +### +### Compile a single C/C++ file with SSE3 and additional Flags +macro SRC_C_SSE3(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE3 $FILE .sse3 $SSE3_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_SSSE3(File Flags...) +### +### Compile a single C/C++ file with SSSE3 and additional Flags +macro SRC_C_SSSE3(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSSE3 $FILE .ssse3 $SSSE3_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_SSE4(File Flags...) +### +### Compile a single C/C++ file with SSE4 and additional Flags +macro SRC_C_SSE4(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE4 $FILE .sse4 $SSE4_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_SSE41(File Flags...) +### +### Compile a single C/C++ file with SSE4.1 and additional Flags +macro SRC_C_SSE41(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE41 $FILE .sse41 $SSE41_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_AVX(File Flags...) +### +### Compile a single C/C++ file with AVX and additional Flags +macro SRC_C_AVX(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX $FILE .avx $AVX_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_AVX2(File Flags...) +### +### Compile a single C/C++ file with AVX2 and additional Flags +macro SRC_C_AVX2(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX2 $FILE .avx2 $AVX2_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_AVX512(File Flags...) +### +### Compile a single C/C++ file with AVX512 and additional Flags +macro SRC_C_AVX512(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX512 $FILE .avx512 $AVX512_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_AVX512(File Flags...) +### +### Compile a single C/C++ file with AVX512 and additional Flags +macro SRC_C_AMX(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AMX $FILE .amx $AMX_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_XOP(File Flags...) +### +### Compile a single C/C++ file with (an AMD-specific instruction set, +### see https://en.wikipedia.org/wiki/XOP_instruction_set) and additional Flags +macro SRC_C_XOP(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_XOP $FILE .xop $XOP_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific tag:cpu +### @uasge SRC_C_PCLMUL(File Flags...) +### +### Compile a single C/C++ file with PCLMUL and additional Flags +macro SRC_C_PCLMUL(FILE, FLAGS...) { + _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_PCLMUL $FILE .pclmul $PCLMUL_CFLAGS $FLAGS ) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal +### +### Defenition of generic macro. Report an error that the File with Ext is not +### supported by macro MacroName if no appropriate macro specialization is found. +macro _SRC_STRICT_C_CPP(EXT, MACRO_NAME, FILE, FLAGS...) { + MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single C file (with .c extension) +macro _SRC_STRICT_C_CPP("c", MACRO_NAME, FILE, FLAGS...) { + _SRC(c $FILE $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cpp extension) +macro _SRC_STRICT_C_CPP("cpp", MACRO_NAME, FILE, FLAGS...) { + _SRC(cpp $FILE $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cxx extension) +macro _SRC_STRICT_C_CPP("cxx", MACRO_NAME, FILE, FLAGS...) { + _SRC(cpp $FILE $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cc extension) +macro _SRC_STRICT_C_CPP("cc", MACRO_NAME, FILE, FLAGS...) { + _SRC(cpp $FILE $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal +### +### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .C extension) +macro _SRC_STRICT_C_CPP("C", MACRO_NAME, FILE, FLAGS...) { + _SRC(cpp $FILE $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @uasge SRC_C_PIC(File Flags...) +### +### Compile a single C/C++ file with -fPIC and additional Flags +macro SRC_C_PIC(FILE, FLAGS...) { + _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_PIC $FILE $PIC_CFLAGS $FLAGS) +} + +# tag:src-specific tag:cpp-specific +### @uasge SRC_C_NO_LTO(File Flags...) +### +### Compile a single C/C++ file with link-time-optimization disabling and additional Flags +macro SRC_C_NO_LTO(FILE, FLAGS...) { + _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_NO_LTO $FILE $NO_LTO_CFLAGS $FLAGS) +} + +# tag:python-processing tag:cython +# TODO: use it in [.pyx] cmd +### @usage: BUILDWITH_CYTHON_CPP(Src Options...) +### +### Generates .cpp file from .pyx. +macro BUILDWITH_CYTHON_CPP(Src, Options...) { + .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} -o ${output;tobindir;suf=${OBJ_SUF}.cpp:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + .SEM=target_cython_sources PRIVATE ${input:Src} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON + ADDINCL(FOR cython contrib/tools/cython/Cython/Includes) +} + +# tag:python-processing tag:cython tag:internal +### @usage: _BUILDWITH_CYTHON_CPP_DEP(Src Dep Options...) # internal +### +### Generates .cpp file from .pyx and attach extra input Dep. +### If Dep changes the .cpp file will be re-generated. +macro _BUILDWITH_CYTHON_CPP_DEP(Src, Dep, Options...) { + .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;tobindir;suf=${OBJ_SUF}.cpp:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + .SEM=target_cython_sources PRIVATE ${input:Src} ${input;hide:Dep} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON + ADDINCL(FOR cython contrib/tools/cython/Cython/Includes) +} + +# tag:python-processing tag:cython tag:internal +### @usage: _BUILDWITH_CYTHON_CPP_H(Src Dep Options...) # internal +### +### BUILDWITH_CYTHON_CPP without .pyx infix and with cdef public .h file. +macro _BUILDWITH_CYTHON_CPP_H(Src, Dep, Options...) { + .CMD=$RUN_CYTHON_SCRIPT_H $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;noext;tobindir:Src.cpp} ${output;hide;addincl;noext;tobindir:Src.h} ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + ADDINCL(FOR cython contrib/tools/cython/Cython/Includes) +} + + +# tag:python-processing tag:cython +### @usage: BUILDWITH_CYTHON_C(Src Options...) +### +### Generates .c file from .pyx. +macro BUILDWITH_CYTHON_C(Src, Options...) { + .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} -o ${output;tobindir;suf=${OBJ_SUF}.c:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + .SEM=target_cython_sources PRIVATE ${input:Src} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON + ADDINCL(FOR cython contrib/tools/cython/Cython/Includes) +} + +# tag:python-processing tag:cython tag:internal +### @usage: _BUILDWITH_CYTHON_C_DEP(Src Dep Options...) # internal +### +### Generates .c file from .pyx and attach extra input Dep. +### If Dep changes the .c file will be re-generated. +macro _BUILDWITH_CYTHON_C_DEP(Src, Dep, Options...) { + .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;tobindir;suf=${OBJ_SUF}.c:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + .SEM=target_cython_sources PRIVATE ${input:Src} ${input;hide:Dep} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON + ADDINCL(FOR cython contrib/tools/cython/Cython/Includes) +} + +# tag:python-processing tag:cython tag:internal +### @usage: _BUILDWITH_CYTHON_C_H(Src Dep Options...) # internal +### +### BUILDWITH_CYTHON_C without .pyx infix and with cdef public .h file. +macro _BUILDWITH_CYTHON_C_H(Src, Dep, Options...) { + .CMD=$RUN_CYTHON_SCRIPT_H $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;noext;tobindir:Src.c} ${output;hide;addincl;noext;tobindir:Src.h} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + ADDINCL(FOR cython contrib/tools/cython/Cython/Includes) +} + +# tag:python-processing tag:cython tag:internal +### @usage: _BUILDWITH_CYTHON_C_API_H(Src Dep Options...) # internal +### +### BUILDWITH_CYTHON_C_H with cdef api _api.h file. +macro _BUILDWITH_CYTHON_C_API_H(Src, Dep, Options...) { + .CMD=$RUN_CYTHON_SCRIPT_H $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;noext;tobindir:Src.c} ${output;hide;addincl;noext;tobindir:Src.h} ${output;hide;addincl;noext;defext=_api.h;tobindir:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"} + ADDINCL(FOR cython contrib/tools/cython/Cython/Includes) +} + +# tag:python-processing tag:internal +### @usage: _SWIG_PYTHON_CPP(Src, DstSubPrefix) # internal +### +### Run swig on Src to produce DstSubPrefix.py and DstSubPrefix_swg.cpp that +### provides DstSubPrefix_swg python module. +macro _SWIG_PYTHON_CPP(Src, DstSubPrefix) { + .CMD=$_SWIG_TOOL -I$ARCADIA_BUILD_ROOT -I$ARCADIA_ROOT -I$_SWIG_LIBRARY_ABS/python -I$_SWIG_LIBRARY_ABS -c++ -python -module ${nopath:DstSubPrefix} -interface ${nopath;suf=_swg:DstSubPrefix} -o ${output;suf=.swg.cpp:DstSubPrefix} ${input:Src} ${output;noauto;hide;suf=.py:DstSubPrefix} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"} + ADDINCL(FOR swig $_SWIG_LIBRARY/python FOR swig $_SWIG_LIBRARY) +} + +# tag:python-processing tag:internal +### @usage: _SWIG_PYTHON_C(Src, DstSubPrefix) # internal +### +### Like _SWIG_PYTHON_CPP but generate DstSubPrefix_swg.c. +macro _SWIG_PYTHON_C(Src, DstSubPrefix) { + .CMD=$_SWIG_TOOL -I$ARCADIA_BUILD_ROOT -I$ARCADIA_ROOT -I$_SWIG_LIBRARY_ABS/python -I$_SWIG_LIBRARY_ABS -python -module ${nopath:DstSubPrefix} -interface ${nopath;suf=_swg:DstSubPrefix} -o ${output;suf=.swg.c:DstSubPrefix} ${input:Src} ${output;noauto;hide;suf=.py:DstSubPrefix} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"} + ADDINCL(FOR swig $_SWIG_LIBRARY/python FOR swig $_SWIG_LIBRARY) +} + +### @usage: BUILDWITH_RAGEL6(Src Options...) +### +### Compile .rl file using Ragel6. +macro BUILDWITH_RAGEL6(Src, Options...) { + .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/ragel6"} $RAGEL6_FLAGS ${Options} -I${ARCADIA_ROOT} -o ${output;nopath;noext;defext=.rl6.cpp:Src} ${input:Src} ${kv;hide:"p R6"} ${kv;hide:"pc yellow"} +} + +# tag:python-processing tag:internal +# TODO: use it in [.pyx] cmd +### @usage: _PY_REGISTER() # internal +### +### Register Python 2.x module in internal resource file system. Arcadia Python 2.x importer will be retrieve these on import directive. +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister +macro _PY_REGISTER(Func) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py_reg.py"} $Func ${output;noauto:Func.reg.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} + SRCS(GLOBAL $Func.reg.cpp) +} + +# tag:python-processing tag:internal +### @usage: _PY3_REGISTER() # internal +### +### Register Python 3.x module in internal resource file system. Arcadia Python 3.x importer will be retrieve these on import directive +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister +macro _PY3_REGISTER(Func) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py3_reg.py"} $Func ${output;noauto:Func.reg3.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} + SRCS(GLOBAL $Func.reg3.cpp) +} + +# tag:python-processing tag:internal +### @usage: _PY_COMPILE_BYTECODE(SrcX Src) # internal +### +### Compile Python 2.x .py source file into Arcadia binary form suitable for PY2_PROGRAM +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister +macro _PY_COMPILE_BYTECODE(SrcX, Src, Dst) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/py_compile.py"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} +} + +# tag:python-processing tag:internal +### @usage: _PY3_COMPILE_BYTECODE(SrcX Src) # internal +### +### Compile Python 3.x .py source file into Arcadia binary form suitable for PY3_PROGRAM +### +### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister +macro _PY3_COMPILE_BYTECODE(SrcX, Src, Dst) { + .CMD=${env:"PYTHONHASHSEED=0"} ${tool:"contrib/tools/python3/pycc"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc3} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} +} + +macro _ARCHIVE_SEM_HELPER(FLAGS[], OUT, Files...) { + .SEM=add_custom_command OUTPUT ${OUT} DEPENDS $ARCH_TOOL ${join= :Files} COMMAND $ARCH_TOOL $FLAGS ${join=\: :Files}: -o ${OUT} +} + +### @usage: ARCHIVE_ASM(NAME archive_name files...) +### +### Similar to the macro ARCHIVE, but: +### 1. works faster and it is better to use for large files. +### 2. Different syntax (see examples in codesearch or users/pg/tests/archive_test) +macro ARCHIVE_ASM(NAME="", DONTCOMPRESS?"-p":"", Files...) { + .CMD=$ARCH_TOOL -q $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;suf=$OBJ_SUF.rodata:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-cyan"} + .SEM=$_ARCHIVE_SEM_HELPER(${output;suf=$OBJ_SUF.rodata:NAME} ${input:Files} FLAGS -q $DONTCOMPRESS) +} + +# tag:yweb-specific +macro PIRE_INLINE_CMD(SRC) { + .CMD=${tool:"library/cpp/regex/pire/inline"} -o ${output:SRC} ${input:SRC} ${output_include;hide:SRC} ${kv;hide:"p PI"} ${kv;hide:"pc yellow"} +} + +# tag:yweb-specific +macro PIRE_INLINE(FILES...) { + foreach (FILE : $FILES) { + PIRE_INLINE_CMD($FILE) + } +} + +### @usage: ARCHIVE(archive_name [DONT_COMPRESS] files...) +### +### Add arbitrary data to a modules. Unlike RESOURCE macro the result should be futher processed by othet macros in the module. +### +### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive +macro ARCHIVE(NAME="", DONTCOMPRESS?"-p":"", Files...) { + .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"} + .SEM=$_ARCHIVE_SEM_HELPER(${output;addincl;noauto:NAME} ${input:Files} FLAGS -q -x $DONTCOMPRESS) && target_sources PRIVATE $BINDIR/$NAME +} + +### @usage: ARCHIVE_BY_KEYS(archive_name key [DONT_COMPRESS] files...) +### +### Add arbitrary data to a module be accessible by specified key. +### Unlike RESOURCE macro the result should be futher processed by othet macros in the module. +### +### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive +macro ARCHIVE_BY_KEYS(NAME="", KEYS="", DONTCOMPRESS?"-p":"", Files...) { + .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input:Files} -k $KEYS -o ${output;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"} +} + +#scripts + +#special commands +BUILDVERSION_SCRIPT=build/scripts/build_info_gen.py +SVNVERSION_JAVA_MARKER=output-java-class +SVNVERSION_GO_MARKER=output-go +VCS_C_OBJ=$BINDIR/__vcs_version__.c$OBJECT_SUF +VCS_C_OBJ_RR=$MODDIR/__vcs_version__.c$OBJECT_SUF +VCS_C=$BINDIR/__vcs_version__.c +VCS_GO=$BINDIR/__vcs_version__.go +VCS_JAVA=$BINDIR/__vcs_version__.mf +VCS_INFO_DISABLE_CACHE__NO_UID__= +YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__= +CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__= +CL_MACRO_INFO_DISABLE_CACHE__NO_UID__= +YASM_DEBUG_INFO= +CL_DEBUG_INFO= +CL_MACRO_INFO= +when ($FORCE_VCS_INFO_UPDATE == "yes") { + VCS_INFO_DISABLE_CACHE__NO_UID__=${hide;kv:"disable_cache"} +} +### Works for pyton too. +GENERATE_VCS_C_INFO_NODEP=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} $(VCS)/vcs.json $VCS_C ${input:"build/scripts/c_templates/svn_interface.c"} $VCS_INFO_DISABLE_CACHE__NO_UID__ && $_SRC_c_nodeps($VCS_C, $VCS_C_OBJ, $(SOURCE_ROOT)) +GENERATE_VCS_GO_INFO_NODEP=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-go $(VCS)/vcs.json $VCS_GO $VCS_INFO_DISABLE_CACHE__NO_UID__ +GENERATE_VCS_JAVA_INFO_NODEP=$YMAKE_PYTHON ${input:"build/scripts/vcs_info.py"} output-java $(VCS)/vcs.json $VCS_JAVA $VCS_INFO_DISABLE_CACHE__NO_UID__ +macro UPDATE_VCS_JAVA_INFO_NODEP(Jar) { + .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-java $(VCS)/vcs.json $VCS_JAVA $Jar $VCS_INFO_DISABLE_CACHE__NO_UID__ +} + +### @usage VCS_INFO_FILE([FILE out_file]) +### +### Save vcs info as a json-file +### +### Info is saved to 'vcs_info.json' by default. +### Use FILE parameter if you want another name. +macro VCS_INFO_FILE(FILE="vcs_info.json") { + .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-json $(VCS)/vcs.json ${output:FILE} $VCS_INFO_DISABLE_CACHE__NO_UID__ ${kv;hide:"p VI"} ${kv;hide:"pc light-cyan"} +} + +### @usage: CREATE_BUILDINFO_FOR(GenHdr) +### +### Creates header file to access some information about build specified via configuration variables. +### Unlike CREATE_SVNVERSION_FOR() it doesn't take revion information from VCS, it uses revision and SandboxTaskId passed via -D options to ya make +macro CREATE_BUILDINFO_FOR(GenHdr) { + .CMD=$YIELD $CXX_COMPILER && $YIELD $CXXFLAGS && $XARGS $YMAKE_PYTHON3 ${input:BUILDVERSION_SCRIPT} ${output:GenHdr} ${kv;hide:"p BI"} ${kv;hide:"pc yellow"} ${hide;kv:"show_out"} $SVN_DEPENDS_CACHE__NO_UID__ + .SEM=$RUN_PYTHON3($BUILDVERSION_SCRIPT $GenHdr \\\"${CMAKE_CXX_COMPILER}\\\" \\\"${CMAKE_CXX_FLAGS}\\\" OUT $GenHdr) +} + +DECIMAL_MD5_SCRIPT=build/scripts/decimal_md5.py +DECIMAL_MD5_FIXED= + +### @usage: DECIMAL_MD5_LOWER_32_BITS(<fileName> [FUNCNAME funcName] [inputs...]) +### +### Generates .cpp file <fileName> with one defined function 'const char* <funcName>() { return "<calculated_md5_hash>"; }'. +### <calculated_md5_hash> will be md5 hash for all inputs passed to this macro. +macro DECIMAL_MD5_LOWER_32_BITS(File, FUNCNAME="", Opts...) { + .CMD=$YMAKE_PYTHON ${input:DECIMAL_MD5_SCRIPT} --fixed-output=${DECIMAL_MD5_FIXED} --func-name=${FUNCNAME} --lower-bits 32 --source-root=$ARCADIA_ROOT ${input;context=TEXT:Opts} ${output;stdout:File} ${kv;hide:"p SV"} ${kv;hide:"pc yellow"} ${hide;kv:"show_out"} +} + +# tag:internal +### @usage $CFG_VARS # internal +### +### Mark commands that embed Configuration variables into files +macro CFG_VARS() { + .GEN_FROM_FILE=yes +} + +### @usage: CONFIGURE_FILE(from to) +### +### Copy file with the replacement of configuration variables in form of @ANY_CONF_VAR@ with their values. +### The values are collected during configure stage, while replacement itself happens during build stage. +### Used implicitly for .in-files processing. +macro CONFIGURE_FILE(Src, Dst) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/configure_file.py"} ${input:Src} ${output;addincl:Dst} $CFG_VARS ${kv;hide:"p CF"} ${kv;hide:"pc yellow"} + .SEM=set_vars ${CFG_VARS} && configure_file $S/${input;rootrel:Src} $B/${output;addincl;rootrel:Dst} +} + +### @usage: BASE_CODEGEN(tool_path prefix) +### +### Generator ${prefix}.cpp + ${prefix}.h files based on ${prefix}.in. +macro BASE_CODEGEN(Tool, Prefix, Opts...) { + .CMD=${tool:Tool} ${input:Prefix.in} ${output;nopath;noauto:Prefix.cpp} ${output;nopath:Prefix.h} $Opts ${kv;hide:"p BC"} ${kv;hide:"pc yellow"} +} + +# tag:internal +### @usage: _SPLIT_CODEGEN_BASE(tool prefix OUTS[] OUTPUT_INCLUDES[]) # internal +### +### Generator of a certain number .the. cpp file + one header .h file from .in. +### This is the call of the generator. Python macro SPLIT_CODEGEN() is defined in order to properly fill command outputs from OUT_NUM argument. +macro _SPLIT_CODEGEN_BASE(Tool, Prefix, OUT[], OPTS[], OUTPUT_INCLUDES[]) { + .CMD=${tool:Tool} ${input:Prefix.in} ${output;hide:OUT} ${output;nopath;noauto:Prefix.cpp} ${output;nopath:Prefix.h} $OPTS ${output_include;hide:OUTPUT_INCLUDES} ${kv;hide:"p SC"} ${kv;hide:"pc yellow"} +} + +STRUCT_CODEGEN_OUTPUT_INCLUDES=${output_include;hide:"util/generic/singleton.h"} \ +${output_include;hide:"util/generic/strbuf.h"} \ +${output_include;hide:"util/generic/vector.h"} \ +${output_include;hide:"util/generic/ptr.h"} \ +${output_include;hide:"util/generic/yexception.h"} \ +${output_include;hide:"kernel/struct_codegen/reflection/reflection.h"} \ +${output_include;hide:"kernel/struct_codegen/reflection/floats.h"} + +### @usage: STRUCT_CODEGEN(Prefix) +### A special case BASE_CODEGEN, in which the kernel/struct_codegen/codegen_tool tool is used. +macro STRUCT_CODEGEN(Prefix) { + .CMD=$BASE_CODEGEN(kernel/struct_codegen/codegen_tool, $Prefix, $STRUCT_CODEGEN_OUTPUT_INCLUDES) + .PEERDIR=kernel/struct_codegen/metadata kernel/struct_codegen/reflection +} + +### @usage: DUMPERF_CODEGEN(Prefix) +### A special case BASE_CODEGEN, in which the extsearch/images/robot/tools/dumperf/codegen tool is used +macro DUMPERF_CODEGEN(Prefix) { + .CMD=$BASE_CODEGEN(extsearch/images/robot/tools/dumperf/codegen, $Prefix, ${output_include;hide:"extsearch/images/kernel/erf/erf_format.h"}) +} + +# tag:flags +### @usage: LDFLAGS(LinkerFlags...) +### +### Add flags to the link command line of executable or shared library/dll. +### Note: LDFLAGS are always global. When set in the LIBRARY module they will affect all programs/dlls/tests the library is linked into. +### Note: remember about the incompatibility of flags for gcc and cl. +macro LDFLAGS(Flags...) { + SET_APPEND(LDFLAGS_GLOBAL $Flags) +} + +# tag:flags +### @usage: CFLAGS([GLOBAL compiler_flag]* compiler_flags) +### +### Add the specified flags to the compilation command of C and C++ files. +### @params: GLOBAL - Propagates these flags to dependent projects +### Note: remember about the incompatibility flags for clang and cl (to set flags specifically for cl.exe use MSVC_FLAGS). +macro CFLAGS(Flags...) { + SET_APPEND_WITH_GLOBAL(USER_CFLAGS $Flags) +} + +# tag:flags +### @usage: MASMFLAGS(compiler flags) +### Add the specified flags to the compilation command of .masm files. +macro MASMFLAGS(Flags...) { + SET_APPEND(MASMFLAGS $Flags) +} + +# tag:flags +### @usage: CONLYFLAGS([GLOBAL compiler_flag]* compiler_flags) +### Add the specified flags to the compilation command of .c (but not .cpp) files. +### @params: GLOBAL - Distributes these flags on dependent projects +macro CONLYFLAGS(Flags...) { + SET_APPEND_WITH_GLOBAL(USER_CONLYFLAGS $Flags) +} + +# tag:flags +### @usage: CXXFLAGS(compiler_flags) +### Add the specified flags to the compilation command of .cpp (but not .c) files. +macro CXXFLAGS(Flags...) { + SET_APPEND_WITH_GLOBAL(USER_CXXFLAGS $Flags) +} + +# tag:flags +### @usage: CUDA_NVCC_FLAGS(compiler flags) +### Add the specified flags to the compile line .cu-files. +macro CUDA_NVCC_FLAGS(Flags...) { + SET_APPEND(CUDA_NVCC_FLAGS $Flags) +} + +# tag:flags +### @usage: NVCC_DEVICE_LINK(file.cu...) +### Run nvcc --device-link on objects compiled from srcs with --device-c. +### This generates a stub object devlink.o that supplies missing pieces for the +### host linker to link relocatable device objects into the final executable. +macro NVCC_DEVICE_LINK(Srcs...) { + .CMD=$NVCC $NVCC_FLAGS -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:"devlink"} -dlink ${input;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:Srcs} ${kv;hide:"p DL"} ${kv;hide:"pc light-blue"} +} + +# tag:flags +### @usage: CYTHON_FLAGS(compiler_flags) +### Add the specified flags to the compilation command of .pyx files. +macro CYTHON_FLAGS(Flags...) { + SET_APPEND(CYTHON_OPTIONS $Flags) +} + +### @usage: STRIP() +### Strip debug info from a PROGRAM, DLL or TEST. +### This macro doesn't work in LIBRARY's, UNION's and PACKAGE's. +macro STRIP() { + ENABLE(STRIP) +} + +### @usage: NO_OPTIMIZE() +### Build code without any optimizations (-O0 mode). +macro NO_OPTIMIZE() { + ENABLE(NO_OPTIMIZE) +} + +#TODO(YMAKE-91) read proper compile flags instead of sending explicit flags to semgraph directly +_SEM_EXTRA_CXX_FLAGS= + +### @usage: NO_COMPILER_WARNINGS() +### Disable all compiler warnings in the module. +### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR. +macro NO_COMPILER_WARNINGS() { + ENABLE(NO_COMPILER_WARNINGS) + SET(_SEM_EXTRA_CXX_FLAGS "$<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>") +} + +### @usage: WERROR() +### Consider warnings as errors in the current module. +### In the bright future will be removed, since WERROR is the default. +### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR. +macro WERROR() { + ENABLE(WERROR) +} + +### @usage: NO_WERROR() +### Override WERROR() behavior +### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR. +macro NO_WERROR() { + DISABLE(WERROR) +} + +### @usage: NO_WSHADOW() +### Disable C++ shadowing warnings. +macro NO_WSHADOW() { + ENABLE(NO_WSHADOW) +} + +# tag:internal +### @usage: NO_PLATFORM_RESOURCES() # internal +### Exclude dependency on platform resources libraries. +### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance. +macro NO_PLATFORM_RESOURCES() { + ENABLE(NOPLATFORM_RESOURCES) +} + +# tag:internal tag:codenav +### @usage: NO_CODENAVIGATION() # internal +### Disable codenaviagtion for a module. Needed to avoid PEERDIR loops in codenavigation support. +### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance. +macro NO_CODENAVIGATION() { + ENABLE(NOCODENAVIGATION) +} + +### @usage: NO_UTIL() +### Build module without dependency on util. +### Note: use this with care. Util most likely will be linked into executable anyway, +### so using util headers/functions/classes may not be detected at build time and may lead to unpredictable behavors at configure time. +macro NO_UTIL() { + ENABLE(NOUTIL) +} + +### @usage: NO_RUNTIME() +### +### This macro: +### 1. Sets the ENABLE(NOUTIL) + DISABLE(USE_INTERNAL_STL); +### 2. If the project that contains the macro NO_RUNTIME(), peerdir-it project does not contain NO_RUNTIME() => Warning. +### Note: use this with care. Arcadia STL most likely will be linked into executable anyway, so using STL headers/functions/classes +### may not be detected at build time and may lead to unpredictable behavors at configure time. +macro NO_RUNTIME() { + SET(USE_ARCADIA_LIBM no) + NO_UTIL() + ENABLE(NORUNTIME) +} + +### @usage: NO_LIBC() +### +### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata). +### Note: use this with care. libc most likely will be linked into executable anyway, +### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time. +macro NO_LIBC() { + NO_RUNTIME() + DISABLE(MUSL) +} + +### @usage: NO_PLATFORM() +### +### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata) and set NO_PLATFORM variable for special processing. +### Note: use this with care. libc most likely will be linked into executable anyway, +### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time. +macro NO_PLATFORM() { + NO_LIBC() + ENABLE(NOPLATFORM) +} + +# tag:cpp-specific +### @usage: USE_CXX() +### +### Add dependency on C++ runtime +### Note: This macro is inteneded for use in _GO_BASE_UNIT like module when the module is built without C++ runtime by default +macro USE_CXX() { + DISABLE(NORUNTIME) +} + +### @usage: USE_UTIL() +### +### Add dependency on util and C++ runtime +### Note: This macro is intended for use in _GO_BASE_UNIT like module when the module is build without util by default +macro USE_UTIL() { + USE_CXX() + DISABLE(NOUTIL) +} + +### @usage: USE_NASM() +### +### Build only .asm files with nasm toolchain instead of yasm +### Add to ya.make file ADDINCL(asm ...) with all folders where .asm files include smth +macro USE_NASM() { + ENABLE(USE_NASM_ASSEMBLER) + PEERDIR(build/external_resources/nasm) +} + +# tag:deprecated +### @usage: NO_JOIN_SRC() # deprecated, does-nothing +### This macro currently does nothing. This is default behavior which cannot be overridden at module level. +macro NO_JOIN_SRC() { + ENABLE(UNUSED_MACRO) +} + +# tag:sanitize +### @usage: NO_SANITIZE() +### +### Disable all sanitizers for the module. +macro NO_SANITIZE() { + DISABLE(SANITIZER_TYPE) +} + +# tag:coverage tag:sanitize +### @usage: NO_SANITIZE_COVERAGE() +### +### Disable lightweight coverage (-fsanitize-coverage) for the module. +### Sanitize coverage is commonly used with fuzzing. +### It might be useful to disable it for libraries that should never +### be the main targets for fuzzing, like libfuzzer library itself. +### Sanitize coverage instrumentation is enabled by the --sanitize-coverage option. +macro NO_SANITIZE_COVERAGE() { + DISABLE(SANITIZE_COVERAGE) +} + +# tag:sanitize +### @usage: NO_SANITIZE_HEADERS() +### +### Disable dependency on sanitizer headers for the module. +macro NO_SANITIZE_HEADERS() { + DISABLE(SANITIZE_HEADERS) +} + +# tag:coverage +### @usage: NO_CLANG_COVERAGE() +### +### Disable heavyweight clang coverage for the module. Clang coverage instrumentation is enabled by the --clang-coverage option. +macro NO_CLANG_COVERAGE() { + DISABLE(CLANG_COVERAGE) +} + +macro NO_CLANG_TIDY() { + DISABLE(TIDY_ENABLED) +} + +# tag:python-specific tag:coverage +### @usage: NO_PYTHON_COVERAGE() +### +### Disable python coverage for module +macro NO_PYTHON_COVERAGE() { + DISABLE(PYTHON_COVERAGE) +} + +# tag:python-specific tag:coverage tag:cython +### @usage: NO_CYTHON_COVERAGE() +### +### Disable cython and cythonized python coverage (CYTHONIZE_PY) +### Implies NO_CLANG_COVERAGE() - right now, we can't disable instrumentation for .py.cpp files, but enable for .cpp +macro NO_CYTHON_COVERAGE() { + DISABLE(CYTHON_COVERAGE) + NO_CLANG_COVERAGE() +} + +# tag:lua-specific +LUAJIT_PATH=${ARCADIA_ROOT}/contrib/libs/luajit +macro _LUAJIT_OBJDUMP(Src, OUT="") { + .CMD=${cwd:LUAJIT_PATH} ${tool:"contrib/libs/luajit/compiler"} -b -g ${input:Src} ${output;noauto:OUT} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"} +} + +# tag:lua-specific +LUAJIT_21_PATH=${ARCADIA_ROOT}/contrib/libs/luajit_21 +macro _LUAJIT_21_OBJDUMP(Src, OUT="") { + .CMD=${cwd:LUAJIT_21_PATH} ${tool:"contrib/libs/luajit_21/compiler"} -b -g ${input:Src} ${output;noauto:OUT} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"} +} + +macro _MX_BIN_TO_INFO(Src) { + .CMD=${tool:"tools/mx_bin2info"} ${input:Src} ${output;nopath;noext;noauto:Src.info} ${kv;hide:"p MX"} ${kv;hide:"pc yellow"} +} + +MX_GEN_TABLE_INCLS=${output_include;hide:"yabs_mx_calc_table.h"} \ +${output_include;hide:"kernel/matrixnet/mn_sse.h"} \ +${output_include;hide:"library/cpp/archive/yarchive.h"} \ +${output_include;hide:"util/memory/blob.h"} \ +${output_include;hide:"util/generic/hash.h"} \ +${output_include;hide:"util/generic/ptr.h"} \ +${output_include;hide:"util/generic/singleton.h"} + +macro _MX_GEN_TABLE(Srcs...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_mx_table.py"} $Srcs ${output;stdout:"mx_tables.cpp"} $MX_GEN_TABLE_INCLS ${kv;hide:"p MX"} ${kv;hide:"pc yellow"} + PEERDIR(kernel/matrixnet) + PEERDIR(library/cpp/archive) +} + +RELEV_FML_CODEGEN_INCLS=${output_include;hide:"kernel/relevfml/relev_fml.h"} ${output_include;hide:"library/cpp/sse/sse.h"} + +### @usage: GENERATE_ENUM_SERIALIZATION(File.h) +### +### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module. +### +### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/ +macro GENERATE_ENUM_SERIALIZATION(File) { + .CMD=$ENUM_PARSER_TOOL ${input:File} --include-path ${input;rootrel:File} --output ${output;suf=_serialized.cpp:File} ${output_include;from_input;hide:File} ${output_include;hide:"util/generic/serialized_enum.h"} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"} + .SEM=generate_enum_serilization ${input:File} ${output;hide;suf=_serialized.o:File} INCLUDE_HEADERS ${input;rootrel:File} ${tool;hide:"tools/enum_parser/enum_parser"} + PEERDIR(tools/enum_parser/enum_serialization_runtime) +} + +### @usage: GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File.h) +### +### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module +### Provide access to serialization functions via generated header File_serialized.h +### +### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/ +macro GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File) { + .CMD=$ENUM_PARSER_TOOL ${input:File} --include-path ${input;rootrel:File} --output ${output;suf=_serialized.cpp:File} --header ${output;suf=_serialized.h:File} ${output_include;from_input;hide:File} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"} + .SEM=generate_enum_serilization ${input:File} ${output;hide;suf=_serialized.o:File} GEN_HEADER ${output;suf=_serialized.h:File} INCLUDE_HEADERS ${input;rootrel:File} ${tool;hide:"tools/enum_parser/enum_parser"} + PEERDIR(tools/enum_parser/enum_serialization_runtime) +} + +### @usage: DEB_VERSION(File) +### +### Creates a header file DebianVersion.h define the DEBIAN_VERSION taken from the File. +macro DEB_VERSION(File) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/mkver.py"} ${input:File} ${output;stdout:"DebianVersion.h"} ${kv;hide:"p CL"} ${kv;hide:"pc yellow"} +} + +BUILD_MN_SCRIPT=build/scripts/build_mn.py + +# tag:matrixnet +### @usage: BUILD_MN([CHECK] [PTR] [MULTI] mninfo mnname) # matrixnet +### +### Generate MatrixNet data and access code using single command. +### Alternative macro BUILD_MNS() works faster and better for large files. +macro BUILD_MN(MnInfo, MnName, CHECK?"fml_tool=$FML_UNUSED_TOOL CHECK":"", MULTI?, PTR?, RANKING_SUFFIX="") { + .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnF $ARCADIA_ROOT $ARCH_TOOL ${input:MnInfo} $MnName ranking_suffix=$RANKING_SUFFIX ${output;pre=mn.:MnName.cpp} ${output;hide;pre=MN_External_;suf=.rodata:MnName} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} $CHECK $MULTI $PTR ${kv;hide:"p MN"} ${kv;hide:"pc yellow"} +} + +macro _BUILD_MNS_FILE(Input, Name, Output, Suffix, Check, Fml_tool, AsmDataName) { + .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnsFilesF $ARCADIA_ROOT $BINDIR $ARCH_TOOL fml_tool=$Fml_tool $Name ranking_suffix=$Suffix ${input:Input} ${output;hide:Output} ${output;hide;pre=MN_External_;suf=.rodata:AsmDataName} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} ${kv;hide:"p MN"} ${kv;hide:"pc yellow"} +} + +MNS_OUTPUT=mnmodels + +macro _BUILD_MNS_CPP(NAME="", CHECK?, RANKING_SUFFIX="", Files...) { + .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnsCppF $NAME ranking_suffix=$RANKING_SUFFIX ${input:MNS_OUTPUT.h} ${output:MNS_OUTPUT.cpp} ${input:Files} ${output_include;hide:MNS_OUTPUT.h} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} ${kv;hide:"p MN"} ${kv;hide:"pc yellow"} +} + +macro _BUILD_MNS_HEADER(NAME="", CHECK?, RANKING_SUFFIX="", Files...) { + .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnsHeaderF $NAME ranking_suffix=$RANKING_SUFFIX ${output:MNS_OUTPUT.h} ${input:Files} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} ${output_include;hide:"kernel/matrixnet/mn_multi_categ.h"} ${kv;hide:"p MN"} ${kv;hide:"pc yellow"} +} + +# TODO: support foreach_in and keywords simultaneous usage (look at BUILD_MNS_FILES) + +# tag:matrixnet +### @usage: BUILD_MNS([CHECK] NAME listname mninfos...) # matrixnet +### +### Generate MatrixNet data and access code using separate commands for support code, interface and data. +### Faster version of BUILD_MN() macro for large files. +macro BUILD_MNS(Files...) { + _BUILD_MNS_HEADER($Files) + _BUILD_MNS_CPP($Files) + _BUILD_MNS_FILES($Files) +} + +### @usage: COMPILE_NLG(nlg_config.json, [TRANSLATIONS_JSON translations.json], Src...) +### +### Generate and compile .nlg templates (Jinja2-based) and interface for megamind runtime in localized mode. +### +### Alice-specific macro +macro COMPILE_NLG(NLG_CONFIG_JSON, TRANSLATIONS_JSON="", Src...) { + when ($TRANSLATIONS_JSON) { + TRANSLATIONS_JSON_ARG=--translations-json + } + otherwise { + TRANSLATIONS_JSON_ARG= + } + PEERDIR(alice/nlg/library/nlg_project_runtime) + RUN_PROGRAM(alice/nlg/tools/codegen compile-cpp --import-dir ${ARCADIA_ROOT} --out-dir ${ARCADIA_BUILD_ROOT} --include-prefix ${MODDIR} --nlg-config-json ${NLG_CONFIG_JSON} ${TRANSLATIONS_JSON_ARG} ${TRANSLATIONS_JSON} ${Src} IN ${TRANSLATIONS_JSON} ${NLG_CONFIG_JSON} ${Src} OUT_NOAUTO nlg_renderer_factory.cpp nlg_renderer_factory.h register.cpp translations.cpp translations.h localizable_phrases.pb.txt ${suf=.cpp:Src} ${suf=.h:Src} ${suf=.pb.txt:Src}) + SRCS(GLOBAL register.cpp nlg_renderer_factory.cpp translations.cpp ${suf=.cpp:Src}) +} + +### @usage: NEED_CHECK() +### +### Commits to the project marked with this macro will be blocked by pre-commit check and then will be +### automatically merged to trunk only if there is no new broken build targets in check results. +### The use of this macro is disabled by default. +macro NEED_CHECK(Flags...) { + # TODO: FIXME + ENABLE(UNUSED_MACRO) +} + +### @usage: NO_NEED_CHECK() +### +### Commits to the project marked with this macro will not be affected by higher-level NEED_CHECK macro. +macro NO_NEED_CHECK(Flags...) { + ENABLE(UNUSED_MACRO) +} + +# tag:deprecated +### @usage: NEED_REVIEW() # deprecated +### +### Mark the project as needing review. +### Reviewers are listed in the macro OWNER. The use of this macro is disabled by default. +### Details can be found here: https://clubs.at.yandex-team.ru/arcadia/6104 +macro NEED_REVIEW(Flags...) { + # TODO: FIXME + ENABLE(UNUSED_MACRO) +} + +### @usage: VERSION(Args...) +### +### Specify version of a module. Currently unused by build system, only informative. +macro VERSION(Flags...) { + ENABLE(UNUSED_MACRO) +} + +DATAWORK_SCHEEME_EXPORT_FLAGS= + +when ($UNIX == "yes") { + SCHEEME2_CFLAGS= -E -x c++ +} + +when ($WIN32 == "yes") { + SCHEEME2_CFLAGS= /E /TP +} + +SCHEEME2_STRUCT_INFO_FLAGS=-f "const static ui32 RecordSig" -u "RecordSig" --gcc44_no_typename --no_complex_overloaded_func_export +### @usage: GEN_SCHEEME2(scheeme_name from_file dependent_files...) +### +### Generates a C++ description for structure(contains the field RecordSig) in the specified file (and connected). +### +### 1. ${scheeme_name}.inc - the name of the generated file. +### 2. Use an environment variable - DATAWORK_SCHEEME_EXPORT_FLAGS that allows to specify flags to tools/structparser +### +### @example: +### +### SET(DATAWORK_SCHEEME_EXPORT_FLAGS --final_only -m "::") +### +### all options are passed to structparser (in this example --final_only - do not export heirs with public base that contains the required field,,- m "::" only from the root namespace) +### sets in extra option +### +### @example: +### +### SET(EXTRACT_STRUCT_INFO_FLAGS -f \"const static ui32 RecordSig\" +### -u \"RecordSig\" -n${scheeme_name}SchemeInfo ----gcc44_no_typename no_complex_overloaded_func_export +### ${DATAWORK_SCHEEME_EXPORT_FLAGS}) +### +### for compatibility with C++ compiler and the external environment. +### See tools/structparser for more details. +macro GEN_SCHEEME2(ScheemeName, FromFile) { + .CMD=$CXX_COMPILER $C_FLAGS_PLATFORM -c ${tmp;stdout:FromFile.cph} $SCHEEME2_CFLAGS ${input:FromFile} ${pre=-I:_C__INCLUDE} $CXXFLAGS -Wno-error && ${tool:"tools/structparser"} -o ${output:ScheemeName.inc} -n N${ScheemeName}SchemeInfo $SCHEEME2_STRUCT_INFO_FLAGS $DATAWORK_SCHEEME_EXPORT_FLAGS ${tmp:FromFile.cph} ${output;stdout;noauto:ScheemeName.inc.log} ${kv;hide:"p SH"} ${kv;hide:"pc yellow"} +} + +### @usage: SYMLINK(from to) +### Add symlink +macro SYMLINK(From, To) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/symlink.py"} ${input;dirallowed:From} ${output;noauto:To} ${kv;hide:"p LN"} ${kv;hide:"pc light-cyan"} +} + +# tag:internal +### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal +### Generate prefix " && target_sources PRIVATE " before $Args when GENERATE is specified in the list of actual arguments +macro _TARGET_SOURCES_FOR_HEADERS_IMPL(GENERATE?" && target_sources PRIVATE ":"", Args...) { + .SEM=$GENERATE ${output;ext=.h:Args} ${output;ext=.hh:Args} ${output;ext=.hpp:Args} ${output;ext=.inc:Args} ${output;ext=.i:Args} +} + +# tag:internal +### @usage: _TARGET_SOURCES_FOR_HEADERS(Args...) # internal +### Generate prefix " && target_sources PRIVATE " before $Args if Args is not empty +macro _TARGET_SOURCES_FOR_HEADERS(Args...) { + .SEM=$_TARGET_SOURCES_FOR_HEADERS_IMPL(${pre=GENERATE :Args}) +} + +# tag:internal +### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal +### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args when GENERATE is specified in the list of actual arguments +macro _SET_ENV_FOR_CUSTOM_COMMAND_IMPL(GENERATE?" ${CMAKE_COMMAND} -E env ":"", Args...) { + .SEM=$GENERATE ${pre= :Args} +} + +# tag:internal +### @usage: _SET_ENV_FOR_CUSTOM_COMMAND(Args...) # internal +### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args if Args is not empty +macro _SET_ENV_FOR_CUSTOM_COMMAND(Args...) { + .SEM=$_SET_ENV_FOR_CUSTOM_COMMAND_IMPL(${pre=GENERATE :Args}) +} + + +macro _FMT_INDUCED_DEPS(For, Deps...) { + .CMD=${induced_deps=$For;hide:Deps} +} + + +### @usage: PREPARE_INDUCED_DEPS(VAR Type Files...) +### +### Format value for `INDUCED_DEPS` param in certain macros and assign to `VAR` +### This tells that files of Type resulted from code generation macros (not neccessarily directly, +### but in processing chain of generated files) should have extra dependencies from list of Files... +### +### Prominent example here is Cython: one can generate .pyx file that may depend on .pxd and have cimpot from +### certain .h. The former is dependency for .pyx itself, while the latter is dependency for .pyx.cpp +### resulted from Cython-processing of generated pyx. The code ganeration will look like: +### ``` +### PREPARE_INDUCED_DEPS(PYX_DEPS pyx imported.pxd) +### PREPARE_INDUCED_DEPS(CPP_DEPS cpp cdefed.h) +### RUN_PYTHON3(generate_pyx.py genereted.pyx OUT generated.pyx INDUCED_DEPS $PYX_DEPS $CPP_DEPS) +### ``` +### +### The VAR will basically contain pair of `Type:[Files...]` in a form suitable for passing +### as an element of array parameter. This is needed because language of ya.make doesn't support +### Dict params right now and so it is impossible to directly pass something +### like `{Type1:[Files2...], Type2:[Files2...]}` +### +macro PREPARE_INDUCED_DEPS(VAR, For, Deps...) { + SET($VAR \$_FMT_INDUCED_DEPS($For $Deps)) +} + +### @usage: RUN_PROGRAM(tool_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...] [INDUCED_DEPS $VARs...]) +### +### Run a program from arcadia. +### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON. +### +### Parameters: +### - tool_path - Path to the directory of the tool. +### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute. +### - CWD dir - Absolute path of the working directory. +### - ENV key=value... - Environment variables. +### - TOOL tools... - Auxiliary tool directories. +### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions. +### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process. +### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file. +### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them. +### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain. +### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies +### +### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or +### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used. +### Note that Tool is always built for the host platform, so be careful to provide that tool can be built for all Arcadia major host platforms (Linux, MacOS and Windows). +macro RUN_PROGRAM(Tool, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], IN_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) { + .CMD=${cwd:CWD} ${env:ENV} ${tool:Tool} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${input;hide:IN_DEPS} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p PR"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} + .SEM=add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} ${output:STDOUT} ${output;noauto:STDOUT_NOAUTO} DEPENDS ${input:IN} ${input;context=TEXT:IN_NOPARSE} ${tool:Tool} ${tool:TOOL} ${pre=WORKING_DIRECTORY :CWD} COMMAND ${tool:Tool} $Args ${pre=> :STDOUT} ${pre=> :STDOUT_NOAUTO} $_TARGET_SOURCES_FOR_HEADERS($OUT $OUT_NOAUTO $STDOUT $STDOUT_NOAUTO) +} + +# tag:lua-specific +### @usage: RUN_LUA(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...] [INDUCED_DEPS $VARs...]) +### +### Run a lua script. +### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON. +### +### Parameters: +### - script_path - Path to the script.3 +### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute. +### - CWD dir - Absolute path of the working directory. +### - ENV key=value... - Environment variables. +### - TOOL tools... - Auxiliary tool directories. +### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions. +### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process. +### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file. +### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them. +### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain. +### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies +### +### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or +### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used. +macro RUN_LUA(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) { + .CMD=${cwd:CWD} ${env:ENV} $LUA_TOOL ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p LU"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} +} + +# tag:python-specific +### @usage: PYTHON(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...] [INDUCED_DEPS $VARs...]) +### +### Run a python script with $(PYTHON)/python built from devtools/huge_python. +### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON. +### +### Parameters: +### - script_path - Path to the script. +### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute. +### - CWD dir - Absolute path of the working directory. +### - ENV key=value... - Environment variables. +### - TOOL tools... - Auxiliary tool directories. +### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions. +### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process. +### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file. +### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them. +### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain. +### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies +### +### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or +### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used. +macro PYTHON(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) { + .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} + .SEM=find_package Python2 && add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} ${output:STDOUT} ${output;noauto:STDOUT_NOAUTO} DEPENDS ${input:IN} ${input;context=TEXT:IN_NOPARSE} ${input:ScriptPath} ${tool:TOOL} ${pre=WORKING_DIRECTORY :CWD} COMMAND Python2::Interpreter ${input:ScriptPath} $Args ${pre=> :STDOUT} ${pre=> :STDOUT_NOAUTO} $_TARGET_SOURCES_FOR_HEADERS($OUT $OUT_NOAUTO $STDOUT $STDOUT_NOAUTO) +} + +# tag:python-specific +### @usage: RUN_PYTHON3(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...] [INDUCED_DEPS $VARs...]) +### +### Run a python script with prebuilt python3 interpretor built from devtools/huge_python3. +### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON. +### +### Parameters: +### - script_path - Path to the script. +### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute. +### - CWD dir - Absolute path of the working directory. +### - ENV key=value... - Environment variables. +### - TOOL tools... - Auxiliary tool directories. +### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions. +### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process. +### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file. +### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them. +### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain. +### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies +### +### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or +### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used. +macro RUN_PYTHON3(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) { + .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON3 ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} + .SEM=find_package Python3 && add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} ${output:STDOUT} ${output;noauto:STDOUT_NOAUTO} DEPENDS ${input:IN} ${input;context=TEXT:IN_NOPARSE} ${input:ScriptPath} ${tool:TOOL} ${pre=WORKING_DIRECTORY :CWD} COMMAND Python3::Interpreter ${input:ScriptPath} $Args ${pre=> :STDOUT} ${pre=> :STDOUT_NOAUTO} $_TARGET_SOURCES_FOR_HEADERS($OUT $OUT_NOAUTO $STDOUT $STDOUT_NOAUTO) +} + +# tag:java-specific +macro _RUN_JAVA(IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], TOOL[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], HIDE_OUTPUT?"stderr2stdout":"stdout2stderr", Args...) { + PEERDIR(build/platform/java/jdk $JDK_RESOURCE_PEERDIR) + .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON ${input;pre=build/scripts/:HIDE_OUTPUT.py} $JDK_RESOURCE/bin/java $Args ${tool;hide:TOOL} ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} +} + +### @usage: FROM_SANDBOX([FILE] resource_id [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...]) +### +### Download the resource from the Sandbox, unpack (if not explicitly specified word FILE) and add OUT files to the build. EXECUTABLE makes them executable. +### You may specify extra dependencies that output files bring using OUTPUT_INCLUDES or INDUCED_DEPS. The change of these may e.g. lead to recompilation of .cpp files extracted from resource. +### If there is no default processing for OUT files or you need process them specially use OUT_NOAUTO instead of OUT. +### +### It is disallowed to specify directory as OUT/OUT_NOAUTO since all outputs of commands shall be known to build system. +### +### RENAME renames files to the corresponding OUT and OUT_NOAUTO outputs: +### FROM_SANDBOX(resource_id RENAME in_file1 in_file2 OUT out_file1 out_file2 out_file3) +### FROM_SANDBOX(resource_id RENAME in_file1 OUT out_file1 RENAME in_file2 OUT out_file2) +### FROM_SANDBOX(FILE resource_id RENAME resource_file OUT out_name) +### +### RENAME RESOURCE allows to rename the resource without specifying its file name. +### +### OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them. +### INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain. +### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies +### +### If AUTOUPDATED is specified than macro will be regularly updated according to autoupdate script. The dedicated Sandbox task scans the arcadia and +### changes resource_ids in such macros if newer resource of specified type is available. Note that the task seeks AUTOUPDATED in specific position, +### so you shall place it immediately after resource_id. +macro FROM_SANDBOX(Id, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], FILE?"--copy-to-dir":"--untar-to", AUTOUPDATED="", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"", 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 $FILE $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p SB"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} + ADD_CHECK(check.resource $Id) +} + +### @usage: FROM_MDS([FILE] key [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...]) +### +### Download resource from MDS with the specified key and process like [FROM_SANDBOX()](#macro_FROM_SANDBOX). +macro FROM_MDS(Key, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], FILE?"--copy-to-dir":"--untar-to", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") { + .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_mds.py"} --key $Key $FILE $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p MD"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} + ADD_CHECK(check.mds $Key) +} + +# tag:internal +### @usage: _FROM_EXTERNAL(ExtFile [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE]) #internal +### +### Use resource described as .external file as [FROM_SANDBOX()](#macro_FROM_SANDBOX)/[FROM_MDS()](#macro_FROM_MDS). +macro _FROM_EXTERNAL(File, OutFile, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], AUTOUPDATED="", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"", EXT="ext:") { + .CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$EXT;suf=.external:OutFile} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_external.py"} --external-file ${input:File} --resource-file $(RESOURCE_ROOT)/ext/$OutFile --copy-to-dir $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${input;hide:"build/scripts/fetch_from_sandbox.py"} ${input;hide:"build/scripts/fetch_from_mds.py"} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p XT"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} + +#FIXME: add '${resource;pre=$EXT:OutFile}' when support of the scheme is added to executors +#FIXME: add 'ADD_CHECK(check.external $File)' when proper testing is implemented +} + +### @usage LARGE_FILES([AUTOUPDATED] Files...) +### +### Use large file ether from working copy or from remote storage via placeholder <File>.external +### If <File> is present locally (and not a symlink!) it will be copied to build directory. +### Otherwise macro will try to locate <File>.external, parse it retrieve ot during build phase. +macro LARGE_FILES(AUTOUPDATED?, Files...) { + # This is needed to correctly switch between remote and local modes + _GLOB($LF $Files) +} + + +### @usage: FROM_ARCHIVE(Src [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...]) +### +### Process file archive as [FROM_SANDBOX()](#macro_FROM_SANDBOX). +macro FROM_ARCHIVE(Src, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") { + .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_archive.py"} "--archive" ${input:Src} "--file-name" ${suf=-:Src} "--untar-to" $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${kv;hide:"p FA"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"} +} + +when ($MSVC == "yes") { + C_AS_CXX_FLAGS=/TP /std:c++17 +} +otherwise { + C_AS_CXX_FLAGS=-x c++ -std=c++17 +} + +# tag:cpp-specific +### @usage: COMPILE_C_AS_CXX() +### +### Compile .c files as .cpp ones within a module. +macro COMPILE_C_AS_CXX() { + SET(EXTRA_C_FLAGS $C_AS_CXX_FLAGS) +} + +### @usage: NO_DEBUG_INFO() +### +### Compile files without debug info collection. +macro NO_DEBUG_INFO() { + SET(NO_DEBUGINFO yes) +} + +### @usage: CTEMPLATE_VARNAMES(File) +### +### Generate File.varnames.h using contrib/libs/ctemplate/make_tpl_varnames_h +### +### Documentation: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/ctemplate/README.md +macro CTEMPLATE_VARNAMES(File) { + .CMD=${tool:"contrib/libs/ctemplate/make_tpl_varnames_h"} -f ${output;addincl;nopath;noallext:File.varnames.h} ${input:File} +} + +LLVM_OPTS= +CLANG_BC_ROOT=${CLANG11_RESOURCE_GLOBAL} + +macro USE_LLVM_BC12() { + SET(CLANG_BC_ROOT ${CLANG12_RESOURCE_GLOBAL}) +} + +CLANG_DEFAULT_ROOT=${CLANG_RESOURCE_GLOBAL} +CLANG_C_COMPILER_BIN=${CLANG_RESOURCE_GLOBAL}/bin/clang +CLANG_CPP_COMPILER_BIN=${CLANG_RESOURCE_GLOBAL}/bin/clang++ + +CLANG_EMIT_EXTRA_OPTS= + +when ($OS_WINDOWS == "yes") { + # we can't use c++latest for clang14 now + # so we set c++20 for it + # for clang11 (actual clang for CLANG_EMIT_AST_CXX and LLVM_COMPILE_* macroses) /std:c++20 provokes "unused-command-line-argument" error + # !do not forget to change this flag when updating build/platform/clang + CLANG_EMIT_EXTRA_OPTS+=/std:c++latest +} + +when ($OS_ANDROID == "yes") { + # We use clang shipped with android-ndk which has different layout + CLANG_DEFAULT_ROOT=$CLANG_ANDROID_RESOURCE_GLOBAL + when ($HOST_OS_DARWIN) { + CLANG_C_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang + CLANG_CPP_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ + } + otherwise { + CLANG_C_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang + CLANG_CPP_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ + } +} + +### @usage: CLANG_EMIT_AST_CXX(Input Output Opts...) +### +### Emit Clang AST from .cpp file. CXXFLAGS and LLVM_OPTS are passed in, while CFLAGS and C_FLAGS_PLATFORM are not. +### Note: Output name is used as is, no extension added. +macro CLANG_EMIT_AST_CXX(Input, Output, Opts...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_CPP_COMPILER_BIN} ${pre=-I:_C__INCLUDE} $CXXFLAGS $C_FLAGS_PLATFORM $LLVM_OPTS -emit-ast -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p ST"} ${kv;hide:"pc light-green"} + PEERDIR(build/platform/clang) +} + +### @usage: LLVM_COMPILE_CXX(Input Output Opts...) +### +### Emit LLVM bytecode from .cpp file. BC_CXXFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not. +### Note: Output name is used as is, no extension added. +macro LLVM_COMPILE_CXX(Input, Output, Opts...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_BC_ROOT}/bin/clang++ ${pre=-I:_C__INCLUDE} $BC_CXXFLAGS $C_FLAGS_PLATFORM -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm -c ${input:Input} -o ${output;noauto:Output} $Opts $CLANG_EMIT_EXTRA_OPTS ${kv;hide:"p BC"} ${kv;hide:"pc light-green"} + .SEM=llvm_compile_cxx ${input:Input} ${output;noauto:Output} ${"${CLANGPLUSPLUS}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts} + PEERDIR(build/platform/clang) +} + +### @usage: LLVM_COMPILE_C(Input Output Opts...) +### +### Emit LLVM bytecode from .c file. BC_CFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not. +### Note: Output name is used as is, no extension added. +macro LLVM_COMPILE_C(Input, Output, Opts...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_BC_ROOT}/bin/clang ${pre=-I:_C__INCLUDE} $BC_CFLAGS $C_FLAGS_PLATFORM $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm -c ${input:Input} -o ${output;noauto:Output} $Opts $CLANG_EMIT_EXTRA_OPTS ${kv;hide:"p BC"} ${kv;hide:"pc light-green"} + .SEM=llvm_compile_c ${input:Input} ${output;noauto:Output} ${"${CLANGC}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts} + PEERDIR(build/platform/clang) +} + +### @usage: BPF(Input Output Opts...) +### +### Emit eBPF bytecode from .c file. +### Note: Output name is used as is, no extension added. +macro BPF(Input, Output, Opts...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_C_COMPILER_BIN} ${pre=-I:_C__INCLUDE} $C_FLAGS_PLATFORM -target bpf -c ${input:Input} -o ${output;noauto:Output} $Opts $CLANG_EMIT_EXTRA_OPTS ${kv;hide:"p BP"} ${kv;hide:"pc light-green"} + PEERDIR(build/platform/clang) +} + +LD_BINARY_NAME=ld +when($OS_LINUX) { + LD_BINARY_NAME=ld.lld +} + +### @usage: BPF_STATIC(Input Output Opts...) +### +### Emit eBPF bytecode from .c file. +### Note: Output name is used as is, no extension added. +macro BPF_STATIC(Input, Output, Opts...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_C_COMPILER_BIN} ${pre=-I:_C__INCLUDE} $C_FLAGS_PLATFORM -target bpf -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p BP"} ${kv;hide:"pc light-green"} && ${cwd:BINDIR} $LLD_ROOT_RESOURCE_GLOBAL/$LD_BINARY_NAME -r -b binary -m elf_x86_64 -o ${output;noauto;suf=.bpf.o:Input} ${noauto;nopath:Output} + PEERDIR(build/platform/clang build/platform/lld) +} + +### @usage: LLVM_COMPILE_LL(Input Output Opts...) +### +### Compile LLVM bytecode to object representation. +### Note: Output name is used as is, no extension added. +macro LLVM_COMPILE_LL(Input, Output, Opts...) { + .CMD=${CLANG_BC_ROOT}/bin/llvm-as ${input:Input} -o ${output;noauto:Output} ${kv;hide:"p BC"} ${kv;hide:"pc light-green"} + PEERDIR(build/platform/clang) +} + +### @usage: LLVM_LINK(Output Inputs...) +### +### Call llvm-link on set of Inputs to produce Output. +### Note: Unlike many other macros output argument goes first. Output name is used as is, no extension added. +macro LLVM_LINK(Output, Inputs...) { + .CMD=${CLANG_BC_ROOT}/bin/llvm-link ${input:Inputs} -o ${output;noauto:Output} ${kv;hide:"p LD"} ${kv;hide:"pc light-red"} + .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Inputs} COMMAND ${LLVMLINK} ${input:Inputs} -o ${output;noauto:Output} + PEERDIR(build/platform/clang) +} + +### @usage: LLVM_OPT(Input Output Opts...) +### +### Call llvm-opt with set of Opts on Input to produce Output. +### Note: Output name is used as is, no extension added. +macro LLVM_OPT(Input, Output, Opts...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/llvm_opt_wrapper.py"} ${CLANG_BC_ROOT}/bin/opt ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p OP"} ${kv;hide:"pc yellow"} + .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Input} COMMAND ${LLVMOPT} ${input:Input} -o ${output;noauto:Output} $Opts + PEERDIR(build/platform/clang) +} + +### @usage: LLVM_LLC(Src Opts...) +### +### Call llvm-llc with set of Opts on Src to produce object file. +### +### Note: Output name is calculated as concatenation of Src name and platform specific object file extension. +macro LLVM_LLC(Src, Opts...) { + .CMD=${tool:"contrib/libs/llvm14/tools/llc"} ${input:Src} --filetype obj -o ${output;suf=$OBJECT_SUF;noauto:Src} $Opts ${kv;hide:"p LC"} ${kv;hide:"pc yellow"} + .SEM=add_custom_command OUTPUT ${output;suf=$OBJECT_SUF;noauto:Src} DEPENDS ${input:Src} COMMAND ${LLVMLLC} --filetype obj ${input:Src} -o ${output;suf=$OBJECT_SUF;noauto:Src} $Opts + PEERDIR(build/platform/clang) +} + +when ($NO_DEBUGINFO == "yes") { + DEBUG_INFO_FLAGS= +} + +when ($CLANG && $DEBUGINFO_LINES_ONLY == "yes" && $NO_DEBUGINFO != "yes") { + DEBUG_INFO_FLAGS=-gline-tables-only +} + +# TODO: configurable tar and touch +PACK_TGZ=${cwd:ARCADIA_BUILD_ROOT} tar -czf ${rootrel:OUTPUT} ${rootrel:INPUT} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"} + +# tag:internal +### @usage TOUCH(Outputs...) # internal +### Just introduce outputs +macro TOUCH(Outputs...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output:Outputs} +} + +TOUCH_UNIT=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"p UN"} ${kv;hide:"pc light-cyan"} $TARGET +FAKE_PACKAGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"pc light-red"} $TARGET +COPY_PACKAGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/copy_to_dir.py"} --dest-dir $BINDIR --build-root $ARCADIA_BUILD_ROOT $PACKED_PACKAGE_ARGS $SRCS_GLOBAL $PEERS_LATE_OUTS ${skip_by_ext=.pkg.fake:PEERS} ${hide;late_out:AUTO_INPUT} ${hide;late_out;to_namespace=$BINDIR/:SRCS_GLOBAL} ${hide;late_out;to_namespace=$BINDIR/:PEERS_LATE_OUTS} ${hide;late_out;skip_by_ext=.pkg.fake;to_namespace=$BINDIR/:PEERS} ${kv;hide:"package PACKAGE"} +TOUCH_PACKAGE=$FAKE_PACKAGE_CMD $VCS_INFO_DISABLE_CACHE__NO_UID__ && $COPY_PACKAGE_CMD +_P_PK=${kv;hide:"p PK"} +TOUCH_PACKAGE_MF=$GENERATE_MF && $TOUCH_PACKAGE $_P_PK + +UNION_OUTS=${hide;late_out:AUTO_INPUT} +# Note: we don't use touch.py in the command below to avoid introduction of undesired input +UNION_CMD=$YMAKE_PYTHON -c open(\'$TARGET\',\'w\').close() ${kv;hide:"p UN"} ${kv;hide:"package UNION"} ${kv;hide:"pc light-cyan"} $UNION_OUTS $VCS_INFO_DISABLE_CACHE__NO_UID__ +UNION_CMD_MF=$UNION_CMD && $GENERATE_MF + +macro _EXPAND_INS_OUTS(FILES{input}[]) { + .CMD=${input;hide:FILES} ${late_out;hide:INPUT} +} + +when ($_UNION_EXPLICIT_OUTPUTS) { + UNION_OUTS=$_EXPAND_INS_OUTS($_UNION_EXPLICIT_OUTPUTS) +} + +_UNION_EXPLICIT_OUTPUTS= + +### @usage: EXPLICIT_OUTPUTS(Files...) +### +### Let UNION has only explicitly specified outputs listed in this macro +### The list of files shall contain results of commands in this UNION. +### Only these files will be outputs of the UNION. This allows to eliminate +### intermediate files being result of the UNION +macro EXPLICIT_OUTPUTS(Files...) { + SET_APPEND(_UNION_EXPLICIT_OUTPUTS ${Files}) +} + +NO_CHECK_IMPORTS_FOR_VALUE=None +### @usage: NO_CHECK_IMPORTS([patterns]) +### +### Do not run checks on imports of Python modules. +### Optional parameter mask patterns describes the names of the modules that do not need to check. +macro NO_CHECK_IMPORTS(Masks...) { + SET(NO_CHECK_IMPORTS_FOR_VALUE $Masks) +} + + +# tag:yasm-specific +_YASM_FMT_VALUE= +_YASM_PLATFORM_FLAGS_VALUE= +_YASM_PREDEFINED_FLAGS_VALUE= +when ($OS_DARWIN || $OS_IOS) { + _YASM_FMT_VALUE=macho + _YASM_PLATFORM_FLAGS_VALUE=-D DARWIN -D UNIX +} +elsewhen ($OS_WINDOWS && $ARCH_X86_64) { + _YASM_FMT_VALUE=win + _YASM_PLATFORM_FLAGS_VALUE=-D WIN64 +} +elsewhen ($OS_WINDOWS && $ARCH_I386) { + _YASM_FMT_VALUE=win + _YASM_PLATFORM_FLAGS_VALUE=-D WIN32 +} +otherwise { + _YASM_FMT_VALUE=elf + _YASM_PLATFORM_FLAGS_VALUE=-D UNIX + _YASM_PREDEFINED_FLAGS_VALUE=-g dwarf2 +} + +when ($ASM_PREFIX) { + ASM_PREFIX_VALUE=--prefix=$ASM_PREFIX +} +otherwise { + ASM_PREFIX_VALUE= +} + +# tag:yasm-specific +YASM_FLAGS= +YASM_PREINCLUDES_VALUE= + +# tag:yasm-specific +macro _SRC_yasm_helper(SRC, PREINCLUDES[], SRCFLAGS...) { + .CMD=${tool:"contrib/tools/yasm"} -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} $_YASM_PLATFORM_FLAGS_VALUE $YASM_DEBUG_INFO $YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__ -D ${pre=_;suf=_:HARDWARE_TYPE} -D_YASM_ $ASM_PREFIX_VALUE $_YASM_PREDEFINED_FLAGS_VALUE $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS -o ${output;noext;suf=${OBJECT_SUF}:SRC} ${pre=-P :PREINCLUDES} ${input;hide:PREINCLUDES} ${SRC} ${kv;hide:"p AS"} ${kv;hide:"pc light-green"} +} + +# tag:yasm-specific +macro _SRC_yasm(SRC, PREINCLUDES[], SRCFLAGS...) { + .CMD=$_SRC_yasm_helper(${input:SRC}, $SRCFLAGS, PREINCLUDES $PREINCLUDES) +} + +# tag:nasm-specific +NASM_FLAGS= + +# tag:nasm-specific +macro _SRC_nasm_helper(SRC, SRCFLAGS...) { + .CMD=${NASM_RESOURCE_GLOBAL}/bin/nasm -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} -D ${pre=_;suf=_:HARDWARE_TYPE} $NASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS -o ${output;noext;suf=${OBJECT_SUF}:SRC} ${SRC} +} + +# tag:nasm-specific +macro _SRC_nasm(SRC, PREINCLUDES[], SRCFLAGS...) { + .CMD=$_SRC_nasm_helper(${input:SRC}, $SRCFLAGS) +} + +# tag:src-processing +when ($USE_NASM_ASSEMBLER == "yes") { + MACRO_ALIAS(_SRC_ASM _SRC_nasm) +} +otherwise { + MACRO_ALIAS(_SRC_ASM _SRC_yasm) +} + +### @usage: ASM_PREINCLUDE(AsmFiles...) +### +### Supply additional .asm files to all assembler calls within a module +macro ASM_PREINCLUDE(PREINCLUDES...) { + SET_APPEND(YASM_PREINCLUDES_VALUE $PREINCLUDES) +} + +### @usage: RUN_ANTLR(Args...) +### +### Macro to invoke ANTLR3 generator (general case) +macro RUN_ANTLR(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) { + PEERDIR(build/external_resources/antlr3 build/platform/java/jdk $JDK_RESOURCE_PEERDIR) + .CMD=$_RUN_JAVA(-jar $ANTLR3_RESOURCE_GLOBAL/antlr-3.5.2-complete-no-st3.jar $Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD}) + .SEM=run_antlr OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $Args +} + +### @usage: RUN_ANTLR4(Args...) +### +### Macro to invoke ANTLR4 generator (general case) +macro RUN_ANTLR4(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) { + _RUN_JAVA(-jar ${input:"contrib/java/antlr/antlr4/antlr.jar"} $Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD}) +} + +_ANTLR4_LISTENER_GRAMMAR=-listener +_ANTLR4_LISTENER__ANTLR4_EMPTY=-no-listener +_ANTLR4_VISITOR_GRAMMAR=-visitor +_ANTLR4_VISITOR__ANTLR4_EMPTY=-no-visitor + +### @usage: RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...) +### +### Macro to invoke ANTLR4 generator (Cpp) +macro RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) { + RUN_ANTLR4(${GRAMMAR} -Dlanguage=Cpp -o ${BINDIR} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} ${Args} CWD ${BINDIR} IN ${GRAMMAR} OUT ${noext;suf=Lexer.cpp:GRAMMAR} ${noext;suf=Lexer.h:GRAMMAR} ${noext;suf=Parser.cpp:GRAMMAR} ${noext;suf=Parser.h:GRAMMAR} ${noext;suf=Listener.h:$LISTENER} ${noext;suf=BaseListener.h:$LISTENER} ${noext;suf=Visitor.h:$VISITOR} ${noext;suf=BaseVisitor.h:$VISITOR} OUTPUT_INCLUDES ${ARCADIA_ROOT}/contrib/libs/antlr4_cpp_runtime/src/antlr4-runtime.h ${OUTPUT_INCLUDES}) + PEERDIR(contrib/libs/antlr4_cpp_runtime) +} + +### @usage: RUN_ANTLR4_GO(GRAMMAR, DEPS <extra_go_deps>, LISTENER, VISITOR, Args...) +### +### Macro to invoke ANTLR4 generator (Go) +macro RUN_ANTLR4_GO(GRAMMAR, DEPS[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) { + RUN_ANTLR4(${GRAMMAR} -Dlanguage=Go -o ${BINDIR} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} ${Args} CWD ${BINDIR} IN ${GRAMMAR} OUT ${noext;tolower;suf=_lexer.go:GRAMMAR} ${noext;tolower;suf=_parser.go:GRAMMAR} ${noext;tolower;suf=_listener.go:$LISTENER} ${noext;tolower;suf=_base_listener.go:$LISTENER} ${noext;tolower;suf=_visitor.go:$VISITOR} ${noext;tolower;suf=_base_visitor.go:$VISITOR}) + PEERDIR(${GOSTD}/fmt ${GOSTD}/reflect ${GOSTD}/strconv ${GOSTD}/sync ${GOSTD}/unicode vendor/github.com/antlr/antlr4/runtime/Go/antlr/v4 $DEPS) +} + +### @usage: RUN_ANTLR4_PYTHON(Grammar [LISTENER] [VISITOR] [SUBDIR] [EXTRA_OUTS Outs...] Args...) +### +### `LISTENER` - emit grammar listener +### `VISITOR` - emit grammar visitor +### `SUBDIR` - place generated files to specified subdirectory of BINDIR +### `EXTRA_OUTS` - list extra outputs produced by Antlr (e.g. .interp and .token files) if they are needed. If `SUBDIR` is specied it will affect these as well. Use file names only. +### +### Macro to invoke ANTLR4 generator (Python). The Python3 will be used for PY3_LIBRARY/PY3_PROGRAM/PY3TEST, Python2 will be used in all other cases. +macro RUN_ANTLR4_PYTHON(GRAMMAR, LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", SUBDIR=".", EXTRA_OUTS[], _ANTLR4_EMPTY="", Args...) { + RUN_ANTLR4(${GRAMMAR} -Dlanguage=$ANTLR_PYTHON -o ${BINDIR}/${SUBDIR} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} ${Args} CWD ${BINDIR} IN ${GRAMMAR} OUT_NOAUTO ${nopath;noext;pre=${SUBDIR}/;suf=Lexer.py:GRAMMAR} ${nopath;noext;pre=${SUBDIR}/;suf=Parser.py:GRAMMAR} ${nopath;noext;pre=${SUBDIR}/;suf=Listener.py:$LISTENER} ${nopath;noext;pre=${SUBDIR}/;suf=Visitor.py:$VISITOR} ${pre=${SUBDIR}/:EXTRA_OUTS}) + PEERDIR(contrib/python/antlr4) +} + + +# tag:cpp-specific +macro CPP_ADDINCL(Dirs...) { + ADDINCL($Dirs) +} + +# tag:internal +_WHOLE_ARCHIVE_PEERS_VALUE= +### @usage: WHOLE_ARCHIVE(dirnames...) # internal +macro WHOLE_ARCHIVE(PEERS...) { + SET_APPEND(_WHOLE_ARCHIVE_PEERS_VALUE ${PEERS}) + REQUIRES(${PEERS}) +} + +ANDROID_SDK_ROOT=${ANDROID_SDK_RESOURCE_GLOBAL}/android_sdk + +macro TASKLET() { + PEERDIR(tasklet/api) + + # CPP + CPP_PROTO_PLUGIN(tasklet_cpp tasklet/v1/gen/cpp .tasklet.h) + + # Python + PY_PROTO_PLUGIN2(tasklet_py _tasklet.py _sbtask.py tasklet/v1/gen/python DEPS tasklet/v1/domain/sandbox tasklet/v1/runtime sandbox/sdk2) +} + +TASKLET_REG_INCLUDES= \ + ${output_include;hide:"tasklet/v1/runtime/lib/cpp_wrapper.h"} \ + ${output_include;hide:"tasklet/v1/runtime/lib/go_wrapper.h"} \ + ${output_include;hide:"tasklet/v1/runtime/lib/py_wrapper.h"} \ + ${output_include;hide:"tasklet/v1/runtime/lib/js_wrapper.h"} \ + ${output_include;hide:"tasklet/v1/runtime/lib/registry.h"} + +macro TASKLET_REG(Name, Lang, Impl, Includes...) { + PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker) + + when($Lang == "js") { + # JS runtime links the Node.js from contrib as a library, which is a bit heavy, + # so we do it, only if any JS tasklets are linked into the target + PEERDIR+=tasklet/v1/runtime/js + } + + .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_tasklet_reg.py"} $Name -l $Lang -i $Impl ${output;noauto:Name.task.cpp} $Includes ${output_include;hide:Includes} $TASKLET_REG_INCLUDES ${kv;hide:"p TT"} ${kv;hide:"pc yellow"} + SRCS(GLOBAL $Name.task.cpp) +} + +# TEMPORARY METHOD FOR EXTENDED REGISTRY SETUP +# NOT COMPLETE +macro TASKLET_REG_EXT(Name, Lang, Impl, Wrapper, Includes...) { + PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker) + + .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_tasklet_reg.py"} $Name -l $Lang -i $Impl -w $Wrapper ${output;noauto:Name.task.cpp} $Includes ${output_include;hide:Includes} $TASKLET_REG_INCLUDES ${kv;hide:"p TT"} ${kv;hide:"pc yellow"} + SRCS(GLOBAL $Name.task.cpp) +} + +# tag:cpp-specific +_CPP_PROTO_MODULE_PREFIX= +_CPP_PROTO_MODULE_SUFFIX= +when ($MSVC == "yes" || $CYGWIN == "yes") { + _CPP_PROTO_MODULE_PREFIX= + _CPP_PROTO_MODULE_SUFFIX=.lib +} +otherwise { + _CPP_PROTO_MODULE_PREFIX=lib + _CPP_PROTO_MODULE_SUFFIX=.a +} + +### @usage: _EXPOSE(OutputsToExport...) +### +### Allows to mark outputs of macro command as unused in the current module but intended +### to be used in modules consuming current via PEERDIR. +### +### TODO(DEVTOOLS-9000) proper implementation needed +macro _EXPOSE(Args...) { + .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output;suf=$_HASH_HELPER($Args).ya_exposed:"empty_"} ${input;hide:Args} +} + + +### @usage: LIST_PROTO([TO list.proto] Files...) # deprecated +### +### Create list of .proto files in a list-file (should be .proto, files.proto by default) +### with original .proto-files as list's dependencies. +### +### This allows to process files listed, passing list as an argument to the processor +### +### TODO: proper implementation needed +macro LIST_PROTO(TO="files.proto", Files...) { + .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/list.py"} ${Files} ${input;hide:Files} ${stdout;output;noauto:TO} ${output_include;from_input;hide:Files} && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output;noext;suf=.pb.h:TO} + _EXPOSE(${TO}) +} + +# tag:proto +macro _PROTO_DESC_CMD(File) { + .CMD=${cwd;rootdir;input:File} $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH --descriptor_set_out=${output;suf=.desc:File} --include_source_info $_PROTOC_FLAGS ${input;rootrel:File} +} + +_PROTO_DESC_MERGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/merge_files.py"} $TARGET $AUTO_INPUT ${kv;hide:"p PD"} ${kv;hide:"pc light-cyan"} +_PROTO_DESC_MERGE_PEERS_CMD=$YMAKE_PYTHON ${input:"build/scripts/merge_files.py"} $TARGET $PEERS $SRCS_GLOBAL ${kv;hide:"p PD"} ${kv;hide:"pc light-cyan"} + +NEED_GOOGLE_PROTO_PEERDIRS=yes + +CPP_PROTO_LIBRARY_SEM=$CPP_LIBRARY_SEM + +JAVA_PROTO_LIBRARY_SEM=$BUILD_PROTO_JAR_SEM $_GRADLE_EXPORT_PUBLISHING_SEM + +# tag:proto +### @usage: PROTO_LIBRARY() +### +### Build some varian of protocol buffers library. +### +### The particular variant is selected based on where PEERDIR to PROTO_LIBRARY comes from. +### +### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go. +### When PEERDIR comes from module for particular language appropriate variant is selected. +### PROTO_LIBRARY also supports emission of GRPC code if GRPC() macro is specified. +### Notes: +### - Python versions emit C++ code in addition to Python as optimization. +### - In some PROTO_LIBRARY-es Java or Python versions are excluded via EXCLUDE_TAGS macros due to incompatibilities. +### - Use from DEPENDS or BUNDLE is not allowed +### +### Documentation: https://wiki.yandex-team.ru/yatool/proto_library/ +### +### See: [GRPC()](#macro_GRPC), [OPTIMIZE_PY_PROTOS()](#macro_OPTIMIZE_PY_PROTOS), [INCLUDE_TAGS()](#macro_INCLUDE_TAGS), [EXCLUDE_TAGS()](#macro_EXCLUDE_TAGS) +multimodule PROTO_LIBRARY { + module CPP_PROTO : LIBRARY { + .ALLOWED=_EXPOSE LIST_PROTO + # TODO(svidyuk): think about marker which forces semantics inheritance + .SEM=CPP_PROTO_LIBRARY_SEM + FORCE_COVERAGE_DISABLED=yes + ENABLE(CPP_PROTO) + ENABLE(GEN_PROTO) + NO_CLANG_TIDY() + SET(PEERDIR_TAGS CPP_PROTO) + + when ($BUILD_PROTO_AS_EVLOG == "yes" && $USE_VANILLA_PROTOC == "yes") { + _OK=no + } + ASSERT(_OK BUILD_PROTO_AS_EVLOG and USE_VANILLA_PROTOC are incompatible yet) + + MODULE_SUFFIX=$_CPP_PROTO_MODULE_SUFFIX + MODULE_PREFIX=$_CPP_PROTO_MODULE_PREFIX + + when ($_COMMON_GOOGLE_APIS != "None") { + PEERDIR += contrib/libs/googleapis-common-protos + } + } + + module JAVA_PROTO: EXTERNAL_JAVA_LIBRARY { + .EXTS=.jsrc + .ALLOWED=GRPC + .SEM=JAVA_PROTO_LIBRARY_SEM + SET(PEERDIR_TAGS JAVA_PROTO) + ENABLE(JAVA_PROTO) + PEERDIR+=$JAVA_PROTOBUF_PEERS + + when ($KOTLIN_PROTO == "yes") { + KOTLIN_PROTO_PEERS=contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION} + KOTLIN_PROTO_FLAGS=--kotlin_out=$ARCADIA_BUILD_ROOT/java_out + } + when ($GRADLE_EXPORT_PUBLISHING == "yes") { + _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM + } + + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_SKIFF CPP_PROTO_PLUGIN2 PY_PROTO_PLUGIN YMAPS_SPROTO RESOURCE + ADDINCL(FOR proto $PROTOBUF_PATH) + + when ($_COMMON_GOOGLE_APIS != "None") { + PEERDIR += contrib/java/com/google/api/grpc/proto-google-common-protos/${JAVA_PROTO_COMMON_VERSION} + ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos + } + } + + module PY_PROTO: PY2_LIBRARY { + .ALIASES=SRCS=PY_SRCS + .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS + .PEERDIRSELF=CPP_PROTO + .SEM=IGNORED + SET(PEERDIR_TAGS PY2 PY_PROTO) + ENABLE(PY_PROTO) + OPTIMIZE_PY_PROTOS() + OBJ_SUF=.py2 + # Can not use NO_LINT(), because is not allowed outside of contrib directory + SET(_NO_LINT_VALUE none_internal) + + when ($_COMMON_GOOGLE_APIS != "None") { + PEERDIR += contrib/libs/googleapis-common-protos + } + + _IGNORE_SELF_PEERS= + _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX + when ($OPTIMIZE_PY_PROTOS_FLAG == "no") { + _IGNORE_PEERDIRSELF=CPP_PROTO + } + SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY) + } + + module PY3_PROTO: PY3_LIBRARY { + .ALIASES=SRCS=PY_SRCS + .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS + .PEERDIRSELF=CPP_PROTO + .SEM=IGNORED + SET(PEERDIR_TAGS PY3 PY3_PROTO) + ENABLE(PY3_PROTO) + OPTIMIZE_PY_PROTOS() + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=py3 + } + otherwise { + MODULE_PREFIX=libpy3 + } + OBJ_SUF=.py3 + # Can not use NO_LINT(), because is not allowed outside of contrib directory + SET(_NO_LINT_VALUE none_internal) + + when ($_COMMON_GOOGLE_APIS != "None") { + PEERDIR += contrib/libs/googleapis-common-protos + } + + _IGNORE_SELF_PEERS= + _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX + when ($OPTIMIZE_PY_PROTOS_FLAG == "no") { + _IGNORE_PEERDIRSELF=CPP_PROTO + } + SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY) + } + + module GO_PROTO: GO_LIBRARY { + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO + .SEM=IGNORED + SET(PEERDIR_TAGS GO GO_PROTO) + ENABLE(GO_PROTO) + + when ($_COMMON_GOOGLE_APIS == "None") { + } + elsewhen ($_COMMON_GOOGLE_APIS == "") { + PEERDIR += $_GO_COMMON_GOOGLE_APIS + ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos + } + otherwise { + PEERDIR += $_COMMON_GOOGLE_APIS + ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos + } + } + + module DESC_PROTO: _BARE_UNIT { + .CMD=_PROTO_DESC_MERGE_CMD + .SEM=IGNORED + .EXTS=.desc + .NODE_TYPE=Library + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO RESOURCE GO_PROTO_PLUGIN GRPC + + SET(PEERDIR_TAGS DESC_PROTO) + ENABLE(DESC_PROTO) + MODULE_SUFFIX=.self.protodesc + SET(MODULE_TYPE LIBRARY) + + MACRO_ALIAS(EVLOG_CMD _PROTO_DESC_CMD) + MACRO_ALIAS(PROTO_CMD _PROTO_DESC_CMD) + + when ($_COMMON_GOOGLE_APIS != "None") { + PEERDIR += contrib/libs/googleapis-common-protos + } + + when ($NEED_GOOGLE_PROTO_PEERDIRS == "yes") { + when ($USE_VANILLA_PROTOC == "yes") { + PEERDIR += contrib/libs/protobuf_std/builtin_proto/protos_from_protobuf + } + otherwise { + PEERDIR += contrib/libs/protobuf/builtin_proto/protos_from_protoc + } + } + } +} + +module PROTO_DESCRIPTIONS: _BARE_UNIT { + .CMD=_PROTO_DESC_MERGE_PEERS_CMD + .PEERDIR_POLICY=as_build_from + .NODE_TYPE=Library + .RESTRICTED=SRCS + .FINAL_TARGET=yes + + SET(PEERDIR_TAGS DESC_PROTO) + SET(MODULE_SUFFIX .protodesc) + SET(MODULE_TYPE PROTO_DESCRIPTIONS) +} + +module PROTO_REGISTRY: PROTO_DESCRIPTIONS { + SET(MODULE_TYPE PROTO_REGISTRY) +} + +# tag:fbs +_FBS_NAMESPACE_MAP_GLOBAL= + +# tag:fbs +macro _FBS_NAMESPACE_IMPL(NAMESPACE, PATH, DUMMY...) { + SET_APPEND(_FBS_NAMESPACE_MAP_GLOBAL ${NAMESPACE}=${PATH}) +} + +# tag:fbs +macro FBS_NAMESPACE(NAMESPACE, PATH...) { + _FBS_NAMESPACE_IMPL($NAMESPACE $PATH $MODDIR) +} + +# tag:fbs +### @usage: FBS_LIBRARY() +### +### Build some variant of Flatbuffers library. +### +### The particular variant is selected based on where PEERDIR to FBS_LIBRARY +### comes from. +### +### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go. +### When PEERDIR comes from module for particular language appropriate variant +### is selected. +### +### Notes: FBS_NAMESPACE must be specified in all dependent FBS_LIBRARY modules +### if build of Go code is requested. +multimodule FBS_LIBRARY { + module CPP_FBS: LIBRARY { + ENABLE(CPP_FBS) + SET(PEERDIR_TAGS CPP_FBS) + } + + module GO_FBS: GO_LIBRARY { + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER + ENABLE(GO_FBS) + SET(PEERDIR_TAGS GO GO_FBS) + } + + module JAVA_FBS: EXTERNAL_JAVA_LIBRARY { + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER + ENABLE(JAVA_FBS) + SET(PEERDIR_TAGS JAVA_FBS) + } + + module PY2_FBS: PY2_LIBRARY { + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER + .ALIASES=SRCS=PY_SRCS + ENABLE(PY2_FBS) + SET(PEERDIR_TAGS PY2 PY2_FBS) + # Can not use NO_LINT(), because is not allowed outside of contrib directory + SET(_NO_LINT_VALUE none_internal) + } + + module PY3_FBS: PY3_LIBRARY { + .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER + .ALIASES=SRCS=PY_SRCS + ENABLE(PY3_FBS) + SET(PEERDIR_TAGS PY3 PY3_FBS) + # Can not use NO_LINT(), because is not allowed outside of contrib directory + SET(_NO_LINT_VALUE none_internal) + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=py3 + } + otherwise { + MODULE_PREFIX=libpy3 + } + OBJ_SUF=.py3 + } +} + +# tag:java-specific +_COMPILE_JSRC=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/compile_jsrc.py"} --input $AUTO_INPUT --output $TARGET --prefix $BINDIR ${kv;hide:"p JC"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + +# tag:java-specific +COMPILE_JSRC_MF=$_COMPILE_JSRC && $GENERATE_MF + +# tag:java-specific tag:internal +### @usage: JSRC_LIBRARY() # internal +module JSRC_LIBRARY: _BARE_UNIT { + .CMD=COMPILE_JSRC_MF + .EXTS=.java + .PEERDIR_POLICY=as_include + .FINAL_TARGET=no + .ALIASES=SRCS=FILES + PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL + MODULE_TYPE=LIBRARY + SET(MODULE_SUFFIX .jsrc) + SET(DONT_RESOLVE_INCLUDES yes) + SET(NEED_PLATFORM_PEERDIRS no) + SET(MODULE_LANG JAVA) + + NO_RUNTIME() +} + +# tag:maps-specific +@import "${CONF_ROOT}/conf/project_specific/maps/asrc.conf" + +# tag:internal +### @usage: _PROXY_LIBRARY() # internal +### +### The use of this module is strictly prohibited!!! +module _PROXY_LIBRARY: LIBRARY { + .EXTS=.a .lib + .PEERDIR_POLICY=as_build_from + .PROXY=yes + .FINAL_TARGET=yes + DISABLE(NEED_ADD_FAKE_SRC) + + NO_UTIL() + NO_RUNTIME() +} + +# tag:maps-specific +@import "${CONF_ROOT}/conf/project_specific/maps/aar.conf" +@import "${CONF_ROOT}/conf/project_specific/maps/sproto.conf" +@import "${CONF_ROOT}/conf/project_specific/maps/mapkit.conf" + +_PRIMARY_OUTPUT_VALUE= + +# tag:internal +### @usage: PRIMARY_OUTPUT_VALUE(Output) # internal +### +### The use of this module is strictly prohibited!!! +macro PRIMARY_OUTPUT(OUTPUT) { + SET(_PRIMARY_OUTPUT_VALUE $OUTPUT) +} + +_DLL_PROXY_LIBRARY_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${input;hide:_PRIMARY_OUTPUT_VALUE} ${TARGET} + +# tag:internal +### @usage: DLL_PROXY_LIBRARY() # internal +### +### The use of this module is strictly prohibited!!! +module DLL_PROXY_LIBRARY: _PROXY_LIBRARY { + .ALLOWED=PRIMARY_OUTPUT + .CMD=_DLL_PROXY_LIBRARY_CMD +} + +_PREBUILT_PROGRAM_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${TARGET} ${kv;hide:"p ld"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + +# tag:internal +### @usage: PREBUILT_PROGRAM([programname]) # internal +### +### Program module which uses a prebuilt prgram as its output. +module PREBUILT_PROGRAM: _LINK_UNIT { + .CMD=_PREBUILT_PROGRAM_CMD + .SYMLINK_POLICY=EXE + .ALLOWED=INDUCED_DEPS PRIMARY_OUTPUT + .RESTRICTED=SRCS + + _BARE_LINK_MODULE() + + SET(MODULE_TYPE PROGRAM) + + when ($WIN32 == "yes" || $OS_CYGWIN == "yes") { + MODULE_SUFFIX=.exe + } +} + +### @usage COLLECT_JINJA_TEMPLATES(varname path) +### +### This macro collects all jinja and yaml files in the directory specified by second argument and +### stores result in the variable with mane specified by first parameter. +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[], GO_FILES...) { + .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_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[], GO_FILES...) { + .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_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[], GO_TEST_FILES[], GO_XTEST_FILES[], GO_FILES...) { + .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_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_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_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_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) + 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) + 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_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"} + } + "yolint_next" ? { + _GO_VET=yes + PEERDIR+=build/external_resources/yolint + _GO_VET_TOOL=${YOLINT_NEXT_RESOURCE_GLOBAL}/yolint + _GO_VET_FLAGS=-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"} +} + +# Conflict between protobuf-java and protobuf-javalite ¯\_(ツ)_/¯ +# both libraries are required by grpc +JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE=\ + com.google.protobuf.AbstractMessageLite \ + com.google.protobuf.AbstractMessageLite$Builder \ + com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream \ + com.google.protobuf.AbstractMessageLite$InternalOneOfEnum \ + com.google.protobuf.AbstractParser \ + com.google.protobuf.AbstractProtobufList \ + com.google.protobuf.AllocatedBuffer \ + com.google.protobuf.AllocatedBuffer$1 \ + com.google.protobuf.AllocatedBuffer$2 \ + com.google.protobuf.Android \ + com.google.protobuf.Any \ + com.google.protobuf.Any$1 \ + com.google.protobuf.Any$Builder \ + com.google.protobuf.AnyOrBuilder \ + com.google.protobuf.AnyProto \ + com.google.protobuf.Api \ + com.google.protobuf.Api$1 \ + com.google.protobuf.Api$Builder \ + com.google.protobuf.ApiOrBuilder \ + com.google.protobuf.ApiProto \ + com.google.protobuf.ArrayDecoders \ + com.google.protobuf.ArrayDecoders$1 \ + com.google.protobuf.ArrayDecoders$Registers \ + com.google.protobuf.BinaryReader \ + com.google.protobuf.BinaryReader$1 \ + com.google.protobuf.BinaryReader$SafeHeapReader \ + com.google.protobuf.BinaryWriter \ + com.google.protobuf.BinaryWriter$1 \ + com.google.protobuf.BinaryWriter$SafeDirectWriter \ + com.google.protobuf.BinaryWriter$SafeHeapWriter \ + com.google.protobuf.BinaryWriter$UnsafeDirectWriter \ + com.google.protobuf.BinaryWriter$UnsafeHeapWriter \ + com.google.protobuf.BooleanArrayList \ + com.google.protobuf.BoolValue \ + com.google.protobuf.BoolValue$1 \ + com.google.protobuf.BoolValue$Builder \ + com.google.protobuf.BoolValueOrBuilder \ + com.google.protobuf.BufferAllocator \ + com.google.protobuf.BufferAllocator$1 \ + com.google.protobuf.ByteBufferWriter \ + com.google.protobuf.ByteOutput \ + com.google.protobuf.ByteString \ + com.google.protobuf.ByteString$1 \ + com.google.protobuf.ByteString$2 \ + com.google.protobuf.ByteString$AbstractByteIterator \ + com.google.protobuf.ByteString$ArraysByteArrayCopier \ + com.google.protobuf.ByteString$BoundedByteString \ + com.google.protobuf.ByteString$ByteArrayCopier \ + com.google.protobuf.ByteString$ByteIterator \ + com.google.protobuf.ByteString$CodedBuilder \ + com.google.protobuf.ByteString$LeafByteString \ + com.google.protobuf.ByteString$LiteralByteString \ + com.google.protobuf.ByteString$Output \ + com.google.protobuf.ByteString$SystemByteArrayCopier \ + com.google.protobuf.BytesValue \ + com.google.protobuf.BytesValue$1 \ + com.google.protobuf.BytesValue$Builder \ + com.google.protobuf.BytesValueOrBuilder \ + com.google.protobuf.CanIgnoreReturnValue \ + com.google.protobuf.CheckReturnValue \ + com.google.protobuf.CodedInputStream \ + com.google.protobuf.CodedInputStream$1 \ + com.google.protobuf.CodedInputStream$ArrayDecoder \ + com.google.protobuf.CodedInputStream$IterableDirectByteBufferDecoder \ + com.google.protobuf.CodedInputStream$StreamDecoder \ + com.google.protobuf.CodedInputStream$StreamDecoder$RefillCallback \ + com.google.protobuf.CodedInputStream$StreamDecoder$SkippedDataSink \ + com.google.protobuf.CodedInputStream$UnsafeDirectNioDecoder \ + com.google.protobuf.CodedInputStreamReader \ + com.google.protobuf.CodedInputStreamReader$1 \ + com.google.protobuf.CodedOutputStream \ + com.google.protobuf.CodedOutputStream$1 \ + com.google.protobuf.CodedOutputStream$AbstractBufferedEncoder \ + com.google.protobuf.CodedOutputStream$ArrayEncoder \ + com.google.protobuf.CodedOutputStream$ByteOutputEncoder \ + com.google.protobuf.CodedOutputStream$HeapNioEncoder \ + com.google.protobuf.CodedOutputStream$OutOfSpaceException \ + com.google.protobuf.CodedOutputStream$OutputStreamEncoder \ + com.google.protobuf.CodedOutputStream$SafeDirectNioEncoder \ + com.google.protobuf.CodedOutputStream$UnsafeDirectNioEncoder \ + com.google.protobuf.CodedOutputStreamWriter \ + com.google.protobuf.CodedOutputStreamWriter$1 \ + com.google.protobuf.DoubleArrayList \ + com.google.protobuf.DoubleValue \ + com.google.protobuf.DoubleValue$1 \ + com.google.protobuf.DoubleValue$Builder \ + com.google.protobuf.DoubleValueOrBuilder \ + com.google.protobuf.Duration \ + com.google.protobuf.Duration$1 \ + com.google.protobuf.Duration$Builder \ + com.google.protobuf.DurationOrBuilder \ + com.google.protobuf.DurationProto \ + com.google.protobuf.Empty \ + com.google.protobuf.Empty$1 \ + com.google.protobuf.Empty$Builder \ + com.google.protobuf.EmptyOrBuilder \ + com.google.protobuf.EmptyProto \ + com.google.protobuf.Enum \ + com.google.protobuf.Enum$1 \ + com.google.protobuf.Enum$Builder \ + com.google.protobuf.EnumOrBuilder \ + com.google.protobuf.EnumValue \ + com.google.protobuf.EnumValue$1 \ + com.google.protobuf.EnumValue$Builder \ + com.google.protobuf.EnumValueOrBuilder \ + com.google.protobuf.ExperimentalApi \ + com.google.protobuf.ExtensionLite \ + com.google.protobuf.ExtensionRegistryFactory \ + com.google.protobuf.ExtensionRegistryLite \ + com.google.protobuf.ExtensionRegistryLite$ExtensionClassHolder \ + com.google.protobuf.ExtensionRegistryLite$ObjectIntPair \ + com.google.protobuf.ExtensionSchema \ + com.google.protobuf.ExtensionSchemaLite \ + com.google.protobuf.ExtensionSchemaLite$1 \ + com.google.protobuf.ExtensionSchemas \ + com.google.protobuf.Field \ + com.google.protobuf.Field$1 \ + com.google.protobuf.Field$Builder \ + com.google.protobuf.Field$Cardinality \ + com.google.protobuf.Field$Cardinality$1 \ + com.google.protobuf.Field$Kind \ + com.google.protobuf.Field$Kind$1 \ + com.google.protobuf.FieldInfo \ + com.google.protobuf.FieldInfo$1 \ + com.google.protobuf.FieldInfo$Builder \ + com.google.protobuf.FieldMask \ + com.google.protobuf.FieldMask$1 \ + com.google.protobuf.FieldMask$Builder \ + com.google.protobuf.FieldMaskOrBuilder \ + com.google.protobuf.FieldMaskProto \ + com.google.protobuf.FieldOrBuilder \ + com.google.protobuf.FieldSet \ + com.google.protobuf.FieldSet$1 \ + com.google.protobuf.FieldSet$Builder \ + com.google.protobuf.FieldSet$FieldDescriptorLite \ + com.google.protobuf.FieldType \ + com.google.protobuf.FieldType$1 \ + com.google.protobuf.FieldType$Collection \ + com.google.protobuf.FloatArrayList \ + com.google.protobuf.FloatValue \ + com.google.protobuf.FloatValue$1 \ + com.google.protobuf.FloatValue$Builder \ + com.google.protobuf.FloatValueOrBuilder \ + com.google.protobuf.GeneratedMessageInfoFactory \ + com.google.protobuf.GeneratedMessageLite \ + com.google.protobuf.GeneratedMessageLite$1 \ + com.google.protobuf.GeneratedMessageLite$Builder \ + com.google.protobuf.GeneratedMessageLite$DefaultInstanceBasedParser \ + com.google.protobuf.GeneratedMessageLite$ExtendableBuilder \ + com.google.protobuf.GeneratedMessageLite$ExtendableMessage \ + com.google.protobuf.GeneratedMessageLite$ExtendableMessage$ExtensionWriter \ + com.google.protobuf.GeneratedMessageLite$ExtendableMessageOrBuilder \ + com.google.protobuf.GeneratedMessageLite$ExtensionDescriptor \ + com.google.protobuf.GeneratedMessageLite$GeneratedExtension \ + com.google.protobuf.GeneratedMessageLite$MethodToInvoke \ + com.google.protobuf.GeneratedMessageLite$SerializedForm \ + com.google.protobuf.Int32Value \ + com.google.protobuf.Int32Value$1 \ + com.google.protobuf.Int32Value$Builder \ + com.google.protobuf.Int32ValueOrBuilder \ + com.google.protobuf.Int64Value \ + com.google.protobuf.Int64Value$1 \ + com.google.protobuf.Int64Value$Builder \ + com.google.protobuf.Int64ValueOrBuilder \ + com.google.protobuf.IntArrayList \ + com.google.protobuf.Internal \ + com.google.protobuf.Internal$BooleanList \ + com.google.protobuf.Internal$DoubleList \ + com.google.protobuf.Internal$EnumLite \ + com.google.protobuf.Internal$EnumLiteMap \ + com.google.protobuf.Internal$EnumVerifier \ + com.google.protobuf.Internal$FloatList \ + com.google.protobuf.Internal$IntList \ + com.google.protobuf.Internal$ListAdapter \ + com.google.protobuf.Internal$ListAdapter$Converter \ + com.google.protobuf.Internal$LongList \ + com.google.protobuf.Internal$MapAdapter \ + com.google.protobuf.Internal$MapAdapter$1 \ + com.google.protobuf.Internal$MapAdapter$Converter \ + com.google.protobuf.Internal$MapAdapter$EntryAdapter \ + com.google.protobuf.Internal$MapAdapter$IteratorAdapter \ + com.google.protobuf.Internal$MapAdapter$SetAdapter \ + com.google.protobuf.Internal$ProtobufList \ + com.google.protobuf.InvalidProtocolBufferException \ + com.google.protobuf.InvalidProtocolBufferException$InvalidWireTypeException \ + com.google.protobuf.IterableByteBufferInputStream \ + com.google.protobuf.JavaType \ + com.google.protobuf.LazyField \ + com.google.protobuf.LazyField$1 \ + com.google.protobuf.LazyField$LazyEntry \ + com.google.protobuf.LazyField$LazyIterator \ + com.google.protobuf.LazyFieldLite \ + com.google.protobuf.LazyStringArrayList \ + com.google.protobuf.LazyStringArrayList$ByteArrayListView \ + com.google.protobuf.LazyStringArrayList$ByteStringListView \ + com.google.protobuf.LazyStringList \ + com.google.protobuf.ListFieldSchema \ + com.google.protobuf.ListFieldSchema$1 \ + com.google.protobuf.ListFieldSchema$ListFieldSchemaFull \ + com.google.protobuf.ListFieldSchema$ListFieldSchemaLite \ + com.google.protobuf.ListValue \ + com.google.protobuf.ListValue$1 \ + com.google.protobuf.ListValue$Builder \ + com.google.protobuf.ListValueOrBuilder \ + com.google.protobuf.LongArrayList \ + com.google.protobuf.ManifestSchemaFactory \ + com.google.protobuf.ManifestSchemaFactory$1 \ + com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory \ + com.google.protobuf.MapEntryLite \ + com.google.protobuf.MapEntryLite$1 \ + com.google.protobuf.MapEntryLite$Metadata \ + com.google.protobuf.MapFieldLite \ + com.google.protobuf.MapFieldSchema \ + com.google.protobuf.MapFieldSchemaLite \ + com.google.protobuf.MapFieldSchemas \ + com.google.protobuf.MessageInfo \ + com.google.protobuf.MessageInfoFactory \ + com.google.protobuf.MessageLite \ + com.google.protobuf.MessageLite$Builder \ + com.google.protobuf.MessageLiteOrBuilder \ + com.google.protobuf.MessageLiteToString \ + com.google.protobuf.MessageSchema \ + com.google.protobuf.MessageSchema$1 \ + com.google.protobuf.MessageSetSchema \ + com.google.protobuf.Method \ + com.google.protobuf.Method$1 \ + com.google.protobuf.Method$Builder \ + com.google.protobuf.MethodOrBuilder \ + com.google.protobuf.Mixin \ + com.google.protobuf.Mixin$1 \ + com.google.protobuf.Mixin$Builder \ + com.google.protobuf.MixinOrBuilder \ + com.google.protobuf.MutabilityOracle \ + com.google.protobuf.MutabilityOracle$1 \ + com.google.protobuf.NewInstanceSchema \ + com.google.protobuf.NewInstanceSchemaLite \ + com.google.protobuf.NewInstanceSchemas \ + com.google.protobuf.NioByteString \ + com.google.protobuf.NioByteString$1 \ + com.google.protobuf.NullValue \ + com.google.protobuf.NullValue$1 \ + com.google.protobuf.OneofInfo \ + com.google.protobuf.Option \ + com.google.protobuf.Option$1 \ + com.google.protobuf.Option$Builder \ + com.google.protobuf.OptionOrBuilder \ + com.google.protobuf.Parser \ + com.google.protobuf.PrimitiveNonBoxingCollection \ + com.google.protobuf.Protobuf \ + com.google.protobuf.ProtobufArrayList \ + com.google.protobuf.ProtobufLists \ + com.google.protobuf.ProtocolStringList \ + com.google.protobuf.ProtoSyntax \ + com.google.protobuf.RawMessageInfo \ + com.google.protobuf.Reader \ + com.google.protobuf.RopeByteString \ + com.google.protobuf.RopeByteString$1 \ + com.google.protobuf.RopeByteString$Balancer \ + com.google.protobuf.RopeByteString$PieceIterator \ + com.google.protobuf.RopeByteString$RopeInputStream \ + com.google.protobuf.Schema \ + com.google.protobuf.SchemaFactory \ + com.google.protobuf.SchemaUtil \ + com.google.protobuf.SmallSortedMap \ + com.google.protobuf.SmallSortedMap$1 \ + com.google.protobuf.SmallSortedMap$DescendingEntryIterator \ + com.google.protobuf.SmallSortedMap$DescendingEntrySet \ + com.google.protobuf.SmallSortedMap$EmptySet \ + com.google.protobuf.SmallSortedMap$EmptySet$1 \ + com.google.protobuf.SmallSortedMap$EmptySet$2 \ + com.google.protobuf.SmallSortedMap$Entry \ + com.google.protobuf.SmallSortedMap$EntryIterator \ + com.google.protobuf.SmallSortedMap$EntrySet \ + com.google.protobuf.SourceContext \ + com.google.protobuf.SourceContext$1 \ + com.google.protobuf.SourceContext$Builder \ + com.google.protobuf.SourceContextOrBuilder \ + com.google.protobuf.SourceContextProto \ + com.google.protobuf.StringValue \ + com.google.protobuf.StringValue$1 \ + com.google.protobuf.StringValue$Builder \ + com.google.protobuf.StringValueOrBuilder \ + com.google.protobuf.Struct \ + com.google.protobuf.Struct$1 \ + com.google.protobuf.Struct$Builder \ + com.google.protobuf.Struct$FieldsDefaultEntryHolder \ + com.google.protobuf.StructOrBuilder \ + com.google.protobuf.StructProto \ + com.google.protobuf.StructuralMessageInfo \ + com.google.protobuf.StructuralMessageInfo$Builder \ + com.google.protobuf.Syntax \ + com.google.protobuf.Syntax$1 \ + com.google.protobuf.TextFormatEscaper \ + com.google.protobuf.TextFormatEscaper$1 \ + com.google.protobuf.TextFormatEscaper$2 \ + com.google.protobuf.TextFormatEscaper$ByteSequence \ + com.google.protobuf.Timestamp \ + com.google.protobuf.Timestamp$1 \ + com.google.protobuf.Timestamp$Builder \ + com.google.protobuf.TimestampOrBuilder \ + com.google.protobuf.TimestampProto \ + com.google.protobuf.Type \ + com.google.protobuf.Type$1 \ + com.google.protobuf.Type$Builder \ + com.google.protobuf.TypeOrBuilder \ + com.google.protobuf.TypeProto \ + com.google.protobuf.UInt32Value \ + com.google.protobuf.UInt32Value$1 \ + com.google.protobuf.UInt32Value$Builder \ + com.google.protobuf.UInt32ValueOrBuilder \ + com.google.protobuf.UInt64Value \ + com.google.protobuf.UInt64Value$1 \ + com.google.protobuf.UInt64Value$Builder \ + com.google.protobuf.UInt64ValueOrBuilder \ + com.google.protobuf.UninitializedMessageException \ + com.google.protobuf.UnknownFieldSchema \ + com.google.protobuf.UnknownFieldSetLite \ + com.google.protobuf.UnknownFieldSetLiteSchema \ + com.google.protobuf.UnmodifiableLazyStringList \ + com.google.protobuf.UnmodifiableLazyStringList$1 \ + com.google.protobuf.UnmodifiableLazyStringList$2 \ + com.google.protobuf.UnsafeByteOperations \ + com.google.protobuf.UnsafeUtil \ + com.google.protobuf.UnsafeUtil$1 \ + com.google.protobuf.UnsafeUtil$Android32MemoryAccessor \ + com.google.protobuf.UnsafeUtil$Android64MemoryAccessor \ + com.google.protobuf.UnsafeUtil$JvmMemoryAccessor \ + com.google.protobuf.UnsafeUtil$MemoryAccessor \ + com.google.protobuf.Utf8 \ + com.google.protobuf.Utf8$DecodeUtil \ + com.google.protobuf.Utf8$Processor \ + com.google.protobuf.Utf8$SafeProcessor \ + com.google.protobuf.Utf8$UnpairedSurrogateException \ + com.google.protobuf.Utf8$UnsafeProcessor \ + com.google.protobuf.Value \ + com.google.protobuf.Value$1 \ + com.google.protobuf.Value$Builder \ + com.google.protobuf.Value$KindCase \ + com.google.protobuf.ValueOrBuilder \ + com.google.protobuf.WireFormat \ + com.google.protobuf.WireFormat$1 \ + com.google.protobuf.WireFormat$FieldType \ + com.google.protobuf.WireFormat$FieldType$1 \ + com.google.protobuf.WireFormat$FieldType$2 \ + com.google.protobuf.WireFormat$FieldType$3 \ + com.google.protobuf.WireFormat$FieldType$4 \ + com.google.protobuf.WireFormat$JavaType \ + com.google.protobuf.WireFormat$Utf8Validation \ + com.google.protobuf.WireFormat$Utf8Validation$1 \ + com.google.protobuf.WireFormat$Utf8Validation$2 \ + com.google.protobuf.WireFormat$Utf8Validation$3 \ + com.google.protobuf.WrappersProto \ + com.google.protobuf.Writer \ + com.google.protobuf.Writer$FieldOrder + +# tag:java-specific +JAVA_IGNORE_CLASSPATH_CLASH_VALUE=$JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE + +### @usage: JAVA_IGNORE_CLASSPATH_CLASH_FOR([classes]) +### Ignore classpath clash test fails for classes +macro JAVA_IGNORE_CLASSPATH_CLASH_FOR(Args...) { + SET_APPEND(JAVA_IGNORE_CLASSPATH_CLASH_VALUE $Args $JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE) +} + +# tag:python-specific +### @usage: PY_SRCS({| CYTHON_C} { | TOP_LEVEL | NAMESPACE ns} Files...) +### +### Build specified Python sources according to Arcadia binary Python build. Basically creates precompiled and source resources keyed with module paths. +### The resources eventually are linked into final program and can be accessed as regular Python modules. +### This custom loader linked into the program will add them to sys.meta_path. +### +### PY_SRCS also support .proto, .ev, .pyx and .swg files. The .proto and .ev are compiled to .py-code by protoc and than handled as usual .py files. +### .pyx and .swg lead to C/C++ Python extensions generation, that are automatically registered in Python as built-in modules. +### +### By default .pyx files are built as C++-extensions. Use CYTHON_C to build them as C (similar to BUILDWITH_CYTHON_C, but with the ability to specify namespace). +### +### __init__.py never required, but if present (and specified in PY_SRCS), it will be imported when you import package modules with __init__.py Oh. +### +### @example +### +### PY2_LIBRARY(mymodule) +### PY_SRCS(a.py sub/dir/b.py e.proto sub/dir/f.proto c.pyx sub/dir/d.pyx g.swg sub/dir/h.swg) +### END() +### +### PY_SRCS honors Python2 and Python3 differences and adjusts itself to Python version of a current module. +### PY_SRCS can be used in any Arcadia Python build modules like PY*_LIBRARY, PY*_PROGRAM, PY*TEST. +### PY_SRCS in LIBRARY or PROGRAM effectively converts these into PY2_LIBRARY and PY2_PROGRAM respectively. +### It is strongly advised to make this conversion explicit. Never use PY_SRCS in a LIBRARY if you plan to use it from external Python extension module. +### +### Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs/#modulipylibrarypy3libraryimakrospysrcs +macro PY_SRCS() { + DEFAULT(MODULE_TAG PY2) + DEFAULT(PYTHON2 yes) + DEFAULT(PYTHON3 no) +} + +# tag:python-specific +_ALL_PY_FILES= + +# tag:python-specific +macro _ALL_PY_SRCS2(TOP_LEVEL?"TOP_LEVEL":"", RECURSIVE?"/**":"", ONLY_TEST_FILES?"test_*.py":"*.py", ONLY_TEST_FILES2?"*_test.py":"***", NO_TEST_FILES?"**/test_*.py **/*_test.py":"", NAMESPACE[], REST[], REST2[], EAT_TAIL[]) { + _GLOB(_ALL_PY_FILES ${suf=${RECURSIVE}/${ONLY_TEST_FILES}:REST} ${suf=${RECURSIVE}/${ONLY_TEST_FILES2}:REST2} ${suf=${RECURSIVE}/ya.make:REST} EXCLUDE ya.make ${NO_TEST_FILES}) +} + +# tag:python-specific +### @usage: ALL_PY_SRCS([RECURSIVE] [NO_TEST_FILES] { | TOP_LEVEL | NAMESPACE ns} [Dirs...]) +### +### Puts all .py-files from given Dirs (relative to projects') into PY_SRCS of the current module. +### If Dirs is ommitted project directory is used +### +### `RECURSIVE` makes lookup recursive with resprect to Dirs +### `NO_TEST_FILES` excludes files `test_*.py` and `*_test.py` those are normally subject to `TEST_SRCS` +### `TOP_LEVEL` and `NAMESPACE` are forwarded to `PY_SRCS` +### +### Note: Only one such macro per module is allowed +### Note: Macro is designed to reject any ya.make files in Dirs except current one +### +### @see [PY_SRCS()](#macro_PY_SRCS) +macro ALL_PY_SRCS(TOP_LEVEL?"TOP_LEVEL":"", NAMESPACE="", RECURSIVE?"RECURSIVE":"", NO_TEST_FILES?"NO_TEST_FILES":"", Files...) { + _ALL_PY_SRCS2(${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} ${RECURSIVE} ${NO_TEST_FILES} REST .${pre=/:Files}) + PY_SRCS(_MR ${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} $_ALL_PY_FILES) +} + +# tag:python-specific +### @usage: ALL_PYTEST_SRCS([RECURSIVE] [Dirs...]) +### +### Puts all .py-files from given Dirs (relative to projects') into TEST_SRCS of the current module. +### If Dirs is omitted project directory is used +### +### `RECURSIVE` makes lookup recursive with respect to Dirs +### `ONLY_TEST_FILES` includes only files `test_*.py` and `*_test.py`, others are normally subject to `PY_SRCS` +### +### Note: Only one such macro per module is allowed +### Note: Macro is designed to reject any ya.make files in Dirs except current one +### +### @see [TEST_SRCS()](#macro_TEST_SRCS) +macro ALL_PYTEST_SRCS(TOP_LEVEL?"TOP_LEVEL":"", NAMESPACE="", RECURSIVE?"RECURSIVE":"", ONLY_TEST_FILES?"ONLY_TEST_FILES ONLY_TEST_FILES2 REST2":"EAT_TAIL", Files...) { + _ALL_PY_SRCS2(${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} ${RECURSIVE} REST .${pre=/:Files} ${ONLY_TEST_FILES} .${pre=/:Files}) + TEST_SRCS(_MR $_ALL_PY_FILES) +} + +# tag:python-specific +_PY_EXTRA_LINT_FILES_VALUE= +### @usage: PY_EXTRA_LINT_FILES(files...) +### +### Add extra Python files for linting. This macro allows adding +### Python files which has no .py extension. +macro PY_EXTRA_LINT_FILES(FILES...) { + SET_APPEND(_PY_EXTRA_LINT_FILES_VALUE $FILES) +} + +# tag:python-specific +### @usage: PY23_LIBRARY([name]) +### +### Build PY2_LIBRARY or PY3_LIBRARY depending on incoming PEERDIR. +### Direct build or build by RECURSE creates both variants. +### This multimodule doesn't define any final targets, so use from DEPENDS or BUNDLE is not allowed. +### +### Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs +multimodule PY23_LIBRARY { + module PY2: PY2_LIBRARY { + .RESTRICTED=RUN_ANTLR4_PYTHON + OBJ_SUF=.py2 + } + module PY3: PY3_LIBRARY { + .RESTRICTED=RUN_ANTLR4_PYTHON + RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=py3 + } + otherwise { + MODULE_PREFIX=libpy3 + } + OBJ_SUF=.py3 + } +} + +# tag:python-specific +### @usage: PY23_NATIVE_LIBRARY([name]) +### +### Build LIBRARY compatible with either Python 2.x or Python 3.x depending on incoming PEERDIR. +### +### This multimodule doesn't depend on Arcadia Python binary build. It is intended only for C++ code and cannot contain PY_SRCS and USE_PYTHON2 macros. +### Use these multimodule instead of PY23_LIBRARY if the C++ extension defined in it will be used in PY2MODULE. +### While it doesn't bring Arcadia Python dependency itself, it is still compatible with Arcadia Python build and can be PEERDIR-ed from PY2_LIBRARY and alikes. +### Proper version will be selected according to Python version of the module PEERDIR comes from. +### +### This mulrtimodule doesn't define any final targets so cannot be used from DEPENDS or BUNDLE macros. +### +### For more information read https://wiki.yandex-team.ru/arcadia/python/pysrcs/#pysrcssrcsipy23nativelibrary +### +### @see [LIBRARY()](#module_LIBRARY), [PY2MODULE()](#module_PY2MODULE) +multimodule PY23_NATIVE_LIBRARY { + module PY2: LIBRARY { + .RESTRICTED=PY_SRCS USE_PYTHON2 USE_PYTHON3 PYTHON3_ADDINCL RUN_ANTLR4_PYTHON + OBJ_SUF=.py2 + PYTHON2_ADDINCL() + SET(MODULE_LANG PY2) + } + module PY3: LIBRARY { + .RESTRICTED=PY_SRCS USE_PYTHON2 USE_PYTHON3 RUN_ANTLR4_PYTHON + .ALIASES=PYTHON2_ADDINCL=PYTHON3_ADDINCL + .SEM=CPP_LIBRARY_SEM + .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM + PYTHON3_ADDINCL() + SET(MODULE_LANG PY3) + when ($MSVC == "yes" || $CYGWIN == "yes") { + MODULE_PREFIX=py3c + } + otherwise { + MODULE_PREFIX=libpy3c + } + OBJ_SUF=.py3 + } +} + +IBTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool +# tag:src-processing +STORYBOARD_FLAGS=--errors --warnings --notices --auto-activate-custom-fonts --output-format human-readable-text +macro _SRC("storyboard", SRC, SRCFLAGS...) { + .CMD=$IBTOOL_PATH $STORYBOARD_FLAGS --module $REALPRJNAME --output-partial-info-plist ${output;suf=.partial_plist:SRC} --compilation-directory $BINDIR ${input:SRC} && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.compiled_storyboard_tar:SRC} $BINDIR/${nopath;suf=c:SRC} $BINDIR/${nopath;suf=c:SRC} +} + +# tag:src-processing +macro _SRC("xib", SRC, SRCFLAGS...) { + .CMD=$IBTOOL_PATH $STORYBOARD_FLAGS --module $REALPRJNAME --output-partial-info-plist ${output;suf=.partial_plist:SRC} --compile ${output;tobindir;nopath;noext;suf=.nib:SRC} ${input:SRC} +} + +ACTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool +# tag:ios-specific +ASSETS_FLAGS=--output-format human-readable-text --notices --warnings +macro _IOS_ASSETS(AssetsDir, Content...) { + .CMD=$FS_TOOLS md $BINDIR/$REALPRJNAME && $ACTOOL_PATH $ASSETS_FLAGS --export-dependency-info $BINDIR/assetcatalog_dependencies --output-partial-info-plist ${output:"assetcatalog_generated_info.partial_plist"} --product-type com.apple.product-type.application --compile $BINDIR/$REALPRJNAME $AssetsDir ${input;hide:Content} && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;suf=_assetes.resource_tar:REALPRJNAME} $REALPRJNAME $REALPRJNAME +} + +# tag:ios-specific +macro IOS_APP_COMMON_FLAGS(Flags...) { + SET_APPEND(STORYBOARD_FLAGS $Flags) + SET_APPEND(ASSETS_FLAGS $Flags) +} + +# tag:ios-specific +macro IOS_APP_ASSETS_FLAGS(Flags...) { + SET_APPEND(ASSETS_FLAGS $Flags) +} + +macro DARWIN_STRINGS_RESOURCE(Resource, Relpath) { + .CMD=$COPY_CMD ${input:Resource} $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.strings_tar:Relpath} $BINDIR/$Relpath $BINDIR +} + +macro DARWIN_SIGNED_RESOURCE(Resource, Relpath) { + .CMD=$COPY_CMD $Resource $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.signed_resource_tar:Relpath} $BINDIR/$Relpath $BINDIR +} + +# tag:ios-specific +DELIM=__DELIM__ +PACK_IOS_ARCHIVE=$GENERATE_MF && $YMAKE_PYTHON ${input:"build/scripts/ios_wrapper.py"} bin $IBTOOL_PATH $TARGET $REALPRJNAME $BINDIR $DELIM $AUTO_INPUT $DELIM $STORYBOARD_FLAGS +### @usage: IOS_INTERFACE() +### iOS GUI module definition +module IOS_INTERFACE: _BARE_UNIT { + .CMD=PACK_IOS_ARCHIVE + .EXTS=.compiled_storyboard_tar .partial_plist .plist .xcent .nib .resource_tar .signed_resource_tar .strings_tar .plist_json + .NODE_TYPE=Library + .FINAL_TARGET=no + SET(MODULE_SUFFIX .ios.interface) + + PEERDIR+=build/platform/xcode/tools +} + +# tag:ios-specific +module DEFAULT_IOS_INTERFACE: IOS_INTERFACE { + SET(MODULE_SUFFIX .default.ios.interface) +} + +DEFAULT_IOS_TYPE= +IOS_TYPE= +when(!$IOS_TYPE) { + when($DEFAULT_IOS_TYPE) { + IOS_TYPE=$DEFAULT_IOS_TYPE + } + otherwise { + IOS_TYPE=com.apple.CoreSimulator.SimDeviceType.iPhone-X + } +} +DEFAULT_IOS_RUNTIME= +IOS_RUNTIME= +when(!$IOS_RUNTIME) { + when($DEFAULT_IOS_RUNTIME) { + IOS_RUNTIME=$DEFAULT_IOS_RUNTIME + } + otherwise { + IOS_RUNTIME=com.apple.CoreSimulator.SimRuntime.iOS-12-1 + } +} +when ($ARCH_I386) { + TEST_IOS_DEVICE_TYPE_VALUE=com.apple.CoreSimulator.SimDeviceType.iPhone-5 + TEST_IOS_RUNTIME_TYPE_VALUE=com.apple.CoreSimulator.SimRuntime.iOS-10-3 +} +otherwise { + TEST_IOS_DEVICE_TYPE_VALUE=$IOS_TYPE + TEST_IOS_RUNTIME_TYPE_VALUE=$IOS_RUNTIME +} + +# tag:java-specific +### @usage: JDK_VERSION(Version) +### +### Specify JDK version for module +macro JDK_VERSION(Arg) { + .SEM=required_jdk $Arg ${output;hide:"JdkVersionFakeProp.java"} + SET(JDK_REAL_VERSION $Arg) + _JDK_VERSION_MACRO_CHECK($Arg) +} + +# tag:java-specific +when ($JDK_REAL_VERSION == "10") { + JDK10=yes # remove this later +} +JAVA_PROGRAM_CP_USE_COMMAND_FILE=yes +when ($JDK_REAL_VERSION == "8") { + JAVA_PROGRAM_CP_USE_COMMAND_FILE=no +} + +# tag:kotlin-specific +KOTLIN_JVM_TARGET= +when ($JDK_REAL_VERSION == "8") { + KOTLIN_JVM_TARGET=1.8 +} +elsewhen ($JDK_REAL_VERSION == "20") { + # remove when kotlin starts supporting jdk20 bytecode + # see also devtools/ya/jbuild/gen/actions/idea.py + KOTLIN_JVM_TARGET=19 +} +otherwise { + KOTLIN_JVM_TARGET=$JDK_REAL_VERSION +} + +# tag:frontend-specific +### @usage: COLLECT_FRONTEND_FILES(Varname, Dir) +### +### Recursively collect files with typical frontend extensions from Dir and save the result into variable Varname +macro COLLECT_FRONTEND_FILES(Varname, Dir) { + _GLOB($Varname $Dir/**/*.(css|ejs|jpg|js|jsx|png|styl|svg|ts|tsx|json|html)) +} + +# tag:java-specific +# local jdk and tools +USE_SYSTEM_JDK= +USE_SYSTEM_UBERJAR= +USE_SYSTEM_ERROR_PRONE= + +# tag:swift-specific +CPP_XCODE_TOOLCHAIN_VERSION=9.2 +SWIFT_XCODE_TOOLCHAIN_VERSION=9.2 +XCODE_TOOLS_VERSION=10.1 +macro COMPILE_SWIFT_MODULE(SRCS{input}[], BRIDGE_HEADER{input}="", Flags...) { + when ($BRIDGE_HEADER != "") { + SWIFT_BRIDGE_HEADER=-import-objc-header ${input:BRIDGE_HEADER} + } + otherwise { + SWIFT_BRIDGE_HEADER= + } + + .PEERDIR+=build/platform/xcode/swift + # swift core libraries + LDFLAGS($SWIFT_LD_FLAGS) + + .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_swiftc_output_map.py"} $(SOURCE_ROOT) $(BUILD_ROOT) $BINDIR/swift_output_map.json ${input:SRCS} && $SWIFT_COMPILER -c $SWIFT_FLAGS_PLATFORM $Flags $SWIFT_BRIDGE_HEADER ${pre=-Xcc -I:_C__INCLUDE} ${input:SRCS} -emit-objc-header -emit-objc-header-path ${output;suf=-Swift.h:REALPRJNAME} -emit-module -module-name $REALPRJNAME -output-file-map $BINDIR/swift_output_map.json ${output;hide;suf=.o:SRCS} +} + +TEST_TOOL_HOST_LOCAL= +TEST_TOOL_TARGET_LOCAL= + +when ($MOST_USED_CUDA) { + CUDA_VERSION=11.4 + CUDNN_VERSION=8.0.5 + TENSORRT_VERSION=7 +} + +when ($TENSORFLOW_WITH_CUDA) { + CUDA_REQUIRED=yes +} + +when (!$TENSORRT_VERSION) { + TENSORRT_VERSION=5 +} + +ANDROID_APK_TEST_ACTIVITY_VALUE=com.yandex.test.unittests/.RunTestsActivity + +MAVEN_BIN=$MAVEN_RESOURCE_GLOBAL/bin/mvn + +when ($QT_REQUIRED) { + QT_BIN=${HOST_QT_RESOURCE_GLOBAL}/bin +} +when ($OPENGL_REQUIRED) { + OPENGL_VERSION=18.0.5 +} + +# tag:python-specific +multimodule PY23_TEST { + module PY2 : PYTEST_BIN { + .RESTRICTED=RUN_ANTLR4_PYTHON + MODULE_PREFIX=py2_ + OBJ_SUF=.py2 + CANONIZE_SUB_PATH=py2test + RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT + } + module PY3TEST_PROGRAM: PY3TEST_BIN { + .FINAL_TARGET=yes + .RESTRICTED=RUN_ANTLR4_PYTHON + OBJ_SUF=.py3 + CANONIZE_SUB_PATH=py3test + RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT + } + + module PY3TEST_LIBRARY: PY3_LIBRARY { + .RESTRICTED=RUN_ANTLR4_PYTHON + PEERDIR+=library/python/pytest + _REQUIRE_EXPLICIT_LICENSE() + RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT + } +} + +# tag:windows-specific +WINDOWS_MANIFEST= +macro WINDOWS_MANIFEST(Manifest) { + SET(WINDOWS_MANIFEST $Manifest) +} + +# https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later +macro WINDOWS_LONG_PATH_MANIFEST() { + SET(WINDOWS_MANIFEST build/long-path.manifest) +} + +# tag:windows-specific +when ($MSVC == "yes" && $WINDOWS_MANIFEST) { + LDFLAGS+=/MANIFEST:EMBED /MANIFESTINPUT:${input:WINDOWS_MANIFEST} +} + +# tag:cpp-specific +_VISIBILITY_LEVEL= +### @usage: VISIBILITY(level) +### +### This macro sets visibility level for symbols compiled for the current module. 'level' +### may take only one of the following values: DEFAULT, HIDDEN. +macro VISIBILITY(LEVEL) { + SET(_VISIBILITY_LEVEL ${LEVEL}) + select ($LEVEL) { + "DEFAULT" | "HIDDEN" ? { + } + default ? { + _OK = no + } + } + ASSERT(_OK Unsupported value [$LEVEL] passed to VISIBILITY macro, expected values are DEFAULT, HIDDEN.) +} + +# tag:cpp-specific +_CFLAGS_VISIBILITY= +when ($_VISIBILITY_LEVEL != "" && $IGNORE_VISIBILITY != "yes") { + when ($CLANG == "yes" || $GCC == "yes") { + _CFLAGS_VISIBILITY=-fvisibility=${tolower:_VISIBILITY_LEVEL} + } +} +CFLAGS+=$_CFLAGS_VISIBILITY + +# tag:cpp-specific +macro SDBUS_CPP_ADAPTOR(File) { + .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --adaptor=${output;nopath;noext:File.adaptor.h} ${input:File} + .PEERDIR=contrib/libs/sdbus-cpp +} + +# tag:cpp-specific +macro SDBUS_CPP_PROXY(File) { + .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --proxy=${output;nopath;noext:File.proxy.h} ${input:File} + .PEERDIR=contrib/libs/sdbus-cpp +} + + +# tag:python-specific +macro _PY_SSQLS_SRC(EXT, SRC, SRCFLAGS...) { + #generic macro +} + +# tag:python-specific +macro _PY_SSQLS_SRC("ssqls", SRC, SRCFLAGS...) { + .CMD=${tool:"metrika/core/tools/ssqls"} ${input;notransformbuilddir:SRC} -S $ARCADIA_ROOT -B $ARCADIA_BUILD_ROOT -L "python" -D $MODDIR $SRCFLAGS ${output;tobindir;noext;hide;pre=autogenerated/$MODDIR/:SRC.py} +} + +# tag:python-specific +macro _PY_SSQLS_SRCS(Srcs...) { + foreach(Src: $Srcs) { + _PY_SSQLS_SRC(${lastext:Src} $Src) + } +} + +# tag:python-specific +macro PY_SSQLS_SRCS(Srcs...) { + _PY_SSQLS_SRCS(KEEP_DIR_STRUCT $Srcs) + PY_SRCS(${noext;pre=autogenerated/$MODDIR/:Srcs.py}) +} + +# tag:python-specific +macro _PY_ENUM_SERIALIZATION_TO_JSON(File) { + .CMD=$ENUM_PARSER_TOOL ${input:File} --output ${output;noext;suf=.generated.h:File} --json-output ${output;noext:File.json} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"} +} + +# tag:python-specific +macro _PY_ENUM_SERIALIZATION_TO_PY(File) { + .CMD=${tool:"metrika/core/tools/python_enum_generator"} ${input;noext:File.json} -D ${MODDIR} --output ${output;noext:File.py} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"} +} + +# tag:metrika +multimodule SSQLS_LIBRARY { + module CPP_SSQLS : LIBRARY { + .ALIASES=ENUMS_SERIALIZATION=CPP_ENUMS_SERIALIZATION + SET(PEERDIR_TAGS CPP_SSQLS) + PEERDIR(metrika/core/libs/appmetrica/types metrika/core/libs/types) + ADDINCL(GLOBAL ${ARCADIA_BUILD_ROOT}/metrika/core/common_tables/include) + } + module PY3_SSQLS : PY3_LIBRARY { + .ALIASES=SRCS=PY_SSQLS_SRCS ENUMS_SERIALIZATION=PY_ENUMS_SERIALIZATION + SET(PEERDIR_TAGS PY3 PY3_SSQLS) + } +} + +macro NGINX_MODULES(Modules...) { + PEERDIR(${Modules}) + RUN_PROGRAM(nginx/module_gen ${Modules} CWD ${ARCADIA_ROOT} IN ${suf=/modules.json:Modules} OUTPUT_INCLUDES contrib/nginx/core/src/core/ngx_config.h contrib/nginx/core/src/core/ngx_core.h STDOUT ngx_modules.c) +} + +# tag:external-build +CONTAINER_LAYER_CMD=$YMAKE_PYTHON ${input:"build/scripts/make_container_layer.py"} -s $SQUASHFS_RESOURCE_GLOBAL -o $TARGET $AUTO_INPUT ${cwd:ARCADIA_BUILD_ROOT} ${kv;hide:"p CL"} ${kv;hide:"pc blue"} +CONTAINER_CMD=$YMAKE_PYTHON ${input:"build/scripts/make_container.py"} -s $SQUASHFS_RESOURCE_GLOBAL -o $TARGET ${rootrel:PEERS} ${cwd:ARCADIA_BUILD_ROOT} ${kv;hide:"p CN"} ${kv;hide:"pc blue"} + +# tag:external-build +module CONTAINER_LAYER: _BARE_UNIT { + .CMD=CONTAINER_LAYER_CMD + PEERDIR(build/external_resources/squashfs_tools) + + MODULE_SUFFIX=.container_layer + CHECK_ALLOWED_PATH() + CHECK_DEPENDENT_DIRS(ALLOW_ONLY PEERDIRS base_layers build/external_resources/squashfs_tools build/platform/python/ymake_python3 junk) +} + +# tag:external-build +module CONTAINER: _BARE_UNIT { + .NODE_TYPE=Bundle + .PEERDIR_POLICY=as_build_from + .FINAL_TARGET=yes + .CMD=CONTAINER_CMD + PEERDIR(build/external_resources/squashfs_tools) + PEERDIR(devtools/contrib/cake/entry) +} + +# tag:external-build +CUSTOM_BUILD_LIBRARY_USE= +CUSTOM_BUILD_LIBRARY_CMD=$GENERATE_MF && ${tool:"devtools/experimental/solar/outbuild/runner"} ${hide:PEERS} --script=${input:CUSTOM_SCRIPT} --output $TARGET --python=${tool:"contrib/tools/python3"} --isolator=${tool:"devtools/experimental/solar/outbuild/isolator"} $CUSTOM_BUILD_LIBRARY_USE + +# tag:external-build +module CUSTOM_BUILD_LIBRARY: LIBRARY { + .NODE_TYPE=Bundle + .PEERDIR_POLICY=as_build_from + .PROXY=yes + .CMD=CUSTOM_BUILD_LIBRARY_CMD + DISABLE(NEED_ADD_FAKE_SRC) +} + +### @usage: ORIGINAL_SOURCE(Source) +### +### This macro specifies the source repository for contrib +### Does nothing now (just a placeholder for future functionality) +### See https://st.yandex-team.ru/DTCC-316 +macro ORIGINAL_SOURCE(Source) { + ENABLE(UNUSED_MACRO) +} + +# tag:licence +CREDITS_FILE_EXTRA_EXT= +CREDITS_FLAGS= +CREDITS_TEXTS_FILE= +NO_CREDITS_TEXTS_FILE= +WITH_CREDITS= +### @usage: LICENSE_TEXTS(File) +### +### This macro specifies the filename with all library licenses texts +macro LICENSE_TEXTS(Source) { + SET(CREDITS_TEXTS_FILE $Source) +} + +# tag:licence +### @usage: WITHOUT_LICENSE_TEXTS() +### +### This macro indicates that the module has no license text +macro WITHOUT_LICENSE_TEXTS() { + ENABLE(NO_CREDITS_TEXTS_FILE) +} + +# tag:licence +when ($WITH_CREDITS) { + CREDITS_FLAGS+=--credits-output ${output;suf=${CREDITS_FILE_EXTRA_EXT}".CREDITS.txt":REALPRJNAME} +} + +GENERATE_MF= +when ($WITH_CREDITS) { + GENERATE_MF=$GENERATE_MF_CMD +} + +macro _MCU_CONVERT(Bin) { + .CMD=${cwd:BINDIR} $OBJCOPY_TOOL -O ihex $Bin ${output;noext:Bin.hex} && ${cwd:BINDIR} $OBJCOPY_TOOL -O srec $Bin ${output;noext:Bin.s37} && ${cwd:BINDIR} $OBJCOPY_TOOL -O binary $Bin ${output;noext:Bin.bin} +} + +MCU_LINK_EXE=$LINK_EXE && $_MCU_CONVERT($MODULE_PREFIX$REALPRJNAME) + +### @usage: MCU_PROGRAM([progname]) +### +### Program module for microcontrollers. Converts ELF to Intel HEX, Motorola S-record and raw binary file formats. +### If name is not specified it will be generated from the name of the containing project directory. +module MCU_PROGRAM: PROGRAM { + .CMD=MCU_LINK_EXE +} + +@import "${CONF_ROOT}/conf/project_specific/esp.conf" + +# tag:flags tag:internal tag:windows-specific +### @usage: _MSVC_FLAGS_WINDOWS_IMPL(target_platform compiler_flags) # internal +### +### Add CFLAGS when the firts argument is WINDOWS +macro _MSVC_FLAGS_WINDOWS_IMPL(WINDOWS[], FLAGS...) { + CFLAGS($WINDOWS) +} + +# tag:flags tag:windows-specific tag:cpp-specific +### @usage: MSVC_FLAGS([GLOBAL compiler_flag]* compiler_flags) +### +### Add the specified flags to the compilation line of C/C++files. +### Flags apply only if the compiler used is MSVC (cl.exe) +macro MSVC_FLAGS(FLAGS...) { + _MSVC_FLAGS_WINDOWS_IMPL($TARGET_PLATFORM $FLAGS) +} + +### @usage: COLLECT_YDB_API_SPECS_LEGACY(VarName Paths...) #deprecated +### +### This macro is ugly hack for legacy YDB go API codegen, any other uses are prohibited +macro COLLECT_YDB_API_SPECS_LEGACY(FILES_VAR, PATHS...) { + _GLOB($FILES_VAR ${suf=/*.proto:PATHS}) + RESTRICT_PATH(kikimr/public/sdk/go/ydb/api MSG This is ugly hack for legacy YDB go API codegen, any other uses are probibited) +} + +# tag:proto tag:apphost +### @usage: APPHOST() +### +### Emit APPHOST service code for all .proto files in a PROTO_LIBRARY. +### This works only for C++ and Java at the moment. +macro APPHOST() { + # C++ + CPP_PROTO_PLUGIN(cpp_plugin apphost/tools/stub_generator/cpp_plugin .apphost.h DEPS apphost/tools/stub_generator/cpp_includes) + + # Java + JAVA_PROTO_PLUGIN(java_plugin apphost/tools/stub_generator/java_plugin DEPS apphost/api/service/java/apphost) +} + +# tag:internal +### Add passed ya.conf.json and all bottle's formula external files to resources +### File MUST be arcadia root relative path (without "${ARCADIA_ROOT}/" prefix). +### NOTE: +### An external formula file referenced from ya.conf.json must be passed as an arcadia root relative path and +### should be located in any subdirectory of the ya.conf.json location ("build/" if we consider a production). +### The later restriction prevents problems in selectively checkouted arcadia. +macro YA_CONF_JSON(File) { + _YA_CONF_JSON($File) + SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$File) +} + + +# tag:internal +# Don't use directly - wrap with custom macros +macro ADD_LINTER_CHECK(CheckName, Linter, DEPENDS[], EXCLUDE[], FILES[], CONFIGS[]) { + SET(_FILES_VAR uniq_${hash:VAR_SALT}) + _GLOB($_FILES_VAR $FILES EXCLUDE $EXCLUDE) + _ADD_LINTER_CHECK($CheckName $Linter ${pre=DEPENDS :DEPENDS} FILES $$_FILES_VAR CONFIGS $CONFIGS) +} + +# tag:internal +# Draft. Don't use. +macro _CPP_STYLE(EXCLUDE[], Files...) { + ADD_LINTER_CHECK(cpp_style tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang12/tools/clang-format EXCLUDE $EXCLUDE FILES $Files CONFIGS devtools/ya/handlers/style/style_config) +} + +# tag:proto +macro ALICE_CAPABILITY() { + CPP_PROTO_PLUGIN(alice_capability_cpp yandex_io/tools/capability_gen .cap.h DEPS yandex_io/libs/protobuf_utils) + + JAVA_PROTO_PLUGIN(alice_capability_java alice/library/go/java_marker_interface_protoc_plugin DEPS alice/protos/endpoint/java_interface alice/megamind/protos/scenarios/java_interface) +} diff --git a/build/ymake_conf.py b/build/ymake_conf.py new file mode 100755 index 00000000000..5390ec16161 --- /dev/null +++ b/build/ymake_conf.py @@ -0,0 +1,2569 @@ +#!/usr/bin/env python +# coding=utf-8 + +from __future__ import print_function + +import base64 +import itertools +import json +import logging +import ntpath +import optparse +import os +import posixpath +import re +import subprocess +import sys +import tempfile + +import six + +logger = logging.getLogger(__name__ if __name__ != '__main__' else 'ymake_conf.py') + + +def init_logger(verbose): + logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO) + + +class DebugString(object): + def __init__(self, get_string_func): + self.get_string_func = get_string_func + + def __str__(self): + return self.get_string_func() + + +class ConfigureError(Exception): + pass + + +class Platform(object): + def __init__(self, name, os, arch): + """ + :type name: str + :type os: str + :type arch: str + """ + self.name = name + self.os = self._parse_os(os) + self.arch = arch.lower() + + self.is_i386 = self.arch in ('i386', 'x86') + self.is_i686 = self.arch == 'i686' + self.is_x86 = self.is_i386 or self.is_i686 + self.is_x86_64 = self.arch in ('x86_64', 'amd64') + self.is_intel = self.is_x86 or self.is_x86_64 + + self.is_armv7 = self.arch in ('armv7', 'armv7a', 'armv7ahf', 'armv7a_neon', 'arm', 'armv7a_cortex_a9', 'armv7ahf_cortex_a35', 'armv7ahf_cortex_a53') + self.is_armv8 = self.arch in ('armv8', 'armv8a', 'arm64', 'aarch64', 'armv8a_cortex_a35', 'armv8a_cortex_a53') + self.is_armv8m = self.arch in ('armv8m_cortex_m33',) + self.is_armv7em = self.arch in ('armv7em_cortex_m4', 'armv7em_cortex_m7') + self.is_arm64 = self.arch in ('arm64',) + self.is_arm = self.is_armv7 or self.is_armv8 or self.is_armv8m or self.is_armv7em + self.is_armv7_neon = self.arch in ('armv7a_neon', 'armv7ahf', 'armv7a_cortex_a9', 'armv7ahf_cortex_a35', 'armv7ahf_cortex_a53') + self.is_armv7hf = self.arch in ('armv7ahf', 'armv7ahf_cortex_a35', 'armv7ahf_cortex_a53') + + self.is_rv32imc = self.arch in ('riscv32_esp',) + self.is_riscv32 = self.is_rv32imc + + self.is_nds32 = self.arch in ('nds32le_elf_mculib_v5f',) + + self.is_xtensa = self.arch in ('xtensa_hifi5',) + + self.armv7_float_abi = None + if self.is_armv7: + if self.is_armv7hf: + self.armv7_float_abi = 'hard' + else: + self.armv7_float_abi = 'softfp' + + self.is_cortex_a9 = self.arch in ('armv7a_cortex_a9',) + self.is_cortex_a35 = self.arch in ('armv7ahf_cortex_a35', 'armv8a_cortex_a35') + self.is_cortex_a53 = self.arch in ('armv7ahf_cortex_a53', 'armv8a_cortex_a53') + self.is_cortex_m33 = self.arch in ('armv8m_cortex_m33',) + self.is_cortex_m4 = self.arch in ('armv7em_cortex_m4',) + self.is_cortex_m7 = self.arch in ('armv7em_cortex_m7') + + self.is_power8le = self.arch == 'ppc64le' + self.is_power9le = self.arch == 'power9le' + self.is_powerpc = self.is_power8le or self.is_power9le + + self.is_32_bit = self.is_x86 or self.is_armv7 or self.is_armv8m or self.is_riscv32 or self.is_nds32 or self.is_armv7em or self.is_xtensa + self.is_64_bit = self.is_x86_64 or self.is_armv8 or self.is_powerpc + + assert self.is_32_bit or self.is_64_bit + assert not (self.is_32_bit and self.is_64_bit) + + self.is_linux = self.os == 'linux' or 'yocto' in self.os + self.is_linux_x86_64 = self.is_linux and self.is_x86_64 + self.is_linux_armv8 = self.is_linux and self.is_armv8 + self.is_linux_armv7 = self.is_linux and self.is_armv7 + self.is_linux_power8le = self.is_linux and self.is_power8le + self.is_linux_power9le = self.is_linux and self.is_power9le + self.is_linux_powerpc = self.is_linux_power8le or self.is_linux_power9le + + self.is_macos = self.os == 'macos' + self.is_macos_x86_64 = self.is_macos and self.is_x86_64 + self.is_macos_arm64 = self.is_macos and self.is_arm64 + self.is_iossim = self.os == 'iossim' or (self.os == 'ios' and self.is_intel) + self.is_ios = self.os == 'ios' or self.is_iossim + self.is_apple = self.is_macos or self.is_ios + + self.is_windows = self.os == 'windows' + self.is_windows_x86_64 = self.is_windows and self.is_x86_64 + + self.is_android = self.os == 'android' + if self.is_android: + # This is default Android API level unless `-DANDROID_API` is specified in cmdline + default_android_api = 21 + self.android_api = int(preset('ANDROID_API', default_android_api)) + + self.is_cygwin = self.os == 'cygwin' + self.is_yocto = self.os == 'yocto' + + self.is_none = self.os == 'none' + + self.is_posix = self.is_linux or self.is_apple or self.is_android or self.is_cygwin or self.is_yocto + + @staticmethod + def from_json(data): + name = data.get('visible_name', data['toolchain']) + return Platform(name, os=data['os'], arch=data['arch']) + + @property + def os_variables(self): + # 'LINUX' variable, for backward compatibility + yield self.os.upper() + + # 'OS_LINUX' variable + yield 'OS_{}'.format(self.os.upper()) + + # yocto is linux + if 'yocto' in self.os: + yield 'LINUX' + yield 'OS_LINUX' + + if self.is_macos: + yield 'DARWIN' + yield 'OS_DARWIN' + if self.is_iossim: + yield 'IOS' + yield 'OS_IOS' + yield 'OS_IOSSIM' + + @property + def arch_variables(self): + return select_multiple(( + (self.is_i386 or self.is_i686, 'ARCH_I386'), + (self.is_i686, 'ARCH_I686'), + (self.is_x86_64, 'ARCH_X86_64'), + (self.is_armv7, 'ARCH_ARM7'), + (self.is_armv7_neon, 'ARCH_ARM7_NEON'), + (self.is_armv8, 'ARCH_ARM64'), + (self.is_armv8m, 'ARCH_ARM8M'), + (self.is_armv7em, 'ARCH_ARM7EM'), + (self.is_arm, 'ARCH_ARM'), + (self.is_linux_armv8 or self.is_macos_arm64, 'ARCH_AARCH64'), + (self.is_powerpc, 'ARCH_PPC64LE'), + (self.is_power8le, 'ARCH_POWER8LE'), + (self.is_power9le, 'ARCH_POWER9LE'), + (self.is_riscv32, 'ARCH_RISCV32'), + (self.is_xtensa, 'ARCH_XTENSA'), + (self.is_nds32, 'ARCH_NDS32'), + (self.is_32_bit, 'ARCH_TYPE_32'), + (self.is_64_bit, 'ARCH_TYPE_64'), + )) + + @property + def library_path_variables(self): + return ['LD_LIBRARY_PATH', 'DYLD_LIBRARY_PATH'] + + def find_in_dict(self, dict_, default=None): + if dict_ is None: + return default + for key in six.iterkeys(dict_): + if self._parse_os(key) == self.os: + return dict_[key] + return default + + @property + def os_compat(self): + if self.is_macos: + return 'DARWIN' + else: + return self.os.upper() + + @property + def canonized_platform(self): + os = None + if self.os == 'macos': + os = 'darwin' + elif self.os == 'windows': + os = 'win32' + else: + os = self.os + if self.arch != 'x86_64': + return '-'.join([os, self.arch]) + else: + return os + + def exe(self, *paths): + if self.is_windows: + return ntpath.join(*itertools.chain(paths[:-1], (paths[-1] + '.exe',))) + else: + return posixpath.join(*paths) + + def __str__(self): + return '{name}-{os}-{arch}'.format(name=self.name, os=self.os, arch=self.arch) + + def __eq__(self, other): + return (self.name, self.os, self.arch) == (other.name, other.os, other.arch) + + def __cmp__(self, other): + return cmp((self.name, self.os, self.arch), (other.name, other.os, other.arch)) + + def __hash__(self): + return hash((self.name, self.os, self.arch)) + + @staticmethod + def _parse_os(os): + os = os.lower() + + if os == 'darwin': + return 'macos' + if os in ('win', 'win32', 'win64'): + return 'windows' + if os.startswith('cygwin'): + return 'cygwin' + + return os + + +def which(prog): + if os.path.exists(prog) and os.access(prog, os.X_OK): + return prog + + # Ищем в $PATH только простые команды, без путей. + if os.path.dirname(prog) != '': + return None + + path = os.getenv('PATH', '') + + pathext = os.environ.get('PATHEXT') + # На Windows %PATHEXT% указывает на список расширений, которые нужно проверять + # при поиске команды в пути. Точное совпадение без расширения имеет приоритет. + pathext = [''] if pathext is None else [''] + pathext.lower().split(os.pathsep) + + for dir_ in path.split(os.path.pathsep): + for ext in pathext: + p = os.path.join(dir_, prog + ext) + if os.path.exists(p) and os.path.isfile(p) and os.access(p, os.X_OK): + return p + + return None + + +def get_stdout(command): + stdout, code = get_stdout_and_code(command) + return stdout if code == 0 else None + + +def get_stdout_and_code(command): + # noinspection PyBroadException + try: + process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, _ = process.communicate() + return stdout, process.returncode + except Exception as e: + logger.info("While run: `%s`", e) + return None, None + + +def to_strings(o): + if isinstance(o, (list, tuple)): + for s in o: + for ss in to_strings(s): + yield ss + else: + if o is not None: + if isinstance(o, bool): + yield 'yes' if o else 'no' + elif isinstance(o, (str, int)): + yield str(o) + else: + raise ConfigureError('Unexpected value {} {}'.format(type(o), o)) + + +def emit(key, *value): + print('{0}={1}'.format(key, ' '.join(to_strings(value)))) + + +def emit_with_comment(comment, key, *value): + print('# {}'.format(comment)) + emit(key, *value) + + +def emit_with_ignore_comment(key, *value): + emit_with_comment('IGNORE YMAKE CONF CONTEXT', key, *value) + + +def append(key, *value): + print('{0}+={1}'.format(key, ' '.join(to_strings(value)))) + + +def emit_big(text): + prefix = None + first = True + for line in text.split('\n'): + if prefix is None: + if not line: + continue + + prefix = 0 + while prefix < len(line) and line[prefix] == ' ': + prefix += 1 + + if first: # Be pretty, prepend an empty line before the output + print() + first = False + + print(line[prefix:]) + + +class Variables(dict): + def emit(self, with_ignore_comment=[]): + with_ignore_comment_set = set(with_ignore_comment) + for k in sorted(self.keys()): + if k in with_ignore_comment_set: + emit_with_ignore_comment(k, self[k]) + else: + emit(k, self[k]) + + def update_from_presets(self): + for k in six.iterkeys(self): + v = preset(k) + if v is not None: + self[k] = v + + def reset_if_any(self, value_check=None, reset_value=None): + if value_check is None: + def value_check(v_): + return v_ is None + + if any(map(value_check, six.itervalues(self))): + for k in six.iterkeys(self): + self[k] = reset_value + + +def format_env(env, list_separator=':'): + def format_value(value): + return value if isinstance(value, str) else ('\\' + list_separator).join(value) + + def format(kv): + return '${env:"%s=%s"}' % (kv[0], format_value(kv[1])) + + return ' '.join(map(format, sorted(six.iteritems(env)))) + + +# TODO(somov): Проверить, используется ли это. Может быть, выпилить. +def userify_presets(presets, keys): + for key in keys: + user_key = 'USER_{}'.format(key) + values = [presets.pop(key, None), presets.get(user_key)] + presets[user_key] = ' '.join(filter(None, values)) + + +def preset(key, default=None): + return opts().presets.get(key, default) + + +def is_positive(key): + return is_positive_str(preset(key, '')) + + +def is_positive_str(s): + return s.lower() in ('yes', 'true', 'on', '1') + + +def is_negative(key): + return is_negative_str(preset(key, '')) + + +def is_negative_str(s): + return s.lower() in ('no', 'false', 'off', '0') + + +def to_bool(s, default=None): + if isinstance(s, six.string_types): + if is_positive_str(s): + return True + if is_negative_str(s): + return False + if default is None: + raise ConfigureError('{} is not a bool value'.format(s)) + return default + + +def select(selectors, default=None, no_default=False): + for enabled, value in selectors: + if enabled: + return value + if no_default: + raise ConfigureError() + return default + + +def select_multiple(selectors): + for enabled, value in selectors: + if enabled: + yield value + + +def unique(it): + known = set() + for i in it: + if i not in known: + known.add(i) + yield i + + +class Options(object): + def __init__(self, argv): + def parse_presets(raw_presets): + presets = {} + for p in raw_presets: + toks = p.split('=', 1) + name = toks[0] + value = toks[1] if len(toks) >= 2 else '' + presets[name] = value + return presets + + parser = optparse.OptionParser(add_help_option=False) + opt_group = optparse.OptionGroup(parser, 'Conf script options') + opt_group.add_option('--toolchain-params', dest='toolchain_params', action='store', help='Set toolchain params via file') + opt_group.add_option('-D', '--preset', dest='presets', action='append', default=[], help='set or override presets') + opt_group.add_option('-l', '--local-distbuild', dest='local_distbuild', action='store_true', default=False, help='conf for local distbuild') + parser.add_option_group(opt_group) + + self.options, self.arguments = parser.parse_args(argv) + + argv = self.arguments + if len(argv) < 4: + print('Usage: ArcRoot, --BuildType--, Verbosity, [Path to local.ymake]', file=sys.stderr) + sys.exit(1) + + self.arcadia_root = argv[1] + init_logger(argv[3] == 'verbose') + + # Эти переменные не надо использоваться напрямую. Их значения уже разбираются в других местах. + self.build_type = argv[2].lower() + self.local_distbuild = self.options.local_distbuild + self.toolchain_params = self.options.toolchain_params + + self.presets = parse_presets(self.options.presets) + userify_presets(self.presets, ('CFLAGS', 'CXXFLAGS', 'CONLYFLAGS', 'LDFLAGS', 'GO_COMPILE_FLAGS', 'GO_LINK_FLAGS', 'USE_LOCAL_SWIG', 'SWIG_TOOL', 'SWIG_LIBRARY')) + + Instance = None + + +def opts(): + if Options.Instance is None: + Options.Instance = Options(sys.argv) + return Options.Instance + + +class Profiler(object): + Generic = 'generic' + GProf = 'gprof' + + +class Arcadia(object): + def __init__(self, root): + self.root = root + + +class Build(object): + def __init__(self, arcadia, build_type, toolchain_params, force_ignore_local_files=False): + self.arcadia = arcadia + self.params = self._load_json_from_base64(toolchain_params) + self.build_type = build_type + + platform = self.params['platform'] + self.host = Platform.from_json(platform['host']) + self.target = Platform.from_json(platform['target']) + + self.tc = self._get_toolchain_options() + + # TODO(somov): Удалить, когда перестанет использоваться. + self.build_system = 'ymake' + + self.ignore_local_files = False + + dist_prefix = 'dist-' + if self.build_type.startswith(dist_prefix): + self.build_system = 'distbuild' + self.build_type = self.build_type[len(dist_prefix):] + + if force_ignore_local_files: + self.ignore_local_files = True + + if self.is_ide_build_type(self.build_type): + self.ignore_local_files = True + + self.pic = not is_positive('FORCE_NO_PIC') + + @property + def host_target(self): + return self.host, self.target + + def print_build(self): + self._print_build_settings() + + host_os = System(self.host) + host_os.print_host_settings() + + target_os = System(self.target) + target_os.print_target_settings() + + if self.pic: + emit('PIC', 'yes') + + emit('COMPILER_ID', self.tc.type.upper()) + + if self.is_valgrind: + emit('WITH_VALGRIND', 'yes') + + if self.is_coverage: + emit('_BUILD_COVERAGE', 'yes') + + if self.is_debug: + emit('_BUILD_DEBUG', 'yes') + + if self.is_fast_debug: + emit('_BUILD_FAST_DEBUG', 'yes') + + if self.is_release: + emit('_BUILD_RELEASE', 'yes') + + if self.is_sanitized: + emit('_BUILD_SANITIZED', 'yes') + + if self.is_size_optimized: + emit('_BUILD_SIZE_OPTIMIZED', 'yes') + + if self.with_ndebug: + emit('_BUILD_WITH_NDEBUG', 'yes') + + toolchain_type, compiler_type, linker_type = Compilers[self.tc.type] + toolchain = toolchain_type(self.tc, self) + compiler = compiler_type(self.tc, self) + linker = linker_type(self.tc, self) + + toolchain.print_toolchain() + compiler.print_compiler() + linker.print_linker() + + self._print_other_settings(compiler) + + def _print_build_settings(self): + emit('BUILD_TYPE', self.build_type.upper()) + emit('BT_' + self.build_type.upper().replace('-', '_'), 'yes') + + if self.build_system == 'distbuild': + emit('DISTBUILD', 'yes') + elif self.build_system != 'ymake': + raise ConfigureError() + + python_bin = preset('BUILD_PYTHON_BIN', '$(PYTHON)/python') + + emit('YMAKE_PYTHON', python_bin) + emit('YMAKE_UNPICKLER', python_bin, '$ARCADIA_ROOT/build/plugins/_unpickler.py') + + @property + def is_release(self): + # TODO(somov): Проверить, бывают ли тут суффиксы на самом деле + return self.build_type in ('release', 'relwithdebinfo', 'minsizerel', 'profile', 'gprof') or self.build_type.endswith('-release') + + @property + def is_debug(self): + return self.build_type in ('debug', 'debugnoasserts', 'fastdebug') or self.build_type.endswith('-debug') + + @property + def is_fast_debug(self): + return self.build_type == 'fastdebug' + + @property + def is_size_optimized(self): + return self.build_type == 'minsizerel' + + @property + def is_coverage(self): + return self.build_type == 'coverage' + + @property + def is_sanitized(self): + sanitizer = preset('SANITIZER_TYPE') + return bool(sanitizer) and not is_negative_str(sanitizer) + + @property + def with_ndebug(self): + return self.build_type in ('release', 'minsizerel', 'valgrind-release', 'profile', 'gprof', 'debugnoasserts') + + @property + def is_valgrind(self): + return self.build_type == 'valgrind' or self.build_type == 'valgrind-release' + + @property + def is_ide(self): + return self.is_ide_build_type(self.build_type) + + @property + def profiler_type(self): + if self.build_type == 'profile': + return Profiler.Generic + elif self.build_type == 'gprof': + return Profiler.GProf + else: + return None + + @staticmethod + def is_ide_build_type(build_type): + return build_type == 'nobuild' + + def _configure_runtime_versions(self): + try: + res = subprocess.check_output(['xcrun', 'simctl', 'list', '--json', 'runtimes']) + except subprocess.CalledProcessError as exc: + logger.warning(exc) + return + raw_object = json.loads(res) + raw_object = raw_object['runtimes'] + for runtime in raw_object: + if runtime['isAvailable']: + if "iOS" in runtime['identifier']: + emit('DEFAULT_IOS_RUNTIME', '{}'.format(runtime['identifier'])) + + def _get_toolchain_options(self): + type_ = self.params['params']['type'] + + if self.params['params'].get('local') and type_ == 'xcode': + detector = CompilerDetector() + detector.detect(self.params['params']['c_compiler'], self.params['params']['cxx_compiler']) + emit('LOCAL_XCODE_TOOLS', 'yes') + emit('XCODE', 'yes') + emit('ACTOOL_PATH', self.params['params']['actool']) + emit('IBTOOL_PATH', self.params['params']['ibtool']) + self._configure_runtime_versions() + elif type_ == 'system_cxx': + detector = CompilerDetector() + detector.detect(self.params['params'].get('c_compiler'), self.params['params'].get('cxx_compiler')) + type_ = detector.type + else: + detector = None + + if type_ == 'msvc': + return MSVCToolchainOptions(self, detector) + else: + return GnuToolchainOptions(self, detector) + + def _print_other_settings(self, compiler): + host = self.host + + emit('USE_LOCAL_TOOLS', 'no' if self.ignore_local_files else 'yes') + + ragel = Ragel() + ragel.configure_toolchain(self, compiler) + ragel.print_variables() + + perl = Perl() + perl.configure_local() + perl.print_variables('LOCAL_') + + swiftc = SwiftCompiler(self) + swiftc.configure() + swiftc.print_compiler() + + if host.is_linux or host.is_macos or host.is_cygwin: + if is_negative('USE_ARCADIA_PYTHON'): + python = Python(self.tc) + python.configure_posix() + python.print_variables() + + cuda = Cuda(self) + cuda.print_() + CuDNN(cuda).print_() + + print_swig_config() + + if self.ignore_local_files or host.is_windows or is_positive('NO_SVN_DEPENDS'): + emit_with_ignore_comment('SVN_DEPENDS') + emit_with_ignore_comment('SVN_DEPENDS_CACHE__NO_UID__') + else: + def find_svn(): + for i in range(0, 3): + for path in (['.svn', 'wc.db'], ['.svn', 'entries'], ['.git', 'logs', 'HEAD']): + path_parts = [os.pardir] * i + path + full_path = os.path.join(self.arcadia.root, *path_parts) + # HACK(somov): No "normpath" here. ymake fails with the "source file name is outside the build tree" error + # when .svn/wc.db found in "trunk" instead of "arcadia". But $ARCADIA_ROOT/../.svn/wc.db is ok. + if os.path.exists(full_path): + out_path = os.path.join('${ARCADIA_ROOT}', *path_parts) + return '${input;hide:"%s"}' % out_path + + # Special processing for arc repository since .arc may be a symlink. + dot_arc = os.path.realpath(os.path.join(self.arcadia.root, '.arc')) + full_path = os.path.join(dot_arc, 'TREE') + if os.path.exists(full_path): + out_path = os.path.join('${ARCADIA_ROOT}', os.path.relpath(full_path, self.arcadia.root)) + return '${input;hide:"%s"}' % out_path + + return '' + + emit_with_ignore_comment('SVN_DEPENDS', find_svn()) + emit_with_ignore_comment('SVN_DEPENDS_CACHE__NO_UID__', '${hide;kv:"disable_cache"}') + + @staticmethod + def _load_json_from_base64(base64str): + """ + :rtype: dict[str, Any] + """ + + def un_unicode(o): + if isinstance(o, six.text_type): + return six.ensure_str(o) + if isinstance(o, list): + return [un_unicode(oo) for oo in o] + if isinstance(o, dict): + return {un_unicode(k): un_unicode(v) for k, v in six.iteritems(o)} + return o + + return un_unicode(json.loads(base64.b64decode(base64str))) + + +class YMake(object): + def __init__(self, arcadia): + self.arcadia = arcadia + + def print_presets(self): + presets = opts().presets + if is_positive_str(presets.get('EXPORT_GRADLE', 'no')): + print('@import "${CONF_ROOT}/conf/export_gradle.yes.conf"') + else: + print('@import "${CONF_ROOT}/conf/export_gradle.no.conf"') + + if presets.get('CLANG_COVERAGE', None) is None: + print('@import "${CONF_ROOT}/conf/coverage_full_instrumentation.conf"') + else: + print('@import "${CONF_ROOT}/conf/coverage_selective_instrumentation.conf"') + + if presets: + print('# Variables set from command line by -D options') + for key in sorted(presets): + if key in ('MY_YMAKE_BIN', 'REAL_YMAKE_BIN'): + emit_with_ignore_comment(key, opts().presets[key]) + else: + emit(key, opts().presets[key]) + + @staticmethod + def _print_conf_content(path): + with open(path, 'r') as fin: + print(fin.read()) + + def print_core_conf(self): + emit('YMAKE_YNDEXER_IGNORE_BUILD_ROOT', 'yes') + print('@import "${CONF_ROOT}/ymake.core.conf"') + + def print_settings(self): + emit_with_ignore_comment('ARCADIA_ROOT', self.arcadia.root) + + @staticmethod + def _find_conf(conf_file): + script_dir = os.path.dirname(__file__) + full_path = os.path.join(script_dir, conf_file) + if os.path.exists(full_path): + return full_path + return None + + def _find_core_conf(self): + return self._find_conf('ymake.core.conf') + + +class System(object): + def __init__(self, platform): + """ + :type platform: Platform + """ + self.platform = platform + + def print_windows_target_const(self): + # TODO(somov): Remove this variables, use generic OS/arch variables in makelists. + emit('WINDOWS', 'yes') + emit('WIN32', 'yes') + if self.platform.is_64_bit == 64: + emit('WIN64', 'yes') + + def print_nix_target_const(self): + emit('JAVA_INCLUDE', '-I{0}/include -I{0}/include/{1}'.format('/usr/lib/jvm/default-java', self.platform.os_compat)) + + emit('UNIX', 'yes') + emit('REALPRJNAME') + emit('SONAME') + + def print_target_settings(self): + emit('TARGET_PLATFORM', self.platform.os_compat) + emit('CANONIZED_TARGET_PLATFORM', self.platform.canonized_platform) + emit('HARDWARE_ARCH', '32' if self.platform.is_32_bit else '64') + emit('HARDWARE_TYPE', self.platform.arch) + + for variable in self.platform.arch_variables: + emit(variable, 'yes') + + for variable in self.platform.os_variables: + emit(variable, 'yes') + + if self.platform.is_armv7: + emit('ARM7_FLOAT_ABI', self.platform.armv7_float_abi) + + if self.platform.is_android: + emit('ANDROID_API', str(self.platform.android_api)) + + if self.platform.is_posix: + self.print_nix_target_const() + elif self.platform.is_windows: + self.print_windows_target_const() + + def print_host_settings(self): + emit('HOST_PLATFORM', self.platform.os_compat) + emit('CANONIZED_HOST_PLATFORM', self.platform.canonized_platform) + + for variable in itertools.chain(self.platform.os_variables, self.platform.arch_variables): + emit('HOST_{var}'.format(var=variable), 'yes') + + +class CompilerDetector(object): + def __init__(self): + self.type = None + self.c_compiler = None + self.cxx_compiler = None + self.version_list = None + + @staticmethod + def preprocess_source(compiler, source): + # noinspection PyBroadException + try: + fd, path = tempfile.mkstemp(suffix='.cpp') + try: + with os.fdopen(fd, 'w') as output: + output.write(source) + stdout, code = get_stdout_and_code([compiler, '-E', path]) + except Exception as e: + logger.info("While writing: `%s`", e) + finally: + os.remove(path) + return stdout, code + + except Exception as e: + logger.debug('Preprocessing failed: %s', e) + return None, None + + @staticmethod + def get_compiler_vars(compiler, names): + prefix = '____YA_VAR_' + source = '\n'.join(['{prefix}{name}={name}\n'.format(prefix=prefix, name=n) for n in names]) + + # Некоторые препроцессоры возвращают ненулевой код возврата. Поэтому его проверять нельзя. + # Мы можем только удостовериться после разбора stdout, что в нём + # присутствовала хотя бы одна подставленная переменная. + # TODO(somov): Исследовать, можно ли проверять ограниченный набор кодов возврата. + # TODO(v-korovin): Нормально прокидывать Exception-ы, оно и так упадёт + stdout, _ = CompilerDetector.preprocess_source(compiler, source) + + if stdout is None: + return None + + vars_ = {} + for line in six.ensure_str(stdout).split('\n'): + parts = line.split('=', 1) + if len(parts) == 2 and parts[0].startswith(prefix): + name, value = parts[0][len(prefix):], parts[1] + if value == name: + continue # Preprocessor variable was not substituted + vars_[name] = value + + return vars_ + + def detect(self, c_compiler=None, cxx_compiler=None): + c_compiler = c_compiler or os.environ.get('CC') + cxx_compiler = cxx_compiler or os.environ.get('CXX') or c_compiler + c_compiler = c_compiler or cxx_compiler + + logger.debug('e=%s', os.environ) + if c_compiler is None: + raise ConfigureError('Custom compiler was requested but not specified') + + c_compiler_path = which(c_compiler) + + clang_vars = ['__clang_major__', '__clang_minor__', '__clang_patchlevel__'] + gcc_vars = ['__GNUC__', '__GNUC_MINOR__', '__GNUC_PATCHLEVEL__'] + msvc_vars = ['_MSC_VER'] + apple_var = '__apple_build_version__' + + compiler_vars = self.get_compiler_vars(c_compiler_path, clang_vars + [apple_var] + gcc_vars + msvc_vars) + + if not compiler_vars: + raise ConfigureError('Could not determine custom compiler version: {}'.format(c_compiler)) + + def version(version_names): + def iter_version(): + for name in version_names: + yield int(compiler_vars[name]) + + # noinspection PyBroadException + try: + return list(iter_version()) + except Exception: + return None + + clang_version = version(clang_vars) + apple_build = apple_var in compiler_vars + # TODO(somov): Учитывать номера версий сборки Apple компилятора Clang. + _ = apple_build + gcc_version = version(gcc_vars) + msvc_version = version(msvc_vars) + + if clang_version: + logger.debug('Detected Clang version %s', clang_version) + self.type = 'clang' + elif gcc_version: + logger.debug('Detected GCC version %s', gcc_version) + # TODO(somov): Переименовать в gcc. + self.type = 'gnu' + elif msvc_version: + logger.debug('Detected MSVC version %s', msvc_version) + self.type = 'msvc' + else: + raise ConfigureError('Could not determine custom compiler type: {}'.format(c_compiler)) + + self.version_list = clang_version or gcc_version or msvc_version + + self.c_compiler = c_compiler_path + self.cxx_compiler = cxx_compiler and which(cxx_compiler) or c_compiler_path + + +class ToolchainOptions(object): + def __init__(self, build, detector): + """ + :type build: Build + """ + self.host = build.host + self.target = build.target + + tc_json = build.params + + logger.debug('Toolchain host %s', self.host) + logger.debug('Toolchain target %s', self.target) + logger.debug('Toolchain json %s', DebugString(lambda: json.dumps(tc_json, indent=4, sort_keys=True))) + + self.params = tc_json['params'] + self._name = tc_json.get('name', 'theyknow') + + if detector: + self.type = detector.type + self.from_arcadia = False + + self.c_compiler = detector.c_compiler + self.cxx_compiler = detector.cxx_compiler + self.compiler_version_list = detector.version_list + self.compiler_version = '.'.join(map(lambda part: six.ensure_str(str(part)), self.compiler_version_list)) + + else: + self.type = self.params['type'] + self.from_arcadia = True + + self.c_compiler = self.params['c_compiler'] + self.cxx_compiler = self.params['cxx_compiler'] + + # TODO(somov): Требовать номер версии всегда. + self.compiler_version = self.params.get('gcc_version') or self.params.get('version') or '0' + self.compiler_version_list = list(map(int, self.compiler_version.split('.'))) + + # TODO(somov): Посмотреть, можно ли спрятать это поле. + self.name_marker = '$(%s)' % self.params.get('match_root', self._name.upper()) + + self.arch_opt = self.params.get('arch_opt', []) + self.triplet_opt = self.params.get('triplet_opt', {}) + self.target_opt = self.params.get('target_opt', []) + + # TODO(somov): Убрать чтение настройки из os.environ. + self.werror_mode = preset('WERROR_MODE') or os.environ.get('WERROR_MODE') or self.params.get('werror_mode') or 'compiler_specific' + + # default C++ standard is set here, some older toolchains might need to redefine it in ya.conf.json + self.cxx_std = self.params.get('cxx_std', 'c++20') + + self._env = tc_json.get('env', {}) + + self.android_ndk_version = self.params.get('android_ndk_version', None) + + logger.debug('c_compiler=%s', self.c_compiler) + logger.debug('cxx_compiler=%s', self.cxx_compiler) + + self.compiler_platform_projects = self.target.find_in_dict(self.params.get('platform'), []) + + def version_at_least(self, *args): + return args <= tuple(self.compiler_version_list) + + def version_exactly(self, *args): + if not args or len(args) > len(self.compiler_version_list): + return False + for l, r in zip(args, list(self.compiler_version_list)[:len(args)]): + if l != r: + return False + return True + + @property + def is_gcc(self): + return self.type == 'gnu' + + @property + def is_clang(self): + return self.type in ('clang', 'xcode') + + @property + def is_xcode(self): + return self.type == 'xcode' + + @property + def is_from_arcadia(self): + return self.from_arcadia + + @property + def is_system_cxx(self): + return self._name == "system_cxx" + + def get_env(self, convert_list=None): + convert_list = convert_list or (lambda x: x) + r = {} + for k, v in six.iteritems(self._env): + if isinstance(v, str): + r[k] = v + elif isinstance(v, list): + r[k] = convert_list(v) + else: + logger.debug('Unexpected values in environment: %s', self._env) + raise ConfigureError('Internal error') + return r + + +class GnuToolchainOptions(ToolchainOptions): + def __init__(self, build, detector): + super(GnuToolchainOptions, self).__init__(build, detector) + + self.ar = self.params.get('ar') + self.ar_plugin = self.params.get('ar_plugin') + self.strip = self.params.get('strip') + self.objcopy = self.params.get('objcopy') + self.objdump = self.params.get('objdump') + self.isystem = self.params.get('isystem') + + self.dwarf_tool = self.target.find_in_dict(self.params.get('dwarf_tool')) + + # TODO(somov): Унифицировать формат sys_lib + self.sys_lib = self.params.get('sys_lib', {}) + if isinstance(self.sys_lib, dict): + self.sys_lib = self.target.find_in_dict(self.sys_lib, []) + + self.os_sdk = preset('OS_SDK') or self._default_os_sdk() + self.os_sdk_local = self.os_sdk == 'local' + + def _default_os_sdk(self): + if self.target.is_linux: + if self.target.is_armv8: + return 'ubuntu-16' + + if self.target.is_armv7 and self.target.armv7_float_abi == 'hard': + return 'ubuntu-16' + + if self.target.is_armv7 and self.target.armv7_float_abi == 'softfp': + return 'ubuntu-18' + + if self.target.is_powerpc: + return 'ubuntu-14' + + # Default OS SDK for Linux builds + return 'ubuntu-14' + + +class Toolchain(object): + def __init__(self, tc, build): + """ + :type tc: ToolchainOptions + :type build: Build + """ + self.tc = tc + self.build = build + self.platform_projects = self.tc.compiler_platform_projects + + def print_toolchain(self): + if self.platform_projects: + emit('COMPILER_PLATFORM', list(unique(self.platform_projects))) + + +class Compiler(object): + def __init__(self, tc, compiler_variable): + self.compiler_variable = compiler_variable + self.tc = tc + + def print_compiler(self): + # CLANG and CLANG_VER variables + emit(self.compiler_variable, 'yes') + emit('{}_VER'.format(self.compiler_variable), self.tc.compiler_version) + if self.tc.is_xcode: + emit('XCODE', 'yes') + + +class GnuToolchain(Toolchain): + def __init__(self, tc, build): + """ + :type tc: GnuToolchainOptions + :type build: Build + """ + + def get_os_sdk(target): + sdk_native_version = 10.11 if not preset('EXPERIMENTAL_MACOS_M1_SUPPORT') else '11.1' + if target.is_macos: + return '$MACOS_SDK_RESOURCE_GLOBAL/MacOSX{}.sdk'.format(sdk_native_version) + elif target.is_yocto: + return '$YOCTO_SDK_RESOURCE_GLOBAL' + return '$OS_SDK_ROOT_RESOURCE_GLOBAL' + + super(GnuToolchain, self).__init__(tc, build) + self.tc = tc + + host = build.host + target = build.target + + self.c_flags_platform = list(tc.target_opt) + + self.default_os_sdk_root = get_os_sdk(target) + + self.env = self.tc.get_env() + + self.env_go = {} + if self.tc.is_clang and not self.tc.is_system_cxx: + self.env_go = {'PATH': ['{}/bin'.format(self.tc.name_marker)]} + if self.tc.is_gcc: + self.env_go = {'PATH': ['{}/gcc/bin'.format(self.tc.name_marker)]} + if 'PATH' in self.env_go: + if target.is_linux: + self.env_go['PATH'].append('$OS_SDK_ROOT_RESOURCE_GLOBAL/usr/bin') + elif target.is_macos: + self.env_go['PATH'].extend([ + '$MACOS_SDK_RESOURCE_GLOBAL/usr/bin', + '$GO_FAKE_XCRUN_RESOURCE_GLOBAL', + ]) + + self.swift_flags_platform = [] + self.swift_lib_path = None + + if self.tc.is_from_arcadia: + for lib_path in build.host.library_path_variables: + self.env.setdefault(lib_path, []).append('{}/lib'.format(self.tc.name_marker)) + + macos_version_min = '11.0' + ios_version_min = '11.0' + # min ios simulator version for Metal App is 13.0 + # https://developer.apple.com/documentation/metal/supporting_simulator_in_a_metal_app + # Mapkit (MAPSMOBI_BUILD_TARGET) uses Metal Framework + if preset('MAPSMOBI_BUILD_TARGET') and target.is_iossim and target.is_armv8: + ios_version_min = '13.0' + # Mapkit uses SecTrustEvaluateWithError function and these are min versions for it + elif preset('MAPSMOBI_BUILD_TARGET'): + ios_version_min = '12.0' + + swift_target = select(default=None, selectors=[ + (target.is_iossim and target.is_x86_64, 'x86_64-apple-ios{}-simulator'.format(ios_version_min)), + (target.is_iossim and target.is_x86, 'i386-apple-ios{}-simulator'.format(ios_version_min)), + (target.is_iossim and target.is_armv8, 'arm64-apple-ios{}-simulator'.format(ios_version_min)), + (not target.is_iossim and target.is_ios and target.is_armv8, 'arm64-apple-ios9'), + (not target.is_iossim and target.is_ios and target.is_armv7, 'armv7-apple-ios9'), + ]) + if swift_target: + self.swift_flags_platform += ['-target', swift_target] + + if self.tc.is_from_arcadia: + self.swift_lib_path = select(default=None, selectors=[ + (host.is_macos and target.is_iossim, '$SWIFT_XCODE_TOOLCHAIN_ROOT_RESOURCE_GLOBAL/usr/lib/swift/iphonesimulator'), + (host.is_macos and not target.is_iossim and target.is_ios and (target.is_armv8 or target.is_armv7), '$SWIFT_XCODE_TOOLCHAIN_ROOT_RESOURCE_GLOBAL/usr/lib/swift/iphoneos'), + ]) + + if self.tc.is_clang: + target_triple = self.tc.triplet_opt.get(target.arch, None) + if not target_triple: + target_triple = select(default=None, selectors=[ + (target.is_linux and target.is_x86_64, 'x86_64-linux-gnu'), + (target.is_linux and target.is_armv8, 'aarch64-linux-gnu'), + (target.is_linux and target.is_armv7 and target.armv7_float_abi == 'hard', 'armv7-linux-gnueabihf'), + (target.is_linux and target.is_armv7 and target.armv7_float_abi == 'softfp', 'armv7-linux-gnueabi'), + (target.is_linux and target.is_powerpc, 'powerpc64le-linux-gnu'), + + (target.is_iossim and target.is_x86_64, 'x86_64-apple-ios{}-simulator'.format(ios_version_min)), + (target.is_iossim and target.is_x86, 'i386-apple-ios{}-simulator'.format(ios_version_min)), + (target.is_iossim and target.is_armv8, 'arm64-apple-ios{}-simulator'.format(ios_version_min)), + (not target.is_iossim and target.is_ios and target.is_armv8, 'arm64-apple-ios{}'.format(ios_version_min)), + (not target.is_iossim and target.is_ios and target.is_armv7, 'armv7-apple-ios{}'.format(ios_version_min)), + + (target.is_apple and target.is_x86, 'i386-apple-darwin14'), + (target.is_apple and target.is_x86_64, 'x86_64-apple-darwin14'), + (target.is_apple and target.is_macos_arm64, 'arm64-apple-macos11'), + (target.is_apple and target.is_armv7, 'armv7-apple-darwin14'), + (target.is_apple and target.is_armv8, 'arm64-apple-darwin14'), + + (target.is_yocto and target.is_armv7, 'arm-poky-linux-gnueabi'), + + (target.is_android and target.is_x86, 'i686-linux-android'), + (target.is_android and target.is_x86_64, 'x86_64-linux-android'), + (target.is_android and target.is_armv7, 'armv7a-linux-androideabi'), + (target.is_android and target.is_armv8, 'aarch64-linux-android'), + ]) + + if target.is_android: + # Android NDK allows specification of API level in target triple, e.g.: + # armv7a-linux-androideabi16, aarch64-linux-android21 + target_triple += str(target.android_api) + + if target_triple: + self.c_flags_platform.append('--target={}'.format(target_triple)) + + if self.tc.isystem: + for root in list(self.tc.isystem): + self.c_flags_platform.extend(['-isystem', root]) + + if target.is_android: + self.c_flags_platform.extend(['-isystem', '{}/sources/cxx-stl/llvm-libc++abi/include'.format(self.tc.name_marker)]) + + if target.is_cortex_a9: + self.c_flags_platform.append('-mcpu=cortex-a9') + + if target.is_cortex_a35: + self.c_flags_platform.append('-mcpu=cortex-a35') + + elif target.is_cortex_a53: + self.c_flags_platform.append('-mcpu=cortex-a53') + + elif target.is_cortex_m4: + self.c_flags_platform.append('-mcpu=cortex-m4 -mfpu=fpv4-sp-d16') + + elif target.is_cortex_m7: + self.c_flags_platform.append('-mcpu=cortex-m7 -mfpu=fpv5-sp-d16') + + elif target.is_cortex_m33: + self.c_flags_platform.append('-mcpu=cortex-m33 -mfpu=fpv5-sp-d16') + + elif target.is_armv7_neon: + self.c_flags_platform.append('-mfpu=neon') + + if (target.is_armv7 or target.is_armv8m or target.is_armv7em) and build.is_size_optimized: + # Enable ARM Thumb2 variable-length instruction encoding + # to reduce code size + self.c_flags_platform.append('-mthumb') + + if target.is_arm or target.is_powerpc: + # On linux, ARM and PPC default to unsigned char + # However, Arcadia requires char to be signed + self.c_flags_platform.append('-fsigned-char') + + if target.is_rv32imc: + self.c_flags_platform.append('-march=rv32imc') + + if self.tc.is_clang or self.tc.is_gcc and self.tc.version_at_least(8, 2): + target_flags = select(default=[], selectors=[ + (target.is_linux and target.is_power8le, ['-mcpu=power8', '-mtune=power8', '-maltivec']), + (target.is_linux and target.is_power9le, ['-mcpu=power9', '-mtune=power9', '-maltivec']), + (target.is_linux and target.is_armv8, ['-march=armv8a']), + (target.is_macos, ['-mmacosx-version-min={}'.format(macos_version_min)]), + (target.is_ios and not target.is_iossim, ['-mios-version-min={}'.format(ios_version_min)]), + (target.is_iossim, ['-mios-simulator-version-min={}'.format(ios_version_min)]), + (target.is_android and target.is_armv7, ['-march=armv7-a', '-mfloat-abi=softfp']), + (target.is_android and target.is_armv8, ['-march=armv8-a']), + (target.is_yocto and target.is_armv7, ['-march=armv7-a', '-mfpu=neon', '-mfloat-abi=hard', '-mcpu=cortex-a9', '-O1']) + ]) + + if target_flags: + self.c_flags_platform.extend(target_flags) + + if target.is_ios: + self.c_flags_platform.append('-D__IOS__=1') + + if self.tc.is_from_arcadia or self.tc.is_system_cxx: + if target.is_apple: + if target.is_ios: + self.setup_sdk(project='build/platform/ios_sdk', var='${IOS_SDK_ROOT_RESOURCE_GLOBAL}') + self.platform_projects.append('build/platform/macos_system_stl') + if target.is_macos: + self.setup_sdk(project='build/platform/macos_sdk', var='${MACOS_SDK_RESOURCE_GLOBAL}') + self.platform_projects.append('build/platform/macos_system_stl') + + if target.is_linux: + if not tc.os_sdk_local: + self.setup_sdk(project='build/platform/linux_sdk', var='$OS_SDK_ROOT_RESOURCE_GLOBAL') + + if target.is_x86_64: + if host.is_linux and not self.tc.is_gcc: + self.setup_tools(project='build/platform/linux_sdk', var='$OS_SDK_ROOT_RESOURCE_GLOBAL', bin='usr/bin', ldlibs='usr/lib/x86_64-linux-gnu') + elif host.is_macos: + self.setup_tools(project='build/platform/binutils', var='$BINUTILS_ROOT_RESOURCE_GLOBAL', bin='x86_64-linux-gnu/bin', ldlibs=None) + elif target.is_powerpc: + self.setup_tools(project='build/platform/linux_sdk', var='$OS_SDK_ROOT_RESOURCE_GLOBAL', bin='usr/bin', ldlibs='usr/x86_64-linux-gnu/powerpc64le-linux-gnu/lib') + elif target.is_armv8: + self.setup_tools(project='build/platform/linux_sdk', var='$OS_SDK_ROOT_RESOURCE_GLOBAL', bin='usr/bin', ldlibs='usr/lib/x86_64-linux-gnu') + + if target.is_yocto: + self.setup_sdk(project='build/platform/yocto_sdk/yocto_sdk', var='${YOCTO_SDK_ROOT_RESOURCE_GLOBAL}') + elif self.tc.params.get('local'): + if target.is_apple: + if not tc.os_sdk_local: + if target.is_ios: + self.setup_sdk(project='build/platform/ios_sdk', var='${IOS_SDK_ROOT_RESOURCE_GLOBAL}') + self.platform_projects.append('build/platform/macos_system_stl') + if target.is_macos: + self.setup_sdk(project='build/platform/macos_sdk', var='${MACOS_SDK_RESOURCE_GLOBAL}') + self.platform_projects.append('build/platform/macos_system_stl') + else: + if target.is_iossim: + self.env.setdefault('SDKROOT', subprocess.check_output(['xcrun', '-sdk', 'iphonesimulator', '--show-sdk-path']).strip()) + elif target.is_ios: + self.env.setdefault('SDKROOT', subprocess.check_output(['xcrun', '-sdk', 'iphoneos', '--show-sdk-path']).strip()) + elif target.is_macos: + self.env.setdefault('SDKROOT', subprocess.check_output(['xcrun', '-sdk', 'macosx', '--show-sdk-path']).strip()) + + def setup_sdk(self, project, var): + self.platform_projects.append(project) + self.c_flags_platform.append('--sysroot={}'.format(var)) + self.swift_flags_platform += ['-sdk', var] + + # noinspection PyShadowingBuiltins + def setup_tools(self, project, var, bin, ldlibs): + self.platform_projects.append(project) + self.c_flags_platform.append('-B{}/{}'.format(var, bin)) + if ldlibs: + for lib_path in self.build.host.library_path_variables: + self.env.setdefault(lib_path, []).append('{}/{}'.format(var, ldlibs)) + + def print_toolchain(self): + super(GnuToolchain, self).print_toolchain() + + emit('TOOLCHAIN_ENV', format_env(self.env, list_separator=':')) + emit('_GO_TOOLCHAIN_ENV_PATH', format_env(self.env_go, list_separator=':')) + emit('C_FLAGS_PLATFORM', self.c_flags_platform) + emit('SWIFT_FLAGS_PLATFORM', self.swift_flags_platform) + emit('SWIFT_LD_FLAGS', '-L{}'.format(self.swift_lib_path) if self.swift_lib_path else '') + + emit('PERL_SDK', preset('OS_SDK') or self.tc.os_sdk) + if preset('OS_SDK') is None: + emit('OS_SDK', self.tc.os_sdk) + emit('OS_SDK_ROOT', None if self.tc.os_sdk_local else self.default_os_sdk_root) + + +class GnuCompiler(Compiler): + def __init__(self, tc, build): + """ + :type tc: GnuToolchainOptions + :type build: Build + """ + compiler_variable = 'CLANG' if tc.is_clang else 'GCC' + super(GnuCompiler, self).__init__(tc, compiler_variable) + + self.build = build + self.host = self.build.host + self.target = self.build.target + self.tc = tc + + self.c_foptions = [ + # Enable C++ exceptions (and allow them to be throw through pure C code) + '-fexceptions', + # Enable standard-conforming behavior and generate duplicate symbol error in case of duplicated global constants. + # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678#c0 + '-fno-common', + ] + + if self.tc.is_clang and self.target.is_linux: + # Use .init_array instead of .ctors (default for old clang versions) + # See: https://maskray.me/blog/2021-11-07-init-ctors-init-array + self.c_foptions.append('-fuse-init-array') + + if self.target.is_xtensa: + self.c_foptions.append('-mlongcalls') + + if self.tc.is_clang: + self.c_foptions += [ + # Set up output colorization + '-fcolor-diagnostics', + # Enable aligned allocation + '-faligned-allocation', + '-fdebug-default-version=4', + ] + elif self.tc.is_gcc: + if self.target.is_xtensa: + # Xtensa toolchain does not support this flag + pass + else: + self.c_foptions += [ + # Set up output colorization + '-fdiagnostics-color=always', + # It looks like there is no way to enable aligned allocation in gcc + ] + + self.c_warnings = [ + # Enable default warnings subset + '-Wall', + '-Wextra', + ] + self.cxx_warnings = [ + # Issue a warning if certain overload is hidden due to inheritance + '-Woverloaded-virtual', + ] + + # Disable some warnings which will fail compilation at the time + self.c_warnings += [ + '-Wno-parentheses', + ] + + self.c_defines = ['${hide:CPP_FAKEID}'] + if self.target.is_android: + self.c_defines.append('${hide:ANDROID_FAKEID}') + + self.c_defines.extend([ + '-DARCADIA_ROOT=${ARCADIA_ROOT}', + '-DARCADIA_BUILD_ROOT=${ARCADIA_BUILD_ROOT}', + ]) + + self.c_defines.extend([ + '-D_THREAD_SAFE', '-D_PTHREADS', '-D_REENTRANT', + '-D_LARGEFILE_SOURCE', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS', + ]) + + if not self.target.is_android: + # There is no usable _FILE_OFFSET_BITS=64 support in Androids until API 21. And it's incomplete until at least API 24. + # https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md + # Arcadia have API 16 for 32-bit Androids. + self.c_defines.append('-D_FILE_OFFSET_BITS=64') + + if self.target.is_linux or self.target.is_android or self.target.is_cygwin or self.target.is_none: + self.c_defines.append('-D_GNU_SOURCE') + + if self.tc.is_clang and self.target.is_linux and self.target.is_x86_64: + self.c_defines.append('-D_YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE') + + if self.target.is_ios: + self.c_defines.extend(['-D_XOPEN_SOURCE', '-D_DARWIN_C_SOURCE']) + + self.c_flags = ['$CL_DEBUG_INFO', '$CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__'] + self.c_flags += self.tc.arch_opt + ['-pipe'] + + self.sfdl_flags = ['-E', '-C', '-x', 'c++'] + + if self.target.is_x86: + self.c_flags.append('-m32') + if self.target.is_x86_64: + self.c_flags.append('-m64') + + self.debug_info_flags = ['-g'] + if self.target.is_linux: + self.debug_info_flags.append('-ggnu-pubnames') + + self.cross_suffix = '' if is_positive('FORCE_NO_PIC') else '.pic' + + self.optimize = None + + self.configure_build_type() + + if self.tc.is_clang: + self.sfdl_flags.append('-Qunused-arguments') + + self.c_warnings += [ + '-Wno-implicit-const-int-float-conversion', + # For nvcc to accept the above. + '-Wno-unknown-warning-option', + ] + + self.cxx_warnings += [ + '-Wimport-preprocessor-directive-pedantic', + '-Wno-ambiguous-reversed-operator', + '-Wno-defaulted-function-deleted', + '-Wno-deprecated-anon-enum-enum-conversion', + '-Wno-deprecated-enum-enum-conversion', + '-Wno-deprecated-enum-float-conversion', + '-Wno-deprecated-volatile', + '-Wno-pessimizing-move', + '-Wno-return-std-move', + '-Wno-undefined-var-template', + ] + + elif self.tc.is_gcc: + if self.target.is_xtensa: + # Xtensa toolchain does not support this flags + pass + else: + self.c_foptions.append('-fno-delete-null-pointer-checks') + self.c_foptions.append('-fabi-version=8') + + # Split all functions and data into separate sections for DCE and ICF linker passes + # NOTE: iOS build uses -fembed-bitcode which conflicts with -ffunction-sections (only relevant for ELF targets) + if not self.target.is_ios: + self.c_foptions.extend(['-ffunction-sections', '-fdata-sections']) + + def configure_build_type(self): + if self.build.is_valgrind: + self.c_defines.append('-DWITH_VALGRIND=1') + + if self.build.is_debug: + self.c_foptions.append('$FSTACK') + + if self.build.is_fast_debug: + self.c_flags.append('-Og') + + if self.build.is_release: + self.c_flags.append('$OPTIMIZE') + if self.build.is_size_optimized: + # -Oz is clang's more size-aggressive version of -Os + # For ARM specifically, clang -Oz is on par with gcc -Os: + # https://github.com/android/ndk/issues/133#issuecomment-365763507 + if self.tc.is_clang: + self.optimize = '-Oz' + else: + self.optimize = '-Os' + + # Generate sections with address significance tables for ICF linker pass + if self.tc.is_clang: + self.c_foptions.extend(['-faddrsig']) + else: + self.optimize = '-O3' + + if self.build.with_ndebug: + self.c_defines.append('-DNDEBUG') + else: + self.c_defines.append('-UNDEBUG') + + if self.build.profiler_type in (Profiler.Generic, Profiler.GProf): + self.c_foptions.append('-fno-omit-frame-pointer') + + if self.build.profiler_type == Profiler.GProf: + self.c_flags.append('-pg') + + def print_compiler(self): + super(GnuCompiler, self).print_compiler() + + emit('C_COMPILER_UNQUOTED', self.tc.c_compiler) + emit('OPTIMIZE', self.optimize) + emit('WERROR_MODE', self.tc.werror_mode) + emit('_C_FLAGS', self.c_flags) + emit('_C_FOPTIONS', self.c_foptions) + emit('_CXX_STD', '-std={}'.format(self.tc.cxx_std)) + append('C_DEFINES', self.c_defines) + append('C_WARNING_OPTS', self.c_warnings) + append('CXX_WARNING_OPTS', self.cxx_warnings) + emit('CXX_COMPILER_UNQUOTED', self.tc.cxx_compiler) + # TODO(somov): Убрать чтение настройки из os.environ + emit('USE_ARC_PROFILE', 'yes' if preset('USE_ARC_PROFILE') or os.environ.get('USE_ARC_PROFILE') else 'no') + emit('DEBUG_INFO_FLAGS', self.debug_info_flags) + + if self.build.is_coverage: + emit('_IS_COVERAGE', 'yes') + + if self.tc.is_clang and self.tc.version_at_least(9): + emit('_HAS_TIME_TRACE', 'yes') + + print('@import "${CONF_ROOT}/conf/compilers/gnu_compiler.conf"') + + +class SwiftCompiler(object): + def __init__(self, build): + self.host = build.host + self.compiler = None + + def configure(self): + if self.host.is_macos: + self.compiler = '$SWIFT_XCODE_TOOLCHAIN_ROOT_RESOURCE_GLOBAL/usr/bin/swiftc' + + def print_compiler(self): + emit('SWIFT_COMPILER', self.compiler or '') + + +class Linker(object): + BFD = 'bfd' + LLD = 'lld' + GOLD = 'gold' + + def __init__(self, tc, build): + """ + :type tc: ToolchainOptions + :type build: Build + """ + self.tc = tc + self.build = build + self.type = self._get_default_linker_type() + + def _get_default_linker_type(self): + if not self.tc.is_from_arcadia or is_positive('EXPORT_CMAKE'): + # External (e.g. system) toolchain: disable linker selection logic + return None + + if self.build.target.is_android: + # Android toolchain is NDK, LLD works on all supported platforms + return Linker.LLD + + elif self.build.target.is_linux or self.build.target.is_macos or self.build.target.is_ios: + return Linker.LLD + + # There is no linker choice on Windows (link.exe) + return None + + def print_linker(self): + self._print_linker_selector() + + def _print_linker_selector(self): + # if self.type is None then _DEFAULT_LINKER is set to empty string value + emit('_DEFAULT_LINKER_ID', self.type) + + +class LD(Linker): + def __init__(self, tc, build): + """ + :type tc: GnuToolchainOptions + :type build: Build + """ + super(LD, self).__init__(tc, build) + + self.build = build + self.host = self.build.host + self.target = self.build.target + self.tc = tc + + target = self.target + + self.ar = preset('AR') or self.tc.ar + self.ar_plugin = self.tc.ar_plugin + self.strip = self.tc.strip + self.objcopy = self.tc.objcopy + self.objdump = self.tc.objdump + + self.musl = Setting('MUSL', convert=to_bool) + + if self.ar is None: + if self.tc.is_from_arcadia: + if self.tc.is_clang: + self.ar = '{}/bin/llvm-ar'.format(self.tc.name_marker) + if self.tc.is_gcc: + self.ar = '{}/gcc/bin/gcc-ar'.format(self.tc.name_marker) + else: + self.ar = 'ar' + + self.ar_type = 'GNU_AR' + self.llvm_ar_format = 'None' + + if 'libtool' in self.ar: + self.ar_type = 'LIBTOOL' + elif 'llvm-ar' in self.ar: + self.ar_type = 'LLVM_AR' + if target.is_apple: + self.llvm_ar_format="darwin" + else: + self.llvm_ar_format="gnu" + + self.ld_flags = [] + + if self.musl.value: + self.ld_flags.extend(['-Wl,--no-as-needed']) + elif target.is_linux: + self.ld_flags.extend(['-ldl', '-lrt', '-Wl,--no-as-needed']) + if self.tc.is_gcc: + self.ld_flags.extend(('-Wl,-Bstatic', '-latomic', '-Wl,-Bdynamic')) + elif target.is_android: + self.ld_flags.extend(['-ldl', '-Wl,--no-as-needed']) + + self.ld_sdk = select(default=None, selectors=[ + # -platform_version <platform> <min_version> <sdk_version> + (target.is_macos, '-Wl,-platform_version,macos,11.0,11.0'), + (not target.is_iossim and target.is_ios, '-Wl,-platform_version,ios,11.0,13.1'), + (target.is_iossim, '-Wl,-platform_version,ios-simulator,14.0,14.5'), + ]) + + if self.build.profiler_type == Profiler.GProf: + self.ld_flags.append('-pg') + + if self.ld_sdk: + self.ld_flags.append(self.ld_sdk) + + self.sys_lib = self.tc.sys_lib + + if target.is_android: + # Use toolchain defaults to link with libunwind/clang_rt.builtins + self.use_stdlib = '-nostdlib++' + + def print_linker(self): + super(LD, self).print_linker() + + emit('AR_TOOL', self.ar) + emit('AR_TYPE', self.ar_type) + emit('_LD_LLVM_AR_FORMAT', self.llvm_ar_format) + emit('_LD_AR_PLUGIN', self.ar_plugin or 'None') + + emit('STRIP_TOOL_VENDOR', self.strip) + emit('OBJCOPY_TOOL_VENDOR', self.objcopy) + emit('OBJDUMP_TOOL_VENDOR', self.objdump) + + emit('_LD_FLAGS', self.ld_flags) + emit('_LD_SYS_LIB', self.sys_lib) + emit('LD_SDK_VERSION', self.ld_sdk) + + dwarf_tool = self.tc.dwarf_tool + if dwarf_tool is None and self.tc.is_clang and (self.target.is_macos or self.target.is_ios): + dsymutil = '{}/bin/{}dsymutil'.format(self.tc.name_marker, '' if self.tc.version_at_least(7) else 'llvm-') + dwarf_tool = '${YMAKE_PYTHON} ${input:"build/scripts/run_llvm_dsymutil.py"} ' + dsymutil + if self.tc.version_at_least(5, 0): + dwarf_tool += ' -flat' + + if dwarf_tool is not None: + emit('DWARF_TOOL', dwarf_tool) + + arch_flag = '--arch={arch}'.format(arch=self.target.os_compat) + emit('_LD_ARCH_FLAG', arch_flag) + + print('@import "${CONF_ROOT}/conf/linkers/ld.conf"') + + +class MSVCToolchainOptions(ToolchainOptions): + def __init__(self, build, detector): + super(MSVCToolchainOptions, self).__init__(build, detector) + + # C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428 + self.vc_root = None + + # C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0 + self.kit_includes = None + + # C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0 + self.kit_libs = None + + self.under_wine = 'wine' in self.params + self.system_msvc = 'system_msvc' in self.params + self.ide_msvs = 'ide_msvs' in self.params + self.use_clang = self.params.get('use_clang', False) + self.use_arcadia_toolchain = self.params.get('use_arcadia_toolchain', False) + + self.sdk_version = None + + if build.host.is_windows: + self.under_wine = False + + if self.ide_msvs: + bindir = '$(VC_ExecutablePath_x64_x64)\\' + self.c_compiler = bindir + 'cl.exe' + self.cxx_compiler = self.c_compiler + + self.link = bindir + 'link.exe' + self.lib = bindir + 'lib.exe' + self.masm_compiler = bindir + 'ml64.exe' + + self.vc_root = None + + sdk_dir = '$(WindowsSdkDir)' + self.sdk_version = '$(WindowsTargetPlatformVersion)' + self.kit_includes = os.path.join(sdk_dir, 'Include', self.sdk_version) + self.kit_libs = os.path.join(sdk_dir, 'Lib', self.sdk_version) + + elif detector: + self.masm_compiler = which('ml64.exe') + self.link = which('link.exe') + self.lib = which('lib.exe') + + sdk_dir = os.environ.get('WindowsSdkDir') + self.sdk_version = os.environ.get('WindowsSDKVersion').replace('\\', '') + vc_install_dir = os.environ.get('VCToolsInstallDir') + # fix for cxx_std detection problem introduced in r7740071 when running in native VS toolkit commandline: + # in that case ya make gets 'system_cxx' configuration name and cxx_std is obviously missing in that config + # so default 'c++20' is substituted and we need to hotfix it here + self.cxx_std = 'c++latest' + + if any([x is None for x in (sdk_dir, self.sdk_version, vc_install_dir)]): + raise ConfigureError('No %WindowsSdkDir%, %WindowsSDKVersion% or %VCINSTALLDIR% present. Please, run vcvars64.bat to setup preferred environment.') + + self.vc_root = os.path.normpath(vc_install_dir) + self.kit_includes = os.path.normpath(os.path.join(sdk_dir, 'Include', self.sdk_version)) + self.kit_libs = os.path.normpath(os.path.join(sdk_dir, 'Lib', self.sdk_version)) + + # TODO(somov): Определять автоматически self.version в этом случае + + else: + if self.version_at_least(2019): + self.sdk_version = '10.0.18362.0' + sdk_dir = '$(WINDOWS_KITS-sbr:1939557911)' + if is_positive('MSVC20'): # XXX: temporary flag, remove after DTCC-123 is completed + self.cxx_std = 'c++latest' + else: + self.sdk_version = '10.0.16299.0' + sdk_dir = '$(WINDOWS_KITS-sbr:1379398385)' + + self.vc_root = self.name_marker if not self.use_clang else '$MSVC_FOR_CLANG_RESOURCE_GLOBAL' + self.kit_includes = os.path.join(sdk_dir, 'Include', self.sdk_version) + self.kit_libs = os.path.join(sdk_dir, 'Lib', self.sdk_version) + + bindir = os.path.join(self.vc_root, 'bin', 'Hostx64') + + tools_name = select(selectors=[ + (build.target.is_x86, 'x86'), + (build.target.is_x86_64, 'x64'), + (build.target.is_armv7, 'arm'), + ]) + + asm_name = select(selectors=[ + (build.target.is_x86, 'ml.exe'), + (build.target.is_x86_64, 'ml64.exe'), + (build.target.is_armv7, 'armasm.exe'), + ]) + + def prefix(_type, _path): + if not self.under_wine: + return _path + return '{wine} {type} $WINE_ENV ${{ARCADIA_ROOT}} ${{ARCADIA_BUILD_ROOT}} {path}'.format( + wine='${YMAKE_PYTHON} ${input:\"build/scripts/run_msvc_wine.py\"} $(WINE_TOOL-sbr:1093314933)/bin/wine64 -v140 ' + + '${input;hide:\"build/scripts/process_command_files.py\"} ${input;hide:\"build/scripts/process_whole_archive_option.py\"}', + type=_type, + path=_path + ) + + self.masm_compiler = prefix('masm', os.path.join(bindir, tools_name, asm_name)) + self.link = prefix('link', os.path.join(bindir, tools_name, 'link.exe')) + self.lib = prefix('lib', os.path.join(bindir, tools_name, 'lib.exe')) + + +class MSVC(object): + # noinspection PyPep8Naming + class WindowsVersion(object): + """ + Predefined values for _WIN32_WINNT macro. + This macro specifies minimal Windows version required by the binary being build. + + A complete list of the values supported by the Windows SDK can be found at + https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt + """ + Windows7 = '0x0601' + Windows8 = '0x0602' + + def __init__(self, tc, build): + """ + :type tc: MSVCToolchainOptions + :type build: Build + """ + if not isinstance(tc, MSVCToolchainOptions): + raise TypeError('Got {} ({}) instead of an MSVCToolchainOptions'.format(tc, type(tc))) + + self.build = build + self.tc = tc + + +class MSVCToolchain(MSVC, Toolchain): + def __init__(self, tc, build): + """ + :type tc: MSVCToolchainOptions + :param build: Build + """ + Toolchain.__init__(self, tc, build) + MSVC.__init__(self, tc, build) + + if self.tc.from_arcadia and not self.tc.ide_msvs: + self.platform_projects.append('build/platform/msvc') + if tc.under_wine: + self.platform_projects.append('build/platform/wine') + + def print_toolchain(self): + super(MSVCToolchain, self).print_toolchain() + + emit('TOOLCHAIN_ENV', format_env(self.tc.get_env(), list_separator=';')) + + if self.tc.sdk_version: + emit('WINDOWS_KITS_VERSION', self.tc.sdk_version) + + if self.tc.under_wine: + emit('_UNDER_WINE', 'yes') + if self.tc.use_clang: + emit('CLANG_CL', 'yes') + if self.tc.ide_msvs: + emit('IDE_MSVS', 'yes') + if self.tc.use_arcadia_toolchain: + emit('USE_ARCADIA_TOOLCHAIN', 'yes') + emit('_MSVC_TC_KIT_LIBS', self.tc.kit_libs) + emit('_MSVC_TC_VC_ROOT', self.tc.vc_root) + + print('@import "${CONF_ROOT}/conf/toolchains/msvc_toolchain.conf"') + + +class MSVCCompiler(MSVC, Compiler): + def __init__(self, tc, build): + Compiler.__init__(self, tc, 'MSVC') + MSVC.__init__(self, tc, build) + + def print_compiler(self): + super(MSVCCompiler, self).print_compiler() + + target = self.build.target + + warns_enabled = [ + 4018, # 'expression' : signed/unsigned mismatch + 4265, # 'class' : class has virtual functions, but destructor is not virtual + 4296, # 'operator' : expression is always false + 4431, # missing type specifier - int assumed + ] + warns_as_error = [ + 4013, # 'function' undefined; assuming extern returning int + ] + warns_disabled = [ + # While this warning corresponds to enabled-by-default -Wmacro-redefinition, + # it floods clog with abundant amount of log lines, + # as yvals_core.h from Windows SDK redefines certain + # which macros logically belong to libcxx + 4005, # '__cpp_lib_*': macro redefinition. + + # Ne need to recheck this, but it looks like _CRT_USE_BUILTIN_OFFSETOF still makes sense + 4117, # macro name '_CRT_USE_BUILTIN_OFFSETOF' is reserved, '#define' ignored + + 4127, # conditional expression is constant + 4200, # nonstandard extension used : zero-sized array in struct/union + 4201, # nonstandard extension used : nameless struct/union + 4351, # elements of array will be default initialized + 4355, # 'this' : used in base member initializer list + 4503, # decorated name length exceeded, name was truncated + 4510, # default constructor could not be generated + 4511, # copy constructor could not be generated + 4512, # assignment operator could not be generated + 4554, # check operator precedence for possible error; use parentheses to clarify precedence + 4610, # 'object' can never be instantiated - user defined constructor required + 4706, # assignment within conditional expression + 4800, # forcing value to bool 'true' or 'false' (performance warning) + 4996, # The POSIX name for this item is deprecated + 4714, # function marked as __forceinline not inlined + 4197, # 'TAtomic' : top-level volatile in cast is ignored + 4245, # 'initializing' : conversion from 'int' to 'ui32', signed/unsigned mismatch + 4324, # 'ystd::function<void (uint8_t *)>': structure was padded due to alignment specifier + 5033, # 'register' is no longer a supported storage class + ] + + defines = [ + # FIXME: This is quick fix to let catboost build from MSVS IDE + # This place is questionable overall, see YMAKE-437 + '/DARCADIA_ROOT=' + ('${ARCADIA_ROOT}' if not self.tc.ide_msvs else '.'), + '/DARCADIA_BUILD_ROOT=' + ('${ARCADIA_BUILD_ROOT}' if not self.tc.ide_msvs else '.'), + '/DFAKEID=$CPP_FAKEID', + '/DWIN32', + '/D_WIN32', + '/D_WINDOWS', + # Define _CRT_*_NO_WARNINGS macros to prevent ucrt from issuing a warning whenever + # a POSIX-style function is used instead of the alternative Microsoft suggests as a secure / standard replacement + # (e. g. `strncpy()` instead of `strncpy_s()`, `access()` instead of `_access()`) + # For details see: + # https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt + '/D_CRT_SECURE_NO_WARNINGS', + '/D_CRT_NONSTDC_NO_WARNINGS', + # Math constants (such as M_PI, M_E, M_SQRT2) are not defined in standard C / C++ + # In order to get them defined by Windows ucrt library, + # you must first define _USE_MATH_DEFINES before #including <cmath> or math.h>. + # (NB: glibc defines these macros whenever _XOPEN_SOURCE is defined) + '/D_USE_MATH_DEFINES', + '/D__STDC_CONSTANT_MACROS', + '/D__STDC_FORMAT_MACROS', + '/D_USING_V110_SDK71_', + '/D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES', + # Below defines are covered at + # https://docs.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers#faster-builds-with-smaller-header-files + # Exclude APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets (while including <windows.h>) + '/DWIN32_LEAN_AND_MEAN', + # Define NOMINMAX to avoid min() and max() macros definition (while including <windows.h>) + '/DNOMINMAX', + ] + + cxx_defines = [ + # Use builtin offsetof implementation + # instead of a crutcy macro defined in ucrt/stddef.h. + # The latter can not be used in constexpr statements. + '/D_CRT_USE_BUILTIN_OFFSETOF', + ] + + if target.is_x86_64: + defines.extend(('/D_WIN64', '/DWIN64')) + + if target.is_armv7: + defines.extend(('/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE', '/D__arm__')) + + winapi_unicode = False + + flags = [ + '/nologo', '/Zm500', '/GR', '/bigobj', '/FC', '/EHs', '/errorReport:prompt', '$MSVC_INLINE_FLAG', '/utf-8', + # enable standard conforming mode + '/permissive-' + ] + flags += self.tc.arch_opt + + c_warnings = ['/we{}'.format(code) for code in warns_as_error] + c_warnings += ['/w1{}'.format(code) for code in warns_enabled] + c_warnings += ['/wd{}'.format(code) for code in warns_disabled] + cxx_warnings = [] + + if self.tc.use_clang: + flags += [ + # Allow <windows.h> to be included via <Windows.h> in case-sensitive file-systems. + '-fcase-insensitive-paths', + + # At the time clang-cl identifies itself as MSVC 19.11: + # (actual value can be found in clang/lib/Driver/ToolChains/MSVC.cpp, the syntax would be like + # ``` + # MSVT = VersionTuple(19, 11); + # ``` + # + # We override this value to match current value of the actual MSVC being used. + '-fms-compatibility-version=19.21', + # for msvc compatibility + # https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions + '-fdelayed-template-parsing', + ] + if target.is_x86: + flags.append('-m32') + elif target.is_x86_64: + flags.append('-m64') + + c_warnings.extend(( + '-Wno-format', + '-Wno-parentheses', + '-Wno-unknown-warning-option', + )) + + cxx_warnings += [ + '-Wimport-preprocessor-directive-pedantic', + '-Woverloaded-virtual', + '-Wno-ambiguous-reversed-operator', + '-Wno-defaulted-function-deleted', + '-Wno-deprecated-anon-enum-enum-conversion', + '-Wno-deprecated-enum-enum-conversion', + '-Wno-deprecated-enum-float-conversion', + '-Wno-deprecated-volatile', + '-Wno-undefined-var-template', + ] + + if self.tc.ide_msvs: + cxx_warnings += [ + '-Wno-unused-command-line-argument', + ] + + win_version_min = self.WindowsVersion.Windows7 + defines.append('/D_WIN32_WINNT={0}'.format(win_version_min)) + + if winapi_unicode: + defines += ['/DUNICODE', '/D_UNICODE'] + else: + defines += ['/D_MBCS'] + + vc_include = os.path.join(self.tc.vc_root, 'include') if not self.tc.ide_msvs else "$(VC_VC_IncludePath.Split(';')[0].Replace('\\','/'))" + + if not self.tc.ide_msvs: + def include_flag(path): + return '{flag}"{path}"'.format(path=path, flag='/I ' if not self.tc.use_clang else '-imsvc') + + for name in ('shared', 'ucrt', 'um', 'winrt'): + flags.append(include_flag(os.path.join(self.tc.kit_includes, name))) + flags.append(include_flag(vc_include)) + + if self.tc.use_clang: + emit('CLANG_CL', 'yes') + if self.tc.ide_msvs: + emit('IDE_MSVS', 'yes') + if self.tc.use_arcadia_toolchain: + emit('USE_ARCADIA_TOOLCHAIN', 'yes') + + emit('CXX_COMPILER', self.tc.cxx_compiler) + emit('C_COMPILER', self.tc.c_compiler) + emit('MASM_COMPILER', self.tc.masm_compiler) + append('C_DEFINES', defines) + append('C_WARNING_OPTS', c_warnings) + emit('_CXX_DEFINES', cxx_defines) + append('CXX_WARNING_OPTS', cxx_warnings) + + if self.build.is_release: + emit('CFLAGS_PER_TYPE', '$CFLAGS_RELEASE') + if self.build.is_debug: + emit('CFLAGS_PER_TYPE', '$CFLAGS_DEBUG') + if self.build.is_ide: + emit('CFLAGS_PER_TYPE', '@[debug|$CFLAGS_DEBUG]@[release|$CFLAGS_RELEASE]') + + emit('_STD_CXX', '/std:{}'.format(self.tc.cxx_std)) + + emit('_MSVC_FLAGS', flags) + + ucrt_include = os.path.join(self.tc.kit_includes, 'ucrt') if not self.tc.ide_msvs else "$(UniversalCRT_IncludePath.Split(';')[0].Replace('\\','/'))" + + # clang-cl has '#include_next', and MSVC hasn't. It needs separately specified CRT and VC include directories for libc++ to include second in order standard C and C++ headers. + if not self.tc.use_clang: + emit('_CFLAGS_UCRT_VC_INCLUDES', '/DY_UCRT_INCLUDE="%s"' % ucrt_include, '/DY_MSVC_INCLUDE="%s"' % vc_include) + else: + emit('_CFLAGS_UCRT_VC_INCLUDES') + + emit('WERROR_MODE', self.tc.werror_mode) + + print('@import "${CONF_ROOT}/conf/compilers/msvc_compiler.conf"') + + +class MSVCLinker(MSVC, Linker): + def __init__(self, tc, build): + MSVC.__init__(self, tc, build) + Linker.__init__(self, tc, build) + + def print_linker(self): + super(MSVCLinker, self).print_linker() + + linker = self.tc.link + linker_lib = self.tc.lib + + emit('LINK_LIB_CMD', linker_lib) + emit('LINK_EXE_CMD', linker) + + if self.build.is_release: + emit('LINK_EXE_FLAGS_PER_TYPE', '$LINK_EXE_FLAGS_RELEASE') + if self.build.is_debug: + emit('LINK_EXE_FLAGS_PER_TYPE', '$LINK_EXE_FLAGS_DEBUG') + if self.build.is_ide and self.tc.ide_msvs: + emit('LINK_EXE_FLAGS_PER_TYPE', '@[debug|$LINK_EXE_FLAGS_DEBUG]@[release|$LINK_EXE_FLAGS_RELEASE]') + + print('@import "${CONF_ROOT}/conf/linkers/msvc_linker.conf"') + + +# TODO(somov): Rename! +Compilers = { + 'gnu': (GnuToolchain, GnuCompiler, LD), + 'clang': (GnuToolchain, GnuCompiler, LD), + 'xcode': (GnuToolchain, GnuCompiler, LD), + 'msvc': (MSVCToolchain, MSVCCompiler, MSVCLinker), +} + + +class Ragel(object): + def __init__(self): + self.rlgen_flags = [] + self.ragel_flags = [] + self.ragel6_flags = [] + + def configure_toolchain(self, build, compiler): + if isinstance(compiler, MSVCCompiler): + self.set_default_flags(optimized=False) + elif isinstance(compiler, GnuCompiler): + self.set_default_flags(optimized=build.is_release and not build.is_sanitized) + else: + raise ConfigureError('Unexpected compiler {}'.format(compiler)) + + def set_default_flags(self, optimized): + if optimized: + self.rlgen_flags.append('-G2') + self.ragel6_flags.append('-CG2') + else: + self.rlgen_flags.append('-T0') + self.ragel6_flags.append('-CT0') + + def print_variables(self): + emit('RLGEN_FLAGS', self.rlgen_flags) + emit('RAGEL_FLAGS', self.ragel_flags) + emit('RAGEL6_FLAGS', self.ragel6_flags) + + +class Python(object): + def __init__(self, tc): + self.python = None + self.flags = None + self.ldflags = None + self.libraries = None + self.includes = None + self.tc = tc + + def configure_posix(self, python=None, python_config=None): + python = python or preset('PYTHON_BIN') or which('python') + python_config = python_config or preset('PYTHON_CONFIG') or which('python-config') + + if python is None or python_config is None: + return + + # python-config dumps each option on one line in the specified order + config = get_stdout([python_config, '--cflags', '--ldflags', '--includes']) or '' + config = config.split('\n') + if len(config) < 3: + return + + self.python = python + self.flags = config[0] + self.ldflags = config[1] + self.includes = config[2] + # Do not split libraries from ldflags. + # They are not used separately and get overriden together, so it is safe. + # TODO(somov): Удалить эту переменную и PYTHON_LIBRARIES из makelist-ов. + self.libraries = '' + if preset('USE_ARCADIA_PYTHON') == 'no' and not preset('USE_SYSTEM_PYTHON') and not self.tc.os_sdk_local: + raise Exception("Use fixed python (see https://clubs.at.yandex-team.ru/arcadia/15392) or set OS_SDK=local flag") + + def print_variables(self): + variables = Variables({ + 'PYTHON_BIN': self.python, + 'PYTHON_FLAGS': self.flags, + 'PYTHON_LDFLAGS': self.ldflags, + 'PYTHON_LIBRARIES': self.libraries, + 'PYTHON_INCLUDE': self.includes + }) + + variables.update_from_presets() + variables.reset_if_any(reset_value='PYTHON-NOT-FOUND') + variables.emit() + + +class Perl(object): + # Parse (key, value) from "version='5.26.0';" lines + PERL_CONFIG_RE = re.compile(r"^(?P<key>\w+)='(?P<value>.*)';$", re.MULTILINE) + + def __init__(self): + self.perl = None + self.version = None + self.privlib = None + self.archlib = None + + def configure_local(self, perl=None): + self.perl = perl or preset('PERL') or which('perl') + if self.perl is None: + return + + # noinspection PyTypeChecker + config = dict(self._iter_config(['version', 'privlibexp', 'archlibexp'])) + self.version = config.get('version') + self.privlib = config.get('privlibexp') + self.archlib = config.get('archlibexp') + + def print_variables(self, prefix=''): + variables = Variables({ + prefix + 'PERL': self.perl, + prefix + 'PERL_VERSION': self.version, + prefix + 'PERL_PRIVLIB': self.privlib, + prefix + 'PERL_ARCHLIB': self.archlib, + }) + + variables.reset_if_any(reset_value='PERL-NOT-FOUND') + variables.emit(with_ignore_comment=variables.keys()) + + def _iter_config(self, config_keys): + # Run perl -V:version -V:etc... + perl_config = [self.perl] + ['-V:{}'.format(key) for key in config_keys] + config = six.ensure_str(get_stdout(perl_config) or '') + + start = 0 + while True: + match = Perl.PERL_CONFIG_RE.search(config, start) + if match is None: + break + yield match.group('key', 'value') + start = match.end() + + +class Setting(object): + def __init__(self, key, auto=None, convert=None, rewrite=False): + self.key = key + + self.auto = auto + self.convert = convert + + self.preset = preset(key) + self.from_user = self.preset is not None + self.rewrite = rewrite + + self._value = Setting.no_value + + @property + def value(self): + if self._value is Setting.no_value: + self._value = self.calculate_value() + return self._value + + def calculate_value(self): + if not self.from_user: + return self.auto if not callable(self.auto) else self.auto() + else: + return self.preset if not self.convert else self.convert(self.preset) + + @value.setter + def value(self, value): + if self.from_user: + raise ConfigureError("Variable {key} already set by user to {old}. Can not change it's value to {new}".format(key=self.key, old=self._value, new=value)) + self._value = value + + def emit(self): + if not self.from_user or self.rewrite: + emit(self.key, self.value) + + no_value = object() + + +class Cuda(object): + def __init__(self, build): + """ + :type build: Build + """ + self.build = build + + self.have_cuda = Setting('HAVE_CUDA', auto=self.auto_have_cuda, convert=to_bool) + + self.cuda_root = Setting('CUDA_ROOT') + self.cuda_version = Setting('CUDA_VERSION', auto=self.auto_cuda_version, convert=self.convert_major_version, rewrite=True) + self.use_arcadia_cuda = Setting('USE_ARCADIA_CUDA', auto=self.auto_use_arcadia_cuda, convert=to_bool) + self.use_arcadia_cuda_host_compiler = Setting('USE_ARCADIA_CUDA_HOST_COMPILER', auto=self.auto_use_arcadia_cuda_host_compiler, convert=to_bool) + self.cuda_use_clang = Setting('CUDA_USE_CLANG', auto=False, convert=to_bool) + self.cuda_host_compiler = Setting('CUDA_HOST_COMPILER', auto=self.auto_cuda_host_compiler) + self.cuda_host_compiler_env = Setting('CUDA_HOST_COMPILER_ENV') + self.cuda_host_msvc_version = Setting('CUDA_HOST_MSVC_VERSION') + self.cuda_nvcc_flags = Setting('CUDA_NVCC_FLAGS', auto=[]) + + self.peerdirs = ['build/platform/cuda'] + + self.nvcc_flags = [ + # Allow __host__, __device__ annotations in lambda declaration. + "--expt-extended-lambda", + # Allow host code to invoke __device__ constexpr functions and vice versa + "--expt-relaxed-constexpr", + ] + + if not self.have_cuda.value: + return + + if self.cuda_host_compiler.value: + self.nvcc_flags.append('--compiler-bindir=$CUDA_HOST_COMPILER') + + if self.use_arcadia_cuda.value: + self.cuda_root.value = '$CUDA_RESOURCE_GLOBAL' + + if self.build.target.is_linux_x86_64 and self.build.tc.is_clang: + # TODO(somov): Эта настройка должна приезжать сюда автоматически из другого места + self.nvcc_flags.append('-I$OS_SDK_ROOT/usr/include/x86_64-linux-gnu') + + def print_(self): + self.print_variables() + self.print_macros() + print('@import "${CONF_ROOT}/conf/compilers/nvcc.conf"') + + def print_variables(self): + self.have_cuda.emit() + if not self.have_cuda.value: + return + + if self.use_arcadia_cuda.value and self.cuda_host_compiler.value is None: + logger.warning('$USE_ARCADIA_CUDA is set, but no $CUDA_HOST_COMPILER') + + self.setup_vc_root() + + self.cuda_root.emit() + self.cuda_version.emit() + self.use_arcadia_cuda.emit() + self.use_arcadia_cuda_host_compiler.emit() + self.cuda_use_clang.emit() + self.cuda_host_compiler.emit() + self.cuda_host_compiler_env.emit() + self.cuda_host_msvc_version.emit() + self.cuda_nvcc_flags.emit() + + emit('NVCC_UNQUOTED', self.build.host.exe('$CUDA_ROOT', 'bin', 'nvcc')) + emit('NVCC', '${quo:NVCC_UNQUOTED}') + emit('NVCC_FLAGS', self.nvcc_flags, '$CUDA_NVCC_FLAGS') + emit('NVCC_OBJ_EXT', '.o' if not self.build.target.is_windows else '.obj') + + def print_macros(self): + mtime = ' ' + if self.build.host_target[1].is_linux: + mtime = ' --mtime ${tool:"tools/mtime0"} ' + if not self.cuda_use_clang.value: + cmd = '$YMAKE_PYTHON ${input:"build/scripts/compile_cuda.py"}' + mtime + '$NVCC $NVCC_FLAGS -c ${input:SRC} -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:SRC} ${pre=-I:_C__INCLUDE} --cflags $C_FLAGS_PLATFORM $CXXFLAGS $NVCC_STD $NVCC_CFLAGS $SRCFLAGS ${input;hide:"build/platform/cuda/cuda_runtime_include.h"} $CUDA_HOST_COMPILER_ENV ${kv;hide:"p CC"} ${kv;hide:"pc light-green"}' # noqa E501 + else: + cmd = '$CXX_COMPILER --cuda-path=$CUDA_ROOT $C_FLAGS_PLATFORM -c ${input:SRC} -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:SRC} ${pre=-I:_C__INCLUDE} $CXXFLAGS $SRCFLAGS $TOOLCHAIN_ENV ${kv;hide:"p CU"} ${kv;hide:"pc green"}' # noqa E501 + + emit('_SRC_CU_CMD', cmd) + emit('_SRC_CU_PEERDIR', ' '.join(sorted(self.peerdirs))) + + def have_cuda_in_arcadia(self): + host, target = self.build.host_target + + if not any((host.is_linux_x86_64, host.is_macos_x86_64, host.is_windows_x86_64, host.is_linux_powerpc)): + return False + + if host != target: + if not(host.is_linux_x86_64 and target.is_linux_armv8): + return False + if not self.cuda_version.from_user: + return False + + if self.cuda_version.value in ('8.0', '9.0', '9.1', '9.2', '10.0'): + raise ConfigureError('CUDA versions 8.x, 9.x and 10.0 are no longer supported.\nSee DEVTOOLS-7108.') + + if self.cuda_version.value in ('10.1', '11.0', '11.1', '11.3', '11.4'): + return True + + return False + + def auto_have_cuda(self): + if is_positive('MUSL'): + return False + if self.build.is_sanitized: + return False + if self.build.host_target[1].is_macos_x86_64 or self.build.host_target[1].is_macos_arm64: + # DEVTOOLSSUPPORT-19178 CUDA is rarely needed on Mac. Disable it by default but allow explicit builds with CUDA. + return False + return self.cuda_root.from_user or self.use_arcadia_cuda.value and self.have_cuda_in_arcadia() + + def auto_cuda_version(self): + if self.use_arcadia_cuda.value: + return '10.1' + + if not self.have_cuda.value: + return None + + nvcc_exe = self.build.host.exe(os.path.expanduser(self.cuda_root.value), 'bin', 'nvcc') + + def error(): + raise ConfigureError('Failed to get CUDA version from {}'.format(nvcc_exe)) + + version_output = get_stdout([nvcc_exe, '--version']) or error() + match = re.search(r'^Cuda compilation tools, release (\d+)\.\d+,', version_output, re.MULTILINE) or error() + + return match.group(1) + + def convert_major_version(self, value): + if value == '10': + return '10.1' + elif value == '11': + return '11.3' + else: + return value + + def auto_use_arcadia_cuda(self): + return not self.cuda_root.from_user + + def auto_use_arcadia_cuda_host_compiler(self): + return not self.cuda_host_compiler.from_user and not self.cuda_use_clang.value + + def auto_cuda_host_compiler(self): + if not self.use_arcadia_cuda_host_compiler.value: + return None + + host, target = self.build.host_target + + if host.is_windows_x86_64 and target.is_windows_x86_64: + return self.cuda_windows_host_compiler() + + return select(( + (host.is_linux_x86_64 and target.is_linux_x86_64, '$CUDA_HOST_TOOLCHAIN_RESOURCE_GLOBAL/bin/clang'), + (host.is_linux_x86_64 and target.is_linux_armv8, '$CUDA_HOST_TOOLCHAIN_RESOURCE_GLOBAL/bin/clang'), + (host.is_linux_powerpc and target.is_linux_powerpc, '$CUDA_HOST_TOOLCHAIN_RESOURCE_GLOBAL/bin/clang'), + (host.is_macos_x86_64 and target.is_macos_x86_64, '$CUDA_HOST_TOOLCHAIN_RESOURCE_GLOBAL/usr/bin/clang'), + )) + + def cuda_windows_host_compiler(self): + vc_version = '14.28.29910' + + env = { + 'Y_VC_Version': vc_version, + 'Y_VC_Root': '$CUDA_HOST_TOOLCHAIN_RESOURCE_GLOBAL/VC/Tools/MSVC/{}'.format(vc_version), + 'Y_SDK_Version': self.build.tc.sdk_version, + 'Y_SDK_Root': '$WINDOWS_KITS_RESOURCE_GLOBAL', + } + + if not self.build.tc.ide_msvs: + self.peerdirs.append('build/platform/msvc') + self.cuda_host_compiler_env.value = format_env(env) + self.cuda_host_msvc_version.value = vc_version + return '%(Y_VC_Root)s/bin/HostX64/x64/cl.exe' % env + + def setup_vc_root(self): + if not self.cuda_host_compiler.from_user: + return # Already set in cuda_windows_host_compiler() + + if self.cuda_host_compiler_env.from_user: + return # We won't override user setting + + def is_root(dir): + return all(os.path.isdir(os.path.join(dir, name)) for name in ('bin', 'include', 'lib')) + + def get_root(): + path, old_path = os.path.normpath(self.cuda_host_compiler.value), None + while path != old_path: + if is_root(path): + return path + path, old_path = os.path.dirname(path), path + + vc_root = get_root() + if vc_root: + self.cuda_host_compiler_env.value = format_env({'Y_VC_Root': vc_root}) + + +class CuDNN(object): + def __init__(self, cuda): + """ + :type cuda: Cuda + """ + self.cuda = cuda + + self.cudnn_version = Setting('CUDNN_VERSION', auto=self.auto_cudnn_version) + + def have_cudnn(self): + return self.cudnn_version.value in ('7.6.5', '8.0.5') + + def auto_cudnn_version(self): + return '7.6.5' + + def print_(self): + if self.cuda.have_cuda.value and self.have_cudnn(): + self.cudnn_version.emit() + + +def print_swig_config(): + def get_swig_tool(): + tool = preset('USER_SWIG_TOOL') + if not tool: + tool = which('swig') + if not tool: + raise ConfigureError('SWIG_TOOL is not specified and "swig" is not found in PATH') + return os.path.abspath(tool) + + def get_swig_library(tool): + library = preset('USER_SWIG_LIBRARY') + if not library: + library, code = get_stdout_and_code((tool, '-swiglib')) + if code != 0: + raise ConfigureError('SWIG_LIBRARY is not specified and "{} -swiglib" failed'.format(tool)) + library = library.split('\n')[0] + return os.path.abspath(library) + + use_local_swig = to_bool(preset('USER_USE_LOCAL_SWIG'), False) or bool(preset('USER_SWIG_TOOL')) + if use_local_swig: + tool = get_swig_tool() + library = get_swig_library(tool) + + emit('USE_LOCAL_SWIG', True) + emit('SWIG_TOOL', tool) + emit('SWIG_LIBRARY', library) + + +def main(): + options = opts() + + arcadia = Arcadia(options.arcadia_root) + + ymake = YMake(arcadia) + + ymake.print_core_conf() + ymake.print_presets() + ymake.print_settings() + + build = Build(arcadia, options.build_type, options.toolchain_params, force_ignore_local_files=not options.local_distbuild) + build.print_build() + + emit_with_ignore_comment('CONF_SCRIPT_DEPENDS', __file__) + + +if __name__ == '__main__': + main() diff --git a/certs/ya.make b/certs/ya.make new file mode 100644 index 00000000000..9b0a45a13f2 --- /dev/null +++ b/certs/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +RESOURCE( + cacert.pem /builtin/cacert +) + +END() diff --git a/contrib/java/com/google/api/grpc/proto-google-common-protos/1.12.0/ya.make b/contrib/java/com/google/api/grpc/proto-google-common-protos/1.12.0/ya.make new file mode 100644 index 00000000000..ead2f94ff1d --- /dev/null +++ b/contrib/java/com/google/api/grpc/proto-google-common-protos/1.12.0/ya.make @@ -0,0 +1,12 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/java/com/google/protobuf/protobuf-java/3.5.1 +) + +JAR_RESOURCE(805479550) +SRC_RESOURCE(805477995) + +END() diff --git a/contrib/java/com/google/api/grpc/proto-google-common-protos/2.0.1/ya.make b/contrib/java/com/google/api/grpc/proto-google-common-protos/2.0.1/ya.make new file mode 100644 index 00000000000..4ca3f2bbdff --- /dev/null +++ b/contrib/java/com/google/api/grpc/proto-google-common-protos/2.0.1/ya.make @@ -0,0 +1,12 @@ +JAVA_CONTRIB(proto-google-common-protos-2.0.1) + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/java/com/google/protobuf/protobuf-java/3.13.0 +) + +JAR_RESOURCE(1965473130) +SRC_RESOURCE(1965469271) + +END() diff --git a/contrib/java/com/google/code/findbugs/jsr305/3.0.2/ya.make b/contrib/java/com/google/code/findbugs/jsr305/3.0.2/ya.make new file mode 100644 index 00000000000..7c757251a43 --- /dev/null +++ b/contrib/java/com/google/code/findbugs/jsr305/3.0.2/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +JAR_RESOURCE(289382642) +SRC_RESOURCE(289381370) + +END() diff --git a/contrib/java/com/google/errorprone/error_prone_annotations/2.5.1/ya.make b/contrib/java/com/google/errorprone/error_prone_annotations/2.5.1/ya.make new file mode 100644 index 00000000000..34990fe0430 --- /dev/null +++ b/contrib/java/com/google/errorprone/error_prone_annotations/2.5.1/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +JAR_RESOURCE(2155789749) +SRC_RESOURCE(2155789748) + +END() diff --git a/contrib/java/com/google/errorprone/error_prone_annotations/2.9.0/ya.make b/contrib/java/com/google/errorprone/error_prone_annotations/2.9.0/ya.make new file mode 100644 index 00000000000..d996574db1b --- /dev/null +++ b/contrib/java/com/google/errorprone/error_prone_annotations/2.9.0/ya.make @@ -0,0 +1,9 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +JAR_RESOURCE(2460308864) + +SRC_RESOURCE(2460308880) + +END() diff --git a/contrib/java/com/google/guava/failureaccess/1.0.1/ya.make b/contrib/java/com/google/guava/failureaccess/1.0.1/ya.make new file mode 100644 index 00000000000..2c07495f8e0 --- /dev/null +++ b/contrib/java/com/google/guava/failureaccess/1.0.1/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +JAR_RESOURCE(840516708) +SRC_RESOURCE(840517584) + +END() diff --git a/contrib/java/com/google/guava/guava/30.1.1-android/ya.make b/contrib/java/com/google/guava/guava/30.1.1-android/ya.make new file mode 100644 index 00000000000..da15f204f14 --- /dev/null +++ b/contrib/java/com/google/guava/guava/30.1.1-android/ya.make @@ -0,0 +1,18 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/java/com/google/guava/failureaccess/1.0.1 + contrib/java/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava + contrib/java/com/google/code/findbugs/jsr305/3.0.2 + contrib/java/org/checkerframework/checker-compat-qual/2.5.5 + contrib/java/com/google/errorprone/error_prone_annotations/2.5.1 + contrib/java/com/google/j2objc/j2objc-annotations/1.3 +) + +JAR_RESOURCE(2283859002) + +SRC_RESOURCE(2283859288) + +END() diff --git a/contrib/java/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/ya.make b/contrib/java/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/ya.make new file mode 100644 index 00000000000..67cb2123e68 --- /dev/null +++ b/contrib/java/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + + +JAR_RESOURCE(721500304) + +END() diff --git a/contrib/java/com/google/j2objc/j2objc-annotations/1.3/ya.make b/contrib/java/com/google/j2objc/j2objc-annotations/1.3/ya.make new file mode 100644 index 00000000000..17c3e547391 --- /dev/null +++ b/contrib/java/com/google/j2objc/j2objc-annotations/1.3/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +JAR_RESOURCE(1096776689) +SRC_RESOURCE(1096777023) + +END() diff --git a/contrib/java/com/google/protobuf/protobuf-java/3.13.0/ya.make b/contrib/java/com/google/protobuf/protobuf-java/3.13.0/ya.make new file mode 100644 index 00000000000..a271f676caa --- /dev/null +++ b/contrib/java/com/google/protobuf/protobuf-java/3.13.0/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB(protobuf-java-3.13.0) + +LICENSE(BSD-3-Clause) + +JAR_RESOURCE(1755015277) +SRC_RESOURCE(1755014752) + +END() diff --git a/contrib/java/com/google/protobuf/protobuf-java/3.19.2/ya.make b/contrib/java/com/google/protobuf/protobuf-java/3.19.2/ya.make new file mode 100644 index 00000000000..3ffb9f4e61f --- /dev/null +++ b/contrib/java/com/google/protobuf/protobuf-java/3.19.2/ya.make @@ -0,0 +1,9 @@ +JAVA_CONTRIB() + +LICENSE(BSD-3-Clause) + +JAR_RESOURCE(2758790421) + +SRC_RESOURCE(2758794869) + +END() diff --git a/contrib/java/com/google/protobuf/protobuf-java/3.21.12/ya.make b/contrib/java/com/google/protobuf/protobuf-java/3.21.12/ya.make new file mode 100644 index 00000000000..5233fe13d75 --- /dev/null +++ b/contrib/java/com/google/protobuf/protobuf-java/3.21.12/ya.make @@ -0,0 +1,9 @@ +JAVA_CONTRIB() + +LICENSE(BSD-3-Clause) + +JAR_RESOURCE(4136336433) + +SRC_RESOURCE(4136336434) + +END() diff --git a/contrib/java/com/google/protobuf/protobuf-java/3.5.1/ya.make b/contrib/java/com/google/protobuf/protobuf-java/3.5.1/ya.make new file mode 100644 index 00000000000..8c4499fe844 --- /dev/null +++ b/contrib/java/com/google/protobuf/protobuf-java/3.5.1/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(BSD-3-Clause) + +JAR_RESOURCE(593726696) +SRC_RESOURCE(593726660) + +END() diff --git a/contrib/java/com/google/protobuf/protobuf-javalite/3.19.2/ya.make b/contrib/java/com/google/protobuf/protobuf-javalite/3.19.2/ya.make new file mode 100644 index 00000000000..4d028e6089b --- /dev/null +++ b/contrib/java/com/google/protobuf/protobuf-javalite/3.19.2/ya.make @@ -0,0 +1,9 @@ +JAVA_CONTRIB() + +LICENSE(BSD-3-Clause) + +JAR_RESOURCE(2758794545) + +SRC_RESOURCE(2758793982) + +END() diff --git a/contrib/java/io/grpc/grpc-api/1.43.2/ya.make b/contrib/java/io/grpc/grpc-api/1.43.2/ya.make new file mode 100644 index 00000000000..adf8f2c23ec --- /dev/null +++ b/contrib/java/io/grpc/grpc-api/1.43.2/ya.make @@ -0,0 +1,16 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/java/io/grpc/grpc-context/1.43.2 + contrib/java/com/google/code/findbugs/jsr305/3.0.2 + contrib/java/com/google/guava/guava/30.1.1-android + contrib/java/com/google/errorprone/error_prone_annotations/2.9.0 +) + +JAR_RESOURCE(2954037905) + +SRC_RESOURCE(2954039734) + +END() diff --git a/contrib/java/io/grpc/grpc-context/1.43.2/ya.make b/contrib/java/io/grpc/grpc-context/1.43.2/ya.make new file mode 100644 index 00000000000..721c5d07859 --- /dev/null +++ b/contrib/java/io/grpc/grpc-context/1.43.2/ya.make @@ -0,0 +1,9 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +JAR_RESOURCE(2954036372) + +SRC_RESOURCE(2954039930) + +END() diff --git a/contrib/java/io/grpc/grpc-protobuf-lite/1.43.2/ya.make b/contrib/java/io/grpc/grpc-protobuf-lite/1.43.2/ya.make new file mode 100644 index 00000000000..c0311b06291 --- /dev/null +++ b/contrib/java/io/grpc/grpc-protobuf-lite/1.43.2/ya.make @@ -0,0 +1,16 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/java/io/grpc/grpc-api/1.43.2 + contrib/java/com/google/protobuf/protobuf-javalite/3.19.2 + contrib/java/com/google/code/findbugs/jsr305/3.0.2 + contrib/java/com/google/guava/guava/30.1.1-android +) + +JAR_RESOURCE(2954030659) + +SRC_RESOURCE(2954036247) + +END() diff --git a/contrib/java/io/grpc/grpc-protobuf/1.43.2/ya.make b/contrib/java/io/grpc/grpc-protobuf/1.43.2/ya.make new file mode 100644 index 00000000000..027fd80f2e3 --- /dev/null +++ b/contrib/java/io/grpc/grpc-protobuf/1.43.2/ya.make @@ -0,0 +1,20 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/java/io/grpc/grpc-api/1.43.2 + contrib/java/com/google/code/findbugs/jsr305/3.0.2 + contrib/java/com/google/protobuf/protobuf-java/3.19.2 + contrib/java/com/google/api/grpc/proto-google-common-protos/2.0.1 + contrib/java/io/grpc/grpc-protobuf-lite/1.43.2 + contrib/java/com/google/guava/guava/30.1.1-android +) + +JAR_RESOURCE(2954038238) + +SRC_RESOURCE(2954032072) + +EXCLUDE(contrib/java/com/google/protobuf/protobuf-javalite/3.19.2) + +END() diff --git a/contrib/java/io/grpc/grpc-stub/1.43.2/ya.make b/contrib/java/io/grpc/grpc-stub/1.43.2/ya.make new file mode 100644 index 00000000000..e7d7303f241 --- /dev/null +++ b/contrib/java/io/grpc/grpc-stub/1.43.2/ya.make @@ -0,0 +1,15 @@ +JAVA_CONTRIB() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/java/io/grpc/grpc-api/1.43.2 + contrib/java/com/google/guava/guava/30.1.1-android + contrib/java/com/google/errorprone/error_prone_annotations/2.9.0 +) + +JAR_RESOURCE(2954038095) + +SRC_RESOURCE(2954031489) + +END() diff --git a/contrib/java/javax/annotation/javax.annotation-api/1.3.1/ya.make b/contrib/java/javax/annotation/javax.annotation-api/1.3.1/ya.make new file mode 100644 index 00000000000..28a71b8ea1b --- /dev/null +++ b/contrib/java/javax/annotation/javax.annotation-api/1.3.1/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(CDDL-1.0) + +JAR_RESOURCE(545709491) +SRC_RESOURCE(545709503) + +END() diff --git a/contrib/java/org/checkerframework/checker-compat-qual/2.5.5/ya.make b/contrib/java/org/checkerframework/checker-compat-qual/2.5.5/ya.make new file mode 100644 index 00000000000..79854122a88 --- /dev/null +++ b/contrib/java/org/checkerframework/checker-compat-qual/2.5.5/ya.make @@ -0,0 +1,8 @@ +JAVA_CONTRIB() + +LICENSE(MIT) + +JAR_RESOURCE(947906909) +SRC_RESOURCE(947905977) + +END() diff --git a/contrib/libs/antlr3_cpp_runtime/ya.make b/contrib/libs/antlr3_cpp_runtime/ya.make new file mode 100644 index 00000000000..cad4d64c0a9 --- /dev/null +++ b/contrib/libs/antlr3_cpp_runtime/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +# git repository: https://github.com/ibre5041/antlr3.git +# XXX fork of: https://github.com/antlr/antlr3.git +# directory: runtime/Cpp +# revision: a4d1928e03b2b3f74579e54a6211cd1d695001b9 + +VERSION(2016-03-31-a4d1928e03b2b3f74579e54a6211cd1d695001b9) + +LICENSE( + BSD-3-Clause AND + Unicode-Mappings +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_COMPILER_WARNINGS() + +ADDINCL( + GLOBAL contrib/libs/antlr3_cpp_runtime/include +) + +SRCS( + antlr3.cpp +) + +END() diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/python/ya.make b/contrib/libs/apache/arrow/cpp/src/arrow/python/ya.make new file mode 100644 index 00000000000..08514d24606 --- /dev/null +++ b/contrib/libs/apache/arrow/cpp/src/arrow/python/ya.make @@ -0,0 +1,58 @@ +# Generated by devtools/yamaker. + +PY3_LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/apache/arrow + contrib/libs/python/Include + contrib/python/numpy +) + +ADDINCL( + contrib/libs/apache/arrow/cpp/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DARROW_HDFS + -DARROW_PYTHON_EXPORTING + -DARROW_WITH_BROTLI + -DARROW_WITH_LZ4 + -DARROW_WITH_RE2 + -DARROW_WITH_SNAPPY + -DARROW_WITH_TIMING_TESTS + -DARROW_WITH_UTF8PROC + -DARROW_WITH_ZLIB + -DARROW_WITH_ZSTD + -DURI_STATIC_BUILD +) + +SRCS( + arrow_to_pandas.cc + benchmark.cc + common.cc + datetime.cc + decimal.cc + deserialize.cc + extension_type.cc + filesystem.cc + helpers.cc + inference.cc + init.cc + io.cc + ipc.cc + numpy_convert.cc + numpy_to_arrow.cc + pyarrow.cc + python_to_arrow.cc + serialize.cc +) + +END() diff --git a/contrib/libs/apache/arrow/ya.make b/contrib/libs/apache/arrow/ya.make new file mode 100644 index 00000000000..b0e4a6b2d20 --- /dev/null +++ b/contrib/libs/apache/arrow/ya.make @@ -0,0 +1,291 @@ +# Generated by devtools/yamaker from nixpkgs 3322db8e36d0b32700737d8de7315bd9e9c2b21a. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + BSD-2-Clause AND + BSD-3-Clause AND + BSL-1.0 AND + CC0-1.0 AND + MIT AND + NCSA AND + Protobuf-License AND + Public-Domain AND + ZPL-2.1 AND + Zlib +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(5.0.0) + +ORIGINAL_SOURCE(https://github.com/apache/arrow/archive/apache-arrow-5.0.0.tar.gz) + +PEERDIR( + contrib/libs/apache/orc + contrib/libs/brotli/dec + contrib/libs/brotli/enc + contrib/libs/double-conversion + contrib/libs/lz4 + contrib/libs/rapidjson + contrib/libs/re2 + contrib/libs/snappy + contrib/libs/utf8proc + contrib/libs/xxhash + contrib/libs/zlib + contrib/libs/zstd + contrib/restricted/fast_float + contrib/restricted/thrift + contrib/restricted/uriparser +) + +ADDINCL( + GLOBAL contrib/libs/apache/arrow/cpp/src + GLOBAL contrib/libs/apache/arrow/src + contrib/libs/apache/arrow/cpp/src/generated + contrib/libs/apache/orc/c++/include + contrib/libs/flatbuffers/include + contrib/libs/lz4 + contrib/libs/rapidjson/include + contrib/libs/re2 + contrib/libs/utf8proc + contrib/libs/zstd/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + GLOBAL -DARROW_STATIC + GLOBAL -DPARQUET_STATIC + -DARROW_EXPORTING + -DARROW_WITH_BROTLI + -DARROW_WITH_LZ4 + -DARROW_WITH_RE2 + -DARROW_WITH_SNAPPY + -DARROW_WITH_TIMING_TESTS + -DARROW_WITH_UTF8PROC + -DARROW_WITH_ZLIB + -DARROW_WITH_ZSTD + -DHAVE_INTTYPES_H + -DHAVE_NETDB_H + -DPARQUET_EXPORTING + -DURI_STATIC_BUILD +) + +IF (NOT OS_WINDOWS) + CFLAGS( + -DHAVE_NETINET_IN_H + ) +ENDIF() + +SRCS( + cpp/src/arrow/adapters/orc/adapter.cc + cpp/src/arrow/adapters/orc/adapter_util.cc + cpp/src/arrow/array/array_base.cc + cpp/src/arrow/array/array_binary.cc + cpp/src/arrow/array/array_decimal.cc + cpp/src/arrow/array/array_dict.cc + cpp/src/arrow/array/array_nested.cc + cpp/src/arrow/array/array_primitive.cc + cpp/src/arrow/array/builder_adaptive.cc + cpp/src/arrow/array/builder_base.cc + cpp/src/arrow/array/builder_binary.cc + cpp/src/arrow/array/builder_decimal.cc + cpp/src/arrow/array/builder_dict.cc + cpp/src/arrow/array/builder_nested.cc + cpp/src/arrow/array/builder_primitive.cc + cpp/src/arrow/array/builder_union.cc + cpp/src/arrow/array/concatenate.cc + cpp/src/arrow/array/data.cc + cpp/src/arrow/array/diff.cc + cpp/src/arrow/array/util.cc + cpp/src/arrow/array/validate.cc + cpp/src/arrow/buffer.cc + cpp/src/arrow/builder.cc + cpp/src/arrow/c/bridge.cc + cpp/src/arrow/chunked_array.cc + cpp/src/arrow/compare.cc + cpp/src/arrow/compute/api_aggregate.cc + cpp/src/arrow/compute/api_scalar.cc + cpp/src/arrow/compute/api_vector.cc + cpp/src/arrow/compute/cast.cc + cpp/src/arrow/compute/exec.cc + cpp/src/arrow/compute/exec/exec_plan.cc + cpp/src/arrow/compute/exec/expression.cc + cpp/src/arrow/compute/exec/key_compare.cc + cpp/src/arrow/compute/exec/key_encode.cc + cpp/src/arrow/compute/exec/key_hash.cc + cpp/src/arrow/compute/exec/key_map.cc + cpp/src/arrow/compute/exec/util.cc + cpp/src/arrow/compute/function.cc + cpp/src/arrow/compute/function_internal.cc + cpp/src/arrow/compute/kernel.cc + cpp/src/arrow/compute/kernels/aggregate_basic.cc + cpp/src/arrow/compute/kernels/aggregate_mode.cc + cpp/src/arrow/compute/kernels/aggregate_quantile.cc + cpp/src/arrow/compute/kernels/aggregate_tdigest.cc + cpp/src/arrow/compute/kernels/aggregate_var_std.cc + cpp/src/arrow/compute/kernels/codegen_internal.cc + cpp/src/arrow/compute/kernels/hash_aggregate.cc + cpp/src/arrow/compute/kernels/scalar_arithmetic.cc + cpp/src/arrow/compute/kernels/scalar_boolean.cc + cpp/src/arrow/compute/kernels/scalar_cast_boolean.cc + cpp/src/arrow/compute/kernels/scalar_cast_dictionary.cc + cpp/src/arrow/compute/kernels/scalar_cast_internal.cc + cpp/src/arrow/compute/kernels/scalar_cast_nested.cc + cpp/src/arrow/compute/kernels/scalar_cast_numeric.cc + cpp/src/arrow/compute/kernels/scalar_cast_string.cc + cpp/src/arrow/compute/kernels/scalar_cast_temporal.cc + cpp/src/arrow/compute/kernels/scalar_compare.cc + cpp/src/arrow/compute/kernels/scalar_fill_null.cc + cpp/src/arrow/compute/kernels/scalar_if_else.cc + cpp/src/arrow/compute/kernels/scalar_nested.cc + cpp/src/arrow/compute/kernels/scalar_set_lookup.cc + cpp/src/arrow/compute/kernels/scalar_string.cc + cpp/src/arrow/compute/kernels/scalar_temporal.cc + cpp/src/arrow/compute/kernels/scalar_validity.cc + cpp/src/arrow/compute/kernels/util_internal.cc + cpp/src/arrow/compute/kernels/vector_hash.cc + cpp/src/arrow/compute/kernels/vector_nested.cc + cpp/src/arrow/compute/kernels/vector_replace.cc + cpp/src/arrow/compute/kernels/vector_selection.cc + cpp/src/arrow/compute/kernels/vector_sort.cc + cpp/src/arrow/compute/registry.cc + cpp/src/arrow/config.cc + cpp/src/arrow/csv/chunker.cc + cpp/src/arrow/csv/column_builder.cc + cpp/src/arrow/csv/column_decoder.cc + cpp/src/arrow/csv/converter.cc + cpp/src/arrow/csv/options.cc + cpp/src/arrow/csv/parser.cc + cpp/src/arrow/csv/reader.cc + cpp/src/arrow/csv/writer.cc + cpp/src/arrow/datum.cc + cpp/src/arrow/device.cc + cpp/src/arrow/extension_type.cc + cpp/src/arrow/filesystem/filesystem.cc + cpp/src/arrow/filesystem/localfs.cc + cpp/src/arrow/filesystem/mockfs.cc + cpp/src/arrow/filesystem/path_util.cc + cpp/src/arrow/filesystem/util_internal.cc + cpp/src/arrow/io/buffered.cc + cpp/src/arrow/io/caching.cc + cpp/src/arrow/io/compressed.cc + cpp/src/arrow/io/file.cc + cpp/src/arrow/io/interfaces.cc + cpp/src/arrow/io/memory.cc + cpp/src/arrow/io/slow.cc + cpp/src/arrow/io/stdio.cc + cpp/src/arrow/io/transform.cc + cpp/src/arrow/ipc/dictionary.cc + cpp/src/arrow/ipc/feather.cc + cpp/src/arrow/ipc/json_simple.cc + cpp/src/arrow/ipc/message.cc + cpp/src/arrow/ipc/metadata_internal.cc + cpp/src/arrow/ipc/options.cc + cpp/src/arrow/ipc/reader.cc + cpp/src/arrow/ipc/writer.cc + cpp/src/arrow/json/chunked_builder.cc + cpp/src/arrow/json/chunker.cc + cpp/src/arrow/json/converter.cc + cpp/src/arrow/json/object_parser.cc + cpp/src/arrow/json/object_writer.cc + cpp/src/arrow/json/options.cc + cpp/src/arrow/json/parser.cc + cpp/src/arrow/json/reader.cc + cpp/src/arrow/memory_pool.cc + cpp/src/arrow/pretty_print.cc + cpp/src/arrow/record_batch.cc + cpp/src/arrow/result.cc + cpp/src/arrow/scalar.cc + cpp/src/arrow/sparse_tensor.cc + cpp/src/arrow/status.cc + cpp/src/arrow/table.cc + cpp/src/arrow/table_builder.cc + cpp/src/arrow/tensor.cc + cpp/src/arrow/tensor/coo_converter.cc + cpp/src/arrow/tensor/csf_converter.cc + cpp/src/arrow/tensor/csx_converter.cc + cpp/src/arrow/type.cc + cpp/src/arrow/util/basic_decimal.cc + cpp/src/arrow/util/bit_block_counter.cc + cpp/src/arrow/util/bit_run_reader.cc + cpp/src/arrow/util/bit_util.cc + cpp/src/arrow/util/bitmap.cc + cpp/src/arrow/util/bitmap_builders.cc + cpp/src/arrow/util/bitmap_ops.cc + cpp/src/arrow/util/bpacking.cc + cpp/src/arrow/util/cancel.cc + cpp/src/arrow/util/compression.cc + cpp/src/arrow/util/compression_brotli.cc + cpp/src/arrow/util/compression_lz4.cc + cpp/src/arrow/util/compression_snappy.cc + cpp/src/arrow/util/compression_zlib.cc + cpp/src/arrow/util/compression_zstd.cc + cpp/src/arrow/util/cpu_info.cc + cpp/src/arrow/util/decimal.cc + cpp/src/arrow/util/delimiting.cc + cpp/src/arrow/util/formatting.cc + cpp/src/arrow/util/future.cc + cpp/src/arrow/util/int_util.cc + cpp/src/arrow/util/io_util.cc + cpp/src/arrow/util/key_value_metadata.cc + cpp/src/arrow/util/logging.cc + cpp/src/arrow/util/memory.cc + cpp/src/arrow/util/mutex.cc + cpp/src/arrow/util/string.cc + cpp/src/arrow/util/string_builder.cc + cpp/src/arrow/util/task_group.cc + cpp/src/arrow/util/tdigest.cc + cpp/src/arrow/util/thread_pool.cc + cpp/src/arrow/util/time.cc + cpp/src/arrow/util/trie.cc + cpp/src/arrow/util/uri.cc + cpp/src/arrow/util/utf8.cc + cpp/src/arrow/util/value_parsing.cc + cpp/src/arrow/vendored/base64.cpp + cpp/src/arrow/vendored/datetime/tz.cpp + cpp/src/arrow/vendored/musl/strptime.c + cpp/src/arrow/visitor.cc + cpp/src/generated/parquet_constants.cpp + cpp/src/generated/parquet_types.cpp + cpp/src/parquet/arrow/path_internal.cc + cpp/src/parquet/arrow/reader.cc + cpp/src/parquet/arrow/reader_internal.cc + cpp/src/parquet/arrow/schema.cc + cpp/src/parquet/arrow/schema_internal.cc + cpp/src/parquet/arrow/writer.cc + cpp/src/parquet/bloom_filter.cc + cpp/src/parquet/column_reader.cc + cpp/src/parquet/column_scanner.cc + cpp/src/parquet/column_writer.cc + cpp/src/parquet/encoding.cc + cpp/src/parquet/encryption/encryption.cc + cpp/src/parquet/encryption/encryption_internal_nossl.cc + cpp/src/parquet/encryption/internal_file_decryptor.cc + cpp/src/parquet/encryption/internal_file_encryptor.cc + cpp/src/parquet/exception.cc + cpp/src/parquet/file_reader.cc + cpp/src/parquet/file_writer.cc + cpp/src/parquet/level_comparison.cc + cpp/src/parquet/level_conversion.cc + cpp/src/parquet/metadata.cc + cpp/src/parquet/murmur3.cc + cpp/src/parquet/platform.cc + cpp/src/parquet/printer.cc + cpp/src/parquet/properties.cc + cpp/src/parquet/schema.cc + cpp/src/parquet/statistics.cc + cpp/src/parquet/stream_reader.cc + cpp/src/parquet/stream_writer.cc + cpp/src/parquet/types.cc +) + +END() + +RECURSE( + cpp/src/arrow/python +) diff --git a/contrib/libs/apache/avro/ya.make b/contrib/libs/apache/avro/ya.make new file mode 100644 index 00000000000..31d4aac915d --- /dev/null +++ b/contrib/libs/apache/avro/ya.make @@ -0,0 +1,76 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + BSL-1.0 AND + FSFAP +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.11.1) + +ORIGINAL_SOURCE(https://github.com/apache/avro/archive/release-1.11.1.tar.gz) + +PEERDIR( + contrib/libs/snappy + contrib/restricted/boost/any + contrib/restricted/boost/asio + contrib/restricted/boost/crc + contrib/restricted/boost/format + contrib/restricted/boost/iostreams + contrib/restricted/boost/math +) + +ADDINCL( + contrib/libs/apache/avro/api +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DAVRO_SOURCE + -DAVRO_VERSION=\"1.11.1\" + -DBOOST_ALL_NO_LIB + -DBOOST_ATOMIC_DYN_LINK + -DBOOST_FILESYSTEM_DYN_LINK + -DBOOST_IOSTREAMS_DYN_LINK + -DBOOST_PROGRAM_OPTIONS_DYN_LINK + -DBOOST_REGEX_DYN_LINK + -DBOOST_SYSTEM_DYN_LINK + -DSNAPPY_CODEC_AVAILABLE +) + +SRCS( + impl/BinaryDecoder.cc + impl/BinaryEncoder.cc + impl/Compiler.cc + impl/CustomFields.cc + impl/DataFile.cc + impl/FileStream.cc + impl/Generic.cc + impl/GenericDatum.cc + impl/LogicalType.cc + impl/Node.cc + impl/NodeImpl.cc + impl/Resolver.cc + impl/ResolverSchema.cc + impl/Schema.cc + impl/Stream.cc + impl/Types.cc + impl/ValidSchema.cc + impl/Validator.cc + impl/Zigzag.cc + impl/json/JsonDom.cc + impl/json/JsonIO.cc + impl/parsing/JsonCodec.cc + impl/parsing/ResolvingDecoder.cc + impl/parsing/Symbol.cc + impl/parsing/ValidatingCodec.cc +) + +END() diff --git a/contrib/libs/apache/orc/ya.make b/contrib/libs/apache/orc/ya.make new file mode 100644 index 00000000000..54933bd7101 --- /dev/null +++ b/contrib/libs/apache/orc/ya.make @@ -0,0 +1,70 @@ +# Generated by devtools/yamaker from nixpkgs e392df43c9f302d4a0892caaadcad3cd693edf9e. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.8.0) + +ORIGINAL_SOURCE(https://github.com/apache/orc/archive/rel/release-1.8.0.tar.gz) + +PEERDIR( + contrib/libs/lz4 + contrib/libs/snappy + contrib/libs/zlib + contrib/libs/zstd +) + +ADDINCL( + GLOBAL contrib/libs/apache/orc/c++/include + contrib/libs/apache/orc/c++/src + contrib/libs/apache/orc/proto + contrib/libs/lz4 + contrib/libs/zstd/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + c++/src/Adaptor.cc + c++/src/BloomFilter.cc + c++/src/ByteRLE.cc + c++/src/ColumnPrinter.cc + c++/src/ColumnReader.cc + c++/src/ColumnWriter.cc + c++/src/Common.cc + c++/src/Compression.cc + c++/src/Exceptions.cc + c++/src/Int128.cc + c++/src/LzoDecompressor.cc + c++/src/MemoryPool.cc + c++/src/Murmur3.cc + c++/src/OrcFile.cc + c++/src/RLE.cc + c++/src/RLEV2Util.cc + c++/src/RLEv1.cc + c++/src/Reader.cc + c++/src/RleDecoderV2.cc + c++/src/RleEncoderV2.cc + c++/src/Statistics.cc + c++/src/StripeStream.cc + c++/src/Timezone.cc + c++/src/TypeImpl.cc + c++/src/Vector.cc + c++/src/Writer.cc + c++/src/io/InputStream.cc + c++/src/io/OutputStream.cc + c++/src/sargs/ExpressionTree.cc + c++/src/sargs/Literal.cc + c++/src/sargs/PredicateLeaf.cc + c++/src/sargs/SargsApplier.cc + c++/src/sargs/SearchArgument.cc + c++/src/sargs/TruthValue.cc + proto/orc_proto.proto +) + +END() diff --git a/contrib/libs/asmglibc/ya.make b/contrib/libs/asmglibc/ya.make new file mode 100644 index 00000000000..c64ea8388a9 --- /dev/null +++ b/contrib/libs/asmglibc/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +LICENSE(LGPL-2.1-or-later) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2.27) + +ORIGINAL_SOURCE(http://ftp.gnu.org/gnu/glibc/) + +NO_PLATFORM() + +SRCS( + memchr.S +) + +END() diff --git a/contrib/libs/asmlib/ya.make b/contrib/libs/asmlib/ya.make new file mode 100644 index 00000000000..35baa5a7a2c --- /dev/null +++ b/contrib/libs/asmlib/ya.make @@ -0,0 +1,110 @@ +LIBRARY() + +LICENSE( + GPL-1.0-or-later AND + GPL-2.0-only AND + GPL-3.0-or-later AND + LGPL-2.0-or-later AND + LGPL-3.0-only +) + +VERSION(2016-11-16) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ORIGINAL_SOURCE(https://www.agner.org/optimize/) + +NO_PLATFORM() + +SET(_YASM_PREDEFINED_FLAGS_VALUE "") + +IF (ARCH_X86_64) + IF (OS_DARWIN) + PEERDIR( + contrib/libs/asmglibc + ) + ENDIF() + IF (NOT OS_DARWIN) + SRCS( + sfmt64.asm + mother64.asm + mersenne64.asm + ) + ENDIF() + SRCS( + debugbreak64.asm + cachesize64.asm + divfixedi64.asm + rdtsc64.asm + strcat64.asm + unalignedisfaster64.asm + strcpy64.asm + substring64.asm + strlen64.asm + cputype64.asm + memcmp64.asm + memmove64.asm + stricmp64.asm + divfixedv64.asm + physseed64.asm + cpuid64.asm + round64.asm + memcpy64.asm + popcount64.asm + dispatchpatch64.asm + #instrset64.asm + procname64.asm + memset64.asm + #disabled because of protection violation + #strcountutf864.asm + #strcountset64.asm + #strtouplow64.asm + #strcmp64.asm + #strspn64.asm + #strstr64.asm + ) +ENDIF() + +IF (ARCH_I386) + SRCS( + debugbreak32.asm + cachesize32.asm + divfixedi32.asm + rdtsc32.asm + strcat32.asm + unalignedisfaster32.asm + strcpy32.asm + substring32.asm + strlen32.asm + cputype32.asm + memcmp32.asm + memmove32.asm + sfmt32.asm + stricmp32.asm + divfixedv32.asm + physseed32.asm + cpuid32.asm + mother32.asm + round32.asm + mersenne32.asm + memcpy32.asm + popcount32.asm + dispatchpatch32.asm + #instrset32.asm + procname32.asm + memset32.asm + #disabled because of protection violation + #strcountutf832.asm + #strcountset32.asm + #strtouplow32.asm + #strcmp32.asm + #strspn32.asm + #strstr32.asm + ) +ENDIF() + +SRCS( + dummy.c +) + +END() diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/ya.make b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/ya.make new file mode 100644 index 00000000000..bdbeda12d74 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/ya.make @@ -0,0 +1,172 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + MIT AND + Zlib +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/curl + contrib/libs/openssl + contrib/restricted/aws/aws-c-common + contrib/restricted/aws/aws-c-event-stream +) + +ADDINCL( + GLOBAL contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DAWS_CAL_USE_IMPORT_EXPORT + -DAWS_CHECKSUMS_USE_IMPORT_EXPORT + -DAWS_COMMON_USE_IMPORT_EXPORT + -DAWS_EVENT_STREAM_USE_IMPORT_EXPORT + -DAWS_IO_USE_IMPORT_EXPORT + -DAWS_SDK_VERSION_MAJOR=1 + -DAWS_SDK_VERSION_MINOR=8 + -DAWS_SDK_VERSION_PATCH=186 + -DAWS_USE_EPOLL + -DCURL_HAS_H2 + -DCURL_HAS_TLS_PROXY + -DENABLE_CURL_CLIENT + -DENABLE_CURL_LOGGING + -DENABLE_OPENSSL_ENCRYPTION + -DHAS_PATHCONF + -DHAS_UMASK + -DS2N_ADX + -DS2N_BIKE_R3_AVX2 + -DS2N_BIKE_R3_AVX512 + -DS2N_BIKE_R3_PCLMUL + -DS2N_BIKE_R3_VPCLMUL + -DS2N_CPUID_AVAILABLE + -DS2N_FALL_THROUGH_SUPPORTED + -DS2N_HAVE_EXECINFO + -DS2N_KYBER512R3_AVX2_BMI2 + -DS2N_SIKE_P434_R3_ASM + -DS2N___RESTRICT__SUPPORTED +) + +SRCS( + source/AmazonSerializableWebServiceRequest.cpp + source/AmazonStreamingWebServiceRequest.cpp + source/AmazonWebServiceRequest.cpp + source/Aws.cpp + source/Globals.cpp + source/Region.cpp + source/Version.cpp + source/auth/AWSAuthSigner.cpp + source/auth/AWSAuthSignerProvider.cpp + source/auth/AWSCredentialsProvider.cpp + source/auth/AWSCredentialsProviderChain.cpp + source/auth/SSOCredentialsProvider.cpp + source/auth/STSCredentialsProvider.cpp + source/client/AWSClient.cpp + source/client/AWSErrorMarshaller.cpp + source/client/AsyncCallerContext.cpp + source/client/ClientConfiguration.cpp + source/client/CoreErrors.cpp + source/client/DefaultRetryStrategy.cpp + source/client/RetryStrategy.cpp + source/client/SpecifiedRetryableErrorsRetryStrategy.cpp + source/config/AWSProfileConfigLoader.cpp + source/external/cjson/cJSON.cpp + source/external/tinyxml2/tinyxml2.cpp + source/http/HttpClient.cpp + source/http/HttpClientFactory.cpp + source/http/HttpRequest.cpp + source/http/HttpTypes.cpp + source/http/Scheme.cpp + source/http/URI.cpp + source/http/curl/CurlHandleContainer.cpp + source/http/curl/CurlHttpClient.cpp + source/http/standard/StandardHttpRequest.cpp + source/http/standard/StandardHttpResponse.cpp + source/internal/AWSHttpResourceClient.cpp + source/monitoring/DefaultMonitoring.cpp + source/monitoring/HttpClientMetrics.cpp + source/monitoring/MonitoringManager.cpp + source/utils/ARN.cpp + source/utils/Array.cpp + source/utils/DNS.cpp + source/utils/DateTimeCommon.cpp + source/utils/Directory.cpp + source/utils/EnumParseOverflowContainer.cpp + source/utils/FileSystemUtils.cpp + source/utils/GetTheLights.cpp + source/utils/HashingUtils.cpp + source/utils/StringUtils.cpp + source/utils/TempFile.cpp + source/utils/UUID.cpp + source/utils/base64/Base64.cpp + source/utils/crypto/Cipher.cpp + source/utils/crypto/ContentCryptoMaterial.cpp + source/utils/crypto/ContentCryptoScheme.cpp + source/utils/crypto/CryptoBuf.cpp + source/utils/crypto/CryptoStream.cpp + source/utils/crypto/EncryptionMaterials.cpp + source/utils/crypto/KeyWrapAlgorithm.cpp + source/utils/crypto/MD5.cpp + source/utils/crypto/Sha1.cpp + source/utils/crypto/Sha256.cpp + source/utils/crypto/Sha256HMAC.cpp + source/utils/crypto/factory/Factories.cpp + source/utils/crypto/openssl/CryptoImpl.cpp + source/utils/event/EventDecoderStream.cpp + source/utils/event/EventEncoderStream.cpp + source/utils/event/EventHeader.cpp + source/utils/event/EventMessage.cpp + source/utils/event/EventStreamBuf.cpp + source/utils/event/EventStreamDecoder.cpp + source/utils/event/EventStreamEncoder.cpp + source/utils/event/EventStreamErrors.cpp + source/utils/json/JsonSerializer.cpp + source/utils/logging/AWSLogging.cpp + source/utils/logging/ConsoleLogSystem.cpp + source/utils/logging/DefaultLogSystem.cpp + source/utils/logging/FormattedLogSystem.cpp + source/utils/logging/LogLevel.cpp + source/utils/memory/AWSMemory.cpp + source/utils/memory/stl/SimpleStringStream.cpp + source/utils/stream/ConcurrentStreamBuf.cpp + source/utils/stream/PreallocatedStreamBuf.cpp + source/utils/stream/ResponseStream.cpp + source/utils/stream/SimpleStreamBuf.cpp + source/utils/threading/Executor.cpp + source/utils/threading/ReaderWriterLock.cpp + source/utils/threading/Semaphore.cpp + source/utils/threading/ThreadTask.cpp + source/utils/xml/XmlSerializer.cpp +) + +IF (OS_WINDOWS) + SRCS( + source/net/windows/Net.cpp + source/net/windows/SimpleUDP.cpp + source/platform/windows/Environment.cpp + source/platform/windows/FileSystem.cpp + source/platform/windows/OSVersionInfo.cpp + source/platform/windows/Security.cpp + source/platform/windows/Time.cpp + ) +ELSE() + SRCS( + source/net/linux-shared/Net.cpp + source/net/linux-shared/SimpleUDP.cpp + source/platform/linux-shared/Environment.cpp + source/platform/linux-shared/FileSystem.cpp + source/platform/linux-shared/OSVersionInfo.cpp + source/platform/linux-shared/Security.cpp + source/platform/linux-shared/Time.cpp + ) +ENDIF() + +END() diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/ya.make b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/ya.make new file mode 100644 index 00000000000..154df74f77e --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/ya.make @@ -0,0 +1,392 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core + contrib/restricted/aws/aws-c-common + contrib/restricted/aws/aws-c-event-stream +) + +ADDINCL( + GLOBAL contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3/include + contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DAWS_CAL_USE_IMPORT_EXPORT + -DAWS_CHECKSUMS_USE_IMPORT_EXPORT + -DAWS_COMMON_USE_IMPORT_EXPORT + -DAWS_EVENT_STREAM_USE_IMPORT_EXPORT + -DAWS_IO_USE_IMPORT_EXPORT + -DAWS_SDK_VERSION_MAJOR=1 + -DAWS_SDK_VERSION_MINOR=8 + -DAWS_SDK_VERSION_PATCH=186 + -DAWS_USE_EPOLL + -DENABLE_CURL_CLIENT + -DENABLE_OPENSSL_ENCRYPTION + -DHAS_PATHCONF + -DHAS_UMASK + -DS2N_ADX + -DS2N_BIKE_R3_AVX2 + -DS2N_BIKE_R3_AVX512 + -DS2N_BIKE_R3_PCLMUL + -DS2N_BIKE_R3_VPCLMUL + -DS2N_CPUID_AVAILABLE + -DS2N_FALL_THROUGH_SUPPORTED + -DS2N_HAVE_EXECINFO + -DS2N_KYBER512R3_AVX2_BMI2 + -DS2N_SIKE_P434_R3_ASM + -DS2N___RESTRICT__SUPPORTED +) + +SRCS( + source/S3ARN.cpp + source/S3Client.cpp + source/S3Endpoint.cpp + source/S3ErrorMarshaller.cpp + source/S3Errors.cpp + source/model/AbortIncompleteMultipartUpload.cpp + source/model/AbortMultipartUploadRequest.cpp + source/model/AbortMultipartUploadResult.cpp + source/model/AccelerateConfiguration.cpp + source/model/AccessControlPolicy.cpp + source/model/AccessControlTranslation.cpp + source/model/AnalyticsAndOperator.cpp + source/model/AnalyticsConfiguration.cpp + source/model/AnalyticsExportDestination.cpp + source/model/AnalyticsFilter.cpp + source/model/AnalyticsS3BucketDestination.cpp + source/model/AnalyticsS3ExportFileFormat.cpp + source/model/ArchiveStatus.cpp + source/model/Bucket.cpp + source/model/BucketAccelerateStatus.cpp + source/model/BucketCannedACL.cpp + source/model/BucketLifecycleConfiguration.cpp + source/model/BucketLocationConstraint.cpp + source/model/BucketLoggingStatus.cpp + source/model/BucketLogsPermission.cpp + source/model/BucketVersioningStatus.cpp + source/model/CORSConfiguration.cpp + source/model/CORSRule.cpp + source/model/CSVInput.cpp + source/model/CSVOutput.cpp + source/model/CloudFunctionConfiguration.cpp + source/model/CommonPrefix.cpp + source/model/CompleteMultipartUploadRequest.cpp + source/model/CompleteMultipartUploadResult.cpp + source/model/CompletedMultipartUpload.cpp + source/model/CompletedPart.cpp + source/model/CompressionType.cpp + source/model/Condition.cpp + source/model/CopyObjectRequest.cpp + source/model/CopyObjectResult.cpp + source/model/CopyObjectResultDetails.cpp + source/model/CopyPartResult.cpp + source/model/CreateBucketConfiguration.cpp + source/model/CreateBucketRequest.cpp + source/model/CreateBucketResult.cpp + source/model/CreateMultipartUploadRequest.cpp + source/model/CreateMultipartUploadResult.cpp + source/model/DefaultRetention.cpp + source/model/Delete.cpp + source/model/DeleteBucketAnalyticsConfigurationRequest.cpp + source/model/DeleteBucketCorsRequest.cpp + source/model/DeleteBucketEncryptionRequest.cpp + source/model/DeleteBucketIntelligentTieringConfigurationRequest.cpp + source/model/DeleteBucketInventoryConfigurationRequest.cpp + source/model/DeleteBucketLifecycleRequest.cpp + source/model/DeleteBucketMetricsConfigurationRequest.cpp + source/model/DeleteBucketOwnershipControlsRequest.cpp + source/model/DeleteBucketPolicyRequest.cpp + source/model/DeleteBucketReplicationRequest.cpp + source/model/DeleteBucketRequest.cpp + source/model/DeleteBucketTaggingRequest.cpp + source/model/DeleteBucketWebsiteRequest.cpp + source/model/DeleteMarkerEntry.cpp + source/model/DeleteMarkerReplication.cpp + source/model/DeleteMarkerReplicationStatus.cpp + source/model/DeleteObjectRequest.cpp + source/model/DeleteObjectResult.cpp + source/model/DeleteObjectTaggingRequest.cpp + source/model/DeleteObjectTaggingResult.cpp + source/model/DeleteObjectsRequest.cpp + source/model/DeleteObjectsResult.cpp + source/model/DeletePublicAccessBlockRequest.cpp + source/model/DeletedObject.cpp + source/model/Destination.cpp + source/model/EncodingType.cpp + source/model/Encryption.cpp + source/model/EncryptionConfiguration.cpp + source/model/Error.cpp + source/model/ErrorDocument.cpp + source/model/Event.cpp + source/model/ExistingObjectReplication.cpp + source/model/ExistingObjectReplicationStatus.cpp + source/model/ExpirationStatus.cpp + source/model/ExpressionType.cpp + source/model/FileHeaderInfo.cpp + source/model/FilterRule.cpp + source/model/FilterRuleName.cpp + source/model/GetBucketAccelerateConfigurationRequest.cpp + source/model/GetBucketAccelerateConfigurationResult.cpp + source/model/GetBucketAclRequest.cpp + source/model/GetBucketAclResult.cpp + source/model/GetBucketAnalyticsConfigurationRequest.cpp + source/model/GetBucketAnalyticsConfigurationResult.cpp + source/model/GetBucketCorsRequest.cpp + source/model/GetBucketCorsResult.cpp + source/model/GetBucketEncryptionRequest.cpp + source/model/GetBucketEncryptionResult.cpp + source/model/GetBucketIntelligentTieringConfigurationRequest.cpp + source/model/GetBucketIntelligentTieringConfigurationResult.cpp + source/model/GetBucketInventoryConfigurationRequest.cpp + source/model/GetBucketInventoryConfigurationResult.cpp + source/model/GetBucketLifecycleConfigurationRequest.cpp + source/model/GetBucketLifecycleConfigurationResult.cpp + source/model/GetBucketLocationRequest.cpp + source/model/GetBucketLocationResult.cpp + source/model/GetBucketLoggingRequest.cpp + source/model/GetBucketLoggingResult.cpp + source/model/GetBucketMetricsConfigurationRequest.cpp + source/model/GetBucketMetricsConfigurationResult.cpp + source/model/GetBucketNotificationConfigurationRequest.cpp + source/model/GetBucketNotificationConfigurationResult.cpp + source/model/GetBucketOwnershipControlsRequest.cpp + source/model/GetBucketOwnershipControlsResult.cpp + source/model/GetBucketPolicyRequest.cpp + source/model/GetBucketPolicyResult.cpp + source/model/GetBucketPolicyStatusRequest.cpp + source/model/GetBucketPolicyStatusResult.cpp + source/model/GetBucketReplicationRequest.cpp + source/model/GetBucketReplicationResult.cpp + source/model/GetBucketRequestPaymentRequest.cpp + source/model/GetBucketRequestPaymentResult.cpp + source/model/GetBucketTaggingRequest.cpp + source/model/GetBucketTaggingResult.cpp + source/model/GetBucketVersioningRequest.cpp + source/model/GetBucketVersioningResult.cpp + source/model/GetBucketWebsiteRequest.cpp + source/model/GetBucketWebsiteResult.cpp + source/model/GetObjectAclRequest.cpp + source/model/GetObjectAclResult.cpp + source/model/GetObjectLegalHoldRequest.cpp + source/model/GetObjectLegalHoldResult.cpp + source/model/GetObjectLockConfigurationRequest.cpp + source/model/GetObjectLockConfigurationResult.cpp + source/model/GetObjectRequest.cpp + source/model/GetObjectResult.cpp + source/model/GetObjectRetentionRequest.cpp + source/model/GetObjectRetentionResult.cpp + source/model/GetObjectTaggingRequest.cpp + source/model/GetObjectTaggingResult.cpp + source/model/GetObjectTorrentRequest.cpp + source/model/GetObjectTorrentResult.cpp + source/model/GetPublicAccessBlockRequest.cpp + source/model/GetPublicAccessBlockResult.cpp + source/model/GlacierJobParameters.cpp + source/model/Grant.cpp + source/model/Grantee.cpp + source/model/HeadBucketRequest.cpp + source/model/HeadObjectRequest.cpp + source/model/HeadObjectResult.cpp + source/model/IndexDocument.cpp + source/model/Initiator.cpp + source/model/InputSerialization.cpp + source/model/IntelligentTieringAccessTier.cpp + source/model/IntelligentTieringAndOperator.cpp + source/model/IntelligentTieringConfiguration.cpp + source/model/IntelligentTieringFilter.cpp + source/model/IntelligentTieringStatus.cpp + source/model/InvalidObjectState.cpp + source/model/InventoryConfiguration.cpp + source/model/InventoryDestination.cpp + source/model/InventoryEncryption.cpp + source/model/InventoryFilter.cpp + source/model/InventoryFormat.cpp + source/model/InventoryFrequency.cpp + source/model/InventoryIncludedObjectVersions.cpp + source/model/InventoryOptionalField.cpp + source/model/InventoryS3BucketDestination.cpp + source/model/InventorySchedule.cpp + source/model/JSONInput.cpp + source/model/JSONOutput.cpp + source/model/JSONType.cpp + source/model/LambdaFunctionConfiguration.cpp + source/model/LifecycleConfiguration.cpp + source/model/LifecycleExpiration.cpp + source/model/LifecycleRule.cpp + source/model/LifecycleRuleAndOperator.cpp + source/model/LifecycleRuleFilter.cpp + source/model/ListBucketAnalyticsConfigurationsRequest.cpp + source/model/ListBucketAnalyticsConfigurationsResult.cpp + source/model/ListBucketIntelligentTieringConfigurationsRequest.cpp + source/model/ListBucketIntelligentTieringConfigurationsResult.cpp + source/model/ListBucketInventoryConfigurationsRequest.cpp + source/model/ListBucketInventoryConfigurationsResult.cpp + source/model/ListBucketMetricsConfigurationsRequest.cpp + source/model/ListBucketMetricsConfigurationsResult.cpp + source/model/ListBucketsResult.cpp + source/model/ListMultipartUploadsRequest.cpp + source/model/ListMultipartUploadsResult.cpp + source/model/ListObjectVersionsRequest.cpp + source/model/ListObjectVersionsResult.cpp + source/model/ListObjectsRequest.cpp + source/model/ListObjectsResult.cpp + source/model/ListObjectsV2Request.cpp + source/model/ListObjectsV2Result.cpp + source/model/ListPartsRequest.cpp + source/model/ListPartsResult.cpp + source/model/LoggingEnabled.cpp + source/model/MFADelete.cpp + source/model/MFADeleteStatus.cpp + source/model/MetadataDirective.cpp + source/model/MetadataEntry.cpp + source/model/Metrics.cpp + source/model/MetricsAndOperator.cpp + source/model/MetricsConfiguration.cpp + source/model/MetricsFilter.cpp + source/model/MetricsStatus.cpp + source/model/MultipartUpload.cpp + source/model/NoncurrentVersionExpiration.cpp + source/model/NoncurrentVersionTransition.cpp + source/model/NotificationConfiguration.cpp + source/model/NotificationConfigurationDeprecated.cpp + source/model/NotificationConfigurationFilter.cpp + source/model/Object.cpp + source/model/ObjectCannedACL.cpp + source/model/ObjectIdentifier.cpp + source/model/ObjectLockConfiguration.cpp + source/model/ObjectLockEnabled.cpp + source/model/ObjectLockLegalHold.cpp + source/model/ObjectLockLegalHoldStatus.cpp + source/model/ObjectLockMode.cpp + source/model/ObjectLockRetention.cpp + source/model/ObjectLockRetentionMode.cpp + source/model/ObjectLockRule.cpp + source/model/ObjectOwnership.cpp + source/model/ObjectStorageClass.cpp + source/model/ObjectVersion.cpp + source/model/ObjectVersionStorageClass.cpp + source/model/OutputLocation.cpp + source/model/OutputSerialization.cpp + source/model/Owner.cpp + source/model/OwnerOverride.cpp + source/model/OwnershipControls.cpp + source/model/OwnershipControlsRule.cpp + source/model/ParquetInput.cpp + source/model/Part.cpp + source/model/Payer.cpp + source/model/Permission.cpp + source/model/PolicyStatus.cpp + source/model/Progress.cpp + source/model/ProgressEvent.cpp + source/model/Protocol.cpp + source/model/PublicAccessBlockConfiguration.cpp + source/model/PutBucketAccelerateConfigurationRequest.cpp + source/model/PutBucketAclRequest.cpp + source/model/PutBucketAnalyticsConfigurationRequest.cpp + source/model/PutBucketCorsRequest.cpp + source/model/PutBucketEncryptionRequest.cpp + source/model/PutBucketIntelligentTieringConfigurationRequest.cpp + source/model/PutBucketInventoryConfigurationRequest.cpp + source/model/PutBucketLifecycleConfigurationRequest.cpp + source/model/PutBucketLoggingRequest.cpp + source/model/PutBucketMetricsConfigurationRequest.cpp + source/model/PutBucketNotificationConfigurationRequest.cpp + source/model/PutBucketOwnershipControlsRequest.cpp + source/model/PutBucketPolicyRequest.cpp + source/model/PutBucketReplicationRequest.cpp + source/model/PutBucketRequestPaymentRequest.cpp + source/model/PutBucketTaggingRequest.cpp + source/model/PutBucketVersioningRequest.cpp + source/model/PutBucketWebsiteRequest.cpp + source/model/PutObjectAclRequest.cpp + source/model/PutObjectAclResult.cpp + source/model/PutObjectLegalHoldRequest.cpp + source/model/PutObjectLegalHoldResult.cpp + source/model/PutObjectLockConfigurationRequest.cpp + source/model/PutObjectLockConfigurationResult.cpp + source/model/PutObjectRequest.cpp + source/model/PutObjectResult.cpp + source/model/PutObjectRetentionRequest.cpp + source/model/PutObjectRetentionResult.cpp + source/model/PutObjectTaggingRequest.cpp + source/model/PutObjectTaggingResult.cpp + source/model/PutPublicAccessBlockRequest.cpp + source/model/QueueConfiguration.cpp + source/model/QueueConfigurationDeprecated.cpp + source/model/QuoteFields.cpp + source/model/Redirect.cpp + source/model/RedirectAllRequestsTo.cpp + source/model/ReplicaModifications.cpp + source/model/ReplicaModificationsStatus.cpp + source/model/ReplicationConfiguration.cpp + source/model/ReplicationRule.cpp + source/model/ReplicationRuleAndOperator.cpp + source/model/ReplicationRuleFilter.cpp + source/model/ReplicationRuleStatus.cpp + source/model/ReplicationStatus.cpp + source/model/ReplicationTime.cpp + source/model/ReplicationTimeStatus.cpp + source/model/ReplicationTimeValue.cpp + source/model/RequestCharged.cpp + source/model/RequestPayer.cpp + source/model/RequestPaymentConfiguration.cpp + source/model/RequestProgress.cpp + source/model/RestoreObjectRequest.cpp + source/model/RestoreObjectResult.cpp + source/model/RestoreRequest.cpp + source/model/RestoreRequestType.cpp + source/model/RoutingRule.cpp + source/model/Rule.cpp + source/model/S3KeyFilter.cpp + source/model/S3Location.cpp + source/model/SSEKMS.cpp + source/model/SSES3.cpp + source/model/ScanRange.cpp + source/model/SelectObjectContentHandler.cpp + source/model/SelectObjectContentRequest.cpp + source/model/SelectParameters.cpp + source/model/ServerSideEncryption.cpp + source/model/ServerSideEncryptionByDefault.cpp + source/model/ServerSideEncryptionConfiguration.cpp + source/model/ServerSideEncryptionRule.cpp + source/model/SourceSelectionCriteria.cpp + source/model/SseKmsEncryptedObjects.cpp + source/model/SseKmsEncryptedObjectsStatus.cpp + source/model/Stats.cpp + source/model/StatsEvent.cpp + source/model/StorageClass.cpp + source/model/StorageClassAnalysis.cpp + source/model/StorageClassAnalysisDataExport.cpp + source/model/StorageClassAnalysisSchemaVersion.cpp + source/model/Tag.cpp + source/model/Tagging.cpp + source/model/TaggingDirective.cpp + source/model/TargetGrant.cpp + source/model/Tier.cpp + source/model/Tiering.cpp + source/model/TopicConfiguration.cpp + source/model/TopicConfigurationDeprecated.cpp + source/model/Transition.cpp + source/model/TransitionStorageClass.cpp + source/model/Type.cpp + source/model/UploadPartCopyRequest.cpp + source/model/UploadPartCopyResult.cpp + source/model/UploadPartRequest.cpp + source/model/UploadPartResult.cpp + source/model/VersioningConfiguration.cpp + source/model/WebsiteConfiguration.cpp + source/model/WriteGetObjectResponseRequest.cpp +) + +END() diff --git a/contrib/libs/base64/avx2/ya.make b/contrib/libs/base64/avx2/ya.make new file mode 100644 index 00000000000..d94d6c90614 --- /dev/null +++ b/contrib/libs/base64/avx2/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +SRCS( + codec_avx2.c + lib.c +) + +IF (ARCH_X86_64 OR ARCH_I386) + IF (MSVC AND NOT CLANG_CL) + CONLYFLAGS(/D__AVX2__=1) + ELSEIF (CLANG_CL) + CONLYFLAGS(-mavx2) + ELSE() + CONLYFLAGS( + -mavx2 + -std=c11 + ) + ENDIF() +ENDIF() + +END() diff --git a/contrib/libs/base64/neon32/ya.make b/contrib/libs/base64/neon32/ya.make new file mode 100644 index 00000000000..0e5890b95c1 --- /dev/null +++ b/contrib/libs/base64/neon32/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +SRCS( + codec_neon32.c + lib.c +) + +IF (OS_LINUX OR OS_DARWIN OR OS_ANDROID) + CONLYFLAGS(-std=c11) +ENDIF() + +END() diff --git a/contrib/libs/base64/neon64/ya.make b/contrib/libs/base64/neon64/ya.make new file mode 100644 index 00000000000..fc89901e701 --- /dev/null +++ b/contrib/libs/base64/neon64/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +SRCS( + codec_neon64.c + lib.c +) + +IF (ARCH_AARCH64 OR ARCH_ARM64) + IF (OS_LINUX OR OS_DARWIN OR OS_ANDROID) + CONLYFLAGS( + -march=armv8-a + -std=c11 + ) + ENDIF() +ENDIF() + +END() diff --git a/contrib/libs/base64/plain32/ya.make b/contrib/libs/base64/plain32/ya.make new file mode 100644 index 00000000000..ead784215c4 --- /dev/null +++ b/contrib/libs/base64/plain32/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +SRCS( + codec_plain.c + lib.c +) + +IF (OS_LINUX OR OS_DARWIN) + CONLYFLAGS(-std=c11) +ENDIF() + +END() diff --git a/contrib/libs/base64/plain64/ya.make b/contrib/libs/base64/plain64/ya.make new file mode 100644 index 00000000000..ead784215c4 --- /dev/null +++ b/contrib/libs/base64/plain64/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +SRCS( + codec_plain.c + lib.c +) + +IF (OS_LINUX OR OS_DARWIN) + CONLYFLAGS(-std=c11) +ENDIF() + +END() diff --git a/contrib/libs/base64/ssse3/ya.make b/contrib/libs/base64/ssse3/ya.make new file mode 100644 index 00000000000..3f686dfda00 --- /dev/null +++ b/contrib/libs/base64/ssse3/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +SRCS( + codec_ssse3.c + lib.c +) + +IF (ARCH_X86_64 OR ARCH_I386) + IF (MSVC AND NOT CLANG_CL) + CONLYFLAGS(/D__SSSE3__=1) + ELSEIF (CLANG_CL) + CONLYFLAGS(-mssse3) + ELSE() + CONLYFLAGS( + -mssse3 + -std=c11 + ) + ENDIF() +ENDIF() + +END() diff --git a/contrib/libs/brotli/common/ya.make b/contrib/libs/brotli/common/ya.make new file mode 100644 index 00000000000..89e38a262cc --- /dev/null +++ b/contrib/libs/brotli/common/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +ADDINCL(contrib/libs/brotli/include) + +SRCS( + dictionary.c + transform.c +) + +CFLAGS(-DBROTLI_BUILD_PORTABLE) + +END() diff --git a/contrib/libs/brotli/dec/ya.make b/contrib/libs/brotli/dec/ya.make new file mode 100644 index 00000000000..826e87a4f7c --- /dev/null +++ b/contrib/libs/brotli/dec/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +ADDINCL(GLOBAL contrib/libs/brotli/include) + +PEERDIR( + contrib/libs/brotli/common +) + +SRCS( + bit_reader.c + decode.c + huffman.c + state.c +) + +END() diff --git a/contrib/libs/brotli/enc/ya.make b/contrib/libs/brotli/enc/ya.make new file mode 100644 index 00000000000..d75ce198809 --- /dev/null +++ b/contrib/libs/brotli/enc/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +ADDINCL(GLOBAL contrib/libs/brotli/include) + +PEERDIR( + contrib/libs/brotli/common + contrib/libs/brotli/dec +) + +SRCS( + backward_references.c + backward_references_hq.c + bit_cost.c + block_splitter.c + brotli_bit_stream.c + cluster.c + compress_fragment.c + compress_fragment_two_pass.c + dictionary_hash.c + encode.c + encoder_dict.c + entropy_encode.c + histogram.c + literal_cost.c + memory.c + metablock.c + static_dict.c + utf8_util.c +) + +CFLAGS(-DBROTLI_BUILD_PORTABLE) + +END() diff --git a/contrib/libs/c-ares/acountry/ya.make b/contrib/libs/c-ares/acountry/ya.make new file mode 100644 index 00000000000..1a39cdbc7fd --- /dev/null +++ b/contrib/libs/c-ares/acountry/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/c-ares +) + +ADDINCL( + GLOBAL contrib/libs/c-ares + GLOBAL contrib/libs/c-ares/include + GLOBAL contrib/libs/c-ares/src/lib + contrib/libs/c-ares/src/tools +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H=1 +) + +SRCDIR(contrib/libs/c-ares/src) + +SRCS( + lib/ares_nowarn.c + lib/ares_strcasecmp.c + tools/acountry.c + tools/ares_getopt.c +) + +END() diff --git a/contrib/libs/c-ares/adig/ya.make b/contrib/libs/c-ares/adig/ya.make new file mode 100644 index 00000000000..31f8cfbd1b9 --- /dev/null +++ b/contrib/libs/c-ares/adig/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/c-ares +) + +ADDINCL( + GLOBAL contrib/libs/c-ares + GLOBAL contrib/libs/c-ares/include + GLOBAL contrib/libs/c-ares/src/lib + contrib/libs/c-ares/src/tools +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H=1 +) + +SRCDIR(contrib/libs/c-ares/src) + +SRCS( + lib/ares_nowarn.c + lib/ares_strcasecmp.c + tools/adig.c + tools/ares_getopt.c +) + +END() diff --git a/contrib/libs/c-ares/ahost/ya.make b/contrib/libs/c-ares/ahost/ya.make new file mode 100644 index 00000000000..434b8436d12 --- /dev/null +++ b/contrib/libs/c-ares/ahost/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/c-ares +) + +ADDINCL( + GLOBAL contrib/libs/c-ares + GLOBAL contrib/libs/c-ares/include + GLOBAL contrib/libs/c-ares/src/lib + contrib/libs/c-ares/src/tools +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H=1 +) + +SRCDIR(contrib/libs/c-ares/src) + +SRCS( + lib/ares_nowarn.c + lib/ares_strcasecmp.c + tools/ahost.c + tools/ares_getopt.c +) + +END() diff --git a/contrib/libs/c-ares/test/ya.make b/contrib/libs/c-ares/test/ya.make new file mode 100644 index 00000000000..e53a94d0ba9 --- /dev/null +++ b/contrib/libs/c-ares/test/ya.make @@ -0,0 +1,59 @@ +# Generated by devtools/yamaker. + +GTEST(arestest) + +WITHOUT_LICENSE_TEXTS() + +SIZE(MEDIUM) + +TAG(ya:external) + +REQUIREMENTS(network:full) + +PEERDIR( + contrib/libs/c-ares + contrib/restricted/googletest/googlemock +) + +ADDINCL( + contrib/libs/c-ares + contrib/libs/c-ares/include + contrib/libs/c-ares/src/lib + contrib/libs/c-ares/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DHAVE_CONFIG_H=1 +) + +SRCS( + ares-test-init.cc + ares-test-internal.cc + ares-test-live.cc + ares-test-misc.cc + ares-test-mock-ai.cc + ares-test-mock.cc + ares-test-ns.cc + ares-test-parse-a.cc + ares-test-parse-aaaa.cc + ares-test-parse-caa.cc + ares-test-parse-mx.cc + ares-test-parse-naptr.cc + ares-test-parse-ns.cc + ares-test-parse-ptr.cc + ares-test-parse-soa-any.cc + ares-test-parse-soa.cc + ares-test-parse-srv.cc + ares-test-parse-txt.cc + ares-test-parse-uri.cc + ares-test-parse.cc + ares-test.cc + dns-proto-test.cc + dns-proto.cc +) + +END() diff --git a/contrib/libs/c-ares/ya.make b/contrib/libs/c-ares/ya.make new file mode 100644 index 00000000000..922e08550d8 --- /dev/null +++ b/contrib/libs/c-ares/ya.make @@ -0,0 +1,126 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + ISC AND + MIT AND + NTP +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.19.1) + +ORIGINAL_SOURCE(https://github.com/c-ares/c-ares/archive/cares-1_19_1.tar.gz) + +OPENSOURCE_EXPORT_REPLACEMENT( + CMAKE + c-ares + CMAKE_TARGET + c-ares::c-ares + CONAN + c-ares/1.19.1 +) + +PEERDIR( + contrib/libs/libc_compat +) + +ADDINCL( + GLOBAL contrib/libs/c-ares + GLOBAL contrib/libs/c-ares/include + contrib/libs/c-ares/src/lib +) + +NO_COMPILER_WARNINGS() + +CFLAGS( + -DCARES_BUILDING_LIBRARY + -DHAVE_CONFIG_H=1 + GLOBAL -DCARES_STATICLIB +) + +IF (ARCH_ARM7) + CFLAGS( + GLOBAL -D__SIZEOF_LONG__=4 + ) +ENDIF() + +IF (NOT EXPORT_CMAKE) + CHECK_CONFIG_H(src/lib/ares_setup.h) +ENDIF() + +SRCS( + src/lib/ares__addrinfo2hostent.c + src/lib/ares__addrinfo_localhost.c + src/lib/ares__close_sockets.c + src/lib/ares__get_hostent.c + src/lib/ares__parse_into_addrinfo.c + src/lib/ares__read_line.c + src/lib/ares__readaddrinfo.c + src/lib/ares__sortaddrinfo.c + src/lib/ares__timeval.c + src/lib/ares_android.c + src/lib/ares_cancel.c + src/lib/ares_create_query.c + src/lib/ares_data.c + src/lib/ares_destroy.c + src/lib/ares_expand_name.c + src/lib/ares_expand_string.c + src/lib/ares_fds.c + src/lib/ares_free_hostent.c + src/lib/ares_free_string.c + src/lib/ares_freeaddrinfo.c + src/lib/ares_getaddrinfo.c + src/lib/ares_getenv.c + src/lib/ares_gethostbyaddr.c + src/lib/ares_gethostbyname.c + src/lib/ares_getnameinfo.c + src/lib/ares_getsock.c + src/lib/ares_init.c + src/lib/ares_library_init.c + src/lib/ares_llist.c + src/lib/ares_mkquery.c + src/lib/ares_nowarn.c + src/lib/ares_options.c + src/lib/ares_parse_a_reply.c + src/lib/ares_parse_aaaa_reply.c + src/lib/ares_parse_caa_reply.c + src/lib/ares_parse_mx_reply.c + src/lib/ares_parse_naptr_reply.c + src/lib/ares_parse_ns_reply.c + src/lib/ares_parse_ptr_reply.c + src/lib/ares_parse_soa_reply.c + src/lib/ares_parse_srv_reply.c + src/lib/ares_parse_txt_reply.c + src/lib/ares_parse_uri_reply.c + src/lib/ares_platform.c + src/lib/ares_process.c + src/lib/ares_query.c + src/lib/ares_rand.c + src/lib/ares_search.c + src/lib/ares_send.c + src/lib/ares_strcasecmp.c + src/lib/ares_strdup.c + src/lib/ares_strerror.c + src/lib/ares_strsplit.c + src/lib/ares_timeout.c + src/lib/ares_version.c + src/lib/ares_writev.c + src/lib/atomic.cpp + src/lib/bitncmp.c + src/lib/inet_net_pton.c + src/lib/inet_ntop.c + src/lib/windows_port.c +) + +END() + +RECURSE( + acountry + adig + ahost + test +) diff --git a/contrib/libs/cblas/ya.make b/contrib/libs/cblas/ya.make new file mode 100644 index 00000000000..bcda32a4685 --- /dev/null +++ b/contrib/libs/cblas/ya.make @@ -0,0 +1,345 @@ +LIBRARY() + +LICENSE(BSD-3-Clause) + +VERSION(1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ORIGINAL_SOURCE(https://www.netlib.org/blas/) + +NO_COMPILER_WARNINGS() + +IF (HAVE_MKL) + PEERDIR( + contrib/libs/intel/mkl + ) +ELSE() + CFLAGS( + -DADD_ + -DNO_BLAS_WRAP + ) + PEERDIR( + ADDINCL contrib/libs/libf2c + ) + ADDINCLSELF() + SRCS( + caxpy.c + ccopy.c + cdotc.c + cdotu.c + cgbmv.c + cgemm.c + cgemv.c + cgerc.c + cgeru.c + chbmv.c + chemm.c + chemv.c + cher.c + cher2.c + cher2k.c + cherk.c + chpmv.c + chpr.c + chpr2.c + crotg.c + cscal.c + csrot.c + csscal.c + cswap.c + csymm.c + csyr2k.c + csyrk.c + ctbmv.c + ctbsv.c + ctpmv.c + ctpsv.c + ctrmm.c + ctrmv.c + ctrsm.c + ctrsv.c + dasum.c + daxpy.c + dcabs1.c + dcopy.c + ddot.c + dgbmv.c + dgemm.c + dgemv.c + dger.c + dnrm2.c + drot.c + drotg.c + drotm.c + drotmg.c + dsbmv.c + dscal.c + dsdot.c + dspmv.c + dspr.c + dspr2.c + dswap.c + dsymm.c + dsymv.c + dsyr.c + dsyr2.c + dsyr2k.c + dsyrk.c + dtbmv.c + dtbsv.c + dtpmv.c + dtpsv.c + dtrmm.c + dtrmv.c + dtrsm.c + dtrsv.c + dzasum.c + dznrm2.c + icamax.c + idamax.c + isamax.c + izamax.c + lsame.c + sasum.c + saxpy.c + scabs1.c + scasum.c + scnrm2.c + scopy.c + sdot.c + sdsdot.c + sgbmv.c + sgemm.c + sgemv.c + sger.c + snrm2.c + srot.c + srotg.c + srotm.c + srotmg.c + ssbmv.c + sscal.c + sspmv.c + sspr.c + sspr2.c + sswap.c + ssymm.c + ssymv.c + ssyr.c + ssyr2.c + ssyr2k.c + ssyrk.c + stbmv.c + stbsv.c + stpmv.c + stpsv.c + strmm.c + strmv.c + strsm.c + strsv.c + xerbla.c + xerbla_array.c + zaxpy.c + zcopy.c + zdotc.c + zdotu.c + zdrot.c + zdscal.c + zgbmv.c + zgemm.c + zgemv.c + zgerc.c + zgeru.c + zhbmv.c + zhemm.c + zhemv.c + zher.c + zher2.c + zher2k.c + zherk.c + zhpmv.c + zhpr.c + zhpr2.c + zrotg.c + zscal.c + zswap.c + zsymm.c + zsyr2k.c + zsyrk.c + ztbmv.c + ztbsv.c + ztpmv.c + ztpsv.c + ztrmm.c + ztrmv.c + ztrsm.c + ztrsv.c + cblas_interface/cblas_caxpy.c + cblas_interface/cblas_ccopy.c + cblas_interface/cblas_cdotc_sub.c + cblas_interface/cblas_cdotu_sub.c + cblas_interface/cblas_cgbmv.c + cblas_interface/cblas_cgemm.c + cblas_interface/cblas_cgemv.c + cblas_interface/cblas_cgerc.c + cblas_interface/cblas_cgeru.c + cblas_interface/cblas_chbmv.c + cblas_interface/cblas_chemm.c + cblas_interface/cblas_chemv.c + cblas_interface/cblas_cher.c + cblas_interface/cblas_cher2.c + cblas_interface/cblas_cher2k.c + cblas_interface/cblas_cherk.c + cblas_interface/cblas_chpmv.c + cblas_interface/cblas_chpr.c + cblas_interface/cblas_chpr2.c + cblas_interface/cblas_cscal.c + cblas_interface/cblas_csscal.c + cblas_interface/cblas_cswap.c + cblas_interface/cblas_csymm.c + cblas_interface/cblas_csyr2k.c + cblas_interface/cblas_csyrk.c + cblas_interface/cblas_ctbmv.c + cblas_interface/cblas_ctbsv.c + cblas_interface/cblas_ctpmv.c + cblas_interface/cblas_ctpsv.c + cblas_interface/cblas_ctrmm.c + cblas_interface/cblas_ctrmv.c + cblas_interface/cblas_ctrsm.c + cblas_interface/cblas_ctrsv.c + cblas_interface/cblas_dasum.c + cblas_interface/cblas_daxpy.c + cblas_interface/cblas_dcopy.c + cblas_interface/cblas_ddot.c + cblas_interface/cblas_dgbmv.c + cblas_interface/cblas_dgemm.c + cblas_interface/cblas_dgemv.c + cblas_interface/cblas_dger.c + cblas_interface/cblas_dnrm2.c + cblas_interface/cblas_drot.c + cblas_interface/cblas_drotg.c + cblas_interface/cblas_drotm.c + cblas_interface/cblas_drotmg.c + cblas_interface/cblas_dsbmv.c + cblas_interface/cblas_dscal.c + cblas_interface/cblas_dsdot.c + cblas_interface/cblas_dspmv.c + cblas_interface/cblas_dspr.c + cblas_interface/cblas_dspr2.c + cblas_interface/cblas_dswap.c + cblas_interface/cblas_dsymm.c + cblas_interface/cblas_dsymv.c + cblas_interface/cblas_dsyr.c + cblas_interface/cblas_dsyr2.c + cblas_interface/cblas_dsyr2k.c + cblas_interface/cblas_dsyrk.c + cblas_interface/cblas_dtbmv.c + cblas_interface/cblas_dtbsv.c + cblas_interface/cblas_dtpmv.c + cblas_interface/cblas_dtpsv.c + cblas_interface/cblas_dtrmm.c + cblas_interface/cblas_dtrmv.c + cblas_interface/cblas_dtrsm.c + cblas_interface/cblas_dtrsv.c + cblas_interface/cblas_dzasum.c + cblas_interface/cblas_dznrm2.c + cblas_interface/cblas_globals.c + cblas_interface/cblas_icamax.c + cblas_interface/cblas_idamax.c + cblas_interface/cblas_isamax.c + cblas_interface/cblas_izamax.c + cblas_interface/cblas_sasum.c + cblas_interface/cblas_saxpy.c + cblas_interface/cblas_scasum.c + cblas_interface/cblas_scnrm2.c + cblas_interface/cblas_scopy.c + cblas_interface/cblas_sdot.c + cblas_interface/cblas_sdsdot.c + cblas_interface/cblas_sgbmv.c + cblas_interface/cblas_sgemm.c + cblas_interface/cblas_sgemv.c + cblas_interface/cblas_sger.c + cblas_interface/cblas_snrm2.c + cblas_interface/cblas_srot.c + cblas_interface/cblas_srotg.c + cblas_interface/cblas_srotm.c + cblas_interface/cblas_srotmg.c + cblas_interface/cblas_ssbmv.c + cblas_interface/cblas_sscal.c + cblas_interface/cblas_sspmv.c + cblas_interface/cblas_sspr.c + cblas_interface/cblas_sspr2.c + cblas_interface/cblas_sswap.c + cblas_interface/cblas_ssymm.c + cblas_interface/cblas_ssymv.c + cblas_interface/cblas_ssyr.c + cblas_interface/cblas_ssyr2.c + cblas_interface/cblas_ssyr2k.c + cblas_interface/cblas_ssyrk.c + cblas_interface/cblas_stbmv.c + cblas_interface/cblas_stbsv.c + cblas_interface/cblas_stpmv.c + cblas_interface/cblas_stpsv.c + cblas_interface/cblas_strmm.c + cblas_interface/cblas_strmv.c + cblas_interface/cblas_strsm.c + cblas_interface/cblas_strsv.c + cblas_interface/cblas_xerbla.c + cblas_interface/cblas_zaxpy.c + cblas_interface/cblas_zcopy.c + cblas_interface/cblas_zdotc_sub.c + cblas_interface/cblas_zdotu_sub.c + cblas_interface/cblas_zdscal.c + cblas_interface/cblas_zgbmv.c + cblas_interface/cblas_zgemm.c + cblas_interface/cblas_zgemv.c + cblas_interface/cblas_zgerc.c + cblas_interface/cblas_zgeru.c + cblas_interface/cblas_zhbmv.c + cblas_interface/cblas_zhemm.c + cblas_interface/cblas_zhemv.c + cblas_interface/cblas_zher.c + cblas_interface/cblas_zher2.c + cblas_interface/cblas_zher2k.c + cblas_interface/cblas_zherk.c + cblas_interface/cblas_zhpmv.c + cblas_interface/cblas_zhpr.c + cblas_interface/cblas_zhpr2.c + cblas_interface/cblas_zscal.c + cblas_interface/cblas_zswap.c + cblas_interface/cblas_zsymm.c + cblas_interface/cblas_zsyr2k.c + cblas_interface/cblas_zsyrk.c + cblas_interface/cblas_ztbmv.c + cblas_interface/cblas_ztbsv.c + cblas_interface/cblas_ztpmv.c + cblas_interface/cblas_ztpsv.c + cblas_interface/cblas_ztrmm.c + cblas_interface/cblas_ztrmv.c + cblas_interface/cblas_ztrsm.c + cblas_interface/cblas_ztrsv.c + cblas_interface/cdotcsub.c + cblas_interface/cdotusub.c + cblas_interface/dasumsub.c + cblas_interface/ddotsub.c + cblas_interface/dnrm2sub.c + cblas_interface/dsdotsub.c + cblas_interface/dzasumsub.c + cblas_interface/dznrm2sub.c + cblas_interface/icamaxsub.c + cblas_interface/idamaxsub.c + cblas_interface/isamaxsub.c + cblas_interface/izamaxsub.c + cblas_interface/sasumsub.c + cblas_interface/scasumsub.c + cblas_interface/scnrm2sub.c + cblas_interface/sdotsub.c + cblas_interface/sdsdotsub.c + cblas_interface/snrm2sub.c + cblas_interface/zdotcsub.c + cblas_interface/zdotusub.c + ) +ENDIF() + +END() diff --git a/contrib/libs/cctz/test/ya.make b/contrib/libs/cctz/test/ya.make new file mode 100644 index 00000000000..0e551d7ba16 --- /dev/null +++ b/contrib/libs/cctz/test/ya.make @@ -0,0 +1,33 @@ +GTEST() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/cctz + contrib/libs/cctz/tzdata +) + +ADDINCL( + contrib/libs/cctz/include +) + +IF (NOT AUTOCHECK) + # We do not set TZDIR to a stable data source, so + # LoadZone("libc:localtime") is inconsistent and makes + # LocalTimeLibC test fail on distbuild. + CFLAGS( + -DCCTZ_TEST_LIBC_LOCALTIME + ) +ENDIF() + +SRCS( + civil_time_test.cc + time_zone_format_test.cc + time_zone_lookup_test.cc +) + +EXPLICIT_DATA() + +END() diff --git a/contrib/libs/cctz/tzdata/ya.make b/contrib/libs/cctz/tzdata/ya.make new file mode 100644 index 00000000000..d881ad5f32e --- /dev/null +++ b/contrib/libs/cctz/tzdata/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/cctz +) + +INCLUDE(ya.make.resources) + +SRCS( + GLOBAL factory.cpp +) + +END() diff --git a/contrib/libs/cctz/tzdata/ya.make.resources b/contrib/libs/cctz/tzdata/ya.make.resources new file mode 100644 index 00000000000..6859cfe1327 --- /dev/null +++ b/contrib/libs/cctz/tzdata/ya.make.resources @@ -0,0 +1,600 @@ +RESOURCE( + generated/58543f30ac34b6510b552b9b3e82b772 /cctz/tzdata/posixrules + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Abidjan + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Accra + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Addis_Ababa + generated/da87d45f88e4684903d7dbb5b7ed08dc /cctz/tzdata/Africa/Algiers + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Asmara + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Asmera + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Bamako + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Bangui + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Banjul + generated/767406f25e6c1c5396e19a3be033304b /cctz/tzdata/Africa/Bissau + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Blantyre + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Brazzaville + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Bujumbura + generated/8dcab26c06fc82939d77511b0c7c24b2 /cctz/tzdata/Africa/Cairo + generated/12de6e9419a748db0e69972d23a640c2 /cctz/tzdata/Africa/Casablanca + generated/00636062cbcd94f2ead5a75cc197675a /cctz/tzdata/Africa/Ceuta + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Conakry + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Dakar + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Dar_es_Salaam + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Djibouti + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Douala + generated/8ba86418f34ed83656d38bcfb19f85ea /cctz/tzdata/Africa/El_Aaiun + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Freetown + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Gaborone + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Harare + generated/a46a56e63a69fd5c5373a33203250d39 /cctz/tzdata/Africa/Johannesburg + generated/c263ea3cac3cd3410ac15d96040c3b3c /cctz/tzdata/Africa/Juba + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Kampala + generated/d00638c4bf95fabcc0c651f13e32e253 /cctz/tzdata/Africa/Khartoum + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Kigali + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Kinshasa + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Lagos + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Libreville + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Lome + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Luanda + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Lubumbashi + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Lusaka + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Malabo + generated/a87061b72790e27d9f155644521d8cce /cctz/tzdata/Africa/Maputo + generated/a46a56e63a69fd5c5373a33203250d39 /cctz/tzdata/Africa/Maseru + generated/a46a56e63a69fd5c5373a33203250d39 /cctz/tzdata/Africa/Mbabane + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Mogadishu + generated/4afacd60281211a6a7530a3ff8062781 /cctz/tzdata/Africa/Monrovia + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Africa/Nairobi + generated/510c0710993f09c4d93d3639ac3fe609 /cctz/tzdata/Africa/Ndjamena + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Niamey + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Nouakchott + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Ouagadougou + generated/89de77d185e9a76612bd5f9fb043a9c2 /cctz/tzdata/Africa/Porto-Novo + generated/7353b5d25ddb353ced2f1f9639251c16 /cctz/tzdata/Africa/Sao_Tome + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Africa/Timbuktu + generated/a6b8c0b7319f5fdca0ed634760ff6e3b /cctz/tzdata/Africa/Tripoli + generated/63615364c91acab170ec8f719aa6f59f /cctz/tzdata/Africa/Tunis + generated/3c6db0baa05cea4617bcad88b40b1e6a /cctz/tzdata/Africa/Windhoek + generated/1df7e605c33529940c76c1c145c52fc5 /cctz/tzdata/America/Adak + generated/77ea6e8a582f87d7a397a9e7b2111be0 /cctz/tzdata/America/Anchorage + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Anguilla + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Antigua + generated/82840448c9d4782ffa56514a7fb4ca95 /cctz/tzdata/America/Araguaina + generated/a4fc7ef39a80ff8875d1cb2708ebc49e /cctz/tzdata/America/Argentina/Buenos_Aires + generated/e3467a68822f3d1365e3494970219b03 /cctz/tzdata/America/Argentina/Catamarca + generated/e3467a68822f3d1365e3494970219b03 /cctz/tzdata/America/Argentina/ComodRivadavia + generated/5c57dc3d11f5a64fac22a08ea0c64d25 /cctz/tzdata/America/Argentina/Cordoba + generated/239a70724a0ff39d5dd3e6b7f4a34212 /cctz/tzdata/America/Argentina/Jujuy + generated/0e84cda11c5dc9030c43c51187a6c78d /cctz/tzdata/America/Argentina/La_Rioja + generated/839eacc63921f196e4ecfded7245a67b /cctz/tzdata/America/Argentina/Mendoza + generated/e0e8162a9ade838f582c23557e530019 /cctz/tzdata/America/Argentina/Rio_Gallegos + generated/0249d27eff0294ba6c5d090d9895fd17 /cctz/tzdata/America/Argentina/Salta + generated/4a5ba954919a3b34fb7779965387992f /cctz/tzdata/America/Argentina/San_Juan + generated/6413085a3a485b5683da3f49944995f0 /cctz/tzdata/America/Argentina/San_Luis + generated/70483b70b5e389865d462a090b99f2ed /cctz/tzdata/America/Argentina/Tucuman + generated/07844fc101071f657d084ecb7d161aa0 /cctz/tzdata/America/Argentina/Ushuaia + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Aruba + generated/9f8d9f5acd176a1a163855959b566bb4 /cctz/tzdata/America/Asuncion + generated/595e67b4c97fda031a90e5ef80813e7d /cctz/tzdata/America/Atikokan + generated/1df7e605c33529940c76c1c145c52fc5 /cctz/tzdata/America/Atka + generated/1c750fa694668ef0a1aad95b61533b2a /cctz/tzdata/America/Bahia + generated/e4bd3e0b46733cfe080ae7a159951665 /cctz/tzdata/America/Bahia_Banderas + generated/c779f9c0f9698e7646946312f10dfc4a /cctz/tzdata/America/Barbados + generated/ace635d426a79002a8e3657033da7795 /cctz/tzdata/America/Belem + generated/fb4e7ca8ebc94bf7b651ad1921cb62df /cctz/tzdata/America/Belize + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Blanc-Sablon + generated/30c97d0792df5d5939ff0f09c53c385d /cctz/tzdata/America/Boa_Vista + generated/ee4b5e263472bc5adf6309f2f5cd8858 /cctz/tzdata/America/Bogota + generated/f3ce1cb0fb7595deac1b8caa16cae961 /cctz/tzdata/America/Boise + generated/a4fc7ef39a80ff8875d1cb2708ebc49e /cctz/tzdata/America/Buenos_Aires + generated/628a7252c0237ddace06127f3f97d066 /cctz/tzdata/America/Cambridge_Bay + generated/8fa410ffc232e56d0f945bd2b6c34dfe /cctz/tzdata/America/Campo_Grande + generated/93e1c90eb5222ffb3eca2a2a29b69a69 /cctz/tzdata/America/Cancun + generated/4d7ff90583dcd0e08fc8c51792761c2b /cctz/tzdata/America/Caracas + generated/e3467a68822f3d1365e3494970219b03 /cctz/tzdata/America/Catamarca + generated/806c5856106eb6b28c3846dd93d3acc4 /cctz/tzdata/America/Cayenne + generated/595e67b4c97fda031a90e5ef80813e7d /cctz/tzdata/America/Cayman + generated/85435a33486747b319872947c68317f3 /cctz/tzdata/America/Chicago + generated/46d5d8b3710cb4825d4cca19f239aade /cctz/tzdata/America/Chihuahua + generated/587990ea7ea7cb10bfd0618d8d314de3 /cctz/tzdata/America/Ciudad_Juarez + generated/595e67b4c97fda031a90e5ef80813e7d /cctz/tzdata/America/Coral_Harbour + generated/5c57dc3d11f5a64fac22a08ea0c64d25 /cctz/tzdata/America/Cordoba + generated/f32590f9bcdfb4ab134294d441804ae5 /cctz/tzdata/America/Costa_Rica + generated/db536e94d95836d7c5725c3b3c086586 /cctz/tzdata/America/Creston + generated/268c9a38823e18c714ec9fb756a8042e /cctz/tzdata/America/Cuiaba + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Curacao + generated/356ff8bd249ee3f6983cba8426901244 /cctz/tzdata/America/Danmarkshavn + generated/79eedb7a0a4788b9bc3c291c4c643b50 /cctz/tzdata/America/Dawson + generated/6ece595060d1d2db3153c5d523fb106b /cctz/tzdata/America/Dawson_Creek + generated/c1b9655d5b1ce7fbc9ac213e921acc88 /cctz/tzdata/America/Denver + generated/48c96bff46ef373ce5d759dc4a4d2de2 /cctz/tzdata/America/Detroit + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Dominica + generated/beb91df50b24718aed963a509c0c2958 /cctz/tzdata/America/Edmonton + generated/fefe5ae6107231a3f738b36d95153f77 /cctz/tzdata/America/Eirunepe + generated/ec589bada56b3352067a359694896292 /cctz/tzdata/America/El_Salvador + generated/661db30d5b9bb274f574dfc456f95137 /cctz/tzdata/America/Ensenada + generated/0998859e2d38d079cc1a3429aa428db4 /cctz/tzdata/America/Fort_Nelson + generated/9208172103191bf0d660e0023b358ea1 /cctz/tzdata/America/Fort_Wayne + generated/c72cd4fac2e9b8659f6b5bb2392b9ae5 /cctz/tzdata/America/Fortaleza + generated/8f9746ead1fc03c962cdd7ddacde663d /cctz/tzdata/America/Glace_Bay + generated/acff9e84de94eeb7b58120a56d50cc50 /cctz/tzdata/America/Godthab + generated/7c49d7ec95c93d0934a7a98b1a1ae66f /cctz/tzdata/America/Goose_Bay + generated/eac76eb95be7b5cc25a41e0485b58c41 /cctz/tzdata/America/Grand_Turk + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Grenada + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Guadeloupe + generated/f8be05a9398502fc14e50eea2693497c /cctz/tzdata/America/Guatemala + generated/dada91f7db29bcab55bfd2478a5b0779 /cctz/tzdata/America/Guayaquil + generated/10089d01ae922cfd19a041f3de5ae1ea /cctz/tzdata/America/Guyana + generated/ef31a488808a56cc6d3c9a3c5a53abeb /cctz/tzdata/America/Halifax + generated/14af0ba77d76b97e0e666c070c2172cf /cctz/tzdata/America/Havana + generated/03ff2b0ed691f72f1e04e18e84818dcf /cctz/tzdata/America/Hermosillo + generated/9208172103191bf0d660e0023b358ea1 /cctz/tzdata/America/Indiana/Indianapolis + generated/964fb4bc6d047b2a8826a0734633ab0b /cctz/tzdata/America/Indiana/Knox + generated/fdc9d5431dd16120c1465f298e28e260 /cctz/tzdata/America/Indiana/Marengo + generated/2c18bc1a2ddb1b06e98ffa553ef1aaee /cctz/tzdata/America/Indiana/Petersburg + generated/90db76a975de863aadbcf37b47e18cd2 /cctz/tzdata/America/Indiana/Tell_City + generated/768d11c820a4f93683de8f8bc03df8c8 /cctz/tzdata/America/Indiana/Vevay + generated/7ca29f8adb394d878db41ab40c4c9a5d /cctz/tzdata/America/Indiana/Vincennes + generated/a23719c2255c2c9829fe6978c1c8ecd7 /cctz/tzdata/America/Indiana/Winamac + generated/9208172103191bf0d660e0023b358ea1 /cctz/tzdata/America/Indianapolis + generated/f51089782974399a845a8ab6e8825bfd /cctz/tzdata/America/Inuvik + generated/b8248a79b8e4c6de4f23c59e360d333e /cctz/tzdata/America/Iqaluit + generated/6ddb543268cbeb4a7fffad436081b019 /cctz/tzdata/America/Jamaica + generated/239a70724a0ff39d5dd3e6b7f4a34212 /cctz/tzdata/America/Jujuy + generated/a9b6712f7efd08406ebb3f4a43bf1862 /cctz/tzdata/America/Juneau + generated/9d9fdcb5bec6ef7173f20c0b968ae540 /cctz/tzdata/America/Kentucky/Louisville + generated/755a91932697ce463a5c9b642e5292d6 /cctz/tzdata/America/Kentucky/Monticello + generated/964fb4bc6d047b2a8826a0734633ab0b /cctz/tzdata/America/Knox_IN + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Kralendijk + generated/fd46d501559b1cf8c8c1fa330196b1b0 /cctz/tzdata/America/La_Paz + generated/bd9c4fdf467f96ab33dde64bf0ac700c /cctz/tzdata/America/Lima + generated/641e03b9a1178df8c823447ea6563f25 /cctz/tzdata/America/Los_Angeles + generated/9d9fdcb5bec6ef7173f20c0b968ae540 /cctz/tzdata/America/Louisville + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Lower_Princes + generated/823a97c8e447d6f0016bacafd20a246e /cctz/tzdata/America/Maceio + generated/8435b750c0255a506ff0fd58bf646f00 /cctz/tzdata/America/Managua + generated/bbb3263234960c35b55fffa1327cc48c /cctz/tzdata/America/Manaus + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Marigot + generated/450d5ffb8f5928afc0981b5a1a8ba4fa /cctz/tzdata/America/Martinique + generated/7f275e73d3e8e33981b4060f6af159ea /cctz/tzdata/America/Matamoros + generated/2b72d499c62e0523c21b73a12d147157 /cctz/tzdata/America/Mazatlan + generated/839eacc63921f196e4ecfded7245a67b /cctz/tzdata/America/Mendoza + generated/b6fc5775917cac51306de9bf93d87827 /cctz/tzdata/America/Menominee + generated/5fcda9efe6faeae5a8097716a64a127b /cctz/tzdata/America/Merida + generated/4335653c96fc0b0fc83e2604a8362934 /cctz/tzdata/America/Metlakatla + generated/82169289ef8c8f15473bc1fcb55123d0 /cctz/tzdata/America/Mexico_City + generated/4b51b9e60156a250908acc46d7c8cabc /cctz/tzdata/America/Miquelon + generated/3ff9cb17a579851ce689eac23e64d899 /cctz/tzdata/America/Moncton + generated/bc1bca66f089c87648f0e54b0d0559a6 /cctz/tzdata/America/Monterrey + generated/64e0eb5df848bbc06156c58b35959680 /cctz/tzdata/America/Montevideo + generated/628174eba2d7050564c54d1370a19ca8 /cctz/tzdata/America/Montreal + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Montserrat + generated/628174eba2d7050564c54d1370a19ca8 /cctz/tzdata/America/Nassau + generated/763d7a8374a42066d2b0bb81bd47218f /cctz/tzdata/America/New_York + generated/628174eba2d7050564c54d1370a19ca8 /cctz/tzdata/America/Nipigon + generated/97ed2cb6ee44823ce8fabdc0beeae2b9 /cctz/tzdata/America/Nome + generated/6c4f6742a67bbd289f89eb4fe7de8e57 /cctz/tzdata/America/Noronha + generated/b72620d427a1898ea97232aeba51c2dc /cctz/tzdata/America/North_Dakota/Beulah + generated/511edb5c79692d730d309f4424bbaa0e /cctz/tzdata/America/North_Dakota/Center + generated/6e5fd4a73872524a21354303cdfff0f8 /cctz/tzdata/America/North_Dakota/New_Salem + generated/acff9e84de94eeb7b58120a56d50cc50 /cctz/tzdata/America/Nuuk + generated/ed478f9e09d75276d125fb7e61188b5f /cctz/tzdata/America/Ojinaga + generated/595e67b4c97fda031a90e5ef80813e7d /cctz/tzdata/America/Panama + generated/b8248a79b8e4c6de4f23c59e360d333e /cctz/tzdata/America/Pangnirtung + generated/7dacf7ad9037fa33db4536edf63da220 /cctz/tzdata/America/Paramaribo + generated/db536e94d95836d7c5725c3b3c086586 /cctz/tzdata/America/Phoenix + generated/f07474008b0495a1830bf6ec76104684 /cctz/tzdata/America/Port-au-Prince + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Port_of_Spain + generated/0b427173cd7de48179954c1706df9f0f /cctz/tzdata/America/Porto_Acre + generated/d3dbc4b002cc7a0e5761a3097651309a /cctz/tzdata/America/Porto_Velho + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Puerto_Rico + generated/a06adc807729db23da9fdb54dc714f8b /cctz/tzdata/America/Punta_Arenas + generated/1ee6e72e10673d4a16b6e24671f793ec /cctz/tzdata/America/Rainy_River + generated/ea521f9e43ebb66928bb2f9462a509d2 /cctz/tzdata/America/Rankin_Inlet + generated/cc7e35a2df60f44003b96877116f4d93 /cctz/tzdata/America/Recife + generated/c87b8b428cfdf54309e9503177e0ca5f /cctz/tzdata/America/Regina + generated/6c82012b52156392f0cd7178ebcfa900 /cctz/tzdata/America/Resolute + generated/0b427173cd7de48179954c1706df9f0f /cctz/tzdata/America/Rio_Branco + generated/5c57dc3d11f5a64fac22a08ea0c64d25 /cctz/tzdata/America/Rosario + generated/661db30d5b9bb274f574dfc456f95137 /cctz/tzdata/America/Santa_Isabel + generated/79b1d15365011739a45fe1de0258ae52 /cctz/tzdata/America/Santarem + generated/c3b66836f89ba29559e1b438d7454e0b /cctz/tzdata/America/Santiago + generated/3f4c05321e52971f2213bfb9e45b7a35 /cctz/tzdata/America/Santo_Domingo + generated/94e0437e48ebbef69b3fb7fe2af5e0f2 /cctz/tzdata/America/Sao_Paulo + generated/77d9cbb7aa1e48aa0380d2c3b61c75d5 /cctz/tzdata/America/Scoresbysund + generated/c1b9655d5b1ce7fbc9ac213e921acc88 /cctz/tzdata/America/Shiprock + generated/4b710acfb88ea85eda7b5f75df122214 /cctz/tzdata/America/Sitka + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/St_Barthelemy + generated/a181d1167a1dbfc2682f6d4ba9f3c803 /cctz/tzdata/America/St_Johns + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/St_Kitts + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/St_Lucia + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/St_Thomas + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/St_Vincent + generated/4a956902cb69a4cba608798e1da71a58 /cctz/tzdata/America/Swift_Current + generated/b3c87245083e0474ed4ce3d23abb7f4f /cctz/tzdata/America/Tegucigalpa + generated/b8c39bf52aaa707c58a301ce115ee576 /cctz/tzdata/America/Thule + generated/628174eba2d7050564c54d1370a19ca8 /cctz/tzdata/America/Thunder_Bay + generated/661db30d5b9bb274f574dfc456f95137 /cctz/tzdata/America/Tijuana + generated/628174eba2d7050564c54d1370a19ca8 /cctz/tzdata/America/Toronto + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Tortola + generated/bc58930f92342790d3ee214524808faa /cctz/tzdata/America/Vancouver + generated/92d3b867243120ea811c24c038e5b053 /cctz/tzdata/America/Virgin + generated/5fa937049e86ffbf52d4348c6c43b0ad /cctz/tzdata/America/Whitehorse + generated/1ee6e72e10673d4a16b6e24671f793ec /cctz/tzdata/America/Winnipeg + generated/3ee52913271777c67f23d5a918bb0f7c /cctz/tzdata/America/Yakutat + generated/beb91df50b24718aed963a509c0c2958 /cctz/tzdata/America/Yellowknife + generated/4d5e4576a979e0cdeb6a7d0e81989b4e /cctz/tzdata/Antarctica/Casey + generated/b61230343294608431fbbd939bb6971d /cctz/tzdata/Antarctica/Davis + generated/bcf8aa818432d7ae244087c7306bcb23 /cctz/tzdata/Antarctica/DumontDUrville + generated/93ccc0d9fe3d862e546a627982ce5ba7 /cctz/tzdata/Antarctica/Macquarie + generated/63f5d146aa8a66720b2c4db9e87ec1f4 /cctz/tzdata/Antarctica/Mawson + generated/655680c9ae07d4896919210710185038 /cctz/tzdata/Antarctica/McMurdo + generated/3a420ea50d496f0c159a0d18af06b211 /cctz/tzdata/Antarctica/Palmer + generated/0fb4aa6fed3f28bc7a3dae35a993171a /cctz/tzdata/Antarctica/Rothera + generated/655680c9ae07d4896919210710185038 /cctz/tzdata/Antarctica/South_Pole + generated/165baa2c51758e236a98a6a1c4cf09a0 /cctz/tzdata/Antarctica/Syowa + generated/11ca9bc056ef1ae4643107bea827928f /cctz/tzdata/Antarctica/Troll + generated/67c981ccf51584922a1f72dd2d529730 /cctz/tzdata/Antarctica/Vostok + generated/2577d6d2ba90616ca47c8ee8d9fbca20 /cctz/tzdata/Arctic/Longyearbyen + generated/165baa2c51758e236a98a6a1c4cf09a0 /cctz/tzdata/Asia/Aden + generated/eaa234bf9babed72ac5b25c9a3dffa15 /cctz/tzdata/Asia/Almaty + generated/0abd3c37bec0c4c7f1a2284c3457adb3 /cctz/tzdata/Asia/Amman + generated/f627017649ea589681b7b0dd45c03118 /cctz/tzdata/Asia/Anadyr + generated/af82eec1529bf616942df14b2ffb4403 /cctz/tzdata/Asia/Aqtau + generated/34dc35c8aa0f4e3a0064a92e5aa5d762 /cctz/tzdata/Asia/Aqtobe + generated/c68faf20645ecd953e8eb2fb70469f59 /cctz/tzdata/Asia/Ashgabat + generated/c68faf20645ecd953e8eb2fb70469f59 /cctz/tzdata/Asia/Ashkhabad + generated/dc74e10d17659800407d742d3a5db22b /cctz/tzdata/Asia/Atyrau + generated/9aa23335da47827d5ce36afc1523bbd3 /cctz/tzdata/Asia/Baghdad + generated/ec12549279e64ebeb926579888cf89d9 /cctz/tzdata/Asia/Bahrain + generated/bde0fe003b2df5121f0d31d3954095a6 /cctz/tzdata/Asia/Baku + generated/ff94f36118acae9ef3e19438688e266b /cctz/tzdata/Asia/Bangkok + generated/8a8ef367f59b0e3880bd1cff6651b357 /cctz/tzdata/Asia/Barnaul + generated/5e8c48c7a60c434f1e2f1e535172cbb9 /cctz/tzdata/Asia/Beirut + generated/56a77f4891fb3e9506aa233f5fbac27e /cctz/tzdata/Asia/Bishkek + generated/bf388a0a1da2be989c25dbfb587076d8 /cctz/tzdata/Asia/Brunei + generated/16a0b637c31e7e480cfccfc46dd75d67 /cctz/tzdata/Asia/Calcutta + generated/2d0a65ce6c15961ab95c917d9f23e882 /cctz/tzdata/Asia/Chita + generated/36687b86e799dc46c4ad4c49e3222ea5 /cctz/tzdata/Asia/Choibalsan + generated/dff9cd919f10d25842d1381cdff9f7f7 /cctz/tzdata/Asia/Chongqing + generated/dff9cd919f10d25842d1381cdff9f7f7 /cctz/tzdata/Asia/Chungking + generated/d41b1974e5ec6b3bc790062a97894a37 /cctz/tzdata/Asia/Colombo + generated/940f5a339a1f12a7153474fc3c92c624 /cctz/tzdata/Asia/Dacca + generated/c8376c6c326f4e99e093b6bc6cb9cd6e /cctz/tzdata/Asia/Damascus + generated/940f5a339a1f12a7153474fc3c92c624 /cctz/tzdata/Asia/Dhaka + generated/8a60b6309c1443774d2f065bcf2bbc61 /cctz/tzdata/Asia/Dili + generated/667e494c45d181f0706bd07b211c850b /cctz/tzdata/Asia/Dubai + generated/7d4619fed11db15c54153613fcf23bda /cctz/tzdata/Asia/Dushanbe + generated/4cd70a6fdc80b1b15c0b9f7c3b807107 /cctz/tzdata/Asia/Famagusta + generated/2910f8ef0c04e980cb9fac5f8f62b334 /cctz/tzdata/Asia/Gaza + generated/dff9cd919f10d25842d1381cdff9f7f7 /cctz/tzdata/Asia/Harbin + generated/6853ddd2f1d2e3899a8433b015ed726a /cctz/tzdata/Asia/Hebron + generated/009a0575634eab075d7e8a15b2e443ae /cctz/tzdata/Asia/Ho_Chi_Minh + generated/f729c88451bacd2895fc1c8d29064c46 /cctz/tzdata/Asia/Hong_Kong + generated/3c4a6f9840f3d89534c5f511329704e8 /cctz/tzdata/Asia/Hovd + generated/4e36cb5f575bdcbdd38b144d5a9195c9 /cctz/tzdata/Asia/Irkutsk + generated/48252c9a797f0f4bea97557a5094cf98 /cctz/tzdata/Asia/Istanbul + generated/325a2d872e0c0e5339f2e134e921047a /cctz/tzdata/Asia/Jakarta + generated/4709fe18f39068d2ca7de4c5396e1513 /cctz/tzdata/Asia/Jayapura + generated/9360bb34802002d91d9bba174c25a8dc /cctz/tzdata/Asia/Jerusalem + generated/17ca5b7fed86c92696b863cb6a78187f /cctz/tzdata/Asia/Kabul + generated/959247e441092255286b22fef107172f /cctz/tzdata/Asia/Kamchatka + generated/ef4485e168a60d91cc5347e5de9a3407 /cctz/tzdata/Asia/Karachi + generated/67c981ccf51584922a1f72dd2d529730 /cctz/tzdata/Asia/Kashgar + generated/90518d05c449fad639594f7f575407d6 /cctz/tzdata/Asia/Kathmandu + generated/90518d05c449fad639594f7f575407d6 /cctz/tzdata/Asia/Katmandu + generated/c46a3b3c120085251d04dd583a06b6a4 /cctz/tzdata/Asia/Khandyga + generated/16a0b637c31e7e480cfccfc46dd75d67 /cctz/tzdata/Asia/Kolkata + generated/702a65f05da90971b14686c21add1a90 /cctz/tzdata/Asia/Krasnoyarsk + generated/8a2bb95893137bb40748ef4ecd8d7435 /cctz/tzdata/Asia/Kuala_Lumpur + generated/bf388a0a1da2be989c25dbfb587076d8 /cctz/tzdata/Asia/Kuching + generated/165baa2c51758e236a98a6a1c4cf09a0 /cctz/tzdata/Asia/Kuwait + generated/d3dfd69107a4d78facbc67c4d8cea004 /cctz/tzdata/Asia/Macao + generated/d3dfd69107a4d78facbc67c4d8cea004 /cctz/tzdata/Asia/Macau + generated/656bd0f3d2def024f4d1e59fc668b538 /cctz/tzdata/Asia/Magadan + generated/c8c41a468e356c6bb65e89c69e4406dc /cctz/tzdata/Asia/Makassar + generated/52f31607db7a4a081c63dfb4cc578408 /cctz/tzdata/Asia/Manila + generated/667e494c45d181f0706bd07b211c850b /cctz/tzdata/Asia/Muscat + generated/beb20df2d2d5e3e5f5f50fb2da2a4782 /cctz/tzdata/Asia/Nicosia + generated/71705112182911b4327ac195ffae174b /cctz/tzdata/Asia/Novokuznetsk + generated/8c3304792234093e5a3d5debcef24a32 /cctz/tzdata/Asia/Novosibirsk + generated/2ee30998e941f8d603ad278135230cbd /cctz/tzdata/Asia/Omsk + generated/c72131eaa200e2aa58e1c12fe94f1f67 /cctz/tzdata/Asia/Oral + generated/ff94f36118acae9ef3e19438688e266b /cctz/tzdata/Asia/Phnom_Penh + generated/28fe8388ff78123cfd04d67e32057886 /cctz/tzdata/Asia/Pontianak + generated/772e6342aeba16851eed7dcda632c5be /cctz/tzdata/Asia/Pyongyang + generated/ec12549279e64ebeb926579888cf89d9 /cctz/tzdata/Asia/Qatar + generated/f44dbe7ca52c5fb8b57e33fd8e094038 /cctz/tzdata/Asia/Qostanay + generated/4fff9a8801bd2b75474dde3870d24e89 /cctz/tzdata/Asia/Qyzylorda + generated/37f26cf8b8fe9179833e366ca13b8916 /cctz/tzdata/Asia/Rangoon + generated/165baa2c51758e236a98a6a1c4cf09a0 /cctz/tzdata/Asia/Riyadh + generated/009a0575634eab075d7e8a15b2e443ae /cctz/tzdata/Asia/Saigon + generated/a1239114e71b76c885dbad8f2fa61de4 /cctz/tzdata/Asia/Sakhalin + generated/9f39ae0771032afbfca86630bec12768 /cctz/tzdata/Asia/Samarkand + generated/da5aae5f9a71de05b4625f74b007c461 /cctz/tzdata/Asia/Seoul + generated/dff9cd919f10d25842d1381cdff9f7f7 /cctz/tzdata/Asia/Shanghai + generated/8a2bb95893137bb40748ef4ecd8d7435 /cctz/tzdata/Asia/Singapore + generated/d155718faacae2f6288b0c88e66f851c /cctz/tzdata/Asia/Srednekolymsk + generated/eda5a4ce01efed633c50e04d09fe73b2 /cctz/tzdata/Asia/Taipei + generated/310f6ba2360c27c334c6e17fccf2b9a5 /cctz/tzdata/Asia/Tashkent + generated/d3ca7527ee42255559acf2d74d749d00 /cctz/tzdata/Asia/Tbilisi + generated/f4825b22e2ad8fb3e0bf20daa84bd774 /cctz/tzdata/Asia/Tehran + generated/9360bb34802002d91d9bba174c25a8dc /cctz/tzdata/Asia/Tel_Aviv + generated/b4aa5f2b966a76ebc38d1aab44d86bce /cctz/tzdata/Asia/Thimbu + generated/b4aa5f2b966a76ebc38d1aab44d86bce /cctz/tzdata/Asia/Thimphu + generated/618a4a8f78720e26749b9c29ed4fd1b3 /cctz/tzdata/Asia/Tokyo + generated/e770be0bb1b43b9bc7df85f9ac184a79 /cctz/tzdata/Asia/Tomsk + generated/c8c41a468e356c6bb65e89c69e4406dc /cctz/tzdata/Asia/Ujung_Pandang + generated/66a0ec5d00519d1826d055514861779d /cctz/tzdata/Asia/Ulaanbaatar + generated/66a0ec5d00519d1826d055514861779d /cctz/tzdata/Asia/Ulan_Bator + generated/67c981ccf51584922a1f72dd2d529730 /cctz/tzdata/Asia/Urumqi + generated/04875c383508e7181ae595cec9856228 /cctz/tzdata/Asia/Ust-Nera + generated/ff94f36118acae9ef3e19438688e266b /cctz/tzdata/Asia/Vientiane + generated/4709139f1759e9693b8c02551b527f58 /cctz/tzdata/Asia/Vladivostok + generated/b22b7be8696db5ca60fb0b7bba4c8718 /cctz/tzdata/Asia/Yakutsk + generated/37f26cf8b8fe9179833e366ca13b8916 /cctz/tzdata/Asia/Yangon + generated/bfd18d52a4546531e2f3112725f092d3 /cctz/tzdata/Asia/Yekaterinburg + generated/d1c5195eed8efac077678d1c6d988f7f /cctz/tzdata/Asia/Yerevan + generated/93bd1a44f9245279aa44a94d4c435e5c /cctz/tzdata/Atlantic/Azores + generated/b85d659fabeeb1257ade1f6282a5ec7d /cctz/tzdata/Atlantic/Bermuda + generated/1e571eef4b7112bb58a746099afd9f02 /cctz/tzdata/Atlantic/Canary + generated/b7ad70caecef25e4a9ba1e5afd95fe25 /cctz/tzdata/Atlantic/Cape_Verde + generated/253d5505eaf3a497f4fa107633bea235 /cctz/tzdata/Atlantic/Faeroe + generated/253d5505eaf3a497f4fa107633bea235 /cctz/tzdata/Atlantic/Faroe + generated/2577d6d2ba90616ca47c8ee8d9fbca20 /cctz/tzdata/Atlantic/Jan_Mayen + generated/4f2a136a6f59628aeea0d09480d630d2 /cctz/tzdata/Atlantic/Madeira + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Atlantic/Reykjavik + generated/2aa2dbd00a40fc7bdc1f1e3d461a2646 /cctz/tzdata/Atlantic/South_Georgia + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Atlantic/St_Helena + generated/2a4c8fd0d241b11b207c41b0aedd6cf9 /cctz/tzdata/Atlantic/Stanley + generated/a1085ba102822f56191705c405f2a8ad /cctz/tzdata/Australia/ACT + generated/02d7a06f7ede604bdd6bf40932b670c6 /cctz/tzdata/Australia/Adelaide + generated/d5464310b37a30d92f5b85d128dd4937 /cctz/tzdata/Australia/Brisbane + generated/35eebba76b28756b47e8fff3157eafdb /cctz/tzdata/Australia/Broken_Hill + generated/a1085ba102822f56191705c405f2a8ad /cctz/tzdata/Australia/Canberra + generated/8371d9f10ef8a679be6eadedc6641d73 /cctz/tzdata/Australia/Currie + generated/09e36f9135b9ddb666cbb9496fecdf89 /cctz/tzdata/Australia/Darwin + generated/e0185725b852fe59ef8e5fef9f619990 /cctz/tzdata/Australia/Eucla + generated/8371d9f10ef8a679be6eadedc6641d73 /cctz/tzdata/Australia/Hobart + generated/e68c0f2ebe9dc247712393ab1bd168d2 /cctz/tzdata/Australia/LHI + generated/1b6ec1c2e23ea5b37361d885e1db8450 /cctz/tzdata/Australia/Lindeman + generated/e68c0f2ebe9dc247712393ab1bd168d2 /cctz/tzdata/Australia/Lord_Howe + generated/e308055a9c06f33a854a9d579ed61249 /cctz/tzdata/Australia/Melbourne + generated/a1085ba102822f56191705c405f2a8ad /cctz/tzdata/Australia/NSW + generated/09e36f9135b9ddb666cbb9496fecdf89 /cctz/tzdata/Australia/North + generated/543113396c7e34a7532457a1ce759c4e /cctz/tzdata/Australia/Perth + generated/d5464310b37a30d92f5b85d128dd4937 /cctz/tzdata/Australia/Queensland + generated/02d7a06f7ede604bdd6bf40932b670c6 /cctz/tzdata/Australia/South + generated/a1085ba102822f56191705c405f2a8ad /cctz/tzdata/Australia/Sydney + generated/8371d9f10ef8a679be6eadedc6641d73 /cctz/tzdata/Australia/Tasmania + generated/e308055a9c06f33a854a9d579ed61249 /cctz/tzdata/Australia/Victoria + generated/543113396c7e34a7532457a1ce759c4e /cctz/tzdata/Australia/West + generated/35eebba76b28756b47e8fff3157eafdb /cctz/tzdata/Australia/Yancowinna + generated/0b427173cd7de48179954c1706df9f0f /cctz/tzdata/Brazil/Acre + generated/6c4f6742a67bbd289f89eb4fe7de8e57 /cctz/tzdata/Brazil/DeNoronha + generated/94e0437e48ebbef69b3fb7fe2af5e0f2 /cctz/tzdata/Brazil/East + generated/bbb3263234960c35b55fffa1327cc48c /cctz/tzdata/Brazil/West + generated/9bc8fb09717950cb4149283c5aff15ac /cctz/tzdata/CET + generated/43c7956d0835817f930236a5633cffa6 /cctz/tzdata/CST6CDT + generated/ef31a488808a56cc6d3c9a3c5a53abeb /cctz/tzdata/Canada/Atlantic + generated/1ee6e72e10673d4a16b6e24671f793ec /cctz/tzdata/Canada/Central + generated/628174eba2d7050564c54d1370a19ca8 /cctz/tzdata/Canada/Eastern + generated/beb91df50b24718aed963a509c0c2958 /cctz/tzdata/Canada/Mountain + generated/a181d1167a1dbfc2682f6d4ba9f3c803 /cctz/tzdata/Canada/Newfoundland + generated/bc58930f92342790d3ee214524808faa /cctz/tzdata/Canada/Pacific + generated/c87b8b428cfdf54309e9503177e0ca5f /cctz/tzdata/Canada/Saskatchewan + generated/5fa937049e86ffbf52d4348c6c43b0ad /cctz/tzdata/Canada/Yukon + generated/c3b66836f89ba29559e1b438d7454e0b /cctz/tzdata/Chile/Continental + generated/57aca34c4b3ca88d9c94b88990c62c79 /cctz/tzdata/Chile/EasterIsland + generated/14af0ba77d76b97e0e666c070c2172cf /cctz/tzdata/Cuba + generated/19ef27aa43febb679c0795f8c5dedc0f /cctz/tzdata/EET + generated/b33eb6506380f950ad798d4d788d136a /cctz/tzdata/EST + generated/5fbedfd64bddc3ec7790a4eb0f22b66c /cctz/tzdata/EST5EDT + generated/8dcab26c06fc82939d77511b0c7c24b2 /cctz/tzdata/Egypt + generated/1917c051a13995cc4c32d2ce05bc3e7b /cctz/tzdata/Eire + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/Etc/GMT + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/Etc/GMT+0 + generated/d8af0cadc03a3813b866bbfeb041e167 /cctz/tzdata/Etc/GMT+1 + generated/9766867907fd0631d6357abfcb71fde5 /cctz/tzdata/Etc/GMT+10 + generated/d40107fc4f4515f2f2eed25a1ca88fb8 /cctz/tzdata/Etc/GMT+11 + generated/52569f1fcc560faffd0ed78e0e9eb69f /cctz/tzdata/Etc/GMT+12 + generated/29c0187634c10fc717832169fc449715 /cctz/tzdata/Etc/GMT+2 + generated/0d49585e3c48010af348561943e319a2 /cctz/tzdata/Etc/GMT+3 + generated/88546761589cb98c5209ff92ac71be7d /cctz/tzdata/Etc/GMT+4 + generated/9c4035bc2046d3be368e14a46fc8685d /cctz/tzdata/Etc/GMT+5 + generated/a79c9f48310a80244f2065d08f09f91a /cctz/tzdata/Etc/GMT+6 + generated/7956f01b2e6933717e9ba4adfd327ccc /cctz/tzdata/Etc/GMT+7 + generated/9eaedd2c3574882c46ddbbfeabc5c444 /cctz/tzdata/Etc/GMT+8 + generated/0d81f8cc7c4066b8f84371ebbbb3e00c /cctz/tzdata/Etc/GMT+9 + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/Etc/GMT-0 + generated/721967abda97296c7f361100d8b868e4 /cctz/tzdata/Etc/GMT-1 + generated/42fcd2bd28f14995f4fec31b081d88b0 /cctz/tzdata/Etc/GMT-10 + generated/ba0134eab8c956f482f642c6a5440ee0 /cctz/tzdata/Etc/GMT-11 + generated/f669833977d5968e30ce9d8288dccd22 /cctz/tzdata/Etc/GMT-12 + generated/7176177837995c39668c29a4a459cb55 /cctz/tzdata/Etc/GMT-13 + generated/39ffa0df7491f260ed87949d60aa34da /cctz/tzdata/Etc/GMT-14 + generated/f72cea14be81564422856a5e3633b0f0 /cctz/tzdata/Etc/GMT-2 + generated/6af1f235706f2c48a99cabb1efcd0e53 /cctz/tzdata/Etc/GMT-3 + generated/dced2b01cc7c29f0b1adf9c62f8603fd /cctz/tzdata/Etc/GMT-4 + generated/167b215e24978122218b1a0eec97ea7a /cctz/tzdata/Etc/GMT-5 + generated/43d37a94ef2f6ee11c55e0a14c2898cb /cctz/tzdata/Etc/GMT-6 + generated/ade2a36e23a06174c36b6fd5d795e865 /cctz/tzdata/Etc/GMT-7 + generated/8e7f6cfc11d44c8e29f7f4a59df5fcae /cctz/tzdata/Etc/GMT-8 + generated/ccc5a76bcf9b46bc41f3ffb232850bbb /cctz/tzdata/Etc/GMT-9 + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/Etc/GMT0 + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/Etc/Greenwich + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/Etc/UCT + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/Etc/UTC + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/Etc/Universal + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/Etc/Zulu + generated/7a350885dea1ebe1bf630eb4254e9abc /cctz/tzdata/Europe/Amsterdam + generated/89cb42bccb29740b74d74dad225a7f70 /cctz/tzdata/Europe/Andorra + generated/29067b92c3481871788d16e05841ce78 /cctz/tzdata/Europe/Astrakhan + generated/9006b968810f68ce90473c809b252776 /cctz/tzdata/Europe/Athens + generated/b14ab0a98fb1964def4eaf00d2a6bb73 /cctz/tzdata/Europe/Belfast + generated/a4ac1780d547f4e4c41cab4c6cf1d76d /cctz/tzdata/Europe/Belgrade + generated/2577d6d2ba90616ca47c8ee8d9fbca20 /cctz/tzdata/Europe/Berlin + generated/9ac4de9fb3bcae616f7de40984ccb6b2 /cctz/tzdata/Europe/Bratislava + generated/7a350885dea1ebe1bf630eb4254e9abc /cctz/tzdata/Europe/Brussels + generated/f0976c6697d91943b1d72c331844db50 /cctz/tzdata/Europe/Bucharest + generated/0b00b9da0d4f68857bdebb750ea28c4d /cctz/tzdata/Europe/Budapest + generated/07b0081174b26fd15187b9d6a019e322 /cctz/tzdata/Europe/Busingen + generated/d62d0d008574b60d70899d22545eb1f9 /cctz/tzdata/Europe/Chisinau + generated/2577d6d2ba90616ca47c8ee8d9fbca20 /cctz/tzdata/Europe/Copenhagen + generated/1917c051a13995cc4c32d2ce05bc3e7b /cctz/tzdata/Europe/Dublin + generated/8629c4ecded1abb6072c099aa6781c47 /cctz/tzdata/Europe/Gibraltar + generated/b14ab0a98fb1964def4eaf00d2a6bb73 /cctz/tzdata/Europe/Guernsey + generated/aecc05607e312ffdbdf3a8f07ac64a6b /cctz/tzdata/Europe/Helsinki + generated/b14ab0a98fb1964def4eaf00d2a6bb73 /cctz/tzdata/Europe/Isle_of_Man + generated/48252c9a797f0f4bea97557a5094cf98 /cctz/tzdata/Europe/Istanbul + generated/b14ab0a98fb1964def4eaf00d2a6bb73 /cctz/tzdata/Europe/Jersey + generated/e019dabd72a8783f7d4b4c1fe3dd5c11 /cctz/tzdata/Europe/Kaliningrad + generated/2a6d051e23c2e3ace6355f98f024796a /cctz/tzdata/Europe/Kiev + generated/0b403c8a9ccd7ca6e2a6efbb8ea7a0f0 /cctz/tzdata/Europe/Kirov + generated/2a6d051e23c2e3ace6355f98f024796a /cctz/tzdata/Europe/Kyiv + generated/41bc7cd4fe8c4fc8f59de742ebb69012 /cctz/tzdata/Europe/Lisbon + generated/a4ac1780d547f4e4c41cab4c6cf1d76d /cctz/tzdata/Europe/Ljubljana + generated/b14ab0a98fb1964def4eaf00d2a6bb73 /cctz/tzdata/Europe/London + generated/7a350885dea1ebe1bf630eb4254e9abc /cctz/tzdata/Europe/Luxembourg + generated/1377f55949e2a3c4cf3ccc96bb5a91a5 /cctz/tzdata/Europe/Madrid + generated/1fd961b54d21dd2ad91b05c7c71435a8 /cctz/tzdata/Europe/Malta + generated/aecc05607e312ffdbdf3a8f07ac64a6b /cctz/tzdata/Europe/Mariehamn + generated/aed64fc971bc7aa23cab042415d57d53 /cctz/tzdata/Europe/Minsk + generated/506e99f9c797d9798e7a411495691504 /cctz/tzdata/Europe/Monaco + generated/39b47bf37a27f7bcd5d3f7c51343c7fc /cctz/tzdata/Europe/Moscow + generated/beb20df2d2d5e3e5f5f50fb2da2a4782 /cctz/tzdata/Europe/Nicosia + generated/2577d6d2ba90616ca47c8ee8d9fbca20 /cctz/tzdata/Europe/Oslo + generated/506e99f9c797d9798e7a411495691504 /cctz/tzdata/Europe/Paris + generated/a4ac1780d547f4e4c41cab4c6cf1d76d /cctz/tzdata/Europe/Podgorica + generated/9ac4de9fb3bcae616f7de40984ccb6b2 /cctz/tzdata/Europe/Prague + generated/d917645873cf9c7577ce2fdbe05963cb /cctz/tzdata/Europe/Riga + generated/c57843caa48aa4715344a26830df1f13 /cctz/tzdata/Europe/Rome + generated/8baab5c53cf4270f860fb2de701ded9d /cctz/tzdata/Europe/Samara + generated/c57843caa48aa4715344a26830df1f13 /cctz/tzdata/Europe/San_Marino + generated/a4ac1780d547f4e4c41cab4c6cf1d76d /cctz/tzdata/Europe/Sarajevo + generated/c4aa97ffb42eeeb70479979e2050d866 /cctz/tzdata/Europe/Saratov + generated/3465e5d0858d49481e9bcfea787d1be7 /cctz/tzdata/Europe/Simferopol + generated/a4ac1780d547f4e4c41cab4c6cf1d76d /cctz/tzdata/Europe/Skopje + generated/710422cb894d7b930689a115e97f688b /cctz/tzdata/Europe/Sofia + generated/2577d6d2ba90616ca47c8ee8d9fbca20 /cctz/tzdata/Europe/Stockholm + generated/2b3fb59013e51fa85db1cee17e54edc8 /cctz/tzdata/Europe/Tallinn + generated/e9faa2fda4c9671e5002bf470313be76 /cctz/tzdata/Europe/Tirane + generated/d62d0d008574b60d70899d22545eb1f9 /cctz/tzdata/Europe/Tiraspol + generated/0dfaf73a64a7c3cfcd10756a6d545e08 /cctz/tzdata/Europe/Ulyanovsk + generated/2a6d051e23c2e3ace6355f98f024796a /cctz/tzdata/Europe/Uzhgorod + generated/07b0081174b26fd15187b9d6a019e322 /cctz/tzdata/Europe/Vaduz + generated/c57843caa48aa4715344a26830df1f13 /cctz/tzdata/Europe/Vatican + generated/fe03dcb43031a0d45d0039e33f1e4c42 /cctz/tzdata/Europe/Vienna + generated/57500f0613dd0355126a75ca0fb0db2c /cctz/tzdata/Europe/Vilnius + generated/19ed55c2f6f06452f1008cfb15e5636b /cctz/tzdata/Europe/Volgograd + generated/d44a4791346a5defc84c6bec9e52645d /cctz/tzdata/Europe/Warsaw + generated/a4ac1780d547f4e4c41cab4c6cf1d76d /cctz/tzdata/Europe/Zagreb + generated/2a6d051e23c2e3ace6355f98f024796a /cctz/tzdata/Europe/Zaporozhye + generated/07b0081174b26fd15187b9d6a019e322 /cctz/tzdata/Europe/Zurich + generated/e369eb23db7f75930ece7bf91b6b86a7 /cctz/tzdata/Factory + generated/b14ab0a98fb1964def4eaf00d2a6bb73 /cctz/tzdata/GB + generated/b14ab0a98fb1964def4eaf00d2a6bb73 /cctz/tzdata/GB-Eire + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/GMT + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/GMT+0 + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/GMT-0 + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/GMT0 + generated/e7577ad74319a942781e7153a97d7690 /cctz/tzdata/Greenwich + generated/a813cd94645ca8774632d328080f8d97 /cctz/tzdata/HST + generated/f729c88451bacd2895fc1c8d29064c46 /cctz/tzdata/Hongkong + generated/796a57137d718e4fa3db8ef611f18e61 /cctz/tzdata/Iceland + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Indian/Antananarivo + generated/f3ac587344d641763d27895afbe16345 /cctz/tzdata/Indian/Chagos + generated/ff94f36118acae9ef3e19438688e266b /cctz/tzdata/Indian/Christmas + generated/37f26cf8b8fe9179833e366ca13b8916 /cctz/tzdata/Indian/Cocos + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Indian/Comoro + generated/5d62b2758da6d68cb971d8f2cf64d432 /cctz/tzdata/Indian/Kerguelen + generated/667e494c45d181f0706bd07b211c850b /cctz/tzdata/Indian/Mahe + generated/5d62b2758da6d68cb971d8f2cf64d432 /cctz/tzdata/Indian/Maldives + generated/cea8767711bc79a4ec192e25706de5a5 /cctz/tzdata/Indian/Mauritius + generated/fe54394a3dcf951bad3c293980109dd2 /cctz/tzdata/Indian/Mayotte + generated/667e494c45d181f0706bd07b211c850b /cctz/tzdata/Indian/Reunion + generated/f4825b22e2ad8fb3e0bf20daa84bd774 /cctz/tzdata/Iran + generated/9360bb34802002d91d9bba174c25a8dc /cctz/tzdata/Israel + generated/6ddb543268cbeb4a7fffad436081b019 /cctz/tzdata/Jamaica + generated/618a4a8f78720e26749b9c29ed4fd1b3 /cctz/tzdata/Japan + generated/475a8ae9a30287527356f20d4456abd4 /cctz/tzdata/Kwajalein + generated/a6b8c0b7319f5fdca0ed634760ff6e3b /cctz/tzdata/Libya + generated/0727fa9015cd130fba15b7e7163ff139 /cctz/tzdata/MET + generated/ef8eca09259416ea4e1d5b4bb865a645 /cctz/tzdata/MST + generated/56dbf10674ff9ef08ef9088d7e7ab639 /cctz/tzdata/MST7MDT + generated/661db30d5b9bb274f574dfc456f95137 /cctz/tzdata/Mexico/BajaNorte + generated/2b72d499c62e0523c21b73a12d147157 /cctz/tzdata/Mexico/BajaSur + generated/82169289ef8c8f15473bc1fcb55123d0 /cctz/tzdata/Mexico/General + generated/655680c9ae07d4896919210710185038 /cctz/tzdata/NZ + generated/41dd4c2678c8776c4abdcc809932bbe7 /cctz/tzdata/NZ-CHAT + generated/c1b9655d5b1ce7fbc9ac213e921acc88 /cctz/tzdata/Navajo + generated/dff9cd919f10d25842d1381cdff9f7f7 /cctz/tzdata/PRC + generated/74b8879270f5bd60554e01c6610b1efb /cctz/tzdata/PST8PDT + generated/fa334faf4eac0c30d0a20353b78f1685 /cctz/tzdata/Pacific/Apia + generated/655680c9ae07d4896919210710185038 /cctz/tzdata/Pacific/Auckland + generated/d8977a620cda17fb8da4421e6c474f0c /cctz/tzdata/Pacific/Bougainville + generated/41dd4c2678c8776c4abdcc809932bbe7 /cctz/tzdata/Pacific/Chatham + generated/bcf8aa818432d7ae244087c7306bcb23 /cctz/tzdata/Pacific/Chuuk + generated/57aca34c4b3ca88d9c94b88990c62c79 /cctz/tzdata/Pacific/Easter + generated/4cddbf0831a9bbaa79369d3b91961a8f /cctz/tzdata/Pacific/Efate + generated/99cc3c716bf45f1ae5bb572baa4ad256 /cctz/tzdata/Pacific/Enderbury + generated/afaa4c77a1e912306f4ca578c933d4a6 /cctz/tzdata/Pacific/Fakaofo + generated/a92ef316c0c20b37f585aa00209c65cf /cctz/tzdata/Pacific/Fiji + generated/ba8d62a6ed66f462087e00ad76f7354d /cctz/tzdata/Pacific/Funafuti + generated/055c3628d78f3c9a01a7732c442f78f9 /cctz/tzdata/Pacific/Galapagos + generated/f4cf94e44810f7c25b2529ffe37ab772 /cctz/tzdata/Pacific/Gambier + generated/44355d47052f97ac7388446bce23e3ab /cctz/tzdata/Pacific/Guadalcanal + generated/ec185892bb2764a8280ee41ff8f2b032 /cctz/tzdata/Pacific/Guam + generated/5ed332a521639d91536739cfb9e4dde6 /cctz/tzdata/Pacific/Honolulu + generated/5ed332a521639d91536739cfb9e4dde6 /cctz/tzdata/Pacific/Johnston + generated/99cc3c716bf45f1ae5bb572baa4ad256 /cctz/tzdata/Pacific/Kanton + generated/1530b1e45e83ed3f4e61d1a6f2f4f706 /cctz/tzdata/Pacific/Kiritimati + generated/fb8a999658da8686edc727548949fd88 /cctz/tzdata/Pacific/Kosrae + generated/475a8ae9a30287527356f20d4456abd4 /cctz/tzdata/Pacific/Kwajalein + generated/ba8d62a6ed66f462087e00ad76f7354d /cctz/tzdata/Pacific/Majuro + generated/82b091bd4358c77e600c08893560419b /cctz/tzdata/Pacific/Marquesas + generated/f789c65f289caa627ea1f690836c48f6 /cctz/tzdata/Pacific/Midway + generated/fa85e90a2dcd44ced6128397a99b2668 /cctz/tzdata/Pacific/Nauru + generated/92ab841a2a7aa104cb62a09be6f1a232 /cctz/tzdata/Pacific/Niue + generated/0e8c2a93c75cfb3705dc63788803ebfb /cctz/tzdata/Pacific/Norfolk + generated/7f89369fd9501f16ae77919d4c0e5658 /cctz/tzdata/Pacific/Noumea + generated/f789c65f289caa627ea1f690836c48f6 /cctz/tzdata/Pacific/Pago_Pago + generated/8d2aeb9646f427ba69fab8ad34c51552 /cctz/tzdata/Pacific/Palau + generated/acf014221290656a061fff7e9fa818ee /cctz/tzdata/Pacific/Pitcairn + generated/44355d47052f97ac7388446bce23e3ab /cctz/tzdata/Pacific/Pohnpei + generated/44355d47052f97ac7388446bce23e3ab /cctz/tzdata/Pacific/Ponape + generated/bcf8aa818432d7ae244087c7306bcb23 /cctz/tzdata/Pacific/Port_Moresby + generated/5b3b7bd518d8afe48e97f141617c0531 /cctz/tzdata/Pacific/Rarotonga + generated/ec185892bb2764a8280ee41ff8f2b032 /cctz/tzdata/Pacific/Saipan + generated/f789c65f289caa627ea1f690836c48f6 /cctz/tzdata/Pacific/Samoa + generated/0672593cd4756dbfb8bba02b4555c91d /cctz/tzdata/Pacific/Tahiti + generated/ba8d62a6ed66f462087e00ad76f7354d /cctz/tzdata/Pacific/Tarawa + generated/460900dfed7410df3acffe5b811d0f02 /cctz/tzdata/Pacific/Tongatapu + generated/bcf8aa818432d7ae244087c7306bcb23 /cctz/tzdata/Pacific/Truk + generated/ba8d62a6ed66f462087e00ad76f7354d /cctz/tzdata/Pacific/Wake + generated/ba8d62a6ed66f462087e00ad76f7354d /cctz/tzdata/Pacific/Wallis + generated/bcf8aa818432d7ae244087c7306bcb23 /cctz/tzdata/Pacific/Yap + generated/d44a4791346a5defc84c6bec9e52645d /cctz/tzdata/Poland + generated/41bc7cd4fe8c4fc8f59de742ebb69012 /cctz/tzdata/Portugal + generated/eda5a4ce01efed633c50e04d09fe73b2 /cctz/tzdata/ROC + generated/da5aae5f9a71de05b4625f74b007c461 /cctz/tzdata/ROK + generated/8a2bb95893137bb40748ef4ecd8d7435 /cctz/tzdata/Singapore + generated/48252c9a797f0f4bea97557a5094cf98 /cctz/tzdata/Turkey + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/UCT + generated/77ea6e8a582f87d7a397a9e7b2111be0 /cctz/tzdata/US/Alaska + generated/1df7e605c33529940c76c1c145c52fc5 /cctz/tzdata/US/Aleutian + generated/db536e94d95836d7c5725c3b3c086586 /cctz/tzdata/US/Arizona + generated/85435a33486747b319872947c68317f3 /cctz/tzdata/US/Central + generated/9208172103191bf0d660e0023b358ea1 /cctz/tzdata/US/East-Indiana + generated/763d7a8374a42066d2b0bb81bd47218f /cctz/tzdata/US/Eastern + generated/5ed332a521639d91536739cfb9e4dde6 /cctz/tzdata/US/Hawaii + generated/964fb4bc6d047b2a8826a0734633ab0b /cctz/tzdata/US/Indiana-Starke + generated/48c96bff46ef373ce5d759dc4a4d2de2 /cctz/tzdata/US/Michigan + generated/c1b9655d5b1ce7fbc9ac213e921acc88 /cctz/tzdata/US/Mountain + generated/641e03b9a1178df8c823447ea6563f25 /cctz/tzdata/US/Pacific + generated/f789c65f289caa627ea1f690836c48f6 /cctz/tzdata/US/Samoa + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/UTC + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/Universal + generated/39b47bf37a27f7bcd5d3f7c51343c7fc /cctz/tzdata/W-SU + generated/0124cd65b22dfd92129cb0a43719c717 /cctz/tzdata/WET + generated/51d8a0e68892ebf0854a1b4250ffb26b /cctz/tzdata/Zulu +) diff --git a/contrib/libs/cctz/ya.make b/contrib/libs/cctz/ya.make new file mode 100644 index 00000000000..f3866287b02 --- /dev/null +++ b/contrib/libs/cctz/ya.make @@ -0,0 +1,49 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2021-03-11) + +ORIGINAL_SOURCE(https://github.com/google/cctz/archive/583c52d1eaef159162790a1d4044940f5e0b201b.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/cctz/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (OS_DARWIN) + LDFLAGS( + -framework + CoreFoundation + ) +ENDIF() + +SRCS( + src/civil_time_detail.cc + src/time_zone_fixed.cc + src/time_zone_format.cc + src/time_zone_if.cc + src/time_zone_impl.cc + src/time_zone_info.cc + src/time_zone_libc.cc + src/time_zone_lookup.cc + src/time_zone_posix.cc + src/zone_info_source.cc +) + +END() + +RECURSE( + test + tzdata +) diff --git a/contrib/libs/clapack/list.inc b/contrib/libs/clapack/list.inc new file mode 100644 index 00000000000..a913c3917b1 --- /dev/null +++ b/contrib/libs/clapack/list.inc @@ -0,0 +1,8 @@ +CFLAGS( + -DNO_BLAS_WRAP +) + +PEERDIR( + ADDINCL contrib/libs/libf2c + ADDINCL contrib/libs/cblas +)
\ No newline at end of file diff --git a/contrib/libs/clapack/part1/ya.make b/contrib/libs/clapack/part1/ya.make new file mode 100644 index 00000000000..4fec16e472b --- /dev/null +++ b/contrib/libs/clapack/part1/ya.make @@ -0,0 +1,756 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +NO_UTIL() + +INCLUDE(../list.inc) + +SRCDIR(contrib/libs/clapack) + +SRCS( + cbdsqr.c + cgbbrd.c + cgbcon.c + cgbequ.c + cgbequb.c + cgbrfs.c + cgbsv.c + cgbsvx.c + cgbtf2.c + cgbtrf.c + cgbtrs.c + cgebak.c + cgebal.c + cgebd2.c + cgebrd.c + cgecon.c + cgeequ.c + cgeequb.c + cgees.c + cgeesx.c + cgeev.c + cgeevx.c + cgegs.c + cgegv.c + cgehd2.c + cgehrd.c + cgelq2.c + cgelqf.c + cgels.c + cgelsd.c + cgelss.c + cgelsx.c + cgelsy.c + cgeql2.c + cgeqlf.c + cgeqp3.c + cgeqpf.c + cgeqr2.c + cgeqrf.c + cgerfs.c + cgerq2.c + cgerqf.c + cgesc2.c + cgesdd.c + cgesv.c + cgesvd.c + cgesvx.c + cgetc2.c + cgetf2.c + cgetrf.c + cgetri.c + cgetrs.c + cggbak.c + cggbal.c + cgges.c + cggesx.c + cggev.c + cggevx.c + cggglm.c + cgghrd.c + cgglse.c + cggqrf.c + cggrqf.c + cggsvd.c + cggsvp.c + cgtcon.c + cgtrfs.c + cgtsv.c + cgtsvx.c + cgttrf.c + cgttrs.c + cgtts2.c + chbev.c + chbevd.c + chbevx.c + chbgst.c + chbgv.c + chbgvd.c + chbgvx.c + chbtrd.c + checon.c + cheequb.c + cheev.c + cheevd.c + cheevr.c + cheevx.c + chegs2.c + chegst.c + chegv.c + chegvd.c + chegvx.c + cherfs.c + chesv.c + chesvx.c + chetd2.c + chetf2.c + chetrd.c + chetrf.c + chetri.c + chetrs.c + chfrk.c + chgeqz.c + chla_transtype.c + chpcon.c + chpev.c + chpevd.c + chpevx.c + chpgst.c + chpgv.c + chpgvd.c + chpgvx.c + chprfs.c + chpsv.c + chpsvx.c + chptrd.c + chptrf.c + chptri.c + chptrs.c + chsein.c + chseqr.c + clabrd.c + clacgv.c + clacn2.c + clacon.c + clacp2.c + clacpy.c + clacrm.c + clacrt.c + cladiv.c + claed0.c + claed7.c + claed8.c + claein.c + claesy.c + claev2.c + clag2z.c + clags2.c + clagtm.c + clahef.c + clahqr.c + clahr2.c + clahrd.c + claic1.c + clals0.c + clalsa.c + clalsd.c + clangb.c + clange.c + clangt.c + clanhb.c + clanhe.c + clanhf.c + clanhp.c + clanhs.c + clanht.c + clansb.c + clansp.c + clansy.c + clantb.c + clantp.c + clantr.c + clapll.c + clapmt.c + claqgb.c + claqge.c + claqhb.c + claqhe.c + claqhp.c + claqp2.c + claqps.c + claqr0.c + claqr1.c + claqr2.c + claqr3.c + claqr4.c + claqr5.c + claqsb.c + claqsp.c + claqsy.c + clar1v.c + clar2v.c + clarcm.c + clarf.c + clarfb.c + clarfg.c + clarfp.c + clarft.c + clarfx.c + clargv.c + clarnv.c + clarrv.c + clartg.c + clartv.c + clarz.c + clarzb.c + clarzt.c + clascl.c + claset.c + clasr.c + classq.c + claswp.c + clasyf.c + clatbs.c + clatdf.c + clatps.c + clatrd.c + clatrs.c + clatrz.c + clatzm.c + clauu2.c + clauum.c + cpbcon.c + cpbequ.c + cpbrfs.c + cpbstf.c + cpbsv.c + cpbsvx.c + cpbtf2.c + cpbtrf.c + cpbtrs.c + cpftrf.c + cpftri.c + cpftrs.c + cpocon.c + cpoequ.c + cpoequb.c + cporfs.c + cposv.c + cposvx.c + cpotf2.c + cpotrf.c + cpotri.c + cpotrs.c + cppcon.c + cppequ.c + cpprfs.c + cppsv.c + cppsvx.c + cpptrf.c + cpptri.c + cpptrs.c + cpstf2.c + cpstrf.c + cptcon.c + cpteqr.c + cptrfs.c + cptsv.c + cptsvx.c + cpttrf.c + cpttrs.c + cptts2.c + crot.c + cspcon.c + cspmv.c + cspr.c + csprfs.c + cspsv.c + cspsvx.c + csptrf.c + csptri.c + csptrs.c + csrscl.c + cstedc.c + cstegr.c + cstein.c + cstemr.c + csteqr.c + csycon.c + csyequb.c + csymv.c + csyr.c + csyrfs.c + csysv.c + csysvx.c + csytf2.c + csytrf.c + csytri.c + csytrs.c + ctbcon.c + ctbrfs.c + ctbtrs.c + ctfsm.c + ctftri.c + ctfttp.c + ctfttr.c + ctgevc.c + ctgex2.c + ctgexc.c + ctgsen.c + ctgsja.c + ctgsna.c + ctgsy2.c + ctgsyl.c + ctpcon.c + ctprfs.c + ctptri.c + ctptrs.c + ctpttf.c + ctpttr.c + ctrcon.c + ctrevc.c + ctrexc.c + ctrrfs.c + ctrsen.c + ctrsna.c + ctrsyl.c + ctrti2.c + ctrtri.c + ctrtrs.c + ctrttf.c + ctrttp.c + ctzrqf.c + ctzrzf.c + cung2l.c + cung2r.c + cungbr.c + cunghr.c + cungl2.c + cunglq.c + cungql.c + cungqr.c + cungr2.c + cungrq.c + cungtr.c + cunm2l.c + cunm2r.c + cunmbr.c + cunmhr.c + cunml2.c + cunmlq.c + cunmql.c + cunmqr.c + cunmr2.c + cunmr3.c + cunmrq.c + cunmrz.c + cunmtr.c + cupgtr.c + cupmtr.c + dbdsdc.c + dbdsqr.c + ddisna.c + dgbbrd.c + dgbcon.c + dgbequ.c + dgbequb.c + dgbrfs.c + dgbsv.c + dgbsvx.c + dgbtf2.c + dgbtrf.c + dgbtrs.c + dgebak.c + dgebal.c + dgebd2.c + dgebrd.c + dgecon.c + dgeequ.c + dgeequb.c + dgees.c + dgeesx.c + dgeev.c + dgeevx.c + dgegs.c + dgegv.c + dgehd2.c + dgehrd.c + dgejsv.c + dgelq2.c + dgelqf.c + dgels.c + dgelsd.c + dgelss.c + dgelsx.c + dgelsy.c + dgeql2.c + dgeqlf.c + dgeqp3.c + dgeqpf.c + dgeqr2.c + dgeqrf.c + dgerfs.c + dgerq2.c + dgerqf.c + dgesc2.c + dgesdd.c + dgesv.c + dgesvd.c + dgesvj.c + dgesvx.c + dgetc2.c + dgetf2.c + dgetrf.c + dgetri.c + dgetrs.c + dggbak.c + dggbal.c + dgges.c + dggesx.c + dggev.c + dggevx.c + dggglm.c + dgghrd.c + dgglse.c + dggqrf.c + dggrqf.c + dggsvd.c + dggsvp.c + dgsvj0.c + dgsvj1.c + dgtcon.c + dgtrfs.c + dgtsv.c + dgtsvx.c + dgttrf.c + dgttrs.c + dgtts2.c + dhgeqz.c + dhsein.c + dhseqr.c + disnan.c + dlabad.c + dlabrd.c + dlacn2.c + dlacon.c + dlacpy.c + dladiv.c + dlae2.c + dlaebz.c + dlaed0.c + dlaed1.c + dlaed2.c + dlaed3.c + dlaed4.c + dlaed5.c + dlaed6.c + dlaed7.c + dlaed8.c + dlaed9.c + dlaeda.c + dlaein.c + dlaev2.c + dlaexc.c + dlag2.c + dlag2s.c + dlags2.c + dlagtf.c + dlagtm.c + dlagts.c + dlagv2.c + dlahqr.c + dlahr2.c + dlahrd.c + dlaic1.c + dlaisnan.c + dlaln2.c + dlals0.c + dlalsa.c + dlalsd.c + dlamch.c + dlamrg.c + dlaneg.c + dlangb.c + dlange.c + dlangt.c + dlanhs.c + dlansb.c + dlansf.c + dlansp.c + dlanst.c + dlansy.c + dlantb.c + dlantp.c + dlantr.c + dlanv2.c + dlapll.c + dlapmt.c + dlapy2.c + dlapy3.c + dlaqgb.c + dlaqge.c + dlaqp2.c + dlaqps.c + dlaqr0.c + dlaqr1.c + dlaqr2.c + dlaqr3.c + dlaqr4.c + dlaqr5.c + dlaqsb.c + dlaqsp.c + dlaqsy.c + dlaqtr.c + dlar1v.c + dlar2v.c + dlarf.c + dlarfb.c + dlarfg.c + dlarfp.c + dlarft.c + dlarfx.c + dlargv.c + dlarnv.c + dlarra.c + dlarrb.c + dlarrc.c + dlarrd.c + dlarre.c + dlarrf.c + dlarrj.c + dlarrk.c + dlarrr.c + dlarrv.c + dlartg.c + dlartv.c + dlaruv.c + dlarz.c + dlarzb.c + dlarzt.c + dlas2.c + dlascl.c + dlasd0.c + dlasd1.c + dlasd2.c + dlasd3.c + dlasd4.c + dlasd5.c + dlasd6.c + dlasd7.c + dlasd8.c + dlasda.c + dlasdq.c + dlasdt.c + dlaset.c + dlasq1.c + dlasq2.c + dlasq3.c + dlasq4.c + dlasq5.c + dlasq6.c + dlasr.c + dlasrt.c + dlassq.c + dlasv2.c + dlaswp.c + dlasy2.c + dlasyf.c + dlat2s.c + dlatbs.c + dlatdf.c + dlatps.c + dlatrd.c + dlatrs.c + dlatrz.c + dlatzm.c + dlauu2.c + dlauum.c + dopgtr.c + dopmtr.c + dorg2l.c + dorg2r.c + dorgbr.c + dorghr.c + dorgl2.c + dorglq.c + dorgql.c + dorgqr.c + dorgr2.c + dorgrq.c + dorgtr.c + dorm2l.c + dorm2r.c + dormbr.c + dormhr.c + dorml2.c + dormlq.c + dormql.c + dormqr.c + dormr2.c + dormr3.c + dormrq.c + dormrz.c + dormtr.c + dpbcon.c + dpbequ.c + dpbrfs.c + dpbstf.c + dpbsv.c + dpbsvx.c + dpbtf2.c + dpbtrf.c + dpbtrs.c + dpftrf.c + dpftri.c + dpftrs.c + dpocon.c + dpoequ.c + dpoequb.c + dporfs.c + dposv.c + dposvx.c + dpotf2.c + dpotrf.c + dpotri.c + dpotrs.c + dppcon.c + dppequ.c + dpprfs.c + dppsv.c + dppsvx.c + dpptrf.c + dpptri.c + dpptrs.c + dpstf2.c + dpstrf.c + dptcon.c + dpteqr.c + dptrfs.c + dptsv.c + dptsvx.c + dpttrf.c + dpttrs.c + dptts2.c + drscl.c + dsbev.c + dsbevd.c + dsbevx.c + dsbgst.c + dsbgv.c + dsbgvd.c + dsbgvx.c + dsbtrd.c + #dsecnd.c + dsfrk.c + dsgesv.c + dspcon.c + dspev.c + dspevd.c + dspevx.c + dspgst.c + dspgv.c + dspgvd.c + dspgvx.c + dsposv.c + dsprfs.c + dspsv.c + dspsvx.c + dsptrd.c + dsptrf.c + dsptri.c + dsptrs.c + dstebz.c + dstedc.c + dstegr.c + dstein.c + dstemr.c + dsteqr.c + dsterf.c + dstev.c + dstevd.c + dstevr.c + dstevx.c + dsycon.c + dsyequb.c + dsyev.c + dsyevd.c + dsyevr.c + dsyevx.c + dsygs2.c + dsygst.c + dsygv.c + dsygvd.c + dsygvx.c + dsyrfs.c + dsysv.c + dsysvx.c + dsytd2.c + dsytf2.c + dsytrd.c + dsytrf.c + dsytri.c + dsytrs.c + dtbcon.c + dtbrfs.c + dtbtrs.c + dtfsm.c + dtftri.c + dtfttp.c + dtfttr.c + dtgevc.c + dtgex2.c + dtgexc.c + dtgsen.c + dtgsja.c + dtgsna.c + dtgsy2.c + dtgsyl.c + dtpcon.c + dtprfs.c + dtptri.c + dtptrs.c + dtpttf.c + dtpttr.c + dtrcon.c + dtrevc.c + dtrexc.c + dtrrfs.c + dtrsen.c + dtrsna.c + dtrsyl.c + dtrti2.c + dtrtri.c + dtrtrs.c + dtrttf.c + dtrttp.c + dtzrqf.c + dtzrzf.c + dzsum1.c + icmax1.c + ieeeck.c + ilaclc.c + ilaclr.c + iladiag.c + iladlc.c + iladlr.c + ilaenv.c + ilaprec.c + ilaslc.c + ilaslr.c + ilatrans.c + ilauplo.c + ilaver.c + ilazlc.c + ilazlr.c + iparmq.c + izmax1.c +) + +END() diff --git a/contrib/libs/clapack/part2/ya.make b/contrib/libs/clapack/part2/ya.make new file mode 100644 index 00000000000..6e0d6abaf72 --- /dev/null +++ b/contrib/libs/clapack/part2/ya.make @@ -0,0 +1,741 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +NO_UTIL() + +INCLUDE(../list.inc) + +SRCDIR(contrib/libs/clapack) + +SRCS( + # lsame.c defined in cblas. + lsamen.c + maxloc.c + sbdsdc.c + sbdsqr.c + scsum1.c + sdisna.c + sgbbrd.c + sgbcon.c + sgbequ.c + sgbequb.c + sgbrfs.c + sgbsv.c + sgbsvx.c + sgbtf2.c + sgbtrf.c + sgbtrs.c + sgebak.c + sgebal.c + sgebd2.c + sgebrd.c + sgecon.c + sgeequ.c + sgeequb.c + sgees.c + sgeesx.c + sgeev.c + sgeevx.c + sgegs.c + sgegv.c + sgehd2.c + sgehrd.c + sgejsv.c + sgelq2.c + sgelqf.c + sgels.c + sgelsd.c + sgelss.c + sgelsx.c + sgelsy.c + sgeql2.c + sgeqlf.c + sgeqp3.c + sgeqpf.c + sgeqr2.c + sgeqrf.c + sgerfs.c + sgerq2.c + sgerqf.c + sgesc2.c + sgesdd.c + sgesv.c + sgesvd.c + sgesvj.c + sgesvx.c + sgetc2.c + sgetf2.c + sgetrf.c + sgetri.c + sgetrs.c + sggbak.c + sggbal.c + sgges.c + sggesx.c + sggev.c + sggevx.c + sggglm.c + sgghrd.c + sgglse.c + sggqrf.c + sggrqf.c + sggsvd.c + sggsvp.c + sgsvj0.c + sgsvj1.c + sgtcon.c + sgtrfs.c + sgtsv.c + sgtsvx.c + sgttrf.c + sgttrs.c + sgtts2.c + shgeqz.c + shsein.c + shseqr.c + sisnan.c + slabad.c + slabrd.c + slacn2.c + slacon.c + slacpy.c + sladiv.c + slae2.c + slaebz.c + slaed0.c + slaed1.c + slaed2.c + slaed3.c + slaed4.c + slaed5.c + slaed6.c + slaed7.c + slaed8.c + slaed9.c + slaeda.c + slaein.c + slaev2.c + slaexc.c + slag2.c + slag2d.c + slags2.c + slagtf.c + slagtm.c + slagts.c + slagv2.c + slahqr.c + slahr2.c + slahrd.c + slaic1.c + slaisnan.c + slaln2.c + slals0.c + slalsa.c + slalsd.c + slamch.c + slamrg.c + slaneg.c + slangb.c + slange.c + slangt.c + slanhs.c + slansb.c + slansf.c + slansp.c + slanst.c + slansy.c + slantb.c + slantp.c + slantr.c + slanv2.c + slapll.c + slapmt.c + slapy2.c + slapy3.c + slaqgb.c + slaqge.c + slaqp2.c + slaqps.c + slaqr0.c + slaqr1.c + slaqr2.c + slaqr3.c + slaqr4.c + slaqr5.c + slaqsb.c + slaqsp.c + slaqsy.c + slaqtr.c + slar1v.c + slar2v.c + slarf.c + slarfb.c + slarfg.c + slarfp.c + slarft.c + slarfx.c + slargv.c + slarnv.c + slarra.c + slarrb.c + slarrc.c + slarrd.c + slarre.c + slarrf.c + slarrj.c + slarrk.c + slarrr.c + slarrv.c + slartg.c + slartv.c + slaruv.c + slarz.c + slarzb.c + slarzt.c + slas2.c + slascl.c + slasd0.c + slasd1.c + slasd2.c + slasd3.c + slasd4.c + slasd5.c + slasd6.c + slasd7.c + slasd8.c + slasda.c + slasdq.c + slasdt.c + slaset.c + slasq1.c + slasq2.c + slasq3.c + slasq4.c + slasq5.c + slasq6.c + slasr.c + slasrt.c + slassq.c + slasv2.c + slaswp.c + slasy2.c + slasyf.c + slatbs.c + slatdf.c + slatps.c + slatrd.c + slatrs.c + slatrz.c + slatzm.c + slauu2.c + slauum.c + sopgtr.c + sopmtr.c + sorg2l.c + sorg2r.c + sorgbr.c + sorghr.c + sorgl2.c + sorglq.c + sorgql.c + sorgqr.c + sorgr2.c + sorgrq.c + sorgtr.c + sorm2l.c + sorm2r.c + sormbr.c + sormhr.c + sorml2.c + sormlq.c + sormql.c + sormqr.c + sormr2.c + sormr3.c + sormrq.c + sormrz.c + sormtr.c + spbcon.c + spbequ.c + spbrfs.c + spbstf.c + spbsv.c + spbsvx.c + spbtf2.c + spbtrf.c + spbtrs.c + spftrf.c + spftri.c + spftrs.c + spocon.c + spoequ.c + spoequb.c + sporfs.c + sposv.c + sposvx.c + spotf2.c + spotrf.c + spotri.c + spotrs.c + sppcon.c + sppequ.c + spprfs.c + sppsv.c + sppsvx.c + spptrf.c + spptri.c + spptrs.c + spstf2.c + spstrf.c + sptcon.c + spteqr.c + sptrfs.c + sptsv.c + sptsvx.c + spttrf.c + spttrs.c + sptts2.c + srscl.c + ssbev.c + ssbevd.c + ssbevx.c + ssbgst.c + ssbgv.c + ssbgvd.c + ssbgvx.c + ssbtrd.c + ssfrk.c + sspcon.c + sspev.c + sspevd.c + sspevx.c + sspgst.c + sspgv.c + sspgvd.c + sspgvx.c + ssprfs.c + sspsv.c + sspsvx.c + ssptrd.c + ssptrf.c + ssptri.c + ssptrs.c + sstebz.c + sstedc.c + sstegr.c + sstein.c + sstemr.c + ssteqr.c + ssterf.c + sstev.c + sstevd.c + sstevr.c + sstevx.c + ssycon.c + ssyequb.c + ssyev.c + ssyevd.c + ssyevr.c + ssyevx.c + ssygs2.c + ssygst.c + ssygv.c + ssygvd.c + ssygvx.c + ssyrfs.c + ssysv.c + ssysvx.c + ssytd2.c + ssytf2.c + ssytrd.c + ssytrf.c + ssytri.c + ssytrs.c + stbcon.c + stbrfs.c + stbtrs.c + stfsm.c + stftri.c + stfttp.c + stfttr.c + stgevc.c + stgex2.c + stgexc.c + stgsen.c + stgsja.c + stgsna.c + stgsy2.c + stgsyl.c + stpcon.c + stprfs.c + stptri.c + stptrs.c + stpttf.c + stpttr.c + strcon.c + strevc.c + strexc.c + strrfs.c + strsen.c + strsna.c + strsyl.c + strti2.c + strtri.c + strtrs.c + strttf.c + strttp.c + stzrqf.c + stzrzf.c + # xerbla.c defined in cblas. + # xerbla_array.c defined in cblas. + zbdsqr.c + zcgesv.c + zcposv.c + zdrscl.c + zgbbrd.c + zgbcon.c + zgbequ.c + zgbequb.c + zgbrfs.c + zgbsv.c + zgbsvx.c + zgbtf2.c + zgbtrf.c + zgbtrs.c + zgebak.c + zgebal.c + zgebd2.c + zgebrd.c + zgecon.c + zgeequ.c + zgeequb.c + zgees.c + zgeesx.c + zgeev.c + zgeevx.c + zgegs.c + zgegv.c + zgehd2.c + zgehrd.c + zgelq2.c + zgelqf.c + zgels.c + zgelsd.c + zgelss.c + zgelsx.c + zgelsy.c + zgeql2.c + zgeqlf.c + zgeqp3.c + zgeqpf.c + zgeqr2.c + zgeqrf.c + zgerfs.c + zgerq2.c + zgerqf.c + zgesc2.c + zgesdd.c + zgesv.c + zgesvd.c + zgesvx.c + zgetc2.c + zgetf2.c + zgetrf.c + zgetri.c + zgetrs.c + zggbak.c + zggbal.c + zgges.c + zggesx.c + zggev.c + zggevx.c + zggglm.c + zgghrd.c + zgglse.c + zggqrf.c + zggrqf.c + zggsvd.c + zggsvp.c + zgtcon.c + zgtrfs.c + zgtsv.c + zgtsvx.c + zgttrf.c + zgttrs.c + zgtts2.c + zhbev.c + zhbevd.c + zhbevx.c + zhbgst.c + zhbgv.c + zhbgvd.c + zhbgvx.c + zhbtrd.c + zhecon.c + zheequb.c + zheev.c + zheevd.c + zheevr.c + zheevx.c + zhegs2.c + zhegst.c + zhegv.c + zhegvd.c + zhegvx.c + zherfs.c + zhesv.c + zhesvx.c + zhetd2.c + zhetf2.c + zhetrd.c + zhetrf.c + zhetri.c + zhetrs.c + zhfrk.c + zhgeqz.c + zhpcon.c + zhpev.c + zhpevd.c + zhpevx.c + zhpgst.c + zhpgv.c + zhpgvd.c + zhpgvx.c + zhprfs.c + zhpsv.c + zhpsvx.c + zhptrd.c + zhptrf.c + zhptri.c + zhptrs.c + zhsein.c + zhseqr.c + zlabrd.c + zlacgv.c + zlacn2.c + zlacon.c + zlacp2.c + zlacpy.c + zlacrm.c + zlacrt.c + zladiv.c + zlaed0.c + zlaed7.c + zlaed8.c + zlaein.c + zlaesy.c + zlaev2.c + zlag2c.c + zlags2.c + zlagtm.c + zlahef.c + zlahqr.c + zlahr2.c + zlahrd.c + zlaic1.c + zlals0.c + zlalsa.c + zlalsd.c + zlangb.c + zlange.c + zlangt.c + zlanhb.c + zlanhe.c + zlanhf.c + zlanhp.c + zlanhs.c + zlanht.c + zlansb.c + zlansp.c + zlansy.c + zlantb.c + zlantp.c + zlantr.c + zlapll.c + zlapmt.c + zlaqgb.c + zlaqge.c + zlaqhb.c + zlaqhe.c + zlaqhp.c + zlaqp2.c + zlaqps.c + zlaqr0.c + zlaqr1.c + zlaqr2.c + zlaqr3.c + zlaqr4.c + zlaqr5.c + zlaqsb.c + zlaqsp.c + zlaqsy.c + zlar1v.c + zlar2v.c + zlarcm.c + zlarf.c + zlarfb.c + zlarfg.c + zlarfp.c + zlarft.c + zlarfx.c + zlargv.c + zlarnv.c + zlarrv.c + zlartg.c + zlartv.c + zlarz.c + zlarzb.c + zlarzt.c + zlascl.c + zlaset.c + zlasr.c + zlassq.c + zlaswp.c + zlasyf.c + zlat2c.c + zlatbs.c + zlatdf.c + zlatps.c + zlatrd.c + zlatrs.c + zlatrz.c + zlatzm.c + zlauu2.c + zlauum.c + zpbcon.c + zpbequ.c + zpbrfs.c + zpbstf.c + zpbsv.c + zpbsvx.c + zpbtf2.c + zpbtrf.c + zpbtrs.c + zpftrf.c + zpftri.c + zpftrs.c + zpocon.c + zpoequ.c + zpoequb.c + zporfs.c + zposv.c + zposvx.c + zpotf2.c + zpotrf.c + zpotri.c + zpotrs.c + zppcon.c + zppequ.c + zpprfs.c + zppsv.c + zppsvx.c + zpptrf.c + zpptri.c + zpptrs.c + zpstf2.c + zpstrf.c + zptcon.c + zpteqr.c + zptrfs.c + zptsv.c + zptsvx.c + zpttrf.c + zpttrs.c + zptts2.c + zrot.c + zspcon.c + zspmv.c + zspr.c + zsprfs.c + zspsv.c + zspsvx.c + zsptrf.c + zsptri.c + zsptrs.c + zstedc.c + zstegr.c + zstein.c + zstemr.c + zsteqr.c + zsycon.c + zsyequb.c + zsymv.c + zsyr.c + zsyrfs.c + zsysv.c + zsysvx.c + zsytf2.c + zsytrf.c + zsytri.c + zsytrs.c + ztbcon.c + ztbrfs.c + ztbtrs.c + ztfsm.c + ztftri.c + ztfttp.c + ztfttr.c + ztgevc.c + ztgex2.c + ztgexc.c + ztgsen.c + ztgsja.c + ztgsna.c + ztgsy2.c + ztgsyl.c + ztpcon.c + ztprfs.c + ztptri.c + ztptrs.c + ztpttf.c + ztpttr.c + ztrcon.c + ztrevc.c + ztrexc.c + ztrrfs.c + ztrsen.c + ztrsna.c + ztrsyl.c + ztrti2.c + ztrtri.c + ztrtrs.c + ztrttf.c + ztrttp.c + ztzrqf.c + ztzrzf.c + zung2l.c + zung2r.c + zungbr.c + zunghr.c + zungl2.c + zunglq.c + zungql.c + zungqr.c + zungr2.c + zungrq.c + zungtr.c + zunm2l.c + zunm2r.c + zunmbr.c + zunmhr.c + zunml2.c + zunmlq.c + zunmql.c + zunmqr.c + zunmr2.c + zunmr3.c + zunmrq.c + zunmrz.c + zunmtr.c + zupgtr.c + zupmtr.c +) + +END() diff --git a/contrib/libs/clapack/ya.make b/contrib/libs/clapack/ya.make new file mode 100644 index 00000000000..0e9e93044ff --- /dev/null +++ b/contrib/libs/clapack/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(3.2.1) + +NO_JOIN_SRC() + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +NO_RUNTIME() + +IF (HAVE_MKL) + PEERDIR( + contrib/libs/intel/mkl + ) +ELSE() + PEERDIR( + contrib/libs/clapack/part1 + contrib/libs/clapack/part2 + ) +ENDIF() + +END() diff --git a/contrib/libs/crcutil/ya.make b/contrib/libs/crcutil/ya.make new file mode 100644 index 00000000000..6d40ef7a93e --- /dev/null +++ b/contrib/libs/crcutil/ya.make @@ -0,0 +1,65 @@ +LIBRARY() + +LICENSE(Apache-2.0) + +VERSION(1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +NO_JOIN_SRC() + +IF (GCC AND USE_LTO) + CFLAGS(-DCRCUTIL_FORCE_ASM_CRC32C=1) +ENDIF() + +IF (ARCH_I386 OR ARCH_X86_64) + IF (OS_WINDOWS) + SRCS( + multiword_64_64_cl_i386_mmx.cc + ) + ELSEIF (OS_ANDROID AND ARCH_I386) + # 32-bit Android has some problems with register allocation, so we fall back to default implementation + ELSE() + IF (CLANG) + CFLAGS(-DCRCUTIL_USE_MM_CRC32=1) + IF (ARCH_I386) + # clang doesn't support this as optimization attribute and has problems with register allocation + SRC( + multiword_64_64_gcc_i386_mmx.cc + -fomit-frame-pointer + ) + ELSE() + SRCS( + multiword_64_64_gcc_i386_mmx.cc + ) + ENDIF() + ELSE() + CFLAGS( + -mcrc32 + -DCRCUTIL_USE_MM_CRC32=1 + ) + ENDIF() + SRCS( + multiword_128_64_gcc_amd64_sse2.cc + multiword_64_64_gcc_amd64_asm.cc + ) + ENDIF() + IF (OS_WINDOWS) + SRCS( + crc32c_sse4.cc + ) + ELSE() + SRC_C_SSE4(crc32c_sse4.cc) + ENDIF() +ENDIF() + +SRCS( + interface.cc + multiword_64_64_intrinsic_i386_mmx.cc +) + +END() diff --git a/contrib/libs/curl/bin/ya.make b/contrib/libs/curl/bin/ya.make new file mode 100644 index 00000000000..70a3338d198 --- /dev/null +++ b/contrib/libs/curl/bin/ya.make @@ -0,0 +1,79 @@ +# Generated by devtools/yamaker. + +PROGRAM(curl) + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/c-ares + contrib/libs/curl +) + +ADDINCL( + contrib/libs/curl/include + contrib/libs/curl/lib + contrib/libs/curl/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DARCADIA_CURL_DNS_RESOLVER_ARES +) + +SRCDIR(contrib/libs/curl) + +SRCS( + lib/curl_multibyte.c + lib/dynbuf.c + lib/nonblock.c + lib/strtoofft.c + lib/timediff.c + lib/version_win32.c + lib/warnless.c + src/slist_wc.c + src/tool_binmode.c + src/tool_bname.c + src/tool_cb_dbg.c + src/tool_cb_hdr.c + src/tool_cb_prg.c + src/tool_cb_rea.c + src/tool_cb_see.c + src/tool_cb_wrt.c + src/tool_cfgable.c + src/tool_dirhie.c + src/tool_doswin.c + src/tool_easysrc.c + src/tool_filetime.c + src/tool_findfile.c + src/tool_formparse.c + src/tool_getparam.c + src/tool_getpass.c + src/tool_help.c + src/tool_helpers.c + src/tool_hugehelp.c + src/tool_libinfo.c + src/tool_listhelp.c + src/tool_main.c + src/tool_msgs.c + src/tool_operate.c + src/tool_operhlp.c + src/tool_panykey.c + src/tool_paramhlp.c + src/tool_parsecfg.c + src/tool_progress.c + src/tool_setopt.c + src/tool_sleep.c + src/tool_strdup.c + src/tool_urlglob.c + src/tool_util.c + src/tool_vms.c + src/tool_writeout.c + src/tool_writeout_json.c + src/tool_xattr.c +) + +END() diff --git a/contrib/libs/curl/ya.make b/contrib/libs/curl/ya.make new file mode 100644 index 00000000000..d9bc485f140 --- /dev/null +++ b/contrib/libs/curl/ya.make @@ -0,0 +1,220 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + ISC AND + Public-Domain AND + curl +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(7.86.0) + +ORIGINAL_SOURCE(https://github.com/curl/curl/releases/download/curl-7_86_0/curl-7.86.0.tar.bz2) + +PEERDIR( + contrib/libs/libc_compat + contrib/libs/openssl + contrib/libs/zlib +) + +ADDINCL( + GLOBAL contrib/libs/curl/include + contrib/libs/c-ares/include + contrib/libs/curl/lib +) + +IF (NOT OS_WINDOWS) + PEERDIR( + contrib/libs/nghttp2 + ) +ENDIF() + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +DEFAULT(ARCADIA_CURL_DNS_RESOLVER ARES) + +CFLAGS( + GLOBAL -DCURL_STATICLIB + -DBUILDING_LIBCURL + -DHAVE_CONFIG_H + -DARCADIA_CURL_DNS_RESOLVER_${ARCADIA_CURL_DNS_RESOLVER} +) + +IF (ARCADIA_CURL_DNS_RESOLVER == ARES) + PEERDIR( + contrib/libs/c-ares + ) +ENDIF() + +IF (OS_DARWIN) + LDFLAGS( + -framework + SystemConfiguration + ) +ENDIF() + +SRCS( + lib/altsvc.c + lib/amigaos.c + lib/asyn-ares.c + lib/asyn-thread.c + lib/base64.c + lib/bufref.c + lib/c-hyper.c + lib/conncache.c + lib/connect.c + lib/content_encoding.c + lib/cookie.c + lib/curl_addrinfo.c + lib/curl_des.c + lib/curl_endian.c + lib/curl_fnmatch.c + lib/curl_get_line.c + lib/curl_gethostname.c + lib/curl_gssapi.c + lib/curl_memrchr.c + lib/curl_multibyte.c + lib/curl_ntlm_core.c + lib/curl_ntlm_wb.c + lib/curl_path.c + lib/curl_range.c + lib/curl_rtmp.c + lib/curl_sasl.c + lib/curl_sspi.c + lib/curl_threads.c + lib/dict.c + lib/doh.c + lib/dynbuf.c + lib/easy.c + lib/easygetopt.c + lib/easyoptions.c + lib/escape.c + lib/file.c + lib/fileinfo.c + lib/fopen.c + lib/formdata.c + lib/ftp.c + lib/ftplistparser.c + lib/getenv.c + lib/getinfo.c + lib/gopher.c + lib/h2h3.c + lib/hash.c + lib/headers.c + lib/hmac.c + lib/hostasyn.c + lib/hostip.c + lib/hostip4.c + lib/hostip6.c + lib/hostsyn.c + lib/hsts.c + lib/http.c + lib/http2.c + lib/http_aws_sigv4.c + lib/http_chunks.c + lib/http_digest.c + lib/http_negotiate.c + lib/http_ntlm.c + lib/http_proxy.c + lib/idn_win32.c + lib/if2ip.c + lib/imap.c + lib/inet_ntop.c + lib/inet_pton.c + lib/krb5.c + lib/ldap.c + lib/llist.c + lib/md4.c + lib/md5.c + lib/memdebug.c + lib/mime.c + lib/mprintf.c + lib/mqtt.c + lib/multi.c + lib/netrc.c + lib/nonblock.c + lib/noproxy.c + lib/openldap.c + lib/parsedate.c + lib/pingpong.c + lib/pop3.c + lib/progress.c + lib/psl.c + lib/rand.c + lib/rename.c + lib/rtsp.c + lib/select.c + lib/sendf.c + lib/setopt.c + lib/sha256.c + lib/share.c + lib/slist.c + lib/smb.c + lib/smtp.c + lib/socketpair.c + lib/socks.c + lib/socks_gssapi.c + lib/socks_sspi.c + lib/speedcheck.c + lib/splay.c + lib/strcase.c + lib/strdup.c + lib/strerror.c + lib/strtok.c + lib/strtoofft.c + lib/system_win32.c + lib/telnet.c + lib/tftp.c + lib/timediff.c + lib/timeval.c + lib/transfer.c + lib/url.c + lib/urlapi.c + lib/vauth/cleartext.c + lib/vauth/cram.c + lib/vauth/digest.c + lib/vauth/digest_sspi.c + lib/vauth/gsasl.c + lib/vauth/krb5_gssapi.c + lib/vauth/krb5_sspi.c + lib/vauth/ntlm.c + lib/vauth/ntlm_sspi.c + lib/vauth/oauth2.c + lib/vauth/spnego_gssapi.c + lib/vauth/spnego_sspi.c + lib/vauth/vauth.c + lib/version.c + lib/version_win32.c + lib/vquic/msh3.c + lib/vquic/ngtcp2.c + lib/vquic/quiche.c + lib/vquic/vquic.c + lib/vssh/libssh.c + lib/vssh/libssh2.c + lib/vssh/wolfssh.c + lib/vtls/bearssl.c + lib/vtls/hostcheck.c + lib/vtls/keylog.c + lib/vtls/mbedtls_threadlock.c + lib/vtls/openssl.c + lib/vtls/rustls.c + lib/vtls/sectransp.c + lib/vtls/vtls.c + lib/vtls/wolfssl.c + lib/vtls/x509asn1.c + lib/warnless.c + lib/wildcard.c + lib/ws.c +) + +END() + +RECURSE( + bin +) diff --git a/contrib/libs/cxxsupp/builtins/ya.make b/contrib/libs/cxxsupp/builtins/ya.make new file mode 100644 index 00000000000..85ba69953ec --- /dev/null +++ b/contrib/libs/cxxsupp/builtins/ya.make @@ -0,0 +1,122 @@ +LIBRARY() + +# Part of compiler-rt LLVM subproject + +# git repository: https://github.com/llvm/llvm-project.git +# directory: compiler-rt/lib/builtins +# revision: 08f0372c351a57b01afee6c64066961203da28c5 + +# os_version_check.c was taken from revision 81b89fd7bdddb7da66f2cdace97d6ede5f99d58a +# os_version_check.c was patched from git repository https://github.com/apple/llvm-project.git revision a02454b91d2aec347b9ce03020656c445f3b2841 + +LICENSE( + Apache-2.0 AND + Apache-2.0 WITH LLVM-exception AND + MIT AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2016-03-03-08f0372c351a57b01afee6c64066961203da28c5) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project) + +# Check MUSL before NO_PLATFORM() disables it. +IF (MUSL) + # We use C headers despite NO_PLATFORM, but we do not propagate + # them with ADDINCL GLOBAL because we do not have an API, and we + # can not propagate them because libcxx has to put its own + # includes before musl includes for its include_next to work. + ADDINCL( + contrib/libs/musl/arch/x86_64 + contrib/libs/musl/arch/generic + contrib/libs/musl/include + contrib/libs/musl/extra + ) +ENDIF() + +NO_UTIL() + +NO_RUNTIME() + +NO_PLATFORM() + +NO_COMPILER_WARNINGS() + +NO_SANITIZE_HEADERS() + +IF (GCC OR CLANG) + # Clang (maybe GCC too) LTO code generator leaves the builtin calls unresolved + # even if they are available. After the code generation pass is done + # a linker is forced to select original object files from this library again + # as they contain unresolved symbols. But code generation is already done, + # object files actually are not ELFs but an LLVM bytecode and we get + # "member at xxxxx is not an ELF object" errors from the linker. + # Just generate native code from the beginning. + DISABLE(USE_LTO) +ENDIF() + +SRCS( + addtf3.c + ashlti3.c + clzti2.c + comparetf2.c + divdc3.c + divsc3.c + divtf3.c + divti3.c + divxc3.c + extenddftf2.c + extendsftf2.c + fixdfti.c + fixsfti.c + fixtfdi.c + fixtfsi.c + fixunsdfti.c + fixunssfti.c + fixunstfdi.c + fixunstfsi.c + fixunstfti.c + fixunsxfti.c + floatditf.c + floatsitf.c + floattidf.c + floattisf.c + floattixf.c + floatunditf.c + floatunsitf.c + floatuntidf.c + floatuntisf.c + gcc_personality_v0.c + int_util.c + lshrti3.c + modti3.c + muldc3.c + muloti4.c + mulsc3.c + multf3.c + mulxc3.c + popcountdi2.c + subtf3.c + trunctfdf2.c + trunctfsf2.c + udivmodti4.c + udivti3.c + umodti3.c +) + +IF (OS_DARWIN OR OS_IOS) + SRCS( + os_version_check.c + ) +ENDIF() + +IF (ARCH_ARM) + SRCS( + clear_cache.c + multc3.c + ) +ENDIF() + +END() diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make new file mode 100644 index 00000000000..74502cedc43 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/ya.make @@ -0,0 +1,258 @@ +LIBRARY() + +LICENSE( + Apache-2.0 AND + Apache-2.0 WITH LLVM-exception AND + BSD-2-Clause AND + MIT AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2022-02-20) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/34313583331e5c8cb0d3df28efb6c34c428fd235.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/cxxsupp/libcxx/include + contrib/libs/cxxsupp/libcxx/src +) + +NO_SANITIZE_HEADERS() + +CXXFLAGS(-D_LIBCPP_BUILDING_LIBRARY) + +IF (OS_ANDROID) + DEFAULT(CXX_RT "default") + IF (ARCH_I686 OR ARCH_ARM7) + # 32-bit architectures require additional libandroid_support.so to be linked + # We add --start-group / --end-group statements due to the issue in NDK < r22. + # See: https://github.com/android/ndk/issues/1130 + # + # Though these statements are not respected by LLD, they might have sense for other linkers. + LDFLAGS( + -Wl,--start-group + -lc++abi + -landroid_support + -Wl,--end-group + ) + ELSE() + LDFLAGS(-lc++abi) + ENDIF() + CFLAGS( + -DLIBCXX_BUILDING_LIBCXXABI + ) +ELSEIF (OS_IOS) + # Take cxxabi implementation from system. + LDFLAGS(-lc++abi) + CFLAGS( + -DLIBCXX_BUILDING_LIBCXXABI + ) + # Yet take builtins library from Arcadia + PEERDIR( + contrib/libs/cxxsupp/builtins + ) +ELSEIF (OS_LINUX OR OS_DARWIN) + IF (ARCH_ARM7) + # XXX: libcxxrt support for ARM is currently broken + DEFAULT(CXX_RT "glibcxx_static") + # ARM7 OS_SDK has old libstdc++ without aligned allocation support + CFLAGS( + GLOBAL -fno-aligned-new + ) + ELSE() + DEFAULT(CXX_RT "libcxxrt") + ENDIF() + IF (MUSL) + PEERDIR( + contrib/libs/musl/include + ) + ENDIF() +ELSEIF (OS_WINDOWS) + SRCS( + src/support/win32/locale_win32.cpp + src/support/win32/support.cpp + src/support/win32/atomic_win32.cpp + src/support/win32/new_win32.cpp + src/support/win32/thread_win32.cpp + ) + CFLAGS( + GLOBAL -D_LIBCPP_VASPRINTF_DEFINED + GLOBAL -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_ + ) + IF (CLANG_CL) + PEERDIR( + contrib/libs/cxxsupp/builtins + ) + ENDIF() +ELSE() + DEFAULT(CXX_RT "glibcxx_static") + CXXFLAGS( + -Wno-unknown-pragmas + -nostdinc++ + ) +ENDIF() + +IF (OS_LINUX) + EXTRALIBS(-lpthread) +ENDIF() + +IF (CLANG) + CFLAGS( + GLOBAL -nostdinc++ + ) +ENDIF() + +# The CXX_RT variable controls which C++ runtime is used. +# * libcxxrt - https://github.com/libcxxrt/libcxxrt library stored in Arcadia +# * glibcxx_static - GNU C++ Library runtime with static linkage +# * glibcxx_dynamic - GNU C++ Library runtime with dynamic linkage +# * default - default C++ runtime provided by the compiler driver +# +# All glibcxx* runtimes are taken from system/compiler SDK + +DEFAULT(CXX_RT "default") + +DISABLE(NEED_GLIBCXX_CXX17_SHIMS) +DISABLE(NEED_CXX_RT_ADDINCL) + +IF (CXX_RT == "libcxxrt") + PEERDIR( + contrib/libs/cxxsupp/libcxxabi-parts + contrib/libs/cxxsupp/libcxxrt + contrib/libs/cxxsupp/builtins + ) + ADDINCL( + GLOBAL contrib/libs/cxxsupp/libcxxrt/include + ) + CFLAGS( + GLOBAL -DLIBCXX_BUILDING_LIBCXXRT + ) + # These builtins are equivalent to clang -rtlib=compiler_rt and + # are needed by potentially any code generated by clang. + # With glibcxx runtime, builtins are provided by libgcc +ELSEIF (CXX_RT == "glibcxx_static") + LDFLAGS( + -Wl,-Bstatic + -lsupc++ + -lgcc + -lgcc_eh + -Wl,-Bdynamic + ) + CXXFLAGS(-D__GLIBCXX__=1) + ENABLE(NEED_GLIBCXX_CXX17_SHIMS) + ENABLE(NEED_CXX_RT_ADDINCL) + CFLAGS( + GLOBAL -DLIBCXX_BUILDING_LIBGCC + ) +ELSEIF (CXX_RT == "glibcxx_dynamic") + LDFLAGS( + -lgcc_s + -lstdc++ + ) + CXXFLAGS(-D__GLIBCXX__=1) + CFLAGS( + GLOBAL -DLIBCXX_BUILDING_LIBGCC + ) + ENABLE(NEED_GLIBCXX_CXX17_SHIMS) + ENABLE(NEED_CXX_RT_ADDINCL) +ELSEIF (CXX_RT == "default") + # Do nothing +ELSE() + MESSAGE(FATAL_ERROR "Unexpected CXX_RT value: ${CXX_RT}") +ENDIF() + +IF (NEED_GLIBCXX_CXX17_SHIMS) + IF (GCC) + # Assume GCC is bundled with a modern enough version of C++ runtime + ELSEIF (OS_SDK == "ubuntu-12" OR OS_SDK == "ubuntu-14" OR OS_SDK == "ubuntu-16") + # Prior to ubuntu-18, system C++ runtime for C++17 is incomplete + # and requires std::uncaught_exceptions() to be implemented. + SRCS( + glibcxx_eh_cxx17.cpp + ) + ENDIF() +ENDIF() + +IF (NEED_CXX_RT_ADDINCL) + # FIXME: + # This looks extremely weird and we have to use cxxabi.h from libsupc++ instead. + # This ADDINCL is placed here just to fix the status quo + ADDINCL( + GLOBAL contrib/libs/cxxsupp/libcxxrt/include + ) +ENDIF() + +NO_UTIL() + +NO_RUNTIME() + +NO_COMPILER_WARNINGS() + +IF (FUZZING) + NO_SANITIZE() + NO_SANITIZE_COVERAGE() +ENDIF() + +SRCS( + src/algorithm.cpp + src/any.cpp + src/assert.cpp + src/atomic.cpp + src/barrier.cpp + src/bind.cpp + src/charconv.cpp + src/chrono.cpp + src/condition_variable.cpp + src/condition_variable_destructor.cpp + src/debug.cpp + src/exception.cpp + src/filesystem/directory_iterator.cpp + src/filesystem/operations.cpp + src/functional.cpp + src/future.cpp + src/hash.cpp + src/ios.cpp + src/ios.instantiations.cpp + src/iostream.cpp + src/legacy_pointer_safety.cpp + src/locale.cpp + src/memory.cpp + src/mutex.cpp + src/mutex_destructor.cpp + src/optional.cpp + src/random.cpp + src/random_shuffle.cpp + src/regex.cpp + src/ryu/d2fixed.cpp + src/ryu/d2s.cpp + src/ryu/f2s.cpp + src/shared_mutex.cpp + src/stdexcept.cpp + src/string.cpp + src/strstream.cpp + src/system_error.cpp + src/thread.cpp + src/typeinfo.cpp + src/utility.cpp + src/valarray.cpp + src/variant.cpp + src/vector.cpp +) + +IF (NOT GCC) + # compiling src/format.cpp requires -std=c++20, + # yet our GCC version it too auld for this. + SRCS( + src/format.cpp + ) +ENDIF() + +IF (NOT OS_WINDOWS) + SRCS( + src/new.cpp + ) +ENDIF() + +END() diff --git a/contrib/libs/cxxsupp/libcxxabi-parts/ya.make b/contrib/libs/cxxsupp/libcxxabi-parts/ya.make new file mode 100644 index 00000000000..cd56d653957 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxabi-parts/ya.make @@ -0,0 +1,48 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE( + Apache-2.0 + WITH + LLVM-exception +) + +VERSION(14.0.6) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/llvmorg-14.0.6.tar.gz) + +ADDINCL( + contrib/libs/cxxsupp/libcxxabi/include + contrib/libs/cxxsupp/libcxx/include + contrib/libs/cxxsupp/libcxx +) + +NO_COMPILER_WARNINGS() + +NO_SANITIZE_HEADERS() + +NO_RUNTIME() + +NO_UTIL() + +CFLAGS(-D_LIBCXXABI_BUILDING_LIBRARY) + +IF (EXPORT_CMAKE) + # TODO(YMAKE-91) keep flags required for libc++ vendoring in a separate core.conf variable + CXXFLAGS(GLOBAL -nostdinc++) +ENDIF() + +SRCDIR(contrib/libs/cxxsupp/libcxxabi) + +SRCS( + src/abort_message.cpp + src/cxa_demangle.cpp +) + +SRC_C_PIC( + src/cxa_thread_atexit.cpp + -fno-lto +) + +END() diff --git a/contrib/libs/cxxsupp/libcxxabi/ya.make b/contrib/libs/cxxsupp/libcxxabi/ya.make new file mode 100644 index 00000000000..d71d5b8ec25 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxabi/ya.make @@ -0,0 +1,59 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Apache-2.0 WITH LLVM-exception AND + MIT AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(14.0.6) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/llvmorg-14.0.6.tar.gz) + +ADDINCL( + contrib/libs/cxxsupp/libcxxabi/include + contrib/libs/cxxsupp/libcxx/include + contrib/libs/cxxsupp/libcxx/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +NO_UTIL() + +CFLAGS( + -D_LIBCXXABI_BUILDING_LIBRARY +) + +SRCS( + src/abort_message.cpp + src/cxa_aux_runtime.cpp + src/cxa_default_handlers.cpp + src/cxa_demangle.cpp + src/cxa_exception.cpp + src/cxa_exception_storage.cpp + src/cxa_guard.cpp + src/cxa_handlers.cpp + src/cxa_personality.cpp + src/cxa_vector.cpp + src/cxa_virtual.cpp + src/fallback_malloc.cpp + src/private_typeinfo.cpp + src/stdlib_exception.cpp + src/stdlib_new_delete.cpp + src/stdlib_stdexcept.cpp + src/stdlib_typeinfo.cpp +) + +SRC_C_PIC( + src/cxa_thread_atexit.cpp + -fno-lto +) + +END() diff --git a/contrib/libs/cxxsupp/libcxxrt/ya.make b/contrib/libs/cxxsupp/libcxxrt/ya.make new file mode 100644 index 00000000000..6e091b8ec9a --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/ya.make @@ -0,0 +1,53 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSD-2-Clause AND + BSD-2-Clause-Views AND + BSD-3-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2021-09-08) + +ORIGINAL_SOURCE(https://github.com/libcxxrt/libcxxrt/archive/14bf5d5526056ae1cc16f03b7b8e96108a1e38d0.tar.gz) + +ADDINCL( + contrib/libs/cxxsupp/libcxxrt +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CXXFLAGS(-nostdinc++) + +IF (CXX_UNWIND == "glibcxx_dynamic" OR ARCH_PPC64LE) + LDFLAGS(-lgcc_s) +ELSE() + PEERDIR( + contrib/libs/libunwind + ) +ENDIF() + +NO_SANITIZE_HEADERS() + +IF (SANITIZER_TYPE == undefined OR FUZZING) + NO_SANITIZE() + NO_SANITIZE_COVERAGE() +ENDIF() + +SRCS( + auxhelper.cc + dynamic_cast.cc + exception.cc + guard.cc + memory.cc + stdexcept.cc + typeinfo.cc +) + +END() diff --git a/contrib/libs/cxxsupp/openmp/ya.make b/contrib/libs/cxxsupp/openmp/ya.make new file mode 100644 index 00000000000..897aa1bd85e --- /dev/null +++ b/contrib/libs/cxxsupp/openmp/ya.make @@ -0,0 +1,93 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Apache-2.0 WITH LLVM-exception AND + Intel-LLVM-SGA AND + MIT AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(15.0.7) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/llvmorg-15.0.7.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/cxxsupp/openmp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +NO_LTO() + +CFLAGS( + -fno-exceptions + -DKMP_USE_MONITOR=1 +) + +IF (SANITIZER_TYPE == thread) + NO_SANITIZE() + CFLAGS( + -fPIC + ) +ENDIF() + +IF (SANITIZER_TYPE == memory) + NO_SANITIZE() + CFLAGS( + -fPIC + ) +ENDIF() + +# The KMP_DEBUG define enables OpenMP debugging support, including tracing (controlled by environment variables) +# and debug asserts. The upstream version unconditionally enables KMP_DEBUG for Debug/RelWithDebInfo builds. +# Instead, we make this opt-in via a `ymake` variable to avoid accidentally releasing a relwithdebinfo binary +# with KMP_DEBUG enabled. Note that the `ymake` variable is called OPENMP_DEBUG for clarity, since no one +# really knows what KMP is. +IF (OPENMP_DEBUG) + CFLAGS( + -DKMP_DEBUG=1 + ) +ENDIF() + +SRCS( + kmp_affinity.cpp + kmp_alloc.cpp + kmp_atomic.cpp + kmp_barrier.cpp + kmp_cancel.cpp + kmp_csupport.cpp + kmp_debug.cpp + kmp_dispatch.cpp + kmp_environment.cpp + kmp_error.cpp + kmp_ftn_cdecl.cpp + kmp_ftn_extra.cpp + kmp_global.cpp + kmp_gsupport.cpp + kmp_i18n.cpp + kmp_io.cpp + kmp_itt.cpp + kmp_lock.cpp + kmp_runtime.cpp + kmp_sched.cpp + kmp_settings.cpp + kmp_str.cpp + kmp_taskdeps.cpp + kmp_tasking.cpp + kmp_threadprivate.cpp + kmp_utility.cpp + kmp_version.cpp + kmp_wait_release.cpp + ompt-general.cpp + z_Linux_asm.S + z_Linux_util.cpp +) + +END() diff --git a/contrib/libs/cxxsupp/ya.make b/contrib/libs/cxxsupp/ya.make new file mode 100644 index 00000000000..6cc84b71411 --- /dev/null +++ b/contrib/libs/cxxsupp/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +# Proxy library +LICENSE(Not-Applicable) + +NO_SANITIZE_HEADERS() + +NO_PLATFORM() + +IF (NOT USE_STL_SYSTEM) + PEERDIR( + contrib/libs/cxxsupp/libcxx + ) +ELSE() + PEERDIR( + contrib/libs/cxxsupp/system_stl + ) +ENDIF() + +END() + +RECURSE( + libcxx + libcxxabi + libcxxrt + openmp +) diff --git a/contrib/libs/double-conversion/ya.make b/contrib/libs/double-conversion/ya.make new file mode 100644 index 00000000000..848dabc59e5 --- /dev/null +++ b/contrib/libs/double-conversion/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(3.2.1) + +ORIGINAL_SOURCE(https://github.com/google/double-conversion/archive/v3.2.1.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/double-conversion +) + +NO_SANITIZE_HEADERS() + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + double-conversion/bignum-dtoa.cc + double-conversion/bignum.cc + double-conversion/cached-powers.cc + double-conversion/double-to-string.cc + double-conversion/fast-dtoa.cc + double-conversion/fixed-dtoa.cc + double-conversion/string-to-double.cc + double-conversion/strtod.cc +) + +END() diff --git a/contrib/libs/expat/ya.make b/contrib/libs/expat/ya.make new file mode 100644 index 00000000000..b1370c43fba --- /dev/null +++ b/contrib/libs/expat/ya.make @@ -0,0 +1,42 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +VERSION(2.5.0) + +ORIGINAL_SOURCE(https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.xz) + +LICENSE( + CC0-1.0 AND + JSON AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + contrib/libs/expat + contrib/libs/expat/lib +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H +) + +IF (OS_WINDOWS) + CFLAGS( + GLOBAL -DXML_STATIC + ) +ENDIF() + +SRCS( + lib/xmlparse.c + lib/xmlrole.c + lib/xmltok.c +) + +END() diff --git a/contrib/libs/farmhash/arch/sse41/ya.make b/contrib/libs/farmhash/arch/sse41/ya.make new file mode 100644 index 00000000000..9cd9d7e8a02 --- /dev/null +++ b/contrib/libs/farmhash/arch/sse41/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +NO_COMPILER_WARNINGS() + +IF (NOT MSVC OR CLANG_CL) + CFLAGS(-msse4.1) +ENDIF() + +SRCDIR(contrib/libs/farmhash) + +SRCS( + farmhashnt.cc +) + +END() diff --git a/contrib/libs/farmhash/arch/sse42/ya.make b/contrib/libs/farmhash/arch/sse42/ya.make new file mode 100644 index 00000000000..3791d345746 --- /dev/null +++ b/contrib/libs/farmhash/arch/sse42/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +NO_COMPILER_WARNINGS() + +IF (NOT MSVC OR CLANG_CL) + CFLAGS(-msse4.2) +ENDIF() + +SRCDIR(contrib/libs/farmhash) + +SRCS( + farmhashsa.cc + farmhashte.cc +) + +END() diff --git a/contrib/libs/farmhash/arch/sse42_aesni/ya.make b/contrib/libs/farmhash/arch/sse42_aesni/ya.make new file mode 100644 index 00000000000..3a578d5053e --- /dev/null +++ b/contrib/libs/farmhash/arch/sse42_aesni/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +NO_COMPILER_WARNINGS() + +IF (NOT MSVC OR CLANG_CL) + CFLAGS( + -msse4.2 + -maes + ) +ENDIF() + +SRCDIR(contrib/libs/farmhash) + +SRCS( + farmhashsu.cc +) + +END() diff --git a/contrib/libs/farmhash/ya.make b/contrib/libs/farmhash/ya.make new file mode 100644 index 00000000000..ce9dca655aa --- /dev/null +++ b/contrib/libs/farmhash/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2017-06-26-23eecfbe7e84ebf2e229bd02248f431c36e12f1a) + +ADDINCL(GLOBAL contrib/libs/farmhash/include) + +PEERDIR( + contrib/libs/farmhash/arch/sse41 + contrib/libs/farmhash/arch/sse42 + contrib/libs/farmhash/arch/sse42_aesni +) + +NO_COMPILER_WARNINGS() + +SRCS( + farmhashuo.cc + farmhashxo.cc + farmhashna.cc + farmhashmk.cc + farmhashcc.cc + farmhash_iface.cc +) + +END() diff --git a/contrib/libs/fastlz/ya.make b/contrib/libs/fastlz/ya.make new file mode 100644 index 00000000000..0b976e4b294 --- /dev/null +++ b/contrib/libs/fastlz/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.1.0) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +SRCS( + fastlz.c + rename.h +) + +END() diff --git a/contrib/libs/fmt/test/args-test/ya.make b/contrib/libs/fmt/test/args-test/ya.make new file mode 100644 index 00000000000..430ed1293a6 --- /dev/null +++ b/contrib/libs/fmt/test/args-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + args-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/assert-test/ya.make b/contrib/libs/fmt/test/assert-test/ya.make new file mode 100644 index 00000000000..7b8997a7e6e --- /dev/null +++ b/contrib/libs/fmt/test/assert-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + assert-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/chrono-test/ya.make b/contrib/libs/fmt/test/chrono-test/ya.make new file mode 100644 index 00000000000..c3f3bbd49e6 --- /dev/null +++ b/contrib/libs/fmt/test/chrono-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + chrono-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/color-test/ya.make b/contrib/libs/fmt/test/color-test/ya.make new file mode 100644 index 00000000000..d526cd77cb3 --- /dev/null +++ b/contrib/libs/fmt/test/color-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + color-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/compile-fp-test/ya.make b/contrib/libs/fmt/test/compile-fp-test/ya.make new file mode 100644 index 00000000000..35f77d31a5e --- /dev/null +++ b/contrib/libs/fmt/test/compile-fp-test/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +ADDINCL( + contrib/libs/fmt/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_HEADER_ONLY=1 + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt) + +SRCS( + src/os.cc + test/compile-fp-test.cc + test/gtest-extra.cc + test/util.cc +) + +END() diff --git a/contrib/libs/fmt/test/compile-test/ya.make b/contrib/libs/fmt/test/compile-test/ya.make new file mode 100644 index 00000000000..d75f41a9086 --- /dev/null +++ b/contrib/libs/fmt/test/compile-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + compile-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/core-test/ya.make b/contrib/libs/fmt/test/core-test/ya.make new file mode 100644 index 00000000000..af342ff1016 --- /dev/null +++ b/contrib/libs/fmt/test/core-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + core-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/enforce-checks-test/ya.make b/contrib/libs/fmt/test/enforce-checks-test/ya.make new file mode 100644 index 00000000000..0d67fef4122 --- /dev/null +++ b/contrib/libs/fmt/test/enforce-checks-test/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_ENFORCE_COMPILE_STRING + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + enforce-checks-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/format-impl-test/ya.make b/contrib/libs/fmt/test/format-impl-test/ya.make new file mode 100644 index 00000000000..fe49868ec11 --- /dev/null +++ b/contrib/libs/fmt/test/format-impl-test/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +ADDINCL( + contrib/libs/fmt/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_HEADER_ONLY=1 + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt) + +SRCS( + test/format-impl-test.cc + test/header-only-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/format-test/ya.make b/contrib/libs/fmt/test/format-test/ya.make new file mode 100644 index 00000000000..672765d32b8 --- /dev/null +++ b/contrib/libs/fmt/test/format-test/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +ALLOCATOR(J) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + format-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/gtest-extra-test/ya.make b/contrib/libs/fmt/test/gtest-extra-test/ya.make new file mode 100644 index 00000000000..407c5e33d84 --- /dev/null +++ b/contrib/libs/fmt/test/gtest-extra-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + gtest-extra-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/os-test/ya.make b/contrib/libs/fmt/test/os-test/ya.make new file mode 100644 index 00000000000..ef90d93fea0 --- /dev/null +++ b/contrib/libs/fmt/test/os-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + os-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/ostream-test/ya.make b/contrib/libs/fmt/test/ostream-test/ya.make new file mode 100644 index 00000000000..74f45abcf91 --- /dev/null +++ b/contrib/libs/fmt/test/ostream-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + ostream-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/posix-mock-test/ya.make b/contrib/libs/fmt/test/posix-mock-test/ya.make new file mode 100644 index 00000000000..411bacbd946 --- /dev/null +++ b/contrib/libs/fmt/test/posix-mock-test/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +ADDINCL( + contrib/libs/fmt/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt) + +SRCS( + src/format.cc + test/gtest-extra.cc + test/posix-mock-test.cc + test/util.cc +) + +END() diff --git a/contrib/libs/fmt/test/printf-test/ya.make b/contrib/libs/fmt/test/printf-test/ya.make new file mode 100644 index 00000000000..1d93b49d906 --- /dev/null +++ b/contrib/libs/fmt/test/printf-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + printf-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/ranges-test/ya.make b/contrib/libs/fmt/test/ranges-test/ya.make new file mode 100644 index 00000000000..251070a6773 --- /dev/null +++ b/contrib/libs/fmt/test/ranges-test/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + ranges-odr-test.cc + ranges-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/scan-test/ya.make b/contrib/libs/fmt/test/scan-test/ya.make new file mode 100644 index 00000000000..f1a6fff1c9b --- /dev/null +++ b/contrib/libs/fmt/test/scan-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + scan-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/unicode-test/ya.make b/contrib/libs/fmt/test/unicode-test/ya.make new file mode 100644 index 00000000000..96544c014b7 --- /dev/null +++ b/contrib/libs/fmt/test/unicode-test/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +ADDINCL( + contrib/libs/fmt/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_HEADER_ONLY=1 + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt) + +SRCS( + src/os.cc + test/gtest-extra.cc + test/unicode-test.cc + test/util.cc +) + +END() diff --git a/contrib/libs/fmt/test/xchar-test/ya.make b/contrib/libs/fmt/test/xchar-test/ya.make new file mode 100644 index 00000000000..d0a5e4c0438 --- /dev/null +++ b/contrib/libs/fmt/test/xchar-test/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +GTEST() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/libs/fmt/test +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DFMT_LOCALE + -DFMT_SHARED + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCDIR(contrib/libs/fmt/test) + +SRCS( + xchar-test.cc +) + +END() diff --git a/contrib/libs/fmt/test/ya.make b/contrib/libs/fmt/test/ya.make new file mode 100644 index 00000000000..46905a71d78 --- /dev/null +++ b/contrib/libs/fmt/test/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(MIT) + +PEERDIR( + contrib/libs/fmt + contrib/restricted/googletest/googlemock + contrib/restricted/googletest/googletest +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DGTEST_HAS_STD_WSTRING=1 + -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 +) + +SRCS( + gtest-extra.cc + util.cc +) + +END() + +RECURSE( + args-test + assert-test + color-test + compile-fp-test + compile-test + core-test + enforce-checks-test + format-impl-test + format-test + gtest-extra-test + os-test + ostream-test + posix-mock-test + printf-test + ranges-test + scan-test +) + +IF (NOT MUSL AND NOT OS_WINDOWS) + # Generated by devtools/yamaker. + RECURSE( + chrono-test + unicode-test + xchar-test + ) +ENDIF() diff --git a/contrib/libs/fmt/ya.make b/contrib/libs/fmt/ya.make new file mode 100644 index 00000000000..7f31226acdc --- /dev/null +++ b/contrib/libs/fmt/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +VERSION(8.1.1) + +ORIGINAL_SOURCE(https://github.com/fmtlib/fmt/archive/8.1.1.tar.gz) + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + MIT AND + Protestware AND + Public-Domain AND + Python-2.0 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/libs/fmt/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + GLOBAL -DFMT_EXPORT + GLOBAL -DFMT_CONSTEVAL= +) + +SRCS( + src/format.cc + src/os.cc +) + +END() + +RECURSE( + test +) diff --git a/contrib/libs/googleapis-common-protos/ya.make b/contrib/libs/googleapis-common-protos/ya.make new file mode 100644 index 00000000000..ebeeb7a7396 --- /dev/null +++ b/contrib/libs/googleapis-common-protos/ya.make @@ -0,0 +1,87 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +PROTO_LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.59.0) + +ORIGINAL_SOURCE(https://github.com/googleapis/python-api-common-protos/archive/v1.59.0.tar.gz) + +PY_NAMESPACE(.) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/googleapis-common-protos +) + +GRPC() + +SRCS( + google/api/annotations.proto + google/api/auth.proto + google/api/backend.proto + google/api/billing.proto + google/api/client.proto + google/api/config_change.proto + google/api/consumer.proto + google/api/context.proto + google/api/control.proto + google/api/distribution.proto + google/api/documentation.proto + google/api/endpoint.proto + google/api/error_reason.proto + google/api/field_behavior.proto + google/api/http.proto + google/api/httpbody.proto + google/api/label.proto + google/api/launch_stage.proto + google/api/log.proto + google/api/logging.proto + google/api/metric.proto + google/api/monitored_resource.proto + google/api/monitoring.proto + google/api/quota.proto + google/api/resource.proto + google/api/routing.proto + google/api/service.proto + google/api/source_info.proto + google/api/system_parameter.proto + google/api/usage.proto + google/api/visibility.proto + google/cloud/extended_operations.proto + google/cloud/location/locations.proto + google/gapic/metadata/gapic_metadata.proto + google/logging/type/http_request.proto + google/logging/type/log_severity.proto + google/longrunning/operations.proto + google/rpc/code.proto + google/rpc/context/attribute_context.proto + google/rpc/context/audit_context.proto + google/rpc/error_details.proto + google/rpc/http.proto + google/rpc/status.proto + google/type/calendar_period.proto + google/type/color.proto + google/type/date.proto + google/type/datetime.proto + google/type/dayofweek.proto + google/type/decimal.proto + google/type/expr.proto + google/type/fraction.proto + google/type/interval.proto + google/type/latlng.proto + google/type/localized_text.proto + google/type/money.proto + google/type/month.proto + google/type/phone_number.proto + google/type/postal_address.proto + google/type/quaternion.proto + google/type/timeofday.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/contrib/libs/grpc/grpc++_reflection/ya.make b/contrib/libs/grpc/grpc++_reflection/ya.make new file mode 100644 index 00000000000..c04eec34ec4 --- /dev/null +++ b/contrib/libs/grpc/grpc++_reflection/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc + contrib/libs/grpc/src/proto/grpc/reflection/v1alpha + contrib/libs/grpc/third_party/address_sorting + contrib/libs/grpc/third_party/upb + contrib/libs/protobuf + contrib/restricted/abseil-cpp-tstring/y_absl/synchronization +) + +ADDINCL( + GLOBAL contrib/libs/grpc/include + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc) + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + GLOBAL src/cpp/ext/proto_server_reflection_plugin.cc + src/cpp/ext/proto_server_reflection.cc +) + +END() diff --git a/contrib/libs/grpc/grpcpp_channelz/ya.make b/contrib/libs/grpc/grpcpp_channelz/ya.make new file mode 100644 index 00000000000..ff52bab7083 --- /dev/null +++ b/contrib/libs/grpc/grpcpp_channelz/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc + contrib/libs/grpc/src/proto/grpc/channelz + contrib/libs/grpc/third_party/address_sorting + contrib/libs/grpc/third_party/upb + contrib/libs/protobuf + contrib/restricted/abseil-cpp-tstring/y_absl/synchronization +) + +ADDINCL( + GLOBAL contrib/libs/grpc/include + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc) + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + src/cpp/server/channelz/channelz_service.cc + src/cpp/server/channelz/channelz_service_plugin.cc +) + +END() diff --git a/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make b/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make new file mode 100644 index 00000000000..1d25cd3eb11 --- /dev/null +++ b/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc/src/compiler/grpc_plugin_support + contrib/libs/protobuf + contrib/libs/protoc +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc + contrib/libs/grpc/include +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc/src/compiler) + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + cpp_plugin.cc +) + +END() diff --git a/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make b/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make new file mode 100644 index 00000000000..77c5d9d7531 --- /dev/null +++ b/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make @@ -0,0 +1,40 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/protobuf + contrib/libs/protoc +) + +ADDINCL( + GLOBAL contrib/libs/grpc/include + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc/src/compiler) + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + cpp_generator.cc + csharp_generator.cc + node_generator.cc + objective_c_generator.cc + php_generator.cc + python_generator.cc + ruby_generator.cc +) + +END() diff --git a/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make b/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make new file mode 100644 index 00000000000..cdfb0d7b5e5 --- /dev/null +++ b/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc/src/compiler/grpc_plugin_support + contrib/libs/protoc +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc + contrib/libs/grpc/include +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc/src/compiler) + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + python_plugin.cc +) + +END() diff --git a/contrib/libs/grpc/src/proto/grpc/channelz/ya.make b/contrib/libs/grpc/src/proto/grpc/channelz/ya.make new file mode 100644 index 00000000000..39343ee3293 --- /dev/null +++ b/contrib/libs/grpc/src/proto/grpc/channelz/ya.make @@ -0,0 +1,20 @@ +PROTO_LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/grpc +) + +GRPC() + +SRCS( + channelz.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/contrib/libs/grpc/src/proto/grpc/core/ya.make b/contrib/libs/grpc/src/proto/grpc/core/ya.make new file mode 100644 index 00000000000..c6ebad89408 --- /dev/null +++ b/contrib/libs/grpc/src/proto/grpc/core/ya.make @@ -0,0 +1,22 @@ +PROTO_LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/grpc +) + +GRPC() + +SRCS( + stats.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/contrib/libs/grpc/src/proto/grpc/health/v1/ya.make b/contrib/libs/grpc/src/proto/grpc/health/v1/ya.make new file mode 100644 index 00000000000..87e9e34c1dd --- /dev/null +++ b/contrib/libs/grpc/src/proto/grpc/health/v1/ya.make @@ -0,0 +1,24 @@ +PROTO_LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/grpc +) + +PY_NAMESPACE("src.proto.grpc.health.v1") + +GRPC() + +SRCS( + health.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/contrib/libs/grpc/src/proto/grpc/reflection/v1alpha/ya.make b/contrib/libs/grpc/src/proto/grpc/reflection/v1alpha/ya.make new file mode 100644 index 00000000000..9a2d0b29bba --- /dev/null +++ b/contrib/libs/grpc/src/proto/grpc/reflection/v1alpha/ya.make @@ -0,0 +1,22 @@ +PROTO_LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/grpc +) + +PY_NAMESPACE(src.proto.grpc.reflection.v1alpha) + +GRPC() + +SRCS( + reflection.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/contrib/libs/grpc/src/proto/grpc/status/ya.make b/contrib/libs/grpc/src/proto/grpc/status/ya.make new file mode 100644 index 00000000000..4641904cabf --- /dev/null +++ b/contrib/libs/grpc/src/proto/grpc/status/ya.make @@ -0,0 +1,22 @@ +PROTO_LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/grpc +) + +GRPC() + +SRCS( + status.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/contrib/libs/grpc/third_party/address_sorting/ya.make b/contrib/libs/grpc/third_party/address_sorting/ya.make new file mode 100644 index 00000000000..3458b8825c8 --- /dev/null +++ b/contrib/libs/grpc/third_party/address_sorting/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc + contrib/libs/grpc/third_party/address_sorting/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + address_sorting.c + address_sorting_posix.c + address_sorting_windows.c +) + +END() diff --git a/contrib/libs/grpc/third_party/upb/ya.make b/contrib/libs/grpc/third_party/upb/ya.make new file mode 100644 index 00000000000..9c0e97275ce --- /dev/null +++ b/contrib/libs/grpc/third_party/upb/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc + contrib/libs/grpc/src/core/ext/upb-generated + contrib/libs/grpc/src/core/ext/upbdefs-generated + contrib/libs/grpc/third_party/upb +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/libs/grpc) + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c + third_party/upb/third_party/utf8_range/naive.c + third_party/upb/third_party/utf8_range/range2-neon.c + third_party/upb/third_party/utf8_range/range2-sse.c + third_party/upb/upb/arena.c + third_party/upb/upb/array.c + third_party/upb/upb/decode.c + third_party/upb/upb/decode_fast.c + third_party/upb/upb/def.c + third_party/upb/upb/encode.c + third_party/upb/upb/extension_registry.c + third_party/upb/upb/json_decode.c + third_party/upb/upb/json_encode.c + third_party/upb/upb/map.c + third_party/upb/upb/mini_table.c + third_party/upb/upb/msg.c + third_party/upb/upb/reflection.c + third_party/upb/upb/status.c + third_party/upb/upb/table.c + third_party/upb/upb/text_encode.c + third_party/upb/upb/upb.c +) + +END() diff --git a/contrib/libs/grpc/ya.make b/contrib/libs/grpc/ya.make new file mode 100644 index 00000000000..619385e3577 --- /dev/null +++ b/contrib/libs/grpc/ya.make @@ -0,0 +1,881 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +VERSION(1.50.2) + +ORIGINAL_SOURCE(https://github.com/grpc/grpc/archive/v1.50.2.tar.gz) + +LICENSE( + Apache-2.0 AND + BSD-3-Clause AND + MPL-2.0 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + certs + contrib/libs/c-ares + contrib/libs/grpc/third_party/address_sorting + contrib/libs/grpc/third_party/upb + contrib/libs/openssl + contrib/libs/re2 + contrib/libs/xxhash + contrib/libs/zlib + contrib/restricted/abseil-cpp-tstring/y_absl/algorithm + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/container + contrib/restricted/abseil-cpp-tstring/y_absl/functional + contrib/restricted/abseil-cpp-tstring/y_absl/hash + contrib/restricted/abseil-cpp-tstring/y_absl/memory + contrib/restricted/abseil-cpp-tstring/y_absl/meta + contrib/restricted/abseil-cpp-tstring/y_absl/random + contrib/restricted/abseil-cpp-tstring/y_absl/status + contrib/restricted/abseil-cpp-tstring/y_absl/strings + contrib/restricted/abseil-cpp-tstring/y_absl/synchronization + contrib/restricted/abseil-cpp-tstring/y_absl/time + contrib/restricted/abseil-cpp-tstring/y_absl/types + contrib/restricted/abseil-cpp-tstring/y_absl/utility + library/cpp/resource +) + +ADDINCL( + GLOBAL contrib/libs/grpc/include + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + contrib/libs/grpc + contrib/libs/grpc/src/core/ext/upb-generated + contrib/libs/grpc/src/core/ext/upbdefs-generated + contrib/libs/grpc/third_party/address_sorting/include + contrib/libs/grpc/third_party/upb + contrib/libs/re2 + contrib/libs/xxhash +) + +NO_COMPILER_WARNINGS() + +IF (OS_LINUX OR OS_DARWIN) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) +ENDIF() + +SRCS( + src/core/ext/filters/census/grpc_context.cc + src/core/ext/filters/channel_idle/channel_idle_filter.cc + src/core/ext/filters/channel_idle/idle_filter_state.cc + src/core/ext/filters/client_channel/backend_metric.cc + src/core/ext/filters/client_channel/backup_poller.cc + src/core/ext/filters/client_channel/channel_connectivity.cc + src/core/ext/filters/client_channel/client_channel.cc + src/core/ext/filters/client_channel/client_channel_channelz.cc + src/core/ext/filters/client_channel/client_channel_factory.cc + src/core/ext/filters/client_channel/client_channel_plugin.cc + src/core/ext/filters/client_channel/config_selector.cc + src/core/ext/filters/client_channel/dynamic_filters.cc + src/core/ext/filters/client_channel/global_subchannel_pool.cc + src/core/ext/filters/client_channel/health/health_check_client.cc + src/core/ext/filters/client_channel/http_proxy.cc + src/core/ext/filters/client_channel/lb_policy/address_filtering.cc + src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc + src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc + src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc + src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc + src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc + src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc + src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc + src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc + src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc + src/core/ext/filters/client_channel/lb_policy/priority/priority.cc + src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc + src/core/ext/filters/client_channel/lb_policy/rls/rls.cc + src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc + src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc + src/core/ext/filters/client_channel/lb_policy/xds/cds.cc + src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc + src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc + src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc + src/core/ext/filters/client_channel/local_subchannel_pool.cc + src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc + src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc + src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc + src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc + src/core/ext/filters/client_channel/resolver/polling_resolver.cc + src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc + src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc + src/core/ext/filters/client_channel/resolver_result_parsing.cc + src/core/ext/filters/client_channel/retry_filter.cc + src/core/ext/filters/client_channel/retry_service_config.cc + src/core/ext/filters/client_channel/retry_throttle.cc + src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc + src/core/ext/filters/client_channel/subchannel.cc + src/core/ext/filters/client_channel/subchannel_pool_interface.cc + src/core/ext/filters/client_channel/subchannel_stream_client.cc + src/core/ext/filters/deadline/deadline_filter.cc + src/core/ext/filters/fault_injection/fault_injection_filter.cc + src/core/ext/filters/fault_injection/service_config_parser.cc + src/core/ext/filters/http/client/http_client_filter.cc + src/core/ext/filters/http/client_authority_filter.cc + src/core/ext/filters/http/http_filters_plugin.cc + src/core/ext/filters/http/message_compress/message_compress_filter.cc + src/core/ext/filters/http/message_compress/message_decompress_filter.cc + src/core/ext/filters/http/server/http_server_filter.cc + src/core/ext/filters/message_size/message_size_filter.cc + src/core/ext/filters/rbac/rbac_filter.cc + src/core/ext/filters/rbac/rbac_service_config_parser.cc + src/core/ext/filters/server_config_selector/server_config_selector.cc + src/core/ext/filters/server_config_selector/server_config_selector_filter.cc + src/core/ext/transport/binder/client/binder_connector.cc + src/core/ext/transport/binder/client/channel_create.cc + src/core/ext/transport/binder/client/channel_create_impl.cc + src/core/ext/transport/binder/client/connection_id_generator.cc + src/core/ext/transport/binder/client/endpoint_binder_pool.cc + src/core/ext/transport/binder/client/jni_utils.cc + src/core/ext/transport/binder/client/security_policy_setting.cc + src/core/ext/transport/binder/security_policy/binder_security_policy.cc + src/core/ext/transport/binder/server/binder_server.cc + src/core/ext/transport/binder/server/binder_server_credentials.cc + src/core/ext/transport/binder/transport/binder_transport.cc + src/core/ext/transport/binder/utils/ndk_binder.cc + src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc + src/core/ext/transport/binder/wire_format/binder_android.cc + src/core/ext/transport/binder/wire_format/binder_constants.cc + src/core/ext/transport/binder/wire_format/transaction.cc + src/core/ext/transport/binder/wire_format/wire_reader_impl.cc + src/core/ext/transport/binder/wire_format/wire_writer.cc + src/core/ext/transport/chttp2/alpn/alpn.cc + src/core/ext/transport/chttp2/client/chttp2_connector.cc + src/core/ext/transport/chttp2/server/chttp2_server.cc + src/core/ext/transport/chttp2/transport/bin_decoder.cc + src/core/ext/transport/chttp2/transport/bin_encoder.cc + src/core/ext/transport/chttp2/transport/chttp2_transport.cc + src/core/ext/transport/chttp2/transport/context_list.cc + src/core/ext/transport/chttp2/transport/decode_huff.cc + src/core/ext/transport/chttp2/transport/flow_control.cc + src/core/ext/transport/chttp2/transport/frame_data.cc + src/core/ext/transport/chttp2/transport/frame_goaway.cc + src/core/ext/transport/chttp2/transport/frame_ping.cc + src/core/ext/transport/chttp2/transport/frame_rst_stream.cc + src/core/ext/transport/chttp2/transport/frame_settings.cc + src/core/ext/transport/chttp2/transport/frame_window_update.cc + src/core/ext/transport/chttp2/transport/hpack_encoder.cc + src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc + src/core/ext/transport/chttp2/transport/hpack_parser.cc + src/core/ext/transport/chttp2/transport/hpack_parser_table.cc + src/core/ext/transport/chttp2/transport/http2_settings.cc + src/core/ext/transport/chttp2/transport/huffsyms.cc + src/core/ext/transport/chttp2/transport/parsing.cc + src/core/ext/transport/chttp2/transport/stream_lists.cc + src/core/ext/transport/chttp2/transport/stream_map.cc + src/core/ext/transport/chttp2/transport/varint.cc + src/core/ext/transport/chttp2/transport/writing.cc + src/core/ext/transport/inproc/inproc_plugin.cc + src/core/ext/transport/inproc/inproc_transport.cc + src/core/ext/upb-generated/envoy/admin/v3/certs.upb.c + src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.c + src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c + src/core/ext/upb-generated/envoy/admin/v3/config_dump_shared.upb.c + src/core/ext/upb-generated/envoy/admin/v3/init_dump.upb.c + src/core/ext/upb-generated/envoy/admin/v3/listeners.upb.c + src/core/ext/upb-generated/envoy/admin/v3/memory.upb.c + src/core/ext/upb-generated/envoy/admin/v3/metrics.upb.c + src/core/ext/upb-generated/envoy/admin/v3/mutex_stats.upb.c + src/core/ext/upb-generated/envoy/admin/v3/server_info.upb.c + src/core/ext/upb-generated/envoy/admin/v3/tap.upb.c + src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c + src/core/ext/upb-generated/envoy/annotations/resource.upb.c + src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c + src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c + src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c + src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c + src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c + src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c + src/core/ext/upb-generated/envoy/config/common/matcher/v3/matcher.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/grpc_method_list.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c + src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c + src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c + src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c + src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c + src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c + src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c + src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c + src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c + src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c + src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.c + src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c + src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c + src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c + src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c + src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c + src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c + src/core/ext/upb-generated/envoy/config/tap/v3/common.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/dynamic_ot.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/lightstep.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/opencensus.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/opentelemetry.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/service.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/skywalking.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/trace.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/xray.upb.c + src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.c + src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c + src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c + src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c + src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c + src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c + src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c + src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.c + src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/wrr_locality/v3/wrr_locality.upb.c + src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c + src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c + src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c + src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c + src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.c + src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c + src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c + src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c + src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c + src/core/ext/upb-generated/envoy/type/http/v3/cookie.upb.c + src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c + src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c + src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c + src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c + src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.c + src/core/ext/upb-generated/envoy/type/v3/http.upb.c + src/core/ext/upb-generated/envoy/type/v3/http_status.upb.c + src/core/ext/upb-generated/envoy/type/v3/percent.upb.c + src/core/ext/upb-generated/envoy/type/v3/range.upb.c + src/core/ext/upb-generated/envoy/type/v3/ratelimit_strategy.upb.c + src/core/ext/upb-generated/envoy/type/v3/ratelimit_unit.upb.c + src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c + src/core/ext/upb-generated/envoy/type/v3/token_bucket.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c + src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c + src/core/ext/upb-generated/google/api/http.upb.c + src/core/ext/upb-generated/google/api/httpbody.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c + src/core/ext/upb-generated/opencensus/proto/trace/v1/trace_config.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c + src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c + src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls_config.upb.c + src/core/ext/upb-generated/udpa/annotations/migrate.upb.c + src/core/ext/upb-generated/udpa/annotations/security.upb.c + src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c + src/core/ext/upb-generated/udpa/annotations/status.upb.c + src/core/ext/upb-generated/udpa/annotations/versioning.upb.c + src/core/ext/upb-generated/validate/validate.upb.c + src/core/ext/upb-generated/xds/annotations/v3/migrate.upb.c + src/core/ext/upb-generated/xds/annotations/v3/security.upb.c + src/core/ext/upb-generated/xds/annotations/v3/sensitive.upb.c + src/core/ext/upb-generated/xds/annotations/v3/status.upb.c + src/core/ext/upb-generated/xds/annotations/v3/versioning.upb.c + src/core/ext/upb-generated/xds/core/v3/authority.upb.c + src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c + src/core/ext/upb-generated/xds/core/v3/context_params.upb.c + src/core/ext/upb-generated/xds/core/v3/extension.upb.c + src/core/ext/upb-generated/xds/core/v3/resource.upb.c + src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c + src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c + src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c + src/core/ext/upb-generated/xds/service/orca/v3/orca.upb.c + src/core/ext/upb-generated/xds/type/matcher/v3/matcher.upb.c + src/core/ext/upb-generated/xds/type/matcher/v3/regex.upb.c + src/core/ext/upb-generated/xds/type/matcher/v3/string.upb.c + src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.c + src/core/ext/upbdefs-generated/envoy/admin/v3/certs.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/clusters.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump_shared.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/init_dump.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/listeners.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/memory.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/metrics.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/mutex_stats.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/server_info.upbdefs.c + src/core/ext/upbdefs-generated/envoy/admin/v3/tap.upbdefs.c + src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c + src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/common/matcher/v3/matcher.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_method_list.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/metrics/v3/metrics_service.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/tap/v3/common.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/datadog.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/dynamic_ot.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/lightstep.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/opencensus.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/opentelemetry.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/service.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/skywalking.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/trace.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/xray.upbdefs.c + src/core/ext/upbdefs-generated/envoy/config/trace/v3/zipkin.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c + src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upbdefs.c + src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c + src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c + src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c + src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/http/v3/cookie.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/http_inputs.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/hash_policy.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/http_status.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/ratelimit_strategy.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/ratelimit_unit.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c + src/core/ext/upbdefs-generated/envoy/type/v3/token_bucket.upbdefs.c + src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c + src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c + src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c + src/core/ext/upbdefs-generated/google/api/http.upbdefs.c + src/core/ext/upbdefs-generated/google/api/httpbody.upbdefs.c + src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c + src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c + src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c + src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c + src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c + src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c + src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c + src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c + src/core/ext/upbdefs-generated/opencensus/proto/trace/v1/trace_config.upbdefs.c + src/core/ext/upbdefs-generated/src/proto/grpc/lookup/v1/rls_config.upbdefs.c + src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c + src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c + src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c + src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c + src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c + src/core/ext/upbdefs-generated/validate/validate.upbdefs.c + src/core/ext/upbdefs-generated/xds/annotations/v3/migrate.upbdefs.c + src/core/ext/upbdefs-generated/xds/annotations/v3/security.upbdefs.c + src/core/ext/upbdefs-generated/xds/annotations/v3/sensitive.upbdefs.c + src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.c + src/core/ext/upbdefs-generated/xds/annotations/v3/versioning.upbdefs.c + src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c + src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c + src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c + src/core/ext/upbdefs-generated/xds/core/v3/extension.upbdefs.c + src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c + src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c + src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c + src/core/ext/upbdefs-generated/xds/type/matcher/v3/matcher.upbdefs.c + src/core/ext/upbdefs-generated/xds/type/matcher/v3/regex.upbdefs.c + src/core/ext/upbdefs-generated/xds/type/matcher/v3/string.upbdefs.c + src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.c + src/core/ext/xds/certificate_provider_store.cc + src/core/ext/xds/file_watcher_certificate_provider_factory.cc + src/core/ext/xds/xds_api.cc + src/core/ext/xds/xds_bootstrap.cc + src/core/ext/xds/xds_bootstrap_grpc.cc + src/core/ext/xds/xds_certificate_provider.cc + src/core/ext/xds/xds_channel_stack_modifier.cc + src/core/ext/xds/xds_client.cc + src/core/ext/xds/xds_client_grpc.cc + src/core/ext/xds/xds_client_stats.cc + src/core/ext/xds/xds_cluster.cc + src/core/ext/xds/xds_cluster_specifier_plugin.cc + src/core/ext/xds/xds_common_types.cc + src/core/ext/xds/xds_endpoint.cc + src/core/ext/xds/xds_http_fault_filter.cc + src/core/ext/xds/xds_http_filters.cc + src/core/ext/xds/xds_http_rbac_filter.cc + src/core/ext/xds/xds_lb_policy_registry.cc + src/core/ext/xds/xds_listener.cc + src/core/ext/xds/xds_resource_type.cc + src/core/ext/xds/xds_route_config.cc + src/core/ext/xds/xds_routing.cc + src/core/ext/xds/xds_server_config_fetcher.cc + src/core/ext/xds/xds_transport_grpc.cc + src/core/lib/address_utils/parse_address.cc + src/core/lib/address_utils/sockaddr_utils.cc + src/core/lib/backoff/backoff.cc + src/core/lib/channel/channel_args.cc + src/core/lib/channel/channel_args_preconditioning.cc + src/core/lib/channel/channel_stack.cc + src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_stack_builder_impl.cc + src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channelz.cc + src/core/lib/channel/channelz_registry.cc + src/core/lib/channel/connected_channel.cc + src/core/lib/channel/promise_based_filter.cc + src/core/lib/channel/status_util.cc + src/core/lib/compression/compression.cc + src/core/lib/compression/compression_internal.cc + src/core/lib/compression/message_compress.cc + src/core/lib/config/core_configuration.cc + src/core/lib/debug/stats.cc + src/core/lib/debug/stats_data.cc + src/core/lib/debug/trace.cc + src/core/lib/event_engine/channel_args_endpoint_config.cc + src/core/lib/event_engine/default_event_engine.cc + src/core/lib/event_engine/default_event_engine_factory.cc + src/core/lib/event_engine/executor/threaded_executor.cc + src/core/lib/event_engine/forkable.cc + src/core/lib/event_engine/memory_allocator.cc + src/core/lib/event_engine/posix_engine/posix_engine.cc + src/core/lib/event_engine/posix_engine/timer.cc + src/core/lib/event_engine/posix_engine/timer_heap.cc + src/core/lib/event_engine/posix_engine/timer_manager.cc + src/core/lib/event_engine/resolved_address.cc + src/core/lib/event_engine/slice.cc + src/core/lib/event_engine/slice_buffer.cc + src/core/lib/event_engine/thread_pool.cc + src/core/lib/event_engine/time_util.cc + src/core/lib/event_engine/trace.cc + src/core/lib/event_engine/utils.cc + src/core/lib/event_engine/windows/iocp.cc + src/core/lib/event_engine/windows/win_socket.cc + src/core/lib/event_engine/windows/windows_engine.cc + src/core/lib/experiments/config.cc + src/core/lib/experiments/experiments.cc + src/core/lib/gpr/alloc.cc + src/core/lib/gpr/atm.cc + src/core/lib/gpr/cpu_iphone.cc + src/core/lib/gpr/cpu_linux.cc + src/core/lib/gpr/cpu_posix.cc + src/core/lib/gpr/cpu_windows.cc + src/core/lib/gpr/log.cc + src/core/lib/gpr/log_android.cc + src/core/lib/gpr/log_linux.cc + src/core/lib/gpr/log_posix.cc + src/core/lib/gpr/log_windows.cc + src/core/lib/gpr/murmur_hash.cc + src/core/lib/gpr/string.cc + src/core/lib/gpr/string_posix.cc + src/core/lib/gpr/string_util_windows.cc + src/core/lib/gpr/string_windows.cc + src/core/lib/gpr/sync.cc + src/core/lib/gpr/sync_abseil.cc + src/core/lib/gpr/sync_posix.cc + src/core/lib/gpr/sync_windows.cc + src/core/lib/gpr/time.cc + src/core/lib/gpr/time_posix.cc + src/core/lib/gpr/time_precise.cc + src/core/lib/gpr/time_windows.cc + src/core/lib/gpr/tmpfile_msys.cc + src/core/lib/gpr/tmpfile_posix.cc + src/core/lib/gpr/tmpfile_windows.cc + src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/env_linux.cc + src/core/lib/gprpp/env_posix.cc + src/core/lib/gprpp/env_windows.cc + src/core/lib/gprpp/examine_stack.cc + src/core/lib/gprpp/fork.cc + src/core/lib/gprpp/global_config_env.cc + src/core/lib/gprpp/host_port.cc + src/core/lib/gprpp/mpscq.cc + src/core/lib/gprpp/stat_posix.cc + src/core/lib/gprpp/stat_windows.cc + src/core/lib/gprpp/status_helper.cc + src/core/lib/gprpp/tchar.cc + src/core/lib/gprpp/thd_posix.cc + src/core/lib/gprpp/thd_windows.cc + src/core/lib/gprpp/time.cc + src/core/lib/gprpp/time_averaged_stats.cc + src/core/lib/gprpp/time_util.cc + src/core/lib/gprpp/validation_errors.cc + src/core/lib/gprpp/work_serializer.cc + src/core/lib/handshaker/proxy_mapper_registry.cc + src/core/lib/http/format_request.cc + src/core/lib/http/httpcli.cc + src/core/lib/http/httpcli_security_connector.cc + src/core/lib/http/parser.cc + src/core/lib/iomgr/buffer_list.cc + src/core/lib/iomgr/call_combiner.cc + src/core/lib/iomgr/cfstream_handle.cc + src/core/lib/iomgr/combiner.cc + src/core/lib/iomgr/dualstack_socket_posix.cc + src/core/lib/iomgr/endpoint.cc + src/core/lib/iomgr/endpoint_cfstream.cc + src/core/lib/iomgr/endpoint_pair_posix.cc + src/core/lib/iomgr/endpoint_pair_windows.cc + src/core/lib/iomgr/error.cc + src/core/lib/iomgr/error_cfstream.cc + src/core/lib/iomgr/ev_apple.cc + src/core/lib/iomgr/ev_epoll1_linux.cc + src/core/lib/iomgr/ev_poll_posix.cc + src/core/lib/iomgr/ev_posix.cc + src/core/lib/iomgr/ev_windows.cc + src/core/lib/iomgr/exec_ctx.cc + src/core/lib/iomgr/executor.cc + src/core/lib/iomgr/fork_posix.cc + src/core/lib/iomgr/fork_windows.cc + src/core/lib/iomgr/gethostname_fallback.cc + src/core/lib/iomgr/gethostname_host_name_max.cc + src/core/lib/iomgr/gethostname_sysconf.cc + src/core/lib/iomgr/grpc_if_nametoindex_posix.cc + src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc + src/core/lib/iomgr/internal_errqueue.cc + src/core/lib/iomgr/iocp_windows.cc + src/core/lib/iomgr/iomgr.cc + src/core/lib/iomgr/iomgr_internal.cc + src/core/lib/iomgr/iomgr_posix.cc + src/core/lib/iomgr/iomgr_posix_cfstream.cc + src/core/lib/iomgr/iomgr_windows.cc + src/core/lib/iomgr/load_file.cc + src/core/lib/iomgr/lockfree_event.cc + src/core/lib/iomgr/polling_entity.cc + src/core/lib/iomgr/pollset.cc + src/core/lib/iomgr/pollset_set.cc + src/core/lib/iomgr/pollset_set_windows.cc + src/core/lib/iomgr/pollset_windows.cc + src/core/lib/iomgr/resolve_address.cc + src/core/lib/iomgr/resolve_address_posix.cc + src/core/lib/iomgr/resolve_address_windows.cc + src/core/lib/iomgr/sockaddr_utils_posix.cc + src/core/lib/iomgr/socket_factory_posix.cc + src/core/lib/iomgr/socket_mutator.cc + src/core/lib/iomgr/socket_utils_common_posix.cc + src/core/lib/iomgr/socket_utils_linux.cc + src/core/lib/iomgr/socket_utils_posix.cc + src/core/lib/iomgr/socket_utils_windows.cc + src/core/lib/iomgr/socket_windows.cc + src/core/lib/iomgr/tcp_client.cc + src/core/lib/iomgr/tcp_client_cfstream.cc + src/core/lib/iomgr/tcp_client_posix.cc + src/core/lib/iomgr/tcp_client_windows.cc + src/core/lib/iomgr/tcp_posix.cc + src/core/lib/iomgr/tcp_server.cc + src/core/lib/iomgr/tcp_server_posix.cc + src/core/lib/iomgr/tcp_server_utils_posix_common.cc + src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc + src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc + src/core/lib/iomgr/tcp_server_windows.cc + src/core/lib/iomgr/tcp_windows.cc + src/core/lib/iomgr/timer.cc + src/core/lib/iomgr/timer_generic.cc + src/core/lib/iomgr/timer_heap.cc + src/core/lib/iomgr/timer_manager.cc + src/core/lib/iomgr/unix_sockets_posix.cc + src/core/lib/iomgr/unix_sockets_posix_noop.cc + src/core/lib/iomgr/wakeup_fd_eventfd.cc + src/core/lib/iomgr/wakeup_fd_nospecial.cc + src/core/lib/iomgr/wakeup_fd_pipe.cc + src/core/lib/iomgr/wakeup_fd_posix.cc + src/core/lib/json/json_object_loader.cc + src/core/lib/json/json_reader.cc + src/core/lib/json/json_util.cc + src/core/lib/json/json_writer.cc + src/core/lib/load_balancing/lb_policy.cc + src/core/lib/load_balancing/lb_policy_registry.cc + src/core/lib/matchers/matchers.cc + src/core/lib/promise/activity.cc + src/core/lib/promise/sleep.cc + src/core/lib/resolver/resolver.cc + src/core/lib/resolver/resolver_registry.cc + src/core/lib/resolver/server_address.cc + src/core/lib/resource_quota/api.cc + src/core/lib/resource_quota/arena.cc + src/core/lib/resource_quota/memory_quota.cc + src/core/lib/resource_quota/periodic_update.cc + src/core/lib/resource_quota/resource_quota.cc + src/core/lib/resource_quota/thread_quota.cc + src/core/lib/resource_quota/trace.cc + src/core/lib/security/authorization/authorization_policy_provider_vtable.cc + src/core/lib/security/authorization/evaluate_args.cc + src/core/lib/security/authorization/grpc_authorization_engine.cc + src/core/lib/security/authorization/grpc_server_authz_filter.cc + src/core/lib/security/authorization/matchers.cc + src/core/lib/security/authorization/rbac_policy.cc + src/core/lib/security/certificate_provider/certificate_provider_registry.cc + src/core/lib/security/context/security_context.cc + src/core/lib/security/credentials/alts/alts_credentials.cc + src/core/lib/security/credentials/alts/check_gcp_environment.cc + src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc + src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc + src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc + src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc + src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc + src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc + src/core/lib/security/credentials/call_creds_util.cc + src/core/lib/security/credentials/channel_creds_registry_init.cc + src/core/lib/security/credentials/composite/composite_credentials.cc + src/core/lib/security/credentials/credentials.cc + src/core/lib/security/credentials/external/aws_external_account_credentials.cc + src/core/lib/security/credentials/external/aws_request_signer.cc + src/core/lib/security/credentials/external/external_account_credentials.cc + src/core/lib/security/credentials/external/file_external_account_credentials.cc + src/core/lib/security/credentials/external/url_external_account_credentials.cc + src/core/lib/security/credentials/fake/fake_credentials.cc + src/core/lib/security/credentials/google_default/credentials_generic.cc + src/core/lib/security/credentials/google_default/google_default_credentials.cc + src/core/lib/security/credentials/iam/iam_credentials.cc + src/core/lib/security/credentials/insecure/insecure_credentials.cc + src/core/lib/security/credentials/jwt/json_token.cc + src/core/lib/security/credentials/jwt/jwt_credentials.cc + src/core/lib/security/credentials/jwt/jwt_verifier.cc + src/core/lib/security/credentials/local/local_credentials.cc + src/core/lib/security/credentials/oauth2/oauth2_credentials.cc + src/core/lib/security/credentials/plugin/plugin_credentials.cc + src/core/lib/security/credentials/ssl/ssl_credentials.cc + src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc + src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc + src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc + src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc + src/core/lib/security/credentials/tls/tls_credentials.cc + src/core/lib/security/credentials/tls/tls_utils.cc + src/core/lib/security/credentials/xds/xds_credentials.cc + src/core/lib/security/security_connector/add_arcadia_root_certs.cpp + src/core/lib/security/security_connector/alts/alts_security_connector.cc + src/core/lib/security/security_connector/fake/fake_security_connector.cc + src/core/lib/security/security_connector/insecure/insecure_security_connector.cc + src/core/lib/security/security_connector/load_system_roots_fallback.cc + src/core/lib/security/security_connector/load_system_roots_supported.cc + src/core/lib/security/security_connector/local/local_security_connector.cc + src/core/lib/security/security_connector/security_connector.cc + src/core/lib/security/security_connector/ssl/ssl_security_connector.cc + src/core/lib/security/security_connector/ssl_utils.cc + src/core/lib/security/security_connector/ssl_utils_config.cc + src/core/lib/security/security_connector/tls/tls_security_connector.cc + src/core/lib/security/transport/client_auth_filter.cc + src/core/lib/security/transport/secure_endpoint.cc + src/core/lib/security/transport/security_handshaker.cc + src/core/lib/security/transport/server_auth_filter.cc + src/core/lib/security/transport/tsi_error.cc + src/core/lib/security/util/json_util.cc + src/core/lib/service_config/service_config_impl.cc + src/core/lib/service_config/service_config_parser.cc + src/core/lib/slice/b64.cc + src/core/lib/slice/percent_encoding.cc + src/core/lib/slice/slice.cc + src/core/lib/slice/slice_api.cc + src/core/lib/slice/slice_buffer.cc + src/core/lib/slice/slice_buffer_api.cc + src/core/lib/slice/slice_refcount.cc + src/core/lib/slice/slice_string_helpers.cc + src/core/lib/surface/api_trace.cc + src/core/lib/surface/builtins.cc + src/core/lib/surface/byte_buffer.cc + src/core/lib/surface/byte_buffer_reader.cc + src/core/lib/surface/call.cc + src/core/lib/surface/call_details.cc + src/core/lib/surface/call_log_batch.cc + src/core/lib/surface/channel.cc + src/core/lib/surface/channel_init.cc + src/core/lib/surface/channel_ping.cc + src/core/lib/surface/channel_stack_type.cc + src/core/lib/surface/completion_queue.cc + src/core/lib/surface/completion_queue_factory.cc + src/core/lib/surface/event_string.cc + src/core/lib/surface/init.cc + src/core/lib/surface/init_internally.cc + src/core/lib/surface/lame_client.cc + src/core/lib/surface/metadata_array.cc + src/core/lib/surface/server.cc + src/core/lib/surface/validate_metadata.cc + src/core/lib/surface/version.cc + src/core/lib/transport/bdp_estimator.cc + src/core/lib/transport/connectivity_state.cc + src/core/lib/transport/error_utils.cc + src/core/lib/transport/handshaker.cc + src/core/lib/transport/handshaker_registry.cc + src/core/lib/transport/http_connect_handshaker.cc + src/core/lib/transport/metadata_batch.cc + src/core/lib/transport/parsed_metadata.cc + src/core/lib/transport/pid_controller.cc + src/core/lib/transport/status_conversion.cc + src/core/lib/transport/tcp_connect_handshaker.cc + src/core/lib/transport/timeout_encoding.cc + src/core/lib/transport/transport.cc + src/core/lib/transport/transport_op_string.cc + src/core/lib/uri/uri_parser.cc + src/core/plugin_registry/grpc_plugin_registry.cc + src/core/plugin_registry/grpc_plugin_registry_extra.cc + src/core/tsi/alts/crypt/aes_gcm.cc + src/core/tsi/alts/crypt/gsec.cc + src/core/tsi/alts/frame_protector/alts_counter.cc + src/core/tsi/alts/frame_protector/alts_crypter.cc + src/core/tsi/alts/frame_protector/alts_frame_protector.cc + src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc + src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc + src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc + src/core/tsi/alts/frame_protector/frame_handler.cc + src/core/tsi/alts/handshaker/alts_handshaker_client.cc + src/core/tsi/alts/handshaker/alts_shared_resource.cc + src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc + src/core/tsi/alts/handshaker/alts_tsi_utils.cc + src/core/tsi/alts/handshaker/transport_security_common_api.cc + src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc + src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc + src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc + src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc + src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc + src/core/tsi/fake_transport_security.cc + src/core/tsi/local_transport_security.cc + src/core/tsi/ssl/key_logging/ssl_key_logging.cc + src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc + src/core/tsi/ssl/session_cache/ssl_session_cache.cc + src/core/tsi/ssl/session_cache/ssl_session_openssl.cc + src/core/tsi/ssl_transport_security.cc + src/core/tsi/transport_security.cc + src/core/tsi/transport_security_grpc.cc + src/cpp/client/channel_cc.cc + src/cpp/client/client_callback.cc + src/cpp/client/client_context.cc + src/cpp/client/client_interceptor.cc + src/cpp/client/create_channel.cc + src/cpp/client/create_channel_internal.cc + src/cpp/client/create_channel_posix.cc + src/cpp/client/credentials_cc.cc + src/cpp/client/insecure_credentials.cc + src/cpp/client/secure_credentials.cc + src/cpp/client/xds_credentials.cc + src/cpp/codegen/codegen_init.cc + src/cpp/common/alarm.cc + src/cpp/common/auth_property_iterator.cc + src/cpp/common/channel_arguments.cc + src/cpp/common/channel_filter.cc + src/cpp/common/completion_queue_cc.cc + src/cpp/common/core_codegen.cc + src/cpp/common/resource_quota_cc.cc + src/cpp/common/rpc_method.cc + src/cpp/common/secure_auth_context.cc + src/cpp/common/secure_channel_arguments.cc + src/cpp/common/secure_create_auth_context.cc + src/cpp/common/tls_certificate_provider.cc + src/cpp/common/tls_certificate_verifier.cc + src/cpp/common/tls_credentials_options.cc + src/cpp/common/validate_service_config.cc + src/cpp/common/version_cc.cc + src/cpp/server/async_generic_service.cc + src/cpp/server/channel_argument_option.cc + src/cpp/server/create_default_thread_pool.cc + src/cpp/server/dynamic_thread_pool.cc + src/cpp/server/external_connection_acceptor_impl.cc + src/cpp/server/health/default_health_check_service.cc + src/cpp/server/health/health_check_service.cc + src/cpp/server/health/health_check_service_server_builder_option.cc + src/cpp/server/insecure_server_credentials.cc + src/cpp/server/orca/call_metric_recorder.cc + src/cpp/server/secure_server_credentials.cc + src/cpp/server/server_builder.cc + src/cpp/server/server_callback.cc + src/cpp/server/server_cc.cc + src/cpp/server/server_context.cc + src/cpp/server/server_credentials.cc + src/cpp/server/server_posix.cc + src/cpp/server/xds_server_credentials.cc + src/cpp/thread_manager/thread_manager.cc + src/cpp/util/byte_buffer_cc.cc + src/cpp/util/status.cc + src/cpp/util/string_ref.cc + src/cpp/util/time_cc.cc +) + +END() + +RECURSE( + grpc++_reflection + grpcpp_channelz + src/compiler/grpc_cpp_plugin + src/compiler/grpc_plugin_support + src/compiler/grpc_python_plugin + src/proto/grpc/channelz + src/proto/grpc/core + src/proto/grpc/health/v1 + src/proto/grpc/reflection/v1alpha + src/proto/grpc/status + third_party/address_sorting + third_party/upb +) diff --git a/contrib/libs/hdr_histogram/ya.make b/contrib/libs/hdr_histogram/ya.make new file mode 100644 index 00000000000..a7087eac4ed --- /dev/null +++ b/contrib/libs/hdr_histogram/ya.make @@ -0,0 +1,33 @@ +LIBRARY() + +LICENSE( + BSD-2-Clause AND + CC0-1.0 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.9.5) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +ADDINCL( + contrib/libs/hdr_histogram/src +) + +SRCS( + src/hdr_encoding.c + src/hdr_interval_recorder.c + src/hdr_histogram.c + src/hdr_writer_reader_phaser.c + src/hdr_time.c + src/hdr_thread.c +) + +PEERDIR( + contrib/libs/zlib +) + +END() diff --git a/contrib/libs/highwayhash/arch/avx2/ya.make b/contrib/libs/highwayhash/arch/avx2/ya.make new file mode 100644 index 00000000000..88ba9710c36 --- /dev/null +++ b/contrib/libs/highwayhash/arch/avx2/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +ADDINCL(contrib/libs/highwayhash) + +SRCDIR(contrib/libs/highwayhash/highwayhash) + +CFLAGS(-mavx2) + +NO_COMPILER_WARNINGS() + +SRCS( + sip_tree_hash.cc + hh_avx2.cc +) + +END() diff --git a/contrib/libs/highwayhash/arch/sse41/ya.make b/contrib/libs/highwayhash/arch/sse41/ya.make new file mode 100644 index 00000000000..639c1f7de56 --- /dev/null +++ b/contrib/libs/highwayhash/arch/sse41/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +ADDINCL(contrib/libs/highwayhash) + +SRCDIR(contrib/libs/highwayhash/highwayhash) + +CFLAGS(-msse4.1) + +NO_COMPILER_WARNINGS() + +SRCS( + hh_sse41.cc +) + +END() diff --git a/contrib/libs/highwayhash/ya.make b/contrib/libs/highwayhash/ya.make new file mode 100644 index 00000000000..09bb380f7f7 --- /dev/null +++ b/contrib/libs/highwayhash/ya.make @@ -0,0 +1,44 @@ +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2017-05-08-2b666ae078292b01024453d01480f3b362a2a012) + +NO_COMPILER_WARNINGS() + +ADDINCL(GLOBAL contrib/libs/highwayhash) + +SRCDIR(contrib/libs/highwayhash/highwayhash) + +SRCS( + # Dispatcher + arch_specific.cc + instruction_sets.cc + nanobenchmark.cc + os_specific.cc + # SipHash + sip_hash.cc + scalar_sip_tree_hash.cc + # sip_tree_hash.cc with AVX2 if available + # HighwayHash + hh_portable.cc + # hh_avx2.cc with AVX2 + # hh_sse41.cc with SSE4.1 + # Library + c_bindings.cc +) + +IF (ARCH_X86_64) + PEERDIR( + contrib/libs/highwayhash/arch/avx2 + contrib/libs/highwayhash/arch/sse41 + ) +ELSE() + SRCS( + sip_tree_hash.cc + ) +ENDIF() + +END() diff --git a/contrib/libs/hyperscan/runtime_avx2/ya.make b/contrib/libs/hyperscan/runtime_avx2/ya.make new file mode 100644 index 00000000000..e6a14b8fff5 --- /dev/null +++ b/contrib/libs/hyperscan/runtime_avx2/ya.make @@ -0,0 +1,491 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + contrib/libs/hyperscan + contrib/libs/hyperscan/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + ${SSE41_CFLAGS} + -DHAVE_SSE41 + ${SSE42_CFLAGS} + -DHAVE_SSE42 + ${POPCNT_CFLAGS} + -DHAVE_POPCOUNT_INSTR + ${AVX_CFLAGS} + -DHAVE_AVX + ${AVX2_CFLAGS} + -DHAVE_AVX2 + -DCrc32c_ComputeBuf=avx2_Crc32c_ComputeBuf + -DblockInitSufPQ=avx2_blockInitSufPQ + -Dcompress_stream=avx2_compress_stream + -Dcpuid_flags=avx2_cpuid_flags + -Dcpuid_tune=avx2_cpuid_tune + -DdbIsValid=avx2_dbIsValid + -DdoAccel128=avx2_doAccel128 + -DdoAccel256=avx2_doAccel256 + -DdoAccel32=avx2_doAccel32 + -DdoAccel384=avx2_doAccel384 + -DdoAccel512=avx2_doAccel512 + -DdoAccel64=avx2_doAccel64 + -Dexpand_stream=avx2_expand_stream + -DfdrExec=avx2_fdrExec + -DfdrExecStreaming=avx2_fdrExecStreaming + -Dfdr_exec_fat_teddy_msks1=avx2_fdr_exec_fat_teddy_msks1 + -Dfdr_exec_fat_teddy_msks1_pck=avx2_fdr_exec_fat_teddy_msks1_pck + -Dfdr_exec_fat_teddy_msks2=avx2_fdr_exec_fat_teddy_msks2 + -Dfdr_exec_fat_teddy_msks2_pck=avx2_fdr_exec_fat_teddy_msks2_pck + -Dfdr_exec_fat_teddy_msks3=avx2_fdr_exec_fat_teddy_msks3 + -Dfdr_exec_fat_teddy_msks3_pck=avx2_fdr_exec_fat_teddy_msks3_pck + -Dfdr_exec_fat_teddy_msks4=avx2_fdr_exec_fat_teddy_msks4 + -Dfdr_exec_fat_teddy_msks4_pck=avx2_fdr_exec_fat_teddy_msks4_pck + -Dfdr_exec_teddy_msks1=avx2_fdr_exec_teddy_msks1 + -Dfdr_exec_teddy_msks1_pck=avx2_fdr_exec_teddy_msks1_pck + -Dfdr_exec_teddy_msks2=avx2_fdr_exec_teddy_msks2 + -Dfdr_exec_teddy_msks2_pck=avx2_fdr_exec_teddy_msks2_pck + -Dfdr_exec_teddy_msks3=avx2_fdr_exec_teddy_msks3 + -Dfdr_exec_teddy_msks3_pck=avx2_fdr_exec_teddy_msks3_pck + -Dfdr_exec_teddy_msks4=avx2_fdr_exec_teddy_msks4 + -Dfdr_exec_teddy_msks4_pck=avx2_fdr_exec_teddy_msks4_pck + -DflushQueuedLiterals_i=avx2_flushQueuedLiterals_i + -DflushStoredSomMatches_i=avx2_flushStoredSomMatches_i + -DhandleSomExternal=avx2_handleSomExternal + -DhandleSomInternal=avx2_handleSomInternal + -Dhs_alloc_scratch=avx2_hs_alloc_scratch + -Dhs_clone_scratch=avx2_hs_clone_scratch + -Dhs_close_stream=avx2_hs_close_stream + -Dhs_compress_stream=avx2_hs_compress_stream + -Dhs_copy_stream=avx2_hs_copy_stream + -Dhs_database_alloc=avx2_hs_database_alloc + -Dhs_database_free=avx2_hs_database_free + -Dhs_database_info=avx2_hs_database_info + -Dhs_database_size=avx2_hs_database_size + -Dhs_deserialize_database=avx2_hs_deserialize_database + -Dhs_deserialize_database_at=avx2_hs_deserialize_database_at + -Dhs_expand_stream=avx2_hs_expand_stream + -Dhs_free_database=avx2_hs_free_database + -Dhs_free_scratch=avx2_hs_free_scratch + -Dhs_misc_alloc=avx2_hs_misc_alloc + -Dhs_misc_free=avx2_hs_misc_free + -Dhs_open_stream=avx2_hs_open_stream + -Dhs_reset_and_copy_stream=avx2_hs_reset_and_copy_stream + -Dhs_reset_and_expand_stream=avx2_hs_reset_and_expand_stream + -Dhs_reset_stream=avx2_hs_reset_stream + -Dhs_scan=avx2_hs_scan + -Dhs_scan_stream=avx2_hs_scan_stream + -Dhs_scan_vector=avx2_hs_scan_vector + -Dhs_scratch_alloc=avx2_hs_scratch_alloc + -Dhs_scratch_free=avx2_hs_scratch_free + -Dhs_scratch_size=avx2_hs_scratch_size + -Dhs_serialize_database=avx2_hs_serialize_database + -Dhs_serialized_database_info=avx2_hs_serialized_database_info + -Dhs_serialized_database_size=avx2_hs_serialized_database_size + -Dhs_set_allocator=avx2_hs_set_allocator + -Dhs_set_database_allocator=avx2_hs_set_database_allocator + -Dhs_set_misc_allocator=avx2_hs_set_misc_allocator + -Dhs_set_scratch_allocator=avx2_hs_set_scratch_allocator + -Dhs_set_stream_allocator=avx2_hs_set_stream_allocator + -Dhs_stream_alloc=avx2_hs_stream_alloc + -Dhs_stream_free=avx2_hs_stream_free + -Dhs_stream_size=avx2_hs_stream_size + -Dhs_valid_platform=avx2_hs_valid_platform + -Dhs_version=avx2_hs_version + -DhwlmExec=avx2_hwlmExec + -DhwlmExecStreaming=avx2_hwlmExecStreaming + -DloadSomFromStream=avx2_loadSomFromStream + -Dloadcompressed128=avx2_loadcompressed128 + -Dloadcompressed256=avx2_loadcompressed256 + -Dloadcompressed32=avx2_loadcompressed32 + -Dloadcompressed384=avx2_loadcompressed384 + -Dloadcompressed512=avx2_loadcompressed512 + -Dloadcompressed64=avx2_loadcompressed64 + -Dmcsheng_pext_mask=avx2_mcsheng_pext_mask + -Dmm_mask_mask=avx2_mm_mask_mask + -Dmm_shuffle_end=avx2_mm_shuffle_end + -Dmmbit_keyshift_lut=avx2_mmbit_keyshift_lut + -Dmmbit_maxlevel_direct_lut=avx2_mmbit_maxlevel_direct_lut + -Dmmbit_maxlevel_from_keyshift_lut=avx2_mmbit_maxlevel_from_keyshift_lut + -Dmmbit_root_offset_from_level=avx2_mmbit_root_offset_from_level + -Dmmbit_zero_to_lut=avx2_mmbit_zero_to_lut + -DnfaBlockExecReverse=avx2_nfaBlockExecReverse + -DnfaCheckFinalState=avx2_nfaCheckFinalState + -DnfaExecCastle_Q=avx2_nfaExecCastle_Q + -DnfaExecCastle_Q2=avx2_nfaExecCastle_Q2 + -DnfaExecCastle_QR=avx2_nfaExecCastle_QR + -DnfaExecCastle_expandState=avx2_nfaExecCastle_expandState + -DnfaExecCastle_inAccept=avx2_nfaExecCastle_inAccept + -DnfaExecCastle_inAnyAccept=avx2_nfaExecCastle_inAnyAccept + -DnfaExecCastle_initCompressedState=avx2_nfaExecCastle_initCompressedState + -DnfaExecCastle_queueCompressState=avx2_nfaExecCastle_queueCompressState + -DnfaExecCastle_queueInitState=avx2_nfaExecCastle_queueInitState + -DnfaExecCastle_reportCurrent=avx2_nfaExecCastle_reportCurrent + -DnfaExecGough16_Q=avx2_nfaExecGough16_Q + -DnfaExecGough16_Q2=avx2_nfaExecGough16_Q2 + -DnfaExecGough16_QR=avx2_nfaExecGough16_QR + -DnfaExecGough16_expandState=avx2_nfaExecGough16_expandState + -DnfaExecGough16_inAccept=avx2_nfaExecGough16_inAccept + -DnfaExecGough16_inAnyAccept=avx2_nfaExecGough16_inAnyAccept + -DnfaExecGough16_initCompressedState=avx2_nfaExecGough16_initCompressedState + -DnfaExecGough16_queueCompressState=avx2_nfaExecGough16_queueCompressState + -DnfaExecGough16_queueInitState=avx2_nfaExecGough16_queueInitState + -DnfaExecGough16_reportCurrent=avx2_nfaExecGough16_reportCurrent + -DnfaExecGough16_testEOD=avx2_nfaExecGough16_testEOD + -DnfaExecGough8_Q=avx2_nfaExecGough8_Q + -DnfaExecGough8_Q2=avx2_nfaExecGough8_Q2 + -DnfaExecGough8_QR=avx2_nfaExecGough8_QR + -DnfaExecGough8_expandState=avx2_nfaExecGough8_expandState + -DnfaExecGough8_inAccept=avx2_nfaExecGough8_inAccept + -DnfaExecGough8_inAnyAccept=avx2_nfaExecGough8_inAnyAccept + -DnfaExecGough8_initCompressedState=avx2_nfaExecGough8_initCompressedState + -DnfaExecGough8_queueCompressState=avx2_nfaExecGough8_queueCompressState + -DnfaExecGough8_queueInitState=avx2_nfaExecGough8_queueInitState + -DnfaExecGough8_reportCurrent=avx2_nfaExecGough8_reportCurrent + -DnfaExecGough8_testEOD=avx2_nfaExecGough8_testEOD + -DnfaExecLbrDot_Q=avx2_nfaExecLbrDot_Q + -DnfaExecLbrDot_Q2=avx2_nfaExecLbrDot_Q2 + -DnfaExecLbrDot_QR=avx2_nfaExecLbrDot_QR + -DnfaExecLbrDot_expandState=avx2_nfaExecLbrDot_expandState + -DnfaExecLbrDot_inAccept=avx2_nfaExecLbrDot_inAccept + -DnfaExecLbrDot_inAnyAccept=avx2_nfaExecLbrDot_inAnyAccept + -DnfaExecLbrDot_initCompressedState=avx2_nfaExecLbrDot_initCompressedState + -DnfaExecLbrDot_queueCompressState=avx2_nfaExecLbrDot_queueCompressState + -DnfaExecLbrDot_queueInitState=avx2_nfaExecLbrDot_queueInitState + -DnfaExecLbrDot_reportCurrent=avx2_nfaExecLbrDot_reportCurrent + -DnfaExecLbrNVerm_Q=avx2_nfaExecLbrNVerm_Q + -DnfaExecLbrNVerm_Q2=avx2_nfaExecLbrNVerm_Q2 + -DnfaExecLbrNVerm_QR=avx2_nfaExecLbrNVerm_QR + -DnfaExecLbrNVerm_expandState=avx2_nfaExecLbrNVerm_expandState + -DnfaExecLbrNVerm_inAccept=avx2_nfaExecLbrNVerm_inAccept + -DnfaExecLbrNVerm_inAnyAccept=avx2_nfaExecLbrNVerm_inAnyAccept + -DnfaExecLbrNVerm_initCompressedState=avx2_nfaExecLbrNVerm_initCompressedState + -DnfaExecLbrNVerm_queueCompressState=avx2_nfaExecLbrNVerm_queueCompressState + -DnfaExecLbrNVerm_queueInitState=avx2_nfaExecLbrNVerm_queueInitState + -DnfaExecLbrNVerm_reportCurrent=avx2_nfaExecLbrNVerm_reportCurrent + -DnfaExecLbrShuf_Q=avx2_nfaExecLbrShuf_Q + -DnfaExecLbrShuf_Q2=avx2_nfaExecLbrShuf_Q2 + -DnfaExecLbrShuf_QR=avx2_nfaExecLbrShuf_QR + -DnfaExecLbrShuf_expandState=avx2_nfaExecLbrShuf_expandState + -DnfaExecLbrShuf_inAccept=avx2_nfaExecLbrShuf_inAccept + -DnfaExecLbrShuf_inAnyAccept=avx2_nfaExecLbrShuf_inAnyAccept + -DnfaExecLbrShuf_initCompressedState=avx2_nfaExecLbrShuf_initCompressedState + -DnfaExecLbrShuf_queueCompressState=avx2_nfaExecLbrShuf_queueCompressState + -DnfaExecLbrShuf_queueInitState=avx2_nfaExecLbrShuf_queueInitState + -DnfaExecLbrShuf_reportCurrent=avx2_nfaExecLbrShuf_reportCurrent + -DnfaExecLbrTruf_Q=avx2_nfaExecLbrTruf_Q + -DnfaExecLbrTruf_Q2=avx2_nfaExecLbrTruf_Q2 + -DnfaExecLbrTruf_QR=avx2_nfaExecLbrTruf_QR + -DnfaExecLbrTruf_expandState=avx2_nfaExecLbrTruf_expandState + -DnfaExecLbrTruf_inAccept=avx2_nfaExecLbrTruf_inAccept + -DnfaExecLbrTruf_inAnyAccept=avx2_nfaExecLbrTruf_inAnyAccept + -DnfaExecLbrTruf_initCompressedState=avx2_nfaExecLbrTruf_initCompressedState + -DnfaExecLbrTruf_queueCompressState=avx2_nfaExecLbrTruf_queueCompressState + -DnfaExecLbrTruf_queueInitState=avx2_nfaExecLbrTruf_queueInitState + -DnfaExecLbrTruf_reportCurrent=avx2_nfaExecLbrTruf_reportCurrent + -DnfaExecLbrVerm_Q=avx2_nfaExecLbrVerm_Q + -DnfaExecLbrVerm_Q2=avx2_nfaExecLbrVerm_Q2 + -DnfaExecLbrVerm_QR=avx2_nfaExecLbrVerm_QR + -DnfaExecLbrVerm_expandState=avx2_nfaExecLbrVerm_expandState + -DnfaExecLbrVerm_inAccept=avx2_nfaExecLbrVerm_inAccept + -DnfaExecLbrVerm_inAnyAccept=avx2_nfaExecLbrVerm_inAnyAccept + -DnfaExecLbrVerm_initCompressedState=avx2_nfaExecLbrVerm_initCompressedState + -DnfaExecLbrVerm_queueCompressState=avx2_nfaExecLbrVerm_queueCompressState + -DnfaExecLbrVerm_queueInitState=avx2_nfaExecLbrVerm_queueInitState + -DnfaExecLbrVerm_reportCurrent=avx2_nfaExecLbrVerm_reportCurrent + -DnfaExecLimEx128_B_Reverse=avx2_nfaExecLimEx128_B_Reverse + -DnfaExecLimEx128_Q=avx2_nfaExecLimEx128_Q + -DnfaExecLimEx128_Q2=avx2_nfaExecLimEx128_Q2 + -DnfaExecLimEx128_QR=avx2_nfaExecLimEx128_QR + -DnfaExecLimEx128_expandState=avx2_nfaExecLimEx128_expandState + -DnfaExecLimEx128_inAccept=avx2_nfaExecLimEx128_inAccept + -DnfaExecLimEx128_inAnyAccept=avx2_nfaExecLimEx128_inAnyAccept + -DnfaExecLimEx128_initCompressedState=avx2_nfaExecLimEx128_initCompressedState + -DnfaExecLimEx128_queueCompressState=avx2_nfaExecLimEx128_queueCompressState + -DnfaExecLimEx128_queueInitState=avx2_nfaExecLimEx128_queueInitState + -DnfaExecLimEx128_reportCurrent=avx2_nfaExecLimEx128_reportCurrent + -DnfaExecLimEx128_testEOD=avx2_nfaExecLimEx128_testEOD + -DnfaExecLimEx128_zombie_status=avx2_nfaExecLimEx128_zombie_status + -DnfaExecLimEx256_B_Reverse=avx2_nfaExecLimEx256_B_Reverse + -DnfaExecLimEx256_Q=avx2_nfaExecLimEx256_Q + -DnfaExecLimEx256_Q2=avx2_nfaExecLimEx256_Q2 + -DnfaExecLimEx256_QR=avx2_nfaExecLimEx256_QR + -DnfaExecLimEx256_expandState=avx2_nfaExecLimEx256_expandState + -DnfaExecLimEx256_inAccept=avx2_nfaExecLimEx256_inAccept + -DnfaExecLimEx256_inAnyAccept=avx2_nfaExecLimEx256_inAnyAccept + -DnfaExecLimEx256_initCompressedState=avx2_nfaExecLimEx256_initCompressedState + -DnfaExecLimEx256_queueCompressState=avx2_nfaExecLimEx256_queueCompressState + -DnfaExecLimEx256_queueInitState=avx2_nfaExecLimEx256_queueInitState + -DnfaExecLimEx256_reportCurrent=avx2_nfaExecLimEx256_reportCurrent + -DnfaExecLimEx256_testEOD=avx2_nfaExecLimEx256_testEOD + -DnfaExecLimEx256_zombie_status=avx2_nfaExecLimEx256_zombie_status + -DnfaExecLimEx32_B_Reverse=avx2_nfaExecLimEx32_B_Reverse + -DnfaExecLimEx32_Q=avx2_nfaExecLimEx32_Q + -DnfaExecLimEx32_Q2=avx2_nfaExecLimEx32_Q2 + -DnfaExecLimEx32_QR=avx2_nfaExecLimEx32_QR + -DnfaExecLimEx32_expandState=avx2_nfaExecLimEx32_expandState + -DnfaExecLimEx32_inAccept=avx2_nfaExecLimEx32_inAccept + -DnfaExecLimEx32_inAnyAccept=avx2_nfaExecLimEx32_inAnyAccept + -DnfaExecLimEx32_initCompressedState=avx2_nfaExecLimEx32_initCompressedState + -DnfaExecLimEx32_queueCompressState=avx2_nfaExecLimEx32_queueCompressState + -DnfaExecLimEx32_queueInitState=avx2_nfaExecLimEx32_queueInitState + -DnfaExecLimEx32_reportCurrent=avx2_nfaExecLimEx32_reportCurrent + -DnfaExecLimEx32_testEOD=avx2_nfaExecLimEx32_testEOD + -DnfaExecLimEx32_zombie_status=avx2_nfaExecLimEx32_zombie_status + -DnfaExecLimEx384_B_Reverse=avx2_nfaExecLimEx384_B_Reverse + -DnfaExecLimEx384_Q=avx2_nfaExecLimEx384_Q + -DnfaExecLimEx384_Q2=avx2_nfaExecLimEx384_Q2 + -DnfaExecLimEx384_QR=avx2_nfaExecLimEx384_QR + -DnfaExecLimEx384_expandState=avx2_nfaExecLimEx384_expandState + -DnfaExecLimEx384_inAccept=avx2_nfaExecLimEx384_inAccept + -DnfaExecLimEx384_inAnyAccept=avx2_nfaExecLimEx384_inAnyAccept + -DnfaExecLimEx384_initCompressedState=avx2_nfaExecLimEx384_initCompressedState + -DnfaExecLimEx384_queueCompressState=avx2_nfaExecLimEx384_queueCompressState + -DnfaExecLimEx384_queueInitState=avx2_nfaExecLimEx384_queueInitState + -DnfaExecLimEx384_reportCurrent=avx2_nfaExecLimEx384_reportCurrent + -DnfaExecLimEx384_testEOD=avx2_nfaExecLimEx384_testEOD + -DnfaExecLimEx384_zombie_status=avx2_nfaExecLimEx384_zombie_status + -DnfaExecLimEx512_B_Reverse=avx2_nfaExecLimEx512_B_Reverse + -DnfaExecLimEx512_Q=avx2_nfaExecLimEx512_Q + -DnfaExecLimEx512_Q2=avx2_nfaExecLimEx512_Q2 + -DnfaExecLimEx512_QR=avx2_nfaExecLimEx512_QR + -DnfaExecLimEx512_expandState=avx2_nfaExecLimEx512_expandState + -DnfaExecLimEx512_inAccept=avx2_nfaExecLimEx512_inAccept + -DnfaExecLimEx512_inAnyAccept=avx2_nfaExecLimEx512_inAnyAccept + -DnfaExecLimEx512_initCompressedState=avx2_nfaExecLimEx512_initCompressedState + -DnfaExecLimEx512_queueCompressState=avx2_nfaExecLimEx512_queueCompressState + -DnfaExecLimEx512_queueInitState=avx2_nfaExecLimEx512_queueInitState + -DnfaExecLimEx512_reportCurrent=avx2_nfaExecLimEx512_reportCurrent + -DnfaExecLimEx512_testEOD=avx2_nfaExecLimEx512_testEOD + -DnfaExecLimEx512_zombie_status=avx2_nfaExecLimEx512_zombie_status + -DnfaExecLimEx64_B_Reverse=avx2_nfaExecLimEx64_B_Reverse + -DnfaExecLimEx64_Q=avx2_nfaExecLimEx64_Q + -DnfaExecLimEx64_Q2=avx2_nfaExecLimEx64_Q2 + -DnfaExecLimEx64_QR=avx2_nfaExecLimEx64_QR + -DnfaExecLimEx64_expandState=avx2_nfaExecLimEx64_expandState + -DnfaExecLimEx64_inAccept=avx2_nfaExecLimEx64_inAccept + -DnfaExecLimEx64_inAnyAccept=avx2_nfaExecLimEx64_inAnyAccept + -DnfaExecLimEx64_initCompressedState=avx2_nfaExecLimEx64_initCompressedState + -DnfaExecLimEx64_queueCompressState=avx2_nfaExecLimEx64_queueCompressState + -DnfaExecLimEx64_queueInitState=avx2_nfaExecLimEx64_queueInitState + -DnfaExecLimEx64_reportCurrent=avx2_nfaExecLimEx64_reportCurrent + -DnfaExecLimEx64_testEOD=avx2_nfaExecLimEx64_testEOD + -DnfaExecLimEx64_zombie_status=avx2_nfaExecLimEx64_zombie_status + -DnfaExecMcClellan16_B=avx2_nfaExecMcClellan16_B + -DnfaExecMcClellan16_Q=avx2_nfaExecMcClellan16_Q + -DnfaExecMcClellan16_Q2=avx2_nfaExecMcClellan16_Q2 + -DnfaExecMcClellan16_QR=avx2_nfaExecMcClellan16_QR + -DnfaExecMcClellan16_SimpStream=avx2_nfaExecMcClellan16_SimpStream + -DnfaExecMcClellan16_expandState=avx2_nfaExecMcClellan16_expandState + -DnfaExecMcClellan16_inAccept=avx2_nfaExecMcClellan16_inAccept + -DnfaExecMcClellan16_inAnyAccept=avx2_nfaExecMcClellan16_inAnyAccept + -DnfaExecMcClellan16_initCompressedState=avx2_nfaExecMcClellan16_initCompressedState + -DnfaExecMcClellan16_queueCompressState=avx2_nfaExecMcClellan16_queueCompressState + -DnfaExecMcClellan16_queueInitState=avx2_nfaExecMcClellan16_queueInitState + -DnfaExecMcClellan16_reportCurrent=avx2_nfaExecMcClellan16_reportCurrent + -DnfaExecMcClellan16_testEOD=avx2_nfaExecMcClellan16_testEOD + -DnfaExecMcClellan8_B=avx2_nfaExecMcClellan8_B + -DnfaExecMcClellan8_Q=avx2_nfaExecMcClellan8_Q + -DnfaExecMcClellan8_Q2=avx2_nfaExecMcClellan8_Q2 + -DnfaExecMcClellan8_QR=avx2_nfaExecMcClellan8_QR + -DnfaExecMcClellan8_SimpStream=avx2_nfaExecMcClellan8_SimpStream + -DnfaExecMcClellan8_expandState=avx2_nfaExecMcClellan8_expandState + -DnfaExecMcClellan8_inAccept=avx2_nfaExecMcClellan8_inAccept + -DnfaExecMcClellan8_inAnyAccept=avx2_nfaExecMcClellan8_inAnyAccept + -DnfaExecMcClellan8_initCompressedState=avx2_nfaExecMcClellan8_initCompressedState + -DnfaExecMcClellan8_queueCompressState=avx2_nfaExecMcClellan8_queueCompressState + -DnfaExecMcClellan8_queueInitState=avx2_nfaExecMcClellan8_queueInitState + -DnfaExecMcClellan8_reportCurrent=avx2_nfaExecMcClellan8_reportCurrent + -DnfaExecMcClellan8_testEOD=avx2_nfaExecMcClellan8_testEOD + -DnfaExecMcSheng16_Q=avx2_nfaExecMcSheng16_Q + -DnfaExecMcSheng16_Q2=avx2_nfaExecMcSheng16_Q2 + -DnfaExecMcSheng16_QR=avx2_nfaExecMcSheng16_QR + -DnfaExecMcSheng16_expandState=avx2_nfaExecMcSheng16_expandState + -DnfaExecMcSheng16_inAccept=avx2_nfaExecMcSheng16_inAccept + -DnfaExecMcSheng16_inAnyAccept=avx2_nfaExecMcSheng16_inAnyAccept + -DnfaExecMcSheng16_initCompressedState=avx2_nfaExecMcSheng16_initCompressedState + -DnfaExecMcSheng16_queueCompressState=avx2_nfaExecMcSheng16_queueCompressState + -DnfaExecMcSheng16_queueInitState=avx2_nfaExecMcSheng16_queueInitState + -DnfaExecMcSheng16_reportCurrent=avx2_nfaExecMcSheng16_reportCurrent + -DnfaExecMcSheng16_testEOD=avx2_nfaExecMcSheng16_testEOD + -DnfaExecMcSheng8_Q=avx2_nfaExecMcSheng8_Q + -DnfaExecMcSheng8_Q2=avx2_nfaExecMcSheng8_Q2 + -DnfaExecMcSheng8_QR=avx2_nfaExecMcSheng8_QR + -DnfaExecMcSheng8_expandState=avx2_nfaExecMcSheng8_expandState + -DnfaExecMcSheng8_inAccept=avx2_nfaExecMcSheng8_inAccept + -DnfaExecMcSheng8_inAnyAccept=avx2_nfaExecMcSheng8_inAnyAccept + -DnfaExecMcSheng8_initCompressedState=avx2_nfaExecMcSheng8_initCompressedState + -DnfaExecMcSheng8_queueCompressState=avx2_nfaExecMcSheng8_queueCompressState + -DnfaExecMcSheng8_queueInitState=avx2_nfaExecMcSheng8_queueInitState + -DnfaExecMcSheng8_reportCurrent=avx2_nfaExecMcSheng8_reportCurrent + -DnfaExecMcSheng8_testEOD=avx2_nfaExecMcSheng8_testEOD + -DnfaExecMpv_Q=avx2_nfaExecMpv_Q + -DnfaExecMpv_QueueExecRaw=avx2_nfaExecMpv_QueueExecRaw + -DnfaExecMpv_expandState=avx2_nfaExecMpv_expandState + -DnfaExecMpv_initCompressedState=avx2_nfaExecMpv_initCompressedState + -DnfaExecMpv_queueCompressState=avx2_nfaExecMpv_queueCompressState + -DnfaExecMpv_queueInitState=avx2_nfaExecMpv_queueInitState + -DnfaExecMpv_reportCurrent=avx2_nfaExecMpv_reportCurrent + -DnfaExecSheng_B=avx2_nfaExecSheng_B + -DnfaExecSheng_Q=avx2_nfaExecSheng_Q + -DnfaExecSheng_Q2=avx2_nfaExecSheng_Q2 + -DnfaExecSheng_QR=avx2_nfaExecSheng_QR + -DnfaExecSheng_expandState=avx2_nfaExecSheng_expandState + -DnfaExecSheng_inAccept=avx2_nfaExecSheng_inAccept + -DnfaExecSheng_inAnyAccept=avx2_nfaExecSheng_inAnyAccept + -DnfaExecSheng_initCompressedState=avx2_nfaExecSheng_initCompressedState + -DnfaExecSheng_queueCompressState=avx2_nfaExecSheng_queueCompressState + -DnfaExecSheng_queueInitState=avx2_nfaExecSheng_queueInitState + -DnfaExecSheng_reportCurrent=avx2_nfaExecSheng_reportCurrent + -DnfaExecSheng_testEOD=avx2_nfaExecSheng_testEOD + -DnfaExecTamarama_Q=avx2_nfaExecTamarama_Q + -DnfaExecTamarama_Q2=avx2_nfaExecTamarama_Q2 + -DnfaExecTamarama_QR=avx2_nfaExecTamarama_QR + -DnfaExecTamarama_expandState=avx2_nfaExecTamarama_expandState + -DnfaExecTamarama_inAccept=avx2_nfaExecTamarama_inAccept + -DnfaExecTamarama_inAnyAccept=avx2_nfaExecTamarama_inAnyAccept + -DnfaExecTamarama_queueCompressState=avx2_nfaExecTamarama_queueCompressState + -DnfaExecTamarama_queueInitState=avx2_nfaExecTamarama_queueInitState + -DnfaExecTamarama_reportCurrent=avx2_nfaExecTamarama_reportCurrent + -DnfaExecTamarama_testEOD=avx2_nfaExecTamarama_testEOD + -DnfaExecTamarama_zombie_status=avx2_nfaExecTamarama_zombie_status + -DnfaExpandState=avx2_nfaExpandState + -DnfaGetZombieStatus=avx2_nfaGetZombieStatus + -DnfaInAcceptState=avx2_nfaInAcceptState + -DnfaInAnyAcceptState=avx2_nfaInAnyAcceptState + -DnfaInitCompressedState=avx2_nfaInitCompressedState + -DnfaQueueCompressState=avx2_nfaQueueCompressState + -DnfaQueueExec=avx2_nfaQueueExec + -DnfaQueueExec2_raw=avx2_nfaQueueExec2_raw + -DnfaQueueExecRose=avx2_nfaQueueExecRose + -DnfaQueueExecToMatch=avx2_nfaQueueExecToMatch + -DnfaQueueExec_raw=avx2_nfaQueueExec_raw + -DnfaQueueInitState=avx2_nfaQueueInitState + -DnfaReportCurrentMatches=avx2_nfaReportCurrentMatches + -DnoodExec=avx2_noodExec + -DnoodExecStreaming=avx2_noodExecStreaming + -Dp_mask_arr=avx2_p_mask_arr + -Dp_mask_arr256=avx2_p_mask_arr256 + -DrepeatHasMatchBitmap=avx2_repeatHasMatchBitmap + -DrepeatHasMatchRange=avx2_repeatHasMatchRange + -DrepeatHasMatchRing=avx2_repeatHasMatchRing + -DrepeatHasMatchSparseOptimalP=avx2_repeatHasMatchSparseOptimalP + -DrepeatHasMatchTrailer=avx2_repeatHasMatchTrailer + -DrepeatLastTopBitmap=avx2_repeatLastTopBitmap + -DrepeatLastTopRange=avx2_repeatLastTopRange + -DrepeatLastTopRing=avx2_repeatLastTopRing + -DrepeatLastTopSparseOptimalP=avx2_repeatLastTopSparseOptimalP + -DrepeatLastTopTrailer=avx2_repeatLastTopTrailer + -DrepeatNextMatchBitmap=avx2_repeatNextMatchBitmap + -DrepeatNextMatchRange=avx2_repeatNextMatchRange + -DrepeatNextMatchRing=avx2_repeatNextMatchRing + -DrepeatNextMatchSparseOptimalP=avx2_repeatNextMatchSparseOptimalP + -DrepeatNextMatchTrailer=avx2_repeatNextMatchTrailer + -DrepeatPack=avx2_repeatPack + -DrepeatStoreBitmap=avx2_repeatStoreBitmap + -DrepeatStoreRange=avx2_repeatStoreRange + -DrepeatStoreRing=avx2_repeatStoreRing + -DrepeatStoreSparseOptimalP=avx2_repeatStoreSparseOptimalP + -DrepeatStoreTrailer=avx2_repeatStoreTrailer + -DrepeatUnpack=avx2_repeatUnpack + -DroseAnchoredCallback=avx2_roseAnchoredCallback + -DroseBlockExec=avx2_roseBlockExec + -DroseCallback=avx2_roseCallback + -DroseCatchUpAll=avx2_roseCatchUpAll + -DroseCatchUpMPV_i=avx2_roseCatchUpMPV_i + -DroseCatchUpSuf=avx2_roseCatchUpSuf + -DroseDelayRebuildCallback=avx2_roseDelayRebuildCallback + -DroseFloatingCallback=avx2_roseFloatingCallback + -DroseHandleChainMatch=avx2_roseHandleChainMatch + -DroseInitState=avx2_roseInitState + -DroseNfaAdaptor=avx2_roseNfaAdaptor + -DroseNfaEarliestSom=avx2_roseNfaEarliestSom + -DroseReportAdaptor=avx2_roseReportAdaptor + -DroseRunBoundaryProgram=avx2_roseRunBoundaryProgram + -DroseRunFlushCombProgram=avx2_roseRunFlushCombProgram + -DroseRunLastFlushCombProgram=avx2_roseRunLastFlushCombProgram + -DroseRunProgram=avx2_roseRunProgram + -DroseRunProgram_l=avx2_roseRunProgram_l + -DroseStreamEodExec=avx2_roseStreamEodExec + -DroseStreamExec=avx2_roseStreamExec + -DrshuftiExec=avx2_rshuftiExec + -DrtruffleExec=avx2_rtruffleExec + -Drun_accel=avx2_run_accel + -DsetSomFromSomAware=avx2_setSomFromSomAware + -DshuftiDoubleExec=avx2_shuftiDoubleExec + -DshuftiExec=avx2_shuftiExec + -Dsimd_onebit_masks=avx2_simd_onebit_masks + -Dsize_compress_stream=avx2_size_compress_stream + -DstoreSomToStream=avx2_storeSomToStream + -Dstorecompressed128=avx2_storecompressed128 + -Dstorecompressed256=avx2_storecompressed256 + -Dstorecompressed32=avx2_storecompressed32 + -Dstorecompressed384=avx2_storecompressed384 + -Dstorecompressed512=avx2_storecompressed512 + -Dstorecompressed64=avx2_storecompressed64 + -DstreamInitSufPQ=avx2_streamInitSufPQ + -DtruffleExec=avx2_truffleExec + -Dvbs_mask_data=avx2_vbs_mask_data +) + +SRCDIR(contrib/libs/hyperscan) + +SRCS( + src/alloc.c + src/crc32.c + src/database.c + src/fdr/fdr.c + src/fdr/teddy.c + src/fdr/teddy_avx2.c + src/hs_valid_platform.c + src/hs_version.c + src/hwlm/hwlm.c + src/hwlm/noodle_engine.c + src/nfa/accel.c + src/nfa/castle.c + src/nfa/gough.c + src/nfa/lbr.c + src/nfa/limex_64.c + src/nfa/limex_accel.c + src/nfa/limex_native.c + src/nfa/limex_simd128.c + src/nfa/limex_simd256.c + src/nfa/limex_simd384.c + src/nfa/limex_simd512.c + src/nfa/mcclellan.c + src/nfa/mcsheng.c + src/nfa/mcsheng_data.c + src/nfa/mpv.c + src/nfa/nfa_api_dispatch.c + src/nfa/repeat.c + src/nfa/sheng.c + src/nfa/shufti.c + src/nfa/tamarama.c + src/nfa/truffle.c + src/rose/block.c + src/rose/catchup.c + src/rose/init.c + src/rose/match.c + src/rose/program_runtime.c + src/rose/stream.c + src/runtime.c + src/scratch.c + src/som/som_runtime.c + src/som/som_stream.c + src/stream_compress.c + src/util/cpuid_flags.c + src/util/masked_move.c + src/util/multibit.c + src/util/simd_utils.c + src/util/state_compress.c +) + +END() diff --git a/contrib/libs/hyperscan/runtime_avx512/ya.make b/contrib/libs/hyperscan/runtime_avx512/ya.make new file mode 100644 index 00000000000..5d839da1ea8 --- /dev/null +++ b/contrib/libs/hyperscan/runtime_avx512/ya.make @@ -0,0 +1,493 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + contrib/libs/hyperscan + contrib/libs/hyperscan/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + ${SSE41_CFLAGS} + -DHAVE_SSE41 + ${SSE42_CFLAGS} + -DHAVE_SSE42 + -DHAVE_POPCOUNT_INSTR + ${POPCNT_CFLAGS} + ${AVX_CFLAGS} + -DHAVE_AVX + ${AVX2_CFLAGS} + -DHAVE_AVX2 + ${AVX512_CFLAGS} + -DHAVE_AVX512 + -DCrc32c_ComputeBuf=avx512_Crc32c_ComputeBuf + -DblockInitSufPQ=avx512_blockInitSufPQ + -Dcompress_stream=avx512_compress_stream + -Dcpuid_flags=avx512_cpuid_flags + -Dcpuid_tune=avx512_cpuid_tune + -DdbIsValid=avx512_dbIsValid + -DdoAccel128=avx512_doAccel128 + -DdoAccel256=avx512_doAccel256 + -DdoAccel32=avx512_doAccel32 + -DdoAccel384=avx512_doAccel384 + -DdoAccel512=avx512_doAccel512 + -DdoAccel64=avx512_doAccel64 + -Dexpand_stream=avx512_expand_stream + -DfdrExec=avx512_fdrExec + -DfdrExecStreaming=avx512_fdrExecStreaming + -Dfdr_exec_fat_teddy_msks1=avx512_fdr_exec_fat_teddy_msks1 + -Dfdr_exec_fat_teddy_msks1_pck=avx512_fdr_exec_fat_teddy_msks1_pck + -Dfdr_exec_fat_teddy_msks2=avx512_fdr_exec_fat_teddy_msks2 + -Dfdr_exec_fat_teddy_msks2_pck=avx512_fdr_exec_fat_teddy_msks2_pck + -Dfdr_exec_fat_teddy_msks3=avx512_fdr_exec_fat_teddy_msks3 + -Dfdr_exec_fat_teddy_msks3_pck=avx512_fdr_exec_fat_teddy_msks3_pck + -Dfdr_exec_fat_teddy_msks4=avx512_fdr_exec_fat_teddy_msks4 + -Dfdr_exec_fat_teddy_msks4_pck=avx512_fdr_exec_fat_teddy_msks4_pck + -Dfdr_exec_teddy_msks1=avx512_fdr_exec_teddy_msks1 + -Dfdr_exec_teddy_msks1_pck=avx512_fdr_exec_teddy_msks1_pck + -Dfdr_exec_teddy_msks2=avx512_fdr_exec_teddy_msks2 + -Dfdr_exec_teddy_msks2_pck=avx512_fdr_exec_teddy_msks2_pck + -Dfdr_exec_teddy_msks3=avx512_fdr_exec_teddy_msks3 + -Dfdr_exec_teddy_msks3_pck=avx512_fdr_exec_teddy_msks3_pck + -Dfdr_exec_teddy_msks4=avx512_fdr_exec_teddy_msks4 + -Dfdr_exec_teddy_msks4_pck=avx512_fdr_exec_teddy_msks4_pck + -DflushQueuedLiterals_i=avx512_flushQueuedLiterals_i + -DflushStoredSomMatches_i=avx512_flushStoredSomMatches_i + -DhandleSomExternal=avx512_handleSomExternal + -DhandleSomInternal=avx512_handleSomInternal + -Dhs_alloc_scratch=avx512_hs_alloc_scratch + -Dhs_clone_scratch=avx512_hs_clone_scratch + -Dhs_close_stream=avx512_hs_close_stream + -Dhs_compress_stream=avx512_hs_compress_stream + -Dhs_copy_stream=avx512_hs_copy_stream + -Dhs_database_alloc=avx512_hs_database_alloc + -Dhs_database_free=avx512_hs_database_free + -Dhs_database_info=avx512_hs_database_info + -Dhs_database_size=avx512_hs_database_size + -Dhs_deserialize_database=avx512_hs_deserialize_database + -Dhs_deserialize_database_at=avx512_hs_deserialize_database_at + -Dhs_expand_stream=avx512_hs_expand_stream + -Dhs_free_database=avx512_hs_free_database + -Dhs_free_scratch=avx512_hs_free_scratch + -Dhs_misc_alloc=avx512_hs_misc_alloc + -Dhs_misc_free=avx512_hs_misc_free + -Dhs_open_stream=avx512_hs_open_stream + -Dhs_reset_and_copy_stream=avx512_hs_reset_and_copy_stream + -Dhs_reset_and_expand_stream=avx512_hs_reset_and_expand_stream + -Dhs_reset_stream=avx512_hs_reset_stream + -Dhs_scan=avx512_hs_scan + -Dhs_scan_stream=avx512_hs_scan_stream + -Dhs_scan_vector=avx512_hs_scan_vector + -Dhs_scratch_alloc=avx512_hs_scratch_alloc + -Dhs_scratch_free=avx512_hs_scratch_free + -Dhs_scratch_size=avx512_hs_scratch_size + -Dhs_serialize_database=avx512_hs_serialize_database + -Dhs_serialized_database_info=avx512_hs_serialized_database_info + -Dhs_serialized_database_size=avx512_hs_serialized_database_size + -Dhs_set_allocator=avx512_hs_set_allocator + -Dhs_set_database_allocator=avx512_hs_set_database_allocator + -Dhs_set_misc_allocator=avx512_hs_set_misc_allocator + -Dhs_set_scratch_allocator=avx512_hs_set_scratch_allocator + -Dhs_set_stream_allocator=avx512_hs_set_stream_allocator + -Dhs_stream_alloc=avx512_hs_stream_alloc + -Dhs_stream_free=avx512_hs_stream_free + -Dhs_stream_size=avx512_hs_stream_size + -Dhs_valid_platform=avx512_hs_valid_platform + -Dhs_version=avx512_hs_version + -DhwlmExec=avx512_hwlmExec + -DhwlmExecStreaming=avx512_hwlmExecStreaming + -DloadSomFromStream=avx512_loadSomFromStream + -Dloadcompressed128=avx512_loadcompressed128 + -Dloadcompressed256=avx512_loadcompressed256 + -Dloadcompressed32=avx512_loadcompressed32 + -Dloadcompressed384=avx512_loadcompressed384 + -Dloadcompressed512=avx512_loadcompressed512 + -Dloadcompressed64=avx512_loadcompressed64 + -Dmcsheng_pext_mask=avx512_mcsheng_pext_mask + -Dmm_mask_mask=avx512_mm_mask_mask + -Dmm_shuffle_end=avx512_mm_shuffle_end + -Dmmbit_keyshift_lut=avx512_mmbit_keyshift_lut + -Dmmbit_maxlevel_direct_lut=avx512_mmbit_maxlevel_direct_lut + -Dmmbit_maxlevel_from_keyshift_lut=avx512_mmbit_maxlevel_from_keyshift_lut + -Dmmbit_root_offset_from_level=avx512_mmbit_root_offset_from_level + -Dmmbit_zero_to_lut=avx512_mmbit_zero_to_lut + -DnfaBlockExecReverse=avx512_nfaBlockExecReverse + -DnfaCheckFinalState=avx512_nfaCheckFinalState + -DnfaExecCastle_Q=avx512_nfaExecCastle_Q + -DnfaExecCastle_Q2=avx512_nfaExecCastle_Q2 + -DnfaExecCastle_QR=avx512_nfaExecCastle_QR + -DnfaExecCastle_expandState=avx512_nfaExecCastle_expandState + -DnfaExecCastle_inAccept=avx512_nfaExecCastle_inAccept + -DnfaExecCastle_inAnyAccept=avx512_nfaExecCastle_inAnyAccept + -DnfaExecCastle_initCompressedState=avx512_nfaExecCastle_initCompressedState + -DnfaExecCastle_queueCompressState=avx512_nfaExecCastle_queueCompressState + -DnfaExecCastle_queueInitState=avx512_nfaExecCastle_queueInitState + -DnfaExecCastle_reportCurrent=avx512_nfaExecCastle_reportCurrent + -DnfaExecGough16_Q=avx512_nfaExecGough16_Q + -DnfaExecGough16_Q2=avx512_nfaExecGough16_Q2 + -DnfaExecGough16_QR=avx512_nfaExecGough16_QR + -DnfaExecGough16_expandState=avx512_nfaExecGough16_expandState + -DnfaExecGough16_inAccept=avx512_nfaExecGough16_inAccept + -DnfaExecGough16_inAnyAccept=avx512_nfaExecGough16_inAnyAccept + -DnfaExecGough16_initCompressedState=avx512_nfaExecGough16_initCompressedState + -DnfaExecGough16_queueCompressState=avx512_nfaExecGough16_queueCompressState + -DnfaExecGough16_queueInitState=avx512_nfaExecGough16_queueInitState + -DnfaExecGough16_reportCurrent=avx512_nfaExecGough16_reportCurrent + -DnfaExecGough16_testEOD=avx512_nfaExecGough16_testEOD + -DnfaExecGough8_Q=avx512_nfaExecGough8_Q + -DnfaExecGough8_Q2=avx512_nfaExecGough8_Q2 + -DnfaExecGough8_QR=avx512_nfaExecGough8_QR + -DnfaExecGough8_expandState=avx512_nfaExecGough8_expandState + -DnfaExecGough8_inAccept=avx512_nfaExecGough8_inAccept + -DnfaExecGough8_inAnyAccept=avx512_nfaExecGough8_inAnyAccept + -DnfaExecGough8_initCompressedState=avx512_nfaExecGough8_initCompressedState + -DnfaExecGough8_queueCompressState=avx512_nfaExecGough8_queueCompressState + -DnfaExecGough8_queueInitState=avx512_nfaExecGough8_queueInitState + -DnfaExecGough8_reportCurrent=avx512_nfaExecGough8_reportCurrent + -DnfaExecGough8_testEOD=avx512_nfaExecGough8_testEOD + -DnfaExecLbrDot_Q=avx512_nfaExecLbrDot_Q + -DnfaExecLbrDot_Q2=avx512_nfaExecLbrDot_Q2 + -DnfaExecLbrDot_QR=avx512_nfaExecLbrDot_QR + -DnfaExecLbrDot_expandState=avx512_nfaExecLbrDot_expandState + -DnfaExecLbrDot_inAccept=avx512_nfaExecLbrDot_inAccept + -DnfaExecLbrDot_inAnyAccept=avx512_nfaExecLbrDot_inAnyAccept + -DnfaExecLbrDot_initCompressedState=avx512_nfaExecLbrDot_initCompressedState + -DnfaExecLbrDot_queueCompressState=avx512_nfaExecLbrDot_queueCompressState + -DnfaExecLbrDot_queueInitState=avx512_nfaExecLbrDot_queueInitState + -DnfaExecLbrDot_reportCurrent=avx512_nfaExecLbrDot_reportCurrent + -DnfaExecLbrNVerm_Q=avx512_nfaExecLbrNVerm_Q + -DnfaExecLbrNVerm_Q2=avx512_nfaExecLbrNVerm_Q2 + -DnfaExecLbrNVerm_QR=avx512_nfaExecLbrNVerm_QR + -DnfaExecLbrNVerm_expandState=avx512_nfaExecLbrNVerm_expandState + -DnfaExecLbrNVerm_inAccept=avx512_nfaExecLbrNVerm_inAccept + -DnfaExecLbrNVerm_inAnyAccept=avx512_nfaExecLbrNVerm_inAnyAccept + -DnfaExecLbrNVerm_initCompressedState=avx512_nfaExecLbrNVerm_initCompressedState + -DnfaExecLbrNVerm_queueCompressState=avx512_nfaExecLbrNVerm_queueCompressState + -DnfaExecLbrNVerm_queueInitState=avx512_nfaExecLbrNVerm_queueInitState + -DnfaExecLbrNVerm_reportCurrent=avx512_nfaExecLbrNVerm_reportCurrent + -DnfaExecLbrShuf_Q=avx512_nfaExecLbrShuf_Q + -DnfaExecLbrShuf_Q2=avx512_nfaExecLbrShuf_Q2 + -DnfaExecLbrShuf_QR=avx512_nfaExecLbrShuf_QR + -DnfaExecLbrShuf_expandState=avx512_nfaExecLbrShuf_expandState + -DnfaExecLbrShuf_inAccept=avx512_nfaExecLbrShuf_inAccept + -DnfaExecLbrShuf_inAnyAccept=avx512_nfaExecLbrShuf_inAnyAccept + -DnfaExecLbrShuf_initCompressedState=avx512_nfaExecLbrShuf_initCompressedState + -DnfaExecLbrShuf_queueCompressState=avx512_nfaExecLbrShuf_queueCompressState + -DnfaExecLbrShuf_queueInitState=avx512_nfaExecLbrShuf_queueInitState + -DnfaExecLbrShuf_reportCurrent=avx512_nfaExecLbrShuf_reportCurrent + -DnfaExecLbrTruf_Q=avx512_nfaExecLbrTruf_Q + -DnfaExecLbrTruf_Q2=avx512_nfaExecLbrTruf_Q2 + -DnfaExecLbrTruf_QR=avx512_nfaExecLbrTruf_QR + -DnfaExecLbrTruf_expandState=avx512_nfaExecLbrTruf_expandState + -DnfaExecLbrTruf_inAccept=avx512_nfaExecLbrTruf_inAccept + -DnfaExecLbrTruf_inAnyAccept=avx512_nfaExecLbrTruf_inAnyAccept + -DnfaExecLbrTruf_initCompressedState=avx512_nfaExecLbrTruf_initCompressedState + -DnfaExecLbrTruf_queueCompressState=avx512_nfaExecLbrTruf_queueCompressState + -DnfaExecLbrTruf_queueInitState=avx512_nfaExecLbrTruf_queueInitState + -DnfaExecLbrTruf_reportCurrent=avx512_nfaExecLbrTruf_reportCurrent + -DnfaExecLbrVerm_Q=avx512_nfaExecLbrVerm_Q + -DnfaExecLbrVerm_Q2=avx512_nfaExecLbrVerm_Q2 + -DnfaExecLbrVerm_QR=avx512_nfaExecLbrVerm_QR + -DnfaExecLbrVerm_expandState=avx512_nfaExecLbrVerm_expandState + -DnfaExecLbrVerm_inAccept=avx512_nfaExecLbrVerm_inAccept + -DnfaExecLbrVerm_inAnyAccept=avx512_nfaExecLbrVerm_inAnyAccept + -DnfaExecLbrVerm_initCompressedState=avx512_nfaExecLbrVerm_initCompressedState + -DnfaExecLbrVerm_queueCompressState=avx512_nfaExecLbrVerm_queueCompressState + -DnfaExecLbrVerm_queueInitState=avx512_nfaExecLbrVerm_queueInitState + -DnfaExecLbrVerm_reportCurrent=avx512_nfaExecLbrVerm_reportCurrent + -DnfaExecLimEx128_B_Reverse=avx512_nfaExecLimEx128_B_Reverse + -DnfaExecLimEx128_Q=avx512_nfaExecLimEx128_Q + -DnfaExecLimEx128_Q2=avx512_nfaExecLimEx128_Q2 + -DnfaExecLimEx128_QR=avx512_nfaExecLimEx128_QR + -DnfaExecLimEx128_expandState=avx512_nfaExecLimEx128_expandState + -DnfaExecLimEx128_inAccept=avx512_nfaExecLimEx128_inAccept + -DnfaExecLimEx128_inAnyAccept=avx512_nfaExecLimEx128_inAnyAccept + -DnfaExecLimEx128_initCompressedState=avx512_nfaExecLimEx128_initCompressedState + -DnfaExecLimEx128_queueCompressState=avx512_nfaExecLimEx128_queueCompressState + -DnfaExecLimEx128_queueInitState=avx512_nfaExecLimEx128_queueInitState + -DnfaExecLimEx128_reportCurrent=avx512_nfaExecLimEx128_reportCurrent + -DnfaExecLimEx128_testEOD=avx512_nfaExecLimEx128_testEOD + -DnfaExecLimEx128_zombie_status=avx512_nfaExecLimEx128_zombie_status + -DnfaExecLimEx256_B_Reverse=avx512_nfaExecLimEx256_B_Reverse + -DnfaExecLimEx256_Q=avx512_nfaExecLimEx256_Q + -DnfaExecLimEx256_Q2=avx512_nfaExecLimEx256_Q2 + -DnfaExecLimEx256_QR=avx512_nfaExecLimEx256_QR + -DnfaExecLimEx256_expandState=avx512_nfaExecLimEx256_expandState + -DnfaExecLimEx256_inAccept=avx512_nfaExecLimEx256_inAccept + -DnfaExecLimEx256_inAnyAccept=avx512_nfaExecLimEx256_inAnyAccept + -DnfaExecLimEx256_initCompressedState=avx512_nfaExecLimEx256_initCompressedState + -DnfaExecLimEx256_queueCompressState=avx512_nfaExecLimEx256_queueCompressState + -DnfaExecLimEx256_queueInitState=avx512_nfaExecLimEx256_queueInitState + -DnfaExecLimEx256_reportCurrent=avx512_nfaExecLimEx256_reportCurrent + -DnfaExecLimEx256_testEOD=avx512_nfaExecLimEx256_testEOD + -DnfaExecLimEx256_zombie_status=avx512_nfaExecLimEx256_zombie_status + -DnfaExecLimEx32_B_Reverse=avx512_nfaExecLimEx32_B_Reverse + -DnfaExecLimEx32_Q=avx512_nfaExecLimEx32_Q + -DnfaExecLimEx32_Q2=avx512_nfaExecLimEx32_Q2 + -DnfaExecLimEx32_QR=avx512_nfaExecLimEx32_QR + -DnfaExecLimEx32_expandState=avx512_nfaExecLimEx32_expandState + -DnfaExecLimEx32_inAccept=avx512_nfaExecLimEx32_inAccept + -DnfaExecLimEx32_inAnyAccept=avx512_nfaExecLimEx32_inAnyAccept + -DnfaExecLimEx32_initCompressedState=avx512_nfaExecLimEx32_initCompressedState + -DnfaExecLimEx32_queueCompressState=avx512_nfaExecLimEx32_queueCompressState + -DnfaExecLimEx32_queueInitState=avx512_nfaExecLimEx32_queueInitState + -DnfaExecLimEx32_reportCurrent=avx512_nfaExecLimEx32_reportCurrent + -DnfaExecLimEx32_testEOD=avx512_nfaExecLimEx32_testEOD + -DnfaExecLimEx32_zombie_status=avx512_nfaExecLimEx32_zombie_status + -DnfaExecLimEx384_B_Reverse=avx512_nfaExecLimEx384_B_Reverse + -DnfaExecLimEx384_Q=avx512_nfaExecLimEx384_Q + -DnfaExecLimEx384_Q2=avx512_nfaExecLimEx384_Q2 + -DnfaExecLimEx384_QR=avx512_nfaExecLimEx384_QR + -DnfaExecLimEx384_expandState=avx512_nfaExecLimEx384_expandState + -DnfaExecLimEx384_inAccept=avx512_nfaExecLimEx384_inAccept + -DnfaExecLimEx384_inAnyAccept=avx512_nfaExecLimEx384_inAnyAccept + -DnfaExecLimEx384_initCompressedState=avx512_nfaExecLimEx384_initCompressedState + -DnfaExecLimEx384_queueCompressState=avx512_nfaExecLimEx384_queueCompressState + -DnfaExecLimEx384_queueInitState=avx512_nfaExecLimEx384_queueInitState + -DnfaExecLimEx384_reportCurrent=avx512_nfaExecLimEx384_reportCurrent + -DnfaExecLimEx384_testEOD=avx512_nfaExecLimEx384_testEOD + -DnfaExecLimEx384_zombie_status=avx512_nfaExecLimEx384_zombie_status + -DnfaExecLimEx512_B_Reverse=avx512_nfaExecLimEx512_B_Reverse + -DnfaExecLimEx512_Q=avx512_nfaExecLimEx512_Q + -DnfaExecLimEx512_Q2=avx512_nfaExecLimEx512_Q2 + -DnfaExecLimEx512_QR=avx512_nfaExecLimEx512_QR + -DnfaExecLimEx512_expandState=avx512_nfaExecLimEx512_expandState + -DnfaExecLimEx512_inAccept=avx512_nfaExecLimEx512_inAccept + -DnfaExecLimEx512_inAnyAccept=avx512_nfaExecLimEx512_inAnyAccept + -DnfaExecLimEx512_initCompressedState=avx512_nfaExecLimEx512_initCompressedState + -DnfaExecLimEx512_queueCompressState=avx512_nfaExecLimEx512_queueCompressState + -DnfaExecLimEx512_queueInitState=avx512_nfaExecLimEx512_queueInitState + -DnfaExecLimEx512_reportCurrent=avx512_nfaExecLimEx512_reportCurrent + -DnfaExecLimEx512_testEOD=avx512_nfaExecLimEx512_testEOD + -DnfaExecLimEx512_zombie_status=avx512_nfaExecLimEx512_zombie_status + -DnfaExecLimEx64_B_Reverse=avx512_nfaExecLimEx64_B_Reverse + -DnfaExecLimEx64_Q=avx512_nfaExecLimEx64_Q + -DnfaExecLimEx64_Q2=avx512_nfaExecLimEx64_Q2 + -DnfaExecLimEx64_QR=avx512_nfaExecLimEx64_QR + -DnfaExecLimEx64_expandState=avx512_nfaExecLimEx64_expandState + -DnfaExecLimEx64_inAccept=avx512_nfaExecLimEx64_inAccept + -DnfaExecLimEx64_inAnyAccept=avx512_nfaExecLimEx64_inAnyAccept + -DnfaExecLimEx64_initCompressedState=avx512_nfaExecLimEx64_initCompressedState + -DnfaExecLimEx64_queueCompressState=avx512_nfaExecLimEx64_queueCompressState + -DnfaExecLimEx64_queueInitState=avx512_nfaExecLimEx64_queueInitState + -DnfaExecLimEx64_reportCurrent=avx512_nfaExecLimEx64_reportCurrent + -DnfaExecLimEx64_testEOD=avx512_nfaExecLimEx64_testEOD + -DnfaExecLimEx64_zombie_status=avx512_nfaExecLimEx64_zombie_status + -DnfaExecMcClellan16_B=avx512_nfaExecMcClellan16_B + -DnfaExecMcClellan16_Q=avx512_nfaExecMcClellan16_Q + -DnfaExecMcClellan16_Q2=avx512_nfaExecMcClellan16_Q2 + -DnfaExecMcClellan16_QR=avx512_nfaExecMcClellan16_QR + -DnfaExecMcClellan16_SimpStream=avx512_nfaExecMcClellan16_SimpStream + -DnfaExecMcClellan16_expandState=avx512_nfaExecMcClellan16_expandState + -DnfaExecMcClellan16_inAccept=avx512_nfaExecMcClellan16_inAccept + -DnfaExecMcClellan16_inAnyAccept=avx512_nfaExecMcClellan16_inAnyAccept + -DnfaExecMcClellan16_initCompressedState=avx512_nfaExecMcClellan16_initCompressedState + -DnfaExecMcClellan16_queueCompressState=avx512_nfaExecMcClellan16_queueCompressState + -DnfaExecMcClellan16_queueInitState=avx512_nfaExecMcClellan16_queueInitState + -DnfaExecMcClellan16_reportCurrent=avx512_nfaExecMcClellan16_reportCurrent + -DnfaExecMcClellan16_testEOD=avx512_nfaExecMcClellan16_testEOD + -DnfaExecMcClellan8_B=avx512_nfaExecMcClellan8_B + -DnfaExecMcClellan8_Q=avx512_nfaExecMcClellan8_Q + -DnfaExecMcClellan8_Q2=avx512_nfaExecMcClellan8_Q2 + -DnfaExecMcClellan8_QR=avx512_nfaExecMcClellan8_QR + -DnfaExecMcClellan8_SimpStream=avx512_nfaExecMcClellan8_SimpStream + -DnfaExecMcClellan8_expandState=avx512_nfaExecMcClellan8_expandState + -DnfaExecMcClellan8_inAccept=avx512_nfaExecMcClellan8_inAccept + -DnfaExecMcClellan8_inAnyAccept=avx512_nfaExecMcClellan8_inAnyAccept + -DnfaExecMcClellan8_initCompressedState=avx512_nfaExecMcClellan8_initCompressedState + -DnfaExecMcClellan8_queueCompressState=avx512_nfaExecMcClellan8_queueCompressState + -DnfaExecMcClellan8_queueInitState=avx512_nfaExecMcClellan8_queueInitState + -DnfaExecMcClellan8_reportCurrent=avx512_nfaExecMcClellan8_reportCurrent + -DnfaExecMcClellan8_testEOD=avx512_nfaExecMcClellan8_testEOD + -DnfaExecMcSheng16_Q=avx512_nfaExecMcSheng16_Q + -DnfaExecMcSheng16_Q2=avx512_nfaExecMcSheng16_Q2 + -DnfaExecMcSheng16_QR=avx512_nfaExecMcSheng16_QR + -DnfaExecMcSheng16_expandState=avx512_nfaExecMcSheng16_expandState + -DnfaExecMcSheng16_inAccept=avx512_nfaExecMcSheng16_inAccept + -DnfaExecMcSheng16_inAnyAccept=avx512_nfaExecMcSheng16_inAnyAccept + -DnfaExecMcSheng16_initCompressedState=avx512_nfaExecMcSheng16_initCompressedState + -DnfaExecMcSheng16_queueCompressState=avx512_nfaExecMcSheng16_queueCompressState + -DnfaExecMcSheng16_queueInitState=avx512_nfaExecMcSheng16_queueInitState + -DnfaExecMcSheng16_reportCurrent=avx512_nfaExecMcSheng16_reportCurrent + -DnfaExecMcSheng16_testEOD=avx512_nfaExecMcSheng16_testEOD + -DnfaExecMcSheng8_Q=avx512_nfaExecMcSheng8_Q + -DnfaExecMcSheng8_Q2=avx512_nfaExecMcSheng8_Q2 + -DnfaExecMcSheng8_QR=avx512_nfaExecMcSheng8_QR + -DnfaExecMcSheng8_expandState=avx512_nfaExecMcSheng8_expandState + -DnfaExecMcSheng8_inAccept=avx512_nfaExecMcSheng8_inAccept + -DnfaExecMcSheng8_inAnyAccept=avx512_nfaExecMcSheng8_inAnyAccept + -DnfaExecMcSheng8_initCompressedState=avx512_nfaExecMcSheng8_initCompressedState + -DnfaExecMcSheng8_queueCompressState=avx512_nfaExecMcSheng8_queueCompressState + -DnfaExecMcSheng8_queueInitState=avx512_nfaExecMcSheng8_queueInitState + -DnfaExecMcSheng8_reportCurrent=avx512_nfaExecMcSheng8_reportCurrent + -DnfaExecMcSheng8_testEOD=avx512_nfaExecMcSheng8_testEOD + -DnfaExecMpv_Q=avx512_nfaExecMpv_Q + -DnfaExecMpv_QueueExecRaw=avx512_nfaExecMpv_QueueExecRaw + -DnfaExecMpv_expandState=avx512_nfaExecMpv_expandState + -DnfaExecMpv_initCompressedState=avx512_nfaExecMpv_initCompressedState + -DnfaExecMpv_queueCompressState=avx512_nfaExecMpv_queueCompressState + -DnfaExecMpv_queueInitState=avx512_nfaExecMpv_queueInitState + -DnfaExecMpv_reportCurrent=avx512_nfaExecMpv_reportCurrent + -DnfaExecSheng_B=avx512_nfaExecSheng_B + -DnfaExecSheng_Q=avx512_nfaExecSheng_Q + -DnfaExecSheng_Q2=avx512_nfaExecSheng_Q2 + -DnfaExecSheng_QR=avx512_nfaExecSheng_QR + -DnfaExecSheng_expandState=avx512_nfaExecSheng_expandState + -DnfaExecSheng_inAccept=avx512_nfaExecSheng_inAccept + -DnfaExecSheng_inAnyAccept=avx512_nfaExecSheng_inAnyAccept + -DnfaExecSheng_initCompressedState=avx512_nfaExecSheng_initCompressedState + -DnfaExecSheng_queueCompressState=avx512_nfaExecSheng_queueCompressState + -DnfaExecSheng_queueInitState=avx512_nfaExecSheng_queueInitState + -DnfaExecSheng_reportCurrent=avx512_nfaExecSheng_reportCurrent + -DnfaExecSheng_testEOD=avx512_nfaExecSheng_testEOD + -DnfaExecTamarama_Q=avx512_nfaExecTamarama_Q + -DnfaExecTamarama_Q2=avx512_nfaExecTamarama_Q2 + -DnfaExecTamarama_QR=avx512_nfaExecTamarama_QR + -DnfaExecTamarama_expandState=avx512_nfaExecTamarama_expandState + -DnfaExecTamarama_inAccept=avx512_nfaExecTamarama_inAccept + -DnfaExecTamarama_inAnyAccept=avx512_nfaExecTamarama_inAnyAccept + -DnfaExecTamarama_queueCompressState=avx512_nfaExecTamarama_queueCompressState + -DnfaExecTamarama_queueInitState=avx512_nfaExecTamarama_queueInitState + -DnfaExecTamarama_reportCurrent=avx512_nfaExecTamarama_reportCurrent + -DnfaExecTamarama_testEOD=avx512_nfaExecTamarama_testEOD + -DnfaExecTamarama_zombie_status=avx512_nfaExecTamarama_zombie_status + -DnfaExpandState=avx512_nfaExpandState + -DnfaGetZombieStatus=avx512_nfaGetZombieStatus + -DnfaInAcceptState=avx512_nfaInAcceptState + -DnfaInAnyAcceptState=avx512_nfaInAnyAcceptState + -DnfaInitCompressedState=avx512_nfaInitCompressedState + -DnfaQueueCompressState=avx512_nfaQueueCompressState + -DnfaQueueExec=avx512_nfaQueueExec + -DnfaQueueExec2_raw=avx512_nfaQueueExec2_raw + -DnfaQueueExecRose=avx512_nfaQueueExecRose + -DnfaQueueExecToMatch=avx512_nfaQueueExecToMatch + -DnfaQueueExec_raw=avx512_nfaQueueExec_raw + -DnfaQueueInitState=avx512_nfaQueueInitState + -DnfaReportCurrentMatches=avx512_nfaReportCurrentMatches + -DnoodExec=avx512_noodExec + -DnoodExecStreaming=avx512_noodExecStreaming + -Dp_mask_arr=avx512_p_mask_arr + -Dp_mask_arr256=avx512_p_mask_arr256 + -DrepeatHasMatchBitmap=avx512_repeatHasMatchBitmap + -DrepeatHasMatchRange=avx512_repeatHasMatchRange + -DrepeatHasMatchRing=avx512_repeatHasMatchRing + -DrepeatHasMatchSparseOptimalP=avx512_repeatHasMatchSparseOptimalP + -DrepeatHasMatchTrailer=avx512_repeatHasMatchTrailer + -DrepeatLastTopBitmap=avx512_repeatLastTopBitmap + -DrepeatLastTopRange=avx512_repeatLastTopRange + -DrepeatLastTopRing=avx512_repeatLastTopRing + -DrepeatLastTopSparseOptimalP=avx512_repeatLastTopSparseOptimalP + -DrepeatLastTopTrailer=avx512_repeatLastTopTrailer + -DrepeatNextMatchBitmap=avx512_repeatNextMatchBitmap + -DrepeatNextMatchRange=avx512_repeatNextMatchRange + -DrepeatNextMatchRing=avx512_repeatNextMatchRing + -DrepeatNextMatchSparseOptimalP=avx512_repeatNextMatchSparseOptimalP + -DrepeatNextMatchTrailer=avx512_repeatNextMatchTrailer + -DrepeatPack=avx512_repeatPack + -DrepeatStoreBitmap=avx512_repeatStoreBitmap + -DrepeatStoreRange=avx512_repeatStoreRange + -DrepeatStoreRing=avx512_repeatStoreRing + -DrepeatStoreSparseOptimalP=avx512_repeatStoreSparseOptimalP + -DrepeatStoreTrailer=avx512_repeatStoreTrailer + -DrepeatUnpack=avx512_repeatUnpack + -DroseAnchoredCallback=avx512_roseAnchoredCallback + -DroseBlockExec=avx512_roseBlockExec + -DroseCallback=avx512_roseCallback + -DroseCatchUpAll=avx512_roseCatchUpAll + -DroseCatchUpMPV_i=avx512_roseCatchUpMPV_i + -DroseCatchUpSuf=avx512_roseCatchUpSuf + -DroseDelayRebuildCallback=avx512_roseDelayRebuildCallback + -DroseFloatingCallback=avx512_roseFloatingCallback + -DroseHandleChainMatch=avx512_roseHandleChainMatch + -DroseInitState=avx512_roseInitState + -DroseNfaAdaptor=avx512_roseNfaAdaptor + -DroseNfaEarliestSom=avx512_roseNfaEarliestSom + -DroseReportAdaptor=avx512_roseReportAdaptor + -DroseRunBoundaryProgram=avx512_roseRunBoundaryProgram + -DroseRunFlushCombProgram=avx512_roseRunFlushCombProgram + -DroseRunLastFlushCombProgram=avx512_roseRunLastFlushCombProgram + -DroseRunProgram=avx512_roseRunProgram + -DroseRunProgram_l=avx512_roseRunProgram_l + -DroseStreamEodExec=avx512_roseStreamEodExec + -DroseStreamExec=avx512_roseStreamExec + -DrshuftiExec=avx512_rshuftiExec + -DrtruffleExec=avx512_rtruffleExec + -Drun_accel=avx512_run_accel + -DsetSomFromSomAware=avx512_setSomFromSomAware + -DshuftiDoubleExec=avx512_shuftiDoubleExec + -DshuftiExec=avx512_shuftiExec + -Dsimd_onebit_masks=avx512_simd_onebit_masks + -Dsize_compress_stream=avx512_size_compress_stream + -DstoreSomToStream=avx512_storeSomToStream + -Dstorecompressed128=avx512_storecompressed128 + -Dstorecompressed256=avx512_storecompressed256 + -Dstorecompressed32=avx512_storecompressed32 + -Dstorecompressed384=avx512_storecompressed384 + -Dstorecompressed512=avx512_storecompressed512 + -Dstorecompressed64=avx512_storecompressed64 + -DstreamInitSufPQ=avx512_streamInitSufPQ + -DtruffleExec=avx512_truffleExec + -Dvbs_mask_data=avx512_vbs_mask_data +) + +SRCDIR(contrib/libs/hyperscan) + +SRCS( + src/alloc.c + src/crc32.c + src/database.c + src/fdr/fdr.c + src/fdr/teddy.c + src/fdr/teddy_avx2.c + src/hs_valid_platform.c + src/hs_version.c + src/hwlm/hwlm.c + src/hwlm/noodle_engine.c + src/nfa/accel.c + src/nfa/castle.c + src/nfa/gough.c + src/nfa/lbr.c + src/nfa/limex_64.c + src/nfa/limex_accel.c + src/nfa/limex_native.c + src/nfa/limex_simd128.c + src/nfa/limex_simd256.c + src/nfa/limex_simd384.c + src/nfa/limex_simd512.c + src/nfa/mcclellan.c + src/nfa/mcsheng.c + src/nfa/mcsheng_data.c + src/nfa/mpv.c + src/nfa/nfa_api_dispatch.c + src/nfa/repeat.c + src/nfa/sheng.c + src/nfa/shufti.c + src/nfa/tamarama.c + src/nfa/truffle.c + src/rose/block.c + src/rose/catchup.c + src/rose/init.c + src/rose/match.c + src/rose/program_runtime.c + src/rose/stream.c + src/runtime.c + src/scratch.c + src/som/som_runtime.c + src/som/som_stream.c + src/stream_compress.c + src/util/cpuid_flags.c + src/util/masked_move.c + src/util/multibit.c + src/util/simd_utils.c + src/util/state_compress.c +) + +END() diff --git a/contrib/libs/hyperscan/runtime_core2/ya.make b/contrib/libs/hyperscan/runtime_core2/ya.make new file mode 100644 index 00000000000..fc696566f72 --- /dev/null +++ b/contrib/libs/hyperscan/runtime_core2/ya.make @@ -0,0 +1,481 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + contrib/libs/hyperscan + contrib/libs/hyperscan/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DCrc32c_ComputeBuf=core2_Crc32c_ComputeBuf + -DblockInitSufPQ=core2_blockInitSufPQ + -Dcompress_stream=core2_compress_stream + -Dcpuid_flags=core2_cpuid_flags + -Dcpuid_tune=core2_cpuid_tune + -DdbIsValid=core2_dbIsValid + -DdoAccel128=core2_doAccel128 + -DdoAccel256=core2_doAccel256 + -DdoAccel32=core2_doAccel32 + -DdoAccel384=core2_doAccel384 + -DdoAccel512=core2_doAccel512 + -DdoAccel64=core2_doAccel64 + -Dexpand_stream=core2_expand_stream + -DfdrExec=core2_fdrExec + -DfdrExecStreaming=core2_fdrExecStreaming + -Dfdr_exec_fat_teddy_msks1=core2_fdr_exec_fat_teddy_msks1 + -Dfdr_exec_fat_teddy_msks1_pck=core2_fdr_exec_fat_teddy_msks1_pck + -Dfdr_exec_fat_teddy_msks2=core2_fdr_exec_fat_teddy_msks2 + -Dfdr_exec_fat_teddy_msks2_pck=core2_fdr_exec_fat_teddy_msks2_pck + -Dfdr_exec_fat_teddy_msks3=core2_fdr_exec_fat_teddy_msks3 + -Dfdr_exec_fat_teddy_msks3_pck=core2_fdr_exec_fat_teddy_msks3_pck + -Dfdr_exec_fat_teddy_msks4=core2_fdr_exec_fat_teddy_msks4 + -Dfdr_exec_fat_teddy_msks4_pck=core2_fdr_exec_fat_teddy_msks4_pck + -Dfdr_exec_teddy_msks1=core2_fdr_exec_teddy_msks1 + -Dfdr_exec_teddy_msks1_pck=core2_fdr_exec_teddy_msks1_pck + -Dfdr_exec_teddy_msks2=core2_fdr_exec_teddy_msks2 + -Dfdr_exec_teddy_msks2_pck=core2_fdr_exec_teddy_msks2_pck + -Dfdr_exec_teddy_msks3=core2_fdr_exec_teddy_msks3 + -Dfdr_exec_teddy_msks3_pck=core2_fdr_exec_teddy_msks3_pck + -Dfdr_exec_teddy_msks4=core2_fdr_exec_teddy_msks4 + -Dfdr_exec_teddy_msks4_pck=core2_fdr_exec_teddy_msks4_pck + -DflushQueuedLiterals_i=core2_flushQueuedLiterals_i + -DflushStoredSomMatches_i=core2_flushStoredSomMatches_i + -DhandleSomExternal=core2_handleSomExternal + -DhandleSomInternal=core2_handleSomInternal + -Dhs_alloc_scratch=core2_hs_alloc_scratch + -Dhs_clone_scratch=core2_hs_clone_scratch + -Dhs_close_stream=core2_hs_close_stream + -Dhs_compress_stream=core2_hs_compress_stream + -Dhs_copy_stream=core2_hs_copy_stream + -Dhs_database_alloc=core2_hs_database_alloc + -Dhs_database_free=core2_hs_database_free + -Dhs_database_info=core2_hs_database_info + -Dhs_database_size=core2_hs_database_size + -Dhs_deserialize_database=core2_hs_deserialize_database + -Dhs_deserialize_database_at=core2_hs_deserialize_database_at + -Dhs_expand_stream=core2_hs_expand_stream + -Dhs_free_database=core2_hs_free_database + -Dhs_free_scratch=core2_hs_free_scratch + -Dhs_misc_alloc=core2_hs_misc_alloc + -Dhs_misc_free=core2_hs_misc_free + -Dhs_open_stream=core2_hs_open_stream + -Dhs_reset_and_copy_stream=core2_hs_reset_and_copy_stream + -Dhs_reset_and_expand_stream=core2_hs_reset_and_expand_stream + -Dhs_reset_stream=core2_hs_reset_stream + -Dhs_scan=core2_hs_scan + -Dhs_scan_stream=core2_hs_scan_stream + -Dhs_scan_vector=core2_hs_scan_vector + -Dhs_scratch_alloc=core2_hs_scratch_alloc + -Dhs_scratch_free=core2_hs_scratch_free + -Dhs_scratch_size=core2_hs_scratch_size + -Dhs_serialize_database=core2_hs_serialize_database + -Dhs_serialized_database_info=core2_hs_serialized_database_info + -Dhs_serialized_database_size=core2_hs_serialized_database_size + -Dhs_set_allocator=core2_hs_set_allocator + -Dhs_set_database_allocator=core2_hs_set_database_allocator + -Dhs_set_misc_allocator=core2_hs_set_misc_allocator + -Dhs_set_scratch_allocator=core2_hs_set_scratch_allocator + -Dhs_set_stream_allocator=core2_hs_set_stream_allocator + -Dhs_stream_alloc=core2_hs_stream_alloc + -Dhs_stream_free=core2_hs_stream_free + -Dhs_stream_size=core2_hs_stream_size + -Dhs_valid_platform=core2_hs_valid_platform + -Dhs_version=core2_hs_version + -DhwlmExec=core2_hwlmExec + -DhwlmExecStreaming=core2_hwlmExecStreaming + -DloadSomFromStream=core2_loadSomFromStream + -Dloadcompressed128=core2_loadcompressed128 + -Dloadcompressed256=core2_loadcompressed256 + -Dloadcompressed32=core2_loadcompressed32 + -Dloadcompressed384=core2_loadcompressed384 + -Dloadcompressed512=core2_loadcompressed512 + -Dloadcompressed64=core2_loadcompressed64 + -Dmcsheng_pext_mask=core2_mcsheng_pext_mask + -Dmm_mask_mask=core2_mm_mask_mask + -Dmm_shuffle_end=core2_mm_shuffle_end + -Dmmbit_keyshift_lut=core2_mmbit_keyshift_lut + -Dmmbit_maxlevel_direct_lut=core2_mmbit_maxlevel_direct_lut + -Dmmbit_maxlevel_from_keyshift_lut=core2_mmbit_maxlevel_from_keyshift_lut + -Dmmbit_root_offset_from_level=core2_mmbit_root_offset_from_level + -Dmmbit_zero_to_lut=core2_mmbit_zero_to_lut + -DnfaBlockExecReverse=core2_nfaBlockExecReverse + -DnfaCheckFinalState=core2_nfaCheckFinalState + -DnfaExecCastle_Q=core2_nfaExecCastle_Q + -DnfaExecCastle_Q2=core2_nfaExecCastle_Q2 + -DnfaExecCastle_QR=core2_nfaExecCastle_QR + -DnfaExecCastle_expandState=core2_nfaExecCastle_expandState + -DnfaExecCastle_inAccept=core2_nfaExecCastle_inAccept + -DnfaExecCastle_inAnyAccept=core2_nfaExecCastle_inAnyAccept + -DnfaExecCastle_initCompressedState=core2_nfaExecCastle_initCompressedState + -DnfaExecCastle_queueCompressState=core2_nfaExecCastle_queueCompressState + -DnfaExecCastle_queueInitState=core2_nfaExecCastle_queueInitState + -DnfaExecCastle_reportCurrent=core2_nfaExecCastle_reportCurrent + -DnfaExecGough16_Q=core2_nfaExecGough16_Q + -DnfaExecGough16_Q2=core2_nfaExecGough16_Q2 + -DnfaExecGough16_QR=core2_nfaExecGough16_QR + -DnfaExecGough16_expandState=core2_nfaExecGough16_expandState + -DnfaExecGough16_inAccept=core2_nfaExecGough16_inAccept + -DnfaExecGough16_inAnyAccept=core2_nfaExecGough16_inAnyAccept + -DnfaExecGough16_initCompressedState=core2_nfaExecGough16_initCompressedState + -DnfaExecGough16_queueCompressState=core2_nfaExecGough16_queueCompressState + -DnfaExecGough16_queueInitState=core2_nfaExecGough16_queueInitState + -DnfaExecGough16_reportCurrent=core2_nfaExecGough16_reportCurrent + -DnfaExecGough16_testEOD=core2_nfaExecGough16_testEOD + -DnfaExecGough8_Q=core2_nfaExecGough8_Q + -DnfaExecGough8_Q2=core2_nfaExecGough8_Q2 + -DnfaExecGough8_QR=core2_nfaExecGough8_QR + -DnfaExecGough8_expandState=core2_nfaExecGough8_expandState + -DnfaExecGough8_inAccept=core2_nfaExecGough8_inAccept + -DnfaExecGough8_inAnyAccept=core2_nfaExecGough8_inAnyAccept + -DnfaExecGough8_initCompressedState=core2_nfaExecGough8_initCompressedState + -DnfaExecGough8_queueCompressState=core2_nfaExecGough8_queueCompressState + -DnfaExecGough8_queueInitState=core2_nfaExecGough8_queueInitState + -DnfaExecGough8_reportCurrent=core2_nfaExecGough8_reportCurrent + -DnfaExecGough8_testEOD=core2_nfaExecGough8_testEOD + -DnfaExecLbrDot_Q=core2_nfaExecLbrDot_Q + -DnfaExecLbrDot_Q2=core2_nfaExecLbrDot_Q2 + -DnfaExecLbrDot_QR=core2_nfaExecLbrDot_QR + -DnfaExecLbrDot_expandState=core2_nfaExecLbrDot_expandState + -DnfaExecLbrDot_inAccept=core2_nfaExecLbrDot_inAccept + -DnfaExecLbrDot_inAnyAccept=core2_nfaExecLbrDot_inAnyAccept + -DnfaExecLbrDot_initCompressedState=core2_nfaExecLbrDot_initCompressedState + -DnfaExecLbrDot_queueCompressState=core2_nfaExecLbrDot_queueCompressState + -DnfaExecLbrDot_queueInitState=core2_nfaExecLbrDot_queueInitState + -DnfaExecLbrDot_reportCurrent=core2_nfaExecLbrDot_reportCurrent + -DnfaExecLbrNVerm_Q=core2_nfaExecLbrNVerm_Q + -DnfaExecLbrNVerm_Q2=core2_nfaExecLbrNVerm_Q2 + -DnfaExecLbrNVerm_QR=core2_nfaExecLbrNVerm_QR + -DnfaExecLbrNVerm_expandState=core2_nfaExecLbrNVerm_expandState + -DnfaExecLbrNVerm_inAccept=core2_nfaExecLbrNVerm_inAccept + -DnfaExecLbrNVerm_inAnyAccept=core2_nfaExecLbrNVerm_inAnyAccept + -DnfaExecLbrNVerm_initCompressedState=core2_nfaExecLbrNVerm_initCompressedState + -DnfaExecLbrNVerm_queueCompressState=core2_nfaExecLbrNVerm_queueCompressState + -DnfaExecLbrNVerm_queueInitState=core2_nfaExecLbrNVerm_queueInitState + -DnfaExecLbrNVerm_reportCurrent=core2_nfaExecLbrNVerm_reportCurrent + -DnfaExecLbrShuf_Q=core2_nfaExecLbrShuf_Q + -DnfaExecLbrShuf_Q2=core2_nfaExecLbrShuf_Q2 + -DnfaExecLbrShuf_QR=core2_nfaExecLbrShuf_QR + -DnfaExecLbrShuf_expandState=core2_nfaExecLbrShuf_expandState + -DnfaExecLbrShuf_inAccept=core2_nfaExecLbrShuf_inAccept + -DnfaExecLbrShuf_inAnyAccept=core2_nfaExecLbrShuf_inAnyAccept + -DnfaExecLbrShuf_initCompressedState=core2_nfaExecLbrShuf_initCompressedState + -DnfaExecLbrShuf_queueCompressState=core2_nfaExecLbrShuf_queueCompressState + -DnfaExecLbrShuf_queueInitState=core2_nfaExecLbrShuf_queueInitState + -DnfaExecLbrShuf_reportCurrent=core2_nfaExecLbrShuf_reportCurrent + -DnfaExecLbrTruf_Q=core2_nfaExecLbrTruf_Q + -DnfaExecLbrTruf_Q2=core2_nfaExecLbrTruf_Q2 + -DnfaExecLbrTruf_QR=core2_nfaExecLbrTruf_QR + -DnfaExecLbrTruf_expandState=core2_nfaExecLbrTruf_expandState + -DnfaExecLbrTruf_inAccept=core2_nfaExecLbrTruf_inAccept + -DnfaExecLbrTruf_inAnyAccept=core2_nfaExecLbrTruf_inAnyAccept + -DnfaExecLbrTruf_initCompressedState=core2_nfaExecLbrTruf_initCompressedState + -DnfaExecLbrTruf_queueCompressState=core2_nfaExecLbrTruf_queueCompressState + -DnfaExecLbrTruf_queueInitState=core2_nfaExecLbrTruf_queueInitState + -DnfaExecLbrTruf_reportCurrent=core2_nfaExecLbrTruf_reportCurrent + -DnfaExecLbrVerm_Q=core2_nfaExecLbrVerm_Q + -DnfaExecLbrVerm_Q2=core2_nfaExecLbrVerm_Q2 + -DnfaExecLbrVerm_QR=core2_nfaExecLbrVerm_QR + -DnfaExecLbrVerm_expandState=core2_nfaExecLbrVerm_expandState + -DnfaExecLbrVerm_inAccept=core2_nfaExecLbrVerm_inAccept + -DnfaExecLbrVerm_inAnyAccept=core2_nfaExecLbrVerm_inAnyAccept + -DnfaExecLbrVerm_initCompressedState=core2_nfaExecLbrVerm_initCompressedState + -DnfaExecLbrVerm_queueCompressState=core2_nfaExecLbrVerm_queueCompressState + -DnfaExecLbrVerm_queueInitState=core2_nfaExecLbrVerm_queueInitState + -DnfaExecLbrVerm_reportCurrent=core2_nfaExecLbrVerm_reportCurrent + -DnfaExecLimEx128_B_Reverse=core2_nfaExecLimEx128_B_Reverse + -DnfaExecLimEx128_Q=core2_nfaExecLimEx128_Q + -DnfaExecLimEx128_Q2=core2_nfaExecLimEx128_Q2 + -DnfaExecLimEx128_QR=core2_nfaExecLimEx128_QR + -DnfaExecLimEx128_expandState=core2_nfaExecLimEx128_expandState + -DnfaExecLimEx128_inAccept=core2_nfaExecLimEx128_inAccept + -DnfaExecLimEx128_inAnyAccept=core2_nfaExecLimEx128_inAnyAccept + -DnfaExecLimEx128_initCompressedState=core2_nfaExecLimEx128_initCompressedState + -DnfaExecLimEx128_queueCompressState=core2_nfaExecLimEx128_queueCompressState + -DnfaExecLimEx128_queueInitState=core2_nfaExecLimEx128_queueInitState + -DnfaExecLimEx128_reportCurrent=core2_nfaExecLimEx128_reportCurrent + -DnfaExecLimEx128_testEOD=core2_nfaExecLimEx128_testEOD + -DnfaExecLimEx128_zombie_status=core2_nfaExecLimEx128_zombie_status + -DnfaExecLimEx256_B_Reverse=core2_nfaExecLimEx256_B_Reverse + -DnfaExecLimEx256_Q=core2_nfaExecLimEx256_Q + -DnfaExecLimEx256_Q2=core2_nfaExecLimEx256_Q2 + -DnfaExecLimEx256_QR=core2_nfaExecLimEx256_QR + -DnfaExecLimEx256_expandState=core2_nfaExecLimEx256_expandState + -DnfaExecLimEx256_inAccept=core2_nfaExecLimEx256_inAccept + -DnfaExecLimEx256_inAnyAccept=core2_nfaExecLimEx256_inAnyAccept + -DnfaExecLimEx256_initCompressedState=core2_nfaExecLimEx256_initCompressedState + -DnfaExecLimEx256_queueCompressState=core2_nfaExecLimEx256_queueCompressState + -DnfaExecLimEx256_queueInitState=core2_nfaExecLimEx256_queueInitState + -DnfaExecLimEx256_reportCurrent=core2_nfaExecLimEx256_reportCurrent + -DnfaExecLimEx256_testEOD=core2_nfaExecLimEx256_testEOD + -DnfaExecLimEx256_zombie_status=core2_nfaExecLimEx256_zombie_status + -DnfaExecLimEx32_B_Reverse=core2_nfaExecLimEx32_B_Reverse + -DnfaExecLimEx32_Q=core2_nfaExecLimEx32_Q + -DnfaExecLimEx32_Q2=core2_nfaExecLimEx32_Q2 + -DnfaExecLimEx32_QR=core2_nfaExecLimEx32_QR + -DnfaExecLimEx32_expandState=core2_nfaExecLimEx32_expandState + -DnfaExecLimEx32_inAccept=core2_nfaExecLimEx32_inAccept + -DnfaExecLimEx32_inAnyAccept=core2_nfaExecLimEx32_inAnyAccept + -DnfaExecLimEx32_initCompressedState=core2_nfaExecLimEx32_initCompressedState + -DnfaExecLimEx32_queueCompressState=core2_nfaExecLimEx32_queueCompressState + -DnfaExecLimEx32_queueInitState=core2_nfaExecLimEx32_queueInitState + -DnfaExecLimEx32_reportCurrent=core2_nfaExecLimEx32_reportCurrent + -DnfaExecLimEx32_testEOD=core2_nfaExecLimEx32_testEOD + -DnfaExecLimEx32_zombie_status=core2_nfaExecLimEx32_zombie_status + -DnfaExecLimEx384_B_Reverse=core2_nfaExecLimEx384_B_Reverse + -DnfaExecLimEx384_Q=core2_nfaExecLimEx384_Q + -DnfaExecLimEx384_Q2=core2_nfaExecLimEx384_Q2 + -DnfaExecLimEx384_QR=core2_nfaExecLimEx384_QR + -DnfaExecLimEx384_expandState=core2_nfaExecLimEx384_expandState + -DnfaExecLimEx384_inAccept=core2_nfaExecLimEx384_inAccept + -DnfaExecLimEx384_inAnyAccept=core2_nfaExecLimEx384_inAnyAccept + -DnfaExecLimEx384_initCompressedState=core2_nfaExecLimEx384_initCompressedState + -DnfaExecLimEx384_queueCompressState=core2_nfaExecLimEx384_queueCompressState + -DnfaExecLimEx384_queueInitState=core2_nfaExecLimEx384_queueInitState + -DnfaExecLimEx384_reportCurrent=core2_nfaExecLimEx384_reportCurrent + -DnfaExecLimEx384_testEOD=core2_nfaExecLimEx384_testEOD + -DnfaExecLimEx384_zombie_status=core2_nfaExecLimEx384_zombie_status + -DnfaExecLimEx512_B_Reverse=core2_nfaExecLimEx512_B_Reverse + -DnfaExecLimEx512_Q=core2_nfaExecLimEx512_Q + -DnfaExecLimEx512_Q2=core2_nfaExecLimEx512_Q2 + -DnfaExecLimEx512_QR=core2_nfaExecLimEx512_QR + -DnfaExecLimEx512_expandState=core2_nfaExecLimEx512_expandState + -DnfaExecLimEx512_inAccept=core2_nfaExecLimEx512_inAccept + -DnfaExecLimEx512_inAnyAccept=core2_nfaExecLimEx512_inAnyAccept + -DnfaExecLimEx512_initCompressedState=core2_nfaExecLimEx512_initCompressedState + -DnfaExecLimEx512_queueCompressState=core2_nfaExecLimEx512_queueCompressState + -DnfaExecLimEx512_queueInitState=core2_nfaExecLimEx512_queueInitState + -DnfaExecLimEx512_reportCurrent=core2_nfaExecLimEx512_reportCurrent + -DnfaExecLimEx512_testEOD=core2_nfaExecLimEx512_testEOD + -DnfaExecLimEx512_zombie_status=core2_nfaExecLimEx512_zombie_status + -DnfaExecLimEx64_B_Reverse=core2_nfaExecLimEx64_B_Reverse + -DnfaExecLimEx64_Q=core2_nfaExecLimEx64_Q + -DnfaExecLimEx64_Q2=core2_nfaExecLimEx64_Q2 + -DnfaExecLimEx64_QR=core2_nfaExecLimEx64_QR + -DnfaExecLimEx64_expandState=core2_nfaExecLimEx64_expandState + -DnfaExecLimEx64_inAccept=core2_nfaExecLimEx64_inAccept + -DnfaExecLimEx64_inAnyAccept=core2_nfaExecLimEx64_inAnyAccept + -DnfaExecLimEx64_initCompressedState=core2_nfaExecLimEx64_initCompressedState + -DnfaExecLimEx64_queueCompressState=core2_nfaExecLimEx64_queueCompressState + -DnfaExecLimEx64_queueInitState=core2_nfaExecLimEx64_queueInitState + -DnfaExecLimEx64_reportCurrent=core2_nfaExecLimEx64_reportCurrent + -DnfaExecLimEx64_testEOD=core2_nfaExecLimEx64_testEOD + -DnfaExecLimEx64_zombie_status=core2_nfaExecLimEx64_zombie_status + -DnfaExecMcClellan16_B=core2_nfaExecMcClellan16_B + -DnfaExecMcClellan16_Q=core2_nfaExecMcClellan16_Q + -DnfaExecMcClellan16_Q2=core2_nfaExecMcClellan16_Q2 + -DnfaExecMcClellan16_QR=core2_nfaExecMcClellan16_QR + -DnfaExecMcClellan16_SimpStream=core2_nfaExecMcClellan16_SimpStream + -DnfaExecMcClellan16_expandState=core2_nfaExecMcClellan16_expandState + -DnfaExecMcClellan16_inAccept=core2_nfaExecMcClellan16_inAccept + -DnfaExecMcClellan16_inAnyAccept=core2_nfaExecMcClellan16_inAnyAccept + -DnfaExecMcClellan16_initCompressedState=core2_nfaExecMcClellan16_initCompressedState + -DnfaExecMcClellan16_queueCompressState=core2_nfaExecMcClellan16_queueCompressState + -DnfaExecMcClellan16_queueInitState=core2_nfaExecMcClellan16_queueInitState + -DnfaExecMcClellan16_reportCurrent=core2_nfaExecMcClellan16_reportCurrent + -DnfaExecMcClellan16_testEOD=core2_nfaExecMcClellan16_testEOD + -DnfaExecMcClellan8_B=core2_nfaExecMcClellan8_B + -DnfaExecMcClellan8_Q=core2_nfaExecMcClellan8_Q + -DnfaExecMcClellan8_Q2=core2_nfaExecMcClellan8_Q2 + -DnfaExecMcClellan8_QR=core2_nfaExecMcClellan8_QR + -DnfaExecMcClellan8_SimpStream=core2_nfaExecMcClellan8_SimpStream + -DnfaExecMcClellan8_expandState=core2_nfaExecMcClellan8_expandState + -DnfaExecMcClellan8_inAccept=core2_nfaExecMcClellan8_inAccept + -DnfaExecMcClellan8_inAnyAccept=core2_nfaExecMcClellan8_inAnyAccept + -DnfaExecMcClellan8_initCompressedState=core2_nfaExecMcClellan8_initCompressedState + -DnfaExecMcClellan8_queueCompressState=core2_nfaExecMcClellan8_queueCompressState + -DnfaExecMcClellan8_queueInitState=core2_nfaExecMcClellan8_queueInitState + -DnfaExecMcClellan8_reportCurrent=core2_nfaExecMcClellan8_reportCurrent + -DnfaExecMcClellan8_testEOD=core2_nfaExecMcClellan8_testEOD + -DnfaExecMcSheng16_Q=core2_nfaExecMcSheng16_Q + -DnfaExecMcSheng16_Q2=core2_nfaExecMcSheng16_Q2 + -DnfaExecMcSheng16_QR=core2_nfaExecMcSheng16_QR + -DnfaExecMcSheng16_expandState=core2_nfaExecMcSheng16_expandState + -DnfaExecMcSheng16_inAccept=core2_nfaExecMcSheng16_inAccept + -DnfaExecMcSheng16_inAnyAccept=core2_nfaExecMcSheng16_inAnyAccept + -DnfaExecMcSheng16_initCompressedState=core2_nfaExecMcSheng16_initCompressedState + -DnfaExecMcSheng16_queueCompressState=core2_nfaExecMcSheng16_queueCompressState + -DnfaExecMcSheng16_queueInitState=core2_nfaExecMcSheng16_queueInitState + -DnfaExecMcSheng16_reportCurrent=core2_nfaExecMcSheng16_reportCurrent + -DnfaExecMcSheng16_testEOD=core2_nfaExecMcSheng16_testEOD + -DnfaExecMcSheng8_Q=core2_nfaExecMcSheng8_Q + -DnfaExecMcSheng8_Q2=core2_nfaExecMcSheng8_Q2 + -DnfaExecMcSheng8_QR=core2_nfaExecMcSheng8_QR + -DnfaExecMcSheng8_expandState=core2_nfaExecMcSheng8_expandState + -DnfaExecMcSheng8_inAccept=core2_nfaExecMcSheng8_inAccept + -DnfaExecMcSheng8_inAnyAccept=core2_nfaExecMcSheng8_inAnyAccept + -DnfaExecMcSheng8_initCompressedState=core2_nfaExecMcSheng8_initCompressedState + -DnfaExecMcSheng8_queueCompressState=core2_nfaExecMcSheng8_queueCompressState + -DnfaExecMcSheng8_queueInitState=core2_nfaExecMcSheng8_queueInitState + -DnfaExecMcSheng8_reportCurrent=core2_nfaExecMcSheng8_reportCurrent + -DnfaExecMcSheng8_testEOD=core2_nfaExecMcSheng8_testEOD + -DnfaExecMpv_Q=core2_nfaExecMpv_Q + -DnfaExecMpv_QueueExecRaw=core2_nfaExecMpv_QueueExecRaw + -DnfaExecMpv_expandState=core2_nfaExecMpv_expandState + -DnfaExecMpv_initCompressedState=core2_nfaExecMpv_initCompressedState + -DnfaExecMpv_queueCompressState=core2_nfaExecMpv_queueCompressState + -DnfaExecMpv_queueInitState=core2_nfaExecMpv_queueInitState + -DnfaExecMpv_reportCurrent=core2_nfaExecMpv_reportCurrent + -DnfaExecSheng_B=core2_nfaExecSheng_B + -DnfaExecSheng_Q=core2_nfaExecSheng_Q + -DnfaExecSheng_Q2=core2_nfaExecSheng_Q2 + -DnfaExecSheng_QR=core2_nfaExecSheng_QR + -DnfaExecSheng_expandState=core2_nfaExecSheng_expandState + -DnfaExecSheng_inAccept=core2_nfaExecSheng_inAccept + -DnfaExecSheng_inAnyAccept=core2_nfaExecSheng_inAnyAccept + -DnfaExecSheng_initCompressedState=core2_nfaExecSheng_initCompressedState + -DnfaExecSheng_queueCompressState=core2_nfaExecSheng_queueCompressState + -DnfaExecSheng_queueInitState=core2_nfaExecSheng_queueInitState + -DnfaExecSheng_reportCurrent=core2_nfaExecSheng_reportCurrent + -DnfaExecSheng_testEOD=core2_nfaExecSheng_testEOD + -DnfaExecTamarama_Q=core2_nfaExecTamarama_Q + -DnfaExecTamarama_Q2=core2_nfaExecTamarama_Q2 + -DnfaExecTamarama_QR=core2_nfaExecTamarama_QR + -DnfaExecTamarama_expandState=core2_nfaExecTamarama_expandState + -DnfaExecTamarama_inAccept=core2_nfaExecTamarama_inAccept + -DnfaExecTamarama_inAnyAccept=core2_nfaExecTamarama_inAnyAccept + -DnfaExecTamarama_queueCompressState=core2_nfaExecTamarama_queueCompressState + -DnfaExecTamarama_queueInitState=core2_nfaExecTamarama_queueInitState + -DnfaExecTamarama_reportCurrent=core2_nfaExecTamarama_reportCurrent + -DnfaExecTamarama_testEOD=core2_nfaExecTamarama_testEOD + -DnfaExecTamarama_zombie_status=core2_nfaExecTamarama_zombie_status + -DnfaExpandState=core2_nfaExpandState + -DnfaGetZombieStatus=core2_nfaGetZombieStatus + -DnfaInAcceptState=core2_nfaInAcceptState + -DnfaInAnyAcceptState=core2_nfaInAnyAcceptState + -DnfaInitCompressedState=core2_nfaInitCompressedState + -DnfaQueueCompressState=core2_nfaQueueCompressState + -DnfaQueueExec=core2_nfaQueueExec + -DnfaQueueExec2_raw=core2_nfaQueueExec2_raw + -DnfaQueueExecRose=core2_nfaQueueExecRose + -DnfaQueueExecToMatch=core2_nfaQueueExecToMatch + -DnfaQueueExec_raw=core2_nfaQueueExec_raw + -DnfaQueueInitState=core2_nfaQueueInitState + -DnfaReportCurrentMatches=core2_nfaReportCurrentMatches + -DnoodExec=core2_noodExec + -DnoodExecStreaming=core2_noodExecStreaming + -Dp_mask_arr=core2_p_mask_arr + -Dp_mask_arr256=core2_p_mask_arr256 + -DrepeatHasMatchBitmap=core2_repeatHasMatchBitmap + -DrepeatHasMatchRange=core2_repeatHasMatchRange + -DrepeatHasMatchRing=core2_repeatHasMatchRing + -DrepeatHasMatchSparseOptimalP=core2_repeatHasMatchSparseOptimalP + -DrepeatHasMatchTrailer=core2_repeatHasMatchTrailer + -DrepeatLastTopBitmap=core2_repeatLastTopBitmap + -DrepeatLastTopRange=core2_repeatLastTopRange + -DrepeatLastTopRing=core2_repeatLastTopRing + -DrepeatLastTopSparseOptimalP=core2_repeatLastTopSparseOptimalP + -DrepeatLastTopTrailer=core2_repeatLastTopTrailer + -DrepeatNextMatchBitmap=core2_repeatNextMatchBitmap + -DrepeatNextMatchRange=core2_repeatNextMatchRange + -DrepeatNextMatchRing=core2_repeatNextMatchRing + -DrepeatNextMatchSparseOptimalP=core2_repeatNextMatchSparseOptimalP + -DrepeatNextMatchTrailer=core2_repeatNextMatchTrailer + -DrepeatPack=core2_repeatPack + -DrepeatStoreBitmap=core2_repeatStoreBitmap + -DrepeatStoreRange=core2_repeatStoreRange + -DrepeatStoreRing=core2_repeatStoreRing + -DrepeatStoreSparseOptimalP=core2_repeatStoreSparseOptimalP + -DrepeatStoreTrailer=core2_repeatStoreTrailer + -DrepeatUnpack=core2_repeatUnpack + -DroseAnchoredCallback=core2_roseAnchoredCallback + -DroseBlockExec=core2_roseBlockExec + -DroseCallback=core2_roseCallback + -DroseCatchUpAll=core2_roseCatchUpAll + -DroseCatchUpMPV_i=core2_roseCatchUpMPV_i + -DroseCatchUpSuf=core2_roseCatchUpSuf + -DroseDelayRebuildCallback=core2_roseDelayRebuildCallback + -DroseFloatingCallback=core2_roseFloatingCallback + -DroseHandleChainMatch=core2_roseHandleChainMatch + -DroseInitState=core2_roseInitState + -DroseNfaAdaptor=core2_roseNfaAdaptor + -DroseNfaEarliestSom=core2_roseNfaEarliestSom + -DroseReportAdaptor=core2_roseReportAdaptor + -DroseRunBoundaryProgram=core2_roseRunBoundaryProgram + -DroseRunFlushCombProgram=core2_roseRunFlushCombProgram + -DroseRunLastFlushCombProgram=core2_roseRunLastFlushCombProgram + -DroseRunProgram=core2_roseRunProgram + -DroseRunProgram_l=core2_roseRunProgram_l + -DroseStreamEodExec=core2_roseStreamEodExec + -DroseStreamExec=core2_roseStreamExec + -DrshuftiExec=core2_rshuftiExec + -DrtruffleExec=core2_rtruffleExec + -Drun_accel=core2_run_accel + -DsetSomFromSomAware=core2_setSomFromSomAware + -DshuftiDoubleExec=core2_shuftiDoubleExec + -DshuftiExec=core2_shuftiExec + -Dsimd_onebit_masks=core2_simd_onebit_masks + -Dsize_compress_stream=core2_size_compress_stream + -DstoreSomToStream=core2_storeSomToStream + -Dstorecompressed128=core2_storecompressed128 + -Dstorecompressed256=core2_storecompressed256 + -Dstorecompressed32=core2_storecompressed32 + -Dstorecompressed384=core2_storecompressed384 + -Dstorecompressed512=core2_storecompressed512 + -Dstorecompressed64=core2_storecompressed64 + -DstreamInitSufPQ=core2_streamInitSufPQ + -DtruffleExec=core2_truffleExec + -Dvbs_mask_data=core2_vbs_mask_data +) + +SRCDIR(contrib/libs/hyperscan) + +SRCS( + src/alloc.c + src/crc32.c + src/database.c + src/fdr/fdr.c + src/fdr/teddy.c + src/fdr/teddy_avx2.c + src/hs_valid_platform.c + src/hs_version.c + src/hwlm/hwlm.c + src/hwlm/noodle_engine.c + src/nfa/accel.c + src/nfa/castle.c + src/nfa/gough.c + src/nfa/lbr.c + src/nfa/limex_64.c + src/nfa/limex_accel.c + src/nfa/limex_native.c + src/nfa/limex_simd128.c + src/nfa/limex_simd256.c + src/nfa/limex_simd384.c + src/nfa/limex_simd512.c + src/nfa/mcclellan.c + src/nfa/mcsheng.c + src/nfa/mcsheng_data.c + src/nfa/mpv.c + src/nfa/nfa_api_dispatch.c + src/nfa/repeat.c + src/nfa/sheng.c + src/nfa/shufti.c + src/nfa/tamarama.c + src/nfa/truffle.c + src/rose/block.c + src/rose/catchup.c + src/rose/init.c + src/rose/match.c + src/rose/program_runtime.c + src/rose/stream.c + src/runtime.c + src/scratch.c + src/som/som_runtime.c + src/som/som_stream.c + src/stream_compress.c + src/util/cpuid_flags.c + src/util/masked_move.c + src/util/multibit.c + src/util/simd_utils.c + src/util/state_compress.c +) + +END() diff --git a/contrib/libs/hyperscan/runtime_corei7/ya.make b/contrib/libs/hyperscan/runtime_corei7/ya.make new file mode 100644 index 00000000000..071ec32457a --- /dev/null +++ b/contrib/libs/hyperscan/runtime_corei7/ya.make @@ -0,0 +1,487 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + contrib/libs/hyperscan + contrib/libs/hyperscan/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + ${SSE41_CFLAGS} + -DHAVE_SSE41 + ${SSE42_CFLAGS} + -DHAVE_SSE42 + ${POPCNT_CFLAGS} + -DHAVE_POPCOUNT_INSTR + -DCrc32c_ComputeBuf=corei7_Crc32c_ComputeBuf + -DblockInitSufPQ=corei7_blockInitSufPQ + -Dcompress_stream=corei7_compress_stream + -Dcpuid_flags=corei7_cpuid_flags + -Dcpuid_tune=corei7_cpuid_tune + -DdbIsValid=corei7_dbIsValid + -DdoAccel128=corei7_doAccel128 + -DdoAccel256=corei7_doAccel256 + -DdoAccel32=corei7_doAccel32 + -DdoAccel384=corei7_doAccel384 + -DdoAccel512=corei7_doAccel512 + -DdoAccel64=corei7_doAccel64 + -Dexpand_stream=corei7_expand_stream + -DfdrExec=corei7_fdrExec + -DfdrExecStreaming=corei7_fdrExecStreaming + -Dfdr_exec_fat_teddy_msks1=corei7_fdr_exec_fat_teddy_msks1 + -Dfdr_exec_fat_teddy_msks1_pck=corei7_fdr_exec_fat_teddy_msks1_pck + -Dfdr_exec_fat_teddy_msks2=corei7_fdr_exec_fat_teddy_msks2 + -Dfdr_exec_fat_teddy_msks2_pck=corei7_fdr_exec_fat_teddy_msks2_pck + -Dfdr_exec_fat_teddy_msks3=corei7_fdr_exec_fat_teddy_msks3 + -Dfdr_exec_fat_teddy_msks3_pck=corei7_fdr_exec_fat_teddy_msks3_pck + -Dfdr_exec_fat_teddy_msks4=corei7_fdr_exec_fat_teddy_msks4 + -Dfdr_exec_fat_teddy_msks4_pck=corei7_fdr_exec_fat_teddy_msks4_pck + -Dfdr_exec_teddy_msks1=corei7_fdr_exec_teddy_msks1 + -Dfdr_exec_teddy_msks1_pck=corei7_fdr_exec_teddy_msks1_pck + -Dfdr_exec_teddy_msks2=corei7_fdr_exec_teddy_msks2 + -Dfdr_exec_teddy_msks2_pck=corei7_fdr_exec_teddy_msks2_pck + -Dfdr_exec_teddy_msks3=corei7_fdr_exec_teddy_msks3 + -Dfdr_exec_teddy_msks3_pck=corei7_fdr_exec_teddy_msks3_pck + -Dfdr_exec_teddy_msks4=corei7_fdr_exec_teddy_msks4 + -Dfdr_exec_teddy_msks4_pck=corei7_fdr_exec_teddy_msks4_pck + -DflushQueuedLiterals_i=corei7_flushQueuedLiterals_i + -DflushStoredSomMatches_i=corei7_flushStoredSomMatches_i + -DhandleSomExternal=corei7_handleSomExternal + -DhandleSomInternal=corei7_handleSomInternal + -Dhs_alloc_scratch=corei7_hs_alloc_scratch + -Dhs_clone_scratch=corei7_hs_clone_scratch + -Dhs_close_stream=corei7_hs_close_stream + -Dhs_compress_stream=corei7_hs_compress_stream + -Dhs_copy_stream=corei7_hs_copy_stream + -Dhs_database_alloc=corei7_hs_database_alloc + -Dhs_database_free=corei7_hs_database_free + -Dhs_database_info=corei7_hs_database_info + -Dhs_database_size=corei7_hs_database_size + -Dhs_deserialize_database=corei7_hs_deserialize_database + -Dhs_deserialize_database_at=corei7_hs_deserialize_database_at + -Dhs_expand_stream=corei7_hs_expand_stream + -Dhs_free_database=corei7_hs_free_database + -Dhs_free_scratch=corei7_hs_free_scratch + -Dhs_misc_alloc=corei7_hs_misc_alloc + -Dhs_misc_free=corei7_hs_misc_free + -Dhs_open_stream=corei7_hs_open_stream + -Dhs_reset_and_copy_stream=corei7_hs_reset_and_copy_stream + -Dhs_reset_and_expand_stream=corei7_hs_reset_and_expand_stream + -Dhs_reset_stream=corei7_hs_reset_stream + -Dhs_scan=corei7_hs_scan + -Dhs_scan_stream=corei7_hs_scan_stream + -Dhs_scan_vector=corei7_hs_scan_vector + -Dhs_scratch_alloc=corei7_hs_scratch_alloc + -Dhs_scratch_free=corei7_hs_scratch_free + -Dhs_scratch_size=corei7_hs_scratch_size + -Dhs_serialize_database=corei7_hs_serialize_database + -Dhs_serialized_database_info=corei7_hs_serialized_database_info + -Dhs_serialized_database_size=corei7_hs_serialized_database_size + -Dhs_set_allocator=corei7_hs_set_allocator + -Dhs_set_database_allocator=corei7_hs_set_database_allocator + -Dhs_set_misc_allocator=corei7_hs_set_misc_allocator + -Dhs_set_scratch_allocator=corei7_hs_set_scratch_allocator + -Dhs_set_stream_allocator=corei7_hs_set_stream_allocator + -Dhs_stream_alloc=corei7_hs_stream_alloc + -Dhs_stream_free=corei7_hs_stream_free + -Dhs_stream_size=corei7_hs_stream_size + -Dhs_valid_platform=corei7_hs_valid_platform + -Dhs_version=corei7_hs_version + -DhwlmExec=corei7_hwlmExec + -DhwlmExecStreaming=corei7_hwlmExecStreaming + -DloadSomFromStream=corei7_loadSomFromStream + -Dloadcompressed128=corei7_loadcompressed128 + -Dloadcompressed256=corei7_loadcompressed256 + -Dloadcompressed32=corei7_loadcompressed32 + -Dloadcompressed384=corei7_loadcompressed384 + -Dloadcompressed512=corei7_loadcompressed512 + -Dloadcompressed64=corei7_loadcompressed64 + -Dmcsheng_pext_mask=corei7_mcsheng_pext_mask + -Dmm_mask_mask=corei7_mm_mask_mask + -Dmm_shuffle_end=corei7_mm_shuffle_end + -Dmmbit_keyshift_lut=corei7_mmbit_keyshift_lut + -Dmmbit_maxlevel_direct_lut=corei7_mmbit_maxlevel_direct_lut + -Dmmbit_maxlevel_from_keyshift_lut=corei7_mmbit_maxlevel_from_keyshift_lut + -Dmmbit_root_offset_from_level=corei7_mmbit_root_offset_from_level + -Dmmbit_zero_to_lut=corei7_mmbit_zero_to_lut + -DnfaBlockExecReverse=corei7_nfaBlockExecReverse + -DnfaCheckFinalState=corei7_nfaCheckFinalState + -DnfaExecCastle_Q=corei7_nfaExecCastle_Q + -DnfaExecCastle_Q2=corei7_nfaExecCastle_Q2 + -DnfaExecCastle_QR=corei7_nfaExecCastle_QR + -DnfaExecCastle_expandState=corei7_nfaExecCastle_expandState + -DnfaExecCastle_inAccept=corei7_nfaExecCastle_inAccept + -DnfaExecCastle_inAnyAccept=corei7_nfaExecCastle_inAnyAccept + -DnfaExecCastle_initCompressedState=corei7_nfaExecCastle_initCompressedState + -DnfaExecCastle_queueCompressState=corei7_nfaExecCastle_queueCompressState + -DnfaExecCastle_queueInitState=corei7_nfaExecCastle_queueInitState + -DnfaExecCastle_reportCurrent=corei7_nfaExecCastle_reportCurrent + -DnfaExecGough16_Q=corei7_nfaExecGough16_Q + -DnfaExecGough16_Q2=corei7_nfaExecGough16_Q2 + -DnfaExecGough16_QR=corei7_nfaExecGough16_QR + -DnfaExecGough16_expandState=corei7_nfaExecGough16_expandState + -DnfaExecGough16_inAccept=corei7_nfaExecGough16_inAccept + -DnfaExecGough16_inAnyAccept=corei7_nfaExecGough16_inAnyAccept + -DnfaExecGough16_initCompressedState=corei7_nfaExecGough16_initCompressedState + -DnfaExecGough16_queueCompressState=corei7_nfaExecGough16_queueCompressState + -DnfaExecGough16_queueInitState=corei7_nfaExecGough16_queueInitState + -DnfaExecGough16_reportCurrent=corei7_nfaExecGough16_reportCurrent + -DnfaExecGough16_testEOD=corei7_nfaExecGough16_testEOD + -DnfaExecGough8_Q=corei7_nfaExecGough8_Q + -DnfaExecGough8_Q2=corei7_nfaExecGough8_Q2 + -DnfaExecGough8_QR=corei7_nfaExecGough8_QR + -DnfaExecGough8_expandState=corei7_nfaExecGough8_expandState + -DnfaExecGough8_inAccept=corei7_nfaExecGough8_inAccept + -DnfaExecGough8_inAnyAccept=corei7_nfaExecGough8_inAnyAccept + -DnfaExecGough8_initCompressedState=corei7_nfaExecGough8_initCompressedState + -DnfaExecGough8_queueCompressState=corei7_nfaExecGough8_queueCompressState + -DnfaExecGough8_queueInitState=corei7_nfaExecGough8_queueInitState + -DnfaExecGough8_reportCurrent=corei7_nfaExecGough8_reportCurrent + -DnfaExecGough8_testEOD=corei7_nfaExecGough8_testEOD + -DnfaExecLbrDot_Q=corei7_nfaExecLbrDot_Q + -DnfaExecLbrDot_Q2=corei7_nfaExecLbrDot_Q2 + -DnfaExecLbrDot_QR=corei7_nfaExecLbrDot_QR + -DnfaExecLbrDot_expandState=corei7_nfaExecLbrDot_expandState + -DnfaExecLbrDot_inAccept=corei7_nfaExecLbrDot_inAccept + -DnfaExecLbrDot_inAnyAccept=corei7_nfaExecLbrDot_inAnyAccept + -DnfaExecLbrDot_initCompressedState=corei7_nfaExecLbrDot_initCompressedState + -DnfaExecLbrDot_queueCompressState=corei7_nfaExecLbrDot_queueCompressState + -DnfaExecLbrDot_queueInitState=corei7_nfaExecLbrDot_queueInitState + -DnfaExecLbrDot_reportCurrent=corei7_nfaExecLbrDot_reportCurrent + -DnfaExecLbrNVerm_Q=corei7_nfaExecLbrNVerm_Q + -DnfaExecLbrNVerm_Q2=corei7_nfaExecLbrNVerm_Q2 + -DnfaExecLbrNVerm_QR=corei7_nfaExecLbrNVerm_QR + -DnfaExecLbrNVerm_expandState=corei7_nfaExecLbrNVerm_expandState + -DnfaExecLbrNVerm_inAccept=corei7_nfaExecLbrNVerm_inAccept + -DnfaExecLbrNVerm_inAnyAccept=corei7_nfaExecLbrNVerm_inAnyAccept + -DnfaExecLbrNVerm_initCompressedState=corei7_nfaExecLbrNVerm_initCompressedState + -DnfaExecLbrNVerm_queueCompressState=corei7_nfaExecLbrNVerm_queueCompressState + -DnfaExecLbrNVerm_queueInitState=corei7_nfaExecLbrNVerm_queueInitState + -DnfaExecLbrNVerm_reportCurrent=corei7_nfaExecLbrNVerm_reportCurrent + -DnfaExecLbrShuf_Q=corei7_nfaExecLbrShuf_Q + -DnfaExecLbrShuf_Q2=corei7_nfaExecLbrShuf_Q2 + -DnfaExecLbrShuf_QR=corei7_nfaExecLbrShuf_QR + -DnfaExecLbrShuf_expandState=corei7_nfaExecLbrShuf_expandState + -DnfaExecLbrShuf_inAccept=corei7_nfaExecLbrShuf_inAccept + -DnfaExecLbrShuf_inAnyAccept=corei7_nfaExecLbrShuf_inAnyAccept + -DnfaExecLbrShuf_initCompressedState=corei7_nfaExecLbrShuf_initCompressedState + -DnfaExecLbrShuf_queueCompressState=corei7_nfaExecLbrShuf_queueCompressState + -DnfaExecLbrShuf_queueInitState=corei7_nfaExecLbrShuf_queueInitState + -DnfaExecLbrShuf_reportCurrent=corei7_nfaExecLbrShuf_reportCurrent + -DnfaExecLbrTruf_Q=corei7_nfaExecLbrTruf_Q + -DnfaExecLbrTruf_Q2=corei7_nfaExecLbrTruf_Q2 + -DnfaExecLbrTruf_QR=corei7_nfaExecLbrTruf_QR + -DnfaExecLbrTruf_expandState=corei7_nfaExecLbrTruf_expandState + -DnfaExecLbrTruf_inAccept=corei7_nfaExecLbrTruf_inAccept + -DnfaExecLbrTruf_inAnyAccept=corei7_nfaExecLbrTruf_inAnyAccept + -DnfaExecLbrTruf_initCompressedState=corei7_nfaExecLbrTruf_initCompressedState + -DnfaExecLbrTruf_queueCompressState=corei7_nfaExecLbrTruf_queueCompressState + -DnfaExecLbrTruf_queueInitState=corei7_nfaExecLbrTruf_queueInitState + -DnfaExecLbrTruf_reportCurrent=corei7_nfaExecLbrTruf_reportCurrent + -DnfaExecLbrVerm_Q=corei7_nfaExecLbrVerm_Q + -DnfaExecLbrVerm_Q2=corei7_nfaExecLbrVerm_Q2 + -DnfaExecLbrVerm_QR=corei7_nfaExecLbrVerm_QR + -DnfaExecLbrVerm_expandState=corei7_nfaExecLbrVerm_expandState + -DnfaExecLbrVerm_inAccept=corei7_nfaExecLbrVerm_inAccept + -DnfaExecLbrVerm_inAnyAccept=corei7_nfaExecLbrVerm_inAnyAccept + -DnfaExecLbrVerm_initCompressedState=corei7_nfaExecLbrVerm_initCompressedState + -DnfaExecLbrVerm_queueCompressState=corei7_nfaExecLbrVerm_queueCompressState + -DnfaExecLbrVerm_queueInitState=corei7_nfaExecLbrVerm_queueInitState + -DnfaExecLbrVerm_reportCurrent=corei7_nfaExecLbrVerm_reportCurrent + -DnfaExecLimEx128_B_Reverse=corei7_nfaExecLimEx128_B_Reverse + -DnfaExecLimEx128_Q=corei7_nfaExecLimEx128_Q + -DnfaExecLimEx128_Q2=corei7_nfaExecLimEx128_Q2 + -DnfaExecLimEx128_QR=corei7_nfaExecLimEx128_QR + -DnfaExecLimEx128_expandState=corei7_nfaExecLimEx128_expandState + -DnfaExecLimEx128_inAccept=corei7_nfaExecLimEx128_inAccept + -DnfaExecLimEx128_inAnyAccept=corei7_nfaExecLimEx128_inAnyAccept + -DnfaExecLimEx128_initCompressedState=corei7_nfaExecLimEx128_initCompressedState + -DnfaExecLimEx128_queueCompressState=corei7_nfaExecLimEx128_queueCompressState + -DnfaExecLimEx128_queueInitState=corei7_nfaExecLimEx128_queueInitState + -DnfaExecLimEx128_reportCurrent=corei7_nfaExecLimEx128_reportCurrent + -DnfaExecLimEx128_testEOD=corei7_nfaExecLimEx128_testEOD + -DnfaExecLimEx128_zombie_status=corei7_nfaExecLimEx128_zombie_status + -DnfaExecLimEx256_B_Reverse=corei7_nfaExecLimEx256_B_Reverse + -DnfaExecLimEx256_Q=corei7_nfaExecLimEx256_Q + -DnfaExecLimEx256_Q2=corei7_nfaExecLimEx256_Q2 + -DnfaExecLimEx256_QR=corei7_nfaExecLimEx256_QR + -DnfaExecLimEx256_expandState=corei7_nfaExecLimEx256_expandState + -DnfaExecLimEx256_inAccept=corei7_nfaExecLimEx256_inAccept + -DnfaExecLimEx256_inAnyAccept=corei7_nfaExecLimEx256_inAnyAccept + -DnfaExecLimEx256_initCompressedState=corei7_nfaExecLimEx256_initCompressedState + -DnfaExecLimEx256_queueCompressState=corei7_nfaExecLimEx256_queueCompressState + -DnfaExecLimEx256_queueInitState=corei7_nfaExecLimEx256_queueInitState + -DnfaExecLimEx256_reportCurrent=corei7_nfaExecLimEx256_reportCurrent + -DnfaExecLimEx256_testEOD=corei7_nfaExecLimEx256_testEOD + -DnfaExecLimEx256_zombie_status=corei7_nfaExecLimEx256_zombie_status + -DnfaExecLimEx32_B_Reverse=corei7_nfaExecLimEx32_B_Reverse + -DnfaExecLimEx32_Q=corei7_nfaExecLimEx32_Q + -DnfaExecLimEx32_Q2=corei7_nfaExecLimEx32_Q2 + -DnfaExecLimEx32_QR=corei7_nfaExecLimEx32_QR + -DnfaExecLimEx32_expandState=corei7_nfaExecLimEx32_expandState + -DnfaExecLimEx32_inAccept=corei7_nfaExecLimEx32_inAccept + -DnfaExecLimEx32_inAnyAccept=corei7_nfaExecLimEx32_inAnyAccept + -DnfaExecLimEx32_initCompressedState=corei7_nfaExecLimEx32_initCompressedState + -DnfaExecLimEx32_queueCompressState=corei7_nfaExecLimEx32_queueCompressState + -DnfaExecLimEx32_queueInitState=corei7_nfaExecLimEx32_queueInitState + -DnfaExecLimEx32_reportCurrent=corei7_nfaExecLimEx32_reportCurrent + -DnfaExecLimEx32_testEOD=corei7_nfaExecLimEx32_testEOD + -DnfaExecLimEx32_zombie_status=corei7_nfaExecLimEx32_zombie_status + -DnfaExecLimEx384_B_Reverse=corei7_nfaExecLimEx384_B_Reverse + -DnfaExecLimEx384_Q=corei7_nfaExecLimEx384_Q + -DnfaExecLimEx384_Q2=corei7_nfaExecLimEx384_Q2 + -DnfaExecLimEx384_QR=corei7_nfaExecLimEx384_QR + -DnfaExecLimEx384_expandState=corei7_nfaExecLimEx384_expandState + -DnfaExecLimEx384_inAccept=corei7_nfaExecLimEx384_inAccept + -DnfaExecLimEx384_inAnyAccept=corei7_nfaExecLimEx384_inAnyAccept + -DnfaExecLimEx384_initCompressedState=corei7_nfaExecLimEx384_initCompressedState + -DnfaExecLimEx384_queueCompressState=corei7_nfaExecLimEx384_queueCompressState + -DnfaExecLimEx384_queueInitState=corei7_nfaExecLimEx384_queueInitState + -DnfaExecLimEx384_reportCurrent=corei7_nfaExecLimEx384_reportCurrent + -DnfaExecLimEx384_testEOD=corei7_nfaExecLimEx384_testEOD + -DnfaExecLimEx384_zombie_status=corei7_nfaExecLimEx384_zombie_status + -DnfaExecLimEx512_B_Reverse=corei7_nfaExecLimEx512_B_Reverse + -DnfaExecLimEx512_Q=corei7_nfaExecLimEx512_Q + -DnfaExecLimEx512_Q2=corei7_nfaExecLimEx512_Q2 + -DnfaExecLimEx512_QR=corei7_nfaExecLimEx512_QR + -DnfaExecLimEx512_expandState=corei7_nfaExecLimEx512_expandState + -DnfaExecLimEx512_inAccept=corei7_nfaExecLimEx512_inAccept + -DnfaExecLimEx512_inAnyAccept=corei7_nfaExecLimEx512_inAnyAccept + -DnfaExecLimEx512_initCompressedState=corei7_nfaExecLimEx512_initCompressedState + -DnfaExecLimEx512_queueCompressState=corei7_nfaExecLimEx512_queueCompressState + -DnfaExecLimEx512_queueInitState=corei7_nfaExecLimEx512_queueInitState + -DnfaExecLimEx512_reportCurrent=corei7_nfaExecLimEx512_reportCurrent + -DnfaExecLimEx512_testEOD=corei7_nfaExecLimEx512_testEOD + -DnfaExecLimEx512_zombie_status=corei7_nfaExecLimEx512_zombie_status + -DnfaExecLimEx64_B_Reverse=corei7_nfaExecLimEx64_B_Reverse + -DnfaExecLimEx64_Q=corei7_nfaExecLimEx64_Q + -DnfaExecLimEx64_Q2=corei7_nfaExecLimEx64_Q2 + -DnfaExecLimEx64_QR=corei7_nfaExecLimEx64_QR + -DnfaExecLimEx64_expandState=corei7_nfaExecLimEx64_expandState + -DnfaExecLimEx64_inAccept=corei7_nfaExecLimEx64_inAccept + -DnfaExecLimEx64_inAnyAccept=corei7_nfaExecLimEx64_inAnyAccept + -DnfaExecLimEx64_initCompressedState=corei7_nfaExecLimEx64_initCompressedState + -DnfaExecLimEx64_queueCompressState=corei7_nfaExecLimEx64_queueCompressState + -DnfaExecLimEx64_queueInitState=corei7_nfaExecLimEx64_queueInitState + -DnfaExecLimEx64_reportCurrent=corei7_nfaExecLimEx64_reportCurrent + -DnfaExecLimEx64_testEOD=corei7_nfaExecLimEx64_testEOD + -DnfaExecLimEx64_zombie_status=corei7_nfaExecLimEx64_zombie_status + -DnfaExecMcClellan16_B=corei7_nfaExecMcClellan16_B + -DnfaExecMcClellan16_Q=corei7_nfaExecMcClellan16_Q + -DnfaExecMcClellan16_Q2=corei7_nfaExecMcClellan16_Q2 + -DnfaExecMcClellan16_QR=corei7_nfaExecMcClellan16_QR + -DnfaExecMcClellan16_SimpStream=corei7_nfaExecMcClellan16_SimpStream + -DnfaExecMcClellan16_expandState=corei7_nfaExecMcClellan16_expandState + -DnfaExecMcClellan16_inAccept=corei7_nfaExecMcClellan16_inAccept + -DnfaExecMcClellan16_inAnyAccept=corei7_nfaExecMcClellan16_inAnyAccept + -DnfaExecMcClellan16_initCompressedState=corei7_nfaExecMcClellan16_initCompressedState + -DnfaExecMcClellan16_queueCompressState=corei7_nfaExecMcClellan16_queueCompressState + -DnfaExecMcClellan16_queueInitState=corei7_nfaExecMcClellan16_queueInitState + -DnfaExecMcClellan16_reportCurrent=corei7_nfaExecMcClellan16_reportCurrent + -DnfaExecMcClellan16_testEOD=corei7_nfaExecMcClellan16_testEOD + -DnfaExecMcClellan8_B=corei7_nfaExecMcClellan8_B + -DnfaExecMcClellan8_Q=corei7_nfaExecMcClellan8_Q + -DnfaExecMcClellan8_Q2=corei7_nfaExecMcClellan8_Q2 + -DnfaExecMcClellan8_QR=corei7_nfaExecMcClellan8_QR + -DnfaExecMcClellan8_SimpStream=corei7_nfaExecMcClellan8_SimpStream + -DnfaExecMcClellan8_expandState=corei7_nfaExecMcClellan8_expandState + -DnfaExecMcClellan8_inAccept=corei7_nfaExecMcClellan8_inAccept + -DnfaExecMcClellan8_inAnyAccept=corei7_nfaExecMcClellan8_inAnyAccept + -DnfaExecMcClellan8_initCompressedState=corei7_nfaExecMcClellan8_initCompressedState + -DnfaExecMcClellan8_queueCompressState=corei7_nfaExecMcClellan8_queueCompressState + -DnfaExecMcClellan8_queueInitState=corei7_nfaExecMcClellan8_queueInitState + -DnfaExecMcClellan8_reportCurrent=corei7_nfaExecMcClellan8_reportCurrent + -DnfaExecMcClellan8_testEOD=corei7_nfaExecMcClellan8_testEOD + -DnfaExecMcSheng16_Q=corei7_nfaExecMcSheng16_Q + -DnfaExecMcSheng16_Q2=corei7_nfaExecMcSheng16_Q2 + -DnfaExecMcSheng16_QR=corei7_nfaExecMcSheng16_QR + -DnfaExecMcSheng16_expandState=corei7_nfaExecMcSheng16_expandState + -DnfaExecMcSheng16_inAccept=corei7_nfaExecMcSheng16_inAccept + -DnfaExecMcSheng16_inAnyAccept=corei7_nfaExecMcSheng16_inAnyAccept + -DnfaExecMcSheng16_initCompressedState=corei7_nfaExecMcSheng16_initCompressedState + -DnfaExecMcSheng16_queueCompressState=corei7_nfaExecMcSheng16_queueCompressState + -DnfaExecMcSheng16_queueInitState=corei7_nfaExecMcSheng16_queueInitState + -DnfaExecMcSheng16_reportCurrent=corei7_nfaExecMcSheng16_reportCurrent + -DnfaExecMcSheng16_testEOD=corei7_nfaExecMcSheng16_testEOD + -DnfaExecMcSheng8_Q=corei7_nfaExecMcSheng8_Q + -DnfaExecMcSheng8_Q2=corei7_nfaExecMcSheng8_Q2 + -DnfaExecMcSheng8_QR=corei7_nfaExecMcSheng8_QR + -DnfaExecMcSheng8_expandState=corei7_nfaExecMcSheng8_expandState + -DnfaExecMcSheng8_inAccept=corei7_nfaExecMcSheng8_inAccept + -DnfaExecMcSheng8_inAnyAccept=corei7_nfaExecMcSheng8_inAnyAccept + -DnfaExecMcSheng8_initCompressedState=corei7_nfaExecMcSheng8_initCompressedState + -DnfaExecMcSheng8_queueCompressState=corei7_nfaExecMcSheng8_queueCompressState + -DnfaExecMcSheng8_queueInitState=corei7_nfaExecMcSheng8_queueInitState + -DnfaExecMcSheng8_reportCurrent=corei7_nfaExecMcSheng8_reportCurrent + -DnfaExecMcSheng8_testEOD=corei7_nfaExecMcSheng8_testEOD + -DnfaExecMpv_Q=corei7_nfaExecMpv_Q + -DnfaExecMpv_QueueExecRaw=corei7_nfaExecMpv_QueueExecRaw + -DnfaExecMpv_expandState=corei7_nfaExecMpv_expandState + -DnfaExecMpv_initCompressedState=corei7_nfaExecMpv_initCompressedState + -DnfaExecMpv_queueCompressState=corei7_nfaExecMpv_queueCompressState + -DnfaExecMpv_queueInitState=corei7_nfaExecMpv_queueInitState + -DnfaExecMpv_reportCurrent=corei7_nfaExecMpv_reportCurrent + -DnfaExecSheng_B=corei7_nfaExecSheng_B + -DnfaExecSheng_Q=corei7_nfaExecSheng_Q + -DnfaExecSheng_Q2=corei7_nfaExecSheng_Q2 + -DnfaExecSheng_QR=corei7_nfaExecSheng_QR + -DnfaExecSheng_expandState=corei7_nfaExecSheng_expandState + -DnfaExecSheng_inAccept=corei7_nfaExecSheng_inAccept + -DnfaExecSheng_inAnyAccept=corei7_nfaExecSheng_inAnyAccept + -DnfaExecSheng_initCompressedState=corei7_nfaExecSheng_initCompressedState + -DnfaExecSheng_queueCompressState=corei7_nfaExecSheng_queueCompressState + -DnfaExecSheng_queueInitState=corei7_nfaExecSheng_queueInitState + -DnfaExecSheng_reportCurrent=corei7_nfaExecSheng_reportCurrent + -DnfaExecSheng_testEOD=corei7_nfaExecSheng_testEOD + -DnfaExecTamarama_Q=corei7_nfaExecTamarama_Q + -DnfaExecTamarama_Q2=corei7_nfaExecTamarama_Q2 + -DnfaExecTamarama_QR=corei7_nfaExecTamarama_QR + -DnfaExecTamarama_expandState=corei7_nfaExecTamarama_expandState + -DnfaExecTamarama_inAccept=corei7_nfaExecTamarama_inAccept + -DnfaExecTamarama_inAnyAccept=corei7_nfaExecTamarama_inAnyAccept + -DnfaExecTamarama_queueCompressState=corei7_nfaExecTamarama_queueCompressState + -DnfaExecTamarama_queueInitState=corei7_nfaExecTamarama_queueInitState + -DnfaExecTamarama_reportCurrent=corei7_nfaExecTamarama_reportCurrent + -DnfaExecTamarama_testEOD=corei7_nfaExecTamarama_testEOD + -DnfaExecTamarama_zombie_status=corei7_nfaExecTamarama_zombie_status + -DnfaExpandState=corei7_nfaExpandState + -DnfaGetZombieStatus=corei7_nfaGetZombieStatus + -DnfaInAcceptState=corei7_nfaInAcceptState + -DnfaInAnyAcceptState=corei7_nfaInAnyAcceptState + -DnfaInitCompressedState=corei7_nfaInitCompressedState + -DnfaQueueCompressState=corei7_nfaQueueCompressState + -DnfaQueueExec=corei7_nfaQueueExec + -DnfaQueueExec2_raw=corei7_nfaQueueExec2_raw + -DnfaQueueExecRose=corei7_nfaQueueExecRose + -DnfaQueueExecToMatch=corei7_nfaQueueExecToMatch + -DnfaQueueExec_raw=corei7_nfaQueueExec_raw + -DnfaQueueInitState=corei7_nfaQueueInitState + -DnfaReportCurrentMatches=corei7_nfaReportCurrentMatches + -DnoodExec=corei7_noodExec + -DnoodExecStreaming=corei7_noodExecStreaming + -Dp_mask_arr=corei7_p_mask_arr + -Dp_mask_arr256=corei7_p_mask_arr256 + -DrepeatHasMatchBitmap=corei7_repeatHasMatchBitmap + -DrepeatHasMatchRange=corei7_repeatHasMatchRange + -DrepeatHasMatchRing=corei7_repeatHasMatchRing + -DrepeatHasMatchSparseOptimalP=corei7_repeatHasMatchSparseOptimalP + -DrepeatHasMatchTrailer=corei7_repeatHasMatchTrailer + -DrepeatLastTopBitmap=corei7_repeatLastTopBitmap + -DrepeatLastTopRange=corei7_repeatLastTopRange + -DrepeatLastTopRing=corei7_repeatLastTopRing + -DrepeatLastTopSparseOptimalP=corei7_repeatLastTopSparseOptimalP + -DrepeatLastTopTrailer=corei7_repeatLastTopTrailer + -DrepeatNextMatchBitmap=corei7_repeatNextMatchBitmap + -DrepeatNextMatchRange=corei7_repeatNextMatchRange + -DrepeatNextMatchRing=corei7_repeatNextMatchRing + -DrepeatNextMatchSparseOptimalP=corei7_repeatNextMatchSparseOptimalP + -DrepeatNextMatchTrailer=corei7_repeatNextMatchTrailer + -DrepeatPack=corei7_repeatPack + -DrepeatStoreBitmap=corei7_repeatStoreBitmap + -DrepeatStoreRange=corei7_repeatStoreRange + -DrepeatStoreRing=corei7_repeatStoreRing + -DrepeatStoreSparseOptimalP=corei7_repeatStoreSparseOptimalP + -DrepeatStoreTrailer=corei7_repeatStoreTrailer + -DrepeatUnpack=corei7_repeatUnpack + -DroseAnchoredCallback=corei7_roseAnchoredCallback + -DroseBlockExec=corei7_roseBlockExec + -DroseCallback=corei7_roseCallback + -DroseCatchUpAll=corei7_roseCatchUpAll + -DroseCatchUpMPV_i=corei7_roseCatchUpMPV_i + -DroseCatchUpSuf=corei7_roseCatchUpSuf + -DroseDelayRebuildCallback=corei7_roseDelayRebuildCallback + -DroseFloatingCallback=corei7_roseFloatingCallback + -DroseHandleChainMatch=corei7_roseHandleChainMatch + -DroseInitState=corei7_roseInitState + -DroseNfaAdaptor=corei7_roseNfaAdaptor + -DroseNfaEarliestSom=corei7_roseNfaEarliestSom + -DroseReportAdaptor=corei7_roseReportAdaptor + -DroseRunBoundaryProgram=corei7_roseRunBoundaryProgram + -DroseRunFlushCombProgram=corei7_roseRunFlushCombProgram + -DroseRunLastFlushCombProgram=corei7_roseRunLastFlushCombProgram + -DroseRunProgram=corei7_roseRunProgram + -DroseRunProgram_l=corei7_roseRunProgram_l + -DroseStreamEodExec=corei7_roseStreamEodExec + -DroseStreamExec=corei7_roseStreamExec + -DrshuftiExec=corei7_rshuftiExec + -DrtruffleExec=corei7_rtruffleExec + -Drun_accel=corei7_run_accel + -DsetSomFromSomAware=corei7_setSomFromSomAware + -DshuftiDoubleExec=corei7_shuftiDoubleExec + -DshuftiExec=corei7_shuftiExec + -Dsimd_onebit_masks=corei7_simd_onebit_masks + -Dsize_compress_stream=corei7_size_compress_stream + -DstoreSomToStream=corei7_storeSomToStream + -Dstorecompressed128=corei7_storecompressed128 + -Dstorecompressed256=corei7_storecompressed256 + -Dstorecompressed32=corei7_storecompressed32 + -Dstorecompressed384=corei7_storecompressed384 + -Dstorecompressed512=corei7_storecompressed512 + -Dstorecompressed64=corei7_storecompressed64 + -DstreamInitSufPQ=corei7_streamInitSufPQ + -DtruffleExec=corei7_truffleExec + -Dvbs_mask_data=corei7_vbs_mask_data +) + +SRCDIR(contrib/libs/hyperscan) + +SRCS( + src/alloc.c + src/crc32.c + src/database.c + src/fdr/fdr.c + src/fdr/teddy.c + src/fdr/teddy_avx2.c + src/hs_valid_platform.c + src/hs_version.c + src/hwlm/hwlm.c + src/hwlm/noodle_engine.c + src/nfa/accel.c + src/nfa/castle.c + src/nfa/gough.c + src/nfa/lbr.c + src/nfa/limex_64.c + src/nfa/limex_accel.c + src/nfa/limex_native.c + src/nfa/limex_simd128.c + src/nfa/limex_simd256.c + src/nfa/limex_simd384.c + src/nfa/limex_simd512.c + src/nfa/mcclellan.c + src/nfa/mcsheng.c + src/nfa/mcsheng_data.c + src/nfa/mpv.c + src/nfa/nfa_api_dispatch.c + src/nfa/repeat.c + src/nfa/sheng.c + src/nfa/shufti.c + src/nfa/tamarama.c + src/nfa/truffle.c + src/rose/block.c + src/rose/catchup.c + src/rose/init.c + src/rose/match.c + src/rose/program_runtime.c + src/rose/stream.c + src/runtime.c + src/scratch.c + src/som/som_runtime.c + src/som/som_stream.c + src/stream_compress.c + src/util/cpuid_flags.c + src/util/masked_move.c + src/util/multibit.c + src/util/simd_utils.c + src/util/state_compress.c +) + +END() diff --git a/contrib/libs/hyperscan/ya.make b/contrib/libs/hyperscan/ya.make new file mode 100644 index 00000000000..7b54bfbd3a8 --- /dev/null +++ b/contrib/libs/hyperscan/ya.make @@ -0,0 +1,254 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSD-2-Clause AND + BSD-3-Clause AND + BSL-1.0 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(5.4.0) + +ORIGINAL_SOURCE(https://github.com/intel/hyperscan/archive/v5.4.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/dynamic_bitset + contrib/restricted/boost/graph + contrib/restricted/boost/icl + contrib/restricted/boost/multi_array + contrib/restricted/boost/property_map +) + +ADDINCL( + contrib/libs/hyperscan + contrib/libs/hyperscan/include + contrib/libs/hyperscan/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DDISABLE_AVX512VBMI_DISPATCH +) + +SRCS( + src/alloc.c + src/compiler/asserts.cpp + src/compiler/compiler.cpp + src/compiler/error.cpp + src/crc32.c + src/database.c + src/fdr/engine_description.cpp + src/fdr/fdr.c + src/fdr/fdr_compile.cpp + src/fdr/fdr_compile_util.cpp + src/fdr/fdr_confirm_compile.cpp + src/fdr/fdr_engine_description.cpp + src/fdr/flood_compile.cpp + src/fdr/teddy.c + src/fdr/teddy_avx2.c + src/fdr/teddy_compile.cpp + src/fdr/teddy_engine_description.cpp + src/grey.cpp + src/hs.cpp + src/hs_valid_platform.c + src/hs_version.c + src/hwlm/hwlm.c + src/hwlm/hwlm_build.cpp + src/hwlm/hwlm_literal.cpp + src/hwlm/noodle_build.cpp + src/hwlm/noodle_engine.c + src/nfa/accel.c + src/nfa/accel_dfa_build_strat.cpp + src/nfa/accelcompile.cpp + src/nfa/castle.c + src/nfa/castlecompile.cpp + src/nfa/dfa_build_strat.cpp + src/nfa/dfa_min.cpp + src/nfa/gough.c + src/nfa/goughcompile.cpp + src/nfa/goughcompile_accel.cpp + src/nfa/goughcompile_reg.cpp + src/nfa/lbr.c + src/nfa/limex_64.c + src/nfa/limex_accel.c + src/nfa/limex_compile.cpp + src/nfa/limex_native.c + src/nfa/limex_simd128.c + src/nfa/limex_simd256.c + src/nfa/limex_simd384.c + src/nfa/limex_simd512.c + src/nfa/mcclellan.c + src/nfa/mcclellancompile.cpp + src/nfa/mcclellancompile_util.cpp + src/nfa/mcsheng.c + src/nfa/mcsheng_compile.cpp + src/nfa/mcsheng_data.c + src/nfa/mpv.c + src/nfa/mpvcompile.cpp + src/nfa/nfa_api_dispatch.c + src/nfa/nfa_build_util.cpp + src/nfa/rdfa.cpp + src/nfa/rdfa_graph.cpp + src/nfa/rdfa_merge.cpp + src/nfa/repeat.c + src/nfa/repeatcompile.cpp + src/nfa/sheng.c + src/nfa/shengcompile.cpp + src/nfa/shufti.c + src/nfa/shufticompile.cpp + src/nfa/tamarama.c + src/nfa/tamaramacompile.cpp + src/nfa/truffle.c + src/nfa/trufflecompile.cpp + src/nfagraph/ng.cpp + src/nfagraph/ng_anchored_acyclic.cpp + src/nfagraph/ng_anchored_dots.cpp + src/nfagraph/ng_asserts.cpp + src/nfagraph/ng_builder.cpp + src/nfagraph/ng_calc_components.cpp + src/nfagraph/ng_cyclic_redundancy.cpp + src/nfagraph/ng_depth.cpp + src/nfagraph/ng_dominators.cpp + src/nfagraph/ng_edge_redundancy.cpp + src/nfagraph/ng_equivalence.cpp + src/nfagraph/ng_execute.cpp + src/nfagraph/ng_expr_info.cpp + src/nfagraph/ng_extparam.cpp + src/nfagraph/ng_fixed_width.cpp + src/nfagraph/ng_fuzzy.cpp + src/nfagraph/ng_haig.cpp + src/nfagraph/ng_holder.cpp + src/nfagraph/ng_is_equal.cpp + src/nfagraph/ng_lbr.cpp + src/nfagraph/ng_limex.cpp + src/nfagraph/ng_limex_accel.cpp + src/nfagraph/ng_literal_analysis.cpp + src/nfagraph/ng_literal_component.cpp + src/nfagraph/ng_literal_decorated.cpp + src/nfagraph/ng_mcclellan.cpp + src/nfagraph/ng_misc_opt.cpp + src/nfagraph/ng_netflow.cpp + src/nfagraph/ng_prefilter.cpp + src/nfagraph/ng_prune.cpp + src/nfagraph/ng_puff.cpp + src/nfagraph/ng_redundancy.cpp + src/nfagraph/ng_region.cpp + src/nfagraph/ng_region_redundancy.cpp + src/nfagraph/ng_repeat.cpp + src/nfagraph/ng_reports.cpp + src/nfagraph/ng_restructuring.cpp + src/nfagraph/ng_revacc.cpp + src/nfagraph/ng_sep.cpp + src/nfagraph/ng_small_literal_set.cpp + src/nfagraph/ng_som.cpp + src/nfagraph/ng_som_add_redundancy.cpp + src/nfagraph/ng_som_util.cpp + src/nfagraph/ng_split.cpp + src/nfagraph/ng_squash.cpp + src/nfagraph/ng_stop.cpp + src/nfagraph/ng_uncalc_components.cpp + src/nfagraph/ng_utf8.cpp + src/nfagraph/ng_util.cpp + src/nfagraph/ng_vacuous.cpp + src/nfagraph/ng_violet.cpp + src/nfagraph/ng_width.cpp + src/parser/AsciiComponentClass.cpp + src/parser/Component.cpp + src/parser/ComponentAlternation.cpp + src/parser/ComponentAssertion.cpp + src/parser/ComponentAtomicGroup.cpp + src/parser/ComponentBackReference.cpp + src/parser/ComponentBoundary.cpp + src/parser/ComponentByte.cpp + src/parser/ComponentClass.cpp + src/parser/ComponentCondReference.cpp + src/parser/ComponentEUS.cpp + src/parser/ComponentEmpty.cpp + src/parser/ComponentRepeat.cpp + src/parser/ComponentSequence.cpp + src/parser/ComponentVisitor.cpp + src/parser/ComponentWordBoundary.cpp + src/parser/ConstComponentVisitor.cpp + src/parser/Parser.rl6 + src/parser/Utf8ComponentClass.cpp + src/parser/buildstate.cpp + src/parser/check_refs.cpp + src/parser/control_verbs.rl6 + src/parser/logical_combination.cpp + src/parser/parse_error.cpp + src/parser/parser_util.cpp + src/parser/prefilter.cpp + src/parser/shortcut_literal.cpp + src/parser/ucp_table.cpp + src/parser/unsupported.cpp + src/parser/utf8_validate.cpp + src/rose/block.c + src/rose/catchup.c + src/rose/init.c + src/rose/match.c + src/rose/program_runtime.c + src/rose/rose_build_add.cpp + src/rose/rose_build_add_mask.cpp + src/rose/rose_build_anchored.cpp + src/rose/rose_build_bytecode.cpp + src/rose/rose_build_castle.cpp + src/rose/rose_build_compile.cpp + src/rose/rose_build_convert.cpp + src/rose/rose_build_dedupe.cpp + src/rose/rose_build_engine_blob.cpp + src/rose/rose_build_exclusive.cpp + src/rose/rose_build_groups.cpp + src/rose/rose_build_infix.cpp + src/rose/rose_build_instructions.cpp + src/rose/rose_build_lit_accel.cpp + src/rose/rose_build_long_lit.cpp + src/rose/rose_build_lookaround.cpp + src/rose/rose_build_matchers.cpp + src/rose/rose_build_merge.cpp + src/rose/rose_build_misc.cpp + src/rose/rose_build_program.cpp + src/rose/rose_build_role_aliasing.cpp + src/rose/rose_build_scatter.cpp + src/rose/rose_build_width.cpp + src/rose/rose_in_util.cpp + src/rose/stream.c + src/runtime.c + src/scratch.c + src/smallwrite/smallwrite_build.cpp + src/som/slot_manager.cpp + src/som/som_runtime.c + src/som/som_stream.c + src/stream_compress.c + src/util/alloc.cpp + src/util/charreach.cpp + src/util/clique.cpp + src/util/compile_context.cpp + src/util/compile_error.cpp + src/util/cpuid_flags.c + src/util/depth.cpp + src/util/dump_mask.cpp + src/util/fatbit_build.cpp + src/util/masked_move.c + src/util/multibit.c + src/util/multibit_build.cpp + src/util/report_manager.cpp + src/util/simd_utils.c + src/util/state_compress.c + src/util/target_info.cpp + src/util/ue2string.cpp +) + +END() + +RECURSE( + runtime_avx2 + runtime_avx512 + runtime_core2 + runtime_corei7 +) diff --git a/contrib/libs/icu/ya.make b/contrib/libs/icu/ya.make new file mode 100644 index 00000000000..3e87efa5ff9 --- /dev/null +++ b/contrib/libs/icu/ya.make @@ -0,0 +1,491 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + Custom-punycode AND + ICU AND + Unicode AND + Unicode-Icu-58 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(67.1) + +ORIGINAL_SOURCE(https://github.com/unicode-org/icu/releases/download/release-67-1/icu4c-67_1-src.tgz) + +ADDINCL( + GLOBAL contrib/libs/icu/include + contrib/libs/icu/common + contrib/libs/icu/i18n + contrib/libs/icu/io +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DU_COMMON_IMPLEMENTATION + -DU_I18N_IMPLEMENTATION + -DU_IO_IMPLEMENTATION +) + +IF (OS_WINDOWS) + CFLAGS( + GLOBAL -DU_STATIC_IMPLEMENTATION + ) +ELSE() + CFLAGS( + -DU_STATIC_IMPLEMENTATION + ) +ENDIF() + +SRCS( + common/appendable.cpp + common/bmpset.cpp + common/brkeng.cpp + common/brkiter.cpp + common/bytesinkutil.cpp + common/bytestream.cpp + common/bytestrie.cpp + common/bytestriebuilder.cpp + common/bytestrieiterator.cpp + common/caniter.cpp + common/characterproperties.cpp + common/chariter.cpp + common/charstr.cpp + common/cmemory.cpp + common/cstr.cpp + common/cstring.cpp + common/cwchar.cpp + common/dictbe.cpp + common/dictionarydata.cpp + common/dtintrv.cpp + common/edits.cpp + common/errorcode.cpp + common/filteredbrk.cpp + common/filterednormalizer2.cpp + common/icudataver.cpp + common/icuplug.cpp + common/loadednormalizer2impl.cpp + common/localebuilder.cpp + common/localematcher.cpp + common/localeprioritylist.cpp + common/locavailable.cpp + common/locbased.cpp + common/locdispnames.cpp + common/locdistance.cpp + common/locdspnm.cpp + common/locid.cpp + common/loclikely.cpp + common/loclikelysubtags.cpp + common/locmap.cpp + common/locresdata.cpp + common/locutil.cpp + common/lsr.cpp + common/messagepattern.cpp + common/normalizer2.cpp + common/normalizer2impl.cpp + common/normlzr.cpp + common/parsepos.cpp + common/patternprops.cpp + common/pluralmap.cpp + common/propname.cpp + common/propsvec.cpp + common/punycode.cpp + common/putil.cpp + common/rbbi.cpp + common/rbbi_cache.cpp + common/rbbidata.cpp + common/rbbinode.cpp + common/rbbirb.cpp + common/rbbiscan.cpp + common/rbbisetb.cpp + common/rbbistbl.cpp + common/rbbitblb.cpp + common/resbund.cpp + common/resbund_cnv.cpp + common/resource.cpp + common/restrace.cpp + common/ruleiter.cpp + common/schriter.cpp + common/serv.cpp + common/servlk.cpp + common/servlkf.cpp + common/servls.cpp + common/servnotf.cpp + common/servrbf.cpp + common/servslkf.cpp + common/sharedobject.cpp + common/simpleformatter.cpp + common/static_unicode_sets.cpp + common/stringpiece.cpp + common/stringtriebuilder.cpp + common/uarrsort.cpp + common/ubidi.cpp + common/ubidi_props.cpp + common/ubidiln.cpp + common/ubiditransform.cpp + common/ubidiwrt.cpp + common/ubrk.cpp + common/ucase.cpp + common/ucasemap.cpp + common/ucasemap_titlecase_brkiter.cpp + common/ucat.cpp + common/uchar.cpp + common/ucharstrie.cpp + common/ucharstriebuilder.cpp + common/ucharstrieiterator.cpp + common/uchriter.cpp + common/ucln_cmn.cpp + common/ucmndata.cpp + common/ucnv.cpp + common/ucnv2022.cpp + common/ucnv_bld.cpp + common/ucnv_cb.cpp + common/ucnv_cnv.cpp + common/ucnv_ct.cpp + common/ucnv_err.cpp + common/ucnv_ext.cpp + common/ucnv_io.cpp + common/ucnv_lmb.cpp + common/ucnv_set.cpp + common/ucnv_u16.cpp + common/ucnv_u32.cpp + common/ucnv_u7.cpp + common/ucnv_u8.cpp + common/ucnvbocu.cpp + common/ucnvdisp.cpp + common/ucnvhz.cpp + common/ucnvisci.cpp + common/ucnvlat1.cpp + common/ucnvmbcs.cpp + common/ucnvscsu.cpp + common/ucnvsel.cpp + common/ucol_swp.cpp + common/ucptrie.cpp + common/ucurr.cpp + common/udata.cpp + common/udatamem.cpp + common/udataswp.cpp + common/uenum.cpp + common/uhash.cpp + common/uhash_us.cpp + common/uidna.cpp + common/uinit.cpp + common/uinvchar.cpp + common/uiter.cpp + common/ulist.cpp + common/uloc.cpp + common/uloc_keytype.cpp + common/uloc_tag.cpp + common/umapfile.cpp + common/umath.cpp + common/umutablecptrie.cpp + common/umutex.cpp + common/unames.cpp + common/unifiedcache.cpp + common/unifilt.cpp + common/unifunct.cpp + common/uniset.cpp + common/uniset_closure.cpp + common/uniset_props.cpp + common/unisetspan.cpp + common/unistr.cpp + common/unistr_case.cpp + common/unistr_case_locale.cpp + common/unistr_cnv.cpp + common/unistr_props.cpp + common/unistr_titlecase_brkiter.cpp + common/unorm.cpp + common/unormcmp.cpp + common/uobject.cpp + common/uprops.cpp + common/ures_cnv.cpp + common/uresbund.cpp + common/uresdata.cpp + common/usc_impl.cpp + common/uscript.cpp + common/uscript_props.cpp + common/uset.cpp + common/uset_props.cpp + common/usetiter.cpp + common/ushape.cpp + common/usprep.cpp + common/ustack.cpp + common/ustr_cnv.cpp + common/ustr_titlecase_brkiter.cpp + common/ustr_wcs.cpp + common/ustrcase.cpp + common/ustrcase_locale.cpp + common/ustrenum.cpp + common/ustrfmt.cpp + common/ustring.cpp + common/ustrtrns.cpp + common/utext.cpp + common/utf_impl.cpp + common/util.cpp + common/util_props.cpp + common/utrace.cpp + common/utrie.cpp + common/utrie2.cpp + common/utrie2_builder.cpp + common/utrie_swap.cpp + common/uts46.cpp + common/utypes.cpp + common/uvector.cpp + common/uvectr32.cpp + common/uvectr64.cpp + common/wintz.cpp + i18n/alphaindex.cpp + i18n/anytrans.cpp + i18n/astro.cpp + i18n/basictz.cpp + i18n/bocsu.cpp + i18n/brktrans.cpp + i18n/buddhcal.cpp + i18n/calendar.cpp + i18n/casetrn.cpp + i18n/cecal.cpp + i18n/chnsecal.cpp + i18n/choicfmt.cpp + i18n/coleitr.cpp + i18n/coll.cpp + i18n/collation.cpp + i18n/collationbuilder.cpp + i18n/collationcompare.cpp + i18n/collationdata.cpp + i18n/collationdatabuilder.cpp + i18n/collationdatareader.cpp + i18n/collationdatawriter.cpp + i18n/collationfastlatin.cpp + i18n/collationfastlatinbuilder.cpp + i18n/collationfcd.cpp + i18n/collationiterator.cpp + i18n/collationkeys.cpp + i18n/collationroot.cpp + i18n/collationrootelements.cpp + i18n/collationruleparser.cpp + i18n/collationsets.cpp + i18n/collationsettings.cpp + i18n/collationtailoring.cpp + i18n/collationweights.cpp + i18n/compactdecimalformat.cpp + i18n/coptccal.cpp + i18n/cpdtrans.cpp + i18n/csdetect.cpp + i18n/csmatch.cpp + i18n/csr2022.cpp + i18n/csrecog.cpp + i18n/csrmbcs.cpp + i18n/csrsbcs.cpp + i18n/csrucode.cpp + i18n/csrutf8.cpp + i18n/curramt.cpp + i18n/currfmt.cpp + i18n/currpinf.cpp + i18n/currunit.cpp + i18n/dangical.cpp + i18n/datefmt.cpp + i18n/dayperiodrules.cpp + i18n/dcfmtsym.cpp + i18n/decContext.cpp + i18n/decNumber.cpp + i18n/decimfmt.cpp + i18n/double-conversion-bignum-dtoa.cpp + i18n/double-conversion-bignum.cpp + i18n/double-conversion-cached-powers.cpp + i18n/double-conversion-double-to-string.cpp + i18n/double-conversion-fast-dtoa.cpp + i18n/double-conversion-string-to-double.cpp + i18n/double-conversion-strtod.cpp + i18n/dtfmtsym.cpp + i18n/dtitvfmt.cpp + i18n/dtitvinf.cpp + i18n/dtptngen.cpp + i18n/dtrule.cpp + i18n/erarules.cpp + i18n/esctrn.cpp + i18n/ethpccal.cpp + i18n/fmtable.cpp + i18n/fmtable_cnv.cpp + i18n/format.cpp + i18n/formatted_string_builder.cpp + i18n/formattedval_iterimpl.cpp + i18n/formattedval_sbimpl.cpp + i18n/formattedvalue.cpp + i18n/fphdlimp.cpp + i18n/fpositer.cpp + i18n/funcrepl.cpp + i18n/gender.cpp + i18n/gregocal.cpp + i18n/gregoimp.cpp + i18n/hebrwcal.cpp + i18n/indiancal.cpp + i18n/inputext.cpp + i18n/islamcal.cpp + i18n/japancal.cpp + i18n/listformatter.cpp + i18n/measfmt.cpp + i18n/measunit.cpp + i18n/measunit_extra.cpp + i18n/measure.cpp + i18n/msgfmt.cpp + i18n/name2uni.cpp + i18n/nfrs.cpp + i18n/nfrule.cpp + i18n/nfsubs.cpp + i18n/nortrans.cpp + i18n/nounit.cpp + i18n/nultrans.cpp + i18n/number_affixutils.cpp + i18n/number_asformat.cpp + i18n/number_capi.cpp + i18n/number_compact.cpp + i18n/number_currencysymbols.cpp + i18n/number_decimalquantity.cpp + i18n/number_decimfmtprops.cpp + i18n/number_fluent.cpp + i18n/number_formatimpl.cpp + i18n/number_grouping.cpp + i18n/number_integerwidth.cpp + i18n/number_longnames.cpp + i18n/number_mapper.cpp + i18n/number_modifiers.cpp + i18n/number_multiplier.cpp + i18n/number_notation.cpp + i18n/number_output.cpp + i18n/number_padding.cpp + i18n/number_patternmodifier.cpp + i18n/number_patternstring.cpp + i18n/number_rounding.cpp + i18n/number_scientific.cpp + i18n/number_skeletons.cpp + i18n/number_utils.cpp + i18n/numfmt.cpp + i18n/numparse_affixes.cpp + i18n/numparse_compositions.cpp + i18n/numparse_currency.cpp + i18n/numparse_decimal.cpp + i18n/numparse_impl.cpp + i18n/numparse_parsednumber.cpp + i18n/numparse_scientific.cpp + i18n/numparse_symbols.cpp + i18n/numparse_validators.cpp + i18n/numrange_fluent.cpp + i18n/numrange_impl.cpp + i18n/numsys.cpp + i18n/olsontz.cpp + i18n/persncal.cpp + i18n/plurfmt.cpp + i18n/plurrule.cpp + i18n/quant.cpp + i18n/quantityformatter.cpp + i18n/rbnf.cpp + i18n/rbt.cpp + i18n/rbt_data.cpp + i18n/rbt_pars.cpp + i18n/rbt_rule.cpp + i18n/rbt_set.cpp + i18n/rbtz.cpp + i18n/regexcmp.cpp + i18n/regeximp.cpp + i18n/regexst.cpp + i18n/regextxt.cpp + i18n/region.cpp + i18n/reldatefmt.cpp + i18n/reldtfmt.cpp + i18n/rematch.cpp + i18n/remtrans.cpp + i18n/repattrn.cpp + i18n/rulebasedcollator.cpp + i18n/scientificnumberformatter.cpp + i18n/scriptset.cpp + i18n/search.cpp + i18n/selfmt.cpp + i18n/sharedbreakiterator.cpp + i18n/simpletz.cpp + i18n/smpdtfmt.cpp + i18n/smpdtfst.cpp + i18n/sortkey.cpp + i18n/standardplural.cpp + i18n/string_segment.cpp + i18n/strmatch.cpp + i18n/strrepl.cpp + i18n/stsearch.cpp + i18n/taiwncal.cpp + i18n/timezone.cpp + i18n/titletrn.cpp + i18n/tmunit.cpp + i18n/tmutamt.cpp + i18n/tmutfmt.cpp + i18n/tolowtrn.cpp + i18n/toupptrn.cpp + i18n/translit.cpp + i18n/transreg.cpp + i18n/tridpars.cpp + i18n/tzfmt.cpp + i18n/tzgnames.cpp + i18n/tznames.cpp + i18n/tznames_impl.cpp + i18n/tzrule.cpp + i18n/tztrans.cpp + i18n/ucal.cpp + i18n/ucln_in.cpp + i18n/ucol.cpp + i18n/ucol_res.cpp + i18n/ucol_sit.cpp + i18n/ucoleitr.cpp + i18n/ucsdet.cpp + i18n/udat.cpp + i18n/udateintervalformat.cpp + i18n/udatpg.cpp + i18n/ufieldpositer.cpp + i18n/uitercollationiterator.cpp + i18n/ulistformatter.cpp + i18n/ulocdata.cpp + i18n/umsg.cpp + i18n/unesctrn.cpp + i18n/uni2name.cpp + i18n/unum.cpp + i18n/unumsys.cpp + i18n/upluralrules.cpp + i18n/uregex.cpp + i18n/uregexc.cpp + i18n/uregion.cpp + i18n/usearch.cpp + i18n/uspoof.cpp + i18n/uspoof_build.cpp + i18n/uspoof_conf.cpp + i18n/uspoof_impl.cpp + i18n/utf16collationiterator.cpp + i18n/utf8collationiterator.cpp + i18n/utmscale.cpp + i18n/utrans.cpp + i18n/vtzone.cpp + i18n/vzone.cpp + i18n/windtfmt.cpp + i18n/winnmfmt.cpp + i18n/wintzimpl.cpp + i18n/zonemeta.cpp + i18n/zrule.cpp + i18n/ztrans.cpp + icudt67_dat.rodata + io/locbund.cpp + io/sprintf.cpp + io/sscanf.cpp + io/ucln_io.cpp + io/ufile.cpp + io/ufmt_cmn.cpp + io/uprintf.cpp + io/uprntf_p.cpp + io/uscanf.cpp + io/uscanf_p.cpp + io/ustdio.cpp + io/ustream.cpp +) + +END() diff --git a/contrib/libs/jemalloc/ya.make b/contrib/libs/jemalloc/ya.make new file mode 100644 index 00000000000..219fd3206e4 --- /dev/null +++ b/contrib/libs/jemalloc/ya.make @@ -0,0 +1,116 @@ +# Generated by devtools/yamaker from nixpkgs 21.11. + +LIBRARY() + +LICENSE( + BSD-2-Clause AND + BSD-2-Clause-Views AND + BSD-3-Clause AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(5.3.0) + +ORIGINAL_SOURCE(https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2) + +ADDINCL( + contrib/libs/jemalloc/include + contrib/libs/libunwind/include +) + +IF (OS_WINDOWS) + ADDINCL( + contrib/libs/jemalloc/include/msvc_compat + ) +ELSE() + CFLAGS( + -funroll-loops + ) + IF (OS_DARWIN OR OS_IOS) + SRCS( + GLOBAL reg_zone.cpp + src/zone.c + ) + ELSE() + PEERDIR( + contrib/libs/libunwind + ) + CFLAGS( + -fvisibility=hidden + ) + ENDIF() +ENDIF() + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + src/arena.c + src/background_thread.c + src/base.c + src/bin.c + src/bin_info.c + src/bitmap.c + src/buf_writer.c + src/cache_bin.c + src/ckh.c + src/counter.c + src/ctl.c + src/decay.c + src/div.c + src/ecache.c + src/edata.c + src/edata_cache.c + src/ehooks.c + src/emap.c + src/eset.c + src/exp_grow.c + src/extent.c + src/extent_dss.c + src/extent_mmap.c + src/fxp.c + src/hook.c + src/hpa.c + src/hpa_hooks.c + src/hpdata.c + src/inspect.c + src/jemalloc.c + src/jemalloc_cpp.cpp + src/large.c + src/log.c + src/malloc_io.c + src/mutex.c + src/nstime.c + src/pa.c + src/pa_extra.c + src/pac.c + src/pages.c + src/pai.c + src/peak_event.c + src/prof.c + src/prof_data.c + src/prof_log.c + src/prof_recent.c + src/prof_stats.c + src/prof_sys.c + src/psset.c + src/rtree.c + src/safety_check.c + src/san.c + src/san_bump.c + src/sc.c + src/sec.c + src/stats.c + src/sz.c + src/tcache.c + src/test_hooks.c + src/thread_event.c + src/ticker.c + src/tsd.c + src/witness.c +) + +END() diff --git a/contrib/libs/jwt-cpp/ya.make b/contrib/libs/jwt-cpp/ya.make new file mode 100644 index 00000000000..f5372b7cd88 --- /dev/null +++ b/contrib/libs/jwt-cpp/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.4.0) + +ORIGINAL_SOURCE(https://github.com/Thalhammer/jwt-cpp/archive/v0.4.0.tar.gz) + +PEERDIR( + contrib/libs/openssl +) + +ADDINCL( + ONE_LEVEL + contrib/libs/jwt-cpp/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +END() diff --git a/contrib/libs/libaio/dynamic/ya.make b/contrib/libs/libaio/dynamic/ya.make new file mode 100644 index 00000000000..e804dd1f40c --- /dev/null +++ b/contrib/libs/libaio/dynamic/ya.make @@ -0,0 +1,17 @@ +# Generated by devtools/yamaker. + +DYNAMIC_LIBRARY() + +LICENSE( + LGPL-2.0-or-later AND + LGPL-2.1-only AND + Linux-syscall-note-in-syscall-glue +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +DYNAMIC_LIBRARY_FROM(contrib/libs/libaio/static) + +NO_RUNTIME() + +END() diff --git a/contrib/libs/libaio/static/ya.make b/contrib/libs/libaio/static/ya.make new file mode 100644 index 00000000000..b540cd41b18 --- /dev/null +++ b/contrib/libs/libaio/static/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + LGPL-2.0-or-later AND + LGPL-2.1-only AND + Linux-syscall-note-in-syscall-glue +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/libs/libaio/include + contrib/libs/libaio/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/libs/libaio/src) + +SRCS( + io_cancel.c + io_destroy.c + io_getevents.c + io_pgetevents.c + io_queue_init.c + io_queue_release.c + io_queue_run.c + io_queue_wait.c + io_setup.c + io_submit.c + raw_syscall.c +) + +END() diff --git a/contrib/libs/libaio/ya.make b/contrib/libs/libaio/ya.make new file mode 100644 index 00000000000..1c3137f6300 --- /dev/null +++ b/contrib/libs/libaio/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +VERSION(0.3.113) + +LICENSE(Service-Dll-Harness) + +NO_RUNTIME() + +IF (EXPORT_CMAKE) + OPENSOURCE_EXPORT_REPLACEMENT( + CMAKE + AIO + CMAKE_TARGET + AIO::aio + ) +ELSEIF (USE_DYNAMIC_AIO) + PEERDIR( + contrib/libs/libaio/dynamic + ) +ELSE() + PEERDIR( + contrib/libs/libaio/static + ) +ENDIF() + +END() + +RECURSE( + dynamic + static +) diff --git a/contrib/libs/libbz2/ya.make b/contrib/libs/libbz2/ya.make new file mode 100644 index 00000000000..f0d4be088d2 --- /dev/null +++ b/contrib/libs/libbz2/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + bzip2-1.0.6 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.0.8) + +ORIGINAL_SOURCE(https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +IF (SANITIZER_TYPE == undefined) + NO_SANITIZE() +ENDIF() + +SRCS( + blocksort.c + bzlib.c + compress.c + crctable.c + decompress.c + huffman.c + randtable.c +) + +END() diff --git a/contrib/libs/libc_compat/ubuntu_14/ya.make b/contrib/libs/libc_compat/ubuntu_14/ya.make new file mode 100644 index 00000000000..b32d30f3ac0 --- /dev/null +++ b/contrib/libs/libc_compat/ubuntu_14/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +NO_SANITIZE_HEADERS() + +NO_PLATFORM() + +NO_RUNTIME() + +NO_UTIL() + +DISABLE(NEED_PLATFORM_PEERDIRS) +DISABLE(OPENSOURCE_EXPORT) + +IF (OS_SDK == "ubuntu-14") + PEERDIR( + build/platform/linux_sdk + ) + SRCS( + aligned_alloc.c + c16rtomb.c + c32rtomb.c + getauxval.cpp + mbrtoc16.c + mbrtoc32.c + secure_getenv.cpp + timespec_get.c + ) + SRC_C_PIC( + glibc.cpp + -fno-lto + ) +ENDIF() + +END() diff --git a/contrib/libs/libc_compat/ya.make b/contrib/libs/libc_compat/ya.make new file mode 100644 index 00000000000..42e1116d450 --- /dev/null +++ b/contrib/libs/libc_compat/ya.make @@ -0,0 +1,158 @@ +LIBRARY() + +LICENSE( + BSD-1-Clause AND + BSD-2-Clause AND + BSD-3-Clause AND + ISC +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_SANITIZE_HEADERS() + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +NO_RUNTIME() + +IF (NOT OS_WINDOWS) + SRCS( + string.c + ) +ENDIF() + +DISABLE(PROVIDE_GETRANDOM_GETENTROPY) +DISABLE(PROVIDE_REALLOCARRAY) + +# Android libc function appearance is documented here: +# https://android.googlesource.com/platform/bionic/+/master/docs/status.md +# +# NB: nested IF's are needed due to the lack of lazy evaluation of logical statements: DEVTOOLS-7837 +IF (OS_ANDROID) + SRCS( + strlcat.c + strlcpy.c + ) + IF (ANDROID_API < 28) + SRCS( + glob.c + ) + ENABLE(PROVIDE_REALLOCARRAY) + ENDIF() + IF (ANDROID_API < 24) + SRCS( + ifaddrs.c + ) + ADDINCL( + GLOBAL contrib/libs/libc_compat/include/ifaddrs + ) + ENDIF() + IF (ANDROID_API < 21) + SRCS( + stpcpy.c + ) + ENDIF() +ENDIF() + +IF (OS_WINDOWS OR OS_DARWIN OR OS_IOS) + SRCS( + memrchr.c + ) +ENDIF() + +IF (OS_DARWIN) + SRCS( + explicit_bzero.c + ) + ENABLE(PROVIDE_REALLOCARRAY) +ENDIF() + +IF (OS_WINDOWS) + ADDINCL( + GLOBAL contrib/libs/libc_compat/include/windows + ) + SRCS( + explicit_bzero.c + stpcpy.c + strlcat.c + strlcpy.c + strcasestr.c + strsep.c + src/windows/sys/uio.c + ) + ENABLE(PROVIDE_REALLOCARRAY) +ENDIF() + +IF (OS_LINUX) + ADDINCL( + GLOBAL contrib/libs/libc_compat/include/readpassphrase + ) + SRCS( + readpassphrase.c + ) +ENDIF() + +IF (OS_LINUX AND NOT MUSL) + IF (OS_SDK == "ubuntu-12") + ADDINCL( + # uchar.h was introduced in glibc=2.16 + GLOBAL contrib/libs/libc_compat/include/uchar + ) + ENDIF() + IF (OS_SDK == "ubuntu-12" OR OS_SDK == "ubuntu-14" OR OS_SDK == "ubuntu-16") + # getrandom and getentropy were added in glibc=2.25 + ENABLE(PROVIDE_GETRANDOM_GETENTROPY) + + SRCS( + # explicit_bzero was added in glibc=2.25 + explicit_bzero.c + # memfd_create was added in glibc=2.27 + memfd_create.c + ) + ENDIF() + IF (OS_SDK != "ubuntu-20") + # reallocarray was added in glibc=2.29 + ENABLE(PROVIDE_REALLOCARRAY) + ENDIF() + SRCS( + # glibc does not offer strlcat / strlcpy yet + strlcat.c + strlcpy.c + ) + IF (SANITIZER_TYPE == "memory") + # llvm sanitized runtime is missing an interceptor for a buggy (getservbyname{_r}). + # See: https://github.com/google/sanitizers/issues/1138 + ENABLE(PROVIDE_GETSERVBYNAME) + ENDIF() +ENDIF() + +IF (PROVIDE_REALLOCARRAY) + SRCS( + reallocarray/reallocarray.c + ) + ADDINCL( + ONE_LEVEL contrib/libs/libc_compat/reallocarray + ) +ENDIF() + +IF (PROVIDE_GETRANDOM_GETENTROPY) + SRCS( + random/getrandom.c + random/getentropy.c + ) + ADDINCL( + ONE_LEVEL contrib/libs/libc_compat/random + ) +ENDIF() + +IF (PROVIDE_GETSERVBYNAME) + SRCS( + getservbyname/getservbyname.c + getservbyname/getservbyname_r.c + getservbyname/lookup_serv.c + ) +ENDIF() + +END() diff --git a/contrib/libs/libevent/event_core/ya.make b/contrib/libs/libevent/event_core/ya.make new file mode 100644 index 00000000000..bcbe22a6593 --- /dev/null +++ b/contrib/libs/libevent/event_core/ya.make @@ -0,0 +1,73 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +PEERDIR( + contrib/libs/libc_compat +) + +ADDINCL( + contrib/libs/libevent + contrib/libs/libevent/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DEVENT__HAVE_STRLCPY=1 +) + +SRCDIR(contrib/libs/libevent) + +SRCS( + buffer.c + bufferevent.c + bufferevent_filter.c + bufferevent_pair.c + bufferevent_ratelim.c + bufferevent_sock.c + event.c + evmap.c + evthread.c + evutil.c + evutil_rand.c + evutil_time.c + listener.c + log.c + signal.c +) + +IF (OS_WINDOWS) + SRCS( + buffer_iocp.c + bufferevent_async.c + event_iocp.c + win32select.c + ) +ELSE() + SRCS( + poll.c + select.c + ) +ENDIF() + +IF (OS_LINUX) + SRCS( + epoll.c + ) +ENDIF() + +IF (OS_FREEBSD OR OS_DARWIN) + SRCS( + kqueue.c + ) +ENDIF() + +END() diff --git a/contrib/libs/libevent/event_extra/ya.make b/contrib/libs/libevent/event_extra/ya.make new file mode 100644 index 00000000000..3d559665f38 --- /dev/null +++ b/contrib/libs/libevent/event_extra/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +PEERDIR( + contrib/libs/libc_compat +) + +ADDINCL( + contrib/libs/libevent + contrib/libs/libevent/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DEVENT__HAVE_STRLCPY=1 +) + +SRCDIR(contrib/libs/libevent) + +SRCS( + evdns.c + event_tagging.c + evrpc.c + http.c +) + +END() diff --git a/contrib/libs/libevent/event_openssl/ya.make b/contrib/libs/libevent/event_openssl/ya.make new file mode 100644 index 00000000000..4c85d19549d --- /dev/null +++ b/contrib/libs/libevent/event_openssl/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +PEERDIR( + contrib/libs/libc_compat + contrib/libs/openssl +) + +ADDINCL( + contrib/libs/libevent + contrib/libs/libevent/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DEVENT__HAVE_STRLCPY=1 +) + +SRCDIR(contrib/libs/libevent) + +SRCS( + bufferevent_openssl.c +) + +END() diff --git a/contrib/libs/libevent/event_thread/ya.make b/contrib/libs/libevent/event_thread/ya.make new file mode 100644 index 00000000000..85d171f96aa --- /dev/null +++ b/contrib/libs/libevent/event_thread/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +PEERDIR( + contrib/libs/libc_compat +) + +ADDINCL( + contrib/libs/libevent + contrib/libs/libevent/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DEVENT__HAVE_STRLCPY=1 +) + +SRCDIR(contrib/libs/libevent) + +IF (OS_WINDOWS) + SRCS( + evthread_win32.c + ) +ELSE() + SRCS( + evthread_pthread.c + ) +ENDIF() + +END() diff --git a/contrib/libs/libevent/ya.make b/contrib/libs/libevent/ya.make new file mode 100644 index 00000000000..33db27e2739 --- /dev/null +++ b/contrib/libs/libevent/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +VERSION(2.1.12) + +ORIGINAL_SOURCE(https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz) + +LICENSE( + BSD-3-Clause AND + CC-PDDC AND + ISC AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/libevent/event_core + contrib/libs/libevent/event_extra + contrib/libs/libevent/event_openssl + contrib/libs/libevent/event_thread +) + +ADDINCL( + GLOBAL contrib/libs/libevent/include + contrib/libs/libevent +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DEVENT__HAVE_STRLCPY=1 +) + +END() + +RECURSE( + event_core + event_extra + event_openssl + event_thread +) diff --git a/contrib/libs/libf2c/ya.make b/contrib/libs/libf2c/ya.make new file mode 100644 index 00000000000..78d9f5728d3 --- /dev/null +++ b/contrib/libs/libf2c/ya.make @@ -0,0 +1,188 @@ +LIBRARY() + +LICENSE(SMLNJ) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2014-07-11) + +NO_COMPILER_WARNINGS() + +ADDINCL(GLOBAL contrib/libs/libf2c) + +CFLAGS( + -DNO_FPINIT + -DSkip_f2c_Undefs + -DNO_My_ctype +) + +IF (OS_WINDOWS) + CFLAGS( + -DMSDOS + -DNO_ISATTY + -DNO_TRUNCATE + -DNO_ISATTY + -DNON_POSIX_STDIO + ) +ENDIF() + +SRCS( + abort_.c + backspac.c + c_abs.c + c_cos.c + c_div.c + c_exp.c + c_log.c + c_sin.c + c_sqrt.c + cabs.c + close.c + ctype.c + d_abs.c + d_acos.c + d_asin.c + d_atan.c + d_atn2.c + d_cnjg.c + d_cos.c + d_cosh.c + d_dim.c + d_exp.c + d_imag.c + d_int.c + d_lg10.c + d_log.c + d_mod.c + d_nint.c + d_prod.c + d_sign.c + d_sin.c + d_sinh.c + d_sqrt.c + d_tan.c + d_tanh.c + derf_.c + derfc_.c + dfe.c + dolio.c + dtime_.c + due.c + ef1asc_.c + ef1cmc_.c + endfile.c + erf_.c + erfc_.c + err.c + etime_.c + exit_.c + f77_aloc.c + f77vers.c + fmt.c + fmtlib.c + ftell_.c + getarg_.c + getenv_.c + h_abs.c + h_dim.c + h_dnnt.c + h_indx.c + h_len.c + h_mod.c + h_nint.c + h_sign.c + hl_ge.c + hl_gt.c + hl_le.c + hl_lt.c + i77vers.c + i_abs.c + i_ceiling.c + i_dim.c + i_dnnt.c + i_indx.c + i_len.c + i_len_trim.c + i_mod.c + i_nint.c + i_sign.c + iargc_.c + iio.c + ilnw.c + inquire.c + l_ge.c + l_gt.c + l_le.c + l_lt.c + lbitbits.c + lbitshft.c + lread.c + lwrite.c + #main.c + open.c + pow_ci.c + pow_dd.c + pow_di.c + pow_hh.c + pow_ii.c + pow_ri.c + pow_zi.c + pow_zz.c + r_abs.c + r_acos.c + r_asin.c + r_atan.c + r_atn2.c + r_cnjg.c + r_cos.c + r_cosh.c + r_dim.c + r_exp.c + r_imag.c + r_int.c + r_lg10.c + r_log.c + r_mod.c + r_nint.c + r_sign.c + r_sin.c + r_sinh.c + r_sqrt.c + r_tan.c + r_tanh.c + rdfmt.c + rewind.c + rsfe.c + rsli.c + rsne.c + s_cat.c + s_cmp.c + s_copy.c + s_paus.c + s_rnge.c + s_stop.c + sfe.c + sig_die.c + signal_.c + sue.c + system_.c + typesize.c + uio.c + uninit.c + util.c + wref.c + wrtfmt.c + wsfe.c + wsle.c + wsne.c + xwsne.c + z_abs.c + z_cos.c + z_div.c + z_exp.c + z_log.c + z_sin.c + z_sqrt.c +) + +END() diff --git a/contrib/libs/libfuzzer/ya.make b/contrib/libs/libfuzzer/ya.make new file mode 100644 index 00000000000..a4f5ab64b06 --- /dev/null +++ b/contrib/libs/libfuzzer/ya.make @@ -0,0 +1,72 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Apache-2.0 WITH LLVM-exception AND + MIT AND + NCSA AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(15.0.5) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/llvmorg-15.0.5.tar.gz) + +SET(SANITIZER_CFLAGS) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (SANITIZE_COVERAGE MATCHES "trace-pc") + MESSAGE(FATAL_ERROR "I will crash you with trace-pc or trace-pc-guard. Use inline-8bit-counters.") +ENDIF() + +NO_SANITIZE_COVERAGE() + +IF (SANITIZER_TYPE == "undefined") + NO_SANITIZE() +ENDIF() + +IF (OS_WINDOWS) + SRCS( + lib/fuzzer/standalone/StandaloneFuzzTargetMain.c + ) +ELSE() + SRCS( + lib/fuzzer/FuzzerCrossOver.cpp + lib/fuzzer/FuzzerDataFlowTrace.cpp + lib/fuzzer/FuzzerDriver.cpp + lib/fuzzer/FuzzerExtFunctionsDlsym.cpp + lib/fuzzer/FuzzerExtFunctionsWeak.cpp + lib/fuzzer/FuzzerExtFunctionsWindows.cpp + lib/fuzzer/FuzzerExtraCounters.cpp + lib/fuzzer/FuzzerExtraCountersDarwin.cpp + lib/fuzzer/FuzzerExtraCountersWindows.cpp + lib/fuzzer/FuzzerFork.cpp + lib/fuzzer/FuzzerIO.cpp + lib/fuzzer/FuzzerIOPosix.cpp + lib/fuzzer/FuzzerIOWindows.cpp + lib/fuzzer/FuzzerLoop.cpp + lib/fuzzer/FuzzerMain.cpp + lib/fuzzer/FuzzerMerge.cpp + lib/fuzzer/FuzzerMutate.cpp + lib/fuzzer/FuzzerSHA1.cpp + lib/fuzzer/FuzzerTracePC.cpp + lib/fuzzer/FuzzerUtil.cpp + lib/fuzzer/FuzzerUtilDarwin.cpp + lib/fuzzer/FuzzerUtilLinux.cpp + lib/fuzzer/FuzzerUtilPosix.cpp + lib/fuzzer/FuzzerUtilWindows.cpp + ) +ENDIF() + +END() + +RECURSE( + lib/fuzzer/afl +) diff --git a/contrib/libs/libfyaml/ya.make b/contrib/libs/libfyaml/ya.make new file mode 100644 index 00000000000..d66967c769b --- /dev/null +++ b/contrib/libs/libfyaml/ya.make @@ -0,0 +1,55 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.8) + +ORIGINAL_SOURCE(https://github.com/pantoniou/libfyaml/archive/v0.8.tar.gz) + +PEERDIR( + contrib/libs/xxhash +) + +ADDINCL( + contrib/libs/libfyaml + contrib/libs/libfyaml/include + contrib/libs/libfyaml/src + contrib/libs/libfyaml/src/lib + contrib/libs/xxhash +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H +) + +SRCS( + src/lib/fy-accel.c + src/lib/fy-atom.c + src/lib/fy-composer.c + src/lib/fy-ctype.c + src/lib/fy-diag.c + src/lib/fy-doc.c + src/lib/fy-docbuilder.c + src/lib/fy-docstate.c + src/lib/fy-dump.c + src/lib/fy-emit.c + src/lib/fy-event.c + src/lib/fy-input.c + src/lib/fy-parse.c + src/lib/fy-path.c + src/lib/fy-token.c + src/lib/fy-types.c + src/lib/fy-utf8.c + src/lib/fy-utils.c + src/lib/fy-walk.c +) + +END() diff --git a/contrib/libs/libiconv/dynamic/ya.make b/contrib/libs/libiconv/dynamic/ya.make new file mode 100644 index 00000000000..45e97b5aa79 --- /dev/null +++ b/contrib/libs/libiconv/dynamic/ya.make @@ -0,0 +1,20 @@ +DYNAMIC_LIBRARY(iconv) + +VERSION(1.13) + +LICENSE( + LGPL-2.0-only + LGPL-2.0-or-later +) + +LICENSE_TEXTS(../.yandex_meta/licenses.list.txt) + +PROVIDES(libiconv) + +NO_RUNTIME() + +EXPORTS_SCRIPT(libiconv.exports) + +DYNAMIC_LIBRARY_FROM(contrib/libs/libiconv/static) + +END() diff --git a/contrib/libs/libiconv/static/ya.make b/contrib/libs/libiconv/static/ya.make new file mode 100644 index 00000000000..df894580468 --- /dev/null +++ b/contrib/libs/libiconv/static/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +VERSION(1.13) + +LICENSE( + LGPL-2.0-only AND + LGPL-2.0-or-later +) + +LICENSE_TEXTS(../.yandex_meta/licenses.list.txt) + +PROVIDES(libiconv) + +NO_RUNTIME() + +NO_COMPILER_WARNINGS() + +IF (ARCADIA_ICONV_NOCJK) + CFLAGS( + -DARCADIA_ICONV_NOCJK + ) +ENDIF() + +SRCDIR(contrib/libs/libiconv) +ADDINCL(GLOBAL contrib/libs/libiconv/include) + +SRCS( + iconv.c +) + +END() diff --git a/contrib/libs/libiconv/ya.make b/contrib/libs/libiconv/ya.make new file mode 100644 index 00000000000..6d6b1141b93 --- /dev/null +++ b/contrib/libs/libiconv/ya.make @@ -0,0 +1,45 @@ +LIBRARY() + +VERSION(1.13) + +LICENSE(Service-Dll-Harness) + +WITHOUT_LICENSE_TEXTS() + +NO_RUNTIME() + +IF(OS_WINDOWS) + OPENSOURCE_EXPORT_REPLACEMENT( + CMAKE Iconv + CMAKE_TARGET Iconv::Iconv + CONAN libiconv/1.15 + CONAN_OPTIONS libiconv:shared=True + ) +ELSE() + # Opensource code is compatible with libc provided iconv API on major linux distributions and macos. + # * We prefere to avoid vendoring LGPL libraries in our opensouce project + # * Major distributions do not provide GNU libiconv as separate package + # * Shared lib dependencies from conan overcomplicate final artefacts distribution + DISABLE(OPENSOURCE_EXPORT) +ENDIF() + +IF (NOT EXPORT_CMAKE) + +IF (USE_DYNAMIC_ICONV) + PEERDIR( + contrib/libs/libiconv/dynamic + ) +ELSE() + PEERDIR( + contrib/libs/libiconv/static + ) +ENDIF() + +ENDIF() + +END() + +RECURSE( + dynamic + static +) diff --git a/contrib/libs/libidn/dynamic/ya.make b/contrib/libs/libidn/dynamic/ya.make new file mode 100644 index 00000000000..8bb40b769bd --- /dev/null +++ b/contrib/libs/libidn/dynamic/ya.make @@ -0,0 +1,25 @@ +# Generated by devtools/yamaker. + +DYNAMIC_LIBRARY() + +LICENSE( + "(GPL-2.0-or-later OR LGPL-3.0-or-later OR GPL-3.0-or-later)" AND + "(LGPL-3.0-or-later OR GPL-2.0-or-later)" AND + Custom-punycode AND + FSFAP AND + LGPL-2.0-or-later AND + LGPL-2.1-only AND + LGPL-2.1-or-later AND + LGPL-3.0-only AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +DYNAMIC_LIBRARY_FROM(contrib/libs/libidn/static) + +NO_RUNTIME() + +EXPORTS_SCRIPT(libidn.exports) + +END() diff --git a/contrib/libs/libidn/static/ya.make b/contrib/libs/libidn/static/ya.make new file mode 100644 index 00000000000..f5c36b72044 --- /dev/null +++ b/contrib/libs/libidn/static/ya.make @@ -0,0 +1,86 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + "(GPL-2.0-or-later OR LGPL-3.0-or-later OR GPL-3.0-or-later)" AND + "(LGPL-3.0-or-later OR GPL-2.0-or-later)" AND + Custom-punycode AND + FSFAP AND + LGPL-2.0-or-later AND + LGPL-2.1-only AND + LGPL-2.1-or-later AND + LGPL-3.0-only AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/libiconv +) + +ADDINCL( + GLOBAL contrib/libs/libidn/include + contrib/libs/libidn + contrib/libs/libidn/gl + contrib/libs/libidn/lib + contrib/libs/libidn/lib/gl +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DLIBIDN_BUILDING + -DLOCALEDIR=\"/tmp/yamaker/libidn/out/share/locale\" +) + +SRCDIR(contrib/libs/libidn) + +SRCS( + gl/basename-lgpl.c + gl/fd-hook.c + gl/malloca.c + gl/stat-time.c + lib/gl/c-ctype.c + lib/gl/c-strcasecmp.c + lib/gl/c-strncasecmp.c + lib/gl/striconv.c + lib/gl/unistr/u8-check.c + lib/gl/unistr/u8-mbtoucr.c + lib/gl/unistr/u8-uctomb-aux.c + lib/gl/unistr/u8-uctomb.c + lib/idn-free.c + lib/idna.c + lib/nfkc.c + lib/pr29.c + lib/profiles.c + lib/punycode.c + lib/rfc3454.c + lib/strerror-idna.c + lib/strerror-pr29.c + lib/strerror-punycode.c + lib/strerror-stringprep.c + lib/strerror-tld.c + lib/stringprep.c + lib/tld.c + lib/tlds.c + lib/toutf8.c + lib/version.c +) + +IF (OS_LINUX) + SRCS( + gl/getprogname.c + ) +ELSEIF (OS_WINDOWS) + SRCS( + gl/getprogname.c + lib/gl/strverscmp.c + ) +ENDIF() + +END() diff --git a/contrib/libs/libidn/ya.make b/contrib/libs/libidn/ya.make new file mode 100644 index 00000000000..1685231bbc6 --- /dev/null +++ b/contrib/libs/libidn/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +VERSION(1.41) + +ORIGINAL_SOURCE(mirror://gnu/libidn/libidn-1.41.tar.gz) + +LICENSE(Service-Dll-Harness) + +NO_RUNTIME() + +IF (EXPORT_CMAKE) + OPENSOURCE_EXPORT_REPLACEMENT( + CMAKE + IDN + CMAKE_TARGET + IDN::IDN + ) +ELSEIF (USE_DYNAMIC_IDN) + PEERDIR( + contrib/libs/libidn/dynamic + ) +ELSE() + PEERDIR( + contrib/libs/libidn/static + ) +ENDIF() + +END() + +RECURSE( + dynamic + static +) diff --git a/contrib/libs/libunwind/ya.make b/contrib/libs/libunwind/ya.make new file mode 100644 index 00000000000..1af0243b611 --- /dev/null +++ b/contrib/libs/libunwind/ya.make @@ -0,0 +1,63 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Apache-2.0 WITH LLVM-exception AND + MIT AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(14.0.6) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/llvmorg-14.0.6.tar.gz) + +DISABLE(USE_LTO) + +ADDINCL( + contrib/libs/libunwind/include +) + +NO_RUNTIME() + +NO_UTIL() + +NO_SANITIZE() + +NO_SANITIZE_COVERAGE() + +CFLAGS( + GLOBAL -D_libunwind_ + -D_LIBUNWIND_IS_NATIVE_ONLY + -fno-exceptions + -fno-rtti + -funwind-tables +) + +IF (SANITIZER_TYPE == memory) + CFLAGS( + -fPIC + ) +ENDIF() + +SRCS( + src/Unwind-EHABI.cpp + src/Unwind-seh.cpp + src/Unwind-sjlj.c + src/UnwindLevel1-gcc-ext.c + src/UnwindLevel1.c + src/UnwindRegistersRestore.S + src/UnwindRegistersSave.S + src/libunwind.cpp +) + +IF (OS_DARWIN OR OS_IOS) + SRCS( + src/Unwind_AppleExtras.cpp + ) +ENDIF() + +END() diff --git a/contrib/libs/liburing/test/232c93d07b74.t/ya.make b/contrib/libs/liburing/test/232c93d07b74.t/ya.make new file mode 100644 index 00000000000..392632c920b --- /dev/null +++ b/contrib/libs/liburing/test/232c93d07b74.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + 232c93d07b74.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/35fa71a030ca.t/ya.make b/contrib/libs/liburing/test/35fa71a030ca.t/ya.make new file mode 100644 index 00000000000..25b50d7e1da --- /dev/null +++ b/contrib/libs/liburing/test/35fa71a030ca.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + 35fa71a030ca.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/500f9fbadef8.t/ya.make b/contrib/libs/liburing/test/500f9fbadef8.t/ya.make new file mode 100644 index 00000000000..348c5de9649 --- /dev/null +++ b/contrib/libs/liburing/test/500f9fbadef8.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + 500f9fbadef8.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/7ad0e4b2f83c.t/ya.make b/contrib/libs/liburing/test/7ad0e4b2f83c.t/ya.make new file mode 100644 index 00000000000..5b35a3b130e --- /dev/null +++ b/contrib/libs/liburing/test/7ad0e4b2f83c.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + 7ad0e4b2f83c.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/8a9973408177.t/ya.make b/contrib/libs/liburing/test/8a9973408177.t/ya.make new file mode 100644 index 00000000000..6da074292a3 --- /dev/null +++ b/contrib/libs/liburing/test/8a9973408177.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + 8a9973408177.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/917257daa0fe.t/ya.make b/contrib/libs/liburing/test/917257daa0fe.t/ya.make new file mode 100644 index 00000000000..e3d6ab5521f --- /dev/null +++ b/contrib/libs/liburing/test/917257daa0fe.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + 917257daa0fe.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/a0908ae19763.t/ya.make b/contrib/libs/liburing/test/a0908ae19763.t/ya.make new file mode 100644 index 00000000000..459f740c7dc --- /dev/null +++ b/contrib/libs/liburing/test/a0908ae19763.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + a0908ae19763.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/a4c0b3decb33.t/ya.make b/contrib/libs/liburing/test/a4c0b3decb33.t/ya.make new file mode 100644 index 00000000000..71fa20cd91c --- /dev/null +++ b/contrib/libs/liburing/test/a4c0b3decb33.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + a4c0b3decb33.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/accept-link.t/ya.make b/contrib/libs/liburing/test/accept-link.t/ya.make new file mode 100644 index 00000000000..56c72bd9b2a --- /dev/null +++ b/contrib/libs/liburing/test/accept-link.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + accept-link.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/accept-reuse.t/ya.make b/contrib/libs/liburing/test/accept-reuse.t/ya.make new file mode 100644 index 00000000000..bcccd840221 --- /dev/null +++ b/contrib/libs/liburing/test/accept-reuse.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + accept-reuse.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/accept-test.t/ya.make b/contrib/libs/liburing/test/accept-test.t/ya.make new file mode 100644 index 00000000000..5f86aba9c6f --- /dev/null +++ b/contrib/libs/liburing/test/accept-test.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + accept-test.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/accept.t/ya.make b/contrib/libs/liburing/test/accept.t/ya.make new file mode 100644 index 00000000000..78aa913f359 --- /dev/null +++ b/contrib/libs/liburing/test/accept.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + accept.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/across-fork.t/ya.make b/contrib/libs/liburing/test/across-fork.t/ya.make new file mode 100644 index 00000000000..7dd93b6944f --- /dev/null +++ b/contrib/libs/liburing/test/across-fork.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + across-fork.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/b19062a56726.t/ya.make b/contrib/libs/liburing/test/b19062a56726.t/ya.make new file mode 100644 index 00000000000..fca4dcff734 --- /dev/null +++ b/contrib/libs/liburing/test/b19062a56726.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + b19062a56726.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/b5837bd5311d.t/ya.make b/contrib/libs/liburing/test/b5837bd5311d.t/ya.make new file mode 100644 index 00000000000..20ac087a710 --- /dev/null +++ b/contrib/libs/liburing/test/b5837bd5311d.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + b5837bd5311d.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/buf-ring.t/ya.make b/contrib/libs/liburing/test/buf-ring.t/ya.make new file mode 100644 index 00000000000..efdb95e1f79 --- /dev/null +++ b/contrib/libs/liburing/test/buf-ring.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + buf-ring.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/ce593a6c480a.t/ya.make b/contrib/libs/liburing/test/ce593a6c480a.t/ya.make new file mode 100644 index 00000000000..81d8a24702a --- /dev/null +++ b/contrib/libs/liburing/test/ce593a6c480a.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + ce593a6c480a.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/close-opath.t/ya.make b/contrib/libs/liburing/test/close-opath.t/ya.make new file mode 100644 index 00000000000..105da4efd82 --- /dev/null +++ b/contrib/libs/liburing/test/close-opath.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + close-opath.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/connect.t/ya.make b/contrib/libs/liburing/test/connect.t/ya.make new file mode 100644 index 00000000000..7a545c77d82 --- /dev/null +++ b/contrib/libs/liburing/test/connect.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + connect.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/cq-full.t/ya.make b/contrib/libs/liburing/test/cq-full.t/ya.make new file mode 100644 index 00000000000..a11faefee91 --- /dev/null +++ b/contrib/libs/liburing/test/cq-full.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + cq-full.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/cq-overflow.t/ya.make b/contrib/libs/liburing/test/cq-overflow.t/ya.make new file mode 100644 index 00000000000..c4577b3f1e4 --- /dev/null +++ b/contrib/libs/liburing/test/cq-overflow.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + cq-overflow.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/cq-peek-batch.t/ya.make b/contrib/libs/liburing/test/cq-peek-batch.t/ya.make new file mode 100644 index 00000000000..2a475594b9f --- /dev/null +++ b/contrib/libs/liburing/test/cq-peek-batch.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + cq-peek-batch.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/cq-ready.t/ya.make b/contrib/libs/liburing/test/cq-ready.t/ya.make new file mode 100644 index 00000000000..18ae64b96d8 --- /dev/null +++ b/contrib/libs/liburing/test/cq-ready.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + cq-ready.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/cq-size.t/ya.make b/contrib/libs/liburing/test/cq-size.t/ya.make new file mode 100644 index 00000000000..e8b0c9e9cf2 --- /dev/null +++ b/contrib/libs/liburing/test/cq-size.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + cq-size.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/d4ae271dfaae.t/ya.make b/contrib/libs/liburing/test/d4ae271dfaae.t/ya.make new file mode 100644 index 00000000000..ab3ae513037 --- /dev/null +++ b/contrib/libs/liburing/test/d4ae271dfaae.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + d4ae271dfaae.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/d77a67ed5f27.t/ya.make b/contrib/libs/liburing/test/d77a67ed5f27.t/ya.make new file mode 100644 index 00000000000..c2ef703bfc0 --- /dev/null +++ b/contrib/libs/liburing/test/d77a67ed5f27.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + d77a67ed5f27.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/defer-taskrun.t/ya.make b/contrib/libs/liburing/test/defer-taskrun.t/ya.make new file mode 100644 index 00000000000..92e7259640c --- /dev/null +++ b/contrib/libs/liburing/test/defer-taskrun.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + defer-taskrun.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/defer.t/ya.make b/contrib/libs/liburing/test/defer.t/ya.make new file mode 100644 index 00000000000..6c8e22b1a74 --- /dev/null +++ b/contrib/libs/liburing/test/defer.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + defer.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/double-poll-crash.t/ya.make b/contrib/libs/liburing/test/double-poll-crash.t/ya.make new file mode 100644 index 00000000000..a7b535b53b8 --- /dev/null +++ b/contrib/libs/liburing/test/double-poll-crash.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + double-poll-crash.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/drop-submit.t/ya.make b/contrib/libs/liburing/test/drop-submit.t/ya.make new file mode 100644 index 00000000000..a841d9f7fd0 --- /dev/null +++ b/contrib/libs/liburing/test/drop-submit.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + drop-submit.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/eeed8b54e0df.t/ya.make b/contrib/libs/liburing/test/eeed8b54e0df.t/ya.make new file mode 100644 index 00000000000..109406685ee --- /dev/null +++ b/contrib/libs/liburing/test/eeed8b54e0df.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + eeed8b54e0df.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/empty-eownerdead.t/ya.make b/contrib/libs/liburing/test/empty-eownerdead.t/ya.make new file mode 100644 index 00000000000..ee326d608d3 --- /dev/null +++ b/contrib/libs/liburing/test/empty-eownerdead.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + empty-eownerdead.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/eventfd-disable.t/ya.make b/contrib/libs/liburing/test/eventfd-disable.t/ya.make new file mode 100644 index 00000000000..0337935c417 --- /dev/null +++ b/contrib/libs/liburing/test/eventfd-disable.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + eventfd-disable.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/eventfd-reg.t/ya.make b/contrib/libs/liburing/test/eventfd-reg.t/ya.make new file mode 100644 index 00000000000..c2d33b79ac4 --- /dev/null +++ b/contrib/libs/liburing/test/eventfd-reg.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + eventfd-reg.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/eventfd-ring.t/ya.make b/contrib/libs/liburing/test/eventfd-ring.t/ya.make new file mode 100644 index 00000000000..8809666f749 --- /dev/null +++ b/contrib/libs/liburing/test/eventfd-ring.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + eventfd-ring.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/eventfd.t/ya.make b/contrib/libs/liburing/test/eventfd.t/ya.make new file mode 100644 index 00000000000..e37b9ad9e5b --- /dev/null +++ b/contrib/libs/liburing/test/eventfd.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + eventfd.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/exec-target.t/ya.make b/contrib/libs/liburing/test/exec-target.t/ya.make new file mode 100644 index 00000000000..d9e7ad6ddc0 --- /dev/null +++ b/contrib/libs/liburing/test/exec-target.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + exec-target.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/exit-no-cleanup.t/ya.make b/contrib/libs/liburing/test/exit-no-cleanup.t/ya.make new file mode 100644 index 00000000000..352ba0019f4 --- /dev/null +++ b/contrib/libs/liburing/test/exit-no-cleanup.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + exit-no-cleanup.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fadvise.t/ya.make b/contrib/libs/liburing/test/fadvise.t/ya.make new file mode 100644 index 00000000000..e2ee5c8755a --- /dev/null +++ b/contrib/libs/liburing/test/fadvise.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fadvise.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fallocate.t/ya.make b/contrib/libs/liburing/test/fallocate.t/ya.make new file mode 100644 index 00000000000..1f071400f6a --- /dev/null +++ b/contrib/libs/liburing/test/fallocate.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fallocate.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fc2a85cb02ef.t/ya.make b/contrib/libs/liburing/test/fc2a85cb02ef.t/ya.make new file mode 100644 index 00000000000..d8ed373ce0a --- /dev/null +++ b/contrib/libs/liburing/test/fc2a85cb02ef.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fc2a85cb02ef.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fd-pass.t/ya.make b/contrib/libs/liburing/test/fd-pass.t/ya.make new file mode 100644 index 00000000000..cb784bdb925 --- /dev/null +++ b/contrib/libs/liburing/test/fd-pass.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fd-pass.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/file-register.t/ya.make b/contrib/libs/liburing/test/file-register.t/ya.make new file mode 100644 index 00000000000..7cd3f05b21d --- /dev/null +++ b/contrib/libs/liburing/test/file-register.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + file-register.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/file-update.t/ya.make b/contrib/libs/liburing/test/file-update.t/ya.make new file mode 100644 index 00000000000..a8ff2d42199 --- /dev/null +++ b/contrib/libs/liburing/test/file-update.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + file-update.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/file-verify.t/ya.make b/contrib/libs/liburing/test/file-verify.t/ya.make new file mode 100644 index 00000000000..0a927735538 --- /dev/null +++ b/contrib/libs/liburing/test/file-verify.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + file-verify.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/files-exit-hang-poll.t/ya.make b/contrib/libs/liburing/test/files-exit-hang-poll.t/ya.make new file mode 100644 index 00000000000..d37795437b4 --- /dev/null +++ b/contrib/libs/liburing/test/files-exit-hang-poll.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + files-exit-hang-poll.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/files-exit-hang-timeout.t/ya.make b/contrib/libs/liburing/test/files-exit-hang-timeout.t/ya.make new file mode 100644 index 00000000000..d92efe73fac --- /dev/null +++ b/contrib/libs/liburing/test/files-exit-hang-timeout.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + files-exit-hang-timeout.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fixed-buf-iter.t/ya.make b/contrib/libs/liburing/test/fixed-buf-iter.t/ya.make new file mode 100644 index 00000000000..acf648f60ac --- /dev/null +++ b/contrib/libs/liburing/test/fixed-buf-iter.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fixed-buf-iter.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fixed-link.t/ya.make b/contrib/libs/liburing/test/fixed-link.t/ya.make new file mode 100644 index 00000000000..cbaac97216a --- /dev/null +++ b/contrib/libs/liburing/test/fixed-link.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fixed-link.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fixed-reuse.t/ya.make b/contrib/libs/liburing/test/fixed-reuse.t/ya.make new file mode 100644 index 00000000000..2e100c343bf --- /dev/null +++ b/contrib/libs/liburing/test/fixed-reuse.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fixed-reuse.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fpos.t/ya.make b/contrib/libs/liburing/test/fpos.t/ya.make new file mode 100644 index 00000000000..ec8c98d92e3 --- /dev/null +++ b/contrib/libs/liburing/test/fpos.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fpos.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fsync.t/ya.make b/contrib/libs/liburing/test/fsync.t/ya.make new file mode 100644 index 00000000000..db2352138dc --- /dev/null +++ b/contrib/libs/liburing/test/fsync.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fsync.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/hardlink.t/ya.make b/contrib/libs/liburing/test/hardlink.t/ya.make new file mode 100644 index 00000000000..2ca842d015b --- /dev/null +++ b/contrib/libs/liburing/test/hardlink.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + hardlink.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/io-cancel.t/ya.make b/contrib/libs/liburing/test/io-cancel.t/ya.make new file mode 100644 index 00000000000..d3031af0b65 --- /dev/null +++ b/contrib/libs/liburing/test/io-cancel.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + io-cancel.c +) + +END() diff --git a/contrib/libs/liburing/test/io_uring_enter.t/ya.make b/contrib/libs/liburing/test/io_uring_enter.t/ya.make new file mode 100644 index 00000000000..4fe4b806e42 --- /dev/null +++ b/contrib/libs/liburing/test/io_uring_enter.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + io_uring_enter.c +) + +END() diff --git a/contrib/libs/liburing/test/io_uring_passthrough.t/ya.make b/contrib/libs/liburing/test/io_uring_passthrough.t/ya.make new file mode 100644 index 00000000000..66fb67d7b9e --- /dev/null +++ b/contrib/libs/liburing/test/io_uring_passthrough.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + io_uring_passthrough.c +) + +END() diff --git a/contrib/libs/liburing/test/io_uring_register.t/ya.make b/contrib/libs/liburing/test/io_uring_register.t/ya.make new file mode 100644 index 00000000000..b0853ab0c1e --- /dev/null +++ b/contrib/libs/liburing/test/io_uring_register.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + io_uring_register.c +) + +END() diff --git a/contrib/libs/liburing/test/io_uring_setup.t/ya.make b/contrib/libs/liburing/test/io_uring_setup.t/ya.make new file mode 100644 index 00000000000..634df89ad51 --- /dev/null +++ b/contrib/libs/liburing/test/io_uring_setup.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + io_uring_setup.c +) + +END() diff --git a/contrib/libs/liburing/test/iopoll-leak.t/ya.make b/contrib/libs/liburing/test/iopoll-leak.t/ya.make new file mode 100644 index 00000000000..1fd6c810f14 --- /dev/null +++ b/contrib/libs/liburing/test/iopoll-leak.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + iopoll-leak.c +) + +END() diff --git a/contrib/libs/liburing/test/iopoll.t/ya.make b/contrib/libs/liburing/test/iopoll.t/ya.make new file mode 100644 index 00000000000..f2237ca2f6e --- /dev/null +++ b/contrib/libs/liburing/test/iopoll.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + iopoll.c +) + +END() diff --git a/contrib/libs/liburing/test/lfs-openat-write.t/ya.make b/contrib/libs/liburing/test/lfs-openat-write.t/ya.make new file mode 100644 index 00000000000..697171e87da --- /dev/null +++ b/contrib/libs/liburing/test/lfs-openat-write.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + lfs-openat-write.c +) + +END() diff --git a/contrib/libs/liburing/test/lfs-openat.t/ya.make b/contrib/libs/liburing/test/lfs-openat.t/ya.make new file mode 100644 index 00000000000..17c95dbc0d8 --- /dev/null +++ b/contrib/libs/liburing/test/lfs-openat.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + lfs-openat.c +) + +END() diff --git a/contrib/libs/liburing/test/link-timeout.t/ya.make b/contrib/libs/liburing/test/link-timeout.t/ya.make new file mode 100644 index 00000000000..7435c6ec6a1 --- /dev/null +++ b/contrib/libs/liburing/test/link-timeout.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + link-timeout.c +) + +END() diff --git a/contrib/libs/liburing/test/link.t/ya.make b/contrib/libs/liburing/test/link.t/ya.make new file mode 100644 index 00000000000..e80fb159dfd --- /dev/null +++ b/contrib/libs/liburing/test/link.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + link.c +) + +END() diff --git a/contrib/libs/liburing/test/link_drain.t/ya.make b/contrib/libs/liburing/test/link_drain.t/ya.make new file mode 100644 index 00000000000..9b8e83bae39 --- /dev/null +++ b/contrib/libs/liburing/test/link_drain.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + link_drain.c +) + +END() diff --git a/contrib/libs/liburing/test/madvise.t/ya.make b/contrib/libs/liburing/test/madvise.t/ya.make new file mode 100644 index 00000000000..d2bf2f7e50a --- /dev/null +++ b/contrib/libs/liburing/test/madvise.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + madvise.c +) + +END() diff --git a/contrib/libs/liburing/test/mkdir.t/ya.make b/contrib/libs/liburing/test/mkdir.t/ya.make new file mode 100644 index 00000000000..5bac3621984 --- /dev/null +++ b/contrib/libs/liburing/test/mkdir.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + mkdir.c +) + +END() diff --git a/contrib/libs/liburing/test/msg-ring.t/ya.make b/contrib/libs/liburing/test/msg-ring.t/ya.make new file mode 100644 index 00000000000..7390bba8326 --- /dev/null +++ b/contrib/libs/liburing/test/msg-ring.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + msg-ring.c +) + +END() diff --git a/contrib/libs/liburing/test/multicqes_drain.t/ya.make b/contrib/libs/liburing/test/multicqes_drain.t/ya.make new file mode 100644 index 00000000000..22701ab8fec --- /dev/null +++ b/contrib/libs/liburing/test/multicqes_drain.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + multicqes_drain.c +) + +END() diff --git a/contrib/libs/liburing/test/nolibc.t/ya.make b/contrib/libs/liburing/test/nolibc.t/ya.make new file mode 100644 index 00000000000..c28e1afe67e --- /dev/null +++ b/contrib/libs/liburing/test/nolibc.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + nolibc.c +) + +END() diff --git a/contrib/libs/liburing/test/nop-all-sizes.t/ya.make b/contrib/libs/liburing/test/nop-all-sizes.t/ya.make new file mode 100644 index 00000000000..d29e71121a6 --- /dev/null +++ b/contrib/libs/liburing/test/nop-all-sizes.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + nop-all-sizes.c +) + +END() diff --git a/contrib/libs/liburing/test/nop.t/ya.make b/contrib/libs/liburing/test/nop.t/ya.make new file mode 100644 index 00000000000..c48cf210ca3 --- /dev/null +++ b/contrib/libs/liburing/test/nop.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + nop.c +) + +END() diff --git a/contrib/libs/liburing/test/open-close.t/ya.make b/contrib/libs/liburing/test/open-close.t/ya.make new file mode 100644 index 00000000000..94cec1bf208 --- /dev/null +++ b/contrib/libs/liburing/test/open-close.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + open-close.c +) + +END() diff --git a/contrib/libs/liburing/test/open-direct-link.t/ya.make b/contrib/libs/liburing/test/open-direct-link.t/ya.make new file mode 100644 index 00000000000..d0829be41c2 --- /dev/null +++ b/contrib/libs/liburing/test/open-direct-link.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + open-direct-link.c +) + +END() diff --git a/contrib/libs/liburing/test/open-direct-pick.t/ya.make b/contrib/libs/liburing/test/open-direct-pick.t/ya.make new file mode 100644 index 00000000000..f0c90f96e2e --- /dev/null +++ b/contrib/libs/liburing/test/open-direct-pick.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + open-direct-pick.c +) + +END() diff --git a/contrib/libs/liburing/test/openat2.t/ya.make b/contrib/libs/liburing/test/openat2.t/ya.make new file mode 100644 index 00000000000..808ae9394d8 --- /dev/null +++ b/contrib/libs/liburing/test/openat2.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + openat2.c +) + +END() diff --git a/contrib/libs/liburing/test/personality.t/ya.make b/contrib/libs/liburing/test/personality.t/ya.make new file mode 100644 index 00000000000..7e04372231a --- /dev/null +++ b/contrib/libs/liburing/test/personality.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + personality.c +) + +END() diff --git a/contrib/libs/liburing/test/pipe-eof.t/ya.make b/contrib/libs/liburing/test/pipe-eof.t/ya.make new file mode 100644 index 00000000000..4e8a60283bc --- /dev/null +++ b/contrib/libs/liburing/test/pipe-eof.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + pipe-eof.c +) + +END() diff --git a/contrib/libs/liburing/test/pipe-reuse.t/ya.make b/contrib/libs/liburing/test/pipe-reuse.t/ya.make new file mode 100644 index 00000000000..cd6529bc971 --- /dev/null +++ b/contrib/libs/liburing/test/pipe-reuse.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + pipe-reuse.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-cancel-all.t/ya.make b/contrib/libs/liburing/test/poll-cancel-all.t/ya.make new file mode 100644 index 00000000000..04f8596d5f3 --- /dev/null +++ b/contrib/libs/liburing/test/poll-cancel-all.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-cancel-all.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-cancel-ton.t/ya.make b/contrib/libs/liburing/test/poll-cancel-ton.t/ya.make new file mode 100644 index 00000000000..72fb1732904 --- /dev/null +++ b/contrib/libs/liburing/test/poll-cancel-ton.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-cancel-ton.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-cancel.t/ya.make b/contrib/libs/liburing/test/poll-cancel.t/ya.make new file mode 100644 index 00000000000..9e829745284 --- /dev/null +++ b/contrib/libs/liburing/test/poll-cancel.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-cancel.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-link.t/ya.make b/contrib/libs/liburing/test/poll-link.t/ya.make new file mode 100644 index 00000000000..a4f68fa9418 --- /dev/null +++ b/contrib/libs/liburing/test/poll-link.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-link.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-many.t/ya.make b/contrib/libs/liburing/test/poll-many.t/ya.make new file mode 100644 index 00000000000..4201db58799 --- /dev/null +++ b/contrib/libs/liburing/test/poll-many.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-many.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-mshot-overflow.t/ya.make b/contrib/libs/liburing/test/poll-mshot-overflow.t/ya.make new file mode 100644 index 00000000000..fa8fccff613 --- /dev/null +++ b/contrib/libs/liburing/test/poll-mshot-overflow.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-mshot-overflow.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-mshot-update.t/ya.make b/contrib/libs/liburing/test/poll-mshot-update.t/ya.make new file mode 100644 index 00000000000..a803086ffab --- /dev/null +++ b/contrib/libs/liburing/test/poll-mshot-update.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-mshot-update.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-ring.t/ya.make b/contrib/libs/liburing/test/poll-ring.t/ya.make new file mode 100644 index 00000000000..ba8b534c9b3 --- /dev/null +++ b/contrib/libs/liburing/test/poll-ring.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-ring.c +) + +END() diff --git a/contrib/libs/liburing/test/poll-v-poll.t/ya.make b/contrib/libs/liburing/test/poll-v-poll.t/ya.make new file mode 100644 index 00000000000..e560f65b4c3 --- /dev/null +++ b/contrib/libs/liburing/test/poll-v-poll.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll-v-poll.c +) + +END() diff --git a/contrib/libs/liburing/test/poll.t/ya.make b/contrib/libs/liburing/test/poll.t/ya.make new file mode 100644 index 00000000000..6c0250d6832 --- /dev/null +++ b/contrib/libs/liburing/test/poll.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + poll.c +) + +END() diff --git a/contrib/libs/liburing/test/pollfree.t/ya.make b/contrib/libs/liburing/test/pollfree.t/ya.make new file mode 100644 index 00000000000..0bc185197f5 --- /dev/null +++ b/contrib/libs/liburing/test/pollfree.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + pollfree.c +) + +END() diff --git a/contrib/libs/liburing/test/probe.t/ya.make b/contrib/libs/liburing/test/probe.t/ya.make new file mode 100644 index 00000000000..ac544d180bf --- /dev/null +++ b/contrib/libs/liburing/test/probe.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + probe.c +) + +END() diff --git a/contrib/libs/liburing/test/read-before-exit.t/ya.make b/contrib/libs/liburing/test/read-before-exit.t/ya.make new file mode 100644 index 00000000000..3432f125726 --- /dev/null +++ b/contrib/libs/liburing/test/read-before-exit.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + read-before-exit.c +) + +END() diff --git a/contrib/libs/liburing/test/read-write.t/ya.make b/contrib/libs/liburing/test/read-write.t/ya.make new file mode 100644 index 00000000000..1358850f7e8 --- /dev/null +++ b/contrib/libs/liburing/test/read-write.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + read-write.c +) + +END() diff --git a/contrib/libs/liburing/test/recv-msgall-stream.t/ya.make b/contrib/libs/liburing/test/recv-msgall-stream.t/ya.make new file mode 100644 index 00000000000..1ac1a18c9bb --- /dev/null +++ b/contrib/libs/liburing/test/recv-msgall-stream.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + recv-msgall-stream.c +) + +END() diff --git a/contrib/libs/liburing/test/recv-msgall.t/ya.make b/contrib/libs/liburing/test/recv-msgall.t/ya.make new file mode 100644 index 00000000000..8d217a3d8e4 --- /dev/null +++ b/contrib/libs/liburing/test/recv-msgall.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + recv-msgall.c +) + +END() diff --git a/contrib/libs/liburing/test/recv-multishot.t/ya.make b/contrib/libs/liburing/test/recv-multishot.t/ya.make new file mode 100644 index 00000000000..f216a62bda8 --- /dev/null +++ b/contrib/libs/liburing/test/recv-multishot.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + recv-multishot.c +) + +END() diff --git a/contrib/libs/liburing/test/register-restrictions.t/ya.make b/contrib/libs/liburing/test/register-restrictions.t/ya.make new file mode 100644 index 00000000000..999b345b9eb --- /dev/null +++ b/contrib/libs/liburing/test/register-restrictions.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + register-restrictions.c +) + +END() diff --git a/contrib/libs/liburing/test/rename.t/ya.make b/contrib/libs/liburing/test/rename.t/ya.make new file mode 100644 index 00000000000..ad05bb11178 --- /dev/null +++ b/contrib/libs/liburing/test/rename.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + rename.c +) + +END() diff --git a/contrib/libs/liburing/test/ring-leak.t/ya.make b/contrib/libs/liburing/test/ring-leak.t/ya.make new file mode 100644 index 00000000000..ed8c58f70a5 --- /dev/null +++ b/contrib/libs/liburing/test/ring-leak.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + ring-leak.c +) + +END() diff --git a/contrib/libs/liburing/test/ring-leak2.t/ya.make b/contrib/libs/liburing/test/ring-leak2.t/ya.make new file mode 100644 index 00000000000..6a6fad42efa --- /dev/null +++ b/contrib/libs/liburing/test/ring-leak2.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + ring-leak2.c +) + +END() diff --git a/contrib/libs/liburing/test/ringbuf-read.t/ya.make b/contrib/libs/liburing/test/ringbuf-read.t/ya.make new file mode 100644 index 00000000000..a438659ae29 --- /dev/null +++ b/contrib/libs/liburing/test/ringbuf-read.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + ringbuf-read.c +) + +END() diff --git a/contrib/libs/liburing/test/rsrc_tags.t/ya.make b/contrib/libs/liburing/test/rsrc_tags.t/ya.make new file mode 100644 index 00000000000..8e5933f11c4 --- /dev/null +++ b/contrib/libs/liburing/test/rsrc_tags.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + rsrc_tags.c +) + +END() diff --git a/contrib/libs/liburing/test/rw_merge_test.t/ya.make b/contrib/libs/liburing/test/rw_merge_test.t/ya.make new file mode 100644 index 00000000000..be8f577459d --- /dev/null +++ b/contrib/libs/liburing/test/rw_merge_test.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + rw_merge_test.c +) + +END() diff --git a/contrib/libs/liburing/test/self.t/ya.make b/contrib/libs/liburing/test/self.t/ya.make new file mode 100644 index 00000000000..4d9b10614b6 --- /dev/null +++ b/contrib/libs/liburing/test/self.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + self.c +) + +END() diff --git a/contrib/libs/liburing/test/send-zerocopy.t/ya.make b/contrib/libs/liburing/test/send-zerocopy.t/ya.make new file mode 100644 index 00000000000..35e3884c923 --- /dev/null +++ b/contrib/libs/liburing/test/send-zerocopy.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + send-zerocopy.c +) + +END() diff --git a/contrib/libs/liburing/test/send_recv.t/ya.make b/contrib/libs/liburing/test/send_recv.t/ya.make new file mode 100644 index 00000000000..63accb8ce36 --- /dev/null +++ b/contrib/libs/liburing/test/send_recv.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + send_recv.c +) + +END() diff --git a/contrib/libs/liburing/test/send_recvmsg.t/ya.make b/contrib/libs/liburing/test/send_recvmsg.t/ya.make new file mode 100644 index 00000000000..6c931203f27 --- /dev/null +++ b/contrib/libs/liburing/test/send_recvmsg.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + send_recvmsg.c +) + +END() diff --git a/contrib/libs/liburing/test/sendmsg_fs_cve.t/ya.make b/contrib/libs/liburing/test/sendmsg_fs_cve.t/ya.make new file mode 100644 index 00000000000..cb23a9fe65c --- /dev/null +++ b/contrib/libs/liburing/test/sendmsg_fs_cve.t/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(GPL-2.0-or-later) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sendmsg_fs_cve.c +) + +END() diff --git a/contrib/libs/liburing/test/shared-wq.t/ya.make b/contrib/libs/liburing/test/shared-wq.t/ya.make new file mode 100644 index 00000000000..6c7d7f68ddc --- /dev/null +++ b/contrib/libs/liburing/test/shared-wq.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + shared-wq.c +) + +END() diff --git a/contrib/libs/liburing/test/short-read.t/ya.make b/contrib/libs/liburing/test/short-read.t/ya.make new file mode 100644 index 00000000000..b6a803a9fb3 --- /dev/null +++ b/contrib/libs/liburing/test/short-read.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + short-read.c +) + +END() diff --git a/contrib/libs/liburing/test/shutdown.t/ya.make b/contrib/libs/liburing/test/shutdown.t/ya.make new file mode 100644 index 00000000000..569c7064096 --- /dev/null +++ b/contrib/libs/liburing/test/shutdown.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + shutdown.c +) + +END() diff --git a/contrib/libs/liburing/test/sigfd-deadlock.t/ya.make b/contrib/libs/liburing/test/sigfd-deadlock.t/ya.make new file mode 100644 index 00000000000..fa75fc58607 --- /dev/null +++ b/contrib/libs/liburing/test/sigfd-deadlock.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sigfd-deadlock.c +) + +END() diff --git a/contrib/libs/liburing/test/single-issuer.t/ya.make b/contrib/libs/liburing/test/single-issuer.t/ya.make new file mode 100644 index 00000000000..956f613a70d --- /dev/null +++ b/contrib/libs/liburing/test/single-issuer.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + single-issuer.c +) + +END() diff --git a/contrib/libs/liburing/test/skip-cqe.t/ya.make b/contrib/libs/liburing/test/skip-cqe.t/ya.make new file mode 100644 index 00000000000..f59bb6eb33c --- /dev/null +++ b/contrib/libs/liburing/test/skip-cqe.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + skip-cqe.c +) + +END() diff --git a/contrib/libs/liburing/test/socket-rw-eagain.t/ya.make b/contrib/libs/liburing/test/socket-rw-eagain.t/ya.make new file mode 100644 index 00000000000..8412126de4c --- /dev/null +++ b/contrib/libs/liburing/test/socket-rw-eagain.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + socket-rw-eagain.c +) + +END() diff --git a/contrib/libs/liburing/test/socket-rw-offset.t/ya.make b/contrib/libs/liburing/test/socket-rw-offset.t/ya.make new file mode 100644 index 00000000000..fe46ddd9e8c --- /dev/null +++ b/contrib/libs/liburing/test/socket-rw-offset.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + socket-rw-offset.c +) + +END() diff --git a/contrib/libs/liburing/test/socket-rw.t/ya.make b/contrib/libs/liburing/test/socket-rw.t/ya.make new file mode 100644 index 00000000000..decdc59a16b --- /dev/null +++ b/contrib/libs/liburing/test/socket-rw.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + socket-rw.c +) + +END() diff --git a/contrib/libs/liburing/test/socket.t/ya.make b/contrib/libs/liburing/test/socket.t/ya.make new file mode 100644 index 00000000000..cfba8ac48e2 --- /dev/null +++ b/contrib/libs/liburing/test/socket.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + socket.c +) + +END() diff --git a/contrib/libs/liburing/test/splice.t/ya.make b/contrib/libs/liburing/test/splice.t/ya.make new file mode 100644 index 00000000000..a6bc2b332af --- /dev/null +++ b/contrib/libs/liburing/test/splice.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + splice.c +) + +END() diff --git a/contrib/libs/liburing/test/sq-full-cpp.t/ya.make b/contrib/libs/liburing/test/sq-full-cpp.t/ya.make new file mode 100644 index 00000000000..dac934e0b17 --- /dev/null +++ b/contrib/libs/liburing/test/sq-full-cpp.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sq-full-cpp.cc +) + +END() diff --git a/contrib/libs/liburing/test/sq-full.t/ya.make b/contrib/libs/liburing/test/sq-full.t/ya.make new file mode 100644 index 00000000000..625699e88f6 --- /dev/null +++ b/contrib/libs/liburing/test/sq-full.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sq-full.c +) + +END() diff --git a/contrib/libs/liburing/test/sq-poll-dup.t/ya.make b/contrib/libs/liburing/test/sq-poll-dup.t/ya.make new file mode 100644 index 00000000000..7282fba5a30 --- /dev/null +++ b/contrib/libs/liburing/test/sq-poll-dup.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sq-poll-dup.c +) + +END() diff --git a/contrib/libs/liburing/test/sq-poll-kthread.t/ya.make b/contrib/libs/liburing/test/sq-poll-kthread.t/ya.make new file mode 100644 index 00000000000..36394c534f2 --- /dev/null +++ b/contrib/libs/liburing/test/sq-poll-kthread.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sq-poll-kthread.c +) + +END() diff --git a/contrib/libs/liburing/test/sq-poll-share.t/ya.make b/contrib/libs/liburing/test/sq-poll-share.t/ya.make new file mode 100644 index 00000000000..b1ae1346cfc --- /dev/null +++ b/contrib/libs/liburing/test/sq-poll-share.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sq-poll-share.c +) + +END() diff --git a/contrib/libs/liburing/test/sq-space_left.t/ya.make b/contrib/libs/liburing/test/sq-space_left.t/ya.make new file mode 100644 index 00000000000..5dae77a0a7e --- /dev/null +++ b/contrib/libs/liburing/test/sq-space_left.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sq-space_left.c +) + +END() diff --git a/contrib/libs/liburing/test/sqpoll-cancel-hang.t/ya.make b/contrib/libs/liburing/test/sqpoll-cancel-hang.t/ya.make new file mode 100644 index 00000000000..d018d031982 --- /dev/null +++ b/contrib/libs/liburing/test/sqpoll-cancel-hang.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sqpoll-cancel-hang.c +) + +END() diff --git a/contrib/libs/liburing/test/sqpoll-disable-exit.t/ya.make b/contrib/libs/liburing/test/sqpoll-disable-exit.t/ya.make new file mode 100644 index 00000000000..645a92c30e5 --- /dev/null +++ b/contrib/libs/liburing/test/sqpoll-disable-exit.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sqpoll-disable-exit.c +) + +END() diff --git a/contrib/libs/liburing/test/sqpoll-exit-hang.t/ya.make b/contrib/libs/liburing/test/sqpoll-exit-hang.t/ya.make new file mode 100644 index 00000000000..d3a0951352b --- /dev/null +++ b/contrib/libs/liburing/test/sqpoll-exit-hang.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sqpoll-exit-hang.c +) + +END() diff --git a/contrib/libs/liburing/test/sqpoll-sleep.t/ya.make b/contrib/libs/liburing/test/sqpoll-sleep.t/ya.make new file mode 100644 index 00000000000..fea530f6803 --- /dev/null +++ b/contrib/libs/liburing/test/sqpoll-sleep.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sqpoll-sleep.c +) + +END() diff --git a/contrib/libs/liburing/test/stdout.t/ya.make b/contrib/libs/liburing/test/stdout.t/ya.make new file mode 100644 index 00000000000..1e9243fdd9a --- /dev/null +++ b/contrib/libs/liburing/test/stdout.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + stdout.c +) + +END() diff --git a/contrib/libs/liburing/test/submit-and-wait.t/ya.make b/contrib/libs/liburing/test/submit-and-wait.t/ya.make new file mode 100644 index 00000000000..7c4bbf2d5d8 --- /dev/null +++ b/contrib/libs/liburing/test/submit-and-wait.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + submit-and-wait.c +) + +END() diff --git a/contrib/libs/liburing/test/submit-link-fail.t/ya.make b/contrib/libs/liburing/test/submit-link-fail.t/ya.make new file mode 100644 index 00000000000..fe783d255cb --- /dev/null +++ b/contrib/libs/liburing/test/submit-link-fail.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + submit-link-fail.c +) + +END() diff --git a/contrib/libs/liburing/test/submit-reuse.t/ya.make b/contrib/libs/liburing/test/submit-reuse.t/ya.make new file mode 100644 index 00000000000..695cf8e9fa6 --- /dev/null +++ b/contrib/libs/liburing/test/submit-reuse.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + submit-reuse.c +) + +END() diff --git a/contrib/libs/liburing/test/symlink.t/ya.make b/contrib/libs/liburing/test/symlink.t/ya.make new file mode 100644 index 00000000000..c81378090b6 --- /dev/null +++ b/contrib/libs/liburing/test/symlink.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + symlink.c +) + +END() diff --git a/contrib/libs/liburing/test/sync-cancel.t/ya.make b/contrib/libs/liburing/test/sync-cancel.t/ya.make new file mode 100644 index 00000000000..2f6e02b23a9 --- /dev/null +++ b/contrib/libs/liburing/test/sync-cancel.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sync-cancel.c +) + +END() diff --git a/contrib/libs/liburing/test/teardowns.t/ya.make b/contrib/libs/liburing/test/teardowns.t/ya.make new file mode 100644 index 00000000000..de112d8974b --- /dev/null +++ b/contrib/libs/liburing/test/teardowns.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + teardowns.c +) + +END() diff --git a/contrib/libs/liburing/test/thread-exit.t/ya.make b/contrib/libs/liburing/test/thread-exit.t/ya.make new file mode 100644 index 00000000000..7446a2d2a2c --- /dev/null +++ b/contrib/libs/liburing/test/thread-exit.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + thread-exit.c +) + +END() diff --git a/contrib/libs/liburing/test/timeout-new.t/ya.make b/contrib/libs/liburing/test/timeout-new.t/ya.make new file mode 100644 index 00000000000..ef9c7f81a40 --- /dev/null +++ b/contrib/libs/liburing/test/timeout-new.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + timeout-new.c +) + +END() diff --git a/contrib/libs/liburing/test/timeout-overflow.t/ya.make b/contrib/libs/liburing/test/timeout-overflow.t/ya.make new file mode 100644 index 00000000000..de0ef396f35 --- /dev/null +++ b/contrib/libs/liburing/test/timeout-overflow.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + timeout-overflow.c +) + +END() diff --git a/contrib/libs/liburing/test/timeout.t/ya.make b/contrib/libs/liburing/test/timeout.t/ya.make new file mode 100644 index 00000000000..d1f6bf6f091 --- /dev/null +++ b/contrib/libs/liburing/test/timeout.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + timeout.c +) + +END() diff --git a/contrib/libs/liburing/test/tty-write-dpoll.t/ya.make b/contrib/libs/liburing/test/tty-write-dpoll.t/ya.make new file mode 100644 index 00000000000..e194f62a612 --- /dev/null +++ b/contrib/libs/liburing/test/tty-write-dpoll.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + tty-write-dpoll.c +) + +END() diff --git a/contrib/libs/liburing/test/unlink.t/ya.make b/contrib/libs/liburing/test/unlink.t/ya.make new file mode 100644 index 00000000000..62500cabd22 --- /dev/null +++ b/contrib/libs/liburing/test/unlink.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + unlink.c +) + +END() diff --git a/contrib/libs/liburing/test/wakeup-hang.t/ya.make b/contrib/libs/liburing/test/wakeup-hang.t/ya.make new file mode 100644 index 00000000000..a15adedefc2 --- /dev/null +++ b/contrib/libs/liburing/test/wakeup-hang.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + wakeup-hang.c +) + +END() diff --git a/contrib/libs/liburing/test/xattr.t/ya.make b/contrib/libs/liburing/test/xattr.t/ya.make new file mode 100644 index 00000000000..6688f4d0fca --- /dev/null +++ b/contrib/libs/liburing/test/xattr.t/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + xattr.c +) + +END() diff --git a/contrib/libs/liburing/ya.make b/contrib/libs/liburing/ya.make new file mode 100644 index 00000000000..ce8ba55e8ed --- /dev/null +++ b/contrib/libs/liburing/ya.make @@ -0,0 +1,183 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + "(GPL-2.0-only WITH Linux-syscall-note OR MIT)" AND + "(LGPL-2.1-only OR MIT)" AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2.3) + +ORIGINAL_SOURCE(https://github.com/axboe/liburing/archive/liburing-2.3.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_INTERNAL +) + +SRCS( + src/queue.c + src/register.c + src/setup.c + src/syscall.c +) + +END() + +RECURSE( + test/232c93d07b74.t + test/35fa71a030ca.t + test/500f9fbadef8.t + test/7ad0e4b2f83c.t + test/8a9973408177.t + test/917257daa0fe.t + test/a0908ae19763.t + test/a4c0b3decb33.t + test/accept-link.t + test/accept-reuse.t + test/accept-test.t + test/accept.t + test/across-fork.t + test/b19062a56726.t + test/b5837bd5311d.t + test/buf-ring.t + test/ce593a6c480a.t + test/close-opath.t + test/connect.t + test/cq-full.t + test/cq-overflow.t + test/cq-peek-batch.t + test/cq-ready.t + test/cq-size.t + test/d4ae271dfaae.t + test/d77a67ed5f27.t + test/defer-taskrun.t + test/defer.t + test/double-poll-crash.t + test/drop-submit.t + test/eeed8b54e0df.t + test/empty-eownerdead.t + test/eventfd-disable.t + test/eventfd-reg.t + test/eventfd-ring.t + test/eventfd.t + test/exec-target.t + test/exit-no-cleanup.t + test/fadvise.t + test/fallocate.t + test/fc2a85cb02ef.t + test/fd-pass.t + test/file-register.t + test/file-update.t + test/file-verify.t + test/files-exit-hang-poll.t + test/files-exit-hang-timeout.t + test/fixed-buf-iter.t + test/fixed-link.t + test/fixed-reuse.t + test/fpos.t + test/fsync.t + test/hardlink.t + test/io-cancel.t + test/io_uring_enter.t + test/io_uring_passthrough.t + test/io_uring_register.t + test/io_uring_setup.t + test/iopoll-leak.t + test/iopoll.t + test/lfs-openat-write.t + test/lfs-openat.t + test/link-timeout.t + test/link.t + test/link_drain.t + test/madvise.t + test/mkdir.t + test/msg-ring.t + test/multicqes_drain.t + test/nolibc.t + test/nop-all-sizes.t + test/nop.t + test/open-close.t + test/open-direct-link.t + test/open-direct-pick.t + test/openat2.t + test/personality.t + test/pipe-eof.t + test/pipe-reuse.t + test/poll-cancel-all.t + test/poll-cancel-ton.t + test/poll-cancel.t + test/poll-link.t + test/poll-many.t + test/poll-mshot-overflow.t + test/poll-mshot-update.t + test/poll-ring.t + test/poll-v-poll.t + test/poll.t + test/pollfree.t + test/probe.t + test/read-before-exit.t + test/read-write.t + test/recv-msgall-stream.t + test/recv-msgall.t + test/recv-multishot.t + test/register-restrictions.t + test/rename.t + test/ring-leak.t + test/ring-leak2.t + test/ringbuf-read.t + test/rsrc_tags.t + test/rw_merge_test.t + test/self.t + test/send-zerocopy.t + test/send_recv.t + test/send_recvmsg.t + test/sendmsg_fs_cve.t + test/shared-wq.t + test/short-read.t + test/shutdown.t + test/sigfd-deadlock.t + test/single-issuer.t + test/skip-cqe.t + test/socket-rw-eagain.t + test/socket-rw-offset.t + test/socket-rw.t + test/socket.t + test/splice.t + test/sq-full-cpp.t + test/sq-full.t + test/sq-poll-dup.t + test/sq-poll-kthread.t + test/sq-poll-share.t + test/sq-space_left.t + test/sqpoll-cancel-hang.t + test/sqpoll-disable-exit.t + test/sqpoll-exit-hang.t + test/sqpoll-sleep.t + test/stdout.t + test/submit-and-wait.t + test/submit-link-fail.t + test/submit-reuse.t + test/symlink.t + test/sync-cancel.t + test/teardowns.t + test/thread-exit.t + test/timeout-new.t + test/timeout-overflow.t + test/timeout.t + test/tty-write-dpoll.t + test/unlink.t + test/wakeup-hang.t + test/xattr.t +) diff --git a/contrib/libs/libxml/ya.make b/contrib/libs/libxml/ya.make new file mode 100644 index 00000000000..bcf10ef16f3 --- /dev/null +++ b/contrib/libs/libxml/ya.make @@ -0,0 +1,94 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + MIT AND + Mit-Veillard-Variant +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2.9.13) + +ORIGINAL_SOURCE(https://gitlab.gnome.org/api/v4/projects/GNOME%2Flibxml2/repository/archive.tar.gz?sha=v2.9.13) + +PEERDIR( + contrib/libs/libiconv + contrib/libs/zlib +) + +ADDINCL( + GLOBAL contrib/libs/libxml/include + contrib/libs/libxml +) + +NO_COMPILER_WARNINGS() + +CFLAGS( + -DHAVE_CONFIG_H + GLOBAL -DLIBXML_STATIC +) + +SRCS( + HTMLparser.c + HTMLtree.c + SAX.c + SAX2.c + buf.c + c14n.c + catalog.c + chvalid.c + debugXML.c + dict.c + encoding.c + entities.c + error.c + globals.c + hash.c + legacy.c + list.c + nanoftp.c + nanohttp.c + parser.c + parserInternals.c + pattern.c + relaxng.c + schematron.c + threads.c + tree.c + uri.c + valid.c + xinclude.c + xlink.c + xmlIO.c + xmlmemory.c + xmlmodule.c + xmlreader.c + xmlregexp.c + xmlsave.c + xmlschemas.c + xmlschemastypes.c + xmlstring.c + xmlunicode.c + xmlwriter.c + xpath.c + xpointer.c + xzlib.c +) + +IF (ARCADIA_LIBXML_DISABLE_EXTRA_ENCODINGS) + NO_RUNTIME() + CFLAGS( + -DARCADIA_LIBXML_DISABLE_EXTRA_ENCODINGS + ) +ELSE() + PEERDIR( + library/cpp/charset + ) + SRCS( + yencoding.cpp + ) +ENDIF() + +END() diff --git a/contrib/libs/linux-headers/ya.make b/contrib/libs/linux-headers/ya.make new file mode 100644 index 00000000000..f36df381a4a --- /dev/null +++ b/contrib/libs/linux-headers/ya.make @@ -0,0 +1,48 @@ +# Generated by devtools/yamaker from nixpkgs 980c4c3c2f664ccc5002f7fd6e08059cf1f00e75. + +LIBRARY() + +VERSION(5.7) + +ORIGINAL_SOURCE(mirror://kernel/linux/kernel/v5.x/linux-5.7.tar.xz) + +LICENSE( + "(GPL-2.0-only WITH Linux-syscall-note OR BSD-2-Clause)" AND + "(GPL-2.0-only WITH Linux-syscall-note OR BSD-3-Clause)" AND + "(GPL-2.0-only WITH Linux-syscall-note OR CDDL-1.0)" AND + "(GPL-2.0-only WITH Linux-syscall-note OR Linux-OpenIB)" AND + "(GPL-2.0-only WITH Linux-syscall-note OR MIT)" AND + "(GPL-2.0-or-later WITH Linux-syscall-note OR BSD-3-Clause)" AND + BSD-2-Clause AND + BSD-3-Clause AND + GPL-1.0-or-later WITH Linux-syscall-note AND + GPL-2.0-only WITH Linux-syscall-note AND + GPL-2.0-or-later WITH Linux-syscall-note AND + ISC AND + Khronos AND + LGPL-2.0-only AND + LGPL-2.0-or-later WITH Linux-syscall-note AND + LGPL-2.1-only AND + LGPL-2.1-only WITH Linux-syscall-note AND + LGPL-2.1-or-later WITH Linux-syscall-note AND + MIT AND + NTP AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +DISABLE(NEED_PLATFORM_PEERDIRS) + +DISABLE(WITH_VALGRIND) + +ADDINCL( + GLOBAL contrib/libs/linux-headers + GLOBAL contrib/libs/linux-headers/_nf +) + +NO_PLATFORM() + +NO_SANITIZE_HEADERS() + +END() diff --git a/contrib/libs/linuxvdso/original/ya.make b/contrib/libs/linuxvdso/original/ya.make new file mode 100644 index 00000000000..2df9007f974 --- /dev/null +++ b/contrib/libs/linuxvdso/original/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +NO_RUNTIME() + +NO_COMPILER_WARNINGS() + +SRCS( + vdso_support.cc + elf_mem_image.cc +) + +END() diff --git a/contrib/libs/linuxvdso/ya.make b/contrib/libs/linuxvdso/ya.make new file mode 100644 index 00000000000..025b8826dfa --- /dev/null +++ b/contrib/libs/linuxvdso/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +VERSION(2.0) + +ORIGINAL_SOURCE(https://github.com/gperftools/gperftools) + +NO_UTIL() + +NO_RUNTIME() + +IF (OS_LINUX) + PEERDIR( + contrib/libs/linuxvdso/original + ) + SRCS( + interface.cpp + ) +ELSE() + SRCS( + fake.cpp + ) +ENDIF() + +END() diff --git a/contrib/libs/llvm12/include/ya.make b/contrib/libs/llvm12/include/ya.make new file mode 100644 index 00000000000..38b79416dce --- /dev/null +++ b/contrib/libs/llvm12/include/ya.make @@ -0,0 +1,3964 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +PROVIDES(llvm) + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + BSD-2-Clause AND + NCSA AND + Public-Domain AND + Unicode-Mappings +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 +) + +NO_UTIL() + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen --gen-directive-decl -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/Frontend/OpenACC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/Frontend/OpenACC/ACC.td --write-if-changed -o + llvm/Frontend/OpenACC/ACC.h.inc -d llvm/Frontend/OpenACC/ACC.h.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/Frontend/Directive/DirectiveBase.td llvm/Frontend/OpenACC/ACC.td + OUTPUT_INCLUDES llvm/ADT/BitmaskEnum.h + OUT_NOAUTO llvm/Frontend/OpenACC/ACC.h.inc llvm/Frontend/OpenACC/ACC.h.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen --gen-directive-decl -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/Frontend/OpenMP -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/Frontend/OpenMP/OMP.td --write-if-changed -o + llvm/Frontend/OpenMP/OMP.h.inc -d llvm/Frontend/OpenMP/OMP.h.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/Frontend/Directive/DirectiveBase.td llvm/Frontend/OpenMP/OMP.td + OUTPUT_INCLUDES llvm/ADT/BitmaskEnum.h + OUT_NOAUTO llvm/Frontend/OpenMP/OMP.h.inc llvm/Frontend/OpenMP/OMP.h.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-attrs -I ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Attributes.td --write-if-changed -o + llvm/IR/Attributes.inc -d llvm/IR/Attributes.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/IR/Attributes.td + OUT_NOAUTO llvm/IR/Attributes.inc llvm/IR/Attributes.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicEnums.inc -d llvm/IR/IntrinsicEnums.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicEnums.inc llvm/IR/IntrinsicEnums.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-impl -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicImpl.inc -d llvm/IR/IntrinsicImpl.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicImpl.inc llvm/IR/IntrinsicImpl.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=aarch64 -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsAArch64.h -d llvm/IR/IntrinsicsAArch64.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsAArch64.h llvm/IR/IntrinsicsAArch64.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=amdgcn -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsAMDGPU.h -d llvm/IR/IntrinsicsAMDGPU.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsAMDGPU.h llvm/IR/IntrinsicsAMDGPU.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=arm -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsARM.h -d llvm/IR/IntrinsicsARM.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsARM.h llvm/IR/IntrinsicsARM.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=bpf -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsBPF.h -d llvm/IR/IntrinsicsBPF.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsBPF.h llvm/IR/IntrinsicsBPF.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=hexagon -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsHexagon.h -d llvm/IR/IntrinsicsHexagon.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsHexagon.h llvm/IR/IntrinsicsHexagon.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=mips -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsMips.h -d llvm/IR/IntrinsicsMips.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsMips.h llvm/IR/IntrinsicsMips.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=nvvm -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsNVPTX.h -d llvm/IR/IntrinsicsNVPTX.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsNVPTX.h llvm/IR/IntrinsicsNVPTX.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=ppc -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsPowerPC.h -d llvm/IR/IntrinsicsPowerPC.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsPowerPC.h llvm/IR/IntrinsicsPowerPC.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=r600 -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsR600.h -d llvm/IR/IntrinsicsR600.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsR600.h llvm/IR/IntrinsicsR600.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=riscv -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsRISCV.h -d llvm/IR/IntrinsicsRISCV.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsRISCV.h llvm/IR/IntrinsicsRISCV.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=s390 -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsS390.h -d llvm/IR/IntrinsicsS390.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsS390.h llvm/IR/IntrinsicsS390.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=ve -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsVE.h -d llvm/IR/IntrinsicsVE.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsVE.h llvm/IR/IntrinsicsVE.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=wasm -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsWebAssembly.h -d llvm/IR/IntrinsicsWebAssembly.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsWebAssembly.h llvm/IR/IntrinsicsWebAssembly.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=x86 -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsX86.h -d llvm/IR/IntrinsicsX86.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsX86.h llvm/IR/IntrinsicsX86.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-intrinsic-enums -intrinsic-prefix=xcore -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/include/llvm/IR -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/IR/Intrinsics.td --write-if-changed -o + llvm/IR/IntrinsicsXCore.h -d llvm/IR/IntrinsicsXCore.h.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/CodeGen/SDNodeProperties.td llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td + llvm/IR/IntrinsicsAArch64.td llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td + llvm/IR/IntrinsicsBPF.td llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td + llvm/IR/IntrinsicsMips.td llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td + llvm/IR/IntrinsicsRISCV.td llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td + llvm/IR/IntrinsicsVEVL.gen.td llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td + llvm/IR/IntrinsicsXCore.td + OUT_NOAUTO llvm/IR/IntrinsicsXCore.h llvm/IR/IntrinsicsXCore.h.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen --gen-directive-impl -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenACC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/Frontend/OpenACC/ACC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenACC/ACC.cpp -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenACC/ACC.cpp.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/Frontend/Directive/DirectiveBase.td llvm/Frontend/OpenACC/ACC.td + OUTPUT_INCLUDES llvm/ADT/StringRef.h llvm/ADT/StringSwitch.h llvm/Frontend/OpenACC/ACC.h.inc + llvm/Support/ErrorHandling.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenACC/ACC.cpp + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenACC/ACC.cpp.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen --gen-directive-impl -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenMP -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include llvm/Frontend/OpenMP/OMP.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenMP/OMP.cpp -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenMP/OMP.cpp.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN llvm/Frontend/Directive/DirectiveBase.td llvm/Frontend/OpenMP/OMP.td + OUTPUT_INCLUDES llvm/ADT/StringRef.h llvm/ADT/StringSwitch.h llvm/Frontend/OpenMP/OMP.h.inc + llvm/Support/ErrorHandling.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenMP/OMP.cpp + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Frontend/OpenMP/OMP.cpp.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-matcher -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmMatcher.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmMatcher.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/Support/Debug.h llvm/Support/Format.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmMatcher.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmMatcher.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -asmwriternum=1 -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter1.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter1.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter1.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenAsmWriter1.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-callingconv -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenCallingConv.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenCallingConv.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenCallingConv.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenCallingConv.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-dag-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target -omit-comments + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDAGISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDAGISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDAGISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDAGISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-disassembler -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDisassemblerTables.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDisassemblerTables.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES assert.h llvm/MC/MCInst.h llvm/Support/DataTypes.h llvm/Support/Debug.h + llvm/Support/LEB128.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDisassemblerTables.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenDisassemblerTables.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-exegesis -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenExegesis.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenExegesis.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenExegesis.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenExegesis.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-fast-isel -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenFastISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenFastISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenFastISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenFastISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-global-isel -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenGlobalISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenGlobalISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenGlobalISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenGlobalISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-instr-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenInstrInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenInstrInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenInstrInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenInstrInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-emitter -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCCodeEmitter.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCCodeEmitter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES _llvm_sstream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCCodeEmitter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCCodeEmitter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-pseudo-lowering -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCPseudoLowering.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCPseudoLowering.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCPseudoLowering.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenMCPseudoLowering.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-global-isel-combiner -combiners=AArch64PostLegalizerCombinerHelper + -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/ADT/SparseBitVector.h + OUT_NOAUTO + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-global-isel-combiner -combiners=AArch64PostLegalizerLoweringHelper + -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/ADT/SparseBitVector.h + OUT_NOAUTO + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-global-isel-combiner -combiners=AArch64PreLegalizerCombinerHelper + -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/ADT/SparseBitVector.h + OUT_NOAUTO + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-bank -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterBank.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterBank.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterBank.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterBank.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetRegisterInfo.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenRegisterInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-subtarget -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSubtargetInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSubtargetInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetSchedule.h llvm/Support/Debug.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSubtargetInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSubtargetInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-searchable-tables -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/AArch64.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSystemOperands.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSystemOperands.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/AArch64/AArch64.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64CallingConvention.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Combine.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrAtomics.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrFormats.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrGISel.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64InstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64PfmCounters.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterBanks.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64RegisterInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SVEInstrInfo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA53.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA55.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA57WriteRes.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedA64FX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedCyclone.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM3.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM4.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedExynosM5.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkor.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedFalkorDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryo.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedKryoDetails.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredExynos.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedPredicates.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedTSV110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX2T99.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SchedThunderX3T110.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64Schedule.td + contrib/libs/llvm12/lib/Target/AArch64/AArch64SystemOperands.td + contrib/libs/llvm12/lib/Target/AArch64/SVEInstrFormats.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/Combine.td + llvm/Target/GlobalISel/RegisterBank.td llvm/Target/GlobalISel/SelectionDAGCompat.td + llvm/Target/GlobalISel/Target.td llvm/Target/Target.td llvm/Target/TargetCallingConv.td + llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td llvm/Target/TargetPfmCounters.td + llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSystemOperands.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64/AArch64GenSystemOperands.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-matcher -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmMatcher.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmMatcher.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/Support/Debug.h llvm/Support/Format.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmMatcher.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmMatcher.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmWriter.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmWriter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmWriter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenAsmWriter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-callingconv -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenCallingConv.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenCallingConv.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenCallingConv.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenCallingConv.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-dag-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target -omit-comments + contrib/libs/llvm12/lib/Target/ARM/ARM.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDAGISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDAGISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDAGISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDAGISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-disassembler -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDisassemblerTables.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDisassemblerTables.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES assert.h llvm/MC/MCInst.h llvm/Support/DataTypes.h llvm/Support/Debug.h + llvm/Support/LEB128.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDisassemblerTables.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenDisassemblerTables.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-fast-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenFastISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenFastISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenFastISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenFastISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-global-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenGlobalISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenGlobalISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenGlobalISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenGlobalISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-instr-info -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenInstrInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenInstrInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenInstrInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenInstrInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-emitter -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCCodeEmitter.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCCodeEmitter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES _llvm_sstream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCCodeEmitter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCCodeEmitter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-pseudo-lowering -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/ARM/ARM.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCPseudoLowering.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCPseudoLowering.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCPseudoLowering.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenMCPseudoLowering.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-bank -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/ARM/ARM.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterBank.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterBank.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterBank.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterBank.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/ARM/ARM.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetRegisterInfo.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenRegisterInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-subtarget -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/ARM/ARM.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSubtargetInfo.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSubtargetInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetSchedule.h llvm/Support/Debug.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSubtargetInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSubtargetInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-searchable-tables -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/ARM -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/ARM/ARM.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSystemRegister.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSystemRegister.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/ARM/ARM.td contrib/libs/llvm12/lib/Target/ARM/ARMCallingConv.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrCDE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrFormats.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrInfo.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrMVE.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrNEON.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb.td + contrib/libs/llvm12/lib/Target/ARM/ARMInstrThumb2.td contrib/libs/llvm12/lib/Target/ARM/ARMInstrVFP.td + contrib/libs/llvm12/lib/Target/ARM/ARMPredicates.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterBanks.td + contrib/libs/llvm12/lib/Target/ARM/ARMRegisterInfo.td + contrib/libs/llvm12/lib/Target/ARM/ARMSchedule.td contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA57WriteRes.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA8.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleA9.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM4.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleM7.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleR52.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleSwift.td + contrib/libs/llvm12/lib/Target/ARM/ARMScheduleV6.td + contrib/libs/llvm12/lib/Target/ARM/ARMSystemRegister.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/TableGen/SearchableTable.td llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSystemRegister.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM/ARMGenSystemRegister.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-matcher -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/BPF/BPF.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmMatcher.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmMatcher.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/Support/Debug.h llvm/Support/Format.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmMatcher.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmMatcher.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/BPF/BPF.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmWriter.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmWriter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmWriter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenAsmWriter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-callingconv -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/BPF/BPF.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenCallingConv.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenCallingConv.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenCallingConv.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenCallingConv.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-dag-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target -omit-comments + contrib/libs/llvm12/lib/Target/BPF/BPF.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDAGISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDAGISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDAGISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDAGISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-disassembler -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/BPF/BPF.td + --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDisassemblerTables.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDisassemblerTables.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES assert.h llvm/MC/MCInst.h llvm/Support/DataTypes.h llvm/Support/Debug.h + llvm/Support/LEB128.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDisassemblerTables.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenDisassemblerTables.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-instr-info -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/BPF/BPF.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenInstrInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenInstrInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenInstrInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenInstrInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-emitter -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/BPF/BPF.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenMCCodeEmitter.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenMCCodeEmitter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES _llvm_sstream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenMCCodeEmitter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenMCCodeEmitter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/BPF/BPF.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenRegisterInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenRegisterInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetRegisterInfo.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenRegisterInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenRegisterInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-subtarget -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/BPF + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/BPF/BPF.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenSubtargetInfo.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenSubtargetInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/BPF/BPF.td contrib/libs/llvm12/lib/Target/BPF/BPFCallingConv.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrFormats.td + contrib/libs/llvm12/lib/Target/BPF/BPFInstrInfo.td + contrib/libs/llvm12/lib/Target/BPF/BPFRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetSchedule.h llvm/Support/Debug.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenSubtargetInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF/BPFGenSubtargetInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenAsmWriter.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenAsmWriter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrFormats.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrInfo.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXIntrinsics.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenAsmWriter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenAsmWriter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-dag-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target -omit-comments + contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenDAGISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenDAGISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrFormats.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrInfo.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXIntrinsics.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenDAGISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenDAGISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-instr-info -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenInstrInfo.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenInstrInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrFormats.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrInfo.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXIntrinsics.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenInstrInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenInstrInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenRegisterInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenRegisterInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrFormats.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrInfo.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXIntrinsics.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetRegisterInfo.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenRegisterInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenRegisterInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-subtarget -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td + --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/NVPTX/NVPTX.td contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrFormats.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXInstrInfo.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXIntrinsics.td + contrib/libs/llvm12/lib/Target/NVPTX/NVPTXRegisterInfo.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetSchedule.h llvm/Support/Debug.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-matcher -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmMatcher.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmMatcher.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/Support/Debug.h llvm/Support/Format.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmMatcher.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmMatcher.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmWriter.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmWriter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmWriter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenAsmWriter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-callingconv -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenCallingConv.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenCallingConv.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenCallingConv.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenCallingConv.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-dag-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target -omit-comments + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDAGISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDAGISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDAGISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDAGISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-disassembler -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDisassemblerTables.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDisassemblerTables.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES assert.h llvm/MC/MCInst.h llvm/Support/DataTypes.h llvm/Support/Debug.h + llvm/Support/LEB128.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDisassemblerTables.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenDisassemblerTables.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-exegesis -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/PowerPC/PPC.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenExegesis.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenExegesis.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenExegesis.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenExegesis.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-fast-isel -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenFastISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenFastISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenFastISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenFastISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-global-isel -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenGlobalISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenGlobalISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenGlobalISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenGlobalISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-instr-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenInstrInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenInstrInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenInstrInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenInstrInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-emitter -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/PowerPC/PPC.td + --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenMCCodeEmitter.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenMCCodeEmitter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES _llvm_sstream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenMCCodeEmitter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenMCCodeEmitter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-bank -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterBank.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterBank.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterBank.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterBank.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetRegisterInfo.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenRegisterInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-subtarget -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenSubtargetInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenSubtargetInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/PowerPC/GISel/PPCRegisterBanks.td + contrib/libs/llvm12/lib/Target/PowerPC/P9InstrResources.td + contrib/libs/llvm12/lib/Target/PowerPC/PPC.td contrib/libs/llvm12/lib/Target/PowerPC/PPCCallingConv.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstr64Bit.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrAltivec.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrFormats.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrHTM.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrPrefix.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrSPE.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCInstrVSX.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCPfmCounters.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCRegisterInfo.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCSchedule440.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleA2.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE500mc.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleE5500.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG3.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG4Plus.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleG5.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP7.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP8.td + contrib/libs/llvm12/lib/Target/PowerPC/PPCScheduleP9.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetSchedule.h llvm/Support/Debug.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenSubtargetInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC/PPCGenSubtargetInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-matcher -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmMatcher.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmMatcher.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/Support/Debug.h llvm/Support/Format.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmMatcher.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmMatcher.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-asm-writer -asmwriternum=1 -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/X86/X86.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter1.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter1.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter1.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenAsmWriter1.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-callingconv -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenCallingConv.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenCallingConv.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenCallingConv.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenCallingConv.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-dag-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target -omit-comments + contrib/libs/llvm12/lib/Target/X86/X86.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDAGISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDAGISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDAGISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDAGISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-disassembler -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDisassemblerTables.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDisassemblerTables.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDisassemblerTables.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenDisassemblerTables.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-x86-EVEX2VEX-tables -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/X86/X86.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenEVEX2VEXTables.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenEVEX2VEXTables.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenEVEX2VEXTables.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenEVEX2VEXTables.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-exegesis -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenExegesis.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenExegesis.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenExegesis.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenExegesis.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-fast-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenFastISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenFastISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenFastISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenFastISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-global-isel -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenGlobalISel.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenGlobalISel.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenGlobalISel.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenGlobalISel.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-instr-info -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenInstrInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenInstrInfo.inc.d + --long-string-literals=0 + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenInstrInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenInstrInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-bank -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/X86/X86.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterBank.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterBank.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterBank.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterBank.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-register-info -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/X86/X86.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterInfo.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetRegisterInfo.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenRegisterInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-subtarget -I ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target/X86 + -Iinclude -I${ARCADIA_ROOT}/contrib/libs/llvm12/include -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/Target contrib/libs/llvm12/lib/Target/X86/X86.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenSubtargetInfo.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenSubtargetInfo.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/Target/X86/X86.td contrib/libs/llvm12/lib/Target/X86/X86CallingConv.td + contrib/libs/llvm12/lib/Target/X86/X86Instr3DNow.td contrib/libs/llvm12/lib/Target/X86/X86InstrAMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrAVX512.td + contrib/libs/llvm12/lib/Target/X86/X86InstrArithmetic.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCMovSetCC.td + contrib/libs/llvm12/lib/Target/X86/X86InstrCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrControl.td + contrib/libs/llvm12/lib/Target/X86/X86InstrExtension.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFMA.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFPStack.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFormats.td + contrib/libs/llvm12/lib/Target/X86/X86InstrFragmentsSIMD.td + contrib/libs/llvm12/lib/Target/X86/X86InstrInfo.td contrib/libs/llvm12/lib/Target/X86/X86InstrKL.td + contrib/libs/llvm12/lib/Target/X86/X86InstrMMX.td contrib/libs/llvm12/lib/Target/X86/X86InstrMPX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSGX.td contrib/libs/llvm12/lib/Target/X86/X86InstrSNP.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSSE.td contrib/libs/llvm12/lib/Target/X86/X86InstrSVM.td + contrib/libs/llvm12/lib/Target/X86/X86InstrShiftRotate.td + contrib/libs/llvm12/lib/Target/X86/X86InstrSystem.td contrib/libs/llvm12/lib/Target/X86/X86InstrTDX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrTSX.td contrib/libs/llvm12/lib/Target/X86/X86InstrVMX.td + contrib/libs/llvm12/lib/Target/X86/X86InstrVecCompiler.td + contrib/libs/llvm12/lib/Target/X86/X86InstrXOP.td contrib/libs/llvm12/lib/Target/X86/X86PfmCounters.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterBanks.td + contrib/libs/llvm12/lib/Target/X86/X86RegisterInfo.td + contrib/libs/llvm12/lib/Target/X86/X86SchedBroadwell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedHaswell.td + contrib/libs/llvm12/lib/Target/X86/X86SchedPredicates.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSandyBridge.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeClient.td + contrib/libs/llvm12/lib/Target/X86/X86SchedSkylakeServer.td + contrib/libs/llvm12/lib/Target/X86/X86Schedule.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleAtom.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBdVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleBtVer2.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleSLM.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver1.td + contrib/libs/llvm12/lib/Target/X86/X86ScheduleZnver2.td llvm/CodeGen/SDNodeProperties.td + llvm/CodeGen/ValueTypes.td llvm/IR/Intrinsics.td llvm/IR/IntrinsicsAArch64.td + llvm/IR/IntrinsicsAMDGPU.td llvm/IR/IntrinsicsARM.td llvm/IR/IntrinsicsBPF.td + llvm/IR/IntrinsicsHexagon.td llvm/IR/IntrinsicsHexagonDep.td llvm/IR/IntrinsicsMips.td + llvm/IR/IntrinsicsNVVM.td llvm/IR/IntrinsicsPowerPC.td llvm/IR/IntrinsicsRISCV.td + llvm/IR/IntrinsicsSystemZ.td llvm/IR/IntrinsicsVE.td llvm/IR/IntrinsicsVEVL.gen.td + llvm/IR/IntrinsicsWebAssembly.td llvm/IR/IntrinsicsX86.td llvm/IR/IntrinsicsXCore.td + llvm/Target/GenericOpcodes.td llvm/Target/GlobalISel/RegisterBank.td + llvm/Target/GlobalISel/SelectionDAGCompat.td llvm/Target/GlobalISel/Target.td llvm/Target/Target.td + llvm/Target/TargetCallingConv.td llvm/Target/TargetInstrPredicate.td llvm/Target/TargetItinerary.td + llvm/Target/TargetPfmCounters.td llvm/Target/TargetSchedule.td llvm/Target/TargetSelectionDAG.td + OUTPUT_INCLUDES llvm/CodeGen/TargetSchedule.h llvm/Support/Debug.h llvm/Support/raw_ostream.h + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenSubtargetInfo.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86/X86GenSubtargetInfo.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include + contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/Options.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/Options.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/Options.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/Options.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/Options.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/Options.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/Options.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/Options.inc + -d ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/Options.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/Options.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/Options.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/Options.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/dsymutil -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/dsymutil/Options.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/dsymutil/Options.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/dsymutil/Options.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/dsymutil/Options.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/dsymutil/Options.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/dsymutil/Options.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-cvtres/Opts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres/Opts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres/Opts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-cvtres/Opts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres/Opts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres/Opts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-lipo -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-lipo/LipoOpts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-lipo/LipoOpts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-lipo/LipoOpts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-lipo/LipoOpts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-lipo/LipoOpts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-lipo/LipoOpts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-ml -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-ml/Opts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-ml/Opts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-ml/Opts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-ml/Opts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-ml/Opts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-ml/Opts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-mt -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-mt/Opts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-mt/Opts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-mt/Opts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-mt/Opts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-mt/Opts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-mt/Opts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include + contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include + contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.td --write-if-changed -o + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-objcopy/ObjcopyOpts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/ObjcopyOpts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/ObjcopyOpts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-objcopy/CommonOpts.td + contrib/libs/llvm12/tools/llvm-objcopy/ObjcopyOpts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/ObjcopyOpts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/ObjcopyOpts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-objcopy/StripOpts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/StripOpts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/StripOpts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-objcopy/CommonOpts.td + contrib/libs/llvm12/tools/llvm-objcopy/StripOpts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/StripOpts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy/StripOpts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-rc -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-rc/Opts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-rc/Opts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-rc/Opts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-rc/Opts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-rc/Opts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-rc/Opts.inc.d +) + +RUN_PROGRAM( + contrib/libs/llvm12/utils/TableGen -gen-opt-parser-defs -I + ${ARCADIA_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer -Iinclude + -I${ARCADIA_ROOT}/contrib/libs/llvm12/include contrib/libs/llvm12/tools/llvm-symbolizer/Opts.td + --write-if-changed -o ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.inc -d + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.inc.d + CWD ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12 + IN contrib/libs/llvm12/tools/llvm-symbolizer/Opts.td llvm/Option/OptParser.td + OUT_NOAUTO ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.inc + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.inc.d +) + +END() diff --git a/contrib/libs/llvm12/lib/Analysis/ya.make b/contrib/libs/llvm12/lib/Analysis/ya.make new file mode 100644 index 00000000000..9de20901d6a --- /dev/null +++ b/contrib/libs/llvm12/lib/Analysis/ya.make @@ -0,0 +1,146 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Analysis +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AliasAnalysis.cpp + AliasAnalysisEvaluator.cpp + AliasAnalysisSummary.cpp + AliasSetTracker.cpp + Analysis.cpp + AssumeBundleQueries.cpp + AssumptionCache.cpp + BasicAliasAnalysis.cpp + BlockFrequencyInfo.cpp + BlockFrequencyInfoImpl.cpp + BranchProbabilityInfo.cpp + CFG.cpp + CFGPrinter.cpp + CFLAndersAliasAnalysis.cpp + CFLSteensAliasAnalysis.cpp + CGSCCPassManager.cpp + CallGraph.cpp + CallGraphSCCPass.cpp + CallPrinter.cpp + CaptureTracking.cpp + CmpInstAnalysis.cpp + CodeMetrics.cpp + ConstantFolding.cpp + ConstraintSystem.cpp + CostModel.cpp + DDG.cpp + DDGPrinter.cpp + Delinearization.cpp + DemandedBits.cpp + DependenceAnalysis.cpp + DependenceGraphBuilder.cpp + DevelopmentModeInlineAdvisor.cpp + DivergenceAnalysis.cpp + DomPrinter.cpp + DomTreeUpdater.cpp + DominanceFrontier.cpp + EHPersonalities.cpp + FunctionPropertiesAnalysis.cpp + GlobalsModRef.cpp + GuardUtils.cpp + HeatUtils.cpp + IRSimilarityIdentifier.cpp + IVDescriptors.cpp + IVUsers.cpp + ImportedFunctionsInliningStatistics.cpp + IndirectCallPromotionAnalysis.cpp + InlineAdvisor.cpp + InlineCost.cpp + InlineSizeEstimatorAnalysis.cpp + InstCount.cpp + InstructionPrecedenceTracking.cpp + InstructionSimplify.cpp + Interval.cpp + IntervalPartition.cpp + LazyBlockFrequencyInfo.cpp + LazyBranchProbabilityInfo.cpp + LazyCallGraph.cpp + LazyValueInfo.cpp + LegacyDivergenceAnalysis.cpp + Lint.cpp + Loads.cpp + LoopAccessAnalysis.cpp + LoopAnalysisManager.cpp + LoopCacheAnalysis.cpp + LoopInfo.cpp + LoopNestAnalysis.cpp + LoopPass.cpp + LoopUnrollAnalyzer.cpp + MLInlineAdvisor.cpp + MemDepPrinter.cpp + MemDerefPrinter.cpp + MemoryBuiltins.cpp + MemoryDependenceAnalysis.cpp + MemoryLocation.cpp + MemorySSA.cpp + MemorySSAUpdater.cpp + ModuleDebugInfoPrinter.cpp + ModuleSummaryAnalysis.cpp + MustExecute.cpp + ObjCARCAliasAnalysis.cpp + ObjCARCAnalysisUtils.cpp + ObjCARCInstKind.cpp + OptimizationRemarkEmitter.cpp + PHITransAddr.cpp + PhiValues.cpp + PostDominators.cpp + ProfileSummaryInfo.cpp + PtrUseVisitor.cpp + RegionInfo.cpp + RegionPass.cpp + RegionPrinter.cpp + ReleaseModeModelRunner.cpp + ReplayInlineAdvisor.cpp + ScalarEvolution.cpp + ScalarEvolutionAliasAnalysis.cpp + ScalarEvolutionDivision.cpp + ScalarEvolutionNormalization.cpp + ScopedNoAliasAA.cpp + StackLifetime.cpp + StackSafetyAnalysis.cpp + SyncDependenceAnalysis.cpp + SyntheticCountsUtils.cpp + TFUtils.cpp + TargetLibraryInfo.cpp + TargetTransformInfo.cpp + Trace.cpp + TypeBasedAliasAnalysis.cpp + TypeMetadataUtils.cpp + VFABIDemangling.cpp + ValueLattice.cpp + ValueLatticeUtils.cpp + ValueTracking.cpp + VectorUtils.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/AsmParser/ya.make b/contrib/libs/llvm12/lib/AsmParser/ya.make new file mode 100644 index 00000000000..5a2ed51a71b --- /dev/null +++ b/contrib/libs/llvm12/lib/AsmParser/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/AsmParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + LLLexer.cpp + LLParser.cpp + Parser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/BinaryFormat/ya.make b/contrib/libs/llvm12/lib/BinaryFormat/ya.make new file mode 100644 index 00000000000..c466edfa5c5 --- /dev/null +++ b/contrib/libs/llvm12/lib/BinaryFormat/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/BinaryFormat +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AMDGPUMetadataVerifier.cpp + Dwarf.cpp + MachO.cpp + Magic.cpp + Minidump.cpp + MsgPackDocument.cpp + MsgPackDocumentYAML.cpp + MsgPackReader.cpp + MsgPackWriter.cpp + Wasm.cpp + XCOFF.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Bitcode/Reader/ya.make b/contrib/libs/llvm12/lib/Bitcode/Reader/ya.make new file mode 100644 index 00000000000..5ff600cff8f --- /dev/null +++ b/contrib/libs/llvm12/lib/Bitcode/Reader/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Bitcode/Reader +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BitReader.cpp + BitcodeAnalyzer.cpp + BitcodeReader.cpp + MetadataLoader.cpp + ValueList.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Bitcode/Writer/ya.make b/contrib/libs/llvm12/lib/Bitcode/Writer/ya.make new file mode 100644 index 00000000000..3a4ff16476d --- /dev/null +++ b/contrib/libs/llvm12/lib/Bitcode/Writer/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Bitcode/Writer +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BitWriter.cpp + BitcodeWriter.cpp + BitcodeWriterPass.cpp + ValueEnumerator.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Bitstream/Reader/ya.make b/contrib/libs/llvm12/lib/Bitstream/Reader/ya.make new file mode 100644 index 00000000000..db6b43a8cb2 --- /dev/null +++ b/contrib/libs/llvm12/lib/Bitstream/Reader/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Bitstream/Reader +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BitstreamReader.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/ya.make b/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/ya.make new file mode 100644 index 00000000000..d0236557d8b --- /dev/null +++ b/contrib/libs/llvm12/lib/CodeGen/AsmPrinter/ya.make @@ -0,0 +1,70 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target +) + +IF (SANITIZER_TYPE == "undefined") + PEERDIR( + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + ) +ENDIF() + +ADDINCL( + contrib/libs/llvm12/lib/CodeGen/AsmPrinter +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AIXException.cpp + ARMException.cpp + AccelTable.cpp + AddressPool.cpp + AsmPrinter.cpp + AsmPrinterDwarf.cpp + AsmPrinterInlineAsm.cpp + CodeViewDebug.cpp + DIE.cpp + DIEHash.cpp + DbgEntityHistoryCalculator.cpp + DebugHandlerBase.cpp + DebugLocStream.cpp + DwarfCFIException.cpp + DwarfCompileUnit.cpp + DwarfDebug.cpp + DwarfExpression.cpp + DwarfFile.cpp + DwarfStringPool.cpp + DwarfUnit.cpp + EHStreamer.cpp + ErlangGCPrinter.cpp + OcamlGCPrinter.cpp + PseudoProbePrinter.cpp + WasmException.cpp + WinCFGuard.cpp + WinException.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/CodeGen/GlobalISel/ya.make b/contrib/libs/llvm12/lib/CodeGen/GlobalISel/ya.make new file mode 100644 index 00000000000..d4ee068affa --- /dev/null +++ b/contrib/libs/llvm12/lib/CodeGen/GlobalISel/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/CodeGen/GlobalISel +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CSEInfo.cpp + CSEMIRBuilder.cpp + CallLowering.cpp + Combiner.cpp + CombinerHelper.cpp + GISelChangeObserver.cpp + GISelKnownBits.cpp + GlobalISel.cpp + IRTranslator.cpp + InlineAsmLowering.cpp + InstructionSelect.cpp + InstructionSelector.cpp + LegalityPredicates.cpp + LegalizeMutations.cpp + Legalizer.cpp + LegalizerHelper.cpp + LegalizerInfo.cpp + Localizer.cpp + LostDebugLocObserver.cpp + MachineIRBuilder.cpp + RegBankSelect.cpp + RegisterBank.cpp + RegisterBankInfo.cpp + Utils.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/CodeGen/MIRParser/ya.make b/contrib/libs/llvm12/lib/CodeGen/MIRParser/ya.make new file mode 100644 index 00000000000..18f32c7f8da --- /dev/null +++ b/contrib/libs/llvm12/lib/CodeGen/MIRParser/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target +) + +ADDINCL( + contrib/libs/llvm12/lib/CodeGen/MIRParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + MILexer.cpp + MIParser.cpp + MIRParser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/CodeGen/SelectionDAG/ya.make b/contrib/libs/llvm12/lib/CodeGen/SelectionDAG/ya.make new file mode 100644 index 00000000000..09d4c52f8f0 --- /dev/null +++ b/contrib/libs/llvm12/lib/CodeGen/SelectionDAG/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/CodeGen/SelectionDAG +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DAGCombiner.cpp + FastISel.cpp + FunctionLoweringInfo.cpp + InstrEmitter.cpp + LegalizeDAG.cpp + LegalizeFloatTypes.cpp + LegalizeIntegerTypes.cpp + LegalizeTypes.cpp + LegalizeTypesGeneric.cpp + LegalizeVectorOps.cpp + LegalizeVectorTypes.cpp + ResourcePriorityQueue.cpp + ScheduleDAGFast.cpp + ScheduleDAGRRList.cpp + ScheduleDAGSDNodes.cpp + ScheduleDAGVLIW.cpp + SelectionDAG.cpp + SelectionDAGAddressAnalysis.cpp + SelectionDAGBuilder.cpp + SelectionDAGDumper.cpp + SelectionDAGISel.cpp + SelectionDAGPrinter.cpp + SelectionDAGTargetInfo.cpp + StatepointLowering.cpp + TargetLowering.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/CodeGen/ya.make b/contrib/libs/llvm12/lib/CodeGen/ya.make new file mode 100644 index 00000000000..249a95e5eba --- /dev/null +++ b/contrib/libs/llvm12/lib/CodeGen/ya.make @@ -0,0 +1,228 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/CodeGen +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AggressiveAntiDepBreaker.cpp + AllocationOrder.cpp + Analysis.cpp + AtomicExpandPass.cpp + BasicBlockSections.cpp + BasicTargetTransformInfo.cpp + BranchFolding.cpp + BranchRelaxation.cpp + BreakFalseDeps.cpp + BuiltinGCs.cpp + CFGuardLongjmp.cpp + CFIInstrInserter.cpp + CalcSpillWeights.cpp + CallingConvLower.cpp + CodeGen.cpp + CodeGenPassBuilder.cpp + CodeGenPrepare.cpp + CommandFlags.cpp + CriticalAntiDepBreaker.cpp + DFAPacketizer.cpp + DeadMachineInstructionElim.cpp + DetectDeadLanes.cpp + DwarfEHPrepare.cpp + EarlyIfConversion.cpp + EdgeBundles.cpp + ExecutionDomainFix.cpp + ExpandMemCmp.cpp + ExpandPostRAPseudos.cpp + ExpandReductions.cpp + FEntryInserter.cpp + FaultMaps.cpp + FinalizeISel.cpp + FixupStatepointCallerSaved.cpp + FuncletLayout.cpp + GCMetadata.cpp + GCMetadataPrinter.cpp + GCRootLowering.cpp + GCStrategy.cpp + GlobalMerge.cpp + HardwareLoops.cpp + IfConversion.cpp + ImplicitNullChecks.cpp + IndirectBrExpandPass.cpp + InlineSpiller.cpp + InterferenceCache.cpp + InterleavedAccessPass.cpp + InterleavedLoadCombinePass.cpp + IntrinsicLowering.cpp + LLVMTargetMachine.cpp + LatencyPriorityQueue.cpp + LazyMachineBlockFrequencyInfo.cpp + LexicalScopes.cpp + LiveDebugValues/InstrRefBasedImpl.cpp + LiveDebugValues/LiveDebugValues.cpp + LiveDebugValues/VarLocBasedImpl.cpp + LiveDebugVariables.cpp + LiveInterval.cpp + LiveIntervalCalc.cpp + LiveIntervalUnion.cpp + LiveIntervals.cpp + LivePhysRegs.cpp + LiveRangeCalc.cpp + LiveRangeEdit.cpp + LiveRangeShrink.cpp + LiveRegMatrix.cpp + LiveRegUnits.cpp + LiveStacks.cpp + LiveVariables.cpp + LocalStackSlotAllocation.cpp + LoopTraversal.cpp + LowLevelType.cpp + LowerEmuTLS.cpp + MBFIWrapper.cpp + MIRCanonicalizerPass.cpp + MIRNamerPass.cpp + MIRPrinter.cpp + MIRPrintingPass.cpp + MIRVRegNamerUtils.cpp + MachineBasicBlock.cpp + MachineBlockFrequencyInfo.cpp + MachineBlockPlacement.cpp + MachineBranchProbabilityInfo.cpp + MachineCSE.cpp + MachineCheckDebugify.cpp + MachineCombiner.cpp + MachineCopyPropagation.cpp + MachineDebugify.cpp + MachineDominanceFrontier.cpp + MachineDominators.cpp + MachineFrameInfo.cpp + MachineFunction.cpp + MachineFunctionPass.cpp + MachineFunctionPrinterPass.cpp + MachineFunctionSplitter.cpp + MachineInstr.cpp + MachineInstrBundle.cpp + MachineLICM.cpp + MachineLoopInfo.cpp + MachineLoopUtils.cpp + MachineModuleInfo.cpp + MachineModuleInfoImpls.cpp + MachineOperand.cpp + MachineOptimizationRemarkEmitter.cpp + MachineOutliner.cpp + MachinePassManager.cpp + MachinePipeliner.cpp + MachinePostDominators.cpp + MachineRegionInfo.cpp + MachineRegisterInfo.cpp + MachineSSAUpdater.cpp + MachineScheduler.cpp + MachineSink.cpp + MachineSizeOpts.cpp + MachineStableHash.cpp + MachineStripDebug.cpp + MachineTraceMetrics.cpp + MachineVerifier.cpp + MacroFusion.cpp + ModuloSchedule.cpp + MultiHazardRecognizer.cpp + NonRelocatableStringpool.cpp + OptimizePHIs.cpp + PHIElimination.cpp + PHIEliminationUtils.cpp + ParallelCG.cpp + PatchableFunction.cpp + PeepholeOptimizer.cpp + PostRAHazardRecognizer.cpp + PostRASchedulerList.cpp + PreISelIntrinsicLowering.cpp + ProcessImplicitDefs.cpp + PrologEpilogInserter.cpp + PseudoProbeInserter.cpp + PseudoSourceValue.cpp + RDFGraph.cpp + RDFLiveness.cpp + RDFRegisters.cpp + ReachingDefAnalysis.cpp + RegAllocBase.cpp + RegAllocBasic.cpp + RegAllocFast.cpp + RegAllocGreedy.cpp + RegAllocPBQP.cpp + RegUsageInfoCollector.cpp + RegUsageInfoPropagate.cpp + RegisterClassInfo.cpp + RegisterCoalescer.cpp + RegisterPressure.cpp + RegisterScavenging.cpp + RegisterUsageInfo.cpp + RenameIndependentSubregs.cpp + ResetMachineFunctionPass.cpp + SafeStack.cpp + SafeStackLayout.cpp + ScheduleDAG.cpp + ScheduleDAGInstrs.cpp + ScheduleDAGPrinter.cpp + ScoreboardHazardRecognizer.cpp + ShadowStackGCLowering.cpp + ShrinkWrap.cpp + SjLjEHPrepare.cpp + SlotIndexes.cpp + SpillPlacement.cpp + SplitKit.cpp + StackColoring.cpp + StackMapLivenessAnalysis.cpp + StackMaps.cpp + StackProtector.cpp + StackSlotColoring.cpp + SwiftErrorValueTracking.cpp + SwitchLoweringUtils.cpp + TailDuplication.cpp + TailDuplicator.cpp + TargetFrameLoweringImpl.cpp + TargetInstrInfo.cpp + TargetLoweringBase.cpp + TargetLoweringObjectFileImpl.cpp + TargetOptionsImpl.cpp + TargetPassConfig.cpp + TargetRegisterInfo.cpp + TargetSchedule.cpp + TargetSubtargetInfo.cpp + TwoAddressInstructionPass.cpp + TypePromotion.cpp + UnreachableBlockElim.cpp + ValueTypes.cpp + VirtRegMap.cpp + WasmEHPrepare.cpp + WinEHPrepare.cpp + XRayInstrumentation.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/DWARFLinker/ya.make b/contrib/libs/llvm12/lib/DWARFLinker/ya.make new file mode 100644 index 00000000000..f1b75852312 --- /dev/null +++ b/contrib/libs/llvm12/lib/DWARFLinker/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/DWARFLinker +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DWARFLinker.cpp + DWARFLinkerCompileUnit.cpp + DWARFLinkerDeclContext.cpp + DWARFStreamer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/DebugInfo/CodeView/ya.make b/contrib/libs/llvm12/lib/DebugInfo/CodeView/ya.make new file mode 100644 index 00000000000..45ae58845e7 --- /dev/null +++ b/contrib/libs/llvm12/lib/DebugInfo/CodeView/ya.make @@ -0,0 +1,66 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/DebugInfo/CodeView +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AppendingTypeTableBuilder.cpp + CVSymbolVisitor.cpp + CVTypeVisitor.cpp + CodeViewError.cpp + CodeViewRecordIO.cpp + ContinuationRecordBuilder.cpp + DebugChecksumsSubsection.cpp + DebugCrossExSubsection.cpp + DebugCrossImpSubsection.cpp + DebugFrameDataSubsection.cpp + DebugInlineeLinesSubsection.cpp + DebugLinesSubsection.cpp + DebugStringTableSubsection.cpp + DebugSubsection.cpp + DebugSubsectionRecord.cpp + DebugSubsectionVisitor.cpp + DebugSymbolRVASubsection.cpp + DebugSymbolsSubsection.cpp + EnumTables.cpp + Formatters.cpp + GlobalTypeTableBuilder.cpp + LazyRandomTypeCollection.cpp + Line.cpp + MergingTypeTableBuilder.cpp + RecordName.cpp + RecordSerialization.cpp + SimpleTypeSerializer.cpp + StringsAndChecksums.cpp + SymbolDumper.cpp + SymbolRecordHelpers.cpp + SymbolRecordMapping.cpp + SymbolSerializer.cpp + TypeDumpVisitor.cpp + TypeHashing.cpp + TypeIndex.cpp + TypeIndexDiscovery.cpp + TypeRecordHelpers.cpp + TypeRecordMapping.cpp + TypeStreamMerger.cpp + TypeTableCollection.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/DebugInfo/DWARF/ya.make b/contrib/libs/llvm12/lib/DebugInfo/DWARF/ya.make new file mode 100644 index 00000000000..22f831fb25d --- /dev/null +++ b/contrib/libs/llvm12/lib/DebugInfo/DWARF/ya.make @@ -0,0 +1,56 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/DebugInfo/DWARF +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DWARFAbbreviationDeclaration.cpp + DWARFAcceleratorTable.cpp + DWARFAddressRange.cpp + DWARFCompileUnit.cpp + DWARFContext.cpp + DWARFDataExtractor.cpp + DWARFDebugAbbrev.cpp + DWARFDebugAddr.cpp + DWARFDebugArangeSet.cpp + DWARFDebugAranges.cpp + DWARFDebugFrame.cpp + DWARFDebugInfoEntry.cpp + DWARFDebugLine.cpp + DWARFDebugLoc.cpp + DWARFDebugMacro.cpp + DWARFDebugPubTable.cpp + DWARFDebugRangeList.cpp + DWARFDebugRnglists.cpp + DWARFDie.cpp + DWARFExpression.cpp + DWARFFormValue.cpp + DWARFGdbIndex.cpp + DWARFListTable.cpp + DWARFLocationExpression.cpp + DWARFTypeUnit.cpp + DWARFUnit.cpp + DWARFUnitIndex.cpp + DWARFVerifier.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/DebugInfo/GSYM/ya.make b/contrib/libs/llvm12/lib/DebugInfo/GSYM/ya.make new file mode 100644 index 00000000000..ea351dc059b --- /dev/null +++ b/contrib/libs/llvm12/lib/DebugInfo/GSYM/ya.make @@ -0,0 +1,42 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/DebugInfo/GSYM +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DwarfTransformer.cpp + FileWriter.cpp + FunctionInfo.cpp + GsymCreator.cpp + GsymReader.cpp + Header.cpp + InlineInfo.cpp + LineTable.cpp + LookupResult.cpp + ObjectFileTransformer.cpp + Range.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/DebugInfo/MSF/ya.make b/contrib/libs/llvm12/lib/DebugInfo/MSF/ya.make new file mode 100644 index 00000000000..97bc6950aec --- /dev/null +++ b/contrib/libs/llvm12/lib/DebugInfo/MSF/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/DebugInfo/MSF +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + MSFBuilder.cpp + MSFCommon.cpp + MSFError.cpp + MappedBlockStream.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/ya.make b/contrib/libs/llvm12/lib/DebugInfo/PDB/ya.make new file mode 100644 index 00000000000..73179cd5ede --- /dev/null +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/ya.make @@ -0,0 +1,119 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/DebugInfo/PDB +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + GenericError.cpp + IPDBSourceFile.cpp + Native/DbiModuleDescriptor.cpp + Native/DbiModuleDescriptorBuilder.cpp + Native/DbiModuleList.cpp + Native/DbiStream.cpp + Native/DbiStreamBuilder.cpp + Native/EnumTables.cpp + Native/GSIStreamBuilder.cpp + Native/GlobalsStream.cpp + Native/Hash.cpp + Native/HashTable.cpp + Native/InfoStream.cpp + Native/InfoStreamBuilder.cpp + Native/InjectedSourceStream.cpp + Native/ModuleDebugStream.cpp + Native/NamedStreamMap.cpp + Native/NativeCompilandSymbol.cpp + Native/NativeEnumGlobals.cpp + Native/NativeEnumInjectedSources.cpp + Native/NativeEnumLineNumbers.cpp + Native/NativeEnumModules.cpp + Native/NativeEnumSymbols.cpp + Native/NativeEnumTypes.cpp + Native/NativeExeSymbol.cpp + Native/NativeFunctionSymbol.cpp + Native/NativeInlineSiteSymbol.cpp + Native/NativeLineNumber.cpp + Native/NativePublicSymbol.cpp + Native/NativeRawSymbol.cpp + Native/NativeSession.cpp + Native/NativeSourceFile.cpp + Native/NativeSymbolEnumerator.cpp + Native/NativeTypeArray.cpp + Native/NativeTypeBuiltin.cpp + Native/NativeTypeEnum.cpp + Native/NativeTypeFunctionSig.cpp + Native/NativeTypePointer.cpp + Native/NativeTypeTypedef.cpp + Native/NativeTypeUDT.cpp + Native/NativeTypeVTShape.cpp + Native/PDBFile.cpp + Native/PDBFileBuilder.cpp + Native/PDBStringTable.cpp + Native/PDBStringTableBuilder.cpp + Native/PublicsStream.cpp + Native/RawError.cpp + Native/SymbolCache.cpp + Native/SymbolStream.cpp + Native/TpiHashing.cpp + Native/TpiStream.cpp + Native/TpiStreamBuilder.cpp + PDB.cpp + PDBContext.cpp + PDBExtras.cpp + PDBInterfaceAnchors.cpp + PDBSymDumper.cpp + PDBSymbol.cpp + PDBSymbolAnnotation.cpp + PDBSymbolBlock.cpp + PDBSymbolCompiland.cpp + PDBSymbolCompilandDetails.cpp + PDBSymbolCompilandEnv.cpp + PDBSymbolCustom.cpp + PDBSymbolData.cpp + PDBSymbolExe.cpp + PDBSymbolFunc.cpp + PDBSymbolFuncDebugEnd.cpp + PDBSymbolFuncDebugStart.cpp + PDBSymbolLabel.cpp + PDBSymbolPublicSymbol.cpp + PDBSymbolThunk.cpp + PDBSymbolTypeArray.cpp + PDBSymbolTypeBaseClass.cpp + PDBSymbolTypeBuiltin.cpp + PDBSymbolTypeCustom.cpp + PDBSymbolTypeDimension.cpp + PDBSymbolTypeEnum.cpp + PDBSymbolTypeFriend.cpp + PDBSymbolTypeFunctionArg.cpp + PDBSymbolTypeFunctionSig.cpp + PDBSymbolTypeManaged.cpp + PDBSymbolTypePointer.cpp + PDBSymbolTypeTypedef.cpp + PDBSymbolTypeUDT.cpp + PDBSymbolTypeVTable.cpp + PDBSymbolTypeVTableShape.cpp + PDBSymbolUnknown.cpp + PDBSymbolUsingNamespace.cpp + UDTLayout.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/DebugInfo/Symbolize/ya.make b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/ya.make new file mode 100644 index 00000000000..6485cf4ff8b --- /dev/null +++ b/contrib/libs/llvm12/lib/DebugInfo/Symbolize/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/DebugInfo/Symbolize +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DIPrinter.cpp + SymbolizableObjectFile.cpp + Symbolize.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Demangle/ya.make b/contrib/libs/llvm12/lib/Demangle/ya.make new file mode 100644 index 00000000000..c4e86534c43 --- /dev/null +++ b/contrib/libs/llvm12/lib/Demangle/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 +) + +ADDINCL( + contrib/libs/llvm12/lib/Demangle +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Demangle.cpp + ItaniumDemangle.cpp + MicrosoftDemangle.cpp + MicrosoftDemangleNodes.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/Interpreter/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/Interpreter/ya.make new file mode 100644 index 00000000000..b220f79fc90 --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/Interpreter/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/restricted/libffi +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/Interpreter + contrib/restricted/libffi/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Execution.cpp + ExternalFunctions.cpp + Interpreter.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/JITLink/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/JITLink/ya.make new file mode 100644 index 00000000000..fcf5d777bd5 --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/JITLink/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/JITLink +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + EHFrameSupport.cpp + ELF.cpp + ELF_x86_64.cpp + JITLink.cpp + JITLinkGeneric.cpp + JITLinkMemoryManager.cpp + MachO.cpp + MachOLinkGraphBuilder.cpp + MachO_arm64.cpp + MachO_x86_64.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/MCJIT/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/MCJIT/ya.make new file mode 100644 index 00000000000..c5977afd203 --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/MCJIT/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + MCJIT.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared/ya.make new file mode 100644 index 00000000000..194fbb6084d --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + OrcError.cpp + RPCError.cpp + TargetProcessControlTypes.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess/ya.make new file mode 100644 index 00000000000..a6b83e52d30 --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + RegisterEHFrames.cpp + TargetExecutionUtils.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/Orc/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/Orc/ya.make new file mode 100644 index 00000000000..906fa426478 --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/Orc/ya.make @@ -0,0 +1,66 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/JITLink + contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared + contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/Orc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CompileOnDemandLayer.cpp + CompileUtils.cpp + Core.cpp + DebugUtils.cpp + ExecutionUtils.cpp + IRCompileLayer.cpp + IRTransformLayer.cpp + IndirectionUtils.cpp + JITTargetMachineBuilder.cpp + LLJIT.cpp + Layer.cpp + LazyReexports.cpp + MachOPlatform.cpp + Mangling.cpp + ObjectLinkingLayer.cpp + ObjectTransformLayer.cpp + OrcABISupport.cpp + OrcV2CBindings.cpp + RTDyldObjectLinkingLayer.cpp + SpeculateAnalyses.cpp + Speculation.cpp + TPCDynamicLibrarySearchGenerator.cpp + TPCEHFrameRegistrar.cpp + TPCIndirectionUtils.cpp + TargetProcessControl.cpp + ThreadSafeModule.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/PerfJITEvents/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/PerfJITEvents/ya.make new file mode 100644 index 00000000000..37edec50f20 --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/PerfJITEvents/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/PerfJITEvents +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + PerfJITEventListener.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld/ya.make new file mode 100644 index 00000000000..3690585316f --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + JITSymbol.cpp + RTDyldMemoryManager.cpp + RuntimeDyld.cpp + RuntimeDyldCOFF.cpp + RuntimeDyldChecker.cpp + RuntimeDyldELF.cpp + RuntimeDyldMachO.cpp + Targets/RuntimeDyldELFMips.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ExecutionEngine/ya.make b/contrib/libs/llvm12/lib/ExecutionEngine/ya.make new file mode 100644 index 00000000000..bae80444554 --- /dev/null +++ b/contrib/libs/llvm12/lib/ExecutionEngine/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target +) + +ADDINCL( + contrib/libs/llvm12/lib/ExecutionEngine +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ExecutionEngine.cpp + ExecutionEngineBindings.cpp + GDBRegistrationListener.cpp + SectionMemoryManager.cpp + TargetSelect.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Extensions/ya.make b/contrib/libs/llvm12/lib/Extensions/ya.make new file mode 100644 index 00000000000..44fc60b9b7c --- /dev/null +++ b/contrib/libs/llvm12/lib/Extensions/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(NCSA) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/tools/polly/lib + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/lib/Extensions +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Extensions.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/FileCheck/ya.make b/contrib/libs/llvm12/lib/FileCheck/ya.make new file mode 100644 index 00000000000..91aff3f22b1 --- /dev/null +++ b/contrib/libs/llvm12/lib/FileCheck/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/FileCheck +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + FileCheck.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Frontend/OpenACC/ya.make b/contrib/libs/llvm12/lib/Frontend/OpenACC/ya.make new file mode 100644 index 00000000000..3e980f094df --- /dev/null +++ b/contrib/libs/llvm12/lib/Frontend/OpenACC/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(NCSA) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Support +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ACC.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Frontend/OpenMP/ya.make b/contrib/libs/llvm12/lib/Frontend/OpenMP/ya.make new file mode 100644 index 00000000000..03e41c95f0c --- /dev/null +++ b/contrib/libs/llvm12/lib/Frontend/OpenMP/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Frontend/OpenMP +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + OMP.cpp + OMPContext.cpp + OMPIRBuilder.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/FuzzMutate/ya.make b/contrib/libs/llvm12/lib/FuzzMutate/ya.make new file mode 100644 index 00000000000..0eaf9bc7077 --- /dev/null +++ b/contrib/libs/llvm12/lib/FuzzMutate/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/Scalar +) + +ADDINCL( + contrib/libs/llvm12/lib/FuzzMutate +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + FuzzerCLI.cpp + IRMutator.cpp + OpDescriptor.cpp + Operations.cpp + RandomIRBuilder.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/IR/ya.make b/contrib/libs/llvm12/lib/IR/ya.make new file mode 100644 index 00000000000..06b802c3386 --- /dev/null +++ b/contrib/libs/llvm12/lib/IR/ya.make @@ -0,0 +1,88 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/IR +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AbstractCallSite.cpp + AsmWriter.cpp + Assumptions.cpp + Attributes.cpp + AutoUpgrade.cpp + BasicBlock.cpp + Comdat.cpp + ConstantFold.cpp + ConstantRange.cpp + Constants.cpp + Core.cpp + DIBuilder.cpp + DataLayout.cpp + DebugInfo.cpp + DebugInfoMetadata.cpp + DebugLoc.cpp + DiagnosticHandler.cpp + DiagnosticInfo.cpp + DiagnosticPrinter.cpp + Dominators.cpp + FPEnv.cpp + Function.cpp + GVMaterializer.cpp + Globals.cpp + IRBuilder.cpp + IRPrintingPasses.cpp + InlineAsm.cpp + Instruction.cpp + Instructions.cpp + IntrinsicInst.cpp + LLVMContext.cpp + LLVMContextImpl.cpp + LLVMRemarkStreamer.cpp + LegacyPassManager.cpp + MDBuilder.cpp + Mangler.cpp + Metadata.cpp + Module.cpp + ModuleSummaryIndex.cpp + Operator.cpp + OptBisect.cpp + Pass.cpp + PassInstrumentation.cpp + PassManager.cpp + PassRegistry.cpp + PassTimingInfo.cpp + PrintPasses.cpp + ProfileSummary.cpp + PseudoProbe.cpp + ReplaceConstant.cpp + SafepointIRVerifier.cpp + Statepoint.cpp + StructuralHash.cpp + Type.cpp + TypeFinder.cpp + Use.cpp + User.cpp + Value.cpp + ValueSymbolTable.cpp + Verifier.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/IRReader/ya.make b/contrib/libs/llvm12/lib/IRReader/ya.make new file mode 100644 index 00000000000..59869e2e814 --- /dev/null +++ b/contrib/libs/llvm12/lib/IRReader/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/IRReader +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + IRReader.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/InterfaceStub/ya.make b/contrib/libs/llvm12/lib/InterfaceStub/ya.make new file mode 100644 index 00000000000..9613dc05513 --- /dev/null +++ b/contrib/libs/llvm12/lib/InterfaceStub/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/InterfaceStub +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ELFObjHandler.cpp + ELFStub.cpp + TBEHandler.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/LTO/ya.make b/contrib/libs/llvm12/lib/LTO/ya.make new file mode 100644 index 00000000000..2b497202de0 --- /dev/null +++ b/contrib/libs/llvm12/lib/LTO/ya.make @@ -0,0 +1,55 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/Extensions + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/tools/polly/lib + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/lib/LTO +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Caching.cpp + LTO.cpp + LTOBackend.cpp + LTOCodeGenerator.cpp + LTOModule.cpp + SummaryBasedOptimizations.cpp + ThinLTOCodeGenerator.cpp + UpdateCompilerUsed.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/LineEditor/ya.make b/contrib/libs/llvm12/lib/LineEditor/ya.make new file mode 100644 index 00000000000..ae06d84afa8 --- /dev/null +++ b/contrib/libs/llvm12/lib/LineEditor/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/LineEditor +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + LineEditor.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Linker/ya.make b/contrib/libs/llvm12/lib/Linker/ya.make new file mode 100644 index 00000000000..38387e713e0 --- /dev/null +++ b/contrib/libs/llvm12/lib/Linker/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Linker +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + IRMover.cpp + LinkModules.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/MC/MCDisassembler/ya.make b/contrib/libs/llvm12/lib/MC/MCDisassembler/ya.make new file mode 100644 index 00000000000..e7c1ed4e0d9 --- /dev/null +++ b/contrib/libs/llvm12/lib/MC/MCDisassembler/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/MC/MCDisassembler +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Disassembler.cpp + MCDisassembler.cpp + MCExternalSymbolizer.cpp + MCRelocationInfo.cpp + MCSymbolizer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/MC/MCParser/ya.make b/contrib/libs/llvm12/lib/MC/MCParser/ya.make new file mode 100644 index 00000000000..2f2ef4bc867 --- /dev/null +++ b/contrib/libs/llvm12/lib/MC/MCParser/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/MC/MCParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AsmLexer.cpp + AsmParser.cpp + COFFAsmParser.cpp + COFFMasmParser.cpp + DarwinAsmParser.cpp + ELFAsmParser.cpp + MCAsmLexer.cpp + MCAsmParser.cpp + MCAsmParserExtension.cpp + MCTargetAsmParser.cpp + MasmParser.cpp + WasmAsmParser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/MC/ya.make b/contrib/libs/llvm12/lib/MC/ya.make new file mode 100644 index 00000000000..a6045371c2b --- /dev/null +++ b/contrib/libs/llvm12/lib/MC/ya.make @@ -0,0 +1,90 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/MC +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ConstantPools.cpp + ELFObjectWriter.cpp + MCAsmBackend.cpp + MCAsmInfo.cpp + MCAsmInfoCOFF.cpp + MCAsmInfoDarwin.cpp + MCAsmInfoELF.cpp + MCAsmInfoWasm.cpp + MCAsmInfoXCOFF.cpp + MCAsmMacro.cpp + MCAsmStreamer.cpp + MCAssembler.cpp + MCCodeEmitter.cpp + MCCodeView.cpp + MCContext.cpp + MCDwarf.cpp + MCELFObjectTargetWriter.cpp + MCELFStreamer.cpp + MCExpr.cpp + MCFragment.cpp + MCInst.cpp + MCInstPrinter.cpp + MCInstrAnalysis.cpp + MCInstrDesc.cpp + MCInstrInfo.cpp + MCLabel.cpp + MCLinkerOptimizationHint.cpp + MCMachOStreamer.cpp + MCMachObjectTargetWriter.cpp + MCNullStreamer.cpp + MCObjectFileInfo.cpp + MCObjectStreamer.cpp + MCObjectWriter.cpp + MCPseudoProbe.cpp + MCRegisterInfo.cpp + MCSchedule.cpp + MCSection.cpp + MCSectionCOFF.cpp + MCSectionELF.cpp + MCSectionMachO.cpp + MCSectionWasm.cpp + MCSectionXCOFF.cpp + MCStreamer.cpp + MCSubtargetInfo.cpp + MCSymbol.cpp + MCSymbolELF.cpp + MCSymbolXCOFF.cpp + MCTargetOptions.cpp + MCTargetOptionsCommandFlags.cpp + MCValue.cpp + MCWasmObjectTargetWriter.cpp + MCWasmStreamer.cpp + MCWin64EH.cpp + MCWinCOFFStreamer.cpp + MCWinEH.cpp + MCXCOFFObjectTargetWriter.cpp + MCXCOFFStreamer.cpp + MachObjectWriter.cpp + StringTableBuilder.cpp + SubtargetFeature.cpp + WasmObjectWriter.cpp + WinCOFFObjectWriter.cpp + XCOFFObjectWriter.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/MCA/ya.make b/contrib/libs/llvm12/lib/MCA/ya.make new file mode 100644 index 00000000000..7163e157b8d --- /dev/null +++ b/contrib/libs/llvm12/lib/MCA/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/MCA +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CodeEmitter.cpp + Context.cpp + HWEventListener.cpp + HardwareUnits/HardwareUnit.cpp + HardwareUnits/LSUnit.cpp + HardwareUnits/RegisterFile.cpp + HardwareUnits/ResourceManager.cpp + HardwareUnits/RetireControlUnit.cpp + HardwareUnits/Scheduler.cpp + InstrBuilder.cpp + Instruction.cpp + Pipeline.cpp + Stages/DispatchStage.cpp + Stages/EntryStage.cpp + Stages/ExecuteStage.cpp + Stages/InstructionTables.cpp + Stages/MicroOpQueueStage.cpp + Stages/RetireStage.cpp + Stages/Stage.cpp + Support.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Object/ya.make b/contrib/libs/llvm12/lib/Object/ya.make new file mode 100644 index 00000000000..d4bee3d0274 --- /dev/null +++ b/contrib/libs/llvm12/lib/Object/ya.make @@ -0,0 +1,61 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/lib/Object +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Archive.cpp + ArchiveWriter.cpp + Binary.cpp + COFFImportFile.cpp + COFFModuleDefinition.cpp + COFFObjectFile.cpp + Decompressor.cpp + ELF.cpp + ELFObjectFile.cpp + Error.cpp + IRObjectFile.cpp + IRSymtab.cpp + MachOObjectFile.cpp + MachOUniversal.cpp + MachOUniversalWriter.cpp + Minidump.cpp + ModuleSymbolTable.cpp + Object.cpp + ObjectFile.cpp + RecordStreamer.cpp + RelocationResolver.cpp + SymbolSize.cpp + SymbolicFile.cpp + TapiFile.cpp + TapiUniversal.cpp + WasmObjectFile.cpp + WindowsMachineFlag.cpp + WindowsResource.cpp + XCOFFObjectFile.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ObjectYAML/ya.make b/contrib/libs/llvm12/lib/ObjectYAML/ya.make new file mode 100644 index 00000000000..6e82a57d8a9 --- /dev/null +++ b/contrib/libs/llvm12/lib/ObjectYAML/ya.make @@ -0,0 +1,51 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ObjectYAML +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ArchiveEmitter.cpp + ArchiveYAML.cpp + COFFEmitter.cpp + COFFYAML.cpp + CodeViewYAMLDebugSections.cpp + CodeViewYAMLSymbols.cpp + CodeViewYAMLTypeHashing.cpp + CodeViewYAMLTypes.cpp + DWARFEmitter.cpp + DWARFYAML.cpp + ELFEmitter.cpp + ELFYAML.cpp + MachOEmitter.cpp + MachOYAML.cpp + MinidumpEmitter.cpp + MinidumpYAML.cpp + ObjectYAML.cpp + WasmEmitter.cpp + WasmYAML.cpp + XCOFFYAML.cpp + YAML.cpp + yaml2obj.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Option/ya.make b/contrib/libs/llvm12/lib/Option/ya.make new file mode 100644 index 00000000000..03e62a33bcb --- /dev/null +++ b/contrib/libs/llvm12/lib/Option/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Option +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Arg.cpp + ArgList.cpp + OptTable.cpp + Option.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Passes/ya.make b/contrib/libs/llvm12/lib/Passes/ya.make new file mode 100644 index 00000000000..5807c7c7ba1 --- /dev/null +++ b/contrib/libs/llvm12/lib/Passes/ya.make @@ -0,0 +1,42 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/lib/Passes +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + PassBuilder.cpp + PassPlugin.cpp + StandardInstrumentations.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ProfileData/Coverage/ya.make b/contrib/libs/llvm12/lib/ProfileData/Coverage/ya.make new file mode 100644 index 00000000000..79b7fca0cef --- /dev/null +++ b/contrib/libs/llvm12/lib/ProfileData/Coverage/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ProfileData/Coverage +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CoverageMapping.cpp + CoverageMappingReader.cpp + CoverageMappingWriter.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ProfileData/ya.make b/contrib/libs/llvm12/lib/ProfileData/ya.make new file mode 100644 index 00000000000..214322a5d4b --- /dev/null +++ b/contrib/libs/llvm12/lib/ProfileData/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/ProfileData +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + GCOV.cpp + InstrProf.cpp + InstrProfReader.cpp + InstrProfWriter.cpp + ProfileSummaryBuilder.cpp + SampleProf.cpp + SampleProfReader.cpp + SampleProfWriter.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Remarks/ya.make b/contrib/libs/llvm12/lib/Remarks/ya.make new file mode 100644 index 00000000000..9c92b75a378 --- /dev/null +++ b/contrib/libs/llvm12/lib/Remarks/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Remarks +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BitstreamRemarkParser.cpp + BitstreamRemarkSerializer.cpp + Remark.cpp + RemarkFormat.cpp + RemarkLinker.cpp + RemarkParser.cpp + RemarkSerializer.cpp + RemarkStreamer.cpp + RemarkStringTable.cpp + YAMLRemarkParser.cpp + YAMLRemarkSerializer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Support/ya.make b/contrib/libs/llvm12/lib/Support/ya.make new file mode 100644 index 00000000000..392a6f8c65f --- /dev/null +++ b/contrib/libs/llvm12/lib/Support/ya.make @@ -0,0 +1,170 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + BSD-2-Clause AND + BSD-3-Clause AND + ISC AND + NCSA AND + Public-Domain AND + Spencer-94 AND + Unicode-Mappings +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/zlib +) + +ADDINCL( + contrib/libs/llvm12/lib/Support +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AArch64TargetParser.cpp + ABIBreak.cpp + AMDGPUMetadata.cpp + APFixedPoint.cpp + APFloat.cpp + APInt.cpp + APSInt.cpp + ARMAttributeParser.cpp + ARMBuildAttrs.cpp + ARMTargetParser.cpp + ARMWinEH.cpp + Allocator.cpp + Atomic.cpp + BinaryStreamError.cpp + BinaryStreamReader.cpp + BinaryStreamRef.cpp + BinaryStreamWriter.cpp + BlockFrequency.cpp + BranchProbability.cpp + BuryPointer.cpp + COM.cpp + CRC.cpp + CachePruning.cpp + Chrono.cpp + CodeGenCoverage.cpp + CommandLine.cpp + Compression.cpp + ConvertUTF.cpp + ConvertUTFWrapper.cpp + CrashRecoveryContext.cpp + DAGDeltaAlgorithm.cpp + DJB.cpp + DataExtractor.cpp + Debug.cpp + DebugCounter.cpp + DeltaAlgorithm.cpp + DynamicLibrary.cpp + ELFAttributeParser.cpp + ELFAttributes.cpp + Errno.cpp + Error.cpp + ErrorHandling.cpp + ExtensibleRTTI.cpp + FileCollector.cpp + FileOutputBuffer.cpp + FileUtilities.cpp + FoldingSet.cpp + FormatVariadic.cpp + FormattedStream.cpp + GlobPattern.cpp + GraphWriter.cpp + Hashing.cpp + Host.cpp + InitLLVM.cpp + InstructionCost.cpp + IntEqClasses.cpp + IntervalMap.cpp + ItaniumManglingCanonicalizer.cpp + JSON.cpp + KnownBits.cpp + LEB128.cpp + LineIterator.cpp + Locale.cpp + LockFileManager.cpp + LowLevelType.cpp + MD5.cpp + ManagedStatic.cpp + MathExtras.cpp + MemAlloc.cpp + Memory.cpp + MemoryBuffer.cpp + MemoryBufferRef.cpp + NativeFormatting.cpp + OptimizedStructLayout.cpp + Optional.cpp + Parallel.cpp + Path.cpp + PluginLoader.cpp + PrettyStackTrace.cpp + Process.cpp + Program.cpp + RISCVAttributeParser.cpp + RISCVAttributes.cpp + RWMutex.cpp + RandomNumberGenerator.cpp + Regex.cpp + SHA1.cpp + ScaledNumber.cpp + ScopedPrinter.cpp + Signals.cpp + Signposts.cpp + SmallPtrSet.cpp + SmallVector.cpp + SourceMgr.cpp + SpecialCaseList.cpp + Statistic.cpp + StringExtras.cpp + StringMap.cpp + StringRef.cpp + StringSaver.cpp + SuffixTree.cpp + SymbolRemappingReader.cpp + SystemUtils.cpp + TarWriter.cpp + TargetParser.cpp + TargetRegistry.cpp + ThreadLocal.cpp + ThreadPool.cpp + Threading.cpp + TimeProfiler.cpp + Timer.cpp + ToolOutputFile.cpp + TrigramIndex.cpp + Triple.cpp + Twine.cpp + Unicode.cpp + UnicodeCaseFold.cpp + Valgrind.cpp + VersionTuple.cpp + VirtualFileSystem.cpp + Watchdog.cpp + WithColor.cpp + X86TargetParser.cpp + YAMLParser.cpp + YAMLTraits.cpp + Z3Solver.cpp + circular_raw_ostream.cpp + raw_os_ostream.cpp + raw_ostream.cpp + regcomp.c + regerror.c + regexec.c + regfree.c + regstrlcpy.c + xxhash.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/TableGen/ya.make b/contrib/libs/llvm12/lib/TableGen/ya.make new file mode 100644 index 00000000000..0706f79175b --- /dev/null +++ b/contrib/libs/llvm12/lib/TableGen/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/TableGen +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DetailedRecordsBackend.cpp + Error.cpp + JSONBackend.cpp + Main.cpp + Record.cpp + SetTheory.cpp + StringMatcher.cpp + TGLexer.cpp + TGParser.cpp + TableGenBackend.cpp + TableGenBackendSkeleton.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/AArch64/AsmParser/ya.make b/contrib/libs/llvm12/lib/Target/AArch64/AsmParser/ya.make new file mode 100644 index 00000000000..d429e6cc2dd --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/AArch64/AsmParser/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AArch64AsmParser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/AArch64/Disassembler/ya.make b/contrib/libs/llvm12/lib/Target/AArch64/Disassembler/ya.make new file mode 100644 index 00000000000..4e974e80bec --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/AArch64/Disassembler/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/Disassembler +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AArch64Disassembler.cpp + AArch64ExternalSymbolizer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc/ya.make b/contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc/ya.make new file mode 100644 index 00000000000..7fd20ed0313 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc/ya.make @@ -0,0 +1,44 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AArch64AsmBackend.cpp + AArch64ELFObjectWriter.cpp + AArch64ELFStreamer.cpp + AArch64InstPrinter.cpp + AArch64MCAsmInfo.cpp + AArch64MCCodeEmitter.cpp + AArch64MCExpr.cpp + AArch64MCTargetDesc.cpp + AArch64MachObjectWriter.cpp + AArch64TargetStreamer.cpp + AArch64WinCOFFObjectWriter.cpp + AArch64WinCOFFStreamer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/AArch64/TargetInfo/ya.make b/contrib/libs/llvm12/lib/Target/AArch64/TargetInfo/ya.make new file mode 100644 index 00000000000..997595760dc --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/AArch64/TargetInfo/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AArch64TargetInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/AArch64/Utils/ya.make b/contrib/libs/llvm12/lib/Target/AArch64/Utils/ya.make new file mode 100644 index 00000000000..e7faa2c7aee --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/AArch64/Utils/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/Utils +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AArch64BaseInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/AArch64/ya.make b/contrib/libs/llvm12/lib/Target/AArch64/ya.make new file mode 100644 index 00000000000..7976bbaba0a --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/AArch64/ya.make @@ -0,0 +1,93 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64 +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AArch64A53Fix835769.cpp + AArch64A57FPLoadBalancing.cpp + AArch64AdvSIMDScalarPass.cpp + AArch64AsmPrinter.cpp + AArch64BranchTargets.cpp + AArch64CallingConvention.cpp + AArch64CleanupLocalDynamicTLSPass.cpp + AArch64CollectLOH.cpp + AArch64CompressJumpTables.cpp + AArch64CondBrTuning.cpp + AArch64ConditionOptimizer.cpp + AArch64ConditionalCompares.cpp + AArch64DeadRegisterDefinitionsPass.cpp + AArch64ExpandImm.cpp + AArch64ExpandPseudoInsts.cpp + AArch64FalkorHWPFFix.cpp + AArch64FastISel.cpp + AArch64FrameLowering.cpp + AArch64ISelDAGToDAG.cpp + AArch64ISelLowering.cpp + AArch64InstrInfo.cpp + AArch64LoadStoreOptimizer.cpp + AArch64MCInstLower.cpp + AArch64MachineFunctionInfo.cpp + AArch64MacroFusion.cpp + AArch64PBQPRegAlloc.cpp + AArch64PromoteConstant.cpp + AArch64RedundantCopyElimination.cpp + AArch64RegisterInfo.cpp + AArch64SIMDInstrOpt.cpp + AArch64SLSHardening.cpp + AArch64SelectionDAGInfo.cpp + AArch64SpeculationHardening.cpp + AArch64StackTagging.cpp + AArch64StackTaggingPreRA.cpp + AArch64StorePairSuppress.cpp + AArch64Subtarget.cpp + AArch64TargetMachine.cpp + AArch64TargetObjectFile.cpp + AArch64TargetTransformInfo.cpp + GISel/AArch64CallLowering.cpp + GISel/AArch64InstructionSelector.cpp + GISel/AArch64LegalizerInfo.cpp + GISel/AArch64PostLegalizerCombiner.cpp + GISel/AArch64PostLegalizerLowering.cpp + GISel/AArch64PostSelectOptimize.cpp + GISel/AArch64PreLegalizerCombiner.cpp + GISel/AArch64RegisterBankInfo.cpp + SVEIntrinsicOpts.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/ARM/AsmParser/ya.make b/contrib/libs/llvm12/lib/Target/ARM/AsmParser/ya.make new file mode 100644 index 00000000000..d0f1526a264 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/ARM/AsmParser/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ARMAsmParser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/ARM/Disassembler/ya.make b/contrib/libs/llvm12/lib/Target/ARM/Disassembler/ya.make new file mode 100644 index 00000000000..b8abfb8e5a1 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/ARM/Disassembler/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/Disassembler +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ARMDisassembler.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc/ya.make b/contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc/ya.make new file mode 100644 index 00000000000..8b14ce95d78 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc/ya.make @@ -0,0 +1,47 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ARMAsmBackend.cpp + ARMELFObjectWriter.cpp + ARMELFStreamer.cpp + ARMInstPrinter.cpp + ARMMCAsmInfo.cpp + ARMMCCodeEmitter.cpp + ARMMCExpr.cpp + ARMMCTargetDesc.cpp + ARMMachORelocationInfo.cpp + ARMMachObjectWriter.cpp + ARMTargetStreamer.cpp + ARMUnwindOpAsm.cpp + ARMWinCOFFObjectWriter.cpp + ARMWinCOFFStreamer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/ARM/TargetInfo/ya.make b/contrib/libs/llvm12/lib/Target/ARM/TargetInfo/ya.make new file mode 100644 index 00000000000..e34301900f3 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/ARM/TargetInfo/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/TargetInfo +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ARMTargetInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/ARM/Utils/ya.make b/contrib/libs/llvm12/lib/Target/ARM/Utils/ya.make new file mode 100644 index 00000000000..3d6ae665577 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/ARM/Utils/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/Utils +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ARMBaseInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/ARM/ya.make b/contrib/libs/llvm12/lib/Target/ARM/ya.make new file mode 100644 index 00000000000..c8aa734a5e0 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/ARM/ya.make @@ -0,0 +1,86 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + A15SDOptimizer.cpp + ARMAsmPrinter.cpp + ARMBaseInstrInfo.cpp + ARMBaseRegisterInfo.cpp + ARMBasicBlockInfo.cpp + ARMBlockPlacement.cpp + ARMCallLowering.cpp + ARMCallingConv.cpp + ARMConstantIslandPass.cpp + ARMConstantPoolValue.cpp + ARMExpandPseudoInsts.cpp + ARMFastISel.cpp + ARMFrameLowering.cpp + ARMHazardRecognizer.cpp + ARMISelDAGToDAG.cpp + ARMISelLowering.cpp + ARMInstrInfo.cpp + ARMInstructionSelector.cpp + ARMLegalizerInfo.cpp + ARMLoadStoreOptimizer.cpp + ARMLowOverheadLoops.cpp + ARMMCInstLower.cpp + ARMMachineFunctionInfo.cpp + ARMMacroFusion.cpp + ARMOptimizeBarriersPass.cpp + ARMParallelDSP.cpp + ARMRegisterBankInfo.cpp + ARMRegisterInfo.cpp + ARMSLSHardening.cpp + ARMSelectionDAGInfo.cpp + ARMSubtarget.cpp + ARMTargetMachine.cpp + ARMTargetObjectFile.cpp + ARMTargetTransformInfo.cpp + MLxExpansionPass.cpp + MVEGatherScatterLowering.cpp + MVETailPredication.cpp + MVEVPTBlockPass.cpp + MVEVPTOptimisationsPass.cpp + Thumb1FrameLowering.cpp + Thumb1InstrInfo.cpp + Thumb2ITBlockPass.cpp + Thumb2InstrInfo.cpp + Thumb2SizeReduction.cpp + ThumbRegisterInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/BPF/AsmParser/ya.make b/contrib/libs/llvm12/lib/Target/BPF/AsmParser/ya.make new file mode 100644 index 00000000000..dd505ffdf4b --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/BPF/AsmParser/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BPFAsmParser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/BPF/Disassembler/ya.make b/contrib/libs/llvm12/lib/Target/BPF/Disassembler/ya.make new file mode 100644 index 00000000000..5e13015fe24 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/BPF/Disassembler/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/BPF/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/Disassembler +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BPFDisassembler.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc/ya.make b/contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc/ya.make new file mode 100644 index 00000000000..aeaae3584b6 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/BPF/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BPFAsmBackend.cpp + BPFELFObjectWriter.cpp + BPFInstPrinter.cpp + BPFMCCodeEmitter.cpp + BPFMCTargetDesc.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/BPF/TargetInfo/ya.make b/contrib/libs/llvm12/lib/Target/BPF/TargetInfo/ya.make new file mode 100644 index 00000000000..24ecc1800ad --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/BPF/TargetInfo/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/TargetInfo +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BPFTargetInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/BPF/ya.make b/contrib/libs/llvm12/lib/Target/BPF/ya.make new file mode 100644 index 00000000000..f422f0f43b8 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/BPF/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BPFAbstractMemberAccess.cpp + BPFAdjustOpt.cpp + BPFAsmPrinter.cpp + BPFCheckAndAdjustIR.cpp + BPFFrameLowering.cpp + BPFISelDAGToDAG.cpp + BPFISelLowering.cpp + BPFInstrInfo.cpp + BPFMCInstLower.cpp + BPFMIChecking.cpp + BPFMIPeephole.cpp + BPFMISimplifyPatchable.cpp + BPFPreserveDIType.cpp + BPFRegisterInfo.cpp + BPFSelectionDAGInfo.cpp + BPFSubtarget.cpp + BPFTargetMachine.cpp + BTFDebug.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc/ya.make b/contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc/ya.make new file mode 100644 index 00000000000..049c5b71d3c --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + NVPTXInstPrinter.cpp + NVPTXMCAsmInfo.cpp + NVPTXMCTargetDesc.cpp + NVPTXTargetStreamer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo/ya.make b/contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo/ya.make new file mode 100644 index 00000000000..167710971a1 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + NVPTXTargetInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/NVPTX/ya.make b/contrib/libs/llvm12/lib/Target/NVPTX/ya.make new file mode 100644 index 00000000000..b86455f3f00 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/NVPTX/ya.make @@ -0,0 +1,64 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + NVPTXAllocaHoisting.cpp + NVPTXAsmPrinter.cpp + NVPTXAssignValidGlobalNames.cpp + NVPTXFrameLowering.cpp + NVPTXGenericToNVVM.cpp + NVPTXISelDAGToDAG.cpp + NVPTXISelLowering.cpp + NVPTXImageOptimizer.cpp + NVPTXInstrInfo.cpp + NVPTXLowerAggrCopies.cpp + NVPTXLowerAlloca.cpp + NVPTXLowerArgs.cpp + NVPTXMCExpr.cpp + NVPTXPeephole.cpp + NVPTXPrologEpilogPass.cpp + NVPTXProxyRegErasure.cpp + NVPTXRegisterInfo.cpp + NVPTXReplaceImageHandles.cpp + NVPTXSubtarget.cpp + NVPTXTargetMachine.cpp + NVPTXTargetTransformInfo.cpp + NVPTXUtilities.cpp + NVVMIntrRange.cpp + NVVMReflect.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/PowerPC/AsmParser/ya.make b/contrib/libs/llvm12/lib/Target/PowerPC/AsmParser/ya.make new file mode 100644 index 00000000000..b090474c9d0 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/PowerPC/AsmParser/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + PPCAsmParser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/PowerPC/Disassembler/ya.make b/contrib/libs/llvm12/lib/Target/PowerPC/Disassembler/ya.make new file mode 100644 index 00000000000..3e4f91f2e85 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/PowerPC/Disassembler/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + PPCDisassembler.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc/ya.make b/contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc/ya.make new file mode 100644 index 00000000000..c01e8f22787 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc/ya.make @@ -0,0 +1,44 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + PPCAsmBackend.cpp + PPCELFObjectWriter.cpp + PPCELFStreamer.cpp + PPCInstPrinter.cpp + PPCMCAsmInfo.cpp + PPCMCCodeEmitter.cpp + PPCMCExpr.cpp + PPCMCTargetDesc.cpp + PPCPredicates.cpp + PPCXCOFFObjectWriter.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo/ya.make b/contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo/ya.make new file mode 100644 index 00000000000..08615c47e85 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + PowerPCTargetInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/PowerPC/ya.make b/contrib/libs/llvm12/lib/Target/PowerPC/ya.make new file mode 100644 index 00000000000..36860097e21 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/PowerPC/ya.make @@ -0,0 +1,78 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + GISel/PPCCallLowering.cpp + GISel/PPCInstructionSelector.cpp + GISel/PPCLegalizerInfo.cpp + GISel/PPCRegisterBankInfo.cpp + PPCAsmPrinter.cpp + PPCBoolRetToInt.cpp + PPCBranchCoalescing.cpp + PPCBranchSelector.cpp + PPCCCState.cpp + PPCCTRLoops.cpp + PPCCallingConv.cpp + PPCEarlyReturn.cpp + PPCExpandISEL.cpp + PPCFastISel.cpp + PPCFrameLowering.cpp + PPCHazardRecognizers.cpp + PPCISelDAGToDAG.cpp + PPCISelLowering.cpp + PPCInstrInfo.cpp + PPCLoopInstrFormPrep.cpp + PPCLowerMASSVEntries.cpp + PPCMCInstLower.cpp + PPCMIPeephole.cpp + PPCMachineFunctionInfo.cpp + PPCMachineScheduler.cpp + PPCMacroFusion.cpp + PPCPreEmitPeephole.cpp + PPCReduceCRLogicals.cpp + PPCRegisterInfo.cpp + PPCSubtarget.cpp + PPCTLSDynamicCall.cpp + PPCTOCRegDeps.cpp + PPCTargetMachine.cpp + PPCTargetObjectFile.cpp + PPCTargetTransformInfo.cpp + PPCVSXCopy.cpp + PPCVSXFMAMutate.cpp + PPCVSXSwapRemoval.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/X86/AsmParser/ya.make b/contrib/libs/llvm12/lib/Target/X86/AsmParser/ya.make new file mode 100644 index 00000000000..7021bc60edd --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/X86/AsmParser/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + X86AsmParser.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/X86/Disassembler/ya.make b/contrib/libs/llvm12/lib/Target/X86/Disassembler/ya.make new file mode 100644 index 00000000000..4b11c2a2faa --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/X86/Disassembler/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/Disassembler +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + X86Disassembler.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/X86/MCTargetDesc/ya.make b/contrib/libs/llvm12/lib/Target/X86/MCTargetDesc/ya.make new file mode 100644 index 00000000000..9c87094d229 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/X86/MCTargetDesc/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + X86ATTInstPrinter.cpp + X86AsmBackend.cpp + X86ELFObjectWriter.cpp + X86InstComments.cpp + X86InstPrinterCommon.cpp + X86IntelInstPrinter.cpp + X86MCAsmInfo.cpp + X86MCCodeEmitter.cpp + X86MCTargetDesc.cpp + X86MachObjectWriter.cpp + X86ShuffleDecode.cpp + X86WinCOFFObjectWriter.cpp + X86WinCOFFStreamer.cpp + X86WinCOFFTargetStreamer.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/X86/TargetInfo/ya.make b/contrib/libs/llvm12/lib/Target/X86/TargetInfo/ya.make new file mode 100644 index 00000000000..acfe9ed6ef0 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/X86/TargetInfo/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + X86TargetInfo.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/X86/ya.make b/contrib/libs/llvm12/lib/Target/X86/ya.make new file mode 100644 index 00000000000..43c016bce4e --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/X86/ya.make @@ -0,0 +1,99 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/Transforms/CFGuard +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86 +) + +NO_CLANG_COVERAGE() + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + X86AsmPrinter.cpp + X86AvoidStoreForwardingBlocks.cpp + X86AvoidTrailingCall.cpp + X86CallFrameOptimization.cpp + X86CallLowering.cpp + X86CallingConv.cpp + X86CmovConversion.cpp + X86DiscriminateMemOps.cpp + X86DomainReassignment.cpp + X86EvexToVex.cpp + X86ExpandPseudo.cpp + X86FastISel.cpp + X86FixupBWInsts.cpp + X86FixupLEAs.cpp + X86FixupSetCC.cpp + X86FlagsCopyLowering.cpp + X86FloatingPoint.cpp + X86FrameLowering.cpp + X86ISelDAGToDAG.cpp + X86ISelLowering.cpp + X86IndirectBranchTracking.cpp + X86IndirectThunks.cpp + X86InsertPrefetch.cpp + X86InsertWait.cpp + X86InstCombineIntrinsic.cpp + X86InstrFMA3Info.cpp + X86InstrFoldTables.cpp + X86InstrInfo.cpp + X86InstructionSelector.cpp + X86InterleavedAccess.cpp + X86LegalizerInfo.cpp + X86LoadValueInjectionLoadHardening.cpp + X86LoadValueInjectionRetHardening.cpp + X86LowerAMXType.cpp + X86MCInstLower.cpp + X86MachineFunctionInfo.cpp + X86MacroFusion.cpp + X86OptimizeLEAs.cpp + X86PadShortFunction.cpp + X86PartialReduction.cpp + X86PreTileConfig.cpp + X86RegisterBankInfo.cpp + X86RegisterInfo.cpp + X86SelectionDAGInfo.cpp + X86ShuffleDecodeConstantPool.cpp + X86SpeculativeExecutionSideEffectSuppression.cpp + X86SpeculativeLoadHardening.cpp + X86Subtarget.cpp + X86TargetMachine.cpp + X86TargetObjectFile.cpp + X86TargetTransformInfo.cpp + X86TileConfig.cpp + X86VZeroUpper.cpp + X86WinAllocaExpander.cpp + X86WinEHState.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Target/ya.make b/contrib/libs/llvm12/lib/Target/ya.make new file mode 100644 index 00000000000..73e90f4b108 --- /dev/null +++ b/contrib/libs/llvm12/lib/Target/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Target +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Target.cpp + TargetIntrinsicInfo.cpp + TargetLoweringObjectFile.cpp + TargetMachine.cpp + TargetMachineC.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/TextAPI/MachO/ya.make b/contrib/libs/llvm12/lib/TextAPI/MachO/ya.make new file mode 100644 index 00000000000..9fedb228b4a --- /dev/null +++ b/contrib/libs/llvm12/lib/TextAPI/MachO/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/TextAPI +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Architecture.cpp + ArchitectureSet.cpp + InterfaceFile.cpp + PackedVersion.cpp + Platform.cpp + Symbol.cpp + Target.cpp + TextStub.cpp + TextStubCommon.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/ya.make b/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/ya.make new file mode 100644 index 00000000000..e26b1db3c9d --- /dev/null +++ b/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool + contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DlltoolDriver.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/ya.make b/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/ya.make new file mode 100644 index 00000000000..c5b2d4e0bdc --- /dev/null +++ b/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/ToolDrivers/llvm-lib + contrib/libs/llvm12/lib/ToolDrivers/llvm-lib +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + LibDriver.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine/ya.make b/contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine/ya.make new file mode 100644 index 00000000000..723b5a29556 --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AggressiveInstCombine.cpp + TruncInstCombine.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/CFGuard/ya.make b/contrib/libs/llvm12/lib/Transforms/CFGuard/ya.make new file mode 100644 index 00000000000..82a33dfab1e --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/CFGuard/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/CFGuard +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CFGuard.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/Coroutines/ya.make b/contrib/libs/llvm12/lib/Transforms/Coroutines/ya.make new file mode 100644 index 00000000000..f19e4e9eb09 --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/Coroutines/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/Coroutines +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CoroCleanup.cpp + CoroEarly.cpp + CoroElide.cpp + CoroFrame.cpp + CoroSplit.cpp + Coroutines.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/HelloNew/ya.make b/contrib/libs/llvm12/lib/Transforms/HelloNew/ya.make new file mode 100644 index 00000000000..bfafb029d3f --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/HelloNew/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/HelloNew +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + HelloWorld.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/IPO/ya.make b/contrib/libs/llvm12/lib/Transforms/IPO/ya.make new file mode 100644 index 00000000000..41f92d67a45 --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/IPO/ya.make @@ -0,0 +1,83 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/IPO +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AlwaysInliner.cpp + Annotation2Metadata.cpp + ArgumentPromotion.cpp + Attributor.cpp + AttributorAttributes.cpp + BarrierNoopPass.cpp + BlockExtractor.cpp + CalledValuePropagation.cpp + ConstantMerge.cpp + CrossDSOCFI.cpp + DeadArgumentElimination.cpp + ElimAvailExtern.cpp + ExtractGV.cpp + ForceFunctionAttrs.cpp + FunctionAttrs.cpp + FunctionImport.cpp + GlobalDCE.cpp + GlobalOpt.cpp + GlobalSplit.cpp + HotColdSplitting.cpp + IPO.cpp + IROutliner.cpp + InferFunctionAttrs.cpp + InlineSimple.cpp + Inliner.cpp + Internalize.cpp + LoopExtractor.cpp + LowerTypeTests.cpp + MergeFunctions.cpp + OpenMPOpt.cpp + PartialInlining.cpp + PassManagerBuilder.cpp + PruneEH.cpp + SCCP.cpp + SampleContextTracker.cpp + SampleProfile.cpp + SampleProfileProbe.cpp + StripDeadPrototypes.cpp + StripSymbols.cpp + SyntheticCountsPropagation.cpp + ThinLTOBitcodeWriter.cpp + WholeProgramDevirt.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/InstCombine/ya.make b/contrib/libs/llvm12/lib/Transforms/InstCombine/ya.make new file mode 100644 index 00000000000..eeda0b4bd62 --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/InstCombine/ya.make @@ -0,0 +1,44 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/InstCombine +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + InstCombineAddSub.cpp + InstCombineAndOrXor.cpp + InstCombineAtomicRMW.cpp + InstCombineCalls.cpp + InstCombineCasts.cpp + InstCombineCompares.cpp + InstCombineLoadStoreAlloca.cpp + InstCombineMulDivRem.cpp + InstCombineNegator.cpp + InstCombinePHI.cpp + InstCombineSelect.cpp + InstCombineShifts.cpp + InstCombineSimplifyDemanded.cpp + InstCombineVectorOps.cpp + InstructionCombining.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/Instrumentation/ya.make b/contrib/libs/llvm12/lib/Transforms/Instrumentation/ya.make new file mode 100644 index 00000000000..5b8d25019db --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/Instrumentation/ya.make @@ -0,0 +1,53 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/Instrumentation +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AddressSanitizer.cpp + BoundsChecking.cpp + CGProfile.cpp + ControlHeightReduction.cpp + DataFlowSanitizer.cpp + GCOVProfiling.cpp + HWAddressSanitizer.cpp + IndirectCallPromotion.cpp + InstrOrderFile.cpp + InstrProfiling.cpp + Instrumentation.cpp + MemProfiler.cpp + MemorySanitizer.cpp + PGOInstrumentation.cpp + PGOMemOPSizeOpt.cpp + PoisonChecking.cpp + SanitizerCoverage.cpp + ThreadSanitizer.cpp + ValueProfileCollector.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/ObjCARC/ya.make b/contrib/libs/llvm12/lib/Transforms/ObjCARC/ya.make new file mode 100644 index 00000000000..84bc394362b --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/ObjCARC/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/ObjCARC +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DependencyAnalysis.cpp + ObjCARC.cpp + ObjCARCAPElim.cpp + ObjCARCContract.cpp + ObjCARCExpand.cpp + ObjCARCOpts.cpp + ProvenanceAnalysis.cpp + ProvenanceAnalysisEvaluator.cpp + PtrState.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/Scalar/ya.make b/contrib/libs/llvm12/lib/Transforms/Scalar/ya.make new file mode 100644 index 00000000000..4d412213aa9 --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/Scalar/ya.make @@ -0,0 +1,109 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/Scalar +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ADCE.cpp + AlignmentFromAssumptions.cpp + AnnotationRemarks.cpp + BDCE.cpp + CallSiteSplitting.cpp + ConstantHoisting.cpp + ConstraintElimination.cpp + CorrelatedValuePropagation.cpp + DCE.cpp + DeadStoreElimination.cpp + DivRemPairs.cpp + EarlyCSE.cpp + FlattenCFGPass.cpp + Float2Int.cpp + GVN.cpp + GVNHoist.cpp + GVNSink.cpp + GuardWidening.cpp + IVUsersPrinter.cpp + IndVarSimplify.cpp + InductiveRangeCheckElimination.cpp + InferAddressSpaces.cpp + InstSimplifyPass.cpp + JumpThreading.cpp + LICM.cpp + LoopAccessAnalysisPrinter.cpp + LoopDataPrefetch.cpp + LoopDeletion.cpp + LoopDistribute.cpp + LoopFlatten.cpp + LoopFuse.cpp + LoopIdiomRecognize.cpp + LoopInstSimplify.cpp + LoopInterchange.cpp + LoopLoadElimination.cpp + LoopPassManager.cpp + LoopPredication.cpp + LoopRerollPass.cpp + LoopRotation.cpp + LoopSimplifyCFG.cpp + LoopSink.cpp + LoopStrengthReduce.cpp + LoopUnrollAndJamPass.cpp + LoopUnrollPass.cpp + LoopUnswitch.cpp + LoopVersioningLICM.cpp + LowerAtomic.cpp + LowerConstantIntrinsics.cpp + LowerExpectIntrinsic.cpp + LowerGuardIntrinsic.cpp + LowerMatrixIntrinsics.cpp + LowerWidenableCondition.cpp + MakeGuardsExplicit.cpp + MemCpyOptimizer.cpp + MergeICmps.cpp + MergedLoadStoreMotion.cpp + NaryReassociate.cpp + NewGVN.cpp + PartiallyInlineLibCalls.cpp + PlaceSafepoints.cpp + Reassociate.cpp + Reg2Mem.cpp + RewriteStatepointsForGC.cpp + SCCP.cpp + SROA.cpp + Scalar.cpp + ScalarizeMaskedMemIntrin.cpp + Scalarizer.cpp + SeparateConstOffsetFromGEP.cpp + SimpleLoopUnswitch.cpp + SimplifyCFGPass.cpp + Sink.cpp + SpeculateAroundPHIs.cpp + SpeculativeExecution.cpp + StraightLineStrengthReduce.cpp + StructurizeCFG.cpp + TailRecursionElimination.cpp + WarnMissedTransforms.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/Utils/ya.make b/contrib/libs/llvm12/lib/Transforms/Utils/ya.make new file mode 100644 index 00000000000..07debc572df --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/Utils/ya.make @@ -0,0 +1,99 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/Utils +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AMDGPUEmitPrintf.cpp + ASanStackFrameLayout.cpp + AddDiscriminators.cpp + AssumeBundleBuilder.cpp + BasicBlockUtils.cpp + BreakCriticalEdges.cpp + BuildLibCalls.cpp + BypassSlowDivision.cpp + CallGraphUpdater.cpp + CallPromotionUtils.cpp + CanonicalizeAliases.cpp + CanonicalizeFreezeInLoops.cpp + CloneFunction.cpp + CloneModule.cpp + CodeExtractor.cpp + CodeMoverUtils.cpp + CtorUtils.cpp + Debugify.cpp + DemoteRegToStack.cpp + EntryExitInstrumenter.cpp + EscapeEnumerator.cpp + Evaluator.cpp + FixIrreducible.cpp + FlattenCFG.cpp + FunctionComparator.cpp + FunctionImportUtils.cpp + GlobalStatus.cpp + GuardUtils.cpp + InjectTLIMappings.cpp + InlineFunction.cpp + InstructionNamer.cpp + IntegerDivision.cpp + LCSSA.cpp + LibCallsShrinkWrap.cpp + Local.cpp + LoopPeel.cpp + LoopRotationUtils.cpp + LoopSimplify.cpp + LoopUnroll.cpp + LoopUnrollAndJam.cpp + LoopUnrollRuntime.cpp + LoopUtils.cpp + LoopVersioning.cpp + LowerInvoke.cpp + LowerMemIntrinsics.cpp + LowerSwitch.cpp + MatrixUtils.cpp + Mem2Reg.cpp + MetaRenamer.cpp + ModuleUtils.cpp + NameAnonGlobals.cpp + PredicateInfo.cpp + PromoteMemoryToRegister.cpp + SSAUpdater.cpp + SSAUpdaterBulk.cpp + SanitizerStats.cpp + ScalarEvolutionExpander.cpp + SimplifyCFG.cpp + SimplifyIndVar.cpp + SimplifyLibCalls.cpp + SizeOpts.cpp + SplitModule.cpp + StripGCRelocates.cpp + StripNonLineTableDebugInfo.cpp + SymbolRewriter.cpp + UnifyFunctionExitNodes.cpp + UnifyLoopExits.cpp + UniqueInternalLinkageNames.cpp + Utils.cpp + VNCoercion.cpp + ValueMapper.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/Transforms/Vectorize/ya.make b/contrib/libs/llvm12/lib/Transforms/Vectorize/ya.make new file mode 100644 index 00000000000..482aed8e023 --- /dev/null +++ b/contrib/libs/llvm12/lib/Transforms/Vectorize/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + LoadStoreVectorizer.cpp + LoopVectorizationLegality.cpp + LoopVectorize.cpp + SLPVectorizer.cpp + VPlan.cpp + VPlanHCFGBuilder.cpp + VPlanPredicator.cpp + VPlanSLP.cpp + VPlanTransforms.cpp + VPlanVerifier.cpp + VectorCombine.cpp + Vectorize.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/WindowsManifest/ya.make b/contrib/libs/llvm12/lib/WindowsManifest/ya.make new file mode 100644 index 00000000000..f4d8f67753c --- /dev/null +++ b/contrib/libs/llvm12/lib/WindowsManifest/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/WindowsManifest +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + WindowsManifestMerger.cpp +) + +END() diff --git a/contrib/libs/llvm12/lib/XRay/ya.make b/contrib/libs/llvm12/lib/XRay/ya.make new file mode 100644 index 00000000000..a82a32f3dfe --- /dev/null +++ b/contrib/libs/llvm12/lib/XRay/ya.make @@ -0,0 +1,40 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/lib/XRay +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BlockIndexer.cpp + BlockPrinter.cpp + BlockVerifier.cpp + FDRRecordProducer.cpp + FDRRecords.cpp + FDRTraceExpander.cpp + FDRTraceWriter.cpp + FileHeaderReader.cpp + InstrumentationMap.cpp + LogBuilderConsumer.cpp + Profile.cpp + RecordInitializer.cpp + RecordPrinter.cpp + Trace.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/bugpoint/ya.make b/contrib/libs/llvm12/tools/bugpoint/ya.make new file mode 100644 index 00000000000..9281034915e --- /dev/null +++ b/contrib/libs/llvm12/tools/bugpoint/ya.make @@ -0,0 +1,100 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Extensions + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize + contrib/libs/llvm12/tools/polly/lib + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/tools/bugpoint +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BugDriver.cpp + CrashDebugger.cpp + ExecutionDriver.cpp + ExtractFunction.cpp + FindBugs.cpp + Miscompilation.cpp + OptimizerDriver.cpp + ToolRunner.cpp + bugpoint.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/dsymutil/ya.make b/contrib/libs/llvm12/tools/dsymutil/ya.make new file mode 100644 index 00000000000..3070abe859e --- /dev/null +++ b/contrib/libs/llvm12/tools/dsymutil/ya.make @@ -0,0 +1,98 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DWARFLinker + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/dsymutil + contrib/libs/llvm12/tools/dsymutil +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BinaryHolder.cpp + CFBundle.cpp + DebugMap.cpp + DwarfLinkerForBinary.cpp + MachODebugMapParser.cpp + MachOUtils.cpp + Reproducer.cpp + SymbolMap.cpp + dsymutil.cpp +) + +IF (OS_DARWIN) + LDFLAGS( + -framework + CoreFoundation + ) +ENDIF() + +END() diff --git a/contrib/libs/llvm12/tools/gold/ya.make b/contrib/libs/llvm12/tools/gold/ya.make new file mode 100644 index 00000000000..a6c4d8b7c3b --- /dev/null +++ b/contrib/libs/llvm12/tools/gold/ya.make @@ -0,0 +1,67 @@ +# Generated by devtools/yamaker. + +DLL(LLVMgold PREFIX "") + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + build/platform/binutils + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/LTO + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/Transforms/IPO +) + +ADDINCL( + contrib/libs/llvm12/tools/gold +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +EXPORTS_SCRIPT(gold.exports) + +CFLAGS( + -I$BINUTILS_ROOT_RESOURCE_GLOBAL/include +) + +SRCS( + gold-plugin.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llc/ya.make b/contrib/libs/llvm12/tools/llc/ya.make new file mode 100644 index 00000000000..61e1ca2eee4 --- /dev/null +++ b/contrib/libs/llvm12/tools/llc/ya.make @@ -0,0 +1,86 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/MIRParser + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/tools/llc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llc.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/lli/ChildTarget/ya.make b/contrib/libs/llvm12/tools/lli/ChildTarget/ya.make new file mode 100644 index 00000000000..18e37e60596 --- /dev/null +++ b/contrib/libs/llvm12/tools/lli/ChildTarget/ya.make @@ -0,0 +1,61 @@ +# Generated by devtools/yamaker. + +PROGRAM(lli-child-target) + +WITHOUT_LICENSE_TEXTS() + +LICENSE(NCSA) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/JITLink + contrib/libs/llvm12/lib/ExecutionEngine/Orc + contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared + contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/tools/lli/ChildTarget +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ChildTarget.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/lli/ya.make b/contrib/libs/llvm12/tools/lli/ya.make new file mode 100644 index 00000000000..bf250616972 --- /dev/null +++ b/contrib/libs/llvm12/tools/lli/ya.make @@ -0,0 +1,83 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/Interpreter + contrib/libs/llvm12/lib/ExecutionEngine/JITLink + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT + contrib/libs/llvm12/lib/ExecutionEngine/Orc + contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared + contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +IF (OS_LINUX) + PEERDIR( + contrib/libs/llvm12/lib/ExecutionEngine/PerfJITEvents + ) +ENDIF() + +ADDINCL( + contrib/libs/llvm12/tools/lli +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + lli.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-ar/ya.make b/contrib/libs/llvm12/tools/llvm-ar/ya.make new file mode 100644 index 00000000000..8e26a9c57aa --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-ar/ya.make @@ -0,0 +1,59 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/ToolDrivers/llvm-dlltool + contrib/libs/llvm12/lib/ToolDrivers/llvm-lib +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-ar +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-ar.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-as/ya.make b/contrib/libs/llvm12/tools/llvm-as/ya.make new file mode 100644 index 00000000000..c0acaeaf630 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-as/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-as +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-as.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-bcanalyzer/ya.make b/contrib/libs/llvm12/tools/llvm-bcanalyzer/ya.make new file mode 100644 index 00000000000..6ae649468a9 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-bcanalyzer/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-bcanalyzer +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-bcanalyzer.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cat/ya.make b/contrib/libs/llvm12/tools/llvm-cat/ya.make new file mode 100644 index 00000000000..9538ce6a36f --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cat/ya.make @@ -0,0 +1,42 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-cat +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-cat.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cfi-verify/lib/ya.make b/contrib/libs/llvm12/tools/llvm-cfi-verify/lib/ya.make new file mode 100644 index 00000000000..90c2ec63420 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cfi-verify/lib/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-cfi-verify/lib +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + FileAnalysis.cpp + GraphBuilder.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cfi-verify/ya.make b/contrib/libs/llvm12/tools/llvm-cfi-verify/ya.make new file mode 100644 index 00000000000..3259392f21c --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cfi-verify/ya.make @@ -0,0 +1,67 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/DebugInfo/Symbolize + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/tools/llvm-cfi-verify/lib +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-cfi-verify +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-cfi-verify.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-config/ya.make b/contrib/libs/llvm12/tools/llvm-config/ya.make new file mode 100644 index 00000000000..bf7af728a9d --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-config/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-config +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DCMAKE_CFG_INTDIR=\".\" +) + +SRCS( + llvm-config.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cov/ya.make b/contrib/libs/llvm12/tools/llvm-cov/ya.make new file mode 100644 index 00000000000..ace0179c7e5 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cov/ya.make @@ -0,0 +1,49 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/ProfileData/Coverage + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-cov +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CodeCoverage.cpp + CoverageExporterJson.cpp + CoverageExporterLcov.cpp + CoverageFilters.cpp + CoverageReport.cpp + CoverageSummaryInfo.cpp + SourceCoverageView.cpp + SourceCoverageViewHTML.cpp + SourceCoverageViewText.cpp + TestingSupport.cpp + gcov.cpp + llvm-cov.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cvtres/ya.make b/contrib/libs/llvm12/tools/llvm-cvtres/ya.make new file mode 100644 index 00000000000..3c1a10ed036 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cvtres/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres + contrib/libs/llvm12/tools/llvm-cvtres +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-cvtres.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cxxdump/ya.make b/contrib/libs/llvm12/tools/llvm-cxxdump/ya.make new file mode 100644 index 00000000000..f500145cb44 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cxxdump/ya.make @@ -0,0 +1,43 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-cxxdump +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Error.cpp + llvm-cxxdump.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cxxfilt/ya.make b/contrib/libs/llvm12/tools/llvm-cxxfilt/ya.make new file mode 100644 index 00000000000..252d94f1af1 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cxxfilt/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-cxxfilt +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-cxxfilt.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-cxxmap/ya.make b/contrib/libs/llvm12/tools/llvm-cxxmap/ya.make new file mode 100644 index 00000000000..53384f4fe45 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-cxxmap/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-cxxmap +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-cxxmap.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-diff/ya.make b/contrib/libs/llvm12/tools/llvm-diff/ya.make new file mode 100644 index 00000000000..6d52ad1ff9a --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-diff/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-diff +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DiffConsumer.cpp + DiffLog.cpp + DifferenceEngine.cpp + llvm-diff.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-dis/ya.make b/contrib/libs/llvm12/tools/llvm-dis/ya.make new file mode 100644 index 00000000000..a16c1173c7d --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-dis/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-dis +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-dis.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-dwarfdump/ya.make b/contrib/libs/llvm12/tools/llvm-dwarfdump/ya.make new file mode 100644 index 00000000000..555379398ca --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-dwarfdump/ya.make @@ -0,0 +1,54 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-dwarfdump +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + SectionSizes.cpp + Statistics.cpp + llvm-dwarfdump.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-dwp/ya.make b/contrib/libs/llvm12/tools/llvm-dwp/ya.make new file mode 100644 index 00000000000..364a66f6455 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-dwp/ya.make @@ -0,0 +1,85 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-dwp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + DWPError.cpp + llvm-dwp.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-elfabi/ya.make b/contrib/libs/llvm12/tools/llvm-elfabi/ya.make new file mode 100644 index 00000000000..3247fce8775 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-elfabi/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/InterfaceStub + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-elfabi +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ErrorCollector.cpp + llvm-elfabi.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-exegesis/lib/AArch64/ya.make b/contrib/libs/llvm12/tools/llvm-exegesis/lib/AArch64/ya.make new file mode 100644 index 00000000000..3fd31cbdf8c --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-exegesis/lib/AArch64/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/tools/llvm-exegesis/lib/AArch64 +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Target.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-exegesis/lib/PowerPC/ya.make b/contrib/libs/llvm12/tools/llvm-exegesis/lib/PowerPC/ya.make new file mode 100644 index 00000000000..a8bdbbeb653 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-exegesis/lib/PowerPC/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/tools/llvm-exegesis/lib/PowerPC +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Target.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-exegesis/lib/X86/ya.make b/contrib/libs/llvm12/tools/llvm-exegesis/lib/X86/ya.make new file mode 100644 index 00000000000..3782826d154 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-exegesis/lib/X86/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/tools/llvm-exegesis/lib/X86 +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Target.cpp + X86Counter.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-exegesis/lib/ya.make b/contrib/libs/llvm12/tools/llvm-exegesis/lib/ya.make new file mode 100644 index 00000000000..8da6dc0a2e3 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-exegesis/lib/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-exegesis/lib +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Analysis.cpp + Assembler.cpp + BenchmarkResult.cpp + BenchmarkRunner.cpp + Clustering.cpp + CodeTemplate.cpp + Error.cpp + LatencyBenchmarkRunner.cpp + LlvmState.cpp + MCInstrDescView.cpp + ParallelSnippetGenerator.cpp + PerfHelper.cpp + RegisterAliasing.cpp + RegisterValue.cpp + SchedClassResolution.cpp + SerialSnippetGenerator.cpp + SnippetFile.cpp + SnippetGenerator.cpp + SnippetRepetitor.cpp + Target.cpp + UopsBenchmarkRunner.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-exegesis/ya.make b/contrib/libs/llvm12/tools/llvm-exegesis/ya.make new file mode 100644 index 00000000000..d66579b57f6 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-exegesis/ya.make @@ -0,0 +1,66 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ObjectYAML + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/tools/llvm-exegesis/lib + contrib/libs/llvm12/tools/llvm-exegesis/lib/X86 +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-exegesis +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DLLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET=InitializeX86ExegesisTarget +) + +SRCS( + llvm-exegesis.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-extract/ya.make b/contrib/libs/llvm12/tools/llvm-extract/ya.make new file mode 100644 index 00000000000..e7f08ddcf63 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-extract/ya.make @@ -0,0 +1,51 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-extract +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-extract.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-gsymutil/ya.make b/contrib/libs/llvm12/tools/llvm-gsymutil/ya.make new file mode 100644 index 00000000000..d85893ceba2 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-gsymutil/ya.make @@ -0,0 +1,90 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(NCSA) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/GSYM + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-gsymutil +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-gsymutil.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-ifs/ya.make b/contrib/libs/llvm12/tools/llvm-ifs/ya.make new file mode 100644 index 00000000000..9c4a085d3b3 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-ifs/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ObjectYAML + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-ifs +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-ifs.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-jitlink/llvm-jitlink-executor/ya.make b/contrib/libs/llvm12/tools/llvm-jitlink/llvm-jitlink-executor/ya.make new file mode 100644 index 00000000000..b836b561390 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-jitlink/llvm-jitlink-executor/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared + contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-jitlink/llvm-jitlink-executor +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-jitlink-executor.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-jitlink/ya.make b/contrib/libs/llvm12/tools/llvm-jitlink/ya.make new file mode 100644 index 00000000000..9ad221c0894 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-jitlink/ya.make @@ -0,0 +1,84 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/JITLink + contrib/libs/llvm12/lib/ExecutionEngine/Orc + contrib/libs/llvm12/lib/ExecutionEngine/Orc/Shared + contrib/libs/llvm12/lib/ExecutionEngine/Orc/TargetProcess + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-jitlink +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-jitlink-elf.cpp + llvm-jitlink-macho.cpp + llvm-jitlink.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-libtool-darwin/ya.make b/contrib/libs/llvm12/tools/llvm-libtool-darwin/ya.make new file mode 100644 index 00000000000..f50c593678d --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-libtool-darwin/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-libtool-darwin +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-libtool-darwin.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-link/ya.make b/contrib/libs/llvm12/tools/llvm-link/ya.make new file mode 100644 index 00000000000..a4ebb486cf1 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-link/ya.make @@ -0,0 +1,51 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-link +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-link.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-lipo/ya.make b/contrib/libs/llvm12/tools/llvm-lipo/ya.make new file mode 100644 index 00000000000..a2104056845 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-lipo/ya.make @@ -0,0 +1,69 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-lipo + contrib/libs/llvm12/tools/llvm-lipo +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-lipo.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-lto/ya.make b/contrib/libs/llvm12/tools/llvm-lto/ya.make new file mode 100644 index 00000000000..a9bc9479185 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-lto/ya.make @@ -0,0 +1,92 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/LTO + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize + contrib/libs/llvm12/tools/polly/lib + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-lto +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-lto.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-lto2/ya.make b/contrib/libs/llvm12/tools/llvm-lto2/ya.make new file mode 100644 index 00000000000..b4e797584ae --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-lto2/ya.make @@ -0,0 +1,92 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/LTO + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize + contrib/libs/llvm12/tools/polly/lib + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-lto2 +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-lto2.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-mc/ya.make b/contrib/libs/llvm12/tools/llvm-mc/ya.make new file mode 100644 index 00000000000..13a4e53f8c6 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-mc/ya.make @@ -0,0 +1,56 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-mc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Disassembler.cpp + llvm-mc.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-mca/ya.make b/contrib/libs/llvm12/tools/llvm-mca/ya.make new file mode 100644 index 00000000000..bc6a92d7f86 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-mca/ya.make @@ -0,0 +1,70 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/MCA + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-mca +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CodeRegion.cpp + CodeRegionGenerator.cpp + PipelinePrinter.cpp + Views/BottleneckAnalysis.cpp + Views/DispatchStatistics.cpp + Views/InstructionInfoView.cpp + Views/InstructionView.cpp + Views/RegisterFileStatistics.cpp + Views/ResourcePressureView.cpp + Views/RetireControlUnitStatistics.cpp + Views/SchedulerStatistics.cpp + Views/SummaryView.cpp + Views/TimelineView.cpp + Views/View.cpp + llvm-mca.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-ml/ya.make b/contrib/libs/llvm12/tools/llvm-ml/ya.make new file mode 100644 index 00000000000..a84205697c0 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-ml/ya.make @@ -0,0 +1,59 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-ml + contrib/libs/llvm12/tools/llvm-ml +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Disassembler.cpp + llvm-ml.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-modextract/ya.make b/contrib/libs/llvm12/tools/llvm-modextract/ya.make new file mode 100644 index 00000000000..055d56a41e5 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-modextract/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-modextract +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-modextract.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-mt/ya.make b/contrib/libs/llvm12/tools/llvm-mt/ya.make new file mode 100644 index 00000000000..44379be67d5 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-mt/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/WindowsManifest +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-mt + contrib/libs/llvm12/tools/llvm-mt +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-mt.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-nm/ya.make b/contrib/libs/llvm12/tools/llvm-nm/ya.make new file mode 100644 index 00000000000..39735659b05 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-nm/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-nm +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-nm.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/ya.make b/contrib/libs/llvm12/tools/llvm-objcopy/ya.make new file mode 100644 index 00000000000..829a92f837b --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-objcopy/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy + contrib/libs/llvm12/tools/llvm-objcopy +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Buffer.cpp + COFF/COFFObjcopy.cpp + COFF/Object.cpp + COFF/Reader.cpp + COFF/Writer.cpp + CopyConfig.cpp + ELF/ELFConfig.cpp + ELF/ELFObjcopy.cpp + ELF/Object.cpp + MachO/MachOLayoutBuilder.cpp + MachO/MachOObjcopy.cpp + MachO/MachOReader.cpp + MachO/MachOWriter.cpp + MachO/Object.cpp + llvm-objcopy.cpp + wasm/Object.cpp + wasm/Reader.cpp + wasm/WasmObjcopy.cpp + wasm/Writer.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-objdump/ya.make b/contrib/libs/llvm12/tools/llvm-objdump/ya.make new file mode 100644 index 00000000000..9523258faaf --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-objdump/ya.make @@ -0,0 +1,73 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/DebugInfo/Symbolize + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-objdump +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + COFFDump.cpp + ELFDump.cpp + MachODump.cpp + WasmDump.cpp + XCOFFDump.cpp + llvm-objdump.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-opt-report/ya.make b/contrib/libs/llvm12/tools/llvm-opt-report/ya.make new file mode 100644 index 00000000000..876e72fbbcd --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-opt-report/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-opt-report +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + OptReport.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-pdbutil/ya.make b/contrib/libs/llvm12/tools/llvm-pdbutil/ya.make new file mode 100644 index 00000000000..77253c47157 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-pdbutil/ya.make @@ -0,0 +1,62 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ObjectYAML + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-pdbutil +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + BytesOutputStyle.cpp + DumpOutputStyle.cpp + ExplainOutputStyle.cpp + FormatUtil.cpp + InputFile.cpp + LinePrinter.cpp + MinimalSymbolDumper.cpp + MinimalTypeDumper.cpp + PdbYaml.cpp + PrettyBuiltinDumper.cpp + PrettyClassDefinitionDumper.cpp + PrettyClassLayoutGraphicalDumper.cpp + PrettyCompilandDumper.cpp + PrettyEnumDumper.cpp + PrettyExternalSymbolDumper.cpp + PrettyFunctionDumper.cpp + PrettyTypeDumper.cpp + PrettyTypedefDumper.cpp + PrettyVariableDumper.cpp + StreamUtil.cpp + TypeReferenceTracker.cpp + YAMLOutputStyle.cpp + llvm-pdbutil.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-profdata/ya.make b/contrib/libs/llvm12/tools/llvm-profdata/ya.make new file mode 100644 index 00000000000..3d81f5dd7ff --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-profdata/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-profdata +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-profdata.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-profgen/ya.make b/contrib/libs/llvm12/tools/llvm-profgen/ya.make new file mode 100644 index 00000000000..965924b3bc7 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-profgen/ya.make @@ -0,0 +1,67 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/DebugInfo/Symbolize + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-profgen +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + PerfReader.cpp + ProfileGenerator.cpp + ProfiledBinary.cpp + PseudoProbe.cpp + llvm-profgen.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-rc/ya.make b/contrib/libs/llvm12/tools/llvm-rc/ya.make new file mode 100644 index 00000000000..793fee0cb4c --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-rc/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-rc + contrib/libs/llvm12/tools/llvm-rc +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ResourceFileWriter.cpp + ResourceScriptCppFilter.cpp + ResourceScriptParser.cpp + ResourceScriptStmt.cpp + ResourceScriptToken.cpp + llvm-rc.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-readobj/ya.make b/contrib/libs/llvm12/tools/llvm-readobj/ya.make new file mode 100644 index 00000000000..a525cb1f027 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-readobj/ya.make @@ -0,0 +1,50 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-readobj +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + ARMWinEHPrinter.cpp + COFFDumper.cpp + COFFImportDumper.cpp + ELFDumper.cpp + MachODumper.cpp + ObjDumper.cpp + WasmDumper.cpp + Win64EHDumper.cpp + WindowsResourceDumper.cpp + XCOFFDumper.cpp + llvm-readobj.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-reduce/ya.make b/contrib/libs/llvm12/tools/llvm-reduce/ya.make new file mode 100644 index 00000000000..621e46c90db --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-reduce/ya.make @@ -0,0 +1,80 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-reduce +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + TestRunner.cpp + deltas/Delta.cpp + deltas/ReduceAliases.cpp + deltas/ReduceArguments.cpp + deltas/ReduceAttributes.cpp + deltas/ReduceBasicBlocks.cpp + deltas/ReduceFunctionBodies.cpp + deltas/ReduceFunctions.cpp + deltas/ReduceGlobalVarInitializers.cpp + deltas/ReduceGlobalVars.cpp + deltas/ReduceInstructions.cpp + deltas/ReduceMetadata.cpp + deltas/ReduceOperandBundles.cpp + deltas/ReduceSpecialGlobals.cpp + llvm-reduce.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-rtdyld/ya.make b/contrib/libs/llvm12/tools/llvm-rtdyld/ya.make new file mode 100644 index 00000000000..cfce473613b --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-rtdyld/ya.make @@ -0,0 +1,59 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/ExecutionEngine + contrib/libs/llvm12/lib/ExecutionEngine/RuntimeDyld + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-rtdyld +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-rtdyld.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-size/ya.make b/contrib/libs/llvm12/tools/llvm-size/ya.make new file mode 100644 index 00000000000..26c9ef9ac95 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-size/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-size +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-size.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-split/ya.make b/contrib/libs/llvm12/tools/llvm-split/ya.make new file mode 100644 index 00000000000..62e248f852e --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-split/ya.make @@ -0,0 +1,43 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/Utils +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-split +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-split.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-stress/ya.make b/contrib/libs/llvm12/tools/llvm-stress/ya.make new file mode 100644 index 00000000000..b24a02cbe6e --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-stress/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-stress +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-stress.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-strings/ya.make b/contrib/libs/llvm12/tools/llvm-strings/ya.make new file mode 100644 index 00000000000..83b05cc9c9b --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-strings/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-strings +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-strings.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-symbolizer/ya.make b/contrib/libs/llvm12/tools/llvm-symbolizer/ya.make new file mode 100644 index 00000000000..ce5c02323ca --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-symbolizer/ya.make @@ -0,0 +1,44 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/DebugInfo/Symbolize + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Option + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer + contrib/libs/llvm12/tools/llvm-symbolizer +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-symbolizer.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-undname/ya.make b/contrib/libs/llvm12/tools/llvm-undname/ya.make new file mode 100644 index 00000000000..78446723ca4 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-undname/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-undname +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-undname.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/llvm-xray/ya.make b/contrib/libs/llvm12/tools/llvm-xray/ya.make new file mode 100644 index 00000000000..2ef035e2c47 --- /dev/null +++ b/contrib/libs/llvm12/tools/llvm-xray/ya.make @@ -0,0 +1,52 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/DebugInfo/Symbolize + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/XRay +) + +ADDINCL( + contrib/libs/llvm12/tools/llvm-xray +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + func-id-helper.cpp + llvm-xray.cpp + xray-account.cpp + xray-color-helper.cpp + xray-converter.cpp + xray-extract.cpp + xray-fdr-dump.cpp + xray-graph-diff.cpp + xray-graph.cpp + xray-registry.cpp + xray-stacks.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/lto/ya.make b/contrib/libs/llvm12/tools/lto/ya.make new file mode 100644 index 00000000000..b7b1ad5e196 --- /dev/null +++ b/contrib/libs/llvm12/tools/lto/ya.make @@ -0,0 +1,63 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/LTO + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo +) + +ADDINCL( + contrib/libs/llvm12/tools/lto +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + LTODisassembler.cpp + lto.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/obj2yaml/ya.make b/contrib/libs/llvm12/tools/obj2yaml/ya.make new file mode 100644 index 00000000000..c5046efb59e --- /dev/null +++ b/contrib/libs/llvm12/tools/obj2yaml/ya.make @@ -0,0 +1,47 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ObjectYAML + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/obj2yaml +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + archive2yaml.cpp + coff2yaml.cpp + dwarf2yaml.cpp + elf2yaml.cpp + macho2yaml.cpp + minidump2yaml.cpp + obj2yaml.cpp + wasm2yaml.cpp + xcoff2yaml.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/opt/ya.make b/contrib/libs/llvm12/tools/opt/ya.make new file mode 100644 index 00000000000..7806e7c0ed3 --- /dev/null +++ b/contrib/libs/llvm12/tools/opt/ya.make @@ -0,0 +1,98 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/CodeGen + contrib/libs/llvm12/lib/CodeGen/AsmPrinter + contrib/libs/llvm12/lib/CodeGen/GlobalISel + contrib/libs/llvm12/lib/CodeGen/SelectionDAG + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Extensions + contrib/libs/llvm12/lib/Frontend/OpenMP + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Target/AArch64 + contrib/libs/llvm12/lib/Target/AArch64/AsmParser + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM + contrib/libs/llvm12/lib/Target/ARM/AsmParser + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF + contrib/libs/llvm12/lib/Target/BPF/AsmParser + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC + contrib/libs/llvm12/lib/Target/PowerPC/AsmParser + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO + contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine + contrib/libs/llvm12/lib/Transforms/CFGuard + contrib/libs/llvm12/lib/Transforms/Coroutines + contrib/libs/llvm12/lib/Transforms/HelloNew + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Instrumentation + contrib/libs/llvm12/lib/Transforms/ObjCARC + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize + contrib/libs/llvm12/tools/polly/lib + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/tools/opt +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AnalysisWrappers.cpp + BreakpointPrinter.cpp + GraphPrinters.cpp + NewPMDriver.cpp + PassPrinters.cpp + PrintSCC.cpp + opt.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/polly/lib/External/isl/ya.make b/contrib/libs/llvm12/tools/polly/lib/External/isl/ya.make new file mode 100644 index 00000000000..1a26b5e6462 --- /dev/null +++ b/contrib/libs/llvm12/tools/polly/lib/External/isl/ya.make @@ -0,0 +1,110 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + contrib/libs/llvm12/tools/polly/lib/External + contrib/libs/llvm12/tools/polly/lib/External/isl + contrib/libs/llvm12/tools/polly/lib/External/isl/imath + contrib/libs/llvm12/tools/polly/lib/External/isl/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCS( + basis_reduction_tab.c + imath/gmp_compat.c + imath/imath.c + imath/imrat.c + isl_aff.c + isl_aff_map.c + isl_affine_hull.c + isl_arg.c + isl_ast.c + isl_ast_build.c + isl_ast_build_expr.c + isl_ast_codegen.c + isl_ast_graft.c + isl_bernstein.c + isl_blk.c + isl_bound.c + isl_box.c + isl_coalesce.c + isl_constraint.c + isl_convex_hull.c + isl_ctx.c + isl_deprecated.c + isl_dim_map.c + isl_equalities.c + isl_factorization.c + isl_farkas.c + isl_ffs.c + isl_flow.c + isl_fold.c + isl_hash.c + isl_id.c + isl_id_to_ast_expr.c + isl_id_to_id.c + isl_id_to_pw_aff.c + isl_ilp.c + isl_imath.c + isl_input.c + isl_int_sioimath.c + isl_local.c + isl_local_space.c + isl_lp.c + isl_map.c + isl_map_list.c + isl_map_simplify.c + isl_map_subtract.c + isl_map_to_basic_set.c + isl_mat.c + isl_morph.c + isl_obj.c + isl_options.c + isl_output.c + isl_point.c + isl_polynomial.c + isl_printer.c + isl_range.c + isl_reordering.c + isl_sample.c + isl_scan.c + isl_schedule.c + isl_schedule_band.c + isl_schedule_constraints.c + isl_schedule_node.c + isl_schedule_read.c + isl_schedule_tree.c + isl_scheduler.c + isl_seq.c + isl_set_list.c + isl_set_to_ast_graft_list.c + isl_sort.c + isl_space.c + isl_stream.c + isl_stride.c + isl_tab.c + isl_tab_pip.c + isl_tarjan.c + isl_transitive_closure.c + isl_union_map.c + isl_val.c + isl_val_sioimath.c + isl_vec.c + isl_version.c + isl_vertices.c + print.c + set_from_map.c + set_to_map.c + uset_from_umap.c + uset_to_umap.c +) + +END() diff --git a/contrib/libs/llvm12/tools/polly/lib/External/ppcg/ya.make b/contrib/libs/llvm12/tools/polly/lib/External/ppcg/ya.make new file mode 100644 index 00000000000..b388690ba63 --- /dev/null +++ b/contrib/libs/llvm12/tools/polly/lib/External/ppcg/ya.make @@ -0,0 +1,49 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/tools/polly/lib/External + contrib/libs/llvm12/tools/polly/lib/External/isl + contrib/libs/llvm12/tools/polly/lib/External/isl/include + contrib/libs/llvm12/tools/polly/lib/External/pet/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +IF (OS_WINDOWS) + CFLAGS( + -DPATH_MAX=260 + ) +ENDIF() + +SRCS( + cuda.c + cuda_common.c + external.c + gpu.c + gpu_array_tile.c + gpu_group.c + gpu_hybrid.c + gpu_print.c + gpu_tree.c + grouping.c + hybrid.c + ppcg.c + ppcg_options.c + print.c + schedule.c + util.c +) + +END() diff --git a/contrib/libs/llvm12/tools/polly/lib/ya.make b/contrib/libs/llvm12/tools/polly/lib/ya.make new file mode 100644 index 00000000000..19dd3260cd2 --- /dev/null +++ b/contrib/libs/llvm12/tools/polly/lib/ya.make @@ -0,0 +1,95 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Passes + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/InstCombine + contrib/libs/llvm12/lib/Transforms/Scalar + contrib/libs/llvm12/lib/Transforms/Utils + contrib/libs/llvm12/lib/Transforms/Vectorize + contrib/libs/llvm12/tools/polly/lib/External/isl +) + +ADDINCL( + contrib/libs/llvm12/tools/polly/include + contrib/libs/llvm12/tools/polly/lib + contrib/libs/llvm12/tools/polly/lib/External + contrib/libs/llvm12/tools/polly/lib/External/isl/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + Analysis/DependenceInfo.cpp + Analysis/PolyhedralInfo.cpp + Analysis/PruneUnprofitable.cpp + Analysis/ScopBuilder.cpp + Analysis/ScopDetection.cpp + Analysis/ScopDetectionDiagnostic.cpp + Analysis/ScopGraphPrinter.cpp + Analysis/ScopInfo.cpp + Analysis/ScopPass.cpp + CodeGen/BlockGenerators.cpp + CodeGen/CodeGeneration.cpp + CodeGen/CodegenCleanup.cpp + CodeGen/IRBuilder.cpp + CodeGen/IslAst.cpp + CodeGen/IslExprBuilder.cpp + CodeGen/IslNodeBuilder.cpp + CodeGen/LoopGenerators.cpp + CodeGen/LoopGeneratorsGOMP.cpp + CodeGen/LoopGeneratorsKMP.cpp + CodeGen/PerfMonitor.cpp + CodeGen/RuntimeDebugBuilder.cpp + CodeGen/Utils.cpp + Exchange/JSONExporter.cpp + Support/DumpModulePass.cpp + Support/GICHelper.cpp + Support/ISLTools.cpp + Support/RegisterPasses.cpp + Support/SCEVAffinator.cpp + Support/SCEVValidator.cpp + Support/ScopHelper.cpp + Support/ScopLocation.cpp + Support/VirtualInstruction.cpp + Transform/Canonicalization.cpp + Transform/CodePreparation.cpp + Transform/DeLICM.cpp + Transform/DeadCodeElimination.cpp + Transform/FlattenAlgo.cpp + Transform/FlattenSchedule.cpp + Transform/ForwardOpTree.cpp + Transform/MaximalStaticExpansion.cpp + Transform/RewriteByReferenceParameters.cpp + Transform/ScheduleOptimizer.cpp + Transform/ScheduleTreeTransform.cpp + Transform/ScopInliner.cpp + Transform/Simplify.cpp + Transform/ZoneAlgo.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/remarks-shlib/ya.make b/contrib/libs/llvm12/tools/remarks-shlib/ya.make new file mode 100644 index 00000000000..f3a099fa42d --- /dev/null +++ b/contrib/libs/llvm12/tools/remarks-shlib/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Remarks +) + +ADDINCL( + contrib/libs/llvm12/tools/remarks-shlib +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + libremarks.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/sancov/ya.make b/contrib/libs/llvm12/tools/sancov/ya.make new file mode 100644 index 00000000000..b2574e4dac9 --- /dev/null +++ b/contrib/libs/llvm12/tools/sancov/ya.make @@ -0,0 +1,61 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/DebugInfo/Symbolize + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCDisassembler + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/Target/AArch64/Disassembler + contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc + contrib/libs/llvm12/lib/Target/AArch64/TargetInfo + contrib/libs/llvm12/lib/Target/AArch64/Utils + contrib/libs/llvm12/lib/Target/ARM/Disassembler + contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc + contrib/libs/llvm12/lib/Target/ARM/TargetInfo + contrib/libs/llvm12/lib/Target/ARM/Utils + contrib/libs/llvm12/lib/Target/BPF/Disassembler + contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc + contrib/libs/llvm12/lib/Target/BPF/TargetInfo + contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc + contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo + contrib/libs/llvm12/lib/Target/PowerPC/Disassembler + contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc + contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Target/X86/MCTargetDesc + contrib/libs/llvm12/lib/Target/X86/TargetInfo + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/sancov +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + sancov.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/sanstats/ya.make b/contrib/libs/llvm12/tools/sanstats/ya.make new file mode 100644 index 00000000000..55384128c63 --- /dev/null +++ b/contrib/libs/llvm12/tools/sanstats/ya.make @@ -0,0 +1,42 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/DebugInfo/DWARF + contrib/libs/llvm12/lib/DebugInfo/MSF + contrib/libs/llvm12/lib/DebugInfo/PDB + contrib/libs/llvm12/lib/DebugInfo/Symbolize + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/sanstats +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + sanstats.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/split-file/ya.make b/contrib/libs/llvm12/tools/split-file/ya.make new file mode 100644 index 00000000000..bdc38c11469 --- /dev/null +++ b/contrib/libs/llvm12/tools/split-file/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Support +) + +ADDINCL( + contrib/libs/llvm12/tools/split-file +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + split-file.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/verify-uselistorder/ya.make b/contrib/libs/llvm12/tools/verify-uselistorder/ya.make new file mode 100644 index 00000000000..c34b9173670 --- /dev/null +++ b/contrib/libs/llvm12/tools/verify-uselistorder/ya.make @@ -0,0 +1,42 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/include + contrib/libs/llvm12/lib/Analysis + contrib/libs/llvm12/lib/AsmParser + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitcode/Writer + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/IRReader + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ProfileData + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/verify-uselistorder +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + verify-uselistorder.cpp +) + +END() diff --git a/contrib/libs/llvm12/tools/yaml2obj/ya.make b/contrib/libs/llvm12/tools/yaml2obj/ya.make new file mode 100644 index 00000000000..873ffd99297 --- /dev/null +++ b/contrib/libs/llvm12/tools/yaml2obj/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/BinaryFormat + contrib/libs/llvm12/lib/Bitcode/Reader + contrib/libs/llvm12/lib/Bitstream/Reader + contrib/libs/llvm12/lib/DebugInfo/CodeView + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/MC + contrib/libs/llvm12/lib/MC/MCParser + contrib/libs/llvm12/lib/Object + contrib/libs/llvm12/lib/ObjectYAML + contrib/libs/llvm12/lib/Remarks + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TextAPI/MachO +) + +ADDINCL( + contrib/libs/llvm12/tools/yaml2obj +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + yaml2obj.cpp +) + +END() diff --git a/contrib/libs/llvm12/utils/TableGen/GlobalISel/ya.make b/contrib/libs/llvm12/utils/TableGen/GlobalISel/ya.make new file mode 100644 index 00000000000..7dffd39f6fd --- /dev/null +++ b/contrib/libs/llvm12/utils/TableGen/GlobalISel/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 +) + +ADDINCL( + contrib/libs/llvm12/utils/TableGen/GlobalISel +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + CodeExpander.cpp + GIMatchDag.cpp + GIMatchDagEdge.cpp + GIMatchDagInstr.cpp + GIMatchDagOperands.cpp + GIMatchDagPredicate.cpp + GIMatchDagPredicateDependencyEdge.cpp + GIMatchTree.cpp +) + +END() diff --git a/contrib/libs/llvm12/utils/TableGen/ya.make b/contrib/libs/llvm12/utils/TableGen/ya.make new file mode 100644 index 00000000000..2cda74481ed --- /dev/null +++ b/contrib/libs/llvm12/utils/TableGen/ya.make @@ -0,0 +1,80 @@ +# Generated by devtools/yamaker. + +PROGRAM(llvm-tblgen) + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm12 + contrib/libs/llvm12/lib/Demangle + contrib/libs/llvm12/lib/Support + contrib/libs/llvm12/lib/TableGen + contrib/libs/llvm12/utils/TableGen/GlobalISel +) + +ADDINCL( + contrib/libs/llvm12/utils/TableGen +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + AsmMatcherEmitter.cpp + AsmWriterEmitter.cpp + AsmWriterInst.cpp + Attributes.cpp + CTagsEmitter.cpp + CallingConvEmitter.cpp + CodeEmitterGen.cpp + CodeGenDAGPatterns.cpp + CodeGenHwModes.cpp + CodeGenInstruction.cpp + CodeGenMapTable.cpp + CodeGenRegisters.cpp + CodeGenSchedule.cpp + CodeGenTarget.cpp + DAGISelEmitter.cpp + DAGISelMatcher.cpp + DAGISelMatcherEmitter.cpp + DAGISelMatcherGen.cpp + DAGISelMatcherOpt.cpp + DFAEmitter.cpp + DFAPacketizerEmitter.cpp + DirectiveEmitter.cpp + DisassemblerEmitter.cpp + ExegesisEmitter.cpp + FastISelEmitter.cpp + FixedLenDecoderEmitter.cpp + GICombinerEmitter.cpp + GlobalISelEmitter.cpp + InfoByHwMode.cpp + InstrDocsEmitter.cpp + InstrInfoEmitter.cpp + IntrinsicEmitter.cpp + OptEmitter.cpp + OptParserEmitter.cpp + OptRSTEmitter.cpp + PredicateExpander.cpp + PseudoLoweringEmitter.cpp + RISCVCompressInstEmitter.cpp + RegisterBankEmitter.cpp + RegisterInfoEmitter.cpp + SDNodeProperties.cpp + SearchableTableEmitter.cpp + SubtargetEmitter.cpp + SubtargetFeatureInfo.cpp + TableGen.cpp + Types.cpp + WebAssemblyDisassemblerEmitter.cpp + X86DisassemblerTables.cpp + X86EVEX2VEXTablesEmitter.cpp + X86FoldTablesEmitter.cpp + X86ModRMFilters.cpp + X86RecognizableInstr.cpp +) + +END() diff --git a/contrib/libs/llvm12/ya.make b/contrib/libs/llvm12/ya.make new file mode 100644 index 00000000000..fa17df6b8e5 --- /dev/null +++ b/contrib/libs/llvm12/ya.make @@ -0,0 +1,204 @@ +# Generated by devtools/yamaker from nixpkgs 21.11. + +LIBRARY() + +LICENSE( + Apache-2.0 WITH LLVM-exception AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(12.0.1) + +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/llvm-12.0.1.src.tar.xz) + +ADDINCL( + GLOBAL ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/include + GLOBAL contrib/libs/llvm12/include +) + +END() + +RECURSE( + include + lib/Analysis + lib/AsmParser + lib/BinaryFormat + lib/Bitcode/Reader + lib/Bitcode/Writer + lib/Bitstream/Reader + lib/CodeGen + lib/CodeGen/AsmPrinter + lib/CodeGen/GlobalISel + lib/CodeGen/MIRParser + lib/CodeGen/SelectionDAG + lib/DWARFLinker + lib/DebugInfo/CodeView + lib/DebugInfo/DWARF + lib/DebugInfo/GSYM + lib/DebugInfo/MSF + lib/DebugInfo/PDB + lib/DebugInfo/Symbolize + lib/Demangle + lib/ExecutionEngine + lib/ExecutionEngine/Interpreter + lib/ExecutionEngine/JITLink + lib/ExecutionEngine/MCJIT + lib/ExecutionEngine/Orc + lib/ExecutionEngine/Orc/Shared + lib/ExecutionEngine/Orc/TargetProcess + lib/ExecutionEngine/RuntimeDyld + lib/Extensions + lib/FileCheck + lib/Frontend/OpenACC + lib/Frontend/OpenMP + lib/FuzzMutate + lib/IR + lib/IRReader + lib/InterfaceStub + lib/LTO + lib/LineEditor + lib/Linker + lib/MC + lib/MC/MCDisassembler + lib/MC/MCParser + lib/MCA + lib/Object + lib/ObjectYAML + lib/Option + lib/Passes + lib/ProfileData + lib/ProfileData/Coverage + lib/Remarks + lib/Support + lib/TableGen + lib/Target + lib/Target/AArch64 + lib/Target/AArch64/AsmParser + lib/Target/AArch64/Disassembler + lib/Target/AArch64/MCTargetDesc + lib/Target/AArch64/TargetInfo + lib/Target/AArch64/Utils + lib/Target/ARM + lib/Target/ARM/AsmParser + lib/Target/ARM/Disassembler + lib/Target/ARM/MCTargetDesc + lib/Target/ARM/TargetInfo + lib/Target/ARM/Utils + lib/Target/BPF + lib/Target/BPF/AsmParser + lib/Target/BPF/Disassembler + lib/Target/BPF/MCTargetDesc + lib/Target/BPF/TargetInfo + lib/Target/NVPTX + lib/Target/NVPTX/MCTargetDesc + lib/Target/NVPTX/TargetInfo + lib/Target/PowerPC + lib/Target/PowerPC/AsmParser + lib/Target/PowerPC/Disassembler + lib/Target/PowerPC/MCTargetDesc + lib/Target/PowerPC/TargetInfo + lib/Target/X86 + lib/Target/X86/AsmParser + lib/Target/X86/Disassembler + lib/Target/X86/MCTargetDesc + lib/Target/X86/TargetInfo + lib/TextAPI/MachO + lib/ToolDrivers/llvm-dlltool + lib/ToolDrivers/llvm-lib + lib/Transforms/AggressiveInstCombine + lib/Transforms/CFGuard + lib/Transforms/Coroutines + lib/Transforms/HelloNew + lib/Transforms/IPO + lib/Transforms/InstCombine + lib/Transforms/Instrumentation + lib/Transforms/ObjCARC + lib/Transforms/Scalar + lib/Transforms/Utils + lib/Transforms/Vectorize + lib/WindowsManifest + lib/XRay + tools/bugpoint + tools/dsymutil + tools/llc + tools/lli + tools/lli/ChildTarget + tools/llvm-ar + tools/llvm-as + tools/llvm-bcanalyzer + tools/llvm-cat + tools/llvm-cfi-verify + tools/llvm-cfi-verify/lib + tools/llvm-config + tools/llvm-cov + tools/llvm-cvtres + tools/llvm-cxxdump + tools/llvm-cxxfilt + tools/llvm-cxxmap + tools/llvm-diff + tools/llvm-dis + tools/llvm-dwarfdump + tools/llvm-dwp + tools/llvm-elfabi + tools/llvm-exegesis + tools/llvm-exegesis/lib + tools/llvm-exegesis/lib/AArch64 + tools/llvm-exegesis/lib/PowerPC + tools/llvm-exegesis/lib/X86 + tools/llvm-extract + tools/llvm-gsymutil + tools/llvm-ifs + tools/llvm-jitlink + tools/llvm-jitlink/llvm-jitlink-executor + tools/llvm-libtool-darwin + tools/llvm-link + tools/llvm-lipo + tools/llvm-lto + tools/llvm-lto2 + tools/llvm-mc + tools/llvm-mca + tools/llvm-ml + tools/llvm-modextract + tools/llvm-mt + tools/llvm-nm + tools/llvm-objcopy + tools/llvm-objdump + tools/llvm-opt-report + tools/llvm-pdbutil + tools/llvm-profdata + tools/llvm-profgen + tools/llvm-rc + tools/llvm-readobj + tools/llvm-reduce + tools/llvm-rtdyld + tools/llvm-size + tools/llvm-split + tools/llvm-stress + tools/llvm-strings + tools/llvm-symbolizer + tools/llvm-undname + tools/llvm-xray + tools/lto + tools/obj2yaml + tools/opt + tools/polly/lib + tools/polly/lib/External/isl + tools/polly/lib/External/ppcg + tools/remarks-shlib + tools/sancov + tools/sanstats + tools/split-file + tools/verify-uselistorder + tools/yaml2obj + utils/TableGen + utils/TableGen/GlobalISel +) + +IF (OS_LINUX) + RECURSE( + lib/ExecutionEngine/PerfJITEvents + tools/gold + ) +ENDIF() diff --git a/contrib/libs/lua/ya.make b/contrib/libs/lua/ya.make new file mode 100644 index 00000000000..942562d2db1 --- /dev/null +++ b/contrib/libs/lua/ya.make @@ -0,0 +1,46 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(5.2.0) + +PROVIDES(lua) + +NO_COMPILER_WARNINGS() + +IF (OS_LINUX) + CFLAGS(-DLUA_USE_LINUX) +ELSEIF (OS_FREEBSD) + CFLAGS(-DLUA_USE_LINUX) +ELSEIF (OS_DARWIN) + CFLAGS(-DLUA_USE_MACOSX) +ELSEIF (OS_WINDOWS) + CFLAGS(-DLUA_WIN) +ELSE() + CFLAGS( + -DLUA_USE_POSIX + -DLUA_USE_DLOPEN + ) +ENDIF() + +ADDINCL(contrib/libs/lua/lua-5.2.0/src) + +SRCDIR(contrib/libs/lua/lua-5.2.0/src) + +ARCHIVE( + NAME common.inc + common/stdlib.lua + common/json.lua +) + +PEERDIR( + library/cpp/archive +) + +SRCS( + lib.cpp +) + +END() diff --git a/contrib/libs/lz4/ya.make b/contrib/libs/lz4/ya.make new file mode 100644 index 00000000000..fa735a4a6d7 --- /dev/null +++ b/contrib/libs/lz4/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +VERSION(1.9.4) + +ORIGINAL_SOURCE(https://github.com/lz4/lz4/archive/v1.9.4.tar.gz) + +LICENSE( + BSD-2-Clause AND + BSD-3-Clause +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/xxhash +) + +ADDINCL( + contrib/libs/xxhash +) + +NO_RUNTIME() + +SRCS( + lz4.c + lz4file.c + lz4frame.c + lz4hc.c +) + +END() diff --git a/contrib/libs/lzma/ya.make b/contrib/libs/lzma/ya.make new file mode 100644 index 00000000000..245d3d88be7 --- /dev/null +++ b/contrib/libs/lzma/ya.make @@ -0,0 +1,119 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(Public-Domain) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(5.4.0) + +ORIGINAL_SOURCE(https://tukaani.org/xz/xz-5.4.0.tar.bz2) + +ADDINCL( + GLOBAL contrib/libs/lzma/liblzma/api + contrib/libs/lzma/common + contrib/libs/lzma/liblzma + contrib/libs/lzma/liblzma/check + contrib/libs/lzma/liblzma/common + contrib/libs/lzma/liblzma/delta + contrib/libs/lzma/liblzma/lz + contrib/libs/lzma/liblzma/lzma + contrib/libs/lzma/liblzma/rangecoder + contrib/libs/lzma/liblzma/simple +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + -DTUKLIB_SYMBOL_PREFIX=lzma_ + GLOBAL -DLZMA_API_STATIC +) + +SRCS( + common/tuklib_cpucores.c + common/tuklib_physmem.c + liblzma/check/check.c + liblzma/check/crc32_fast.c + liblzma/check/crc32_table.c + liblzma/check/crc64_fast.c + liblzma/check/crc64_table.c + liblzma/check/sha256.c + liblzma/common/alone_decoder.c + liblzma/common/alone_encoder.c + liblzma/common/auto_decoder.c + liblzma/common/block_buffer_decoder.c + liblzma/common/block_buffer_encoder.c + liblzma/common/block_decoder.c + liblzma/common/block_encoder.c + liblzma/common/block_header_decoder.c + liblzma/common/block_header_encoder.c + liblzma/common/block_util.c + liblzma/common/common.c + liblzma/common/easy_buffer_encoder.c + liblzma/common/easy_decoder_memusage.c + liblzma/common/easy_encoder.c + liblzma/common/easy_encoder_memusage.c + liblzma/common/easy_preset.c + liblzma/common/file_info.c + liblzma/common/filter_buffer_decoder.c + liblzma/common/filter_buffer_encoder.c + liblzma/common/filter_common.c + liblzma/common/filter_decoder.c + liblzma/common/filter_encoder.c + liblzma/common/filter_flags_decoder.c + liblzma/common/filter_flags_encoder.c + liblzma/common/hardware_cputhreads.c + liblzma/common/hardware_physmem.c + liblzma/common/index.c + liblzma/common/index_decoder.c + liblzma/common/index_encoder.c + liblzma/common/index_hash.c + liblzma/common/lzip_decoder.c + liblzma/common/microlzma_decoder.c + liblzma/common/microlzma_encoder.c + liblzma/common/outqueue.c + liblzma/common/stream_buffer_decoder.c + liblzma/common/stream_buffer_encoder.c + liblzma/common/stream_decoder.c + liblzma/common/stream_decoder_mt.c + liblzma/common/stream_encoder.c + liblzma/common/stream_encoder_mt.c + liblzma/common/stream_flags_common.c + liblzma/common/stream_flags_decoder.c + liblzma/common/stream_flags_encoder.c + liblzma/common/string_conversion.c + liblzma/common/vli_decoder.c + liblzma/common/vli_encoder.c + liblzma/common/vli_size.c + liblzma/delta/delta_common.c + liblzma/delta/delta_decoder.c + liblzma/delta/delta_encoder.c + liblzma/lz/lz_decoder.c + liblzma/lz/lz_encoder.c + liblzma/lz/lz_encoder_mf.c + liblzma/lzma/fastpos_table.c + liblzma/lzma/lzma2_decoder.c + liblzma/lzma/lzma2_encoder.c + liblzma/lzma/lzma_decoder.c + liblzma/lzma/lzma_encoder.c + liblzma/lzma/lzma_encoder_optimum_fast.c + liblzma/lzma/lzma_encoder_optimum_normal.c + liblzma/lzma/lzma_encoder_presets.c + liblzma/rangecoder/price_table.c + liblzma/simple/arm.c + liblzma/simple/arm64.c + liblzma/simple/armthumb.c + liblzma/simple/ia64.c + liblzma/simple/powerpc.c + liblzma/simple/simple_coder.c + liblzma/simple/simple_decoder.c + liblzma/simple/simple_encoder.c + liblzma/simple/sparc.c + liblzma/simple/x86.c +) + +END() diff --git a/contrib/libs/lzmasdk/ya.make b/contrib/libs/lzmasdk/ya.make new file mode 100644 index 00000000000..eea4951ce08 --- /dev/null +++ b/contrib/libs/lzmasdk/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +LICENSE(Public-Domain) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +# https://www.7-zip.org/sdk.html +VERSION(19.00) + +CFLAGS(-D_7ZIP_ST=1) + +NO_UTIL() + +SRCS( + 7zStream.c + Aes.c + AesOpt.c + Alloc.c + Bra.c + Bra86.c + BraIA64.c + CpuArch.c + LzFind.c + Lzma2Dec.c + Lzma2Enc.c + LzmaDec.c + LzmaEnc.c + LzmaLib.c + Sha256.c +) + +END() diff --git a/contrib/libs/mimalloc/ya.make b/contrib/libs/mimalloc/ya.make new file mode 100644 index 00000000000..b23b8c23942 --- /dev/null +++ b/contrib/libs/mimalloc/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +CFLAGS( + -w + -DMI_MALLOC_OVERRIDE=1 + -DMI_PADDING=0 +) + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.7.2) + +ADDINCL(contrib/libs/mimalloc/include) +NO_UTIL() +SRCS( + src/static.c +) + +END() diff --git a/contrib/libs/miniselect/ya.make b/contrib/libs/miniselect/ya.make new file mode 100644 index 00000000000..6369cc4645e --- /dev/null +++ b/contrib/libs/miniselect/ya.make @@ -0,0 +1,17 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + MIT AND + Zlib +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.4.0) + +ORIGINAL_SOURCE(https://github.com/danlark1/miniselect/archive/0.4.0.tar.gz) + +END() diff --git a/contrib/libs/nayuki_md5/ya.make b/contrib/libs/nayuki_md5/ya.make new file mode 100644 index 00000000000..a76caeace00 --- /dev/null +++ b/contrib/libs/nayuki_md5/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2016) + +ORIGINAL_SOURCE(https://www.nayuki.io/page/fast-md5-hash-implementation-in-x86-assembly) + +IF (OS_LINUX AND ARCH_X86_64) + SRCS( + md5-fast-x8664.S + ) +ELSE() + SRCS( + md5.c + ) +ENDIF() + +END() diff --git a/contrib/libs/nghttp2/ya.make b/contrib/libs/nghttp2/ya.make new file mode 100644 index 00000000000..ecff52c06ed --- /dev/null +++ b/contrib/libs/nghttp2/ya.make @@ -0,0 +1,58 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + FSFAP AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.53.0) + +ORIGINAL_SOURCE(https://github.com/nghttp2/nghttp2/archive/v1.53.0.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/nghttp2/lib/includes + contrib/libs/nghttp2 + contrib/libs/nghttp2/lib +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DBUILDING_NGHTTP2 + -DHAVE_CONFIG_H +) + +SRCS( + lib/nghttp2_buf.c + lib/nghttp2_callbacks.c + lib/nghttp2_debug.c + lib/nghttp2_extpri.c + lib/nghttp2_frame.c + lib/nghttp2_hd.c + lib/nghttp2_hd_huffman.c + lib/nghttp2_hd_huffman_data.c + lib/nghttp2_helper.c + lib/nghttp2_http.c + lib/nghttp2_map.c + lib/nghttp2_mem.c + lib/nghttp2_npn.c + lib/nghttp2_option.c + lib/nghttp2_outbound_item.c + lib/nghttp2_pq.c + lib/nghttp2_priority_spec.c + lib/nghttp2_queue.c + lib/nghttp2_rcbuf.c + lib/nghttp2_session.c + lib/nghttp2_stream.c + lib/nghttp2_submit.c + lib/nghttp2_version.c + lib/sfparse.c +) + +END() diff --git a/contrib/libs/openssl/apps/ya.make b/contrib/libs/openssl/apps/ya.make new file mode 100644 index 00000000000..5b30a9f7351 --- /dev/null +++ b/contrib/libs/openssl/apps/ya.make @@ -0,0 +1,166 @@ +PROGRAM(openssl) + +LICENSE( + OpenSSL AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/openssl + contrib/libs/openssl/crypto +) + +ADDINCL( + contrib/libs/openssl + contrib/libs/openssl/apps + contrib/libs/openssl/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DAESNI_ASM + -DECP_NISTZ256_ASM + -DKECCAK1600_ASM + -DOPENSSL_BN_ASM_MONT + -DOPENSSL_CPUID_OBJ + -DOPENSSL_PIC + -DPOLY1305_ASM + -DSHA1_ASM + -DSHA256_ASM + -DSHA512_ASM + -DVPAES_ASM + -DZLIB +) + +IF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64) + CFLAGS( + -DENGINESDIR=\"/usr/local/lib/engines-1.1\" + -DOPENSSLDIR=\"/usr/local/ssl\" + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND ARCH_X86_64) + CFLAGS( + -DGHASH_ASM + -DL_ENDIAN + -DMD5_ASM + -DOPENSSL_BN_ASM_GF2m + -DOPENSSL_BN_ASM_MONT5 + -DOPENSSL_IA32_SSE2 + -DPADLOCK_ASM + -DRC4_ASM + -DX25519_ASM + ) +ENDIF() + +IF (OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64) + CFLAGS( + -DOPENSSL_USE_NODELETE + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64) + CFLAGS( + -D_REENTRANT + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_ARM64) + CFLAGS( + -DL_ENDIAN + -DOPENSSL_PIC + -D_REENTRANT + ) +ENDIF() + +IF (OS_WINDOWS) + IF (ARCH_X86_64) + CFLAGS( + -DENGINESDIR="\"C:\\\\Program\ Files\\\\OpenSSL\\\\lib\\\\engines-1_1\"" + -DOPENSSLDIR="\"C:\\\\Program\ Files\\\\Common\ Files\\\\SSL\"" + ) + ELSEIF (ARCH_I386) + CFLAGS( + -DENGINESDIR="\"C:\\\\Program\ Files\ \(x86\)\\\\OpenSSL\\\\lib\\\\engines-1_1\"" + -DOPENSSLDIR="\"C:\\\\Program\ Files\ \(x86\)\\\\Common\ Files\\\\SSL\"" + ) + ENDIF() + CFLAGS( + -DOPENSSL_SYS_WIN32 + -DUNICODE + -DWIN32_LEAN_AND_MEAN + -D_CRT_SECURE_NO_DEPRECATE + -D_UNICODE + -D_WINSOCK_DEPRECATED_NO_WARNINGS + /GF + ) +ENDIF() + +SRCS( + app_rand.c + apps.c + asn1pars.c + bf_prefix.c + ca.c + ciphers.c + cms.c + crl.c + crl2p7.c + dgst.c + dhparam.c + dsa.c + dsaparam.c + ec.c + ecparam.c + enc.c + engine.c + errstr.c + gendsa.c + genpkey.c + genrsa.c + nseq.c + ocsp.c + openssl.c + opt.c + passwd.c + pkcs12.c + pkcs7.c + pkcs8.c + pkey.c + pkeyparam.c + pkeyutl.c + prime.c + rand.c + rehash.c + req.c + rsa.c + rsautl.c + s_cb.c + s_client.c + s_server.c + s_socket.c + s_time.c + sess_id.c + smime.c + speed.c + spkac.c + srp.c + storeutl.c + ts.c + verify.c + version.c + x509.c +) + +IF (OS_WINDOWS) + SRCS( + win32_init.c + ) +ENDIF() + +END() diff --git a/contrib/libs/openssl/crypto/ya.make b/contrib/libs/openssl/crypto/ya.make new file mode 100644 index 00000000000..721348592bc --- /dev/null +++ b/contrib/libs/openssl/crypto/ya.make @@ -0,0 +1,1379 @@ +LIBRARY() + +LICENSE( + Apache-2.0 AND + BSD-2-Clause AND + BSD-3-Clause AND + BSD-Source-Code AND + CC0-1.0 AND + OpenSSL AND + Public-Domain AND + Snprintf +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +OPENSOURCE_EXPORT_REPLACEMENT( + CMAKE OpenSSL + CMAKE_PACKAGE_COMPONENT Crypto + CMAKE_TARGET OpenSSL::Crypto + CONAN openssl/1.1.1l +) + +PEERDIR( + contrib/libs/zlib +) + +ADDINCL( + contrib/libs/openssl + contrib/libs/openssl/crypto + contrib/libs/openssl/crypto/ec/curve448 + contrib/libs/openssl/crypto/ec/curve448/arch_32 + contrib/libs/openssl/crypto/modes + contrib/libs/openssl/include +) + +IF (NOT EXPORT_CMAKE) + +IF (OS_LINUX) + IF (ARCH_ARM64) + SET(LINUX_ARM64 yes) + ELSEIF (ARCH_ARM7) + SET(LINUX_ARMV7 yes) + ELSEIF (ARCH_X86_64) + SET(LINUX_X86_64 yes) + ENDIF() +ENDIF() + +IF (OS_IOS) + IF (ARCH_ARM64) + SET(IOS_ARM64 yes) + ELSEIF (ARCH_ARM7) + SET(IOS_ARMV7 yes) + ELSEIF (ARCH_X86_64) + SET(IOS_X86_64 yes) + ELSEIF (ARCH_I386) + SET(IOS_I386 yes) + ENDIF() +ENDIF() + +IF (OS_ANDROID) + IF (ARCH_ARM64) + SET(ANDROID_ARM64 yes) + ELSEIF (ARCH_ARM7) + SET(ANDROID_ARMV7 yes) + ELSEIF (ARCH_X86_64) + SET(ANDROID_X86_64 yes) + ELSEIF (ARCH_I686) + SET(ANDROID_I686 yes) + ENDIF() +ENDIF() + +IF (OS_WINDOWS) + IF (ARCH_X86_64) + SET(WINDOWS_X86_64 yes) + ELSEIF (ARCH_I686) + SET(WINDOWS_I686 yes) + ENDIF() +ENDIF() + +IF (OS_DARWIN AND ARCH_ARM64) + SET(DARWIN_ARM64 yes) +ENDIF() + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DOPENSSL_BN_ASM_MONT + -DOPENSSL_CPUID_OBJ + -DSHA1_ASM + -DSHA256_ASM + -DSHA512_ASM + -DZLIB +) + +IF (NOT OS_IOS AND NOT DARWIN_ARM64) + CFLAGS( + -DDSO_NONE + -DAESNI_ASM + ) +ENDIF() + +IF (NOT WINDOWS_I686) + CFLAGS( + -DECP_NISTZ256_ASM + -DPOLY1305_ASM + ) +ENDIF() + +IF (NOT IOS_I386 AND NOT ANDROID_I686 AND NOT WINDOWS_I686) + CFLAGS( + -DKECCAK1600_ASM + ) +ENDIF() + +IF (NOT IOS_ARMV7 AND NOT ANDROID_ARMV7 AND NOT LINUX_ARMV7) + CFLAGS( + -DVPAES_ASM + ) +ENDIF() + +IF (NOT OS_WINDOWS) + CFLAGS( + -DENGINESDIR=\"/usr/local/lib/engines-1.1\" + -DOPENSSLDIR=\"/usr/local/ssl\" + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND ARCH_X86_64) + CFLAGS( + -DGHASH_ASM + -DL_ENDIAN + -DMD5_ASM + -DOPENSSL_BN_ASM_GF2m + -DOPENSSL_BN_ASM_MONT5 + -DOPENSSL_IA32_SSE2 + -DRC4_ASM + -DX25519_ASM + ) +ENDIF() + +IF (OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64) + CFLAGS( + -DOPENSSL_USE_NODELETE + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64) + CFLAGS( + -D_REENTRANT + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_ARM64) + CFLAGS( + -DL_ENDIAN + -DOPENSSL_PIC + -D_REENTRANT + ) +ENDIF() + +IF (OS_WINDOWS) + IF (ARCH_X86_64) + CFLAGS( + -DENGINESDIR="\"C:\\\\Program\ Files\\\\OpenSSL\\\\lib\\\\engines-1_1\"" + -DOPENSSLDIR="\"C:\\\\Program\ Files\\\\Common\ Files\\\\SSL\"" + ) + ELSEIF (ARCH_I386) + CFLAGS( + -DENGINESDIR="\"C:\\\\Program\ Files\ \(x86\)\\\\OpenSSL\\\\lib\\\\engines-1_1\"" + -DOPENSSLDIR="\"C:\\\\Program\ Files\ \(x86\)\\\\Common\ Files\\\\SSL\"" + ) + ENDIF() + CFLAGS( + -DOPENSSL_SYS_WIN32 + -DUNICODE + -DWIN32_LEAN_AND_MEAN + -D_CRT_SECURE_NO_DEPRECATE + -D_UNICODE + -D_WINSOCK_DEPRECATED_NO_WARNINGS + /GF + ) +ENDIF() + +IF (SANITIZER_TYPE == memory) + CFLAGS( + -DPURIFY + ) +ENDIF() + +IF (MUSL) + CFLAGS( + -DOPENSSL_NO_ASYNC + ) +ENDIF() + +IF (ARCH_TYPE_32) + CFLAGS( + -DOPENSSL_NO_EC_NISTP_64_GCC_128 + ) +ENDIF() + +IF (ARCH_X86_64 AND NOT MSVC) + SET_APPEND( + SFLAGS + -mavx512bw + -mavx512ifma + -mavx512vl + ) +ENDIF() + +SRCS( + aes/aes_cbc.c + aes/aes_cfb.c + aes/aes_ecb.c + aes/aes_ige.c + aes/aes_misc.c + aes/aes_ofb.c + aes/aes_wrap.c + aria/aria.c + asn1/a_bitstr.c + asn1/a_d2i_fp.c + asn1/a_digest.c + asn1/a_dup.c + asn1/a_gentm.c + asn1/a_i2d_fp.c + asn1/a_int.c + asn1/a_mbstr.c + asn1/a_object.c + asn1/a_octet.c + asn1/a_print.c + asn1/a_sign.c + asn1/a_strex.c + asn1/a_strnid.c + asn1/a_time.c + asn1/a_type.c + asn1/a_utctm.c + asn1/a_utf8.c + asn1/a_verify.c + asn1/ameth_lib.c + asn1/asn1_err.c + asn1/asn1_gen.c + asn1/asn1_item_list.c + asn1/asn1_lib.c + asn1/asn1_par.c + asn1/asn_mime.c + asn1/asn_moid.c + asn1/asn_mstbl.c + asn1/asn_pack.c + asn1/bio_asn1.c + asn1/bio_ndef.c + asn1/d2i_pr.c + asn1/d2i_pu.c + asn1/evp_asn1.c + asn1/f_int.c + asn1/f_string.c + asn1/i2d_pr.c + asn1/i2d_pu.c + asn1/n_pkey.c + asn1/nsseq.c + asn1/p5_pbe.c + asn1/p5_pbev2.c + asn1/p5_scrypt.c + asn1/p8_pkey.c + asn1/t_bitst.c + asn1/t_pkey.c + asn1/t_spki.c + asn1/tasn_dec.c + asn1/tasn_enc.c + asn1/tasn_fre.c + asn1/tasn_new.c + asn1/tasn_prn.c + asn1/tasn_scn.c + asn1/tasn_typ.c + asn1/tasn_utl.c + asn1/x_algor.c + asn1/x_bignum.c + asn1/x_info.c + asn1/x_int64.c + asn1/x_long.c + asn1/x_pkey.c + asn1/x_sig.c + asn1/x_spki.c + asn1/x_val.c + async/arch/async_null.c + async/arch/async_posix.c + async/arch/async_win.c + async/async.c + async/async_err.c + async/async_wait.c + bf/bf_cfb64.c + bf/bf_ecb.c + bf/bf_ofb64.c + bf/bf_skey.c + bio/b_addr.c + bio/b_dump.c + bio/b_print.c + bio/b_sock.c + bio/b_sock2.c + bio/bf_buff.c + bio/bf_lbuf.c + bio/bf_nbio.c + bio/bf_null.c + bio/bio_cb.c + bio/bio_err.c + bio/bio_lib.c + bio/bio_meth.c + bio/bss_acpt.c + bio/bss_bio.c + bio/bss_conn.c + bio/bss_dgram.c + bio/bss_fd.c + bio/bss_file.c + bio/bss_log.c + bio/bss_mem.c + bio/bss_null.c + bio/bss_sock.c + blake2/blake2b.c + blake2/blake2s.c + blake2/m_blake2b.c + blake2/m_blake2s.c + bn/bn_add.c + bn/bn_blind.c + bn/bn_const.c + bn/bn_ctx.c + bn/bn_depr.c + bn/bn_dh.c + bn/bn_div.c + bn/bn_err.c + bn/bn_exp.c + bn/bn_exp2.c + bn/bn_gcd.c + bn/bn_gf2m.c + bn/bn_intern.c + bn/bn_kron.c + bn/bn_lib.c + bn/bn_mod.c + bn/bn_mont.c + bn/bn_mpi.c + bn/bn_mul.c + bn/bn_nist.c + bn/bn_prime.c + bn/bn_print.c + bn/bn_rand.c + bn/bn_recp.c + bn/bn_shift.c + bn/bn_sqr.c + bn/bn_sqrt.c + bn/bn_srp.c + bn/bn_word.c + bn/bn_x931p.c + buffer/buf_err.c + buffer/buffer.c + camellia/cmll_cfb.c + camellia/cmll_ctr.c + camellia/cmll_ecb.c + camellia/cmll_ofb.c + cast/c_cfb64.c + cast/c_ecb.c + cast/c_enc.c + cast/c_ofb64.c + cast/c_skey.c + cmac/cm_ameth.c + cmac/cm_pmeth.c + cmac/cmac.c + cms/cms_asn1.c + cms/cms_att.c + cms/cms_cd.c + cms/cms_dd.c + cms/cms_enc.c + cms/cms_env.c + cms/cms_err.c + cms/cms_ess.c + cms/cms_io.c + cms/cms_kari.c + cms/cms_lib.c + cms/cms_pwri.c + cms/cms_sd.c + cms/cms_smime.c + comp/c_zlib.c + comp/comp_err.c + comp/comp_lib.c + conf/conf_api.c + conf/conf_def.c + conf/conf_err.c + conf/conf_lib.c + conf/conf_mall.c + conf/conf_mod.c + conf/conf_sap.c + conf/conf_ssl.c + cpt_err.c + cryptlib.c + ct/ct_b64.c + ct/ct_err.c + ct/ct_log.c + ct/ct_oct.c + ct/ct_policy.c + ct/ct_prn.c + ct/ct_sct.c + ct/ct_sct_ctx.c + ct/ct_vfy.c + ct/ct_x509v3.c + ctype.c + cversion.c + des/cbc_cksm.c + des/cbc_enc.c + des/cfb64ede.c + des/cfb64enc.c + des/cfb_enc.c + des/ecb3_enc.c + des/ecb_enc.c + des/fcrypt.c + des/ofb64ede.c + des/ofb64enc.c + des/ofb_enc.c + des/pcbc_enc.c + des/qud_cksm.c + des/rand_key.c + des/set_key.c + des/str2key.c + des/xcbc_enc.c + dh/dh_ameth.c + dh/dh_asn1.c + dh/dh_check.c + dh/dh_depr.c + dh/dh_err.c + dh/dh_gen.c + dh/dh_kdf.c + dh/dh_key.c + dh/dh_lib.c + dh/dh_meth.c + dh/dh_pmeth.c + dh/dh_prn.c + dh/dh_rfc5114.c + dh/dh_rfc7919.c + dsa/dsa_ameth.c + dsa/dsa_asn1.c + dsa/dsa_depr.c + dsa/dsa_err.c + dsa/dsa_gen.c + dsa/dsa_key.c + dsa/dsa_lib.c + dsa/dsa_meth.c + dsa/dsa_ossl.c + dsa/dsa_pmeth.c + dsa/dsa_prn.c + dsa/dsa_sign.c + dsa/dsa_vrf.c + dso/dso_dl.c + dso/dso_err.c + dso/dso_lib.c + dso/dso_openssl.c + dso/dso_vms.c + dso/dso_win32.c + ebcdic.c + ec/curve25519.c + ec/curve448/arch_32/f_impl.c + ec/curve448/curve448.c + ec/curve448/curve448_tables.c + ec/curve448/eddsa.c + ec/curve448/f_generic.c + ec/curve448/scalar.c + ec/ec2_oct.c + ec/ec2_smpl.c + ec/ec_ameth.c + ec/ec_asn1.c + ec/ec_check.c + ec/ec_curve.c + ec/ec_cvt.c + ec/ec_err.c + ec/ec_key.c + ec/ec_kmeth.c + ec/ec_lib.c + ec/ec_mult.c + ec/ec_oct.c + ec/ec_pmeth.c + ec/ec_print.c + ec/ecdh_kdf.c + ec/ecdh_ossl.c + ec/ecdsa_ossl.c + ec/ecdsa_sign.c + ec/ecdsa_vrf.c + ec/eck_prn.c + ec/ecp_mont.c + ec/ecp_nist.c + ec/ecp_nistp224.c + ec/ecp_nistp256.c + ec/ecp_nistp521.c + ec/ecp_nistputil.c + ec/ecp_oct.c + ec/ecp_smpl.c + ec/ecx_meth.c + engine/eng_all.c + engine/eng_cnf.c + engine/eng_ctrl.c + engine/eng_dyn.c + engine/eng_err.c + engine/eng_fat.c + engine/eng_init.c + engine/eng_lib.c + engine/eng_list.c + engine/eng_openssl.c + engine/eng_pkey.c + engine/eng_rdrand.c + engine/eng_table.c + engine/tb_asnmth.c + engine/tb_cipher.c + engine/tb_dh.c + engine/tb_digest.c + engine/tb_dsa.c + engine/tb_eckey.c + engine/tb_pkmeth.c + engine/tb_rand.c + engine/tb_rsa.c + err/err.c + err/err_all.c + err/err_prn.c + evp/bio_b64.c + evp/bio_enc.c + evp/bio_md.c + evp/bio_ok.c + evp/c_allc.c + evp/c_alld.c + evp/cmeth_lib.c + evp/digest.c + evp/e_aes.c + evp/e_aes_cbc_hmac_sha1.c + evp/e_aes_cbc_hmac_sha256.c + evp/e_aria.c + evp/e_bf.c + evp/e_camellia.c + evp/e_cast.c + evp/e_chacha20_poly1305.c + evp/e_des.c + evp/e_des3.c + evp/e_idea.c + evp/e_null.c + evp/e_old.c + evp/e_rc2.c + evp/e_rc4.c + evp/e_rc4_hmac_md5.c + evp/e_rc5.c + evp/e_seed.c + evp/e_sm4.c + evp/e_xcbc_d.c + evp/encode.c + evp/evp_cnf.c + evp/evp_enc.c + evp/evp_err.c + evp/evp_key.c + evp/evp_lib.c + evp/evp_pbe.c + evp/evp_pkey.c + evp/m_md2.c + evp/m_md4.c + evp/m_md5.c + evp/m_md5_sha1.c + evp/m_mdc2.c + evp/m_null.c + evp/m_ripemd.c + evp/m_sha1.c + evp/m_sha3.c + evp/m_sigver.c + evp/m_wp.c + evp/names.c + evp/p5_crpt.c + evp/p5_crpt2.c + evp/p_dec.c + evp/p_enc.c + evp/p_lib.c + evp/p_open.c + evp/p_seal.c + evp/p_sign.c + evp/p_verify.c + evp/pbe_scrypt.c + evp/pmeth_fn.c + evp/pmeth_gn.c + evp/pmeth_lib.c + ex_data.c + getenv.c + hmac/hm_ameth.c + hmac/hm_pmeth.c + hmac/hmac.c + idea/i_cbc.c + idea/i_cfb64.c + idea/i_ecb.c + idea/i_ofb64.c + idea/i_skey.c + init.c + kdf/hkdf.c + kdf/kdf_err.c + kdf/scrypt.c + kdf/tls1_prf.c + lhash/lh_stats.c + lhash/lhash.c + md4/md4_dgst.c + md4/md4_one.c + md5/md5_dgst.c + md5/md5_one.c + mdc2/mdc2_one.c + mdc2/mdc2dgst.c + mem.c + mem_dbg.c + mem_sec.c + modes/cbc128.c + modes/ccm128.c + modes/cfb128.c + modes/ctr128.c + modes/cts128.c + modes/gcm128.c + modes/ocb128.c + modes/ofb128.c + modes/wrap128.c + modes/xts128.c + o_dir.c + o_fips.c + o_fopen.c + o_init.c + o_str.c + o_time.c + objects/o_names.c + objects/obj_dat.c + objects/obj_err.c + objects/obj_lib.c + objects/obj_xref.c + ocsp/ocsp_asn.c + ocsp/ocsp_cl.c + ocsp/ocsp_err.c + ocsp/ocsp_ext.c + ocsp/ocsp_ht.c + ocsp/ocsp_lib.c + ocsp/ocsp_prn.c + ocsp/ocsp_srv.c + ocsp/ocsp_vfy.c + ocsp/v3_ocsp.c + pem/pem_all.c + pem/pem_err.c + pem/pem_info.c + pem/pem_lib.c + pem/pem_oth.c + pem/pem_pk8.c + pem/pem_pkey.c + pem/pem_sign.c + pem/pem_x509.c + pem/pem_xaux.c + pem/pvkfmt.c + pkcs12/p12_add.c + pkcs12/p12_asn.c + pkcs12/p12_attr.c + pkcs12/p12_crpt.c + pkcs12/p12_crt.c + pkcs12/p12_decr.c + pkcs12/p12_init.c + pkcs12/p12_key.c + pkcs12/p12_kiss.c + pkcs12/p12_mutl.c + pkcs12/p12_npas.c + pkcs12/p12_p8d.c + pkcs12/p12_p8e.c + pkcs12/p12_sbag.c + pkcs12/p12_utl.c + pkcs12/pk12err.c + pkcs7/bio_pk7.c + pkcs7/pk7_asn1.c + pkcs7/pk7_attr.c + pkcs7/pk7_doit.c + pkcs7/pk7_lib.c + pkcs7/pk7_mime.c + pkcs7/pk7_smime.c + pkcs7/pkcs7err.c + poly1305/poly1305.c + poly1305/poly1305_ameth.c + poly1305/poly1305_pmeth.c + rand/drbg_ctr.c + rand/drbg_lib.c + rand/rand_egd.c + rand/rand_err.c + rand/rand_lib.c + rand/rand_unix.c + rand/rand_win.c + rand/randfile.c + rc2/rc2_cbc.c + rc2/rc2_ecb.c + rc2/rc2_skey.c + rc2/rc2cfb64.c + rc2/rc2ofb64.c + ripemd/rmd_dgst.c + ripemd/rmd_one.c + rsa/rsa_ameth.c + rsa/rsa_asn1.c + rsa/rsa_chk.c + rsa/rsa_crpt.c + rsa/rsa_depr.c + rsa/rsa_err.c + rsa/rsa_gen.c + rsa/rsa_lib.c + rsa/rsa_meth.c + rsa/rsa_mp.c + rsa/rsa_none.c + rsa/rsa_oaep.c + rsa/rsa_ossl.c + rsa/rsa_pk1.c + rsa/rsa_pmeth.c + rsa/rsa_prn.c + rsa/rsa_pss.c + rsa/rsa_saos.c + rsa/rsa_sign.c + rsa/rsa_ssl.c + rsa/rsa_x931.c + rsa/rsa_x931g.c + seed/seed.c + seed/seed_cbc.c + seed/seed_cfb.c + seed/seed_ecb.c + seed/seed_ofb.c + sha/sha1_one.c + sha/sha1dgst.c + sha/sha256.c + sha/sha512.c + siphash/siphash.c + siphash/siphash_ameth.c + siphash/siphash_pmeth.c + sm2/sm2_crypt.c + sm2/sm2_err.c + sm2/sm2_pmeth.c + sm2/sm2_sign.c + sm3/m_sm3.c + sm3/sm3.c + sm4/sm4.c + srp/srp_lib.c + srp/srp_vfy.c + stack/stack.c + store/loader_file.c + store/store_err.c + store/store_init.c + store/store_lib.c + store/store_register.c + store/store_strings.c + threads_none.c + threads_pthread.c + threads_win.c + ts/ts_asn1.c + ts/ts_conf.c + ts/ts_err.c + ts/ts_lib.c + ts/ts_req_print.c + ts/ts_req_utils.c + ts/ts_rsp_print.c + ts/ts_rsp_sign.c + ts/ts_rsp_utils.c + ts/ts_rsp_verify.c + ts/ts_verify_ctx.c + txt_db/txt_db.c + ui/ui_err.c + ui/ui_lib.c + ui/ui_null.c + ui/ui_openssl.c + ui/ui_util.c + uid.c + whrlpool/wp_dgst.c + x509/by_dir.c + x509/by_file.c + x509/t_crl.c + x509/t_req.c + x509/t_x509.c + x509/x509_att.c + x509/x509_cmp.c + x509/x509_d2.c + x509/x509_def.c + x509/x509_err.c + x509/x509_ext.c + x509/x509_lu.c + x509/x509_meth.c + x509/x509_obj.c + x509/x509_r2x.c + x509/x509_req.c + x509/x509_set.c + x509/x509_trs.c + x509/x509_txt.c + x509/x509_v3.c + x509/x509_vfy.c + x509/x509_vpm.c + x509/x509cset.c + x509/x509name.c + x509/x509rset.c + x509/x509spki.c + x509/x509type.c + x509/x_all.c + x509/x_attrib.c + x509/x_crl.c + x509/x_exten.c + x509/x_name.c + x509/x_pubkey.c + x509/x_req.c + x509/x_x509.c + x509/x_x509a.c + x509v3/pcy_cache.c + x509v3/pcy_data.c + x509v3/pcy_lib.c + x509v3/pcy_map.c + x509v3/pcy_node.c + x509v3/pcy_tree.c + x509v3/v3_addr.c + x509v3/v3_admis.c + x509v3/v3_akey.c + x509v3/v3_akeya.c + x509v3/v3_alt.c + x509v3/v3_asid.c + x509v3/v3_bcons.c + x509v3/v3_bitst.c + x509v3/v3_conf.c + x509v3/v3_cpols.c + x509v3/v3_crld.c + x509v3/v3_enum.c + x509v3/v3_extku.c + x509v3/v3_genn.c + x509v3/v3_ia5.c + x509v3/v3_info.c + x509v3/v3_int.c + x509v3/v3_lib.c + x509v3/v3_ncons.c + x509v3/v3_pci.c + x509v3/v3_pcia.c + x509v3/v3_pcons.c + x509v3/v3_pku.c + x509v3/v3_pmaps.c + x509v3/v3_prn.c + x509v3/v3_purp.c + x509v3/v3_skey.c + x509v3/v3_sxnet.c + x509v3/v3_tlsf.c + x509v3/v3_utl.c + x509v3/v3err.c +) + +IF (NOT WINDOWS_I686) + SRCS( + ec/ecp_nistz256.c + ) +ENDIF() + +IF (NOT IOS_ARMV7 AND NOT ANDROID_ARMV7 AND NOT LINUX_ARMV7) + SRCS( + aes/aes_core.c + ) +ENDIF() + +IF (NOT IOS_I386 AND NOT ANDROID_I686 AND NOT WINDOWS_I686) + SRCS( + bf/bf_enc.c + camellia/cmll_misc.c + des/des_enc.c + des/fcrypt_b.c + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND ARCH_X86_64) + SRCS( + bn/rsaz_exp.c + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64) + SRCS( + bn/asm/x86_64-gcc.c + ) +ENDIF() + +IF (OS_LINUX AND ARCH_AARCH64 OR OS_WINDOWS AND ARCH_X86_64 OR OS_LINUX AND ARCH_PPC64LE) + SRCS( + bn/bn_asm.c + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64) + SRCS( + ../asm/darwin/crypto/aes/aesni-mb-x86_64.s + ../asm/darwin/crypto/aes/aesni-sha1-x86_64.s + ../asm/darwin/crypto/aes/aesni-sha256-x86_64.s + ../asm/darwin/crypto/aes/aesni-x86_64.s + ../asm/darwin/crypto/aes/vpaes-x86_64.s + ../asm/darwin/crypto/bn/rsaz-avx2.s + ../asm/darwin/crypto/bn/rsaz-x86_64.s + ../asm/darwin/crypto/bn/x86_64-gf2m.s + ../asm/darwin/crypto/bn/x86_64-mont.s + ../asm/darwin/crypto/bn/x86_64-mont5.s + ../asm/darwin/crypto/camellia/cmll-x86_64.s + ../asm/darwin/crypto/chacha/chacha-x86_64.s + ../asm/darwin/crypto/ec/ecp_nistz256-x86_64.s + ../asm/darwin/crypto/ec/x25519-x86_64.s + ../asm/darwin/crypto/md5/md5-x86_64.s + ../asm/darwin/crypto/modes/aesni-gcm-x86_64.s + ../asm/darwin/crypto/modes/ghash-x86_64.s + ../asm/darwin/crypto/poly1305/poly1305-x86_64.s + ../asm/darwin/crypto/rc4/rc4-md5-x86_64.s + ../asm/darwin/crypto/rc4/rc4-x86_64.s + ../asm/darwin/crypto/sha/keccak1600-x86_64.s + ../asm/darwin/crypto/sha/sha1-mb-x86_64.s + ../asm/darwin/crypto/sha/sha1-x86_64.s + ../asm/darwin/crypto/sha/sha256-mb-x86_64.s + ../asm/darwin/crypto/sha/sha256-x86_64.s + ../asm/darwin/crypto/sha/sha512-x86_64.s + ../asm/darwin/crypto/whrlpool/wp-x86_64.s + ../asm/darwin/crypto/x86_64cpuid.s + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_ARM64) + SRCS( + ../asm/darwin-arm64/crypto/sha/keccak1600-armv8.S + ../asm/darwin-arm64/crypto/sha/sha512-armv8.S + ../asm/darwin-arm64/crypto/sha/sha1-armv8.S + ../asm/darwin-arm64/crypto/sha/sha256-armv8.S + ../asm/darwin-arm64/crypto/poly1305/poly1305-armv8.S + ../asm/darwin-arm64/crypto/ec/ecp_nistz256-armv8.S + ../asm/darwin-arm64/crypto/chacha/chacha-armv8.S + ../asm/darwin-arm64/crypto/bn/armv8-mont.S + ../asm/darwin-arm64/crypto/arm64cpuid.S + ../asm/darwin-arm64/crypto/aes/aesv8-armx.S + ../asm/darwin-arm64/crypto/aes/vpaes-armv8.S + ../asm/darwin-arm64/crypto/modes/ghashv8-armx.S + armcap.c + bn/bn_asm.c + camellia/camellia.c + camellia/cmll_cbc.c + dso/dso_dlfcn.c + rc4/rc4_enc.c + rc4/rc4_skey.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_LINUX AND ARCH_ARM7) + IF (CLANG) + # XXX: This is a workarond for 'out of range immediate fixup value' + # error with clang integrated assembler: + # https://github.com/openssl/openssl/issues/7878 + CFLAGS( + -mno-thumb + ) + ENDIF() + CFLAGS( + -DOPENSSL_PIC + -DOPENSSL_BN_ASM_GF2m + -DAES_ASM + -DBSAES_ASM + -DGHASH_ASM + ) + SRCS( + ../asm/android/arm/crypto/ec/ecp_nistz256-armv4.S + ../asm/android/arm/crypto/poly1305/poly1305-armv4.S + ../asm/android/arm/crypto/armv4cpuid.S + ../asm/android/arm/crypto/bn/armv4-mont.S + ../asm/android/arm/crypto/bn/armv4-gf2m.S + ../asm/android/arm/crypto/aes/aes-armv4.S + ../asm/android/arm/crypto/aes/bsaes-armv7.S + ../asm/android/arm/crypto/aes/aesv8-armx.S + ../asm/android/arm/crypto/sha/keccak1600-armv4.S + ../asm/android/arm/crypto/sha/sha256-armv4.S + ../asm/android/arm/crypto/sha/sha512-armv4.S + ../asm/android/arm/crypto/sha/sha1-armv4-large.S + ../asm/android/arm/crypto/chacha/chacha-armv4.S + ../asm/android/arm/crypto/modes/ghashv8-armx.S + ../asm/android/arm/crypto/modes/ghash-armv4.S + armcap.c + bn/bn_asm.c + camellia/camellia.c + camellia/cmll_cbc.c + dso/dso_dlfcn.c + rand/rand_vms.c + rc4/rc4_enc.c + rc4/rc4_skey.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_LINUX AND ARCH_AARCH64) + SRCS( + ../asm/aarch64/crypto/aes/aesv8-armx.S + ../asm/aarch64/crypto/aes/vpaes-armv8.S + ../asm/aarch64/crypto/arm64cpuid.S + ../asm/aarch64/crypto/bn/armv8-mont.S + ../asm/aarch64/crypto/chacha/chacha-armv8.S + ../asm/aarch64/crypto/ec/ecp_nistz256-armv8.S + ../asm/aarch64/crypto/modes/ghashv8-armx.S + ../asm/aarch64/crypto/poly1305/poly1305-armv8.S + ../asm/aarch64/crypto/sha/keccak1600-armv8.S + ../asm/aarch64/crypto/sha/sha1-armv8.S + ../asm/aarch64/crypto/sha/sha256-armv8.S + ../asm/aarch64/crypto/sha/sha512-armv8.S + armcap.c + camellia/camellia.c + camellia/cmll_cbc.c + rc4/rc4_enc.c + rc4/rc4_skey.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_LINUX AND ARCH_PPC64LE) + SRCS( + ../asm/ppc64le/crypto/aes/aesp8-ppc.s + ../asm/ppc64le/crypto/aes/vpaes-ppc.s + ../asm/ppc64le/crypto/bn/bn-ppc.s + ../asm/ppc64le/crypto/bn/ppc-mont.s + ../asm/ppc64le/crypto/chacha/chacha-ppc.s + ../asm/ppc64le/crypto/ec/ecp_nistz256-ppc64.s + ../asm/ppc64le/crypto/ec/x25519-ppc64.s + ../asm/ppc64le/crypto/modes/ghashp8-ppc.s + ../asm/ppc64le/crypto/poly1305/poly1305-ppc.s + ../asm/ppc64le/crypto/poly1305/poly1305-ppcfp.s + ../asm/ppc64le/crypto/ppccpuid.s + ../asm/ppc64le/crypto/sha/keccak1600-ppc64.s + ../asm/ppc64le/crypto/sha/sha1-ppc.s + ../asm/ppc64le/crypto/sha/sha256-ppc.s + ../asm/ppc64le/crypto/sha/sha256p8-ppc.s + ../asm/ppc64le/crypto/sha/sha512-ppc.s + ../asm/ppc64le/crypto/sha/sha512p8-ppc.s + ppccap.c + camellia/camellia.c + camellia/cmll_cbc.c + rc4/rc4_enc.c + rc4/rc4_skey.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_LINUX AND ARCH_X86_64) + SRCS( + ../asm/linux/crypto/aes/aesni-mb-x86_64.s + ../asm/linux/crypto/aes/aesni-sha1-x86_64.s + ../asm/linux/crypto/aes/aesni-sha256-x86_64.s + ../asm/linux/crypto/aes/aesni-x86_64.s + ../asm/linux/crypto/aes/vpaes-x86_64.s + ../asm/linux/crypto/bn/rsaz-avx2.s + ../asm/linux/crypto/bn/rsaz-x86_64.s + ../asm/linux/crypto/bn/x86_64-gf2m.s + ../asm/linux/crypto/bn/x86_64-mont.s + ../asm/linux/crypto/bn/x86_64-mont5.s + ../asm/linux/crypto/camellia/cmll-x86_64.s + ../asm/linux/crypto/chacha/chacha-x86_64.s + ../asm/linux/crypto/ec/ecp_nistz256-x86_64.s + ../asm/linux/crypto/ec/x25519-x86_64.s + ../asm/linux/crypto/md5/md5-x86_64.s + ../asm/linux/crypto/modes/aesni-gcm-x86_64.s + ../asm/linux/crypto/modes/ghash-x86_64.s + ../asm/linux/crypto/poly1305/poly1305-x86_64.s + ../asm/linux/crypto/rc4/rc4-md5-x86_64.s + ../asm/linux/crypto/rc4/rc4-x86_64.s + ../asm/linux/crypto/sha/keccak1600-x86_64.s + ../asm/linux/crypto/sha/sha1-mb-x86_64.s + ../asm/linux/crypto/sha/sha1-x86_64.s + ../asm/linux/crypto/sha/sha256-mb-x86_64.s + ../asm/linux/crypto/sha/sha256-x86_64.s + ../asm/linux/crypto/sha/sha512-x86_64.s + ../asm/linux/crypto/whrlpool/wp-x86_64.s + ../asm/linux/crypto/x86_64cpuid.s + ) +ENDIF() + +IF (OS_WINDOWS AND ARCH_X86_64) + SRCS( + ../asm/windows/crypto/aes/aesni-mb-x86_64.masm + ../asm/windows/crypto/aes/aesni-sha1-x86_64.masm + ../asm/windows/crypto/aes/aesni-sha256-x86_64.masm + ../asm/windows/crypto/aes/aesni-x86_64.masm + ../asm/windows/crypto/aes/vpaes-x86_64.masm + ../asm/windows/crypto/bn/rsaz-avx2.masm + ../asm/windows/crypto/bn/rsaz-x86_64.masm + ../asm/windows/crypto/bn/x86_64-gf2m.masm + ../asm/windows/crypto/bn/x86_64-mont.masm + ../asm/windows/crypto/bn/x86_64-mont5.masm + ../asm/windows/crypto/camellia/cmll-x86_64.masm + ../asm/windows/crypto/chacha/chacha-x86_64.masm + ../asm/windows/crypto/ec/ecp_nistz256-x86_64.masm + ../asm/windows/crypto/ec/x25519-x86_64.masm + ../asm/windows/crypto/md5/md5-x86_64.masm + ../asm/windows/crypto/modes/aesni-gcm-x86_64.masm + ../asm/windows/crypto/modes/ghash-x86_64.masm + ../asm/windows/crypto/poly1305/poly1305-x86_64.masm + ../asm/windows/crypto/rc4/rc4-md5-x86_64.masm + ../asm/windows/crypto/rc4/rc4-x86_64.masm + ../asm/windows/crypto/sha/keccak1600-x86_64.masm + ../asm/windows/crypto/sha/sha1-mb-x86_64.masm + ../asm/windows/crypto/sha/sha1-x86_64.masm + ../asm/windows/crypto/sha/sha256-mb-x86_64.masm + ../asm/windows/crypto/sha/sha256-x86_64.masm + ../asm/windows/crypto/sha/sha512-x86_64.masm + ../asm/windows/crypto/whrlpool/wp-x86_64.masm + ../asm/windows/crypto/uplink-x86_64.masm + ../asm/windows/crypto/x86_64cpuid.masm + ) +ENDIF() + +IF (OS_WINDOWS AND ARCH_I386) + CFLAGS( + -DGHASH_ASM + -DOPENSSL_BN_ASM_GF2m + -DRC4_ASM + -DMD5_ASM + ) + SRCS( + ../asm/windows/crypto/aes/aesni-x86.masm + ../asm/windows/crypto/aes/vpaes-x86.masm + ../asm/windows/crypto/bn/x86-gf2m.masm + ../asm/windows/crypto/bn/x86-mont.masm + ../asm/windows/crypto/camellia/cmll-x86.masm + ../asm/windows/crypto/chacha/chacha-x86.masm + ../asm/windows/crypto/md5/md5-586.masm + ../asm/windows/crypto/modes/ghash-x86.masm + ../asm/windows/crypto/rc4/rc4-586.masm + ../asm/windows/crypto/sha/sha1-586.masm + ../asm/windows/crypto/sha/sha256-586.masm + ../asm/windows/crypto/sha/sha512-586.masm + ../asm/windows/crypto/x86cpuid.masm + bf/bf_enc.c + bn/bn_asm.c + des/des_enc.c + des/fcrypt_b.c + sha/keccak1600.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_IOS AND ARCH_ARM64) + CFLAGS( + -DOPENSSL_PIC + -D_REENTRANT + ) + SRCS( + ../asm/ios/arm64/crypto/aes/aesv8-armx.S + ../asm/ios/arm64/crypto/aes/vpaes-armv8.S + ../asm/ios/arm64/crypto/arm64cpuid.S + ../asm/ios/arm64/crypto/bn/armv8-mont.S + ../asm/ios/arm64/crypto/chacha/chacha-armv8.S + ../asm/ios/arm64/crypto/ec/ecp_nistz256-armv8.S + ../asm/ios/arm64/crypto/modes/ghashv8-armx.S + ../asm/ios/arm64/crypto/poly1305/poly1305-armv8.S + ../asm/ios/arm64/crypto/sha/keccak1600-armv8.S + ../asm/ios/arm64/crypto/sha/sha1-armv8.S + ../asm/ios/arm64/crypto/sha/sha256-armv8.S + ../asm/ios/arm64/crypto/sha/sha512-armv8.S + armcap.c + bn/bn_asm.c + camellia/camellia.c + camellia/cmll_cbc.c + dso/dso_dlfcn.c + rand/rand_vms.c + rc4/rc4_enc.c + rc4/rc4_skey.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_IOS AND ARCH_X86_64) + CFLAGS( + -DL_ENDIAN + -DOPENSSL_PIC + -DOPENSSL_IA32_SSE2 + -DOPENSSL_BN_ASM_MONT5 + -DOPENSSL_BN_ASM_GF2m + -DRC4_ASM + -DMD5_ASM + -DGHASH_ASM + -DECP_NISTZ256_ASM + -DX25519_ASM + -D_REENTRANT + ) + SRCS( + ../asm/ios/x86_64/crypto/md5/md5-x86_64.s + ../asm/ios/x86_64/crypto/rc4/rc4-md5-x86_64.s + ../asm/ios/x86_64/crypto/rc4/rc4-x86_64.s + ../asm/ios/x86_64/crypto/modes/ghash-x86_64.s + ../asm/ios/x86_64/crypto/modes/aesni-gcm-x86_64.s + ../asm/ios/x86_64/crypto/chacha/chacha-x86_64.s + ../asm/ios/x86_64/crypto/ec/ecp_nistz256-x86_64.s + ../asm/ios/x86_64/crypto/ec/x25519-x86_64.s + ../asm/ios/x86_64/crypto/x86_64cpuid.s + ../asm/ios/x86_64/crypto/poly1305/poly1305-x86_64.s + ../asm/ios/x86_64/crypto/bn/rsaz-x86_64.s + ../asm/ios/x86_64/crypto/bn/x86_64-mont.s + ../asm/ios/x86_64/crypto/bn/x86_64-gf2m.s + ../asm/ios/x86_64/crypto/bn/x86_64-mont5.s + ../asm/ios/x86_64/crypto/bn/rsaz-avx2.s + ../asm/ios/x86_64/crypto/sha/sha512-x86_64.s + ../asm/ios/x86_64/crypto/sha/sha256-x86_64.s + ../asm/ios/x86_64/crypto/sha/keccak1600-x86_64.s + ../asm/ios/x86_64/crypto/sha/sha1-x86_64.s + ../asm/ios/x86_64/crypto/sha/sha1-mb-x86_64.s + ../asm/ios/x86_64/crypto/sha/sha256-mb-x86_64.s + ../asm/ios/x86_64/crypto/camellia/cmll-x86_64.s + ../asm/ios/x86_64/crypto/whrlpool/wp-x86_64.s + ../asm/ios/x86_64/crypto/aes/vpaes-x86_64.s + ../asm/ios/x86_64/crypto/aes/aesni-sha1-x86_64.s + ../asm/ios/x86_64/crypto/aes/aesni-sha256-x86_64.s + ../asm/ios/x86_64/crypto/aes/aesni-x86_64.s + ../asm/ios/x86_64/crypto/aes/aesni-mb-x86_64.s + bn/asm/x86_64-gcc.c + bn/rsaz_exp.c + dso/dso_dlfcn.c + rand/rand_vms.c + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_X86_64) + CFLAGS( + -DOPENSSL_USE_NODELETE + -DOPENSSL_PIC + -DOPENSSL_IA32_SSE2 + -DOPENSSL_BN_ASM_MONT5 + -DOPENSSL_BN_ASM_GF2m + -DRC4_ASM + -DMD5_ASM + -DGHASH_ASM + -DX25519_ASM + ) + SRCS( + ../asm/android/x86_64/crypto/ec/x25519-x86_64.s + ../asm/android/x86_64/crypto/ec/ecp_nistz256-x86_64.s + ../asm/android/x86_64/crypto/md5/md5-x86_64.s + ../asm/android/x86_64/crypto/rc4/rc4-x86_64.s + ../asm/android/x86_64/crypto/rc4/rc4-md5-x86_64.s + ../asm/android/x86_64/crypto/whrlpool/wp-x86_64.s + ../asm/android/x86_64/crypto/poly1305/poly1305-x86_64.s + ../asm/android/x86_64/crypto/x86_64cpuid.s + ../asm/android/x86_64/crypto/camellia/cmll-x86_64.s + ../asm/android/x86_64/crypto/bn/x86_64-mont5.s + ../asm/android/x86_64/crypto/bn/rsaz-avx2.s + ../asm/android/x86_64/crypto/bn/rsaz-x86_64.s + ../asm/android/x86_64/crypto/bn/x86_64-mont.s + ../asm/android/x86_64/crypto/bn/x86_64-gf2m.s + ../asm/android/x86_64/crypto/aes/aesni-sha256-x86_64.s + ../asm/android/x86_64/crypto/aes/aesni-mb-x86_64.s + ../asm/android/x86_64/crypto/aes/aesni-x86_64.s + ../asm/android/x86_64/crypto/aes/vpaes-x86_64.s + ../asm/android/x86_64/crypto/aes/aesni-sha1-x86_64.s + ../asm/android/x86_64/crypto/sha/sha256-x86_64.s + ../asm/android/x86_64/crypto/sha/sha1-mb-x86_64.s + ../asm/android/x86_64/crypto/sha/sha1-x86_64.s + ../asm/android/x86_64/crypto/sha/sha256-mb-x86_64.s + ../asm/android/x86_64/crypto/sha/sha512-x86_64.s + ../asm/android/x86_64/crypto/sha/keccak1600-x86_64.s + ../asm/android/x86_64/crypto/chacha/chacha-x86_64.s + ../asm/android/x86_64/crypto/modes/ghash-x86_64.s + ../asm/android/x86_64/crypto/modes/aesni-gcm-x86_64.s + bn/asm/x86_64-gcc.c + bn/rsaz_exp.c + dso/dso_dlfcn.c + rand/rand_vms.c + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_I686) + CFLAGS( + -DOPENSSL_PIC + -DOPENSSL_BN_ASM_PART_WORDS + -DOPENSSL_IA32_SSE2 + -DOPENSSL_BN_ASM_GF2m + -DRC4_ASM + -DMD5_ASM + -DRMD160_ASM + -DWHIRLPOOL_ASM + -DGHASH_ASM + ) + SRCS( + ../asm/android/i686/crypto/ec/ecp_nistz256-x86.s + ../asm/android/i686/crypto/bf/bf-586.s + ../asm/android/i686/crypto/md5/md5-586.s + ../asm/android/i686/crypto/rc4/rc4-586.s + ../asm/android/i686/crypto/whrlpool/wp-mmx.s + ../asm/android/i686/crypto/x86cpuid.s + ../asm/android/i686/crypto/des/crypt586.s + ../asm/android/i686/crypto/des/des-586.s + ../asm/android/i686/crypto/poly1305/poly1305-x86.s + ../asm/android/i686/crypto/ripemd/rmd-586.s + ../asm/android/i686/crypto/camellia/cmll-x86.s + ../asm/android/i686/crypto/bn/bn-586.s + ../asm/android/i686/crypto/bn/co-586.s + ../asm/android/i686/crypto/bn/x86-gf2m.s + ../asm/android/i686/crypto/bn/x86-mont.s + ../asm/android/i686/crypto/aes/aesni-x86.s + ../asm/android/i686/crypto/aes/vpaes-x86.s + ../asm/android/i686/crypto/sha/sha512-586.s + ../asm/android/i686/crypto/sha/sha256-586.s + ../asm/android/i686/crypto/sha/sha1-586.s + ../asm/android/i686/crypto/chacha/chacha-x86.s + ../asm/android/i686/crypto/modes/ghash-x86.s + dso/dso_dlfcn.c + rand/rand_vms.c + sha/keccak1600.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_ARM7) + IF (CLANG) + # XXX: This is a workarond for 'out of range immediate fixup value' + # error with clang integrated assembler: + # https://github.com/openssl/openssl/issues/7878 + CFLAGS( + -mno-thumb + ) + ENDIF() + CFLAGS( + -DOPENSSL_PIC + -DOPENSSL_BN_ASM_GF2m + -DAES_ASM + -DBSAES_ASM + -DGHASH_ASM + ) + SRCS( + ../asm/android/arm/crypto/ec/ecp_nistz256-armv4.S + ../asm/android/arm/crypto/poly1305/poly1305-armv4.S + ../asm/android/arm/crypto/armv4cpuid.S + ../asm/android/arm/crypto/bn/armv4-mont.S + ../asm/android/arm/crypto/bn/armv4-gf2m.S + ../asm/android/arm/crypto/aes/aes-armv4.S + ../asm/android/arm/crypto/aes/bsaes-armv7.S + ../asm/android/arm/crypto/aes/aesv8-armx.S + ../asm/android/arm/crypto/sha/keccak1600-armv4.S + ../asm/android/arm/crypto/sha/sha256-armv4.S + ../asm/android/arm/crypto/sha/sha512-armv4.S + ../asm/android/arm/crypto/sha/sha1-armv4-large.S + ../asm/android/arm/crypto/chacha/chacha-armv4.S + ../asm/android/arm/crypto/modes/ghashv8-armx.S + ../asm/android/arm/crypto/modes/ghash-armv4.S + armcap.c + bn/bn_asm.c + camellia/camellia.c + camellia/cmll_cbc.c + dso/dso_dlfcn.c + rand/rand_vms.c + rc4/rc4_enc.c + rc4/rc4_skey.c + whrlpool/wp_block.c + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_ARM64) + CFLAGS( + -DOPENSSL_PIC + ) + SRCS( + ../asm/android/arm64/crypto/ec/ecp_nistz256-armv8.S + ../asm/android/arm64/crypto/poly1305/poly1305-armv8.S + ../asm/android/arm64/crypto/bn/armv8-mont.S + ../asm/android/arm64/crypto/aes/vpaes-armv8.S + ../asm/android/arm64/crypto/aes/aesv8-armx.S + ../asm/android/arm64/crypto/sha/sha512-armv8.S + ../asm/android/arm64/crypto/sha/keccak1600-armv8.S + ../asm/android/arm64/crypto/sha/sha1-armv8.S + ../asm/android/arm64/crypto/sha/sha256-armv8.S + ../asm/android/arm64/crypto/arm64cpuid.S + ../asm/android/arm64/crypto/chacha/chacha-armv8.S + ../asm/android/arm64/crypto/modes/ghashv8-armx.S + armcap.c + bn/bn_asm.c + camellia/camellia.c + camellia/cmll_cbc.c + dso/dso_dlfcn.c + rand/rand_vms.c + rc4/rc4_enc.c + rc4/rc4_skey.c + whrlpool/wp_block.c + ) +ENDIF() + +# mitigate SIGILL on some armv7 platforms +# https://github.com/openssl/openssl/issues/17009 +IF (ARCADIA_OPENSSL_DISABLE_ARMV7_TICK) + CFLAGS( + -DARCADIA_OPENSSL_DISABLE_ARMV7_TICK + ) +ENDIF() + +ENDIF() + +END() diff --git a/contrib/libs/openssl/ya.make b/contrib/libs/openssl/ya.make new file mode 100644 index 00000000000..ee7c59b2bf9 --- /dev/null +++ b/contrib/libs/openssl/ya.make @@ -0,0 +1,350 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +VERSION(1.1.1t) + +ORIGINAL_SOURCE(https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz) + +OPENSOURCE_EXPORT_REPLACEMENT( + CMAKE OpenSSL + CMAKE_TARGET OpenSSL::OpenSSL + CONAN openssl/1.1.1s +) + +LICENSE( + Apache-2.0 AND + BSD-2-Clause AND + BSD-3-Clause AND + BSD-Source-Code AND + OpenSSL AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PROVIDES(openssl) + +PEERDIR( + contrib/libs/openssl/crypto +) + +ADDINCL( + GLOBAL contrib/libs/openssl/include + contrib/libs/openssl +) + +IF (NOT EXPORT_CMAKE) + +IF (OS_LINUX) + IF (ARCH_ARM64) + SET(LINUX_ARM64 yes) + ELSEIF (ARCH_ARM7) + SET(LINUX_ARMV7 yes) + ELSEIF (ARCH_X86_64) + SET(LINUX_X86_64 yes) + ENDIF() +ENDIF() + +IF (OS_IOS) + IF (ARCH_ARM64) + SET(IOS_ARM64 yes) + ELSEIF (ARCH_ARM7) + SET(IOS_ARMV7 yes) + ELSEIF (ARCH_X86_64) + SET(IOS_X86_64 yes) + ELSEIF (ARCH_I386) + SET(IOS_I386 yes) + ENDIF() +ENDIF() + +IF (OS_ANDROID) + IF (ARCH_ARM64) + SET(ANDROID_ARM64 yes) + ELSEIF (ARCH_ARM7) + SET(ANDROID_ARMV7 yes) + ELSEIF (ARCH_X86_64) + SET(ANDROID_X86_64 yes) + ELSEIF (ARCH_I686) + SET(ANDROID_I686 yes) + ENDIF() +ENDIF() + +IF (OS_WINDOWS) + IF (ARCH_X86_64) + SET(WINDOWS_X86_64 yes) + ELSEIF (ARCH_I686) + SET(WINDOWS_I686 yes) + ENDIF() +ENDIF() + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DAESNI_ASM + -DOPENSSL_BN_ASM_MONT + -DOPENSSL_CPUID_OBJ + -DSHA1_ASM + -DSHA256_ASM + -DSHA512_ASM +) + +IF (NOT WINDOWS_I686) + CFLAGS( + -DECP_NISTZ256_ASM + -DPOLY1305_ASM + ) +ENDIF() + +IF (NOT ANDROID_I686 AND NOT WINDOWS_I686) + CFLAGS( + -DKECCAK1600_ASM + ) +ENDIF() + +IF (NOT OS_WINDOWS) + CFLAGS( + -DENGINESDIR=\"/usr/local/lib/engines-1.1\" + -DOPENSSLDIR=\"/usr/local/ssl\" + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND ARCH_X86_64) + CFLAGS( + -DGHASH_ASM + -DL_ENDIAN + -DMD5_ASM + -DOPENSSL_BN_ASM_GF2m + -DOPENSSL_BN_ASM_MONT5 + -DOPENSSL_IA32_SSE2 + -DPADLOCK_ASM + -DRC4_ASM + -DX25519_ASM + ) +ENDIF() + +IF (OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64 OR OS_ANDROID) + CFLAGS( + -DOPENSSL_USE_NODELETE + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64) + CFLAGS( + -D_REENTRANT + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_ARM64) + CFLAGS( + -DL_ENDIAN + -DOPENSSL_PIC + -D_REENTRANT + ) +ENDIF() + +IF (OS_WINDOWS) + IF (ARCH_X86_64) + CFLAGS( + -DENGINESDIR="\"C:\\\\Program\ Files\\\\OpenSSL\\\\lib\\\\engines-1_1\"" + -DOPENSSLDIR="\"C:\\\\Program\ Files\\\\Common\ Files\\\\SSL\"" + ) + ELSEIF (ARCH_I386) + CFLAGS( + -DENGINESDIR="\"C:\\\\Program\ Files\ \(x86\)\\\\OpenSSL\\\\lib\\\\engines-1_1\"" + -DOPENSSLDIR="\"C:\\\\Program\ Files\ \(x86\)\\\\Common\ Files\\\\SSL\"" + ) + ENDIF() + CFLAGS( + -DOPENSSL_SYS_WIN32 + -DUNICODE + -DWIN32_LEAN_AND_MEAN + -D_CRT_SECURE_NO_DEPRECATE + -D_UNICODE + -D_WINSOCK_DEPRECATED_NO_WARNINGS + /GF + ) +ENDIF() + +IF (SANITIZER_TYPE == memory) + CFLAGS( + -DPURIFY + ) +ENDIF() + +IF (MUSL) + CFLAGS( + -DOPENSSL_NO_ASYNC + ) +ENDIF() + +IF (ARCH_TYPE_32) + CFLAGS( + -DOPENSSL_NO_EC_NISTP_64_GCC_128 + ) +ENDIF() + +SRCS( + engines/e_capi.c + engines/e_padlock.c + ssl/bio_ssl.c + ssl/d1_lib.c + ssl/d1_msg.c + ssl/d1_srtp.c + ssl/methods.c + ssl/packet.c + ssl/pqueue.c + ssl/record/dtls1_bitmap.c + ssl/record/rec_layer_d1.c + ssl/record/rec_layer_s3.c + ssl/record/ssl3_buffer.c + ssl/record/ssl3_record.c + ssl/record/ssl3_record_tls13.c + ssl/s3_cbc.c + ssl/s3_enc.c + ssl/s3_lib.c + ssl/s3_msg.c + ssl/ssl_asn1.c + ssl/ssl_cert.c + ssl/ssl_ciph.c + ssl/ssl_conf.c + ssl/ssl_err.c + ssl/ssl_init.c + ssl/ssl_lib.c + ssl/ssl_mcnf.c + ssl/ssl_rsa.c + ssl/ssl_sess.c + ssl/ssl_stat.c + ssl/ssl_txt.c + ssl/ssl_utst.c + ssl/statem/extensions.c + ssl/statem/extensions_clnt.c + ssl/statem/extensions_cust.c + ssl/statem/extensions_srvr.c + ssl/statem/statem.c + ssl/statem/statem_clnt.c + ssl/statem/statem_dtls.c + ssl/statem/statem_lib.c + ssl/statem/statem_srvr.c + ssl/t1_enc.c + ssl/t1_lib.c + ssl/t1_trce.c + ssl/tls13_enc.c + ssl/tls_srp.c +) + +IF (NOT IOS_ARMV7 AND NOT LINUX_ARMV7) + CFLAGS( + -DVPAES_ASM + ) +ENDIF() + +IF (OS_LINUX AND ARCH_ARM7 OR OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64 OR OS_LINUX AND ARCH_PPC64LE) + SRCS( + engines/e_afalg.c + ) +ENDIF() + +IF (OS_DARWIN AND ARCH_X86_64) + SRCS( + asm/darwin/engines/e_padlock-x86_64.s + ) +ENDIF() + +IF (OS_LINUX AND ARCH_X86_64) + SRCS( + asm/linux/engines/e_padlock-x86_64.s + ) +ENDIF() + +IF (OS_WINDOWS AND ARCH_X86_64) + SRCS( + asm/windows/engines/e_padlock-x86_64.masm + ) +ENDIF() + +IF (OS_WINDOWS AND ARCH_I386) + CFLAGS( + -DPADLOCK_ASM + ) + SRCS( + asm/windows/engines/e_padlock-x86.masm + ) +ENDIF() + +IF (OS_IOS AND ARCH_X86_64) + CFLAGS( + -DPADLOCK_ASM + -D_REENTRANT + ) + SRCS( + asm/ios/x86_64/engines/e_padlock-x86_64.s + engines/e_dasync.c + engines/e_ossltest.c + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_X86_64) + CFLAGS( + -DOPENSSL_PIC + -DOPENSSL_IA32_SSE2 + -DOPENSSL_BN_ASM_MONT5 + -DOPENSSL_BN_ASM_GF2m + -DDRC4_ASM + -DMD5_ASM + -DGHASH_ASM + -DX25519_ASM + ) + SRCS( + asm/android/x86_64/engines/e_padlock-x86_64.s + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_I686) + CFLAGS( + -DOPENSSL_PIC + -DOPENSSL_BN_ASM_PART_WORDS + -DOPENSSL_IA32_SSE2 + -DOPENSSL_BN_ASM_MONT + -DOPENSSL_BN_ASM_GF2m + -DRC4_ASM + -DMD5_ASM + -DRMD160_ASM + -DVPAES_ASM + -DWHIRLPOOL_ASM + -DGHASH_ASM + ) + SRCS( + asm/android/i686/engines/e_padlock-x86.s + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_ARM7) + CFLAGS( + -DOPENSSL_PIC + -DOPENSSL_BN_ASM_GF2m + -DKECCAK1600_ASM + -DAES_ASM + -DBSAES_ASM + -DGHASH_ASM + ) +ENDIF() + +IF (OS_ANDROID AND ARCH_ARM64) + CFLAGS( + -DOPENSSL_PIC + -DKECCAK1600_ASM + -DVPAES_ASM + ) +ENDIF() + +ENDIF() + +END() + +RECURSE( + apps + crypto +) diff --git a/contrib/libs/pcre/pcre16/ya.make b/contrib/libs/pcre/pcre16/ya.make new file mode 100644 index 00000000000..022b24ccaf8 --- /dev/null +++ b/contrib/libs/pcre/pcre16/ya.make @@ -0,0 +1,49 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +ADDINCL( + contrib/libs/pcre +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H +) + +SRCDIR(contrib/libs/pcre) + +SRCS( + pcre16_byte_order.c + pcre16_chartables.c + pcre16_compile.c + pcre16_config.c + pcre16_dfa_exec.c + pcre16_exec.c + pcre16_fullinfo.c + pcre16_get.c + pcre16_globals.c + pcre16_jit_compile.c + pcre16_maketables.c + pcre16_newline.c + pcre16_ord2utf16.c + pcre16_refcount.c + pcre16_string_utils.c + pcre16_study.c + pcre16_tables.c + pcre16_ucd.c + pcre16_utf16_utils.c + pcre16_valid_utf16.c + pcre16_version.c + pcre16_xclass.c + pcre_chartables.c +) + +END() diff --git a/contrib/libs/pcre/pcre32/ya.make b/contrib/libs/pcre/pcre32/ya.make new file mode 100644 index 00000000000..718045f4471 --- /dev/null +++ b/contrib/libs/pcre/pcre32/ya.make @@ -0,0 +1,49 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +ADDINCL( + contrib/libs/pcre +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H +) + +SRCDIR(contrib/libs/pcre) + +SRCS( + pcre32_byte_order.c + pcre32_chartables.c + pcre32_compile.c + pcre32_config.c + pcre32_dfa_exec.c + pcre32_exec.c + pcre32_fullinfo.c + pcre32_get.c + pcre32_globals.c + pcre32_jit_compile.c + pcre32_maketables.c + pcre32_newline.c + pcre32_ord2utf32.c + pcre32_refcount.c + pcre32_string_utils.c + pcre32_study.c + pcre32_tables.c + pcre32_ucd.c + pcre32_utf32_utils.c + pcre32_valid_utf32.c + pcre32_version.c + pcre32_xclass.c + pcre_chartables.c +) + +END() diff --git a/contrib/libs/pcre/pcrecpp/ya.make b/contrib/libs/pcre/pcrecpp/ya.make new file mode 100644 index 00000000000..6bc75935f35 --- /dev/null +++ b/contrib/libs/pcre/pcrecpp/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +PEERDIR( + contrib/libs/pcre +) + +ADDINCL( + contrib/libs/pcre +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DHAVE_CONFIG_H +) + +SRCDIR(contrib/libs/pcre) + +SRCS( + pcre_scanner.cc + pcre_stringpiece.cc + pcrecpp.cc +) + +END() diff --git a/contrib/libs/pcre/ya.make b/contrib/libs/pcre/ya.make new file mode 100644 index 00000000000..d3345c87a2d --- /dev/null +++ b/contrib/libs/pcre/ya.make @@ -0,0 +1,72 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +VERSION(8.45) + +ORIGINAL_SOURCE(https://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.bz2) + +LICENSE( + BSD-2-Clause AND + BSD-3-Clause AND + FSFAP AND + PCRE AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + contrib/libs/pcre +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + GLOBAL -DPCRE_STATIC + -DHAVE_CONFIG_H +) + +# JIT adds ≈108KB to binary size which may be critical for mobile and embedded devices binary distributions +DEFAULT(ARCADIA_PCRE_ENABLE_JIT yes) + +IF (ARCADIA_PCRE_ENABLE_JIT) + CFLAGS( + -DARCADIA_PCRE_ENABLE_JIT + ) +ENDIF() + +SRCS( + pcre_byte_order.c + pcre_chartables.c + pcre_compile.c + pcre_config.c + pcre_dfa_exec.c + pcre_exec.c + pcre_fullinfo.c + pcre_get.c + pcre_globals.c + pcre_jit_compile.c + pcre_maketables.c + pcre_newline.c + pcre_ord2utf8.c + pcre_refcount.c + pcre_string_utils.c + pcre_study.c + pcre_tables.c + pcre_ucd.c + pcre_valid_utf8.c + pcre_version.c + pcre_xclass.c + pcreposix.c +) + +END() + +RECURSE( + pcre16 + pcre32 + pcrecpp +) diff --git a/contrib/libs/pdqsort/ya.make b/contrib/libs/pdqsort/ya.make new file mode 100644 index 00000000000..0a8ed229a41 --- /dev/null +++ b/contrib/libs/pdqsort/ya.make @@ -0,0 +1,13 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(Zlib) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2021-03-14) + +ORIGINAL_SOURCE(https://github.com/orlp/pdqsort/archive/b1ef26a55cdb60d236a5cb199c4234c704f46726.tar.gz) + +END() diff --git a/contrib/libs/poco/Crypto/ya.make b/contrib/libs/poco/Crypto/ya.make new file mode 100644 index 00000000000..90b571c8480 --- /dev/null +++ b/contrib/libs/poco/Crypto/ya.make @@ -0,0 +1,72 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/openssl + contrib/libs/poco/Foundation +) + +ADDINCL( + GLOBAL contrib/libs/poco/Crypto/include + contrib/libs/poco/Crypto/src + contrib/libs/poco/Foundation/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DPOCO_ENABLE_CPP11 + -DPOCO_ENABLE_CPP14 + -DPOCO_NO_AUTOMATIC_LIBS + -DPOCO_UNBUNDLED +) + +IF (OS_DARWIN) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_NO_STAT64 + ) +ELSEIF (OS_LINUX) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_HAVE_FD_EPOLL + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DPOCO_OS_FAMILY_WINDOWS + ) +ENDIF() + +SRCS( + src/Cipher.cpp + src/CipherFactory.cpp + src/CipherImpl.cpp + src/CipherKey.cpp + src/CipherKeyImpl.cpp + src/CryptoException.cpp + src/CryptoStream.cpp + src/CryptoTransform.cpp + src/DigestEngine.cpp + src/ECDSADigestEngine.cpp + src/ECKey.cpp + src/ECKeyImpl.cpp + src/EVPPKey.cpp + src/KeyPair.cpp + src/KeyPairImpl.cpp + src/OpenSSLInitializer.cpp + src/PKCS12Container.cpp + src/RSACipherImpl.cpp + src/RSADigestEngine.cpp + src/RSAKey.cpp + src/RSAKeyImpl.cpp + src/X509Certificate.cpp +) + +END() diff --git a/contrib/libs/poco/Foundation/ya.make b/contrib/libs/poco/Foundation/ya.make new file mode 100644 index 00000000000..f74fb3da580 --- /dev/null +++ b/contrib/libs/poco/Foundation/ya.make @@ -0,0 +1,225 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + BSL-1.0 AND + NCSA AND + Public-Domain AND + RSA-MD AND + RSA-MD4 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/double-conversion + contrib/libs/pcre + contrib/libs/zlib +) + +ADDINCL( + GLOBAL contrib/libs/poco/Foundation/include + contrib/libs/double-conversion + contrib/libs/pcre + contrib/libs/poco/Foundation/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DHAVE_PTHREAD_SETAFFINITY_NP + -DHAVE_THREE_PARAM_SCHED_SETAFFINITY + -DPCRE_STATIC + -DPOCO_ENABLE_CPP11 + -DPOCO_ENABLE_CPP14 + -DPOCO_NO_AUTOMATIC_LIBS + -DPOCO_UNBUNDLED +) + +IF (OS_DARWIN) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_NO_STAT64 + ) +ELSEIF (OS_LINUX) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_HAVE_FD_EPOLL + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DPOCO_OS_FAMILY_WINDOWS + ) +ENDIF() + +SRCS( + src/ASCIIEncoding.cpp + src/AbstractObserver.cpp + src/ActiveDispatcher.cpp + src/ArchiveStrategy.cpp + src/Ascii.cpp + src/AsyncChannel.cpp + src/AtomicCounter.cpp + src/Base32Decoder.cpp + src/Base32Encoder.cpp + src/Base64Decoder.cpp + src/Base64Encoder.cpp + src/BinaryReader.cpp + src/BinaryWriter.cpp + src/Bugcheck.cpp + src/ByteOrder.cpp + src/Channel.cpp + src/Checksum.cpp + src/Clock.cpp + src/Condition.cpp + src/Configurable.cpp + src/ConsoleChannel.cpp + src/CountingStream.cpp + src/DateTime.cpp + src/DateTimeFormat.cpp + src/DateTimeFormatter.cpp + src/DateTimeParser.cpp + src/Debugger.cpp + src/DeflatingStream.cpp + src/DigestEngine.cpp + src/DigestStream.cpp + src/DirectoryIterator.cpp + src/DirectoryIteratorStrategy.cpp + src/DirectoryWatcher.cpp + src/Environment.cpp + src/Error.cpp + src/ErrorHandler.cpp + src/Event.cpp + src/EventArgs.cpp + src/EventChannel.cpp + src/Exception.cpp + src/FIFOBufferStream.cpp + src/FPEnvironment.cpp + src/File.cpp + src/FileChannel.cpp + src/FileStream.cpp + src/FileStreamFactory.cpp + src/Format.cpp + src/Formatter.cpp + src/FormattingChannel.cpp + src/Glob.cpp + src/Hash.cpp + src/HashStatistic.cpp + src/HexBinaryDecoder.cpp + src/HexBinaryEncoder.cpp + src/InflatingStream.cpp + src/JSONString.cpp + src/Latin1Encoding.cpp + src/Latin2Encoding.cpp + src/Latin9Encoding.cpp + src/LineEndingConverter.cpp + src/LocalDateTime.cpp + src/LogFile.cpp + src/LogStream.cpp + src/Logger.cpp + src/LoggingFactory.cpp + src/LoggingRegistry.cpp + src/MD4Engine.cpp + src/MD5Engine.cpp + src/Manifest.cpp + src/MemoryPool.cpp + src/MemoryStream.cpp + src/Message.cpp + src/Mutex.cpp + src/NamedEvent.cpp + src/NamedMutex.cpp + src/NestedDiagnosticContext.cpp + src/Notification.cpp + src/NotificationCenter.cpp + src/NotificationQueue.cpp + src/NullChannel.cpp + src/NullStream.cpp + src/NumberFormatter.cpp + src/NumberParser.cpp + src/NumericString.cpp + src/Path.cpp + src/PatternFormatter.cpp + src/Pipe.cpp + src/PipeImpl.cpp + src/PipeStream.cpp + src/PriorityNotificationQueue.cpp + src/Process.cpp + src/PurgeStrategy.cpp + src/RWLock.cpp + src/Random.cpp + src/RandomStream.cpp + src/RefCountedObject.cpp + src/RegularExpression.cpp + src/RotateStrategy.cpp + src/Runnable.cpp + src/SHA1Engine.cpp + src/Semaphore.cpp + src/SharedLibrary.cpp + src/SharedMemory.cpp + src/SignalHandler.cpp + src/SimpleFileChannel.cpp + src/SortedDirectoryIterator.cpp + src/SplitterChannel.cpp + src/Stopwatch.cpp + src/StreamChannel.cpp + src/StreamConverter.cpp + src/StreamCopier.cpp + src/StreamTokenizer.cpp + src/String.cpp + src/StringTokenizer.cpp + src/SynchronizedObject.cpp + src/Task.cpp + src/TaskManager.cpp + src/TaskNotification.cpp + src/TeeStream.cpp + src/TemporaryFile.cpp + src/TextBufferIterator.cpp + src/TextConverter.cpp + src/TextEncoding.cpp + src/TextIterator.cpp + src/Thread.cpp + src/ThreadLocal.cpp + src/ThreadPool.cpp + src/ThreadTarget.cpp + src/TimedNotificationQueue.cpp + src/Timer.cpp + src/Timespan.cpp + src/Timestamp.cpp + src/Timezone.cpp + src/Token.cpp + src/URI.cpp + src/URIStreamFactory.cpp + src/URIStreamOpener.cpp + src/UTF16Encoding.cpp + src/UTF32Encoding.cpp + src/UTF8Encoding.cpp + src/UTF8String.cpp + src/UUID.cpp + src/UUIDGenerator.cpp + src/Unicode.cpp + src/UnicodeConverter.cpp + src/Var.cpp + src/VarHolder.cpp + src/VarIterator.cpp + src/Void.cpp + src/Windows1250Encoding.cpp + src/Windows1251Encoding.cpp + src/Windows1252Encoding.cpp +) + +IF (OS_WINDOWS) + SRCS( + src/EventLogChannel.cpp + src/WindowsConsoleChannel.cpp + ) +ELSE() + SRCS( + src/SyslogChannel.cpp + ) +ENDIF() + +END() diff --git a/contrib/libs/poco/JSON/ya.make b/contrib/libs/poco/JSON/ya.make new file mode 100644 index 00000000000..ad94d3e815b --- /dev/null +++ b/contrib/libs/poco/JSON/ya.make @@ -0,0 +1,62 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/poco/Foundation +) + +ADDINCL( + GLOBAL contrib/libs/poco/JSON/include + contrib/libs/poco/Foundation/include + contrib/libs/poco/JSON/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DPOCO_ENABLE_CPP11 + -DPOCO_ENABLE_CPP14 + -DPOCO_NO_AUTOMATIC_LIBS + -DPOCO_UNBUNDLED +) + +IF (OS_DARWIN) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_NO_STAT64 + ) +ELSEIF (OS_LINUX) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_HAVE_FD_EPOLL + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DPOCO_OS_FAMILY_WINDOWS + ) +ENDIF() + +SRCS( + src/Array.cpp + src/Handler.cpp + src/JSONException.cpp + src/Object.cpp + src/ParseHandler.cpp + src/Parser.cpp + src/ParserImpl.cpp + src/PrintHandler.cpp + src/Query.cpp + src/Stringifier.cpp + src/Template.cpp + src/TemplateCache.cpp + src/pdjson.c +) + +END() diff --git a/contrib/libs/poco/Net/ya.make b/contrib/libs/poco/Net/ya.make new file mode 100644 index 00000000000..af5b581e4cf --- /dev/null +++ b/contrib/libs/poco/Net/ya.make @@ -0,0 +1,152 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Custom-punycode +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/poco/Foundation +) + +ADDINCL( + GLOBAL contrib/libs/poco/Net/include + contrib/libs/poco/Foundation/include + contrib/libs/poco/Net/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DPOCO_ENABLE_CPP11 + -DPOCO_ENABLE_CPP14 + -DPOCO_NO_AUTOMATIC_LIBS + -DPOCO_UNBUNDLED +) + +IF (OS_DARWIN) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_NO_STAT64 + ) +ELSEIF (OS_LINUX) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_HAVE_FD_EPOLL + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DPOCO_OS_FAMILY_WINDOWS + ) +ENDIF() + +SRCS( + src/AbstractHTTPRequestHandler.cpp + src/DNS.cpp + src/DatagramSocket.cpp + src/DatagramSocketImpl.cpp + src/DialogSocket.cpp + src/FTPClientSession.cpp + src/FTPStreamFactory.cpp + src/FilePartSource.cpp + src/HTMLForm.cpp + src/HTTPAuthenticationParams.cpp + src/HTTPBasicCredentials.cpp + src/HTTPBufferAllocator.cpp + src/HTTPChunkedStream.cpp + src/HTTPClientSession.cpp + src/HTTPCookie.cpp + src/HTTPCredentials.cpp + src/HTTPDigestCredentials.cpp + src/HTTPFixedLengthStream.cpp + src/HTTPHeaderStream.cpp + src/HTTPIOStream.cpp + src/HTTPMessage.cpp + src/HTTPRequest.cpp + src/HTTPRequestHandler.cpp + src/HTTPRequestHandlerFactory.cpp + src/HTTPResponse.cpp + src/HTTPServer.cpp + src/HTTPServerConnection.cpp + src/HTTPServerConnectionFactory.cpp + src/HTTPServerParams.cpp + src/HTTPServerRequest.cpp + src/HTTPServerRequestImpl.cpp + src/HTTPServerResponse.cpp + src/HTTPServerResponseImpl.cpp + src/HTTPServerSession.cpp + src/HTTPSession.cpp + src/HTTPSessionFactory.cpp + src/HTTPSessionInstantiator.cpp + src/HTTPStream.cpp + src/HTTPStreamFactory.cpp + src/HostEntry.cpp + src/ICMPClient.cpp + src/ICMPEventArgs.cpp + src/ICMPPacket.cpp + src/ICMPPacketImpl.cpp + src/ICMPSocket.cpp + src/ICMPSocketImpl.cpp + src/ICMPv4PacketImpl.cpp + src/IPAddress.cpp + src/IPAddressImpl.cpp + src/MailMessage.cpp + src/MailRecipient.cpp + src/MailStream.cpp + src/MediaType.cpp + src/MessageHeader.cpp + src/MulticastSocket.cpp + src/MultipartReader.cpp + src/MultipartWriter.cpp + src/NTPClient.cpp + src/NTPEventArgs.cpp + src/NTPPacket.cpp + src/NameValueCollection.cpp + src/Net.cpp + src/NetException.cpp + src/NetworkInterface.cpp + src/NullPartHandler.cpp + src/OAuth10Credentials.cpp + src/OAuth20Credentials.cpp + src/POP3ClientSession.cpp + src/PartHandler.cpp + src/PartSource.cpp + src/PartStore.cpp + src/PollSet.cpp + src/QuotedPrintableDecoder.cpp + src/QuotedPrintableEncoder.cpp + src/RawSocket.cpp + src/RawSocketImpl.cpp + src/RemoteSyslogChannel.cpp + src/RemoteSyslogListener.cpp + src/SMTPChannel.cpp + src/SMTPClientSession.cpp + src/ServerSocket.cpp + src/ServerSocketImpl.cpp + src/Socket.cpp + src/SocketAddress.cpp + src/SocketAddressImpl.cpp + src/SocketImpl.cpp + src/SocketNotification.cpp + src/SocketNotifier.cpp + src/SocketReactor.cpp + src/SocketStream.cpp + src/StreamSocket.cpp + src/StreamSocketImpl.cpp + src/StringPartSource.cpp + src/TCPServer.cpp + src/TCPServerConnection.cpp + src/TCPServerConnectionFactory.cpp + src/TCPServerDispatcher.cpp + src/TCPServerParams.cpp + src/WebSocket.cpp + src/WebSocketImpl.cpp +) + +END() diff --git a/contrib/libs/poco/NetSSL_OpenSSL/ya.make b/contrib/libs/poco/NetSSL_OpenSSL/ya.make new file mode 100644 index 00000000000..10063312d1a --- /dev/null +++ b/contrib/libs/poco/NetSSL_OpenSSL/ya.make @@ -0,0 +1,85 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/openssl + contrib/libs/poco/Crypto + contrib/libs/poco/Foundation + contrib/libs/poco/JSON + contrib/libs/poco/Net + contrib/libs/poco/Util + contrib/libs/poco/XML +) + +ADDINCL( + GLOBAL contrib/libs/poco/NetSSL_OpenSSL/include + contrib/libs/poco/Crypto/include + contrib/libs/poco/Foundation/include + contrib/libs/poco/Net/include + contrib/libs/poco/NetSSL_OpenSSL/src + contrib/libs/poco/Util/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DPOCO_ENABLE_CPP11 + -DPOCO_ENABLE_CPP14 + -DPOCO_NO_AUTOMATIC_LIBS + -DPOCO_UNBUNDLED +) + +IF (OS_DARWIN) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_NO_STAT64 + ) +ELSEIF (OS_LINUX) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_HAVE_FD_EPOLL + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DPOCO_OS_FAMILY_WINDOWS + ) +ENDIF() + +SRCS( + src/AcceptCertificateHandler.cpp + src/CertificateHandlerFactory.cpp + src/CertificateHandlerFactoryMgr.cpp + src/ConsoleCertificateHandler.cpp + src/Context.cpp + src/HTTPSClientSession.cpp + src/HTTPSSessionInstantiator.cpp + src/HTTPSStreamFactory.cpp + src/InvalidCertificateHandler.cpp + src/KeyConsoleHandler.cpp + src/KeyFileHandler.cpp + src/PrivateKeyFactory.cpp + src/PrivateKeyFactoryMgr.cpp + src/PrivateKeyPassphraseHandler.cpp + src/RejectCertificateHandler.cpp + src/SSLException.cpp + src/SSLManager.cpp + src/SecureSMTPClientSession.cpp + src/SecureServerSocket.cpp + src/SecureServerSocketImpl.cpp + src/SecureSocketImpl.cpp + src/SecureStreamSocket.cpp + src/SecureStreamSocketImpl.cpp + src/Session.cpp + src/Utility.cpp + src/VerificationErrorArgs.cpp + src/X509Certificate.cpp +) + +END() diff --git a/contrib/libs/poco/Util/ya.make b/contrib/libs/poco/Util/ya.make new file mode 100644 index 00000000000..060aeb8a8f2 --- /dev/null +++ b/contrib/libs/poco/Util/ya.make @@ -0,0 +1,82 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/expat + contrib/libs/poco/Foundation + contrib/libs/poco/JSON + contrib/libs/poco/XML +) + +ADDINCL( + GLOBAL contrib/libs/poco/Util/include + contrib/libs/expat + contrib/libs/poco/Foundation/include + contrib/libs/poco/JSON/include + contrib/libs/poco/Util/src + contrib/libs/poco/XML/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DPOCO_ENABLE_CPP11 + -DPOCO_ENABLE_CPP14 + -DPOCO_NO_AUTOMATIC_LIBS + -DPOCO_UNBUNDLED +) + +IF (OS_DARWIN) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_NO_STAT64 + ) +ELSEIF (OS_LINUX) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_HAVE_FD_EPOLL + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DPOCO_OS_FAMILY_WINDOWS + ) +ENDIF() + +SRCS( + src/AbstractConfiguration.cpp + src/Application.cpp + src/ConfigurationMapper.cpp + src/ConfigurationView.cpp + src/FilesystemConfiguration.cpp + src/HelpFormatter.cpp + src/IniFileConfiguration.cpp + src/IntValidator.cpp + src/JSONConfiguration.cpp + src/LayeredConfiguration.cpp + src/LoggingConfigurator.cpp + src/LoggingSubsystem.cpp + src/MapConfiguration.cpp + src/Option.cpp + src/OptionCallback.cpp + src/OptionException.cpp + src/OptionProcessor.cpp + src/OptionSet.cpp + src/PropertyFileConfiguration.cpp + src/RegExpValidator.cpp + src/ServerApplication.cpp + src/Subsystem.cpp + src/SystemConfiguration.cpp + src/Timer.cpp + src/TimerTask.cpp + src/Validator.cpp + src/XMLConfiguration.cpp +) + +END() diff --git a/contrib/libs/poco/XML/ya.make b/contrib/libs/poco/XML/ya.make new file mode 100644 index 00000000000..3dd7cddfa99 --- /dev/null +++ b/contrib/libs/poco/XML/ya.make @@ -0,0 +1,125 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/expat + contrib/libs/poco/Foundation +) + +ADDINCL( + GLOBAL contrib/libs/expat + GLOBAL contrib/libs/poco/XML/include + contrib/libs/poco/Foundation/include + contrib/libs/poco/XML/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DHAVE_EXPAT_CONFIG_H + -DPOCO_ENABLE_CPP11 + -DPOCO_ENABLE_CPP14 + -DPOCO_NO_AUTOMATIC_LIBS + -DPOCO_UNBUNDLED + -DXML_DTD + -DXML_NS +) + +IF (OS_DARWIN) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_NO_STAT64 + ) +ELSEIF (OS_LINUX) + CFLAGS( + -DPOCO_OS_FAMILY_UNIX + -DPOCO_HAVE_FD_EPOLL + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DPOCO_OS_FAMILY_WINDOWS + ) +ENDIF() + +SRCS( + src/AbstractContainerNode.cpp + src/AbstractNode.cpp + src/Attr.cpp + src/AttrMap.cpp + src/Attributes.cpp + src/AttributesImpl.cpp + src/CDATASection.cpp + src/CharacterData.cpp + src/ChildNodesList.cpp + src/Comment.cpp + src/ContentHandler.cpp + src/DOMBuilder.cpp + src/DOMException.cpp + src/DOMImplementation.cpp + src/DOMObject.cpp + src/DOMParser.cpp + src/DOMSerializer.cpp + src/DOMWriter.cpp + src/DTDHandler.cpp + src/DTDMap.cpp + src/DeclHandler.cpp + src/DefaultHandler.cpp + src/Document.cpp + src/DocumentEvent.cpp + src/DocumentFragment.cpp + src/DocumentType.cpp + src/Element.cpp + src/ElementsByTagNameList.cpp + src/Entity.cpp + src/EntityReference.cpp + src/EntityResolver.cpp + src/EntityResolverImpl.cpp + src/ErrorHandler.cpp + src/Event.cpp + src/EventDispatcher.cpp + src/EventException.cpp + src/EventListener.cpp + src/EventTarget.cpp + src/InputSource.cpp + src/LexicalHandler.cpp + src/Locator.cpp + src/LocatorImpl.cpp + src/MutationEvent.cpp + src/Name.cpp + src/NamePool.cpp + src/NamedNodeMap.cpp + src/NamespaceStrategy.cpp + src/NamespaceSupport.cpp + src/Node.cpp + src/NodeAppender.cpp + src/NodeFilter.cpp + src/NodeIterator.cpp + src/NodeList.cpp + src/Notation.cpp + src/ParserEngine.cpp + src/ProcessingInstruction.cpp + src/QName.cpp + src/SAXException.cpp + src/SAXParser.cpp + src/Text.cpp + src/TreeWalker.cpp + src/ValueTraits.cpp + src/WhitespaceFilter.cpp + src/XMLException.cpp + src/XMLFilter.cpp + src/XMLFilterImpl.cpp + src/XMLReader.cpp + src/XMLStreamParser.cpp + src/XMLStreamParserException.cpp + src/XMLString.cpp + src/XMLWriter.cpp +) + +END() diff --git a/contrib/libs/protobuf-mutator/ya.make b/contrib/libs/protobuf-mutator/ya.make new file mode 100644 index 00000000000..e7f5abf770c --- /dev/null +++ b/contrib/libs/protobuf-mutator/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.1) + +ORIGINAL_SOURCE(https://github.com/google/libprotobuf-mutator/archive/v1.1.tar.gz) + +PEERDIR( + contrib/libs/protobuf +) + +ADDINCL( + GLOBAL contrib/libs/protobuf-mutator +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + src/binary_format.cc + src/libfuzzer/libfuzzer_macro.cc + src/libfuzzer/libfuzzer_mutator.cc + src/mutator.cc + src/text_format.cc + src/utf8_fix.cc +) + +END() diff --git a/contrib/libs/protobuf/builtin_proto/protos_from_protobuf/ya.make b/contrib/libs/protobuf/builtin_proto/protos_from_protobuf/ya.make new file mode 100644 index 00000000000..d5c6d3239aa --- /dev/null +++ b/contrib/libs/protobuf/builtin_proto/protos_from_protobuf/ya.make @@ -0,0 +1,41 @@ +PROTO_LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +EXCLUDE_TAGS( + CPP_PROTO + GO_PROTO +) + +NO_MYPY() + +NO_OPTIMIZE_PY_PROTOS() + +DISABLE(NEED_GOOGLE_PROTO_PEERDIRS) + +PY_NAMESPACE(.) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/protobuf/src +) + +SRCDIR(contrib/libs/protobuf/src) + +SRCS( + google/protobuf/any.proto + google/protobuf/api.proto + google/protobuf/descriptor.proto + google/protobuf/duration.proto + google/protobuf/empty.proto + google/protobuf/field_mask.proto + google/protobuf/source_context.proto + google/protobuf/struct.proto + google/protobuf/timestamp.proto + google/protobuf/type.proto + google/protobuf/wrappers.proto +) + +END() diff --git a/contrib/libs/protobuf/builtin_proto/protos_from_protoc/ya.make b/contrib/libs/protobuf/builtin_proto/protos_from_protoc/ya.make new file mode 100644 index 00000000000..23b5a349f90 --- /dev/null +++ b/contrib/libs/protobuf/builtin_proto/protos_from_protoc/ya.make @@ -0,0 +1,35 @@ +PROTO_LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(BSD-3-Clause) + +EXCLUDE_TAGS( + CPP_PROTO + GO_PROTO +) + +NO_MYPY() + +NO_OPTIMIZE_PY_PROTOS() + +DISABLE(NEED_GOOGLE_PROTO_PEERDIRS) + +PY_NAMESPACE(.) + +PROTO_NAMESPACE( + GLOBAL + contrib/libs/protoc/src +) + +SRCDIR(contrib/libs/protoc/src) + +PEERDIR( + contrib/libs/protobuf/builtin_proto/protos_from_protobuf +) + +SRCS( + google/protobuf/compiler/plugin.proto +) + +END() diff --git a/contrib/libs/protobuf/builtin_proto/ya.make b/contrib/libs/protobuf/builtin_proto/ya.make new file mode 100644 index 00000000000..b3ca1755b45 --- /dev/null +++ b/contrib/libs/protobuf/builtin_proto/ya.make @@ -0,0 +1,4 @@ +RECURSE( + protos_from_protobuf + protos_from_protoc +) diff --git a/contrib/libs/protobuf/ya.make b/contrib/libs/protobuf/ya.make new file mode 100644 index 00000000000..2223b2f0ab5 --- /dev/null +++ b/contrib/libs/protobuf/ya.make @@ -0,0 +1,147 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + Protobuf-License +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PROVIDES(protobuf) + +VERSION(3.19.0) + +ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.19.0.tar.gz) + +PEERDIR( + contrib/libs/zlib +) + +ADDINCL( + GLOBAL contrib/libs/protobuf/src + GLOBAL FOR + proto + contrib/libs/protobuf/src +) + +NO_COMPILER_WARNINGS() + +CFLAGS( + -DHAVE_CONFIG_H + -DHAVE_PTHREAD=1 + -DHAVE_ZLIB=1 +) + +IF (OS_ANDROID) + EXTRALIBS(log) +ENDIF() + +SRCS( + GLOBAL src/google/protobuf/generated_message_util.cc + src/google/protobuf/any.cc + src/google/protobuf/any.pb.cc + src/google/protobuf/any_lite.cc + src/google/protobuf/api.pb.cc + src/google/protobuf/arena.cc + src/google/protobuf/arenastring.cc + src/google/protobuf/descriptor.cc + src/google/protobuf/descriptor.pb.cc + src/google/protobuf/descriptor_database.cc + src/google/protobuf/duration.pb.cc + src/google/protobuf/dynamic_message.cc + src/google/protobuf/empty.pb.cc + src/google/protobuf/extension_set.cc + src/google/protobuf/extension_set_heavy.cc + src/google/protobuf/field_mask.pb.cc + src/google/protobuf/generated_enum_util.cc + src/google/protobuf/generated_message_bases.cc + src/google/protobuf/generated_message_reflection.cc + src/google/protobuf/generated_message_table_driven.cc + src/google/protobuf/generated_message_table_driven_lite.cc + src/google/protobuf/generated_message_tctable_full.cc + src/google/protobuf/generated_message_tctable_lite.cc + src/google/protobuf/implicit_weak_message.cc + src/google/protobuf/inlined_string_field.cc + src/google/protobuf/io/coded_stream.cc + src/google/protobuf/io/gzip_stream.cc + src/google/protobuf/io/io_win32.cc + src/google/protobuf/io/printer.cc + src/google/protobuf/io/strtod.cc + src/google/protobuf/io/tokenizer.cc + src/google/protobuf/io/zero_copy_stream.cc + src/google/protobuf/io/zero_copy_stream_impl.cc + src/google/protobuf/io/zero_copy_stream_impl_lite.cc + src/google/protobuf/json_util.cc + src/google/protobuf/map.cc + src/google/protobuf/map_field.cc + src/google/protobuf/message.cc + src/google/protobuf/message_lite.cc + src/google/protobuf/messagext.cc + src/google/protobuf/parse_context.cc + src/google/protobuf/reflection_ops.cc + src/google/protobuf/repeated_field.cc + src/google/protobuf/repeated_ptr_field.cc + src/google/protobuf/service.cc + src/google/protobuf/source_context.pb.cc + src/google/protobuf/struct.pb.cc + src/google/protobuf/stubs/bytestream.cc + src/google/protobuf/stubs/common.cc + src/google/protobuf/stubs/int128.cc + src/google/protobuf/stubs/status.cc + src/google/protobuf/stubs/statusor.cc + src/google/protobuf/stubs/stringpiece.cc + src/google/protobuf/stubs/stringprintf.cc + src/google/protobuf/stubs/structurally_valid.cc + src/google/protobuf/stubs/strutil.cc + src/google/protobuf/stubs/substitute.cc + src/google/protobuf/stubs/time.cc + src/google/protobuf/text_format.cc + src/google/protobuf/timestamp.pb.cc + src/google/protobuf/type.pb.cc + src/google/protobuf/unknown_field_set.cc + src/google/protobuf/util/delimited_message_util.cc + src/google/protobuf/util/field_comparator.cc + src/google/protobuf/util/field_mask_util.cc + src/google/protobuf/util/internal/datapiece.cc + src/google/protobuf/util/internal/default_value_objectwriter.cc + src/google/protobuf/util/internal/error_listener.cc + src/google/protobuf/util/internal/field_mask_utility.cc + src/google/protobuf/util/internal/json_escaping.cc + src/google/protobuf/util/internal/json_objectwriter.cc + src/google/protobuf/util/internal/json_stream_parser.cc + src/google/protobuf/util/internal/object_writer.cc + src/google/protobuf/util/internal/proto_writer.cc + src/google/protobuf/util/internal/protostream_objectsource.cc + src/google/protobuf/util/internal/protostream_objectwriter.cc + src/google/protobuf/util/internal/type_info.cc + src/google/protobuf/util/internal/utility.cc + src/google/protobuf/util/json_util.cc + src/google/protobuf/util/message_differencer.cc + src/google/protobuf/util/time_util.cc + src/google/protobuf/util/type_resolver_util.cc + src/google/protobuf/wire_format.cc + src/google/protobuf/wire_format_lite.cc + src/google/protobuf/wrappers.pb.cc +) + +FILES( + src/google/protobuf/any.proto + src/google/protobuf/api.proto + src/google/protobuf/descriptor.proto + src/google/protobuf/duration.proto + src/google/protobuf/empty.proto + src/google/protobuf/field_mask.proto + src/google/protobuf/source_context.proto + src/google/protobuf/struct.proto + src/google/protobuf/timestamp.proto + src/google/protobuf/type.proto + src/google/protobuf/wrappers.proto +) + +END() + +RECURSE( + builtin_proto +) diff --git a/contrib/libs/protoc/ya.make b/contrib/libs/protoc/ya.make new file mode 100644 index 00000000000..f1134013cb7 --- /dev/null +++ b/contrib/libs/protoc/ya.make @@ -0,0 +1,126 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + Protobuf-License +) + +PROVIDES(protoc) + +VERSION(3.19.0) + +ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.19.0.tar.gz) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/protobuf +) + +ADDINCL( + GLOBAL contrib/libs/protoc/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DHAVE_CONFIG_H + -DHAVE_PTHREAD=1 + -DHAVE_ZLIB=1 +) + +SRCS( + src/google/protobuf/compiler/code_generator.cc + src/google/protobuf/compiler/command_line_interface.cc + src/google/protobuf/compiler/cpp/cpp_enum.cc + src/google/protobuf/compiler/cpp/cpp_enum_field.cc + src/google/protobuf/compiler/cpp/cpp_extension.cc + src/google/protobuf/compiler/cpp/cpp_field.cc + src/google/protobuf/compiler/cpp/cpp_file.cc + src/google/protobuf/compiler/cpp/cpp_generator.cc + src/google/protobuf/compiler/cpp/cpp_helpers.cc + src/google/protobuf/compiler/cpp/cpp_map_field.cc + src/google/protobuf/compiler/cpp/cpp_message.cc + src/google/protobuf/compiler/cpp/cpp_message_field.cc + src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc + src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc + src/google/protobuf/compiler/cpp/cpp_primitive_field.cc + src/google/protobuf/compiler/cpp/cpp_service.cc + src/google/protobuf/compiler/cpp/cpp_string_field.cc + src/google/protobuf/compiler/csharp/csharp_doc_comment.cc + src/google/protobuf/compiler/csharp/csharp_enum.cc + src/google/protobuf/compiler/csharp/csharp_enum_field.cc + src/google/protobuf/compiler/csharp/csharp_field_base.cc + src/google/protobuf/compiler/csharp/csharp_generator.cc + src/google/protobuf/compiler/csharp/csharp_helpers.cc + src/google/protobuf/compiler/csharp/csharp_map_field.cc + src/google/protobuf/compiler/csharp/csharp_message.cc + src/google/protobuf/compiler/csharp/csharp_message_field.cc + src/google/protobuf/compiler/csharp/csharp_primitive_field.cc + src/google/protobuf/compiler/csharp/csharp_reflection_class.cc + src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc + src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc + src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc + src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc + src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc + src/google/protobuf/compiler/importer.cc + src/google/protobuf/compiler/java/java_context.cc + src/google/protobuf/compiler/java/java_doc_comment.cc + src/google/protobuf/compiler/java/java_enum.cc + src/google/protobuf/compiler/java/java_enum_field.cc + src/google/protobuf/compiler/java/java_enum_field_lite.cc + src/google/protobuf/compiler/java/java_enum_lite.cc + src/google/protobuf/compiler/java/java_extension.cc + src/google/protobuf/compiler/java/java_extension_lite.cc + src/google/protobuf/compiler/java/java_field.cc + src/google/protobuf/compiler/java/java_file.cc + src/google/protobuf/compiler/java/java_generator.cc + src/google/protobuf/compiler/java/java_generator_factory.cc + src/google/protobuf/compiler/java/java_helpers.cc + src/google/protobuf/compiler/java/java_kotlin_generator.cc + src/google/protobuf/compiler/java/java_map_field.cc + src/google/protobuf/compiler/java/java_map_field_lite.cc + src/google/protobuf/compiler/java/java_message.cc + src/google/protobuf/compiler/java/java_message_builder.cc + src/google/protobuf/compiler/java/java_message_builder_lite.cc + src/google/protobuf/compiler/java/java_message_field.cc + src/google/protobuf/compiler/java/java_message_field_lite.cc + src/google/protobuf/compiler/java/java_message_lite.cc + src/google/protobuf/compiler/java/java_name_resolver.cc + src/google/protobuf/compiler/java/java_primitive_field.cc + src/google/protobuf/compiler/java/java_primitive_field_lite.cc + src/google/protobuf/compiler/java/java_service.cc + src/google/protobuf/compiler/java/java_shared_code_generator.cc + src/google/protobuf/compiler/java/java_string_field.cc + src/google/protobuf/compiler/java/java_string_field_lite.cc + src/google/protobuf/compiler/js/js_generator.cc + src/google/protobuf/compiler/js/well_known_types_embed.cc + src/google/protobuf/compiler/objectivec/objectivec_enum.cc + src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc + src/google/protobuf/compiler/objectivec/objectivec_extension.cc + src/google/protobuf/compiler/objectivec/objectivec_field.cc + src/google/protobuf/compiler/objectivec/objectivec_file.cc + src/google/protobuf/compiler/objectivec/objectivec_generator.cc + src/google/protobuf/compiler/objectivec/objectivec_helpers.cc + src/google/protobuf/compiler/objectivec/objectivec_map_field.cc + src/google/protobuf/compiler/objectivec/objectivec_message.cc + src/google/protobuf/compiler/objectivec/objectivec_message_field.cc + src/google/protobuf/compiler/objectivec/objectivec_oneof.cc + src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc + src/google/protobuf/compiler/parser.cc + src/google/protobuf/compiler/perlxs/perlxs_generator.cc + src/google/protobuf/compiler/perlxs/perlxs_helpers.cc + src/google/protobuf/compiler/php/php_generator.cc + src/google/protobuf/compiler/plugin.cc + src/google/protobuf/compiler/plugin.pb.cc + src/google/protobuf/compiler/python/python_generator.cc + src/google/protobuf/compiler/ruby/ruby_generator.cc + src/google/protobuf/compiler/subprocess.cc + src/google/protobuf/compiler/zip_writer.cc +) + +END() diff --git a/contrib/libs/python/Include/ya.make b/contrib/libs/python/Include/ya.make new file mode 100644 index 00000000000..970d0b1b1db --- /dev/null +++ b/contrib/libs/python/Include/ya.make @@ -0,0 +1,23 @@ +PY23_LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(YandexOpen) + +NO_PYTHON_INCLUDES() + +ADDINCL(GLOBAL contrib/libs/python/Include) + +IF (PYTHON2) + CFLAGS(GLOBAL -DUSE_PYTHON2) + PEERDIR( + contrib/tools/python/lib + ) +ELSE() + CFLAGS(GLOBAL -DUSE_PYTHON3) + PEERDIR( + contrib/tools/python3/src + ) +ENDIF() + +END() diff --git a/contrib/libs/python/ya.make b/contrib/libs/python/ya.make new file mode 100644 index 00000000000..95e7f8744e9 --- /dev/null +++ b/contrib/libs/python/ya.make @@ -0,0 +1,46 @@ +PY23_LIBRARY() + +LICENSE(YandexOpen) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_PYTHON_INCLUDES() + +IF (USE_ARCADIA_PYTHON) + PEERDIR( + contrib/libs/python/Include + library/python/symbols/module + library/python/symbols/libc + library/python/symbols/python + ) + IF (NOT OS_WINDOWS AND NOT OPENSOURCE) + PEERDIR( + library/python/symbols/uuid + ) + ENDIF() + IF (MODULE_TAG == "PY2") + PEERDIR( + contrib/tools/python/lib + library/python/runtime + ) + ELSE() + PEERDIR( + contrib/tools/python3/lib + library/python/runtime_py3 + ) + ENDIF() +ELSE() + IF (USE_SYSTEM_PYTHON) + PEERDIR( + build/platform/python + ) + ELSE() + CFLAGS(GLOBAL $PYTHON_INCLUDE) + ENDIF() +ENDIF() + +END() + +RECURSE( + Include +) diff --git a/contrib/libs/rapidjson/ya.make b/contrib/libs/rapidjson/ya.make new file mode 100644 index 00000000000..16d73170a26 --- /dev/null +++ b/contrib/libs/rapidjson/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +LICENSE( + BSD-3-Clause AND + ISC AND + JSON AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.1.0) + +ADDINCL( + contrib/libs/rapidjson/include +) + +END() diff --git a/contrib/libs/re2/re2/testing/ya.make b/contrib/libs/re2/re2/testing/ya.make new file mode 100644 index 00000000000..393d51ec02b --- /dev/null +++ b/contrib/libs/re2/re2/testing/ya.make @@ -0,0 +1,50 @@ +# Generated by devtools/yamaker. + +GTEST() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/re2 +) + +ADDINCL( + contrib/libs/re2 +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +EXPLICIT_DATA() + +SRCDIR(contrib/libs/re2) + +SRCS( + re2/testing/backtrack.cc + re2/testing/charclass_test.cc + re2/testing/compile_test.cc + re2/testing/dump.cc + re2/testing/exhaustive_tester.cc + re2/testing/filtered_re2_test.cc + re2/testing/mimics_pcre_test.cc + re2/testing/null_walker.cc + re2/testing/parse_test.cc + re2/testing/possible_match_test.cc + re2/testing/re2_arg_test.cc + re2/testing/re2_test.cc + re2/testing/regexp_generator.cc + re2/testing/regexp_test.cc + re2/testing/required_prefix_test.cc + re2/testing/search_test.cc + re2/testing/set_test.cc + re2/testing/simplify_test.cc + re2/testing/string_generator.cc + re2/testing/string_generator_test.cc + re2/testing/tester.cc + util/pcre.cc +) + +END() diff --git a/contrib/libs/re2/ya.make b/contrib/libs/re2/ya.make new file mode 100644 index 00000000000..a63dde4ace4 --- /dev/null +++ b/contrib/libs/re2/ya.make @@ -0,0 +1,59 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSD-3-Clause AND + X11-Lucent +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2023-03-01) + +ORIGINAL_SOURCE(https://github.com/google/re2/archive/2023-03-01.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/re2/include + contrib/libs/re2 +) + +NO_COMPILER_WARNINGS() + +IF (WITH_VALGRIND) + CFLAGS( + GLOBAL -DRE2_ON_VALGRIND + ) +ENDIF() + +SRCS( + re2/bitmap256.cc + re2/bitstate.cc + re2/compile.cc + re2/dfa.cc + re2/filtered_re2.cc + re2/mimics_pcre.cc + re2/nfa.cc + re2/onepass.cc + re2/parse.cc + re2/perl_groups.cc + re2/prefilter.cc + re2/prefilter_tree.cc + re2/prog.cc + re2/re2.cc + re2/regexp.cc + re2/set.cc + re2/simplify.cc + re2/stringpiece.cc + re2/tostring.cc + re2/unicode_casefold.cc + re2/unicode_groups.cc + util/rune.cc + util/strutil.cc +) + +END() + +RECURSE( + re2/testing +) diff --git a/contrib/libs/snappy/ya.make b/contrib/libs/snappy/ya.make new file mode 100644 index 00000000000..b19c972e612 --- /dev/null +++ b/contrib/libs/snappy/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.1.9) + +ORIGINAL_SOURCE(https://github.com/google/snappy/archive/1.1.9.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/snappy/include +) + +NO_COMPILER_WARNINGS() + +CFLAGS( + -DHAVE_CONFIG_H +) + +SRCS( + snappy-c.cc + snappy-sinksource.cc + snappy-stubs-internal.cc + snappy.cc +) + +END() diff --git a/contrib/libs/sparsehash/ya.make b/contrib/libs/sparsehash/ya.make new file mode 100644 index 00000000000..c409d1d7f03 --- /dev/null +++ b/contrib/libs/sparsehash/ya.make @@ -0,0 +1,17 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2.0.4) + +ORIGINAL_SOURCE(https://github.com/sparsehash/sparsehash/archive/sparsehash-2.0.4.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/sparsehash/src +) + +END() diff --git a/contrib/libs/sqlite3/ya.make b/contrib/libs/sqlite3/ya.make new file mode 100644 index 00000000000..9922ed06f96 --- /dev/null +++ b/contrib/libs/sqlite3/ya.make @@ -0,0 +1,64 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + Public-Domain AND + blessing +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(3.40.1) + +ORIGINAL_SOURCE(https://github.com/sqlite/sqlite/archive/version-3.40.1.tar.gz) + +ADDINCL( + contrib/libs/sqlite3 +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DBUILD_sqlite + -DHAVE_USLEEP + -DSQLITE_ENABLE_COLUMN_METADATA + -DSQLITE_ENABLE_DBSTAT_VTAB + -DSQLITE_ENABLE_FTS3 + -DSQLITE_ENABLE_FTS3_PARENTHESIS + -DSQLITE_ENABLE_FTS3_TOKENIZER + -DSQLITE_ENABLE_FTS4 + -DSQLITE_ENABLE_FTS5 + -DSQLITE_ENABLE_JSON1 + -DSQLITE_ENABLE_MATH_FUNCTIONS + -DSQLITE_ENABLE_RTREE + -DSQLITE_ENABLE_STMT_SCANSTATUS + -DSQLITE_ENABLE_UNLOCK_NOTIFY + -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT + -DSQLITE_HAVE_ZLIB=1 + -DSQLITE_MAX_EXPR_DEPTH=10000 + -DSQLITE_MAX_VARIABLE_NUMBER=250000 + -DSQLITE_SECURE_DELETE + -DSQLITE_SOUNDEX + -DSQLITE_TEMP_STORE=1 + -DSQLITE_THREADSAFE=1 +) + +IF (OS_WINDOWS) + CFLAGS( + -DSQLITE_OS_WIN + ) +ELSE() + CFLAGS( + -DSQLITE_OS_UNIX + ) +ENDIF() + +SRCS( + sqlite3.c + test_multiplex.c +) + +END() diff --git a/contrib/libs/t1ha/ya.make b/contrib/libs/t1ha/ya.make new file mode 100644 index 00000000000..5b4b7e500ea --- /dev/null +++ b/contrib/libs/t1ha/ya.make @@ -0,0 +1,40 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + Protestware AND + Zlib +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2.1.4) + +ORIGINAL_SOURCE(https://github.com/PositiveTechnologies/t1ha/archive/v2.1.4.tar.gz) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCS( + src/t1ha0.c + src/t1ha0_ia32aes_avx.c + src/t1ha0_ia32aes_avx2.c + src/t1ha0_ia32aes_noavx.c + src/t1ha0_selfcheck.c + src/t1ha1.c + src/t1ha1_selfcheck.c + src/t1ha2.c + src/t1ha2_selfcheck.c + src/t1ha_selfcheck.c + src/t1ha_selfcheck_all.c +) + +IF (ARCH_X86_64) + CFLAGS( + -maes + ) +ENDIF() + +END() diff --git a/contrib/libs/tbb/ya.make b/contrib/libs/tbb/ya.make new file mode 100644 index 00000000000..595b2fc64a2 --- /dev/null +++ b/contrib/libs/tbb/ya.make @@ -0,0 +1,91 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +VERSION(2021.8.0) + +ORIGINAL_SOURCE(https://github.com/oneapi-src/oneTBB/archive/v2021.8.0.tar.gz) + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/libs/tbb/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -D__TBB_BUILD +) + +SRCS( + src/tbb/address_waiter.cpp + src/tbb/allocator.cpp + src/tbb/arena.cpp + src/tbb/arena_slot.cpp + src/tbb/concurrent_bounded_queue.cpp + src/tbb/dynamic_link.cpp + src/tbb/exception.cpp + src/tbb/global_control.cpp + src/tbb/governor.cpp + src/tbb/main.cpp + src/tbb/market.cpp + src/tbb/misc.cpp + src/tbb/misc_ex.cpp + src/tbb/observer_proxy.cpp + src/tbb/parallel_pipeline.cpp + src/tbb/private_server.cpp + src/tbb/profiling.cpp + src/tbb/queuing_rw_mutex.cpp + src/tbb/rml_tbb.cpp + src/tbb/rtm_mutex.cpp + src/tbb/rtm_rw_mutex.cpp + src/tbb/semaphore.cpp + src/tbb/small_object_pool.cpp + src/tbb/task.cpp + src/tbb/task_dispatcher.cpp + src/tbb/task_group_context.cpp + src/tbb/version.cpp +) + +IF (CLANG OR CLANG_CL) + IF (ARCH_I386 OR ARCH_I686 OR ARCH_X86_64) + CFLAGS( + -mrtm + -mwaitpkg + ) + ENDIF() +ENDIF() + +IF (OS_WINDOWS) + CFLAGS( + -DUSE_WINTHREAD + ) +ELSE() + CFLAGS( + -DUSE_PTHREAD + ) +ENDIF() + +IF (GCC) + CFLAGS( + -flifetime-dse=1 + -mrtm + ) +ENDIF() + +IF (NOT ARCH_ARM64) + CFLAGS( + -D__TBB_USE_ITT_NOTIFY + -DDO_ITT_NOTIFY + ) + SRCS( + src/tbb/itt_notify.cpp + ) +ENDIF() + +END() diff --git a/contrib/libs/tcmalloc/common.inc b/contrib/libs/tcmalloc/common.inc new file mode 100644 index 00000000000..077942c3871 --- /dev/null +++ b/contrib/libs/tcmalloc/common.inc @@ -0,0 +1,58 @@ +GLOBAL_SRCS( + # TCMalloc + tcmalloc/tcmalloc.cc + + # Common Sources + tcmalloc/arena.cc + tcmalloc/background.cc + tcmalloc/central_freelist.cc + tcmalloc/common.cc + tcmalloc/cpu_cache.cc + tcmalloc/experimental_pow2_below64_size_class.cc + tcmalloc/experimental_pow2_size_class.cc + tcmalloc/legacy_size_classes.cc + tcmalloc/guarded_page_allocator.cc + tcmalloc/huge_address_map.cc + tcmalloc/huge_allocator.cc + tcmalloc/huge_cache.cc + tcmalloc/huge_page_aware_allocator.cc + tcmalloc/page_allocator.cc + tcmalloc/page_allocator_interface.cc + tcmalloc/page_heap.cc + tcmalloc/pagemap.cc + tcmalloc/parameters.cc + tcmalloc/peak_heap_tracker.cc + tcmalloc/sampler.cc + tcmalloc/size_classes.cc + tcmalloc/span.cc + tcmalloc/stack_trace_table.cc + tcmalloc/static_vars.cc + tcmalloc/stats.cc + tcmalloc/system-alloc.cc + tcmalloc/thread_cache.cc + tcmalloc/transfer_cache.cc + + # Common deps + tcmalloc/experiment.cc + tcmalloc/noruntime_size_classes.cc + + # Internal libraries + tcmalloc/internal/cache_topology.cc + tcmalloc/internal/environment.cc + tcmalloc/internal/logging.cc + tcmalloc/internal/memory_stats.cc + tcmalloc/internal/mincore.cc + tcmalloc/internal/numa.cc + tcmalloc/internal/percpu.cc + tcmalloc/internal/percpu_rseq_asm.S + tcmalloc/internal/percpu_rseq_unsupported.cc + tcmalloc/internal/util.cc +) + +PEERDIR( + contrib/restricted/abseil-cpp + contrib/libs/tcmalloc/malloc_extension +) + +NO_UTIL() +NO_COMPILER_WARNINGS() diff --git a/contrib/libs/tcmalloc/default/ya.make b/contrib/libs/tcmalloc/default/ya.make new file mode 100644 index 00000000000..b610084ea6b --- /dev/null +++ b/contrib/libs/tcmalloc/default/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) +ALLOCATOR_IMPL() + +SRCDIR(contrib/libs/tcmalloc) + +INCLUDE(../common.inc) + +GLOBAL_SRCS( + # Options + tcmalloc/want_hpaa_subrelease.cc +) + +END() diff --git a/contrib/libs/tcmalloc/dynamic/ya.make b/contrib/libs/tcmalloc/dynamic/ya.make new file mode 100644 index 00000000000..9c008b201e2 --- /dev/null +++ b/contrib/libs/tcmalloc/dynamic/ya.make @@ -0,0 +1 @@ +DLL_FOR(contrib/libs/tcmalloc tcmalloc) diff --git a/contrib/libs/tcmalloc/malloc_extension/ya.make b/contrib/libs/tcmalloc/malloc_extension/ya.make new file mode 100644 index 00000000000..a2044f60c2a --- /dev/null +++ b/contrib/libs/tcmalloc/malloc_extension/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +# https://github.com/google/tcmalloc +VERSION(2020-11-23-a643d89610317be1eff9f7298104eef4c987d8d5) + +SRCDIR(contrib/libs/tcmalloc) + +SRCS( + tcmalloc/malloc_extension.cc +) + +PEERDIR( + contrib/restricted/abseil-cpp +) + +ADDINCL( + GLOBAL contrib/libs/tcmalloc +) + +CFLAGS( + -DTCMALLOC_256K_PAGES +) + +END() diff --git a/contrib/libs/tcmalloc/no_percpu_cache/ya.make b/contrib/libs/tcmalloc/no_percpu_cache/ya.make new file mode 100644 index 00000000000..cd57c6e24d0 --- /dev/null +++ b/contrib/libs/tcmalloc/no_percpu_cache/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) +ALLOCATOR_IMPL() + +SRCDIR(contrib/libs/tcmalloc) + +GLOBAL_SRCS( + # Options + tcmalloc/want_hpaa.cc +) + +INCLUDE(../common.inc) + +SRCS(aligned_alloc.c) + +CFLAGS( + -DTCMALLOC_256K_PAGES + -DTCMALLOC_DEPRECATED_PERTHREAD +) + +END() diff --git a/contrib/libs/tcmalloc/numa_256k/ya.make b/contrib/libs/tcmalloc/numa_256k/ya.make new file mode 100644 index 00000000000..89fe3f67888 --- /dev/null +++ b/contrib/libs/tcmalloc/numa_256k/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) +ALLOCATOR_IMPL() + +SRCDIR(contrib/libs/tcmalloc) + +INCLUDE(../common.inc) + +GLOBAL_SRCS( + # Options + tcmalloc/want_hpaa_subrelease.cc + tcmalloc/want_numa_aware.cc +) + +CFLAGS( + -DTCMALLOC_256K_PAGES + -DTCMALLOC_NUMA_AWARE +) + +END() diff --git a/contrib/libs/tcmalloc/numa_large_pages/ya.make b/contrib/libs/tcmalloc/numa_large_pages/ya.make new file mode 100644 index 00000000000..56f658e3faf --- /dev/null +++ b/contrib/libs/tcmalloc/numa_large_pages/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) +ALLOCATOR_IMPL() + +SRCDIR(contrib/libs/tcmalloc) + +INCLUDE(../common.inc) + +GLOBAL_SRCS( + # Options + tcmalloc/want_hpaa_subrelease.cc + tcmalloc/want_numa_aware.cc +) + +CFLAGS( + -DTCMALLOC_LARGE_PAGES + -DTCMALLOC_NUMA_AWARE +) + +END() diff --git a/contrib/libs/tcmalloc/small_but_slow/ya.make b/contrib/libs/tcmalloc/small_but_slow/ya.make new file mode 100644 index 00000000000..19803e9070c --- /dev/null +++ b/contrib/libs/tcmalloc/small_but_slow/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(Apache-2.0) +ALLOCATOR_IMPL() + +SRCDIR(contrib/libs/tcmalloc) + +INCLUDE(../common.inc) + +CFLAGS( + -DTCMALLOC_SMALL_BUT_SLOW +) + +END() diff --git a/contrib/libs/tcmalloc/ya.make b/contrib/libs/tcmalloc/ya.make new file mode 100644 index 00000000000..589a2a097c4 --- /dev/null +++ b/contrib/libs/tcmalloc/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) +ALLOCATOR_IMPL() + +# https://github.com/google/tcmalloc +VERSION(2021-10-04-45c59ccbc062ac96d83710205033c656e490d376) + +SRCS( + # Options + tcmalloc/want_hpaa.cc +) + +INCLUDE(common.inc) + +CFLAGS( + -DTCMALLOC_256K_PAGES +) + +END() + +IF (NOT DLL_FOR) + RECURSE( + default + dynamic + malloc_extension + no_percpu_cache + numa_256k + numa_large_pages + small_but_slow + ) +ENDIF() diff --git a/contrib/libs/utf8proc/ya.make b/contrib/libs/utf8proc/ya.make new file mode 100644 index 00000000000..006c2a89030 --- /dev/null +++ b/contrib/libs/utf8proc/ya.make @@ -0,0 +1,24 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + MIT AND + Unicode +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(2.8.0) + +ORIGINAL_SOURCE(https://github.com/JuliaStrings/utf8proc/archive/v2.8.0.tar.gz) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCS( + utf8proc.c +) + +END() diff --git a/contrib/libs/xxhash/ya.make b/contrib/libs/xxhash/ya.make new file mode 100644 index 00000000000..5f780127e9c --- /dev/null +++ b/contrib/libs/xxhash/ya.make @@ -0,0 +1,21 @@ +# Generated by devtools/yamaker from nixpkgs 5852a21819542e6809f68ba5a798600e69874e76. + +LIBRARY() + +VERSION(0.8.0) + +ORIGINAL_SOURCE(https://github.com/Cyan4973/xxHash/archive/v0.8.0.tar.gz) + +LICENSE(BSD-2-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCS( + xxhash.c +) + +END() diff --git a/contrib/libs/yaml-cpp/ya.make b/contrib/libs/yaml-cpp/ya.make new file mode 100644 index 00000000000..ce87822e378 --- /dev/null +++ b/contrib/libs/yaml-cpp/ya.make @@ -0,0 +1,46 @@ +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.5.3) + +NO_UTIL() + +NO_WSHADOW() + +ADDINCL(GLOBAL contrib/libs/yaml-cpp/include) + +SRCS( + src/binary.cpp + src/convert.cpp + src/directives.cpp + src/emit.cpp + src/emitfromevents.cpp + src/emitter.cpp + src/emitterstate.cpp + src/emitterutils.cpp + src/exceptions.cpp + src/exp.cpp + src/memory.cpp + src/nodebuilder.cpp + src/node.cpp + src/node_data.cpp + src/nodeevents.cpp + src/null.cpp + src/ostream_wrapper.cpp + src/parse.cpp + src/parser.cpp + src/regex_yaml.cpp + src/scanner.cpp + src/scanscalar.cpp + src/scantag.cpp + src/scantoken.cpp + src/simplekey.cpp + src/singledocparser.cpp + src/stream.cpp + src/tag.cpp +) + +END() diff --git a/contrib/libs/yaml/ya.make b/contrib/libs/yaml/ya.make new file mode 100644 index 00000000000..27dd591a7e1 --- /dev/null +++ b/contrib/libs/yaml/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.2.5) + +ORIGINAL_SOURCE(https://github.com/yaml/libyaml/archive/0.2.5.tar.gz) + +ADDINCL( + GLOBAL contrib/libs/yaml/include + contrib/libs/yaml/src +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H +) + +SRCS( + src/api.c + src/dumper.c + src/emitter.c + src/loader.c + src/parser.c + src/reader.c + src/scanner.c + src/writer.c +) + +END() diff --git a/contrib/libs/zlib/ya.make b/contrib/libs/zlib/ya.make new file mode 100644 index 00000000000..e2c7e231378 --- /dev/null +++ b/contrib/libs/zlib/ya.make @@ -0,0 +1,56 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(Zlib) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.2.13) + +ORIGINAL_SOURCE(https://www.zlib.net/fossils/zlib-1.2.13.tar.gz) + +OPENSOURCE_EXPORT_REPLACEMENT( + CMAKE + ZLIB + CMAKE_TARGET + ZLIB::ZLIB + CONAN + zlib/1.2.13 +) + +ADDINCL( + GLOBAL contrib/libs/zlib/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +NO_SANITIZE_HEADERS() + +IF (NOT MSVC) + CFLAGS( + -DHAVE_HIDDEN + ) +ENDIF() + +SRCS( + adler32.c + compress.c + crc32.c + deflate.c + gzclose.c + gzlib.c + gzread.c + gzwrite.c + infback.c + inffast.c + inflate.c + inftrees.c + trees.c + uncompr.c + zutil.c +) + +END() diff --git a/contrib/libs/zstd/programs/zstd/ya.make b/contrib/libs/zstd/programs/zstd/ya.make new file mode 100644 index 00000000000..f36fe7b3de8 --- /dev/null +++ b/contrib/libs/zstd/programs/zstd/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/libs/zstd +) + +ADDINCL( + contrib/libs/zstd/lib + contrib/libs/zstd/lib/common + contrib/libs/zstd/programs +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DZSTD_LEGACY_SUPPORT=1 + -DZSTD_MULTITHREAD +) + +SRCDIR(contrib/libs/zstd/programs) + +SRCS( + benchfn.c + benchzstd.c + datagen.c + dibio.c + fileio.c + fileio_asyncio.c + timefn.c + util.c + zstdcli.c + zstdcli_trace.c +) + +END() diff --git a/contrib/libs/zstd/ya.make b/contrib/libs/zstd/ya.make new file mode 100644 index 00000000000..0ea329180ff --- /dev/null +++ b/contrib/libs/zstd/ya.make @@ -0,0 +1,89 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + "(BSD-2-Clause OR GPL-2.0-only)" AND + "(BSD-3-Clause OR GPL-2.0-only)" AND + BSD-2-Clause AND + BSD-3-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.5.5) + +ORIGINAL_SOURCE(https://github.com/facebook/zstd/archive/v1.5.5.tar.gz) + +PEERDIR( + contrib/libs/xxhash +) + +ADDINCL( + contrib/libs/zstd/lib + contrib/libs/zstd/lib/common + contrib/libs/zstd/lib/legacy +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DZSTD_LEGACY_SUPPORT=1 + -DZSTD_MULTITHREAD +) + +IF (ARCH_X86_64 AND NOT MSVC) + CFLAGS( + -DDYNAMIC_BMI2 + ) + SRCS( + lib/decompress/huf_decompress_amd64.S + ) +ENDIF() + +SRCS( + lib/common/debug.c + lib/common/entropy_common.c + lib/common/error_private.c + lib/common/fse_decompress.c + lib/common/pool.c + lib/common/threading.c + lib/common/zstd_common.c + lib/compress/fse_compress.c + lib/compress/hist.c + lib/compress/huf_compress.c + lib/compress/zstd_compress.c + lib/compress/zstd_compress_literals.c + lib/compress/zstd_compress_sequences.c + lib/compress/zstd_compress_superblock.c + lib/compress/zstd_double_fast.c + lib/compress/zstd_fast.c + lib/compress/zstd_lazy.c + lib/compress/zstd_ldm.c + lib/compress/zstd_opt.c + lib/compress/zstdmt_compress.c + lib/decompress/huf_decompress.c + lib/decompress/zstd_ddict.c + lib/decompress/zstd_decompress.c + lib/decompress/zstd_decompress_block.c + lib/dictBuilder/cover.c + lib/dictBuilder/divsufsort.c + lib/dictBuilder/fastcover.c + lib/dictBuilder/zdict.c + lib/legacy/zstd_v01.c + lib/legacy/zstd_v02.c + lib/legacy/zstd_v03.c + lib/legacy/zstd_v04.c + lib/legacy/zstd_v05.c + lib/legacy/zstd_v06.c + lib/legacy/zstd_v07.c +) + +END() + +RECURSE( + programs/zstd +) diff --git a/contrib/libs/zstd06/ya.make b/contrib/libs/zstd06/ya.make new file mode 100644 index 00000000000..d4ced358f89 --- /dev/null +++ b/contrib/libs/zstd06/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +VERSION(0.6.2) + +LICENSE( + BSD-2-Clause AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +SRCS( + common/entropy_common.c + common/fse_decompress.c + common/xxhash.c + common/zstd_common.c + compress/fse_compress.c + compress/huf_compress.c + compress/zbuff_compress.c + compress/zstd_compress.c + decompress/huf_decompress.c + decompress/zbuff_decompress.c + decompress/zstd_decompress.c + dictBuilder/divsufsort.c + dictBuilder/zdict.c + legacy/zstd_v01.c + legacy/zstd_v02.c + legacy/zstd_v03.c + legacy/zstd_v04.c + legacy/zstd_v05.c + legacy/zstd_v07.c + legacy/zstd_v08.c +) + +NO_COMPILER_WARNINGS() + +CFLAGS( + -DZSTD_LEGACY_SUPPORT=1 +) + +ADDINCL( + contrib/libs/zstd06 + contrib/libs/zstd06/common + contrib/libs/zstd06/compress + contrib/libs/zstd06/decompress + contrib/libs/zstd06/dictBuilder + contrib/libs/zstd06/legacy +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/ya.make new file mode 100644 index 00000000000..26a3c441525 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/ya.make @@ -0,0 +1,15 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/base/ya.make new file mode 100644 index 00000000000..3d6b70b0c46 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + internal/cycleclock.cc + internal/low_level_alloc.cc + internal/raw_logging.cc + internal/scoped_set_env.cc + internal/spinlock.cc + internal/spinlock_wait.cc + internal/strerror.cc + internal/sysinfo.cc + internal/thread_identity.cc + internal/throw_delegate.cc + internal/unscaledcycleclock.cc + log_severity.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make new file mode 100644 index 00000000000..bbbb4a7abba --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/debugging + contrib/restricted/abseil-cpp-tstring/y_absl/hash + contrib/restricted/abseil-cpp-tstring/y_absl/memory + contrib/restricted/abseil-cpp-tstring/y_absl/numeric + contrib/restricted/abseil-cpp-tstring/y_absl/profiling + contrib/restricted/abseil-cpp-tstring/y_absl/strings + contrib/restricted/abseil-cpp-tstring/y_absl/synchronization + contrib/restricted/abseil-cpp-tstring/y_absl/time + contrib/restricted/abseil-cpp-tstring/y_absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + internal/hashtablez_sampler.cc + internal/hashtablez_sampler_force_weak_definition.cc + internal/raw_hash_set.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make new file mode 100644 index 00000000000..ae625a264cc --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + failure_signal_handler.cc + internal/address_is_readable.cc + internal/demangle.cc + internal/elf_mem_image.cc + internal/examine_stack.cc + internal/vdso_support.cc + leak_check.cc + stacktrace.cc + symbolize.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/ya.make new file mode 100644 index 00000000000..26a3c441525 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/ya.make @@ -0,0 +1,15 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/ya.make new file mode 100644 index 00000000000..96236c55a39 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/numeric + contrib/restricted/abseil-cpp-tstring/y_absl/strings + contrib/restricted/abseil-cpp-tstring/y_absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + internal/city.cc + internal/hash.cc + internal/low_level_hash.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/memory/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/memory/ya.make new file mode 100644 index 00000000000..30722e54e4b --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/memory/ya.make @@ -0,0 +1,19 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/meta +) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/meta/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/meta/ya.make new file mode 100644 index 00000000000..1660ae53fc8 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/meta/ya.make @@ -0,0 +1,19 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base +) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/ya.make new file mode 100644 index 00000000000..e8aa89d47fd --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/ya.make @@ -0,0 +1,19 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + int128.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/ya.make new file mode 100644 index 00000000000..ec5add2f790 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/ya.make @@ -0,0 +1,20 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + internal/exponential_biased.cc + internal/periodic_sampler.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/random/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/random/ya.make new file mode 100644 index 00000000000..a997aed8e7c --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/random/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/numeric + contrib/restricted/abseil-cpp-tstring/y_absl/strings + contrib/restricted/abseil-cpp-tstring/y_absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + discrete_distribution.cc + gaussian_distribution.cc + internal/chi_square.cc + internal/distribution_test_util.cc + internal/pool_urbg.cc + internal/randen.cc + internal/randen_detect.cc + internal/randen_hwaes.cc + internal/randen_round_keys.cc + internal/randen_slow.cc + internal/seed_material.cc + seed_gen_exception.cc + seed_sequences.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/status/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/status/ya.make new file mode 100644 index 00000000000..e68ee292af2 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/status/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/debugging + contrib/restricted/abseil-cpp-tstring/y_absl/numeric + contrib/restricted/abseil-cpp-tstring/y_absl/profiling + contrib/restricted/abseil-cpp-tstring/y_absl/strings + contrib/restricted/abseil-cpp-tstring/y_absl/synchronization + contrib/restricted/abseil-cpp-tstring/y_absl/time + contrib/restricted/abseil-cpp-tstring/y_absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + status.cc + status_payload_printer.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make new file mode 100644 index 00000000000..fde0b02323c --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make @@ -0,0 +1,72 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/numeric +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/restricted/abseil-cpp-tstring/y_absl) + +SRCS( + crc/crc32c.cc + crc/internal/cpu_detect.cc + crc/internal/crc.cc + crc/internal/crc_cord_state.cc + crc/internal/crc_memcpy_fallback.cc + crc/internal/crc_memcpy_x86_64.cc + crc/internal/crc_non_temporal_memcpy.cc + crc/internal/crc_x86_arm_combined.cc + status/statusor.cc + strings/ascii.cc + strings/charconv.cc + strings/cord.cc + strings/cord_analysis.cc + strings/cord_buffer.cc + strings/escaping.cc + strings/internal/charconv_bigint.cc + strings/internal/charconv_parse.cc + strings/internal/cord_internal.cc + strings/internal/cord_rep_btree.cc + strings/internal/cord_rep_btree_navigator.cc + strings/internal/cord_rep_btree_reader.cc + strings/internal/cord_rep_consume.cc + strings/internal/cord_rep_crc.cc + strings/internal/cord_rep_ring.cc + strings/internal/cordz_functions.cc + strings/internal/cordz_handle.cc + strings/internal/cordz_info.cc + strings/internal/cordz_sample_token.cc + strings/internal/damerau_levenshtein_distance.cc + strings/internal/escaping.cc + strings/internal/memutil.cc + strings/internal/ostringstream.cc + strings/internal/str_format/arg.cc + strings/internal/str_format/bind.cc + strings/internal/str_format/extension.cc + strings/internal/str_format/float_conversion.cc + strings/internal/str_format/output.cc + strings/internal/str_format/parser.cc + strings/internal/stringify_sink.cc + strings/internal/utf8.cc + strings/match.cc + strings/numbers.cc + strings/str_cat.cc + strings/str_replace.cc + strings/str_split.cc + strings/string_view.cc + strings/substitute.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make new file mode 100644 index 00000000000..def50a20914 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/debugging + contrib/restricted/abseil-cpp-tstring/y_absl/numeric + contrib/restricted/abseil-cpp-tstring/y_absl/strings + contrib/restricted/abseil-cpp-tstring/y_absl/time +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + barrier.cc + blocking_counter.cc + internal/create_thread_identity.cc + internal/graphcycles.cc + internal/per_thread_sem.cc + internal/waiter.cc + mutex.cc + notification.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/time/ya.make new file mode 100644 index 00000000000..8bba1a4123d --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/numeric + contrib/restricted/abseil-cpp-tstring/y_absl/strings +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +IF (OS_DARWIN) + EXTRALIBS("-framework CoreFoundation") +ENDIF() + +NO_COMPILER_WARNINGS() + +SRCS( + civil_time.cc + clock.cc + duration.cc + format.cc + internal/cctz/src/civil_time_detail.cc + internal/cctz/src/time_zone_fixed.cc + internal/cctz/src/time_zone_format.cc + internal/cctz/src/time_zone_if.cc + internal/cctz/src/time_zone_impl.cc + internal/cctz/src/time_zone_info.cc + internal/cctz/src/time_zone_libc.cc + internal/cctz/src/time_zone_lookup.cc + internal/cctz/src/time_zone_posix.cc + internal/cctz/src/zone_info_source.cc + time.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/types/ya.make new file mode 100644 index 00000000000..81c2dbe076a --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/memory +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + bad_any_cast.cc + bad_optional_access.cc + bad_variant_access.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/utility/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/utility/ya.make new file mode 100644 index 00000000000..26a3c441525 --- /dev/null +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/utility/ya.make @@ -0,0 +1,15 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp/absl/algorithm/ya.make b/contrib/restricted/abseil-cpp/absl/algorithm/ya.make new file mode 100644 index 00000000000..26a3c441525 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/algorithm/ya.make @@ -0,0 +1,15 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp/absl/base/ya.make b/contrib/restricted/abseil-cpp/absl/base/ya.make new file mode 100644 index 00000000000..72ef4a1b772 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/base/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + internal/cycleclock.cc + internal/low_level_alloc.cc + internal/raw_logging.cc + internal/scoped_set_env.cc + internal/spinlock.cc + internal/spinlock_wait.cc + internal/strerror.cc + internal/sysinfo.cc + internal/thread_identity.cc + internal/throw_delegate.cc + internal/unscaledcycleclock.cc + log_severity.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/container/ya.make b/contrib/restricted/abseil-cpp/absl/container/ya.make new file mode 100644 index 00000000000..fa8ba13aba0 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/container/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/debugging + contrib/restricted/abseil-cpp/absl/hash + contrib/restricted/abseil-cpp/absl/memory + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/profiling + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/synchronization + contrib/restricted/abseil-cpp/absl/time + contrib/restricted/abseil-cpp/absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + internal/hashtablez_sampler.cc + internal/hashtablez_sampler_force_weak_definition.cc + internal/raw_hash_set.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/debugging/ya.make b/contrib/restricted/abseil-cpp/absl/debugging/ya.make new file mode 100644 index 00000000000..3aadfdee3ec --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/debugging/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + failure_signal_handler.cc + internal/address_is_readable.cc + internal/demangle.cc + internal/elf_mem_image.cc + internal/examine_stack.cc + internal/vdso_support.cc + leak_check.cc + stacktrace.cc + symbolize.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/flags/ya.make b/contrib/restricted/abseil-cpp/absl/flags/ya.make new file mode 100644 index 00000000000..f0006d104f3 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/flags/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/container + contrib/restricted/abseil-cpp/absl/debugging + contrib/restricted/abseil-cpp/absl/hash + contrib/restricted/abseil-cpp/absl/memory + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/profiling + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/synchronization + contrib/restricted/abseil-cpp/absl/time + contrib/restricted/abseil-cpp/absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + commandlineflag.cc + flag.cc + internal/commandlineflag.cc + internal/flag.cc + internal/private_handle_accessor.cc + internal/program_name.cc + internal/usage.cc + marshalling.cc + parse.cc + reflection.cc + usage.cc + usage_config.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/functional/ya.make b/contrib/restricted/abseil-cpp/absl/functional/ya.make new file mode 100644 index 00000000000..26a3c441525 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/functional/ya.make @@ -0,0 +1,15 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp/absl/hash/ya.make b/contrib/restricted/abseil-cpp/absl/hash/ya.make new file mode 100644 index 00000000000..280fc5e6ef7 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/hash/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + internal/city.cc + internal/hash.cc + internal/low_level_hash.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/log/ya.make b/contrib/restricted/abseil-cpp/absl/log/ya.make new file mode 100644 index 00000000000..cb73fdb2b23 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/log/ya.make @@ -0,0 +1,48 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/container + contrib/restricted/abseil-cpp/absl/debugging + contrib/restricted/abseil-cpp/absl/flags + contrib/restricted/abseil-cpp/absl/hash + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/profiling + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/synchronization + contrib/restricted/abseil-cpp/absl/time + contrib/restricted/abseil-cpp/absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + die_if_null.cc + flags.cc + globals.cc + initialize.cc + internal/check_op.cc + internal/conditions.cc + internal/globals.cc + internal/log_format.cc + internal/log_message.cc + internal/log_sink_set.cc + internal/nullguard.cc + internal/proto.cc + log_entry.cc + log_sink.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/memory/ya.make b/contrib/restricted/abseil-cpp/absl/memory/ya.make new file mode 100644 index 00000000000..55027cd4a0c --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/memory/ya.make @@ -0,0 +1,19 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/meta +) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp/absl/meta/ya.make b/contrib/restricted/abseil-cpp/absl/meta/ya.make new file mode 100644 index 00000000000..463880441a3 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/meta/ya.make @@ -0,0 +1,19 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base +) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp/absl/numeric/ya.make b/contrib/restricted/abseil-cpp/absl/numeric/ya.make new file mode 100644 index 00000000000..40980852ae7 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/numeric/ya.make @@ -0,0 +1,21 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + int128.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/profiling/ya.make b/contrib/restricted/abseil-cpp/absl/profiling/ya.make new file mode 100644 index 00000000000..5d4fc42d777 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/profiling/ya.make @@ -0,0 +1,22 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + internal/exponential_biased.cc + internal/periodic_sampler.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/random/ya.make b/contrib/restricted/abseil-cpp/absl/random/ya.make new file mode 100644 index 00000000000..9f282b40a25 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/random/ya.make @@ -0,0 +1,40 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + discrete_distribution.cc + gaussian_distribution.cc + internal/chi_square.cc + internal/distribution_test_util.cc + internal/pool_urbg.cc + internal/randen.cc + internal/randen_detect.cc + internal/randen_hwaes.cc + internal/randen_round_keys.cc + internal/randen_slow.cc + internal/seed_material.cc + seed_gen_exception.cc + seed_sequences.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/status/ya.make b/contrib/restricted/abseil-cpp/absl/status/ya.make new file mode 100644 index 00000000000..f4a990c542f --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/status/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/debugging + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/profiling + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/synchronization + contrib/restricted/abseil-cpp/absl/time + contrib/restricted/abseil-cpp/absl/types +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + status.cc + status_payload_printer.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/strings/ya.make b/contrib/restricted/abseil-cpp/absl/strings/ya.make new file mode 100644 index 00000000000..99b03d7bd6a --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/strings/ya.make @@ -0,0 +1,74 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/numeric +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCDIR(contrib/restricted/abseil-cpp/absl) + +SRCS( + crc/crc32c.cc + crc/internal/cpu_detect.cc + crc/internal/crc.cc + crc/internal/crc_cord_state.cc + crc/internal/crc_memcpy_fallback.cc + crc/internal/crc_memcpy_x86_64.cc + crc/internal/crc_non_temporal_memcpy.cc + crc/internal/crc_x86_arm_combined.cc + status/statusor.cc + strings/ascii.cc + strings/charconv.cc + strings/cord.cc + strings/cord_analysis.cc + strings/cord_buffer.cc + strings/escaping.cc + strings/internal/charconv_bigint.cc + strings/internal/charconv_parse.cc + strings/internal/cord_internal.cc + strings/internal/cord_rep_btree.cc + strings/internal/cord_rep_btree_navigator.cc + strings/internal/cord_rep_btree_reader.cc + strings/internal/cord_rep_consume.cc + strings/internal/cord_rep_crc.cc + strings/internal/cord_rep_ring.cc + strings/internal/cordz_functions.cc + strings/internal/cordz_handle.cc + strings/internal/cordz_info.cc + strings/internal/cordz_sample_token.cc + strings/internal/damerau_levenshtein_distance.cc + strings/internal/escaping.cc + strings/internal/memutil.cc + strings/internal/ostringstream.cc + strings/internal/str_format/arg.cc + strings/internal/str_format/bind.cc + strings/internal/str_format/extension.cc + strings/internal/str_format/float_conversion.cc + strings/internal/str_format/output.cc + strings/internal/str_format/parser.cc + strings/internal/stringify_sink.cc + strings/internal/utf8.cc + strings/match.cc + strings/numbers.cc + strings/str_cat.cc + strings/str_replace.cc + strings/str_split.cc + strings/string_view.cc + strings/substitute.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/synchronization/ya.make b/contrib/restricted/abseil-cpp/absl/synchronization/ya.make new file mode 100644 index 00000000000..e7f1f2db8c2 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/synchronization/ya.make @@ -0,0 +1,36 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/debugging + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/time +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + barrier.cc + blocking_counter.cc + internal/create_thread_identity.cc + internal/graphcycles.cc + internal/per_thread_sem.cc + internal/waiter.cc + mutex.cc + notification.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/time/ya.make b/contrib/restricted/abseil-cpp/absl/time/ya.make new file mode 100644 index 00000000000..cf29ee64cb0 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/time/ya.make @@ -0,0 +1,48 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/strings +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +IF (OS_DARWIN) + EXTRALIBS("-framework CoreFoundation") +ENDIF() + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + civil_time.cc + clock.cc + duration.cc + format.cc + internal/cctz/src/civil_time_detail.cc + internal/cctz/src/time_zone_fixed.cc + internal/cctz/src/time_zone_format.cc + internal/cctz/src/time_zone_if.cc + internal/cctz/src/time_zone_impl.cc + internal/cctz/src/time_zone_info.cc + internal/cctz/src/time_zone_libc.cc + internal/cctz/src/time_zone_lookup.cc + internal/cctz/src/time_zone_posix.cc + internal/cctz/src/zone_info_source.cc + time.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/types/ya.make b/contrib/restricted/abseil-cpp/absl/types/ya.make new file mode 100644 index 00000000000..b8b2f8b08c5 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/types/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/memory +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + bad_any_cast.cc + bad_optional_access.cc + bad_variant_access.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp/absl/utility/ya.make b/contrib/restricted/abseil-cpp/absl/utility/ya.make new file mode 100644 index 00000000000..26a3c441525 --- /dev/null +++ b/contrib/restricted/abseil-cpp/absl/utility/ya.make @@ -0,0 +1,15 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +NO_RUNTIME() + +END() diff --git a/contrib/restricted/abseil-cpp/ya.make b/contrib/restricted/abseil-cpp/ya.make new file mode 100644 index 00000000000..40de33d37c9 --- /dev/null +++ b/contrib/restricted/abseil-cpp/ya.make @@ -0,0 +1,59 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(20230125.3) + +ORIGINAL_SOURCE(https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz) + +PEERDIR( + contrib/restricted/abseil-cpp/absl/algorithm + contrib/restricted/abseil-cpp/absl/base + contrib/restricted/abseil-cpp/absl/container + contrib/restricted/abseil-cpp/absl/debugging + contrib/restricted/abseil-cpp/absl/flags + contrib/restricted/abseil-cpp/absl/functional + contrib/restricted/abseil-cpp/absl/hash + contrib/restricted/abseil-cpp/absl/log + contrib/restricted/abseil-cpp/absl/memory + contrib/restricted/abseil-cpp/absl/meta + contrib/restricted/abseil-cpp/absl/numeric + contrib/restricted/abseil-cpp/absl/profiling + contrib/restricted/abseil-cpp/absl/random + contrib/restricted/abseil-cpp/absl/status + contrib/restricted/abseil-cpp/absl/strings + contrib/restricted/abseil-cpp/absl/synchronization + contrib/restricted/abseil-cpp/absl/time + contrib/restricted/abseil-cpp/absl/types + contrib/restricted/abseil-cpp/absl/utility +) + +NO_RUNTIME() + +END() + +RECURSE( + absl/algorithm + absl/base + absl/container + absl/debugging + absl/flags + absl/functional + absl/hash + absl/log + absl/memory + absl/meta + absl/numeric + absl/profiling + absl/random + absl/status + absl/strings + absl/synchronization + absl/time + absl/types + absl/utility +) diff --git a/contrib/restricted/aws/aws-c-cal/ya.make b/contrib/restricted/aws/aws-c-cal/ya.make new file mode 100644 index 00000000000..cb5a1722b96 --- /dev/null +++ b/contrib/restricted/aws/aws-c-cal/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.5.26) + +ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-cal/archive/v0.5.26.tar.gz) + +PEERDIR( + contrib/libs/openssl + contrib/restricted/aws/aws-c-common +) + +ADDINCL( + GLOBAL contrib/restricted/aws/aws-c-cal/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DAWS_CAL_USE_IMPORT_EXPORT + -DAWS_COMMON_USE_IMPORT_EXPORT + -DHAVE_SYSCONF +) + +SRCS( + source/cal.c + source/der.c + source/ecc.c + source/hash.c + source/hmac.c + source/symmetric_cipher.c + source/unix/openssl_aes.c + source/unix/openssl_platform_init.c + source/unix/opensslcrypto_ecc.c + source/unix/opensslcrypto_hash.c + source/unix/opensslcrypto_hmac.c +) + +END() diff --git a/contrib/restricted/aws/aws-c-common/ya.make b/contrib/restricted/aws/aws-c-common/ya.make new file mode 100644 index 00000000000..afc4b7af5b2 --- /dev/null +++ b/contrib/restricted/aws/aws-c-common/ya.make @@ -0,0 +1,128 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + BSD-3-Clause AND + MIT AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.8.6) + +ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-common/archive/v0.8.6.tar.gz) + +ADDINCL( + GLOBAL contrib/restricted/aws/aws-c-common/generated/include + GLOBAL contrib/restricted/aws/aws-c-common/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DAWS_COMMON_USE_IMPORT_EXPORT + -DAWS_PTHREAD_SETNAME_TAKES_2ARGS + -DCJSON_HIDE_SYMBOLS + -DHAVE_SYSCONF +) + +IF (MUSL) + CFLAGS( + -DAWS_AFFINITY_METHOD=AWS_AFFINITY_METHOD_PTHREAD + ) +ELSEIF (OS_DARWIN) + CFLAGS( + -DAWS_AFFINITY_METHOD=AWS_AFFINITY_METHOD_NONE + ) + LDFLAGS( + -framework + CoreFoundation + ) +ELSE() + CFLAGS( + -DAWS_AFFINITY_METHOD=AWS_AFFINITY_METHOD_PTHREAD_ATTR + ) +ENDIF() + +IF (ARCH_X86_64) + CFLAGS( + -DHAVE_MM256_EXTRACT_EPI64 + -DHAVE_AVX2_INTRINSICS + -DUSE_SIMD_ENCODING + ) +ENDIF() + +SRCS( + source/allocator.c + source/allocator_sba.c + source/array_list.c + source/assert.c + source/bus.c + source/byte_buf.c + source/cache.c + source/codegen.c + source/command_line_parser.c + source/common.c + source/condition_variable.c + source/date_time.c + source/device_random.c + source/encoding.c + source/error.c + source/external/cJSON.c + source/fifo_cache.c + source/file.c + source/hash_table.c + source/json.c + source/lifo_cache.c + source/linked_hash_table.c + source/log_channel.c + source/log_formatter.c + source/log_writer.c + source/logging.c + source/lru_cache.c + source/math.c + source/memtrace.c + source/posix/clock.c + source/posix/condition_variable.c + source/posix/device_random.c + source/posix/environment.c + source/posix/file.c + source/posix/mutex.c + source/posix/process.c + source/posix/rw_lock.c + source/posix/system_info.c + source/posix/thread.c + source/posix/time.c + source/priority_queue.c + source/process_common.c + source/promise.c + source/ref_count.c + source/ring_buffer.c + source/statistics.c + source/string.c + source/task_scheduler.c + source/thread_scheduler.c + source/thread_shared.c + source/uri.c + source/uuid.c + source/xml_parser.c +) + +IF (ARCH_ARM) + SRCS( + source/arch/arm/asm/cpuid.c + ) +ELSEIF (ARCH_X86_64) + SRCS( + source/arch/intel/asm/cpuid.c + source/arch/intel/cpuid.c + ) + SRC_C_AVX2(source/arch/intel/encoding_avx2.c) +ENDIF() + +END() diff --git a/contrib/restricted/aws/aws-c-event-stream/ya.make b/contrib/restricted/aws/aws-c-event-stream/ya.make new file mode 100644 index 00000000000..80896b79a30 --- /dev/null +++ b/contrib/restricted/aws/aws-c-event-stream/ya.make @@ -0,0 +1,60 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.2.7) + +ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-event-stream/archive/v0.2.7.tar.gz) + +PEERDIR( + contrib/restricted/aws/aws-c-common + contrib/restricted/aws/aws-c-io + contrib/restricted/aws/aws-checksums +) + +ADDINCL( + GLOBAL contrib/restricted/aws/aws-c-event-stream/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DAWS_CAL_USE_IMPORT_EXPORT + -DAWS_CHECKSUMS_USE_IMPORT_EXPORT + -DAWS_COMMON_USE_IMPORT_EXPORT + -DAWS_EVENT_STREAM_USE_IMPORT_EXPORT + -DAWS_IO_USE_IMPORT_EXPORT + -DAWS_USE_EPOLL + -DHAVE_SYSCONF + -DS2N_ADX + -DS2N_BIKE_R3_AVX2 + -DS2N_BIKE_R3_AVX512 + -DS2N_BIKE_R3_PCLMUL + -DS2N_CLONE_SUPPORTED + -DS2N_CPUID_AVAILABLE + -DS2N_FALL_THROUGH_SUPPORTED + -DS2N_FEATURES_AVAILABLE + -DS2N_HAVE_EXECINFO + -DS2N_KYBER512R3_AVX2_BMI2 + -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD5_SHA1_HASH + -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD_CTX_SET_PKEY_CTX + -DS2N_MADVISE_SUPPORTED + -DS2N_SIKE_P434_R3_ASM + -DS2N___RESTRICT__SUPPORTED +) + +SRCS( + source/event_stream.c + source/event_stream_channel_handler.c + source/event_stream_rpc.c + source/event_stream_rpc_client.c + source/event_stream_rpc_server.c +) + +END() diff --git a/contrib/restricted/aws/aws-c-io/ya.make b/contrib/restricted/aws/aws-c-io/ya.make new file mode 100644 index 00000000000..e8c63092469 --- /dev/null +++ b/contrib/restricted/aws/aws-c-io/ya.make @@ -0,0 +1,87 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Custom-Oasis-Pkcs11 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.13.21) + +ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-io/archive/v0.13.21.tar.gz) + +PEERDIR( + contrib/restricted/aws/aws-c-cal + contrib/restricted/aws/aws-c-common + contrib/restricted/aws/s2n +) + +ADDINCL( + GLOBAL contrib/restricted/aws/aws-c-io/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DAWS_CAL_USE_IMPORT_EXPORT + -DAWS_COMMON_USE_IMPORT_EXPORT + -DAWS_IO_USE_IMPORT_EXPORT + -DAWS_USE_EPOLL + -DHAVE_SYSCONF + -DS2N_CLONE_SUPPORTED + -DS2N_CPUID_AVAILABLE + -DS2N_FALL_THROUGH_SUPPORTED + -DS2N_FEATURES_AVAILABLE + -DS2N_KYBER512R3_AVX2_BMI2 + -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD5_SHA1_HASH + -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD_CTX_SET_PKEY_CTX + -DS2N_LIBCRYPTO_SUPPORTS_EVP_RC4 + -DS2N_MADVISE_SUPPORTED + -DS2N_STACKTRACE + -DS2N___RESTRICT__SUPPORTED + -DUSE_S2N +) + +SRCS( + source/alpn_handler.c + source/channel.c + source/channel_bootstrap.c + source/event_loop.c + source/exponential_backoff_retry_strategy.c + source/host_resolver.c + source/io.c + source/message_pool.c + source/pem_utils.c + source/pkcs11_lib.c + source/pkcs11_tls_op_handler.c + source/pki_utils.c + source/posix/host_resolver.c + source/posix/pipe.c + source/posix/shared_library.c + source/posix/socket.c + source/retry_strategy.c + source/s2n/s2n_tls_channel_handler.c + source/socket_channel_handler.c + source/standard_retry_strategy.c + source/statistics.c + source/stream.c + source/tls_channel_handler.c + source/tls_channel_handler_shared.c +) + +IF (OS_DARWIN) + SRCS( + source/bsd/kqueue_event_loop.c + ) +ELSEIF (OS_LINUX) + SRCS( + source/linux/epoll_event_loop.c + ) +ENDIF() + +END() diff --git a/contrib/restricted/aws/aws-checksums/ya.make b/contrib/restricted/aws/aws-checksums/ya.make new file mode 100644 index 00000000000..db901e9d09b --- /dev/null +++ b/contrib/restricted/aws/aws-checksums/ya.make @@ -0,0 +1,43 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.1.14) + +ORIGINAL_SOURCE(https://github.com/awslabs/aws-checksums/archive/v0.1.14.tar.gz) + +PEERDIR( + contrib/restricted/aws/aws-c-common +) + +ADDINCL( + GLOBAL contrib/restricted/aws/aws-checksums/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DAWS_CHECKSUMS_USE_IMPORT_EXPORT + -DAWS_COMMON_USE_IMPORT_EXPORT + -DHAVE_SYSCONF +) + +IF (BUILD_TYPE == "DEBUG") + CFLAGS( + -DDEBUG_BUILD + ) +ENDIF() + +SRCS( + source/crc.c + source/crc_sw.c + source/intel/asm/crc32c_sse42_asm.c +) + +END() diff --git a/contrib/restricted/aws/s2n/ya.make b/contrib/restricted/aws/s2n/ya.make new file mode 100644 index 00000000000..478bbee6027 --- /dev/null +++ b/contrib/restricted/aws/s2n/ya.make @@ -0,0 +1,257 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + Brian-Gladman-3-Clause AND + CC0-1.0 AND + MIT AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.3.44) + +ORIGINAL_SOURCE(https://github.com/aws/s2n-tls/archive/v1.3.44.tar.gz) + +PEERDIR( + contrib/libs/openssl +) + +ADDINCL( + GLOBAL contrib/restricted/aws/s2n + GLOBAL contrib/restricted/aws/s2n/api +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DS2N_CLONE_SUPPORTED + -DS2N_FALL_THROUGH_SUPPORTED + -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD5_SHA1_HASH + -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD_CTX_SET_PKEY_CTX + -DS2N_LIBCRYPTO_SUPPORTS_EVP_RC4 + -DS2N_MADVISE_SUPPORTED + -DS2N_PLATFORM_SUPPORTS_KTLS + -DS2N___RESTRICT__SUPPORTED +) + +IF (OS_LINUX) + CFLAGS( + -DS2N_FEATURES_AVAILABLE + ) +ENDIF() + +IF (NOT MUSL) + CFLAGS( + -DS2N_STACKTRACE + ) +ENDIF() + +IF (ARCH_X86_64) + CFLAGS( + -DS2N_CPUID_AVAILABLE + -DS2N_KYBER512R3_AVX2_BMI2 + ) + SRCS( + pq-crypto/kyber_r3/kyber512r3_basemul_avx2.S + pq-crypto/kyber_r3/kyber512r3_fq_avx2.S + pq-crypto/kyber_r3/kyber512r3_invntt_avx2.S + pq-crypto/kyber_r3/kyber512r3_ntt_avx2.S + pq-crypto/kyber_r3/kyber512r3_shuffle_avx2.S + ) + SRC_C_AVX2(pq-crypto/kyber_r3/KeccakP-1600-times4-SIMD256_avx2.c) + SRC_C_AVX2(pq-crypto/kyber_r3/kyber512r3_cbd_avx2.c) + SRC_C_AVX2(pq-crypto/kyber_r3/kyber512r3_consts_avx2.c) + SRC_C_AVX2(pq-crypto/kyber_r3/kyber512r3_fips202x4_avx2.c) + SRC_C_AVX2(pq-crypto/kyber_r3/kyber512r3_indcpa_avx2.c) + SRC_C_AVX2(pq-crypto/kyber_r3/kyber512r3_poly_avx2.c) + SRC_C_AVX2(pq-crypto/kyber_r3/kyber512r3_polyvec_avx2.c) + SRC_C_AVX2(pq-crypto/kyber_r3/kyber512r3_rejsample_avx2.c) +ENDIF() + +SRCS( + crypto/s2n_aead_cipher_aes_gcm.c + crypto/s2n_aead_cipher_chacha20_poly1305.c + crypto/s2n_cbc_cipher_3des.c + crypto/s2n_cbc_cipher_aes.c + crypto/s2n_certificate.c + crypto/s2n_cipher.c + crypto/s2n_composite_cipher_aes_sha.c + crypto/s2n_crypto.c + crypto/s2n_dhe.c + crypto/s2n_drbg.c + crypto/s2n_ecc_evp.c + crypto/s2n_ecdsa.c + crypto/s2n_evp.c + crypto/s2n_evp_signing.c + crypto/s2n_fips.c + crypto/s2n_hash.c + crypto/s2n_hkdf.c + crypto/s2n_hmac.c + crypto/s2n_libcrypto.c + crypto/s2n_locking.c + crypto/s2n_openssl_x509.c + crypto/s2n_pkey.c + crypto/s2n_rsa.c + crypto/s2n_rsa_pss.c + crypto/s2n_rsa_signing.c + crypto/s2n_sequence.c + crypto/s2n_stream_cipher_null.c + crypto/s2n_stream_cipher_rc4.c + crypto/s2n_tls13_keys.c + error/s2n_errno.c + pq-crypto/kyber_r3/kyber512r3_cbd.c + pq-crypto/kyber_r3/kyber512r3_fips202.c + pq-crypto/kyber_r3/kyber512r3_indcpa.c + pq-crypto/kyber_r3/kyber512r3_kem.c + pq-crypto/kyber_r3/kyber512r3_ntt.c + pq-crypto/kyber_r3/kyber512r3_poly.c + pq-crypto/kyber_r3/kyber512r3_polyvec.c + pq-crypto/kyber_r3/kyber512r3_reduce.c + pq-crypto/kyber_r3/kyber512r3_symmetric-shake.c + pq-crypto/s2n_kyber_512_evp.c + pq-crypto/s2n_pq.c + pq-crypto/s2n_pq_random.c + stuffer/s2n_stuffer.c + stuffer/s2n_stuffer_base64.c + stuffer/s2n_stuffer_file.c + stuffer/s2n_stuffer_network_order.c + stuffer/s2n_stuffer_pem.c + stuffer/s2n_stuffer_text.c + tls/extensions/s2n_cert_status.c + tls/extensions/s2n_cert_status_response.c + tls/extensions/s2n_client_alpn.c + tls/extensions/s2n_client_cert_status_request.c + tls/extensions/s2n_client_cookie.c + tls/extensions/s2n_client_early_data_indication.c + tls/extensions/s2n_client_ems.c + tls/extensions/s2n_client_key_share.c + tls/extensions/s2n_client_max_frag_len.c + tls/extensions/s2n_client_pq_kem.c + tls/extensions/s2n_client_psk.c + tls/extensions/s2n_client_renegotiation_info.c + tls/extensions/s2n_client_sct_list.c + tls/extensions/s2n_client_server_name.c + tls/extensions/s2n_client_session_ticket.c + tls/extensions/s2n_client_signature_algorithms.c + tls/extensions/s2n_client_supported_groups.c + tls/extensions/s2n_client_supported_versions.c + tls/extensions/s2n_ec_point_format.c + tls/extensions/s2n_extension_list.c + tls/extensions/s2n_extension_type.c + tls/extensions/s2n_extension_type_lists.c + tls/extensions/s2n_key_share.c + tls/extensions/s2n_npn.c + tls/extensions/s2n_nst_early_data_indication.c + tls/extensions/s2n_psk_key_exchange_modes.c + tls/extensions/s2n_quic_transport_params.c + tls/extensions/s2n_server_alpn.c + tls/extensions/s2n_server_cert_status_request.c + tls/extensions/s2n_server_cookie.c + tls/extensions/s2n_server_early_data_indication.c + tls/extensions/s2n_server_ems.c + tls/extensions/s2n_server_key_share.c + tls/extensions/s2n_server_max_fragment_length.c + tls/extensions/s2n_server_psk.c + tls/extensions/s2n_server_renegotiation_info.c + tls/extensions/s2n_server_sct_list.c + tls/extensions/s2n_server_server_name.c + tls/extensions/s2n_server_session_ticket.c + tls/extensions/s2n_server_signature_algorithms.c + tls/extensions/s2n_server_supported_versions.c + tls/extensions/s2n_supported_versions.c + tls/s2n_aead.c + tls/s2n_alerts.c + tls/s2n_async_pkey.c + tls/s2n_auth_selection.c + tls/s2n_cbc.c + tls/s2n_change_cipher_spec.c + tls/s2n_cipher_preferences.c + tls/s2n_cipher_suites.c + tls/s2n_client_cert.c + tls/s2n_client_cert_verify.c + tls/s2n_client_finished.c + tls/s2n_client_hello.c + tls/s2n_client_hello_request.c + tls/s2n_client_key_exchange.c + tls/s2n_config.c + tls/s2n_connection.c + tls/s2n_crl.c + tls/s2n_crypto.c + tls/s2n_early_data.c + tls/s2n_early_data_io.c + tls/s2n_ecc_preferences.c + tls/s2n_encrypted_extensions.c + tls/s2n_establish_session.c + tls/s2n_fingerprint.c + tls/s2n_handshake.c + tls/s2n_handshake_hashes.c + tls/s2n_handshake_io.c + tls/s2n_handshake_transcript.c + tls/s2n_handshake_type.c + tls/s2n_kem.c + tls/s2n_kem_preferences.c + tls/s2n_kex.c + tls/s2n_key_log.c + tls/s2n_key_update.c + tls/s2n_ktls.c + tls/s2n_next_protocol.c + tls/s2n_ocsp_stapling.c + tls/s2n_post_handshake.c + tls/s2n_prf.c + tls/s2n_protocol_preferences.c + tls/s2n_psk.c + tls/s2n_quic_support.c + tls/s2n_record_read.c + tls/s2n_record_read_aead.c + tls/s2n_record_read_cbc.c + tls/s2n_record_read_composite.c + tls/s2n_record_read_stream.c + tls/s2n_record_write.c + tls/s2n_recv.c + tls/s2n_renegotiate.c + tls/s2n_resume.c + tls/s2n_security_policies.c + tls/s2n_send.c + tls/s2n_server_cert.c + tls/s2n_server_cert_request.c + tls/s2n_server_done.c + tls/s2n_server_extensions.c + tls/s2n_server_finished.c + tls/s2n_server_hello.c + tls/s2n_server_hello_retry.c + tls/s2n_server_key_exchange.c + tls/s2n_server_new_session_ticket.c + tls/s2n_shutdown.c + tls/s2n_signature_algorithms.c + tls/s2n_signature_scheme.c + tls/s2n_tls.c + tls/s2n_tls13.c + tls/s2n_tls13_certificate_verify.c + tls/s2n_tls13_handshake.c + tls/s2n_tls13_key_schedule.c + tls/s2n_tls13_secrets.c + tls/s2n_x509_validator.c + utils/s2n_array.c + utils/s2n_asn1_time.c + utils/s2n_blob.c + utils/s2n_ensure.c + utils/s2n_fork_detection.c + utils/s2n_init.c + utils/s2n_map.c + utils/s2n_mem.c + utils/s2n_random.c + utils/s2n_result.c + utils/s2n_rfc5952.c + utils/s2n_safety.c + utils/s2n_set.c + utils/s2n_socket.c + utils/s2n_timer.c +) + +END() diff --git a/contrib/restricted/boost/algorithm/ya.make b/contrib/restricted/boost/algorithm/ya.make new file mode 100644 index 00000000000..c34a1dea463 --- /dev/null +++ b/contrib/restricted/boost/algorithm/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/algorithm/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/exception + contrib/restricted/boost/function + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/range + contrib/restricted/boost/regex + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/unordered +) + +ADDINCL( + GLOBAL contrib/restricted/boost/algorithm/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/align/ya.make b/contrib/restricted/boost/align/ya.make new file mode 100644 index 00000000000..3b8992ca0d1 --- /dev/null +++ b/contrib/restricted/boost/align/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/align/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/static_assert +) + +ADDINCL( + GLOBAL contrib/restricted/boost/align/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/any/ya.make b/contrib/restricted/boost/any/ya.make new file mode 100644 index 00000000000..11120291f6b --- /dev/null +++ b/contrib/restricted/boost/any/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/any/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_index + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/any/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/array/ya.make b/contrib/restricted/boost/array/ya.make new file mode 100644 index 00000000000..492051cfabd --- /dev/null +++ b/contrib/restricted/boost/array/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/array/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception +) + +ADDINCL( + GLOBAL contrib/restricted/boost/array/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/asio/ya.make b/contrib/restricted/boost/asio/ya.make new file mode 100644 index 00000000000..f97a74f7282 --- /dev/null +++ b/contrib/restricted/boost/asio/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.67.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/asio/archive/boost-1.67.0.tar.gz) + +PEERDIR( + contrib/libs/openssl + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/chrono + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/coroutine + contrib/restricted/boost/date_time + contrib/restricted/boost/function + contrib/restricted/boost/regex + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/system + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/asio/include +) + +END() diff --git a/contrib/restricted/boost/assert/ya.make b/contrib/restricted/boost/assert/ya.make new file mode 100644 index 00000000000..2da6f3028af --- /dev/null +++ b/contrib/restricted/boost/assert/ya.make @@ -0,0 +1,25 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/assert/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config +) + +ADDINCL( + GLOBAL contrib/restricted/boost/assert/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/atomic/ya.make b/contrib/restricted/boost/atomic/ya.make new file mode 100644 index 00000000000..c12564ebe81 --- /dev/null +++ b/contrib/restricted/boost/atomic/ya.make @@ -0,0 +1,63 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/atomic/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/align + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/predef + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits + contrib/restricted/boost/winapi +) + +IF (OS_WINDOWS) + SRCS( + src/wait_on_address.cpp + ) +ENDIF() + +ADDINCL( + GLOBAL contrib/restricted/boost/atomic/include + contrib/restricted/boost/atomic/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DBOOST_ATOMIC_SOURCE +) + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_ATOMIC_DYN_LINK + ) +ENDIF() + +SRCS( + src/find_address_sse2.cpp + src/lock_pool.cpp +) + +IF (USE_SSE4) + CFLAGS( + -DBOOST_ATOMIC_USE_SSE41 + ) + SRCS( + src/find_address_sse41.cpp + ) +ENDIF() + +END() diff --git a/contrib/restricted/boost/bimap/ya.make b/contrib/restricted/boost/bimap/ya.make new file mode 100644 index 00000000000..1c15b0353d9 --- /dev/null +++ b/contrib/restricted/boost/bimap/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/bimap/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/iterator + contrib/restricted/boost/lambda + contrib/restricted/boost/mpl + contrib/restricted/boost/multi_index + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/bimap/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/bind/ya.make b/contrib/restricted/boost/bind/ya.make new file mode 100644 index 00000000000..e543d42d22f --- /dev/null +++ b/contrib/restricted/boost/bind/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/bind/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core +) + +ADDINCL( + GLOBAL contrib/restricted/boost/bind/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/chrono/ya.make b/contrib/restricted/boost/chrono/ya.make new file mode 100644 index 00000000000..581971e66d4 --- /dev/null +++ b/contrib/restricted/boost/chrono/ya.make @@ -0,0 +1,55 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + MIT AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/chrono/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/move + contrib/restricted/boost/mpl + contrib/restricted/boost/predef + contrib/restricted/boost/ratio + contrib/restricted/boost/static_assert + contrib/restricted/boost/system + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof + contrib/restricted/boost/utility + contrib/restricted/boost/winapi +) + +ADDINCL( + GLOBAL contrib/restricted/boost/chrono/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_CHRONO_DYN_LINK + ) +ENDIF() + +SRCS( + src/chrono.cpp + src/process_cpu_clocks.cpp + src/thread_clock.cpp +) + +END() diff --git a/contrib/restricted/boost/concept_check/ya.make b/contrib/restricted/boost/concept_check/ya.make new file mode 100644 index 00000000000..c9095892402 --- /dev/null +++ b/contrib/restricted/boost/concept_check/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/concept_check/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/concept_check/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/config/ya.make b/contrib/restricted/boost/config/ya.make new file mode 100644 index 00000000000..b77d38ae3e2 --- /dev/null +++ b/contrib/restricted/boost/config/ya.make @@ -0,0 +1,25 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/config/archive/boost-1.82.0.tar.gz) + +ADDINCL( + GLOBAL contrib/restricted/boost/config/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + GLOBAL -DBOOST_ALL_NO_LIB +) + +END() diff --git a/contrib/restricted/boost/container/ya.make b/contrib/restricted/boost/container/ya.make new file mode 100644 index 00000000000..520e283f090 --- /dev/null +++ b/contrib/restricted/boost/container/ya.make @@ -0,0 +1,48 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + CC0-1.0 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/container/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/intrusive + contrib/restricted/boost/move + contrib/restricted/boost/static_assert +) + +ADDINCL( + GLOBAL contrib/restricted/boost/container/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_CONTAINER_DYN_LINK + ) +ENDIF() + +SRCS( + src/alloc_lib.c + src/dlmalloc.cpp + src/global_resource.cpp + src/monotonic_buffer_resource.cpp + src/pool_resource.cpp + src/synchronized_pool_resource.cpp + src/unsynchronized_pool_resource.cpp +) + +END() diff --git a/contrib/restricted/boost/container_hash/ya.make b/contrib/restricted/boost/container_hash/ya.make new file mode 100644 index 00000000000..9363505f6ac --- /dev/null +++ b/contrib/restricted/boost/container_hash/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/container_hash/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/describe + contrib/restricted/boost/mp11 + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/container_hash/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/context/fcontext_impl/ya.make b/contrib/restricted/boost/context/fcontext_impl/ya.make new file mode 100644 index 00000000000..721befb5b3c --- /dev/null +++ b/contrib/restricted/boost/context/fcontext_impl/ya.make @@ -0,0 +1,75 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/context/archive/boost-1.82.0.tar.gz) + +LICENSE(BSL-1.0) + +SET(BOOST_CONTEXT_ABI sysv) + +SET(BOOST_CONTEXT_ARCHITECTURE x86_64) + +SET(BOOST_CONTEXT_ASM_EXT .S) + +SET(BOOST_CONTEXT_ASSEMBLER gas) + +SET(BOOST_CONTEXT_BINARY_FORMAT elf) + +PEERDIR( + contrib/restricted/boost/context/impl_common +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (OS_WINDOWS) + IF (DYNAMIC_BOOST) + MASMFLAGS(/DBOOST_CONTEXT_EXPORT=EXPORT) + ELSE() + MASMFLAGS(/DBOOST_CONTEXT_EXPORT=) + ENDIF() +ENDIF() + +SRCDIR(contrib/restricted/boost/context/src) + +IF (OS_DARWIN OR OS_IOS) + SET(BOOST_CONTEXT_BINARY_FORMAT macho) +ELSEIF (OS_WINDOWS) + SET(BOOST_CONTEXT_ABI ms) + SET(BOOST_CONTEXT_ASM_EXT .masm) + SET(BOOST_CONTEXT_ASSEMBLER masm) + SET(BOOST_CONTEXT_BINARY_FORMAT pe) + IF (ARCH_ARM) + SET(BOOST_CONTEXT_ASSEMBLER armasm) + ELSEIF (ARCH_I386) + MASMFLAGS(/safeseh) + ENDIF() +ENDIF() + +IF (ARCH_ARM) + SET(BOOST_CONTEXT_ABI aapcs) +ENDIF() + +IF (ARCH_ARM64) + SET(BOOST_CONTEXT_ARCHITECTURE arm64) +ELSEIF (ARCH_ARM7) + SET(BOOST_CONTEXT_ARCHITECTURE arm) +ELSEIF (ARCH_I386) + SET(BOOST_CONTEXT_ARCHITECTURE i386) +ENDIF() + +SET(BOOST_CONTEXT_ASM_SUFFIX ${BOOST_CONTEXT_ARCHITECTURE}_${BOOST_CONTEXT_ABI}_${BOOST_CONTEXT_BINARY_FORMAT}_${BOOST_CONTEXT_ASSEMBLER}${BOOST_CONTEXT_ASM_EXT}) + +SRCS( + asm/jump_${BOOST_CONTEXT_ASM_SUFFIX} + asm/make_${BOOST_CONTEXT_ASM_SUFFIX} + asm/ontop_${BOOST_CONTEXT_ASM_SUFFIX} +) + +END() diff --git a/contrib/restricted/boost/context/impl_common/ya.make b/contrib/restricted/boost/context/impl_common/ya.make new file mode 100644 index 00000000000..1ea9ac41ee6 --- /dev/null +++ b/contrib/restricted/boost/context/impl_common/ya.make @@ -0,0 +1,53 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +WITHOUT_LICENSE_TEXTS() + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/context/archive/boost-1.82.0.tar.gz) + +LICENSE(BSL-1.0) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/mp11 + contrib/restricted/boost/pool + contrib/restricted/boost/predef + contrib/restricted/boost/smart_ptr +) + +ADDINCL( + GLOBAL contrib/restricted/boost/context/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DBOOST_CONTEXT_SOURCE +) + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_CONTEXT_DYN_LINK + ) +ENDIF() + +SRCDIR(contrib/restricted/boost/context/src) + +IF (OS_WINDOWS) + SRCS( + windows/stack_traits.cpp + ) +ELSE() + SRCS( + posix/stack_traits.cpp + ) +ENDIF() + +END() diff --git a/contrib/restricted/boost/conversion/ya.make b/contrib/restricted/boost/conversion/ya.make new file mode 100644 index 00000000000..4c4a4674083 --- /dev/null +++ b/contrib/restricted/boost/conversion/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/conversion/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof +) + +ADDINCL( + GLOBAL contrib/restricted/boost/conversion/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/core/ya.make b/contrib/restricted/boost/core/ya.make new file mode 100644 index 00000000000..d3b77e16378 --- /dev/null +++ b/contrib/restricted/boost/core/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/core/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception +) + +ADDINCL( + GLOBAL contrib/restricted/boost/core/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/coroutine/ya.make b/contrib/restricted/boost/coroutine/ya.make new file mode 100644 index 00000000000..e116dab231e --- /dev/null +++ b/contrib/restricted/boost/coroutine/ya.make @@ -0,0 +1,60 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/coroutine/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/context/fcontext_impl + contrib/restricted/boost/core + contrib/restricted/boost/exception + contrib/restricted/boost/move + contrib/restricted/boost/system + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/coroutine/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + GLOBAL -DBOOST_COROUTINES_NO_DEPRECATION_WARNING + -DBOOST_COROUTINES_SOURCE +) + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_COROUTINES_DYN_LINK + ) +ENDIF() + +IF (OS_WINDOWS) + SRCS( + src/windows/stack_traits.cpp + ) +ELSE() + SRCS( + src/posix/stack_traits.cpp + ) +ENDIF() + +SRCS( + src/detail/coroutine_context.cpp + src/exceptions.cpp +) + +END() diff --git a/contrib/restricted/boost/crc/ya.make b/contrib/restricted/boost/crc/ya.make new file mode 100644 index 00000000000..fc85e98fafc --- /dev/null +++ b/contrib/restricted/boost/crc/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/crc/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/config + contrib/restricted/boost/integer + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/crc/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/date_time/ya.make b/contrib/restricted/boost/date_time/ya.make new file mode 100644 index 00000000000..f220fef98fe --- /dev/null +++ b/contrib/restricted/boost/date_time/ya.make @@ -0,0 +1,45 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/date_time/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/algorithm + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/io + contrib/restricted/boost/lexical_cast + contrib/restricted/boost/numeric_conversion + contrib/restricted/boost/range + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tokenizer + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility + contrib/restricted/boost/winapi +) + +ADDINCL( + GLOBAL contrib/restricted/boost/date_time/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_DATE_TIME_DYN_LINK + ) +ENDIF() + +END() diff --git a/contrib/restricted/boost/describe/ya.make b/contrib/restricted/boost/describe/ya.make new file mode 100644 index 00000000000..f6ecfb95f76 --- /dev/null +++ b/contrib/restricted/boost/describe/ya.make @@ -0,0 +1,25 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/describe/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/mp11 +) + +ADDINCL( + GLOBAL contrib/restricted/boost/describe/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/detail/ya.make b/contrib/restricted/boost/detail/ya.make new file mode 100644 index 00000000000..bfac4c9641c --- /dev/null +++ b/contrib/restricted/boost/detail/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Mit-Old-Style +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/detail/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/detail/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/dynamic_bitset/ya.make b/contrib/restricted/boost/dynamic_bitset/ya.make new file mode 100644 index 00000000000..f8998855f75 --- /dev/null +++ b/contrib/restricted/boost/dynamic_bitset/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/dynamic_bitset/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/move + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception +) + +ADDINCL( + GLOBAL contrib/restricted/boost/dynamic_bitset/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/endian/ya.make b/contrib/restricted/boost/endian/ya.make new file mode 100644 index 00000000000..8f044aba95d --- /dev/null +++ b/contrib/restricted/boost/endian/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/endian/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/endian/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/exception/ya.make b/contrib/restricted/boost/exception/ya.make new file mode 100644 index 00000000000..4df834c3088 --- /dev/null +++ b/contrib/restricted/boost/exception/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/exception/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/exception/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + src/clone_current_exception_non_intrusive.cpp +) + +END() diff --git a/contrib/restricted/boost/foreach/ya.make b/contrib/restricted/boost/foreach/ya.make new file mode 100644 index 00000000000..71369309676 --- /dev/null +++ b/contrib/restricted/boost/foreach/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/foreach/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/range + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/foreach/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/format/ya.make b/contrib/restricted/boost/format/ya.make new file mode 100644 index 00000000000..5d4ac6cdea7 --- /dev/null +++ b/contrib/restricted/boost/format/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/format/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/optional + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/throw_exception + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/format/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/function/ya.make b/contrib/restricted/boost/function/ya.make new file mode 100644 index 00000000000..1dabe2ebccc --- /dev/null +++ b/contrib/restricted/boost/function/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/function/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/preprocessor + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof +) + +ADDINCL( + GLOBAL contrib/restricted/boost/function/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/function_types/ya.make b/contrib/restricted/boost/function_types/ya.make new file mode 100644 index 00000000000..62d6455d909 --- /dev/null +++ b/contrib/restricted/boost/function_types/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/function_types/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/function_types/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/functional/ya.make b/contrib/restricted/boost/functional/ya.make new file mode 100644 index 00000000000..2be68741aa7 --- /dev/null +++ b/contrib/restricted/boost/functional/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/functional/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/function + contrib/restricted/boost/function_types + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/functional/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/fusion/ya.make b/contrib/restricted/boost/fusion/ya.make new file mode 100644 index 00000000000..0f5b82797af --- /dev/null +++ b/contrib/restricted/boost/fusion/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/fusion/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/describe + contrib/restricted/boost/function_types + contrib/restricted/boost/functional + contrib/restricted/boost/mp11 + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/fusion/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/graph/.yandex_meta/devtools.copyrights.report b/contrib/restricted/boost/graph/.yandex_meta/devtools.copyrights.report deleted file mode 100644 index 6d1a7f30bcb..00000000000 --- a/contrib/restricted/boost/graph/.yandex_meta/devtools.copyrights.report +++ /dev/null @@ -1,1155 +0,0 @@ -# File format ($ symbol means the beginning of a line): -# -# $ # this message -# $ # ======================= -# $ # comments (all commentaries should starts with some number of spaces and # symbol) -# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits -# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files -# $ # user comments -# $ -# ${action} {license id} {license text hash} -# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make -# ${all_file_action} filename -# $ # user commentaries (many lines) -# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) -# ${action} {license spdx} {license text hash} -# $BELONGS ./ya/make/file/relative/path/3/ya.make -# ${all_file_action} filename -# $ # user commentaries -# $ generated description -# $ ... -# -# You can modify action, all_file_action and add commentaries -# Available actions: -# keep - keep license in contrib and use in credits -# skip - skip license -# remove - remove all files with this license -# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file -# -# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) -# We suppose that that files can contain some license info -# Available all file actions: -# FILE_IGNORE - ignore file (do nothing) -# FILE_INCLUDE - include all file data into licenses text file -# ======================= - -KEEP COPYRIGHT_SERVICE_LABEL 00d8c23eb547d50de392cb17b51e426e -BELONGS ya.make - License text: - // Copyright 2002 Indiana University. - // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/adjacency_iterator.hpp [2:3] - include/boost/graph/create_condensation_graph.hpp [2:3] - include/boost/graph/dag_shortest_paths.hpp [2:3] - include/boost/graph/detail/incremental_components.hpp [2:4] - include/boost/graph/detail/list_base.hpp [2:3] - include/boost/graph/exception.hpp [2:3] - include/boost/graph/graph_archetypes.hpp [2:3] - include/boost/graph/graph_selectors.hpp [2:3] - include/boost/graph/iteration_macros_undef.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL 01ee5bf19060374ef2efda82af9fc108 -BELONGS ya.make - License text: - // Copyright Michael Drexl 2005, 2006. - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/r_c_shortest_paths.hpp [3:5] - -KEEP COPYRIGHT_SERVICE_LABEL 0248c07689d63f8e0b5cff0f09a2737a -BELONGS ya.make - License text: - // Copyright (C) 2012 Flavio De Lorenzi (fdlorenzi@gmail.com) - // Copyright (C) 2013 Jakob Lykke Andersen, University of Southern Denmark - // (jlandersen@imada.sdu.dk) - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/vf2_sub_graph_iso.hpp [2:4] - -KEEP COPYRIGHT_SERVICE_LABEL 09990d303a67b1a0c87b3ccf09c2097c -BELONGS ya.make - License text: - // Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de> - // Copyright (C) 2004,2009 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/graphml.cpp [1:2] - -KEEP COPYRIGHT_SERVICE_LABEL 0a1ddf2f633492698f29966f2ba00d47 -BELONGS ya.make - License text: - // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. - // Copyright (C) Vladimir Prus 2003 - // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/random.hpp [2:4] - -KEEP COPYRIGHT_SERVICE_LABEL 0b29116922cfef70c51094e6d835a79b -BELONGS ya.make - License text: - // (C) Copyright Francois Faure, iMAGIS-GRAVIR / UJF, 2001. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/property_iter_range.hpp [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL 1503802c606bb498fc119fbf3329ccce -BELONGS ya.make - License text: - // Copyright (c) Jeremy Siek 2001 - // Copyright (c) Douglas Gregor 2004 - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/biconnected_components.hpp [1:2] - -KEEP COPYRIGHT_SERVICE_LABEL 1638af8b9d8a13b7d2e95217a0492d14 -BELONGS ya.make - License text: - // (C) Copyright Andrew Sutton 2007 - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/geodesic_distance.hpp [1:1] - include/boost/graph/property_maps/null_property_map.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 1a243be6fc839e64391e9bd0d3aea29a -BELONGS ya.make - License text: - // (c) Copyright Juergen Hunold 2008 - // Use, modification and distribution is subject to the Boost Software - // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/edmunds_karp_max_flow.hpp [2:4] - -KEEP COPYRIGHT_SERVICE_LABEL 1b49b31378926fed6bad2e9e34790202 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/pending/container_traits.hpp [1:5] - include/boost/pending/detail/disjoint_sets.hpp [1:3] - include/boost/pending/detail/property.hpp [1:3] - include/boost/pending/fibonacci_heap.hpp [1:3] - include/boost/pending/property.hpp [1:3] - include/boost/pending/queue.hpp [1:3] - include/boost/pending/stringtok.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL 1bf87741a9385d7452ade49e1b079010 -BELONGS ya.make - License text: - // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. - // Copyright 2010 Thomas Claveirole - // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Thomas Claveirole - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/adjacency_list.hpp [2:4] - include/boost/graph/bellman_ford_shortest_paths.hpp [3:4] - include/boost/graph/breadth_first_search.hpp [3:4] - include/boost/graph/cuthill_mckee_ordering.hpp [2:5] - include/boost/graph/depth_first_search.hpp [2:4] - include/boost/graph/detail/adj_list_edge_iterator.hpp [3:4] - include/boost/graph/detail/adjacency_list.hpp [3:5] - include/boost/graph/detail/array_binary_tree.hpp [3:4] - include/boost/graph/detail/connected_components.hpp [2:3] - include/boost/graph/detail/edge.hpp [3:4] - include/boost/graph/detail/incidence_iterator.hpp [3:4] - include/boost/graph/detail/self_avoiding_walk.hpp [2:3] - include/boost/graph/detail/sparse_ordering.hpp [2:5] - include/boost/graph/dijkstra_shortest_paths.hpp [2:3] - include/boost/graph/dijkstra_shortest_paths_no_color_map.hpp [2:4] - include/boost/graph/edge_list.hpp [2:3] - include/boost/graph/filtered_graph.hpp [2:3] - include/boost/graph/graph_as_tree.hpp [3:4] - include/boost/graph/graph_concepts.hpp [3:4] - include/boost/graph/graph_traits.hpp [2:3] - include/boost/graph/graph_utility.hpp [3:4] - include/boost/graph/johnson_all_pairs_shortest.hpp [2:3] - include/boost/graph/king_ordering.hpp [2:5] - include/boost/graph/kruskal_min_spanning_tree.hpp [3:4] - include/boost/graph/leda_graph.hpp [2:6] - include/boost/graph/matrix_as_graph.hpp [3:4] - include/boost/graph/named_function_params.hpp [2:3] - include/boost/graph/neighbor_bfs.hpp [3:4] - include/boost/graph/prim_minimum_spanning_tree.hpp [2:3] - include/boost/graph/properties.hpp [2:3] - include/boost/graph/random.hpp [2:4] - include/boost/graph/read_dimacs.hpp [2:3] - include/boost/graph/relax.hpp [2:3] - include/boost/graph/sequential_vertex_coloring.hpp [2:4] - include/boost/graph/smallest_last_ordering.hpp [2:3] - include/boost/graph/strong_components.hpp [3:4] - include/boost/graph/topological_sort.hpp [3:4] - include/boost/graph/transpose_graph.hpp [3:4] - include/boost/graph/undirected_dfs.hpp [3:4] - include/boost/graph/vector_as_graph.hpp [2:5] - include/boost/graph/visitors.hpp [2:3] - include/boost/pending/bucket_sorter.hpp [3:4] - include/boost/pending/disjoint_sets.hpp [3:4] - include/boost/pending/indirect_cmp.hpp [3:4] - include/boost/pending/is_heap.hpp [3:4] - include/boost/pending/mutable_heap.hpp [3:4] - include/boost/pending/mutable_queue.hpp [3:4] - -KEEP COPYRIGHT_SERVICE_LABEL 1e6c23354a6747a6c3eef56fb2537b44 -BELONGS ya.make - License text: - // Copyright (c) 2006, Stephan Diederich - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/boykov_kolmogorov_max_flow.hpp [1:1] - include/boost/graph/write_dimacs.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 22403f1361a990fb6fd5cc8b876e046d -BELONGS ya.make - License text: - // Copyright (c) 2004 Kristopher Beevers - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/astar_search.hpp [5:5] - -KEEP COPYRIGHT_SERVICE_LABEL 22b8921218f5846e7fc7d4a2ac8c34c0 -BELONGS ya.make - License text: - // Copyright 2004-2006 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/plod_generator.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 26ec38d4689211b14e2c5b53e9a78f76 -BELONGS ya.make - License text: - // Copyright 2009 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/histogram_sort.hpp [1:1] - include/boost/graph/topology.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 29b0154b5b9497e05eafdea58aee1ec9 -BELONGS ya.make - License text: - // Copyright 2000 University of Notre Dame. - // Authors: Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/edge_connectivity.hpp [2:3] - include/boost/graph/edmonds_karp_max_flow.hpp [2:3] - include/boost/graph/push_relabel_max_flow.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL 2e933bb084c95d7e3472974501e28c75 -BELONGS ya.make - License text: - // Copyright (c) Jeremy Siek 2001, Marc Wintermantel 2002 - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/bandwidth.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 351746b3263b8ecde03d30e68809a8c2 -BELONGS ya.make - License text: - // Copyright 2005 Trustees of Indiana University - // Authors: Andrew Lumsdaine, Douglas Gregor - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/simple_point.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL 35f3967788124fb1166bf637d6cd211a -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/transitive_closure.hpp [1:4] - -KEEP COPYRIGHT_SERVICE_LABEL 368bc0676fed97d8e20cb5e9e1a4530f -BELONGS ya.make - License text: - // Copyright (C) 2009 Andrew Sutton - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/labeled_graph_traits.hpp [1:1] - include/boost/graph/graph_mutability_traits.hpp [1:1] - include/boost/graph/labeled_graph.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 3761f0e38b5da4769378918141293e40 -BELONGS ya.make - License text: - // Copyright 2002 Rensselaer Polytechnic Institute - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/floyd_warshall_shortest.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 3e8210b2d067c6fa6eca9745ccdb03df -BELONGS ya.make - License text: - // Copyright 2008 - // Author: Matyas W Egyhazy - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/metric_tsp_approx.hpp [3:4] - -KEEP COPYRIGHT_SERVICE_LABEL 471d4b0a42c396158389600e3135b118 -BELONGS ya.make - License text: - // Copyright 2001 University of Notre Dame. - // Copyright 2003 Jeremy Siek - // Authors: Lie-Quan Lee, Jeremy Siek, and Douglas Gregor - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/dll_import_export.hpp [2:4] - include/boost/graph/graphviz.hpp [2:4] - -KEEP COPYRIGHT_SERVICE_LABEL 483fdf5158d0f8518198f5ac2c492f5f -BELONGS ya.make - License text: - // (C) Copyright Jeremy Siek 2001. - // Distributed under the Boost Software License, Version 1.0. (See accompany- - // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/detail/algorithm.hpp [1:3] - include/boost/graph/detail/permutation.hpp [1:3] - include/boost/graph/detail/set_adaptor.hpp [1:3] - include/boost/graph/detail/shadow_iterator.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL 4a4c85d50d7786e732eb8f9d7ce88a13 -BELONGS ya.make - License text: - // (C) Copyright 2007 Andrew Sutton - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/geodesic.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 4c7e1f597f1997587410c32f9a6d6fdb -BELONGS ya.make - License text: - // Copyright (c) 2005 Aaron Windsor - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/max_cardinality_matching.hpp [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL 4cf14bcc6afe3ad08dfd547e89ac0920 -BELONGS ya.make - License text: - // Copyright 2010 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/loop_erased_random_walk.hpp [1:1] - include/boost/graph/random_spanning_tree.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 4d26b7ae91cf6f8491cee13434ff5797 -BELONGS ya.make - License text: - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/detail/algorithm.hpp [19:20] - -KEEP COPYRIGHT_SERVICE_LABEL 572b131daaeb41ada07b46e9bcc351e8 -BELONGS ya.make - License text: - // Copyright (C) 2005-2010 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/one_bit_color_map.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 586afb33401cfbc0d9c28c9f0b024801 -BELONGS ya.make - License text: - // Copyright 2005 Jeremy G. Siek - // Authors: Jeremy G. Siek - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/adj_list_serialize.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL 59f7375811a04f7a1af214791e9e2591 -BELONGS ya.make - License text: - // Copyright (C) 2004-2009 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/use_mpi.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 5bb192a3ec0466664f95da7b439ee5e7 -BELONGS ya.make - License text: - // Copyright 2012 Fernando Vilas - // 2010 Daniel Trebbien - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/maximum_adjacency_search.hpp [3:4] - -KEEP COPYRIGHT_SERVICE_LABEL 670e9fea8b553fd6cefa4f9a295c8a0a -BELONGS ya.make - License text: - // Copyright 2012 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/is_distributed_selector.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 686307e753ad6e1d636dbc622eedb324 -BELONGS ya.make - License text: - // Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de> - // Copyright (C) 2004 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/graphml.hpp [1:2] - -KEEP COPYRIGHT_SERVICE_LABEL 69913f770ab644c0c626ffe368b41c06 -BELONGS ya.make - License text: - // (C) Copyright Jeremiah Willcock 2004 - // Distributed under the Boost Software License, Version 1.0. (See - // accompanying file LICENSE_1_0.txt or copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/pending/fenced_priority_queue.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL 6b1ab40ae46ff90ccb7c47e8c55973bc -BELONGS ya.make - License text: - // Copyright Daniel Trebbien 2010. - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or the copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/buffer_concepts.hpp [1:3] - include/boost/graph/stoer_wagner_min_cut.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL 6faaf754e301184e7a07944b24799553 -BELONGS ya.make - License text: - // Copyright 2004 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/bc_clustering.hpp [1:1] - include/boost/graph/betweenness_centrality.hpp [1:1] - include/boost/graph/circle_layout.hpp [1:1] - include/boost/graph/gursoy_atun_layout.hpp [1:1] - include/boost/graph/kamada_kawai_spring_layout.hpp [1:1] - include/boost/graph/leda_graph.hpp [2:6] - include/boost/graph/overloading.hpp [1:1] - include/boost/graph/random_layout.hpp [1:1] - include/boost/graph/sequential_vertex_coloring.hpp [2:4] - include/boost/graph/small_world_generator.hpp [1:1] - include/boost/graph/vertex_and_edge_range.hpp [1:1] - include/boost/pending/relaxed_heap.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 7154f956948b41d87bf8a2b73a07d675 -BELONGS ya.make - License text: - // (C) Copyright Jeremy Siek 1999. - // Distributed under the Boost Software License, Version 1.0. (See - // accompanying file LICENSE_1_0.txt or copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/tree_traits.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL 740b8b21c73d73ca167354e62df16207 -BELONGS ya.make - License text: - * Copyright (c) 2010 Matthias Walter (xammy@xammy.homelinux.net) - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/bipartite.hpp [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL 779f3f74aa28c6ec9cbf99f210980137 -BELONGS ya.make - License text: - // Copyright 2007 Stanford University - // Authors: David Gleich - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/core_numbers.hpp [3:4] - -KEEP COPYRIGHT_SERVICE_LABEL 7da1e963669f385bf3784df6bc8f2553 -BELONGS ya.make - License text: - // Copyright (C) 2005-2006 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/two_bit_color_map.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 807dea3c55c068fbbaf4810187c7c84b -BELONGS ya.make - License text: - // (C) Copyright 2007-2009 Andrew Sutton - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/bron_kerbosch_all_cliques.hpp [1:1] - include/boost/graph/closeness_centrality.hpp [1:1] - include/boost/graph/clustering_coefficient.hpp [1:1] - include/boost/graph/degree_centrality.hpp [1:1] - include/boost/graph/detail/index.hpp [1:1] - include/boost/graph/directed_graph.hpp [1:1] - include/boost/graph/eccentricity.hpp [1:1] - include/boost/graph/exterior_property.hpp [1:1] - include/boost/graph/numeric_values.hpp [1:1] - include/boost/graph/property_maps/constant_property_map.hpp [1:1] - include/boost/graph/property_maps/container_property_map.hpp [1:1] - include/boost/graph/property_maps/matrix_property_map.hpp [1:1] - include/boost/graph/tiernan_all_cycles.hpp [1:1] - include/boost/graph/undirected_graph.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 89b41c99892d77117372460a7f90d72f -BELONGS ya.make - License text: - // Copyright 2004-5 The Trustees of Indiana University. - // Copyright 2002 Brad King and Douglas Gregor - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/page_rank.hpp [1:2] - -KEEP COPYRIGHT_SERVICE_LABEL 8aaadc898368c37b5d90c024f9104351 -BELONGS ya.make - License text: - // Copyright (C) 2012, Michele Caini. - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/two_graphs_common_spanning_trees.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL 9207c14a0f73cfde357a50e86305b641 -BELONGS ya.make - License text: - // Copyright 2004-9 Trustees of Indiana University - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/read_graphviz_new.hpp [1:1] - include/boost/graph/detail/read_graphviz_spirit.hpp [1:1] - src/read_graphviz_new.cpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 96b2ef2696a6c6919d3372f54d0dcce4 -BELONGS ya.make - License text: - // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. - // Copyright 2009 Trustees of Indiana University. - // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Michael Hansen - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/d_ary_heap.hpp [3:4] - include/boost/graph/detail/incremental_components.hpp [2:4] - include/boost/graph/dijkstra_shortest_paths_no_color_map.hpp [2:4] - include/boost/graph/grid_graph.hpp [2:3] - include/boost/graph/incremental_components.hpp [3:5] - include/boost/graph/lookup_edge.hpp [2:3] - include/boost/graph/mcgregor_common_subgraphs.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL 98be8460f5eeedee67d327e5aa099ae2 -BELONGS ya.make - License text: - // Copyright 2004-5 The Trustees of Indiana University. - // Copyright 2002 Brad King and Douglas Gregor - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/page_rank.hpp [1:2] - -KEEP COPYRIGHT_SERVICE_LABEL 9cf9d5ea6d40a88eeda2127bd41fc81a -BELONGS ya.make - License text: - // Copyright (C) 2012 Flavio De Lorenzi (fdlorenzi@gmail.com) - // Copyright (C) 2013 Jakob Lykke Andersen, University of Southern Denmark - // (jlandersen@imada.sdu.dk) - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/vf2_sub_graph_iso.hpp [2:4] - -KEEP COPYRIGHT_SERVICE_LABEL 9d08918c66a0d366cbbae02999f8438d -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/transitive_closure.hpp [1:4] - include/boost/graph/vector_as_graph.hpp [2:5] - -KEEP COPYRIGHT_SERVICE_LABEL a717e4b7c213ca28bbeaec4750bb98ec -BELONGS ya.make - License text: - // Copyright 2004, 2005 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/erdos_renyi_generator.hpp [1:1] - include/boost/graph/fruchterman_reingold.hpp [1:1] - include/boost/graph/mesh_graph_generator.hpp [1:1] - include/boost/graph/point_traits.hpp [1:1] - include/boost/graph/rmat_graph_generator.hpp [1:1] - include/boost/graph/ssca_graph_generator.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL a7831931571cb11df5942e281a68009f -BELONGS ya.make - License text: - * Copyright (c) 1994 - * Hewlett-Packard Company - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/detail/algorithm.hpp [7:8] - -KEEP COPYRIGHT_SERVICE_LABEL a9d5074bdc20d985f64135ae02f955a0 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/pending/container_traits.hpp [1:5] - -KEEP COPYRIGHT_SERVICE_LABEL ab71254ad02f316b826c74cda23fc7de -BELONGS ya.make - License text: - // Copyright 2001 Universite Joseph Fourier, Grenoble. - // Author: Francois Faure - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/adjacency_list_io.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL ac019423baf07909ddd9038922e85359 -BELONGS ya.make - License text: - // Copyright 2005 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/indexed_properties.hpp [1:1] - include/boost/graph/dimacs.hpp [1:1] - include/boost/graph/graph_stats.hpp [1:1] - include/boost/graph/metis.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL b1820d2cd3cc81402964cf6c2c64f349 -BELONGS ya.make - License text: - // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. - // Copyright 2010 Thomas Claveirole - // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Thomas Claveirole - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/adjacency_list.hpp [2:4] - include/boost/graph/detail/adjacency_list.hpp [3:5] - -KEEP COPYRIGHT_SERVICE_LABEL b608aafcf17c3fbc3a9abfa54ff163ce -BELONGS ya.make - License text: - // Copyright (C) 2007 Douglas Gregor - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/named_graph.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL ba5506df7530081f1cb89a1a0c3dde35 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/vector_as_graph.hpp [2:5] - -KEEP COPYRIGHT_SERVICE_LABEL baf28d14712b3b53f3b722d4d80fdb6c -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/pending/container_traits.hpp [1:5] - -KEEP COPYRIGHT_SERVICE_LABEL bd84a09c4319b7c30ed8c9bc63531fff -BELONGS ya.make - License text: - // Copyright (c) 2018 Yi Ji - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/maximum_weighted_matching.hpp [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL bda792b52a7a784797c1280c82f443a0 -BELONGS ya.make - License text: - // (C) Copyright David Abrahams 2000. - // Distributed under the Boost Software License, Version 1.0. (See - // accompanying file LICENSE_1_0.txt or copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/reverse_graph.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL c02bfefa74f87417f2dbc10a0395ffac -BELONGS ya.make - License text: - // Copyright 2018 Peter Dimov - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/detail/empty_header.hpp [4:4] - include/boost/graph/detail/mpi_include.hpp [4:4] - -KEEP COPYRIGHT_SERVICE_LABEL c3a440d06912f47e5190235167d26eea -BELONGS ya.make - License text: - // Copyright 2001 University of Notre Dame. - // Copyright 2006 Trustees of Indiana University - // Authors: Jeremy G. Siek and Douglas Gregor <dgregor@cs.indiana.edu> - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/adjacency_matrix.hpp [2:4] - -KEEP COPYRIGHT_SERVICE_LABEL c43f1a8f551d96ac636a4afde37c7277 -BELONGS ya.make - License text: - // (C) Copyright 2009 Eric Bose-Wolf - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/transitive_reduction.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL c44aa21684966e124d964b7f61ceb274 -BELONGS ya.make - License text: - // Copyright (C) 2006 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/st_connected.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL c6f32cbdc60da329c029d3eceb822cb5 -BELONGS ya.make - License text: - // Copyright 2001 Indiana University - // Author: Jeremy G. Siek - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/iteration_macros.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL c8b2225195e675e39283e940da8d4aca -BELONGS ya.make - License text: - // Copyright 2013 Maciej Piechotka - // Authors: Maciej Piechotka - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/edge_coloring.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL c91df6862997c9f36164f1308b236bf7 -BELONGS ya.make - License text: - // Copyright 2007 Aaron Windsor - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/boyer_myrvold_planar_test.hpp [2:2] - include/boost/graph/is_kuratowski_subgraph.hpp [2:2] - include/boost/graph/is_straight_line_drawing.hpp [2:2] - include/boost/graph/make_biconnected_planar.hpp [2:2] - include/boost/graph/make_connected.hpp [2:2] - include/boost/graph/make_maximal_planar.hpp [2:2] - include/boost/graph/planar_detail/add_edge_visitors.hpp [2:2] - include/boost/graph/planar_detail/bucket_sort.hpp [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL cc20f3be80fcae2741d451fd54843c93 -BELONGS ya.make - License text: - // Copyright 2001 University of Notre Dame. - // Copyright 2006 Trustees of Indiana University - // Authors: Jeremy G. Siek and Douglas Gregor <dgregor@cs.indiana.edu> - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/adjacency_matrix.hpp [2:4] - include/boost/graph/dll_import_export.hpp [2:4] - include/boost/graph/graphviz.hpp [2:4] - include/boost/graph/subgraph.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL cde0b758663026af6e7dea405ee6bf38 -BELONGS ya.make - License text: - // Copyright Louis Dionne 2013 - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/hawick_circuits.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL d08ee88acc4c1b352aea89d4523daace -BELONGS ya.make - License text: - // Copyright 2009, Andrew Sutton - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/graph_concepts.hpp [6:6] - -KEEP COPYRIGHT_SERVICE_LABEL d52e2e3deec2da9a498dcf40b8dc3655 -BELONGS ya.make - License text: - // Copyright 2002 Marc Wintermantel (wintermantel@even-ag.ch) - // ETH Zurich, Center of Structure Technologies - // (https://web.archive.org/web/20050307090307/http://www.structures.ethz.ch/) - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/profile.hpp [3:5] - include/boost/graph/sloan_ordering.hpp [3:5] - include/boost/graph/wavefront.hpp [3:5] - -KEEP COPYRIGHT_SERVICE_LABEL d91946878c8cc10edec238acbae07c4c -BELONGS ya.make - License text: - // Copyright 2005-2009 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/compressed_sparse_row_graph.hpp [1:1] - include/boost/graph/detail/compressed_sparse_row_struct.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL d9d3f9179a9781a228af49eebba2dba2 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/leda_graph.hpp [2:6] - -KEEP COPYRIGHT_SERVICE_LABEL e52d2d00c0bddf195fcd2e865710a087 -BELONGS ya.make - License text: - // Copyright (C) 2001 Jeremy Siek, Douglas Gregor, Brian Osman - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/isomorphism.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL e660351224f73455ec6e8b19ff54015b -BELONGS ya.make - License text: - // Copyright 2013 University of Warsaw. - // Authors: Piotr Wygocki - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/cycle_canceling.hpp [2:3] - include/boost/graph/detail/augment.hpp [2:3] - include/boost/graph/find_flow_cost.hpp [2:3] - include/boost/graph/successive_shortest_path_nonnegative_weights.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL e948c32bb4fec5a27e9bbe3a45398269 -BELONGS ya.make - License text: - // (C) Copyright Jeremy Siek 2006 - // Distributed under the Boost Software License, Version 1.0. (See - // accompanying file LICENSE_1_0.txt or copy at - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/pending/property_serialize.hpp [1:3] - -KEEP COPYRIGHT_SERVICE_LABEL e9c139c5d04d10ee2bf656ff900cbbaf -BELONGS ya.make - License text: - // Copyright (c) Aaron Windsor 2007 - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/chrobak_payne_drawing.hpp [2:2] - include/boost/graph/planar_canonical_ordering.hpp [2:2] - include/boost/graph/planar_detail/boyer_myrvold_impl.hpp [2:2] - include/boost/graph/planar_detail/face_handles.hpp [2:2] - include/boost/graph/planar_detail/face_iterators.hpp [2:2] - include/boost/graph/planar_face_traversal.hpp [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL edd357e5bb31d28a8d2f7af650d68345 -BELONGS ya.make - License text: - // Copyright (C) 2006-2009 Dmitry Bufistov and Andrey Parfenov - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/howard_cycle_ratio.hpp [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL f135edc02c00b6582ebdd933caabbc00 -BELONGS ya.make - License text: - // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. - // Copyright 2003 Bruce Barr - // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/depth_first_search.hpp [2:4] - -KEEP COPYRIGHT_SERVICE_LABEL f1f8468601bd581bae0bf23eba4b070b -BELONGS ya.make - License text: - // Copyright (c) Jeremy Siek 2001 - // Copyright (c) Douglas Gregor 2004 - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/biconnected_components.hpp [1:2] - -KEEP COPYRIGHT_SERVICE_LABEL f2afe39f6ff7491f267ce9bc28a07daa -BELONGS ya.make - License text: - // Copyright 1997-2001 University of Notre Dame. - // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/connected_components.hpp [3:4] - include/boost/graph/copy.hpp [3:4] - include/boost/graph/incremental_components.hpp [3:5] - include/boost/graph/minimum_degree_ordering.hpp [3:4] - include/boost/graph/stanford_graph.hpp [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL fd6578dd286e9257f73d8cc59e377eb7 -BELONGS ya.make - License text: - // Copyright (C) 2005-2009 Jongsoo Park <jongsoo.park -at- gmail.com> - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/dominator_tree.hpp [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL fda42ec6f8d7fcf06eb7924a33f02d3c -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/cuthill_mckee_ordering.hpp [2:5] - include/boost/graph/detail/sparse_ordering.hpp [2:5] - include/boost/graph/king_ordering.hpp [2:5] - -KEEP COPYRIGHT_SERVICE_LABEL ff121923a9c0b6799597434faafbacb1 -BELONGS ya.make - License text: - // Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de> - // Copyright (C) 2004 The Trustees of Indiana University. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/boost/graph/graphml.hpp [1:2] - src/graphml.cpp [1:2] diff --git a/contrib/restricted/boost/graph/.yandex_meta/devtools.licenses.report b/contrib/restricted/boost/graph/.yandex_meta/devtools.licenses.report deleted file mode 100644 index 28dd1966081..00000000000 --- a/contrib/restricted/boost/graph/.yandex_meta/devtools.licenses.report +++ /dev/null @@ -1,422 +0,0 @@ -# File format ($ symbol means the beginning of a line): -# -# $ # this message -# $ # ======================= -# $ # comments (all commentaries should starts with some number of spaces and # symbol) -# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits -# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files -# $ # user comments -# $ -# ${action} {license id} {license text hash} -# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make -# ${all_file_action} filename -# $ # user commentaries (many lines) -# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) -# ${action} {license spdx} {license text hash} -# $BELONGS ./ya/make/file/relative/path/3/ya.make -# ${all_file_action} filename -# $ # user commentaries -# $ generated description -# $ ... -# -# You can modify action, all_file_action and add commentaries -# Available actions: -# keep - keep license in contrib and use in credits -# skip - skip license -# remove - remove all files with this license -# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file -# -# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) -# We suppose that that files can contain some license info -# Available all file actions: -# FILE_IGNORE - ignore file (do nothing) -# FILE_INCLUDE - include all file data into licenses text file -# ======================= - -KEEP BSL-1.0 05954ae47dedb48ccaf95b3af88bc2aa -BELONGS ya.make - License text: - // Use, modification and distribution is subject to the Boost Software - // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - // http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 96.88 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/detail/labeled_graph_traits.hpp [3:5] - include/boost/graph/dimacs.hpp [3:5] - include/boost/graph/edmunds_karp_max_flow.hpp [3:5] - include/boost/graph/graph_mutability_traits.hpp [3:5] - include/boost/graph/graph_stats.hpp [3:5] - include/boost/graph/graphml.hpp [4:6] - include/boost/graph/howard_cycle_ratio.hpp [3:5] - include/boost/graph/labeled_graph.hpp [3:5] - include/boost/graph/mesh_graph_generator.hpp [3:5] - include/boost/graph/metis.hpp [3:5] - include/boost/graph/named_graph.hpp [3:5] - include/boost/graph/overloading.hpp [3:5] - include/boost/graph/point_traits.hpp [3:5] - include/boost/graph/rmat_graph_generator.hpp [3:5] - include/boost/graph/ssca_graph_generator.hpp [3:5] - include/boost/graph/st_connected.hpp [3:5] - include/boost/graph/use_mpi.hpp [3:5] - include/boost/graph/vertex_and_edge_range.hpp [3:5] - include/boost/pending/relaxed_heap.hpp [3:5] - src/graphml.cpp [4:6] - -KEEP BSL-1.0 2cc71fe4bd12718a9884bf7ff37269f3 -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or copy at - // http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/bc_clustering.hpp [3:5] - include/boost/graph/betweenness_centrality.hpp [3:5] - include/boost/graph/circle_layout.hpp [3:5] - include/boost/graph/compressed_sparse_row_graph.hpp [3:5] - include/boost/graph/detail/compressed_sparse_row_struct.hpp [3:5] - include/boost/graph/detail/histogram_sort.hpp [3:5] - include/boost/graph/detail/indexed_properties.hpp [3:5] - include/boost/graph/detail/is_distributed_selector.hpp [3:5] - include/boost/graph/detail/read_graphviz_new.hpp [3:5] - include/boost/graph/detail/read_graphviz_spirit.hpp [3:5] - include/boost/graph/dominator_tree.hpp [4:6] - include/boost/graph/erdos_renyi_generator.hpp [3:5] - include/boost/graph/floyd_warshall_shortest.hpp [3:5] - include/boost/graph/fruchterman_reingold.hpp [3:5] - include/boost/graph/gursoy_atun_layout.hpp [3:5] - include/boost/graph/kamada_kawai_spring_layout.hpp [3:5] - include/boost/graph/loop_erased_random_walk.hpp [3:5] - include/boost/graph/max_cardinality_matching.hpp [4:6] - include/boost/graph/maximum_weighted_matching.hpp [4:6] - include/boost/graph/one_bit_color_map.hpp [3:5] - include/boost/graph/page_rank.hpp [4:6] - include/boost/graph/plod_generator.hpp [3:5] - include/boost/graph/random_layout.hpp [3:5] - include/boost/graph/random_spanning_tree.hpp [3:5] - include/boost/graph/small_world_generator.hpp [3:5] - include/boost/graph/topology.hpp [3:5] - include/boost/graph/two_bit_color_map.hpp [3:5] - src/read_graphviz_new.cpp [3:5] - -KEEP BSL-1.0 3483ad6500a5ec5c1eed3d256900b057 -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or copy at - // http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/boykov_kolmogorov_max_flow.hpp [28:30] - include/boost/graph/write_dimacs.hpp [28:30] - -KEEP BSL-1.0 47a0454637d4fa45d78eb2557ccd70c4 -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. (See - // accompanying file LICENSE_1_0.txt or copy at - // http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/adj_list_serialize.hpp [5:7] - include/boost/graph/adjacency_iterator.hpp [5:7] - include/boost/graph/adjacency_list.hpp [6:8] - include/boost/graph/adjacency_list_io.hpp [5:7] - include/boost/graph/adjacency_matrix.hpp [6:8] - include/boost/graph/astar_search.hpp [7:9] - include/boost/graph/bandwidth.hpp [3:5] - include/boost/graph/bellman_ford_shortest_paths.hpp [6:8] - include/boost/graph/biconnected_components.hpp [4:6] - include/boost/graph/boyer_myrvold_planar_test.hpp [4:6] - include/boost/graph/breadth_first_search.hpp [6:8] - include/boost/graph/chrobak_payne_drawing.hpp [4:6] - include/boost/graph/connected_components.hpp [6:8] - include/boost/graph/copy.hpp [6:8] - include/boost/graph/core_numbers.hpp [6:8] - include/boost/graph/create_condensation_graph.hpp [5:7] - include/boost/graph/cuthill_mckee_ordering.hpp [7:9] - include/boost/graph/cycle_canceling.hpp [5:7] - include/boost/graph/dag_shortest_paths.hpp [5:7] - include/boost/graph/depth_first_search.hpp [6:8] - include/boost/graph/detail/adj_list_edge_iterator.hpp [6:8] - include/boost/graph/detail/adjacency_list.hpp [7:9] - include/boost/graph/detail/array_binary_tree.hpp [6:8] - include/boost/graph/detail/augment.hpp [5:7] - include/boost/graph/detail/connected_components.hpp [5:7] - include/boost/graph/detail/d_ary_heap.hpp [6:8] - include/boost/graph/detail/edge.hpp [6:8] - include/boost/graph/detail/incidence_iterator.hpp [6:8] - include/boost/graph/detail/incremental_components.hpp [6:8] - include/boost/graph/detail/list_base.hpp [5:7] - include/boost/graph/detail/permutation.hpp [2:4] - include/boost/graph/detail/self_avoiding_walk.hpp [5:7] - include/boost/graph/detail/set_adaptor.hpp [2:4] - include/boost/graph/detail/shadow_iterator.hpp [2:4] - include/boost/graph/detail/sparse_ordering.hpp [7:9] - include/boost/graph/dijkstra_shortest_paths.hpp [5:7] - include/boost/graph/dijkstra_shortest_paths_no_color_map.hpp [6:8] - include/boost/graph/dll_import_export.hpp [6:8] - include/boost/graph/edge_coloring.hpp [5:7] - include/boost/graph/edge_connectivity.hpp [5:7] - include/boost/graph/edge_list.hpp [5:7] - include/boost/graph/edmonds_karp_max_flow.hpp [5:7] - include/boost/graph/exception.hpp [5:7] - include/boost/graph/filtered_graph.hpp [5:7] - include/boost/graph/find_flow_cost.hpp [5:7] - include/boost/graph/graph_archetypes.hpp [5:7] - include/boost/graph/graph_as_tree.hpp [6:8] - include/boost/graph/graph_concepts.hpp [8:10] - include/boost/graph/graph_selectors.hpp [5:7] - include/boost/graph/graph_traits.hpp [5:7] - include/boost/graph/graph_utility.hpp [6:8] - include/boost/graph/graphviz.hpp [6:8] - include/boost/graph/grid_graph.hpp [5:7] - include/boost/graph/incremental_components.hpp [7:9] - include/boost/graph/is_kuratowski_subgraph.hpp [4:6] - include/boost/graph/is_straight_line_drawing.hpp [4:6] - include/boost/graph/isomorphism.hpp [3:5] - include/boost/graph/iteration_macros.hpp [5:7] - include/boost/graph/iteration_macros_undef.hpp [5:7] - include/boost/graph/johnson_all_pairs_shortest.hpp [5:7] - include/boost/graph/king_ordering.hpp [7:9] - include/boost/graph/kruskal_min_spanning_tree.hpp [6:8] - include/boost/graph/leda_graph.hpp [8:10] - include/boost/graph/lookup_edge.hpp [5:7] - include/boost/graph/make_biconnected_planar.hpp [4:6] - include/boost/graph/make_connected.hpp [4:6] - include/boost/graph/make_maximal_planar.hpp [4:6] - include/boost/graph/matrix_as_graph.hpp [6:8] - include/boost/graph/maximum_adjacency_search.hpp [6:8] - include/boost/graph/mcgregor_common_subgraphs.hpp [5:7] - include/boost/graph/metric_tsp_approx.hpp [6:8] - include/boost/graph/minimum_degree_ordering.hpp [6:8] - include/boost/graph/named_function_params.hpp [5:7] - include/boost/graph/neighbor_bfs.hpp [6:8] - include/boost/graph/planar_canonical_ordering.hpp [4:6] - include/boost/graph/planar_detail/add_edge_visitors.hpp [4:6] - include/boost/graph/planar_detail/boyer_myrvold_impl.hpp [4:6] - include/boost/graph/planar_detail/bucket_sort.hpp [4:6] - include/boost/graph/planar_detail/face_handles.hpp [4:6] - include/boost/graph/planar_detail/face_iterators.hpp [4:6] - include/boost/graph/planar_face_traversal.hpp [4:6] - include/boost/graph/prim_minimum_spanning_tree.hpp [5:7] - include/boost/graph/profile.hpp [7:9] - include/boost/graph/properties.hpp [5:7] - include/boost/graph/property_iter_range.hpp [4:6] - include/boost/graph/push_relabel_max_flow.hpp [5:7] - include/boost/graph/random.hpp [6:8] - include/boost/graph/read_dimacs.hpp [5:7] - include/boost/graph/relax.hpp [5:7] - include/boost/graph/reverse_graph.hpp [2:4] - include/boost/graph/sequential_vertex_coloring.hpp [6:8] - include/boost/graph/simple_point.hpp [5:7] - include/boost/graph/sloan_ordering.hpp [7:9] - include/boost/graph/smallest_last_ordering.hpp [5:7] - include/boost/graph/stanford_graph.hpp [5:7] - include/boost/graph/strong_components.hpp [6:8] - include/boost/graph/subgraph.hpp [5:7] - include/boost/graph/successive_shortest_path_nonnegative_weights.hpp [5:7] - include/boost/graph/topological_sort.hpp [6:8] - include/boost/graph/transitive_closure.hpp [3:5] - include/boost/graph/transpose_graph.hpp [6:8] - include/boost/graph/tree_traits.hpp [2:4] - include/boost/graph/undirected_dfs.hpp [6:8] - include/boost/graph/vector_as_graph.hpp [7:9] - include/boost/graph/vf2_sub_graph_iso.hpp [10:12] - include/boost/graph/visitors.hpp [5:7] - include/boost/graph/wavefront.hpp [7:9] - include/boost/pending/bucket_sorter.hpp [6:8] - include/boost/pending/disjoint_sets.hpp [6:8] - include/boost/pending/fibonacci_heap.hpp [2:4] - include/boost/pending/indirect_cmp.hpp [6:8] - include/boost/pending/is_heap.hpp [6:8] - include/boost/pending/mutable_heap.hpp [6:8] - include/boost/pending/mutable_queue.hpp [6:8] - -KEEP BSL-1.0 50dc18b27f34dab68ff41aa3f7880dda -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or copy at - // http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/two_graphs_common_spanning_trees.hpp [2:4] - -KEEP BSL-1.0 56683ba341300dc4497f873f670c97b9 -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or copy at - // http://boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 96.30 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/r_c_shortest_paths.hpp [4:6] - -KEEP BSL-1.0 8abbac2c705b0911702566954b0ebe9b -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. (See - // accompanying file LICENSE_1_0.txt or copy at - // http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/pending/container_traits.hpp [4:6] - include/boost/pending/detail/disjoint_sets.hpp [2:4] - include/boost/pending/detail/property.hpp [2:4] - include/boost/pending/fenced_priority_queue.hpp [2:4] - include/boost/pending/property.hpp [2:4] - include/boost/pending/property_serialize.hpp [2:4] - include/boost/pending/queue.hpp [2:4] - include/boost/pending/stringtok.hpp [2:4] - -KEEP Mit-Old-Style 99b210ed9efe704d061e43a6c4c4beb3 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: LicenseRef-scancode-mit-old-style - Score : 100.00 - Match type : TEXT - Links : http://fedoraproject.org/wiki/Licensing:MIT#Old_Style, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit-old-style.LICENSE - Files with this license: - include/boost/detail/algorithm.hpp [22:28] - -KEEP BSL-1.0 a4b06853a77321815bca2cbd7654b649 -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. (See accompany- - // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 96.30 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/detail/algorithm.hpp [2:3] - -KEEP BSL-1.0 b03e7ad31a88c7f7892fe8557944edb4 -BELONGS ya.make - License text: - // Use, modification and distribution are subject to the - // Boost Software License, Version 1.0 (See accompanying file - // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 93.75 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/bron_kerbosch_all_cliques.hpp [3:5] - include/boost/graph/closeness_centrality.hpp [3:5] - include/boost/graph/clustering_coefficient.hpp [3:5] - include/boost/graph/degree_centrality.hpp [3:5] - include/boost/graph/detail/empty_header.hpp [6:8] - include/boost/graph/detail/geodesic.hpp [3:5] - include/boost/graph/detail/index.hpp [3:5] - include/boost/graph/detail/mpi_include.hpp [6:8] - include/boost/graph/directed_graph.hpp [3:5] - include/boost/graph/eccentricity.hpp [3:5] - include/boost/graph/exterior_property.hpp [3:5] - include/boost/graph/geodesic_distance.hpp [3:5] - include/boost/graph/numeric_values.hpp [3:5] - include/boost/graph/property_maps/constant_property_map.hpp [3:5] - include/boost/graph/property_maps/container_property_map.hpp [3:5] - include/boost/graph/property_maps/matrix_property_map.hpp [3:5] - include/boost/graph/property_maps/null_property_map.hpp [3:5] - include/boost/graph/tiernan_all_cycles.hpp [3:5] - include/boost/graph/transitive_reduction.hpp [3:5] - include/boost/graph/undirected_graph.hpp [3:5] - -KEEP Mit-Old-Style b202f5e6061e3eeef6c7dcc2414164b3 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: LicenseRef-scancode-mit-old-style - Score : 100.00 - Match type : TEXT - Links : http://fedoraproject.org/wiki/Licensing:MIT#Old_Style, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit-old-style.LICENSE - Files with this license: - include/boost/detail/algorithm.hpp [10:16] - -KEEP BSL-1.0 bb0492d92471ff074c380f255ab94b94 -BELONGS ya.make - License text: - // Use, modification and distribution is subject to the Boost Software - // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy - // at http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 96.88 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/hawick_circuits.hpp [3:5] - -KEEP BSL-1.0 bf0fd55850dbf83aac86f825081dbe20 -BELONGS ya.make - License text: - // Distributed under the Boost Software License, Version 1.0. - // (See accompanying file LICENSE_1_0.txt or the copy at - // http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 96.43 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/buffer_concepts.hpp [2:4] - include/boost/graph/stoer_wagner_min_cut.hpp [2:4] - -KEEP MIT e8fa61ad26065c016c4c968298a683bd -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: MIT - Score : 100.00 - Match type : TEXT - Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT - Files with this license: - include/boost/graph/boykov_kolmogorov_max_flow.hpp [5:24] - include/boost/graph/write_dimacs.hpp [5:24] - -KEEP BSL-1.0 f20f9faff5dff60d6b8844771d700dd5 -BELONGS ya.make - License text: - * Distributed under the Boost Software License, Version 1.0. (See - * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - Scancode info: - Original SPDX id: BSL-1.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 - Files with this license: - include/boost/graph/bipartite.hpp [7:9] diff --git a/contrib/restricted/boost/graph/.yandex_meta/licenses.list.txt b/contrib/restricted/boost/graph/.yandex_meta/licenses.list.txt deleted file mode 100644 index fc77e6bd4f5..00000000000 --- a/contrib/restricted/boost/graph/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,481 +0,0 @@ -====================BSL-1.0==================== - * Distributed under the Boost Software License, Version 1.0. (See - * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or the copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0 (See accompanying file -// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Use, modification and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy -// at http://www.boost.org/LICENSE_1_0.txt) - - -====================BSL-1.0==================== -// Use, modification and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -====================COPYRIGHT==================== - * Copyright (c) 1994 - * Hewlett-Packard Company - - -====================COPYRIGHT==================== - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - - -====================COPYRIGHT==================== - * Copyright (c) 2010 Matthias Walter (xammy@xammy.homelinux.net) - - -====================COPYRIGHT==================== -// Copyright Daniel Trebbien 2010. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or the copy at - - -====================COPYRIGHT==================== -// Copyright (C) 2012, Michele Caini. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// (C) Copyright David Abrahams 2000. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// (C) Copyright Jeremiah Willcock 2004 -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// (C) Copyright Jeremy Siek 1999. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// (C) Copyright Jeremy Siek 2004 -// (C) Copyright Thomas Claveirole 2010 -// (C) Copyright Ignacy Gawedzki 2010 -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// (C) Copyright Jeremy Siek 2006 -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// Copyright (c) 2006, Stephan Diederich - - -====================COPYRIGHT==================== -// (C) Copyright 2007 Andrew Sutton - - -====================COPYRIGHT==================== -// (C) Copyright 2007-2009 Andrew Sutton - - -====================COPYRIGHT==================== -// (C) Copyright 2009 Eric Bose-Wolf - - -====================COPYRIGHT==================== -// (C) Copyright Andrew Sutton 2007 - - -====================COPYRIGHT==================== -// (C) Copyright Francois Faure, iMAGIS-GRAVIR / UJF, 2001. - - -====================COPYRIGHT==================== -// (C) Copyright Jeremy Siek 2001. -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -====================COPYRIGHT==================== -// (c) Copyright Juergen Hunold 2008 -// Use, modification and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// Copyright (C) 2001 Jeremy Siek, Douglas Gregor, Brian Osman - - -====================COPYRIGHT==================== -// Copyright (C) 2001 Vladimir Prus <ghost@cs.msu.su> -// Copyright (C) 2001 Jeremy Siek <jsiek@cs.indiana.edu> -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at - - -====================COPYRIGHT==================== -// Copyright (C) 2004-2009 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright (C) 2005-2006 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright (C) 2005-2009 Jongsoo Park <jongsoo.park -at- gmail.com> - - -====================COPYRIGHT==================== -// Copyright (C) 2005-2010 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de> -// Copyright (C) 2004 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright (C) 2006 Tiago de Paula Peixoto <tiago@forked.de> -// Copyright (C) 2004,2009 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright (C) 2006 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright (C) 2006-2009 Dmitry Bufistov and Andrey Parfenov - - -====================COPYRIGHT==================== -// Copyright (C) 2007 Douglas Gregor - - -====================COPYRIGHT==================== -// Copyright (C) 2009 Andrew Sutton - - -====================COPYRIGHT==================== -// Copyright (C) 2012 Flavio De Lorenzi (fdlorenzi@gmail.com) -// Copyright (C) 2013 Jakob Lykke Andersen, University of Southern Denmark -// (jlandersen@imada.sdu.dk) - - -====================COPYRIGHT==================== -// Copyright (c) 2004 Kristopher Beevers - - -====================COPYRIGHT==================== -// Copyright (c) 2005 Aaron Windsor - - -====================COPYRIGHT==================== -// Copyright (c) 2018 Yi Ji - - -====================COPYRIGHT==================== -// Copyright (c) Aaron Windsor 2007 - - -====================COPYRIGHT==================== -// Copyright (c) Jeremy Siek 2001 -// Copyright (c) Douglas Gregor 2004 - - -====================COPYRIGHT==================== -// Copyright (c) Jeremy Siek 2001, Marc Wintermantel 2002 - - -====================COPYRIGHT==================== -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Copyright (C) Vladimir Prus 2003 -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - - -====================COPYRIGHT==================== -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Copyright 2003 Bruce Barr -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - - -====================COPYRIGHT==================== -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Copyright 2004 The Trustees of Indiana University. -// Copyright 2007 University of Karlsruhe -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Douglas Gregor, -// Jens Mueller - - -====================COPYRIGHT==================== -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Copyright 2004, 2005 Trustees of Indiana University -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, -// Doug Gregor, D. Kevin McGrath - - -====================COPYRIGHT==================== -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Copyright 2006 The Trustees of Indiana University. -// Copyright (C) 2001 Vladimir Prus <ghost@cs.msu.su> -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Douglas Gregor - - -====================COPYRIGHT==================== -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Copyright 2009 Trustees of Indiana University. -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Michael Hansen - - -====================COPYRIGHT==================== -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Copyright 2010 Thomas Claveirole -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Thomas Claveirole - - -====================COPYRIGHT==================== -// Copyright 1997-2001 University of Notre Dame. -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - - -====================COPYRIGHT==================== -// Copyright 2000 University of Notre Dame. -// Authors: Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee - - -====================COPYRIGHT==================== -// Copyright 2001 Indiana University -// Author: Jeremy G. Siek - - -====================COPYRIGHT==================== -// Copyright 2001 Universite Joseph Fourier, Grenoble. -// Author: Francois Faure - - -====================COPYRIGHT==================== -// Copyright 2001 University of Notre Dame. -// Copyright 2003 Jeremy Siek -// Authors: Lie-Quan Lee, Jeremy Siek, and Douglas Gregor - - -====================COPYRIGHT==================== -// Copyright 2001 University of Notre Dame. -// Copyright 2006 Trustees of Indiana University -// Authors: Jeremy G. Siek and Douglas Gregor <dgregor@cs.indiana.edu> - - -====================COPYRIGHT==================== -// Copyright 2002 Indiana University. -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek - - -====================COPYRIGHT==================== -// Copyright 2002 Marc Wintermantel (wintermantel@even-ag.ch) -// ETH Zurich, Center of Structure Technologies -// (https://web.archive.org/web/20050307090307/http://www.structures.ethz.ch/) - - -====================COPYRIGHT==================== -// Copyright 2002 Rensselaer Polytechnic Institute - - -====================COPYRIGHT==================== -// Copyright 2004 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2004, 2005 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2004-2006 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2004-5 The Trustees of Indiana University. -// Copyright 2002 Brad King and Douglas Gregor - - -====================COPYRIGHT==================== -// Copyright 2004-9 Trustees of Indiana University - - -====================COPYRIGHT==================== -// Copyright 2005 Jeremy G. Siek -// Authors: Jeremy G. Siek - - -====================COPYRIGHT==================== -// Copyright 2005 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2005 Trustees of Indiana University -// Authors: Andrew Lumsdaine, Douglas Gregor - - -====================COPYRIGHT==================== -// Copyright 2005-2009 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2007 Aaron Windsor - - -====================COPYRIGHT==================== -// Copyright 2007 Stanford University -// Authors: David Gleich - - -====================COPYRIGHT==================== -// Copyright 2008 -// Author: Matyas W Egyhazy - - -====================COPYRIGHT==================== -// Copyright 2009 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2009, Andrew Sutton - - -====================COPYRIGHT==================== -// Copyright 2010 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2012 Fernando Vilas -// 2010 Daniel Trebbien - - -====================COPYRIGHT==================== -// Copyright 2012 The Trustees of Indiana University. - - -====================COPYRIGHT==================== -// Copyright 2013 Maciej Piechotka -// Authors: Maciej Piechotka - - -====================COPYRIGHT==================== -// Copyright 2013 University of Warsaw. -// Authors: Piotr Wygocki - - -====================COPYRIGHT==================== -// Copyright 2018 Peter Dimov - - -====================COPYRIGHT==================== -// Copyright Louis Dionne 2013 - - -====================COPYRIGHT==================== -// Copyright Michael Drexl 2005, 2006. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at - - -====================MIT==================== -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. OF SUCH DAMAGE. - - -====================Mit-Old-Style==================== - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - - -====================Mit-Old-Style==================== - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. diff --git a/contrib/restricted/boost/graph/ya.make b/contrib/restricted/boost/graph/ya.make new file mode 100644 index 00000000000..adf54adbeea --- /dev/null +++ b/contrib/restricted/boost/graph/ya.make @@ -0,0 +1,80 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + MIT AND + Mit-Old-Style +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/graph/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/algorithm + contrib/restricted/boost/any + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/bimap + contrib/restricted/boost/bind + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/conversion + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/foreach + contrib/restricted/boost/function + contrib/restricted/boost/integer + contrib/restricted/boost/iterator + contrib/restricted/boost/lexical_cast + contrib/restricted/boost/math + contrib/restricted/boost/move + contrib/restricted/boost/mpl + contrib/restricted/boost/multi_index + contrib/restricted/boost/optional + contrib/restricted/boost/parameter + contrib/restricted/boost/preprocessor + contrib/restricted/boost/property_map + contrib/restricted/boost/property_tree + contrib/restricted/boost/random + contrib/restricted/boost/range + contrib/restricted/boost/regex + contrib/restricted/boost/serialization + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/spirit + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tti + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof + contrib/restricted/boost/unordered + contrib/restricted/boost/utility + contrib/restricted/boost/xpressive +) + +ADDINCL( + GLOBAL contrib/restricted/boost/graph/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_GRAPH_DYN_LINK + ) +ENDIF() + +SRCS( + src/graphml.cpp + src/read_graphviz_new.cpp +) + +END() diff --git a/contrib/restricted/boost/icl/ya.make b/contrib/restricted/boost/icl/ya.make new file mode 100644 index 00000000000..9b1f7ab6f9a --- /dev/null +++ b/contrib/restricted/boost/icl/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/icl/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/container + contrib/restricted/boost/core + contrib/restricted/boost/date_time + contrib/restricted/boost/detail + contrib/restricted/boost/iterator + contrib/restricted/boost/move + contrib/restricted/boost/mpl + contrib/restricted/boost/range + contrib/restricted/boost/rational + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/icl/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/integer/ya.make b/contrib/restricted/boost/integer/ya.make new file mode 100644 index 00000000000..c91e024c94d --- /dev/null +++ b/contrib/restricted/boost/integer/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/integer/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception +) + +ADDINCL( + GLOBAL contrib/restricted/boost/integer/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/interprocess/ya.make b/contrib/restricted/boost/interprocess/ya.make new file mode 100644 index 00000000000..426d3e79150 --- /dev/null +++ b/contrib/restricted/boost/interprocess/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Mit-Old-Style +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/interprocess/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/container + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/intrusive + contrib/restricted/boost/move + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits + contrib/restricted/boost/unordered + contrib/restricted/boost/winapi +) + +ADDINCL( + GLOBAL contrib/restricted/boost/interprocess/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/intrusive/ya.make b/contrib/restricted/boost/intrusive/ya.make new file mode 100644 index 00000000000..c7811ae78e6 --- /dev/null +++ b/contrib/restricted/boost/intrusive/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Public-Domain +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/intrusive/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/move + contrib/restricted/boost/static_assert +) + +ADDINCL( + GLOBAL contrib/restricted/boost/intrusive/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/io/ya.make b/contrib/restricted/boost/io/ya.make new file mode 100644 index 00000000000..f9ba972219b --- /dev/null +++ b/contrib/restricted/boost/io/ya.make @@ -0,0 +1,25 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/io/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config +) + +ADDINCL( + GLOBAL contrib/restricted/boost/io/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/iostreams/ya.make b/contrib/restricted/boost/iostreams/ya.make new file mode 100644 index 00000000000..6ab0613d10b --- /dev/null +++ b/contrib/restricted/boost/iostreams/ya.make @@ -0,0 +1,68 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/iostreams/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/libs/libbz2 + contrib/libs/lzma + contrib/libs/zlib + contrib/libs/zstd + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/function + contrib/restricted/boost/integer + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/numeric_conversion + contrib/restricted/boost/preprocessor + contrib/restricted/boost/random + contrib/restricted/boost/range + contrib/restricted/boost/regex + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/iostreams/include + contrib/libs/libbz2 + contrib/libs/zstd/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DBOOST_IOSTREAMS_USE_DEPRECATED +) + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_IOSTREAMS_DYN_LINK + ) +ENDIF() + +SRCS( + src/bzip2.cpp + src/file_descriptor.cpp + src/gzip.cpp + src/lzma.cpp + src/mapped_file.cpp + src/zlib.cpp + src/zstd.cpp +) + +END() diff --git a/contrib/restricted/boost/iterator/ya.make b/contrib/restricted/boost/iterator/ya.make new file mode 100644 index 00000000000..52be178159c --- /dev/null +++ b/contrib/restricted/boost/iterator/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/iterator/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/conversion + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/function_types + contrib/restricted/boost/fusion + contrib/restricted/boost/mpl + contrib/restricted/boost/optional + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/iterator/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/lambda/ya.make b/contrib/restricted/boost/lambda/ya.make new file mode 100644 index 00000000000..ae9dd78c7c4 --- /dev/null +++ b/contrib/restricted/boost/lambda/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/lambda/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/bind + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/lambda/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/lexical_cast/ya.make b/contrib/restricted/boost/lexical_cast/ya.make new file mode 100644 index 00000000000..48220c38b0e --- /dev/null +++ b/contrib/restricted/boost/lexical_cast/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/lexical_cast/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/container + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/numeric_conversion + contrib/restricted/boost/range + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/lexical_cast/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/locale/ya.make b/contrib/restricted/boost/locale/ya.make new file mode 100644 index 00000000000..1e440342d33 --- /dev/null +++ b/contrib/restricted/boost/locale/ya.make @@ -0,0 +1,105 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/locale/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/libs/icu + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/iterator + contrib/restricted/boost/predef + contrib/restricted/boost/thread +) + +ADDINCL( + GLOBAL contrib/restricted/boost/locale/include + contrib/restricted/boost/locale/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DBOOST_LOCALE_WITH_ICU +) + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_LOCALE_DYN_LINK + ) +ENDIF() + +IF (OS_ANDROID) + CFLAGS( + -DBOOST_LOCALE_NO_POSIX_BACKEND + -DBOOST_LOCALE_NO_WINAPI_BACKEND + ) +ELSEIF (OS_WINDOWS) + CFLAGS( + -DBOOST_LOCALE_NO_POSIX_BACKEND + ) + SRCS( + src/boost/locale/win32/collate.cpp + src/boost/locale/win32/converter.cpp + src/boost/locale/win32/lcid.cpp + src/boost/locale/win32/numeric.cpp + src/boost/locale/win32/win_backend.cpp + ) +ELSE() + CFLAGS( + -DBOOST_LOCALE_NO_WINAPI_BACKEND + ) + SRCS( + src/boost/locale/posix/codecvt.cpp + src/boost/locale/posix/collate.cpp + src/boost/locale/posix/converter.cpp + src/boost/locale/posix/numeric.cpp + src/boost/locale/posix/posix_backend.cpp + ) +ENDIF() + +SRCS( + src/boost/locale/encoding/codepage.cpp + src/boost/locale/icu/boundary.cpp + src/boost/locale/icu/codecvt.cpp + src/boost/locale/icu/collator.cpp + src/boost/locale/icu/conversion.cpp + src/boost/locale/icu/date_time.cpp + src/boost/locale/icu/formatter.cpp + src/boost/locale/icu/formatters_cache.cpp + src/boost/locale/icu/icu_backend.cpp + src/boost/locale/icu/numeric.cpp + src/boost/locale/icu/time_zone.cpp + src/boost/locale/shared/date_time.cpp + src/boost/locale/shared/format.cpp + src/boost/locale/shared/formatting.cpp + src/boost/locale/shared/generator.cpp + src/boost/locale/shared/iconv_codecvt.cpp + src/boost/locale/shared/ids.cpp + src/boost/locale/shared/localization_backend.cpp + src/boost/locale/shared/message.cpp + src/boost/locale/shared/mo_lambda.cpp + src/boost/locale/std/codecvt.cpp + src/boost/locale/std/collate.cpp + src/boost/locale/std/converter.cpp + src/boost/locale/std/numeric.cpp + src/boost/locale/std/std_backend.cpp + src/boost/locale/util/codecvt_converter.cpp + src/boost/locale/util/default_locale.cpp + src/boost/locale/util/encoding.cpp + src/boost/locale/util/gregorian.cpp + src/boost/locale/util/info.cpp + src/boost/locale/util/locale_data.cpp +) + +END() diff --git a/contrib/restricted/boost/math/ya.make b/contrib/restricted/boost/math/ya.make new file mode 100644 index 00000000000..dcd074ca451 --- /dev/null +++ b/contrib/restricted/boost/math/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/math/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/lexical_cast + contrib/restricted/boost/predef + contrib/restricted/boost/random + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception +) + +ADDINCL( + GLOBAL contrib/restricted/boost/math/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/move/ya.make b/contrib/restricted/boost/move/ya.make new file mode 100644 index 00000000000..b300e583aef --- /dev/null +++ b/contrib/restricted/boost/move/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Zlib +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/move/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config +) + +ADDINCL( + GLOBAL contrib/restricted/boost/move/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/mp11/ya.make b/contrib/restricted/boost/mp11/ya.make new file mode 100644 index 00000000000..a8d127272f1 --- /dev/null +++ b/contrib/restricted/boost/mp11/ya.make @@ -0,0 +1,21 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/mp11/archive/boost-1.82.0.tar.gz) + +ADDINCL( + GLOBAL contrib/restricted/boost/mp11/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/mpl/ya.make b/contrib/restricted/boost/mpl/ya.make new file mode 100644 index 00000000000..f5e5e1eaae1 --- /dev/null +++ b/contrib/restricted/boost/mpl/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/mpl/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/predef + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/mpl/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/multi_array/ya.make b/contrib/restricted/boost/multi_array/ya.make new file mode 100644 index 00000000000..b59c005626c --- /dev/null +++ b/contrib/restricted/boost/multi_array/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Mit-Old-Style +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/multi_array/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/functional + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/multi_array/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/multi_index/ya.make b/contrib/restricted/boost/multi_index/ya.make new file mode 100644 index 00000000000..a21a1cdf24d --- /dev/null +++ b/contrib/restricted/boost/multi_index/ya.make @@ -0,0 +1,43 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Mit-Old-Style +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/multi_index/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/iterator + contrib/restricted/boost/move + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/multi_index/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/numeric_conversion/ya.make b/contrib/restricted/boost/numeric_conversion/ya.make new file mode 100644 index 00000000000..ddd30882229 --- /dev/null +++ b/contrib/restricted/boost/numeric_conversion/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/numeric_conversion/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/conversion + contrib/restricted/boost/core + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/numeric_conversion/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/optional/ya.make b/contrib/restricted/boost/optional/ya.make new file mode 100644 index 00000000000..9f1ff98866e --- /dev/null +++ b/contrib/restricted/boost/optional/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/optional/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/move + contrib/restricted/boost/predef + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/optional/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/parameter/ya.make b/contrib/restricted/boost/parameter/ya.make new file mode 100644 index 00000000000..d6f44f4f37f --- /dev/null +++ b/contrib/restricted/boost/parameter/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/parameter/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/function + contrib/restricted/boost/fusion + contrib/restricted/boost/mp11 + contrib/restricted/boost/mpl + contrib/restricted/boost/optional + contrib/restricted/boost/preprocessor + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/parameter/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/phoenix/ya.make b/contrib/restricted/boost/phoenix/ya.make new file mode 100644 index 00000000000..052565c3b00 --- /dev/null +++ b/contrib/restricted/boost/phoenix/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/phoenix/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/function + contrib/restricted/boost/fusion + contrib/restricted/boost/mpl + contrib/restricted/boost/predef + contrib/restricted/boost/preprocessor + contrib/restricted/boost/proto + contrib/restricted/boost/range + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/phoenix/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/pool/ya.make b/contrib/restricted/boost/pool/ya.make new file mode 100644 index 00000000000..bdba88992c1 --- /dev/null +++ b/contrib/restricted/boost/pool/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/pool/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/integer + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/winapi +) + +ADDINCL( + GLOBAL contrib/restricted/boost/pool/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/predef/ya.make b/contrib/restricted/boost/predef/ya.make new file mode 100644 index 00000000000..2ee2182bb46 --- /dev/null +++ b/contrib/restricted/boost/predef/ya.make @@ -0,0 +1,21 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/predef/archive/boost-1.82.0.tar.gz) + +ADDINCL( + GLOBAL contrib/restricted/boost/predef/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/preprocessor/ya.make b/contrib/restricted/boost/preprocessor/ya.make new file mode 100644 index 00000000000..889f663ac6d --- /dev/null +++ b/contrib/restricted/boost/preprocessor/ya.make @@ -0,0 +1,21 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/preprocessor/archive/boost-1.82.0.tar.gz) + +ADDINCL( + GLOBAL contrib/restricted/boost/preprocessor/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/program_options/ya.make b/contrib/restricted/boost/program_options/ya.make new file mode 100644 index 00000000000..0390a784176 --- /dev/null +++ b/contrib/restricted/boost/program_options/ya.make @@ -0,0 +1,57 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/program_options/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/any + contrib/restricted/boost/bind + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/function + contrib/restricted/boost/iterator + contrib/restricted/boost/lexical_cast + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tokenizer + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/program_options/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_PROGRAM_OPTIONS_DYN_LINK + ) +ENDIF() + +SRCS( + src/cmdline.cpp + src/config_file.cpp + src/convert.cpp + src/options_description.cpp + src/parsers.cpp + src/positional_options.cpp + src/split.cpp + src/utf8_codecvt_facet.cpp + src/value_semantic.cpp + src/variables_map.cpp + src/winmain.cpp +) + +END() diff --git a/contrib/restricted/boost/property_map/ya.make b/contrib/restricted/boost/property_map/ya.make new file mode 100644 index 00000000000..26c3cff54ff --- /dev/null +++ b/contrib/restricted/boost/property_map/ya.make @@ -0,0 +1,38 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/property_map/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/any + contrib/restricted/boost/assert + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/function + contrib/restricted/boost/iterator + contrib/restricted/boost/lexical_cast + contrib/restricted/boost/mpl + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/property_map/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/property_tree/ya.make b/contrib/restricted/boost/property_tree/ya.make new file mode 100644 index 00000000000..3087782d568 --- /dev/null +++ b/contrib/restricted/boost/property_tree/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/property_tree/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/any + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/format + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/multi_index + contrib/restricted/boost/optional + contrib/restricted/boost/range + contrib/restricted/boost/serialization + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/property_tree/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/proto/ya.make b/contrib/restricted/boost/proto/ya.make new file mode 100644 index 00000000000..c3fde1189d1 --- /dev/null +++ b/contrib/restricted/boost/proto/ya.make @@ -0,0 +1,34 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/proto/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/fusion + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/range + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/proto/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/random/ya.make b/contrib/restricted/boost/random/ya.make new file mode 100644 index 00000000000..910eaa69c5b --- /dev/null +++ b/contrib/restricted/boost/random/ya.make @@ -0,0 +1,47 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/random/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/dynamic_bitset + contrib/restricted/boost/integer + contrib/restricted/boost/io + contrib/restricted/boost/range + contrib/restricted/boost/static_assert + contrib/restricted/boost/system + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/random/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_RANDOM_DYN_LINK + ) +ENDIF() + +SRCS( + src/random_device.cpp +) + +END() diff --git a/contrib/restricted/boost/range/ya.make b/contrib/restricted/boost/range/ya.make new file mode 100644 index 00000000000..af25654702c --- /dev/null +++ b/contrib/restricted/boost/range/ya.make @@ -0,0 +1,41 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/range/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/conversion + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/optional + contrib/restricted/boost/preprocessor + contrib/restricted/boost/regex + contrib/restricted/boost/static_assert + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/range/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/ratio/ya.make b/contrib/restricted/boost/ratio/ya.make new file mode 100644 index 00000000000..7378f59b5a9 --- /dev/null +++ b/contrib/restricted/boost/ratio/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/ratio/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/mpl + contrib/restricted/boost/rational + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/ratio/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/rational/ya.make b/contrib/restricted/boost/rational/ya.make new file mode 100644 index 00000000000..494e1c60c8a --- /dev/null +++ b/contrib/restricted/boost/rational/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/rational/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/rational/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/regex/ya.make b/contrib/restricted/boost/regex/ya.make new file mode 100644 index 00000000000..f53f6e48241 --- /dev/null +++ b/contrib/restricted/boost/regex/ya.make @@ -0,0 +1,62 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/regex/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/libs/icu + contrib/restricted/boost/assert + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/integer + contrib/restricted/boost/mpl + contrib/restricted/boost/predef + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/regex/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DBOOST_HAS_ICU + -DBOOST_NO_CXX98_BINDERS +) + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_REGEX_DYN_LINK + ) +ENDIF() + +IF (OS_WINDOWS) + CFLAGS( + GLOBAL -DBOOST_REGEX_USE_CPP_LOCALE + ) +ENDIF() + +SRCS( + src/posix_api.cpp + src/regex.cpp + src/regex_debug.cpp + src/static_mutex.cpp + src/wide_posix_api.cpp +) + +END() diff --git a/contrib/restricted/boost/scope_exit/ya.make b/contrib/restricted/boost/scope_exit/ya.make new file mode 100644 index 00000000000..d92f8ba03f4 --- /dev/null +++ b/contrib/restricted/boost/scope_exit/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/scope_exit/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/function + contrib/restricted/boost/preprocessor + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof +) + +ADDINCL( + GLOBAL contrib/restricted/boost/scope_exit/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/serialization/ya.make b/contrib/restricted/boost/serialization/ya.make new file mode 100644 index 00000000000..df1f0999240 --- /dev/null +++ b/contrib/restricted/boost/serialization/ya.make @@ -0,0 +1,105 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + Zlib +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/serialization/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/function + contrib/restricted/boost/integer + contrib/restricted/boost/io + contrib/restricted/boost/iterator + contrib/restricted/boost/move + contrib/restricted/boost/mpl + contrib/restricted/boost/optional + contrib/restricted/boost/predef + contrib/restricted/boost/preprocessor + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/spirit + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits + contrib/restricted/boost/unordered + contrib/restricted/boost/utility + contrib/restricted/boost/variant +) + +ADDINCL( + GLOBAL contrib/restricted/boost/serialization/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_SERIALIZATION_DYN_LINK + ) +ENDIF() + +SRCS( + src/archive_exception.cpp + src/basic_archive.cpp + src/basic_iarchive.cpp + src/basic_iserializer.cpp + src/basic_oarchive.cpp + src/basic_oserializer.cpp + src/basic_pointer_iserializer.cpp + src/basic_pointer_oserializer.cpp + src/basic_serializer_map.cpp + src/basic_text_iprimitive.cpp + src/basic_text_oprimitive.cpp + src/basic_text_wiprimitive.cpp + src/basic_text_woprimitive.cpp + src/basic_xml_archive.cpp + src/binary_iarchive.cpp + src/binary_oarchive.cpp + src/binary_wiarchive.cpp + src/binary_woarchive.cpp + src/codecvt_null.cpp + src/extended_type_info.cpp + src/extended_type_info_no_rtti.cpp + src/extended_type_info_typeid.cpp + src/polymorphic_binary_iarchive.cpp + src/polymorphic_binary_oarchive.cpp + src/polymorphic_iarchive.cpp + src/polymorphic_oarchive.cpp + src/polymorphic_text_iarchive.cpp + src/polymorphic_text_oarchive.cpp + src/polymorphic_text_wiarchive.cpp + src/polymorphic_text_woarchive.cpp + src/polymorphic_xml_iarchive.cpp + src/polymorphic_xml_oarchive.cpp + src/polymorphic_xml_wiarchive.cpp + src/polymorphic_xml_woarchive.cpp + src/stl_port.cpp + src/text_iarchive.cpp + src/text_oarchive.cpp + src/text_wiarchive.cpp + src/text_woarchive.cpp + src/utf8_codecvt_facet.cpp + src/void_cast.cpp + src/xml_archive_exception.cpp + src/xml_grammar.cpp + src/xml_iarchive.cpp + src/xml_oarchive.cpp + src/xml_wgrammar.cpp + src/xml_wiarchive.cpp + src/xml_woarchive.cpp +) + +END() diff --git a/contrib/restricted/boost/smart_ptr/ya.make b/contrib/restricted/boost/smart_ptr/ya.make new file mode 100644 index 00000000000..4b0fe82e32b --- /dev/null +++ b/contrib/restricted/boost/smart_ptr/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/smart_ptr/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/move + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/smart_ptr/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/spirit/ya.make b/contrib/restricted/boost/spirit/ya.make new file mode 100644 index 00000000000..27d7d3b8da7 --- /dev/null +++ b/contrib/restricted/boost/spirit/ya.make @@ -0,0 +1,53 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/spirit/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/endian + contrib/restricted/boost/function + contrib/restricted/boost/function_types + contrib/restricted/boost/fusion + contrib/restricted/boost/integer + contrib/restricted/boost/io + contrib/restricted/boost/iterator + contrib/restricted/boost/move + contrib/restricted/boost/mpl + contrib/restricted/boost/optional + contrib/restricted/boost/phoenix + contrib/restricted/boost/pool + contrib/restricted/boost/preprocessor + contrib/restricted/boost/proto + contrib/restricted/boost/range + contrib/restricted/boost/regex + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/thread + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof + contrib/restricted/boost/unordered + contrib/restricted/boost/utility + contrib/restricted/boost/variant +) + +ADDINCL( + GLOBAL contrib/restricted/boost/spirit/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/static_assert/ya.make b/contrib/restricted/boost/static_assert/ya.make new file mode 100644 index 00000000000..e7906a9df60 --- /dev/null +++ b/contrib/restricted/boost/static_assert/ya.make @@ -0,0 +1,25 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/static_assert/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config +) + +ADDINCL( + GLOBAL contrib/restricted/boost/static_assert/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/system/ya.make b/contrib/restricted/boost/system/ya.make new file mode 100644 index 00000000000..b097df9843b --- /dev/null +++ b/contrib/restricted/boost/system/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/system/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/throw_exception + contrib/restricted/boost/variant2 + contrib/restricted/boost/winapi +) + +ADDINCL( + GLOBAL contrib/restricted/boost/system/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/thread/ya.make b/contrib/restricted/boost/thread/ya.make new file mode 100644 index 00000000000..d10f2d9bb1f --- /dev/null +++ b/contrib/restricted/boost/thread/ya.make @@ -0,0 +1,97 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + BSL-1.0 AND + MIT AND + NCSA +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/thread/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/algorithm + contrib/restricted/boost/assert + contrib/restricted/boost/atomic + contrib/restricted/boost/bind + contrib/restricted/boost/chrono + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/container + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/date_time + contrib/restricted/boost/exception + contrib/restricted/boost/function + contrib/restricted/boost/intrusive + contrib/restricted/boost/io + contrib/restricted/boost/iterator + contrib/restricted/boost/lexical_cast + contrib/restricted/boost/move + contrib/restricted/boost/optional + contrib/restricted/boost/predef + contrib/restricted/boost/preprocessor + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/system + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility + contrib/restricted/boost/winapi +) + +ADDINCL( + GLOBAL contrib/restricted/boost/thread/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + -DBOOST_THREAD_BUILD_DLL + GLOBAL -DBOOST_THREAD_USE_DLL + ) +ELSE() + CFLAGS( + -DBOOST_THREAD_BUILD_LIB + GLOBAL -DBOOST_THREAD_USE_LIB + ) +ENDIF() + +SRCS( + src/future.cpp +) + +IF (OS_WINDOWS) + CFLAGS( + GLOBAL -DBOOST_THREAD_WIN32 + -DBOOST_THREAD_USES_CHRONO + -DWIN32_LEAN_AND_MEAN + -DBOOST_USE_WINDOWS_H + ) + SRCS( + src/win32/thread.cpp + src/win32/thread_primitives.cpp + src/win32/tss_dll.cpp + src/win32/tss_pe.cpp + ) +ELSE() + CFLAGS( + GLOBAL -DBOOST_THREAD_POSIX + -DBOOST_THREAD_DONT_USE_CHRONO + ) + SRCS( + src/pthread/once.cpp + src/pthread/thread.cpp + ) +ENDIF() + +END() diff --git a/contrib/restricted/boost/throw_exception/ya.make b/contrib/restricted/boost/throw_exception/ya.make new file mode 100644 index 00000000000..afa915cae13 --- /dev/null +++ b/contrib/restricted/boost/throw_exception/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/throw_exception/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config +) + +ADDINCL( + GLOBAL contrib/restricted/boost/throw_exception/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/tokenizer/ya.make b/contrib/restricted/boost/tokenizer/ya.make new file mode 100644 index 00000000000..a3be340c07a --- /dev/null +++ b/contrib/restricted/boost/tokenizer/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/tokenizer/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/tokenizer/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/tti/ya.make b/contrib/restricted/boost/tti/ya.make new file mode 100644 index 00000000000..a4aed99318e --- /dev/null +++ b/contrib/restricted/boost/tti/ya.make @@ -0,0 +1,29 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/tti/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/function_types + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/tti/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/tuple/ya.make b/contrib/restricted/boost/tuple/ya.make new file mode 100644 index 00000000000..be52e9cd8c1 --- /dev/null +++ b/contrib/restricted/boost/tuple/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/tuple/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/static_assert + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/tuple/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/type_index/ya.make b/contrib/restricted/boost/type_index/ya.make new file mode 100644 index 00000000000..8e140633ee4 --- /dev/null +++ b/contrib/restricted/boost/type_index/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/type_index/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/type_index/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/type_traits/ya.make b/contrib/restricted/boost/type_traits/ya.make new file mode 100644 index 00000000000..b722f39867e --- /dev/null +++ b/contrib/restricted/boost/type_traits/ya.make @@ -0,0 +1,26 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/type_traits/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/static_assert +) + +ADDINCL( + GLOBAL contrib/restricted/boost/type_traits/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/typeof/ya.make b/contrib/restricted/boost/typeof/ya.make new file mode 100644 index 00000000000..6029879923e --- /dev/null +++ b/contrib/restricted/boost/typeof/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/typeof/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/preprocessor + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/typeof/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/unordered/ya.make b/contrib/restricted/boost/unordered/ya.make new file mode 100644 index 00000000000..8f7106580ba --- /dev/null +++ b/contrib/restricted/boost/unordered/ya.make @@ -0,0 +1,37 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.77.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/unordered/archive/boost-1.77.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/container + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/move + contrib/restricted/boost/predef + contrib/restricted/boost/preprocessor + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/unordered/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/utility/ya.make b/contrib/restricted/boost/utility/ya.make new file mode 100644 index 00000000000..6c43a8afebc --- /dev/null +++ b/contrib/restricted/boost/utility/ya.make @@ -0,0 +1,31 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/utility/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/io + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits +) + +ADDINCL( + GLOBAL contrib/restricted/boost/utility/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/variant/ya.make b/contrib/restricted/boost/variant/ya.make new file mode 100644 index 00000000000..08306d01dde --- /dev/null +++ b/contrib/restricted/boost/variant/ya.make @@ -0,0 +1,39 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/variant/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/config + contrib/restricted/boost/container_hash + contrib/restricted/boost/core + contrib/restricted/boost/detail + contrib/restricted/boost/integer + contrib/restricted/boost/move + contrib/restricted/boost/mpl + contrib/restricted/boost/preprocessor + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_index + contrib/restricted/boost/type_traits + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/variant/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/variant2/ya.make b/contrib/restricted/boost/variant2/ya.make new file mode 100644 index 00000000000..0f4321f132a --- /dev/null +++ b/contrib/restricted/boost/variant2/ya.make @@ -0,0 +1,27 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/variant2/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/mp11 +) + +ADDINCL( + GLOBAL contrib/restricted/boost/variant2/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/boost/winapi/ya.make b/contrib/restricted/boost/winapi/ya.make new file mode 100644 index 00000000000..34685f2ba7a --- /dev/null +++ b/contrib/restricted/boost/winapi/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/winapi/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/config + contrib/restricted/boost/predef +) + +ADDINCL( + GLOBAL contrib/restricted/boost/winapi/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (OS_WINDOWS) + CFLAGS( + GLOBAL -DBOOST_USE_WINDOWS_H + ) +ENDIF() + +END() diff --git a/contrib/restricted/boost/xpressive/ya.make b/contrib/restricted/boost/xpressive/ya.make new file mode 100644 index 00000000000..5d0205fadb9 --- /dev/null +++ b/contrib/restricted/boost/xpressive/ya.make @@ -0,0 +1,45 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.82.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/xpressive/archive/boost-1.82.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/assert + contrib/restricted/boost/config + contrib/restricted/boost/conversion + contrib/restricted/boost/core + contrib/restricted/boost/exception + contrib/restricted/boost/fusion + contrib/restricted/boost/integer + contrib/restricted/boost/iterator + contrib/restricted/boost/lexical_cast + contrib/restricted/boost/mpl + contrib/restricted/boost/numeric_conversion + contrib/restricted/boost/optional + contrib/restricted/boost/preprocessor + contrib/restricted/boost/proto + contrib/restricted/boost/range + contrib/restricted/boost/smart_ptr + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/type_traits + contrib/restricted/boost/typeof + contrib/restricted/boost/utility +) + +ADDINCL( + GLOBAL contrib/restricted/boost/xpressive/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() diff --git a/contrib/restricted/cityhash-1.0.2/ya.make b/contrib/restricted/cityhash-1.0.2/ya.make new file mode 100644 index 00000000000..55064c5fac4 --- /dev/null +++ b/contrib/restricted/cityhash-1.0.2/ya.make @@ -0,0 +1,21 @@ +# Origin: https://github.com/google/cityhash.git + +LIBRARY() + +VERSION(bc38ef45ddbbe640e48db7b8ef65e80ea7f71298) + +LICENSE(MIT) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +ADDINCL( + GLOBAL contrib/restricted/cityhash-1.0.2 +) + +SRCS( + city.cc +) + +END() diff --git a/contrib/restricted/dragonbox/ya.make b/contrib/restricted/dragonbox/ya.make new file mode 100644 index 00000000000..2ccff2fdf1d --- /dev/null +++ b/contrib/restricted/dragonbox/ya.make @@ -0,0 +1,31 @@ +LIBRARY(dragonbox) + +# git repository: https://github.com/ClickHouse-Extras/dragonbox.git +# fork of: https://github.com/jk-jeon/dragonbox.git +# revision: b2751c65c0592c0239aec3becd53d0ea2fde9329 + +VERSION(2020-12-14-b2751c65c0592c0239aec3becd53d0ea2fde9329) + +LICENSE( + "(BSL-1.0 OR Apache-2.0)" AND + Apache-2.0 AND + Apache-2.0 WITH LLVM-exception AND + BSL-1.0 AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +ADDINCL( + GLOBAL contrib/restricted/dragonbox/include +) + +SRCS( + source/dragonbox_to_chars.cpp +) + +END() diff --git a/contrib/restricted/fast_float/ya.make b/contrib/restricted/fast_float/ya.make new file mode 100644 index 00000000000..cde7739eba0 --- /dev/null +++ b/contrib/restricted/fast_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker from nixpkgs 22.11. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + BSL-1.0 AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(5.0.0) + +ORIGINAL_SOURCE(https://github.com/fastfloat/fast_float/archive/v5.0.0.tar.gz) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +NO_UTIL() + +END() diff --git a/contrib/restricted/google/benchmark/test/ya.make b/contrib/restricted/google/benchmark/test/ya.make new file mode 100644 index 00000000000..e5ca53e0d81 --- /dev/null +++ b/contrib/restricted/google/benchmark/test/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +GTEST(benchmark_gtest) + +WITHOUT_LICENSE_TEXTS() + +PEERDIR( + contrib/restricted/google/benchmark +) + +ADDINCL( + contrib/restricted/google/benchmark/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DBENCHMARK_STATIC_DEFINE + -DGTEST_LINKED_AS_SHARED_LIBRARY=1 + -DHAVE_POSIX_REGEX + -DHAVE_STD_REGEX + -DHAVE_STEADY_CLOCK +) + +SRCS( + benchmark_gtest.cc + benchmark_name_gtest.cc + commandlineflags_gtest.cc + statistics_gtest.cc + string_util_gtest.cc +) + +END() diff --git a/contrib/restricted/google/benchmark/ya.make b/contrib/restricted/google/benchmark/ya.make new file mode 100644 index 00000000000..8ef295a7b5a --- /dev/null +++ b/contrib/restricted/google/benchmark/ya.make @@ -0,0 +1,56 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(1.7.1) + +ORIGINAL_SOURCE(https://github.com/google/benchmark/archive/v1.7.1.tar.gz) + +ADDINCL( + GLOBAL contrib/restricted/google/benchmark/include + contrib/restricted/google/benchmark/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + GLOBAL -DBENCHMARK_STATIC_DEFINE + -DHAVE_POSIX_REGEX + -DHAVE_STD_REGEX + -DHAVE_STEADY_CLOCK +) + +SRCS( + src/benchmark.cc + src/benchmark_api_internal.cc + src/benchmark_name.cc + src/benchmark_register.cc + src/benchmark_runner.cc + src/check.cc + src/colorprint.cc + src/commandlineflags.cc + src/complexity.cc + src/console_reporter.cc + src/counter.cc + src/csv_reporter.cc + src/json_reporter.cc + src/perf_counters.cc + src/reporter.cc + src/sleep.cc + src/statistics.cc + src/string_util.cc + src/sysinfo.cc + src/timers.cc +) + +END() + +RECURSE( + test +) diff --git a/contrib/restricted/googletest/googlemock/ya.make b/contrib/restricted/googletest/googlemock/ya.make new file mode 100644 index 00000000000..d01f1c1aa21 --- /dev/null +++ b/contrib/restricted/googletest/googlemock/ya.make @@ -0,0 +1,28 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/googletest/googletest +) + +ADDINCL( + GLOBAL contrib/restricted/googletest/googlemock/include + contrib/restricted/googletest/googlemock + contrib/restricted/googletest/googletest + contrib/restricted/googletest/googletest/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + src/gmock-all.cc +) + +END() diff --git a/contrib/restricted/googletest/googletest/ya.make b/contrib/restricted/googletest/googletest/ya.make new file mode 100644 index 00000000000..f48cd9b7026 --- /dev/null +++ b/contrib/restricted/googletest/googletest/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/re2 +) + +ADDINCL( + GLOBAL contrib/restricted/googletest/googletest/include + contrib/restricted/googletest/googletest +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + GLOBAL -DGTEST_HAS_ABSL=0 + GLOBAL -DGTEST_HAS_POSIX_RE=0 + GLOBAL -DGTEST_HAS_STD_WSTRING=1 + GLOBAL -DGTEST_USES_RE2=1 +) + +SRCS( + src/gtest-all.cc +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.bhaible/test-call/ya.make b/contrib/restricted/libffi/testsuite/libffi.bhaible/test-call/ya.make new file mode 100644 index 00000000000..38b5f1a61ff --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.bhaible/test-call/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.bhaible) + +SRCS( + test-call.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.bhaible/test-callback/ya.make b/contrib/restricted/libffi/testsuite/libffi.bhaible/test-callback/ya.make new file mode 100644 index 00000000000..f4c8478253c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.bhaible/test-callback/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.bhaible) + +SRCS( + test-callback.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.bhaible/ya.make b/contrib/restricted/libffi/testsuite/libffi.bhaible/ya.make new file mode 100644 index 00000000000..40dfa0bac98 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.bhaible/ya.make @@ -0,0 +1,6 @@ +# Generated by devtools/yamaker. + +RECURSE( + test-call + test-callback +) diff --git a/contrib/restricted/libffi/testsuite/libffi.call/align_mixed/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/align_mixed/ya.make new file mode 100644 index 00000000000..92689f798d4 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/align_mixed/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + align_mixed.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/align_stdcall/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/align_stdcall/ya.make new file mode 100644 index 00000000000..4f196d972f1 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/align_stdcall/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + align_stdcall.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/err_bad_typedef/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/err_bad_typedef/ya.make new file mode 100644 index 00000000000..7192b99c5ba --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/err_bad_typedef/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + err_bad_typedef.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/float/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/float/ya.make new file mode 100644 index 00000000000..b17424bbca7 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/float1/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/float1/ya.make new file mode 100644 index 00000000000..6d5cde154da --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/float1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + float1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/float2/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/float2/ya.make new file mode 100644 index 00000000000..2310ee8bd8b --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/float2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + float2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/float3/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/float3/ya.make new file mode 100644 index 00000000000..8af4716fe39 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/float3/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + float3.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/float4/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/float4/ya.make new file mode 100644 index 00000000000..ed7217089fc --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/float4/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + float4.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/float_va/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/float_va/ya.make new file mode 100644 index 00000000000..8f918d816a4 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/float_va/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + float_va.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/many/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/many/ya.make new file mode 100644 index 00000000000..aaffb260e69 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/many/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + many.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/many2/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/many2/ya.make new file mode 100644 index 00000000000..fb57b45bf60 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/many2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + many2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/many_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/many_double/ya.make new file mode 100644 index 00000000000..d70b0f3cdbb --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/many_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + many_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/many_mixed/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/many_mixed/ya.make new file mode 100644 index 00000000000..0fdfb347064 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/many_mixed/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + many_mixed.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/negint/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/negint/ya.make new file mode 100644 index 00000000000..f83088b22db --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/negint/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + negint.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/offsets/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/offsets/ya.make new file mode 100644 index 00000000000..303bcec33c6 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/offsets/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + offsets.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/pr1172638/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/pr1172638/ya.make new file mode 100644 index 00000000000..41f9b30396a --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/pr1172638/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + pr1172638.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/promotion/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/promotion/ya.make new file mode 100644 index 00000000000..e57d931ee7f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/promotion/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + promotion.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/pyobjc-tc/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/pyobjc-tc/ya.make new file mode 100644 index 00000000000..c8ee70e634b --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/pyobjc-tc/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + pyobjc-tc.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_dbl/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_dbl/ya.make new file mode 100644 index 00000000000..4f63523532a --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_dbl/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_dbl.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_dbl1/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_dbl1/ya.make new file mode 100644 index 00000000000..8365c22a511 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_dbl1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_dbl1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_dbl2/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_dbl2/ya.make new file mode 100644 index 00000000000..60edf8ff426 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_dbl2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_dbl2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_fl/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_fl/ya.make new file mode 100644 index 00000000000..675dcbd6587 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_fl/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_fl.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_fl1/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_fl1/ya.make new file mode 100644 index 00000000000..a0cc661bd7e --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_fl1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_fl1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_fl2/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_fl2/ya.make new file mode 100644 index 00000000000..d00c509facb --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_fl2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_fl2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_fl3/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_fl3/ya.make new file mode 100644 index 00000000000..8a8f1634373 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_fl3/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_fl3.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_ldl/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_ldl/ya.make new file mode 100644 index 00000000000..1b5be17ca78 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_ldl/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_ldl.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_ll/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_ll/ya.make new file mode 100644 index 00000000000..7efd08d4d46 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_ll/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_ll.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_ll1/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_ll1/ya.make new file mode 100644 index 00000000000..2a4c7a5fde0 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_ll1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_ll1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_sc/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_sc/ya.make new file mode 100644 index 00000000000..a41cd581cdc --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_sc/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_sc.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_sl/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_sl/ya.make new file mode 100644 index 00000000000..09917f10b6e --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_sl/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_sl.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_uc/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_uc/ya.make new file mode 100644 index 00000000000..21486df4e53 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_uc/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_uc.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/return_ul/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/return_ul/ya.make new file mode 100644 index 00000000000..52902463226 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/return_ul/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + return_ul.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/strlen/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/strlen/ya.make new file mode 100644 index 00000000000..658a70807b9 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/strlen/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + strlen.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/strlen2/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/strlen2/ya.make new file mode 100644 index 00000000000..e4dbcd12daf --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/strlen2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + strlen2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/strlen3/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/strlen3/ya.make new file mode 100644 index 00000000000..f8f127281e2 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/strlen3/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + strlen3.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/strlen4/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/strlen4/ya.make new file mode 100644 index 00000000000..1373d31c401 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/strlen4/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + strlen4.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct1/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct1/ya.make new file mode 100644 index 00000000000..4390cccdf80 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct10/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct10/ya.make new file mode 100644 index 00000000000..502f6e5ffc3 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct10/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct10.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct2/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct2/ya.make new file mode 100644 index 00000000000..feeaa5b323d --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct3/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct3/ya.make new file mode 100644 index 00000000000..9155587f5cf --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct3/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct3.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct4/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct4/ya.make new file mode 100644 index 00000000000..dea8b9c824f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct4/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct4.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct5/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct5/ya.make new file mode 100644 index 00000000000..275c8ed9139 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct5/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct5.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct6/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct6/ya.make new file mode 100644 index 00000000000..4e8d569576d --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct6/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct6.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct7/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct7/ya.make new file mode 100644 index 00000000000..fd0f0a69299 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct7/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct7.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct8/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct8/ya.make new file mode 100644 index 00000000000..523c40dacb3 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct8/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct8.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/struct9/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/struct9/ya.make new file mode 100644 index 00000000000..769563ff329 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/struct9/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + struct9.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/uninitialized/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/uninitialized/ya.make new file mode 100644 index 00000000000..b235be9937c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/uninitialized/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + uninitialized.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/va_1/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/va_1/ya.make new file mode 100644 index 00000000000..33f50f35f59 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/va_1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + va_1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/va_struct1/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/va_struct1/ya.make new file mode 100644 index 00000000000..4df73cc62b5 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/va_struct1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + va_struct1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/va_struct2/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/va_struct2/ya.make new file mode 100644 index 00000000000..5e29bfe2a96 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/va_struct2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + va_struct2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/va_struct3/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/va_struct3/ya.make new file mode 100644 index 00000000000..c6a6efe4a5f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/va_struct3/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.call) + +SRCS( + va_struct3.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.call/ya.make b/contrib/restricted/libffi/testsuite/libffi.call/ya.make new file mode 100644 index 00000000000..744afe63428 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.call/ya.make @@ -0,0 +1,55 @@ +# Generated by devtools/yamaker. + +RECURSE( + align_mixed + align_stdcall + err_bad_typedef + float + float1 + float2 + float3 + float4 + float_va + many + many2 + many_double + many_mixed + negint + offsets + pr1172638 + promotion + pyobjc-tc + return_dbl + return_dbl1 + return_dbl2 + return_fl + return_fl1 + return_fl2 + return_fl3 + return_ldl + return_ll + return_ll1 + return_sc + return_sl + return_uc + return_ul + strlen + strlen2 + strlen3 + strlen4 + struct1 + struct10 + struct2 + struct3 + struct4 + struct5 + struct6 + struct7 + struct8 + struct9 + uninitialized + va_1 + va_struct1 + va_struct2 + va_struct3 +) diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn0/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn0/ya.make new file mode 100644 index 00000000000..2c55774a2ef --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn0/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_fn0.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn1/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn1/ya.make new file mode 100644 index 00000000000..3d0fdaeca68 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_fn1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn2/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn2/ya.make new file mode 100644 index 00000000000..3a2e949ceb4 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_fn2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn3/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn3/ya.make new file mode 100644 index 00000000000..5b8cec79c8f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn3/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_fn3.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn4/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn4/ya.make new file mode 100644 index 00000000000..755f9781a5b --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn4/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_fn4.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn5/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn5/ya.make new file mode 100644 index 00000000000..7d221414e4e --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn5/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_fn5.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn6/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn6/ya.make new file mode 100644 index 00000000000..4cddd79a83c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_fn6/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_fn6.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_loc_fn0/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_loc_fn0/ya.make new file mode 100644 index 00000000000..1a951f82149 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_loc_fn0/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_loc_fn0.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/closure_simple/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/closure_simple/ya.make new file mode 100644 index 00000000000..75e3cd78326 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/closure_simple/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + closure_simple.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_12byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_12byte/ya.make new file mode 100644 index 00000000000..39c05764670 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_12byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_12byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_16byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_16byte/ya.make new file mode 100644 index 00000000000..dd57366b4e5 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_16byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_16byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_18byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_18byte/ya.make new file mode 100644 index 00000000000..da74045634f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_18byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_18byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_19byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_19byte/ya.make new file mode 100644 index 00000000000..e9c17f1b021 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_19byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_19byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_1_1byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_1_1byte/ya.make new file mode 100644 index 00000000000..e964987a480 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_1_1byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_1_1byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_20byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_20byte/ya.make new file mode 100644 index 00000000000..0e34f625285 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_20byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_20byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_20byte1/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_20byte1/ya.make new file mode 100644 index 00000000000..dd35edd6e22 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_20byte1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_20byte1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_24byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_24byte/ya.make new file mode 100644 index 00000000000..8a772deb6c1 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_24byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_24byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_2byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_2byte/ya.make new file mode 100644 index 00000000000..dfae15b9179 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_2byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_2byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_3_1byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3_1byte/ya.make new file mode 100644 index 00000000000..791b59200d2 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3_1byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_3_1byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_3byte1/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3byte1/ya.make new file mode 100644 index 00000000000..3d86dda9192 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3byte1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_3byte1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_3byte2/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3byte2/ya.make new file mode 100644 index 00000000000..38089d23c2c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3byte2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_3byte2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_3float/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3float/ya.make new file mode 100644 index 00000000000..726d7160733 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_3float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_3float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_4_1byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_4_1byte/ya.make new file mode 100644 index 00000000000..6828e3d7e5f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_4_1byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_4_1byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_4byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_4byte/ya.make new file mode 100644 index 00000000000..751a52b34a0 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_4byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_4byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_5_1_byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_5_1_byte/ya.make new file mode 100644 index 00000000000..930e1fb39dc --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_5_1_byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_5_1_byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_5byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_5byte/ya.make new file mode 100644 index 00000000000..1bf392d8c4f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_5byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_5byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_64byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_64byte/ya.make new file mode 100644 index 00000000000..df029e85c8c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_64byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_64byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_6_1_byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_6_1_byte/ya.make new file mode 100644 index 00000000000..63dfc9431fa --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_6_1_byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_6_1_byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_6byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_6byte/ya.make new file mode 100644 index 00000000000..b9860a58006 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_6byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_6byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_7_1_byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_7_1_byte/ya.make new file mode 100644 index 00000000000..229969c600b --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_7_1_byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_7_1_byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_7byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_7byte/ya.make new file mode 100644 index 00000000000..7792c6cb6cd --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_7byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_7byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_8byte/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_8byte/ya.make new file mode 100644 index 00000000000..90600682ddc --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_8byte/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_8byte.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_9byte1/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_9byte1/ya.make new file mode 100644 index 00000000000..aecb79162d2 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_9byte1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_9byte1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_9byte2/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_9byte2/ya.make new file mode 100644 index 00000000000..28dae35afc9 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_9byte2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_9byte2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_double/ya.make new file mode 100644 index 00000000000..4b5027aaf71 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_float/ya.make new file mode 100644 index 00000000000..09060f6cec0 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble/ya.make new file mode 100644 index 00000000000..d9765925a79 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble_split/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble_split/ya.make new file mode 100644 index 00000000000..fb385164892 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble_split/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_longdouble_split.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble_split2/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble_split2/ya.make new file mode 100644 index 00000000000..322b96b3896 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_longdouble_split2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_longdouble_split2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_pointer/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_pointer/ya.make new file mode 100644 index 00000000000..2fd39f1400c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_pointer/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_pointer.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint16/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint16/ya.make new file mode 100644 index 00000000000..e11e0edbb32 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint16/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_sint16.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint32/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint32/ya.make new file mode 100644 index 00000000000..e15126ef2b5 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint32/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_sint32.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint64/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint64/ya.make new file mode 100644 index 00000000000..eae6b790e7e --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_sint64/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_sint64.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint16/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint16/ya.make new file mode 100644 index 00000000000..ddd0995e654 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint16/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_uint16.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint32/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint32/ya.make new file mode 100644 index 00000000000..e8024f45c03 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint32/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_uint32.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint64/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint64/ya.make new file mode 100644 index 00000000000..a3f448c2048 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_align_uint64/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_align_uint64.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_dbls_struct/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_dbls_struct/ya.make new file mode 100644 index 00000000000..2ce493dacc3 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_dbls_struct/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_dbls_struct.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_double/ya.make new file mode 100644 index 00000000000..36a08128b1d --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_double_va/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_double_va/ya.make new file mode 100644 index 00000000000..ec1f4661f95 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_double_va/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_double_va.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_float/ya.make new file mode 100644 index 00000000000..b279b7135e9 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_longdouble/ya.make new file mode 100644 index 00000000000..a5ea33ba2f7 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_longdouble_va/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_longdouble_va/ya.make new file mode 100644 index 00000000000..511bd87d320 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_longdouble_va/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_longdouble_va.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_many_mixed_args/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_many_mixed_args/ya.make new file mode 100644 index 00000000000..b51e2bb72fc --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_many_mixed_args/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_many_mixed_args.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_many_mixed_float_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_many_mixed_float_double/ya.make new file mode 100644 index 00000000000..96b6e84e897 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_many_mixed_float_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_many_mixed_float_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_schar/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_schar/ya.make new file mode 100644 index 00000000000..d0521db434c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_schar/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_multi_schar.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_sshort/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_sshort/ya.make new file mode 100644 index 00000000000..3606390afa7 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_sshort/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_multi_sshort.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_sshortchar/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_sshortchar/ya.make new file mode 100644 index 00000000000..b0697c5155e --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_sshortchar/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_multi_sshortchar.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_uchar/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_uchar/ya.make new file mode 100644 index 00000000000..775518803b8 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_uchar/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_multi_uchar.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_ushort/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_ushort/ya.make new file mode 100644 index 00000000000..e762c9772a4 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_ushort/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_multi_ushort.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_ushortchar/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_ushortchar/ya.make new file mode 100644 index 00000000000..5ad9878b34f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_multi_ushortchar/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_multi_ushortchar.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_pointer/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_pointer/ya.make new file mode 100644 index 00000000000..1949f64e822 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_pointer/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_pointer.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_pointer_stack/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_pointer_stack/ya.make new file mode 100644 index 00000000000..cf94f31995b --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_pointer_stack/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_pointer_stack.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_schar/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_schar/ya.make new file mode 100644 index 00000000000..a97c29be5c3 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_schar/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_schar.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_sint/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_sint/ya.make new file mode 100644 index 00000000000..6e4cd79a1e7 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_sint/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_sint.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_sshort/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_sshort/ya.make new file mode 100644 index 00000000000..87f69a5b5bb --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_sshort/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_sshort.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_struct_va1/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_struct_va1/ya.make new file mode 100644 index 00000000000..bd3fcfbeb1d --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_struct_va1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_struct_va1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_uchar/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uchar/ya.make new file mode 100644 index 00000000000..768b022308c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uchar/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_uchar.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_uchar_va/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uchar_va/ya.make new file mode 100644 index 00000000000..4006842ab28 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uchar_va/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_uchar_va.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_uint/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uint/ya.make new file mode 100644 index 00000000000..37ef53cb7c3 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uint/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_uint.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_uint_va/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uint_va/ya.make new file mode 100644 index 00000000000..f9706363ff8 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_uint_va/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_uint_va.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_ulong_va/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ulong_va/ya.make new file mode 100644 index 00000000000..fad449f901c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ulong_va/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_ulong_va.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_ulonglong/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ulonglong/ya.make new file mode 100644 index 00000000000..a01c750abf4 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ulonglong/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_ulonglong.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_ushort/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ushort/ya.make new file mode 100644 index 00000000000..c23dd0e636a --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ushort/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_ushort.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/cls_ushort_va/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ushort_va/ya.make new file mode 100644 index 00000000000..1b8d0bd03f2 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/cls_ushort_va/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + cls_ushort_va.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/err_bad_abi/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/err_bad_abi/ya.make new file mode 100644 index 00000000000..0a15c5197fd --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/err_bad_abi/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + err_bad_abi.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/huge_struct/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/huge_struct/ya.make new file mode 100644 index 00000000000..dd12ab763fb --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/huge_struct/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + huge_struct.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct/ya.make new file mode 100644 index 00000000000..e2aa1e939fd --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct1/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct1/ya.make new file mode 100644 index 00000000000..37cf064bbfd --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct10/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct10/ya.make new file mode 100644 index 00000000000..78c215ab19e --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct10/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct10.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct11/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct11/ya.make new file mode 100644 index 00000000000..11ab5a9a5c9 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct11/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct11.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct2/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct2/ya.make new file mode 100644 index 00000000000..dac69bba2b5 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct3/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct3/ya.make new file mode 100644 index 00000000000..59d836f6502 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct3/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct3.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct4/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct4/ya.make new file mode 100644 index 00000000000..295c626df27 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct4/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct4.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct5/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct5/ya.make new file mode 100644 index 00000000000..14766ed0d78 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct5/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct5.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct6/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct6/ya.make new file mode 100644 index 00000000000..d2dff91ab2a --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct6/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct6.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct7/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct7/ya.make new file mode 100644 index 00000000000..83c22922cb8 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct7/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct7.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct8/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct8/ya.make new file mode 100644 index 00000000000..8c990c40d71 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct8/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct8.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct9/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct9/ya.make new file mode 100644 index 00000000000..37b2784f369 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/nested_struct9/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + nested_struct9.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/problem1/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/problem1/ya.make new file mode 100644 index 00000000000..bcd8e251f0a --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/problem1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + problem1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/stret_large/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/stret_large/ya.make new file mode 100644 index 00000000000..059f01d0044 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/stret_large/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + stret_large.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/stret_large2/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/stret_large2/ya.make new file mode 100644 index 00000000000..9ab9b2a7d73 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/stret_large2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + stret_large2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/stret_medium/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/stret_medium/ya.make new file mode 100644 index 00000000000..aac9750da8f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/stret_medium/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + stret_medium.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/stret_medium2/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/stret_medium2/ya.make new file mode 100644 index 00000000000..f37bf99b78b --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/stret_medium2/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + stret_medium2.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/testclosure/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/testclosure/ya.make new file mode 100644 index 00000000000..176d09ad549 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/testclosure/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.closures) + +SRCS( + testclosure.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.closures/ya.make b/contrib/restricted/libffi/testsuite/libffi.closures/ya.make new file mode 100644 index 00000000000..40565af539b --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.closures/ya.make @@ -0,0 +1,103 @@ +# Generated by devtools/yamaker. + +RECURSE( + closure_fn0 + closure_fn1 + closure_fn2 + closure_fn3 + closure_fn4 + closure_fn5 + closure_fn6 + closure_loc_fn0 + closure_simple + cls_12byte + cls_16byte + cls_18byte + cls_19byte + cls_1_1byte + cls_20byte + cls_20byte1 + cls_24byte + cls_2byte + cls_3_1byte + cls_3byte1 + cls_3byte2 + cls_3float + cls_4_1byte + cls_4byte + cls_5_1_byte + cls_5byte + cls_64byte + cls_6_1_byte + cls_6byte + cls_7_1_byte + cls_7byte + cls_8byte + cls_9byte1 + cls_9byte2 + cls_align_double + cls_align_float + cls_align_longdouble + cls_align_pointer + cls_align_sint16 + cls_align_sint32 + cls_align_sint64 + cls_align_uint16 + cls_align_uint32 + cls_align_uint64 + cls_dbls_struct + cls_double + cls_double_va + cls_float + cls_longdouble + cls_longdouble_va + cls_many_mixed_args + cls_multi_schar + cls_multi_sshort + cls_multi_sshortchar + cls_multi_uchar + cls_multi_ushort + cls_multi_ushortchar + cls_pointer + cls_pointer_stack + cls_schar + cls_sint + cls_sshort + cls_struct_va1 + cls_uchar + cls_uchar_va + cls_uint + cls_uint_va + cls_ulong_va + cls_ulonglong + cls_ushort + cls_ushort_va + err_bad_abi + huge_struct + nested_struct + nested_struct1 + nested_struct10 + nested_struct11 + nested_struct2 + nested_struct3 + nested_struct4 + nested_struct5 + nested_struct6 + nested_struct7 + nested_struct8 + nested_struct9 + problem1 + stret_large + stret_large2 + stret_medium + stret_medium2 + testclosure +) + +IF (NOT OS_WINDOWS) + RECURSE( + cls_align_longdouble_split + cls_align_longdouble_split2 + cls_many_mixed_float_double + ) +ENDIF() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_double/ya.make new file mode 100644 index 00000000000..bd7d0a025a6 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_align_complex_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_float/ya.make new file mode 100644 index 00000000000..03b4814daf5 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_align_complex_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_longdouble/ya.make new file mode 100644 index 00000000000..93718cf15b6 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_align_complex_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_align_complex_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_double/ya.make new file mode 100644 index 00000000000..f3a2ae0f58e --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_float/ya.make new file mode 100644 index 00000000000..f429013e393 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_longdouble/ya.make new file mode 100644 index 00000000000..d6c794a3de2 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_double/ya.make new file mode 100644 index 00000000000..58514e99add --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_struct_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_float/ya.make new file mode 100644 index 00000000000..5661158178f --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_struct_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble/ya.make new file mode 100644 index 00000000000..6b27dc05248 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_struct_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_double/ya.make new file mode 100644 index 00000000000..00c5014fb25 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_va_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_float/ya.make new file mode 100644 index 00000000000..3a7195a4a5c --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_va_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_longdouble/ya.make new file mode 100644 index 00000000000..c66dc74f328 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/cls_complex_va_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + cls_complex_va_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/complex_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/complex_double/ya.make new file mode 100644 index 00000000000..6b18d6c2c0d --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/complex_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + complex_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/complex_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/complex_float/ya.make new file mode 100644 index 00000000000..3f67c81a0ad --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/complex_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + complex_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/complex_int/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/complex_int/ya.make new file mode 100644 index 00000000000..df57214a938 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/complex_int/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + complex_int.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/complex_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/complex_longdouble/ya.make new file mode 100644 index 00000000000..b2b879ea1e6 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/complex_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + complex_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_double/ya.make new file mode 100644 index 00000000000..f3ad40cd0ea --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + many_complex_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_float/ya.make new file mode 100644 index 00000000000..52f2a9aa221 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + many_complex_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_longdouble/ya.make new file mode 100644 index 00000000000..5e93571cfe6 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/many_complex_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + many_complex_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_double/ya.make new file mode 100644 index 00000000000..30710b30263 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex1_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_float/ya.make new file mode 100644 index 00000000000..0a62edbdbea --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex1_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_longdouble/ya.make new file mode 100644 index 00000000000..50e5938a257 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex1_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex1_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_double/ya.make new file mode 100644 index 00000000000..913bbba738d --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex2_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_float/ya.make new file mode 100644 index 00000000000..d06f31eb028 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex2_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_longdouble/ya.make new file mode 100644 index 00000000000..de063a6b6fd --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex2_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex2_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_double/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_double/ya.make new file mode 100644 index 00000000000..bc971aa67b0 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_double/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex_double.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_float/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_float/ya.make new file mode 100644 index 00000000000..846b3df2acd --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_float/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex_float.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_longdouble/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_longdouble/ya.make new file mode 100644 index 00000000000..fdf9a6c20c1 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/return_complex_longdouble/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.complex) + +SRCS( + return_complex_longdouble.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.complex/ya.make b/contrib/restricted/libffi/testsuite/libffi.complex/ya.make new file mode 100644 index 00000000000..032d03839a7 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.complex/ya.make @@ -0,0 +1,32 @@ +# Generated by devtools/yamaker. + +RECURSE( + cls_align_complex_double + cls_align_complex_float + cls_align_complex_longdouble + cls_complex_double + cls_complex_float + cls_complex_longdouble + cls_complex_struct_double + cls_complex_struct_float + cls_complex_struct_longdouble + cls_complex_va_double + cls_complex_va_float + cls_complex_va_longdouble + complex_double + complex_float + complex_int + complex_longdouble + many_complex_double + many_complex_float + many_complex_longdouble + return_complex1_double + return_complex1_float + return_complex1_longdouble + return_complex2_double + return_complex2_float + return_complex2_longdouble + return_complex_double + return_complex_float + return_complex_longdouble +) diff --git a/contrib/restricted/libffi/testsuite/libffi.go/aa-direct/ya.make b/contrib/restricted/libffi/testsuite/libffi.go/aa-direct/ya.make new file mode 100644 index 00000000000..cb790b091c3 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.go/aa-direct/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.go) + +SRCS( + aa-direct.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.go/closure1/ya.make b/contrib/restricted/libffi/testsuite/libffi.go/closure1/ya.make new file mode 100644 index 00000000000..5a7a18fc431 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.go/closure1/ya.make @@ -0,0 +1,23 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +LICENSE(GPL-2.0-only) + +PEERDIR( + contrib/restricted/libffi +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCDIR(contrib/restricted/libffi/testsuite/libffi.go) + +SRCS( + closure1.c +) + +END() diff --git a/contrib/restricted/libffi/testsuite/libffi.go/ya.make b/contrib/restricted/libffi/testsuite/libffi.go/ya.make new file mode 100644 index 00000000000..9e8d002d782 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/libffi.go/ya.make @@ -0,0 +1,6 @@ +# Generated by devtools/yamaker. + +RECURSE( + aa-direct + closure1 +) diff --git a/contrib/restricted/libffi/testsuite/ya.make b/contrib/restricted/libffi/testsuite/ya.make new file mode 100644 index 00000000000..7f589109a00 --- /dev/null +++ b/contrib/restricted/libffi/testsuite/ya.make @@ -0,0 +1,19 @@ +# Generated by devtools/yamaker. + +RECURSE( + libffi.bhaible + libffi.call + libffi.closures +) + +IF (NOT OS_IOS) + RECURSE( + libffi.go + ) +ENDIF() + +IF (NOT OS_WINDOWS AND NOT ARCH_PPC64LE) + RECURSE( + libffi.complex + ) +ENDIF() diff --git a/contrib/restricted/libffi/ya.make b/contrib/restricted/libffi/ya.make new file mode 100644 index 00000000000..49630f67dda --- /dev/null +++ b/contrib/restricted/libffi/ya.make @@ -0,0 +1,192 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + CC-PDDC AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(3.3) + +ORIGINAL_SOURCE(https://github.com/libffi/libffi/archive/v3.3.tar.gz) + +ADDINCL( + contrib/restricted/libffi + contrib/restricted/libffi/include + contrib/restricted/libffi/src + GLOBAL contrib/restricted/libffi/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DHAVE_CONFIG_H + GLOBAL -DFFI_BUILDING +) + +SRCS( + src/closures.c + src/java_raw_api.c + src/prep_cif.c + src/raw_api.c + src/types.c +) + +IF (ARCH_ARM64 AND OS_ANDROID) + ADDINCL( + contrib/restricted/libffi/configs/aarch64-unknown-linux-android21 + GLOBAL contrib/restricted/libffi/configs/aarch64-unknown-linux-android21/include + ) + SRCS( + src/aarch64/ffi.c + src/aarch64/sysv.S + ) +ELSEIF (ARCH_ARM64 AND OS_DARWIN) + ADDINCL( + contrib/restricted/libffi/configs/aarch64-apple-macos + GLOBAL contrib/restricted/libffi/configs/aarch64-apple-macos/include + ) + SRCS( + src/aarch64/ffi.c + src/aarch64/sysv.S + ) +ELSEIF (ARCH_ARM64 AND OS_IOS) + ADDINCL( + contrib/restricted/libffi/configs/aarch64-apple-iphoneos + GLOBAL contrib/restricted/libffi/configs/aarch64-apple-iphoneos/include + ) + SRCS( + src/aarch64/ffi.c + src/aarch64/sysv.S + ) +ELSEIF (ARCH_ARM64 AND OS_LINUX) + ADDINCL( + contrib/restricted/libffi/configs/aarch64-unknown-linux-gnu + GLOBAL contrib/restricted/libffi/configs/aarch64-unknown-linux-gnu/include + ) + SRCS( + src/aarch64/ffi.c + src/aarch64/sysv.S + ) +ELSEIF (ARCH_ARM7 AND OS_ANDROID) + ADDINCL( + contrib/restricted/libffi/configs/armv7a-unknown-linux-androideabi16 + GLOBAL contrib/restricted/libffi/configs/armv7a-unknown-linux-androideabi16/include + ) + SRCS( + src/arm/ffi.c + src/arm/sysv.S + ) +ELSEIF (ARCH_ARM7 AND OS_LINUX) + ADDINCL( + contrib/restricted/libffi/configs/armv7a-unknown-linux-gnueabihf + GLOBAL contrib/restricted/libffi/configs/armv7a-unknown-linux-gnueabihf/include + ) + SRCS( + src/arm/ffi.c + src/arm/sysv.S + ) +ELSEIF (ARCH_I386 AND OS_ANDROID) + ADDINCL( + contrib/restricted/libffi/configs/i686-pc-linux-android16 + GLOBAL contrib/restricted/libffi/configs/i686-pc-linux-android16/include + ) + SRCS( + src/x86/ffi.c + src/x86/sysv.S + ) +ELSEIF (ARCH_I386 AND OS_WINDOWS) + ADDINCL( + contrib/restricted/libffi/configs/i386-microsoft-windows + GLOBAL contrib/restricted/libffi/configs/i386-microsoft-windows/include + ) + SRCS( + configs/i386-microsoft-windows/sysv_intel.masm + src/x86/ffi.c + ) +ELSEIF (ARCH_PPC64LE AND OS_LINUX) + ADDINCL( + contrib/restricted/libffi/configs/powerpc64le-unknown-linux-gnu + GLOBAL contrib/restricted/libffi/configs/powerpc64le-unknown-linux-gnu/include + ) + SRCS( + src/powerpc/ffi.c + src/powerpc/ffi_linux64.c + src/powerpc/ffi_sysv.c + src/powerpc/linux64.S + src/powerpc/linux64_closure.S + src/powerpc/ppc_closure.S + src/powerpc/sysv.S + ) +ELSEIF (ARCH_RISCV32 AND OS_NONE) + ADDINCL( + contrib/restricted/libffi/configs/x86_64-pc-linux-gnu + GLOBAL contrib/restricted/libffi/configs/x86_64-pc-linux-gnu/include + ) +ELSEIF (ARCH_X86_64 AND OS_ANDROID) + ADDINCL( + contrib/restricted/libffi/configs/x86_64-pc-linux-android21 + GLOBAL contrib/restricted/libffi/configs/x86_64-pc-linux-android21/include + ) + SRCS( + src/x86/ffi64.c + src/x86/ffiw64.c + src/x86/unix64.S + src/x86/win64.S + ) +ELSEIF (ARCH_X86_64 AND OS_DARWIN) + ADDINCL( + contrib/restricted/libffi/configs/x86_64-apple-macosx + GLOBAL contrib/restricted/libffi/configs/x86_64-apple-macosx/include + ) + SRCS( + src/x86/ffi64.c + src/x86/ffiw64.c + src/x86/unix64.S + src/x86/win64.S + ) +ELSEIF (ARCH_X86_64 AND OS_IOS) + ADDINCL( + contrib/restricted/libffi/configs/x86_64-apple-iphonesimulator + GLOBAL contrib/restricted/libffi/configs/x86_64-apple-iphonesimulator/include + ) + SRCS( + src/x86/ffi64.c + src/x86/ffiw64.c + src/x86/unix64.S + src/x86/win64.S + ) +ELSEIF (ARCH_X86_64 AND OS_LINUX) + ADDINCL( + contrib/restricted/libffi/configs/x86_64-pc-linux-gnu + GLOBAL contrib/restricted/libffi/configs/x86_64-pc-linux-gnu/include + ) + SRCS( + src/x86/ffi64.c + src/x86/ffiw64.c + src/x86/unix64.S + src/x86/win64.S + ) +ELSEIF (ARCH_X86_64 AND OS_WINDOWS) + ADDINCL( + contrib/restricted/libffi/configs/x86_64-microsoft-windows + GLOBAL contrib/restricted/libffi/configs/x86_64-microsoft-windows/include + ) + SRCS( + configs/x86_64-microsoft-windows/win64_intel.masm + src/x86/ffiw64.c + ) +ELSE() + MESSAGE(FATAL_ERROR Unsupported libffi platform: ${TARGET_PLATFORM} / ${HARDWARE_TYPE}) +ENDIF() + +END() + +RECURSE( + testsuite +) diff --git a/contrib/restricted/nlohmann_json/ya.make b/contrib/restricted/nlohmann_json/ya.make new file mode 100644 index 00000000000..8e1b4e67cfe --- /dev/null +++ b/contrib/restricted/nlohmann_json/ya.make @@ -0,0 +1,24 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE( + Apache-2.0 AND + CC0-1.0 AND + MIT +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(3.11.2) + +ORIGINAL_SOURCE(https://github.com/nlohmann/json/archive/v3.11.2.tar.gz) + +ADDINCL( + ONE_LEVEL + contrib/restricted/nlohmann_json/include +) + +NO_UTIL() + +END() diff --git a/contrib/restricted/thrift/ya.make b/contrib/restricted/thrift/ya.make new file mode 100644 index 00000000000..87fa7052036 --- /dev/null +++ b/contrib/restricted/thrift/ya.make @@ -0,0 +1,100 @@ +LIBRARY() + +VERSION(0.10.0) + +LICENSE(Apache-2.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_UTIL() + +NO_COMPILER_WARNINGS() + +ADDINCL( + GLOBAL contrib/restricted/thrift +) + +PEERDIR( + contrib/libs/libevent + contrib/libs/openssl + contrib/libs/zlib + contrib/restricted/boost/interprocess + contrib/restricted/boost/locale + contrib/restricted/boost/math + contrib/restricted/boost/system + contrib/restricted/boost/thread +) + +SRCS( + thrift/TApplicationException.cpp + thrift/TOutput.cpp + thrift/VirtualProfiling.cpp + thrift/async/TAsyncChannel.cpp + thrift/async/TAsyncProtocolProcessor.cpp + thrift/async/TConcurrentClientSyncInfo.cpp + thrift/async/TEvhttpClientChannel.cpp + thrift/async/TEvhttpServer.cpp + thrift/concurrency/StdMonitor.cpp + thrift/concurrency/StdMutex.cpp + thrift/concurrency/StdThreadFactory.cpp + thrift/concurrency/ThreadManager.cpp + thrift/concurrency/TimerManager.cpp + thrift/concurrency/Util.cpp + thrift/processor/PeekProcessor.cpp + thrift/protocol/TBase64Utils.cpp + thrift/protocol/TDebugProtocol.cpp + thrift/protocol/THeaderProtocol.cpp + thrift/protocol/TJSONProtocol.cpp + thrift/protocol/TMultiplexedProtocol.cpp + thrift/protocol/TProtocol.cpp + thrift/server/TConnectedClient.cpp + thrift/server/TNonblockingServer.cpp + thrift/server/TServer.cpp + thrift/server/TServerFramework.cpp + thrift/server/TSimpleServer.cpp + thrift/server/TThreadPoolServer.cpp + thrift/server/TThreadedServer.cpp + thrift/transport/TBufferTransports.cpp + thrift/transport/TFDTransport.cpp + thrift/transport/TFileTransport.cpp + thrift/transport/THeaderTransport.cpp + thrift/transport/THttpClient.cpp + thrift/transport/THttpServer.cpp + thrift/transport/THttpTransport.cpp + thrift/transport/TNonblockingSSLServerSocket.cpp + thrift/transport/TNonblockingServerSocket.cpp + thrift/transport/TPipe.cpp + thrift/transport/TPipeServer.cpp + thrift/transport/TSSLServerSocket.cpp + thrift/transport/TSSLSocket.cpp + thrift/transport/TServerSocket.cpp + thrift/transport/TSimpleFileTransport.cpp + thrift/transport/TSocket.cpp + thrift/transport/TSocketPool.cpp + thrift/transport/TTransportException.cpp + thrift/transport/TTransportUtils.cpp + thrift/transport/TZlibTransport.cpp +) + +IF (OS_WINDOWS) + PEERDIR( + contrib/restricted/boost/scope_exit + ) + SRCS( + thrift/windows/GetTimeOfDay.cpp + thrift/windows/OverlappedSubmissionThread.cpp + thrift/windows/SocketPair.cpp + thrift/windows/TWinsockSingleton.cpp + thrift/windows/WinFcntl.cpp + ) +ELSE() + CXXFLAGS( + -Wno-deprecated-declarations + -Wno-unused-function + -Wno-unused-parameter + -Wno-unused-private-field + -Wno-unused-variable + ) +ENDIF() + +END() diff --git a/contrib/restricted/uriparser/test/ya.make b/contrib/restricted/uriparser/test/ya.make new file mode 100644 index 00000000000..48a1dae162c --- /dev/null +++ b/contrib/restricted/uriparser/test/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker. + +GTEST(testrunner) + +LICENSE( + LGPL-2.1-only AND + LGPL-2.1-or-later +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/uriparser +) + +ADDINCL( + contrib/restricted/uriparser +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +EXPLICIT_DATA() + +SRCS( + FourSuite.cpp + MemoryManagerSuite.cpp + VersionSuite.cpp + test.cpp +) + +END() diff --git a/contrib/restricted/uriparser/tool/ya.make b/contrib/restricted/uriparser/tool/ya.make new file mode 100644 index 00000000000..5f9024c70ec --- /dev/null +++ b/contrib/restricted/uriparser/tool/ya.make @@ -0,0 +1,25 @@ +# Generated by devtools/yamaker. + +PROGRAM(uriparse) + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/restricted/uriparser +) + +ADDINCL( + contrib/restricted/uriparser/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +SRCS( + uriparse.c +) + +END() diff --git a/contrib/restricted/uriparser/ya.make b/contrib/restricted/uriparser/ya.make new file mode 100644 index 00000000000..d78a6d31459 --- /dev/null +++ b/contrib/restricted/uriparser/ya.make @@ -0,0 +1,54 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSD-3-Clause) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +VERSION(0.9.7) + +ORIGINAL_SOURCE(https://github.com/uriparser/uriparser/archive/uriparser-0.9.7.tar.gz) + +PEERDIR( + contrib/libs/libc_compat +) + +ADDINCL( + GLOBAL contrib/restricted/uriparser/include + contrib/restricted/uriparser +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DURI_LIBRARY_BUILD + -DURI_VISIBILITY +) + +SRCS( + src/UriCommon.c + src/UriCompare.c + src/UriEscape.c + src/UriFile.c + src/UriIp4.c + src/UriIp4Base.c + src/UriMemory.c + src/UriNormalize.c + src/UriNormalizeBase.c + src/UriParse.c + src/UriParseBase.c + src/UriQuery.c + src/UriRecompose.c + src/UriResolve.c + src/UriShorten.c +) + +END() + +RECURSE( + test + tool +) diff --git a/contrib/tools/bison/bison/ya.make b/contrib/tools/bison/bison/ya.make new file mode 100644 index 00000000000..11cc9b80bc5 --- /dev/null +++ b/contrib/tools/bison/bison/ya.make @@ -0,0 +1,67 @@ +PROGRAM() + +LICENSE( + GPL-3.0-or-later AND + GPL-3.0-or-later WITH Bison-exception-2.2 +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +IF (NOT MUSL) + NO_RUNTIME() +ENDIF() + +NO_COMPILER_WARNINGS() + +ADDINCLSELF() + +SRCS( + src/AnnotationList.c + src/InadequacyList.c + src/LR0.c + src/Sbitset.c + src/assoc.c + src/closure.c + src/complain.c + src/conflicts.c + src/derives.c + src/files.c + src/getargs.c + src/gram.c + src/graphviz.c + src/ielr.c + src/lalr.c + src/location.c + src/main.c + src/muscle-tab.c + src/named-ref.c + src/nullable.c + src/output.c + src/parse-gram.c + src/print-xml.c + src/print.c + src/print_graph.c + src/reader.c + src/reduce.c + src/relation.c + src/scan-code-c.c + src/scan-gram-c.c + src/scan-skel-c.c + src/state.c + src/symlist.c + src/symtab.c + src/tables.c + src/uniqstr.c + arcadia_root.cpp.in +) + +CFLAGS( + -Daccept=bison_accept + -DBISON_DATA_DIR="contrib/tools/bison/bison/data" +) + +PEERDIR( + contrib/tools/bison/gnulib +) + +END() diff --git a/contrib/tools/bison/gnulib/ya.make b/contrib/tools/bison/gnulib/ya.make new file mode 100644 index 00000000000..47f6a742dc7 --- /dev/null +++ b/contrib/tools/bison/gnulib/ya.make @@ -0,0 +1,244 @@ +LIBRARY() + +LICENSE( + BSD-3-Clause AND + GPL-3.0-or-later AND + LGPL-2.0-or-later +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +IF (NOT MUSL) + NO_RUNTIME() +ENDIF() + +NO_COMPILER_WARNINGS() + +ADDINCL( + GLOBAL contrib/tools/bison/gnulib/src +) + +IF (OS_WINDOWS) + ADDINCL( + GLOBAL contrib/tools/bison/gnulib/platform/win64 + ) +ELSE() + ADDINCL( + GLOBAL contrib/tools/bison/gnulib/platform/posix + ) +ENDIF() + +IF (OS_DARWIN) + CFLAGS( + -D_XOPEN_SOURCE=600 + ) +ENDIF() + +IF (NOT OS_WINDOWS) + CFLAGS( + GLOBAL -Dregcomp=gnu_regcomp + GLOBAL -Dregerror=gnu_regerror + GLOBAL -Dregfree=gnu_regfree + GLOBAL -Dregexec=gnu_regexec + ) +ENDIF() + +SRCS( + src/abitset.c + src/argmatch.c + src/asnprintf.c + src/basename-lgpl.c + src/basename.c + src/binary-io.c + src/bitrotate.c + src/bitset.c + src/bitset_stats.c + src/bitsetv-print.c + src/bitsetv.c + src/c-ctype.c + src/c-stack.c + src/c-strcasecmp.c + src/c-strncasecmp.c + src/calloc.c + src/clean-temp.c + src/cloexec.c + src/close-stream.c + src/close.c + src/closein.c + src/closeout.c + src/concat-filename.c + src/dirname-lgpl.c + src/dirname.c + src/dup-safer-flag.c + src/dup-safer.c + src/dup2.c + src/ebitset.c + src/error.c + src/execute.c + src/exitfail.c + src/fatal-signal.c + src/fclose.c + src/fcntl.c + src/fd-hook.c + src/fd-safer-flag.c + src/fd-safer.c + src/fflush.c + src/filenamecat-lgpl.c + src/filenamecat.c + src/float.c + src/fopen-safer.c + src/fpurge.c + src/freading.c + src/fstat.c + src/get-errno.c + src/getdtablesize.c + src/getopt.c + src/getopt1.c + src/gl_avltree_oset.c + src/gl_linkedhash_list.c + src/gl_list.c + src/gl_oset.c + src/gl_xlist.c + src/gl_xoset.c + src/hash.c + src/isnand.c + src/isnanf.c + src/isnanl.c + src/itold.c + src/lbitset.c + src/localcharset.c + src/lseek.c + src/lstat.c + src/malloc.c + src/malloca.c + src/mbrtowc.c + src/mbswidth.c + src/memchr2.c + src/mkstemp-safer.c + src/nl_langinfo.c + src/pipe-safer.c + src/pipe2-safer.c + src/printf-args.c + src/printf-frexp.c + src/printf-frexpl.c + src/printf-parse.c + src/progname.c + src/quotearg.c + src/raise.c + src/rawmemchr.c + src/readlink.c + src/realloc.c + src/regex.c + src/rename.c + src/rmdir.c + src/secure_getenv.c + src/sig-handler.c + src/signbitd.c + src/signbitf.c + src/signbitl.c + src/spawn-pipe.c + src/stat.c + src/stpcpy.c + src/strchrnul.c + src/strdup.c + src/stripslash.c + src/tempname.c + src/timevar.c + src/tmpdir.c + src/unistd.c + src/unsetenv.c + src/vasnprintf.c + src/vbitset.c + src/verror.c + src/version-etc-fsf.c + src/version-etc.c + src/wait-process.c + src/wctype-h.c + src/xalloc-die.c + src/xasprintf.c + src/xconcat-filename.c + src/xmalloc.c + src/xmalloca.c + src/xmemdup0.c + src/xprintf.c + src/xsize.c + src/xstrndup.c + src/xvasprintf.c +) + +IF (NOT MUSL) + SRCS( + src/freadahead.c + src/fseterr.c + # src/fseek.c + ) +ENDIF() + +IF (NOT OS_LINUX) + SRCS( + src/pipe2.c + src/strverscmp.c + ) +ENDIF() + +IF (NOT OS_WINDOWS) + SRCS( + src/stdio-write.c + ) +ENDIF() + +IF (OS_WINDOWS) + SRCS( + src/frexp.c + src/wcrtomb.c + src/perror.c + src/strstr.c + src/mkstemp.c + src/vasprintf.c + src/strsignal.c + src/mkdtemp.c + src/fseeko.c + src/fopen.c + src/ftello.c + src/gettimeofday.c + src/localeconv.c + src/msvc-inval.c + src/msvc-nothrow.c + src/open.c + src/sigaction.c + src/sigprocmask.c + src/snprintf.c + src/spawn_faction_addclose.c + src/spawn_faction_adddup2.c + src/spawn_faction_addopen.c + src/spawn_faction_destroy.c + src/spawn_faction_init.c + src/spawnattr_destroy.c + src/spawnattr_init.c + src/spawnattr_setflags.c + src/spawnattr_setsigmask.c + src/spawni.c + src/spawnp.c + src/strndup.c + src/waitpid.c + src/wcwidth.c + src/uniwidth/width.c + ) +ENDIF() + +IF (NOT OS_LINUX OR MUSL) + SRCS( + src/obstack.c + src/obstack_printf.c + ) +ENDIF() + +IF (OS_CYGWIN OR OS_LINUX) + #not need it +ELSE() + SRCS( + src/fpending.c + ) +ENDIF() + +END() diff --git a/contrib/tools/bison/m4/ya.make b/contrib/tools/bison/m4/ya.make new file mode 100644 index 00000000000..f474cbfb714 --- /dev/null +++ b/contrib/tools/bison/m4/ya.make @@ -0,0 +1,36 @@ +PROGRAM() + +LICENSE(GPL-3.0-or-later) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +NO_RUNTIME() + +NO_COMPILER_WARNINGS() + +IF (MUSL) + CFLAGS( + -DO_BINARY=0 + ) +ENDIF() + +SRCS( + src/builtin.c + src/debug.c + src/eval.c + src/format.c + src/freeze.c + src/input.c + src/m4.c + src/macro.c + src/output.c + src/path.c + src/symtab.c + src/cpp.cpp +) + +PEERDIR( + contrib/tools/bison/gnulib +) + +END() diff --git a/contrib/tools/cython/.dist-info/METADATA b/contrib/tools/cython/.dist-info/METADATA new file mode 100644 index 00000000000..88ca3d9ef58 --- /dev/null +++ b/contrib/tools/cython/.dist-info/METADATA @@ -0,0 +1,66 @@ +Metadata-Version: 2.1 +Name: Cython +Version: 0.29.34 +Summary: The Cython compiler for writing C extensions for the Python language. +Home-page: http://cython.org/ +Author: Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al. +Author-email: cython-devel@python.org +License: Apache +Project-URL: Documentation, https://cython.readthedocs.io/ +Project-URL: Donate, https://cython.readthedocs.io/en/latest/src/donating.html +Project-URL: Source Code, https://github.com/cython/cython +Project-URL: Bug Tracker, https://github.com/cython/cython/issues +Project-URL: User Group, https://groups.google.com/g/cython-users +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: Implementation :: CPython +Classifier: Programming Language :: Python :: Implementation :: PyPy +Classifier: Programming Language :: C +Classifier: Programming Language :: Cython +Classifier: Topic :: Software Development :: Code Generators +Classifier: Topic :: Software Development :: Compilers +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.* +License-File: LICENSE.txt +License-File: COPYING.txt + +The Cython language makes writing C extensions for the Python language as +easy as Python itself. Cython is a source code translator based on Pyrex_, +but supports more cutting edge functionality and optimizations. + +The Cython language is a superset of the Python language (almost all Python +code is also valid Cython code), but Cython additionally supports optional +static typing to natively call C functions, operate with C++ classes and +declare fast C types on variables and class attributes. This allows the +compiler to generate very efficient C code from Cython code. + +This makes Cython the ideal language for writing glue code for external +C/C++ libraries, and for fast C modules that speed up the execution of +Python code. + +Note that for one-time builds, e.g. for CI/testing, on platforms that are not +covered by one of the wheel packages provided on PyPI *and* the pure Python wheel +that we provide is not used, it is substantially faster than a full source build +to install an uncompiled (slower) version of Cython with:: + + pip install Cython --install-option="--no-cython-compile" + +.. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ + + diff --git a/contrib/tools/cython/.dist-info/entry_points.txt b/contrib/tools/cython/.dist-info/entry_points.txt new file mode 100644 index 00000000000..f8b3914454c --- /dev/null +++ b/contrib/tools/cython/.dist-info/entry_points.txt @@ -0,0 +1,4 @@ +[console_scripts] +cygdb = Cython.Debugger.Cygdb:main +cython = Cython.Compiler.Main:setuptools_main +cythonize = Cython.Build.Cythonize:main diff --git a/contrib/tools/cython/.dist-info/top_level.txt b/contrib/tools/cython/.dist-info/top_level.txt new file mode 100644 index 00000000000..48cccd7fc20 --- /dev/null +++ b/contrib/tools/cython/.dist-info/top_level.txt @@ -0,0 +1,3 @@ +Cython +cython +pyximport diff --git a/contrib/tools/cython/.yandex_meta/devtools.copyrights.report b/contrib/tools/cython/.yandex_meta/devtools.copyrights.report new file mode 100644 index 00000000000..024b923968a --- /dev/null +++ b/contrib/tools/cython/.yandex_meta/devtools.copyrights.report @@ -0,0 +1,45 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits +# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files +# $ # user comments +# $ +# ${action} {license id} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP COPYRIGHT_SERVICE_LABEL ba4550f2155d0b776fb4c0be0145de18 +BELONGS Cython/ya.make + License text: + \# Copyright (C) 2010-2011, IPython Development Team. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + Cython/Build/IpythonMagic.py [40:40] diff --git a/contrib/tools/cython/.yandex_meta/devtools.licenses.report b/contrib/tools/cython/.yandex_meta/devtools.licenses.report new file mode 100644 index 00000000000..76aa2ad6c76 --- /dev/null +++ b/contrib/tools/cython/.yandex_meta/devtools.licenses.report @@ -0,0 +1,172 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits +# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files +# $ # user comments +# $ +# ${action} {license id} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP LicenseRef-scancode-unknown-license-reference 05a06fc4032d942dd3f429b0a85e5ada +BELONGS ya.make + License text: + The original Pyrex code as of 2006-04 is licensed under the following + Scancode info: + Original SPDX id: LicenseRef-scancode-unknown-license-reference + Score : 16.00 + Match type : INTRO + Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE + Files with this license: + COPYING.txt [1:1] + +KEEP LicenseRef-scancode-unknown-license-reference AND Apache-2.0 1400309c67a0aa7225fd6bc233a2a832 +BELONGS ya.make + License text: + Cython itself is licensed under the permissive **Apache License**. + Scancode info: + Original SPDX id: LicenseRef-scancode-unknown-license-reference + Score : 16.00 + Match type : INTRO + Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE + Files with this license: + README.rst [37:37] + Scancode info: + Original SPDX id: Apache-2.0 + Score : 100.00 + Match type : REFERENCE + Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 + Files with this license: + README.rst [37:37] + +KEEP Apache-2.0 184f7a78939a4fbb79148cfa29a95a48 +BELONGS ya.make + License text: + Cython, which derives from Pyrex, is licensed under the Apache 2.0 + Software License. More precisely, all modifications and new code + Scancode info: + Original SPDX id: Apache-2.0 + Score : 44.00 + Match type : REFERENCE + Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 + Files with this license: + COPYING.txt [7:8] + +KEEP Apache-2.0 34f8c1142fd6208a8be89399cb521df9 +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: Apache-2.0 + Score : 100.00 + Match type : TEXT + Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 + Files with this license: + LICENSE.txt [1:176] + +SKIP GPL-2.0-or-later AND Bootloader-exception 35b681ec6079cfeb49b0bd28c29f807a +BELONGS Cython/ya.make + License text: + \# Distributed under the terms of the Modified BSD License. + \# + \# The full license is in the file ipython-COPYING.rst, distributed with this software. + Scancode info: + Original SPDX id: GPL-2.0-or-later + Score : 57.58 + Match type : NOTICE + Links : http://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html, https://spdx.org/licenses/GPL-2.0-or-later + Files with this license: + Cython/Build/IpythonMagic.py [42:44] + Scancode info: + Original SPDX id: Bootloader-exception + Score : 57.58 + Match type : NOTICE + Links : https://github.com/pyinstaller/pyinstaller/blob/develop/COPYING.txt, https://spdx.org/licenses/Bootloader-exception + Files with this license: + Cython/Build/IpythonMagic.py [42:44] + +KEEP Public-Domain 5e5fc519986cb79a430b651afa9afe9b +BELONGS Cython/ya.make + License text: + // Written by Rusty Russell, public domain, http://ccodearchive.net/ + Scancode info: + Original SPDX id: LicenseRef-scancode-public-domain + Score : 70.00 + Match type : REFERENCE + Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE + Files with this license: + Cython/Utility/ObjectHandling.c [1984:1984] + +KEEP Apache-2.0 61d70dcaa7e25996bcb85b4855e537d3 +BELONGS ya.make + License text: + License: Apache + Scancode info: + Original SPDX id: Apache-2.0 + Score : 90.00 + Match type : TAG + Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 + Files with this license: + .dist-info/METADATA [8:8] + +KEEP LicenseRef-scancode-unknown-license-reference 77e02435d3b0399a4f806e7a6b17ea8c +BELONGS ya.make +FILE_INCLUDE LICENSE.txt found in files: COPYING.txt at line 11 + License text: + See LICENSE.txt for more details. + Scancode info: + Original SPDX id: LicenseRef-scancode-unknown-license-reference + Score : 90.00 + Match type : REFERENCE + Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE + Files with this license: + COPYING.txt [11:11] + +KEEP Apache-2.0 86e8237b9a37a6951edea992afba41f3 +BELONGS ya.make + License text: + Classifier: License :: OSI Approved :: Apache Software License + Scancode info: + Original SPDX id: Apache-2.0 + Score : 95.00 + Match type : TAG + Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 + Files with this license: + .dist-info/METADATA [17:17] + +KEEP LicenseRef-scancode-unknown-license-reference 8ec7c99b03de2d2c6bd840f80b68cb59 +BELONGS ya.make +FILE_INCLUDE LICENSE.txt found in files: README.rst at line 39 + License text: + See `LICENSE.txt <https://github.com/cython/cython/blob/master/LICENSE.txt>`_. + Scancode info: + Original SPDX id: LicenseRef-scancode-unknown-license-reference + Score : 90.00 + Match type : REFERENCE + Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE + Files with this license: + README.rst [39:39] diff --git a/contrib/tools/cython/.yandex_meta/licenses.list.txt b/contrib/tools/cython/.yandex_meta/licenses.list.txt new file mode 100644 index 00000000000..d34a1de27d5 --- /dev/null +++ b/contrib/tools/cython/.yandex_meta/licenses.list.txt @@ -0,0 +1,384 @@ +====================Apache-2.0==================== + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +====================Apache-2.0==================== +Classifier: License :: OSI Approved :: Apache Software License + + +====================Apache-2.0==================== +Cython, which derives from Pyrex, is licensed under the Apache 2.0 +Software License. More precisely, all modifications and new code + + +====================Apache-2.0==================== +License: Apache + + +====================File: LICENSE.txt==================== + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + +====================LicenseRef-scancode-unknown-license-reference==================== +See LICENSE.txt for more details. + + +====================LicenseRef-scancode-unknown-license-reference==================== +See `LICENSE.txt <https://github.com/cython/cython/blob/master/LICENSE.txt>`_. + + +====================LicenseRef-scancode-unknown-license-reference==================== +The original Pyrex code as of 2006-04 is licensed under the following + + +====================LicenseRef-scancode-unknown-license-reference AND Apache-2.0==================== +Cython itself is licensed under the permissive **Apache License**. diff --git a/contrib/tools/cython/CHANGES.rst b/contrib/tools/cython/CHANGES.rst new file mode 100644 index 00000000000..696463f3a1a --- /dev/null +++ b/contrib/tools/cython/CHANGES.rst @@ -0,0 +1,3529 @@ +================ +Cython Changelog +================ + +0.29.34 (2023-04-02) +==================== + +Bugs fixed +---------- + +* A refence leak of the for-loop list/tuple iterable was resolved if the for-loop's + ``else:`` branch executes a ``break`` for an outer loop. + (Github issue :issue:`5347`) + +* Some C compile failures in CPython 3.12 were resolved. + +* Some old usages of the deprecated Python ``imp`` module were replaced with ``importlib``. + Patch by Matúš Valo. (Github issue :issue:`5300`) + +* Some issues with ``depfile`` generation were resolved. + Patches by Eli Schwartz. (Github issues :issue:`5279`, :issue:`5291`) + + +0.29.33 (2023-01-06) +==================== + +Features added +-------------- + +* The ``cythonize`` and ``cython`` commands have a new option ``-M`` / ``--depfile`` + to generate ``.dep`` dependency files for the compilation unit. This can be used + by external build tools to track these dependencies. + The ``cythonize`` option was already available in Cython :ref:`0.29.27`. + Patches by Evgeni Burovski and Eli Schwartz. (Github issue :issue:`1214`) + +Bugs fixed +---------- + +* ``const`` fused types could not be used with memory views. + Patch by Thomas Vincent. (Github issue :issue:`1772`) + +* ``wstr`` usage was removed in Python 3.12 and later (PEP-623). + (Github issue :issue:`5145`) + +* A type check assertion for Cython functions failed in debug Python builds. + (Github issue :issue:`5031`) + +* Fixed various compiler warnings. + Patches by Lisandro Dalcin et al. (Github issues :issue:`4948`, :issue:`5086`) + +* Fixed error when calculating complex powers of negative numbers. + (Github issue :issue:`5014`) + +* Corrected a small mis-formatting of exception messages on Python 2. + (Github issue :issue:`5018`) + +* The ``PyUnicode_AsUTF8AndSize()`` C-API function was missing from the CPython declarations. + (Github issue :issue:`5163`) + +* A performance problem in the compiler was resolved when nesting conditional expressions. + (Github issue :issue:`5197`) + +* Test suite problems with recent NumPy and CPython versions were resolved. + (Github issues :issue:`5183`, :issue:`5190`) + +Other changes +------------- + +* The undocumented, untested and apparently useless syntax + ``from somemodule cimport class/struct/union somename`` was deprecated + in anticipation of its removal in Cython 3. The type + modifier is not needed here and a plain ``cimport`` of the name will do. + (Github issue :issue:`4905`) + +* Properly disable generation of descriptor docstrings on PyPy since they cause crashes. + It was previously disabled, but only accidentally via a typo. + Patch by Matti Picus. (Github issue :issue:`5083`) + +* The ``cpow`` directive of Cython 3.0 is available as a no-op. + (Github issue :issue:`5016`) + + +0.29.32 (2022-07-29) +==================== + +Bugs fixed +---------- + +* Revert "Using memoryview typed arguments in inner functions is now rejected as unsupported." + Patch by David Woods. (Github issue #4798) + +* ``from module import *`` failed in 0.29.31 when using memoryviews. + Patch by David Woods. (Github issue #4927) + + +0.29.31 (2022-07-27) +==================== + +Features added +-------------- + +* A new argument ``--module-name`` was added to the ``cython`` command to + provide the (one) exact target module name from the command line. + Patch by Matthew Brett and h-vetinari. (Github issue #4906) + +* A new keyword ``noexcept`` was added for forward compatibility with Cython 3. + Patch by David Woods. (Github issue #4903) + +Bugs fixed +---------- + +* Use ``importlib.util.find_spec()`` instead of the deprecated ``importlib.find_loader()`` + function when setting up the package path at import-time. + Patch by Matti Picus. (Github issue #4764) + +* Require the C compiler to support the two-arg form of ``va_start`` + on Python 3.10 and higher. + Patch by Thomas Caswell. (Github issue #4820) + +* Make ``fused_type`` subscriptable in Shadow.py. + Patch by Pfebrer. (Github issue #4842) + +* Fix the incorrect code generation of the target type in ``bytearray`` loops. + Patch by Kenrick Everett. (Github issue #4108) + +* Atomic refcounts for memoryviews were not used on some GCC versions by accident. + Patch by Sam Gross. (Github issue #4915) + +* Silence some GCC ``-Wconversion`` warnings in C utility code. + Patch by Lisandro Dalcin. (Github issue #4854) + +* Tuple multiplication was ignored in expressions such as ``[*(1,) * 2]``. + Patch by David Woods. (Github issue #4864) + +* Calling ``append`` methods on extension types could fail to find the method + in some cases. + Patch by David Woods. (Github issue #4828) + +* Ensure that object buffers (e.g. ``ndarray[object, ndim=1]``) containing + ``NULL`` pointers are safe to use, returning ``None`` instead of the ``NULL`` + pointer. + Patch by Sebastian Berg. (Github issue #4859) + +* Using memoryview typed arguments in inner functions is now rejected as unsupported. + Patch by David Woods. (Github issue #4798) + +* Compilation could fail on systems (e.g. FIPS) that block MD5 checksums at runtime. + (Github issue #4909) + +* Experimental adaptations for the CPython "nogil" fork was added. + Note that there is no official support for this in Cython 0.x. + Patch by Sam Gross. (Github issue #4912) + + +0.29.30 (2022-05-16) +==================== + +Bugs fixed +---------- + +* The GIL handling changes in 0.29.29 introduced a regression where + objects could be deallocated without holding the GIL. + (Github issue #4796) + + +0.29.29 (2022-05-16) +==================== + +Features added +-------------- + +* Avoid acquiring the GIL at the end of nogil functions. + This change was backported in order to avoid generating wrong C code + that would trigger C compiler warnings with tracing support enabled. + Backport by Oleksandr Pavlyk. (Github issue #4637) + +Bugs fixed +---------- + +* Function definitions in ``finally:`` clauses were not correctly generated. + Patch by David Woods. (Github issue #4651) + +* A case where C-API functions could be called with a live exception set was fixed. + Patch by Jakub Kulík. (Github issue #4722) + +* Pickles can now be exchanged again with those generated from Cython 3.0 modules. + (Github issue #4680) + +* Cython now correctly generates Python methods for both the provided regular and + reversed special numeric methods of extension types. + Patch by David Woods. (Github issue #4750) + +* Calling unbound extension type methods without arguments could raise an + ``IndexError`` instead of a ``TypeError``. + Patch by David Woods. (Github issue #4779) + +* Calling unbound ``.__contains__()`` super class methods on some builtin base + types could trigger an infinite recursion. + Patch by David Woods. (Github issue #4785) + +* The C union type in pure Python mode mishandled some field names. + Patch by Jordan Brière. (Github issue #4727) + +* Allow users to overwrite the C macro ``_USE_MATH_DEFINES``. + Patch by Yuriy Chernyshov. (Github issue #4690) + +* Improved compatibility with CPython 3.10/11. + Patches by Thomas Caswell, David Woods. (Github issues #4609, #4667, #4721, #4730, #4777) + +* Docstrings of descriptors are now provided in PyPy 7.3.9. + Patch by Matti Picus. (Github issue #4701) + + +0.29.28 (2022-02-17) +==================== + +Bugs fixed +---------- + +* Due to backwards incompatible changes in CPython 3.11a4, the feature flags + ``CYTHON_FAST_THREAD_STATE`` and ``CYTHON_USE_EXC_INFO_STACK`` are now disabled + in Python 3.11 and later. They are enabled again in Cython 3.0. + Patch by David Woods. (Github issue #4610) + +* A C compiler warning in older PyPy versions was resolved. + Patch by Matti Picus. (Github issue #4236) + + +0.29.27 (2022-01-28) +==================== + +Features added +-------------- + +* The ``cythonize`` command has a new option ``-M`` to generate ``.dep`` dependency + files for the compilation unit. This can be used by external build tools to track + these dependencies. + Patch by Evgeni Burovski. (Github issue #1214) + +Bugs fixed +---------- + +* Compilation failures on PyPy were resolved. + Patches by Matti Picus. (Github issues #4509, #4517) + +* Calls to ``range()`` with more than three arguments did not fail. + Original patch by Max Bachmann. (Github issue #4550) + +* Some C compiler warnings about missing type struct initialisers in Py3.10 were resolved. + +* Cython no longer warns about using OpenMP 3.0 features since they are now + considered generally available. + + +0.29.26 (2021-12-16) +==================== + +Bugs fixed +---------- + +* An incompatibility with CPython 3.11.0a3 was resolved. + (Github issue #4499) + +* The ``in`` operator failed on literal lists with starred expressions. + Patch by Arvind Natarajan. (Github issue #3938) + +* A C compiler warning in PyPy about a missing struct field initialisation was resolved. + + +0.29.25 (2021-12-06) +==================== + +Bugs fixed +---------- + +* Several incompatibilities with CPython 3.11 were resolved. + Patches by David Woods, Victor Stinner, Thomas Caswell. + (Github issues #4411, #4414, #4415, #4416, #4420, #4428, #4473, #4479, #4480) + +* Some C compiler warnings were resolved. + Patches by Lisandro Dalcin and others. (Github issue #4439) + +* C++ ``std::move()`` should only be used automatically in MSVC versions that support it. + Patch by Max Bachmann. (Github issue #4191) + + * The ``Py_hash_t`` type failed to accept arbitrary "index" values. + (Github issue #2752) + +* Avoid copying unaligned 16-bit values since some platforms require them to be aligned. + Use memcpy() instead to let the C compiler decide how to do it. + (Github issue #4343) + +* Cython crashed on invalid truthiness tests on C++ types without ``operator bool``. + Patch by David Woods. (Github issue #4348) + +* The declaration of ``PyUnicode_CompareWithASCIIString()`` in ``cpython.unicode`` was incorrect. + Patch by Max Bachmann. (Github issue #4344) + + +0.29.24 (2021-07-14) +==================== + +Bugs fixed +---------- + +* Inline functions in pxd files that used memory views could lead to invalid + C code if the module that imported from them does not use memory views. + Patch by David Woods. (Github issue #1415) + +* Several declarations in ``libcpp.string`` were added and corrected. + Patch by Janek Bevendorff. (Github issue #4268) + +* Pickling unbound Cython compiled methods failed. + Patch by Pierre Glaser. (Github issue #2972) + +* The tracing code was adapted to work with CPython 3.10. + +* The optimised ``in`` operator failed on unicode strings in Py3.9 and later + that were constructed from an external ``wchar_t`` source. + Also, related C compiler warnings about deprecated C-API usage were resolved. + (Github issue #3925) + +* Some compiler crashes were resolved. + Patch by David Woods. (Github issues #4214, #2811) + +* An incorrect warning about 'unused' generator expressions was removed. + (GIthub issue #1699) + +* The attributes ``gen.gi_frame`` and ``coro.cr_frame`` of Cython compiled + generators and coroutines now return an actual frame object for introspection, + instead of ``None``. + (Github issue #2306) + + +0.29.23 (2021-04-14) +==================== + +Bugs fixed +---------- + +* Some problems with Python 3.10 were resolved. + Patches by Victor Stinner and David Woods. (Github issues #4046, #4100) + +* An incorrect "optimisation" was removed that allowed changes to a keyword + dict to leak into keyword arguments passed into a function. + Patch by Peng Weikang. (Github issue #3227) + +* Multiplied str constants could end up as bytes constants with language_level=2. + Patch by Alphadelta14 and David Woods. (Github issue #3951) + +* ``PY_SSIZE_T_CLEAN`` does not get defined any more if it is already defined. + Patch by Andrew Jones. (Github issue #4104) + + +0.29.22 (2021-02-20) +==================== + +Features added +-------------- + +* Some declarations were added to the provided pxd includes. + Patches by Zackery Spytz and John Kirkham. + (Github issues #3811, #3882, #3899, #3901) + +Bugs fixed +---------- + +* A crash when calling certain functions in Py3.9 and later was resolved. + (Github issue #3917) + +* ``const`` memory views of structs failed to compile. + (Github issue #2251) + +* ``const`` template declarations could not be nested. + Patch by Ashwin Srinath. (Github issue #1355) + +* The declarations in the ``cpython.pycapsule`` module were missing their + ``const`` modifiers and generated incorrect C code. + Patch by Warren Weckesser. (Github issue #3964) + +* Casts to memory views failed for fused dtypes. + Patch by David Woods. (Github issue #3881) + +* ``repr()`` was assumed to return ``str`` instead of ``unicode`` with ``language_level=3``. + (Github issue #3736) + +* Calling ``cpdef`` functions from cimported modules crashed the compiler. + Patch by David Woods. (Github issue #4000) + +* Cython no longer validates the ABI size of the NumPy classes it compiled against. + See the discussion in https://github.com/numpy/numpy/pull/432 + +* A C compiler warning about enum value casting was resolved in GCC. + (Github issue #2749) + +* Coverage reporting in the annotated HTML file failed in Py3.9. + Patch by Nick Pope. (Github issue #3865) + +* The embedding code now reports Python errors as exit status. + +* Long type declarations could lead to (harmless) random changes in the + C file when used in auto-generated Python wrappers or pickled classes. + +Other changes +------------- + +* Variables defined as ``cpdef`` now generate a warning since this + is currently useless and thus does not do what users would expect. + Patch by David Woods. (Github issue #3959) + + +0.29.21 (2020-07-09) +==================== + +Bugs fixed +---------- + +* Fix a regression in 0.29.20 where ``__div__`` failed to be found in extension types. + (Github issue #3688) + +* Fix a regression in 0.29.20 where a call inside of a finally clause could fail to compile. + Patch by David Woods. (Github issue #3712) + +* Zero-sized buffers could fail to validate as C/Fortran-contiguous. + Patch by Clemens Hofreither. (Github issue #2093) + +* ``exec()`` did not allow recent Python syntax features in Py3.8+ due to + https://bugs.python.org/issue35975. + (Github issue #3695) + +* Binding staticmethods of Cython functions were not behaving like Python methods in Py3. + Patch by Jeroen Demeyer and Michał Górny. (Github issue #3106) + +* Pythran calls to NumPy methods no longer generate useless method lookup code. + +* The ``PyUnicode_GET_LENGTH()`` macro was missing from the ``cpython.*`` declarations. + Patch by Thomas Caswell. (Github issue #3692) + +* The deprecated ``PyUnicode_*()`` C-API functions are no longer used, except for Unicode + strings that contain lone surrogates. Unicode strings that contain non-BMP characters + or surrogate pairs now generate different C code on 16-bit Python 2.x Unicode deployments + (such as MS-Windows). Generating the C code on Python 3.x is recommended in this case. + Original patches by Inada Naoki and Victor Stinner. (Github issues #3677, #3721, #3697) + +* Some template parameters were missing from the C++ ``std::unordered_map`` declaration. + Patch by will. (Github issue #3685) + +* Several internal code generation issues regarding temporary variables were resolved. + (Github issue #3708) + + +0.29.20 (2020-06-10) +==================== + +Bugs fixed +---------- + +* Nested try-except statements with multiple ``return`` statements could crash + due to incorrect deletion of the ``except as`` target variable. + (Github issue #3666) + +* The ``@classmethod`` decorator no longer rejects unknown input from other decorators. + Patch by David Woods. (Github issue #3660) + +* Fused types could leak into unrelated usages. + Patch by David Woods. (Github issue #3642) + +* Now uses ``Py_SET_SIZE()`` and ``Py_SET_REFCNT()`` in Py3.9+ to avoid low-level + write access to these object fields. + Patch by Victor Stinner. (Github issue #3639) + +* The built-in ``abs()`` function could lead to undefined behaviour when used on + the negative-most value of a signed C integer type. + Patch by Serge Guelton. (Github issue #1911) + +* Usages of ``sizeof()`` and ``typeid()`` on uninitialised variables no longer + produce a warning. + Patch by Celelibi. (Github issue #3575) + +* The C++ ``typeid()`` function was allowed in C mode. + Patch by Celelibi. (Github issue #3637) + +* The error position reported for errors found in f-strings was misleading. + (Github issue #3674) + +* The new ``c_api_binop_methods`` directive was added for forward compatibility, but can + only be set to True (the current default value). It can be disabled in Cython 3.0. + + +0.29.19 (2020-05-20) +==================== + +Bugs fixed +---------- + +* A typo in Windows specific code in 0.29.18 was fixed that broke "libc.math". + (Github issue #3622) + +* A platform specific test failure in 0.29.18 was fixed. + Patch by smutch. (Github issue #3620) + + +0.29.18 (2020-05-18) +==================== + +Bugs fixed +---------- + +* Exception position reporting could run into race conditions on threaded code. + It now uses function-local variables again. + +* Error handling early in the module init code could lead to a crash. + +* Error handling in ``cython.array`` creation was improved to avoid calling + C-API functions with an error held. + +* A memory corruption was fixed when garbage collection was triggered during calls + to ``PyType_Ready()`` of extension type subclasses. + (Github issue #3603) + +* Memory view slicing generated unused error handling code which could negatively + impact the C compiler optimisations for parallel OpenMP code etc. Also, it is + now helped by static branch hints. + (Github issue #2987) + +* Cython's built-in OpenMP functions were not translated inside of call arguments. + Original patch by Celelibi and David Woods. (Github issue #3594) + +* Complex buffer item types of structs of arrays could fail to validate. + Patch by Leo and smutch. (Github issue #1407) + +* Decorators were not allowed on nested `async def` functions. + (Github issue #1462) + +* C-tuples could use invalid C struct casting. + Patch by MegaIng. (Github issue #3038) + +* Optimised ``%d`` string formatting into f-strings failed on float values. + (Github issue #3092) + +* Optimised aligned string formatting (``%05s``, ``%-5s``) failed. + (Github issue #3476) + +* When importing the old Cython ``build_ext`` integration with distutils, the + additional command line arguments leaked into the regular command. + Patch by Kamekameha. (Github issue #2209) + +* When using the ``CYTHON_NO_PYINIT_EXPORT`` option in C++, the module init function + was not declared as ``extern "C"``. + (Github issue #3414) + +* Three missing timedelta access macros were added in ``cpython.datetime``. + +* The signature of the NumPy C-API function ``PyArray_SearchSorted()`` was fixed. + Patch by Brock Mendel. (Github issue #3606) + + +0.29.17 (2020-04-26) +==================== + +Features added +-------------- + +* ``std::move()`` is now available from ``libcpp.utility``. + Patch by Omer Ozarslan. (Github issue #2169) + +* The ``@cython.binding`` decorator is available in Python code. + (Github issue #3505) + +Bugs fixed +---------- + +* Creating an empty unicode slice with large bounds could crash. + Patch by Sam Sneddon. (Github issue #3531) + +* Decoding an empty bytes/char* slice with large bounds could crash. + Patch by Sam Sneddon. (Github issue #3534) + +* Re-importing a Cython extension no longer raises the error + "``__reduce_cython__ not found``". + (Github issue #3545) + +* Unused C-tuples could generate incorrect code in 0.29.16. + Patch by Kirk Meyer. (Github issue #3543) + +* Creating a fused function attached it to the garbage collector before it + was fully initialised, thus risking crashes in rare failure cases. + Original patch by achernomorov. (Github issue #3215) + +* Temporary buffer indexing variables were not released and could show up in + C compiler warnings, e.g. in generators. + Patch by David Woods. (Github issues #3430, #3522) + +* The compilation cache in ``cython.inline("…")`` failed to take the language + level into account. + Patch by will-ca. (Github issue #3419) + +* The deprecated ``PyUnicode_GET_SIZE()`` function is no longer used in Py3. + + +0.29.16 (2020-03-24) +==================== + +Bugs fixed +---------- + +* Temporary internal variables in nested prange loops could leak into other + threads. Patch by Frank Schlimbach. (Github issue #3348) + +* Default arguments on fused functions could crash. + Patch by David Woods. (Github issue #3370) + +* C-tuples declared in ``.pxd`` files could generate incomplete C code. + Patch by Kirk Meyer. (Github issue #1427) + +* Fused functions were not always detected and optimised as Cython + implemented functions. + Patch by David Woods. (Github issue #3384) + +* Valid Python object concatenation of (iterable) strings to non-strings + could fail with an exception. + Patch by David Woods. (Github issue #3433) + +* Using C functions as temporary values lead to invalid C code. + Original patch by David Woods. (Github issue #3418) + +* Fix an unhandled C++ exception in comparisons. + Patch by David Woods. (Github issue #3361) + +* Fix deprecated import of "imp" module. + Patch by Matti Picus. (Github issue #3350) + +* Fix compatibility with Pythran 0.9.6 and later. + Patch by Serge Guelton. (Github issue #3308) + +* The ``_Py_PyAtExit()`` function in ``cpython.pylifecycle`` was misdeclared. + Patch by Zackery Spytz. (Github issue #3382) + +* Several missing declarations in ``cpython.*`` were added. + Patches by Zackery Spytz. (Github issue #3452, #3421, #3411, #3402) + +* A declaration for ``libc.math.fpclassify()`` was added. + Patch by Zackery Spytz. (Github issue #2514) + +* Avoid "undeclared" warning about automatically generated pickle methods. + Patch by David Woods. (Github issue #3353) + +* Avoid C compiler warning about unreachable code in ``prange()``. + +* Some C compiler warnings in PyPy were resolved. + Patch by Matti Picus. (Github issue #3437) + + +0.29.15 (2020-02-06) +==================== + +Bugs fixed +---------- + +* Crash when returning a temporary Python object from an async-def function. + (Github issue #3337) + +* Crash when using ``**kwargs`` in generators. + Patch by David Woods. (Github issue #3265) + +* Double reference free in ``__class__`` cell handling for ``super()`` calls. + (Github issue #3246) + +* Compile error when using ``*args`` as Python class bases. + (Github issue #3338) + +* Import failure in IPython 7.11. + (Github issue #3297) + +* Fixed C name collision in the auto-pickle code. + Patch by ThePrez. (Github issue #3238) + +* Deprecated import failed in Python 3.9. + (Github issue #3266) + + +0.29.14 (2019-11-01) +==================== + +Bugs fixed +---------- + +* The generated code failed to initialise the ``tp_print`` slot in CPython 3.8. + Patches by Pablo Galindo and Orivej Desh. (Github issues #3171, #3201) + +* ``?`` for ``bool`` was missing from the supported NumPy dtypes. + Patch by Max Klein. (Github issue #2675) + +* ``await`` was not allowed inside of f-strings. + Patch by Dmitro Getz. (Github issue #2877) + +* Coverage analysis failed for projects where the code resides in separate + source sub-directories. + Patch by Antonio Valentino. (Github issue #1985) + +* An incorrect compiler warning was fixed in automatic C++ string conversions. + Patch by Gerion Entrup. (Github issue #3108) + +* Error reports in the Jupyter notebook showed unhelpful stack traces. + Patch by Matthew Edwards (Github issue #3196). + +* ``Python.h`` is now also included explicitly from ``public`` header files. + (Github issue #3133). + +* Distutils builds with ``--parallel`` did not work when using Cython's + deprecated ``build_ext`` command. + Patch by Alphadelta14 (Github issue #3187). + +Other changes +------------- + +* The ``PyMemoryView_*()`` C-API is available in ``cpython.memoryview``. + Patch by Nathan Manville. (Github issue #2541) + + +0.29.13 (2019-07-26) +==================== + +Bugs fixed +---------- + +* A reference leak for ``None`` was fixed when converting a memoryview + to a Python object. (Github issue #3023) + +* The declaration of ``PyGILState_STATE`` in ``cpython.pystate`` was unusable. + Patch by Kirill Smelkov. (Github issue #2997) + + +Other changes +------------- + +* The declarations in ``posix.mman`` were extended. + Patches by Kirill Smelkov. (Github issues #2893, #2894, #3012) + + +0.29.12 (2019-07-07) +==================== + +Bugs fixed +---------- + +* Fix compile error in CPython 3.8b2 regarding the ``PyCode_New()`` signature. + (Github issue #3031) + +* Fix a C compiler warning about a missing ``int`` downcast. + (Github issue #3028) + +* Fix reported error positions of undefined builtins and constants. + Patch by Orivej Desh. (Github issue #3030) + +* A 32 bit issue in the Pythran support was resolved. + Patch by Serge Guelton. (Github issue #3032) + + +0.29.11 (2019-06-30) +==================== + +Bugs fixed +---------- + +* Fix compile error in CPython 3.8b2 regarding the ``PyCode_New()`` signature. + Patch by Nick Coghlan. (Github issue #3009) + +* Invalid C code generated for lambda functions in cdef methods. + Patch by Josh Tobin. (Github issue #2967) + +* Support slice handling in newer Pythran versions. + Patch by Serge Guelton. (Github issue #2989) + +* A reference leak in power-of-2 calculation was fixed. + Patch by Sebastian Berg. (Github issue #3022) + +* The search order for include files was changed. Previously it was + ``include_directories``, ``Cython/Includes``, ``sys.path``. Now it is + ``include_directories``, ``sys.path``, ``Cython/Includes``. This was done to + allow third-party ``*.pxd`` files to override the ones in Cython. + Original patch by Matti Picus. (Github issue #2905) + +* Setting ``language_level=2`` in a file did not work if ``language_level=3`` + was enabled globally before. + Patch by Jeroen Demeyer. (Github issue #2791) + + +0.29.10 (2019-06-02) +==================== + +Bugs fixed +---------- + +* Fix compile errors in CPython 3.8b1 due to the new "tp_vectorcall" slots. + (Github issue #2976) + + +0.29.9 (2019-05-29) +=================== + +Bugs fixed +---------- + +* Fix a crash regression in 0.29.8 when creating code objects fails. + +* Remove an incorrect cast when using true-division in C++ operations. + (Github issue #1950) + + +0.29.8 (2019-05-28) +=================== + +Bugs fixed +---------- + +* C compile errors with CPython 3.8 were resolved. + Patch by Marcel Plch. (Github issue #2938) + +* Python tuple constants that compare equal but have different item + types could incorrectly be merged into a single constant. + (Github issue #2919) + +* Non-ASCII characters in unprefixed strings could crash the compiler when + used with language level ``3str``. + +* Starred expressions in %-formatting tuples could fail to compile for + unicode strings. (Github issue #2939) + +* Passing Python class references through ``cython.inline()`` was broken. + (Github issue #2936) + + +0.29.7 (2019-04-14) +=================== + +Bugs fixed +---------- + +* Crash when the shared Cython config module gets unloaded and another Cython + module reports an exceptions. Cython now makes sure it keeps an owned reference + to the module. + (Github issue #2885) + +* Resolved a C89 compilation problem when enabling the fast-gil sharing feature. + +* Coverage reporting did not include the signature line of ``cdef`` functions. + (Github issue #1461) + +* Casting a GIL-requiring function into a nogil function now issues a warning. + (Github issue #2879) + +* Generators and coroutines were missing their return type annotation. + (Github issue #2884) + + +0.29.6 (2019-02-27) +=================== + +Bugs fixed +---------- + +* Fix a crash when accessing the ``__kwdefaults__`` special attribute of + fused functions. (Github issue #1470) + +* Fix the parsing of buffer format strings that contain numeric sizes, which + could lead to incorrect input rejections. (Github issue #2845) + +* Avoid a C #pragma in old gcc versions that was only added in GCC 4.6. + Patch by Michael Anselmi. (Github issue #2838) + +* Auto-encoding of Unicode strings to UTF-8 C/C++ strings failed in Python 3, + even though the default encoding there is UTF-8. + (Github issue #2819) + + +0.29.5 (2019-02-09) +=================== + +Bugs fixed +---------- + +* Crash when defining a Python subclass of an extension type and repeatedly calling + a cpdef method on it. (Github issue #2823) + +* Compiler crash when ``prange()`` loops appear inside of with-statements. + (Github issue #2780) + +* Some C compiler warnings were resolved. + Patches by Christoph Gohlke. (Github issues #2815, #2816, #2817, #2822) + +* Python conversion of C++ enums failed in 0.29. + Patch by Orivej Desh. (Github issue #2767) + + +0.29.4 (2019-02-01) +=================== + +Bugs fixed +---------- + +* Division of numeric constants by a runtime value of 0 could fail to raise a + ``ZeroDivisionError``. (Github issue #2820) + + +0.29.3 (2019-01-19) +=================== + +Bugs fixed +---------- + +* Some C code for memoryviews was generated in a non-deterministic order. + Patch by Martijn van Steenbergen. (Github issue #2779) + +* C89 compatibility was accidentally lost since 0.28. + Patches by gastineau and true-pasky. (Github issues #2778, #2801) + +* A C compiler cast warning was resolved. + Patch by Michael Buesch. (Github issue #2774) + +* An compilation failure with complex numbers under MSVC++ was resolved. + (Github issue #2797) + +* Coverage reporting could fail when modules were moved around after the build. + Patch by Wenjun Si. (Github issue #2776) + + +0.29.2 (2018-12-14) +=================== + +Bugs fixed +---------- + +* The code generated for deduplicated constants leaked some references. + (Github issue #2750) + +* The declaration of ``sigismember()`` in ``libc.signal`` was corrected. + (Github issue #2756) + +* Crashes in compiler and test runner were fixed. + (Github issue #2736, #2755) + +* A C compiler warning about an invalid safety check was resolved. + (Github issue #2731) + + +0.29.1 (2018-11-24) +=================== + +Bugs fixed +---------- + +* Extensions compiled with MinGW-64 under Windows could misinterpret integer + objects larger than 15 bit and return incorrect results. + (Github issue #2670) + +* Cython no longer requires the source to be writable when copying its data + into a memory view slice. + Patch by Andrey Paramonov. (Github issue #2644) + +* Line tracing of ``try``-statements generated invalid C code. + (Github issue #2274) + +* When using the ``warn.undeclared`` directive, Cython's own code generated + warnings that are now fixed. + Patch by Nicolas Pauss. (Github issue #2685) + +* Cython's memoryviews no longer require strides for setting the shape field + but only the ``PyBUF_ND`` flag to be set. + Patch by John Kirkham. (Github issue #2716) + +* Some C compiler warnings about unused memoryview code were fixed. + Patch by Ho Cheuk Ting. (Github issue #2588) + +* A C compiler warning about implicit signed/unsigned conversion was fixed. + (Github issue #2729) + +* Assignments to C++ references returned by ``operator[]`` could fail to compile. + (Github issue #2671) + +* The power operator and the support for NumPy math functions were fixed + in Pythran expressions. + Patch by Serge Guelton. (Github issues #2702, #2709) + +* Signatures with memory view arguments now show the expected type + when embedded in docstrings. + Patch by Matthew Chan and Benjamin Weigel. (Github issue #2634) + +* Some ``from ... cimport ...`` constructs were not correctly considered + when searching modified dependencies in ``cythonize()`` to decide + whether to recompile a module. + Patch by Kryštof Pilnáček. (Github issue #2638) + +* A struct field type in the ``cpython.array`` declarations was corrected. + Patch by John Kirkham. (Github issue #2712) + + +0.29 (2018-10-14) +================= + +Features added +-------------- + +* PEP-489 multi-phase module initialisation has been enabled again. Module + reloads in other subinterpreters raise an exception to prevent corruption + of the static module state. + +* A set of ``mypy`` compatible PEP-484 declarations were added for Cython's C data + types to integrate with static analysers in typed Python code. They are available + in the ``Cython/Shadow.pyi`` module and describe the types in the special ``cython`` + module that can be used for typing in Python code. + Original patch by Julian Gethmann. (Github issue #1965) + +* Memoryviews are supported in PEP-484/526 style type declarations. + (Github issue #2529) + +* ``@cython.nogil`` is supported as a C-function decorator in Python code. + (Github issue #2557) + +* Raising exceptions from nogil code will automatically acquire the GIL, instead + of requiring an explicit ``with gil`` block. + +* C++ functions can now be declared as potentially raising both C++ and Python + exceptions, so that Cython can handle both correctly. + (Github issue #2615) + +* ``cython.inline()`` supports a direct ``language_level`` keyword argument that + was previously only available via a directive. + +* A new language level name ``3str`` was added that mostly corresponds to language + level 3, but keeps unprefixed string literals as type 'str' in both Py2 and Py3, + and the builtin 'str' type unchanged. This will become the default in the next + Cython release and is meant to help user code a) transition more easily to this + new default and b) migrate to Python 3 source code semantics without making support + for Python 2.x difficult. + +* In CPython 3.6 and later, looking up globals in the module dict is almost + as fast as looking up C globals. + (Github issue #2313) + +* For a Python subclass of an extension type, repeated method calls to non-overridden + cpdef methods can avoid the attribute lookup in Py3.6+, which makes them 4x faster. + (Github issue #2313) + +* (In-)equality comparisons of objects to integer literals are faster. + (Github issue #2188) + +* Some internal and 1-argument method calls are faster. + +* Modules that cimport many external extension types from other Cython modules + execute less import requests during module initialisation. + +* Constant tuples and slices are deduplicated and only created once per module. + (Github issue #2292) + +* The coverage plugin considers more C file extensions such as ``.cc`` and ``.cxx``. + (Github issue #2266) + +* The ``cythonize`` command accepts compile time variable values (as set by ``DEF``) + through the new ``-E`` option. + Patch by Jerome Kieffer. (Github issue #2315) + +* ``pyximport`` can import from namespace packages. + Patch by Prakhar Goel. (Github issue #2294) + +* Some missing numpy and CPython C-API declarations were added. + Patch by John Kirkham. (Github issues #2523, #2520, #2537) + +* Declarations for the ``pylifecycle`` C-API functions were added in a new .pxd file + ``cpython.pylifecycle``. + +* The Pythran support was updated to work with the latest Pythran 0.8.7. + Original patch by Adrien Guinet. (Github issue #2600) + +* ``%a`` is included in the string formatting types that are optimised into f-strings. + In this case, it is also automatically mapped to ``%r`` in Python 2.x. + +* New C macro ``CYTHON_HEX_VERSION`` to access Cython's version in the same style as + ``PY_VERSION_HEX``. + +* Constants in ``libc.math`` are now declared as ``const`` to simplify their handling. + +* An additional ``check_size`` clause was added to the ``ctypedef class`` name + specification to allow suppressing warnings when importing modules with + backwards-compatible ``PyTypeObject`` size changes. + Patch by Matti Picus. (Github issue #2627) + +Bugs fixed +---------- + +* The exception handling in generators and coroutines under CPython 3.7 was adapted + to the newly introduced exception stack. Users of Cython 0.28 who want to support + Python 3.7 are encouraged to upgrade to 0.29 to avoid potentially incorrect error + reporting and tracebacks. (Github issue #1958) + +* Crash when importing a module under Stackless Python that was built for CPython. + Patch by Anselm Kruis. (Github issue #2534) + +* 2-value slicing of typed sequences failed if the start or stop index was None. + Patch by Christian Gibson. (Github issue #2508) + +* Multiplied string literals lost their factor when they are part of another + constant expression (e.g. 'x' * 10 + 'y' => 'xy'). + +* String formatting with the '%' operator didn't call the special ``__rmod__()`` + method if the right side is a string subclass that implements it. + (Python issue 28598) + +* The directive ``language_level=3`` did not apply to the first token in the + source file. (Github issue #2230) + +* Overriding cpdef methods did not work in Python subclasses with slots. + Note that this can have a performance impact on calls from Cython code. + (Github issue #1771) + +* Fix declarations of builtin or C types using strings in pure python mode. + (Github issue #2046) + +* Generator expressions and lambdas failed to compile in ``@cfunc`` functions. + (Github issue #459) + +* Global names with ``const`` types were not excluded from star-import assignments + which could lead to invalid C code. + (Github issue #2621) + +* Several internal function signatures were fixed that lead to warnings in gcc-8. + (Github issue #2363) + +* The numpy helper functions ``set_array_base()`` and ``get_array_base()`` + were adapted to the current numpy C-API recommendations. + Patch by Matti Picus. (Github issue #2528) + +* Some NumPy related code was updated to avoid deprecated API usage. + Original patch by jbrockmendel. (Github issue #2559) + +* Several C++ STL declarations were extended and corrected. + Patch by Valentin Valls. (Github issue #2207) + +* C lines of the module init function were unconditionally not reported in + exception stack traces. + Patch by Jeroen Demeyer. (Github issue #2492) + +* When PEP-489 support is enabled, reloading the module overwrote any static + module state. It now raises an exception instead, given that reloading is + not actually supported. + +* Object-returning, C++ exception throwing functions were not checking that + the return value was non-null. + Original patch by Matt Wozniski (Github Issue #2603) + +* The source file encoding detection could get confused if the + ``c_string_encoding`` directive appeared within the first two lines. + (Github issue #2632) + +* Cython generated modules no longer emit a warning during import when the + size of the NumPy array type is larger than what was found at compile time. + Instead, this is assumed to be a backwards compatible change on NumPy side. + +Other changes +------------- + +* Cython now emits a warning when no ``language_level`` (2, 3 or '3str') is set + explicitly, neither as a ``cythonize()`` option nor as a compiler directive. + This is meant to prepare the transition of the default language level from + currently Py2 to Py3, since that is what most new users will expect these days. + The future default will, however, not enforce unicode literals, because this + has proven a major obstacle in the support for both Python 2.x and 3.x. The + next major release is intended to make this change, so that it will parse all + code that does not request a specific language level as Python 3 code, but with + ``str`` literals. The language level 2 will continue to be supported for an + indefinite time. + +* The documentation was restructured, cleaned up and examples are now tested. + The NumPy tutorial was also rewritten to simplify the running example. + Contributed by Gabriel de Marmiesse. (Github issue #2245) + +* Cython compiles less of its own modules at build time to reduce the installed + package size to about half of its previous size. This makes the compiler + slightly slower, by about 5-7%. + + +0.28.6 (2018-11-01) +=================== + +Bugs fixed +---------- + +* Extensions compiled with MinGW-64 under Windows could misinterpret integer + objects larger than 15 bit and return incorrect results. + (Github issue #2670) + +* Multiplied string literals lost their factor when they are part of another + constant expression (e.g. 'x' * 10 + 'y' => 'xy'). + + +0.28.5 (2018-08-03) +=================== + +Bugs fixed +---------- + +* The discouraged usage of GCC's attribute ``optimize("Os")`` was replaced by the + similar attribute ``cold`` to reduce the code impact of the module init functions. + (Github issue #2494) + +* A reference leak in Py2.x was fixed when comparing str to unicode for equality. + + +0.28.4 (2018-07-08) +=================== + +Bugs fixed +---------- + +* Reallowing ``tp_clear()`` in a subtype of an ``@no_gc_clear`` extension type + generated an invalid C function call to the (non-existent) base type implementation. + (Github issue #2309) + +* Exception catching based on a non-literal (runtime) tuple could fail to match the + exception. (Github issue #2425) + +* Compile fix for CPython 3.7.0a2. (Github issue #2477) + + +0.28.3 (2018-05-27) +=================== + +Bugs fixed +---------- + +* Set iteration was broken in non-CPython since 0.28. + +* ``UnicodeEncodeError`` in Py2 when ``%s`` formatting is optimised for + unicode strings. (Github issue #2276) + +* Work around a crash bug in g++ 4.4.x by disabling the size reduction setting + of the module init function in this version. (Github issue #2235) + +* Crash when exceptions occur early during module initialisation. + (Github issue #2199) + + +0.28.2 (2018-04-13) +=================== + +Features added +-------------- + +* ``abs()`` is faster for Python long objects. + +* The C++11 methods ``front()`` and ``end()`` were added to the declaration of + ``libcpp.string``. Patch by Alex Huszagh. (Github issue #2123) + +* The C++11 methods ``reserve()`` and ``bucket_count()`` are declared for + ``libcpp.unordered_map``. Patch by Valentin Valls. (Github issue #2168) + +Bugs fixed +---------- + +* The copy of a read-only memoryview was considered read-only as well, whereas + a common reason to copy a read-only view is to make it writable. The result + of the copying is now a writable buffer by default. + (Github issue #2134) + +* The ``switch`` statement generation failed to apply recursively to the body of + converted if-statements. + +* ``NULL`` was sometimes rejected as exception return value when the returned + type is a fused pointer type. + Patch by Callie LeFave. (Github issue #2177) + +* Fixed compatibility with PyPy 5.11. + Patch by Matti Picus. (Github issue #2165) + +Other changes +------------- + +* The NumPy tutorial was rewritten to use memoryviews instead of the older + buffer declaration syntax. + Contributed by Gabriel de Marmiesse. (Github issue #2162) + + +0.28.1 (2018-03-18) +=================== + +Bugs fixed +---------- + +* ``PyFrozenSet_New()`` was accidentally used in PyPy where it is missing + from the C-API. + +* Assignment between some C++ templated types were incorrectly rejected + when the templates mix ``const`` with ``ctypedef``. + (Github issue #2148) + +* Undeclared C++ no-args constructors in subclasses could make the compilation + fail if the base class constructor was declared without ``nogil``. + (Github issue #2157) + +* Bytes %-formatting inferred ``basestring`` (bytes or unicode) as result type + in some cases where ``bytes`` would have been safe to infer. + (Github issue #2153) + +* ``None`` was accidentally disallowed as typed return value of ``dict.pop()``. + (Github issue #2152) + + +0.28 (2018-03-13) +================= + +Features added +-------------- + +* Cdef classes can now multiply inherit from ordinary Python classes. + (The primary base must still be a c class, possibly ``object``, and + the other bases must *not* be cdef classes.) + +* Type inference is now supported for Pythran compiled NumPy expressions. + Patch by Nils Braun. (Github issue #1954) + +* The ``const`` modifier can be applied to memoryview declarations to allow + read-only buffers as input. (Github issues #1605, #1869) + +* C code in the docstring of a ``cdef extern`` block is copied verbatimly + into the generated file. + Patch by Jeroen Demeyer. (Github issue #1915) + +* When compiling with gcc, the module init function is now tuned for small + code size instead of whatever compile flags were provided externally. + Cython now also disables some code intensive optimisations in that function + to further reduce the code size. (Github issue #2102) + +* Decorating an async coroutine with ``@cython.iterable_coroutine`` changes its + type at compile time to make it iterable. While this is not strictly in line + with PEP-492, it improves the interoperability with old-style coroutines that + use ``yield from`` instead of ``await``. + +* The IPython magic has preliminary support for JupyterLab. + (Github issue #1775) + +* The new TSS C-API in CPython 3.7 is supported and has been backported. + Patch by Naotoshi Seo. (Github issue #1932) + +* Cython knows the new ``Py_tss_t`` type defined in PEP-539 and automatically + initialises variables declared with that type to ``Py_tss_NEEDS_INIT``, + a value which cannot be used outside of static assignments. + +* The set methods ``.remove()`` and ``.discard()`` are optimised. + Patch by Antoine Pitrou. (Github issue #2042) + +* ``dict.pop()`` is optimised. + Original patch by Antoine Pitrou. (Github issue #2047) + +* Iteration over sets and frozensets is optimised. + (Github issue #2048) + +* Safe integer loops (< range(2^30)) are automatically optimised into C loops. + +* ``alist.extend([a,b,c])`` is optimised into sequential ``list.append()`` calls + for short literal sequences. + +* Calls to builtin methods that are not specifically optimised into C-API calls + now use a cache that avoids repeated lookups of the underlying C function. + (Github issue #2054) + +* Single argument function calls can avoid the argument tuple creation in some cases. + +* Some redundant extension type checks are avoided. + +* Formatting C enum values in f-strings is faster, as well as some other special cases. + +* String formatting with the '%' operator is optimised into f-strings in simple cases. + +* Subscripting (item access) is faster in some cases. + +* Some ``bytearray`` operations have been optimised similar to ``bytes``. + +* Some PEP-484/526 container type declarations are now considered for + loop optimisations. + +* Indexing into memoryview slices with ``view[i][j]`` is now optimised into + ``view[i, j]``. + +* Python compatible ``cython.*`` types can now be mixed with type declarations + in Cython syntax. + +* Name lookups in the module and in classes are faster. + +* Python attribute lookups on extension types without instance dict are faster. + +* Some missing signals were added to ``libc/signal.pxd``. + Patch by Jeroen Demeyer. (Github issue #1914) + +* The warning about repeated extern declarations is now visible by default. + (Github issue #1874) + +* The exception handling of the function types used by CPython's type slot + functions was corrected to match the de-facto standard behaviour, so that + code that uses them directly benefits from automatic and correct exception + propagation. Patch by Jeroen Demeyer. (Github issue #1980) + +* Defining the macro ``CYTHON_NO_PYINIT_EXPORT`` will prevent the module init + function from being exported as symbol, e.g. when linking modules statically + in an embedding setup. Patch by AraHaan. (Github issue #1944) + +Bugs fixed +---------- + +* If a module name is explicitly provided for an ``Extension()`` that is compiled + via ``cythonize()``, it was previously ignored and replaced by the source file + name. It can now be used to override the target module name, e.g. for compiling + prefixed accelerator modules from Python files. (Github issue #2038) + +* The arguments of the ``num_threads`` parameter of parallel sections + were not sufficiently validated and could lead to invalid C code. + (Github issue #1957) + +* Catching exceptions with a non-trivial exception pattern could call into + CPython with a live exception set. This triggered incorrect behaviour + and crashes, especially in CPython 3.7. + +* The signature of the special ``__richcmp__()`` method was corrected to recognise + the type of the first argument as ``self``. It was previously treated as plain + object, but CPython actually guarantees that it always has the correct type. + Note: this can change the semantics of user code that previously relied on + ``self`` being untyped. + +* Some Python 3 exceptions were not recognised as builtins when running Cython + under Python 2. + +* Some async helper functions were not defined in the generated C code when + compiling simple async code. (Github issue #2075) + +* Line tracing did not include generators and coroutines. + (Github issue #1949) + +* C++ declarations for ``unordered_map`` were corrected. + Patch by Michael Schatzow. (Github issue #1484) + +* Iterator declarations in C++ ``deque`` and ``vector`` were corrected. + Patch by Alex Huszagh. (Github issue #1870) + +* The const modifiers in the C++ ``string`` declarations were corrected, together + with the coercion behaviour of string literals into C++ strings. + (Github issue #2132) + +* Some declaration types in ``libc.limits`` were corrected. + Patch by Jeroen Demeyer. (Github issue #2016) + +* ``@cython.final`` was not accepted on Python classes with an ``@cython.cclass`` + decorator. (Github issue #2040) + +* Cython no longer creates useless and incorrect ``PyInstanceMethod`` wrappers for + methods in Python 3. Patch by Jeroen Demeyer. (Github issue #2105) + +* The builtin ``bytearray`` type could not be used as base type of cdef classes. + (Github issue #2106) + +Other changes +------------- + + +0.27.3 (2017-11-03) +=================== + +Bugs fixed +---------- + +* String forward references to extension types like ``@cython.locals(x="ExtType")`` + failed to find the named type. (Github issue #1962) + +* NumPy slicing generated incorrect results when compiled with Pythran. + Original patch by Serge Guelton (Github issue #1946). + +* Fix "undefined reference" linker error for generators on Windows in Py3.3-3.5. + (Github issue #1968) + +* Adapt to recent C-API change of ``PyThreadState`` in CPython 3.7. + +* Fix signature of ``PyWeakref_GetObject()`` API declaration. + Patch by Jeroen Demeyer (Github issue #1975). + + +0.27.2 (2017-10-22) +=================== + +Bugs fixed +---------- + +* Comprehensions could incorrectly be optimised away when they appeared in boolean + test contexts. (Github issue #1920) + +* The special methods ``__eq__``, ``__lt__`` etc. in extension types did not type + their first argument as the type of the class but ``object``. (Github issue #1935) + +* Crash on first lookup of "cline_in_traceback" option during exception handling. + (Github issue #1907) + +* Some nested module level comprehensions failed to compile. + (Github issue #1906) + +* Compiler crash on some complex type declarations in pure mode. + (Github issue #1908) + +* ``std::unordered_map.erase()`` was declared with an incorrect ``void`` return + type in ``libcpp.unordered_map``. (Github issue #1484) + +* Invalid use of C++ ``fallthrough`` attribute before C++11 and similar issue in clang. + (Github issue #1930) + +* Compiler crash on misnamed properties. (Github issue #1905) + + +0.27.1 (2017-10-01) +=================== + +Features added +-------------- + +* The Jupyter magic has a new debug option ``--verbose`` that shows details about + the distutils invocation. Patch by Boris Filippov (Github issue #1881). + +Bugs fixed +---------- + +* Py3 list comprehensions in class bodies resulted in invalid C code. + (Github issue #1889) + +* Modules built for later CPython 3.5.x versions failed to import in 3.5.0/3.5.1. + (Github issue #1880) + +* Deallocating fused types functions and methods kept their GC tracking enabled, + which could potentially lead to recursive deallocation attempts. + +* Crash when compiling in C++ mode with old setuptools versions. + (Github issue #1879) + +* C++ object arguments for the constructor of Cython implemented C++ are now + passed by reference and not by value to allow for non-copyable arguments, such + as ``unique_ptr``. + +* API-exported C++ classes with Python object members failed to compile. + (Github issue #1866) + +* Some issues with the new relaxed exception value handling were resolved. + +* Python classes as annotation types could prevent compilation. + (Github issue #1887) + +* Cython annotation types in Python files could lead to import failures + with a "cython undefined" error. Recognised types are now turned into strings. + +* Coverage analysis could fail to report on extension modules on some platforms. + +* Annotations could be parsed (and rejected) as types even with + ``annotation_typing=False``. + +Other changes +------------- + +* PEP 489 support has been disabled by default to counter incompatibilities with + import setups that try to reload or reinitialise modules. + + +0.27 (2017-09-23) +================= + +Features added +-------------- + +* Extension module initialisation follows + `PEP 489 <https://www.python.org/dev/peps/pep-0489/>`_ in CPython 3.5+, which + resolves several differences with regard to normal Python modules. This makes + the global names ``__file__`` and ``__path__`` correctly available to module + level code and improves the support for module-level relative imports. + (Github issues #1715, #1753, #1035) + +* Asynchronous generators (`PEP 525 <https://www.python.org/dev/peps/pep-0525/>`_) + and asynchronous comprehensions (`PEP 530 <https://www.python.org/dev/peps/pep-0530/>`_) + have been implemented. Note that async generators require finalisation support + in order to allow for asynchronous operations during cleanup, which is only + available in CPython 3.6+. All other functionality has been backported as usual. + +* Variable annotations are now parsed according to + `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_. Cython types (e.g. + ``cython.int``) are evaluated as C type declarations and everything else as Python + types. This can be disabled with the directive ``annotation_typing=False``. + Note that most complex PEP-484 style annotations are currently ignored. This will + change in future releases. (Github issue #1850) + +* Extension types (also in pure Python mode) can implement the normal special methods + ``__eq__``, ``__lt__`` etc. for comparisons instead of the low-level ``__richcmp__`` + method. (Github issue #690) + +* New decorator ``@cython.exceptval(x=None, check=False)`` that makes the signature + declarations ``except x``, ``except? x`` and ``except *`` available to pure Python + code. Original patch by Antonio Cuni. (Github issue #1653) + +* Signature annotations are now included in the signature docstring generated by + the ``embedsignature`` directive. Patch by Lisandro Dalcin (Github issue #1781). + +* The gdb support for Python code (``libpython.py``) was updated to the latest + version in CPython 3.7 (git rev 5fe59f8). + +* The compiler tries to find a usable exception return value for cdef functions + with ``except *`` if the returned type allows it. Note that this feature is subject + to safety limitations, so it is still better to provide an explicit declaration. + +* C functions can be assigned to function pointers with a compatible exception + declaration, not only with exact matches. A side-effect is that certain compatible + signature overrides are now allowed and some more mismatches of exception signatures + are now detected and rejected as errors that were not detected before. + +* The IPython/Jupyter magic integration has a new option ``%%cython --pgo`` for profile + guided optimisation. It compiles the cell with PGO settings for the C compiler, + executes it to generate a runtime profile, and then compiles it again using that + profile for C compiler optimisation. Currently only tested with gcc. + +* ``len(memoryview)`` can be used in nogil sections to get the size of the + first dimension of a memory view (``shape[0]``). (Github issue #1733) + +* C++ classes can now contain (properly refcounted) Python objects. + +* NumPy dtype subarrays are now accessible through the C-API. + Patch by Gerald Dalley (Github issue #245). + +* Resolves several issues with PyPy and uses faster async slots in PyPy3. + Patch by Ronan Lamy (Github issues #1871, #1878). + +Bugs fixed +---------- + +* Extension types that were cimported from other Cython modules could disagree + about the order of fused cdef methods in their call table. This could lead + to wrong methods being called and potentially also crashes. The fix required + changes to the ordering of fused methods in the call table, which may break + existing compiled modules that call fused cdef methods across module boundaries, + if these methods were implemented in a different order than they were declared + in the corresponding .pxd file. (Github issue #1873) + +* The exception state handling in generators and coroutines could lead to + exceptions in the caller being lost if an exception was raised and handled + inside of the coroutine when yielding. (Github issue #1731) + +* Loops over ``range(enum)`` were not converted into C for-loops. Note that it + is still recommended to use an explicit cast to a C integer type in this case. + +* Error positions of names (e.g. variables) were incorrectly reported after the + name and not at the beginning of the name. + +* Compile time ``DEF`` assignments were evaluated even when they occur inside of + falsy ``IF`` blocks. (Github issue #1796) + +* Disabling the line tracing from a trace function could fail. + Original patch by Dmitry Trofimov. (Github issue #1769) + +* Several issues with the Pythran integration were resolved. + +* abs(signed int) now returns a signed rather than unsigned int. + (Github issue #1837) + +* Reading ``frame.f_locals`` of a Cython function (e.g. from a debugger or profiler + could modify the module globals. (Github issue #1836) + +* Buffer type mismatches in the NumPy buffer support could leak a reference to the + buffer owner. + +* Using the "is_f_contig" and "is_c_contig" memoryview methods together could leave + one of them undeclared. (Github issue #1872) + +* Compilation failed if the for-in-range loop target was not a variable but a more + complex expression, e.g. an item assignment. (Github issue #1831) + +* Compile time evaluations of (partially) constant f-strings could show incorrect + results. + +* Escape sequences in raw f-strings (``fr'...'``) were resolved instead of passing + them through as expected. + +* Some ref-counting issues in buffer error handling have been resolved. + +Other changes +------------- + +* Type declarations in signature annotations are now parsed according to + `PEP 484 <https://www.python.org/dev/peps/pep-0484/>`_ + typing. Only Cython types (e.g. ``cython.int``) and Python builtin types are + currently considered as type declarations. Everything else is ignored, but this + will change in a future Cython release. + (Github issue #1672) + +* The directive ``annotation_typing`` is now ``True`` by default, which enables + parsing type declarations from annotations. + +* This release no longer supports Python 3.2. + + +0.26.1 (2017-08-29) +=================== + +Features added +-------------- + +Bugs fixed +---------- + +* ``cython.view.array`` was missing ``.__len__()``. + +* Extension types with a ``.pxd`` override for their ``__releasebuffer__`` slot + (e.g. as provided by Cython for the Python ``array.array`` type) could leak + a reference to the buffer owner on release, thus not freeing the memory. + (Github issue #1638) + +* Auto-decoding failed in 0.26 for strings inside of C++ containers. + (Github issue #1790) + +* Compile error when inheriting from C++ container types. + (Github issue #1788) + +* Invalid C code in generators (declaration after code). + (Github issue #1801) + +* Arithmetic operations on ``const`` integer variables could generate invalid code. + (Github issue #1798) + +* Local variables with names of special Python methods failed to compile inside of + closures. (Github issue #1797) + +* Problem with indirect Emacs buffers in cython-mode. + Patch by Martin Albrecht (Github issue #1743). + +* Extension types named ``result`` or ``PickleError`` generated invalid unpickling code. + Patch by Jason Madden (Github issue #1786). + +* Bazel integration failed to compile ``.py`` files. + Patch by Guro Bokum (Github issue #1784). + +* Some include directories and dependencies were referenced with their absolute paths + in the generated files despite lying within the project directory. + +* Failure to compile in Py3.7 due to a modified signature of ``_PyCFunctionFast()`` + + +0.26 (2017-07-19) +================= + +Features added +-------------- + +* Pythran can be used as a backend for evaluating NumPy array expressions. + Patch by Adrien Guinet (Github issue #1607). + +* cdef classes now support pickling by default when possible. + This can be disabled with the ``auto_pickle`` directive. + +* Speed up comparisons of strings if their hash value is available. + Patch by Claudio Freire (Github issue #1571). + +* Support pyximport from zip files. + Patch by Sergei Lebedev (Github issue #1485). + +* IPython magic now respects the ``__all__`` variable and ignores + names with leading-underscore (like ``import *`` does). + Patch by Syrtis Major (Github issue #1625). + +* ``abs()`` is optimised for C complex numbers. + Patch by da-woods (Github issue #1648). + +* The display of C lines in Cython tracebacks can now be enabled at runtime + via ``import cython_runtime; cython_runtime.cline_in_traceback=True``. + The default has been changed to False. + +* The overhead of calling fused types generic functions was reduced. + +* "cdef extern" include files are now also searched relative to the current file. + Patch by Jeroen Demeyer (Github issue #1654). + +* Optional optimization for re-aquiring the GIL, controlled by the + `fast_gil` directive. + +Bugs fixed +---------- + +* Item lookup/assignment with a unicode character as index that is typed + (explicitly or implicitly) as ``Py_UCS4`` or ``Py_UNICODE`` used the + integer value instead of the Unicode string value. Code that relied on + the previous behaviour now triggers a warning that can be disabled by + applying an explicit cast. (Github issue #1602) + +* f-string processing was adapted to changes in PEP 498 and CPython 3.6. + +* Invalid C code when decoding from UTF-16(LE/BE) byte strings. + (Github issue #1696) + +* Unicode escapes in 'ur' raw-unicode strings were not resolved in Py2 code. + Original patch by Aaron Gallagher (Github issue #1594). + +* File paths of code objects are now relative. + Original patch by Jelmer Vernooij (Github issue #1565). + +* Decorators of cdef class methods could be executed twice. + Patch by Jeroen Demeyer (Github issue #1724). + +* Dict iteration using the Py2 ``iter*`` methods failed in PyPy3. + Patch by Armin Rigo (Github issue #1631). + +* Several warnings in the generated code are now suppressed. + +Other changes +------------- + +* The ``unraisable_tracebacks`` option now defaults to ``True``. + +* Coercion of C++ containers to Python is no longer automatic on attribute + access (Github issue #1521). + +* Access to Python attributes of cimported modules without the corresponding + import is now a compile-time (rather than runtime) error. + +* Do not use special dll linkage for "cdef public" functions. + Patch by Jeroen Demeyer (Github issue #1687). + +* cdef/cpdef methods must match their declarations. See Github Issue #1732. + This is now a warning and will be an error in future releases. + + +0.25.2 (2016-12-08) +=================== + +Bugs fixed +---------- + +* Fixes several issues with C++ template deduction. + +* Fixes a issue with bound method type inference (Github issue #551). + +* Fixes a bug with cascaded tuple assignment (Github issue #1523). + +* Fixed or silenced many Clang warnings. + +* Fixes bug with powers of pure real complex numbers (Github issue #1538). + + +0.25.1 (2016-10-26) +=================== + +Bugs fixed +---------- + +* Fixes a bug with ``isinstance(o, Exception)`` (Github issue #1496). + +* Fixes bug with ``cython.view.array`` missing utility code in some cases + (Github issue #1502). + +Other changes +------------- + +* The distutils extension ``Cython.Distutils.build_ext`` has been reverted, + temporarily, to be ``old_build_ext`` to give projects time to migrate. + The new build_ext is available as ``new_build_ext``. + + +0.25 (2016-10-25) +================= + +Features added +-------------- + +* def/cpdef methods of cdef classes benefit from Cython's internal function + implementation, which enables introspection and line profiling for them. + Implementation sponsored by Turbostream (www.turbostream-cfd.com). + +* Calls to Python functions are faster, following the recent "FastCall" + optimisations that Victor Stinner implemented for CPython 3.6. + See https://bugs.python.org/issue27128 and related issues. + +* The new METH_FASTCALL calling convention for PyCFunctions is supported + in CPython 3.6. See https://bugs.python.org/issue27810 + +* Initial support for using Cython modules in Pyston. + Patch by Boxiang Sun. + +* Dynamic Python attributes are allowed on cdef classes if an attribute + ``cdef dict __dict__`` is declared in the class. Patch by empyrical. + +* Cython implemented C++ classes can make direct calls to base class methods. + Patch by empyrical. + +* C++ classes can now have typedef members. STL containers updated with + value_type. + +* New directive ``cython.no_gc`` to fully disable GC for a cdef class. + Patch by Claudio Freire. + +* Buffer variables are no longer excluded from ``locals()``. + Patch by da-woods. + +* Building f-strings is faster, especially when formatting C integers. + +* for-loop iteration over "std::string". + +* ``libc/math.pxd`` provides ``e`` and ``pi`` as alias constants to simplify + usage as a drop-in replacement for Python's math module. + +* Speed up cython.inline(). + +* Binary lshift operations with small constant Python integers are faster. + +* Some integer operations on Python long objects are faster in Python 2.7. + +* Support for the C++ ``typeid`` operator. + +* Support for bazel using a the pyx_library rule in //Tools:rules.bzl. + +Significant Bugs fixed +---------------------- + +* Division of complex numbers avoids overflow by using Smith's method. + +* Some function signatures in ``libc.math`` and ``numpy.pxd`` were incorrect. + Patch by Michael Seifert. + +Other changes +------------- + +* The "%%cython" IPython/jupyter magic now defaults to the language level of + the current jupyter kernel. The language level can be set explicitly with + "%%cython -2" or "%%cython -3". + +* The distutils extension ``Cython.Distutils.build_ext`` has now been updated + to use cythonize which properly handles dependencies. The old extension can + still be found in ``Cython.Distutils.old_build_ext`` and is now deprecated. + +* ``directive_defaults`` is no longer available in ``Cython.Compiler.Options``, + use ``get_directive_defaults()`` instead. + + +0.24.1 (2016-07-15) +=================== + +Bugs fixed +---------- + +* IPython cell magic was lacking a good way to enable Python 3 code semantics. + It can now be used as "%%cython -3". + +* Follow a recent change in `PEP 492 <https://www.python.org/dev/peps/pep-0492/>`_ + and CPython 3.5.2 that now requires the ``__aiter__()`` method of asynchronous + iterators to be a simple ``def`` method instead of an ``async def`` method. + +* Coroutines and generators were lacking the ``__module__`` special attribute. + +* C++ ``std::complex`` values failed to auto-convert from and to Python complex + objects. + +* Namespaced C++ types could not be used as memory view types due to lack of + name mangling. Patch by Ivan Smirnov. + +* Assignments between identical C++ types that were declared with differently + typedefed template types could fail. + +* Rebuilds could fail to evaluate dependency timestamps in C++ mode. + Patch by Ian Henriksen. + +* Macros defined in the ``distutils`` compiler option do not require values + anymore. Patch by Ian Henriksen. + +* Minor fixes for MSVC, Cygwin and PyPy. + + +0.24 (2016-04-04) +================= + +Features added +-------------- + +* `PEP 498 <https://www.python.org/dev/peps/pep-0498/>`_: + Literal String Formatting (f-strings). + Original patch by Jelle Zijlstra. + +* `PEP 515 <https://www.python.org/dev/peps/pep-0515/>`_: + Underscores as visual separators in number literals. + +* Parser was adapted to some minor syntax changes in Py3.6, e.g. + https://bugs.python.org/issue9232 + +* The embedded C code comments that show the original source code + can be discarded with the new directive ``emit_code_comments=False``. + +* Cpdef enums are now first-class iterable, callable types in Python. + +* Ctuples can now be declared in pure Python code. + +* Posix declarations for DLL loading and stdio extensions were added. + Patch by Lars Buitinck. + +* The Py2-only builtins ``unicode()``, ``xrange()``, ``reduce()`` and + ``long`` are now also available in compile time ``DEF`` expressions + when compiling with Py3. + +* Exception type tests have slightly lower overhead. + This fixes ticket 868. + +* @property syntax fully supported in cdef classes, old syntax deprecated. + +* C++ classes can now be declared with default template parameters. + +Bugs fixed +---------- + +* C++ exceptions raised by overloaded C++ operators were not always + handled. Patch by Ian Henriksen. + +* C string literals were previously always stored as non-const global + variables in the module. They are now stored as global constants + when possible, and otherwise as non-const C string literals in the + generated code that uses them. This improves compatibility with + strict C compiler options and prevents non-const strings literals + with the same content from being incorrectly merged. + +* Compile time evaluated ``str`` expressions (``DEF``) now behave in a + more useful way by turning into Unicode strings when compiling under + Python 3. This allows using them as intermediate values in expressions. + Previously, they always evaluated to bytes objects. + +* ``isinf()`` declarations in ``libc/math.pxd`` and ``numpy/math.pxd`` now + reflect the actual tristate ``int`` return value instead of using ``bint``. + +* Literal assignments to ctuples avoid Python tuple round-trips in some + more corner cases. + +* Iteration over ``dict(...).items()`` failed to get optimised when dict + arguments included keyword arguments. + +* cProfile now correctly profiles cpdef functions and methods. + + +0.23.5 (2016-03-26) +=================== + +* Compile errors and warnings in integer type conversion code. This fixes + ticket 877. Patches by Christian Neukirchen, Nikolaus Rath, Ian Henriksen. + +* Reference leak when "*args" argument was reassigned in closures. + +* Truth-testing Unicode strings could waste time and memory in Py3.3+. + +* Return values of async functions could be ignored and replaced by ``None``. + +* Compiler crash in CPython 3.6. + +* Fix prange() to behave identically to range(). The end condition was + miscalculated when the range was not exactly divisible by the step. + +* Optimised ``all(genexpr)``/``any(genexpr)`` calls could warn about unused + code. This fixes ticket 876. + + +0.23.4 (2015-10-10) +=================== + +Bugs fixed +---------- + +* Memory leak when calling Python functions in PyPy. + +* Compilation problem with MSVC in C99-ish mode. + +* Warning about unused values in a helper macro. + + +0.23.3 (2015-09-29) +=================== + +Bugs fixed +---------- + +* Invalid C code for some builtin methods. This fixes ticket 856 again. + +* Incorrect C code in helper functions for PyLong conversion and string + decoding. This fixes ticket 863, ticket 864 and ticket 865. + Original patch by Nikolaus Rath. + +* Large folded or inserted integer constants could use too small C + integer types and thus trigger a value wrap-around. + +Other changes +------------- + +* The coroutine and generator types of Cython now also register directly + with the ``Coroutine`` and ``Generator`` ABCs in the ``backports_abc`` + module if it can be imported. This fixes ticket 870. + + +0.23.2 (2015-09-11) +=================== + +Bugs fixed +---------- + +* Compiler crash when analysing some optimised expressions. + +* Coverage plugin was adapted to coverage.py 4.0 beta 2. + +* C++ destructor calls could fail when '&' operator is overwritten. + +* Incorrect C literal generation for large integers in compile-time + evaluated DEF expressions and constant folded expressions. + +* Byte string constants could end up as Unicode strings when originating + from compile-time evaluated DEF expressions. + +* Invalid C code when caching known builtin methods. + This fixes ticket 860. + +* ``ino_t`` in ``posix.types`` was not declared as ``unsigned``. + +* Declarations in ``libcpp/memory.pxd`` were missing ``operator!()``. + Patch by Leo Razoumov. + +* Static cdef methods can now be declared in .pxd files. + + +0.23.1 (2015-08-22) +=================== + +Bugs fixed +---------- + +* Invalid C code for generators. This fixes ticket 858. + +* Invalid C code for some builtin methods. This fixes ticket 856. + +* Invalid C code for unused local buffer variables. + This fixes ticket 154. + +* Test failures on 32bit systems. This fixes ticket 857. + +* Code that uses ``from xyz import *`` and global C struct/union/array + variables could fail to compile due to missing helper functions. + This fixes ticket 851. + +* Misnamed PEP 492 coroutine property ``cr_yieldfrom`` renamed to + ``cr_await`` to match CPython. + +* Missing deallocation code for C++ object attributes in certain + extension class hierarchies. + +* Crash when async coroutine was not awaited. + +* Compiler crash on ``yield`` in signature annotations and default + argument values. Both are forbidden now. + +* Compiler crash on certain constructs in ``finally`` clauses. + +* Cython failed to build when CPython's pgen is installed. + + +0.23 (2015-08-08) +================= + +Features added +-------------- + +* `PEP 492 <https://www.python.org/dev/peps/pep-0492/>`_ + (async/await) was implemented. + +* `PEP 448 <https://www.python.org/dev/peps/pep-0448/>`_ + (Additional Unpacking Generalizations) was implemented. + +* Support for coverage.py 4.0+ can be enabled by adding the plugin + "Cython.Coverage" to the ".coveragerc" config file. + +* Annotated HTML source pages can integrate (XML) coverage reports. + +* Tracing is supported in ``nogil`` functions/sections and module init code. + +* When generators are used in a Cython module and the module imports the + modules "inspect" and/or "asyncio", Cython enables interoperability by + patching these modules during the import to recognise Cython's internal + generator and coroutine types. This can be disabled by C compiling the + module with "-D CYTHON_PATCH_ASYNCIO=0" or "-D CYTHON_PATCH_INSPECT=0" + +* When generators or coroutines are used in a Cython module, their types + are registered with the ``Generator`` and ``Coroutine`` ABCs in the + ``collections`` or ``collections.abc`` stdlib module at import time to + enable interoperability with code that needs to detect and process Python + generators/coroutines. These ABCs were added in CPython 3.5 and are + available for older Python versions through the ``backports_abc`` module + on PyPI. See https://bugs.python.org/issue24018 + +* Adding/subtracting/dividing/modulus and equality comparisons with + constant Python floats and small integers are faster. + +* Binary and/or/xor/rshift operations with small constant Python integers + are faster. + +* When called on generator expressions, the builtins ``all()``, ``any()``, + ``dict()``, ``list()``, ``set()``, ``sorted()`` and ``unicode.join()`` + avoid the generator iteration overhead by inlining a part of their + functionality into the for-loop. + +* Keyword argument dicts are no longer copied on function entry when they + are not being used or only passed through to other function calls (e.g. + in wrapper functions). + +* The ``PyTypeObject`` declaration in ``cpython.object`` was extended. + +* The builtin ``type`` type is now declared as PyTypeObject in source, + allowing for extern functions taking type parameters to have the correct + C signatures. Note that this might break code that uses ``type`` just + for passing around Python types in typed variables. Removing the type + declaration provides a backwards compatible fix. + +* ``wraparound()`` and ``boundscheck()`` are available as no-ops in pure + Python mode. + +* Const iterators were added to the provided C++ STL declarations. + +* Smart pointers were added to the provided C++ STL declarations. + Patch by Daniel Filonik. + +* ``NULL`` is allowed as default argument when embedding signatures. + This fixes ticket 843. + +* When compiling with ``--embed``, the internal module name is changed to + ``__main__`` to allow arbitrary program names, including those that would + be invalid for modules. Note that this prevents reuse of the generated + C code as an importable module. + +* External C++ classes that overload the assignment operator can be used. + Patch by Ian Henriksen. + +* Support operator bool() for C++ classes so they can be used in if statements. + +Bugs fixed +---------- + +* Calling "yield from" from Python on a Cython generator that returned a + value triggered a crash in CPython. This is now being worked around. + See https://bugs.python.org/issue23996 + +* Language level 3 did not enable true division (a.k.a. float division) + for integer operands. + +* Functions with fused argument types that included a generic 'object' + fallback could end up using that fallback also for other explicitly + listed object types. + +* Relative cimports could accidentally fall back to trying an absolute + cimport on failure. + +* The result of calling a C struct constructor no longer requires an + intermediate assignment when coercing to a Python dict. + +* C++ exception declarations with mapping functions could fail to compile + when pre-declared in .pxd files. + +* ``cpdef void`` methods are now permitted. + +* ``abs(cint)`` could fail to compile in MSVC and used sub-optimal code + in C++. Patch by David Vierra, original patch by Michael Enßlin. + +* Buffer index calculations using index variables with small C integer + types could overflow for large buffer sizes. + Original patch by David Vierra. + +* C unions use a saner way to coerce from and to Python dicts. + +* When compiling a module ``foo.pyx``, the directories in ``sys.path`` + are no longer searched when looking for ``foo.pxd``. + Patch by Jeroen Demeyer. + +* Memory leaks in the embedding main function were fixed. + Original patch by Michael Enßlin. + +* Some complex Python expressions could fail to compile inside of finally + clauses. + +* Unprefixed 'str' literals were not supported as C varargs arguments. + +* Fixed type errors in conversion enum types to/from Python. Note that + this imposes stricter correctness requirements on enum declarations. + + +Other changes +------------- + +* Changed mangling scheme in header files generated by ``cdef api`` + declarations. + +* Installation under CPython 3.3+ no longer requires a pass of the + 2to3 tool. This also makes it possible to run Cython in Python + 3.3+ from a source checkout without installing it first. + Patch by Petr Viktorin. + +* ``jedi-typer.py`` (in ``Tools/``) was extended and renamed to + ``jedityper.py`` (to make it importable) and now works with and + requires Jedi 0.9. Patch by Tzer-jen Wei. + + +0.22.1 (2015-06-20) +=================== + +Bugs fixed +---------- + +* Crash when returning values on generator termination. + +* In some cases, exceptions raised during internal isinstance() checks were + not propagated. + +* Runtime reported file paths of source files (e.g for profiling and tracing) + are now relative to the build root directory instead of the main source file. + +* Tracing exception handling code could enter the trace function with an active + exception set. + +* The internal generator function type was not shared across modules. + +* Comparisons of (inferred) ctuples failed to compile. + +* Closures inside of cdef functions returning ``void`` failed to compile. + +* Using ``const`` C++ references in intermediate parts of longer expressions + could fail to compile. + +* C++ exception declarations with mapping functions could fail to compile when + pre-declared in .pxd files. + +* C++ compilation could fail with an ambiguity error in recent MacOS-X Xcode + versions. + +* C compilation could fail in pypy3. + +* Fixed a memory leak in the compiler when compiling multiple modules. + +* When compiling multiple modules, external library dependencies could leak + into later compiler runs. Fix by Jeroen Demeyer. This fixes ticket 845. + + +0.22 (2015-02-11) +================= + +Features added +-------------- + +* C functions can coerce to Python functions, which allows passing them + around as callable objects. + +* C arrays can be assigned by value and auto-coerce from Python iterables + and to Python lists (and tuples). + +* Extern C functions can now be declared as cpdef to export them to + the module's Python namespace. Extern C functions in pxd files export + their values to their own module, iff it exists. + +* Anonymous C tuple types can be declared as (ctype1, ctype2, ...). + +* `PEP 479 <https://www.python.org/dev/peps/pep-0479/>`_: + turn accidental StopIteration exceptions that exit generators + into a RuntimeError, activated with future import "generator_stop". + +* Looping over ``reversed(range())`` is optimised in the same way as + ``range()``. Patch by Favian Contreras. + +Bugs fixed +---------- + +* Mismatching 'except' declarations on signatures in .pxd and .pyx files failed + to produce a compile error. + +* Failure to find any files for the path pattern(s) passed into ``cythonize()`` + is now an error to more easily detect accidental typos. + +* The ``logaddexp`` family of functions in ``numpy.math`` now has correct + declarations. + +* In Py2.6/7 and Py3.2, simple Cython memory views could accidentally be + interpreted as non-contiguous by CPython, which could trigger a CPython + bug when copying data from them, thus leading to data corruption. + See CPython issues 12834 and 23349. + +Other changes +------------- + +* Preliminary support for defining the Cython language with a formal grammar. + To try parsing your files against this grammar, use the --formal_grammar directive. + Experimental. + +* ``_`` is no longer considered a cacheable builtin as it could interfere with + gettext. + +* Cythonize-computed metadata now cached in the generated C files. + +* Several corrections and extensions in numpy, cpython, and libcpp pxd files. + + +0.21.2 (2014-12-27) +=================== + +Bugs fixed +---------- + +* Crash when assigning a C value to both a Python and C target at the same time. + +* Automatic coercion from C++ strings to ``str`` generated incomplete code that + failed to compile. + +* Declaring a constructor in a C++ child class erroneously required a default + constructor declaration in the super class. + +* ``resize_smart()`` in ``cpython.array`` was broken. + +* Functions in ``libcpp.cast`` are now declared as ``nogil``. + +* Some missing C-API declarations were added. + +* Py3 main code in embedding program code was lacking casts. + +* Exception related to distutils "Distribution" class type in pyximport under + latest CPython 2.7 and 3.4 releases when setuptools is being imported later. + + +0.21.1 (2014-10-18) +=================== + +Features added +-------------- + +* New ``cythonize`` option ``-a`` to generate the annotated HTML source view. + +* Missing C-API declarations in ``cpython.unicode`` were added. + +* Passing ``language='c++'`` into cythonize() globally enables C++ mode for + all modules that were not passed as Extension objects (i.e. only source + files and file patterns). + +* ``Py_hash_t`` is a known type (used in CPython for hash values). + +* ``PySlice_*()`` C-API functions are available from the ``cpython.slice`` + module. + +* Allow arrays of C++ classes. + +Bugs fixed +---------- + +* Reference leak for non-simple Python expressions in boolean and/or expressions. + +* To fix a name collision and to reflect availability on host platforms, + standard C declarations [ clock(), time(), struct tm and tm* functions ] + were moved from posix/time.pxd to a new libc/time.pxd. Patch by Charles + Blake. + +* Rerunning unmodified modules in IPython's cython support failed. + Patch by Matthias Bussonier. + +* Casting C++ ``std::string`` to Python byte strings failed when + auto-decoding was enabled. + +* Fatal exceptions in global module init code could lead to crashes + if the already created module was used later on (e.g. through a + stale reference in sys.modules or elsewhere). + +* ``cythonize.py`` script was not installed on MS-Windows. + +Other changes +------------- + +* Compilation no longer fails hard when unknown compilation options are + passed. Instead, it raises a warning and ignores them (as it did silently + before 0.21). This will be changed back to an error in a future release. + + +0.21 (2014-09-10) +================= + +Features added +-------------- + +* C (cdef) functions allow inner Python functions. + +* Enums can now be declared as cpdef to export their values to + the module's Python namespace. Cpdef enums in pxd files export + their values to their own module, iff it exists. + +* Allow @staticmethod decorator to declare static cdef methods. + This is especially useful for declaring "constructors" for + cdef classes that can take non-Python arguments. + +* Taking a ``char*`` from a temporary Python string object is safer + in more cases and can be done inside of non-trivial expressions, + including arguments of a function call. A compile time error + is raised only when such a pointer is assigned to a variable and + would thus exceed the lifetime of the string itself. + +* Generators have new properties ``__name__`` and ``__qualname__`` + that provide the plain/qualified name of the generator function + (following CPython 3.5). See http://bugs.python.org/issue21205 + +* The ``inline`` function modifier is available as a decorator + ``@cython.inline`` in pure mode. + +* When cygdb is run in a virtualenv, it enables the same virtualenv + inside of the debugger. Patch by Marc Abramowitz. + +* PEP 465: dedicated infix operator for matrix multiplication (A @ B). + +* HTML output of annotated code uses Pygments for code highlighting + and generally received a major overhaul by Matthias Bussonier. + +* IPython magic support is now available directly from Cython with + the command "%load_ext cython". Cython code can directly be + executed in a cell when marked with "%%cython". Code analysis + is available with "%%cython -a". Patch by Martín Gaitán. + +* Simple support for declaring Python object types in Python signature + annotations. Currently requires setting the compiler directive + ``annotation_typing=True``. + +* New directive ``use_switch`` (defaults to True) to optionally disable + the optimization of chained if statement to C switch statements. + +* Defines dynamic_cast et al. in ``libcpp.cast`` and C++ heap data + structure operations in ``libcpp.algorithm``. + +* Shipped header declarations in ``posix.*`` were extended to cover + more of the POSIX API. Patches by Lars Buitinck and Mark Peek. + +Optimizations +------------- + +* Simple calls to C implemented Python functions/methods are faster. + This also speeds up many operations on builtins that Cython cannot + otherwise optimise. + +* The "and"/"or" operators try to avoid unnecessary coercions of their + arguments. They now evaluate the truth value of each argument + independently and only coerce the final result of the whole expression + to the target type (e.g. the type on the left side of an assignment). + This also avoids reference counting overhead for Python values during + evaluation and generally improves the code flow in the generated C code. + +* The Python expression "2 ** N" is optimised into bit shifting. + See http://bugs.python.org/issue21420 + +* Cascaded assignments (a = b = ...) try to minimise the number of + type coercions. + +* Calls to ``slice()`` are translated to a straight C-API call. + +Bugs fixed +---------- + +* Crash when assigning memory views from ternary conditional expressions. + +* Nested C++ templates could lead to unseparated ">>" characters being + generated into the C++ declarations, which older C++ compilers could + not parse. + +* Sending SIGINT (Ctrl-C) during parallel cythonize() builds could + hang the child processes. + +* No longer ignore local setup.cfg files for distutils in pyximport. + Patch by Martin Teichmann. + +* Taking a ``char*`` from an indexed Python string generated unsafe + reference counting code. + +* Set literals now create all of their items before trying to add them + to the set, following the behaviour in CPython. This makes a + difference in the rare case that the item creation has side effects + and some items are not hashable (or if hashing them has side effects, + too). + +* Cython no longer generates the cross product of C functions for code + that uses memory views of fused types in function signatures (e.g. + ``cdef func(floating[:] a, floating[:] b)``). This is considered the + expected behaviour by most users and was previously inconsistent with + other structured types like C arrays. Code that really wants all type + combinations can create the same fused memoryview type under different + names and use those in the signature to make it clear which types are + independent. + +* Names that were unknown at compile time were looked up as builtins at + runtime but not as global module names. Trying both lookups helps with + globals() manipulation. + +* Fixed stl container conversion for typedef element types. + +* ``obj.pop(x)`` truncated large C integer values of x to ``Py_ssize_t``. + +* ``__init__.pyc`` is recognised as marking a package directory + (in addition to .py, .pyx and .pxd). + +* Syntax highlighting in ``cython-mode.el`` for Emacs no longer + incorrectly highlights keywords found as part of longer names. + +* Correctly handle ``from cython.submodule cimport name``. + +* Fix infinite recursion when using super with cpdef methods. + +* No-args ``dir()`` was not guaranteed to return a sorted list. + +Other changes +------------- + +* The header line in the generated C files no longer contains the + timestamp but only the Cython version that wrote it. This was + changed to make builds more reproducible. + +* Removed support for CPython 2.4, 2.5 and 3.1. + +* The licensing implications on the generated code were clarified + to avoid legal constraints for users. + + +0.20.2 (2014-06-16) +=================== + +Features added +-------------- + +* Some optimisations for set/frozenset instantiation. + +* Support for C++ unordered_set and unordered_map. + +Bugs fixed +---------- + +* Access to attributes of optimised builtin methods (e.g. + ``[].append.__name__``) could fail to compile. + +* Memory leak when extension subtypes add a memory view as attribute + to those of the parent type without having Python object attributes + or a user provided dealloc method. + +* Compiler crash on readonly properties in "binding" mode. + +* Auto-encoding with ``c_string_encoding=ascii`` failed in Py3.3. + +* Crash when subtyping freelist enabled Cython extension types with + Python classes that use ``__slots__``. + +* Freelist usage is restricted to CPython to avoid problems with other + Python implementations. + +* Memory leak in memory views when copying overlapping, contiguous slices. + +* Format checking when requesting non-contiguous buffers from + ``cython.array`` objects was accidentally omitted in Py3. + +* C++ destructor calls in extension types could fail to compile in clang. + +* Buffer format validation failed for sequences of strings in structs. + +* Docstrings on extension type attributes in .pxd files were rejected. + + +0.20.1 (2014-02-11) +=================== + +Bugs fixed +---------- + +* Build error under recent MacOS-X versions where ``isspace()`` could not be + resolved by clang. + +* List/Tuple literals multiplied by more than one factor were only multiplied + by the last factor instead of all. + +* Lookups of special methods (specifically for context managers) could fail + in Python <= 2.6/3.1. + +* Local variables were erroneously appended to the signature introspection + of Cython implemented functions with keyword-only arguments under Python 3. + +* In-place assignments to variables with inferred Python builtin/extension + types could fail with type errors if the result value type was incompatible + with the type of the previous value. + +* The C code generation order of cdef classes, closures, helper code, + etc. was not deterministic, thus leading to high code churn. + +* Type inference could fail to deduce C enum types. + +* Type inference could deduce unsafe or inefficient types from integer + assignments within a mix of inferred Python variables and integer + variables. + + +0.20 (2014-01-18) +================= + +Features added +-------------- + +* Support for CPython 3.4. + +* Support for calling C++ template functions. + +* ``yield`` is supported in ``finally`` clauses. + +* The C code generated for finally blocks is duplicated for each exit + case to allow for better optimisations by the C compiler. + +* Cython tries to undo the Python optimisationism of assigning a bound + method to a local variable when it can generate better code for the + direct call. + +* Constant Python float values are cached. + +* String equality comparisons can use faster type specific code in + more cases than before. + +* String/Unicode formatting using the '%' operator uses a faster + C-API call. + +* ``bytearray`` has become a known type and supports coercion from and + to C strings. Indexing, slicing and decoding is optimised. Note that + this may have an impact on existing code due to type inference. + +* Using ``cdef basestring stringvar`` and function arguments typed as + ``basestring`` is now meaningful and allows assigning exactly + ``str`` and ``unicode`` objects, but no subtypes of these types. + +* Support for the ``__debug__`` builtin. + +* Assertions in Cython compiled modules are disabled if the running + Python interpreter was started with the "-O" option. + +* Some types that Cython provides internally, such as functions and + generators, are now shared across modules if more than one Cython + implemented module is imported. + +* The type inference algorithm works more fine granular by taking the + results of the control flow analysis into account. + +* A new script in ``bin/cythonize`` provides a command line frontend + to the cythonize() compilation function (including distutils build). + +* The new extension type decorator ``@cython.no_gc_clear`` prevents + objects from being cleared during cyclic garbage collection, thus + making sure that object attributes are kept alive until deallocation. + +* During cyclic garbage collection, attributes of extension types that + cannot create reference cycles due to their type (e.g. strings) are + no longer considered for traversal or clearing. This can reduce the + processing overhead when searching for or cleaning up reference cycles. + +* Package compilation (i.e. ``__init__.py`` files) now works, starting + with Python 3.3. + +* The cython-mode.el script for Emacs was updated. Patch by Ivan Andrus. + +* An option common_utility_include_dir was added to cythonize() to save + oft-used utility code once in a separate directory rather than as + part of each generated file. + +* ``unraisable_tracebacks`` directive added to control printing of + tracebacks of unraisable exceptions. + +Bugs fixed +---------- + +* Abstract Python classes that subtyped a Cython extension type + failed to raise an exception on instantiation, and thus ended + up being instantiated. + +* ``set.add(a_tuple)`` and ``set.discard(a_tuple)`` failed with a + TypeError in Py2.4. + +* The PEP 3155 ``__qualname__`` was incorrect for nested classes and + inner classes/functions declared as ``global``. + +* Several corner cases in the try-finally statement were fixed. + +* The metaclass of a Python class was not inherited from its parent + class(es). It is now extracted from the list of base classes if not + provided explicitly using the Py3 ``metaclass`` keyword argument. + In Py2 compilation mode, a ``__metaclass__`` entry in the class + dict will still take precedence if not using Py3 metaclass syntax, + but only *after* creating the class dict (which may have been done + by a metaclass of a base class, see PEP 3115). It is generally + recommended to use the explicit Py3 syntax to define metaclasses + for Python types at compile time. + +* The automatic C switch statement generation behaves more safely for + heterogeneous value types (e.g. mixing enum and char), allowing for + a slightly wider application and reducing corner cases. It now always + generates a 'default' clause to avoid C compiler warnings about + unmatched enum values. + +* Fixed a bug where class hierarchies declared out-of-order could result + in broken generated code. + +* Fixed a bug which prevented overriding const methods of C++ classes. + +* Fixed a crash when converting Python objects to C++ strings fails. + +Other changes +------------- + +* In Py3 compilation mode, Python2-style metaclasses declared by a + ``__metaclass__`` class dict entry are ignored. + +* In Py3.4+, the Cython generator type uses ``tp_finalize()`` for safer + cleanup instead of ``tp_del()``. + + +0.19.2 (2013-10-13) +=================== + +Features added +-------------- + +Bugs fixed +---------- + +* Some standard declarations were fixed or updated, including the previously + incorrect declaration of ``PyBuffer_FillInfo()`` and some missing bits in + ``libc.math``. + +* Heap allocated subtypes of ``type`` used the wrong base type struct at the + C level. + +* Calling the unbound method dict.keys/value/items() in dict subtypes could + call the bound object method instead of the unbound supertype method. + +* "yield" wasn't supported in "return" value expressions. + +* Using the "bint" type in memory views lead to unexpected results. + It is now an error. + +* Assignments to global/closure variables could catch them in an illegal state + while deallocating the old value. + +Other changes +------------- + + +0.19.1 (2013-05-11) +=================== + +Features added +-------------- + +* Completely empty C-API structs for extension type slots (protocols like + number/mapping/sequence) are no longer generated into the C code. + +* Docstrings that directly follow a public/readonly attribute declaration + in a cdef class will be used as docstring of the auto-generated property. + This fixes ticket 206. + +* The automatic signature documentation tries to preserve more semantics + of default arguments and argument types. Specifically, ``bint`` arguments + now appear as type ``bool``. + +* A warning is emitted when negative literal indices are found inside of + a code section that disables ``wraparound`` handling. This helps with + fixing invalid code that might fail in the face of future compiler + optimisations. + +* Constant folding for boolean expressions (and/or) was improved. + +* Added a build_dir option to cythonize() which allows one to place + the generated .c files outside the source tree. + +Bugs fixed +---------- + +* ``isinstance(X, type)`` failed to get optimised into a call to + ``PyType_Check()``, as done for other builtin types. + +* A spurious ``from datetime cimport *`` was removed from the "cpython" + declaration package. This means that the "datetime" declarations + (added in 0.19) are no longer available directly from the "cpython" + namespace, but only from "cpython.datetime". This is the correct + way of doing it because the declarations refer to a standard library + module, not the core CPython C-API itself. + +* The C code for extension types is now generated in topological order + instead of source code order to avoid C compiler errors about missing + declarations for subtypes that are defined before their parent. + +* The ``memoryview`` type name no longer shows up in the module dict of + modules that use memory views. This fixes trac ticket 775. + +* Regression in 0.19 that rejected valid C expressions from being used + in C array size declarations. + +* In C++ mode, the C99-only keyword ``restrict`` could accidentally be + seen by the GNU C++ compiler. It is now specially handled for both + GCC and MSVC. + +* Testing large (> int) C integer values for their truth value could fail + due to integer wrap-around. + +Other changes +------------- + + +0.19 (2013-04-19) +================= + +Features added +-------------- + +* New directives ``c_string_type`` and ``c_string_encoding`` to more easily + and automatically convert between C strings and the different Python string + types. + +* The extension type flag ``Py_TPFLAGS_HAVE_VERSION_TAG`` is enabled by default + on extension types and can be disabled using the ``type_version_tag`` compiler + directive. + +* EXPERIMENTAL support for simple Cython code level line tracing. Enabled by + the "linetrace" compiler directive. + +* Cython implemented functions make their argument and return type annotations + available through the ``__annotations__`` attribute (PEP 3107). + +* Access to non-cdef module globals and Python object attributes is faster. + +* ``Py_UNICODE*`` coerces from and to Python unicode strings. This is + helpful when talking to Windows APIs, which use compatible wchar_t + arrays for strings. Note that the ``Py_UNICODE`` type is otherwise + deprecated as of CPython 3.3. + +* ``isinstance(obj, basestring)`` is optimised. In Python 3 it only tests + for instances of ``str`` (i.e. Py2 ``unicode``). + +* The ``basestring`` builtin is mapped to ``str`` (i.e. Py2 ``unicode``) when + compiling the generated C code under Python 3. + +* Closures use freelists, which can speed up their creation quite substantially. + This is also visible for short running generator expressions, for example. + +* A new class decorator ``@cython.freelist(N)`` creates a static freelist of N + instances for an extension type, thus avoiding the costly allocation step if + possible. This can speed up object instantiation by 20-30% in suitable + scenarios. Note that freelists are currently only supported for base types, + not for types that inherit from others. + +* Fast extension type instantiation using the ``Type.__new__(Type)`` idiom has + gained support for passing arguments. It is also a bit faster for types defined + inside of the module. + +* The Python2-only dict methods ``.iter*()`` and ``.view*()`` (requires Python 2.7) + are automatically mapped to the equivalent keys/values/items methods in Python 3 + for typed dictionaries. + +* Slicing unicode strings, lists and tuples is faster. + +* list.append() is faster on average. + +* ``raise Exception() from None`` suppresses the exception context in Py3.3. + +* Py3 compatible ``exec(tuple)`` syntax is supported in Py2 code. + +* Keyword arguments are supported for cdef functions. + +* External C++ classes can be declared nogil. Patch by John Stumpo. This fixes + trac ticket 805. + +Bugs fixed +---------- + +* 2-value slicing of unknown objects passes the correct slice when the ``getitem`` + protocol is used instead of the ``getslice`` protocol (especially in Python 3), + i.e. ``None`` values for missing bounds instead of ``[0,maxsize]``. It is also + a bit faster in some cases, e.g. for constant bounds. This fixes trac ticket 636. + +* Cascaded assignments of None values to extension type variables failed with + a ``TypeError`` at runtime. + +* The ``__defaults__`` attribute was not writable for Cython implemented + functions. + +* Default values of keyword-only arguments showed up in ``__defaults__`` instead + of ``__kwdefaults__`` (which was not implemented). Both are available for + Cython implemented functions now, as specified in Python 3.x. + +* ``yield`` works inside of ``with gil`` sections. It previously lead to a crash. + This fixes trac ticket 803. + +* Static methods without explicitly named positional arguments (e.g. having only + ``*args``) crashed when being called. This fixes trac ticket 804. + +* ``dir()`` without arguments previously returned an unsorted list, which now + gets sorted as expected. + +* ``dict.items()``, ``dict.keys()`` and ``dict.values()`` no longer return lists + in Python 3. + +* Exiting from an ``except-as`` clause now deletes the exception in Python 3 mode. + +* The declarations of ``frexp()`` and ``ldexp()`` in ``math.pxd`` were incorrect. + +Other changes +------------- + + +0.18 (2013-01-28) +================= + +Features added +-------------- + +* Named Unicode escapes ("\N{...}") are supported. + +* Python functions/classes provide the special attribute "__qualname__" + as defined by PEP 3155. + +* Added a directive ``overflowcheck`` which raises an OverflowException when + arithmetic with C ints overflow. This has a modest performance penalty, but + is much faster than using Python ints. + +* Calls to nested Python functions are resolved at compile time. + +* Type inference works across nested functions. + +* ``py_bytes_string.decode(...)`` is optimised. + +* C ``const`` declarations are supported in the language. + +Bugs fixed +---------- + +* Automatic C++ exception mapping didn't work in nogil functions (only in + "with nogil" blocks). + +Other changes +------------- + + +0.17.4 (2013-01-03) +=================== + +Bugs fixed +---------- + +* Garbage collection triggered during deallocation of container classes could lead to a double-deallocation. + + +0.17.3 (2012-12-14) +=================== + +Features added +-------------- + +Bugs fixed +---------- + +* During final interpreter cleanup (with types cleanup enabled at compile time), extension types that inherit from base types over more than one level that were cimported from other modules could lead to a crash. + +* Weak-reference support in extension types (with a ``cdef __weakref__`` attribute) generated incorrect deallocation code. + +* In CPython 3.3, converting a Unicode character to the Py_UNICODE type could fail to raise an overflow for non-BMP characters that do not fit into a wchar_t on the current platform. + +* Negative C integer constants lost their longness suffix in the generated C code. + +Other changes +------------- + + +0.17.2 (2012-11-20) +=================== + +Features added +-------------- + +* ``cythonize()`` gained a best effort compile mode that can be used to simply ignore .py files that fail to compile. + +Bugs fixed +---------- + +* Replacing an object reference with the value of one of its cdef attributes could generate incorrect C code that accessed the object after deleting its last reference. + +* C-to-Python type coercions during cascaded comparisons could generate invalid C code, specifically when using the 'in' operator. + +* "obj[1,]" passed a single integer into the item getter instead of a tuple. + +* Cyclic imports at module init time did not work in Py3. + +* The names of C++ destructors for template classes were built incorrectly. + +* In pure mode, type casts in Cython syntax and the C ampersand operator are now rejected. Use the pure mode replacements instead. + +* In pure mode, C type names and the sizeof() function are no longer recognised as such and can be used as normal Python names. + +* The extended C level support for the CPython array type was declared too late to be used by user defined classes. + +* C++ class nesting was broken. + +* Better checking for required nullary constructors for stack-allocated C++ instances. + +* Remove module docstring in no-docstring mode. + +* Fix specialization for varargs function signatures. + +* Fix several compiler crashes. + +Other changes +------------- + +* An experimental distutils script for compiling the CPython standard library was added as Tools/cystdlib.py. + + +0.17.1 (2012-09-26) +=================== + +Features added +-------------- + +Bugs fixed +---------- + +* A reference leak was fixed in the new dict iteration code when the loop target was not a plain variable but an unpacked tuple. + +* Memory views did not handle the special case of a NULL buffer strides value, as allowed by PEP3118. + +Other changes +------------- + + +0.17 (2012-09-01) +================= + +Features added +-------------- + +* Alpha quality support for compiling and running Cython generated extension modules in PyPy (through cpyext). Note that this requires at least PyPy 1.9 and in many cases also adaptations in user code, especially to avoid borrowed references when no owned reference is being held directly in C space (a reference in a Python list or dict is not enough, for example). See the documentation on porting Cython code to PyPy. + +* "yield from" is supported (PEP 380) and a couple of minor problems with generators were fixed. + +* C++ STL container classes automatically coerce from and to the equivalent Python container types on typed assignments and casts. Note that the data in the containers is copied during this conversion. + +* C++ iterators can now be iterated over using "for x in cpp_container" whenever cpp_container has begin() and end() methods returning objects satisfying the iterator pattern (that is, it can be incremented, dereferenced, and compared (for non-equality)). + +* cdef classes can now have C++ class members (provided a zero-argument constructor exists) + +* A new cpython.array standard cimport file allows to efficiently talk to the stdlib array.array data type in Python 2. Since CPython does not export an official C-API for this module, it receives special casing by the compiler in order to avoid setup overhead on user side. In Python 3, both buffers and memory views on the array type already worked out of the box with earlier versions of Cython due to the native support for the buffer interface in the Py3 array module. + +* Fast dict iteration is now enabled optimistically also for untyped variables when the common iteration methods are used. + +* The unicode string processing code was adapted for the upcoming CPython 3.3 (PEP 393, new Unicode buffer layout). + +* Buffer arguments and memory view arguments in Python functions can be declared "not None" to raise a TypeError on None input. + +* c(p)def functions in pure mode can specify their return type with "@cython.returns()". + +* Automatic dispatch for fused functions with memoryview arguments + +* Support newaxis indexing for memoryviews + +* Support decorators for fused functions + +Bugs fixed +---------- + +* Old-style Py2 imports did not work reliably in Python 3.x and were broken in Python 3.3. Regardless of this fix, it's generally best to be explicit about relative and global imports in Cython code because old-style imports have a higher overhead. To this end, "from __future__ import absolute_import" is supported in Python/Cython 2.x code now (previous versions of Cython already used it when compiling Python 3 code). + +* Stricter constraints on the "inline" and "final" modifiers. If your code does not compile due to this change, chances are these modifiers were previously being ignored by the compiler and can be removed without any performance regression. + +* Exceptions are always instantiated while raising them (as in Python), instead of risking to instantiate them in potentially unsafe situations when they need to be handled or otherwise processed. + +* locals() properly ignores names that do not have Python compatible types (including automatically inferred types). + +* Some garbage collection issues of memory views were fixed. + +* numpy.pxd compiles in Python 3 mode. + +* Several C compiler warnings were fixed. + +* Several bugs related to memoryviews and fused types were fixed. + +* Several bug-fixes and improvements related to cythonize(), including ccache-style caching. + +Other changes +------------- + +* libc.string provides a convenience declaration for const uchar in addition to const char. + +* User declared char* types are now recognised as such and auto-coerce to and from Python bytes strings. + +* callable() and next() compile to more efficient C code. + +* list.append() is faster on average. + +* Modules generated by @cython.inline() are written into the directory pointed to by the environment variable CYTHON_CACHE_DIR if set. + + +0.16 (2012-04-21) +================= + +Features added +-------------- + +* Enhancements to Cython's function type (support for weak references, default arguments, code objects, dynamic attributes, classmethods, staticmethods, and more) + +* Fused Types - Template-like support for functions and methods CEP 522 (docs) + +* Typed views on memory - Support for efficient direct and indirect buffers (indexing, slicing, transposing, ...) CEP 517 (docs) + +* super() without arguments + +* Final cdef methods (which translate into direct calls on known instances) + +Bugs fixed +---------- + +* fix alignment handling for record types in buffer support + +Other changes +------------- + +* support default arguments for closures + +* search sys.path for pxd files + +* support C++ template casting + +* faster traceback building and faster generator termination + +* support inplace operators on indexed buffers + +* allow nested prange sections + + +0.15.1 (2011-09-19) +=================== + +Features added +-------------- + +Bugs fixed +---------- + +Other changes +------------- + + +0.15 (2011-08-05) +================= + +Features added +-------------- + +* Generators (yield) - Cython has full support for generators, generator expressions and PEP 342 coroutines. + +* The nonlocal keyword is supported. + +* Re-acquiring the gil: with gil - works as expected within a nogil context. + +* OpenMP support: prange. + +* Control flow analysis prunes dead code and emits warnings and errors about uninitialised variables. + +* Debugger command cy set to assign values of expressions to Cython variables and cy exec counterpart $cy_eval(). + +* Exception chaining PEP 3134. + +* Relative imports PEP 328. + +* Improved pure syntax including cython.cclass, cython.cfunc, and cython.ccall. + +* The with statement has its own dedicated and faster C implementation. + +* Support for del. + +* Boundschecking directives implemented for builtin Python sequence types. + +* Several updates and additions to the shipped standard library .pxd files. + +* Forward declaration of types is no longer required for circular references. + +Bugs fixed +---------- + +Other changes +------------- + +* Uninitialized variables are no longer initialized to None and accessing them has the same semantics as standard Python. + +* globals() now returns a read-only dict of the Cython module's globals, rather than the globals of the first non-Cython module in the stack + +* Many C++ exceptions are now special cased to give closer Python counterparts. This means that except+ functions that formerly raised generic RuntimeErrors may raise something else such as ArithmeticError. + +* The inlined generator expressions (introduced in Cython 0.13) were disabled in favour of full generator expression support. This breaks code that previously used them inside of cdef functions (usage in def functions continues to work) and induces a performance regression for cases that continue to work but that were previously inlined. We hope to reinstate this feature in the near future. + + +0.14.1 (2011-02-04) +=================== + +Features added +-------------- + +* The gdb debugging support was extended to include all major Cython features, including closures. + +* raise MemoryError() is now safe to use as Cython replaces it with the correct C-API call. + +Bugs fixed +---------- + +Other changes +------------- + +* Decorators on special methods of cdef classes now raise a compile time error rather than being ignored. + +* In Python 3 language level mode (-3 option), the 'str' type is now mapped to 'unicode', so that cdef str s declares a Unicode string even when running in Python 2. + + +0.14 (2010-12-14) +================= + +Features added +-------------- + +* Python classes can now be nested and receive a proper closure at definition time. + +* Redefinition is supported for Python functions, even within the same scope. + +* Lambda expressions are supported in class bodies and at the module level. + +* Metaclasses are supported for Python classes, both in Python 2 and Python 3 syntax. The Python 3 syntax (using a keyword argument in the type declaration) is preferred and optimised at compile time. + +* "final" extension classes prevent inheritance in Python space. This feature is available through the new "cython.final" decorator. In the future, these classes may receive further optimisations. + +* "internal" extension classes do not show up in the module dictionary. This feature is available through the new "cython.internal" decorator. + +* Extension type inheritance from builtin types, such as "cdef class MyUnicode(unicode)", now works without further external type redeclarations (which are also strongly discouraged now and continue to issue a warning). + +* GDB support. http://docs.cython.org/src/userguide/debugging.html + +* A new build system with support for inline distutils directives, correct dependency tracking, and parallel compilation. https://github.com/cython/cython/wiki/enhancements-distutils_preprocessing + +* Support for dynamic compilation at runtime via the new cython.inline function and cython.compile decorator. https://github.com/cython/cython/wiki/enhancements-inline + +* "nogil" blocks are supported when compiling pure Python code by writing "with cython.nogil". + +* Iterating over arbitrary pointer types is now supported, as is an optimized version of the in operator, e.g. x in ptr[a:b]. + +Bugs fixed +---------- + +* In parallel assignments, the right side was evaluated in reverse order in 0.13. This could result in errors if it had side effects (e.g. function calls). + +* In some cases, methods of builtin types would raise a SystemError instead of an AttributeError when called on None. + +Other changes +------------- + +* Constant tuples are now cached over the lifetime of an extension module, just like CPython does. Constant argument tuples of Python function calls are also cached. + +* Closures have tightened to include exactly the names used in the inner functions and classes. Previously, they held the complete locals of the defining function. + +* The builtin "next()" function in Python 2.6 and later is now implemented internally and therefore available in all Python versions. This makes it the preferred and portable way of manually advancing an iterator. + +* In addition to the previously supported inlined generator expressions in 0.13, "sorted(genexpr)" can now be used as well. Typing issues were fixed in "sum(genexpr)" that could lead to invalid C code being generated. Other known issues with inlined generator expressions were also fixed that make upgrading to 0.14 a strong recommendation for code that uses them. Note that general generators and generator expressions continue to be not supported. + +* Inplace arithmetic operators now respect the cdivision directive and are supported for complex types. + +* Typing a variable as type "complex" previously gave it the Python object type. It now uses the appropriate C/C++ double complex type. A side-effect is that assignments and typed function parameters now accept anything that Python can coerce to a complex, including integers and floats, and not only complex instances. + +* Large integer literals pass through the compiler in a safer way. To prevent truncation in C code, non 32-bit literals are turned into Python objects if not used in a C context. This context can either be given by a clear C literal suffix such as "UL" or "LL" (or "L" in Python 3 code), or it can be an assignment to a typed variable or a typed function argument, in which case it is up to the user to take care of a sufficiently large value space of the target. + +* Python functions are declared in the order they appear in the file, rather than all being created at module creation time. This is consistent with Python and needed to support, for example, conditional or repeated declarations of functions. In the face of circular imports this may cause code to break, so a new --disable-function-redefinition flag was added to revert to the old behavior. This flag will be removed in a future release, so should only be used as a stopgap until old code can be fixed. + + +0.13 (2010-08-25) +================= + +Features added +-------------- + +* Closures are fully supported for Python functions. Cython supports inner functions and lambda expressions. Generators and generator expressions are not supported in this release. + +* Proper C++ support. Cython knows about C++ classes, templates and overloaded function signatures, so that Cython code can interact with them in a straight forward way. + +* Type inference is enabled by default for safe C types (e.g. double, bint, C++ classes) and known extension types. This reduces the need for explicit type declarations and can improve the performance of untyped code in some cases. There is also a verbose compile mode for testing the impact on user code. + +* Cython's for-in-loop can iterate over C arrays and sliced pointers. The type of the loop variable will be inferred automatically in this case. + +* The Py_UNICODE integer type for Unicode code points is fully supported, including for-loops and 'in' tests on unicode strings. It coerces from and to single character unicode strings. Note that untyped for-loop variables will automatically be inferred as Py_UNICODE when iterating over a unicode string. In most cases, this will be much more efficient than yielding sliced string objects, but can also have a negative performance impact when the variable is used in a Python context multiple times, so that it needs to coerce to a unicode string object more than once. If this happens, typing the loop variable as unicode or object will help. + +* The built-in functions any(), all(), sum(), list(), set() and dict() are inlined as plain for loops when called on generator expressions. Note that generator expressions are not generally supported apart from this feature. Also, tuple(genexpr) is not currently supported - use tuple([listcomp]) instead. + +* More shipped standard library declarations. The python_* and stdlib/stdio .pxd files have been deprecated in favor of clib.* and cpython[.*] and may get removed in a future release. + +* Pure Python mode no longer disallows non-Python keywords like 'cdef', 'include' or 'cimport'. It also no longer recognises syntax extensions like the for-from loop. + +* Parsing has improved for Python 3 syntax in Python code, although not all features are correctly supported. The missing Python 3 features are being worked on for the next release. + +* from __future__ import print_function is supported in Python 2.6 and later. Note that there is currently no emulation for earlier Python versions, so code that uses print() with this future import will require at least Python 2.6. + +* New compiler directive language_level (valid values: 2 or 3) with corresponding command line options -2 and -3 requests source code compatibility with Python 2.x or Python 3.x respectively. Language level 3 currently enforces unicode literals for unprefixed string literals, enables the print function (requires Python 2.6 or later) and keeps loop variables in list comprehensions from leaking. + +* Loop variables in set/dict comprehensions no longer leak into the surrounding scope (following Python 2.7). List comprehensions are unchanged in language level 2. + +* print >> stream + +Bugs fixed +---------- + +Other changes +------------- + +* The availability of type inference by default means that Cython will also infer the type of pointers on assignments. Previously, code like this:: + + cdef char* s = ... + untyped_variable = s + + would convert the char* to a Python bytes string and assign that. This is no longer the case and no coercion will happen in the example above. The correct way of doing this is through an explicit cast or by typing the target variable, i.e. + + :: + + cdef char* s = ... + untyped_variable1 = <bytes>s + untyped_variable2 = <object>s + + cdef object py_object = s + cdef bytes bytes_string = s + +* bool is no longer a valid type name by default. The problem is that it's not clear whether bool should refer to the Python type or the C++ type, and expecting one and finding the other has already led to several hard-to-find bugs. Both types are available for importing: you can use from cpython cimport bool for the Python bool type, and from libcpp cimport bool for the C++ type. bool is still a valid object by default, so one can still write bool(x). + +* ``__getsegcount__`` is now correctly typed to take a ``Py_size_t*`` rather than an ``int*``. + + +0.12.1 (2010-02-02) +=================== + +Features added +-------------- + +* Type inference improvements. + + * There have been several bug fixes and improvements to the type inferencer. + + * Notably, there is now a "safe" mode enabled by setting the infer_types directive to None. (The None here refers to the "default" mode, which will be the default in 0.13.) This safe mode limits inference to Python object types and C doubles, which should speed up execution without affecting any semantics such as integer overflow behavior like infer_types=True might. There is also an infer_types.verbose option which allows one to see what types are inferred. + +* The boundscheck directive works for lists and tuples as well as buffers. + +* len(s) and s.decode("encoding") are efficiently supported for char* s. + +* Cython's INLINE macro has been renamed to CYTHON_INLINE to reduce conflict and has better support for the MSVC compiler on Windows. It is no longer clobbered if externally defined. + +* Revision history is now omitted from the source package, resulting in a 85% size reduction. Running make repo will download the history and turn the directory into a complete Mercurial working repository. + +* Cython modules don't need to be recompiled when the size of an external type grows. (A warning, rather than an error, is produced.) This should be helpful for binary distributions relying on NumPy. + +Bugs fixed +---------- + +* Several other bugs and minor improvements have been made. This release should be fully backwards compatible with 0.12. + +Other changes +------------- + + +0.12 (2009-11-23) +================= + +Features added +-------------- + +* Type inference with the infer_types directive + +* Seamless C++ complex support + +* Fast extension type instantiation using the normal Python meme obj = MyType.__new__(MyType) + +* Improved support for Py3.1 + +* Cython now runs under Python 3.x using the 2to3 tool + +* unittest support for doctests in Cython modules + +* Optimised handling of C strings (char*): for c in cstring[2:50] and cstring.decode() + +* Looping over c pointers: for i in intptr[:50]. + +* pyximport improvements + +* cython_freeze improvements + +Bugs fixed +---------- + +* Many bug fixes + +Other changes +------------- + +* Many other optimisation, e.g. enumerate() loops, parallel swap assignments (a,b = b,a), and unicode.encode() + +* More complete numpy.pxd + + +0.11.2 (2009-05-20) +=================== + +Features added +-------------- + +* There's now native complex floating point support! C99 complex will be used if complex.h is included, otherwise explicit complex arithmetic working on all C compilers is used. [Robert Bradshaw] + + :: + + cdef double complex a = 1 + 0.3j + cdef np.ndarray[np.complex128_t, ndim=2] arr = \ + np.zeros(10, np.complex128) + +* Cython can now generate a main()-method for embedding of the Python interpreter into an executable (see #289) [Robert Bradshaw] + +* @wraparound directive (another way to disable arr[idx] for negative idx) [Dag Sverre Seljebotn] + +* Correct support for NumPy record dtypes with different alignments, and "cdef packed struct" support [Dag Sverre Seljebotn] + +* @callspec directive, allowing custom calling convention macros [Lisandro Dalcin] + +Bugs fixed +---------- + +Other changes +------------- + +* Bug fixes and smaller improvements. For the full list, see [1]. diff --git a/contrib/tools/cython/COPYING.txt b/contrib/tools/cython/COPYING.txt new file mode 100644 index 00000000000..1a05a211a01 --- /dev/null +++ b/contrib/tools/cython/COPYING.txt @@ -0,0 +1,19 @@ +The original Pyrex code as of 2006-04 is licensed under the following +license: "Copyright stuff: Pyrex is free of restrictions. You may use, +redistribute, modify and distribute modified versions." + +------------------ + +Cython, which derives from Pyrex, is licensed under the Apache 2.0 +Software License. More precisely, all modifications and new code +made to go from Pyrex to Cython are so licensed. + +See LICENSE.txt for more details. + +------------------ + +The output of a Cython compilation is NOT considered a derivative +work of Cython. Specifically, though the compilation process may +embed snippets of varying lengths into the final output, these +snippets, as embedded in the output, do not encumber the resulting +output with any license restrictions. diff --git a/contrib/tools/cython/Cython/.yandex_meta/licenses.list.txt b/contrib/tools/cython/Cython/.yandex_meta/licenses.list.txt new file mode 100644 index 00000000000..9f94ca7e8ef --- /dev/null +++ b/contrib/tools/cython/Cython/.yandex_meta/licenses.list.txt @@ -0,0 +1,6 @@ +====================COPYRIGHT==================== +# Copyright (C) 2010-2011, IPython Development Team. + + +====================Public-Domain==================== +// Written by Rusty Russell, public domain, http://ccodearchive.net/ diff --git a/contrib/tools/cython/Cython/Build/BuildExecutable.py b/contrib/tools/cython/Cython/Build/BuildExecutable.py new file mode 100644 index 00000000000..2db9e5d7457 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/BuildExecutable.py @@ -0,0 +1,142 @@ +""" +Compile a Python script into an executable that embeds CPython and run it. +Requires CPython to be built as a shared library ('libpythonX.Y'). + +Basic usage: + + python cythonrun somefile.py [ARGS] +""" + +from __future__ import absolute_import + +DEBUG = True + +import sys +import os +from distutils import sysconfig + + +def get_config_var(name, default=''): + return sysconfig.get_config_var(name) or default + +INCDIR = sysconfig.get_python_inc() +LIBDIR1 = get_config_var('LIBDIR') +LIBDIR2 = get_config_var('LIBPL') +PYLIB = get_config_var('LIBRARY') +PYLIB_DYN = get_config_var('LDLIBRARY') +if PYLIB_DYN == PYLIB: + # no shared library + PYLIB_DYN = '' +else: + PYLIB_DYN = os.path.splitext(PYLIB_DYN[3:])[0] # 'lib(XYZ).so' -> XYZ + +CC = get_config_var('CC', os.environ.get('CC', '')) +CFLAGS = get_config_var('CFLAGS') + ' ' + os.environ.get('CFLAGS', '') +LINKCC = get_config_var('LINKCC', os.environ.get('LINKCC', CC)) +LINKFORSHARED = get_config_var('LINKFORSHARED') +LIBS = get_config_var('LIBS') +SYSLIBS = get_config_var('SYSLIBS') +EXE_EXT = sysconfig.get_config_var('EXE') + +def _debug(msg, *args): + if DEBUG: + if args: + msg = msg % args + sys.stderr.write(msg + '\n') + +def dump_config(): + _debug('INCDIR: %s', INCDIR) + _debug('LIBDIR1: %s', LIBDIR1) + _debug('LIBDIR2: %s', LIBDIR2) + _debug('PYLIB: %s', PYLIB) + _debug('PYLIB_DYN: %s', PYLIB_DYN) + _debug('CC: %s', CC) + _debug('CFLAGS: %s', CFLAGS) + _debug('LINKCC: %s', LINKCC) + _debug('LINKFORSHARED: %s', LINKFORSHARED) + _debug('LIBS: %s', LIBS) + _debug('SYSLIBS: %s', SYSLIBS) + _debug('EXE_EXT: %s', EXE_EXT) + +def runcmd(cmd, shell=True): + if shell: + cmd = ' '.join(cmd) + _debug(cmd) + else: + _debug(' '.join(cmd)) + + try: + import subprocess + except ImportError: # Python 2.3 ... + returncode = os.system(cmd) + else: + returncode = subprocess.call(cmd, shell=shell) + + if returncode: + sys.exit(returncode) + +def clink(basename): + runcmd([LINKCC, '-o', basename + EXE_EXT, basename+'.o', '-L'+LIBDIR1, '-L'+LIBDIR2] + + [PYLIB_DYN and ('-l'+PYLIB_DYN) or os.path.join(LIBDIR1, PYLIB)] + + LIBS.split() + SYSLIBS.split() + LINKFORSHARED.split()) + +def ccompile(basename): + runcmd([CC, '-c', '-o', basename+'.o', basename+'.c', '-I' + INCDIR] + CFLAGS.split()) + +def cycompile(input_file, options=()): + from ..Compiler import Version, CmdLine, Main + options, sources = CmdLine.parse_command_line(list(options or ()) + ['--embed', input_file]) + _debug('Using Cython %s to compile %s', Version.version, input_file) + result = Main.compile(sources, options) + if result.num_errors > 0: + sys.exit(1) + +def exec_file(program_name, args=()): + runcmd([os.path.abspath(program_name)] + list(args), shell=False) + +def build(input_file, compiler_args=(), force=False): + """ + Build an executable program from a Cython module. + + Returns the name of the executable file. + """ + basename = os.path.splitext(input_file)[0] + exe_file = basename + EXE_EXT + if not force and os.path.abspath(exe_file) == os.path.abspath(input_file): + raise ValueError("Input and output file names are the same, refusing to overwrite") + if (not force and os.path.exists(exe_file) and os.path.exists(input_file) + and os.path.getmtime(input_file) <= os.path.getmtime(exe_file)): + _debug("File is up to date, not regenerating %s", exe_file) + return exe_file + cycompile(input_file, compiler_args) + ccompile(basename) + clink(basename) + return exe_file + +def build_and_run(args): + """ + Build an executable program from a Cython module and runs it. + + Arguments after the module name will be passed verbatimely to the + program. + """ + cy_args = [] + last_arg = None + for i, arg in enumerate(args): + if arg.startswith('-'): + cy_args.append(arg) + elif last_arg in ('-X', '--directive'): + cy_args.append(arg) + else: + input_file = arg + args = args[i+1:] + break + last_arg = arg + else: + raise ValueError('no input file provided') + + program_name = build(input_file, cy_args) + exec_file(program_name, args) + +if __name__ == '__main__': + build_and_run(sys.argv[1:]) diff --git a/contrib/tools/cython/Cython/Build/Cythonize.py b/contrib/tools/cython/Cython/Build/Cythonize.py new file mode 100644 index 00000000000..c85b6eabab2 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Cythonize.py @@ -0,0 +1,229 @@ +#!/usr/bin/env python + +from __future__ import absolute_import + +import os +import shutil +import tempfile +from distutils.core import setup + +from .Dependencies import cythonize, extended_iglob +from ..Utils import is_package_dir +from ..Compiler import Options + +try: + import multiprocessing + parallel_compiles = int(multiprocessing.cpu_count() * 1.5) +except ImportError: + multiprocessing = None + parallel_compiles = 0 + + +class _FakePool(object): + def map_async(self, func, args): + try: + from itertools import imap + except ImportError: + imap=map + for _ in imap(func, args): + pass + + def close(self): + pass + + def terminate(self): + pass + + def join(self): + pass + + +def parse_directives(option, name, value, parser): + dest = option.dest + old_directives = dict(getattr(parser.values, dest, + Options.get_directive_defaults())) + directives = Options.parse_directive_list( + value, relaxed_bool=True, current_settings=old_directives) + setattr(parser.values, dest, directives) + + +def parse_options(option, name, value, parser): + dest = option.dest + options = dict(getattr(parser.values, dest, {})) + for opt in value.split(','): + if '=' in opt: + n, v = opt.split('=', 1) + v = v.lower() not in ('false', 'f', '0', 'no') + else: + n, v = opt, True + options[n] = v + setattr(parser.values, dest, options) + + +def parse_compile_time_env(option, name, value, parser): + dest = option.dest + old_env = dict(getattr(parser.values, dest, {})) + new_env = Options.parse_compile_time_env(value, current_settings=old_env) + setattr(parser.values, dest, new_env) + + +def find_package_base(path): + base_dir, package_path = os.path.split(path) + while os.path.isfile(os.path.join(base_dir, '__init__.py')): + base_dir, parent = os.path.split(base_dir) + package_path = '%s/%s' % (parent, package_path) + return base_dir, package_path + + +def cython_compile(path_pattern, options): + pool = None + all_paths = map(os.path.abspath, extended_iglob(path_pattern)) + try: + for path in all_paths: + if options.build_inplace: + base_dir = path + while not os.path.isdir(base_dir) or is_package_dir(base_dir): + base_dir = os.path.dirname(base_dir) + else: + base_dir = None + + if os.path.isdir(path): + # recursively compiling a package + paths = [os.path.join(path, '**', '*.{py,pyx}')] + else: + # assume it's a file(-like thing) + paths = [path] + + ext_modules = cythonize( + paths, + nthreads=options.parallel, + exclude_failures=options.keep_going, + exclude=options.excludes, + compiler_directives=options.directives, + compile_time_env=options.compile_time_env, + force=options.force, + quiet=options.quiet, + depfile=options.depfile, + **options.options) + + if ext_modules and options.build: + if len(ext_modules) > 1 and options.parallel > 1: + if pool is None: + try: + pool = multiprocessing.Pool(options.parallel) + except OSError: + pool = _FakePool() + pool.map_async(run_distutils, [ + (base_dir, [ext]) for ext in ext_modules]) + else: + run_distutils((base_dir, ext_modules)) + except: + if pool is not None: + pool.terminate() + raise + else: + if pool is not None: + pool.close() + pool.join() + + +def run_distutils(args): + base_dir, ext_modules = args + script_args = ['build_ext', '-i'] + cwd = os.getcwd() + temp_dir = None + try: + if base_dir: + os.chdir(base_dir) + temp_dir = tempfile.mkdtemp(dir=base_dir) + script_args.extend(['--build-temp', temp_dir]) + setup( + script_name='setup.py', + script_args=script_args, + ext_modules=ext_modules, + ) + finally: + if base_dir: + os.chdir(cwd) + if temp_dir and os.path.isdir(temp_dir): + shutil.rmtree(temp_dir) + + +def parse_args(args): + from optparse import OptionParser + parser = OptionParser(usage='%prog [options] [sources and packages]+') + + parser.add_option('-X', '--directive', metavar='NAME=VALUE,...', + dest='directives', default={}, type="str", + action='callback', callback=parse_directives, + help='set a compiler directive') + parser.add_option('-E', '--compile-time-env', metavar='NAME=VALUE,...', + dest='compile_time_env', default={}, type="str", + action='callback', callback=parse_compile_time_env, + help='set a compile time environment variable') + parser.add_option('-s', '--option', metavar='NAME=VALUE', + dest='options', default={}, type="str", + action='callback', callback=parse_options, + help='set a cythonize option') + parser.add_option('-2', dest='language_level', action='store_const', const=2, default=None, + help='use Python 2 syntax mode by default') + parser.add_option('-3', dest='language_level', action='store_const', const=3, + help='use Python 3 syntax mode by default') + parser.add_option('--3str', dest='language_level', action='store_const', const='3str', + help='use Python 3 syntax mode by default') + parser.add_option('-a', '--annotate', dest='annotate', action='store_true', + help='generate annotated HTML page for source files') + + parser.add_option('-x', '--exclude', metavar='PATTERN', dest='excludes', + action='append', default=[], + help='exclude certain file patterns from the compilation') + + parser.add_option('-b', '--build', dest='build', action='store_true', + help='build extension modules using distutils') + parser.add_option('-i', '--inplace', dest='build_inplace', action='store_true', + help='build extension modules in place using distutils (implies -b)') + parser.add_option('-j', '--parallel', dest='parallel', metavar='N', + type=int, default=parallel_compiles, + help=('run builds in N parallel jobs (default: %d)' % + parallel_compiles or 1)) + parser.add_option('-f', '--force', dest='force', action='store_true', + help='force recompilation') + parser.add_option('-q', '--quiet', dest='quiet', action='store_true', + help='be less verbose during compilation') + + parser.add_option('--lenient', dest='lenient', action='store_true', + help='increase Python compatibility by ignoring some compile time errors') + parser.add_option('-k', '--keep-going', dest='keep_going', action='store_true', + help='compile as much as possible, ignore compilation failures') + parser.add_option('-M', '--depfile', action='store_true', help='produce depfiles for the sources') + + options, args = parser.parse_args(args) + if not args: + parser.error("no source files provided") + if options.build_inplace: + options.build = True + if multiprocessing is None: + options.parallel = 0 + if options.language_level: + assert options.language_level in (2, 3, '3str') + options.options['language_level'] = options.language_level + return options, args + + +def main(args=None): + options, paths = parse_args(args) + + if options.lenient: + # increase Python compatibility by ignoring compile time errors + Options.error_on_unknown_names = False + Options.error_on_uninitialized = False + + if options.annotate: + Options.annotate = True + + for path in paths: + cython_compile(path, options) + + +if __name__ == '__main__': + main() diff --git a/contrib/tools/cython/Cython/Build/Dependencies.py b/contrib/tools/cython/Cython/Build/Dependencies.py new file mode 100644 index 00000000000..28c48ed8c3b --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Dependencies.py @@ -0,0 +1,1296 @@ +from __future__ import absolute_import, print_function + +import cython +from .. import __version__ + +import collections +import contextlib +import hashlib +import os +import shutil +import subprocess +import re, sys, time +import warnings +from glob import iglob +from io import open as io_open +from os.path import relpath as _relpath +from distutils.extension import Extension +from distutils.util import strtobool +import zipfile + +try: + from collections.abc import Iterable +except ImportError: + from collections import Iterable + +try: + import gzip + gzip_open = gzip.open + gzip_ext = '.gz' +except ImportError: + gzip_open = open + gzip_ext = '' + +try: + import zlib + zipfile_compression_mode = zipfile.ZIP_DEFLATED +except ImportError: + zipfile_compression_mode = zipfile.ZIP_STORED + +try: + import pythran +except: + pythran = None + +from .. import Utils +from ..Utils import (cached_function, cached_method, path_exists, write_depfile, + safe_makedirs, copy_file_to_dir_if_newer, is_package_dir, replace_suffix) +from ..Compiler.Main import Context, CompilationOptions, default_options + +join_path = cached_function(os.path.join) +copy_once_if_newer = cached_function(copy_file_to_dir_if_newer) +safe_makedirs_once = cached_function(safe_makedirs) + +if sys.version_info[0] < 3: + # stupid Py2 distutils enforces str type in list of sources + _fs_encoding = sys.getfilesystemencoding() + if _fs_encoding is None: + _fs_encoding = sys.getdefaultencoding() + def encode_filename_in_py2(filename): + if not isinstance(filename, bytes): + return filename.encode(_fs_encoding) + return filename +else: + def encode_filename_in_py2(filename): + return filename + basestring = str + + +def _make_relative(file_paths, base=None): + if not base: + base = os.getcwd() + if base[-1] != os.path.sep: + base += os.path.sep + return [_relpath(path, base) if path.startswith(base) else path + for path in file_paths] + + +def extended_iglob(pattern): + if '{' in pattern: + m = re.match('(.*){([^}]+)}(.*)', pattern) + if m: + before, switch, after = m.groups() + for case in switch.split(','): + for path in extended_iglob(before + case + after): + yield path + return + if '**/' in pattern: + seen = set() + first, rest = pattern.split('**/', 1) + if first: + first = iglob(first+'/') + else: + first = [''] + for root in first: + for path in extended_iglob(join_path(root, rest)): + if path not in seen: + seen.add(path) + yield path + for path in extended_iglob(join_path(root, '*', '**/' + rest)): + if path not in seen: + seen.add(path) + yield path + else: + for path in iglob(pattern): + yield path + + +def nonempty(it, error_msg="expected non-empty iterator"): + empty = True + for value in it: + empty = False + yield value + if empty: + raise ValueError(error_msg) + + +@cached_function +def file_hash(filename): + path = os.path.normpath(filename) + prefix = ('%d:%s' % (len(path), path)).encode("UTF-8") + m = hashlib.md5(prefix) + with open(path, 'rb') as f: + data = f.read(65000) + while data: + m.update(data) + data = f.read(65000) + return m.hexdigest() + + +def update_pythran_extension(ext): + if pythran is None: + raise RuntimeError("You first need to install Pythran to use the np_pythran directive.") + try: + pythran_ext = pythran.config.make_extension(python=True) + except TypeError: # older pythran version only + pythran_ext = pythran.config.make_extension() + + ext.include_dirs.extend(pythran_ext['include_dirs']) + ext.extra_compile_args.extend(pythran_ext['extra_compile_args']) + ext.extra_link_args.extend(pythran_ext['extra_link_args']) + ext.define_macros.extend(pythran_ext['define_macros']) + ext.undef_macros.extend(pythran_ext['undef_macros']) + ext.library_dirs.extend(pythran_ext['library_dirs']) + ext.libraries.extend(pythran_ext['libraries']) + ext.language = 'c++' + + # These options are not compatible with the way normal Cython extensions work + for bad_option in ["-fwhole-program", "-fvisibility=hidden"]: + try: + ext.extra_compile_args.remove(bad_option) + except ValueError: + pass + + +def parse_list(s): + """ + >>> parse_list("") + [] + >>> parse_list("a") + ['a'] + >>> parse_list("a b c") + ['a', 'b', 'c'] + >>> parse_list("[a, b, c]") + ['a', 'b', 'c'] + >>> parse_list('a " " b') + ['a', ' ', 'b'] + >>> parse_list('[a, ",a", "a,", ",", ]') + ['a', ',a', 'a,', ','] + """ + if len(s) >= 2 and s[0] == '[' and s[-1] == ']': + s = s[1:-1] + delimiter = ',' + else: + delimiter = ' ' + s, literals = strip_string_literals(s) + def unquote(literal): + literal = literal.strip() + if literal[0] in "'\"": + return literals[literal[1:-1]] + else: + return literal + return [unquote(item) for item in s.split(delimiter) if item.strip()] + + +transitive_str = object() +transitive_list = object() +bool_or = object() + +distutils_settings = { + 'name': str, + 'sources': list, + 'define_macros': list, + 'undef_macros': list, + 'libraries': transitive_list, + 'library_dirs': transitive_list, + 'runtime_library_dirs': transitive_list, + 'include_dirs': transitive_list, + 'extra_objects': list, + 'extra_compile_args': transitive_list, + 'extra_link_args': transitive_list, + 'export_symbols': list, + 'depends': transitive_list, + 'language': transitive_str, + 'np_pythran': bool_or +} + + +@cython.locals(start=cython.Py_ssize_t, end=cython.Py_ssize_t) +def line_iter(source): + if isinstance(source, basestring): + start = 0 + while True: + end = source.find('\n', start) + if end == -1: + yield source[start:] + return + yield source[start:end] + start = end+1 + else: + for line in source: + yield line + + +class DistutilsInfo(object): + + def __init__(self, source=None, exn=None): + self.values = {} + if source is not None: + for line in line_iter(source): + line = line.lstrip() + if not line: + continue + if line[0] != '#': + break + line = line[1:].lstrip() + kind = next((k for k in ("distutils:","cython:") if line.startswith(k)), None) + if kind is not None: + key, _, value = [s.strip() for s in line[len(kind):].partition('=')] + type = distutils_settings.get(key, None) + if line.startswith("cython:") and type is None: continue + if type in (list, transitive_list): + value = parse_list(value) + if key == 'define_macros': + value = [tuple(macro.split('=', 1)) + if '=' in macro else (macro, None) + for macro in value] + if type is bool_or: + value = strtobool(value) + self.values[key] = value + elif exn is not None: + for key in distutils_settings: + if key in ('name', 'sources','np_pythran'): + continue + value = getattr(exn, key, None) + if value: + self.values[key] = value + + def merge(self, other): + if other is None: + return self + for key, value in other.values.items(): + type = distutils_settings[key] + if type is transitive_str and key not in self.values: + self.values[key] = value + elif type is transitive_list: + if key in self.values: + # Change a *copy* of the list (Trac #845) + all = self.values[key][:] + for v in value: + if v not in all: + all.append(v) + value = all + self.values[key] = value + elif type is bool_or: + self.values[key] = self.values.get(key, False) | value + return self + + def subs(self, aliases): + if aliases is None: + return self + resolved = DistutilsInfo() + for key, value in self.values.items(): + type = distutils_settings[key] + if type in [list, transitive_list]: + new_value_list = [] + for v in value: + if v in aliases: + v = aliases[v] + if isinstance(v, list): + new_value_list += v + else: + new_value_list.append(v) + value = new_value_list + else: + if value in aliases: + value = aliases[value] + resolved.values[key] = value + return resolved + + def apply(self, extension): + for key, value in self.values.items(): + type = distutils_settings[key] + if type in [list, transitive_list]: + value = getattr(extension, key) + list(value) + setattr(extension, key, value) + + +@cython.locals(start=cython.Py_ssize_t, q=cython.Py_ssize_t, + single_q=cython.Py_ssize_t, double_q=cython.Py_ssize_t, + hash_mark=cython.Py_ssize_t, end=cython.Py_ssize_t, + k=cython.Py_ssize_t, counter=cython.Py_ssize_t, quote_len=cython.Py_ssize_t) +def strip_string_literals(code, prefix='__Pyx_L'): + """ + Normalizes every string literal to be of the form '__Pyx_Lxxx', + returning the normalized code and a mapping of labels to + string literals. + """ + new_code = [] + literals = {} + counter = 0 + start = q = 0 + in_quote = False + hash_mark = single_q = double_q = -1 + code_len = len(code) + quote_type = None + quote_len = -1 + + while True: + if hash_mark < q: + hash_mark = code.find('#', q) + if single_q < q: + single_q = code.find("'", q) + if double_q < q: + double_q = code.find('"', q) + q = min(single_q, double_q) + if q == -1: + q = max(single_q, double_q) + + # We're done. + if q == -1 and hash_mark == -1: + new_code.append(code[start:]) + break + + # Try to close the quote. + elif in_quote: + if code[q-1] == u'\\': + k = 2 + while q >= k and code[q-k] == u'\\': + k += 1 + if k % 2 == 0: + q += 1 + continue + if code[q] == quote_type and ( + quote_len == 1 or (code_len > q + 2 and quote_type == code[q+1] == code[q+2])): + counter += 1 + label = "%s%s_" % (prefix, counter) + literals[label] = code[start+quote_len:q] + full_quote = code[q:q+quote_len] + new_code.append(full_quote) + new_code.append(label) + new_code.append(full_quote) + q += quote_len + in_quote = False + start = q + else: + q += 1 + + # Process comment. + elif -1 != hash_mark and (hash_mark < q or q == -1): + new_code.append(code[start:hash_mark+1]) + end = code.find('\n', hash_mark) + counter += 1 + label = "%s%s_" % (prefix, counter) + if end == -1: + end_or_none = None + else: + end_or_none = end + literals[label] = code[hash_mark+1:end_or_none] + new_code.append(label) + if end == -1: + break + start = q = end + + # Open the quote. + else: + if code_len >= q+3 and (code[q] == code[q+1] == code[q+2]): + quote_len = 3 + else: + quote_len = 1 + in_quote = True + quote_type = code[q] + new_code.append(code[start:q]) + start = q + q += quote_len + + return "".join(new_code), literals + + +# We need to allow spaces to allow for conditional compilation like +# IF ...: +# cimport ... +dependency_regex = re.compile(r"(?:^\s*from +([0-9a-zA-Z_.]+) +cimport)|" + r"(?:^\s*cimport +([0-9a-zA-Z_.]+(?: *, *[0-9a-zA-Z_.]+)*))|" + r"(?:^\s*cdef +extern +from +['\"]([^'\"]+)['\"])|" + r"(?:^\s*include +['\"]([^'\"]+)['\"])", re.M) +dependency_after_from_regex = re.compile( + r"(?:^\s+\(([0-9a-zA-Z_., ]*)\)[#\n])|" + r"(?:^\s+([0-9a-zA-Z_., ]*)[#\n])", + re.M) + + +def normalize_existing(base_path, rel_paths): + return normalize_existing0(os.path.dirname(base_path), tuple(set(rel_paths))) + + +@cached_function +def normalize_existing0(base_dir, rel_paths): + """ + Given some base directory ``base_dir`` and a list of path names + ``rel_paths``, normalize each relative path name ``rel`` by + replacing it by ``os.path.join(base, rel)`` if that file exists. + + Return a couple ``(normalized, needed_base)`` where ``normalized`` + if the list of normalized file names and ``needed_base`` is + ``base_dir`` if we actually needed ``base_dir``. If no paths were + changed (for example, if all paths were already absolute), then + ``needed_base`` is ``None``. + """ + normalized = [] + needed_base = None + for rel in rel_paths: + if os.path.isabs(rel): + normalized.append(rel) + continue + path = join_path(base_dir, rel) + if path_exists(path): + normalized.append(os.path.normpath(path)) + needed_base = base_dir + else: + normalized.append(rel) + return (normalized, needed_base) + + +def resolve_depends(depends, include_dirs): + include_dirs = tuple(include_dirs) + resolved = [] + for depend in depends: + path = resolve_depend(depend, include_dirs) + if path is not None: + resolved.append(path) + return resolved + + +@cached_function +def resolve_depend(depend, include_dirs): + if depend[0] == '<' and depend[-1] == '>': + return None + for dir in include_dirs: + path = join_path(dir, depend) + if path_exists(path): + return os.path.normpath(path) + return None + + +@cached_function +def package(filename): + dir = os.path.dirname(os.path.abspath(str(filename))) + if dir != filename and is_package_dir(dir): + return package(dir) + (os.path.basename(dir),) + else: + return () + + +@cached_function +def fully_qualified_name(filename): + module = os.path.splitext(os.path.basename(filename))[0] + return '.'.join(package(filename) + (module,)) + + +@cached_function +def parse_dependencies(source_filename): + # Actual parsing is way too slow, so we use regular expressions. + # The only catch is that we must strip comments and string + # literals ahead of time. + with Utils.open_source_file(source_filename, error_handling='ignore') as fh: + source = fh.read() + distutils_info = DistutilsInfo(source) + source, literals = strip_string_literals(source) + source = source.replace('\\\n', ' ').replace('\t', ' ') + + # TODO: pure mode + cimports = [] + includes = [] + externs = [] + for m in dependency_regex.finditer(source): + cimport_from, cimport_list, extern, include = m.groups() + if cimport_from: + cimports.append(cimport_from) + m_after_from = dependency_after_from_regex.search(source, pos=m.end()) + if m_after_from: + multiline, one_line = m_after_from.groups() + subimports = multiline or one_line + cimports.extend("{0}.{1}".format(cimport_from, s.strip()) + for s in subimports.split(',')) + + elif cimport_list: + cimports.extend(x.strip() for x in cimport_list.split(",")) + elif extern: + externs.append(literals[extern]) + else: + includes.append(literals[include]) + return cimports, includes, externs, distutils_info + + +class DependencyTree(object): + + def __init__(self, context, quiet=False): + self.context = context + self.quiet = quiet + self._transitive_cache = {} + + def parse_dependencies(self, source_filename): + if path_exists(source_filename): + source_filename = os.path.normpath(source_filename) + return parse_dependencies(source_filename) + + @cached_method + def included_files(self, filename): + # This is messy because included files are textually included, resolving + # cimports (but not includes) relative to the including file. + all = set() + for include in self.parse_dependencies(filename)[1]: + include_path = join_path(os.path.dirname(filename), include) + if not path_exists(include_path): + include_path = self.context.find_include_file(include, None) + if include_path: + if '.' + os.path.sep in include_path: + include_path = os.path.normpath(include_path) + all.add(include_path) + all.update(self.included_files(include_path)) + elif not self.quiet: + print("Unable to locate '%s' referenced from '%s'" % (filename, include)) + return all + + @cached_method + def cimports_externs_incdirs(self, filename): + # This is really ugly. Nested cimports are resolved with respect to the + # includer, but includes are resolved with respect to the includee. + cimports, includes, externs = self.parse_dependencies(filename)[:3] + cimports = set(cimports) + externs = set(externs) + incdirs = set() + for include in self.included_files(filename): + included_cimports, included_externs, included_incdirs = self.cimports_externs_incdirs(include) + cimports.update(included_cimports) + externs.update(included_externs) + incdirs.update(included_incdirs) + externs, incdir = normalize_existing(filename, externs) + if incdir: + incdirs.add(incdir) + return tuple(cimports), externs, incdirs + + def cimports(self, filename): + return self.cimports_externs_incdirs(filename)[0] + + def package(self, filename): + return package(filename) + + def fully_qualified_name(self, filename): + return fully_qualified_name(filename) + + @cached_method + def find_pxd(self, module, filename=None): + is_relative = module[0] == '.' + if is_relative and not filename: + raise NotImplementedError("New relative imports.") + if filename is not None: + module_path = module.split('.') + if is_relative: + module_path.pop(0) # just explicitly relative + package_path = list(self.package(filename)) + while module_path and not module_path[0]: + try: + package_path.pop() + except IndexError: + return None # FIXME: error? + module_path.pop(0) + relative = '.'.join(package_path + module_path) + pxd = self.context.find_pxd_file(relative, None) + if pxd: + return pxd + if is_relative: + return None # FIXME: error? + return self.context.find_pxd_file(module, None) + + @cached_method + def cimported_files(self, filename): + if filename[-4:] == '.pyx' and path_exists(filename[:-4] + '.pxd'): + pxd_list = [filename[:-4] + '.pxd'] + else: + pxd_list = [] + # Cimports generates all possible combinations package.module + # when imported as from package cimport module. + for module in self.cimports(filename): + if module[:7] == 'cython.' or module == 'cython': + continue + pxd_file = self.find_pxd(module, filename) + if pxd_file is not None: + pxd_list.append(pxd_file) + return tuple(pxd_list) + + @cached_method + def immediate_dependencies(self, filename): + all = set([filename]) + all.update(self.cimported_files(filename)) + all.update(self.included_files(filename)) + return all + + def all_dependencies(self, filename): + return self.transitive_merge(filename, self.immediate_dependencies, set.union) + + @cached_method + def timestamp(self, filename): + return os.path.getmtime(filename) + + def extract_timestamp(self, filename): + return self.timestamp(filename), filename + + def newest_dependency(self, filename): + return max([self.extract_timestamp(f) for f in self.all_dependencies(filename)]) + + def transitive_fingerprint(self, filename, module, compilation_options): + r""" + Return a fingerprint of a cython file that is about to be cythonized. + + Fingerprints are looked up in future compilations. If the fingerprint + is found, the cythonization can be skipped. The fingerprint must + incorporate everything that has an influence on the generated code. + """ + try: + m = hashlib.md5(__version__.encode('UTF-8')) + m.update(file_hash(filename).encode('UTF-8')) + for x in sorted(self.all_dependencies(filename)): + if os.path.splitext(x)[1] not in ('.c', '.cpp', '.h'): + m.update(file_hash(x).encode('UTF-8')) + # Include the module attributes that change the compilation result + # in the fingerprint. We do not iterate over module.__dict__ and + # include almost everything here as users might extend Extension + # with arbitrary (random) attributes that would lead to cache + # misses. + m.update(str(( + module.language, + getattr(module, 'py_limited_api', False), + getattr(module, 'np_pythran', False) + )).encode('UTF-8')) + + m.update(compilation_options.get_fingerprint().encode('UTF-8')) + return m.hexdigest() + except IOError: + return None + + def distutils_info0(self, filename): + info = self.parse_dependencies(filename)[3] + kwds = info.values + cimports, externs, incdirs = self.cimports_externs_incdirs(filename) + basedir = os.getcwd() + # Add dependencies on "cdef extern from ..." files + if externs: + externs = _make_relative(externs, basedir) + if 'depends' in kwds: + kwds['depends'] = list(set(kwds['depends']).union(externs)) + else: + kwds['depends'] = list(externs) + # Add include_dirs to ensure that the C compiler will find the + # "cdef extern from ..." files + if incdirs: + include_dirs = list(kwds.get('include_dirs', [])) + for inc in _make_relative(incdirs, basedir): + if inc not in include_dirs: + include_dirs.append(inc) + kwds['include_dirs'] = include_dirs + return info + + def distutils_info(self, filename, aliases=None, base=None): + return (self.transitive_merge(filename, self.distutils_info0, DistutilsInfo.merge) + .subs(aliases) + .merge(base)) + + def transitive_merge(self, node, extract, merge): + try: + seen = self._transitive_cache[extract, merge] + except KeyError: + seen = self._transitive_cache[extract, merge] = {} + return self.transitive_merge_helper( + node, extract, merge, seen, {}, self.cimported_files)[0] + + def transitive_merge_helper(self, node, extract, merge, seen, stack, outgoing): + if node in seen: + return seen[node], None + deps = extract(node) + if node in stack: + return deps, node + try: + stack[node] = len(stack) + loop = None + for next in outgoing(node): + sub_deps, sub_loop = self.transitive_merge_helper(next, extract, merge, seen, stack, outgoing) + if sub_loop is not None: + if loop is not None and stack[loop] < stack[sub_loop]: + pass + else: + loop = sub_loop + deps = merge(deps, sub_deps) + if loop == node: + loop = None + if loop is None: + seen[node] = deps + return deps, loop + finally: + del stack[node] + + +_dep_tree = None + +def create_dependency_tree(ctx=None, quiet=False): + global _dep_tree + if _dep_tree is None: + if ctx is None: + ctx = Context(["."], CompilationOptions(default_options)) + _dep_tree = DependencyTree(ctx, quiet=quiet) + return _dep_tree + + +# If this changes, change also docs/src/reference/compilation.rst +# which mentions this function +def default_create_extension(template, kwds): + if 'depends' in kwds: + include_dirs = kwds.get('include_dirs', []) + ["."] + depends = resolve_depends(kwds['depends'], include_dirs) + kwds['depends'] = sorted(set(depends + template.depends)) + + t = template.__class__ + ext = t(**kwds) + metadata = dict(distutils=kwds, module_name=kwds['name']) + return (ext, metadata) + + +# This may be useful for advanced users? +def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet=False, language=None, + exclude_failures=False): + if language is not None: + print('Warning: passing language={0!r} to cythonize() is deprecated. ' + 'Instead, put "# distutils: language={0}" in your .pyx or .pxd file(s)'.format(language)) + if exclude is None: + exclude = [] + if patterns is None: + return [], {} + elif isinstance(patterns, basestring) or not isinstance(patterns, Iterable): + patterns = [patterns] + explicit_modules = set([m.name for m in patterns if isinstance(m, Extension)]) + seen = set() + deps = create_dependency_tree(ctx, quiet=quiet) + to_exclude = set() + if not isinstance(exclude, list): + exclude = [exclude] + for pattern in exclude: + to_exclude.update(map(os.path.abspath, extended_iglob(pattern))) + + module_list = [] + module_metadata = {} + + # workaround for setuptools + if 'setuptools' in sys.modules: + Extension_distutils = sys.modules['setuptools.extension']._Extension + Extension_setuptools = sys.modules['setuptools'].Extension + else: + # dummy class, in case we do not have setuptools + Extension_distutils = Extension + class Extension_setuptools(Extension): pass + + # if no create_extension() function is defined, use a simple + # default function. + create_extension = ctx.options.create_extension or default_create_extension + + for pattern in patterns: + if isinstance(pattern, str): + filepattern = pattern + template = Extension(pattern, []) # Fake Extension without sources + name = '*' + base = None + ext_language = language + elif isinstance(pattern, (Extension_distutils, Extension_setuptools)): + cython_sources = [s for s in pattern.sources + if os.path.splitext(s)[1] in ('.py', '.pyx')] + if cython_sources: + filepattern = cython_sources[0] + if len(cython_sources) > 1: + print("Warning: Multiple cython sources found for extension '%s': %s\n" + "See http://cython.readthedocs.io/en/latest/src/userguide/sharing_declarations.html " + "for sharing declarations among Cython files." % (pattern.name, cython_sources)) + else: + # ignore non-cython modules + module_list.append(pattern) + continue + template = pattern + name = template.name + base = DistutilsInfo(exn=template) + ext_language = None # do not override whatever the Extension says + else: + msg = str("pattern is not of type str nor subclass of Extension (%s)" + " but of type %s and class %s" % (repr(Extension), + type(pattern), + pattern.__class__)) + raise TypeError(msg) + + for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern): + if os.path.abspath(file) in to_exclude: + continue + module_name = deps.fully_qualified_name(file) + if '*' in name: + if module_name in explicit_modules: + continue + elif name: + module_name = name + + Utils.raise_error_if_module_name_forbidden(module_name) + + if module_name not in seen: + try: + kwds = deps.distutils_info(file, aliases, base).values + except Exception: + if exclude_failures: + continue + raise + if base is not None: + for key, value in base.values.items(): + if key not in kwds: + kwds[key] = value + + kwds['name'] = module_name + + sources = [file] + [m for m in template.sources if m != filepattern] + if 'sources' in kwds: + # allow users to add .c files etc. + for source in kwds['sources']: + source = encode_filename_in_py2(source) + if source not in sources: + sources.append(source) + kwds['sources'] = sources + + if ext_language and 'language' not in kwds: + kwds['language'] = ext_language + + np_pythran = kwds.pop('np_pythran', False) + + # Create the new extension + m, metadata = create_extension(template, kwds) + m.np_pythran = np_pythran or getattr(m, 'np_pythran', False) + if m.np_pythran: + update_pythran_extension(m) + module_list.append(m) + + # Store metadata (this will be written as JSON in the + # generated C file but otherwise has no purpose) + module_metadata[module_name] = metadata + + if file not in m.sources: + # Old setuptools unconditionally replaces .pyx with .c/.cpp + target_file = os.path.splitext(file)[0] + ('.cpp' if m.language == 'c++' else '.c') + try: + m.sources.remove(target_file) + except ValueError: + # never seen this in the wild, but probably better to warn about this unexpected case + print("Warning: Cython source file not found in sources list, adding %s" % file) + m.sources.insert(0, file) + seen.add(name) + return module_list, module_metadata + + +# This is the user-exposed entry point. +def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False, force=False, language=None, + exclude_failures=False, **options): + """ + Compile a set of source modules into C/C++ files and return a list of distutils + Extension objects for them. + + :param module_list: As module list, pass either a glob pattern, a list of glob + patterns or a list of Extension objects. The latter + allows you to configure the extensions separately + through the normal distutils options. + You can also pass Extension objects that have + glob patterns as their sources. Then, cythonize + will resolve the pattern and create a + copy of the Extension for every matching file. + + :param exclude: When passing glob patterns as ``module_list``, you can exclude certain + module names explicitly by passing them into the ``exclude`` option. + + :param nthreads: The number of concurrent builds for parallel compilation + (requires the ``multiprocessing`` module). + + :param aliases: If you want to use compiler directives like ``# distutils: ...`` but + can only know at compile time (when running the ``setup.py``) which values + to use, you can use aliases and pass a dictionary mapping those aliases + to Python strings when calling :func:`cythonize`. As an example, say you + want to use the compiler + directive ``# distutils: include_dirs = ../static_libs/include/`` + but this path isn't always fixed and you want to find it when running + the ``setup.py``. You can then do ``# distutils: include_dirs = MY_HEADERS``, + find the value of ``MY_HEADERS`` in the ``setup.py``, put it in a python + variable called ``foo`` as a string, and then call + ``cythonize(..., aliases={'MY_HEADERS': foo})``. + + :param quiet: If True, Cython won't print error, warning, or status messages during the + compilation. + + :param force: Forces the recompilation of the Cython modules, even if the timestamps + don't indicate that a recompilation is necessary. + + :param language: To globally enable C++ mode, you can pass ``language='c++'``. Otherwise, this + will be determined at a per-file level based on compiler directives. This + affects only modules found based on file names. Extension instances passed + into :func:`cythonize` will not be changed. It is recommended to rather + use the compiler directive ``# distutils: language = c++`` than this option. + + :param exclude_failures: For a broad 'try to compile' mode that ignores compilation + failures and simply excludes the failed extensions, + pass ``exclude_failures=True``. Note that this only + really makes sense for compiling ``.py`` files which can also + be used without compilation. + + :param annotate: If ``True``, will produce a HTML file for each of the ``.pyx`` or ``.py`` + files compiled. The HTML file gives an indication + of how much Python interaction there is in + each of the source code lines, compared to plain C code. + It also allows you to see the C/C++ code + generated for each line of Cython code. This report is invaluable when + optimizing a function for speed, + and for determining when to :ref:`release the GIL <nogil>`: + in general, a ``nogil`` block may contain only "white" code. + See examples in :ref:`determining_where_to_add_types` or + :ref:`primes`. + + :param compiler_directives: Allow to set compiler directives in the ``setup.py`` like this: + ``compiler_directives={'embedsignature': True}``. + See :ref:`compiler-directives`. + + :param depfile: produce depfiles for the sources if True. + """ + if exclude is None: + exclude = [] + if 'include_path' not in options: + options['include_path'] = ['.'] + if 'common_utility_include_dir' in options: + safe_makedirs(options['common_utility_include_dir']) + + depfile = options.pop('depfile', None) + + if pythran is None: + pythran_options = None + else: + pythran_options = CompilationOptions(**options) + pythran_options.cplus = True + pythran_options.np_pythran = True + + if force is None: + force = os.environ.get("CYTHON_FORCE_REGEN") == "1" # allow global overrides for build systems + + c_options = CompilationOptions(**options) + cpp_options = CompilationOptions(**options); cpp_options.cplus = True + ctx = c_options.create_context() + options = c_options + module_list, module_metadata = create_extension_list( + module_list, + exclude=exclude, + ctx=ctx, + quiet=quiet, + exclude_failures=exclude_failures, + language=language, + aliases=aliases) + deps = create_dependency_tree(ctx, quiet=quiet) + build_dir = getattr(options, 'build_dir', None) + + def copy_to_build_dir(filepath, root=os.getcwd()): + filepath_abs = os.path.abspath(filepath) + if os.path.isabs(filepath): + filepath = filepath_abs + if filepath_abs.startswith(root): + # distutil extension depends are relative to cwd + mod_dir = join_path(build_dir, + os.path.dirname(_relpath(filepath, root))) + copy_once_if_newer(filepath_abs, mod_dir) + + modules_by_cfile = collections.defaultdict(list) + to_compile = [] + for m in module_list: + if build_dir: + for dep in m.depends: + copy_to_build_dir(dep) + + cy_sources = [ + source for source in m.sources + if os.path.splitext(source)[1] in ('.pyx', '.py')] + if len(cy_sources) == 1: + # normal "special" case: believe the Extension module name to allow user overrides + full_module_name = m.name + else: + # infer FQMN from source files + full_module_name = None + + new_sources = [] + for source in m.sources: + base, ext = os.path.splitext(source) + if ext in ('.pyx', '.py'): + if m.np_pythran: + c_file = base + '.cpp' + options = pythran_options + elif m.language == 'c++': + c_file = base + '.cpp' + options = cpp_options + else: + c_file = base + '.c' + options = c_options + + # setup for out of place build directory if enabled + if build_dir: + if os.path.isabs(c_file): + warnings.warn("build_dir has no effect for absolute source paths") + c_file = os.path.join(build_dir, c_file) + dir = os.path.dirname(c_file) + safe_makedirs_once(dir) + + # write out the depfile, if requested + if depfile: + dependencies = deps.all_dependencies(source) + write_depfile(c_file, source, dependencies) + + if os.path.exists(c_file): + c_timestamp = os.path.getmtime(c_file) + else: + c_timestamp = -1 + + # Priority goes first to modified files, second to direct + # dependents, and finally to indirect dependents. + if c_timestamp < deps.timestamp(source): + dep_timestamp, dep = deps.timestamp(source), source + priority = 0 + else: + dep_timestamp, dep = deps.newest_dependency(source) + priority = 2 - (dep in deps.immediate_dependencies(source)) + if force or c_timestamp < dep_timestamp: + if not quiet and not force: + if source == dep: + print("Compiling %s because it changed." % source) + else: + print("Compiling %s because it depends on %s." % (source, dep)) + if not force and options.cache: + fingerprint = deps.transitive_fingerprint(source, m, options) + else: + fingerprint = None + to_compile.append(( + priority, source, c_file, fingerprint, quiet, + options, not exclude_failures, module_metadata.get(m.name), + full_module_name)) + new_sources.append(c_file) + modules_by_cfile[c_file].append(m) + else: + new_sources.append(source) + if build_dir: + copy_to_build_dir(source) + m.sources = new_sources + + if options.cache: + if not os.path.exists(options.cache): + os.makedirs(options.cache) + to_compile.sort() + # Drop "priority" component of "to_compile" entries and add a + # simple progress indicator. + N = len(to_compile) + progress_fmt = "[{0:%d}/{1}] " % len(str(N)) + for i in range(N): + progress = progress_fmt.format(i+1, N) + to_compile[i] = to_compile[i][1:] + (progress,) + + if N <= 1: + nthreads = 0 + if nthreads: + # Requires multiprocessing (or Python >= 2.6) + try: + import multiprocessing + pool = multiprocessing.Pool( + nthreads, initializer=_init_multiprocessing_helper) + except (ImportError, OSError): + print("multiprocessing required for parallel cythonization") + nthreads = 0 + else: + # This is a bit more involved than it should be, because KeyboardInterrupts + # break the multiprocessing workers when using a normal pool.map(). + # See, for example: + # http://noswap.com/blog/python-multiprocessing-keyboardinterrupt + try: + result = pool.map_async(cythonize_one_helper, to_compile, chunksize=1) + pool.close() + while not result.ready(): + try: + result.get(99999) # seconds + except multiprocessing.TimeoutError: + pass + except KeyboardInterrupt: + pool.terminate() + raise + pool.join() + if not nthreads: + for args in to_compile: + cythonize_one(*args) + + if exclude_failures: + failed_modules = set() + for c_file, modules in modules_by_cfile.items(): + if not os.path.exists(c_file): + failed_modules.update(modules) + elif os.path.getsize(c_file) < 200: + f = io_open(c_file, 'r', encoding='iso8859-1') + try: + if f.read(len('#error ')) == '#error ': + # dead compilation result + failed_modules.update(modules) + finally: + f.close() + if failed_modules: + for module in failed_modules: + module_list.remove(module) + print("Failed compilations: %s" % ', '.join(sorted([ + module.name for module in failed_modules]))) + + if options.cache: + cleanup_cache(options.cache, getattr(options, 'cache_size', 1024 * 1024 * 100)) + # cythonize() is often followed by the (non-Python-buffered) + # compiler output, flush now to avoid interleaving output. + sys.stdout.flush() + return module_list + + +if os.environ.get('XML_RESULTS'): + compile_result_dir = os.environ['XML_RESULTS'] + def record_results(func): + def with_record(*args): + t = time.time() + success = True + try: + try: + func(*args) + except: + success = False + finally: + t = time.time() - t + module = fully_qualified_name(args[0]) + name = "cythonize." + module + failures = 1 - success + if success: + failure_item = "" + else: + failure_item = "failure" + output = open(os.path.join(compile_result_dir, name + ".xml"), "w") + output.write(""" + <?xml version="1.0" ?> + <testsuite name="%(name)s" errors="0" failures="%(failures)s" tests="1" time="%(t)s"> + <testcase classname="%(name)s" name="cythonize"> + %(failure_item)s + </testcase> + </testsuite> + """.strip() % locals()) + output.close() + return with_record +else: + def record_results(func): + return func + + +# TODO: Share context? Issue: pyx processing leaks into pxd module +@record_results +def cythonize_one(pyx_file, c_file, fingerprint, quiet, options=None, + raise_on_failure=True, embedded_metadata=None, full_module_name=None, + progress=""): + from ..Compiler.Main import compile_single, default_options + from ..Compiler.Errors import CompileError, PyrexError + + if fingerprint: + if not os.path.exists(options.cache): + safe_makedirs(options.cache) + # Cython-generated c files are highly compressible. + # (E.g. a compression ratio of about 10 for Sage). + fingerprint_file_base = join_path( + options.cache, "%s-%s" % (os.path.basename(c_file), fingerprint)) + gz_fingerprint_file = fingerprint_file_base + gzip_ext + zip_fingerprint_file = fingerprint_file_base + '.zip' + if os.path.exists(gz_fingerprint_file) or os.path.exists(zip_fingerprint_file): + if not quiet: + print("%sFound compiled %s in cache" % (progress, pyx_file)) + if os.path.exists(gz_fingerprint_file): + os.utime(gz_fingerprint_file, None) + with contextlib.closing(gzip_open(gz_fingerprint_file, 'rb')) as g: + with contextlib.closing(open(c_file, 'wb')) as f: + shutil.copyfileobj(g, f) + else: + os.utime(zip_fingerprint_file, None) + dirname = os.path.dirname(c_file) + with contextlib.closing(zipfile.ZipFile(zip_fingerprint_file)) as z: + for artifact in z.namelist(): + z.extract(artifact, os.path.join(dirname, artifact)) + return + if not quiet: + print("%sCythonizing %s" % (progress, pyx_file)) + if options is None: + options = CompilationOptions(default_options) + options.output_file = c_file + options.embedded_metadata = embedded_metadata + + any_failures = 0 + try: + result = compile_single(pyx_file, options, full_module_name=full_module_name) + if result.num_errors > 0: + any_failures = 1 + except (EnvironmentError, PyrexError) as e: + sys.stderr.write('%s\n' % e) + any_failures = 1 + # XXX + import traceback + traceback.print_exc() + except Exception: + if raise_on_failure: + raise + import traceback + traceback.print_exc() + any_failures = 1 + if any_failures: + if raise_on_failure: + raise CompileError(None, pyx_file) + elif os.path.exists(c_file): + os.remove(c_file) + elif fingerprint: + artifacts = list(filter(None, [ + getattr(result, attr, None) + for attr in ('c_file', 'h_file', 'api_file', 'i_file')])) + if len(artifacts) == 1: + fingerprint_file = gz_fingerprint_file + with contextlib.closing(open(c_file, 'rb')) as f: + with contextlib.closing(gzip_open(fingerprint_file + '.tmp', 'wb')) as g: + shutil.copyfileobj(f, g) + else: + fingerprint_file = zip_fingerprint_file + with contextlib.closing(zipfile.ZipFile( + fingerprint_file + '.tmp', 'w', zipfile_compression_mode)) as zip: + for artifact in artifacts: + zip.write(artifact, os.path.basename(artifact)) + os.rename(fingerprint_file + '.tmp', fingerprint_file) + + +def cythonize_one_helper(m): + import traceback + try: + return cythonize_one(*m) + except Exception: + traceback.print_exc() + raise + + +def _init_multiprocessing_helper(): + # KeyboardInterrupt kills workers, so don't let them get it + import signal + signal.signal(signal.SIGINT, signal.SIG_IGN) + + +def cleanup_cache(cache, target_size, ratio=.85): + try: + p = subprocess.Popen(['du', '-s', '-k', os.path.abspath(cache)], stdout=subprocess.PIPE) + res = p.wait() + if res == 0: + total_size = 1024 * int(p.stdout.read().strip().split()[0]) + if total_size < target_size: + return + except (OSError, ValueError): + pass + total_size = 0 + all = [] + for file in os.listdir(cache): + path = join_path(cache, file) + s = os.stat(path) + total_size += s.st_size + all.append((s.st_atime, s.st_size, path)) + if total_size > target_size: + for time, size, file in reversed(sorted(all)): + os.unlink(file) + total_size -= size + if total_size < target_size * ratio: + break diff --git a/contrib/tools/cython/Cython/Build/Distutils.py b/contrib/tools/cython/Cython/Build/Distutils.py new file mode 100644 index 00000000000..3efcc0d7b51 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Distutils.py @@ -0,0 +1 @@ +from Cython.Distutils.build_ext import build_ext diff --git a/contrib/tools/cython/Cython/Build/Inline.py b/contrib/tools/cython/Cython/Build/Inline.py new file mode 100644 index 00000000000..69684e03ff5 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Inline.py @@ -0,0 +1,377 @@ +from __future__ import absolute_import + +import hashlib +import inspect +import os +import re +import sys + +from distutils.core import Distribution, Extension +from distutils.command.build_ext import build_ext + +import Cython +from ..Compiler.Main import Context, default_options + +from ..Compiler.Visitor import CythonTransform, EnvTransform +from ..Compiler.ParseTreeTransforms import SkipDeclarations +from ..Compiler.TreeFragment import parse_from_strings +from ..Compiler.StringEncoding import _unicode +from .Dependencies import strip_string_literals, cythonize, cached_function +from ..Compiler import Pipeline +from ..Utils import get_cython_cache_dir +import cython as cython_module + + +IS_PY3 = sys.version_info >= (3,) + +# A utility function to convert user-supplied ASCII strings to unicode. +if not IS_PY3: + def to_unicode(s): + if isinstance(s, bytes): + return s.decode('ascii') + else: + return s +else: + to_unicode = lambda x: x + +if sys.version_info < (3, 5): + import imp + def load_dynamic(name, module_path): + return imp.load_dynamic(name, module_path) +else: + import importlib.util + from importlib.machinery import ExtensionFileLoader + + def load_dynamic(name, path): + spec = importlib.util.spec_from_file_location(name, loader=ExtensionFileLoader(name, path)) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + +class UnboundSymbols(EnvTransform, SkipDeclarations): + def __init__(self): + CythonTransform.__init__(self, None) + self.unbound = set() + def visit_NameNode(self, node): + if not self.current_env().lookup(node.name): + self.unbound.add(node.name) + return node + def __call__(self, node): + super(UnboundSymbols, self).__call__(node) + return self.unbound + + +@cached_function +def unbound_symbols(code, context=None): + code = to_unicode(code) + if context is None: + context = Context([], default_options) + from ..Compiler.ParseTreeTransforms import AnalyseDeclarationsTransform + tree = parse_from_strings('(tree fragment)', code) + for phase in Pipeline.create_pipeline(context, 'pyx'): + if phase is None: + continue + tree = phase(tree) + if isinstance(phase, AnalyseDeclarationsTransform): + break + try: + import builtins + except ImportError: + import __builtin__ as builtins + return tuple(UnboundSymbols()(tree) - set(dir(builtins))) + + +def unsafe_type(arg, context=None): + py_type = type(arg) + if py_type is int: + return 'long' + else: + return safe_type(arg, context) + + +def safe_type(arg, context=None): + py_type = type(arg) + if py_type in (list, tuple, dict, str): + return py_type.__name__ + elif py_type is complex: + return 'double complex' + elif py_type is float: + return 'double' + elif py_type is bool: + return 'bint' + elif 'numpy' in sys.modules and isinstance(arg, sys.modules['numpy'].ndarray): + return 'numpy.ndarray[numpy.%s_t, ndim=%s]' % (arg.dtype.name, arg.ndim) + else: + for base_type in py_type.__mro__: + if base_type.__module__ in ('__builtin__', 'builtins'): + return 'object' + module = context.find_module(base_type.__module__, need_pxd=False) + if module: + entry = module.lookup(base_type.__name__) + if entry.is_type: + return '%s.%s' % (base_type.__module__, base_type.__name__) + return 'object' + + +def _get_build_extension(): + dist = Distribution() + # Ensure the build respects distutils configuration by parsing + # the configuration files + config_files = dist.find_config_files() + dist.parse_config_files(config_files) + build_extension = build_ext(dist) + build_extension.finalize_options() + return build_extension + + +@cached_function +def _create_context(cython_include_dirs): + return Context(list(cython_include_dirs), default_options) + + +_cython_inline_cache = {} +_cython_inline_default_context = _create_context(('.',)) + + +def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None): + for symbol in unbound_symbols: + if symbol not in kwds: + if locals is None or globals is None: + calling_frame = inspect.currentframe().f_back.f_back.f_back + if locals is None: + locals = calling_frame.f_locals + if globals is None: + globals = calling_frame.f_globals + if symbol in locals: + kwds[symbol] = locals[symbol] + elif symbol in globals: + kwds[symbol] = globals[symbol] + else: + print("Couldn't find %r" % symbol) + + +def _inline_key(orig_code, arg_sigs, language_level): + key = orig_code, arg_sigs, sys.version_info, sys.executable, language_level, Cython.__version__ + return hashlib.sha1(_unicode(key).encode('utf-8')).hexdigest() + + +def cython_inline(code, get_type=unsafe_type, + lib_dir=os.path.join(get_cython_cache_dir(), 'inline'), + cython_include_dirs=None, cython_compiler_directives=None, + force=False, quiet=False, locals=None, globals=None, language_level=None, **kwds): + + if get_type is None: + get_type = lambda x: 'object' + ctx = _create_context(tuple(cython_include_dirs)) if cython_include_dirs else _cython_inline_default_context + + cython_compiler_directives = dict(cython_compiler_directives) if cython_compiler_directives else {} + if language_level is None and 'language_level' not in cython_compiler_directives: + language_level = '3str' + if language_level is not None: + cython_compiler_directives['language_level'] = language_level + + # Fast path if this has been called in this session. + _unbound_symbols = _cython_inline_cache.get(code) + if _unbound_symbols is not None: + _populate_unbound(kwds, _unbound_symbols, locals, globals) + args = sorted(kwds.items()) + arg_sigs = tuple([(get_type(value, ctx), arg) for arg, value in args]) + key_hash = _inline_key(code, arg_sigs, language_level) + invoke = _cython_inline_cache.get((code, arg_sigs, key_hash)) + if invoke is not None: + arg_list = [arg[1] for arg in args] + return invoke(*arg_list) + + orig_code = code + code = to_unicode(code) + code, literals = strip_string_literals(code) + code = strip_common_indent(code) + if locals is None: + locals = inspect.currentframe().f_back.f_back.f_locals + if globals is None: + globals = inspect.currentframe().f_back.f_back.f_globals + try: + _cython_inline_cache[orig_code] = _unbound_symbols = unbound_symbols(code) + _populate_unbound(kwds, _unbound_symbols, locals, globals) + except AssertionError: + if not quiet: + # Parsing from strings not fully supported (e.g. cimports). + print("Could not parse code as a string (to extract unbound symbols).") + + cimports = [] + for name, arg in list(kwds.items()): + if arg is cython_module: + cimports.append('\ncimport cython as %s' % name) + del kwds[name] + arg_names = sorted(kwds) + arg_sigs = tuple([(get_type(kwds[arg], ctx), arg) for arg in arg_names]) + key_hash = _inline_key(orig_code, arg_sigs, language_level) + module_name = "_cython_inline_" + key_hash + + if module_name in sys.modules: + module = sys.modules[module_name] + + else: + build_extension = None + if cython_inline.so_ext is None: + # Figure out and cache current extension suffix + build_extension = _get_build_extension() + cython_inline.so_ext = build_extension.get_ext_filename('') + + module_path = os.path.join(lib_dir, module_name + cython_inline.so_ext) + + if not os.path.exists(lib_dir): + os.makedirs(lib_dir) + if force or not os.path.isfile(module_path): + cflags = [] + c_include_dirs = [] + qualified = re.compile(r'([.\w]+)[.]') + for type, _ in arg_sigs: + m = qualified.match(type) + if m: + cimports.append('\ncimport %s' % m.groups()[0]) + # one special case + if m.groups()[0] == 'numpy': + import numpy + c_include_dirs.append(numpy.get_include()) + # cflags.append('-Wno-unused') + module_body, func_body = extract_func_code(code) + params = ', '.join(['%s %s' % a for a in arg_sigs]) + module_code = """ +%(module_body)s +%(cimports)s +def __invoke(%(params)s): +%(func_body)s + return locals() + """ % {'cimports': '\n'.join(cimports), + 'module_body': module_body, + 'params': params, + 'func_body': func_body } + for key, value in literals.items(): + module_code = module_code.replace(key, value) + pyx_file = os.path.join(lib_dir, module_name + '.pyx') + fh = open(pyx_file, 'w') + try: + fh.write(module_code) + finally: + fh.close() + extension = Extension( + name = module_name, + sources = [pyx_file], + include_dirs = c_include_dirs, + extra_compile_args = cflags) + if build_extension is None: + build_extension = _get_build_extension() + build_extension.extensions = cythonize( + [extension], + include_path=cython_include_dirs or ['.'], + compiler_directives=cython_compiler_directives, + quiet=quiet) + build_extension.build_temp = os.path.dirname(pyx_file) + build_extension.build_lib = lib_dir + build_extension.run() + + module = load_dynamic(module_name, module_path) + + _cython_inline_cache[orig_code, arg_sigs, key_hash] = module.__invoke + arg_list = [kwds[arg] for arg in arg_names] + return module.__invoke(*arg_list) + + +# Cached suffix used by cython_inline above. None should get +# overridden with actual value upon the first cython_inline invocation +cython_inline.so_ext = None + +_find_non_space = re.compile('[^ ]').search + + +def strip_common_indent(code): + min_indent = None + lines = code.splitlines() + for line in lines: + match = _find_non_space(line) + if not match: + continue # blank + indent = match.start() + if line[indent] == '#': + continue # comment + if min_indent is None or min_indent > indent: + min_indent = indent + for ix, line in enumerate(lines): + match = _find_non_space(line) + if not match or not line or line[indent:indent+1] == '#': + continue + lines[ix] = line[min_indent:] + return '\n'.join(lines) + + +module_statement = re.compile(r'^((cdef +(extern|class))|cimport|(from .+ cimport)|(from .+ import +[*]))') +def extract_func_code(code): + module = [] + function = [] + current = function + code = code.replace('\t', ' ') + lines = code.split('\n') + for line in lines: + if not line.startswith(' '): + if module_statement.match(line): + current = module + else: + current = function + current.append(line) + return '\n'.join(module), ' ' + '\n '.join(function) + + +try: + from inspect import getcallargs +except ImportError: + def getcallargs(func, *arg_values, **kwd_values): + all = {} + args, varargs, kwds, defaults = inspect.getargspec(func) + if varargs is not None: + all[varargs] = arg_values[len(args):] + for name, value in zip(args, arg_values): + all[name] = value + for name, value in list(kwd_values.items()): + if name in args: + if name in all: + raise TypeError("Duplicate argument %s" % name) + all[name] = kwd_values.pop(name) + if kwds is not None: + all[kwds] = kwd_values + elif kwd_values: + raise TypeError("Unexpected keyword arguments: %s" % list(kwd_values)) + if defaults is None: + defaults = () + first_default = len(args) - len(defaults) + for ix, name in enumerate(args): + if name not in all: + if ix >= first_default: + all[name] = defaults[ix - first_default] + else: + raise TypeError("Missing argument: %s" % name) + return all + + +def get_body(source): + ix = source.index(':') + if source[:5] == 'lambda': + return "return %s" % source[ix+1:] + else: + return source[ix+1:] + + +# Lots to be done here... It would be especially cool if compiled functions +# could invoke each other quickly. +class RuntimeCompiledFunction(object): + + def __init__(self, f): + self._f = f + self._body = get_body(inspect.getsource(f)) + + def __call__(self, *args, **kwds): + all = getcallargs(self._f, *args, **kwds) + if IS_PY3: + return cython_inline(self._body, locals=self._f.__globals__, globals=self._f.__globals__, **all) + else: + return cython_inline(self._body, locals=self._f.func_globals, globals=self._f.func_globals, **all) diff --git a/contrib/tools/cython/Cython/Build/IpythonMagic.py b/contrib/tools/cython/Cython/Build/IpythonMagic.py new file mode 100644 index 00000000000..b3a9d7c583b --- /dev/null +++ b/contrib/tools/cython/Cython/Build/IpythonMagic.py @@ -0,0 +1,564 @@ +# -*- coding: utf-8 -*- +""" +===================== +Cython related magics +===================== + +Magic command interface for interactive work with Cython + +.. note:: + + The ``Cython`` package needs to be installed separately. It + can be obtained using ``easy_install`` or ``pip``. + +Usage +===== + +To enable the magics below, execute ``%load_ext cython``. + +``%%cython`` + +{CYTHON_DOC} + +``%%cython_inline`` + +{CYTHON_INLINE_DOC} + +``%%cython_pyximport`` + +{CYTHON_PYXIMPORT_DOC} + +Author: +* Brian Granger + +Code moved from IPython and adapted by: +* Martín Gaitán + +Parts of this code were taken from Cython.inline. +""" +#----------------------------------------------------------------------------- +# Copyright (C) 2010-2011, IPython Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file ipython-COPYING.rst, distributed with this software. +#----------------------------------------------------------------------------- + +from __future__ import absolute_import, print_function + +import io +import os +import re +import sys +import time +import copy +import distutils.log +import textwrap + +IO_ENCODING = sys.getfilesystemencoding() +IS_PY2 = sys.version_info[0] < 3 + +try: + reload +except NameError: # Python 3 + from imp import reload + +try: + import hashlib +except ImportError: + import md5 as hashlib + +from distutils.core import Distribution, Extension +from distutils.command.build_ext import build_ext + +from IPython.core import display +from IPython.core import magic_arguments +from IPython.core.magic import Magics, magics_class, cell_magic +try: + from IPython.paths import get_ipython_cache_dir +except ImportError: + # older IPython version + from IPython.utils.path import get_ipython_cache_dir +from IPython.utils.text import dedent + +from ..Shadow import __version__ as cython_version +from ..Compiler.Errors import CompileError +from .Inline import cython_inline, load_dynamic +from .Dependencies import cythonize + + +PGO_CONFIG = { + 'gcc': { + 'gen': ['-fprofile-generate', '-fprofile-dir={TEMPDIR}'], + 'use': ['-fprofile-use', '-fprofile-correction', '-fprofile-dir={TEMPDIR}'], + }, + # blind copy from 'configure' script in CPython 3.7 + 'icc': { + 'gen': ['-prof-gen'], + 'use': ['-prof-use'], + } +} +PGO_CONFIG['mingw32'] = PGO_CONFIG['gcc'] + + +if IS_PY2: + def encode_fs(name): + return name if isinstance(name, bytes) else name.encode(IO_ENCODING) +else: + def encode_fs(name): + return name + + +@magics_class +class CythonMagics(Magics): + + def __init__(self, shell): + super(CythonMagics, self).__init__(shell) + self._reloads = {} + self._code_cache = {} + self._pyximport_installed = False + + def _import_all(self, module): + mdict = module.__dict__ + if '__all__' in mdict: + keys = mdict['__all__'] + else: + keys = [k for k in mdict if not k.startswith('_')] + + for k in keys: + try: + self.shell.push({k: mdict[k]}) + except KeyError: + msg = "'module' object has no attribute '%s'" % k + raise AttributeError(msg) + + @cell_magic + def cython_inline(self, line, cell): + """Compile and run a Cython code cell using Cython.inline. + + This magic simply passes the body of the cell to Cython.inline + and returns the result. If the variables `a` and `b` are defined + in the user's namespace, here is a simple example that returns + their sum:: + + %%cython_inline + return a+b + + For most purposes, we recommend the usage of the `%%cython` magic. + """ + locs = self.shell.user_global_ns + globs = self.shell.user_ns + return cython_inline(cell, locals=locs, globals=globs) + + @cell_magic + def cython_pyximport(self, line, cell): + """Compile and import a Cython code cell using pyximport. + + The contents of the cell are written to a `.pyx` file in the current + working directory, which is then imported using `pyximport`. This + magic requires a module name to be passed:: + + %%cython_pyximport modulename + def f(x): + return 2.0*x + + The compiled module is then imported and all of its symbols are + injected into the user's namespace. For most purposes, we recommend + the usage of the `%%cython` magic. + """ + module_name = line.strip() + if not module_name: + raise ValueError('module name must be given') + fname = module_name + '.pyx' + with io.open(fname, 'w', encoding='utf-8') as f: + f.write(cell) + if 'pyximport' not in sys.modules or not self._pyximport_installed: + import pyximport + pyximport.install() + self._pyximport_installed = True + if module_name in self._reloads: + module = self._reloads[module_name] + # Note: reloading extension modules is not actually supported + # (requires PEP-489 reinitialisation support). + # Don't know why this should ever have worked as it reads here. + # All we really need to do is to update the globals below. + #reload(module) + else: + __import__(module_name) + module = sys.modules[module_name] + self._reloads[module_name] = module + self._import_all(module) + + @magic_arguments.magic_arguments() + @magic_arguments.argument( + '-a', '--annotate', action='store_true', default=False, + help="Produce a colorized HTML version of the source." + ) + @magic_arguments.argument( + '-+', '--cplus', action='store_true', default=False, + help="Output a C++ rather than C file." + ) + @magic_arguments.argument( + '-3', dest='language_level', action='store_const', const=3, default=None, + help="Select Python 3 syntax." + ) + @magic_arguments.argument( + '-2', dest='language_level', action='store_const', const=2, default=None, + help="Select Python 2 syntax." + ) + @magic_arguments.argument( + '-f', '--force', action='store_true', default=False, + help="Force the compilation of a new module, even if the source has been " + "previously compiled." + ) + @magic_arguments.argument( + '-c', '--compile-args', action='append', default=[], + help="Extra flags to pass to compiler via the `extra_compile_args` " + "Extension flag (can be specified multiple times)." + ) + @magic_arguments.argument( + '--link-args', action='append', default=[], + help="Extra flags to pass to linker via the `extra_link_args` " + "Extension flag (can be specified multiple times)." + ) + @magic_arguments.argument( + '-l', '--lib', action='append', default=[], + help="Add a library to link the extension against (can be specified " + "multiple times)." + ) + @magic_arguments.argument( + '-n', '--name', + help="Specify a name for the Cython module." + ) + @magic_arguments.argument( + '-L', dest='library_dirs', metavar='dir', action='append', default=[], + help="Add a path to the list of library directories (can be specified " + "multiple times)." + ) + @magic_arguments.argument( + '-I', '--include', action='append', default=[], + help="Add a path to the list of include directories (can be specified " + "multiple times)." + ) + @magic_arguments.argument( + '-S', '--src', action='append', default=[], + help="Add a path to the list of src files (can be specified " + "multiple times)." + ) + @magic_arguments.argument( + '--pgo', dest='pgo', action='store_true', default=False, + help=("Enable profile guided optimisation in the C compiler. " + "Compiles the cell twice and executes it in between to generate a runtime profile.") + ) + @magic_arguments.argument( + '--verbose', dest='quiet', action='store_false', default=True, + help=("Print debug information like generated .c/.cpp file location " + "and exact gcc/g++ command invoked.") + ) + @cell_magic + def cython(self, line, cell): + """Compile and import everything from a Cython code cell. + + The contents of the cell are written to a `.pyx` file in the + directory `IPYTHONDIR/cython` using a filename with the hash of the + code. This file is then cythonized and compiled. The resulting module + is imported and all of its symbols are injected into the user's + namespace. The usage is similar to that of `%%cython_pyximport` but + you don't have to pass a module name:: + + %%cython + def f(x): + return 2.0*x + + To compile OpenMP codes, pass the required `--compile-args` + and `--link-args`. For example with gcc:: + + %%cython --compile-args=-fopenmp --link-args=-fopenmp + ... + + To enable profile guided optimisation, pass the ``--pgo`` option. + Note that the cell itself needs to take care of establishing a suitable + profile when executed. This can be done by implementing the functions to + optimise, and then calling them directly in the same cell on some realistic + training data like this:: + + %%cython --pgo + def critical_function(data): + for item in data: + ... + + # execute function several times to build profile + from somewhere import some_typical_data + for _ in range(100): + critical_function(some_typical_data) + + In Python 3.5 and later, you can distinguish between the profile and + non-profile runs as follows:: + + if "_pgo_" in __name__: + ... # execute critical code here + """ + args = magic_arguments.parse_argstring(self.cython, line) + code = cell if cell.endswith('\n') else cell + '\n' + lib_dir = os.path.join(get_ipython_cache_dir(), 'cython') + key = (code, line, sys.version_info, sys.executable, cython_version) + + if not os.path.exists(lib_dir): + os.makedirs(lib_dir) + + if args.pgo: + key += ('pgo',) + if args.force: + # Force a new module name by adding the current time to the + # key which is hashed to determine the module name. + key += (time.time(),) + + if args.name: + module_name = str(args.name) # no-op in Py3 + else: + module_name = "_cython_magic_" + hashlib.md5(str(key).encode('utf-8')).hexdigest() + html_file = os.path.join(lib_dir, module_name + '.html') + module_path = os.path.join(lib_dir, module_name + self.so_ext) + + have_module = os.path.isfile(module_path) + need_cythonize = args.pgo or not have_module + + if args.annotate: + if not os.path.isfile(html_file): + need_cythonize = True + + extension = None + if need_cythonize: + extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet) + if extensions is None: + # Compilation failed and printed error message + return None + assert len(extensions) == 1 + extension = extensions[0] + self._code_cache[key] = module_name + + if args.pgo: + self._profile_pgo_wrapper(extension, lib_dir) + + try: + self._build_extension(extension, lib_dir, pgo_step_name='use' if args.pgo else None, + quiet=args.quiet) + except distutils.errors.CompileError: + # Build failed and printed error message + return None + + module = load_dynamic(module_name, module_path) + self._import_all(module) + + if args.annotate: + try: + with io.open(html_file, encoding='utf-8') as f: + annotated_html = f.read() + except IOError as e: + # File could not be opened. Most likely the user has a version + # of Cython before 0.15.1 (when `cythonize` learned the + # `force` keyword argument) and has already compiled this + # exact source without annotation. + print('Cython completed successfully but the annotated ' + 'source could not be read.', file=sys.stderr) + print(e, file=sys.stderr) + else: + return display.HTML(self.clean_annotated_html(annotated_html)) + + def _profile_pgo_wrapper(self, extension, lib_dir): + """ + Generate a .c file for a separate extension module that calls the + module init function of the original module. This makes sure that the + PGO profiler sees the correct .o file of the final module, but it still + allows us to import the module under a different name for profiling, + before recompiling it into the PGO optimised module. Overwriting and + reimporting the same shared library is not portable. + """ + extension = copy.copy(extension) # shallow copy, do not modify sources in place! + module_name = extension.name + pgo_module_name = '_pgo_' + module_name + pgo_wrapper_c_file = os.path.join(lib_dir, pgo_module_name + '.c') + with io.open(pgo_wrapper_c_file, 'w', encoding='utf-8') as f: + f.write(textwrap.dedent(u""" + #include "Python.h" + #if PY_MAJOR_VERSION < 3 + extern PyMODINIT_FUNC init%(module_name)s(void); + PyMODINIT_FUNC init%(pgo_module_name)s(void); /*proto*/ + PyMODINIT_FUNC init%(pgo_module_name)s(void) { + PyObject *sys_modules; + init%(module_name)s(); if (PyErr_Occurred()) return; + sys_modules = PyImport_GetModuleDict(); /* borrowed, no exception, "never" fails */ + if (sys_modules) { + PyObject *module = PyDict_GetItemString(sys_modules, "%(module_name)s"); if (!module) return; + PyDict_SetItemString(sys_modules, "%(pgo_module_name)s", module); + Py_DECREF(module); + } + } + #else + extern PyMODINIT_FUNC PyInit_%(module_name)s(void); + PyMODINIT_FUNC PyInit_%(pgo_module_name)s(void); /*proto*/ + PyMODINIT_FUNC PyInit_%(pgo_module_name)s(void) { + return PyInit_%(module_name)s(); + } + #endif + """ % {'module_name': module_name, 'pgo_module_name': pgo_module_name})) + + extension.sources = extension.sources + [pgo_wrapper_c_file] # do not modify in place! + extension.name = pgo_module_name + + self._build_extension(extension, lib_dir, pgo_step_name='gen') + + # import and execute module code to generate profile + so_module_path = os.path.join(lib_dir, pgo_module_name + self.so_ext) + load_dynamic(pgo_module_name, so_module_path) + + def _cythonize(self, module_name, code, lib_dir, args, quiet=True): + pyx_file = os.path.join(lib_dir, module_name + '.pyx') + pyx_file = encode_fs(pyx_file) + + c_include_dirs = args.include + c_src_files = list(map(str, args.src)) + if 'numpy' in code: + import numpy + c_include_dirs.append(numpy.get_include()) + with io.open(pyx_file, 'w', encoding='utf-8') as f: + f.write(code) + extension = Extension( + name=module_name, + sources=[pyx_file] + c_src_files, + include_dirs=c_include_dirs, + library_dirs=args.library_dirs, + extra_compile_args=args.compile_args, + extra_link_args=args.link_args, + libraries=args.lib, + language='c++' if args.cplus else 'c', + ) + try: + opts = dict( + quiet=quiet, + annotate=args.annotate, + force=True, + ) + if args.language_level is not None: + assert args.language_level in (2, 3) + opts['language_level'] = args.language_level + elif sys.version_info[0] >= 3: + opts['language_level'] = 3 + return cythonize([extension], **opts) + except CompileError: + return None + + def _build_extension(self, extension, lib_dir, temp_dir=None, pgo_step_name=None, quiet=True): + build_extension = self._get_build_extension( + extension, lib_dir=lib_dir, temp_dir=temp_dir, pgo_step_name=pgo_step_name) + old_threshold = None + try: + if not quiet: + old_threshold = distutils.log.set_threshold(distutils.log.DEBUG) + build_extension.run() + finally: + if not quiet and old_threshold is not None: + distutils.log.set_threshold(old_threshold) + + def _add_pgo_flags(self, build_extension, step_name, temp_dir): + compiler_type = build_extension.compiler.compiler_type + if compiler_type == 'unix': + compiler_cmd = build_extension.compiler.compiler_so + # TODO: we could try to call "[cmd] --version" for better insights + if not compiler_cmd: + pass + elif 'clang' in compiler_cmd or 'clang' in compiler_cmd[0]: + compiler_type = 'clang' + elif 'icc' in compiler_cmd or 'icc' in compiler_cmd[0]: + compiler_type = 'icc' + elif 'gcc' in compiler_cmd or 'gcc' in compiler_cmd[0]: + compiler_type = 'gcc' + elif 'g++' in compiler_cmd or 'g++' in compiler_cmd[0]: + compiler_type = 'gcc' + config = PGO_CONFIG.get(compiler_type) + orig_flags = [] + if config and step_name in config: + flags = [f.format(TEMPDIR=temp_dir) for f in config[step_name]] + for extension in build_extension.extensions: + orig_flags.append((extension.extra_compile_args, extension.extra_link_args)) + extension.extra_compile_args = extension.extra_compile_args + flags + extension.extra_link_args = extension.extra_link_args + flags + else: + print("No PGO %s configuration known for C compiler type '%s'" % (step_name, compiler_type), + file=sys.stderr) + return orig_flags + + @property + def so_ext(self): + """The extension suffix for compiled modules.""" + try: + return self._so_ext + except AttributeError: + self._so_ext = self._get_build_extension().get_ext_filename('') + return self._so_ext + + def _clear_distutils_mkpath_cache(self): + """clear distutils mkpath cache + + prevents distutils from skipping re-creation of dirs that have been removed + """ + try: + from distutils.dir_util import _path_created + except ImportError: + pass + else: + _path_created.clear() + + def _get_build_extension(self, extension=None, lib_dir=None, temp_dir=None, + pgo_step_name=None, _build_ext=build_ext): + self._clear_distutils_mkpath_cache() + dist = Distribution() + config_files = dist.find_config_files() + try: + config_files.remove('setup.cfg') + except ValueError: + pass + dist.parse_config_files(config_files) + + if not temp_dir: + temp_dir = lib_dir + add_pgo_flags = self._add_pgo_flags + + if pgo_step_name: + base_build_ext = _build_ext + class _build_ext(_build_ext): + def build_extensions(self): + add_pgo_flags(self, pgo_step_name, temp_dir) + base_build_ext.build_extensions(self) + + build_extension = _build_ext(dist) + build_extension.finalize_options() + if temp_dir: + temp_dir = encode_fs(temp_dir) + build_extension.build_temp = temp_dir + if lib_dir: + lib_dir = encode_fs(lib_dir) + build_extension.build_lib = lib_dir + if extension is not None: + build_extension.extensions = [extension] + return build_extension + + @staticmethod + def clean_annotated_html(html): + """Clean up the annotated HTML source. + + Strips the link to the generated C or C++ file, which we do not + present to the user. + """ + r = re.compile('<p>Raw output: <a href="(.*)">(.*)</a>') + html = '\n'.join(l for l in html.splitlines() if not r.match(l)) + return html + +__doc__ = __doc__.format( + # rST doesn't see the -+ flag as part of an option list, so we + # hide it from the module-level docstring. + CYTHON_DOC=dedent(CythonMagics.cython.__doc__\ + .replace('-+, --cplus', '--cplus ')), + CYTHON_INLINE_DOC=dedent(CythonMagics.cython_inline.__doc__), + CYTHON_PYXIMPORT_DOC=dedent(CythonMagics.cython_pyximport.__doc__), +) diff --git a/contrib/tools/cython/Cython/Build/Tests/TestCyCache.py b/contrib/tools/cython/Cython/Build/Tests/TestCyCache.py new file mode 100644 index 00000000000..a3224b41750 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Tests/TestCyCache.py @@ -0,0 +1,106 @@ +import difflib +import glob +import gzip +import os +import tempfile + +import Cython.Build.Dependencies +import Cython.Utils +from Cython.TestUtils import CythonTest + + +class TestCyCache(CythonTest): + + def setUp(self): + CythonTest.setUp(self) + self.temp_dir = tempfile.mkdtemp( + prefix='cycache-test', + dir='TEST_TMP' if os.path.isdir('TEST_TMP') else None) + self.src_dir = tempfile.mkdtemp(prefix='src', dir=self.temp_dir) + self.cache_dir = tempfile.mkdtemp(prefix='cache', dir=self.temp_dir) + + def cache_files(self, file_glob): + return glob.glob(os.path.join(self.cache_dir, file_glob)) + + def fresh_cythonize(self, *args, **kwargs): + Cython.Utils.clear_function_caches() + Cython.Build.Dependencies._dep_tree = None # discard method caches + Cython.Build.Dependencies.cythonize(*args, **kwargs) + + def test_cycache_switch(self): + content1 = 'value = 1\n' + content2 = 'value = 2\n' + a_pyx = os.path.join(self.src_dir, 'a.pyx') + a_c = a_pyx[:-4] + '.c' + + open(a_pyx, 'w').write(content1) + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + self.assertEqual(1, len(self.cache_files('a.c*'))) + a_contents1 = open(a_c).read() + os.unlink(a_c) + + open(a_pyx, 'w').write(content2) + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + a_contents2 = open(a_c).read() + os.unlink(a_c) + + self.assertNotEqual(a_contents1, a_contents2, 'C file not changed!') + self.assertEqual(2, len(self.cache_files('a.c*'))) + + open(a_pyx, 'w').write(content1) + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + self.assertEqual(2, len(self.cache_files('a.c*'))) + a_contents = open(a_c).read() + self.assertEqual( + a_contents, a_contents1, + msg='\n'.join(list(difflib.unified_diff( + a_contents.split('\n'), a_contents1.split('\n')))[:10])) + + def test_cycache_uses_cache(self): + a_pyx = os.path.join(self.src_dir, 'a.pyx') + a_c = a_pyx[:-4] + '.c' + open(a_pyx, 'w').write('pass') + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + a_cache = os.path.join(self.cache_dir, os.listdir(self.cache_dir)[0]) + gzip.GzipFile(a_cache, 'wb').write('fake stuff'.encode('ascii')) + os.unlink(a_c) + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + a_contents = open(a_c).read() + self.assertEqual(a_contents, 'fake stuff', + 'Unexpected contents: %s...' % a_contents[:100]) + + def test_multi_file_output(self): + a_pyx = os.path.join(self.src_dir, 'a.pyx') + a_c = a_pyx[:-4] + '.c' + a_h = a_pyx[:-4] + '.h' + a_api_h = a_pyx[:-4] + '_api.h' + open(a_pyx, 'w').write('cdef public api int foo(int x): return x\n') + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + expected = [a_c, a_h, a_api_h] + for output in expected: + self.assertTrue(os.path.exists(output), output) + os.unlink(output) + self.fresh_cythonize(a_pyx, cache=self.cache_dir) + for output in expected: + self.assertTrue(os.path.exists(output), output) + + def test_options_invalidation(self): + hash_pyx = os.path.join(self.src_dir, 'options.pyx') + hash_c = hash_pyx[:-len('.pyx')] + '.c' + + open(hash_pyx, 'w').write('pass') + self.fresh_cythonize(hash_pyx, cache=self.cache_dir, cplus=False) + self.assertEqual(1, len(self.cache_files('options.c*'))) + + os.unlink(hash_c) + self.fresh_cythonize(hash_pyx, cache=self.cache_dir, cplus=True) + self.assertEqual(2, len(self.cache_files('options.c*'))) + + os.unlink(hash_c) + self.fresh_cythonize(hash_pyx, cache=self.cache_dir, cplus=False, show_version=False) + self.assertEqual(2, len(self.cache_files('options.c*'))) + + os.unlink(hash_c) + self.fresh_cythonize(hash_pyx, cache=self.cache_dir, cplus=False, show_version=True) + self.assertEqual(2, len(self.cache_files('options.c*'))) diff --git a/contrib/tools/cython/Cython/Build/Tests/TestInline.py b/contrib/tools/cython/Cython/Build/Tests/TestInline.py new file mode 100644 index 00000000000..d209488083e --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Tests/TestInline.py @@ -0,0 +1,96 @@ +import os, tempfile +from Cython.Shadow import inline +from Cython.Build.Inline import safe_type +from Cython.TestUtils import CythonTest + +try: + import numpy + has_numpy = True +except: + has_numpy = False + +test_kwds = dict(force=True, quiet=True) + +global_value = 100 + +class TestInline(CythonTest): + def setUp(self): + CythonTest.setUp(self) + self.test_kwds = dict(test_kwds) + if os.path.isdir('TEST_TMP'): + lib_dir = os.path.join('TEST_TMP','inline') + else: + lib_dir = tempfile.mkdtemp(prefix='cython_inline_') + self.test_kwds['lib_dir'] = lib_dir + + def test_simple(self): + self.assertEqual(inline("return 1+2", **self.test_kwds), 3) + + def test_types(self): + self.assertEqual(inline(""" + cimport cython + return cython.typeof(a), cython.typeof(b) + """, a=1.0, b=[], **self.test_kwds), ('double', 'list object')) + + def test_locals(self): + a = 1 + b = 2 + self.assertEqual(inline("return a+b", **self.test_kwds), 3) + + def test_globals(self): + self.assertEqual(inline("return global_value + 1", **self.test_kwds), global_value + 1) + + def test_no_return(self): + self.assertEqual(inline(""" + a = 1 + cdef double b = 2 + cdef c = [] + """, **self.test_kwds), dict(a=1, b=2.0, c=[])) + + def test_def_node(self): + foo = inline("def foo(x): return x * x", **self.test_kwds)['foo'] + self.assertEqual(foo(7), 49) + + def test_class_ref(self): + class Type(object): + pass + tp = inline("Type")['Type'] + self.assertEqual(tp, Type) + + def test_pure(self): + import cython as cy + b = inline(""" + b = cy.declare(float, a) + c = cy.declare(cy.pointer(cy.float), &b) + return b + """, a=3, **self.test_kwds) + self.assertEqual(type(b), float) + + def test_compiler_directives(self): + self.assertEqual( + inline('return sum(x)', + x=[1, 2, 3], + cython_compiler_directives={'boundscheck': False}), + 6 + ) + + def test_lang_version(self): + # GH-3419. Caching for inline code didn't always respect compiler directives. + inline_divcode = "def f(int a, int b): return a/b" + self.assertEqual( + inline(inline_divcode, language_level=2)['f'](5,2), + 2 + ) + self.assertEqual( + inline(inline_divcode, language_level=3)['f'](5,2), + 2.5 + ) + + if has_numpy: + + def test_numpy(self): + import numpy + a = numpy.ndarray((10, 20)) + a[0,0] = 10 + self.assertEqual(safe_type(a), 'numpy.ndarray[numpy.float64_t, ndim=2]') + self.assertEqual(inline("return a[0,0]", a=a, **self.test_kwds), 10.0) diff --git a/contrib/tools/cython/Cython/Build/Tests/TestIpythonMagic.py b/contrib/tools/cython/Cython/Build/Tests/TestIpythonMagic.py new file mode 100644 index 00000000000..24213091b26 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Tests/TestIpythonMagic.py @@ -0,0 +1,205 @@ +# -*- coding: utf-8 -*- +# tag: ipython + +"""Tests for the Cython magics extension.""" + +from __future__ import absolute_import + +import os +import sys +from contextlib import contextmanager +from Cython.Build import IpythonMagic +from Cython.TestUtils import CythonTest + +try: + import IPython.testing.globalipapp +except ImportError: + # Disable tests and fake helpers for initialisation below. + def skip_if_not_installed(_): + return None +else: + def skip_if_not_installed(c): + return c + +try: + # disable IPython history thread before it gets started to avoid having to clean it up + from IPython.core.history import HistoryManager + HistoryManager.enabled = False +except ImportError: + pass + +code = u"""\ +def f(x): + return 2*x +""" + +cython3_code = u"""\ +def f(int x): + return 2 / x + +def call(x): + return f(*(x,)) +""" + +pgo_cython3_code = cython3_code + u"""\ +def main(): + for _ in range(100): call(5) +main() +""" + + +if sys.platform == 'win32': + # not using IPython's decorators here because they depend on "nose" + try: + from unittest import skip as skip_win32 + except ImportError: + # poor dev's silent @unittest.skip() + def skip_win32(dummy): + def _skip_win32(func): + return None + return _skip_win32 +else: + def skip_win32(dummy): + def _skip_win32(func): + def wrapper(*args, **kwargs): + func(*args, **kwargs) + return wrapper + return _skip_win32 + + +@skip_if_not_installed +class TestIPythonMagic(CythonTest): + + @classmethod + def setUpClass(cls): + CythonTest.setUpClass() + cls._ip = IPython.testing.globalipapp.get_ipython() + + def setUp(self): + CythonTest.setUp(self) + self._ip.extension_manager.load_extension('cython') + + def test_cython_inline(self): + ip = self._ip + ip.ex('a=10; b=20') + result = ip.run_cell_magic('cython_inline', '', 'return a+b') + self.assertEqual(result, 30) + + @skip_win32('Skip on Windows') + def test_cython_pyximport(self): + ip = self._ip + module_name = '_test_cython_pyximport' + ip.run_cell_magic('cython_pyximport', module_name, code) + ip.ex('g = f(10)') + self.assertEqual(ip.user_ns['g'], 20.0) + ip.run_cell_magic('cython_pyximport', module_name, code) + ip.ex('h = f(-10)') + self.assertEqual(ip.user_ns['h'], -20.0) + try: + os.remove(module_name + '.pyx') + except OSError: + pass + + def test_cython(self): + ip = self._ip + ip.run_cell_magic('cython', '', code) + ip.ex('g = f(10)') + self.assertEqual(ip.user_ns['g'], 20.0) + + def test_cython_name(self): + # The Cython module named 'mymodule' defines the function f. + ip = self._ip + ip.run_cell_magic('cython', '--name=mymodule', code) + # This module can now be imported in the interactive namespace. + ip.ex('import mymodule; g = mymodule.f(10)') + self.assertEqual(ip.user_ns['g'], 20.0) + + def test_cython_language_level(self): + # The Cython cell defines the functions f() and call(). + ip = self._ip + ip.run_cell_magic('cython', '', cython3_code) + ip.ex('g = f(10); h = call(10)') + if sys.version_info[0] < 3: + self.assertEqual(ip.user_ns['g'], 2 // 10) + self.assertEqual(ip.user_ns['h'], 2 // 10) + else: + self.assertEqual(ip.user_ns['g'], 2.0 / 10.0) + self.assertEqual(ip.user_ns['h'], 2.0 / 10.0) + + def test_cython3(self): + # The Cython cell defines the functions f() and call(). + ip = self._ip + ip.run_cell_magic('cython', '-3', cython3_code) + ip.ex('g = f(10); h = call(10)') + self.assertEqual(ip.user_ns['g'], 2.0 / 10.0) + self.assertEqual(ip.user_ns['h'], 2.0 / 10.0) + + def test_cython2(self): + # The Cython cell defines the functions f() and call(). + ip = self._ip + ip.run_cell_magic('cython', '-2', cython3_code) + ip.ex('g = f(10); h = call(10)') + self.assertEqual(ip.user_ns['g'], 2 // 10) + self.assertEqual(ip.user_ns['h'], 2 // 10) + + @skip_win32('Skip on Windows') + def test_cython3_pgo(self): + # The Cython cell defines the functions f() and call(). + ip = self._ip + ip.run_cell_magic('cython', '-3 --pgo', pgo_cython3_code) + ip.ex('g = f(10); h = call(10); main()') + self.assertEqual(ip.user_ns['g'], 2.0 / 10.0) + self.assertEqual(ip.user_ns['h'], 2.0 / 10.0) + + @skip_win32('Skip on Windows') + def test_extlibs(self): + ip = self._ip + code = u""" +from libc.math cimport sin +x = sin(0.0) + """ + ip.user_ns['x'] = 1 + ip.run_cell_magic('cython', '-l m', code) + self.assertEqual(ip.user_ns['x'], 0) + + + def test_cython_verbose(self): + ip = self._ip + ip.run_cell_magic('cython', '--verbose', code) + ip.ex('g = f(10)') + self.assertEqual(ip.user_ns['g'], 20.0) + + def test_cython_verbose_thresholds(self): + @contextmanager + def mock_distutils(): + class MockLog: + DEBUG = 1 + INFO = 2 + thresholds = [INFO] + + def set_threshold(self, val): + self.thresholds.append(val) + return self.thresholds[-2] + + + new_log = MockLog() + old_log = IpythonMagic.distutils.log + try: + IpythonMagic.distutils.log = new_log + yield new_log + finally: + IpythonMagic.distutils.log = old_log + + ip = self._ip + with mock_distutils() as verbose_log: + ip.run_cell_magic('cython', '--verbose', code) + ip.ex('g = f(10)') + self.assertEqual(ip.user_ns['g'], 20.0) + self.assertEqual([verbose_log.INFO, verbose_log.DEBUG, verbose_log.INFO], + verbose_log.thresholds) + + with mock_distutils() as normal_log: + ip.run_cell_magic('cython', '', code) + ip.ex('g = f(10)') + self.assertEqual(ip.user_ns['g'], 20.0) + self.assertEqual([normal_log.INFO], normal_log.thresholds) diff --git a/contrib/tools/cython/Cython/Build/Tests/TestStripLiterals.py b/contrib/tools/cython/Cython/Build/Tests/TestStripLiterals.py new file mode 100644 index 00000000000..a7572a50838 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Tests/TestStripLiterals.py @@ -0,0 +1,57 @@ +from Cython.Build.Dependencies import strip_string_literals + +from Cython.TestUtils import CythonTest + +class TestStripLiterals(CythonTest): + + def t(self, before, expected): + actual, literals = strip_string_literals(before, prefix="_L") + self.assertEqual(expected, actual) + for key, value in literals.items(): + actual = actual.replace(key, value) + self.assertEqual(before, actual) + + def test_empty(self): + self.t("", "") + + def test_single_quote(self): + self.t("'x'", "'_L1_'") + + def test_double_quote(self): + self.t('"x"', '"_L1_"') + + def test_nested_quotes(self): + self.t(""" '"' "'" """, """ '_L1_' "_L2_" """) + + def test_triple_quote(self): + self.t(" '''a\n''' ", " '''_L1_''' ") + + def test_backslash(self): + self.t(r"'a\'b'", "'_L1_'") + self.t(r"'a\\'", "'_L1_'") + self.t(r"'a\\\'b'", "'_L1_'") + + def test_unicode(self): + self.t("u'abc'", "u'_L1_'") + + def test_raw(self): + self.t(r"r'abc\\'", "r'_L1_'") + + def test_raw_unicode(self): + self.t(r"ru'abc\\'", "ru'_L1_'") + + def test_comment(self): + self.t("abc # foo", "abc #_L1_") + + def test_comment_and_quote(self): + self.t("abc # 'x'", "abc #_L1_") + self.t("'abc#'", "'_L1_'") + + def test_include(self): + self.t("include 'a.pxi' # something here", + "include '_L1_' #_L2_") + + def test_extern(self): + self.t("cdef extern from 'a.h': # comment", + "cdef extern from '_L1_': #_L2_") + diff --git a/contrib/tools/cython/Cython/Build/Tests/__init__.py b/contrib/tools/cython/Cython/Build/Tests/__init__.py new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Build/Tests/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Build/__init__.py b/contrib/tools/cython/Cython/Build/__init__.py new file mode 100644 index 00000000000..d6f3986597b --- /dev/null +++ b/contrib/tools/cython/Cython/Build/__init__.py @@ -0,0 +1,2 @@ +from .Dependencies import cythonize +from .Distutils import build_ext diff --git a/contrib/tools/cython/Cython/CodeWriter.py b/contrib/tools/cython/Cython/CodeWriter.py new file mode 100644 index 00000000000..2e4646a6544 --- /dev/null +++ b/contrib/tools/cython/Cython/CodeWriter.py @@ -0,0 +1,816 @@ +""" +Serializes a Cython code tree to Cython code. This is primarily useful for +debugging and testing purposes. + +The output is in a strict format, no whitespace or comments from the input +is preserved (and it could not be as it is not present in the code tree). +""" + +from __future__ import absolute_import, print_function + +from .Compiler.Visitor import TreeVisitor +from .Compiler.ExprNodes import * + + +class LinesResult(object): + def __init__(self): + self.lines = [] + self.s = u"" + + def put(self, s): + self.s += s + + def newline(self): + self.lines.append(self.s) + self.s = u"" + + def putline(self, s): + self.put(s) + self.newline() + +class DeclarationWriter(TreeVisitor): + + indent_string = u" " + + def __init__(self, result=None): + super(DeclarationWriter, self).__init__() + if result is None: + result = LinesResult() + self.result = result + self.numindents = 0 + self.tempnames = {} + self.tempblockindex = 0 + + def write(self, tree): + self.visit(tree) + return self.result + + def indent(self): + self.numindents += 1 + + def dedent(self): + self.numindents -= 1 + + def startline(self, s=u""): + self.result.put(self.indent_string * self.numindents + s) + + def put(self, s): + self.result.put(s) + + def putline(self, s): + self.result.putline(self.indent_string * self.numindents + s) + + def endline(self, s=u""): + self.result.putline(s) + + def line(self, s): + self.startline(s) + self.endline() + + def comma_separated_list(self, items, output_rhs=False): + if len(items) > 0: + for item in items[:-1]: + self.visit(item) + if output_rhs and item.default is not None: + self.put(u" = ") + self.visit(item.default) + self.put(u", ") + self.visit(items[-1]) + + def visit_Node(self, node): + raise AssertionError("Node not handled by serializer: %r" % node) + + def visit_ModuleNode(self, node): + self.visitchildren(node) + + def visit_StatListNode(self, node): + self.visitchildren(node) + + def visit_CDefExternNode(self, node): + if node.include_file is None: + file = u'*' + else: + file = u'"%s"' % node.include_file + self.putline(u"cdef extern from %s:" % file) + self.indent() + self.visit(node.body) + self.dedent() + + def visit_CPtrDeclaratorNode(self, node): + self.put('*') + self.visit(node.base) + + def visit_CReferenceDeclaratorNode(self, node): + self.put('&') + self.visit(node.base) + + def visit_CArrayDeclaratorNode(self, node): + self.visit(node.base) + self.put(u'[') + if node.dimension is not None: + self.visit(node.dimension) + self.put(u']') + + def visit_CArrayDeclaratorNode(self, node): + self.visit(node.base) + self.put(u'[') + if node.dimension is not None: + self.visit(node.dimension) + self.put(u']') + + def visit_CFuncDeclaratorNode(self, node): + # TODO: except, gil, etc. + self.visit(node.base) + self.put(u'(') + self.comma_separated_list(node.args) + self.endline(u')') + + def visit_CNameDeclaratorNode(self, node): + self.put(node.name) + + def visit_CSimpleBaseTypeNode(self, node): + # See Parsing.p_sign_and_longness + if node.is_basic_c_type: + self.put(("unsigned ", "", "signed ")[node.signed]) + if node.longness < 0: + self.put("short " * -node.longness) + elif node.longness > 0: + self.put("long " * node.longness) + self.put(node.name) + + def visit_CComplexBaseTypeNode(self, node): + self.put(u'(') + self.visit(node.base_type) + self.visit(node.declarator) + self.put(u')') + + def visit_CNestedBaseTypeNode(self, node): + self.visit(node.base_type) + self.put(u'.') + self.put(node.name) + + def visit_TemplatedTypeNode(self, node): + self.visit(node.base_type_node) + self.put(u'[') + self.comma_separated_list(node.positional_args + node.keyword_args.key_value_pairs) + self.put(u']') + + def visit_CVarDefNode(self, node): + self.startline(u"cdef ") + self.visit(node.base_type) + self.put(u" ") + self.comma_separated_list(node.declarators, output_rhs=True) + self.endline() + + def visit_container_node(self, node, decl, extras, attributes): + # TODO: visibility + self.startline(decl) + if node.name: + self.put(u' ') + self.put(node.name) + if node.cname is not None: + self.put(u' "%s"' % node.cname) + if extras: + self.put(extras) + self.endline(':') + self.indent() + if not attributes: + self.putline('pass') + else: + for attribute in attributes: + self.visit(attribute) + self.dedent() + + def visit_CStructOrUnionDefNode(self, node): + if node.typedef_flag: + decl = u'ctypedef ' + else: + decl = u'cdef ' + if node.visibility == 'public': + decl += u'public ' + if node.packed: + decl += u'packed ' + decl += node.kind + self.visit_container_node(node, decl, None, node.attributes) + + def visit_CppClassNode(self, node): + extras = "" + if node.templates: + extras = u"[%s]" % ", ".join(node.templates) + if node.base_classes: + extras += "(%s)" % ", ".join(node.base_classes) + self.visit_container_node(node, u"cdef cppclass", extras, node.attributes) + + def visit_CEnumDefNode(self, node): + self.visit_container_node(node, u"cdef enum", None, node.items) + + def visit_CEnumDefItemNode(self, node): + self.startline(node.name) + if node.cname: + self.put(u' "%s"' % node.cname) + if node.value: + self.put(u" = ") + self.visit(node.value) + self.endline() + + def visit_CClassDefNode(self, node): + assert not node.module_name + if node.decorators: + for decorator in node.decorators: + self.visit(decorator) + self.startline(u"cdef class ") + self.put(node.class_name) + if node.base_class_name: + self.put(u"(") + if node.base_class_module: + self.put(node.base_class_module) + self.put(u".") + self.put(node.base_class_name) + self.put(u")") + self.endline(u":") + self.indent() + self.visit(node.body) + self.dedent() + + def visit_CTypeDefNode(self, node): + self.startline(u"ctypedef ") + self.visit(node.base_type) + self.put(u" ") + self.visit(node.declarator) + self.endline() + + def visit_FuncDefNode(self, node): + self.startline(u"def %s(" % node.name) + self.comma_separated_list(node.args) + self.endline(u"):") + self.indent() + self.visit(node.body) + self.dedent() + + def visit_CArgDeclNode(self, node): + if node.base_type.name is not None: + self.visit(node.base_type) + self.put(u" ") + self.visit(node.declarator) + if node.default is not None: + self.put(u" = ") + self.visit(node.default) + + def visit_CImportStatNode(self, node): + self.startline(u"cimport ") + self.put(node.module_name) + if node.as_name: + self.put(u" as ") + self.put(node.as_name) + self.endline() + + def visit_FromCImportStatNode(self, node): + self.startline(u"from ") + self.put(node.module_name) + self.put(u" cimport ") + first = True + for pos, name, as_name, kind in node.imported_names: + assert kind is None + if first: + first = False + else: + self.put(u", ") + self.put(name) + if as_name: + self.put(u" as ") + self.put(as_name) + self.endline() + + def visit_NameNode(self, node): + self.put(node.name) + + def visit_IntNode(self, node): + self.put(node.value) + + def visit_NoneNode(self, node): + self.put(u"None") + + def visit_NotNode(self, node): + self.put(u"(not ") + self.visit(node.operand) + self.put(u")") + + def visit_DecoratorNode(self, node): + self.startline("@") + self.visit(node.decorator) + self.endline() + + def visit_BinopNode(self, node): + self.visit(node.operand1) + self.put(u" %s " % node.operator) + self.visit(node.operand2) + + def visit_AttributeNode(self, node): + self.visit(node.obj) + self.put(u".%s" % node.attribute) + + def visit_BoolNode(self, node): + self.put(str(node.value)) + + # FIXME: represent string nodes correctly + def visit_StringNode(self, node): + value = node.value + if value.encoding is not None: + value = value.encode(value.encoding) + self.put(repr(value)) + + def visit_PassStatNode(self, node): + self.startline(u"pass") + self.endline() + +class CodeWriter(DeclarationWriter): + + def visit_SingleAssignmentNode(self, node): + self.startline() + self.visit(node.lhs) + self.put(u" = ") + self.visit(node.rhs) + self.endline() + + def visit_CascadedAssignmentNode(self, node): + self.startline() + for lhs in node.lhs_list: + self.visit(lhs) + self.put(u" = ") + self.visit(node.rhs) + self.endline() + + def visit_PrintStatNode(self, node): + self.startline(u"print ") + self.comma_separated_list(node.arg_tuple.args) + if not node.append_newline: + self.put(u",") + self.endline() + + def visit_ForInStatNode(self, node): + self.startline(u"for ") + self.visit(node.target) + self.put(u" in ") + self.visit(node.iterator.sequence) + self.endline(u":") + self.indent() + self.visit(node.body) + self.dedent() + if node.else_clause is not None: + self.line(u"else:") + self.indent() + self.visit(node.else_clause) + self.dedent() + + def visit_IfStatNode(self, node): + # The IfClauseNode is handled directly without a separate match + # for clariy. + self.startline(u"if ") + self.visit(node.if_clauses[0].condition) + self.endline(":") + self.indent() + self.visit(node.if_clauses[0].body) + self.dedent() + for clause in node.if_clauses[1:]: + self.startline("elif ") + self.visit(clause.condition) + self.endline(":") + self.indent() + self.visit(clause.body) + self.dedent() + if node.else_clause is not None: + self.line("else:") + self.indent() + self.visit(node.else_clause) + self.dedent() + + def visit_SequenceNode(self, node): + self.comma_separated_list(node.args) # Might need to discover whether we need () around tuples...hmm... + + def visit_SimpleCallNode(self, node): + self.visit(node.function) + self.put(u"(") + self.comma_separated_list(node.args) + self.put(")") + + def visit_GeneralCallNode(self, node): + self.visit(node.function) + self.put(u"(") + posarg = node.positional_args + if isinstance(posarg, AsTupleNode): + self.visit(posarg.arg) + else: + self.comma_separated_list(posarg.args) # TupleNode.args + if node.keyword_args: + if isinstance(node.keyword_args, DictNode): + for i, (name, value) in enumerate(node.keyword_args.key_value_pairs): + if i > 0: + self.put(', ') + self.visit(name) + self.put('=') + self.visit(value) + else: + raise Exception("Not implemented yet") + self.put(u")") + + def visit_ExprStatNode(self, node): + self.startline() + self.visit(node.expr) + self.endline() + + def visit_InPlaceAssignmentNode(self, node): + self.startline() + self.visit(node.lhs) + self.put(u" %s= " % node.operator) + self.visit(node.rhs) + self.endline() + + def visit_WithStatNode(self, node): + self.startline() + self.put(u"with ") + self.visit(node.manager) + if node.target is not None: + self.put(u" as ") + self.visit(node.target) + self.endline(u":") + self.indent() + self.visit(node.body) + self.dedent() + + def visit_TryFinallyStatNode(self, node): + self.line(u"try:") + self.indent() + self.visit(node.body) + self.dedent() + self.line(u"finally:") + self.indent() + self.visit(node.finally_clause) + self.dedent() + + def visit_TryExceptStatNode(self, node): + self.line(u"try:") + self.indent() + self.visit(node.body) + self.dedent() + for x in node.except_clauses: + self.visit(x) + if node.else_clause is not None: + self.visit(node.else_clause) + + def visit_ExceptClauseNode(self, node): + self.startline(u"except") + if node.pattern is not None: + self.put(u" ") + self.visit(node.pattern) + if node.target is not None: + self.put(u", ") + self.visit(node.target) + self.endline(":") + self.indent() + self.visit(node.body) + self.dedent() + + def visit_ReturnStatNode(self, node): + self.startline("return ") + self.visit(node.value) + self.endline() + + def visit_ReraiseStatNode(self, node): + self.line("raise") + + def visit_ImportNode(self, node): + self.put(u"(import %s)" % node.module_name.value) + + def visit_TempsBlockNode(self, node): + """ + Temporaries are output like $1_1', where the first number is + an index of the TempsBlockNode and the second number is an index + of the temporary which that block allocates. + """ + idx = 0 + for handle in node.temps: + self.tempnames[handle] = "$%d_%d" % (self.tempblockindex, idx) + idx += 1 + self.tempblockindex += 1 + self.visit(node.body) + + def visit_TempRefNode(self, node): + self.put(self.tempnames[node.handle]) + + +class PxdWriter(DeclarationWriter): + def __call__(self, node): + print(u'\n'.join(self.write(node).lines)) + return node + + def visit_CFuncDefNode(self, node): + if 'inline' in node.modifiers: + return + if node.overridable: + self.startline(u'cpdef ') + else: + self.startline(u'cdef ') + if node.visibility != 'private': + self.put(node.visibility) + self.put(u' ') + if node.api: + self.put(u'api ') + self.visit(node.declarator) + + def visit_StatNode(self, node): + pass + + +class ExpressionWriter(TreeVisitor): + + def __init__(self, result=None): + super(ExpressionWriter, self).__init__() + if result is None: + result = u"" + self.result = result + self.precedence = [0] + + def write(self, tree): + self.visit(tree) + return self.result + + def put(self, s): + self.result += s + + def remove(self, s): + if self.result.endswith(s): + self.result = self.result[:-len(s)] + + def comma_separated_list(self, items): + if len(items) > 0: + for item in items[:-1]: + self.visit(item) + self.put(u", ") + self.visit(items[-1]) + + def visit_Node(self, node): + raise AssertionError("Node not handled by serializer: %r" % node) + + def visit_NameNode(self, node): + self.put(node.name) + + def visit_NoneNode(self, node): + self.put(u"None") + + def visit_EllipsisNode(self, node): + self.put(u"...") + + def visit_BoolNode(self, node): + self.put(str(node.value)) + + def visit_ConstNode(self, node): + self.put(str(node.value)) + + def visit_ImagNode(self, node): + self.put(node.value) + self.put(u"j") + + def emit_string(self, node, prefix=u""): + repr_val = repr(node.value) + if repr_val[0] in 'ub': + repr_val = repr_val[1:] + self.put(u"%s%s" % (prefix, repr_val)) + + def visit_BytesNode(self, node): + self.emit_string(node, u"b") + + def visit_StringNode(self, node): + self.emit_string(node) + + def visit_UnicodeNode(self, node): + self.emit_string(node, u"u") + + def emit_sequence(self, node, parens=(u"", u"")): + open_paren, close_paren = parens + items = node.subexpr_nodes() + self.put(open_paren) + self.comma_separated_list(items) + self.put(close_paren) + + def visit_ListNode(self, node): + self.emit_sequence(node, u"[]") + + def visit_TupleNode(self, node): + self.emit_sequence(node, u"()") + + def visit_SetNode(self, node): + if len(node.subexpr_nodes()) > 0: + self.emit_sequence(node, u"{}") + else: + self.put(u"set()") + + def visit_DictNode(self, node): + self.emit_sequence(node, u"{}") + + def visit_DictItemNode(self, node): + self.visit(node.key) + self.put(u": ") + self.visit(node.value) + + unop_precedence = { + 'not': 3, '!': 3, + '+': 11, '-': 11, '~': 11, + } + binop_precedence = { + 'or': 1, + 'and': 2, + # unary: 'not': 3, '!': 3, + 'in': 4, 'not_in': 4, 'is': 4, 'is_not': 4, '<': 4, '<=': 4, '>': 4, '>=': 4, '!=': 4, '==': 4, + '|': 5, + '^': 6, + '&': 7, + '<<': 8, '>>': 8, + '+': 9, '-': 9, + '*': 10, '@': 10, '/': 10, '//': 10, '%': 10, + # unary: '+': 11, '-': 11, '~': 11 + '**': 12, + } + + def operator_enter(self, new_prec): + old_prec = self.precedence[-1] + if old_prec > new_prec: + self.put(u"(") + self.precedence.append(new_prec) + + def operator_exit(self): + old_prec, new_prec = self.precedence[-2:] + if old_prec > new_prec: + self.put(u")") + self.precedence.pop() + + def visit_NotNode(self, node): + op = 'not' + prec = self.unop_precedence[op] + self.operator_enter(prec) + self.put(u"not ") + self.visit(node.operand) + self.operator_exit() + + def visit_UnopNode(self, node): + op = node.operator + prec = self.unop_precedence[op] + self.operator_enter(prec) + self.put(u"%s" % node.operator) + self.visit(node.operand) + self.operator_exit() + + def visit_BinopNode(self, node): + op = node.operator + prec = self.binop_precedence.get(op, 0) + self.operator_enter(prec) + self.visit(node.operand1) + self.put(u" %s " % op.replace('_', ' ')) + self.visit(node.operand2) + self.operator_exit() + + def visit_BoolBinopNode(self, node): + self.visit_BinopNode(node) + + def visit_PrimaryCmpNode(self, node): + self.visit_BinopNode(node) + + def visit_IndexNode(self, node): + self.visit(node.base) + self.put(u"[") + if isinstance(node.index, TupleNode): + self.emit_sequence(node.index) + else: + self.visit(node.index) + self.put(u"]") + + def visit_SliceIndexNode(self, node): + self.visit(node.base) + self.put(u"[") + if node.start: + self.visit(node.start) + self.put(u":") + if node.stop: + self.visit(node.stop) + if node.slice: + self.put(u":") + self.visit(node.slice) + self.put(u"]") + + def visit_SliceNode(self, node): + if not node.start.is_none: + self.visit(node.start) + self.put(u":") + if not node.stop.is_none: + self.visit(node.stop) + if not node.step.is_none: + self.put(u":") + self.visit(node.step) + + def visit_CondExprNode(self, node): + self.visit(node.true_val) + self.put(u" if ") + self.visit(node.test) + self.put(u" else ") + self.visit(node.false_val) + + def visit_AttributeNode(self, node): + self.visit(node.obj) + self.put(u".%s" % node.attribute) + + def visit_SimpleCallNode(self, node): + self.visit(node.function) + self.put(u"(") + self.comma_separated_list(node.args) + self.put(")") + + def emit_pos_args(self, node): + if node is None: + return + if isinstance(node, AddNode): + self.emit_pos_args(node.operand1) + self.emit_pos_args(node.operand2) + elif isinstance(node, TupleNode): + for expr in node.subexpr_nodes(): + self.visit(expr) + self.put(u", ") + elif isinstance(node, AsTupleNode): + self.put("*") + self.visit(node.arg) + self.put(u", ") + else: + self.visit(node) + self.put(u", ") + + def emit_kwd_args(self, node): + if node is None: + return + if isinstance(node, MergedDictNode): + for expr in node.subexpr_nodes(): + self.emit_kwd_args(expr) + elif isinstance(node, DictNode): + for expr in node.subexpr_nodes(): + self.put(u"%s=" % expr.key.value) + self.visit(expr.value) + self.put(u", ") + else: + self.put(u"**") + self.visit(node) + self.put(u", ") + + def visit_GeneralCallNode(self, node): + self.visit(node.function) + self.put(u"(") + self.emit_pos_args(node.positional_args) + self.emit_kwd_args(node.keyword_args) + self.remove(u", ") + self.put(")") + + def emit_comprehension(self, body, target, + sequence, condition, + parens=(u"", u"")): + open_paren, close_paren = parens + self.put(open_paren) + self.visit(body) + self.put(u" for ") + self.visit(target) + self.put(u" in ") + self.visit(sequence) + if condition: + self.put(u" if ") + self.visit(condition) + self.put(close_paren) + + def visit_ComprehensionAppendNode(self, node): + self.visit(node.expr) + + def visit_DictComprehensionAppendNode(self, node): + self.visit(node.key_expr) + self.put(u": ") + self.visit(node.value_expr) + + def visit_ComprehensionNode(self, node): + tpmap = {'list': u"[]", 'dict': u"{}", 'set': u"{}"} + parens = tpmap[node.type.py_type_name()] + body = node.loop.body + target = node.loop.target + sequence = node.loop.iterator.sequence + condition = None + if hasattr(body, 'if_clauses'): + # type(body) is Nodes.IfStatNode + condition = body.if_clauses[0].condition + body = body.if_clauses[0].body + self.emit_comprehension(body, target, sequence, condition, parens) + + def visit_GeneratorExpressionNode(self, node): + body = node.loop.body + target = node.loop.target + sequence = node.loop.iterator.sequence + condition = None + if hasattr(body, 'if_clauses'): + # type(body) is Nodes.IfStatNode + condition = body.if_clauses[0].condition + body = body.if_clauses[0].body.expr.arg + elif hasattr(body, 'expr'): + # type(body) is Nodes.ExprStatNode + body = body.expr.arg + self.emit_comprehension(body, target, sequence, condition, u"()") diff --git a/contrib/tools/cython/Cython/Compiler/AnalysedTreeTransforms.py b/contrib/tools/cython/Cython/Compiler/AnalysedTreeTransforms.py new file mode 100644 index 00000000000..07bf31f3e06 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/AnalysedTreeTransforms.py @@ -0,0 +1,99 @@ +from __future__ import absolute_import + +from .Visitor import ScopeTrackingTransform +from .Nodes import StatListNode, SingleAssignmentNode, CFuncDefNode, DefNode +from .ExprNodes import DictNode, DictItemNode, NameNode, UnicodeNode +from .PyrexTypes import py_object_type +from .StringEncoding import EncodedString +from . import Symtab + +class AutoTestDictTransform(ScopeTrackingTransform): + # Handles autotestdict directive + + blacklist = ['__cinit__', '__dealloc__', '__richcmp__', + '__nonzero__', '__bool__', + '__len__', '__contains__'] + + def visit_ModuleNode(self, node): + if node.is_pxd: + return node + self.scope_type = 'module' + self.scope_node = node + + if not self.current_directives['autotestdict']: + return node + self.all_docstrings = self.current_directives['autotestdict.all'] + self.cdef_docstrings = self.all_docstrings or self.current_directives['autotestdict.cdef'] + + assert isinstance(node.body, StatListNode) + + # First see if __test__ is already created + if u'__test__' in node.scope.entries: + # Do nothing + return node + + pos = node.pos + + self.tests = [] + self.testspos = node.pos + + test_dict_entry = node.scope.declare_var(EncodedString(u'__test__'), + py_object_type, + pos, + visibility='public') + create_test_dict_assignment = SingleAssignmentNode(pos, + lhs=NameNode(pos, name=EncodedString(u'__test__'), + entry=test_dict_entry), + rhs=DictNode(pos, key_value_pairs=self.tests)) + self.visitchildren(node) + node.body.stats.append(create_test_dict_assignment) + return node + + def add_test(self, testpos, path, doctest): + pos = self.testspos + keystr = u'%s (line %d)' % (path, testpos[1]) + key = UnicodeNode(pos, value=EncodedString(keystr)) + value = UnicodeNode(pos, value=doctest) + self.tests.append(DictItemNode(pos, key=key, value=value)) + + def visit_ExprNode(self, node): + # expressions cannot contain functions and lambda expressions + # do not have a docstring + return node + + def visit_FuncDefNode(self, node): + if not node.doc or (isinstance(node, DefNode) and node.fused_py_func): + return node + if not self.cdef_docstrings: + if isinstance(node, CFuncDefNode) and not node.py_func: + return node + if not self.all_docstrings and '>>>' not in node.doc: + return node + + pos = self.testspos + if self.scope_type == 'module': + path = node.entry.name + elif self.scope_type in ('pyclass', 'cclass'): + if isinstance(node, CFuncDefNode): + if node.py_func is not None: + name = node.py_func.name + else: + name = node.entry.name + else: + name = node.name + if self.scope_type == 'cclass' and name in self.blacklist: + return node + if self.scope_type == 'pyclass': + class_name = self.scope_node.name + else: + class_name = self.scope_node.class_name + if isinstance(node.entry.scope, Symtab.PropertyScope): + property_method_name = node.entry.scope.name + path = "%s.%s.%s" % (class_name, node.entry.scope.name, + node.entry.name) + else: + path = "%s.%s" % (class_name, node.entry.name) + else: + assert False + self.add_test(node.pos, path, node.doc) + return node diff --git a/contrib/tools/cython/Cython/Compiler/Annotate.py b/contrib/tools/cython/Cython/Compiler/Annotate.py new file mode 100644 index 00000000000..2ea38c00c74 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Annotate.py @@ -0,0 +1,320 @@ +# Note: Work in progress + +from __future__ import absolute_import + +import os +import os.path +import re +import codecs +import textwrap +from datetime import datetime +from functools import partial +from collections import defaultdict +try: + from xml.sax.saxutils import escape as html_escape +except ImportError: + pass +try: + from StringIO import StringIO +except ImportError: + from io import StringIO # does not support writing 'str' in Py2 + +from . import Version +from .Code import CCodeWriter +from .. import Utils + + +class AnnotationCCodeWriter(CCodeWriter): + + def __init__(self, create_from=None, buffer=None, copy_formatting=True): + CCodeWriter.__init__(self, create_from, buffer, copy_formatting=copy_formatting) + if create_from is None: + self.annotation_buffer = StringIO() + self.last_annotated_pos = None + # annotations[filename][line] -> [(column, AnnotationItem)*] + self.annotations = defaultdict(partial(defaultdict, list)) + # code[filename][line] -> str + self.code = defaultdict(partial(defaultdict, str)) + # scopes[filename][line] -> set(scopes) + self.scopes = defaultdict(partial(defaultdict, set)) + else: + # When creating an insertion point, keep references to the same database + self.annotation_buffer = create_from.annotation_buffer + self.annotations = create_from.annotations + self.code = create_from.code + self.scopes = create_from.scopes + self.last_annotated_pos = create_from.last_annotated_pos + + def create_new(self, create_from, buffer, copy_formatting): + return AnnotationCCodeWriter(create_from, buffer, copy_formatting) + + def write(self, s): + CCodeWriter.write(self, s) + self.annotation_buffer.write(s) + + def mark_pos(self, pos, trace=True): + if pos is not None: + CCodeWriter.mark_pos(self, pos, trace) + if self.funcstate and self.funcstate.scope: + # lambdas and genexprs can result in multiple scopes per line => keep them in a set + self.scopes[pos[0].filename][pos[1]].add(self.funcstate.scope) + if self.last_annotated_pos: + source_desc, line, _ = self.last_annotated_pos + pos_code = self.code[source_desc.filename] + pos_code[line] += self.annotation_buffer.getvalue() + self.annotation_buffer = StringIO() + self.last_annotated_pos = pos + + def annotate(self, pos, item): + self.annotations[pos[0].filename][pos[1]].append((pos[2], item)) + + def _css(self): + """css template will later allow to choose a colormap""" + css = [self._css_template] + for i in range(255): + color = u"FFFF%02x" % int(255/(1+i/10.0)) + css.append('.cython.score-%d {background-color: #%s;}' % (i, color)) + try: + from pygments.formatters import HtmlFormatter + except ImportError: + pass + else: + css.append(HtmlFormatter().get_style_defs('.cython')) + return '\n'.join(css) + + _css_template = textwrap.dedent(""" + body.cython { font-family: courier; font-size: 12; } + + .cython.tag { } + .cython.line { margin: 0em } + .cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; } + + .cython.line .run { background-color: #B0FFB0; } + .cython.line .mis { background-color: #FFB0B0; } + .cython.code.run { border-left: 8px solid #B0FFB0; } + .cython.code.mis { border-left: 8px solid #FFB0B0; } + + .cython.code .py_c_api { color: red; } + .cython.code .py_macro_api { color: #FF7000; } + .cython.code .pyx_c_api { color: #FF3000; } + .cython.code .pyx_macro_api { color: #FF7000; } + .cython.code .refnanny { color: #FFA000; } + .cython.code .trace { color: #FFA000; } + .cython.code .error_goto { color: #FFA000; } + + .cython.code .coerce { color: #008000; border: 1px dotted #008000 } + .cython.code .py_attr { color: #FF0000; font-weight: bold; } + .cython.code .c_attr { color: #0000FF; } + .cython.code .py_call { color: #FF0000; font-weight: bold; } + .cython.code .c_call { color: #0000FF; } + """) + + # on-click toggle function to show/hide C source code + _onclick_attr = ' onclick="{0}"'.format(( + "(function(s){" + " s.display = s.display === 'block' ? 'none' : 'block'" + "})(this.nextElementSibling.style)" + ).replace(' ', '') # poor dev's JS minification + ) + + def save_annotation(self, source_filename, target_filename, coverage_xml=None): + with Utils.open_source_file(source_filename) as f: + code = f.read() + generated_code = self.code.get(source_filename, {}) + c_file = Utils.decode_filename(os.path.basename(target_filename)) + html_filename = os.path.splitext(target_filename)[0] + ".html" + + with codecs.open(html_filename, "w", encoding="UTF-8") as out_buffer: + out_buffer.write(self._save_annotation(code, generated_code, c_file, source_filename, coverage_xml)) + + def _save_annotation_header(self, c_file, source_filename, coverage_timestamp=None): + coverage_info = '' + if coverage_timestamp: + coverage_info = u' with coverage data from {timestamp}'.format( + timestamp=datetime.fromtimestamp(int(coverage_timestamp) // 1000)) + + outlist = [ + textwrap.dedent(u'''\ + <!DOCTYPE html> + <!-- Generated by Cython {watermark} --> + <html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Cython: {filename}</title> + <style type="text/css"> + {css} + </style> + </head> + <body class="cython"> + <p><span style="border-bottom: solid 1px grey;">Generated by Cython {watermark}</span>{more_info}</p> + <p> + <span style="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br /> + Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it. + </p> + ''').format(css=self._css(), watermark=Version.watermark, + filename=os.path.basename(source_filename) if source_filename else '', + more_info=coverage_info) + ] + if c_file: + outlist.append(u'<p>Raw output: <a href="%s">%s</a></p>\n' % (c_file, c_file)) + return outlist + + def _save_annotation_footer(self): + return (u'</body></html>\n',) + + def _save_annotation(self, code, generated_code, c_file=None, source_filename=None, coverage_xml=None): + """ + lines : original cython source code split by lines + generated_code : generated c code keyed by line number in original file + target filename : name of the file in which to store the generated html + c_file : filename in which the c_code has been written + """ + if coverage_xml is not None and source_filename: + coverage_timestamp = coverage_xml.get('timestamp', '').strip() + covered_lines = self._get_line_coverage(coverage_xml, source_filename) + else: + coverage_timestamp = covered_lines = None + annotation_items = dict(self.annotations[source_filename]) + scopes = dict(self.scopes[source_filename]) + + outlist = [] + outlist.extend(self._save_annotation_header(c_file, source_filename, coverage_timestamp)) + outlist.extend(self._save_annotation_body(code, generated_code, annotation_items, scopes, covered_lines)) + outlist.extend(self._save_annotation_footer()) + return ''.join(outlist) + + def _get_line_coverage(self, coverage_xml, source_filename): + coverage_data = None + for entry in coverage_xml.iterfind('.//class'): + if not entry.get('filename'): + continue + if (entry.get('filename') == source_filename or + os.path.abspath(entry.get('filename')) == source_filename): + coverage_data = entry + break + elif source_filename.endswith(entry.get('filename')): + coverage_data = entry # but we might still find a better match... + if coverage_data is None: + return None + return dict( + (int(line.get('number')), int(line.get('hits'))) + for line in coverage_data.iterfind('lines/line') + ) + + def _htmlify_code(self, code): + try: + from pygments import highlight + from pygments.lexers import CythonLexer + from pygments.formatters import HtmlFormatter + except ImportError: + # no Pygments, just escape the code + return html_escape(code) + + html_code = highlight( + code, CythonLexer(stripnl=False, stripall=False), + HtmlFormatter(nowrap=True)) + return html_code + + def _save_annotation_body(self, cython_code, generated_code, annotation_items, scopes, covered_lines=None): + outlist = [u'<div class="cython">'] + pos_comment_marker = u'/* \N{HORIZONTAL ELLIPSIS} */\n' + new_calls_map = dict( + (name, 0) for name in + 'refnanny trace py_macro_api py_c_api pyx_macro_api pyx_c_api error_goto'.split() + ).copy + + self.mark_pos(None) + + def annotate(match): + group_name = match.lastgroup + calls[group_name] += 1 + return u"<span class='%s'>%s</span>" % ( + group_name, match.group(group_name)) + + lines = self._htmlify_code(cython_code).splitlines() + lineno_width = len(str(len(lines))) + if not covered_lines: + covered_lines = None + + for k, line in enumerate(lines, 1): + try: + c_code = generated_code[k] + except KeyError: + c_code = '' + else: + c_code = _replace_pos_comment(pos_comment_marker, c_code) + if c_code.startswith(pos_comment_marker): + c_code = c_code[len(pos_comment_marker):] + c_code = html_escape(c_code) + + calls = new_calls_map() + c_code = _parse_code(annotate, c_code) + score = (5 * calls['py_c_api'] + 2 * calls['pyx_c_api'] + + calls['py_macro_api'] + calls['pyx_macro_api']) + + if c_code: + onclick = self._onclick_attr + expandsymbol = '+' + else: + onclick = '' + expandsymbol = ' ' + + covered = '' + if covered_lines is not None and k in covered_lines: + hits = covered_lines[k] + if hits is not None: + covered = 'run' if hits else 'mis' + + outlist.append( + u'<pre class="cython line score-{score}"{onclick}>' + # generate line number with expand symbol in front, + # and the right number of digit + u'{expandsymbol}<span class="{covered}">{line:0{lineno_width}d}</span>: {code}</pre>\n'.format( + score=score, + expandsymbol=expandsymbol, + covered=covered, + lineno_width=lineno_width, + line=k, + code=line.rstrip(), + onclick=onclick, + )) + if c_code: + outlist.append(u"<pre class='cython code score-{score} {covered}'>{code}</pre>".format( + score=score, covered=covered, code=c_code)) + outlist.append(u"</div>") + return outlist + + +_parse_code = re.compile(( + br'(?P<refnanny>__Pyx_X?(?:GOT|GIVE)REF|__Pyx_RefNanny[A-Za-z]+)|' + br'(?P<trace>__Pyx_Trace[A-Za-z]+)|' + br'(?:' + br'(?P<pyx_macro_api>__Pyx_[A-Z][A-Z_]+)|' + br'(?P<pyx_c_api>(?:__Pyx_[A-Z][a-z_][A-Za-z_]*)|__pyx_convert_[A-Za-z_]*)|' + br'(?P<py_macro_api>Py[A-Z][a-z]+_[A-Z][A-Z_]+)|' + br'(?P<py_c_api>Py[A-Z][a-z]+_[A-Z][a-z][A-Za-z_]*)' + br')(?=\()|' # look-ahead to exclude subsequent '(' from replacement + br'(?P<error_goto>(?:(?<=;) *if [^;]* +)?__PYX_ERR\([^)]+\))' +).decode('ascii')).sub + + +_replace_pos_comment = re.compile( + # this matches what Cython generates as code line marker comment + br'^\s*/\*(?:(?:[^*]|\*[^/])*\n)+\s*\*/\s*\n'.decode('ascii'), + re.M +).sub + + +class AnnotationItem(object): + + def __init__(self, style, text, tag="", size=0): + self.style = style + self.text = text + self.tag = tag + self.size = size + + def start(self): + return u"<span class='cython tag %s' title='%s'>%s" % (self.style, self.text, self.tag) + + def end(self): + return self.size, u"</span>" diff --git a/contrib/tools/cython/Cython/Compiler/AutoDocTransforms.py b/contrib/tools/cython/Cython/Compiler/AutoDocTransforms.py new file mode 100644 index 00000000000..d3c0a1d0da4 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/AutoDocTransforms.py @@ -0,0 +1,214 @@ +from __future__ import absolute_import, print_function + +from .Visitor import CythonTransform +from .StringEncoding import EncodedString +from . import Options +from . import PyrexTypes, ExprNodes +from ..CodeWriter import ExpressionWriter + + +class AnnotationWriter(ExpressionWriter): + + def visit_Node(self, node): + self.put(u"<???>") + + def visit_LambdaNode(self, node): + # XXX Should we do better? + self.put("<lambda>") + + +class EmbedSignature(CythonTransform): + + def __init__(self, context): + super(EmbedSignature, self).__init__(context) + self.class_name = None + self.class_node = None + + def _fmt_expr(self, node): + writer = AnnotationWriter() + result = writer.write(node) + # print(type(node).__name__, '-->', result) + return result + + def _fmt_arg(self, arg): + if arg.type is PyrexTypes.py_object_type or arg.is_self_arg: + doc = arg.name + else: + doc = arg.type.declaration_code(arg.name, for_display=1) + + if arg.annotation: + annotation = self._fmt_expr(arg.annotation) + doc = doc + (': %s' % annotation) + if arg.default: + default = self._fmt_expr(arg.default) + doc = doc + (' = %s' % default) + elif arg.default: + default = self._fmt_expr(arg.default) + doc = doc + ('=%s' % default) + return doc + + def _fmt_star_arg(self, arg): + arg_doc = arg.name + if arg.annotation: + annotation = self._fmt_expr(arg.annotation) + arg_doc = arg_doc + (': %s' % annotation) + return arg_doc + + def _fmt_arglist(self, args, + npargs=0, pargs=None, + nkargs=0, kargs=None, + hide_self=False): + arglist = [] + for arg in args: + if not hide_self or not arg.entry.is_self_arg: + arg_doc = self._fmt_arg(arg) + arglist.append(arg_doc) + if pargs: + arg_doc = self._fmt_star_arg(pargs) + arglist.insert(npargs, '*%s' % arg_doc) + elif nkargs: + arglist.insert(npargs, '*') + if kargs: + arg_doc = self._fmt_star_arg(kargs) + arglist.append('**%s' % arg_doc) + return arglist + + def _fmt_ret_type(self, ret): + if ret is PyrexTypes.py_object_type: + return None + else: + return ret.declaration_code("", for_display=1) + + def _fmt_signature(self, cls_name, func_name, args, + npargs=0, pargs=None, + nkargs=0, kargs=None, + return_expr=None, + return_type=None, hide_self=False): + arglist = self._fmt_arglist(args, + npargs, pargs, + nkargs, kargs, + hide_self=hide_self) + arglist_doc = ', '.join(arglist) + func_doc = '%s(%s)' % (func_name, arglist_doc) + if cls_name: + func_doc = '%s.%s' % (cls_name, func_doc) + ret_doc = None + if return_expr: + ret_doc = self._fmt_expr(return_expr) + elif return_type: + ret_doc = self._fmt_ret_type(return_type) + if ret_doc: + func_doc = '%s -> %s' % (func_doc, ret_doc) + return func_doc + + def _embed_signature(self, signature, node_doc): + if node_doc: + return "%s\n%s" % (signature, node_doc) + else: + return signature + + def __call__(self, node): + if not Options.docstrings: + return node + else: + return super(EmbedSignature, self).__call__(node) + + def visit_ClassDefNode(self, node): + oldname = self.class_name + oldclass = self.class_node + self.class_node = node + try: + # PyClassDefNode + self.class_name = node.name + except AttributeError: + # CClassDefNode + self.class_name = node.class_name + self.visitchildren(node) + self.class_name = oldname + self.class_node = oldclass + return node + + def visit_LambdaNode(self, node): + # lambda expressions so not have signature or inner functions + return node + + def visit_DefNode(self, node): + if not self.current_directives['embedsignature']: + return node + + is_constructor = False + hide_self = False + if node.entry.is_special: + is_constructor = self.class_node and node.name == '__init__' + if not is_constructor: + return node + class_name, func_name = None, self.class_name + hide_self = True + else: + class_name, func_name = self.class_name, node.name + + nkargs = getattr(node, 'num_kwonly_args', 0) + npargs = len(node.args) - nkargs + signature = self._fmt_signature( + class_name, func_name, node.args, + npargs, node.star_arg, + nkargs, node.starstar_arg, + return_expr=node.return_type_annotation, + return_type=None, hide_self=hide_self) + if signature: + if is_constructor: + doc_holder = self.class_node.entry.type.scope + else: + doc_holder = node.entry + + if doc_holder.doc is not None: + old_doc = doc_holder.doc + elif not is_constructor and getattr(node, 'py_func', None) is not None: + old_doc = node.py_func.entry.doc + else: + old_doc = None + new_doc = self._embed_signature(signature, old_doc) + doc_holder.doc = EncodedString(new_doc) + if not is_constructor and getattr(node, 'py_func', None) is not None: + node.py_func.entry.doc = EncodedString(new_doc) + return node + + def visit_CFuncDefNode(self, node): + if not self.current_directives['embedsignature']: + return node + if not node.overridable: # not cpdef FOO(...): + return node + + signature = self._fmt_signature( + self.class_name, node.declarator.base.name, + node.declarator.args, + return_type=node.return_type) + if signature: + if node.entry.doc is not None: + old_doc = node.entry.doc + elif getattr(node, 'py_func', None) is not None: + old_doc = node.py_func.entry.doc + else: + old_doc = None + new_doc = self._embed_signature(signature, old_doc) + node.entry.doc = EncodedString(new_doc) + if hasattr(node, 'py_func') and node.py_func is not None: + node.py_func.entry.doc = EncodedString(new_doc) + return node + + def visit_PropertyNode(self, node): + if not self.current_directives['embedsignature']: + return node + + entry = node.entry + if entry.visibility == 'public': + # property synthesised from a cdef public attribute + type_name = entry.type.declaration_code("", for_display=1) + if not entry.type.is_pyobject: + type_name = "'%s'" % type_name + elif entry.type.is_extension_type: + type_name = entry.type.module_name + '.' + type_name + signature = '%s: %s' % (entry.name, type_name) + new_doc = self._embed_signature(signature, entry.doc) + entry.doc = EncodedString(new_doc) + return node diff --git a/contrib/tools/cython/Cython/Compiler/Buffer.py b/contrib/tools/cython/Cython/Compiler/Buffer.py new file mode 100644 index 00000000000..c62a24f5686 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Buffer.py @@ -0,0 +1,740 @@ +from __future__ import absolute_import + +from .Visitor import CythonTransform +from .ModuleNode import ModuleNode +from .Errors import CompileError +from .UtilityCode import CythonUtilityCode +from .Code import UtilityCode, TempitaUtilityCode + +from . import Options +from . import Interpreter +from . import PyrexTypes +from . import Naming +from . import Symtab + +def dedent(text, reindent=0): + from textwrap import dedent + text = dedent(text) + if reindent > 0: + indent = " " * reindent + text = '\n'.join([indent + x for x in text.split('\n')]) + return text + +class IntroduceBufferAuxiliaryVars(CythonTransform): + + # + # Entry point + # + + buffers_exists = False + using_memoryview = False + + def __call__(self, node): + assert isinstance(node, ModuleNode) + self.max_ndim = 0 + result = super(IntroduceBufferAuxiliaryVars, self).__call__(node) + if self.buffers_exists: + use_bufstruct_declare_code(node.scope) + use_py2_buffer_functions(node.scope) + + return result + + + # + # Basic operations for transforms + # + def handle_scope(self, node, scope): + # For all buffers, insert extra variables in the scope. + # The variables are also accessible from the buffer_info + # on the buffer entry + scope_items = scope.entries.items() + bufvars = [entry for name, entry in scope_items if entry.type.is_buffer] + if len(bufvars) > 0: + bufvars.sort(key=lambda entry: entry.name) + self.buffers_exists = True + + memviewslicevars = [entry for name, entry in scope_items if entry.type.is_memoryviewslice] + if len(memviewslicevars) > 0: + self.buffers_exists = True + + + for (name, entry) in scope_items: + if name == 'memoryview' and isinstance(entry.utility_code_definition, CythonUtilityCode): + self.using_memoryview = True + break + del scope_items + + if isinstance(node, ModuleNode) and len(bufvars) > 0: + # for now...note that pos is wrong + raise CompileError(node.pos, "Buffer vars not allowed in module scope") + for entry in bufvars: + if entry.type.dtype.is_ptr: + raise CompileError(node.pos, "Buffers with pointer types not yet supported.") + + name = entry.name + buftype = entry.type + if buftype.ndim > Options.buffer_max_dims: + raise CompileError(node.pos, + "Buffer ndims exceeds Options.buffer_max_dims = %d" % Options.buffer_max_dims) + if buftype.ndim > self.max_ndim: + self.max_ndim = buftype.ndim + + # Declare auxiliary vars + def decvar(type, prefix): + cname = scope.mangle(prefix, name) + aux_var = scope.declare_var(name=None, cname=cname, + type=type, pos=node.pos) + if entry.is_arg: + aux_var.used = True # otherwise, NameNode will mark whether it is used + + return aux_var + + auxvars = ((PyrexTypes.c_pyx_buffer_nd_type, Naming.pybuffernd_prefix), + (PyrexTypes.c_pyx_buffer_type, Naming.pybufferstruct_prefix)) + pybuffernd, rcbuffer = [decvar(type, prefix) for (type, prefix) in auxvars] + + entry.buffer_aux = Symtab.BufferAux(pybuffernd, rcbuffer) + + scope.buffer_entries = bufvars + self.scope = scope + + def visit_ModuleNode(self, node): + self.handle_scope(node, node.scope) + self.visitchildren(node) + return node + + def visit_FuncDefNode(self, node): + self.handle_scope(node, node.local_scope) + self.visitchildren(node) + return node + +# +# Analysis +# +buffer_options = ("dtype", "ndim", "mode", "negative_indices", "cast") # ordered! +buffer_defaults = {"ndim": 1, "mode": "full", "negative_indices": True, "cast": False} +buffer_positional_options_count = 1 # anything beyond this needs keyword argument + +ERR_BUF_OPTION_UNKNOWN = '"%s" is not a buffer option' +ERR_BUF_TOO_MANY = 'Too many buffer options' +ERR_BUF_DUP = '"%s" buffer option already supplied' +ERR_BUF_MISSING = '"%s" missing' +ERR_BUF_MODE = 'Only allowed buffer modes are: "c", "fortran", "full", "strided" (as a compile-time string)' +ERR_BUF_NDIM = 'ndim must be a non-negative integer' +ERR_BUF_DTYPE = 'dtype must be "object", numeric type or a struct' +ERR_BUF_BOOL = '"%s" must be a boolean' + +def analyse_buffer_options(globalpos, env, posargs, dictargs, defaults=None, need_complete=True): + """ + Must be called during type analysis, as analyse is called + on the dtype argument. + + posargs and dictargs should consist of a list and a dict + of tuples (value, pos). Defaults should be a dict of values. + + Returns a dict containing all the options a buffer can have and + its value (with the positions stripped). + """ + if defaults is None: + defaults = buffer_defaults + + posargs, dictargs = Interpreter.interpret_compiletime_options( + posargs, dictargs, type_env=env, type_args=(0, 'dtype')) + + if len(posargs) > buffer_positional_options_count: + raise CompileError(posargs[-1][1], ERR_BUF_TOO_MANY) + + options = {} + for name, (value, pos) in dictargs.items(): + if not name in buffer_options: + raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name) + options[name] = value + + for name, (value, pos) in zip(buffer_options, posargs): + if not name in buffer_options: + raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name) + if name in options: + raise CompileError(pos, ERR_BUF_DUP % name) + options[name] = value + + # Check that they are all there and copy defaults + for name in buffer_options: + if not name in options: + try: + options[name] = defaults[name] + except KeyError: + if need_complete: + raise CompileError(globalpos, ERR_BUF_MISSING % name) + + dtype = options.get("dtype") + if dtype and dtype.is_extension_type: + raise CompileError(globalpos, ERR_BUF_DTYPE) + + ndim = options.get("ndim") + if ndim and (not isinstance(ndim, int) or ndim < 0): + raise CompileError(globalpos, ERR_BUF_NDIM) + + mode = options.get("mode") + if mode and not (mode in ('full', 'strided', 'c', 'fortran')): + raise CompileError(globalpos, ERR_BUF_MODE) + + def assert_bool(name): + x = options.get(name) + if not isinstance(x, bool): + raise CompileError(globalpos, ERR_BUF_BOOL % name) + + assert_bool('negative_indices') + assert_bool('cast') + + return options + + +# +# Code generation +# + +class BufferEntry(object): + def __init__(self, entry): + self.entry = entry + self.type = entry.type + self.cname = entry.buffer_aux.buflocal_nd_var.cname + self.buf_ptr = "%s.rcbuffer->pybuffer.buf" % self.cname + self.buf_ptr_type = entry.type.buffer_ptr_type + self.init_attributes() + + def init_attributes(self): + self.shape = self.get_buf_shapevars() + self.strides = self.get_buf_stridevars() + self.suboffsets = self.get_buf_suboffsetvars() + + def get_buf_suboffsetvars(self): + return self._for_all_ndim("%s.diminfo[%d].suboffsets") + + def get_buf_stridevars(self): + return self._for_all_ndim("%s.diminfo[%d].strides") + + def get_buf_shapevars(self): + return self._for_all_ndim("%s.diminfo[%d].shape") + + def _for_all_ndim(self, s): + return [s % (self.cname, i) for i in range(self.type.ndim)] + + def generate_buffer_lookup_code(self, code, index_cnames): + # Create buffer lookup and return it + # This is done via utility macros/inline functions, which vary + # according to the access mode used. + params = [] + nd = self.type.ndim + mode = self.type.mode + if mode == 'full': + for i, s, o in zip(index_cnames, + self.get_buf_stridevars(), + self.get_buf_suboffsetvars()): + params.append(i) + params.append(s) + params.append(o) + funcname = "__Pyx_BufPtrFull%dd" % nd + funcgen = buf_lookup_full_code + else: + if mode == 'strided': + funcname = "__Pyx_BufPtrStrided%dd" % nd + funcgen = buf_lookup_strided_code + elif mode == 'c': + funcname = "__Pyx_BufPtrCContig%dd" % nd + funcgen = buf_lookup_c_code + elif mode == 'fortran': + funcname = "__Pyx_BufPtrFortranContig%dd" % nd + funcgen = buf_lookup_fortran_code + else: + assert False + for i, s in zip(index_cnames, self.get_buf_stridevars()): + params.append(i) + params.append(s) + + # Make sure the utility code is available + if funcname not in code.globalstate.utility_codes: + code.globalstate.utility_codes.add(funcname) + protocode = code.globalstate['utility_code_proto'] + defcode = code.globalstate['utility_code_def'] + funcgen(protocode, defcode, name=funcname, nd=nd) + + buf_ptr_type_code = self.buf_ptr_type.empty_declaration_code() + ptrcode = "%s(%s, %s, %s)" % (funcname, buf_ptr_type_code, self.buf_ptr, + ", ".join(params)) + return ptrcode + + +def get_flags(buffer_aux, buffer_type): + flags = 'PyBUF_FORMAT' + mode = buffer_type.mode + if mode == 'full': + flags += '| PyBUF_INDIRECT' + elif mode == 'strided': + flags += '| PyBUF_STRIDES' + elif mode == 'c': + flags += '| PyBUF_C_CONTIGUOUS' + elif mode == 'fortran': + flags += '| PyBUF_F_CONTIGUOUS' + else: + assert False + if buffer_aux.writable_needed: flags += "| PyBUF_WRITABLE" + return flags + +def used_buffer_aux_vars(entry): + buffer_aux = entry.buffer_aux + buffer_aux.buflocal_nd_var.used = True + buffer_aux.rcbuf_var.used = True + +def put_unpack_buffer_aux_into_scope(buf_entry, code): + # Generate code to copy the needed struct info into local + # variables. + buffer_aux, mode = buf_entry.buffer_aux, buf_entry.type.mode + pybuffernd_struct = buffer_aux.buflocal_nd_var.cname + + fldnames = ['strides', 'shape'] + if mode == 'full': + fldnames.append('suboffsets') + + ln = [] + for i in range(buf_entry.type.ndim): + for fldname in fldnames: + ln.append("%s.diminfo[%d].%s = %s.rcbuffer->pybuffer.%s[%d];" % \ + (pybuffernd_struct, i, fldname, + pybuffernd_struct, fldname, i)) + code.putln(' '.join(ln)) + +def put_init_vars(entry, code): + bufaux = entry.buffer_aux + pybuffernd_struct = bufaux.buflocal_nd_var.cname + pybuffer_struct = bufaux.rcbuf_var.cname + # init pybuffer_struct + code.putln("%s.pybuffer.buf = NULL;" % pybuffer_struct) + code.putln("%s.refcount = 0;" % pybuffer_struct) + # init the buffer object + # code.put_init_var_to_py_none(entry) + # init the pybuffernd_struct + code.putln("%s.data = NULL;" % pybuffernd_struct) + code.putln("%s.rcbuffer = &%s;" % (pybuffernd_struct, pybuffer_struct)) + + +def put_acquire_arg_buffer(entry, code, pos): + buffer_aux = entry.buffer_aux + getbuffer = get_getbuffer_call(code, entry.cname, buffer_aux, entry.type) + + # Acquire any new buffer + code.putln("{") + code.putln("__Pyx_BufFmt_StackElem __pyx_stack[%d];" % entry.type.dtype.struct_nesting_depth()) + code.putln(code.error_goto_if("%s == -1" % getbuffer, pos)) + code.putln("}") + # An exception raised in arg parsing cannot be caught, so no + # need to care about the buffer then. + put_unpack_buffer_aux_into_scope(entry, code) + + +def put_release_buffer_code(code, entry): + code.globalstate.use_utility_code(acquire_utility_code) + code.putln("__Pyx_SafeReleaseBuffer(&%s.rcbuffer->pybuffer);" % entry.buffer_aux.buflocal_nd_var.cname) + + +def get_getbuffer_call(code, obj_cname, buffer_aux, buffer_type): + ndim = buffer_type.ndim + cast = int(buffer_type.cast) + flags = get_flags(buffer_aux, buffer_type) + pybuffernd_struct = buffer_aux.buflocal_nd_var.cname + + dtype_typeinfo = get_type_information_cname(code, buffer_type.dtype) + + code.globalstate.use_utility_code(acquire_utility_code) + return ("__Pyx_GetBufferAndValidate(&%(pybuffernd_struct)s.rcbuffer->pybuffer, " + "(PyObject*)%(obj_cname)s, &%(dtype_typeinfo)s, %(flags)s, %(ndim)d, " + "%(cast)d, __pyx_stack)" % locals()) + + +def put_assign_to_buffer(lhs_cname, rhs_cname, buf_entry, + is_initialized, pos, code): + """ + Generate code for reassigning a buffer variables. This only deals with getting + the buffer auxiliary structure and variables set up correctly, the assignment + itself and refcounting is the responsibility of the caller. + + However, the assignment operation may throw an exception so that the reassignment + never happens. + + Depending on the circumstances there are two possible outcomes: + - Old buffer released, new acquired, rhs assigned to lhs + - Old buffer released, new acquired which fails, reaqcuire old lhs buffer + (which may or may not succeed). + """ + + buffer_aux, buffer_type = buf_entry.buffer_aux, buf_entry.type + pybuffernd_struct = buffer_aux.buflocal_nd_var.cname + flags = get_flags(buffer_aux, buffer_type) + + code.putln("{") # Set up necessary stack for getbuffer + code.putln("__Pyx_BufFmt_StackElem __pyx_stack[%d];" % buffer_type.dtype.struct_nesting_depth()) + + getbuffer = get_getbuffer_call(code, "%s", buffer_aux, buffer_type) # fill in object below + + if is_initialized: + # Release any existing buffer + code.putln('__Pyx_SafeReleaseBuffer(&%s.rcbuffer->pybuffer);' % pybuffernd_struct) + # Acquire + retcode_cname = code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) + code.putln("%s = %s;" % (retcode_cname, getbuffer % rhs_cname)) + code.putln('if (%s) {' % (code.unlikely("%s < 0" % retcode_cname))) + # If acquisition failed, attempt to reacquire the old buffer + # before raising the exception. A failure of reacquisition + # will cause the reacquisition exception to be reported, one + # can consider working around this later. + exc_temps = tuple(code.funcstate.allocate_temp(PyrexTypes.py_object_type, manage_ref=False) + for _ in range(3)) + code.putln('PyErr_Fetch(&%s, &%s, &%s);' % exc_temps) + code.putln('if (%s) {' % code.unlikely("%s == -1" % (getbuffer % lhs_cname))) + code.putln('Py_XDECREF(%s); Py_XDECREF(%s); Py_XDECREF(%s);' % exc_temps) # Do not refnanny these! + code.globalstate.use_utility_code(raise_buffer_fallback_code) + code.putln('__Pyx_RaiseBufferFallbackError();') + code.putln('} else {') + code.putln('PyErr_Restore(%s, %s, %s);' % exc_temps) + code.putln('}') + code.putln('%s = %s = %s = 0;' % exc_temps) + for t in exc_temps: + code.funcstate.release_temp(t) + code.putln('}') + # Unpack indices + put_unpack_buffer_aux_into_scope(buf_entry, code) + code.putln(code.error_goto_if_neg(retcode_cname, pos)) + code.funcstate.release_temp(retcode_cname) + else: + # Our entry had no previous value, so set to None when acquisition fails. + # In this case, auxiliary vars should be set up right in initialization to a zero-buffer, + # so it suffices to set the buf field to NULL. + code.putln('if (%s) {' % code.unlikely("%s == -1" % (getbuffer % rhs_cname))) + code.putln('%s = %s; __Pyx_INCREF(Py_None); %s.rcbuffer->pybuffer.buf = NULL;' % + (lhs_cname, + PyrexTypes.typecast(buffer_type, PyrexTypes.py_object_type, "Py_None"), + pybuffernd_struct)) + code.putln(code.error_goto(pos)) + code.put('} else {') + # Unpack indices + put_unpack_buffer_aux_into_scope(buf_entry, code) + code.putln('}') + + code.putln("}") # Release stack + + +def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, + pos, code, negative_indices, in_nogil_context): + """ + Generates code to process indices and calculate an offset into + a buffer. Returns a C string which gives a pointer which can be + read from or written to at will (it is an expression so caller should + store it in a temporary if it is used more than once). + + As the bounds checking can have any number of combinations of unsigned + arguments, smart optimizations etc. we insert it directly in the function + body. The lookup however is delegated to a inline function that is instantiated + once per ndim (lookup with suboffsets tend to get quite complicated). + + entry is a BufferEntry + """ + negative_indices = directives['wraparound'] and negative_indices + + if directives['boundscheck']: + # Check bounds and fix negative indices. + # We allocate a temporary which is initialized to -1, meaning OK (!). + # If an error occurs, the temp is set to the index dimension the + # error is occurring at. + failed_dim_temp = code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) + code.putln("%s = -1;" % failed_dim_temp) + for dim, (signed, cname, shape) in enumerate(zip(index_signeds, index_cnames, entry.get_buf_shapevars())): + if signed != 0: + # not unsigned, deal with negative index + code.putln("if (%s < 0) {" % cname) + if negative_indices: + code.putln("%s += %s;" % (cname, shape)) + code.putln("if (%s) %s = %d;" % ( + code.unlikely("%s < 0" % cname), + failed_dim_temp, dim)) + else: + code.putln("%s = %d;" % (failed_dim_temp, dim)) + code.put("} else ") + # check bounds in positive direction + if signed != 0: + cast = "" + else: + cast = "(size_t)" + code.putln("if (%s) %s = %d;" % ( + code.unlikely("%s >= %s%s" % (cname, cast, shape)), + failed_dim_temp, dim)) + + if in_nogil_context: + code.globalstate.use_utility_code(raise_indexerror_nogil) + func = '__Pyx_RaiseBufferIndexErrorNogil' + else: + code.globalstate.use_utility_code(raise_indexerror_code) + func = '__Pyx_RaiseBufferIndexError' + + code.putln("if (%s) {" % code.unlikely("%s != -1" % failed_dim_temp)) + code.putln('%s(%s);' % (func, failed_dim_temp)) + code.putln(code.error_goto(pos)) + code.putln('}') + code.funcstate.release_temp(failed_dim_temp) + elif negative_indices: + # Only fix negative indices. + for signed, cname, shape in zip(index_signeds, index_cnames, entry.get_buf_shapevars()): + if signed != 0: + code.putln("if (%s < 0) %s += %s;" % (cname, cname, shape)) + + return entry.generate_buffer_lookup_code(code, index_cnames) + + +def use_bufstruct_declare_code(env): + env.use_utility_code(buffer_struct_declare_code) + + +def buf_lookup_full_code(proto, defin, name, nd): + """ + Generates a buffer lookup function for the right number + of dimensions. The function gives back a void* at the right location. + """ + # _i_ndex, _s_tride, sub_o_ffset + macroargs = ", ".join(["i%d, s%d, o%d" % (i, i, i) for i in range(nd)]) + proto.putln("#define %s(type, buf, %s) (type)(%s_imp(buf, %s))" % (name, macroargs, name, macroargs)) + + funcargs = ", ".join(["Py_ssize_t i%d, Py_ssize_t s%d, Py_ssize_t o%d" % (i, i, i) for i in range(nd)]) + proto.putln("static CYTHON_INLINE void* %s_imp(void* buf, %s);" % (name, funcargs)) + defin.putln(dedent(""" + static CYTHON_INLINE void* %s_imp(void* buf, %s) { + char* ptr = (char*)buf; + """) % (name, funcargs) + "".join([dedent("""\ + ptr += s%d * i%d; + if (o%d >= 0) ptr = *((char**)ptr) + o%d; + """) % (i, i, i, i) for i in range(nd)] + ) + "\nreturn ptr;\n}") + + +def buf_lookup_strided_code(proto, defin, name, nd): + """ + Generates a buffer lookup function for the right number + of dimensions. The function gives back a void* at the right location. + """ + # _i_ndex, _s_tride + args = ", ".join(["i%d, s%d" % (i, i) for i in range(nd)]) + offset = " + ".join(["i%d * s%d" % (i, i) for i in range(nd)]) + proto.putln("#define %s(type, buf, %s) (type)((char*)buf + %s)" % (name, args, offset)) + + +def buf_lookup_c_code(proto, defin, name, nd): + """ + Similar to strided lookup, but can assume that the last dimension + doesn't need a multiplication as long as. + Still we keep the same signature for now. + """ + if nd == 1: + proto.putln("#define %s(type, buf, i0, s0) ((type)buf + i0)" % name) + else: + args = ", ".join(["i%d, s%d" % (i, i) for i in range(nd)]) + offset = " + ".join(["i%d * s%d" % (i, i) for i in range(nd - 1)]) + proto.putln("#define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)" % (name, args, offset, nd - 1)) + + +def buf_lookup_fortran_code(proto, defin, name, nd): + """ + Like C lookup, but the first index is optimized instead. + """ + if nd == 1: + proto.putln("#define %s(type, buf, i0, s0) ((type)buf + i0)" % name) + else: + args = ", ".join(["i%d, s%d" % (i, i) for i in range(nd)]) + offset = " + ".join(["i%d * s%d" % (i, i) for i in range(1, nd)]) + proto.putln("#define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)" % (name, args, offset, 0)) + + +def use_py2_buffer_functions(env): + env.use_utility_code(GetAndReleaseBufferUtilityCode()) + + +class GetAndReleaseBufferUtilityCode(object): + # Emulation of PyObject_GetBuffer and PyBuffer_Release for Python 2. + # For >= 2.6 we do double mode -- use the new buffer interface on objects + # which has the right tp_flags set, but emulation otherwise. + + requires = None + is_cython_utility = False + + def __init__(self): + pass + + def __eq__(self, other): + return isinstance(other, GetAndReleaseBufferUtilityCode) + + def __hash__(self): + return 24342342 + + def get_tree(self, **kwargs): pass + + def put_code(self, output): + code = output['utility_code_def'] + proto_code = output['utility_code_proto'] + env = output.module_node.scope + cython_scope = env.context.cython_scope + + # Search all types for __getbuffer__ overloads + types = [] + visited_scopes = set() + def find_buffer_types(scope): + if scope in visited_scopes: + return + visited_scopes.add(scope) + for m in scope.cimported_modules: + find_buffer_types(m) + for e in scope.type_entries: + if isinstance(e.utility_code_definition, CythonUtilityCode): + continue + t = e.type + if t.is_extension_type: + if scope is cython_scope and not e.used: + continue + release = get = None + for x in t.scope.pyfunc_entries: + if x.name == u"__getbuffer__": get = x.func_cname + elif x.name == u"__releasebuffer__": release = x.func_cname + if get: + types.append((t.typeptr_cname, get, release)) + + find_buffer_types(env) + + util_code = TempitaUtilityCode.load( + "GetAndReleaseBuffer", from_file="Buffer.c", + context=dict(types=types)) + + proto = util_code.format_code(util_code.proto) + impl = util_code.format_code( + util_code.inject_string_constants(util_code.impl, output)[1]) + + proto_code.putln(proto) + code.putln(impl) + + +def mangle_dtype_name(dtype): + # Use prefixes to separate user defined types from builtins + # (consider "typedef float unsigned_int") + if dtype.is_pyobject: + return "object" + elif dtype.is_ptr: + return "ptr" + else: + if dtype.is_typedef or dtype.is_struct_or_union: + prefix = "nn_" + else: + prefix = "" + return prefix + dtype.specialization_name() + +def get_type_information_cname(code, dtype, maxdepth=None): + """ + Output the run-time type information (__Pyx_TypeInfo) for given dtype, + and return the name of the type info struct. + + Structs with two floats of the same size are encoded as complex numbers. + One can separate between complex numbers declared as struct or with native + encoding by inspecting to see if the fields field of the type is + filled in. + """ + namesuffix = mangle_dtype_name(dtype) + name = "__Pyx_TypeInfo_%s" % namesuffix + structinfo_name = "__Pyx_StructFields_%s" % namesuffix + + if dtype.is_error: return "<error>" + + # It's critical that walking the type info doesn't use more stack + # depth than dtype.struct_nesting_depth() returns, so use an assertion for this + if maxdepth is None: maxdepth = dtype.struct_nesting_depth() + if maxdepth <= 0: + assert False + + if name not in code.globalstate.utility_codes: + code.globalstate.utility_codes.add(name) + typecode = code.globalstate['typeinfo'] + + arraysizes = [] + if dtype.is_array: + while dtype.is_array: + arraysizes.append(dtype.size) + dtype = dtype.base_type + + complex_possible = dtype.is_struct_or_union and dtype.can_be_complex() + + declcode = dtype.empty_declaration_code() + if dtype.is_simple_buffer_dtype(): + structinfo_name = "NULL" + elif dtype.is_struct: + struct_scope = dtype.scope + if dtype.is_const: + struct_scope = struct_scope.const_base_type_scope + # Must pre-call all used types in order not to recurse during utility code writing. + fields = struct_scope.var_entries + assert len(fields) > 0 + types = [get_type_information_cname(code, f.type, maxdepth - 1) + for f in fields] + typecode.putln("static __Pyx_StructField %s[] = {" % structinfo_name, safe=True) + for f, typeinfo in zip(fields, types): + typecode.putln(' {&%s, "%s", offsetof(%s, %s)},' % + (typeinfo, f.name, dtype.empty_declaration_code(), f.cname), safe=True) + typecode.putln(' {NULL, NULL, 0}', safe=True) + typecode.putln("};", safe=True) + else: + assert False + + rep = str(dtype) + + flags = "0" + is_unsigned = "0" + if dtype is PyrexTypes.c_char_type: + is_unsigned = "IS_UNSIGNED(%s)" % declcode + typegroup = "'H'" + elif dtype.is_int: + is_unsigned = "IS_UNSIGNED(%s)" % declcode + typegroup = "%s ? 'U' : 'I'" % is_unsigned + elif complex_possible or dtype.is_complex: + typegroup = "'C'" + elif dtype.is_float: + typegroup = "'R'" + elif dtype.is_struct: + typegroup = "'S'" + if dtype.packed: + flags = "__PYX_BUF_FLAGS_PACKED_STRUCT" + elif dtype.is_pyobject: + typegroup = "'O'" + else: + assert False, dtype + + typeinfo = ('static __Pyx_TypeInfo %s = ' + '{ "%s", %s, sizeof(%s), { %s }, %s, %s, %s, %s };') + tup = (name, rep, structinfo_name, declcode, + ', '.join([str(x) for x in arraysizes]) or '0', len(arraysizes), + typegroup, is_unsigned, flags) + typecode.putln(typeinfo % tup, safe=True) + + return name + +def load_buffer_utility(util_code_name, context=None, **kwargs): + if context is None: + return UtilityCode.load(util_code_name, "Buffer.c", **kwargs) + else: + return TempitaUtilityCode.load(util_code_name, "Buffer.c", context=context, **kwargs) + +context = dict(max_dims=Options.buffer_max_dims) +buffer_struct_declare_code = load_buffer_utility("BufferStructDeclare", context=context) +buffer_formats_declare_code = load_buffer_utility("BufferFormatStructs") + +# Utility function to set the right exception +# The caller should immediately goto_error +raise_indexerror_code = load_buffer_utility("BufferIndexError") +raise_indexerror_nogil = load_buffer_utility("BufferIndexErrorNogil") +raise_buffer_fallback_code = load_buffer_utility("BufferFallbackError") + +acquire_utility_code = load_buffer_utility("BufferGetAndValidate", context=context) +buffer_format_check_code = load_buffer_utility("BufferFormatCheck", context=context) + +# See utility code BufferFormatFromTypeInfo +_typeinfo_to_format_code = load_buffer_utility("TypeInfoToFormat") diff --git a/contrib/tools/cython/Cython/Compiler/Builtin.py b/contrib/tools/cython/Cython/Compiler/Builtin.py new file mode 100644 index 00000000000..e0d203ae027 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Builtin.py @@ -0,0 +1,444 @@ +# +# Builtin Definitions +# + +from __future__ import absolute_import + +from .Symtab import BuiltinScope, StructOrUnionScope +from .Code import UtilityCode +from .TypeSlots import Signature +from . import PyrexTypes +from . import Options + + +# C-level implementations of builtin types, functions and methods + +iter_next_utility_code = UtilityCode.load("IterNext", "ObjectHandling.c") +getattr_utility_code = UtilityCode.load("GetAttr", "ObjectHandling.c") +getattr3_utility_code = UtilityCode.load("GetAttr3", "Builtins.c") +pyexec_utility_code = UtilityCode.load("PyExec", "Builtins.c") +pyexec_globals_utility_code = UtilityCode.load("PyExecGlobals", "Builtins.c") +globals_utility_code = UtilityCode.load("Globals", "Builtins.c") + +builtin_utility_code = { + 'StopAsyncIteration': UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c"), +} + + +# mapping from builtins to their C-level equivalents + +class _BuiltinOverride(object): + def __init__(self, py_name, args, ret_type, cname, py_equiv="*", + utility_code=None, sig=None, func_type=None, + is_strict_signature=False, builtin_return_type=None): + self.py_name, self.cname, self.py_equiv = py_name, cname, py_equiv + self.args, self.ret_type = args, ret_type + self.func_type, self.sig = func_type, sig + self.builtin_return_type = builtin_return_type + self.is_strict_signature = is_strict_signature + self.utility_code = utility_code + + def build_func_type(self, sig=None, self_arg=None): + if sig is None: + sig = Signature(self.args, self.ret_type) + sig.exception_check = False # not needed for the current builtins + func_type = sig.function_type(self_arg) + if self.is_strict_signature: + func_type.is_strict_signature = True + if self.builtin_return_type: + func_type.return_type = builtin_types[self.builtin_return_type] + return func_type + + +class BuiltinAttribute(object): + def __init__(self, py_name, cname=None, field_type=None, field_type_name=None): + self.py_name = py_name + self.cname = cname or py_name + self.field_type_name = field_type_name # can't do the lookup before the type is declared! + self.field_type = field_type + + def declare_in_type(self, self_type): + if self.field_type_name is not None: + # lazy type lookup + field_type = builtin_scope.lookup(self.field_type_name).type + else: + field_type = self.field_type or PyrexTypes.py_object_type + entry = self_type.scope.declare(self.py_name, self.cname, field_type, None, 'private') + entry.is_variable = True + + +class BuiltinFunction(_BuiltinOverride): + def declare_in_scope(self, scope): + func_type, sig = self.func_type, self.sig + if func_type is None: + func_type = self.build_func_type(sig) + scope.declare_builtin_cfunction(self.py_name, func_type, self.cname, + self.py_equiv, self.utility_code) + + +class BuiltinMethod(_BuiltinOverride): + def declare_in_type(self, self_type): + method_type, sig = self.func_type, self.sig + if method_type is None: + # override 'self' type (first argument) + self_arg = PyrexTypes.CFuncTypeArg("", self_type, None) + self_arg.not_none = True + self_arg.accept_builtin_subtypes = True + method_type = self.build_func_type(sig, self_arg) + self_type.scope.declare_builtin_cfunction( + self.py_name, method_type, self.cname, utility_code=self.utility_code) + + +builtin_function_table = [ + # name, args, return, C API func, py equiv = "*" + BuiltinFunction('abs', "d", "d", "fabs", + is_strict_signature = True), + BuiltinFunction('abs', "f", "f", "fabsf", + is_strict_signature = True), + BuiltinFunction('abs', "i", "i", "abs", + is_strict_signature = True), + BuiltinFunction('abs', "l", "l", "labs", + is_strict_signature = True), + BuiltinFunction('abs', None, None, "__Pyx_abs_longlong", + utility_code = UtilityCode.load("abs_longlong", "Builtins.c"), + func_type = PyrexTypes.CFuncType( + PyrexTypes.c_longlong_type, [ + PyrexTypes.CFuncTypeArg("arg", PyrexTypes.c_longlong_type, None) + ], + is_strict_signature = True, nogil=True)), + ] + list( + BuiltinFunction('abs', None, None, "/*abs_{0}*/".format(t.specialization_name()), + func_type = PyrexTypes.CFuncType( + t, + [PyrexTypes.CFuncTypeArg("arg", t, None)], + is_strict_signature = True, nogil=True)) + for t in (PyrexTypes.c_uint_type, PyrexTypes.c_ulong_type, PyrexTypes.c_ulonglong_type) + ) + list( + BuiltinFunction('abs', None, None, "__Pyx_c_abs{0}".format(t.funcsuffix), + func_type = PyrexTypes.CFuncType( + t.real_type, [ + PyrexTypes.CFuncTypeArg("arg", t, None) + ], + is_strict_signature = True, nogil=True)) + for t in (PyrexTypes.c_float_complex_type, + PyrexTypes.c_double_complex_type, + PyrexTypes.c_longdouble_complex_type) + ) + [ + BuiltinFunction('abs', "O", "O", "__Pyx_PyNumber_Absolute", + utility_code=UtilityCode.load("py_abs", "Builtins.c")), + #('all', "", "", ""), + #('any', "", "", ""), + #('ascii', "", "", ""), + #('bin', "", "", ""), + BuiltinFunction('callable', "O", "b", "__Pyx_PyCallable_Check", + utility_code = UtilityCode.load("CallableCheck", "ObjectHandling.c")), + #('chr', "", "", ""), + #('cmp', "", "", "", ""), # int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result) + #('compile', "", "", ""), # PyObject* Py_CompileString( char *str, char *filename, int start) + BuiltinFunction('delattr', "OO", "r", "PyObject_DelAttr"), + BuiltinFunction('dir', "O", "O", "PyObject_Dir"), + BuiltinFunction('divmod', "OO", "O", "PyNumber_Divmod"), + BuiltinFunction('exec', "O", "O", "__Pyx_PyExecGlobals", + utility_code = pyexec_globals_utility_code), + BuiltinFunction('exec', "OO", "O", "__Pyx_PyExec2", + utility_code = pyexec_utility_code), + BuiltinFunction('exec', "OOO", "O", "__Pyx_PyExec3", + utility_code = pyexec_utility_code), + #('eval', "", "", ""), + #('execfile', "", "", ""), + #('filter', "", "", ""), + BuiltinFunction('getattr3', "OOO", "O", "__Pyx_GetAttr3", "getattr", + utility_code=getattr3_utility_code), # Pyrex legacy + BuiltinFunction('getattr', "OOO", "O", "__Pyx_GetAttr3", + utility_code=getattr3_utility_code), + BuiltinFunction('getattr', "OO", "O", "__Pyx_GetAttr", + utility_code=getattr_utility_code), + BuiltinFunction('hasattr', "OO", "b", "__Pyx_HasAttr", + utility_code = UtilityCode.load("HasAttr", "Builtins.c")), + BuiltinFunction('hash', "O", "h", "PyObject_Hash"), + #('hex', "", "", ""), + #('id', "", "", ""), + #('input', "", "", ""), + BuiltinFunction('intern', "O", "O", "__Pyx_Intern", + utility_code = UtilityCode.load("Intern", "Builtins.c")), + BuiltinFunction('isinstance', "OO", "b", "PyObject_IsInstance"), + BuiltinFunction('issubclass', "OO", "b", "PyObject_IsSubclass"), + BuiltinFunction('iter', "OO", "O", "PyCallIter_New"), + BuiltinFunction('iter', "O", "O", "PyObject_GetIter"), + BuiltinFunction('len', "O", "z", "PyObject_Length"), + BuiltinFunction('locals', "", "O", "__pyx_locals"), + #('map', "", "", ""), + #('max', "", "", ""), + #('min', "", "", ""), + BuiltinFunction('next', "O", "O", "__Pyx_PyIter_Next", + utility_code = iter_next_utility_code), # not available in Py2 => implemented here + BuiltinFunction('next', "OO", "O", "__Pyx_PyIter_Next2", + utility_code = iter_next_utility_code), # not available in Py2 => implemented here + #('oct', "", "", ""), + #('open', "ss", "O", "PyFile_FromString"), # not in Py3 +] + [ + BuiltinFunction('ord', None, None, "__Pyx_long_cast", + func_type=PyrexTypes.CFuncType( + PyrexTypes.c_long_type, [PyrexTypes.CFuncTypeArg("c", c_type, None)], + is_strict_signature=True)) + for c_type in [PyrexTypes.c_py_ucs4_type, PyrexTypes.c_py_unicode_type] +] + [ + BuiltinFunction('ord', None, None, "__Pyx_uchar_cast", + func_type=PyrexTypes.CFuncType( + PyrexTypes.c_uchar_type, [PyrexTypes.CFuncTypeArg("c", c_type, None)], + is_strict_signature=True)) + for c_type in [PyrexTypes.c_char_type, PyrexTypes.c_schar_type, PyrexTypes.c_uchar_type] +] + [ + BuiltinFunction('ord', None, None, "__Pyx_PyObject_Ord", + utility_code=UtilityCode.load_cached("object_ord", "Builtins.c"), + func_type=PyrexTypes.CFuncType( + PyrexTypes.c_long_type, [ + PyrexTypes.CFuncTypeArg("c", PyrexTypes.py_object_type, None) + ], + exception_value="(long)(Py_UCS4)-1")), + BuiltinFunction('pow', "OOO", "O", "PyNumber_Power"), + BuiltinFunction('pow', "OO", "O", "__Pyx_PyNumber_Power2", + utility_code = UtilityCode.load("pow2", "Builtins.c")), + #('range', "", "", ""), + #('raw_input', "", "", ""), + #('reduce', "", "", ""), + BuiltinFunction('reload', "O", "O", "PyImport_ReloadModule"), + BuiltinFunction('repr', "O", "O", "PyObject_Repr"), # , builtin_return_type='str'), # add in Cython 3.1 + #('round', "", "", ""), + BuiltinFunction('setattr', "OOO", "r", "PyObject_SetAttr"), + #('sum', "", "", ""), + #('sorted', "", "", ""), + #('type', "O", "O", "PyObject_Type"), + #('unichr', "", "", ""), + #('unicode', "", "", ""), + #('vars', "", "", ""), + #('zip', "", "", ""), + # Can't do these easily until we have builtin type entries. + #('typecheck', "OO", "i", "PyObject_TypeCheck", False), + #('issubtype', "OO", "i", "PyType_IsSubtype", False), + + # Put in namespace append optimization. + BuiltinFunction('__Pyx_PyObject_Append', "OO", "O", "__Pyx_PyObject_Append"), + + # This is conditionally looked up based on a compiler directive. + BuiltinFunction('__Pyx_Globals', "", "O", "__Pyx_Globals", + utility_code=globals_utility_code), +] + + +# Builtin types +# bool +# buffer +# classmethod +# dict +# enumerate +# file +# float +# int +# list +# long +# object +# property +# slice +# staticmethod +# super +# str +# tuple +# type +# xrange + +builtin_types_table = [ + + ("type", "PyType_Type", []), + +# This conflicts with the C++ bool type, and unfortunately +# C++ is too liberal about PyObject* <-> bool conversions, +# resulting in unintuitive runtime behavior and segfaults. +# ("bool", "PyBool_Type", []), + + ("int", "PyInt_Type", []), + ("long", "PyLong_Type", []), + ("float", "PyFloat_Type", []), + + ("complex", "PyComplex_Type", [BuiltinAttribute('cval', field_type_name = 'Py_complex'), + BuiltinAttribute('real', 'cval.real', field_type = PyrexTypes.c_double_type), + BuiltinAttribute('imag', 'cval.imag', field_type = PyrexTypes.c_double_type), + ]), + + ("basestring", "PyBaseString_Type", [ + BuiltinMethod("join", "TO", "T", "__Pyx_PyBaseString_Join", + utility_code=UtilityCode.load("StringJoin", "StringTools.c")), + ]), + ("bytearray", "PyByteArray_Type", [ + ]), + ("bytes", "PyBytes_Type", [BuiltinMethod("join", "TO", "O", "__Pyx_PyBytes_Join", + utility_code=UtilityCode.load("StringJoin", "StringTools.c")), + ]), + ("str", "PyString_Type", [BuiltinMethod("join", "TO", "O", "__Pyx_PyString_Join", + builtin_return_type='basestring', + utility_code=UtilityCode.load("StringJoin", "StringTools.c")), + ]), + ("unicode", "PyUnicode_Type", [BuiltinMethod("__contains__", "TO", "b", "PyUnicode_Contains"), + BuiltinMethod("join", "TO", "T", "PyUnicode_Join"), + ]), + + ("tuple", "PyTuple_Type", []), + + ("list", "PyList_Type", [BuiltinMethod("insert", "TzO", "r", "PyList_Insert"), + BuiltinMethod("reverse", "T", "r", "PyList_Reverse"), + BuiltinMethod("append", "TO", "r", "__Pyx_PyList_Append", + utility_code=UtilityCode.load("ListAppend", "Optimize.c")), + BuiltinMethod("extend", "TO", "r", "__Pyx_PyList_Extend", + utility_code=UtilityCode.load("ListExtend", "Optimize.c")), + ]), + + ("dict", "PyDict_Type", [BuiltinMethod("__contains__", "TO", "b", "PyDict_Contains"), + BuiltinMethod("has_key", "TO", "b", "PyDict_Contains"), + BuiltinMethod("items", "T", "O", "__Pyx_PyDict_Items", + utility_code=UtilityCode.load("py_dict_items", "Builtins.c")), + BuiltinMethod("keys", "T", "O", "__Pyx_PyDict_Keys", + utility_code=UtilityCode.load("py_dict_keys", "Builtins.c")), + BuiltinMethod("values", "T", "O", "__Pyx_PyDict_Values", + utility_code=UtilityCode.load("py_dict_values", "Builtins.c")), + BuiltinMethod("iteritems", "T", "O", "__Pyx_PyDict_IterItems", + utility_code=UtilityCode.load("py_dict_iteritems", "Builtins.c")), + BuiltinMethod("iterkeys", "T", "O", "__Pyx_PyDict_IterKeys", + utility_code=UtilityCode.load("py_dict_iterkeys", "Builtins.c")), + BuiltinMethod("itervalues", "T", "O", "__Pyx_PyDict_IterValues", + utility_code=UtilityCode.load("py_dict_itervalues", "Builtins.c")), + BuiltinMethod("viewitems", "T", "O", "__Pyx_PyDict_ViewItems", + utility_code=UtilityCode.load("py_dict_viewitems", "Builtins.c")), + BuiltinMethod("viewkeys", "T", "O", "__Pyx_PyDict_ViewKeys", + utility_code=UtilityCode.load("py_dict_viewkeys", "Builtins.c")), + BuiltinMethod("viewvalues", "T", "O", "__Pyx_PyDict_ViewValues", + utility_code=UtilityCode.load("py_dict_viewvalues", "Builtins.c")), + BuiltinMethod("clear", "T", "r", "__Pyx_PyDict_Clear", + utility_code=UtilityCode.load("py_dict_clear", "Optimize.c")), + BuiltinMethod("copy", "T", "T", "PyDict_Copy")]), + + ("slice", "PySlice_Type", [BuiltinAttribute('start'), + BuiltinAttribute('stop'), + BuiltinAttribute('step'), + ]), +# ("file", "PyFile_Type", []), # not in Py3 + + ("set", "PySet_Type", [BuiltinMethod("clear", "T", "r", "PySet_Clear"), + # discard() and remove() have a special treatment for unhashable values + BuiltinMethod("discard", "TO", "r", "__Pyx_PySet_Discard", + utility_code=UtilityCode.load("py_set_discard", "Optimize.c")), + BuiltinMethod("remove", "TO", "r", "__Pyx_PySet_Remove", + utility_code=UtilityCode.load("py_set_remove", "Optimize.c")), + # update is actually variadic (see Github issue #1645) +# BuiltinMethod("update", "TO", "r", "__Pyx_PySet_Update", +# utility_code=UtilityCode.load_cached("PySet_Update", "Builtins.c")), + BuiltinMethod("add", "TO", "r", "PySet_Add"), + BuiltinMethod("pop", "T", "O", "PySet_Pop")]), + ("frozenset", "PyFrozenSet_Type", []), + ("Exception", "((PyTypeObject*)PyExc_Exception)[0]", []), + ("StopAsyncIteration", "((PyTypeObject*)__Pyx_PyExc_StopAsyncIteration)[0]", []), +] + + +types_that_construct_their_instance = set([ + # some builtin types do not always return an instance of + # themselves - these do: + 'type', 'bool', 'long', 'float', 'complex', + 'bytes', 'unicode', 'bytearray', + 'tuple', 'list', 'dict', 'set', 'frozenset' + # 'str', # only in Py3.x + # 'file', # only in Py2.x +]) + + +builtin_structs_table = [ + ('Py_buffer', 'Py_buffer', + [("buf", PyrexTypes.c_void_ptr_type), + ("obj", PyrexTypes.py_object_type), + ("len", PyrexTypes.c_py_ssize_t_type), + ("itemsize", PyrexTypes.c_py_ssize_t_type), + ("readonly", PyrexTypes.c_bint_type), + ("ndim", PyrexTypes.c_int_type), + ("format", PyrexTypes.c_char_ptr_type), + ("shape", PyrexTypes.c_py_ssize_t_ptr_type), + ("strides", PyrexTypes.c_py_ssize_t_ptr_type), + ("suboffsets", PyrexTypes.c_py_ssize_t_ptr_type), + ("smalltable", PyrexTypes.CArrayType(PyrexTypes.c_py_ssize_t_type, 2)), + ("internal", PyrexTypes.c_void_ptr_type), + ]), + ('Py_complex', 'Py_complex', + [('real', PyrexTypes.c_double_type), + ('imag', PyrexTypes.c_double_type), + ]) +] + +# set up builtin scope + +builtin_scope = BuiltinScope() + +def init_builtin_funcs(): + for bf in builtin_function_table: + bf.declare_in_scope(builtin_scope) + +builtin_types = {} + +def init_builtin_types(): + global builtin_types + for name, cname, methods in builtin_types_table: + utility = builtin_utility_code.get(name) + if name == 'frozenset': + objstruct_cname = 'PySetObject' + elif name == 'bytearray': + objstruct_cname = 'PyByteArrayObject' + elif name == 'bool': + objstruct_cname = None + elif name == 'Exception': + objstruct_cname = "PyBaseExceptionObject" + elif name == 'StopAsyncIteration': + objstruct_cname = "PyBaseExceptionObject" + else: + objstruct_cname = 'Py%sObject' % name.capitalize() + the_type = builtin_scope.declare_builtin_type(name, cname, utility, objstruct_cname) + builtin_types[name] = the_type + for method in methods: + method.declare_in_type(the_type) + +def init_builtin_structs(): + for name, cname, attribute_types in builtin_structs_table: + scope = StructOrUnionScope(name) + for attribute_name, attribute_type in attribute_types: + scope.declare_var(attribute_name, attribute_type, None, + attribute_name, allow_pyobject=True) + builtin_scope.declare_struct_or_union( + name, "struct", scope, 1, None, cname = cname) + + +def init_builtins(): + init_builtin_structs() + init_builtin_types() + init_builtin_funcs() + + builtin_scope.declare_var( + '__debug__', PyrexTypes.c_const_type(PyrexTypes.c_bint_type), + pos=None, cname='(!Py_OptimizeFlag)', is_cdef=True) + + global list_type, tuple_type, dict_type, set_type, frozenset_type + global bytes_type, str_type, unicode_type, basestring_type, slice_type + global float_type, bool_type, type_type, complex_type, bytearray_type + type_type = builtin_scope.lookup('type').type + list_type = builtin_scope.lookup('list').type + tuple_type = builtin_scope.lookup('tuple').type + dict_type = builtin_scope.lookup('dict').type + set_type = builtin_scope.lookup('set').type + frozenset_type = builtin_scope.lookup('frozenset').type + slice_type = builtin_scope.lookup('slice').type + bytes_type = builtin_scope.lookup('bytes').type + str_type = builtin_scope.lookup('str').type + unicode_type = builtin_scope.lookup('unicode').type + basestring_type = builtin_scope.lookup('basestring').type + bytearray_type = builtin_scope.lookup('bytearray').type + float_type = builtin_scope.lookup('float').type + bool_type = builtin_scope.lookup('bool').type + complex_type = builtin_scope.lookup('complex').type + + +init_builtins() diff --git a/contrib/tools/cython/Cython/Compiler/CmdLine.py b/contrib/tools/cython/Cython/Compiler/CmdLine.py new file mode 100644 index 00000000000..db36a41f8f7 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/CmdLine.py @@ -0,0 +1,244 @@ +# +# Cython - Command Line Parsing +# + +from __future__ import absolute_import + +import os +import sys +from . import Options + +usage = """\ +Cython (http://cython.org) is a compiler for code written in the +Cython language. Cython is based on Pyrex by Greg Ewing. + +Usage: cython [options] sourcefile.{pyx,py} ... + +Options: + -V, --version Display version number of cython compiler + -l, --create-listing Write error messages to a listing file + -I, --include-dir <directory> Search for include files in named directory + (multiple include directories are allowed). + -o, --output-file <filename> Specify name of generated C file + -t, --timestamps Only compile newer source files + -f, --force Compile all source files (overrides implied -t) + -v, --verbose Be verbose, print file names on multiple compilation + -p, --embed-positions If specified, the positions in Cython files of each + function definition is embedded in its docstring. + --cleanup <level> Release interned objects on python exit, for memory debugging. + Level indicates aggressiveness, default 0 releases nothing. + -w, --working <directory> Sets the working directory for Cython (the directory modules + are searched from) + --gdb Output debug information for cygdb + --gdb-outdir <directory> Specify gdb debug information output directory. Implies --gdb. + + -D, --no-docstrings Strip docstrings from the compiled module. + -a, --annotate Produce a colorized HTML version of the source. + --annotate-coverage <cov.xml> Annotate and include coverage information from cov.xml. + --line-directives Produce #line directives pointing to the .pyx source + --cplus Output a C++ rather than C file. + --embed[=<method_name>] Generate a main() function that embeds the Python interpreter. + -2 Compile based on Python-2 syntax and code semantics. + -3 Compile based on Python-3 syntax and code semantics. + --3str Compile based on Python-3 syntax and code semantics without + assuming unicode by default for string literals under Python 2. + --lenient Change some compile time errors to runtime errors to + improve Python compatibility + --capi-reexport-cincludes Add cincluded headers to any auto-generated header files. + --fast-fail Abort the compilation on the first error + --warning-errors, -Werror Make all warnings into errors + --warning-extra, -Wextra Enable extra warnings + -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive + -E, --compile-time-env name=value[,<name=value,...] Provides compile time env like DEF would do. + --module-name Fully qualified module name. If not given, it is deduced from the + import path if source file is in a package, or equals the + filename otherwise. + -M, --depfile Produce depfiles for the sources +""" + + +# The following experimental options are supported only on MacOSX: +# -C, --compile Compile generated .c file to .o file +# --link Link .o file to produce extension module (implies -C) +# -+, --cplus Use C++ compiler for compiling and linking +# Additional .o files to link may be supplied when using -X.""" + +def bad_usage(): + sys.stderr.write(usage) + sys.exit(1) + +def parse_command_line(args): + from .Main import CompilationOptions, default_options + + pending_arg = [] + + def pop_arg(): + if not args or pending_arg: + bad_usage() + if '=' in args[0] and args[0].startswith('--'): # allow "--long-option=xyz" + name, value = args.pop(0).split('=', 1) + pending_arg.append(value) + return name + return args.pop(0) + + def pop_value(default=None): + if pending_arg: + return pending_arg.pop() + elif default is not None: + return default + elif not args: + bad_usage() + return args.pop(0) + + def get_param(option): + tail = option[2:] + if tail: + return tail + else: + return pop_arg() + + options = CompilationOptions(default_options) + sources = [] + while args: + if args[0].startswith("-"): + option = pop_arg() + if option in ("-V", "--version"): + options.show_version = 1 + elif option in ("-l", "--create-listing"): + options.use_listing_file = 1 + elif option in ("-+", "--cplus"): + options.cplus = 1 + elif option == "--embed": + Options.embed = pop_value("main") + elif option.startswith("-I"): + options.include_path.append(get_param(option)) + elif option == "--include-dir": + options.include_path.append(pop_value()) + elif option in ("-w", "--working"): + options.working_path = pop_value() + elif option in ("-o", "--output-file"): + options.output_file = pop_value() + elif option in ("-t", "--timestamps"): + options.timestamps = 1 + elif option in ("-f", "--force"): + options.timestamps = 0 + elif option in ("-v", "--verbose"): + options.verbose += 1 + elif option in ("-p", "--embed-positions"): + Options.embed_pos_in_docstring = 1 + elif option in ("-z", "--pre-import"): + Options.pre_import = pop_value() + elif option == "--cleanup": + Options.generate_cleanup_code = int(pop_value()) + elif option in ("-D", "--no-docstrings"): + Options.docstrings = False + elif option in ("-a", "--annotate"): + Options.annotate = True + elif option == "--annotate-coverage": + Options.annotate = True + Options.annotate_coverage_xml = pop_value() + elif option == "--convert-range": + Options.convert_range = True + elif option == "--line-directives": + options.emit_linenums = True + elif option == "--no-c-in-traceback": + options.c_line_in_traceback = False + elif option == "--gdb": + options.gdb_debug = True + options.output_dir = os.curdir + elif option == "--gdb-outdir": + options.gdb_debug = True + options.output_dir = pop_value() + elif option == "--lenient": + Options.error_on_unknown_names = False + Options.error_on_uninitialized = False + elif option == '--init-suffix': + options.init_suffix = pop_arg() + elif option == '--source-root': + Options.source_root = pop_arg() + elif option == '-2': + options.language_level = 2 + elif option == '-3': + options.language_level = 3 + elif option == '--3str': + options.language_level = '3str' + elif option == "--capi-reexport-cincludes": + options.capi_reexport_cincludes = True + elif option == "--fast-fail": + Options.fast_fail = True + elif option == "--cimport-from-pyx": + Options.cimport_from_pyx = True + elif option in ('-Werror', '--warning-errors'): + Options.warning_errors = True + elif option in ('-Wextra', '--warning-extra'): + options.compiler_directives.update(Options.extra_warnings) + elif option == "--old-style-globals": + Options.old_style_globals = True + elif option == "--directive" or option.startswith('-X'): + if option.startswith('-X') and option[2:].strip(): + x_args = option[2:] + else: + x_args = pop_value() + try: + options.compiler_directives = Options.parse_directive_list( + x_args, relaxed_bool=True, + current_settings=options.compiler_directives) + except ValueError as e: + sys.stderr.write("Error in compiler directive: %s\n" % e.args[0]) + sys.exit(1) + elif option == "--compile-time-env" or option.startswith('-E'): + if option.startswith('-E') and option[2:].strip(): + x_args = option[2:] + else: + x_args = pop_value() + try: + options.compile_time_env = Options.parse_compile_time_env( + x_args, current_settings=options.compile_time_env) + except ValueError as e: + sys.stderr.write("Error in compile-time-env: %s\n" % e.args[0]) + sys.exit(1) + elif option == "--module-name": + options.module_name = pop_value() + elif option in ('-M', '--depfile'): + options.depfile = True + elif option.startswith('--debug'): + option = option[2:].replace('-', '_') + from . import DebugFlags + if option in dir(DebugFlags): + setattr(DebugFlags, option, True) + else: + sys.stderr.write("Unknown debug flag: %s\n" % option) + bad_usage() + elif option in ('-h', '--help'): + sys.stdout.write(usage) + sys.exit(0) + else: + sys.stderr.write(usage) + sys.stderr.write("Unknown compiler flag: %s\n" % option) + sys.exit(1) + else: + sources.append(pop_arg()) + + if pending_arg: + bad_usage() + + if options.use_listing_file and len(sources) > 1: + sys.stderr.write( + "cython: Only one source file allowed when using -o\n") + sys.exit(1) + if len(sources) == 0 and not options.show_version: + bad_usage() + if Options.embed and len(sources) > 1: + sys.stderr.write( + "cython: Only one source file allowed when using --embed\n") + sys.exit(1) + if options.module_name: + if options.timestamps: + sys.stderr.write( + "cython: Cannot use --module-name with --timestamps\n") + sys.exit(1) + if len(sources) > 1: + sys.stderr.write( + "cython: Only one source file allowed when using --module-name\n") + sys.exit(1) + return options, sources diff --git a/contrib/tools/cython/Cython/Compiler/Code.pxd b/contrib/tools/cython/Cython/Compiler/Code.pxd new file mode 100644 index 00000000000..acad0c1cf44 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Code.pxd @@ -0,0 +1,124 @@ + +from __future__ import absolute_import + +cimport cython +from ..StringIOTree cimport StringIOTree + + +cdef class UtilityCodeBase(object): + cpdef format_code(self, code_string, replace_empty_lines=*) + + +cdef class UtilityCode(UtilityCodeBase): + cdef public object name + cdef public object proto + cdef public object impl + cdef public object init + cdef public object cleanup + cdef public object proto_block + cdef public object requires + cdef public dict _cache + cdef public list specialize_list + cdef public object file + + cpdef none_or_sub(self, s, context) + + +cdef class FunctionState: + cdef public set names_taken + cdef public object owner + cdef public object scope + + cdef public object error_label + cdef public size_t label_counter + cdef public set labels_used + cdef public object return_label + cdef public object continue_label + cdef public object break_label + cdef public list yield_labels + + cdef public object return_from_error_cleanup_label # not used in __init__ ? + + cdef public object exc_vars + cdef public object current_except + cdef public bint in_try_finally + cdef public bint can_trace + cdef public bint gil_owned + + cdef public list temps_allocated + cdef public dict temps_free + cdef public dict temps_used_type + cdef public set zombie_temps + cdef public size_t temp_counter + cdef public list collect_temps_stack + + cdef public object closure_temps + cdef public bint should_declare_error_indicator + cdef public bint uses_error_indicator + + @cython.locals(n=size_t) + cpdef new_label(self, name=*) + cpdef tuple get_loop_labels(self) + cpdef set_loop_labels(self, labels) + cpdef tuple get_all_labels(self) + cpdef set_all_labels(self, labels) + cpdef start_collecting_temps(self) + cpdef stop_collecting_temps(self) + + cpdef list temps_in_use(self) + +cdef class IntConst: + cdef public object cname + cdef public object value + cdef public bint is_long + +cdef class PyObjectConst: + cdef public object cname + cdef public object type + +cdef class StringConst: + cdef public object cname + cdef public object text + cdef public object escaped_value + cdef public dict py_strings + cdef public list py_versions + + @cython.locals(intern=bint, is_str=bint, is_unicode=bint) + cpdef get_py_string_const(self, encoding, identifier=*, is_str=*, py3str_cstring=*) + +## cdef class PyStringConst: +## cdef public object cname +## cdef public object encoding +## cdef public bint is_str +## cdef public bint is_unicode +## cdef public bint intern + +#class GlobalState(object): + +#def funccontext_property(name): + +cdef class CCodeWriter(object): + cdef readonly StringIOTree buffer + cdef readonly list pyclass_stack + cdef readonly object globalstate + cdef readonly object funcstate + cdef object code_config + cdef object last_pos + cdef object last_marked_pos + cdef Py_ssize_t level + cdef public Py_ssize_t call_level # debug-only, see Nodes.py + cdef bint bol + + cpdef write(self, s) + cpdef put(self, code) + cpdef put_safe(self, code) + cpdef putln(self, code=*, bint safe=*) + @cython.final + cdef increase_indent(self) + @cython.final + cdef decrease_indent(self) + + +cdef class PyrexCodeWriter: + cdef public object f + cdef public Py_ssize_t level diff --git a/contrib/tools/cython/Cython/Compiler/Code.py b/contrib/tools/cython/Cython/Compiler/Code.py new file mode 100644 index 00000000000..d0b4756e599 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Code.py @@ -0,0 +1,2597 @@ +# cython: language_level = 2 +# cython: auto_pickle=False +# +# Code output module +# + +from __future__ import absolute_import + +import cython +cython.declare(os=object, re=object, operator=object, textwrap=object, + Template=object, Naming=object, Options=object, StringEncoding=object, + Utils=object, SourceDescriptor=object, StringIOTree=object, + DebugFlags=object, basestring=object, defaultdict=object, + closing=object, partial=object) + +import os +import re +import shutil +import sys +import operator +import textwrap +from string import Template +from functools import partial +from contextlib import closing +from collections import defaultdict + +try: + import hashlib +except ImportError: + import md5 as hashlib + +from . import Naming +from . import Options +from . import DebugFlags +from . import StringEncoding +from . import Version +from .. import Utils +from .Scanning import SourceDescriptor +from ..StringIOTree import StringIOTree + +try: + from __builtin__ import basestring +except ImportError: + from builtins import str as basestring + +KEYWORDS_MUST_BE_BYTES = sys.version_info < (2, 7) + + +non_portable_builtins_map = { + # builtins that have different names in different Python versions + 'bytes' : ('PY_MAJOR_VERSION < 3', 'str'), + 'unicode' : ('PY_MAJOR_VERSION >= 3', 'str'), + 'basestring' : ('PY_MAJOR_VERSION >= 3', 'str'), + 'xrange' : ('PY_MAJOR_VERSION >= 3', 'range'), + 'raw_input' : ('PY_MAJOR_VERSION >= 3', 'input'), +} + +ctypedef_builtins_map = { + # types of builtins in "ctypedef class" statements which we don't + # import either because the names conflict with C types or because + # the type simply is not exposed. + 'py_int' : '&PyInt_Type', + 'py_long' : '&PyLong_Type', + 'py_float' : '&PyFloat_Type', + 'wrapper_descriptor' : '&PyWrapperDescr_Type', +} + +basicsize_builtins_map = { + # builtins whose type has a different tp_basicsize than sizeof(...) + 'PyTypeObject': 'PyHeapTypeObject', +} + +uncachable_builtins = [ + # Global/builtin names that cannot be cached because they may or may not + # be available at import time, for various reasons: + ## - Py3.7+ + 'breakpoint', # might deserve an implementation in Cython + ## - Py3.4+ + '__loader__', + '__spec__', + ## - Py3+ + 'BlockingIOError', + 'BrokenPipeError', + 'ChildProcessError', + 'ConnectionAbortedError', + 'ConnectionError', + 'ConnectionRefusedError', + 'ConnectionResetError', + 'FileExistsError', + 'FileNotFoundError', + 'InterruptedError', + 'IsADirectoryError', + 'ModuleNotFoundError', + 'NotADirectoryError', + 'PermissionError', + 'ProcessLookupError', + 'RecursionError', + 'ResourceWarning', + #'StopAsyncIteration', # backported + 'TimeoutError', + '__build_class__', + 'ascii', # might deserve an implementation in Cython + #'exec', # implemented in Cython + ## - Py2.7+ + 'memoryview', + ## - platform specific + 'WindowsError', + ## - others + '_', # e.g. used by gettext +] + +special_py_methods = set([ + '__cinit__', '__dealloc__', '__richcmp__', '__next__', + '__await__', '__aiter__', '__anext__', + '__getreadbuffer__', '__getwritebuffer__', '__getsegcount__', + '__getcharbuffer__', '__getbuffer__', '__releasebuffer__' +]) + +modifier_output_mapper = { + 'inline': 'CYTHON_INLINE' +}.get + + +class IncludeCode(object): + """ + An include file and/or verbatim C code to be included in the + generated sources. + """ + # attributes: + # + # pieces {order: unicode}: pieces of C code to be generated. + # For the included file, the key "order" is zero. + # For verbatim include code, the "order" is the "order" + # attribute of the original IncludeCode where this piece + # of C code was first added. This is needed to prevent + # duplication if the same include code is found through + # multiple cimports. + # location int: where to put this include in the C sources, one + # of the constants INITIAL, EARLY, LATE + # order int: sorting order (automatically set by increasing counter) + + # Constants for location. If the same include occurs with different + # locations, the earliest one takes precedense. + INITIAL = 0 + EARLY = 1 + LATE = 2 + + counter = 1 # Counter for "order" + + def __init__(self, include=None, verbatim=None, late=True, initial=False): + self.order = self.counter + type(self).counter += 1 + self.pieces = {} + + if include: + if include[0] == '<' and include[-1] == '>': + self.pieces[0] = u'#include {0}'.format(include) + late = False # system include is never late + else: + self.pieces[0] = u'#include "{0}"'.format(include) + + if verbatim: + self.pieces[self.order] = verbatim + + if initial: + self.location = self.INITIAL + elif late: + self.location = self.LATE + else: + self.location = self.EARLY + + def dict_update(self, d, key): + """ + Insert `self` in dict `d` with key `key`. If that key already + exists, update the attributes of the existing value with `self`. + """ + if key in d: + other = d[key] + other.location = min(self.location, other.location) + other.pieces.update(self.pieces) + else: + d[key] = self + + def sortkey(self): + return self.order + + def mainpiece(self): + """ + Return the main piece of C code, corresponding to the include + file. If there was no include file, return None. + """ + return self.pieces.get(0) + + def write(self, code): + # Write values of self.pieces dict, sorted by the keys + for k in sorted(self.pieces): + code.putln(self.pieces[k]) + + +def get_utility_dir(): + # make this a function and not global variables: + # http://trac.cython.org/cython_trac/ticket/475 + Cython_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + return os.path.join(Cython_dir, "Utility") + + +class UtilityCodeBase(object): + """ + Support for loading utility code from a file. + + Code sections in the file can be specified as follows: + + ##### MyUtility.proto ##### + + [proto declarations] + + ##### MyUtility.init ##### + + [code run at module initialization] + + ##### MyUtility ##### + #@requires: MyOtherUtility + #@substitute: naming + + [definitions] + + for prototypes and implementation respectively. For non-python or + -cython files backslashes should be used instead. 5 to 30 comment + characters may be used on either side. + + If the @cname decorator is not used and this is a CythonUtilityCode, + one should pass in the 'name' keyword argument to be used for name + mangling of such entries. + """ + + is_cython_utility = False + _utility_cache = {} + + @classmethod + def _add_utility(cls, utility, type, lines, begin_lineno, tags=None): + if utility is None: + return + + code = '\n'.join(lines) + if tags and 'substitute' in tags and tags['substitute'] == set(['naming']): + del tags['substitute'] + try: + code = Template(code).substitute(vars(Naming)) + except (KeyError, ValueError) as e: + raise RuntimeError("Error parsing templated utility code of type '%s' at line %d: %s" % ( + type, begin_lineno, e)) + + # remember correct line numbers at least until after templating + code = '\n' * begin_lineno + code + + if type == 'proto': + utility[0] = code + elif type == 'impl': + utility[1] = code + else: + all_tags = utility[2] + if KEYWORDS_MUST_BE_BYTES: + type = type.encode('ASCII') + all_tags[type] = code + + if tags: + all_tags = utility[2] + for name, values in tags.items(): + if KEYWORDS_MUST_BE_BYTES: + name = name.encode('ASCII') + all_tags.setdefault(name, set()).update(values) + + @classmethod + def load_utilities_from_file(cls, path): + utilities = cls._utility_cache.get(path) + if utilities: + return utilities + + filename = os.path.join(get_utility_dir(), path) + _, ext = os.path.splitext(path) + if ext in ('.pyx', '.py', '.pxd', '.pxi'): + comment = '#' + strip_comments = partial(re.compile(r'^\s*#(?!\s*cython\s*:).*').sub, '') + rstrip = StringEncoding._unicode.rstrip + else: + comment = '/' + strip_comments = partial(re.compile(r'^\s*//.*|/\*[^*]*\*/').sub, '') + rstrip = partial(re.compile(r'\s+(\\?)$').sub, r'\1') + match_special = re.compile( + (r'^%(C)s{5,30}\s*(?P<name>(?:\w|\.)+)\s*%(C)s{5,30}|' + r'^%(C)s+@(?P<tag>\w+)\s*:\s*(?P<value>(?:\w|[.:])+)') % + {'C': comment}).match + match_type = re.compile(r'(.+)[.](proto(?:[.]\S+)?|impl|init|cleanup)$').match + + with closing(Utils.open_source_file(filename, encoding='UTF-8')) as f: + all_lines = f.readlines() + + utilities = defaultdict(lambda: [None, None, {}]) + lines = [] + tags = defaultdict(set) + utility = type = None + begin_lineno = 0 + + for lineno, line in enumerate(all_lines): + m = match_special(line) + if m: + if m.group('name'): + cls._add_utility(utility, type, lines, begin_lineno, tags) + + begin_lineno = lineno + 1 + del lines[:] + tags.clear() + + name = m.group('name') + mtype = match_type(name) + if mtype: + name, type = mtype.groups() + else: + type = 'impl' + utility = utilities[name] + else: + tags[m.group('tag')].add(m.group('value')) + lines.append('') # keep line number correct + else: + lines.append(rstrip(strip_comments(line))) + + if utility is None: + raise ValueError("Empty utility code file") + + # Don't forget to add the last utility code + cls._add_utility(utility, type, lines, begin_lineno, tags) + + utilities = dict(utilities) # un-defaultdict-ify + cls._utility_cache[path] = utilities + return utilities + + @classmethod + def load(cls, util_code_name, from_file=None, **kwargs): + """ + Load utility code from a file specified by from_file (relative to + Cython/Utility) and name util_code_name. If from_file is not given, + load it from the file util_code_name.*. There should be only one + file matched by this pattern. + """ + if '::' in util_code_name: + from_file, util_code_name = util_code_name.rsplit('::', 1) + if not from_file: + utility_dir = get_utility_dir() + prefix = util_code_name + '.' + try: + listing = os.listdir(utility_dir) + except OSError: + # XXX the code below assumes as 'zipimport.zipimporter' instance + # XXX should be easy to generalize, but too lazy right now to write it + import zipfile + global __loader__ + loader = __loader__ + archive = loader.archive + with closing(zipfile.ZipFile(archive)) as fileobj: + listing = [os.path.basename(name) + for name in fileobj.namelist() + if os.path.join(archive, name).startswith(utility_dir)] + files = [filename for filename in listing + if filename.startswith(prefix)] + if not files: + raise ValueError("No match found for utility code " + util_code_name) + if len(files) > 1: + raise ValueError("More than one filename match found for utility code " + util_code_name) + from_file = files[0] + + utilities = cls.load_utilities_from_file(from_file) + proto, impl, tags = utilities[util_code_name] + + if tags: + orig_kwargs = kwargs.copy() + for name, values in tags.items(): + if name in kwargs: + continue + # only pass lists when we have to: most argument expect one value or None + if name == 'requires': + if orig_kwargs: + values = [cls.load(dep, from_file, **orig_kwargs) + for dep in sorted(values)] + else: + # dependencies are rarely unique, so use load_cached() when we can + values = [cls.load_cached(dep, from_file) + for dep in sorted(values)] + elif not values: + values = None + elif len(values) == 1: + values = list(values)[0] + kwargs[name] = values + + if proto is not None: + kwargs['proto'] = proto + if impl is not None: + kwargs['impl'] = impl + + if 'name' not in kwargs: + kwargs['name'] = util_code_name + + if 'file' not in kwargs and from_file: + kwargs['file'] = from_file + return cls(**kwargs) + + @classmethod + def load_cached(cls, utility_code_name, from_file=None, __cache={}): + """ + Calls .load(), but using a per-type cache based on utility name and file name. + """ + key = (cls, from_file, utility_code_name) + try: + return __cache[key] + except KeyError: + pass + code = __cache[key] = cls.load(utility_code_name, from_file) + return code + + @classmethod + def load_as_string(cls, util_code_name, from_file=None, **kwargs): + """ + Load a utility code as a string. Returns (proto, implementation) + """ + util = cls.load(util_code_name, from_file, **kwargs) + proto, impl = util.proto, util.impl + return util.format_code(proto), util.format_code(impl) + + def format_code(self, code_string, replace_empty_lines=re.compile(r'\n\n+').sub): + """ + Format a code section for output. + """ + if code_string: + code_string = replace_empty_lines('\n', code_string.strip()) + '\n\n' + return code_string + + def __str__(self): + return "<%s(%s)>" % (type(self).__name__, self.name) + + def get_tree(self, **kwargs): + pass + + def __deepcopy__(self, memodict=None): + # No need to deep-copy utility code since it's essentially immutable. + return self + + +class UtilityCode(UtilityCodeBase): + """ + Stores utility code to add during code generation. + + See GlobalState.put_utility_code. + + hashes/equals by instance + + proto C prototypes + impl implementation code + init code to call on module initialization + requires utility code dependencies + proto_block the place in the resulting file where the prototype should + end up + name name of the utility code (or None) + file filename of the utility code file this utility was loaded + from (or None) + """ + + def __init__(self, proto=None, impl=None, init=None, cleanup=None, requires=None, + proto_block='utility_code_proto', name=None, file=None): + # proto_block: Which code block to dump prototype in. See GlobalState. + self.proto = proto + self.impl = impl + self.init = init + self.cleanup = cleanup + self.requires = requires + self._cache = {} + self.specialize_list = [] + self.proto_block = proto_block + self.name = name + self.file = file + + def __hash__(self): + return hash((self.proto, self.impl)) + + def __eq__(self, other): + if self is other: + return True + self_type, other_type = type(self), type(other) + if self_type is not other_type and not (isinstance(other, self_type) or isinstance(self, other_type)): + return False + + self_proto = getattr(self, 'proto', None) + other_proto = getattr(other, 'proto', None) + return (self_proto, self.impl) == (other_proto, other.impl) + + def none_or_sub(self, s, context): + """ + Format a string in this utility code with context. If None, do nothing. + """ + if s is None: + return None + return s % context + + def specialize(self, pyrex_type=None, **data): + # Dicts aren't hashable... + name = self.name + if pyrex_type is not None: + data['type'] = pyrex_type.empty_declaration_code() + data['type_name'] = pyrex_type.specialization_name() + name = "%s[%s]" % (name, data['type_name']) + key = tuple(sorted(data.items())) + try: + return self._cache[key] + except KeyError: + if self.requires is None: + requires = None + else: + requires = [r.specialize(data) for r in self.requires] + + s = self._cache[key] = UtilityCode( + self.none_or_sub(self.proto, data), + self.none_or_sub(self.impl, data), + self.none_or_sub(self.init, data), + self.none_or_sub(self.cleanup, data), + requires, + self.proto_block, + name, + ) + + self.specialize_list.append(s) + return s + + def inject_string_constants(self, impl, output): + """Replace 'PYIDENT("xyz")' by a constant Python identifier cname. + """ + if 'PYIDENT(' not in impl and 'PYUNICODE(' not in impl: + return False, impl + + replacements = {} + def externalise(matchobj): + key = matchobj.groups() + try: + cname = replacements[key] + except KeyError: + str_type, name = key + cname = replacements[key] = output.get_py_string_const( + StringEncoding.EncodedString(name), identifier=str_type == 'IDENT').cname + return cname + + impl = re.sub(r'PY(IDENT|UNICODE)\("([^"]+)"\)', externalise, impl) + assert 'PYIDENT(' not in impl and 'PYUNICODE(' not in impl + return True, impl + + def inject_unbound_methods(self, impl, output): + """Replace 'UNBOUND_METHOD(type, "name")' by a constant Python identifier cname. + """ + if 'CALL_UNBOUND_METHOD(' not in impl: + return False, impl + + def externalise(matchobj): + type_cname, method_name, obj_cname, args = matchobj.groups() + args = [arg.strip() for arg in args[1:].split(',')] if args else [] + assert len(args) < 3, "CALL_UNBOUND_METHOD() does not support %d call arguments" % len(args) + return output.cached_unbound_method_call_code(obj_cname, type_cname, method_name, args) + + impl = re.sub( + r'CALL_UNBOUND_METHOD\(' + r'([a-zA-Z_]+),' # type cname + r'\s*"([^"]+)",' # method name + r'\s*([^),]+)' # object cname + r'((?:,\s*[^),]+)*)' # args* + r'\)', externalise, impl) + assert 'CALL_UNBOUND_METHOD(' not in impl + + return True, impl + + def wrap_c_strings(self, impl): + """Replace CSTRING('''xyz''') by a C compatible string + """ + if 'CSTRING(' not in impl: + return impl + + def split_string(matchobj): + content = matchobj.group(1).replace('"', '\042') + return ''.join( + '"%s\\n"\n' % line if not line.endswith('\\') or line.endswith('\\\\') else '"%s"\n' % line[:-1] + for line in content.splitlines()) + + impl = re.sub(r'CSTRING\(\s*"""([^"]*(?:"[^"]+)*)"""\s*\)', split_string, impl) + assert 'CSTRING(' not in impl + return impl + + def put_code(self, output): + if self.requires: + for dependency in self.requires: + output.use_utility_code(dependency) + if self.proto: + writer = output[self.proto_block] + writer.putln("/* %s.proto */" % self.name) + writer.put_or_include( + self.format_code(self.proto), '%s_proto' % self.name) + if self.impl: + impl = self.format_code(self.wrap_c_strings(self.impl)) + is_specialised1, impl = self.inject_string_constants(impl, output) + is_specialised2, impl = self.inject_unbound_methods(impl, output) + writer = output['utility_code_def'] + writer.putln("/* %s */" % self.name) + if not (is_specialised1 or is_specialised2): + # no module specific adaptations => can be reused + writer.put_or_include(impl, '%s_impl' % self.name) + else: + writer.put(impl) + if self.init: + writer = output['init_globals'] + writer.putln("/* %s.init */" % self.name) + if isinstance(self.init, basestring): + writer.put(self.format_code(self.init)) + else: + self.init(writer, output.module_pos) + writer.putln(writer.error_goto_if_PyErr(output.module_pos)) + writer.putln() + if self.cleanup and Options.generate_cleanup_code: + writer = output['cleanup_globals'] + writer.putln("/* %s.cleanup */" % self.name) + if isinstance(self.cleanup, basestring): + writer.put_or_include( + self.format_code(self.cleanup), + '%s_cleanup' % self.name) + else: + self.cleanup(writer, output.module_pos) + + +def sub_tempita(s, context, file=None, name=None): + "Run tempita on string s with given context." + if not s: + return None + + if file: + context['__name'] = "%s:%s" % (file, name) + elif name: + context['__name'] = name + + from ..Tempita import sub + return sub(s, **context) + + +class TempitaUtilityCode(UtilityCode): + def __init__(self, name=None, proto=None, impl=None, init=None, file=None, context=None, **kwargs): + if context is None: + context = {} + proto = sub_tempita(proto, context, file, name) + impl = sub_tempita(impl, context, file, name) + init = sub_tempita(init, context, file, name) + super(TempitaUtilityCode, self).__init__( + proto, impl, init=init, name=name, file=file, **kwargs) + + @classmethod + def load_cached(cls, utility_code_name, from_file=None, context=None, __cache={}): + context_key = tuple(sorted(context.items())) if context else None + assert hash(context_key) is not None # raise TypeError if not hashable + key = (cls, from_file, utility_code_name, context_key) + try: + return __cache[key] + except KeyError: + pass + code = __cache[key] = cls.load(utility_code_name, from_file, context=context) + return code + + def none_or_sub(self, s, context): + """ + Format a string in this utility code with context. If None, do nothing. + """ + if s is None: + return None + return sub_tempita(s, context, self.file, self.name) + + +class LazyUtilityCode(UtilityCodeBase): + """ + Utility code that calls a callback with the root code writer when + available. Useful when you only have 'env' but not 'code'. + """ + __name__ = '<lazy>' + requires = None + + def __init__(self, callback): + self.callback = callback + + def put_code(self, globalstate): + utility = self.callback(globalstate.rootwriter) + globalstate.use_utility_code(utility) + + +class FunctionState(object): + # return_label string function return point label + # error_label string error catch point label + # continue_label string loop continue point label + # break_label string loop break point label + # return_from_error_cleanup_label string + # label_counter integer counter for naming labels + # in_try_finally boolean inside try of try...finally + # exc_vars (string * 3) exception variables for reraise, or None + # can_trace boolean line tracing is supported in the current context + # scope Scope the scope object of the current function + + # Not used for now, perhaps later + def __init__(self, owner, names_taken=set(), scope=None): + self.names_taken = names_taken + self.owner = owner + self.scope = scope + + self.error_label = None + self.label_counter = 0 + self.labels_used = set() + self.return_label = self.new_label() + self.new_error_label() + self.continue_label = None + self.break_label = None + self.yield_labels = [] + + self.in_try_finally = 0 + self.exc_vars = None + self.current_except = None + self.can_trace = False + self.gil_owned = True + + self.temps_allocated = [] # of (name, type, manage_ref, static) + self.temps_free = {} # (type, manage_ref) -> list of free vars with same type/managed status + self.temps_used_type = {} # name -> (type, manage_ref) + self.zombie_temps = set() # temps that must not be reused after release + self.temp_counter = 0 + self.closure_temps = None + + # This is used to collect temporaries, useful to find out which temps + # need to be privatized in parallel sections + self.collect_temps_stack = [] + + # This is used for the error indicator, which needs to be local to the + # function. It used to be global, which relies on the GIL being held. + # However, exceptions may need to be propagated through 'nogil' + # sections, in which case we introduce a race condition. + self.should_declare_error_indicator = False + self.uses_error_indicator = False + + # safety checks + + def validate_exit(self): + # validate that all allocated temps have been freed + if self.temps_allocated: + leftovers = self.temps_in_use() + if leftovers: + msg = "TEMPGUARD: Temps left over at end of '%s': %s" % (self.scope.name, ', '.join([ + '%s [%s]' % (name, ctype) + for name, ctype, is_pytemp in sorted(leftovers)]), + ) + #print(msg) + raise RuntimeError(msg) + + # labels + + def new_label(self, name=None): + n = self.label_counter + self.label_counter = n + 1 + label = "%s%d" % (Naming.label_prefix, n) + if name is not None: + label += '_' + name + return label + + def new_yield_label(self, expr_type='yield'): + label = self.new_label('resume_from_%s' % expr_type) + num_and_label = (len(self.yield_labels) + 1, label) + self.yield_labels.append(num_and_label) + return num_and_label + + def new_error_label(self): + old_err_lbl = self.error_label + self.error_label = self.new_label('error') + return old_err_lbl + + def get_loop_labels(self): + return ( + self.continue_label, + self.break_label) + + def set_loop_labels(self, labels): + (self.continue_label, + self.break_label) = labels + + def new_loop_labels(self): + old_labels = self.get_loop_labels() + self.set_loop_labels( + (self.new_label("continue"), + self.new_label("break"))) + return old_labels + + def get_all_labels(self): + return ( + self.continue_label, + self.break_label, + self.return_label, + self.error_label) + + def set_all_labels(self, labels): + (self.continue_label, + self.break_label, + self.return_label, + self.error_label) = labels + + def all_new_labels(self): + old_labels = self.get_all_labels() + new_labels = [] + for old_label, name in zip(old_labels, ['continue', 'break', 'return', 'error']): + if old_label: + new_labels.append(self.new_label(name)) + else: + new_labels.append(old_label) + self.set_all_labels(new_labels) + return old_labels + + def use_label(self, lbl): + self.labels_used.add(lbl) + + def label_used(self, lbl): + return lbl in self.labels_used + + # temp handling + + def allocate_temp(self, type, manage_ref, static=False, reusable=True): + """ + Allocates a temporary (which may create a new one or get a previously + allocated and released one of the same type). Type is simply registered + and handed back, but will usually be a PyrexType. + + If type.is_pyobject, manage_ref comes into play. If manage_ref is set to + True, the temp will be decref-ed on return statements and in exception + handling clauses. Otherwise the caller has to deal with any reference + counting of the variable. + + If not type.is_pyobject, then manage_ref will be ignored, but it + still has to be passed. It is recommended to pass False by convention + if it is known that type will never be a Python object. + + static=True marks the temporary declaration with "static". + This is only used when allocating backing store for a module-level + C array literals. + + if reusable=False, the temp will not be reused after release. + + A C string referring to the variable is returned. + """ + if type.is_const and not type.is_reference: + type = type.const_base_type + elif type.is_reference and not type.is_fake_reference: + type = type.ref_base_type + elif type.is_cfunction: + from . import PyrexTypes + type = PyrexTypes.c_ptr_type(type) # A function itself isn't an l-value + if not type.is_pyobject and not type.is_memoryviewslice: + # Make manage_ref canonical, so that manage_ref will always mean + # a decref is needed. + manage_ref = False + + freelist = self.temps_free.get((type, manage_ref)) + if reusable and freelist is not None and freelist[0]: + result = freelist[0].pop() + freelist[1].remove(result) + else: + while True: + self.temp_counter += 1 + result = "%s%d" % (Naming.codewriter_temp_prefix, self.temp_counter) + if result not in self.names_taken: break + self.temps_allocated.append((result, type, manage_ref, static)) + if not reusable: + self.zombie_temps.add(result) + self.temps_used_type[result] = (type, manage_ref) + if DebugFlags.debug_temp_code_comments: + self.owner.putln("/* %s allocated (%s)%s */" % (result, type, "" if reusable else " - zombie")) + + if self.collect_temps_stack: + self.collect_temps_stack[-1].add((result, type)) + + return result + + def release_temp(self, name): + """ + Releases a temporary so that it can be reused by other code needing + a temp of the same type. + """ + type, manage_ref = self.temps_used_type[name] + freelist = self.temps_free.get((type, manage_ref)) + if freelist is None: + freelist = ([], set()) # keep order in list and make lookups in set fast + self.temps_free[(type, manage_ref)] = freelist + if name in freelist[1]: + raise RuntimeError("Temp %s freed twice!" % name) + if name not in self.zombie_temps: + freelist[0].append(name) + freelist[1].add(name) + if DebugFlags.debug_temp_code_comments: + self.owner.putln("/* %s released %s*/" % ( + name, " - zombie" if name in self.zombie_temps else "")) + + def temps_in_use(self): + """Return a list of (cname,type,manage_ref) tuples of temp names and their type + that are currently in use. + """ + used = [] + for name, type, manage_ref, static in self.temps_allocated: + freelist = self.temps_free.get((type, manage_ref)) + if freelist is None or name not in freelist[1]: + used.append((name, type, manage_ref and type.is_pyobject)) + return used + + def temps_holding_reference(self): + """Return a list of (cname,type) tuples of temp names and their type + that are currently in use. This includes only temps of a + Python object type which owns its reference. + """ + return [(name, type) + for name, type, manage_ref in self.temps_in_use() + if manage_ref and type.is_pyobject] + + def all_managed_temps(self): + """Return a list of (cname, type) tuples of refcount-managed Python objects. + """ + return [(cname, type) + for cname, type, manage_ref, static in self.temps_allocated + if manage_ref] + + def all_free_managed_temps(self): + """Return a list of (cname, type) tuples of refcount-managed Python + objects that are not currently in use. This is used by + try-except and try-finally blocks to clean up temps in the + error case. + """ + return sorted([ # Enforce deterministic order. + (cname, type) + for (type, manage_ref), freelist in self.temps_free.items() if manage_ref + for cname in freelist[0] + ]) + + def start_collecting_temps(self): + """ + Useful to find out which temps were used in a code block + """ + self.collect_temps_stack.append(set()) + + def stop_collecting_temps(self): + return self.collect_temps_stack.pop() + + def init_closure_temps(self, scope): + self.closure_temps = ClosureTempAllocator(scope) + + +class NumConst(object): + """Global info about a Python number constant held by GlobalState. + + cname string + value string + py_type string int, long, float + value_code string evaluation code if different from value + """ + + def __init__(self, cname, value, py_type, value_code=None): + self.cname = cname + self.value = value + self.py_type = py_type + self.value_code = value_code or value + + +class PyObjectConst(object): + """Global info about a generic constant held by GlobalState. + """ + # cname string + # type PyrexType + + def __init__(self, cname, type): + self.cname = cname + self.type = type + + +cython.declare(possible_unicode_identifier=object, possible_bytes_identifier=object, + replace_identifier=object, find_alphanums=object) +possible_unicode_identifier = re.compile(br"(?![0-9])\w+$".decode('ascii'), re.U).match +possible_bytes_identifier = re.compile(r"(?![0-9])\w+$".encode('ASCII')).match +replace_identifier = re.compile(r'[^a-zA-Z0-9_]+').sub +find_alphanums = re.compile('([a-zA-Z0-9]+)').findall + +class StringConst(object): + """Global info about a C string constant held by GlobalState. + """ + # cname string + # text EncodedString or BytesLiteral + # py_strings {(identifier, encoding) : PyStringConst} + + def __init__(self, cname, text, byte_string): + self.cname = cname + self.text = text + self.escaped_value = StringEncoding.escape_byte_string(byte_string) + self.py_strings = None + self.py_versions = [] + + def add_py_version(self, version): + if not version: + self.py_versions = [2, 3] + elif version not in self.py_versions: + self.py_versions.append(version) + + def get_py_string_const(self, encoding, identifier=None, + is_str=False, py3str_cstring=None): + py_strings = self.py_strings + text = self.text + + is_str = bool(identifier or is_str) + is_unicode = encoding is None and not is_str + + if encoding is None: + # unicode string + encoding_key = None + else: + # bytes or str + encoding = encoding.lower() + if encoding in ('utf8', 'utf-8', 'ascii', 'usascii', 'us-ascii'): + encoding = None + encoding_key = None + else: + encoding_key = ''.join(find_alphanums(encoding)) + + key = (is_str, is_unicode, encoding_key, py3str_cstring) + if py_strings is not None: + try: + return py_strings[key] + except KeyError: + pass + else: + self.py_strings = {} + + if identifier: + intern = True + elif identifier is None: + if isinstance(text, bytes): + intern = bool(possible_bytes_identifier(text)) + else: + intern = bool(possible_unicode_identifier(text)) + else: + intern = False + if intern: + prefix = Naming.interned_prefixes['str'] + else: + prefix = Naming.py_const_prefix + + if encoding_key: + encoding_prefix = '_%s' % encoding_key + else: + encoding_prefix = '' + + pystring_cname = "%s%s%s_%s" % ( + prefix, + (is_str and 's') or (is_unicode and 'u') or 'b', + encoding_prefix, + self.cname[len(Naming.const_prefix):]) + + py_string = PyStringConst( + pystring_cname, encoding, is_unicode, is_str, py3str_cstring, intern) + self.py_strings[key] = py_string + return py_string + +class PyStringConst(object): + """Global info about a Python string constant held by GlobalState. + """ + # cname string + # py3str_cstring string + # encoding string + # intern boolean + # is_unicode boolean + # is_str boolean + + def __init__(self, cname, encoding, is_unicode, is_str=False, + py3str_cstring=None, intern=False): + self.cname = cname + self.py3str_cstring = py3str_cstring + self.encoding = encoding + self.is_str = is_str + self.is_unicode = is_unicode + self.intern = intern + + def __lt__(self, other): + return self.cname < other.cname + + +class GlobalState(object): + # filename_table {string : int} for finding filename table indexes + # filename_list [string] filenames in filename table order + # input_file_contents dict contents (=list of lines) of any file that was used as input + # to create this output C code. This is + # used to annotate the comments. + # + # utility_codes set IDs of used utility code (to avoid reinsertion) + # + # declared_cnames {string:Entry} used in a transition phase to merge pxd-declared + # constants etc. into the pyx-declared ones (i.e, + # check if constants are already added). + # In time, hopefully the literals etc. will be + # supplied directly instead. + # + # const_cnames_used dict global counter for unique constant identifiers + # + + # parts {string:CCodeWriter} + + + # interned_strings + # consts + # interned_nums + + # directives set Temporary variable used to track + # the current set of directives in the code generation + # process. + + directives = {} + + code_layout = [ + 'h_code', + 'filename_table', + 'utility_code_proto_before_types', + 'numeric_typedefs', # Let these detailed individual parts stay!, + 'complex_type_declarations', # as the proper solution is to make a full DAG... + 'type_declarations', # More coarse-grained blocks would simply hide + 'utility_code_proto', # the ugliness, not fix it + 'module_declarations', + 'typeinfo', + 'before_global_var', + 'global_var', + 'string_decls', + 'decls', + 'late_includes', + 'all_the_rest', + 'pystring_table', + 'cached_builtins', + 'cached_constants', + 'init_globals', + 'init_module', + 'cleanup_globals', + 'cleanup_module', + 'main_method', + 'utility_code_def', + 'end' + ] + + + def __init__(self, writer, module_node, code_config, common_utility_include_dir=None): + self.filename_table = {} + self.filename_list = [] + self.input_file_contents = {} + self.utility_codes = set() + self.declared_cnames = {} + self.in_utility_code_generation = False + self.code_config = code_config + self.common_utility_include_dir = common_utility_include_dir + self.parts = {} + self.module_node = module_node # because some utility code generation needs it + # (generating backwards-compatible Get/ReleaseBuffer + + self.const_cnames_used = {} + self.string_const_index = {} + self.dedup_const_index = {} + self.pyunicode_ptr_const_index = {} + self.num_const_index = {} + self.py_constants = [] + self.cached_cmethods = {} + self.initialised_constants = set() + + writer.set_global_state(self) + self.rootwriter = writer + + def initialize_main_c_code(self): + rootwriter = self.rootwriter + for part in self.code_layout: + self.parts[part] = rootwriter.insertion_point() + + if not Options.cache_builtins: + del self.parts['cached_builtins'] + else: + w = self.parts['cached_builtins'] + w.enter_cfunc_scope() + w.putln("static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {") + + w = self.parts['cached_constants'] + w.enter_cfunc_scope() + w.putln("") + w.putln("static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {") + w.put_declare_refcount_context() + w.put_setup_refcount_context("__Pyx_InitCachedConstants") + + w = self.parts['init_globals'] + w.enter_cfunc_scope() + w.putln("") + w.putln("static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {") + + if not Options.generate_cleanup_code: + del self.parts['cleanup_globals'] + else: + w = self.parts['cleanup_globals'] + w.enter_cfunc_scope() + w.putln("") + w.putln("static CYTHON_SMALL_CODE void __Pyx_CleanupGlobals(void) {") + + code = self.parts['utility_code_proto'] + code.putln("") + code.putln("/* --- Runtime support code (head) --- */") + + code = self.parts['utility_code_def'] + if self.code_config.emit_linenums: + code.write('\n#line 1 "cython_utility"\n') + code.putln("") + code.putln("/* --- Runtime support code --- */") + + def finalize_main_c_code(self): + self.close_global_decls() + + # + # utility_code_def + # + code = self.parts['utility_code_def'] + util = TempitaUtilityCode.load_cached("TypeConversions", "TypeConversion.c") + code.put(util.format_code(util.impl)) + code.putln("") + + def __getitem__(self, key): + return self.parts[key] + + # + # Global constants, interned objects, etc. + # + def close_global_decls(self): + # This is called when it is known that no more global declarations will + # declared. + self.generate_const_declarations() + if Options.cache_builtins: + w = self.parts['cached_builtins'] + w.putln("return 0;") + if w.label_used(w.error_label): + w.put_label(w.error_label) + w.putln("return -1;") + w.putln("}") + w.exit_cfunc_scope() + + w = self.parts['cached_constants'] + w.put_finish_refcount_context() + w.putln("return 0;") + if w.label_used(w.error_label): + w.put_label(w.error_label) + w.put_finish_refcount_context() + w.putln("return -1;") + w.putln("}") + w.exit_cfunc_scope() + + w = self.parts['init_globals'] + w.putln("return 0;") + if w.label_used(w.error_label): + w.put_label(w.error_label) + w.putln("return -1;") + w.putln("}") + w.exit_cfunc_scope() + + if Options.generate_cleanup_code: + w = self.parts['cleanup_globals'] + w.putln("}") + w.exit_cfunc_scope() + + if Options.generate_cleanup_code: + w = self.parts['cleanup_module'] + w.putln("}") + w.exit_cfunc_scope() + + def put_pyobject_decl(self, entry): + self['global_var'].putln("static PyObject *%s;" % entry.cname) + + # constant handling at code generation time + + def get_cached_constants_writer(self, target=None): + if target is not None: + if target in self.initialised_constants: + # Return None on second/later calls to prevent duplicate creation code. + return None + self.initialised_constants.add(target) + return self.parts['cached_constants'] + + def get_int_const(self, str_value, longness=False): + py_type = longness and 'long' or 'int' + try: + c = self.num_const_index[(str_value, py_type)] + except KeyError: + c = self.new_num_const(str_value, py_type) + return c + + def get_float_const(self, str_value, value_code): + try: + c = self.num_const_index[(str_value, 'float')] + except KeyError: + c = self.new_num_const(str_value, 'float', value_code) + return c + + def get_py_const(self, type, prefix='', cleanup_level=None, dedup_key=None): + if dedup_key is not None: + const = self.dedup_const_index.get(dedup_key) + if const is not None: + return const + # create a new Python object constant + const = self.new_py_const(type, prefix) + if cleanup_level is not None \ + and cleanup_level <= Options.generate_cleanup_code: + cleanup_writer = self.parts['cleanup_globals'] + cleanup_writer.putln('Py_CLEAR(%s);' % const.cname) + if dedup_key is not None: + self.dedup_const_index[dedup_key] = const + return const + + def get_string_const(self, text, py_version=None): + # return a C string constant, creating a new one if necessary + if text.is_unicode: + byte_string = text.utf8encode() + else: + byte_string = text.byteencode() + try: + c = self.string_const_index[byte_string] + except KeyError: + c = self.new_string_const(text, byte_string) + c.add_py_version(py_version) + return c + + def get_pyunicode_ptr_const(self, text): + # return a Py_UNICODE[] constant, creating a new one if necessary + assert text.is_unicode + try: + c = self.pyunicode_ptr_const_index[text] + except KeyError: + c = self.pyunicode_ptr_const_index[text] = self.new_const_cname() + return c + + def get_py_string_const(self, text, identifier=None, + is_str=False, unicode_value=None): + # return a Python string constant, creating a new one if necessary + py3str_cstring = None + if is_str and unicode_value is not None \ + and unicode_value.utf8encode() != text.byteencode(): + py3str_cstring = self.get_string_const(unicode_value, py_version=3) + c_string = self.get_string_const(text, py_version=2) + else: + c_string = self.get_string_const(text) + py_string = c_string.get_py_string_const( + text.encoding, identifier, is_str, py3str_cstring) + return py_string + + def get_interned_identifier(self, text): + return self.get_py_string_const(text, identifier=True) + + def new_string_const(self, text, byte_string): + cname = self.new_string_const_cname(byte_string) + c = StringConst(cname, text, byte_string) + self.string_const_index[byte_string] = c + return c + + def new_num_const(self, value, py_type, value_code=None): + cname = self.new_num_const_cname(value, py_type) + c = NumConst(cname, value, py_type, value_code) + self.num_const_index[(value, py_type)] = c + return c + + def new_py_const(self, type, prefix=''): + cname = self.new_const_cname(prefix) + c = PyObjectConst(cname, type) + self.py_constants.append(c) + return c + + def new_string_const_cname(self, bytes_value): + # Create a new globally-unique nice name for a C string constant. + value = bytes_value.decode('ASCII', 'ignore') + return self.new_const_cname(value=value) + + def new_num_const_cname(self, value, py_type): + if py_type == 'long': + value += 'L' + py_type = 'int' + prefix = Naming.interned_prefixes[py_type] + cname = "%s%s" % (prefix, value) + cname = cname.replace('+', '_').replace('-', 'neg_').replace('.', '_') + return cname + + def new_const_cname(self, prefix='', value=''): + value = replace_identifier('_', value)[:32].strip('_') + used = self.const_cnames_used + name_suffix = value + while name_suffix in used: + counter = used[value] = used[value] + 1 + name_suffix = '%s_%d' % (value, counter) + used[name_suffix] = 1 + if prefix: + prefix = Naming.interned_prefixes[prefix] + else: + prefix = Naming.const_prefix + return "%s%s" % (prefix, name_suffix) + + def get_cached_unbound_method(self, type_cname, method_name): + key = (type_cname, method_name) + try: + cname = self.cached_cmethods[key] + except KeyError: + cname = self.cached_cmethods[key] = self.new_const_cname( + 'umethod', '%s_%s' % (type_cname, method_name)) + return cname + + def cached_unbound_method_call_code(self, obj_cname, type_cname, method_name, arg_cnames): + # admittedly, not the best place to put this method, but it is reused by UtilityCode and ExprNodes ... + utility_code_name = "CallUnboundCMethod%d" % len(arg_cnames) + self.use_utility_code(UtilityCode.load_cached(utility_code_name, "ObjectHandling.c")) + cache_cname = self.get_cached_unbound_method(type_cname, method_name) + args = [obj_cname] + arg_cnames + return "__Pyx_%s(&%s, %s)" % ( + utility_code_name, + cache_cname, + ', '.join(args), + ) + + def add_cached_builtin_decl(self, entry): + if entry.is_builtin and entry.is_const: + if self.should_declare(entry.cname, entry): + self.put_pyobject_decl(entry) + w = self.parts['cached_builtins'] + condition = None + if entry.name in non_portable_builtins_map: + condition, replacement = non_portable_builtins_map[entry.name] + w.putln('#if %s' % condition) + self.put_cached_builtin_init( + entry.pos, StringEncoding.EncodedString(replacement), + entry.cname) + w.putln('#else') + self.put_cached_builtin_init( + entry.pos, StringEncoding.EncodedString(entry.name), + entry.cname) + if condition: + w.putln('#endif') + + def put_cached_builtin_init(self, pos, name, cname): + w = self.parts['cached_builtins'] + interned_cname = self.get_interned_identifier(name).cname + self.use_utility_code( + UtilityCode.load_cached("GetBuiltinName", "ObjectHandling.c")) + w.putln('%s = __Pyx_GetBuiltinName(%s); if (!%s) %s' % ( + cname, + interned_cname, + cname, + w.error_goto(pos))) + + def generate_const_declarations(self): + self.generate_cached_methods_decls() + self.generate_string_constants() + self.generate_num_constants() + self.generate_object_constant_decls() + + def generate_object_constant_decls(self): + consts = [(len(c.cname), c.cname, c) + for c in self.py_constants] + consts.sort() + decls_writer = self.parts['decls'] + for _, cname, c in consts: + decls_writer.putln( + "static %s;" % c.type.declaration_code(cname)) + + def generate_cached_methods_decls(self): + if not self.cached_cmethods: + return + + decl = self.parts['decls'] + init = self.parts['init_globals'] + cnames = [] + for (type_cname, method_name), cname in sorted(self.cached_cmethods.items()): + cnames.append(cname) + method_name_cname = self.get_interned_identifier(StringEncoding.EncodedString(method_name)).cname + decl.putln('static __Pyx_CachedCFunction %s = {0, &%s, 0, 0, 0};' % ( + cname, method_name_cname)) + # split type reference storage as it might not be static + init.putln('%s.type = (PyObject*)&%s;' % ( + cname, type_cname)) + + if Options.generate_cleanup_code: + cleanup = self.parts['cleanup_globals'] + for cname in cnames: + cleanup.putln("Py_CLEAR(%s.method);" % cname) + + def generate_string_constants(self): + c_consts = [(len(c.cname), c.cname, c) for c in self.string_const_index.values()] + c_consts.sort() + py_strings = [] + + decls_writer = self.parts['string_decls'] + for _, cname, c in c_consts: + conditional = False + if c.py_versions and (2 not in c.py_versions or 3 not in c.py_versions): + conditional = True + decls_writer.putln("#if PY_MAJOR_VERSION %s 3" % ( + (2 in c.py_versions) and '<' or '>=')) + decls_writer.putln('static const char %s[] = "%s";' % ( + cname, StringEncoding.split_string_literal(c.escaped_value))) + if conditional: + decls_writer.putln("#endif") + if c.py_strings is not None: + for py_string in c.py_strings.values(): + py_strings.append((c.cname, len(py_string.cname), py_string)) + + for c, cname in sorted(self.pyunicode_ptr_const_index.items()): + utf16_array, utf32_array = StringEncoding.encode_pyunicode_string(c) + if utf16_array: + # Narrow and wide representations differ + decls_writer.putln("#ifdef Py_UNICODE_WIDE") + decls_writer.putln("static Py_UNICODE %s[] = { %s };" % (cname, utf32_array)) + if utf16_array: + decls_writer.putln("#else") + decls_writer.putln("static Py_UNICODE %s[] = { %s };" % (cname, utf16_array)) + decls_writer.putln("#endif") + + if py_strings: + self.use_utility_code(UtilityCode.load_cached("InitStrings", "StringTools.c")) + py_strings.sort() + w = self.parts['pystring_table'] + w.putln("") + w.putln("static __Pyx_StringTabEntry %s[] = {" % Naming.stringtab_cname) + for c_cname, _, py_string in py_strings: + if not py_string.is_str or not py_string.encoding or \ + py_string.encoding in ('ASCII', 'USASCII', 'US-ASCII', + 'UTF8', 'UTF-8'): + encoding = '0' + else: + encoding = '"%s"' % py_string.encoding.lower() + + decls_writer.putln( + "static PyObject *%s;" % py_string.cname) + if py_string.py3str_cstring: + w.putln("#if PY_MAJOR_VERSION >= 3") + w.putln("{&%s, %s, sizeof(%s), %s, %d, %d, %d}," % ( + py_string.cname, + py_string.py3str_cstring.cname, + py_string.py3str_cstring.cname, + '0', 1, 0, + py_string.intern + )) + w.putln("#else") + w.putln("{&%s, %s, sizeof(%s), %s, %d, %d, %d}," % ( + py_string.cname, + c_cname, + c_cname, + encoding, + py_string.is_unicode, + py_string.is_str, + py_string.intern + )) + if py_string.py3str_cstring: + w.putln("#endif") + w.putln("{0, 0, 0, 0, 0, 0, 0}") + w.putln("};") + + init_globals = self.parts['init_globals'] + init_globals.putln( + "if (__Pyx_InitStrings(%s) < 0) %s" % ( + Naming.stringtab_cname, + init_globals.error_goto(self.module_pos))) + + def generate_num_constants(self): + consts = [(c.py_type, c.value[0] == '-', len(c.value), c.value, c.value_code, c) + for c in self.num_const_index.values()] + consts.sort() + decls_writer = self.parts['decls'] + init_globals = self.parts['init_globals'] + for py_type, _, _, value, value_code, c in consts: + cname = c.cname + decls_writer.putln("static PyObject *%s;" % cname) + if py_type == 'float': + function = 'PyFloat_FromDouble(%s)' + elif py_type == 'long': + function = 'PyLong_FromString((char *)"%s", 0, 0)' + elif Utils.long_literal(value): + function = 'PyInt_FromString((char *)"%s", 0, 0)' + elif len(value.lstrip('-')) > 4: + function = "PyInt_FromLong(%sL)" + else: + function = "PyInt_FromLong(%s)" + init_globals.putln('%s = %s; %s' % ( + cname, function % value_code, + init_globals.error_goto_if_null(cname, self.module_pos))) + + # The functions below are there in a transition phase only + # and will be deprecated. They are called from Nodes.BlockNode. + # The copy&paste duplication is intentional in order to be able + # to see quickly how BlockNode worked, until this is replaced. + + def should_declare(self, cname, entry): + if cname in self.declared_cnames: + other = self.declared_cnames[cname] + assert str(entry.type) == str(other.type) + assert entry.init == other.init + return False + else: + self.declared_cnames[cname] = entry + return True + + # + # File name state + # + + def lookup_filename(self, source_desc): + entry = source_desc.get_filenametable_entry() + try: + index = self.filename_table[entry] + except KeyError: + index = len(self.filename_list) + self.filename_list.append(source_desc) + self.filename_table[entry] = index + return index + + def commented_file_contents(self, source_desc): + try: + return self.input_file_contents[source_desc] + except KeyError: + pass + source_file = source_desc.get_lines(encoding='ASCII', + error_handling='ignore') + try: + F = [u' * ' + line.rstrip().replace( + u'*/', u'*[inserted by cython to avoid comment closer]/' + ).replace( + u'/*', u'/[inserted by cython to avoid comment start]*' + ) + for line in source_file] + finally: + if hasattr(source_file, 'close'): + source_file.close() + if not F: F.append(u'') + self.input_file_contents[source_desc] = F + return F + + # + # Utility code state + # + + def use_utility_code(self, utility_code): + """ + Adds code to the C file. utility_code should + a) implement __eq__/__hash__ for the purpose of knowing whether the same + code has already been included + b) implement put_code, which takes a globalstate instance + + See UtilityCode. + """ + if utility_code and utility_code not in self.utility_codes: + self.utility_codes.add(utility_code) + utility_code.put_code(self) + + def use_entry_utility_code(self, entry): + if entry is None: + return + if entry.utility_code: + self.use_utility_code(entry.utility_code) + if entry.utility_code_definition: + self.use_utility_code(entry.utility_code_definition) + + +def funccontext_property(func): + name = func.__name__ + attribute_of = operator.attrgetter(name) + def get(self): + return attribute_of(self.funcstate) + def set(self, value): + setattr(self.funcstate, name, value) + return property(get, set) + + +class CCodeConfig(object): + # emit_linenums boolean write #line pragmas? + # emit_code_comments boolean copy the original code into C comments? + # c_line_in_traceback boolean append the c file and line number to the traceback for exceptions? + + def __init__(self, emit_linenums=True, emit_code_comments=True, c_line_in_traceback=True): + self.emit_code_comments = emit_code_comments + self.emit_linenums = emit_linenums + self.c_line_in_traceback = c_line_in_traceback + + +class CCodeWriter(object): + """ + Utility class to output C code. + + When creating an insertion point one must care about the state that is + kept: + - formatting state (level, bol) is cloned and used in insertion points + as well + - labels, temps, exc_vars: One must construct a scope in which these can + exist by calling enter_cfunc_scope/exit_cfunc_scope (these are for + sanity checking and forward compatibility). Created insertion points + looses this scope and cannot access it. + - marker: Not copied to insertion point + - filename_table, filename_list, input_file_contents: All codewriters + coming from the same root share the same instances simultaneously. + """ + + # f file output file + # buffer StringIOTree + + # level int indentation level + # bol bool beginning of line? + # marker string comment to emit before next line + # funcstate FunctionState contains state local to a C function used for code + # generation (labels and temps state etc.) + # globalstate GlobalState contains state global for a C file (input file info, + # utility code, declared constants etc.) + # pyclass_stack list used during recursive code generation to pass information + # about the current class one is in + # code_config CCodeConfig configuration options for the C code writer + + @cython.locals(create_from='CCodeWriter') + def __init__(self, create_from=None, buffer=None, copy_formatting=False): + if buffer is None: buffer = StringIOTree() + self.buffer = buffer + self.last_pos = None + self.last_marked_pos = None + self.pyclass_stack = [] + + self.funcstate = None + self.globalstate = None + self.code_config = None + self.level = 0 + self.call_level = 0 + self.bol = 1 + + if create_from is not None: + # Use same global state + self.set_global_state(create_from.globalstate) + self.funcstate = create_from.funcstate + # Clone formatting state + if copy_formatting: + self.level = create_from.level + self.bol = create_from.bol + self.call_level = create_from.call_level + self.last_pos = create_from.last_pos + self.last_marked_pos = create_from.last_marked_pos + + def create_new(self, create_from, buffer, copy_formatting): + # polymorphic constructor -- very slightly more versatile + # than using __class__ + result = CCodeWriter(create_from, buffer, copy_formatting) + return result + + def set_global_state(self, global_state): + assert self.globalstate is None # prevent overwriting once it's set + self.globalstate = global_state + self.code_config = global_state.code_config + + def copyto(self, f): + self.buffer.copyto(f) + + def getvalue(self): + return self.buffer.getvalue() + + def write(self, s): + # also put invalid markers (lineno 0), to indicate that those lines + # have no Cython source code correspondence + cython_lineno = self.last_marked_pos[1] if self.last_marked_pos else 0 + self.buffer.markers.extend([cython_lineno] * s.count('\n')) + self.buffer.write(s) + + def insertion_point(self): + other = self.create_new(create_from=self, buffer=self.buffer.insertion_point(), copy_formatting=True) + return other + + def new_writer(self): + """ + Creates a new CCodeWriter connected to the same global state, which + can later be inserted using insert. + """ + return CCodeWriter(create_from=self) + + def insert(self, writer): + """ + Inserts the contents of another code writer (created with + the same global state) in the current location. + + It is ok to write to the inserted writer also after insertion. + """ + assert writer.globalstate is self.globalstate + self.buffer.insert(writer.buffer) + + # Properties delegated to function scope + @funccontext_property + def label_counter(self): pass + @funccontext_property + def return_label(self): pass + @funccontext_property + def error_label(self): pass + @funccontext_property + def labels_used(self): pass + @funccontext_property + def continue_label(self): pass + @funccontext_property + def break_label(self): pass + @funccontext_property + def return_from_error_cleanup_label(self): pass + @funccontext_property + def yield_labels(self): pass + + # Functions delegated to function scope + def new_label(self, name=None): return self.funcstate.new_label(name) + def new_error_label(self): return self.funcstate.new_error_label() + def new_yield_label(self, *args): return self.funcstate.new_yield_label(*args) + def get_loop_labels(self): return self.funcstate.get_loop_labels() + def set_loop_labels(self, labels): return self.funcstate.set_loop_labels(labels) + def new_loop_labels(self): return self.funcstate.new_loop_labels() + def get_all_labels(self): return self.funcstate.get_all_labels() + def set_all_labels(self, labels): return self.funcstate.set_all_labels(labels) + def all_new_labels(self): return self.funcstate.all_new_labels() + def use_label(self, lbl): return self.funcstate.use_label(lbl) + def label_used(self, lbl): return self.funcstate.label_used(lbl) + + + def enter_cfunc_scope(self, scope=None): + self.funcstate = FunctionState(self, scope=scope) + + def exit_cfunc_scope(self): + self.funcstate = None + + # constant handling + + def get_py_int(self, str_value, longness): + return self.globalstate.get_int_const(str_value, longness).cname + + def get_py_float(self, str_value, value_code): + return self.globalstate.get_float_const(str_value, value_code).cname + + def get_py_const(self, type, prefix='', cleanup_level=None, dedup_key=None): + return self.globalstate.get_py_const(type, prefix, cleanup_level, dedup_key).cname + + def get_string_const(self, text): + return self.globalstate.get_string_const(text).cname + + def get_pyunicode_ptr_const(self, text): + return self.globalstate.get_pyunicode_ptr_const(text) + + def get_py_string_const(self, text, identifier=None, + is_str=False, unicode_value=None): + return self.globalstate.get_py_string_const( + text, identifier, is_str, unicode_value).cname + + def get_argument_default_const(self, type): + return self.globalstate.get_py_const(type).cname + + def intern(self, text): + return self.get_py_string_const(text) + + def intern_identifier(self, text): + return self.get_py_string_const(text, identifier=True) + + def get_cached_constants_writer(self, target=None): + return self.globalstate.get_cached_constants_writer(target) + + # code generation + + def putln(self, code="", safe=False): + if self.last_pos and self.bol: + self.emit_marker() + if self.code_config.emit_linenums and self.last_marked_pos: + source_desc, line, _ = self.last_marked_pos + self.write('\n#line %s "%s"\n' % (line, source_desc.get_escaped_description())) + if code: + if safe: + self.put_safe(code) + else: + self.put(code) + self.write("\n") + self.bol = 1 + + def mark_pos(self, pos, trace=True): + if pos is None: + return + if self.last_marked_pos and self.last_marked_pos[:2] == pos[:2]: + return + self.last_pos = (pos, trace) + + def emit_marker(self): + pos, trace = self.last_pos + self.last_marked_pos = pos + self.last_pos = None + self.write("\n") + if self.code_config.emit_code_comments: + self.indent() + self.write("/* %s */\n" % self._build_marker(pos)) + if trace and self.funcstate and self.funcstate.can_trace and self.globalstate.directives['linetrace']: + self.indent() + self.write('__Pyx_TraceLine(%d,%d,%s)\n' % ( + pos[1], not self.funcstate.gil_owned, self.error_goto(pos))) + + def _build_marker(self, pos): + source_desc, line, col = pos + assert isinstance(source_desc, SourceDescriptor) + contents = self.globalstate.commented_file_contents(source_desc) + lines = contents[max(0, line-3):line] # line numbers start at 1 + lines[-1] += u' # <<<<<<<<<<<<<<' + lines += contents[line:line+2] + return u'"%s":%d\n%s\n' % (source_desc.get_escaped_description(), line, u'\n'.join(lines)) + + def put_safe(self, code): + # put code, but ignore {} + self.write(code) + self.bol = 0 + + def put_or_include(self, code, name): + include_dir = self.globalstate.common_utility_include_dir + if include_dir and len(code) > 1024: + include_file = "%s_%s.h" % ( + name, hashlib.md5(code.encode('utf8')).hexdigest()) + path = os.path.join(include_dir, include_file) + if not os.path.exists(path): + tmp_path = '%s.tmp%s' % (path, os.getpid()) + with closing(Utils.open_new_file(tmp_path)) as f: + f.write(code) + shutil.move(tmp_path, path) + code = '#include "%s"\n' % path + self.put(code) + + def put(self, code): + fix_indent = False + if "{" in code: + dl = code.count("{") + else: + dl = 0 + if "}" in code: + dl -= code.count("}") + if dl < 0: + self.level += dl + elif dl == 0 and code[0] == "}": + # special cases like "} else {" need a temporary dedent + fix_indent = True + self.level -= 1 + if self.bol: + self.indent() + self.write(code) + self.bol = 0 + if dl > 0: + self.level += dl + elif fix_indent: + self.level += 1 + + def putln_tempita(self, code, **context): + from ..Tempita import sub + self.putln(sub(code, **context)) + + def put_tempita(self, code, **context): + from ..Tempita import sub + self.put(sub(code, **context)) + + def increase_indent(self): + self.level += 1 + + def decrease_indent(self): + self.level -= 1 + + def begin_block(self): + self.putln("{") + self.increase_indent() + + def end_block(self): + self.decrease_indent() + self.putln("}") + + def indent(self): + self.write(" " * self.level) + + def get_py_version_hex(self, pyversion): + return "0x%02X%02X%02X%02X" % (tuple(pyversion) + (0,0,0,0))[:4] + + def put_label(self, lbl): + if lbl in self.funcstate.labels_used: + self.putln("%s:;" % lbl) + + def put_goto(self, lbl): + self.funcstate.use_label(lbl) + self.putln("goto %s;" % lbl) + + def put_var_declaration(self, entry, storage_class="", + dll_linkage=None, definition=True): + #print "Code.put_var_declaration:", entry.name, "definition =", definition ### + if entry.visibility == 'private' and not (definition or entry.defined_in_pxd): + #print "...private and not definition, skipping", entry.cname ### + return + if entry.visibility == "private" and not entry.used: + #print "...private and not used, skipping", entry.cname ### + return + if storage_class: + self.put("%s " % storage_class) + if not entry.cf_used: + self.put('CYTHON_UNUSED ') + self.put(entry.type.declaration_code( + entry.cname, dll_linkage=dll_linkage)) + if entry.init is not None: + self.put_safe(" = %s" % entry.type.literal_code(entry.init)) + elif entry.type.is_pyobject: + self.put(" = NULL") + self.putln(";") + + def put_temp_declarations(self, func_context): + for name, type, manage_ref, static in func_context.temps_allocated: + decl = type.declaration_code(name) + if type.is_pyobject: + self.putln("%s = NULL;" % decl) + elif type.is_memoryviewslice: + from . import MemoryView + self.putln("%s = %s;" % (decl, MemoryView.memslice_entry_init)) + else: + self.putln("%s%s;" % (static and "static " or "", decl)) + + if func_context.should_declare_error_indicator: + if self.funcstate.uses_error_indicator: + unused = '' + else: + unused = 'CYTHON_UNUSED ' + # Initialize these variables to silence compiler warnings + self.putln("%sint %s = 0;" % (unused, Naming.lineno_cname)) + self.putln("%sconst char *%s = NULL;" % (unused, Naming.filename_cname)) + self.putln("%sint %s = 0;" % (unused, Naming.clineno_cname)) + + def put_generated_by(self): + self.putln("/* Generated by Cython %s */" % Version.watermark) + self.putln("") + + def put_h_guard(self, guard): + self.putln("#ifndef %s" % guard) + self.putln("#define %s" % guard) + + def unlikely(self, cond): + if Options.gcc_branch_hints: + return 'unlikely(%s)' % cond + else: + return cond + + def build_function_modifiers(self, modifiers, mapper=modifier_output_mapper): + if not modifiers: + return '' + return '%s ' % ' '.join([mapper(m,m) for m in modifiers]) + + # Python objects and reference counting + + def entry_as_pyobject(self, entry): + type = entry.type + if (not entry.is_self_arg and not entry.type.is_complete() + or entry.type.is_extension_type): + return "(PyObject *)" + entry.cname + else: + return entry.cname + + def as_pyobject(self, cname, type): + from .PyrexTypes import py_object_type, typecast + return typecast(py_object_type, type, cname) + + def put_gotref(self, cname): + self.putln("__Pyx_GOTREF(%s);" % cname) + + def put_giveref(self, cname): + self.putln("__Pyx_GIVEREF(%s);" % cname) + + def put_xgiveref(self, cname): + self.putln("__Pyx_XGIVEREF(%s);" % cname) + + def put_xgotref(self, cname): + self.putln("__Pyx_XGOTREF(%s);" % cname) + + def put_incref(self, cname, type, nanny=True): + if nanny: + self.putln("__Pyx_INCREF(%s);" % self.as_pyobject(cname, type)) + else: + self.putln("Py_INCREF(%s);" % self.as_pyobject(cname, type)) + + def put_decref(self, cname, type, nanny=True): + self._put_decref(cname, type, nanny, null_check=False, clear=False) + + def put_var_gotref(self, entry): + if entry.type.is_pyobject: + self.putln("__Pyx_GOTREF(%s);" % self.entry_as_pyobject(entry)) + + def put_var_giveref(self, entry): + if entry.type.is_pyobject: + self.putln("__Pyx_GIVEREF(%s);" % self.entry_as_pyobject(entry)) + + def put_var_xgotref(self, entry): + if entry.type.is_pyobject: + self.putln("__Pyx_XGOTREF(%s);" % self.entry_as_pyobject(entry)) + + def put_var_xgiveref(self, entry): + if entry.type.is_pyobject: + self.putln("__Pyx_XGIVEREF(%s);" % self.entry_as_pyobject(entry)) + + def put_var_incref(self, entry, nanny=True): + if entry.type.is_pyobject: + if nanny: + self.putln("__Pyx_INCREF(%s);" % self.entry_as_pyobject(entry)) + else: + self.putln("Py_INCREF(%s);" % self.entry_as_pyobject(entry)) + + def put_var_xincref(self, entry): + if entry.type.is_pyobject: + self.putln("__Pyx_XINCREF(%s);" % self.entry_as_pyobject(entry)) + + def put_decref_clear(self, cname, type, nanny=True, clear_before_decref=False): + self._put_decref(cname, type, nanny, null_check=False, + clear=True, clear_before_decref=clear_before_decref) + + def put_xdecref(self, cname, type, nanny=True, have_gil=True): + self._put_decref(cname, type, nanny, null_check=True, + have_gil=have_gil, clear=False) + + def put_xdecref_clear(self, cname, type, nanny=True, clear_before_decref=False): + self._put_decref(cname, type, nanny, null_check=True, + clear=True, clear_before_decref=clear_before_decref) + + def _put_decref(self, cname, type, nanny=True, null_check=False, + have_gil=True, clear=False, clear_before_decref=False): + if type.is_memoryviewslice: + self.put_xdecref_memoryviewslice(cname, have_gil=have_gil) + return + + prefix = '__Pyx' if nanny else 'Py' + X = 'X' if null_check else '' + + if clear: + if clear_before_decref: + if not nanny: + X = '' # CPython doesn't have a Py_XCLEAR() + self.putln("%s_%sCLEAR(%s);" % (prefix, X, cname)) + else: + self.putln("%s_%sDECREF(%s); %s = 0;" % ( + prefix, X, self.as_pyobject(cname, type), cname)) + else: + self.putln("%s_%sDECREF(%s);" % ( + prefix, X, self.as_pyobject(cname, type))) + + def put_decref_set(self, cname, rhs_cname): + self.putln("__Pyx_DECREF_SET(%s, %s);" % (cname, rhs_cname)) + + def put_xdecref_set(self, cname, rhs_cname): + self.putln("__Pyx_XDECREF_SET(%s, %s);" % (cname, rhs_cname)) + + def put_var_decref(self, entry): + if entry.type.is_pyobject: + self.putln("__Pyx_XDECREF(%s);" % self.entry_as_pyobject(entry)) + + def put_var_xdecref(self, entry, nanny=True): + if entry.type.is_pyobject: + if nanny: + self.putln("__Pyx_XDECREF(%s);" % self.entry_as_pyobject(entry)) + else: + self.putln("Py_XDECREF(%s);" % self.entry_as_pyobject(entry)) + + def put_var_decref_clear(self, entry): + self._put_var_decref_clear(entry, null_check=False) + + def put_var_xdecref_clear(self, entry): + self._put_var_decref_clear(entry, null_check=True) + + def _put_var_decref_clear(self, entry, null_check): + if entry.type.is_pyobject: + if entry.in_closure: + # reset before DECREF to make sure closure state is + # consistent during call to DECREF() + self.putln("__Pyx_%sCLEAR(%s);" % ( + null_check and 'X' or '', + entry.cname)) + else: + self.putln("__Pyx_%sDECREF(%s); %s = 0;" % ( + null_check and 'X' or '', + self.entry_as_pyobject(entry), + entry.cname)) + + def put_var_decrefs(self, entries, used_only = 0): + for entry in entries: + if not used_only or entry.used: + if entry.xdecref_cleanup: + self.put_var_xdecref(entry) + else: + self.put_var_decref(entry) + + def put_var_xdecrefs(self, entries): + for entry in entries: + self.put_var_xdecref(entry) + + def put_var_xdecrefs_clear(self, entries): + for entry in entries: + self.put_var_xdecref_clear(entry) + + def put_incref_memoryviewslice(self, slice_cname, have_gil=False): + from . import MemoryView + self.globalstate.use_utility_code(MemoryView.memviewslice_init_code) + self.putln("__PYX_INC_MEMVIEW(&%s, %d);" % (slice_cname, int(have_gil))) + + def put_xdecref_memoryviewslice(self, slice_cname, have_gil=False): + from . import MemoryView + self.globalstate.use_utility_code(MemoryView.memviewslice_init_code) + self.putln("__PYX_XDEC_MEMVIEW(&%s, %d);" % (slice_cname, int(have_gil))) + + def put_xgiveref_memoryviewslice(self, slice_cname): + self.put_xgiveref("%s.memview" % slice_cname) + + def put_init_to_py_none(self, cname, type, nanny=True): + from .PyrexTypes import py_object_type, typecast + py_none = typecast(type, py_object_type, "Py_None") + if nanny: + self.putln("%s = %s; __Pyx_INCREF(Py_None);" % (cname, py_none)) + else: + self.putln("%s = %s; Py_INCREF(Py_None);" % (cname, py_none)) + + def put_init_var_to_py_none(self, entry, template = "%s", nanny=True): + code = template % entry.cname + #if entry.type.is_extension_type: + # code = "((PyObject*)%s)" % code + self.put_init_to_py_none(code, entry.type, nanny) + if entry.in_closure: + self.put_giveref('Py_None') + + def put_pymethoddef(self, entry, term, allow_skip=True, wrapper_code_writer=None): + if entry.is_special or entry.name == '__getattribute__': + if entry.name not in special_py_methods: + if entry.name == '__getattr__' and not self.globalstate.directives['fast_getattr']: + pass + # Python's typeobject.c will automatically fill in our slot + # in add_operators() (called by PyType_Ready) with a value + # that's better than ours. + elif allow_skip: + return + + method_flags = entry.signature.method_flags() + if not method_flags: + return + from . import TypeSlots + if entry.is_special or TypeSlots.is_reverse_number_slot(entry.name): + method_flags += [TypeSlots.method_coexist] + func_ptr = wrapper_code_writer.put_pymethoddef_wrapper(entry) if wrapper_code_writer else entry.func_cname + # Add required casts, but try not to shadow real warnings. + cast = '__Pyx_PyCFunctionFast' if 'METH_FASTCALL' in method_flags else 'PyCFunction' + if 'METH_KEYWORDS' in method_flags: + cast += 'WithKeywords' + if cast != 'PyCFunction': + func_ptr = '(void*)(%s)%s' % (cast, func_ptr) + self.putln( + '{"%s", (PyCFunction)%s, %s, %s}%s' % ( + entry.name, + func_ptr, + "|".join(method_flags), + entry.doc_cname if entry.doc else '0', + term)) + + def put_pymethoddef_wrapper(self, entry): + func_cname = entry.func_cname + if entry.is_special: + method_flags = entry.signature.method_flags() + if method_flags and 'METH_NOARGS' in method_flags: + # Special NOARGS methods really take no arguments besides 'self', but PyCFunction expects one. + func_cname = Naming.method_wrapper_prefix + func_cname + self.putln("static PyObject *%s(PyObject *self, CYTHON_UNUSED PyObject *arg) {return %s(self);}" % ( + func_cname, entry.func_cname)) + return func_cname + + # GIL methods + + def put_ensure_gil(self, declare_gilstate=True, variable=None): + """ + Acquire the GIL. The generated code is safe even when no PyThreadState + has been allocated for this thread (for threads not initialized by + using the Python API). Additionally, the code generated by this method + may be called recursively. + """ + self.globalstate.use_utility_code( + UtilityCode.load_cached("ForceInitThreads", "ModuleSetupCode.c")) + if self.globalstate.directives['fast_gil']: + self.globalstate.use_utility_code(UtilityCode.load_cached("FastGil", "ModuleSetupCode.c")) + else: + self.globalstate.use_utility_code(UtilityCode.load_cached("NoFastGil", "ModuleSetupCode.c")) + self.putln("#ifdef WITH_THREAD") + if not variable: + variable = '__pyx_gilstate_save' + if declare_gilstate: + self.put("PyGILState_STATE ") + self.putln("%s = __Pyx_PyGILState_Ensure();" % variable) + self.putln("#endif") + + def put_release_ensured_gil(self, variable=None): + """ + Releases the GIL, corresponds to `put_ensure_gil`. + """ + if self.globalstate.directives['fast_gil']: + self.globalstate.use_utility_code(UtilityCode.load_cached("FastGil", "ModuleSetupCode.c")) + else: + self.globalstate.use_utility_code(UtilityCode.load_cached("NoFastGil", "ModuleSetupCode.c")) + if not variable: + variable = '__pyx_gilstate_save' + self.putln("#ifdef WITH_THREAD") + self.putln("__Pyx_PyGILState_Release(%s);" % variable) + self.putln("#endif") + + def put_acquire_gil(self, variable=None): + """ + Acquire the GIL. The thread's thread state must have been initialized + by a previous `put_release_gil` + """ + if self.globalstate.directives['fast_gil']: + self.globalstate.use_utility_code(UtilityCode.load_cached("FastGil", "ModuleSetupCode.c")) + else: + self.globalstate.use_utility_code(UtilityCode.load_cached("NoFastGil", "ModuleSetupCode.c")) + self.putln("#ifdef WITH_THREAD") + self.putln("__Pyx_FastGIL_Forget();") + if variable: + self.putln('_save = %s;' % variable) + self.putln("Py_BLOCK_THREADS") + self.putln("#endif") + + def put_release_gil(self, variable=None): + "Release the GIL, corresponds to `put_acquire_gil`." + if self.globalstate.directives['fast_gil']: + self.globalstate.use_utility_code(UtilityCode.load_cached("FastGil", "ModuleSetupCode.c")) + else: + self.globalstate.use_utility_code(UtilityCode.load_cached("NoFastGil", "ModuleSetupCode.c")) + self.putln("#ifdef WITH_THREAD") + self.putln("PyThreadState *_save;") + self.putln("Py_UNBLOCK_THREADS") + if variable: + self.putln('%s = _save;' % variable) + self.putln("__Pyx_FastGIL_Remember();") + self.putln("#endif") + + def declare_gilstate(self): + self.putln("#ifdef WITH_THREAD") + self.putln("PyGILState_STATE __pyx_gilstate_save;") + self.putln("#endif") + + # error handling + + def put_error_if_neg(self, pos, value): + # TODO this path is almost _never_ taken, yet this macro makes is slower! + # return self.putln("if (unlikely(%s < 0)) %s" % (value, self.error_goto(pos))) + return self.putln("if (%s < 0) %s" % (value, self.error_goto(pos))) + + def put_error_if_unbound(self, pos, entry, in_nogil_context=False): + from . import ExprNodes + if entry.from_closure: + func = '__Pyx_RaiseClosureNameError' + self.globalstate.use_utility_code( + ExprNodes.raise_closure_name_error_utility_code) + elif entry.type.is_memoryviewslice and in_nogil_context: + func = '__Pyx_RaiseUnboundMemoryviewSliceNogil' + self.globalstate.use_utility_code( + ExprNodes.raise_unbound_memoryview_utility_code_nogil) + else: + func = '__Pyx_RaiseUnboundLocalError' + self.globalstate.use_utility_code( + ExprNodes.raise_unbound_local_error_utility_code) + + self.putln('if (unlikely(!%s)) { %s("%s"); %s }' % ( + entry.type.check_for_null_code(entry.cname), + func, + entry.name, + self.error_goto(pos))) + + def set_error_info(self, pos, used=False): + self.funcstate.should_declare_error_indicator = True + if used: + self.funcstate.uses_error_indicator = True + return "__PYX_MARK_ERR_POS(%s, %s)" % ( + self.lookup_filename(pos[0]), + pos[1]) + + def error_goto(self, pos, used=True): + lbl = self.funcstate.error_label + self.funcstate.use_label(lbl) + if pos is None: + return 'goto %s;' % lbl + self.funcstate.should_declare_error_indicator = True + if used: + self.funcstate.uses_error_indicator = True + return "__PYX_ERR(%s, %s, %s)" % ( + self.lookup_filename(pos[0]), + pos[1], + lbl) + + def error_goto_if(self, cond, pos): + return "if (%s) %s" % (self.unlikely(cond), self.error_goto(pos)) + + def error_goto_if_null(self, cname, pos): + return self.error_goto_if("!%s" % cname, pos) + + def error_goto_if_neg(self, cname, pos): + return self.error_goto_if("%s < 0" % cname, pos) + + def error_goto_if_PyErr(self, pos): + return self.error_goto_if("PyErr_Occurred()", pos) + + def lookup_filename(self, filename): + return self.globalstate.lookup_filename(filename) + + def put_declare_refcount_context(self): + self.putln('__Pyx_RefNannyDeclarations') + + def put_setup_refcount_context(self, name, acquire_gil=False): + if acquire_gil: + self.globalstate.use_utility_code( + UtilityCode.load_cached("ForceInitThreads", "ModuleSetupCode.c")) + self.putln('__Pyx_RefNannySetupContext("%s", %d);' % (name, acquire_gil and 1 or 0)) + + def put_finish_refcount_context(self): + self.putln("__Pyx_RefNannyFinishContext();") + + def put_add_traceback(self, qualified_name, include_cline=True): + """ + Build a Python traceback for propagating exceptions. + + qualified_name should be the qualified name of the function. + """ + format_tuple = ( + qualified_name, + Naming.clineno_cname if include_cline else 0, + Naming.lineno_cname, + Naming.filename_cname, + ) + self.funcstate.uses_error_indicator = True + self.putln('__Pyx_AddTraceback("%s", %s, %s, %s);' % format_tuple) + + def put_unraisable(self, qualified_name, nogil=False): + """ + Generate code to print a Python warning for an unraisable exception. + + qualified_name should be the qualified name of the function. + """ + format_tuple = ( + qualified_name, + Naming.clineno_cname, + Naming.lineno_cname, + Naming.filename_cname, + self.globalstate.directives['unraisable_tracebacks'], + nogil, + ) + self.funcstate.uses_error_indicator = True + self.putln('__Pyx_WriteUnraisable("%s", %s, %s, %s, %d, %d);' % format_tuple) + self.globalstate.use_utility_code( + UtilityCode.load_cached("WriteUnraisableException", "Exceptions.c")) + + def put_trace_declarations(self): + self.putln('__Pyx_TraceDeclarations') + + def put_trace_frame_init(self, codeobj=None): + if codeobj: + self.putln('__Pyx_TraceFrameInit(%s)' % codeobj) + + def put_trace_call(self, name, pos, nogil=False): + self.putln('__Pyx_TraceCall("%s", %s[%s], %s, %d, %s);' % ( + name, Naming.filetable_cname, self.lookup_filename(pos[0]), pos[1], nogil, self.error_goto(pos))) + + def put_trace_exception(self): + self.putln("__Pyx_TraceException();") + + def put_trace_return(self, retvalue_cname, nogil=False): + self.putln("__Pyx_TraceReturn(%s, %d);" % (retvalue_cname, nogil)) + + def putln_openmp(self, string): + self.putln("#ifdef _OPENMP") + self.putln(string) + self.putln("#endif /* _OPENMP */") + + def undef_builtin_expect(self, cond): + """ + Redefine the macros likely() and unlikely to no-ops, depending on + condition 'cond' + """ + self.putln("#if %s" % cond) + self.putln(" #undef likely") + self.putln(" #undef unlikely") + self.putln(" #define likely(x) (x)") + self.putln(" #define unlikely(x) (x)") + self.putln("#endif") + + def redef_builtin_expect(self, cond): + self.putln("#if %s" % cond) + self.putln(" #undef likely") + self.putln(" #undef unlikely") + self.putln(" #define likely(x) __builtin_expect(!!(x), 1)") + self.putln(" #define unlikely(x) __builtin_expect(!!(x), 0)") + self.putln("#endif") + + +class PyrexCodeWriter(object): + # f file output file + # level int indentation level + + def __init__(self, outfile_name): + self.f = Utils.open_new_file(outfile_name) + self.level = 0 + + def putln(self, code): + self.f.write("%s%s\n" % (" " * self.level, code)) + + def indent(self): + self.level += 1 + + def dedent(self): + self.level -= 1 + +class PyxCodeWriter(object): + """ + Can be used for writing out some Cython code. To use the indenter + functionality, the Cython.Compiler.Importer module will have to be used + to load the code to support python 2.4 + """ + + def __init__(self, buffer=None, indent_level=0, context=None, encoding='ascii'): + self.buffer = buffer or StringIOTree() + self.level = indent_level + self.context = context + self.encoding = encoding + + def indent(self, levels=1): + self.level += levels + return True + + def dedent(self, levels=1): + self.level -= levels + + def indenter(self, line): + """ + Instead of + + with pyx_code.indenter("for i in range(10):"): + pyx_code.putln("print i") + + write + + if pyx_code.indenter("for i in range(10);"): + pyx_code.putln("print i") + pyx_code.dedent() + """ + self.putln(line) + self.indent() + return True + + def getvalue(self): + result = self.buffer.getvalue() + if isinstance(result, bytes): + result = result.decode(self.encoding) + return result + + def putln(self, line, context=None): + context = context or self.context + if context: + line = sub_tempita(line, context) + self._putln(line) + + def _putln(self, line): + self.buffer.write("%s%s\n" % (self.level * " ", line)) + + def put_chunk(self, chunk, context=None): + context = context or self.context + if context: + chunk = sub_tempita(chunk, context) + + chunk = textwrap.dedent(chunk) + for line in chunk.splitlines(): + self._putln(line) + + def insertion_point(self): + return PyxCodeWriter(self.buffer.insertion_point(), self.level, + self.context) + + def named_insertion_point(self, name): + setattr(self, name, self.insertion_point()) + + +class ClosureTempAllocator(object): + def __init__(self, klass): + self.klass = klass + self.temps_allocated = {} + self.temps_free = {} + self.temps_count = 0 + + def reset(self): + for type, cnames in self.temps_allocated.items(): + self.temps_free[type] = list(cnames) + + def allocate_temp(self, type): + if type not in self.temps_allocated: + self.temps_allocated[type] = [] + self.temps_free[type] = [] + elif self.temps_free[type]: + return self.temps_free[type].pop(0) + cname = '%s%d' % (Naming.codewriter_temp_prefix, self.temps_count) + self.klass.declare_var(pos=None, name=cname, cname=cname, type=type, is_cdef=True) + self.temps_allocated[type].append(cname) + self.temps_count += 1 + return cname diff --git a/contrib/tools/cython/Cython/Compiler/CodeGeneration.py b/contrib/tools/cython/Cython/Compiler/CodeGeneration.py new file mode 100644 index 00000000000..e64049c7f5d --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/CodeGeneration.py @@ -0,0 +1,35 @@ +from __future__ import absolute_import + +from .Visitor import VisitorTransform +from .Nodes import StatListNode + + +class ExtractPxdCode(VisitorTransform): + """ + Finds nodes in a pxd file that should generate code, and + returns them in a StatListNode. + + The result is a tuple (StatListNode, ModuleScope), i.e. + everything that is needed from the pxd after it is processed. + + A purer approach would be to separately compile the pxd code, + but the result would have to be slightly more sophisticated + than pure strings (functions + wanted interned strings + + wanted utility code + wanted cached objects) so for now this + approach is taken. + """ + + def __call__(self, root): + self.funcs = [] + self.visitchildren(root) + return (StatListNode(root.pos, stats=self.funcs), root.scope) + + def visit_FuncDefNode(self, node): + self.funcs.append(node) + # Do not visit children, nested funcdefnodes will + # also be moved by this action... + return node + + def visit_Node(self, node): + self.visitchildren(node) + return node diff --git a/contrib/tools/cython/Cython/Compiler/CythonScope.py b/contrib/tools/cython/Cython/Compiler/CythonScope.py new file mode 100644 index 00000000000..1c25d1a6b4c --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/CythonScope.py @@ -0,0 +1,164 @@ +from __future__ import absolute_import + +from .Symtab import ModuleScope +from .PyrexTypes import * +from .UtilityCode import CythonUtilityCode +from .Errors import error +from .Scanning import StringSourceDescriptor +from . import MemoryView + + +class CythonScope(ModuleScope): + is_cython_builtin = 1 + _cythonscope_initialized = False + + def __init__(self, context): + ModuleScope.__init__(self, u'cython', None, None) + self.pxd_file_loaded = True + self.populate_cython_scope() + # The Main.Context object + self.context = context + + for fused_type in (cy_integral_type, cy_floating_type, cy_numeric_type): + entry = self.declare_typedef(fused_type.name, + fused_type, + None, + cname='<error>') + entry.in_cinclude = True + + def is_cpp(self): + # Allow C++ utility code in C++ contexts. + return self.context.cpp + + def lookup_type(self, name): + # This function should go away when types are all first-level objects. + type = parse_basic_type(name) + if type: + return type + + return super(CythonScope, self).lookup_type(name) + + def lookup(self, name): + entry = super(CythonScope, self).lookup(name) + + if entry is None and not self._cythonscope_initialized: + self.load_cythonscope() + entry = super(CythonScope, self).lookup(name) + + return entry + + def find_module(self, module_name, pos): + error("cython.%s is not available" % module_name, pos) + + def find_submodule(self, module_name): + entry = self.entries.get(module_name, None) + if not entry: + self.load_cythonscope() + entry = self.entries.get(module_name, None) + + if entry and entry.as_module: + return entry.as_module + else: + # TODO: fix find_submodule control flow so that we're not + # expected to create a submodule here (to protect CythonScope's + # possible immutability). Hack ourselves out of the situation + # for now. + raise error((StringSourceDescriptor(u"cython", u""), 0, 0), + "cython.%s is not available" % module_name) + + def lookup_qualified_name(self, qname): + # ExprNode.as_cython_attribute generates qnames and we untangle it here... + name_path = qname.split(u'.') + scope = self + while len(name_path) > 1: + scope = scope.lookup_here(name_path[0]) + if scope: + scope = scope.as_module + del name_path[0] + if scope is None: + return None + else: + return scope.lookup_here(name_path[0]) + + def populate_cython_scope(self): + # These are used to optimize isinstance in FinalOptimizePhase + type_object = self.declare_typedef( + 'PyTypeObject', + base_type = c_void_type, + pos = None, + cname = 'PyTypeObject') + type_object.is_void = True + type_object_type = type_object.type + + self.declare_cfunction( + 'PyObject_TypeCheck', + CFuncType(c_bint_type, [CFuncTypeArg("o", py_object_type, None), + CFuncTypeArg("t", c_ptr_type(type_object_type), None)]), + pos = None, + defining = 1, + cname = 'PyObject_TypeCheck') + + def load_cythonscope(self): + """ + Creates some entries for testing purposes and entries for + cython.array() and for cython.view.*. + """ + if self._cythonscope_initialized: + return + + self._cythonscope_initialized = True + cython_testscope_utility_code.declare_in_scope( + self, cython_scope=self) + cython_test_extclass_utility_code.declare_in_scope( + self, cython_scope=self) + + # + # The view sub-scope + # + self.viewscope = viewscope = ModuleScope(u'view', self, None) + self.declare_module('view', viewscope, None).as_module = viewscope + viewscope.is_cython_builtin = True + viewscope.pxd_file_loaded = True + + cythonview_testscope_utility_code.declare_in_scope( + viewscope, cython_scope=self) + + view_utility_scope = MemoryView.view_utility_code.declare_in_scope( + self.viewscope, cython_scope=self, + whitelist=MemoryView.view_utility_whitelist) + + # self.entries["array"] = view_utility_scope.entries.pop("array") + + +def create_cython_scope(context): + # One could in fact probably make it a singleton, + # but not sure yet whether any code mutates it (which would kill reusing + # it across different contexts) + return CythonScope(context) + +# Load test utilities for the cython scope + +def load_testscope_utility(cy_util_name, **kwargs): + return CythonUtilityCode.load(cy_util_name, "TestCythonScope.pyx", **kwargs) + + +undecorated_methods_protos = UtilityCode(proto=u""" + /* These methods are undecorated and have therefore no prototype */ + static PyObject *__pyx_TestClass_cdef_method( + struct __pyx_TestClass_obj *self, int value); + static PyObject *__pyx_TestClass_cpdef_method( + struct __pyx_TestClass_obj *self, int value, int skip_dispatch); + static PyObject *__pyx_TestClass_def_method( + PyObject *self, PyObject *value); +""") + +cython_testscope_utility_code = load_testscope_utility("TestScope") + +test_cython_utility_dep = load_testscope_utility("TestDep") + +cython_test_extclass_utility_code = \ + load_testscope_utility("TestClass", name="TestClass", + requires=[undecorated_methods_protos, + test_cython_utility_dep]) + +cythonview_testscope_utility_code = load_testscope_utility("View.TestScope") diff --git a/contrib/tools/cython/Cython/Compiler/DebugFlags.py b/contrib/tools/cython/Cython/Compiler/DebugFlags.py new file mode 100644 index 00000000000..e830ab1849c --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/DebugFlags.py @@ -0,0 +1,21 @@ +# Can be enabled at the command line with --debug-xxx. + +debug_disposal_code = 0 +debug_temp_alloc = 0 +debug_coercion = 0 + +# Write comments into the C code that show where temporary variables +# are allocated and released. +debug_temp_code_comments = 0 + +# Write a call trace of the code generation phase into the C code. +debug_trace_code_generation = 0 + +# Do not replace exceptions with user-friendly error messages. +debug_no_exception_intercept = 0 + +# Print a message each time a new stage in the pipeline is entered. +debug_verbose_pipeline = 0 + +# Raise an exception when an error is encountered. +debug_exception_on_error = 0 diff --git a/contrib/tools/cython/Cython/Compiler/Errors.py b/contrib/tools/cython/Cython/Compiler/Errors.py new file mode 100644 index 00000000000..9761b52c32f --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Errors.py @@ -0,0 +1,265 @@ +# +# Errors +# + +from __future__ import absolute_import + +try: + from __builtin__ import basestring as any_string_type +except ImportError: + any_string_type = (bytes, str) + +import sys +from contextlib import contextmanager + +from ..Utils import open_new_file +from . import DebugFlags +from . import Options + + +class PyrexError(Exception): + pass + + +class PyrexWarning(Exception): + pass + + +def context(position): + source = position[0] + assert not (isinstance(source, any_string_type)), ( + "Please replace filename strings with Scanning.FileSourceDescriptor instances %r" % source) + try: + F = source.get_lines() + except UnicodeDecodeError: + # file has an encoding problem + s = u"[unprintable code]\n" + else: + s = u''.join(F[max(0, position[1]-6):position[1]]) + s = u'...\n%s%s^\n' % (s, u' '*(position[2]-1)) + s = u'%s\n%s%s\n' % (u'-'*60, s, u'-'*60) + return s + +def format_position(position): + if position: + return u"%s:%d:%d: " % (position[0].get_error_description(), + position[1], position[2]) + return u'' + +def format_error(message, position): + if position: + pos_str = format_position(position) + cont = context(position) + message = u'\nError compiling Cython file:\n%s\n%s%s' % (cont, pos_str, message or u'') + return message + +class CompileError(PyrexError): + + def __init__(self, position = None, message = u""): + self.position = position + self.message_only = message + self.formatted_message = format_error(message, position) + self.reported = False + # Deprecated and withdrawn in 2.6: + # self.message = message + Exception.__init__(self, self.formatted_message) + # Python Exception subclass pickling is broken, + # see http://bugs.python.org/issue1692335 + self.args = (position, message) + + def __str__(self): + return self.formatted_message + +class CompileWarning(PyrexWarning): + + def __init__(self, position = None, message = ""): + self.position = position + # Deprecated and withdrawn in 2.6: + # self.message = message + Exception.__init__(self, format_position(position) + message) + +class InternalError(Exception): + # If this is ever raised, there is a bug in the compiler. + + def __init__(self, message): + self.message_only = message + Exception.__init__(self, u"Internal compiler error: %s" + % message) + +class AbortError(Exception): + # Throw this to stop the compilation immediately. + + def __init__(self, message): + self.message_only = message + Exception.__init__(self, u"Abort error: %s" % message) + +class CompilerCrash(CompileError): + # raised when an unexpected exception occurs in a transform + def __init__(self, pos, context, message, cause, stacktrace=None): + if message: + message = u'\n' + message + else: + message = u'\n' + self.message_only = message + if context: + message = u"Compiler crash in %s%s" % (context, message) + if stacktrace: + import traceback + message += ( + u'\n\nCompiler crash traceback from this point on:\n' + + u''.join(traceback.format_tb(stacktrace))) + if cause: + if not stacktrace: + message += u'\n' + message += u'%s: %s' % (cause.__class__.__name__, cause) + CompileError.__init__(self, pos, message) + # Python Exception subclass pickling is broken, + # see http://bugs.python.org/issue1692335 + self.args = (pos, context, message, cause, stacktrace) + +class NoElementTreeInstalledException(PyrexError): + """raised when the user enabled options.gdb_debug but no ElementTree + implementation was found + """ + +listing_file = None +num_errors = 0 +echo_file = None + +def open_listing_file(path, echo_to_stderr = 1): + # Begin a new error listing. If path is None, no file + # is opened, the error counter is just reset. + global listing_file, num_errors, echo_file + if path is not None: + listing_file = open_new_file(path) + else: + listing_file = None + if echo_to_stderr: + echo_file = sys.stderr + else: + echo_file = None + num_errors = 0 + +def close_listing_file(): + global listing_file + if listing_file: + listing_file.close() + listing_file = None + +def report_error(err, use_stack=True): + if error_stack and use_stack: + error_stack[-1].append(err) + else: + global num_errors + # See Main.py for why dual reporting occurs. Quick fix for now. + if err.reported: return + err.reported = True + try: line = u"%s\n" % err + except UnicodeEncodeError: + # Python <= 2.5 does this for non-ASCII Unicode exceptions + line = format_error(getattr(err, 'message_only', "[unprintable exception message]"), + getattr(err, 'position', None)) + u'\n' + if listing_file: + try: listing_file.write(line) + except UnicodeEncodeError: + listing_file.write(line.encode('ASCII', 'replace')) + if echo_file: + try: echo_file.write(line) + except UnicodeEncodeError: + echo_file.write(line.encode('ASCII', 'replace')) + num_errors += 1 + if Options.fast_fail: + raise AbortError("fatal errors") + + +def error(position, message): + #print("Errors.error:", repr(position), repr(message)) ### + if position is None: + raise InternalError(message) + err = CompileError(position, message) + if DebugFlags.debug_exception_on_error: raise Exception(err) # debug + report_error(err) + return err + + +LEVEL = 1 # warn about all errors level 1 or higher + + +def message(position, message, level=1): + if level < LEVEL: + return + warn = CompileWarning(position, message) + line = "note: %s\n" % warn + if listing_file: + listing_file.write(line) + if echo_file: + echo_file.write(line) + return warn + + +def warning(position, message, level=0): + if level < LEVEL: + return + if Options.warning_errors and position: + return error(position, message) + warn = CompileWarning(position, message) + line = "warning: %s\n" % warn + if listing_file: + listing_file.write(line) + if echo_file: + echo_file.write(line) + return warn + + +_warn_once_seen = {} +def warn_once(position, message, level=0): + if level < LEVEL or message in _warn_once_seen: + return + warn = CompileWarning(position, message) + line = "warning: %s\n" % warn + if listing_file: + listing_file.write(line) + if echo_file: + echo_file.write(line) + _warn_once_seen[message] = True + return warn + + +# These functions can be used to momentarily suppress errors. + +error_stack = [] + + +def hold_errors(): + error_stack.append([]) + + +def release_errors(ignore=False): + held_errors = error_stack.pop() + if not ignore: + for err in held_errors: + report_error(err) + + +def held_errors(): + return error_stack[-1] + + +# same as context manager: + +@contextmanager +def local_errors(ignore=False): + errors = [] + error_stack.append(errors) + try: + yield errors + finally: + release_errors(ignore=ignore) + + +# this module needs a redesign to support parallel cythonisation, but +# for now, the following works at least in sequential compiler runs + +def reset(): + _warn_once_seen.clear() + del error_stack[:] diff --git a/contrib/tools/cython/Cython/Compiler/ExprNodes.py b/contrib/tools/cython/Cython/Compiler/ExprNodes.py new file mode 100644 index 00000000000..7b065fcaba3 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/ExprNodes.py @@ -0,0 +1,13719 @@ +# +# Parse tree nodes for expressions +# + +from __future__ import absolute_import + +import cython +cython.declare(error=object, warning=object, warn_once=object, InternalError=object, + CompileError=object, UtilityCode=object, TempitaUtilityCode=object, + StringEncoding=object, operator=object, local_errors=object, report_error=object, + Naming=object, Nodes=object, PyrexTypes=object, py_object_type=object, + list_type=object, tuple_type=object, set_type=object, dict_type=object, + unicode_type=object, str_type=object, bytes_type=object, type_type=object, + Builtin=object, Symtab=object, Utils=object, find_coercion_error=object, + debug_disposal_code=object, debug_temp_alloc=object, debug_coercion=object, + bytearray_type=object, slice_type=object, _py_int_types=object, + IS_PYTHON3=cython.bint) + +import re +import sys +import copy +import os.path +import operator + +from .Errors import ( + error, warning, InternalError, CompileError, report_error, local_errors) +from .Code import UtilityCode, TempitaUtilityCode +from . import StringEncoding +from . import Naming +from . import Nodes +from .Nodes import Node, utility_code_for_imports, analyse_type_annotation +from . import PyrexTypes +from .PyrexTypes import py_object_type, c_long_type, typecast, error_type, \ + unspecified_type +from . import TypeSlots +from .Builtin import list_type, tuple_type, set_type, dict_type, type_type, \ + unicode_type, str_type, bytes_type, bytearray_type, basestring_type, slice_type +from . import Builtin +from . import Symtab +from .. import Utils +from .Annotate import AnnotationItem +from . import Future +from ..Debugging import print_call_chain +from .DebugFlags import debug_disposal_code, debug_temp_alloc, \ + debug_coercion +from .Pythran import (to_pythran, is_pythran_supported_type, is_pythran_supported_operation_type, + is_pythran_expr, pythran_func_type, pythran_binop_type, pythran_unaryop_type, has_np_pythran, + pythran_indexing_code, pythran_indexing_type, is_pythran_supported_node_or_none, pythran_type, + pythran_is_numpy_func_supported, pythran_get_func_include_file, pythran_functor) +from .PyrexTypes import PythranExpr + +try: + from __builtin__ import basestring +except ImportError: + # Python 3 + basestring = str + any_string_type = (bytes, str) +else: + # Python 2 + any_string_type = (bytes, unicode) + + +if sys.version_info[0] >= 3: + IS_PYTHON3 = True + _py_int_types = int +else: + IS_PYTHON3 = False + _py_int_types = (int, long) + + +class NotConstant(object): + _obj = None + + def __new__(cls): + if NotConstant._obj is None: + NotConstant._obj = super(NotConstant, cls).__new__(cls) + + return NotConstant._obj + + def __repr__(self): + return "<NOT CONSTANT>" + +not_a_constant = NotConstant() +constant_value_not_set = object() + +# error messages when coercing from key[0] to key[1] +coercion_error_dict = { + # string related errors + (unicode_type, str_type): ("Cannot convert Unicode string to 'str' implicitly." + " This is not portable and requires explicit encoding."), + (unicode_type, bytes_type): "Cannot convert Unicode string to 'bytes' implicitly, encoding required.", + (unicode_type, PyrexTypes.c_char_ptr_type): "Unicode objects only support coercion to Py_UNICODE*.", + (unicode_type, PyrexTypes.c_const_char_ptr_type): "Unicode objects only support coercion to Py_UNICODE*.", + (unicode_type, PyrexTypes.c_uchar_ptr_type): "Unicode objects only support coercion to Py_UNICODE*.", + (unicode_type, PyrexTypes.c_const_uchar_ptr_type): "Unicode objects only support coercion to Py_UNICODE*.", + (bytes_type, unicode_type): "Cannot convert 'bytes' object to unicode implicitly, decoding required", + (bytes_type, str_type): "Cannot convert 'bytes' object to str implicitly. This is not portable to Py3.", + (bytes_type, basestring_type): ("Cannot convert 'bytes' object to basestring implicitly." + " This is not portable to Py3."), + (bytes_type, PyrexTypes.c_py_unicode_ptr_type): "Cannot convert 'bytes' object to Py_UNICODE*, use 'unicode'.", + (bytes_type, PyrexTypes.c_const_py_unicode_ptr_type): ( + "Cannot convert 'bytes' object to Py_UNICODE*, use 'unicode'."), + (basestring_type, bytes_type): "Cannot convert 'basestring' object to bytes implicitly. This is not portable.", + (str_type, unicode_type): ("str objects do not support coercion to unicode," + " use a unicode string literal instead (u'')"), + (str_type, bytes_type): "Cannot convert 'str' to 'bytes' implicitly. This is not portable.", + (str_type, PyrexTypes.c_char_ptr_type): "'str' objects do not support coercion to C types (use 'bytes'?).", + (str_type, PyrexTypes.c_const_char_ptr_type): "'str' objects do not support coercion to C types (use 'bytes'?).", + (str_type, PyrexTypes.c_uchar_ptr_type): "'str' objects do not support coercion to C types (use 'bytes'?).", + (str_type, PyrexTypes.c_const_uchar_ptr_type): "'str' objects do not support coercion to C types (use 'bytes'?).", + (str_type, PyrexTypes.c_py_unicode_ptr_type): "'str' objects do not support coercion to C types (use 'unicode'?).", + (str_type, PyrexTypes.c_const_py_unicode_ptr_type): ( + "'str' objects do not support coercion to C types (use 'unicode'?)."), + (PyrexTypes.c_char_ptr_type, unicode_type): "Cannot convert 'char*' to unicode implicitly, decoding required", + (PyrexTypes.c_const_char_ptr_type, unicode_type): ( + "Cannot convert 'char*' to unicode implicitly, decoding required"), + (PyrexTypes.c_uchar_ptr_type, unicode_type): "Cannot convert 'char*' to unicode implicitly, decoding required", + (PyrexTypes.c_const_uchar_ptr_type, unicode_type): ( + "Cannot convert 'char*' to unicode implicitly, decoding required"), +} + +def find_coercion_error(type_tuple, default, env): + err = coercion_error_dict.get(type_tuple) + if err is None: + return default + elif (env.directives['c_string_encoding'] and + any(t in type_tuple for t in (PyrexTypes.c_char_ptr_type, PyrexTypes.c_uchar_ptr_type, + PyrexTypes.c_const_char_ptr_type, PyrexTypes.c_const_uchar_ptr_type))): + if type_tuple[1].is_pyobject: + return default + elif env.directives['c_string_encoding'] in ('ascii', 'default'): + return default + else: + return "'%s' objects do not support coercion to C types with non-ascii or non-default c_string_encoding" % type_tuple[0].name + else: + return err + + +def default_str_type(env): + return { + 'bytes': bytes_type, + 'bytearray': bytearray_type, + 'str': str_type, + 'unicode': unicode_type + }.get(env.directives['c_string_type']) + + +def check_negative_indices(*nodes): + """ + Raise a warning on nodes that are known to have negative numeric values. + Used to find (potential) bugs inside of "wraparound=False" sections. + """ + for node in nodes: + if node is None or ( + not isinstance(node.constant_result, _py_int_types) and + not isinstance(node.constant_result, float)): + continue + if node.constant_result < 0: + warning(node.pos, + "the result of using negative indices inside of " + "code sections marked as 'wraparound=False' is " + "undefined", level=1) + + +def infer_sequence_item_type(env, seq_node, index_node=None, seq_type=None): + if not seq_node.is_sequence_constructor: + if seq_type is None: + seq_type = seq_node.infer_type(env) + if seq_type is tuple_type: + # tuples are immutable => we can safely follow assignments + if seq_node.cf_state and len(seq_node.cf_state) == 1: + try: + seq_node = seq_node.cf_state[0].rhs + except AttributeError: + pass + if seq_node is not None and seq_node.is_sequence_constructor: + if index_node is not None and index_node.has_constant_result(): + try: + item = seq_node.args[index_node.constant_result] + except (ValueError, TypeError, IndexError): + pass + else: + return item.infer_type(env) + # if we're lucky, all items have the same type + item_types = set([item.infer_type(env) for item in seq_node.args]) + if len(item_types) == 1: + return item_types.pop() + return None + + +def make_dedup_key(outer_type, item_nodes): + """ + Recursively generate a deduplication key from a sequence of values. + Includes Cython node types to work around the fact that (1, 2.0) == (1.0, 2), for example. + + @param outer_type: The type of the outer container. + @param item_nodes: A sequence of constant nodes that will be traversed recursively. + @return: A tuple that can be used as a dict key for deduplication. + """ + item_keys = [ + (py_object_type, None, type(None)) if node is None + # For sequences and their "mult_factor", see TupleNode. + else make_dedup_key(node.type, [node.mult_factor if node.is_literal else None] + node.args) if node.is_sequence_constructor + else make_dedup_key(node.type, (node.start, node.stop, node.step)) if node.is_slice + # For constants, look at the Python value type if we don't know the concrete Cython type. + else (node.type, node.constant_result, + type(node.constant_result) if node.type is py_object_type else None) if node.has_constant_result() + else None # something we cannot handle => short-circuit below + for node in item_nodes + ] + if None in item_keys: + return None + return outer_type, tuple(item_keys) + + +# Returns a block of code to translate the exception, +# plus a boolean indicating whether to check for Python exceptions. +def get_exception_handler(exception_value): + if exception_value is None: + return "__Pyx_CppExn2PyErr();", False + elif (exception_value.type == PyrexTypes.c_char_type + and exception_value.value == '*'): + return "__Pyx_CppExn2PyErr();", True + elif exception_value.type.is_pyobject: + return ( + 'try { throw; } catch(const std::exception& exn) {' + 'PyErr_SetString(%s, exn.what());' + '} catch(...) { PyErr_SetNone(%s); }' % ( + exception_value.entry.cname, + exception_value.entry.cname), + False) + else: + return ( + '%s(); if (!PyErr_Occurred())' + 'PyErr_SetString(PyExc_RuntimeError, ' + '"Error converting c++ exception.");' % ( + exception_value.entry.cname), + False) + +def maybe_check_py_error(code, check_py_exception, pos, nogil): + if check_py_exception: + if nogil: + code.putln(code.error_goto_if("__Pyx_ErrOccurredWithGIL()", pos)) + else: + code.putln(code.error_goto_if("PyErr_Occurred()", pos)) + +def translate_cpp_exception(code, pos, inside, py_result, exception_value, nogil): + raise_py_exception, check_py_exception = get_exception_handler(exception_value) + code.putln("try {") + code.putln("%s" % inside) + if py_result: + code.putln(code.error_goto_if_null(py_result, pos)) + maybe_check_py_error(code, check_py_exception, pos, nogil) + code.putln("} catch(...) {") + if nogil: + code.put_ensure_gil(declare_gilstate=True) + code.putln(raise_py_exception) + if nogil: + code.put_release_ensured_gil() + code.putln(code.error_goto(pos)) + code.putln("}") + +# Used to handle the case where an lvalue expression and an overloaded assignment +# both have an exception declaration. +def translate_double_cpp_exception(code, pos, lhs_type, lhs_code, rhs_code, + lhs_exc_val, assign_exc_val, nogil): + handle_lhs_exc, lhc_check_py_exc = get_exception_handler(lhs_exc_val) + handle_assignment_exc, assignment_check_py_exc = get_exception_handler(assign_exc_val) + code.putln("try {") + code.putln(lhs_type.declaration_code("__pyx_local_lvalue = %s;" % lhs_code)) + maybe_check_py_error(code, lhc_check_py_exc, pos, nogil) + code.putln("try {") + code.putln("__pyx_local_lvalue = %s;" % rhs_code) + maybe_check_py_error(code, assignment_check_py_exc, pos, nogil) + # Catch any exception from the overloaded assignment. + code.putln("} catch(...) {") + if nogil: + code.put_ensure_gil(declare_gilstate=True) + code.putln(handle_assignment_exc) + if nogil: + code.put_release_ensured_gil() + code.putln(code.error_goto(pos)) + code.putln("}") + # Catch any exception from evaluating lhs. + code.putln("} catch(...) {") + if nogil: + code.put_ensure_gil(declare_gilstate=True) + code.putln(handle_lhs_exc) + if nogil: + code.put_release_ensured_gil() + code.putln(code.error_goto(pos)) + code.putln('}') + + +class ExprNode(Node): + # subexprs [string] Class var holding names of subexpr node attrs + # type PyrexType Type of the result + # result_code string Code fragment + # result_ctype string C type of result_code if different from type + # is_temp boolean Result is in a temporary variable + # is_sequence_constructor + # boolean Is a list or tuple constructor expression + # is_starred boolean Is a starred expression (e.g. '*a') + # saved_subexpr_nodes + # [ExprNode or [ExprNode or None] or None] + # Cached result of subexpr_nodes() + # use_managed_ref boolean use ref-counted temps/assignments/etc. + # result_is_used boolean indicates that the result will be dropped and the + # result_code/temp_result can safely be set to None + # is_numpy_attribute boolean Is a Numpy module attribute + # annotation ExprNode or None PEP526 annotation for names or expressions + + result_ctype = None + type = None + annotation = None + temp_code = None + old_temp = None # error checker for multiple frees etc. + use_managed_ref = True # can be set by optimisation transforms + result_is_used = True + is_numpy_attribute = False + + # The Analyse Expressions phase for expressions is split + # into two sub-phases: + # + # Analyse Types + # Determines the result type of the expression based + # on the types of its sub-expressions, and inserts + # coercion nodes into the expression tree where needed. + # Marks nodes which will need to have temporary variables + # allocated. + # + # Allocate Temps + # Allocates temporary variables where needed, and fills + # in the result_code field of each node. + # + # ExprNode provides some convenience routines which + # perform both of the above phases. These should only + # be called from statement nodes, and only when no + # coercion nodes need to be added around the expression + # being analysed. In that case, the above two phases + # should be invoked separately. + # + # Framework code in ExprNode provides much of the common + # processing for the various phases. It makes use of the + # 'subexprs' class attribute of ExprNodes, which should + # contain a list of the names of attributes which can + # hold sub-nodes or sequences of sub-nodes. + # + # The framework makes use of a number of abstract methods. + # Their responsibilities are as follows. + # + # Declaration Analysis phase + # + # analyse_target_declaration + # Called during the Analyse Declarations phase to analyse + # the LHS of an assignment or argument of a del statement. + # Nodes which cannot be the LHS of an assignment need not + # implement it. + # + # Expression Analysis phase + # + # analyse_types + # - Call analyse_types on all sub-expressions. + # - Check operand types, and wrap coercion nodes around + # sub-expressions where needed. + # - Set the type of this node. + # - If a temporary variable will be required for the + # result, set the is_temp flag of this node. + # + # analyse_target_types + # Called during the Analyse Types phase to analyse + # the LHS of an assignment or argument of a del + # statement. Similar responsibilities to analyse_types. + # + # target_code + # Called by the default implementation of allocate_target_temps. + # Should return a C lvalue for assigning to the node. The default + # implementation calls calculate_result_code. + # + # check_const + # - Check that this node and its subnodes form a + # legal constant expression. If so, do nothing, + # otherwise call not_const. + # + # The default implementation of check_const + # assumes that the expression is not constant. + # + # check_const_addr + # - Same as check_const, except check that the + # expression is a C lvalue whose address is + # constant. Otherwise, call addr_not_const. + # + # The default implementation of calc_const_addr + # assumes that the expression is not a constant + # lvalue. + # + # Code Generation phase + # + # generate_evaluation_code + # - Call generate_evaluation_code for sub-expressions. + # - Perform the functions of generate_result_code + # (see below). + # - If result is temporary, call generate_disposal_code + # on all sub-expressions. + # + # A default implementation of generate_evaluation_code + # is provided which uses the following abstract methods: + # + # generate_result_code + # - Generate any C statements necessary to calculate + # the result of this node from the results of its + # sub-expressions. + # + # calculate_result_code + # - Should return a C code fragment evaluating to the + # result. This is only called when the result is not + # a temporary. + # + # generate_assignment_code + # Called on the LHS of an assignment. + # - Call generate_evaluation_code for sub-expressions. + # - Generate code to perform the assignment. + # - If the assignment absorbed a reference, call + # generate_post_assignment_code on the RHS, + # otherwise call generate_disposal_code on it. + # + # generate_deletion_code + # Called on an argument of a del statement. + # - Call generate_evaluation_code for sub-expressions. + # - Generate code to perform the deletion. + # - Call generate_disposal_code on all sub-expressions. + # + # + + is_sequence_constructor = False + is_dict_literal = False + is_set_literal = False + is_string_literal = False + is_attribute = False + is_subscript = False + is_slice = False + + is_buffer_access = False + is_memview_index = False + is_memview_slice = False + is_memview_broadcast = False + is_memview_copy_assignment = False + + saved_subexpr_nodes = None + is_temp = False + is_target = False + is_starred = False + + constant_result = constant_value_not_set + + child_attrs = property(fget=operator.attrgetter('subexprs')) + + def not_implemented(self, method_name): + print_call_chain(method_name, "not implemented") ### + raise InternalError( + "%s.%s not implemented" % + (self.__class__.__name__, method_name)) + + def is_lvalue(self): + return 0 + + def is_addressable(self): + return self.is_lvalue() and not self.type.is_memoryviewslice + + def is_ephemeral(self): + # An ephemeral node is one whose result is in + # a Python temporary and we suspect there are no + # other references to it. Certain operations are + # disallowed on such values, since they are + # likely to result in a dangling pointer. + return self.type.is_pyobject and self.is_temp + + def subexpr_nodes(self): + # Extract a list of subexpression nodes based + # on the contents of the subexprs class attribute. + nodes = [] + for name in self.subexprs: + item = getattr(self, name) + if item is not None: + if type(item) is list: + nodes.extend(item) + else: + nodes.append(item) + return nodes + + def result(self): + if self.is_temp: + #if not self.temp_code: + # pos = (os.path.basename(self.pos[0].get_description()),) + self.pos[1:] if self.pos else '(?)' + # raise RuntimeError("temp result name not set in %s at %r" % ( + # self.__class__.__name__, pos)) + return self.temp_code + else: + return self.calculate_result_code() + + def pythran_result(self, type_=None): + if is_pythran_supported_node_or_none(self): + return to_pythran(self) + + assert(type_ is not None) + return to_pythran(self, type_) + + def is_c_result_required(self): + """ + Subtypes may return False here if result temp allocation can be skipped. + """ + return True + + def result_as(self, type = None): + # Return the result code cast to the specified C type. + if (self.is_temp and self.type.is_pyobject and + type != py_object_type): + # Allocated temporaries are always PyObject *, which may not + # reflect the actual type (e.g. an extension type) + return typecast(type, py_object_type, self.result()) + return typecast(type, self.ctype(), self.result()) + + def py_result(self): + # Return the result code cast to PyObject *. + return self.result_as(py_object_type) + + def ctype(self): + # Return the native C type of the result (i.e. the + # C type of the result_code expression). + return self.result_ctype or self.type + + def get_constant_c_result_code(self): + # Return the constant value of this node as a result code + # string, or None if the node is not constant. This method + # can be called when the constant result code is required + # before the code generation phase. + # + # The return value is a string that can represent a simple C + # value, a constant C name or a constant C expression. If the + # node type depends on Python code, this must return None. + return None + + def calculate_constant_result(self): + # Calculate the constant compile time result value of this + # expression and store it in ``self.constant_result``. Does + # nothing by default, thus leaving ``self.constant_result`` + # unknown. If valid, the result can be an arbitrary Python + # value. + # + # This must only be called when it is assured that all + # sub-expressions have a valid constant_result value. The + # ConstantFolding transform will do this. + pass + + def has_constant_result(self): + return self.constant_result is not constant_value_not_set and \ + self.constant_result is not not_a_constant + + def compile_time_value(self, denv): + # Return value of compile-time expression, or report error. + error(self.pos, "Invalid compile-time expression") + + def compile_time_value_error(self, e): + error(self.pos, "Error in compile-time expression: %s: %s" % ( + e.__class__.__name__, e)) + + # ------------- Declaration Analysis ---------------- + + def analyse_target_declaration(self, env): + error(self.pos, "Cannot assign to or delete this") + + # ------------- Expression Analysis ---------------- + + def analyse_const_expression(self, env): + # Called during the analyse_declarations phase of a + # constant expression. Analyses the expression's type, + # checks whether it is a legal const expression, + # and determines its value. + node = self.analyse_types(env) + node.check_const() + return node + + def analyse_expressions(self, env): + # Convenience routine performing both the Type + # Analysis and Temp Allocation phases for a whole + # expression. + return self.analyse_types(env) + + def analyse_target_expression(self, env, rhs): + # Convenience routine performing both the Type + # Analysis and Temp Allocation phases for the LHS of + # an assignment. + return self.analyse_target_types(env) + + def analyse_boolean_expression(self, env): + # Analyse expression and coerce to a boolean. + node = self.analyse_types(env) + bool = node.coerce_to_boolean(env) + return bool + + def analyse_temp_boolean_expression(self, env): + # Analyse boolean expression and coerce result into + # a temporary. This is used when a branch is to be + # performed on the result and we won't have an + # opportunity to ensure disposal code is executed + # afterwards. By forcing the result into a temporary, + # we ensure that all disposal has been done by the + # time we get the result. + node = self.analyse_types(env) + return node.coerce_to_boolean(env).coerce_to_simple(env) + + # --------------- Type Inference ----------------- + + def type_dependencies(self, env): + # Returns the list of entries whose types must be determined + # before the type of self can be inferred. + if hasattr(self, 'type') and self.type is not None: + return () + return sum([node.type_dependencies(env) for node in self.subexpr_nodes()], ()) + + def infer_type(self, env): + # Attempt to deduce the type of self. + # Differs from analyse_types as it avoids unnecessary + # analysis of subexpressions, but can assume everything + # in self.type_dependencies() has been resolved. + if hasattr(self, 'type') and self.type is not None: + return self.type + elif hasattr(self, 'entry') and self.entry is not None: + return self.entry.type + else: + self.not_implemented("infer_type") + + def nonlocally_immutable(self): + # Returns whether this variable is a safe reference, i.e. + # can't be modified as part of globals or closures. + return self.is_literal or self.is_temp or self.type.is_array or self.type.is_cfunction + + def inferable_item_node(self, index=0): + """ + Return a node that represents the (type) result of an indexing operation, + e.g. for tuple unpacking or iteration. + """ + return IndexNode(self.pos, base=self, index=IntNode( + self.pos, value=str(index), constant_result=index, type=PyrexTypes.c_py_ssize_t_type)) + + # --------------- Type Analysis ------------------ + + def analyse_as_module(self, env): + # If this node can be interpreted as a reference to a + # cimported module, return its scope, else None. + return None + + def analyse_as_type(self, env): + # If this node can be interpreted as a reference to a + # type, return that type, else None. + return None + + def analyse_as_extension_type(self, env): + # If this node can be interpreted as a reference to an + # extension type or builtin type, return its type, else None. + return None + + def analyse_types(self, env): + self.not_implemented("analyse_types") + + def analyse_target_types(self, env): + return self.analyse_types(env) + + def nogil_check(self, env): + # By default, any expression based on Python objects is + # prevented in nogil environments. Subtypes must override + # this if they can work without the GIL. + if self.type and self.type.is_pyobject: + self.gil_error() + + def gil_assignment_check(self, env): + if env.nogil and self.type.is_pyobject: + error(self.pos, "Assignment of Python object not allowed without gil") + + def check_const(self): + self.not_const() + return False + + def not_const(self): + error(self.pos, "Not allowed in a constant expression") + + def check_const_addr(self): + self.addr_not_const() + return False + + def addr_not_const(self): + error(self.pos, "Address is not constant") + + # ----------------- Result Allocation ----------------- + + def result_in_temp(self): + # Return true if result is in a temporary owned by + # this node or one of its subexpressions. Overridden + # by certain nodes which can share the result of + # a subnode. + return self.is_temp + + def target_code(self): + # Return code fragment for use as LHS of a C assignment. + return self.calculate_result_code() + + def calculate_result_code(self): + self.not_implemented("calculate_result_code") + +# def release_target_temp(self, env): +# # Release temporaries used by LHS of an assignment. +# self.release_subexpr_temps(env) + + def allocate_temp_result(self, code): + if self.temp_code: + raise RuntimeError("Temp allocated multiple times in %r: %r" % (self.__class__.__name__, self.pos)) + type = self.type + if not type.is_void: + if type.is_pyobject: + type = PyrexTypes.py_object_type + elif not (self.result_is_used or type.is_memoryviewslice or self.is_c_result_required()): + self.temp_code = None + return + self.temp_code = code.funcstate.allocate_temp( + type, manage_ref=self.use_managed_ref) + else: + self.temp_code = None + + def release_temp_result(self, code): + if not self.temp_code: + if not self.result_is_used: + # not used anyway, so ignore if not set up + return + pos = (os.path.basename(self.pos[0].get_description()),) + self.pos[1:] if self.pos else '(?)' + if self.old_temp: + raise RuntimeError("temp %s released multiple times in %s at %r" % ( + self.old_temp, self.__class__.__name__, pos)) + else: + raise RuntimeError("no temp, but release requested in %s at %r" % ( + self.__class__.__name__, pos)) + code.funcstate.release_temp(self.temp_code) + self.old_temp = self.temp_code + self.temp_code = None + + # ---------------- Code Generation ----------------- + + def make_owned_reference(self, code): + """ + If result is a pyobject, make sure we own a reference to it. + If the result is in a temp, it is already a new reference. + """ + if self.type.is_pyobject and not self.result_in_temp(): + code.put_incref(self.result(), self.ctype()) + + def make_owned_memoryviewslice(self, code): + """ + Make sure we own the reference to this memoryview slice. + """ + if not self.result_in_temp(): + code.put_incref_memoryviewslice(self.result(), + have_gil=self.in_nogil_context) + + def generate_evaluation_code(self, code): + # Generate code to evaluate this node and + # its sub-expressions, and dispose of any + # temporary results of its sub-expressions. + self.generate_subexpr_evaluation_code(code) + + code.mark_pos(self.pos) + if self.is_temp: + self.allocate_temp_result(code) + + self.generate_result_code(code) + if self.is_temp and not (self.type.is_string or self.type.is_pyunicode_ptr): + # If we are temp we do not need to wait until this node is disposed + # before disposing children. + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + + def generate_subexpr_evaluation_code(self, code): + for node in self.subexpr_nodes(): + node.generate_evaluation_code(code) + + def generate_result_code(self, code): + self.not_implemented("generate_result_code") + + def generate_disposal_code(self, code): + if self.is_temp: + if self.type.is_string or self.type.is_pyunicode_ptr: + # postponed from self.generate_evaluation_code() + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + if self.result(): + if self.type.is_pyobject: + code.put_decref_clear(self.result(), self.ctype()) + elif self.type.is_memoryviewslice: + code.put_xdecref_memoryviewslice( + self.result(), have_gil=not self.in_nogil_context) + code.putln("%s.memview = NULL;" % self.result()) + code.putln("%s.data = NULL;" % self.result()) + else: + # Already done if self.is_temp + self.generate_subexpr_disposal_code(code) + + def generate_subexpr_disposal_code(self, code): + # Generate code to dispose of temporary results + # of all sub-expressions. + for node in self.subexpr_nodes(): + node.generate_disposal_code(code) + + def generate_post_assignment_code(self, code): + if self.is_temp: + if self.type.is_string or self.type.is_pyunicode_ptr: + # postponed from self.generate_evaluation_code() + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + elif self.type.is_pyobject: + code.putln("%s = 0;" % self.result()) + elif self.type.is_memoryviewslice: + code.putln("%s.memview = NULL;" % self.result()) + code.putln("%s.data = NULL;" % self.result()) + else: + self.generate_subexpr_disposal_code(code) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False, + exception_check=None, exception_value=None): + # Stub method for nodes which are not legal as + # the LHS of an assignment. An error will have + # been reported earlier. + pass + + def generate_deletion_code(self, code, ignore_nonexisting=False): + # Stub method for nodes that are not legal as + # the argument of a del statement. An error + # will have been reported earlier. + pass + + def free_temps(self, code): + if self.is_temp: + if not self.type.is_void: + self.release_temp_result(code) + else: + self.free_subexpr_temps(code) + + def free_subexpr_temps(self, code): + for sub in self.subexpr_nodes(): + sub.free_temps(code) + + def generate_function_definitions(self, env, code): + pass + + # ---------------- Annotation --------------------- + + def annotate(self, code): + for node in self.subexpr_nodes(): + node.annotate(code) + + # ----------------- Coercion ---------------------- + + def coerce_to(self, dst_type, env): + # Coerce the result so that it can be assigned to + # something of type dst_type. If processing is necessary, + # wraps this node in a coercion node and returns that. + # Otherwise, returns this node unchanged. + # + # This method is called during the analyse_expressions + # phase of the src_node's processing. + # + # Note that subclasses that override this (especially + # ConstNodes) must not (re-)set their own .type attribute + # here. Since expression nodes may turn up in different + # places in the tree (e.g. inside of CloneNodes in cascaded + # assignments), this method must return a new node instance + # if it changes the type. + # + src = self + src_type = self.type + + if self.check_for_coercion_error(dst_type, env): + return self + + used_as_reference = dst_type.is_reference + if used_as_reference and not src_type.is_reference: + dst_type = dst_type.ref_base_type + + if src_type.is_const: + src_type = src_type.const_base_type + + if src_type.is_fused or dst_type.is_fused: + # See if we are coercing a fused function to a pointer to a + # specialized function + if (src_type.is_cfunction and not dst_type.is_fused and + dst_type.is_ptr and dst_type.base_type.is_cfunction): + + dst_type = dst_type.base_type + + for signature in src_type.get_all_specialized_function_types(): + if signature.same_as(dst_type): + src.type = signature + src.entry = src.type.entry + src.entry.used = True + return self + + if src_type.is_fused: + error(self.pos, "Type is not specialized") + elif src_type.is_null_ptr and dst_type.is_ptr: + # NULL can be implicitly cast to any pointer type + return self + else: + error(self.pos, "Cannot coerce to a type that is not specialized") + + self.type = error_type + return self + + if self.coercion_type is not None: + # This is purely for error checking purposes! + node = NameNode(self.pos, name='', type=self.coercion_type) + node.coerce_to(dst_type, env) + + if dst_type.is_memoryviewslice: + from . import MemoryView + if not src.type.is_memoryviewslice: + if src.type.is_pyobject: + src = CoerceToMemViewSliceNode(src, dst_type, env) + elif src.type.is_array: + src = CythonArrayNode.from_carray(src, env).coerce_to(dst_type, env) + elif not src_type.is_error: + error(self.pos, + "Cannot convert '%s' to memoryviewslice" % (src_type,)) + else: + if src.type.writable_needed: + dst_type.writable_needed = True + if not src.type.conforms_to(dst_type, broadcast=self.is_memview_broadcast, + copying=self.is_memview_copy_assignment): + if src.type.dtype.same_as(dst_type.dtype): + msg = "Memoryview '%s' not conformable to memoryview '%s'." + tup = src.type, dst_type + else: + msg = "Different base types for memoryviews (%s, %s)" + tup = src.type.dtype, dst_type.dtype + + error(self.pos, msg % tup) + + elif dst_type.is_pyobject: + if not src.type.is_pyobject: + if dst_type is bytes_type and src.type.is_int: + src = CoerceIntToBytesNode(src, env) + else: + src = CoerceToPyTypeNode(src, env, type=dst_type) + if not src.type.subtype_of(dst_type): + if src.constant_result is not None: + src = PyTypeTestNode(src, dst_type, env) + elif is_pythran_expr(dst_type) and is_pythran_supported_type(src.type): + # We let the compiler decide whether this is valid + return src + elif is_pythran_expr(src.type): + if is_pythran_supported_type(dst_type): + # Match the case were a pythran expr is assigned to a value, or vice versa. + # We let the C++ compiler decide whether this is valid or not! + return src + # Else, we need to convert the Pythran expression to a Python object + src = CoerceToPyTypeNode(src, env, type=dst_type) + elif src.type.is_pyobject: + if used_as_reference and dst_type.is_cpp_class: + warning( + self.pos, + "Cannot pass Python object as C++ data structure reference (%s &), will pass by copy." % dst_type) + src = CoerceFromPyTypeNode(dst_type, src, env) + elif (dst_type.is_complex + and src_type != dst_type + and dst_type.assignable_from(src_type)): + src = CoerceToComplexNode(src, dst_type, env) + else: # neither src nor dst are py types + # Added the string comparison, since for c types that + # is enough, but Cython gets confused when the types are + # in different pxi files. + # TODO: Remove this hack and require shared declarations. + if not (src.type == dst_type or str(src.type) == str(dst_type) or dst_type.assignable_from(src_type)): + self.fail_assignment(dst_type) + return src + + def fail_assignment(self, dst_type): + error(self.pos, "Cannot assign type '%s' to '%s'" % (self.type, dst_type)) + + def check_for_coercion_error(self, dst_type, env, fail=False, default=None): + if fail and not default: + default = "Cannot assign type '%(FROM)s' to '%(TO)s'" + message = find_coercion_error((self.type, dst_type), default, env) + if message is not None: + error(self.pos, message % {'FROM': self.type, 'TO': dst_type}) + return True + if fail: + self.fail_assignment(dst_type) + return True + return False + + def coerce_to_pyobject(self, env): + return self.coerce_to(PyrexTypes.py_object_type, env) + + def coerce_to_boolean(self, env): + # Coerce result to something acceptable as + # a boolean value. + + # if it's constant, calculate the result now + if self.has_constant_result(): + bool_value = bool(self.constant_result) + return BoolNode(self.pos, value=bool_value, + constant_result=bool_value) + + type = self.type + if type.is_enum or type.is_error: + return self + elif type.is_pyobject or type.is_int or type.is_ptr or type.is_float: + return CoerceToBooleanNode(self, env) + elif type.is_cpp_class and type.scope and type.scope.lookup("operator bool"): + return SimpleCallNode( + self.pos, + function=AttributeNode( + self.pos, obj=self, attribute=StringEncoding.EncodedString('operator bool')), + args=[]).analyse_types(env) + elif type.is_ctuple: + bool_value = len(type.components) == 0 + return BoolNode(self.pos, value=bool_value, + constant_result=bool_value) + else: + error(self.pos, "Type '%s' not acceptable as a boolean" % type) + return self + + def coerce_to_integer(self, env): + # If not already some C integer type, coerce to longint. + if self.type.is_int: + return self + else: + return self.coerce_to(PyrexTypes.c_long_type, env) + + def coerce_to_temp(self, env): + # Ensure that the result is in a temporary. + if self.result_in_temp(): + return self + else: + return CoerceToTempNode(self, env) + + def coerce_to_simple(self, env): + # Ensure that the result is simple (see is_simple). + if self.is_simple(): + return self + else: + return self.coerce_to_temp(env) + + def is_simple(self): + # A node is simple if its result is something that can + # be referred to without performing any operations, e.g. + # a constant, local var, C global var, struct member + # reference, or temporary. + return self.result_in_temp() + + def may_be_none(self): + if self.type and not (self.type.is_pyobject or + self.type.is_memoryviewslice): + return False + if self.has_constant_result(): + return self.constant_result is not None + return True + + def as_cython_attribute(self): + return None + + def as_none_safe_node(self, message, error="PyExc_TypeError", format_args=()): + # Wraps the node in a NoneCheckNode if it is not known to be + # not-None (e.g. because it is a Python literal). + if self.may_be_none(): + return NoneCheckNode(self, error, message, format_args) + else: + return self + + @classmethod + def from_node(cls, node, **kwargs): + """Instantiate this node class from another node, properly + copying over all attributes that one would forget otherwise. + """ + attributes = "cf_state cf_maybe_null cf_is_null constant_result".split() + for attr_name in attributes: + if attr_name in kwargs: + continue + try: + value = getattr(node, attr_name) + except AttributeError: + pass + else: + kwargs[attr_name] = value + return cls(node.pos, **kwargs) + + +class AtomicExprNode(ExprNode): + # Abstract base class for expression nodes which have + # no sub-expressions. + + subexprs = [] + + # Override to optimize -- we know we have no children + def generate_subexpr_evaluation_code(self, code): + pass + def generate_subexpr_disposal_code(self, code): + pass + +class PyConstNode(AtomicExprNode): + # Abstract base class for constant Python values. + + is_literal = 1 + type = py_object_type + + def is_simple(self): + return 1 + + def may_be_none(self): + return False + + def analyse_types(self, env): + return self + + def calculate_result_code(self): + return self.value + + def generate_result_code(self, code): + pass + + +class NoneNode(PyConstNode): + # The constant value None + + is_none = 1 + value = "Py_None" + + constant_result = None + + nogil_check = None + + def compile_time_value(self, denv): + return None + + def may_be_none(self): + return True + + def coerce_to(self, dst_type, env): + if not (dst_type.is_pyobject or dst_type.is_memoryviewslice or dst_type.is_error): + # Catch this error early and loudly. + error(self.pos, "Cannot assign None to %s" % dst_type) + return super(NoneNode, self).coerce_to(dst_type, env) + + +class EllipsisNode(PyConstNode): + # '...' in a subscript list. + + value = "Py_Ellipsis" + + constant_result = Ellipsis + + def compile_time_value(self, denv): + return Ellipsis + + +class ConstNode(AtomicExprNode): + # Abstract base type for literal constant nodes. + # + # value string C code fragment + + is_literal = 1 + nogil_check = None + + def is_simple(self): + return 1 + + def nonlocally_immutable(self): + return 1 + + def may_be_none(self): + return False + + def analyse_types(self, env): + return self # Types are held in class variables + + def check_const(self): + return True + + def get_constant_c_result_code(self): + return self.calculate_result_code() + + def calculate_result_code(self): + return str(self.value) + + def generate_result_code(self, code): + pass + + +class BoolNode(ConstNode): + type = PyrexTypes.c_bint_type + # The constant value True or False + + def calculate_constant_result(self): + self.constant_result = self.value + + def compile_time_value(self, denv): + return self.value + + def calculate_result_code(self): + if self.type.is_pyobject: + return self.value and 'Py_True' or 'Py_False' + else: + return str(int(self.value)) + + def coerce_to(self, dst_type, env): + if dst_type == self.type: + return self + if dst_type is py_object_type and self.type is Builtin.bool_type: + return self + if dst_type.is_pyobject and self.type.is_int: + return BoolNode( + self.pos, value=self.value, + constant_result=self.constant_result, + type=Builtin.bool_type) + if dst_type.is_int and self.type.is_pyobject: + return BoolNode( + self.pos, value=self.value, + constant_result=self.constant_result, + type=PyrexTypes.c_bint_type) + return ConstNode.coerce_to(self, dst_type, env) + + +class NullNode(ConstNode): + type = PyrexTypes.c_null_ptr_type + value = "NULL" + constant_result = 0 + + def get_constant_c_result_code(self): + return self.value + + +class CharNode(ConstNode): + type = PyrexTypes.c_char_type + + def calculate_constant_result(self): + self.constant_result = ord(self.value) + + def compile_time_value(self, denv): + return ord(self.value) + + def calculate_result_code(self): + return "'%s'" % StringEncoding.escape_char(self.value) + + +class IntNode(ConstNode): + + # unsigned "" or "U" + # longness "" or "L" or "LL" + # is_c_literal True/False/None creator considers this a C integer literal + + unsigned = "" + longness = "" + is_c_literal = None # unknown + + def __init__(self, pos, **kwds): + ExprNode.__init__(self, pos, **kwds) + if 'type' not in kwds: + self.type = self.find_suitable_type_for_value() + + def find_suitable_type_for_value(self): + if self.constant_result is constant_value_not_set: + try: + self.calculate_constant_result() + except ValueError: + pass + # we ignore 'is_c_literal = True' and instead map signed 32bit + # integers as C long values + if self.is_c_literal or \ + not self.has_constant_result() or \ + self.unsigned or self.longness == 'LL': + # clearly a C literal + rank = (self.longness == 'LL') and 2 or 1 + suitable_type = PyrexTypes.modifiers_and_name_to_type[not self.unsigned, rank, "int"] + if self.type: + suitable_type = PyrexTypes.widest_numeric_type(suitable_type, self.type) + else: + # C literal or Python literal - split at 32bit boundary + if -2**31 <= self.constant_result < 2**31: + if self.type and self.type.is_int: + suitable_type = self.type + else: + suitable_type = PyrexTypes.c_long_type + else: + suitable_type = PyrexTypes.py_object_type + return suitable_type + + def coerce_to(self, dst_type, env): + if self.type is dst_type: + return self + elif dst_type.is_float: + if self.has_constant_result(): + return FloatNode(self.pos, value='%d.0' % int(self.constant_result), type=dst_type, + constant_result=float(self.constant_result)) + else: + return FloatNode(self.pos, value=self.value, type=dst_type, + constant_result=not_a_constant) + if dst_type.is_numeric and not dst_type.is_complex: + node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, + type=dst_type, is_c_literal=True, + unsigned=self.unsigned, longness=self.longness) + return node + elif dst_type.is_pyobject: + node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, + type=PyrexTypes.py_object_type, is_c_literal=False, + unsigned=self.unsigned, longness=self.longness) + else: + # FIXME: not setting the type here to keep it working with + # complex numbers. Should they be special cased? + node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, + unsigned=self.unsigned, longness=self.longness) + # We still need to perform normal coerce_to processing on the + # result, because we might be coercing to an extension type, + # in which case a type test node will be needed. + return ConstNode.coerce_to(node, dst_type, env) + + def coerce_to_boolean(self, env): + return IntNode( + self.pos, value=self.value, + constant_result=self.constant_result, + type=PyrexTypes.c_bint_type, + unsigned=self.unsigned, longness=self.longness) + + def generate_evaluation_code(self, code): + if self.type.is_pyobject: + # pre-allocate a Python version of the number + plain_integer_string = str(Utils.str_to_number(self.value)) + self.result_code = code.get_py_int(plain_integer_string, self.longness) + else: + self.result_code = self.get_constant_c_result_code() + + def get_constant_c_result_code(self): + unsigned, longness = self.unsigned, self.longness + literal = self.value_as_c_integer_string() + if not (unsigned or longness) and self.type.is_int and literal[0] == '-' and literal[1] != '0': + # negative decimal literal => guess longness from type to prevent wrap-around + if self.type.rank >= PyrexTypes.c_longlong_type.rank: + longness = 'LL' + elif self.type.rank >= PyrexTypes.c_long_type.rank: + longness = 'L' + return literal + unsigned + longness + + def value_as_c_integer_string(self): + value = self.value + if len(value) <= 2: + # too short to go wrong (and simplifies code below) + return value + neg_sign = '' + if value[0] == '-': + neg_sign = '-' + value = value[1:] + if value[0] == '0': + literal_type = value[1] # 0'o' - 0'b' - 0'x' + # 0x123 hex literals and 0123 octal literals work nicely in C + # but C-incompatible Py3 oct/bin notations need conversion + if neg_sign and literal_type in 'oOxX0123456789' and value[2:].isdigit(): + # negative hex/octal literal => prevent C compiler from using + # unsigned integer types by converting to decimal (see C standard 6.4.4.1) + value = str(Utils.str_to_number(value)) + elif literal_type in 'oO': + value = '0' + value[2:] # '0o123' => '0123' + elif literal_type in 'bB': + value = str(int(value[2:], 2)) + elif value.isdigit() and not self.unsigned and not self.longness: + if not neg_sign: + # C compilers do not consider unsigned types for decimal literals, + # but they do for hex (see C standard 6.4.4.1) + value = '0x%X' % int(value) + return neg_sign + value + + def calculate_result_code(self): + return self.result_code + + def calculate_constant_result(self): + self.constant_result = Utils.str_to_number(self.value) + + def compile_time_value(self, denv): + return Utils.str_to_number(self.value) + +class FloatNode(ConstNode): + type = PyrexTypes.c_double_type + + def calculate_constant_result(self): + self.constant_result = float(self.value) + + def compile_time_value(self, denv): + return float(self.value) + + def coerce_to(self, dst_type, env): + if dst_type.is_pyobject and self.type.is_float: + return FloatNode( + self.pos, value=self.value, + constant_result=self.constant_result, + type=Builtin.float_type) + if dst_type.is_float and self.type.is_pyobject: + return FloatNode( + self.pos, value=self.value, + constant_result=self.constant_result, + type=dst_type) + return ConstNode.coerce_to(self, dst_type, env) + + def calculate_result_code(self): + return self.result_code + + def get_constant_c_result_code(self): + strval = self.value + assert isinstance(strval, basestring) + cmpval = repr(float(strval)) + if cmpval == 'nan': + return "(Py_HUGE_VAL * 0)" + elif cmpval == 'inf': + return "Py_HUGE_VAL" + elif cmpval == '-inf': + return "(-Py_HUGE_VAL)" + else: + return strval + + def generate_evaluation_code(self, code): + c_value = self.get_constant_c_result_code() + if self.type.is_pyobject: + self.result_code = code.get_py_float(self.value, c_value) + else: + self.result_code = c_value + + +def _analyse_name_as_type(name, pos, env): + type = PyrexTypes.parse_basic_type(name) + if type is not None: + return type + + global_entry = env.global_scope().lookup(name) + if global_entry and global_entry.type and ( + global_entry.type.is_extension_type + or global_entry.type.is_struct_or_union + or global_entry.type.is_builtin_type + or global_entry.type.is_cpp_class): + return global_entry.type + + from .TreeFragment import TreeFragment + with local_errors(ignore=True): + pos = (pos[0], pos[1], pos[2]-7) + try: + declaration = TreeFragment(u"sizeof(%s)" % name, name=pos[0].filename, initial_pos=pos) + except CompileError: + pass + else: + sizeof_node = declaration.root.stats[0].expr + if isinstance(sizeof_node, SizeofTypeNode): + sizeof_node = sizeof_node.analyse_types(env) + if isinstance(sizeof_node, SizeofTypeNode): + return sizeof_node.arg_type + return None + + +class BytesNode(ConstNode): + # A char* or bytes literal + # + # value BytesLiteral + + is_string_literal = True + # start off as Python 'bytes' to support len() in O(1) + type = bytes_type + + def calculate_constant_result(self): + self.constant_result = self.value + + def as_sliced_node(self, start, stop, step=None): + value = StringEncoding.bytes_literal(self.value[start:stop:step], self.value.encoding) + return BytesNode(self.pos, value=value, constant_result=value) + + def compile_time_value(self, denv): + return self.value.byteencode() + + def analyse_as_type(self, env): + return _analyse_name_as_type(self.value.decode('ISO8859-1'), self.pos, env) + + def can_coerce_to_char_literal(self): + return len(self.value) == 1 + + def coerce_to_boolean(self, env): + # This is special because testing a C char* for truth directly + # would yield the wrong result. + bool_value = bool(self.value) + return BoolNode(self.pos, value=bool_value, constant_result=bool_value) + + def coerce_to(self, dst_type, env): + if self.type == dst_type: + return self + if dst_type.is_int: + if not self.can_coerce_to_char_literal(): + error(self.pos, "Only single-character string literals can be coerced into ints.") + return self + if dst_type.is_unicode_char: + error(self.pos, "Bytes literals cannot coerce to Py_UNICODE/Py_UCS4, use a unicode literal instead.") + return self + return CharNode(self.pos, value=self.value, + constant_result=ord(self.value)) + + node = BytesNode(self.pos, value=self.value, constant_result=self.constant_result) + if dst_type.is_pyobject: + if dst_type in (py_object_type, Builtin.bytes_type): + node.type = Builtin.bytes_type + else: + self.check_for_coercion_error(dst_type, env, fail=True) + return node + elif dst_type in (PyrexTypes.c_char_ptr_type, PyrexTypes.c_const_char_ptr_type): + node.type = dst_type + return node + elif dst_type in (PyrexTypes.c_uchar_ptr_type, PyrexTypes.c_const_uchar_ptr_type, PyrexTypes.c_void_ptr_type): + node.type = (PyrexTypes.c_const_char_ptr_type if dst_type == PyrexTypes.c_const_uchar_ptr_type + else PyrexTypes.c_char_ptr_type) + return CastNode(node, dst_type) + elif dst_type.assignable_from(PyrexTypes.c_char_ptr_type): + # Exclude the case of passing a C string literal into a non-const C++ string. + if not dst_type.is_cpp_class or dst_type.is_const: + node.type = dst_type + return node + + # We still need to perform normal coerce_to processing on the + # result, because we might be coercing to an extension type, + # in which case a type test node will be needed. + return ConstNode.coerce_to(node, dst_type, env) + + def generate_evaluation_code(self, code): + if self.type.is_pyobject: + result = code.get_py_string_const(self.value) + elif self.type.is_const: + result = code.get_string_const(self.value) + else: + # not const => use plain C string literal and cast to mutable type + literal = self.value.as_c_string_literal() + # C++ may require a cast + result = typecast(self.type, PyrexTypes.c_void_ptr_type, literal) + self.result_code = result + + def get_constant_c_result_code(self): + return None # FIXME + + def calculate_result_code(self): + return self.result_code + + +class UnicodeNode(ConstNode): + # A Py_UNICODE* or unicode literal + # + # value EncodedString + # bytes_value BytesLiteral the literal parsed as bytes string + # ('-3' unicode literals only) + + is_string_literal = True + bytes_value = None + type = unicode_type + + def calculate_constant_result(self): + self.constant_result = self.value + + def analyse_as_type(self, env): + return _analyse_name_as_type(self.value, self.pos, env) + + def as_sliced_node(self, start, stop, step=None): + if StringEncoding.string_contains_surrogates(self.value[:stop]): + # this is unsafe as it may give different results + # in different runtimes + return None + value = StringEncoding.EncodedString(self.value[start:stop:step]) + value.encoding = self.value.encoding + if self.bytes_value is not None: + bytes_value = StringEncoding.bytes_literal( + self.bytes_value[start:stop:step], self.bytes_value.encoding) + else: + bytes_value = None + return UnicodeNode( + self.pos, value=value, bytes_value=bytes_value, + constant_result=value) + + def coerce_to(self, dst_type, env): + if dst_type is self.type: + pass + elif dst_type.is_unicode_char: + if not self.can_coerce_to_char_literal(): + error(self.pos, + "Only single-character Unicode string literals or " + "surrogate pairs can be coerced into Py_UCS4/Py_UNICODE.") + return self + int_value = ord(self.value) + return IntNode(self.pos, type=dst_type, value=str(int_value), + constant_result=int_value) + elif not dst_type.is_pyobject: + if dst_type.is_string and self.bytes_value is not None: + # special case: '-3' enforced unicode literal used in a + # C char* context + return BytesNode(self.pos, value=self.bytes_value + ).coerce_to(dst_type, env) + if dst_type.is_pyunicode_ptr: + node = UnicodeNode(self.pos, value=self.value) + node.type = dst_type + return node + error(self.pos, + "Unicode literals do not support coercion to C types other " + "than Py_UNICODE/Py_UCS4 (for characters) or Py_UNICODE* " + "(for strings).") + elif dst_type not in (py_object_type, Builtin.basestring_type): + self.check_for_coercion_error(dst_type, env, fail=True) + return self + + def can_coerce_to_char_literal(self): + return len(self.value) == 1 + ## or (len(self.value) == 2 + ## and (0xD800 <= self.value[0] <= 0xDBFF) + ## and (0xDC00 <= self.value[1] <= 0xDFFF)) + + def coerce_to_boolean(self, env): + bool_value = bool(self.value) + return BoolNode(self.pos, value=bool_value, constant_result=bool_value) + + def contains_surrogates(self): + return StringEncoding.string_contains_surrogates(self.value) + + def generate_evaluation_code(self, code): + if self.type.is_pyobject: + # FIXME: this should go away entirely! + # Since string_contains_lone_surrogates() returns False for surrogate pairs in Py2/UCS2, + # Py2 can generate different code from Py3 here. Let's hope we get away with claiming that + # the processing of surrogate pairs in code was always ambiguous and lead to different results + # on P16/32bit Unicode platforms. + if StringEncoding.string_contains_lone_surrogates(self.value): + # lone (unpaired) surrogates are not really portable and cannot be + # decoded by the UTF-8 codec in Py3.3 + self.result_code = code.get_py_const(py_object_type, 'ustring') + data_cname = code.get_string_const( + StringEncoding.BytesLiteral(self.value.encode('unicode_escape'))) + const_code = code.get_cached_constants_writer(self.result_code) + if const_code is None: + return # already initialised + const_code.mark_pos(self.pos) + const_code.putln( + "%s = PyUnicode_DecodeUnicodeEscape(%s, sizeof(%s) - 1, NULL); %s" % ( + self.result_code, + data_cname, + data_cname, + const_code.error_goto_if_null(self.result_code, self.pos))) + const_code.put_error_if_neg( + self.pos, "__Pyx_PyUnicode_READY(%s)" % self.result_code) + else: + self.result_code = code.get_py_string_const(self.value) + else: + self.result_code = code.get_pyunicode_ptr_const(self.value) + + def calculate_result_code(self): + return self.result_code + + def compile_time_value(self, env): + return self.value + + +class StringNode(PyConstNode): + # A Python str object, i.e. a byte string in Python 2.x and a + # unicode string in Python 3.x + # + # value BytesLiteral (or EncodedString with ASCII content) + # unicode_value EncodedString or None + # is_identifier boolean + + type = str_type + is_string_literal = True + is_identifier = None + unicode_value = None + + def calculate_constant_result(self): + if self.unicode_value is not None: + # only the Unicode value is portable across Py2/3 + self.constant_result = self.unicode_value + + def analyse_as_type(self, env): + return _analyse_name_as_type(self.unicode_value or self.value.decode('ISO8859-1'), self.pos, env) + + def as_sliced_node(self, start, stop, step=None): + value = type(self.value)(self.value[start:stop:step]) + value.encoding = self.value.encoding + if self.unicode_value is not None: + if StringEncoding.string_contains_surrogates(self.unicode_value[:stop]): + # this is unsafe as it may give different results in different runtimes + return None + unicode_value = StringEncoding.EncodedString( + self.unicode_value[start:stop:step]) + else: + unicode_value = None + return StringNode( + self.pos, value=value, unicode_value=unicode_value, + constant_result=value, is_identifier=self.is_identifier) + + def coerce_to(self, dst_type, env): + if dst_type is not py_object_type and not str_type.subtype_of(dst_type): +# if dst_type is Builtin.bytes_type: +# # special case: bytes = 'str literal' +# return BytesNode(self.pos, value=self.value) + if not dst_type.is_pyobject: + return BytesNode(self.pos, value=self.value).coerce_to(dst_type, env) + if dst_type is not Builtin.basestring_type: + self.check_for_coercion_error(dst_type, env, fail=True) + return self + + def can_coerce_to_char_literal(self): + return not self.is_identifier and len(self.value) == 1 + + def generate_evaluation_code(self, code): + self.result_code = code.get_py_string_const( + self.value, identifier=self.is_identifier, is_str=True, + unicode_value=self.unicode_value) + + def get_constant_c_result_code(self): + return None + + def calculate_result_code(self): + return self.result_code + + def compile_time_value(self, env): + if self.value.is_unicode: + return self.value + if not IS_PYTHON3: + # use plain str/bytes object in Py2 + return self.value.byteencode() + # in Py3, always return a Unicode string + if self.unicode_value is not None: + return self.unicode_value + return self.value.decode('iso8859-1') + + +class IdentifierStringNode(StringNode): + # A special str value that represents an identifier (bytes in Py2, + # unicode in Py3). + is_identifier = True + + +class ImagNode(AtomicExprNode): + # Imaginary number literal + # + # value string imaginary part (float value) + + type = PyrexTypes.c_double_complex_type + + def calculate_constant_result(self): + self.constant_result = complex(0.0, float(self.value)) + + def compile_time_value(self, denv): + return complex(0.0, float(self.value)) + + def analyse_types(self, env): + self.type.create_declaration_utility_code(env) + return self + + def may_be_none(self): + return False + + def coerce_to(self, dst_type, env): + if self.type is dst_type: + return self + node = ImagNode(self.pos, value=self.value) + if dst_type.is_pyobject: + node.is_temp = 1 + node.type = Builtin.complex_type + # We still need to perform normal coerce_to processing on the + # result, because we might be coercing to an extension type, + # in which case a type test node will be needed. + return AtomicExprNode.coerce_to(node, dst_type, env) + + gil_message = "Constructing complex number" + + def calculate_result_code(self): + if self.type.is_pyobject: + return self.result() + else: + return "%s(0, %r)" % (self.type.from_parts, float(self.value)) + + def generate_result_code(self, code): + if self.type.is_pyobject: + code.putln( + "%s = PyComplex_FromDoubles(0.0, %r); %s" % ( + self.result(), + float(self.value), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class NewExprNode(AtomicExprNode): + + # C++ new statement + # + # cppclass node c++ class to create + + type = None + + def infer_type(self, env): + type = self.cppclass.analyse_as_type(env) + if type is None or not type.is_cpp_class: + error(self.pos, "new operator can only be applied to a C++ class") + self.type = error_type + return + self.cpp_check(env) + constructor = type.get_constructor(self.pos) + self.class_type = type + self.entry = constructor + self.type = constructor.type + return self.type + + def analyse_types(self, env): + if self.type is None: + self.infer_type(env) + return self + + def may_be_none(self): + return False + + def generate_result_code(self, code): + pass + + def calculate_result_code(self): + return "new " + self.class_type.empty_declaration_code() + + +class NameNode(AtomicExprNode): + # Reference to a local or global variable name. + # + # name string Python name of the variable + # entry Entry Symbol table entry + # type_entry Entry For extension type names, the original type entry + # cf_is_null boolean Is uninitialized before this node + # cf_maybe_null boolean Maybe uninitialized before this node + # allow_null boolean Don't raise UnboundLocalError + # nogil boolean Whether it is used in a nogil context + + is_name = True + is_cython_module = False + cython_attribute = None + lhs_of_first_assignment = False # TODO: remove me + is_used_as_rvalue = 0 + entry = None + type_entry = None + cf_maybe_null = True + cf_is_null = False + allow_null = False + nogil = False + inferred_type = None + + def as_cython_attribute(self): + return self.cython_attribute + + def type_dependencies(self, env): + if self.entry is None: + self.entry = env.lookup(self.name) + if self.entry is not None and self.entry.type.is_unspecified: + return (self,) + else: + return () + + def infer_type(self, env): + if self.entry is None: + self.entry = env.lookup(self.name) + if self.entry is None or self.entry.type is unspecified_type: + if self.inferred_type is not None: + return self.inferred_type + return py_object_type + elif (self.entry.type.is_extension_type or self.entry.type.is_builtin_type) and \ + self.name == self.entry.type.name: + # Unfortunately the type attribute of type objects + # is used for the pointer to the type they represent. + return type_type + elif self.entry.type.is_cfunction: + if self.entry.scope.is_builtin_scope: + # special case: optimised builtin functions must be treated as Python objects + return py_object_type + else: + # special case: referring to a C function must return its pointer + return PyrexTypes.CPtrType(self.entry.type) + else: + # If entry is inferred as pyobject it's safe to use local + # NameNode's inferred_type. + if self.entry.type.is_pyobject and self.inferred_type: + # Overflow may happen if integer + if not (self.inferred_type.is_int and self.entry.might_overflow): + return self.inferred_type + return self.entry.type + + def compile_time_value(self, denv): + try: + return denv.lookup(self.name) + except KeyError: + error(self.pos, "Compile-time name '%s' not defined" % self.name) + + def get_constant_c_result_code(self): + if not self.entry or self.entry.type.is_pyobject: + return None + return self.entry.cname + + def coerce_to(self, dst_type, env): + # If coercing to a generic pyobject and this is a builtin + # C function with a Python equivalent, manufacture a NameNode + # referring to the Python builtin. + #print "NameNode.coerce_to:", self.name, dst_type ### + if dst_type is py_object_type: + entry = self.entry + if entry and entry.is_cfunction: + var_entry = entry.as_variable + if var_entry: + if var_entry.is_builtin and var_entry.is_const: + var_entry = env.declare_builtin(var_entry.name, self.pos) + node = NameNode(self.pos, name = self.name) + node.entry = var_entry + node.analyse_rvalue_entry(env) + return node + + return super(NameNode, self).coerce_to(dst_type, env) + + def declare_from_annotation(self, env, as_target=False): + """Implements PEP 526 annotation typing in a fairly relaxed way. + + Annotations are ignored for global variables, Python class attributes and already declared variables. + String literals are allowed and ignored. + The ambiguous Python types 'int' and 'long' are ignored and the 'cython.int' form must be used instead. + """ + if not env.directives['annotation_typing']: + return + if env.is_module_scope or env.is_py_class_scope: + # annotations never create global cdef names and Python classes don't support them anyway + return + name = self.name + if self.entry or env.lookup_here(name) is not None: + # already declared => ignore annotation + return + + annotation = self.annotation + if annotation.is_string_literal: + # name: "description" => not a type, but still a declared variable or attribute + atype = None + else: + _, atype = analyse_type_annotation(annotation, env) + if atype is None: + atype = unspecified_type if as_target and env.directives['infer_types'] != False else py_object_type + self.entry = env.declare_var(name, atype, self.pos, is_cdef=not as_target) + self.entry.annotation = annotation + + def analyse_as_module(self, env): + # Try to interpret this as a reference to a cimported module. + # Returns the module scope, or None. + entry = self.entry + if not entry: + entry = env.lookup(self.name) + if entry and entry.as_module: + return entry.as_module + return None + + def analyse_as_type(self, env): + if self.cython_attribute: + type = PyrexTypes.parse_basic_type(self.cython_attribute) + else: + type = PyrexTypes.parse_basic_type(self.name) + if type: + return type + entry = self.entry + if not entry: + entry = env.lookup(self.name) + if entry and entry.is_type: + return entry.type + else: + return None + + def analyse_as_extension_type(self, env): + # Try to interpret this as a reference to an extension type. + # Returns the extension type, or None. + entry = self.entry + if not entry: + entry = env.lookup(self.name) + if entry and entry.is_type: + if entry.type.is_extension_type or entry.type.is_builtin_type: + return entry.type + return None + + def analyse_target_declaration(self, env): + if not self.entry: + self.entry = env.lookup_here(self.name) + if not self.entry and self.annotation is not None: + # name : type = ... + self.declare_from_annotation(env, as_target=True) + if not self.entry: + if env.directives['warn.undeclared']: + warning(self.pos, "implicit declaration of '%s'" % self.name, 1) + if env.directives['infer_types'] != False: + type = unspecified_type + else: + type = py_object_type + self.entry = env.declare_var(self.name, type, self.pos) + if self.entry.is_declared_generic: + self.result_ctype = py_object_type + if self.entry.as_module: + # cimported modules namespace can shadow actual variables + self.entry.is_variable = 1 + + def analyse_types(self, env): + self.initialized_check = env.directives['initializedcheck'] + entry = self.entry + if entry is None: + entry = env.lookup(self.name) + if not entry: + entry = env.declare_builtin(self.name, self.pos) + if entry and entry.is_builtin and entry.is_const: + self.is_literal = True + if not entry: + self.type = PyrexTypes.error_type + return self + self.entry = entry + entry.used = 1 + if entry.type.is_buffer: + from . import Buffer + Buffer.used_buffer_aux_vars(entry) + self.analyse_rvalue_entry(env) + return self + + def analyse_target_types(self, env): + self.analyse_entry(env, is_target=True) + + entry = self.entry + if entry.is_cfunction and entry.as_variable: + # FIXME: unify "is_overridable" flags below + if (entry.is_overridable or entry.type.is_overridable) or not self.is_lvalue() and entry.fused_cfunction: + # We need this for assigning to cpdef names and for the fused 'def' TreeFragment + entry = self.entry = entry.as_variable + self.type = entry.type + + if self.type.is_const: + error(self.pos, "Assignment to const '%s'" % self.name) + if self.type.is_reference: + error(self.pos, "Assignment to reference '%s'" % self.name) + if not self.is_lvalue(): + error(self.pos, "Assignment to non-lvalue '%s'" % self.name) + self.type = PyrexTypes.error_type + entry.used = 1 + if entry.type.is_buffer: + from . import Buffer + Buffer.used_buffer_aux_vars(entry) + return self + + def analyse_rvalue_entry(self, env): + #print "NameNode.analyse_rvalue_entry:", self.name ### + #print "Entry:", self.entry.__dict__ ### + self.analyse_entry(env) + entry = self.entry + + if entry.is_declared_generic: + self.result_ctype = py_object_type + + if entry.is_pyglobal or entry.is_builtin: + if entry.is_builtin and entry.is_const: + self.is_temp = 0 + else: + self.is_temp = 1 + + self.is_used_as_rvalue = 1 + elif entry.type.is_memoryviewslice: + self.is_temp = False + self.is_used_as_rvalue = True + self.use_managed_ref = True + return self + + def nogil_check(self, env): + self.nogil = True + if self.is_used_as_rvalue: + entry = self.entry + if entry.is_builtin: + if not entry.is_const: # cached builtins are ok + self.gil_error() + elif entry.is_pyglobal: + self.gil_error() + + gil_message = "Accessing Python global or builtin" + + def analyse_entry(self, env, is_target=False): + #print "NameNode.analyse_entry:", self.name ### + self.check_identifier_kind() + entry = self.entry + type = entry.type + if (not is_target and type.is_pyobject and self.inferred_type and + self.inferred_type.is_builtin_type): + # assume that type inference is smarter than the static entry + type = self.inferred_type + self.type = type + + def check_identifier_kind(self): + # Check that this is an appropriate kind of name for use in an + # expression. Also finds the variable entry associated with + # an extension type. + entry = self.entry + if entry.is_type and entry.type.is_extension_type: + self.type_entry = entry + if entry.is_type and entry.type.is_enum: + py_entry = Symtab.Entry(self.name, None, py_object_type) + py_entry.is_pyglobal = True + py_entry.scope = self.entry.scope + self.entry = py_entry + elif not (entry.is_const or entry.is_variable or + entry.is_builtin or entry.is_cfunction or + entry.is_cpp_class): + if self.entry.as_variable: + self.entry = self.entry.as_variable + elif not self.is_cython_module: + error(self.pos, "'%s' is not a constant, variable or function identifier" % self.name) + + def is_cimported_module_without_shadow(self, env): + if self.is_cython_module or self.cython_attribute: + return False + entry = self.entry or env.lookup(self.name) + return entry.as_module and not entry.is_variable + + def is_simple(self): + # If it's not a C variable, it'll be in a temp. + return 1 + + def may_be_none(self): + if self.cf_state and self.type and (self.type.is_pyobject or + self.type.is_memoryviewslice): + # gard against infinite recursion on self-dependencies + if getattr(self, '_none_checking', False): + # self-dependency - either this node receives a None + # value from *another* node, or it can not reference + # None at this point => safe to assume "not None" + return False + self._none_checking = True + # evaluate control flow state to see if there were any + # potential None values assigned to the node so far + may_be_none = False + for assignment in self.cf_state: + if assignment.rhs.may_be_none(): + may_be_none = True + break + del self._none_checking + return may_be_none + return super(NameNode, self).may_be_none() + + def nonlocally_immutable(self): + if ExprNode.nonlocally_immutable(self): + return True + entry = self.entry + if not entry or entry.in_closure: + return False + return entry.is_local or entry.is_arg or entry.is_builtin or entry.is_readonly + + def calculate_target_results(self, env): + pass + + def check_const(self): + entry = self.entry + if entry is not None and not ( + entry.is_const or + entry.is_cfunction or + entry.is_builtin or + entry.type.is_const): + self.not_const() + return False + return True + + def check_const_addr(self): + entry = self.entry + if not (entry.is_cglobal or entry.is_cfunction or entry.is_builtin): + self.addr_not_const() + return False + return True + + def is_lvalue(self): + return ( + self.entry.is_variable and + not self.entry.is_readonly + ) or ( + self.entry.is_cfunction and + self.entry.is_overridable + ) + + def is_addressable(self): + return self.entry.is_variable and not self.type.is_memoryviewslice + + def is_ephemeral(self): + # Name nodes are never ephemeral, even if the + # result is in a temporary. + return 0 + + def calculate_result_code(self): + entry = self.entry + if not entry: + return "<error>" # There was an error earlier + return entry.cname + + def generate_result_code(self, code): + assert hasattr(self, 'entry') + entry = self.entry + if entry is None: + return # There was an error earlier + if entry.utility_code: + code.globalstate.use_utility_code(entry.utility_code) + if entry.is_builtin and entry.is_const: + return # Lookup already cached + elif entry.is_pyclass_attr: + assert entry.type.is_pyobject, "Python global or builtin not a Python object" + interned_cname = code.intern_identifier(self.entry.name) + if entry.is_builtin: + namespace = Naming.builtins_cname + else: # entry.is_pyglobal + namespace = entry.scope.namespace_cname + if not self.cf_is_null: + code.putln( + '%s = PyObject_GetItem(%s, %s);' % ( + self.result(), + namespace, + interned_cname)) + code.putln('if (unlikely(!%s)) {' % self.result()) + code.putln('PyErr_Clear();') + code.globalstate.use_utility_code( + UtilityCode.load_cached("GetModuleGlobalName", "ObjectHandling.c")) + code.putln( + '__Pyx_GetModuleGlobalName(%s, %s);' % ( + self.result(), + interned_cname)) + if not self.cf_is_null: + code.putln("}") + code.putln(code.error_goto_if_null(self.result(), self.pos)) + code.put_gotref(self.py_result()) + + elif entry.is_builtin and not entry.scope.is_module_scope: + # known builtin + assert entry.type.is_pyobject, "Python global or builtin not a Python object" + interned_cname = code.intern_identifier(self.entry.name) + code.globalstate.use_utility_code( + UtilityCode.load_cached("GetBuiltinName", "ObjectHandling.c")) + code.putln( + '%s = __Pyx_GetBuiltinName(%s); %s' % ( + self.result(), + interned_cname, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + elif entry.is_pyglobal or (entry.is_builtin and entry.scope.is_module_scope): + # name in class body, global name or unknown builtin + assert entry.type.is_pyobject, "Python global or builtin not a Python object" + interned_cname = code.intern_identifier(self.entry.name) + if entry.scope.is_module_scope: + code.globalstate.use_utility_code( + UtilityCode.load_cached("GetModuleGlobalName", "ObjectHandling.c")) + code.putln( + '__Pyx_GetModuleGlobalName(%s, %s); %s' % ( + self.result(), + interned_cname, + code.error_goto_if_null(self.result(), self.pos))) + else: + # FIXME: is_pyglobal is also used for class namespace + code.globalstate.use_utility_code( + UtilityCode.load_cached("GetNameInClass", "ObjectHandling.c")) + code.putln( + '__Pyx_GetNameInClass(%s, %s, %s); %s' % ( + self.result(), + entry.scope.namespace_cname, + interned_cname, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + elif entry.is_local or entry.in_closure or entry.from_closure or entry.type.is_memoryviewslice: + # Raise UnboundLocalError for objects and memoryviewslices + raise_unbound = ( + (self.cf_maybe_null or self.cf_is_null) and not self.allow_null) + null_code = entry.type.check_for_null_code(entry.cname) + + memslice_check = entry.type.is_memoryviewslice and self.initialized_check + + if null_code and raise_unbound and (entry.type.is_pyobject or memslice_check): + code.put_error_if_unbound(self.pos, entry, self.in_nogil_context) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False, + exception_check=None, exception_value=None): + #print "NameNode.generate_assignment_code:", self.name ### + entry = self.entry + if entry is None: + return # There was an error earlier + + if (self.entry.type.is_ptr and isinstance(rhs, ListNode) + and not self.lhs_of_first_assignment and not rhs.in_module_scope): + error(self.pos, "Literal list must be assigned to pointer at time of declaration") + + # is_pyglobal seems to be True for module level-globals only. + # We use this to access class->tp_dict if necessary. + if entry.is_pyglobal: + assert entry.type.is_pyobject, "Python global or builtin not a Python object" + interned_cname = code.intern_identifier(self.entry.name) + namespace = self.entry.scope.namespace_cname + if entry.is_member: + # if the entry is a member we have to cheat: SetAttr does not work + # on types, so we create a descriptor which is then added to tp_dict + setter = 'PyDict_SetItem' + namespace = '%s->tp_dict' % namespace + elif entry.scope.is_module_scope: + setter = 'PyDict_SetItem' + namespace = Naming.moddict_cname + elif entry.is_pyclass_attr: + code.globalstate.use_utility_code(UtilityCode.load_cached("SetNameInClass", "ObjectHandling.c")) + setter = '__Pyx_SetNameInClass' + else: + assert False, repr(entry) + code.put_error_if_neg( + self.pos, + '%s(%s, %s, %s)' % ( + setter, + namespace, + interned_cname, + rhs.py_result())) + if debug_disposal_code: + print("NameNode.generate_assignment_code:") + print("...generating disposal code for %s" % rhs) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + if entry.is_member: + # in Py2.6+, we need to invalidate the method cache + code.putln("PyType_Modified(%s);" % + entry.scope.parent_type.typeptr_cname) + else: + if self.type.is_memoryviewslice: + self.generate_acquire_memoryviewslice(rhs, code) + + elif self.type.is_buffer: + # Generate code for doing the buffer release/acquisition. + # This might raise an exception in which case the assignment (done + # below) will not happen. + # + # The reason this is not in a typetest-like node is because the + # variables that the acquired buffer info is stored to is allocated + # per entry and coupled with it. + self.generate_acquire_buffer(rhs, code) + assigned = False + if self.type.is_pyobject: + #print "NameNode.generate_assignment_code: to", self.name ### + #print "...from", rhs ### + #print "...LHS type", self.type, "ctype", self.ctype() ### + #print "...RHS type", rhs.type, "ctype", rhs.ctype() ### + if self.use_managed_ref: + rhs.make_owned_reference(code) + is_external_ref = entry.is_cglobal or self.entry.in_closure or self.entry.from_closure + if is_external_ref: + if not self.cf_is_null: + if self.cf_maybe_null: + code.put_xgotref(self.py_result()) + else: + code.put_gotref(self.py_result()) + assigned = True + if entry.is_cglobal: + code.put_decref_set( + self.result(), rhs.result_as(self.ctype())) + else: + if not self.cf_is_null: + if self.cf_maybe_null: + code.put_xdecref_set( + self.result(), rhs.result_as(self.ctype())) + else: + code.put_decref_set( + self.result(), rhs.result_as(self.ctype())) + else: + assigned = False + if is_external_ref: + code.put_giveref(rhs.py_result()) + if not self.type.is_memoryviewslice: + if not assigned: + if overloaded_assignment: + result = rhs.result() + if exception_check == '+': + translate_cpp_exception( + code, self.pos, + '%s = %s;' % (self.result(), result), + self.result() if self.type.is_pyobject else None, + exception_value, self.in_nogil_context) + else: + code.putln('%s = %s;' % (self.result(), result)) + else: + result = rhs.result_as(self.ctype()) + + if is_pythran_expr(self.type): + code.putln('new (&%s) decltype(%s){%s};' % (self.result(), self.result(), result)) + elif result != self.result(): + code.putln('%s = %s;' % (self.result(), result)) + if debug_disposal_code: + print("NameNode.generate_assignment_code:") + print("...generating post-assignment code for %s" % rhs) + rhs.generate_post_assignment_code(code) + elif rhs.result_in_temp(): + rhs.generate_post_assignment_code(code) + + rhs.free_temps(code) + + def generate_acquire_memoryviewslice(self, rhs, code): + """ + Slices, coercions from objects, return values etc are new references. + We have a borrowed reference in case of dst = src + """ + from . import MemoryView + + MemoryView.put_acquire_memoryviewslice( + lhs_cname=self.result(), + lhs_type=self.type, + lhs_pos=self.pos, + rhs=rhs, + code=code, + have_gil=not self.in_nogil_context, + first_assignment=self.cf_is_null) + + def generate_acquire_buffer(self, rhs, code): + # rhstmp is only used in case the rhs is a complicated expression leading to + # the object, to avoid repeating the same C expression for every reference + # to the rhs. It does NOT hold a reference. + pretty_rhs = isinstance(rhs, NameNode) or rhs.is_temp + if pretty_rhs: + rhstmp = rhs.result_as(self.ctype()) + else: + rhstmp = code.funcstate.allocate_temp(self.entry.type, manage_ref=False) + code.putln('%s = %s;' % (rhstmp, rhs.result_as(self.ctype()))) + + from . import Buffer + Buffer.put_assign_to_buffer(self.result(), rhstmp, self.entry, + is_initialized=not self.lhs_of_first_assignment, + pos=self.pos, code=code) + + if not pretty_rhs: + code.putln("%s = 0;" % rhstmp) + code.funcstate.release_temp(rhstmp) + + def generate_deletion_code(self, code, ignore_nonexisting=False): + if self.entry is None: + return # There was an error earlier + elif self.entry.is_pyclass_attr: + namespace = self.entry.scope.namespace_cname + interned_cname = code.intern_identifier(self.entry.name) + if ignore_nonexisting: + key_error_code = 'PyErr_Clear(); else' + else: + # minor hack: fake a NameError on KeyError + key_error_code = ( + '{ PyErr_Clear(); PyErr_Format(PyExc_NameError, "name \'%%s\' is not defined", "%s"); }' % + self.entry.name) + code.putln( + 'if (unlikely(PyObject_DelItem(%s, %s) < 0)) {' + ' if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) %s' + ' %s ' + '}' % (namespace, interned_cname, + key_error_code, + code.error_goto(self.pos))) + elif self.entry.is_pyglobal: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectSetAttrStr", "ObjectHandling.c")) + interned_cname = code.intern_identifier(self.entry.name) + del_code = '__Pyx_PyObject_DelAttrStr(%s, %s)' % ( + Naming.module_cname, interned_cname) + if ignore_nonexisting: + code.putln( + 'if (unlikely(%s < 0)) {' + ' if (likely(PyErr_ExceptionMatches(PyExc_AttributeError))) PyErr_Clear(); else %s ' + '}' % (del_code, code.error_goto(self.pos))) + else: + code.put_error_if_neg(self.pos, del_code) + elif self.entry.type.is_pyobject or self.entry.type.is_memoryviewslice: + if not self.cf_is_null: + if self.cf_maybe_null and not ignore_nonexisting: + code.put_error_if_unbound(self.pos, self.entry) + + if self.entry.type.is_pyobject: + if self.entry.in_closure: + # generator + if ignore_nonexisting and self.cf_maybe_null: + code.put_xgotref(self.result()) + else: + code.put_gotref(self.result()) + if ignore_nonexisting and self.cf_maybe_null: + code.put_xdecref(self.result(), self.ctype()) + else: + code.put_decref(self.result(), self.ctype()) + code.putln('%s = NULL;' % self.result()) + else: + code.put_xdecref_memoryviewslice(self.entry.cname, + have_gil=not self.nogil) + else: + error(self.pos, "Deletion of C names not supported") + + def annotate(self, code): + if hasattr(self, 'is_called') and self.is_called: + pos = (self.pos[0], self.pos[1], self.pos[2] - len(self.name) - 1) + if self.type.is_pyobject: + style, text = 'py_call', 'python function (%s)' + else: + style, text = 'c_call', 'c function (%s)' + code.annotate(pos, AnnotationItem(style, text % self.type, size=len(self.name))) + +class BackquoteNode(ExprNode): + # `expr` + # + # arg ExprNode + + type = py_object_type + + subexprs = ['arg'] + + def analyse_types(self, env): + self.arg = self.arg.analyse_types(env) + self.arg = self.arg.coerce_to_pyobject(env) + self.is_temp = 1 + return self + + gil_message = "Backquote expression" + + def calculate_constant_result(self): + self.constant_result = repr(self.arg.constant_result) + + def generate_result_code(self, code): + code.putln( + "%s = PyObject_Repr(%s); %s" % ( + self.result(), + self.arg.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class ImportNode(ExprNode): + # Used as part of import statement implementation. + # Implements result = + # __import__(module_name, globals(), None, name_list, level) + # + # module_name StringNode dotted name of module. Empty module + # name means importing the parent package according + # to level + # name_list ListNode or None list of names to be imported + # level int relative import level: + # -1: attempt both relative import and absolute import; + # 0: absolute import; + # >0: the number of parent directories to search + # relative to the current module. + # None: decide the level according to language level and + # directives + + type = py_object_type + + subexprs = ['module_name', 'name_list'] + + def analyse_types(self, env): + if self.level is None: + if (env.directives['py2_import'] or + Future.absolute_import not in env.global_scope().context.future_directives): + self.level = -1 + else: + self.level = 0 + module_name = self.module_name.analyse_types(env) + self.module_name = module_name.coerce_to_pyobject(env) + if self.name_list: + name_list = self.name_list.analyse_types(env) + self.name_list = name_list.coerce_to_pyobject(env) + self.is_temp = 1 + return self + + gil_message = "Python import" + + def generate_result_code(self, code): + if self.name_list: + name_list_code = self.name_list.py_result() + else: + name_list_code = "0" + + code.globalstate.use_utility_code(UtilityCode.load_cached("Import", "ImportExport.c")) + import_code = "__Pyx_Import(%s, %s, %d)" % ( + self.module_name.py_result(), + name_list_code, + self.level) + + if (self.level <= 0 and + self.module_name.is_string_literal and + self.module_name.value in utility_code_for_imports): + helper_func, code_name, code_file = utility_code_for_imports[self.module_name.value] + code.globalstate.use_utility_code(UtilityCode.load_cached(code_name, code_file)) + import_code = '%s(%s)' % (helper_func, import_code) + + code.putln("%s = %s; %s" % ( + self.result(), + import_code, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class IteratorNode(ExprNode): + # Used as part of for statement implementation. + # + # Implements result = iter(sequence) + # + # sequence ExprNode + + type = py_object_type + iter_func_ptr = None + counter_cname = None + cpp_iterator_cname = None + reversed = False # currently only used for list/tuple types (see Optimize.py) + is_async = False + + subexprs = ['sequence'] + + def analyse_types(self, env): + self.sequence = self.sequence.analyse_types(env) + if (self.sequence.type.is_array or self.sequence.type.is_ptr) and \ + not self.sequence.type.is_string: + # C array iteration will be transformed later on + self.type = self.sequence.type + elif self.sequence.type.is_cpp_class: + self.analyse_cpp_types(env) + else: + self.sequence = self.sequence.coerce_to_pyobject(env) + if self.sequence.type in (list_type, tuple_type): + self.sequence = self.sequence.as_none_safe_node("'NoneType' object is not iterable") + self.is_temp = 1 + return self + + gil_message = "Iterating over Python object" + + _func_iternext_type = PyrexTypes.CPtrType(PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None), + ])) + + def type_dependencies(self, env): + return self.sequence.type_dependencies(env) + + def infer_type(self, env): + sequence_type = self.sequence.infer_type(env) + if sequence_type.is_array or sequence_type.is_ptr: + return sequence_type + elif sequence_type.is_cpp_class: + begin = sequence_type.scope.lookup("begin") + if begin is not None: + return begin.type.return_type + elif sequence_type.is_pyobject: + return sequence_type + return py_object_type + + def analyse_cpp_types(self, env): + sequence_type = self.sequence.type + if sequence_type.is_ptr: + sequence_type = sequence_type.base_type + begin = sequence_type.scope.lookup("begin") + end = sequence_type.scope.lookup("end") + if (begin is None + or not begin.type.is_cfunction + or begin.type.args): + error(self.pos, "missing begin() on %s" % self.sequence.type) + self.type = error_type + return + if (end is None + or not end.type.is_cfunction + or end.type.args): + error(self.pos, "missing end() on %s" % self.sequence.type) + self.type = error_type + return + iter_type = begin.type.return_type + if iter_type.is_cpp_class: + if env.lookup_operator_for_types( + self.pos, + "!=", + [iter_type, end.type.return_type]) is None: + error(self.pos, "missing operator!= on result of begin() on %s" % self.sequence.type) + self.type = error_type + return + if env.lookup_operator_for_types(self.pos, '++', [iter_type]) is None: + error(self.pos, "missing operator++ on result of begin() on %s" % self.sequence.type) + self.type = error_type + return + if env.lookup_operator_for_types(self.pos, '*', [iter_type]) is None: + error(self.pos, "missing operator* on result of begin() on %s" % self.sequence.type) + self.type = error_type + return + self.type = iter_type + elif iter_type.is_ptr: + if not (iter_type == end.type.return_type): + error(self.pos, "incompatible types for begin() and end()") + self.type = iter_type + else: + error(self.pos, "result type of begin() on %s must be a C++ class or pointer" % self.sequence.type) + self.type = error_type + return + + def generate_result_code(self, code): + sequence_type = self.sequence.type + if sequence_type.is_cpp_class: + if self.sequence.is_name: + # safe: C++ won't allow you to reassign to class references + begin_func = "%s.begin" % self.sequence.result() + else: + sequence_type = PyrexTypes.c_ptr_type(sequence_type) + self.cpp_iterator_cname = code.funcstate.allocate_temp(sequence_type, manage_ref=False) + code.putln("%s = &%s;" % (self.cpp_iterator_cname, self.sequence.result())) + begin_func = "%s->begin" % self.cpp_iterator_cname + # TODO: Limit scope. + code.putln("%s = %s();" % (self.result(), begin_func)) + return + if sequence_type.is_array or sequence_type.is_ptr: + raise InternalError("for in carray slice not transformed") + + is_builtin_sequence = sequence_type in (list_type, tuple_type) + if not is_builtin_sequence: + # reversed() not currently optimised (see Optimize.py) + assert not self.reversed, "internal error: reversed() only implemented for list/tuple objects" + self.may_be_a_sequence = not sequence_type.is_builtin_type + if self.may_be_a_sequence: + code.putln( + "if (likely(PyList_CheckExact(%s)) || PyTuple_CheckExact(%s)) {" % ( + self.sequence.py_result(), + self.sequence.py_result())) + + if is_builtin_sequence or self.may_be_a_sequence: + self.counter_cname = code.funcstate.allocate_temp( + PyrexTypes.c_py_ssize_t_type, manage_ref=False) + if self.reversed: + if sequence_type is list_type: + init_value = 'PyList_GET_SIZE(%s) - 1' % self.result() + else: + init_value = 'PyTuple_GET_SIZE(%s) - 1' % self.result() + else: + init_value = '0' + code.putln("%s = %s; __Pyx_INCREF(%s); %s = %s;" % ( + self.result(), + self.sequence.py_result(), + self.result(), + self.counter_cname, + init_value)) + if not is_builtin_sequence: + self.iter_func_ptr = code.funcstate.allocate_temp(self._func_iternext_type, manage_ref=False) + if self.may_be_a_sequence: + code.putln("%s = NULL;" % self.iter_func_ptr) + code.putln("} else {") + code.put("%s = -1; " % self.counter_cname) + + code.putln("%s = PyObject_GetIter(%s); %s" % ( + self.result(), + self.sequence.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + # PyObject_GetIter() fails if "tp_iternext" is not set, but the check below + # makes it visible to the C compiler that the pointer really isn't NULL, so that + # it can distinguish between the special cases and the generic case + code.putln("%s = Py_TYPE(%s)->tp_iternext; %s" % ( + self.iter_func_ptr, self.py_result(), + code.error_goto_if_null(self.iter_func_ptr, self.pos))) + if self.may_be_a_sequence: + code.putln("}") + + def generate_next_sequence_item(self, test_name, result_name, code): + assert self.counter_cname, "internal error: counter_cname temp not prepared" + final_size = 'Py%s_GET_SIZE(%s)' % (test_name, self.py_result()) + if self.sequence.is_sequence_constructor: + item_count = len(self.sequence.args) + if self.sequence.mult_factor is None: + final_size = item_count + elif isinstance(self.sequence.mult_factor.constant_result, _py_int_types): + final_size = item_count * self.sequence.mult_factor.constant_result + code.putln("if (%s >= %s) break;" % (self.counter_cname, final_size)) + if self.reversed: + inc_dec = '--' + else: + inc_dec = '++' + code.putln("#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS") + code.putln( + "%s = Py%s_GET_ITEM(%s, %s); __Pyx_INCREF(%s); %s%s; %s" % ( + result_name, + test_name, + self.py_result(), + self.counter_cname, + result_name, + self.counter_cname, + inc_dec, + # use the error label to avoid C compiler warnings if we only use it below + code.error_goto_if_neg('0', self.pos) + )) + code.putln("#else") + code.putln( + "%s = PySequence_ITEM(%s, %s); %s%s; %s" % ( + result_name, + self.py_result(), + self.counter_cname, + self.counter_cname, + inc_dec, + code.error_goto_if_null(result_name, self.pos))) + code.put_gotref(result_name) + code.putln("#endif") + + def generate_iter_next_result_code(self, result_name, code): + sequence_type = self.sequence.type + if self.reversed: + code.putln("if (%s < 0) break;" % self.counter_cname) + if sequence_type.is_cpp_class: + if self.cpp_iterator_cname: + end_func = "%s->end" % self.cpp_iterator_cname + else: + end_func = "%s.end" % self.sequence.result() + # TODO: Cache end() call? + code.putln("if (!(%s != %s())) break;" % ( + self.result(), + end_func)) + code.putln("%s = *%s;" % ( + result_name, + self.result())) + code.putln("++%s;" % self.result()) + return + elif sequence_type is list_type: + self.generate_next_sequence_item('List', result_name, code) + return + elif sequence_type is tuple_type: + self.generate_next_sequence_item('Tuple', result_name, code) + return + + if self.may_be_a_sequence: + code.putln("if (likely(!%s)) {" % self.iter_func_ptr) + code.putln("if (likely(PyList_CheckExact(%s))) {" % self.py_result()) + self.generate_next_sequence_item('List', result_name, code) + code.putln("} else {") + self.generate_next_sequence_item('Tuple', result_name, code) + code.putln("}") + code.put("} else ") + + code.putln("{") + code.putln( + "%s = %s(%s);" % ( + result_name, + self.iter_func_ptr, + self.py_result())) + code.putln("if (unlikely(!%s)) {" % result_name) + code.putln("PyObject* exc_type = PyErr_Occurred();") + code.putln("if (exc_type) {") + code.putln("if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();") + code.putln("else %s" % code.error_goto(self.pos)) + code.putln("}") + code.putln("break;") + code.putln("}") + code.put_gotref(result_name) + code.putln("}") + + def free_temps(self, code): + if self.counter_cname: + code.funcstate.release_temp(self.counter_cname) + if self.iter_func_ptr: + code.funcstate.release_temp(self.iter_func_ptr) + self.iter_func_ptr = None + if self.cpp_iterator_cname: + code.funcstate.release_temp(self.cpp_iterator_cname) + ExprNode.free_temps(self, code) + + +class NextNode(AtomicExprNode): + # Used as part of for statement implementation. + # Implements result = next(iterator) + # Created during analyse_types phase. + # The iterator is not owned by this node. + # + # iterator IteratorNode + + def __init__(self, iterator): + AtomicExprNode.__init__(self, iterator.pos) + self.iterator = iterator + + def nogil_check(self, env): + # ignore - errors (if any) are already handled by IteratorNode + pass + + def type_dependencies(self, env): + return self.iterator.type_dependencies(env) + + def infer_type(self, env, iterator_type=None): + if iterator_type is None: + iterator_type = self.iterator.infer_type(env) + if iterator_type.is_ptr or iterator_type.is_array: + return iterator_type.base_type + elif self.iterator.sequence.type is bytearray_type: + # This is a temporary work-around to fix bytearray iteration in 0.29.x + # It has been fixed properly in master, refer to ticket: 3473 + return py_object_type + elif iterator_type.is_cpp_class: + item_type = env.lookup_operator_for_types(self.pos, "*", [iterator_type]).type.return_type + if item_type.is_reference: + item_type = item_type.ref_base_type + if item_type.is_const: + item_type = item_type.const_base_type + return item_type + else: + # Avoid duplication of complicated logic. + fake_index_node = IndexNode( + self.pos, + base=self.iterator.sequence, + index=IntNode(self.pos, value='PY_SSIZE_T_MAX', + type=PyrexTypes.c_py_ssize_t_type)) + return fake_index_node.infer_type(env) + + def analyse_types(self, env): + self.type = self.infer_type(env, self.iterator.type) + self.is_temp = 1 + return self + + def generate_result_code(self, code): + self.iterator.generate_iter_next_result_code(self.result(), code) + + +class AsyncIteratorNode(ExprNode): + # Used as part of 'async for' statement implementation. + # + # Implements result = sequence.__aiter__() + # + # sequence ExprNode + + subexprs = ['sequence'] + + is_async = True + type = py_object_type + is_temp = 1 + + def infer_type(self, env): + return py_object_type + + def analyse_types(self, env): + self.sequence = self.sequence.analyse_types(env) + if not self.sequence.type.is_pyobject: + error(self.pos, "async for loops not allowed on C/C++ types") + self.sequence = self.sequence.coerce_to_pyobject(env) + return self + + def generate_result_code(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("AsyncIter", "Coroutine.c")) + code.putln("%s = __Pyx_Coroutine_GetAsyncIter(%s); %s" % ( + self.result(), + self.sequence.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.result()) + + +class AsyncNextNode(AtomicExprNode): + # Used as part of 'async for' statement implementation. + # Implements result = iterator.__anext__() + # Created during analyse_types phase. + # The iterator is not owned by this node. + # + # iterator IteratorNode + + type = py_object_type + is_temp = 1 + + def __init__(self, iterator): + AtomicExprNode.__init__(self, iterator.pos) + self.iterator = iterator + + def infer_type(self, env): + return py_object_type + + def analyse_types(self, env): + return self + + def generate_result_code(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("AsyncIter", "Coroutine.c")) + code.putln("%s = __Pyx_Coroutine_AsyncIterNext(%s); %s" % ( + self.result(), + self.iterator.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.result()) + + +class WithExitCallNode(ExprNode): + # The __exit__() call of a 'with' statement. Used in both the + # except and finally clauses. + + # with_stat WithStatNode the surrounding 'with' statement + # args TupleNode or ResultStatNode the exception info tuple + # await_expr AwaitExprNode the await expression of an 'async with' statement + + subexprs = ['args', 'await_expr'] + test_if_run = True + await_expr = None + + def analyse_types(self, env): + self.args = self.args.analyse_types(env) + if self.await_expr: + self.await_expr = self.await_expr.analyse_types(env) + self.type = PyrexTypes.c_bint_type + self.is_temp = True + return self + + def generate_evaluation_code(self, code): + if self.test_if_run: + # call only if it was not already called (and decref-cleared) + code.putln("if (%s) {" % self.with_stat.exit_var) + + self.args.generate_evaluation_code(code) + result_var = code.funcstate.allocate_temp(py_object_type, manage_ref=False) + + code.mark_pos(self.pos) + code.globalstate.use_utility_code(UtilityCode.load_cached( + "PyObjectCall", "ObjectHandling.c")) + code.putln("%s = __Pyx_PyObject_Call(%s, %s, NULL);" % ( + result_var, + self.with_stat.exit_var, + self.args.result())) + code.put_decref_clear(self.with_stat.exit_var, type=py_object_type) + self.args.generate_disposal_code(code) + self.args.free_temps(code) + + code.putln(code.error_goto_if_null(result_var, self.pos)) + code.put_gotref(result_var) + + if self.await_expr: + # FIXME: result_var temp currently leaks into the closure + self.await_expr.generate_evaluation_code(code, source_cname=result_var, decref_source=True) + code.putln("%s = %s;" % (result_var, self.await_expr.py_result())) + self.await_expr.generate_post_assignment_code(code) + self.await_expr.free_temps(code) + + if self.result_is_used: + self.allocate_temp_result(code) + code.putln("%s = __Pyx_PyObject_IsTrue(%s);" % (self.result(), result_var)) + code.put_decref_clear(result_var, type=py_object_type) + if self.result_is_used: + code.put_error_if_neg(self.pos, self.result()) + code.funcstate.release_temp(result_var) + if self.test_if_run: + code.putln("}") + + +class ExcValueNode(AtomicExprNode): + # Node created during analyse_types phase + # of an ExceptClauseNode to fetch the current + # exception value. + + type = py_object_type + + def __init__(self, pos): + ExprNode.__init__(self, pos) + + def set_var(self, var): + self.var = var + + def calculate_result_code(self): + return self.var + + def generate_result_code(self, code): + pass + + def analyse_types(self, env): + return self + + +class TempNode(ExprNode): + # Node created during analyse_types phase + # of some nodes to hold a temporary value. + # + # Note: One must call "allocate" and "release" on + # the node during code generation to get/release the temp. + # This is because the temp result is often used outside of + # the regular cycle. + + subexprs = [] + + def __init__(self, pos, type, env=None): + ExprNode.__init__(self, pos) + self.type = type + if type.is_pyobject: + self.result_ctype = py_object_type + self.is_temp = 1 + + def analyse_types(self, env): + return self + + def analyse_target_declaration(self, env): + pass + + def generate_result_code(self, code): + pass + + def allocate(self, code): + self.temp_cname = code.funcstate.allocate_temp(self.type, manage_ref=True) + + def release(self, code): + code.funcstate.release_temp(self.temp_cname) + self.temp_cname = None + + def result(self): + try: + return self.temp_cname + except: + assert False, "Remember to call allocate/release on TempNode" + raise + + # Do not participate in normal temp alloc/dealloc: + def allocate_temp_result(self, code): + pass + + def release_temp_result(self, code): + pass + +class PyTempNode(TempNode): + # TempNode holding a Python value. + + def __init__(self, pos, env): + TempNode.__init__(self, pos, PyrexTypes.py_object_type, env) + +class RawCNameExprNode(ExprNode): + subexprs = [] + + def __init__(self, pos, type=None, cname=None): + ExprNode.__init__(self, pos, type=type) + if cname is not None: + self.cname = cname + + def analyse_types(self, env): + return self + + def set_cname(self, cname): + self.cname = cname + + def result(self): + return self.cname + + def generate_result_code(self, code): + pass + + +#------------------------------------------------------------------- +# +# F-strings +# +#------------------------------------------------------------------- + + +class JoinedStrNode(ExprNode): + # F-strings + # + # values [UnicodeNode|FormattedValueNode] Substrings of the f-string + # + type = unicode_type + is_temp = True + + subexprs = ['values'] + + def analyse_types(self, env): + self.values = [v.analyse_types(env).coerce_to_pyobject(env) for v in self.values] + return self + + def may_be_none(self): + # PyUnicode_Join() always returns a Unicode string or raises an exception + return False + + def generate_evaluation_code(self, code): + code.mark_pos(self.pos) + num_items = len(self.values) + list_var = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + ulength_var = code.funcstate.allocate_temp(PyrexTypes.c_py_ssize_t_type, manage_ref=False) + max_char_var = code.funcstate.allocate_temp(PyrexTypes.c_py_ucs4_type, manage_ref=False) + + code.putln('%s = PyTuple_New(%s); %s' % ( + list_var, + num_items, + code.error_goto_if_null(list_var, self.pos))) + code.put_gotref(list_var) + code.putln("%s = 0;" % ulength_var) + code.putln("%s = 127;" % max_char_var) # at least ASCII character range + + for i, node in enumerate(self.values): + node.generate_evaluation_code(code) + node.make_owned_reference(code) + + ulength = "__Pyx_PyUnicode_GET_LENGTH(%s)" % node.py_result() + max_char_value = "__Pyx_PyUnicode_MAX_CHAR_VALUE(%s)" % node.py_result() + is_ascii = False + if isinstance(node, UnicodeNode): + try: + # most strings will be ASCII or at least Latin-1 + node.value.encode('iso8859-1') + max_char_value = '255' + node.value.encode('us-ascii') + is_ascii = True + except UnicodeEncodeError: + if max_char_value != '255': + # not ISO8859-1 => check BMP limit + max_char = max(map(ord, node.value)) + if max_char < 0xD800: + # BMP-only, no surrogate pairs used + max_char_value = '65535' + ulength = str(len(node.value)) + elif max_char >= 65536: + # cleary outside of BMP, and not on a 16-bit Unicode system + max_char_value = '1114111' + ulength = str(len(node.value)) + else: + # not really worth implementing a check for surrogate pairs here + # drawback: C code can differ when generating on Py2 with 2-byte Unicode + pass + else: + ulength = str(len(node.value)) + elif isinstance(node, FormattedValueNode) and node.value.type.is_numeric: + is_ascii = True # formatted C numbers are always ASCII + + if not is_ascii: + code.putln("%s = (%s > %s) ? %s : %s;" % ( + max_char_var, max_char_value, max_char_var, max_char_value, max_char_var)) + code.putln("%s += %s;" % (ulength_var, ulength)) + + code.put_giveref(node.py_result()) + code.putln('PyTuple_SET_ITEM(%s, %s, %s);' % (list_var, i, node.py_result())) + node.generate_post_assignment_code(code) + node.free_temps(code) + + code.mark_pos(self.pos) + self.allocate_temp_result(code) + code.globalstate.use_utility_code(UtilityCode.load_cached("JoinPyUnicode", "StringTools.c")) + code.putln('%s = __Pyx_PyUnicode_Join(%s, %d, %s, %s); %s' % ( + self.result(), + list_var, + num_items, + ulength_var, + max_char_var, + code.error_goto_if_null(self.py_result(), self.pos))) + code.put_gotref(self.py_result()) + + code.put_decref_clear(list_var, py_object_type) + code.funcstate.release_temp(list_var) + code.funcstate.release_temp(ulength_var) + code.funcstate.release_temp(max_char_var) + + +class FormattedValueNode(ExprNode): + # {}-delimited portions of an f-string + # + # value ExprNode The expression itself + # conversion_char str or None Type conversion (!s, !r, !a, or none, or 'd' for integer conversion) + # format_spec JoinedStrNode or None Format string passed to __format__ + # c_format_spec str or None If not None, formatting can be done at the C level + + subexprs = ['value', 'format_spec'] + + type = unicode_type + is_temp = True + c_format_spec = None + + find_conversion_func = { + 's': 'PyObject_Unicode', + 'r': 'PyObject_Repr', + 'a': 'PyObject_ASCII', # NOTE: mapped to PyObject_Repr() in Py2 + 'd': '__Pyx_PyNumber_IntOrLong', # NOTE: internal mapping for '%d' formatting + }.get + + def may_be_none(self): + # PyObject_Format() always returns a Unicode string or raises an exception + return False + + def analyse_types(self, env): + self.value = self.value.analyse_types(env) + if not self.format_spec or self.format_spec.is_string_literal: + c_format_spec = self.format_spec.value if self.format_spec else self.value.type.default_format_spec + if self.value.type.can_coerce_to_pystring(env, format_spec=c_format_spec): + self.c_format_spec = c_format_spec + + if self.format_spec: + self.format_spec = self.format_spec.analyse_types(env).coerce_to_pyobject(env) + if self.c_format_spec is None: + self.value = self.value.coerce_to_pyobject(env) + if not self.format_spec and (not self.conversion_char or self.conversion_char == 's'): + if self.value.type is unicode_type and not self.value.may_be_none(): + # value is definitely a unicode string and we don't format it any special + return self.value + return self + + def generate_result_code(self, code): + if self.c_format_spec is not None and not self.value.type.is_pyobject: + convert_func_call = self.value.type.convert_to_pystring( + self.value.result(), code, self.c_format_spec) + code.putln("%s = %s; %s" % ( + self.result(), + convert_func_call, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + return + + value_result = self.value.py_result() + value_is_unicode = self.value.type is unicode_type and not self.value.may_be_none() + if self.format_spec: + format_func = '__Pyx_PyObject_Format' + format_spec = self.format_spec.py_result() + else: + # common case: expect simple Unicode pass-through if no format spec + format_func = '__Pyx_PyObject_FormatSimple' + # passing a Unicode format string in Py2 forces PyObject_Format() to also return a Unicode string + format_spec = Naming.empty_unicode + + conversion_char = self.conversion_char + if conversion_char == 's' and value_is_unicode: + # no need to pipe unicode strings through str() + conversion_char = None + + if conversion_char: + fn = self.find_conversion_func(conversion_char) + assert fn is not None, "invalid conversion character found: '%s'" % conversion_char + value_result = '%s(%s)' % (fn, value_result) + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectFormatAndDecref", "StringTools.c")) + format_func += 'AndDecref' + elif self.format_spec: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectFormat", "StringTools.c")) + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectFormatSimple", "StringTools.c")) + + code.putln("%s = %s(%s, %s); %s" % ( + self.result(), + format_func, + value_result, + format_spec, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +#------------------------------------------------------------------- +# +# Parallel nodes (cython.parallel.thread(savailable|id)) +# +#------------------------------------------------------------------- + +class ParallelThreadsAvailableNode(AtomicExprNode): + """ + Note: this is disabled and not a valid directive at this moment + + Implements cython.parallel.threadsavailable(). If we are called from the + sequential part of the application, we need to call omp_get_max_threads(), + and in the parallel part we can just call omp_get_num_threads() + """ + + type = PyrexTypes.c_int_type + + def analyse_types(self, env): + self.is_temp = True + # env.add_include_file("omp.h") + return self + + def generate_result_code(self, code): + code.putln("#ifdef _OPENMP") + code.putln("if (omp_in_parallel()) %s = omp_get_max_threads();" % + self.temp_code) + code.putln("else %s = omp_get_num_threads();" % self.temp_code) + code.putln("#else") + code.putln("%s = 1;" % self.temp_code) + code.putln("#endif") + + def result(self): + return self.temp_code + + +class ParallelThreadIdNode(AtomicExprNode): #, Nodes.ParallelNode): + """ + Implements cython.parallel.threadid() + """ + + type = PyrexTypes.c_int_type + + def analyse_types(self, env): + self.is_temp = True + # env.add_include_file("omp.h") + return self + + def generate_result_code(self, code): + code.putln("#ifdef _OPENMP") + code.putln("%s = omp_get_thread_num();" % self.temp_code) + code.putln("#else") + code.putln("%s = 0;" % self.temp_code) + code.putln("#endif") + + def result(self): + return self.temp_code + + +#------------------------------------------------------------------- +# +# Trailer nodes +# +#------------------------------------------------------------------- + + +class _IndexingBaseNode(ExprNode): + # Base class for indexing nodes. + # + # base ExprNode the value being indexed + + def is_ephemeral(self): + # in most cases, indexing will return a safe reference to an object in a container, + # so we consider the result safe if the base object is + return self.base.is_ephemeral() or self.base.type in ( + basestring_type, str_type, bytes_type, bytearray_type, unicode_type) + + def check_const_addr(self): + return self.base.check_const_addr() and self.index.check_const() + + def is_lvalue(self): + # NOTE: references currently have both is_reference and is_ptr + # set. Since pointers and references have different lvalue + # rules, we must be careful to separate the two. + if self.type.is_reference: + if self.type.ref_base_type.is_array: + # fixed-sized arrays aren't l-values + return False + elif self.type.is_ptr: + # non-const pointers can always be reassigned + return True + # Just about everything else returned by the index operator + # can be an lvalue. + return True + + +class IndexNode(_IndexingBaseNode): + # Sequence indexing. + # + # base ExprNode + # index ExprNode + # type_indices [PyrexType] + # + # is_fused_index boolean Whether the index is used to specialize a + # c(p)def function + + subexprs = ['base', 'index'] + type_indices = None + + is_subscript = True + is_fused_index = False + + def calculate_constant_result(self): + self.constant_result = self.base.constant_result[self.index.constant_result] + + def compile_time_value(self, denv): + base = self.base.compile_time_value(denv) + index = self.index.compile_time_value(denv) + try: + return base[index] + except Exception as e: + self.compile_time_value_error(e) + + def is_simple(self): + base = self.base + return (base.is_simple() and self.index.is_simple() + and base.type and (base.type.is_ptr or base.type.is_array)) + + def may_be_none(self): + base_type = self.base.type + if base_type: + if base_type.is_string: + return False + if isinstance(self.index, SliceNode): + # slicing! + if base_type in (bytes_type, bytearray_type, str_type, unicode_type, + basestring_type, list_type, tuple_type): + return False + return ExprNode.may_be_none(self) + + def analyse_target_declaration(self, env): + pass + + def analyse_as_type(self, env): + base_type = self.base.analyse_as_type(env) + if base_type and not base_type.is_pyobject: + if base_type.is_cpp_class: + if isinstance(self.index, TupleNode): + template_values = self.index.args + else: + template_values = [self.index] + type_node = Nodes.TemplatedTypeNode( + pos=self.pos, + positional_args=template_values, + keyword_args=None) + return type_node.analyse(env, base_type=base_type) + elif self.index.is_slice or self.index.is_sequence_constructor: + # memory view + from . import MemoryView + env.use_utility_code(MemoryView.view_utility_code) + axes = [self.index] if self.index.is_slice else list(self.index.args) + return PyrexTypes.MemoryViewSliceType(base_type, MemoryView.get_axes_specs(env, axes)) + else: + # C array + index = self.index.compile_time_value(env) + if index is not None: + try: + index = int(index) + except (ValueError, TypeError): + pass + else: + return PyrexTypes.CArrayType(base_type, index) + error(self.pos, "Array size must be a compile time constant") + return None + + def type_dependencies(self, env): + return self.base.type_dependencies(env) + self.index.type_dependencies(env) + + def infer_type(self, env): + base_type = self.base.infer_type(env) + if self.index.is_slice: + # slicing! + if base_type.is_string: + # sliced C strings must coerce to Python + return bytes_type + elif base_type.is_pyunicode_ptr: + # sliced Py_UNICODE* strings must coerce to Python + return unicode_type + elif base_type in (unicode_type, bytes_type, str_type, + bytearray_type, list_type, tuple_type): + # slicing these returns the same type + return base_type + else: + # TODO: Handle buffers (hopefully without too much redundancy). + return py_object_type + + index_type = self.index.infer_type(env) + if index_type and index_type.is_int or isinstance(self.index, IntNode): + # indexing! + if base_type is unicode_type: + # Py_UCS4 will automatically coerce to a unicode string + # if required, so this is safe. We only infer Py_UCS4 + # when the index is a C integer type. Otherwise, we may + # need to use normal Python item access, in which case + # it's faster to return the one-char unicode string than + # to receive it, throw it away, and potentially rebuild it + # on a subsequent PyObject coercion. + return PyrexTypes.c_py_ucs4_type + elif base_type is str_type: + # always returns str - Py2: bytes, Py3: unicode + return base_type + elif base_type is bytearray_type: + return PyrexTypes.c_uchar_type + elif isinstance(self.base, BytesNode): + #if env.global_scope().context.language_level >= 3: + # # inferring 'char' can be made to work in Python 3 mode + # return PyrexTypes.c_char_type + # Py2/3 return different types on indexing bytes objects + return py_object_type + elif base_type in (tuple_type, list_type): + # if base is a literal, take a look at its values + item_type = infer_sequence_item_type( + env, self.base, self.index, seq_type=base_type) + if item_type is not None: + return item_type + elif base_type.is_ptr or base_type.is_array: + return base_type.base_type + elif base_type.is_ctuple and isinstance(self.index, IntNode): + if self.index.has_constant_result(): + index = self.index.constant_result + if index < 0: + index += base_type.size + if 0 <= index < base_type.size: + return base_type.components[index] + + if base_type.is_cpp_class: + class FakeOperand: + def __init__(self, **kwds): + self.__dict__.update(kwds) + operands = [ + FakeOperand(pos=self.pos, type=base_type), + FakeOperand(pos=self.pos, type=index_type), + ] + index_func = env.lookup_operator('[]', operands) + if index_func is not None: + return index_func.type.return_type + + if is_pythran_expr(base_type) and is_pythran_expr(index_type): + index_with_type = (self.index, index_type) + return PythranExpr(pythran_indexing_type(base_type, [index_with_type])) + + # may be slicing or indexing, we don't know + if base_type in (unicode_type, str_type): + # these types always returns their own type on Python indexing/slicing + return base_type + else: + # TODO: Handle buffers (hopefully without too much redundancy). + return py_object_type + + def analyse_types(self, env): + return self.analyse_base_and_index_types(env, getting=True) + + def analyse_target_types(self, env): + node = self.analyse_base_and_index_types(env, setting=True) + if node.type.is_const: + error(self.pos, "Assignment to const dereference") + if node is self and not node.is_lvalue(): + error(self.pos, "Assignment to non-lvalue of type '%s'" % node.type) + return node + + def analyse_base_and_index_types(self, env, getting=False, setting=False, + analyse_base=True): + # Note: This might be cleaned up by having IndexNode + # parsed in a saner way and only construct the tuple if + # needed. + if analyse_base: + self.base = self.base.analyse_types(env) + + if self.base.type.is_error: + # Do not visit child tree if base is undeclared to avoid confusing + # error messages + self.type = PyrexTypes.error_type + return self + + is_slice = self.index.is_slice + if not env.directives['wraparound']: + if is_slice: + check_negative_indices(self.index.start, self.index.stop) + else: + check_negative_indices(self.index) + + # Potentially overflowing index value. + if not is_slice and isinstance(self.index, IntNode) and Utils.long_literal(self.index.value): + self.index = self.index.coerce_to_pyobject(env) + + is_memslice = self.base.type.is_memoryviewslice + # Handle the case where base is a literal char* (and we expect a string, not an int) + if not is_memslice and (isinstance(self.base, BytesNode) or is_slice): + if self.base.type.is_string or not (self.base.type.is_ptr or self.base.type.is_array): + self.base = self.base.coerce_to_pyobject(env) + + replacement_node = self.analyse_as_buffer_operation(env, getting) + if replacement_node is not None: + return replacement_node + + self.nogil = env.nogil + base_type = self.base.type + + if not base_type.is_cfunction: + self.index = self.index.analyse_types(env) + self.original_index_type = self.index.type + + if base_type.is_unicode_char: + # we infer Py_UNICODE/Py_UCS4 for unicode strings in some + # cases, but indexing must still work for them + if setting: + warning(self.pos, "cannot assign to Unicode string index", level=1) + elif self.index.constant_result in (0, -1): + # uchar[0] => uchar + return self.base + self.base = self.base.coerce_to_pyobject(env) + base_type = self.base.type + + if base_type.is_pyobject: + return self.analyse_as_pyobject(env, is_slice, getting, setting) + elif base_type.is_ptr or base_type.is_array: + return self.analyse_as_c_array(env, is_slice) + elif base_type.is_cpp_class: + return self.analyse_as_cpp(env, setting) + elif base_type.is_cfunction: + return self.analyse_as_c_function(env) + elif base_type.is_ctuple: + return self.analyse_as_c_tuple(env, getting, setting) + else: + error(self.pos, + "Attempting to index non-array type '%s'" % + base_type) + self.type = PyrexTypes.error_type + return self + + def analyse_as_pyobject(self, env, is_slice, getting, setting): + base_type = self.base.type + if self.index.type.is_unicode_char and base_type is not dict_type: + # TODO: eventually fold into case below and remove warning, once people have adapted their code + warning(self.pos, + "Item lookup of unicode character codes now always converts to a Unicode string. " + "Use an explicit C integer cast to get back the previous integer lookup behaviour.", level=1) + self.index = self.index.coerce_to_pyobject(env) + self.is_temp = 1 + elif self.index.type.is_int and base_type is not dict_type: + if (getting + and (base_type in (list_type, tuple_type, bytearray_type)) + and (not self.index.type.signed + or not env.directives['wraparound'] + or (isinstance(self.index, IntNode) and + self.index.has_constant_result() and self.index.constant_result >= 0)) + and not env.directives['boundscheck']): + self.is_temp = 0 + else: + self.is_temp = 1 + self.index = self.index.coerce_to(PyrexTypes.c_py_ssize_t_type, env).coerce_to_simple(env) + self.original_index_type.create_to_py_utility_code(env) + else: + self.index = self.index.coerce_to_pyobject(env) + self.is_temp = 1 + + if self.index.type.is_int and base_type is unicode_type: + # Py_UNICODE/Py_UCS4 will automatically coerce to a unicode string + # if required, so this is fast and safe + self.type = PyrexTypes.c_py_ucs4_type + elif self.index.type.is_int and base_type is bytearray_type: + if setting: + self.type = PyrexTypes.c_uchar_type + else: + # not using 'uchar' to enable fast and safe error reporting as '-1' + self.type = PyrexTypes.c_int_type + elif is_slice and base_type in (bytes_type, bytearray_type, str_type, unicode_type, list_type, tuple_type): + self.type = base_type + else: + item_type = None + if base_type in (list_type, tuple_type) and self.index.type.is_int: + item_type = infer_sequence_item_type( + env, self.base, self.index, seq_type=base_type) + if item_type is None: + item_type = py_object_type + self.type = item_type + if base_type in (list_type, tuple_type, dict_type): + # do the None check explicitly (not in a helper) to allow optimising it away + self.base = self.base.as_none_safe_node("'NoneType' object is not subscriptable") + + self.wrap_in_nonecheck_node(env, getting) + return self + + def analyse_as_c_array(self, env, is_slice): + base_type = self.base.type + self.type = base_type.base_type + if is_slice: + self.type = base_type + elif self.index.type.is_pyobject: + self.index = self.index.coerce_to(PyrexTypes.c_py_ssize_t_type, env) + elif not self.index.type.is_int: + error(self.pos, "Invalid index type '%s'" % self.index.type) + return self + + def analyse_as_cpp(self, env, setting): + base_type = self.base.type + function = env.lookup_operator("[]", [self.base, self.index]) + if function is None: + error(self.pos, "Indexing '%s' not supported for index type '%s'" % (base_type, self.index.type)) + self.type = PyrexTypes.error_type + self.result_code = "<error>" + return self + func_type = function.type + if func_type.is_ptr: + func_type = func_type.base_type + self.exception_check = func_type.exception_check + self.exception_value = func_type.exception_value + if self.exception_check: + if not setting: + self.is_temp = True + if self.exception_value is None: + env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp")) + self.index = self.index.coerce_to(func_type.args[0].type, env) + self.type = func_type.return_type + if setting and not func_type.return_type.is_reference: + error(self.pos, "Can't set non-reference result '%s'" % self.type) + return self + + def analyse_as_c_function(self, env): + base_type = self.base.type + if base_type.is_fused: + self.parse_indexed_fused_cdef(env) + else: + self.type_indices = self.parse_index_as_types(env) + self.index = None # FIXME: use a dedicated Node class instead of generic IndexNode + if base_type.templates is None: + error(self.pos, "Can only parameterize template functions.") + self.type = error_type + elif self.type_indices is None: + # Error recorded earlier. + self.type = error_type + elif len(base_type.templates) != len(self.type_indices): + error(self.pos, "Wrong number of template arguments: expected %s, got %s" % ( + (len(base_type.templates), len(self.type_indices)))) + self.type = error_type + else: + self.type = base_type.specialize(dict(zip(base_type.templates, self.type_indices))) + # FIXME: use a dedicated Node class instead of generic IndexNode + return self + + def analyse_as_c_tuple(self, env, getting, setting): + base_type = self.base.type + if isinstance(self.index, IntNode) and self.index.has_constant_result(): + index = self.index.constant_result + if -base_type.size <= index < base_type.size: + if index < 0: + index += base_type.size + self.type = base_type.components[index] + else: + error(self.pos, + "Index %s out of bounds for '%s'" % + (index, base_type)) + self.type = PyrexTypes.error_type + return self + else: + self.base = self.base.coerce_to_pyobject(env) + return self.analyse_base_and_index_types(env, getting=getting, setting=setting, analyse_base=False) + + def analyse_as_buffer_operation(self, env, getting): + """ + Analyse buffer indexing and memoryview indexing/slicing + """ + if isinstance(self.index, TupleNode): + indices = self.index.args + else: + indices = [self.index] + + base = self.base + base_type = base.type + replacement_node = None + if base_type.is_memoryviewslice: + # memoryviewslice indexing or slicing + from . import MemoryView + if base.is_memview_slice: + # For memory views, "view[i][j]" is the same as "view[i, j]" => use the latter for speed. + merged_indices = base.merged_indices(indices) + if merged_indices is not None: + base = base.base + base_type = base.type + indices = merged_indices + have_slices, indices, newaxes = MemoryView.unellipsify(indices, base_type.ndim) + if have_slices: + replacement_node = MemoryViewSliceNode(self.pos, indices=indices, base=base) + else: + replacement_node = MemoryViewIndexNode(self.pos, indices=indices, base=base) + elif base_type.is_buffer or base_type.is_pythran_expr: + if base_type.is_pythran_expr or len(indices) == base_type.ndim: + # Buffer indexing + is_buffer_access = True + indices = [index.analyse_types(env) for index in indices] + if base_type.is_pythran_expr: + do_replacement = all( + index.type.is_int or index.is_slice or index.type.is_pythran_expr + for index in indices) + if do_replacement: + for i,index in enumerate(indices): + if index.is_slice: + index = SliceIntNode(index.pos, start=index.start, stop=index.stop, step=index.step) + index = index.analyse_types(env) + indices[i] = index + else: + do_replacement = all(index.type.is_int for index in indices) + if do_replacement: + replacement_node = BufferIndexNode(self.pos, indices=indices, base=base) + # On cloning, indices is cloned. Otherwise, unpack index into indices. + assert not isinstance(self.index, CloneNode) + + if replacement_node is not None: + replacement_node = replacement_node.analyse_types(env, getting) + return replacement_node + + def wrap_in_nonecheck_node(self, env, getting): + if not env.directives['nonecheck'] or not self.base.may_be_none(): + return + self.base = self.base.as_none_safe_node("'NoneType' object is not subscriptable") + + def parse_index_as_types(self, env, required=True): + if isinstance(self.index, TupleNode): + indices = self.index.args + else: + indices = [self.index] + type_indices = [] + for index in indices: + type_indices.append(index.analyse_as_type(env)) + if type_indices[-1] is None: + if required: + error(index.pos, "not parsable as a type") + return None + return type_indices + + def parse_indexed_fused_cdef(self, env): + """ + Interpret fused_cdef_func[specific_type1, ...] + + Note that if this method is called, we are an indexed cdef function + with fused argument types, and this IndexNode will be replaced by the + NameNode with specific entry just after analysis of expressions by + AnalyseExpressionsTransform. + """ + self.type = PyrexTypes.error_type + + self.is_fused_index = True + + base_type = self.base.type + positions = [] + + if self.index.is_name or self.index.is_attribute: + positions.append(self.index.pos) + elif isinstance(self.index, TupleNode): + for arg in self.index.args: + positions.append(arg.pos) + specific_types = self.parse_index_as_types(env, required=False) + + if specific_types is None: + self.index = self.index.analyse_types(env) + + if not self.base.entry.as_variable: + error(self.pos, "Can only index fused functions with types") + else: + # A cpdef function indexed with Python objects + self.base.entry = self.entry = self.base.entry.as_variable + self.base.type = self.type = self.entry.type + + self.base.is_temp = True + self.is_temp = True + + self.entry.used = True + + self.is_fused_index = False + return + + for i, type in enumerate(specific_types): + specific_types[i] = type.specialize_fused(env) + + fused_types = base_type.get_fused_types() + if len(specific_types) > len(fused_types): + return error(self.pos, "Too many types specified") + elif len(specific_types) < len(fused_types): + t = fused_types[len(specific_types)] + return error(self.pos, "Not enough types specified to specialize " + "the function, %s is still fused" % t) + + # See if our index types form valid specializations + for pos, specific_type, fused_type in zip(positions, + specific_types, + fused_types): + if not any([specific_type.same_as(t) for t in fused_type.types]): + return error(pos, "Type not in fused type") + + if specific_type is None or specific_type.is_error: + return + + fused_to_specific = dict(zip(fused_types, specific_types)) + type = base_type.specialize(fused_to_specific) + + if type.is_fused: + # Only partially specific, this is invalid + error(self.pos, + "Index operation makes function only partially specific") + else: + # Fully specific, find the signature with the specialized entry + for signature in self.base.type.get_all_specialized_function_types(): + if type.same_as(signature): + self.type = signature + + if self.base.is_attribute: + # Pretend to be a normal attribute, for cdef extension + # methods + self.entry = signature.entry + self.is_attribute = True + self.obj = self.base.obj + + self.type.entry.used = True + self.base.type = signature + self.base.entry = signature.entry + + break + else: + # This is a bug + raise InternalError("Couldn't find the right signature") + + gil_message = "Indexing Python object" + + def calculate_result_code(self): + if self.base.type in (list_type, tuple_type, bytearray_type): + if self.base.type is list_type: + index_code = "PyList_GET_ITEM(%s, %s)" + elif self.base.type is tuple_type: + index_code = "PyTuple_GET_ITEM(%s, %s)" + elif self.base.type is bytearray_type: + index_code = "((unsigned char)(PyByteArray_AS_STRING(%s)[%s]))" + else: + assert False, "unexpected base type in indexing: %s" % self.base.type + elif self.base.type.is_cfunction: + return "%s<%s>" % ( + self.base.result(), + ",".join([param.empty_declaration_code() for param in self.type_indices])) + elif self.base.type.is_ctuple: + index = self.index.constant_result + if index < 0: + index += self.base.type.size + return "%s.f%s" % (self.base.result(), index) + else: + if (self.type.is_ptr or self.type.is_array) and self.type == self.base.type: + error(self.pos, "Invalid use of pointer slice") + return + index_code = "(%s[%s])" + return index_code % (self.base.result(), self.index.result()) + + def extra_index_params(self, code): + if self.index.type.is_int: + is_list = self.base.type is list_type + wraparound = ( + bool(code.globalstate.directives['wraparound']) and + self.original_index_type.signed and + not (isinstance(self.index.constant_result, _py_int_types) + and self.index.constant_result >= 0)) + boundscheck = bool(code.globalstate.directives['boundscheck']) + return ", %s, %d, %s, %d, %d, %d" % ( + self.original_index_type.empty_declaration_code(), + self.original_index_type.signed and 1 or 0, + self.original_index_type.to_py_function, + is_list, wraparound, boundscheck) + else: + return "" + + def generate_result_code(self, code): + if not self.is_temp: + # all handled in self.calculate_result_code() + return + + utility_code = None + if self.type.is_pyobject: + error_value = 'NULL' + if self.index.type.is_int: + if self.base.type is list_type: + function = "__Pyx_GetItemInt_List" + elif self.base.type is tuple_type: + function = "__Pyx_GetItemInt_Tuple" + else: + function = "__Pyx_GetItemInt" + utility_code = TempitaUtilityCode.load_cached("GetItemInt", "ObjectHandling.c") + else: + if self.base.type is dict_type: + function = "__Pyx_PyDict_GetItem" + utility_code = UtilityCode.load_cached("DictGetItem", "ObjectHandling.c") + elif self.base.type is py_object_type and self.index.type in (str_type, unicode_type): + # obj[str] is probably doing a dict lookup + function = "__Pyx_PyObject_Dict_GetItem" + utility_code = UtilityCode.load_cached("DictGetItem", "ObjectHandling.c") + else: + function = "__Pyx_PyObject_GetItem" + code.globalstate.use_utility_code( + TempitaUtilityCode.load_cached("GetItemInt", "ObjectHandling.c")) + utility_code = UtilityCode.load_cached("ObjectGetItem", "ObjectHandling.c") + elif self.type.is_unicode_char and self.base.type is unicode_type: + assert self.index.type.is_int + function = "__Pyx_GetItemInt_Unicode" + error_value = '(Py_UCS4)-1' + utility_code = UtilityCode.load_cached("GetItemIntUnicode", "StringTools.c") + elif self.base.type is bytearray_type: + assert self.index.type.is_int + assert self.type.is_int + function = "__Pyx_GetItemInt_ByteArray" + error_value = '-1' + utility_code = UtilityCode.load_cached("GetItemIntByteArray", "StringTools.c") + elif not (self.base.type.is_cpp_class and self.exception_check): + assert False, "unexpected type %s and base type %s for indexing" % ( + self.type, self.base.type) + + if utility_code is not None: + code.globalstate.use_utility_code(utility_code) + + if self.index.type.is_int: + index_code = self.index.result() + else: + index_code = self.index.py_result() + + if self.base.type.is_cpp_class and self.exception_check: + translate_cpp_exception(code, self.pos, + "%s = %s[%s];" % (self.result(), self.base.result(), + self.index.result()), + self.result() if self.type.is_pyobject else None, + self.exception_value, self.in_nogil_context) + else: + error_check = '!%s' if error_value == 'NULL' else '%%s == %s' % error_value + code.putln( + "%s = %s(%s, %s%s); %s" % ( + self.result(), + function, + self.base.py_result(), + index_code, + self.extra_index_params(code), + code.error_goto_if(error_check % self.result(), self.pos))) + if self.type.is_pyobject: + code.put_gotref(self.py_result()) + + def generate_setitem_code(self, value_code, code): + if self.index.type.is_int: + if self.base.type is bytearray_type: + code.globalstate.use_utility_code( + UtilityCode.load_cached("SetItemIntByteArray", "StringTools.c")) + function = "__Pyx_SetItemInt_ByteArray" + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("SetItemInt", "ObjectHandling.c")) + function = "__Pyx_SetItemInt" + index_code = self.index.result() + else: + index_code = self.index.py_result() + if self.base.type is dict_type: + function = "PyDict_SetItem" + # It would seem that we could specialized lists/tuples, but that + # shouldn't happen here. + # Both PyList_SetItem() and PyTuple_SetItem() take a Py_ssize_t as + # index instead of an object, and bad conversion here would give + # the wrong exception. Also, tuples are supposed to be immutable, + # and raise a TypeError when trying to set their entries + # (PyTuple_SetItem() is for creating new tuples from scratch). + else: + function = "PyObject_SetItem" + code.putln(code.error_goto_if_neg( + "%s(%s, %s, %s%s)" % ( + function, + self.base.py_result(), + index_code, + value_code, + self.extra_index_params(code)), + self.pos)) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False, + exception_check=None, exception_value=None): + self.generate_subexpr_evaluation_code(code) + + if self.type.is_pyobject: + self.generate_setitem_code(rhs.py_result(), code) + elif self.base.type is bytearray_type: + value_code = self._check_byte_value(code, rhs) + self.generate_setitem_code(value_code, code) + elif self.base.type.is_cpp_class and self.exception_check and self.exception_check == '+': + if overloaded_assignment and exception_check and \ + self.exception_value != exception_value: + # Handle the case that both the index operator and the assignment + # operator have a c++ exception handler and they are not the same. + translate_double_cpp_exception(code, self.pos, self.type, + self.result(), rhs.result(), self.exception_value, + exception_value, self.in_nogil_context) + else: + # Handle the case that only the index operator has a + # c++ exception handler, or that + # both exception handlers are the same. + translate_cpp_exception(code, self.pos, + "%s = %s;" % (self.result(), rhs.result()), + self.result() if self.type.is_pyobject else None, + self.exception_value, self.in_nogil_context) + else: + code.putln( + "%s = %s;" % (self.result(), rhs.result())) + + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + + def _check_byte_value(self, code, rhs): + # TODO: should we do this generally on downcasts, or just here? + assert rhs.type.is_int, repr(rhs.type) + value_code = rhs.result() + if rhs.has_constant_result(): + if 0 <= rhs.constant_result < 256: + return value_code + needs_cast = True # make at least the C compiler happy + warning(rhs.pos, + "value outside of range(0, 256)" + " when assigning to byte: %s" % rhs.constant_result, + level=1) + else: + needs_cast = rhs.type != PyrexTypes.c_uchar_type + + if not self.nogil: + conditions = [] + if rhs.is_literal or rhs.type.signed: + conditions.append('%s < 0' % value_code) + if (rhs.is_literal or not + (rhs.is_temp and rhs.type in ( + PyrexTypes.c_uchar_type, PyrexTypes.c_char_type, + PyrexTypes.c_schar_type))): + conditions.append('%s > 255' % value_code) + if conditions: + code.putln("if (unlikely(%s)) {" % ' || '.join(conditions)) + code.putln( + 'PyErr_SetString(PyExc_ValueError,' + ' "byte must be in range(0, 256)"); %s' % + code.error_goto(self.pos)) + code.putln("}") + + if needs_cast: + value_code = '((unsigned char)%s)' % value_code + return value_code + + def generate_deletion_code(self, code, ignore_nonexisting=False): + self.generate_subexpr_evaluation_code(code) + #if self.type.is_pyobject: + if self.index.type.is_int: + function = "__Pyx_DelItemInt" + index_code = self.index.result() + code.globalstate.use_utility_code( + UtilityCode.load_cached("DelItemInt", "ObjectHandling.c")) + else: + index_code = self.index.py_result() + if self.base.type is dict_type: + function = "PyDict_DelItem" + else: + function = "PyObject_DelItem" + code.putln(code.error_goto_if_neg( + "%s(%s, %s%s)" % ( + function, + self.base.py_result(), + index_code, + self.extra_index_params(code)), + self.pos)) + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + + +class BufferIndexNode(_IndexingBaseNode): + """ + Indexing of buffers and memoryviews. This node is created during type + analysis from IndexNode and replaces it. + + Attributes: + base - base node being indexed + indices - list of indexing expressions + """ + + subexprs = ['base', 'indices'] + + is_buffer_access = True + + # Whether we're assigning to a buffer (in that case it needs to be writable) + writable_needed = False + + # Any indexing temp variables that we need to clean up. + index_temps = () + + def analyse_target_types(self, env): + self.analyse_types(env, getting=False) + + def analyse_types(self, env, getting=True): + """ + Analyse types for buffer indexing only. Overridden by memoryview + indexing and slicing subclasses + """ + # self.indices are already analyzed + if not self.base.is_name and not is_pythran_expr(self.base.type): + error(self.pos, "Can only index buffer variables") + self.type = error_type + return self + + if not getting: + if not self.base.entry.type.writable: + error(self.pos, "Writing to readonly buffer") + else: + self.writable_needed = True + if self.base.type.is_buffer: + self.base.entry.buffer_aux.writable_needed = True + + self.none_error_message = "'NoneType' object is not subscriptable" + self.analyse_buffer_index(env, getting) + self.wrap_in_nonecheck_node(env) + return self + + def analyse_buffer_index(self, env, getting): + if is_pythran_expr(self.base.type): + index_with_type_list = [(idx, idx.type) for idx in self.indices] + self.type = PythranExpr(pythran_indexing_type(self.base.type, index_with_type_list)) + else: + self.base = self.base.coerce_to_simple(env) + self.type = self.base.type.dtype + self.buffer_type = self.base.type + + if getting and (self.type.is_pyobject or self.type.is_pythran_expr): + self.is_temp = True + + def analyse_assignment(self, rhs): + """ + Called by IndexNode when this node is assigned to, + with the rhs of the assignment + """ + + def wrap_in_nonecheck_node(self, env): + if not env.directives['nonecheck'] or not self.base.may_be_none(): + return + self.base = self.base.as_none_safe_node(self.none_error_message) + + def nogil_check(self, env): + if self.is_buffer_access or self.is_memview_index: + if self.type.is_pyobject: + error(self.pos, "Cannot access buffer with object dtype without gil") + self.type = error_type + + def calculate_result_code(self): + return "(*%s)" % self.buffer_ptr_code + + def buffer_entry(self): + base = self.base + if self.base.is_nonecheck: + base = base.arg + return base.type.get_entry(base) + + def get_index_in_temp(self, code, ivar): + ret = code.funcstate.allocate_temp( + PyrexTypes.widest_numeric_type( + ivar.type, + PyrexTypes.c_ssize_t_type if ivar.type.signed else PyrexTypes.c_size_t_type), + manage_ref=False) + code.putln("%s = %s;" % (ret, ivar.result())) + return ret + + def buffer_lookup_code(self, code): + """ + ndarray[1, 2, 3] and memslice[1, 2, 3] + """ + if self.in_nogil_context: + if self.is_buffer_access or self.is_memview_index: + if code.globalstate.directives['boundscheck']: + warning(self.pos, "Use boundscheck(False) for faster access", level=1) + + # Assign indices to temps of at least (s)size_t to allow further index calculations. + self.index_temps = index_temps = [self.get_index_in_temp(code,ivar) for ivar in self.indices] + + # Generate buffer access code using these temps + from . import Buffer + buffer_entry = self.buffer_entry() + if buffer_entry.type.is_buffer: + negative_indices = buffer_entry.type.negative_indices + else: + negative_indices = Buffer.buffer_defaults['negative_indices'] + + return buffer_entry, Buffer.put_buffer_lookup_code( + entry=buffer_entry, + index_signeds=[ivar.type.signed for ivar in self.indices], + index_cnames=index_temps, + directives=code.globalstate.directives, + pos=self.pos, code=code, + negative_indices=negative_indices, + in_nogil_context=self.in_nogil_context) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False): + self.generate_subexpr_evaluation_code(code) + self.generate_buffer_setitem_code(rhs, code) + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + + def generate_buffer_setitem_code(self, rhs, code, op=""): + base_type = self.base.type + if is_pythran_expr(base_type) and is_pythran_supported_type(rhs.type): + obj = code.funcstate.allocate_temp(PythranExpr(pythran_type(self.base.type)), manage_ref=False) + # We have got to do this because we have to declare pythran objects + # at the beginning of the functions. + # Indeed, Cython uses "goto" statement for error management, and + # RAII doesn't work with that kind of construction. + # Moreover, the way Pythran expressions are made is that they don't + # support move-assignation easily. + # This, we explicitly destroy then in-place new objects in this + # case. + code.putln("__Pyx_call_destructor(%s);" % obj) + code.putln("new (&%s) decltype(%s){%s};" % (obj, obj, self.base.pythran_result())) + code.putln("%s%s %s= %s;" % ( + obj, + pythran_indexing_code(self.indices), + op, + rhs.pythran_result())) + code.funcstate.release_temp(obj) + return + + # Used from generate_assignment_code and InPlaceAssignmentNode + buffer_entry, ptrexpr = self.buffer_lookup_code(code) + + if self.buffer_type.dtype.is_pyobject: + # Must manage refcounts. XDecref what is already there + # and incref what we put in (NumPy allows there to be NULL) + ptr = code.funcstate.allocate_temp(buffer_entry.buf_ptr_type, + manage_ref=False) + rhs_code = rhs.result() + code.putln("%s = %s;" % (ptr, ptrexpr)) + code.put_xgotref("*%s" % ptr) + code.putln("__Pyx_INCREF(%s); __Pyx_XDECREF(*%s);" % ( + rhs_code, ptr)) + code.putln("*%s %s= %s;" % (ptr, op, rhs_code)) + code.put_xgiveref("*%s" % ptr) + code.funcstate.release_temp(ptr) + else: + # Simple case + code.putln("*%s %s= %s;" % (ptrexpr, op, rhs.result())) + + def generate_result_code(self, code): + if is_pythran_expr(self.base.type): + res = self.result() + code.putln("__Pyx_call_destructor(%s);" % res) + code.putln("new (&%s) decltype(%s){%s%s};" % ( + res, + res, + self.base.pythran_result(), + pythran_indexing_code(self.indices))) + return + buffer_entry, self.buffer_ptr_code = self.buffer_lookup_code(code) + if self.type.is_pyobject: + # is_temp is True, so must pull out value and incref it. + # NOTE: object temporary results for nodes are declared + # as PyObject *, so we need a cast + res = self.result() + code.putln("%s = (PyObject *) *%s;" % (res, self.buffer_ptr_code)) + # NumPy does (occasionally) allow NULL to denote None. + code.putln("if (unlikely(%s == NULL)) %s = Py_None;" % (res, res)) + code.putln("__Pyx_INCREF((PyObject*)%s);" % res) + + def free_subexpr_temps(self, code): + for temp in self.index_temps: + code.funcstate.release_temp(temp) + self.index_temps = () + super(BufferIndexNode, self).free_subexpr_temps(code) + + +class MemoryViewIndexNode(BufferIndexNode): + + is_memview_index = True + is_buffer_access = False + warned_untyped_idx = False + + def analyse_types(self, env, getting=True): + # memoryviewslice indexing or slicing + from . import MemoryView + + self.is_pythran_mode = has_np_pythran(env) + indices = self.indices + have_slices, indices, newaxes = MemoryView.unellipsify(indices, self.base.type.ndim) + + if not getting: + self.writable_needed = True + if self.base.is_name or self.base.is_attribute: + self.base.entry.type.writable_needed = True + + self.memslice_index = (not newaxes and len(indices) == self.base.type.ndim) + axes = [] + + index_type = PyrexTypes.c_py_ssize_t_type + new_indices = [] + + if len(indices) - len(newaxes) > self.base.type.ndim: + self.type = error_type + error(indices[self.base.type.ndim].pos, + "Too many indices specified for type %s" % self.base.type) + return self + + axis_idx = 0 + for i, index in enumerate(indices[:]): + index = index.analyse_types(env) + if index.is_none: + self.is_memview_slice = True + new_indices.append(index) + axes.append(('direct', 'strided')) + continue + + access, packing = self.base.type.axes[axis_idx] + axis_idx += 1 + + if index.is_slice: + self.is_memview_slice = True + if index.step.is_none: + axes.append((access, packing)) + else: + axes.append((access, 'strided')) + + # Coerce start, stop and step to temps of the right type + for attr in ('start', 'stop', 'step'): + value = getattr(index, attr) + if not value.is_none: + value = value.coerce_to(index_type, env) + #value = value.coerce_to_temp(env) + setattr(index, attr, value) + new_indices.append(value) + + elif index.type.is_int or index.type.is_pyobject: + if index.type.is_pyobject and not self.warned_untyped_idx: + warning(index.pos, "Index should be typed for more efficient access", level=2) + MemoryViewIndexNode.warned_untyped_idx = True + + self.is_memview_index = True + index = index.coerce_to(index_type, env) + indices[i] = index + new_indices.append(index) + + else: + self.type = error_type + error(index.pos, "Invalid index for memoryview specified, type %s" % index.type) + return self + + ### FIXME: replace by MemoryViewSliceNode if is_memview_slice ? + self.is_memview_index = self.is_memview_index and not self.is_memview_slice + self.indices = new_indices + # All indices with all start/stop/step for slices. + # We need to keep this around. + self.original_indices = indices + self.nogil = env.nogil + + self.analyse_operation(env, getting, axes) + self.wrap_in_nonecheck_node(env) + return self + + def analyse_operation(self, env, getting, axes): + self.none_error_message = "Cannot index None memoryview slice" + self.analyse_buffer_index(env, getting) + + def analyse_broadcast_operation(self, rhs): + """ + Support broadcasting for slice assignment. + E.g. + m_2d[...] = m_1d # or, + m_1d[...] = m_2d # if the leading dimension has extent 1 + """ + if self.type.is_memoryviewslice: + lhs = self + if lhs.is_memview_broadcast or rhs.is_memview_broadcast: + lhs.is_memview_broadcast = True + rhs.is_memview_broadcast = True + + def analyse_as_memview_scalar_assignment(self, rhs): + lhs = self.analyse_assignment(rhs) + if lhs: + rhs.is_memview_copy_assignment = lhs.is_memview_copy_assignment + return lhs + return self + + +class MemoryViewSliceNode(MemoryViewIndexNode): + + is_memview_slice = True + + # No-op slicing operation, this node will be replaced + is_ellipsis_noop = False + is_memview_scalar_assignment = False + is_memview_index = False + is_memview_broadcast = False + + def analyse_ellipsis_noop(self, env, getting): + """Slicing operations needing no evaluation, i.e. m[...] or m[:, :]""" + ### FIXME: replace directly + self.is_ellipsis_noop = all( + index.is_slice and index.start.is_none and index.stop.is_none and index.step.is_none + for index in self.indices) + + if self.is_ellipsis_noop: + self.type = self.base.type + + def analyse_operation(self, env, getting, axes): + from . import MemoryView + + if not getting: + self.is_memview_broadcast = True + self.none_error_message = "Cannot assign to None memoryview slice" + else: + self.none_error_message = "Cannot slice None memoryview slice" + + self.analyse_ellipsis_noop(env, getting) + if self.is_ellipsis_noop: + return + + self.index = None + self.is_temp = True + self.use_managed_ref = True + + if not MemoryView.validate_axes(self.pos, axes): + self.type = error_type + return + + self.type = PyrexTypes.MemoryViewSliceType(self.base.type.dtype, axes) + + if not (self.base.is_simple() or self.base.result_in_temp()): + self.base = self.base.coerce_to_temp(env) + + def analyse_assignment(self, rhs): + if not rhs.type.is_memoryviewslice and ( + self.type.dtype.assignable_from(rhs.type) or + rhs.type.is_pyobject): + # scalar assignment + return MemoryCopyScalar(self.pos, self) + else: + return MemoryCopySlice(self.pos, self) + + def merged_indices(self, indices): + """Return a new list of indices/slices with 'indices' merged into the current ones + according to slicing rules. + Is used to implement "view[i][j]" => "view[i, j]". + Return None if the indices cannot (easily) be merged at compile time. + """ + if not indices: + return None + # NOTE: Need to evaluate "self.original_indices" here as they might differ from "self.indices". + new_indices = self.original_indices[:] + indices = indices[:] + for i, s in enumerate(self.original_indices): + if s.is_slice: + if s.start.is_none and s.stop.is_none and s.step.is_none: + # Full slice found, replace by index. + new_indices[i] = indices[0] + indices.pop(0) + if not indices: + return new_indices + else: + # Found something non-trivial, e.g. a partial slice. + return None + elif not s.type.is_int: + # Not a slice, not an integer index => could be anything... + return None + if indices: + if len(new_indices) + len(indices) > self.base.type.ndim: + return None + new_indices += indices + return new_indices + + def is_simple(self): + if self.is_ellipsis_noop: + # TODO: fix SimpleCallNode.is_simple() + return self.base.is_simple() or self.base.result_in_temp() + + return self.result_in_temp() + + def calculate_result_code(self): + """This is called in case this is a no-op slicing node""" + return self.base.result() + + def generate_result_code(self, code): + if self.is_ellipsis_noop: + return ### FIXME: remove + buffer_entry = self.buffer_entry() + have_gil = not self.in_nogil_context + + # TODO Mark: this is insane, do it better + have_slices = False + it = iter(self.indices) + for index in self.original_indices: + if index.is_slice: + have_slices = True + if not index.start.is_none: + index.start = next(it) + if not index.stop.is_none: + index.stop = next(it) + if not index.step.is_none: + index.step = next(it) + else: + next(it) + + assert not list(it) + + buffer_entry.generate_buffer_slice_code( + code, self.original_indices, self.result(), + have_gil=have_gil, have_slices=have_slices, + directives=code.globalstate.directives) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False): + if self.is_ellipsis_noop: + self.generate_subexpr_evaluation_code(code) + else: + self.generate_evaluation_code(code) + + if self.is_memview_scalar_assignment: + self.generate_memoryviewslice_assign_scalar_code(rhs, code) + else: + self.generate_memoryviewslice_setslice_code(rhs, code) + + if self.is_ellipsis_noop: + self.generate_subexpr_disposal_code(code) + else: + self.generate_disposal_code(code) + + rhs.generate_disposal_code(code) + rhs.free_temps(code) + + +class MemoryCopyNode(ExprNode): + """ + Wraps a memoryview slice for slice assignment. + + dst: destination mememoryview slice + """ + + subexprs = ['dst'] + + def __init__(self, pos, dst): + super(MemoryCopyNode, self).__init__(pos) + self.dst = dst + self.type = dst.type + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False): + self.dst.generate_evaluation_code(code) + self._generate_assignment_code(rhs, code) + self.dst.generate_disposal_code(code) + self.dst.free_temps(code) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + + +class MemoryCopySlice(MemoryCopyNode): + """ + Copy the contents of slice src to slice dst. Does not support indirect + slices. + + memslice1[...] = memslice2 + memslice1[:] = memslice2 + """ + + is_memview_copy_assignment = True + copy_slice_cname = "__pyx_memoryview_copy_contents" + + def _generate_assignment_code(self, src, code): + dst = self.dst + + src.type.assert_direct_dims(src.pos) + dst.type.assert_direct_dims(dst.pos) + + code.putln(code.error_goto_if_neg( + "%s(%s, %s, %d, %d, %d)" % (self.copy_slice_cname, + src.result(), dst.result(), + src.type.ndim, dst.type.ndim, + dst.type.dtype.is_pyobject), + dst.pos)) + + +class MemoryCopyScalar(MemoryCopyNode): + """ + Assign a scalar to a slice. dst must be simple, scalar will be assigned + to a correct type and not just something assignable. + + memslice1[...] = 0.0 + memslice1[:] = 0.0 + """ + + def __init__(self, pos, dst): + super(MemoryCopyScalar, self).__init__(pos, dst) + self.type = dst.type.dtype + + def _generate_assignment_code(self, scalar, code): + from . import MemoryView + + self.dst.type.assert_direct_dims(self.dst.pos) + + dtype = self.dst.type.dtype + type_decl = dtype.declaration_code("") + slice_decl = self.dst.type.declaration_code("") + + code.begin_block() + code.putln("%s __pyx_temp_scalar = %s;" % (type_decl, scalar.result())) + if self.dst.result_in_temp() or self.dst.is_simple(): + dst_temp = self.dst.result() + else: + code.putln("%s __pyx_temp_slice = %s;" % (slice_decl, self.dst.result())) + dst_temp = "__pyx_temp_slice" + + slice_iter_obj = MemoryView.slice_iter(self.dst.type, dst_temp, + self.dst.type.ndim, code) + p = slice_iter_obj.start_loops() + + if dtype.is_pyobject: + code.putln("Py_DECREF(*(PyObject **) %s);" % p) + + code.putln("*((%s *) %s) = __pyx_temp_scalar;" % (type_decl, p)) + + if dtype.is_pyobject: + code.putln("Py_INCREF(__pyx_temp_scalar);") + + slice_iter_obj.end_loops() + code.end_block() + + +class SliceIndexNode(ExprNode): + # 2-element slice indexing + # + # base ExprNode + # start ExprNode or None + # stop ExprNode or None + # slice ExprNode or None constant slice object + + subexprs = ['base', 'start', 'stop', 'slice'] + + slice = None + + def infer_type(self, env): + base_type = self.base.infer_type(env) + if base_type.is_string or base_type.is_cpp_class: + return bytes_type + elif base_type.is_pyunicode_ptr: + return unicode_type + elif base_type in (bytes_type, bytearray_type, str_type, unicode_type, + basestring_type, list_type, tuple_type): + return base_type + elif base_type.is_ptr or base_type.is_array: + return PyrexTypes.c_array_type(base_type.base_type, None) + return py_object_type + + def inferable_item_node(self, index=0): + # slicing shouldn't change the result type of the base, but the index might + if index is not not_a_constant and self.start: + if self.start.has_constant_result(): + index += self.start.constant_result + else: + index = not_a_constant + return self.base.inferable_item_node(index) + + def may_be_none(self): + base_type = self.base.type + if base_type: + if base_type.is_string: + return False + if base_type in (bytes_type, str_type, unicode_type, + basestring_type, list_type, tuple_type): + return False + return ExprNode.may_be_none(self) + + def calculate_constant_result(self): + if self.start is None: + start = None + else: + start = self.start.constant_result + if self.stop is None: + stop = None + else: + stop = self.stop.constant_result + self.constant_result = self.base.constant_result[start:stop] + + def compile_time_value(self, denv): + base = self.base.compile_time_value(denv) + if self.start is None: + start = 0 + else: + start = self.start.compile_time_value(denv) + if self.stop is None: + stop = None + else: + stop = self.stop.compile_time_value(denv) + try: + return base[start:stop] + except Exception as e: + self.compile_time_value_error(e) + + def analyse_target_declaration(self, env): + pass + + def analyse_target_types(self, env): + node = self.analyse_types(env, getting=False) + # when assigning, we must accept any Python type + if node.type.is_pyobject: + node.type = py_object_type + return node + + def analyse_types(self, env, getting=True): + self.base = self.base.analyse_types(env) + + if self.base.type.is_buffer or self.base.type.is_pythran_expr or self.base.type.is_memoryviewslice: + none_node = NoneNode(self.pos) + index = SliceNode(self.pos, + start=self.start or none_node, + stop=self.stop or none_node, + step=none_node) + index_node = IndexNode(self.pos, index=index, base=self.base) + return index_node.analyse_base_and_index_types( + env, getting=getting, setting=not getting, + analyse_base=False) + + if self.start: + self.start = self.start.analyse_types(env) + if self.stop: + self.stop = self.stop.analyse_types(env) + + if not env.directives['wraparound']: + check_negative_indices(self.start, self.stop) + + base_type = self.base.type + if base_type.is_array and not getting: + # cannot assign directly to C array => try to assign by making a copy + if not self.start and not self.stop: + self.type = base_type + else: + self.type = PyrexTypes.CPtrType(base_type.base_type) + elif base_type.is_string or base_type.is_cpp_string: + self.type = default_str_type(env) + elif base_type.is_pyunicode_ptr: + self.type = unicode_type + elif base_type.is_ptr: + self.type = base_type + elif base_type.is_array: + # we need a ptr type here instead of an array type, as + # array types can result in invalid type casts in the C + # code + self.type = PyrexTypes.CPtrType(base_type.base_type) + else: + self.base = self.base.coerce_to_pyobject(env) + self.type = py_object_type + if base_type.is_builtin_type: + # slicing builtin types returns something of the same type + self.type = base_type + self.base = self.base.as_none_safe_node("'NoneType' object is not subscriptable") + + if self.type is py_object_type: + if (not self.start or self.start.is_literal) and \ + (not self.stop or self.stop.is_literal): + # cache the constant slice object, in case we need it + none_node = NoneNode(self.pos) + self.slice = SliceNode( + self.pos, + start=copy.deepcopy(self.start or none_node), + stop=copy.deepcopy(self.stop or none_node), + step=none_node + ).analyse_types(env) + else: + c_int = PyrexTypes.c_py_ssize_t_type + + def allow_none(node, default_value, env): + # Coerce to Py_ssize_t, but allow None as meaning the default slice bound. + from .UtilNodes import EvalWithTempExprNode, ResultRefNode + + node_ref = ResultRefNode(node) + new_expr = CondExprNode( + node.pos, + true_val=IntNode( + node.pos, + type=c_int, + value=default_value, + constant_result=int(default_value) if default_value.isdigit() else not_a_constant, + ), + false_val=node_ref.coerce_to(c_int, env), + test=PrimaryCmpNode( + node.pos, + operand1=node_ref, + operator='is', + operand2=NoneNode(node.pos), + ).analyse_types(env) + ).analyse_result_type(env) + return EvalWithTempExprNode(node_ref, new_expr) + + if self.start: + if self.start.type.is_pyobject: + self.start = allow_none(self.start, '0', env) + self.start = self.start.coerce_to(c_int, env) + if self.stop: + if self.stop.type.is_pyobject: + self.stop = allow_none(self.stop, 'PY_SSIZE_T_MAX', env) + self.stop = self.stop.coerce_to(c_int, env) + self.is_temp = 1 + return self + + def analyse_as_type(self, env): + base_type = self.base.analyse_as_type(env) + if base_type and not base_type.is_pyobject: + if not self.start and not self.stop: + # memory view + from . import MemoryView + env.use_utility_code(MemoryView.view_utility_code) + none_node = NoneNode(self.pos) + slice_node = SliceNode( + self.pos, + start=none_node, + stop=none_node, + step=none_node, + ) + return PyrexTypes.MemoryViewSliceType( + base_type, MemoryView.get_axes_specs(env, [slice_node])) + return None + + nogil_check = Node.gil_error + gil_message = "Slicing Python object" + + get_slice_utility_code = TempitaUtilityCode.load( + "SliceObject", "ObjectHandling.c", context={'access': 'Get'}) + + set_slice_utility_code = TempitaUtilityCode.load( + "SliceObject", "ObjectHandling.c", context={'access': 'Set'}) + + def coerce_to(self, dst_type, env): + if ((self.base.type.is_string or self.base.type.is_cpp_string) + and dst_type in (bytes_type, bytearray_type, str_type, unicode_type)): + if (dst_type not in (bytes_type, bytearray_type) + and not env.directives['c_string_encoding']): + error(self.pos, + "default encoding required for conversion from '%s' to '%s'" % + (self.base.type, dst_type)) + self.type = dst_type + if dst_type.is_array and self.base.type.is_array: + if not self.start and not self.stop: + # redundant slice building, copy C arrays directly + return self.base.coerce_to(dst_type, env) + # else: check array size if possible + return super(SliceIndexNode, self).coerce_to(dst_type, env) + + def generate_result_code(self, code): + if not self.type.is_pyobject: + error(self.pos, + "Slicing is not currently supported for '%s'." % self.type) + return + + base_result = self.base.result() + result = self.result() + start_code = self.start_code() + stop_code = self.stop_code() + if self.base.type.is_string: + base_result = self.base.result() + if self.base.type not in (PyrexTypes.c_char_ptr_type, PyrexTypes.c_const_char_ptr_type): + base_result = '((const char*)%s)' % base_result + if self.type is bytearray_type: + type_name = 'ByteArray' + else: + type_name = self.type.name.title() + if self.stop is None: + code.putln( + "%s = __Pyx_Py%s_FromString(%s + %s); %s" % ( + result, + type_name, + base_result, + start_code, + code.error_goto_if_null(result, self.pos))) + else: + code.putln( + "%s = __Pyx_Py%s_FromStringAndSize(%s + %s, %s - %s); %s" % ( + result, + type_name, + base_result, + start_code, + stop_code, + start_code, + code.error_goto_if_null(result, self.pos))) + elif self.base.type.is_pyunicode_ptr: + base_result = self.base.result() + if self.base.type != PyrexTypes.c_py_unicode_ptr_type: + base_result = '((const Py_UNICODE*)%s)' % base_result + if self.stop is None: + code.putln( + "%s = __Pyx_PyUnicode_FromUnicode(%s + %s); %s" % ( + result, + base_result, + start_code, + code.error_goto_if_null(result, self.pos))) + else: + code.putln( + "%s = __Pyx_PyUnicode_FromUnicodeAndLength(%s + %s, %s - %s); %s" % ( + result, + base_result, + start_code, + stop_code, + start_code, + code.error_goto_if_null(result, self.pos))) + + elif self.base.type is unicode_type: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyUnicode_Substring", "StringTools.c")) + code.putln( + "%s = __Pyx_PyUnicode_Substring(%s, %s, %s); %s" % ( + result, + base_result, + start_code, + stop_code, + code.error_goto_if_null(result, self.pos))) + elif self.type is py_object_type: + code.globalstate.use_utility_code(self.get_slice_utility_code) + (has_c_start, has_c_stop, c_start, c_stop, + py_start, py_stop, py_slice) = self.get_slice_config() + code.putln( + "%s = __Pyx_PyObject_GetSlice(%s, %s, %s, %s, %s, %s, %d, %d, %d); %s" % ( + result, + self.base.py_result(), + c_start, c_stop, + py_start, py_stop, py_slice, + has_c_start, has_c_stop, + bool(code.globalstate.directives['wraparound']), + code.error_goto_if_null(result, self.pos))) + else: + if self.base.type is list_type: + code.globalstate.use_utility_code( + TempitaUtilityCode.load_cached("SliceTupleAndList", "ObjectHandling.c")) + cfunc = '__Pyx_PyList_GetSlice' + elif self.base.type is tuple_type: + code.globalstate.use_utility_code( + TempitaUtilityCode.load_cached("SliceTupleAndList", "ObjectHandling.c")) + cfunc = '__Pyx_PyTuple_GetSlice' + else: + cfunc = 'PySequence_GetSlice' + code.putln( + "%s = %s(%s, %s, %s); %s" % ( + result, + cfunc, + self.base.py_result(), + start_code, + stop_code, + code.error_goto_if_null(result, self.pos))) + code.put_gotref(self.py_result()) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False, + exception_check=None, exception_value=None): + self.generate_subexpr_evaluation_code(code) + if self.type.is_pyobject: + code.globalstate.use_utility_code(self.set_slice_utility_code) + (has_c_start, has_c_stop, c_start, c_stop, + py_start, py_stop, py_slice) = self.get_slice_config() + code.put_error_if_neg(self.pos, + "__Pyx_PyObject_SetSlice(%s, %s, %s, %s, %s, %s, %s, %d, %d, %d)" % ( + self.base.py_result(), + rhs.py_result(), + c_start, c_stop, + py_start, py_stop, py_slice, + has_c_start, has_c_stop, + bool(code.globalstate.directives['wraparound']))) + else: + start_offset = self.start_code() if self.start else '0' + if rhs.type.is_array: + array_length = rhs.type.size + self.generate_slice_guard_code(code, array_length) + else: + array_length = '%s - %s' % (self.stop_code(), start_offset) + + code.globalstate.use_utility_code(UtilityCode.load_cached("IncludeStringH", "StringTools.c")) + code.putln("memcpy(&(%s[%s]), %s, sizeof(%s[0]) * (%s));" % ( + self.base.result(), start_offset, + rhs.result(), + self.base.result(), array_length + )) + + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + + def generate_deletion_code(self, code, ignore_nonexisting=False): + if not self.base.type.is_pyobject: + error(self.pos, + "Deleting slices is only supported for Python types, not '%s'." % self.type) + return + self.generate_subexpr_evaluation_code(code) + code.globalstate.use_utility_code(self.set_slice_utility_code) + (has_c_start, has_c_stop, c_start, c_stop, + py_start, py_stop, py_slice) = self.get_slice_config() + code.put_error_if_neg(self.pos, + "__Pyx_PyObject_DelSlice(%s, %s, %s, %s, %s, %s, %d, %d, %d)" % ( + self.base.py_result(), + c_start, c_stop, + py_start, py_stop, py_slice, + has_c_start, has_c_stop, + bool(code.globalstate.directives['wraparound']))) + self.generate_subexpr_disposal_code(code) + self.free_subexpr_temps(code) + + def get_slice_config(self): + has_c_start, c_start, py_start = False, '0', 'NULL' + if self.start: + has_c_start = not self.start.type.is_pyobject + if has_c_start: + c_start = self.start.result() + else: + py_start = '&%s' % self.start.py_result() + has_c_stop, c_stop, py_stop = False, '0', 'NULL' + if self.stop: + has_c_stop = not self.stop.type.is_pyobject + if has_c_stop: + c_stop = self.stop.result() + else: + py_stop = '&%s' % self.stop.py_result() + py_slice = self.slice and '&%s' % self.slice.py_result() or 'NULL' + return (has_c_start, has_c_stop, c_start, c_stop, + py_start, py_stop, py_slice) + + def generate_slice_guard_code(self, code, target_size): + if not self.base.type.is_array: + return + slice_size = self.base.type.size + try: + total_length = slice_size = int(slice_size) + except ValueError: + total_length = None + + start = stop = None + if self.stop: + stop = self.stop.result() + try: + stop = int(stop) + if stop < 0: + if total_length is None: + slice_size = '%s + %d' % (slice_size, stop) + else: + slice_size += stop + else: + slice_size = stop + stop = None + except ValueError: + pass + + if self.start: + start = self.start.result() + try: + start = int(start) + if start < 0: + if total_length is None: + start = '%s + %d' % (self.base.type.size, start) + else: + start += total_length + if isinstance(slice_size, _py_int_types): + slice_size -= start + else: + slice_size = '%s - (%s)' % (slice_size, start) + start = None + except ValueError: + pass + + runtime_check = None + compile_time_check = False + try: + int_target_size = int(target_size) + except ValueError: + int_target_size = None + else: + compile_time_check = isinstance(slice_size, _py_int_types) + + if compile_time_check and slice_size < 0: + if int_target_size > 0: + error(self.pos, "Assignment to empty slice.") + elif compile_time_check and start is None and stop is None: + # we know the exact slice length + if int_target_size != slice_size: + error(self.pos, "Assignment to slice of wrong length, expected %s, got %s" % ( + slice_size, target_size)) + elif start is not None: + if stop is None: + stop = slice_size + runtime_check = "(%s)-(%s)" % (stop, start) + elif stop is not None: + runtime_check = stop + else: + runtime_check = slice_size + + if runtime_check: + code.putln("if (unlikely((%s) != (%s))) {" % (runtime_check, target_size)) + code.putln( + 'PyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length,' + ' expected %%" CYTHON_FORMAT_SSIZE_T "d, got %%" CYTHON_FORMAT_SSIZE_T "d",' + ' (Py_ssize_t)(%s), (Py_ssize_t)(%s));' % ( + target_size, runtime_check)) + code.putln(code.error_goto(self.pos)) + code.putln("}") + + def start_code(self): + if self.start: + return self.start.result() + else: + return "0" + + def stop_code(self): + if self.stop: + return self.stop.result() + elif self.base.type.is_array: + return self.base.type.size + else: + return "PY_SSIZE_T_MAX" + + def calculate_result_code(self): + # self.result() is not used, but this method must exist + return "<unused>" + + +class SliceNode(ExprNode): + # start:stop:step in subscript list + # + # start ExprNode + # stop ExprNode + # step ExprNode + + subexprs = ['start', 'stop', 'step'] + is_slice = True + type = slice_type + is_temp = 1 + + def calculate_constant_result(self): + self.constant_result = slice( + self.start.constant_result, + self.stop.constant_result, + self.step.constant_result) + + def compile_time_value(self, denv): + start = self.start.compile_time_value(denv) + stop = self.stop.compile_time_value(denv) + step = self.step.compile_time_value(denv) + try: + return slice(start, stop, step) + except Exception as e: + self.compile_time_value_error(e) + + def may_be_none(self): + return False + + def analyse_types(self, env): + start = self.start.analyse_types(env) + stop = self.stop.analyse_types(env) + step = self.step.analyse_types(env) + self.start = start.coerce_to_pyobject(env) + self.stop = stop.coerce_to_pyobject(env) + self.step = step.coerce_to_pyobject(env) + if self.start.is_literal and self.stop.is_literal and self.step.is_literal: + self.is_literal = True + self.is_temp = False + return self + + gil_message = "Constructing Python slice object" + + def calculate_result_code(self): + return self.result_code + + def generate_result_code(self, code): + if self.is_literal: + dedup_key = make_dedup_key(self.type, (self,)) + self.result_code = code.get_py_const(py_object_type, 'slice', cleanup_level=2, dedup_key=dedup_key) + code = code.get_cached_constants_writer(self.result_code) + if code is None: + return # already initialised + code.mark_pos(self.pos) + + code.putln( + "%s = PySlice_New(%s, %s, %s); %s" % ( + self.result(), + self.start.py_result(), + self.stop.py_result(), + self.step.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + if self.is_literal: + code.put_giveref(self.py_result()) + +class SliceIntNode(SliceNode): + # start:stop:step in subscript list + # This is just a node to hold start,stop and step nodes that can be + # converted to integers. This does not generate a slice python object. + # + # start ExprNode + # stop ExprNode + # step ExprNode + + is_temp = 0 + + def calculate_constant_result(self): + self.constant_result = slice( + self.start.constant_result, + self.stop.constant_result, + self.step.constant_result) + + def compile_time_value(self, denv): + start = self.start.compile_time_value(denv) + stop = self.stop.compile_time_value(denv) + step = self.step.compile_time_value(denv) + try: + return slice(start, stop, step) + except Exception as e: + self.compile_time_value_error(e) + + def may_be_none(self): + return False + + def analyse_types(self, env): + self.start = self.start.analyse_types(env) + self.stop = self.stop.analyse_types(env) + self.step = self.step.analyse_types(env) + + if not self.start.is_none: + self.start = self.start.coerce_to_integer(env) + if not self.stop.is_none: + self.stop = self.stop.coerce_to_integer(env) + if not self.step.is_none: + self.step = self.step.coerce_to_integer(env) + + if self.start.is_literal and self.stop.is_literal and self.step.is_literal: + self.is_literal = True + self.is_temp = False + return self + + def calculate_result_code(self): + pass + + def generate_result_code(self, code): + for a in self.start,self.stop,self.step: + if isinstance(a, CloneNode): + a.arg.result() + + +class CallNode(ExprNode): + + # allow overriding the default 'may_be_none' behaviour + may_return_none = None + + def infer_type(self, env): + # TODO(robertwb): Reduce redundancy with analyse_types. + function = self.function + func_type = function.infer_type(env) + if isinstance(function, NewExprNode): + # note: needs call to infer_type() above + return PyrexTypes.CPtrType(function.class_type) + if func_type is py_object_type: + # function might have lied for safety => try to find better type + entry = getattr(function, 'entry', None) + if entry is not None: + func_type = entry.type or func_type + if func_type.is_ptr: + func_type = func_type.base_type + if func_type.is_cfunction: + if getattr(self.function, 'entry', None) and hasattr(self, 'args'): + alternatives = self.function.entry.all_alternatives() + arg_types = [arg.infer_type(env) for arg in self.args] + func_entry = PyrexTypes.best_match(arg_types, alternatives) + if func_entry: + func_type = func_entry.type + if func_type.is_ptr: + func_type = func_type.base_type + return func_type.return_type + return func_type.return_type + elif func_type is type_type: + if function.is_name and function.entry and function.entry.type: + result_type = function.entry.type + if result_type.is_extension_type: + return result_type + elif result_type.is_builtin_type: + if function.entry.name == 'float': + return PyrexTypes.c_double_type + elif function.entry.name in Builtin.types_that_construct_their_instance: + return result_type + return py_object_type + + def type_dependencies(self, env): + # TODO: Update when Danilo's C++ code merged in to handle the + # the case of function overloading. + return self.function.type_dependencies(env) + + def is_simple(self): + # C function calls could be considered simple, but they may + # have side-effects that may hit when multiple operations must + # be effected in order, e.g. when constructing the argument + # sequence for a function call or comparing values. + return False + + def may_be_none(self): + if self.may_return_none is not None: + return self.may_return_none + func_type = self.function.type + if func_type is type_type and self.function.is_name: + entry = self.function.entry + if entry.type.is_extension_type: + return False + if (entry.type.is_builtin_type and + entry.name in Builtin.types_that_construct_their_instance): + return False + return ExprNode.may_be_none(self) + + def set_py_result_type(self, function, func_type=None): + if func_type is None: + func_type = function.type + if func_type is Builtin.type_type and ( + function.is_name and + function.entry and + function.entry.is_builtin and + function.entry.name in Builtin.types_that_construct_their_instance): + # calling a builtin type that returns a specific object type + if function.entry.name == 'float': + # the following will come true later on in a transform + self.type = PyrexTypes.c_double_type + self.result_ctype = PyrexTypes.c_double_type + else: + self.type = Builtin.builtin_types[function.entry.name] + self.result_ctype = py_object_type + self.may_return_none = False + elif function.is_name and function.type_entry: + # We are calling an extension type constructor. As long as we do not + # support __new__(), the result type is clear + self.type = function.type_entry.type + self.result_ctype = py_object_type + self.may_return_none = False + else: + self.type = py_object_type + + def analyse_as_type_constructor(self, env): + type = self.function.analyse_as_type(env) + if type and type.is_struct_or_union: + args, kwds = self.explicit_args_kwds() + items = [] + for arg, member in zip(args, type.scope.var_entries): + items.append(DictItemNode(pos=arg.pos, key=StringNode(pos=arg.pos, value=member.name), value=arg)) + if kwds: + items += kwds.key_value_pairs + self.key_value_pairs = items + self.__class__ = DictNode + self.analyse_types(env) # FIXME + self.coerce_to(type, env) + return True + elif type and type.is_cpp_class: + self.args = [ arg.analyse_types(env) for arg in self.args ] + constructor = type.scope.lookup("<init>") + if not constructor: + error(self.function.pos, "no constructor found for C++ type '%s'" % self.function.name) + self.type = error_type + return self + self.function = RawCNameExprNode(self.function.pos, constructor.type) + self.function.entry = constructor + self.function.set_cname(type.empty_declaration_code()) + self.analyse_c_function_call(env) + self.type = type + return True + + def is_lvalue(self): + return self.type.is_reference + + def nogil_check(self, env): + func_type = self.function_type() + if func_type.is_pyobject: + self.gil_error() + elif not func_type.is_error and not getattr(func_type, 'nogil', False): + self.gil_error() + + gil_message = "Calling gil-requiring function" + + +class SimpleCallNode(CallNode): + # Function call without keyword, * or ** args. + # + # function ExprNode + # args [ExprNode] + # arg_tuple ExprNode or None used internally + # self ExprNode or None used internally + # coerced_self ExprNode or None used internally + # wrapper_call bool used internally + # has_optional_args bool used internally + # nogil bool used internally + + subexprs = ['self', 'coerced_self', 'function', 'args', 'arg_tuple'] + + self = None + coerced_self = None + arg_tuple = None + wrapper_call = False + has_optional_args = False + nogil = False + analysed = False + overflowcheck = False + + def compile_time_value(self, denv): + function = self.function.compile_time_value(denv) + args = [arg.compile_time_value(denv) for arg in self.args] + try: + return function(*args) + except Exception as e: + self.compile_time_value_error(e) + + def analyse_as_type(self, env): + attr = self.function.as_cython_attribute() + if attr == 'pointer': + if len(self.args) != 1: + error(self.args.pos, "only one type allowed.") + else: + type = self.args[0].analyse_as_type(env) + if not type: + error(self.args[0].pos, "Unknown type") + else: + return PyrexTypes.CPtrType(type) + elif attr == 'typeof': + if len(self.args) != 1: + error(self.args.pos, "only one type allowed.") + operand = self.args[0].analyse_types(env) + return operand.type + + def explicit_args_kwds(self): + return self.args, None + + def analyse_types(self, env): + if self.analyse_as_type_constructor(env): + return self + if self.analysed: + return self + self.analysed = True + self.function.is_called = 1 + self.function = self.function.analyse_types(env) + function = self.function + + if function.is_attribute and function.entry and function.entry.is_cmethod: + # Take ownership of the object from which the attribute + # was obtained, because we need to pass it as 'self'. + self.self = function.obj + function.obj = CloneNode(self.self) + + func_type = self.function_type() + self.is_numpy_call_with_exprs = False + if (has_np_pythran(env) and function.is_numpy_attribute and + pythran_is_numpy_func_supported(function)): + has_pythran_args = True + self.arg_tuple = TupleNode(self.pos, args = self.args) + self.arg_tuple = self.arg_tuple.analyse_types(env) + for arg in self.arg_tuple.args: + has_pythran_args &= is_pythran_supported_node_or_none(arg) + self.is_numpy_call_with_exprs = bool(has_pythran_args) + if self.is_numpy_call_with_exprs: + env.add_include_file(pythran_get_func_include_file(function)) + return NumPyMethodCallNode.from_node( + self, + function_cname=pythran_functor(function), + arg_tuple=self.arg_tuple, + type=PythranExpr(pythran_func_type(function, self.arg_tuple.args)), + ) + elif func_type.is_pyobject: + self.arg_tuple = TupleNode(self.pos, args = self.args) + self.arg_tuple = self.arg_tuple.analyse_types(env).coerce_to_pyobject(env) + self.args = None + self.set_py_result_type(function, func_type) + self.is_temp = 1 + else: + self.args = [ arg.analyse_types(env) for arg in self.args ] + self.analyse_c_function_call(env) + if func_type.exception_check == '+': + self.is_temp = True + return self + + def function_type(self): + # Return the type of the function being called, coercing a function + # pointer to a function if necessary. If the function has fused + # arguments, return the specific type. + func_type = self.function.type + + if func_type.is_ptr: + func_type = func_type.base_type + + return func_type + + def analyse_c_function_call(self, env): + func_type = self.function.type + if func_type is error_type: + self.type = error_type + return + + if func_type.is_cfunction and func_type.is_static_method: + if self.self and self.self.type.is_extension_type: + # To support this we'd need to pass self to determine whether + # it was overloaded in Python space (possibly via a Cython + # superclass turning a cdef method into a cpdef one). + error(self.pos, "Cannot call a static method on an instance variable.") + args = self.args + elif self.self: + args = [self.self] + self.args + else: + args = self.args + + if func_type.is_cpp_class: + overloaded_entry = self.function.type.scope.lookup("operator()") + if overloaded_entry is None: + self.type = PyrexTypes.error_type + self.result_code = "<error>" + return + elif hasattr(self.function, 'entry'): + overloaded_entry = self.function.entry + elif self.function.is_subscript and self.function.is_fused_index: + overloaded_entry = self.function.type.entry + else: + overloaded_entry = None + + if overloaded_entry: + if self.function.type.is_fused: + functypes = self.function.type.get_all_specialized_function_types() + alternatives = [f.entry for f in functypes] + else: + alternatives = overloaded_entry.all_alternatives() + + entry = PyrexTypes.best_match( + [arg.type for arg in args], alternatives, self.pos, env, args) + + if not entry: + self.type = PyrexTypes.error_type + self.result_code = "<error>" + return + + entry.used = True + if not func_type.is_cpp_class: + self.function.entry = entry + self.function.type = entry.type + func_type = self.function_type() + else: + entry = None + func_type = self.function_type() + if not func_type.is_cfunction: + error(self.pos, "Calling non-function type '%s'" % func_type) + self.type = PyrexTypes.error_type + self.result_code = "<error>" + return + + # Check no. of args + max_nargs = len(func_type.args) + expected_nargs = max_nargs - func_type.optional_arg_count + actual_nargs = len(args) + if func_type.optional_arg_count and expected_nargs != actual_nargs: + self.has_optional_args = 1 + self.is_temp = 1 + + # check 'self' argument + if entry and entry.is_cmethod and func_type.args and not func_type.is_static_method: + formal_arg = func_type.args[0] + arg = args[0] + if formal_arg.not_none: + if self.self: + self.self = self.self.as_none_safe_node( + "'NoneType' object has no attribute '%{0}s'".format('.30' if len(entry.name) <= 30 else ''), + error='PyExc_AttributeError', + format_args=[entry.name]) + else: + # unbound method + arg = arg.as_none_safe_node( + "descriptor '%s' requires a '%s' object but received a 'NoneType'", + format_args=[entry.name, formal_arg.type.name]) + if self.self: + if formal_arg.accept_builtin_subtypes: + arg = CMethodSelfCloneNode(self.self) + else: + arg = CloneNode(self.self) + arg = self.coerced_self = arg.coerce_to(formal_arg.type, env) + elif formal_arg.type.is_builtin_type: + # special case: unbound methods of builtins accept subtypes + arg = arg.coerce_to(formal_arg.type, env) + if arg.type.is_builtin_type and isinstance(arg, PyTypeTestNode): + arg.exact_builtin_type = False + args[0] = arg + + # Coerce arguments + some_args_in_temps = False + for i in range(min(max_nargs, actual_nargs)): + formal_arg = func_type.args[i] + formal_type = formal_arg.type + arg = args[i].coerce_to(formal_type, env) + if formal_arg.not_none: + # C methods must do the None checks at *call* time + arg = arg.as_none_safe_node( + "cannot pass None into a C function argument that is declared 'not None'") + if arg.is_temp: + if i > 0: + # first argument in temp doesn't impact subsequent arguments + some_args_in_temps = True + elif arg.type.is_pyobject and not env.nogil: + if i == 0 and self.self is not None: + # a method's cloned "self" argument is ok + pass + elif arg.nonlocally_immutable(): + # plain local variables are ok + pass + else: + # we do not safely own the argument's reference, + # but we must make sure it cannot be collected + # before we return from the function, so we create + # an owned temp reference to it + if i > 0: # first argument doesn't matter + some_args_in_temps = True + arg = arg.coerce_to_temp(env) + args[i] = arg + + # handle additional varargs parameters + for i in range(max_nargs, actual_nargs): + arg = args[i] + if arg.type.is_pyobject: + if arg.type is str_type: + arg_ctype = PyrexTypes.c_char_ptr_type + else: + arg_ctype = arg.type.default_coerced_ctype() + if arg_ctype is None: + error(self.args[i].pos, + "Python object cannot be passed as a varargs parameter") + else: + args[i] = arg = arg.coerce_to(arg_ctype, env) + if arg.is_temp and i > 0: + some_args_in_temps = True + + if some_args_in_temps: + # if some args are temps and others are not, they may get + # constructed in the wrong order (temps first) => make + # sure they are either all temps or all not temps (except + # for the last argument, which is evaluated last in any + # case) + for i in range(actual_nargs-1): + if i == 0 and self.self is not None: + continue # self is ok + arg = args[i] + if arg.nonlocally_immutable(): + # locals, C functions, unassignable types are safe. + pass + elif arg.type.is_cpp_class: + # Assignment has side effects, avoid. + pass + elif env.nogil and arg.type.is_pyobject: + # can't copy a Python reference into a temp in nogil + # env (this is safe: a construction would fail in + # nogil anyway) + pass + else: + #self.args[i] = arg.coerce_to_temp(env) + # instead: issue a warning + if i > 0 or i == 1 and self.self is not None: # skip first arg + warning(arg.pos, "Argument evaluation order in C function call is undefined and may not be as expected", 0) + break + + self.args[:] = args + + # Calc result type and code fragment + if isinstance(self.function, NewExprNode): + self.type = PyrexTypes.CPtrType(self.function.class_type) + else: + self.type = func_type.return_type + + if self.function.is_name or self.function.is_attribute: + func_entry = self.function.entry + if func_entry and (func_entry.utility_code or func_entry.utility_code_definition): + self.is_temp = 1 # currently doesn't work for self.calculate_result_code() + + if self.type.is_pyobject: + self.result_ctype = py_object_type + self.is_temp = 1 + elif func_type.exception_value is not None or func_type.exception_check: + self.is_temp = 1 + elif self.type.is_memoryviewslice: + self.is_temp = 1 + # func_type.exception_check = True + + if self.is_temp and self.type.is_reference: + self.type = PyrexTypes.CFakeReferenceType(self.type.ref_base_type) + + # Called in 'nogil' context? + self.nogil = env.nogil + if (self.nogil and + func_type.exception_check and + func_type.exception_check != '+'): + env.use_utility_code(pyerr_occurred_withgil_utility_code) + # C++ exception handler + if func_type.exception_check == '+': + if func_type.exception_value is None: + env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp")) + + self.overflowcheck = env.directives['overflowcheck'] + + def calculate_result_code(self): + return self.c_call_code() + + def c_call_code(self): + func_type = self.function_type() + if self.type is PyrexTypes.error_type or not func_type.is_cfunction: + return "<error>" + formal_args = func_type.args + arg_list_code = [] + args = list(zip(formal_args, self.args)) + max_nargs = len(func_type.args) + expected_nargs = max_nargs - func_type.optional_arg_count + actual_nargs = len(self.args) + for formal_arg, actual_arg in args[:expected_nargs]: + arg_code = actual_arg.result_as(formal_arg.type) + arg_list_code.append(arg_code) + + if func_type.is_overridable: + arg_list_code.append(str(int(self.wrapper_call or self.function.entry.is_unbound_cmethod))) + + if func_type.optional_arg_count: + if expected_nargs == actual_nargs: + optional_args = 'NULL' + else: + optional_args = "&%s" % self.opt_arg_struct + arg_list_code.append(optional_args) + + for actual_arg in self.args[len(formal_args):]: + arg_list_code.append(actual_arg.result()) + + result = "%s(%s)" % (self.function.result(), ', '.join(arg_list_code)) + return result + + def is_c_result_required(self): + func_type = self.function_type() + if not func_type.exception_value or func_type.exception_check == '+': + return False # skip allocation of unused result temp + return True + + def generate_evaluation_code(self, code): + function = self.function + if function.is_name or function.is_attribute: + code.globalstate.use_entry_utility_code(function.entry) + + abs_function_cnames = ('abs', 'labs', '__Pyx_abs_longlong') + is_signed_int = self.type.is_int and self.type.signed + if self.overflowcheck and is_signed_int and function.result() in abs_function_cnames: + code.globalstate.use_utility_code(UtilityCode.load_cached("Common", "Overflow.c")) + code.putln('if (unlikely(%s == __PYX_MIN(%s))) {\ + PyErr_SetString(PyExc_OverflowError,\ + "Trying to take the absolute value of the most negative integer is not defined."); %s; }' % ( + self.args[0].result(), + self.args[0].type.empty_declaration_code(), + code.error_goto(self.pos))) + + if not function.type.is_pyobject or len(self.arg_tuple.args) > 1 or ( + self.arg_tuple.args and self.arg_tuple.is_literal): + super(SimpleCallNode, self).generate_evaluation_code(code) + return + + # Special case 0-args and try to avoid explicit tuple creation for Python calls with 1 arg. + arg = self.arg_tuple.args[0] if self.arg_tuple.args else None + subexprs = (self.self, self.coerced_self, function, arg) + for subexpr in subexprs: + if subexpr is not None: + subexpr.generate_evaluation_code(code) + + code.mark_pos(self.pos) + assert self.is_temp + self.allocate_temp_result(code) + + if arg is None: + code.globalstate.use_utility_code(UtilityCode.load_cached( + "PyObjectCallNoArg", "ObjectHandling.c")) + code.putln( + "%s = __Pyx_PyObject_CallNoArg(%s); %s" % ( + self.result(), + function.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + else: + code.globalstate.use_utility_code(UtilityCode.load_cached( + "PyObjectCallOneArg", "ObjectHandling.c")) + code.putln( + "%s = __Pyx_PyObject_CallOneArg(%s, %s); %s" % ( + self.result(), + function.py_result(), + arg.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + + code.put_gotref(self.py_result()) + + for subexpr in subexprs: + if subexpr is not None: + subexpr.generate_disposal_code(code) + subexpr.free_temps(code) + + def generate_result_code(self, code): + func_type = self.function_type() + if func_type.is_pyobject: + arg_code = self.arg_tuple.py_result() + code.globalstate.use_utility_code(UtilityCode.load_cached( + "PyObjectCall", "ObjectHandling.c")) + code.putln( + "%s = __Pyx_PyObject_Call(%s, %s, NULL); %s" % ( + self.result(), + self.function.py_result(), + arg_code, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + elif func_type.is_cfunction: + if self.has_optional_args: + actual_nargs = len(self.args) + expected_nargs = len(func_type.args) - func_type.optional_arg_count + self.opt_arg_struct = code.funcstate.allocate_temp( + func_type.op_arg_struct.base_type, manage_ref=True) + code.putln("%s.%s = %s;" % ( + self.opt_arg_struct, + Naming.pyrex_prefix + "n", + len(self.args) - expected_nargs)) + args = list(zip(func_type.args, self.args)) + for formal_arg, actual_arg in args[expected_nargs:actual_nargs]: + code.putln("%s.%s = %s;" % ( + self.opt_arg_struct, + func_type.opt_arg_cname(formal_arg.name), + actual_arg.result_as(formal_arg.type))) + exc_checks = [] + if self.type.is_pyobject and self.is_temp: + exc_checks.append("!%s" % self.result()) + elif self.type.is_memoryviewslice: + assert self.is_temp + exc_checks.append(self.type.error_condition(self.result())) + elif func_type.exception_check != '+': + exc_val = func_type.exception_value + exc_check = func_type.exception_check + if exc_val is not None: + exc_checks.append("%s == %s" % (self.result(), func_type.return_type.cast_code(exc_val))) + if exc_check: + if self.nogil: + exc_checks.append("__Pyx_ErrOccurredWithGIL()") + else: + exc_checks.append("PyErr_Occurred()") + if self.is_temp or exc_checks: + rhs = self.c_call_code() + if self.result(): + lhs = "%s = " % self.result() + if self.is_temp and self.type.is_pyobject: + #return_type = self.type # func_type.return_type + #print "SimpleCallNode.generate_result_code: casting", rhs, \ + # "from", return_type, "to pyobject" ### + rhs = typecast(py_object_type, self.type, rhs) + else: + lhs = "" + if func_type.exception_check == '+': + translate_cpp_exception(code, self.pos, '%s%s;' % (lhs, rhs), + self.result() if self.type.is_pyobject else None, + func_type.exception_value, self.nogil) + else: + if exc_checks: + goto_error = code.error_goto_if(" && ".join(exc_checks), self.pos) + else: + goto_error = "" + code.putln("%s%s; %s" % (lhs, rhs, goto_error)) + if self.type.is_pyobject and self.result(): + code.put_gotref(self.py_result()) + if self.has_optional_args: + code.funcstate.release_temp(self.opt_arg_struct) + + +class NumPyMethodCallNode(ExprNode): + # Pythran call to a NumPy function or method. + # + # function_cname string the function/method to call + # arg_tuple TupleNode the arguments as an args tuple + + subexprs = ['arg_tuple'] + is_temp = True + may_return_none = True + + def generate_evaluation_code(self, code): + code.mark_pos(self.pos) + self.allocate_temp_result(code) + + assert self.arg_tuple.mult_factor is None + args = self.arg_tuple.args + for arg in args: + arg.generate_evaluation_code(code) + + code.putln("// function evaluation code for numpy function") + code.putln("__Pyx_call_destructor(%s);" % self.result()) + code.putln("new (&%s) decltype(%s){%s{}(%s)};" % ( + self.result(), + self.result(), + self.function_cname, + ", ".join(a.pythran_result() for a in args))) + + +class PyMethodCallNode(SimpleCallNode): + # Specialised call to a (potential) PyMethodObject with non-constant argument tuple. + # Allows the self argument to be injected directly instead of repacking a tuple for it. + # + # function ExprNode the function/method object to call + # arg_tuple TupleNode the arguments for the args tuple + + subexprs = ['function', 'arg_tuple'] + is_temp = True + + def generate_evaluation_code(self, code): + code.mark_pos(self.pos) + self.allocate_temp_result(code) + + self.function.generate_evaluation_code(code) + assert self.arg_tuple.mult_factor is None + args = self.arg_tuple.args + for arg in args: + arg.generate_evaluation_code(code) + + # make sure function is in temp so that we can replace the reference below if it's a method + reuse_function_temp = self.function.is_temp + if reuse_function_temp: + function = self.function.result() + else: + function = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + self.function.make_owned_reference(code) + code.put("%s = %s; " % (function, self.function.py_result())) + self.function.generate_disposal_code(code) + self.function.free_temps(code) + + self_arg = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + code.putln("%s = NULL;" % self_arg) + arg_offset_cname = None + if len(args) > 1: + arg_offset_cname = code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) + code.putln("%s = 0;" % arg_offset_cname) + + def attribute_is_likely_method(attr): + obj = attr.obj + if obj.is_name and obj.entry.is_pyglobal: + return False # more likely to be a function + return True + + if self.function.is_attribute: + likely_method = 'likely' if attribute_is_likely_method(self.function) else 'unlikely' + elif self.function.is_name and self.function.cf_state: + # not an attribute itself, but might have been assigned from one (e.g. bound method) + for assignment in self.function.cf_state: + value = assignment.rhs + if value and value.is_attribute and value.obj.type and value.obj.type.is_pyobject: + if attribute_is_likely_method(value): + likely_method = 'likely' + break + else: + likely_method = 'unlikely' + else: + likely_method = 'unlikely' + + code.putln("if (CYTHON_UNPACK_METHODS && %s(PyMethod_Check(%s))) {" % (likely_method, function)) + code.putln("%s = PyMethod_GET_SELF(%s);" % (self_arg, function)) + # the following is always true in Py3 (kept only for safety), + # but is false for unbound methods in Py2 + code.putln("if (likely(%s)) {" % self_arg) + code.putln("PyObject* function = PyMethod_GET_FUNCTION(%s);" % function) + code.put_incref(self_arg, py_object_type) + code.put_incref("function", py_object_type) + # free method object as early to possible to enable reuse from CPython's freelist + code.put_decref_set(function, "function") + if len(args) > 1: + code.putln("%s = 1;" % arg_offset_cname) + code.putln("}") + code.putln("}") + + if not args: + # fastest special case: try to avoid tuple creation + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectCallNoArg", "ObjectHandling.c")) + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectCallOneArg", "ObjectHandling.c")) + code.putln( + "%s = (%s) ? __Pyx_PyObject_CallOneArg(%s, %s) : __Pyx_PyObject_CallNoArg(%s);" % ( + self.result(), self_arg, + function, self_arg, + function)) + code.put_xdecref_clear(self_arg, py_object_type) + code.funcstate.release_temp(self_arg) + code.putln(code.error_goto_if_null(self.result(), self.pos)) + code.put_gotref(self.py_result()) + elif len(args) == 1: + # fastest special case: try to avoid tuple creation + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectCall2Args", "ObjectHandling.c")) + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectCallOneArg", "ObjectHandling.c")) + arg = args[0] + code.putln( + "%s = (%s) ? __Pyx_PyObject_Call2Args(%s, %s, %s) : __Pyx_PyObject_CallOneArg(%s, %s);" % ( + self.result(), self_arg, + function, self_arg, arg.py_result(), + function, arg.py_result())) + code.put_xdecref_clear(self_arg, py_object_type) + code.funcstate.release_temp(self_arg) + arg.generate_disposal_code(code) + arg.free_temps(code) + code.putln(code.error_goto_if_null(self.result(), self.pos)) + code.put_gotref(self.py_result()) + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyFunctionFastCall", "ObjectHandling.c")) + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyCFunctionFastCall", "ObjectHandling.c")) + for test_func, call_prefix in [('PyFunction_Check', 'Py'), ('__Pyx_PyFastCFunction_Check', 'PyC')]: + code.putln("#if CYTHON_FAST_%sCALL" % call_prefix.upper()) + code.putln("if (%s(%s)) {" % (test_func, function)) + code.putln("PyObject *%s[%d] = {%s, %s};" % ( + Naming.quick_temp_cname, + len(args)+1, + self_arg, + ', '.join(arg.py_result() for arg in args))) + code.putln("%s = __Pyx_%sFunction_FastCall(%s, %s+1-%s, %d+%s); %s" % ( + self.result(), + call_prefix, + function, + Naming.quick_temp_cname, + arg_offset_cname, + len(args), + arg_offset_cname, + code.error_goto_if_null(self.result(), self.pos))) + code.put_xdecref_clear(self_arg, py_object_type) + code.put_gotref(self.py_result()) + for arg in args: + arg.generate_disposal_code(code) + code.putln("} else") + code.putln("#endif") + + code.putln("{") + args_tuple = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + code.putln("%s = PyTuple_New(%d+%s); %s" % ( + args_tuple, len(args), arg_offset_cname, + code.error_goto_if_null(args_tuple, self.pos))) + code.put_gotref(args_tuple) + + if len(args) > 1: + code.putln("if (%s) {" % self_arg) + code.putln("__Pyx_GIVEREF(%s); PyTuple_SET_ITEM(%s, 0, %s); %s = NULL;" % ( + self_arg, args_tuple, self_arg, self_arg)) # stealing owned ref in this case + code.funcstate.release_temp(self_arg) + if len(args) > 1: + code.putln("}") + + for i, arg in enumerate(args): + arg.make_owned_reference(code) + code.put_giveref(arg.py_result()) + code.putln("PyTuple_SET_ITEM(%s, %d+%s, %s);" % ( + args_tuple, i, arg_offset_cname, arg.py_result())) + if len(args) > 1: + code.funcstate.release_temp(arg_offset_cname) + + for arg in args: + arg.generate_post_assignment_code(code) + arg.free_temps(code) + + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectCall", "ObjectHandling.c")) + code.putln( + "%s = __Pyx_PyObject_Call(%s, %s, NULL); %s" % ( + self.result(), + function, args_tuple, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + code.put_decref_clear(args_tuple, py_object_type) + code.funcstate.release_temp(args_tuple) + + if len(args) == 1: + code.putln("}") + code.putln("}") # !CYTHON_FAST_PYCALL + + if reuse_function_temp: + self.function.generate_disposal_code(code) + self.function.free_temps(code) + else: + code.put_decref_clear(function, py_object_type) + code.funcstate.release_temp(function) + + +class InlinedDefNodeCallNode(CallNode): + # Inline call to defnode + # + # function PyCFunctionNode + # function_name NameNode + # args [ExprNode] + + subexprs = ['args', 'function_name'] + is_temp = 1 + type = py_object_type + function = None + function_name = None + + def can_be_inlined(self): + func_type= self.function.def_node + if func_type.star_arg or func_type.starstar_arg: + return False + if len(func_type.args) != len(self.args): + return False + if func_type.num_kwonly_args: + return False # actually wrong number of arguments + return True + + def analyse_types(self, env): + self.function_name = self.function_name.analyse_types(env) + + self.args = [ arg.analyse_types(env) for arg in self.args ] + func_type = self.function.def_node + actual_nargs = len(self.args) + + # Coerce arguments + some_args_in_temps = False + for i in range(actual_nargs): + formal_type = func_type.args[i].type + arg = self.args[i].coerce_to(formal_type, env) + if arg.is_temp: + if i > 0: + # first argument in temp doesn't impact subsequent arguments + some_args_in_temps = True + elif arg.type.is_pyobject and not env.nogil: + if arg.nonlocally_immutable(): + # plain local variables are ok + pass + else: + # we do not safely own the argument's reference, + # but we must make sure it cannot be collected + # before we return from the function, so we create + # an owned temp reference to it + if i > 0: # first argument doesn't matter + some_args_in_temps = True + arg = arg.coerce_to_temp(env) + self.args[i] = arg + + if some_args_in_temps: + # if some args are temps and others are not, they may get + # constructed in the wrong order (temps first) => make + # sure they are either all temps or all not temps (except + # for the last argument, which is evaluated last in any + # case) + for i in range(actual_nargs-1): + arg = self.args[i] + if arg.nonlocally_immutable(): + # locals, C functions, unassignable types are safe. + pass + elif arg.type.is_cpp_class: + # Assignment has side effects, avoid. + pass + elif env.nogil and arg.type.is_pyobject: + # can't copy a Python reference into a temp in nogil + # env (this is safe: a construction would fail in + # nogil anyway) + pass + else: + #self.args[i] = arg.coerce_to_temp(env) + # instead: issue a warning + if i > 0: + warning(arg.pos, "Argument evaluation order in C function call is undefined and may not be as expected", 0) + break + return self + + def generate_result_code(self, code): + arg_code = [self.function_name.py_result()] + func_type = self.function.def_node + for arg, proto_arg in zip(self.args, func_type.args): + if arg.type.is_pyobject: + arg_code.append(arg.result_as(proto_arg.type)) + else: + arg_code.append(arg.result()) + arg_code = ', '.join(arg_code) + code.putln( + "%s = %s(%s); %s" % ( + self.result(), + self.function.def_node.entry.pyfunc_cname, + arg_code, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class PythonCapiFunctionNode(ExprNode): + subexprs = [] + + def __init__(self, pos, py_name, cname, func_type, utility_code = None): + ExprNode.__init__(self, pos, name=py_name, cname=cname, + type=func_type, utility_code=utility_code) + + def analyse_types(self, env): + return self + + def generate_result_code(self, code): + if self.utility_code: + code.globalstate.use_utility_code(self.utility_code) + + def calculate_result_code(self): + return self.cname + + +class PythonCapiCallNode(SimpleCallNode): + # Python C-API Function call (only created in transforms) + + # By default, we assume that the call never returns None, as this + # is true for most C-API functions in CPython. If this does not + # apply to a call, set the following to True (or None to inherit + # the default behaviour). + may_return_none = False + + def __init__(self, pos, function_name, func_type, + utility_code = None, py_name=None, **kwargs): + self.type = func_type.return_type + self.result_ctype = self.type + self.function = PythonCapiFunctionNode( + pos, py_name, function_name, func_type, + utility_code = utility_code) + # call this last so that we can override the constructed + # attributes above with explicit keyword arguments if required + SimpleCallNode.__init__(self, pos, **kwargs) + + +class CachedBuiltinMethodCallNode(CallNode): + # Python call to a method of a known Python builtin (only created in transforms) + + subexprs = ['obj', 'args'] + is_temp = True + + def __init__(self, call_node, obj, method_name, args): + super(CachedBuiltinMethodCallNode, self).__init__( + call_node.pos, + obj=obj, method_name=method_name, args=args, + may_return_none=call_node.may_return_none, + type=call_node.type) + + def may_be_none(self): + if self.may_return_none is not None: + return self.may_return_none + return ExprNode.may_be_none(self) + + def generate_result_code(self, code): + type_cname = self.obj.type.cname + obj_cname = self.obj.py_result() + args = [arg.py_result() for arg in self.args] + call_code = code.globalstate.cached_unbound_method_call_code( + obj_cname, type_cname, self.method_name, args) + code.putln("%s = %s; %s" % ( + self.result(), call_code, + code.error_goto_if_null(self.result(), self.pos) + )) + code.put_gotref(self.result()) + + +class GeneralCallNode(CallNode): + # General Python function call, including keyword, + # * and ** arguments. + # + # function ExprNode + # positional_args ExprNode Tuple of positional arguments + # keyword_args ExprNode or None Dict of keyword arguments + + type = py_object_type + + subexprs = ['function', 'positional_args', 'keyword_args'] + + nogil_check = Node.gil_error + + def compile_time_value(self, denv): + function = self.function.compile_time_value(denv) + positional_args = self.positional_args.compile_time_value(denv) + keyword_args = self.keyword_args.compile_time_value(denv) + try: + return function(*positional_args, **keyword_args) + except Exception as e: + self.compile_time_value_error(e) + + def explicit_args_kwds(self): + if (self.keyword_args and not self.keyword_args.is_dict_literal or + not self.positional_args.is_sequence_constructor): + raise CompileError(self.pos, + 'Compile-time keyword arguments must be explicit.') + return self.positional_args.args, self.keyword_args + + def analyse_types(self, env): + if self.analyse_as_type_constructor(env): + return self + self.function = self.function.analyse_types(env) + if not self.function.type.is_pyobject: + if self.function.type.is_error: + self.type = error_type + return self + if hasattr(self.function, 'entry'): + node = self.map_to_simple_call_node() + if node is not None and node is not self: + return node.analyse_types(env) + elif self.function.entry.as_variable: + self.function = self.function.coerce_to_pyobject(env) + elif node is self: + error(self.pos, + "Non-trivial keyword arguments and starred " + "arguments not allowed in cdef functions.") + else: + # error was already reported + pass + else: + self.function = self.function.coerce_to_pyobject(env) + if self.keyword_args: + self.keyword_args = self.keyword_args.analyse_types(env) + self.positional_args = self.positional_args.analyse_types(env) + self.positional_args = \ + self.positional_args.coerce_to_pyobject(env) + self.set_py_result_type(self.function) + self.is_temp = 1 + return self + + def map_to_simple_call_node(self): + """ + Tries to map keyword arguments to declared positional arguments. + Returns self to try a Python call, None to report an error + or a SimpleCallNode if the mapping succeeds. + """ + if not isinstance(self.positional_args, TupleNode): + # has starred argument + return self + if not self.keyword_args.is_dict_literal: + # keywords come from arbitrary expression => nothing to do here + return self + function = self.function + entry = getattr(function, 'entry', None) + if not entry: + return self + function_type = entry.type + if function_type.is_ptr: + function_type = function_type.base_type + if not function_type.is_cfunction: + return self + + pos_args = self.positional_args.args + kwargs = self.keyword_args + declared_args = function_type.args + if entry.is_cmethod: + declared_args = declared_args[1:] # skip 'self' + + if len(pos_args) > len(declared_args): + error(self.pos, "function call got too many positional arguments, " + "expected %d, got %s" % (len(declared_args), + len(pos_args))) + return None + + matched_args = set([ arg.name for arg in declared_args[:len(pos_args)] + if arg.name ]) + unmatched_args = declared_args[len(pos_args):] + matched_kwargs_count = 0 + args = list(pos_args) + + # check for duplicate keywords + seen = set(matched_args) + has_errors = False + for arg in kwargs.key_value_pairs: + name = arg.key.value + if name in seen: + error(arg.pos, "argument '%s' passed twice" % name) + has_errors = True + # continue to report more errors if there are any + seen.add(name) + + # match keywords that are passed in order + for decl_arg, arg in zip(unmatched_args, kwargs.key_value_pairs): + name = arg.key.value + if decl_arg.name == name: + matched_args.add(name) + matched_kwargs_count += 1 + args.append(arg.value) + else: + break + + # match keyword arguments that are passed out-of-order, but keep + # the evaluation of non-simple arguments in order by moving them + # into temps + from .UtilNodes import EvalWithTempExprNode, LetRefNode + temps = [] + if len(kwargs.key_value_pairs) > matched_kwargs_count: + unmatched_args = declared_args[len(args):] + keywords = dict([ (arg.key.value, (i+len(pos_args), arg)) + for i, arg in enumerate(kwargs.key_value_pairs) ]) + first_missing_keyword = None + for decl_arg in unmatched_args: + name = decl_arg.name + if name not in keywords: + # missing keyword argument => either done or error + if not first_missing_keyword: + first_missing_keyword = name + continue + elif first_missing_keyword: + if entry.as_variable: + # we might be able to convert the function to a Python + # object, which then allows full calling semantics + # with default values in gaps - currently, we only + # support optional arguments at the end + return self + # wasn't the last keyword => gaps are not supported + error(self.pos, "C function call is missing " + "argument '%s'" % first_missing_keyword) + return None + pos, arg = keywords[name] + matched_args.add(name) + matched_kwargs_count += 1 + if arg.value.is_simple(): + args.append(arg.value) + else: + temp = LetRefNode(arg.value) + assert temp.is_simple() + args.append(temp) + temps.append((pos, temp)) + + if temps: + # may have to move preceding non-simple args into temps + final_args = [] + new_temps = [] + first_temp_arg = temps[0][-1] + for arg_value in args: + if arg_value is first_temp_arg: + break # done + if arg_value.is_simple(): + final_args.append(arg_value) + else: + temp = LetRefNode(arg_value) + new_temps.append(temp) + final_args.append(temp) + if new_temps: + args = final_args + temps = new_temps + [ arg for i,arg in sorted(temps) ] + + # check for unexpected keywords + for arg in kwargs.key_value_pairs: + name = arg.key.value + if name not in matched_args: + has_errors = True + error(arg.pos, + "C function got unexpected keyword argument '%s'" % + name) + + if has_errors: + # error was reported already + return None + + # all keywords mapped to positional arguments + # if we are missing arguments, SimpleCallNode will figure it out + node = SimpleCallNode(self.pos, function=function, args=args) + for temp in temps[::-1]: + node = EvalWithTempExprNode(temp, node) + return node + + def generate_result_code(self, code): + if self.type.is_error: return + if self.keyword_args: + kwargs = self.keyword_args.py_result() + else: + kwargs = 'NULL' + code.globalstate.use_utility_code(UtilityCode.load_cached( + "PyObjectCall", "ObjectHandling.c")) + code.putln( + "%s = __Pyx_PyObject_Call(%s, %s, %s); %s" % ( + self.result(), + self.function.py_result(), + self.positional_args.py_result(), + kwargs, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class AsTupleNode(ExprNode): + # Convert argument to tuple. Used for normalising + # the * argument of a function call. + # + # arg ExprNode + + subexprs = ['arg'] + is_temp = 1 + + def calculate_constant_result(self): + self.constant_result = tuple(self.arg.constant_result) + + def compile_time_value(self, denv): + arg = self.arg.compile_time_value(denv) + try: + return tuple(arg) + except Exception as e: + self.compile_time_value_error(e) + + def analyse_types(self, env): + self.arg = self.arg.analyse_types(env).coerce_to_pyobject(env) + if self.arg.type is tuple_type: + return self.arg.as_none_safe_node("'NoneType' object is not iterable") + self.type = tuple_type + return self + + def may_be_none(self): + return False + + nogil_check = Node.gil_error + gil_message = "Constructing Python tuple" + + def generate_result_code(self, code): + cfunc = "__Pyx_PySequence_Tuple" if self.arg.type in (py_object_type, tuple_type) else "PySequence_Tuple" + code.putln( + "%s = %s(%s); %s" % ( + self.result(), + cfunc, self.arg.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class MergedDictNode(ExprNode): + # Helper class for keyword arguments and other merged dicts. + # + # keyword_args [DictNode or other ExprNode] + + subexprs = ['keyword_args'] + is_temp = 1 + type = dict_type + reject_duplicates = True + + def calculate_constant_result(self): + result = {} + reject_duplicates = self.reject_duplicates + for item in self.keyword_args: + if item.is_dict_literal: + # process items in order + items = ((key.constant_result, value.constant_result) + for key, value in item.key_value_pairs) + else: + items = item.constant_result.iteritems() + + for key, value in items: + if reject_duplicates and key in result: + raise ValueError("duplicate keyword argument found: %s" % key) + result[key] = value + + self.constant_result = result + + def compile_time_value(self, denv): + result = {} + reject_duplicates = self.reject_duplicates + for item in self.keyword_args: + if item.is_dict_literal: + # process items in order + items = [(key.compile_time_value(denv), value.compile_time_value(denv)) + for key, value in item.key_value_pairs] + else: + items = item.compile_time_value(denv).iteritems() + + try: + for key, value in items: + if reject_duplicates and key in result: + raise ValueError("duplicate keyword argument found: %s" % key) + result[key] = value + except Exception as e: + self.compile_time_value_error(e) + return result + + def type_dependencies(self, env): + return () + + def infer_type(self, env): + return dict_type + + def analyse_types(self, env): + self.keyword_args = [ + arg.analyse_types(env).coerce_to_pyobject(env).as_none_safe_node( + # FIXME: CPython's error message starts with the runtime function name + 'argument after ** must be a mapping, not NoneType') + for arg in self.keyword_args + ] + + return self + + def may_be_none(self): + return False + + gil_message = "Constructing Python dict" + + def generate_evaluation_code(self, code): + code.mark_pos(self.pos) + self.allocate_temp_result(code) + + args = iter(self.keyword_args) + item = next(args) + item.generate_evaluation_code(code) + if item.type is not dict_type: + # CPython supports calling functions with non-dicts, so do we + code.putln('if (likely(PyDict_CheckExact(%s))) {' % + item.py_result()) + + if item.is_dict_literal: + item.make_owned_reference(code) + code.putln("%s = %s;" % (self.result(), item.py_result())) + item.generate_post_assignment_code(code) + else: + code.putln("%s = PyDict_Copy(%s); %s" % ( + self.result(), + item.py_result(), + code.error_goto_if_null(self.result(), item.pos))) + code.put_gotref(self.result()) + item.generate_disposal_code(code) + + if item.type is not dict_type: + code.putln('} else {') + code.putln("%s = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, %s, NULL); %s" % ( + self.result(), + item.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + item.generate_disposal_code(code) + code.putln('}') + item.free_temps(code) + + helpers = set() + for item in args: + if item.is_dict_literal: + # inline update instead of creating an intermediate dict + for arg in item.key_value_pairs: + arg.generate_evaluation_code(code) + if self.reject_duplicates: + code.putln("if (unlikely(PyDict_Contains(%s, %s))) {" % ( + self.result(), + arg.key.py_result())) + helpers.add("RaiseDoubleKeywords") + # FIXME: find out function name at runtime! + code.putln('__Pyx_RaiseDoubleKeywordsError("function", %s); %s' % ( + arg.key.py_result(), + code.error_goto(self.pos))) + code.putln("}") + code.put_error_if_neg(arg.key.pos, "PyDict_SetItem(%s, %s, %s)" % ( + self.result(), + arg.key.py_result(), + arg.value.py_result())) + arg.generate_disposal_code(code) + arg.free_temps(code) + else: + item.generate_evaluation_code(code) + if self.reject_duplicates: + # merge mapping into kwdict one by one as we need to check for duplicates + helpers.add("MergeKeywords") + code.put_error_if_neg(item.pos, "__Pyx_MergeKeywords(%s, %s)" % ( + self.result(), item.py_result())) + else: + # simple case, just add all entries + helpers.add("RaiseMappingExpected") + code.putln("if (unlikely(PyDict_Update(%s, %s) < 0)) {" % ( + self.result(), item.py_result())) + code.putln("if (PyErr_ExceptionMatches(PyExc_AttributeError)) " + "__Pyx_RaiseMappingExpectedError(%s);" % item.py_result()) + code.putln(code.error_goto(item.pos)) + code.putln("}") + item.generate_disposal_code(code) + item.free_temps(code) + + for helper in sorted(helpers): + code.globalstate.use_utility_code(UtilityCode.load_cached(helper, "FunctionArguments.c")) + + def annotate(self, code): + for item in self.keyword_args: + item.annotate(code) + + +class AttributeNode(ExprNode): + # obj.attribute + # + # obj ExprNode + # attribute string + # needs_none_check boolean Used if obj is an extension type. + # If set to True, it is known that the type is not None. + # + # Used internally: + # + # is_py_attr boolean Is a Python getattr operation + # member string C name of struct member + # is_called boolean Function call is being done on result + # entry Entry Symbol table entry of attribute + + is_attribute = 1 + subexprs = ['obj'] + + type = PyrexTypes.error_type + entry = None + is_called = 0 + needs_none_check = True + is_memslice_transpose = False + is_special_lookup = False + is_py_attr = 0 + + def as_cython_attribute(self): + if (isinstance(self.obj, NameNode) and + self.obj.is_cython_module and not + self.attribute == u"parallel"): + return self.attribute + + cy = self.obj.as_cython_attribute() + if cy: + return "%s.%s" % (cy, self.attribute) + return None + + def coerce_to(self, dst_type, env): + # If coercing to a generic pyobject and this is a cpdef function + # we can create the corresponding attribute + if dst_type is py_object_type: + entry = self.entry + if entry and entry.is_cfunction and entry.as_variable: + # must be a cpdef function + self.is_temp = 1 + self.entry = entry.as_variable + self.analyse_as_python_attribute(env) + return self + return ExprNode.coerce_to(self, dst_type, env) + + def calculate_constant_result(self): + attr = self.attribute + if attr.startswith("__") and attr.endswith("__"): + return + self.constant_result = getattr(self.obj.constant_result, attr) + + def compile_time_value(self, denv): + attr = self.attribute + if attr.startswith("__") and attr.endswith("__"): + error(self.pos, + "Invalid attribute name '%s' in compile-time expression" % attr) + return None + obj = self.obj.compile_time_value(denv) + try: + return getattr(obj, attr) + except Exception as e: + self.compile_time_value_error(e) + + def type_dependencies(self, env): + return self.obj.type_dependencies(env) + + def infer_type(self, env): + # FIXME: this is way too redundant with analyse_types() + node = self.analyse_as_cimported_attribute_node(env, target=False) + if node is not None: + if node.entry.type and node.entry.type.is_cfunction: + # special-case - function converted to pointer + return PyrexTypes.CPtrType(node.entry.type) + else: + return node.entry.type + node = self.analyse_as_type_attribute(env) + if node is not None: + return node.entry.type + obj_type = self.obj.infer_type(env) + self.analyse_attribute(env, obj_type=obj_type) + if obj_type.is_builtin_type and self.type.is_cfunction: + # special case: C-API replacements for C methods of + # builtin types cannot be inferred as C functions as + # that would prevent their use as bound methods + return py_object_type + elif self.entry and self.entry.is_cmethod: + # special case: bound methods should not be inferred + # as their unbound method types + return py_object_type + return self.type + + def analyse_target_declaration(self, env): + pass + + def analyse_target_types(self, env): + node = self.analyse_types(env, target = 1) + if node.type.is_const: + error(self.pos, "Assignment to const attribute '%s'" % self.attribute) + if not node.is_lvalue(): + error(self.pos, "Assignment to non-lvalue of type '%s'" % self.type) + return node + + def analyse_types(self, env, target = 0): + self.initialized_check = env.directives['initializedcheck'] + node = self.analyse_as_cimported_attribute_node(env, target) + if node is None and not target: + node = self.analyse_as_type_attribute(env) + if node is None: + node = self.analyse_as_ordinary_attribute_node(env, target) + assert node is not None + if node.entry: + node.entry.used = True + if node.is_attribute: + node.wrap_obj_in_nonecheck(env) + return node + + def analyse_as_cimported_attribute_node(self, env, target): + # Try to interpret this as a reference to an imported + # C const, type, var or function. If successful, mutates + # this node into a NameNode and returns 1, otherwise + # returns 0. + module_scope = self.obj.analyse_as_module(env) + if module_scope: + entry = module_scope.lookup_here(self.attribute) + if entry and ( + entry.is_cglobal or entry.is_cfunction + or entry.is_type or entry.is_const): + return self.as_name_node(env, entry, target) + if self.is_cimported_module_without_shadow(env): + error(self.pos, "cimported module has no attribute '%s'" % self.attribute) + return self + return None + + def analyse_as_type_attribute(self, env): + # Try to interpret this as a reference to an unbound + # C method of an extension type or builtin type. If successful, + # creates a corresponding NameNode and returns it, otherwise + # returns None. + if self.obj.is_string_literal: + return + type = self.obj.analyse_as_type(env) + if type: + if type.is_extension_type or type.is_builtin_type or type.is_cpp_class: + entry = type.scope.lookup_here(self.attribute) + if entry and (entry.is_cmethod or type.is_cpp_class and entry.type.is_cfunction): + if type.is_builtin_type: + if not self.is_called: + # must handle this as Python object + return None + ubcm_entry = entry + else: + # Create a temporary entry describing the C method + # as an ordinary function. + if entry.func_cname and not hasattr(entry.type, 'op_arg_struct'): + cname = entry.func_cname + if entry.type.is_static_method or ( + env.parent_scope and env.parent_scope.is_cpp_class_scope): + ctype = entry.type + elif type.is_cpp_class: + error(self.pos, "%s not a static member of %s" % (entry.name, type)) + ctype = PyrexTypes.error_type + else: + # Fix self type. + ctype = copy.copy(entry.type) + ctype.args = ctype.args[:] + ctype.args[0] = PyrexTypes.CFuncTypeArg('self', type, 'self', None) + else: + cname = "%s->%s" % (type.vtabptr_cname, entry.cname) + ctype = entry.type + ubcm_entry = Symtab.Entry(entry.name, cname, ctype) + ubcm_entry.is_cfunction = 1 + ubcm_entry.func_cname = entry.func_cname + ubcm_entry.is_unbound_cmethod = 1 + ubcm_entry.scope = entry.scope + return self.as_name_node(env, ubcm_entry, target=False) + elif type.is_enum: + if self.attribute in type.values: + for entry in type.entry.enum_values: + if entry.name == self.attribute: + return self.as_name_node(env, entry, target=False) + else: + error(self.pos, "%s not a known value of %s" % (self.attribute, type)) + else: + error(self.pos, "%s not a known value of %s" % (self.attribute, type)) + return None + + def analyse_as_type(self, env): + module_scope = self.obj.analyse_as_module(env) + if module_scope: + return module_scope.lookup_type(self.attribute) + if not self.obj.is_string_literal: + base_type = self.obj.analyse_as_type(env) + if base_type and hasattr(base_type, 'scope') and base_type.scope is not None: + return base_type.scope.lookup_type(self.attribute) + return None + + def analyse_as_extension_type(self, env): + # Try to interpret this as a reference to an extension type + # in a cimported module. Returns the extension type, or None. + module_scope = self.obj.analyse_as_module(env) + if module_scope: + entry = module_scope.lookup_here(self.attribute) + if entry and entry.is_type: + if entry.type.is_extension_type or entry.type.is_builtin_type: + return entry.type + return None + + def analyse_as_module(self, env): + # Try to interpret this as a reference to a cimported module + # in another cimported module. Returns the module scope, or None. + module_scope = self.obj.analyse_as_module(env) + if module_scope: + entry = module_scope.lookup_here(self.attribute) + if entry and entry.as_module: + return entry.as_module + return None + + def as_name_node(self, env, entry, target): + # Create a corresponding NameNode from this node and complete the + # analyse_types phase. + node = NameNode.from_node(self, name=self.attribute, entry=entry) + if target: + node = node.analyse_target_types(env) + else: + node = node.analyse_rvalue_entry(env) + node.entry.used = 1 + return node + + def analyse_as_ordinary_attribute_node(self, env, target): + self.obj = self.obj.analyse_types(env) + self.analyse_attribute(env) + if self.entry and self.entry.is_cmethod and not self.is_called: +# error(self.pos, "C method can only be called") + pass + ## Reference to C array turns into pointer to first element. + #while self.type.is_array: + # self.type = self.type.element_ptr_type() + if self.is_py_attr: + if not target: + self.is_temp = 1 + self.result_ctype = py_object_type + elif target and self.obj.type.is_builtin_type: + error(self.pos, "Assignment to an immutable object field") + #elif self.type.is_memoryviewslice and not target: + # self.is_temp = True + return self + + def analyse_attribute(self, env, obj_type = None): + # Look up attribute and set self.type and self.member. + immutable_obj = obj_type is not None # used during type inference + self.is_py_attr = 0 + self.member = self.attribute + if obj_type is None: + if self.obj.type.is_string or self.obj.type.is_pyunicode_ptr: + self.obj = self.obj.coerce_to_pyobject(env) + obj_type = self.obj.type + else: + if obj_type.is_string or obj_type.is_pyunicode_ptr: + obj_type = py_object_type + if obj_type.is_ptr or obj_type.is_array: + obj_type = obj_type.base_type + self.op = "->" + elif obj_type.is_extension_type or obj_type.is_builtin_type: + self.op = "->" + elif obj_type.is_reference and obj_type.is_fake_reference: + self.op = "->" + else: + self.op = "." + if obj_type.has_attributes: + if obj_type.attributes_known(): + entry = obj_type.scope.lookup_here(self.attribute) + if obj_type.is_memoryviewslice and not entry: + if self.attribute == 'T': + self.is_memslice_transpose = True + self.is_temp = True + self.use_managed_ref = True + self.type = self.obj.type.transpose(self.pos) + return + else: + obj_type.declare_attribute(self.attribute, env, self.pos) + entry = obj_type.scope.lookup_here(self.attribute) + if entry and entry.is_member: + entry = None + else: + error(self.pos, + "Cannot select attribute of incomplete type '%s'" + % obj_type) + self.type = PyrexTypes.error_type + return + self.entry = entry + if entry: + if obj_type.is_extension_type and entry.name == "__weakref__": + error(self.pos, "Illegal use of special attribute __weakref__") + + # def methods need the normal attribute lookup + # because they do not have struct entries + # fused function go through assignment synthesis + # (foo = pycfunction(foo_func_obj)) and need to go through + # regular Python lookup as well + if (entry.is_variable and not entry.fused_cfunction) or entry.is_cmethod: + self.type = entry.type + self.member = entry.cname + return + else: + # If it's not a variable or C method, it must be a Python + # method of an extension type, so we treat it like a Python + # attribute. + pass + # If we get here, the base object is not a struct/union/extension + # type, or it is an extension type and the attribute is either not + # declared or is declared as a Python method. Treat it as a Python + # attribute reference. + self.analyse_as_python_attribute(env, obj_type, immutable_obj) + + def analyse_as_python_attribute(self, env, obj_type=None, immutable_obj=False): + if obj_type is None: + obj_type = self.obj.type + # mangle private '__*' Python attributes used inside of a class + self.attribute = env.mangle_class_private_name(self.attribute) + self.member = self.attribute + self.type = py_object_type + self.is_py_attr = 1 + + if not obj_type.is_pyobject and not obj_type.is_error: + # Expose python methods for immutable objects. + if (obj_type.is_string or obj_type.is_cpp_string + or obj_type.is_buffer or obj_type.is_memoryviewslice + or obj_type.is_numeric + or (obj_type.is_ctuple and obj_type.can_coerce_to_pyobject(env)) + or (obj_type.is_struct and obj_type.can_coerce_to_pyobject(env))): + if not immutable_obj: + self.obj = self.obj.coerce_to_pyobject(env) + elif (obj_type.is_cfunction and (self.obj.is_name or self.obj.is_attribute) + and self.obj.entry.as_variable + and self.obj.entry.as_variable.type.is_pyobject): + # might be an optimised builtin function => unpack it + if not immutable_obj: + self.obj = self.obj.coerce_to_pyobject(env) + else: + error(self.pos, + "Object of type '%s' has no attribute '%s'" % + (obj_type, self.attribute)) + + def wrap_obj_in_nonecheck(self, env): + if not env.directives['nonecheck']: + return + + msg = None + format_args = () + if (self.obj.type.is_extension_type and self.needs_none_check and not + self.is_py_attr): + msg = "'NoneType' object has no attribute '%{0}s'".format('.30' if len(self.attribute) <= 30 else '') + format_args = (self.attribute,) + elif self.obj.type.is_memoryviewslice: + if self.is_memslice_transpose: + msg = "Cannot transpose None memoryview slice" + else: + entry = self.obj.type.scope.lookup_here(self.attribute) + if entry: + # copy/is_c_contig/shape/strides etc + msg = "Cannot access '%s' attribute of None memoryview slice" + format_args = (entry.name,) + + if msg: + self.obj = self.obj.as_none_safe_node(msg, 'PyExc_AttributeError', + format_args=format_args) + + def nogil_check(self, env): + if self.is_py_attr: + self.gil_error() + + gil_message = "Accessing Python attribute" + + def is_cimported_module_without_shadow(self, env): + return self.obj.is_cimported_module_without_shadow(env) + + def is_simple(self): + if self.obj: + return self.result_in_temp() or self.obj.is_simple() + else: + return NameNode.is_simple(self) + + def is_lvalue(self): + if self.obj: + return True + else: + return NameNode.is_lvalue(self) + + def is_ephemeral(self): + if self.obj: + return self.obj.is_ephemeral() + else: + return NameNode.is_ephemeral(self) + + def calculate_result_code(self): + #print "AttributeNode.calculate_result_code:", self.member ### + #print "...obj node =", self.obj, "code", self.obj.result() ### + #print "...obj type", self.obj.type, "ctype", self.obj.ctype() ### + obj = self.obj + obj_code = obj.result_as(obj.type) + #print "...obj_code =", obj_code ### + if self.entry and self.entry.is_cmethod: + if obj.type.is_extension_type and not self.entry.is_builtin_cmethod: + if self.entry.final_func_cname: + return self.entry.final_func_cname + + if self.type.from_fused: + # If the attribute was specialized through indexing, make + # sure to get the right fused name, as our entry was + # replaced by our parent index node + # (AnalyseExpressionsTransform) + self.member = self.entry.cname + + return "((struct %s *)%s%s%s)->%s" % ( + obj.type.vtabstruct_cname, obj_code, self.op, + obj.type.vtabslot_cname, self.member) + elif self.result_is_used: + return self.member + # Generating no code at all for unused access to optimised builtin + # methods fixes the problem that some optimisations only exist as + # macros, i.e. there is no function pointer to them, so we would + # generate invalid C code here. + return + elif obj.type.is_complex: + return "__Pyx_C%s(%s)" % (self.member.upper(), obj_code) + else: + if obj.type.is_builtin_type and self.entry and self.entry.is_variable: + # accessing a field of a builtin type, need to cast better than result_as() does + obj_code = obj.type.cast_code(obj.result(), to_object_struct = True) + return "%s%s%s" % (obj_code, self.op, self.member) + + def generate_result_code(self, code): + if self.is_py_attr: + if self.is_special_lookup: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectLookupSpecial", "ObjectHandling.c")) + lookup_func_name = '__Pyx_PyObject_LookupSpecial' + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectGetAttrStr", "ObjectHandling.c")) + lookup_func_name = '__Pyx_PyObject_GetAttrStr' + code.putln( + '%s = %s(%s, %s); %s' % ( + self.result(), + lookup_func_name, + self.obj.py_result(), + code.intern_identifier(self.attribute), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + elif self.type.is_memoryviewslice: + if self.is_memslice_transpose: + # transpose the slice + for access, packing in self.type.axes: + if access == 'ptr': + error(self.pos, "Transposing not supported for slices " + "with indirect dimensions") + return + + code.putln("%s = %s;" % (self.result(), self.obj.result())) + code.put_incref_memoryviewslice(self.result(), have_gil=True) + + T = "__pyx_memslice_transpose(&%s) == 0" + code.putln(code.error_goto_if(T % self.result(), self.pos)) + elif self.initialized_check: + code.putln( + 'if (unlikely(!%s.memview)) {' + 'PyErr_SetString(PyExc_AttributeError,' + '"Memoryview is not initialized");' + '%s' + '}' % (self.result(), code.error_goto(self.pos))) + else: + # result_code contains what is needed, but we may need to insert + # a check and raise an exception + if self.obj.type and self.obj.type.is_extension_type: + pass + elif self.entry and self.entry.is_cmethod: + # C method implemented as function call with utility code + code.globalstate.use_entry_utility_code(self.entry) + + def generate_disposal_code(self, code): + if self.is_temp and self.type.is_memoryviewslice and self.is_memslice_transpose: + # mirror condition for putting the memview incref here: + code.put_xdecref_memoryviewslice( + self.result(), have_gil=True) + code.putln("%s.memview = NULL;" % self.result()) + code.putln("%s.data = NULL;" % self.result()) + else: + ExprNode.generate_disposal_code(self, code) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False, + exception_check=None, exception_value=None): + self.obj.generate_evaluation_code(code) + if self.is_py_attr: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectSetAttrStr", "ObjectHandling.c")) + code.put_error_if_neg(self.pos, + '__Pyx_PyObject_SetAttrStr(%s, %s, %s)' % ( + self.obj.py_result(), + code.intern_identifier(self.attribute), + rhs.py_result())) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + elif self.obj.type.is_complex: + code.putln("__Pyx_SET_C%s(%s, %s);" % ( + self.member.upper(), + self.obj.result_as(self.obj.type), + rhs.result_as(self.ctype()))) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + else: + select_code = self.result() + if self.type.is_pyobject and self.use_managed_ref: + rhs.make_owned_reference(code) + code.put_giveref(rhs.py_result()) + code.put_gotref(select_code) + code.put_decref(select_code, self.ctype()) + elif self.type.is_memoryviewslice: + from . import MemoryView + MemoryView.put_assign_to_memviewslice( + select_code, rhs, rhs.result(), self.type, code) + + if not self.type.is_memoryviewslice: + code.putln( + "%s = %s;" % ( + select_code, + rhs.result_as(self.ctype()))) + #rhs.result())) + rhs.generate_post_assignment_code(code) + rhs.free_temps(code) + self.obj.generate_disposal_code(code) + self.obj.free_temps(code) + + def generate_deletion_code(self, code, ignore_nonexisting=False): + self.obj.generate_evaluation_code(code) + if self.is_py_attr or (self.entry.scope.is_property_scope + and u'__del__' in self.entry.scope.entries): + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectSetAttrStr", "ObjectHandling.c")) + code.put_error_if_neg(self.pos, + '__Pyx_PyObject_DelAttrStr(%s, %s)' % ( + self.obj.py_result(), + code.intern_identifier(self.attribute))) + else: + error(self.pos, "Cannot delete C attribute of extension type") + self.obj.generate_disposal_code(code) + self.obj.free_temps(code) + + def annotate(self, code): + if self.is_py_attr: + style, text = 'py_attr', 'python attribute (%s)' + else: + style, text = 'c_attr', 'c attribute (%s)' + code.annotate(self.pos, AnnotationItem(style, text % self.type, size=len(self.attribute))) + + +#------------------------------------------------------------------- +# +# Constructor nodes +# +#------------------------------------------------------------------- + +class StarredUnpackingNode(ExprNode): + # A starred expression like "*a" + # + # This is only allowed in sequence assignment or construction such as + # + # a, *b = (1,2,3,4) => a = 1 ; b = [2,3,4] + # + # and will be special cased during type analysis (or generate an error + # if it's found at unexpected places). + # + # target ExprNode + + subexprs = ['target'] + is_starred = 1 + type = py_object_type + is_temp = 1 + starred_expr_allowed_here = False + + def __init__(self, pos, target): + ExprNode.__init__(self, pos, target=target) + + def analyse_declarations(self, env): + if not self.starred_expr_allowed_here: + error(self.pos, "starred expression is not allowed here") + self.target.analyse_declarations(env) + + def infer_type(self, env): + return self.target.infer_type(env) + + def analyse_types(self, env): + if not self.starred_expr_allowed_here: + error(self.pos, "starred expression is not allowed here") + self.target = self.target.analyse_types(env) + self.type = self.target.type + return self + + def analyse_target_declaration(self, env): + self.target.analyse_target_declaration(env) + + def analyse_target_types(self, env): + self.target = self.target.analyse_target_types(env) + self.type = self.target.type + return self + + def calculate_result_code(self): + return "" + + def generate_result_code(self, code): + pass + + +class SequenceNode(ExprNode): + # Base class for list and tuple constructor nodes. + # Contains common code for performing sequence unpacking. + # + # args [ExprNode] + # unpacked_items [ExprNode] or None + # coerced_unpacked_items [ExprNode] or None + # mult_factor ExprNode the integer number of content repetitions ([1,2]*3) + + subexprs = ['args', 'mult_factor'] + + is_sequence_constructor = 1 + unpacked_items = None + mult_factor = None + slow = False # trade speed for code size (e.g. use PyTuple_Pack()) + + def compile_time_value_list(self, denv): + return [arg.compile_time_value(denv) for arg in self.args] + + def replace_starred_target_node(self): + # replace a starred node in the targets by the contained expression + self.starred_assignment = False + args = [] + for arg in self.args: + if arg.is_starred: + if self.starred_assignment: + error(arg.pos, "more than 1 starred expression in assignment") + self.starred_assignment = True + arg = arg.target + arg.is_starred = True + args.append(arg) + self.args = args + + def analyse_target_declaration(self, env): + self.replace_starred_target_node() + for arg in self.args: + arg.analyse_target_declaration(env) + + def analyse_types(self, env, skip_children=False): + for i, arg in enumerate(self.args): + if not skip_children: + arg = arg.analyse_types(env) + self.args[i] = arg.coerce_to_pyobject(env) + if self.mult_factor: + self.mult_factor = self.mult_factor.analyse_types(env) + if not self.mult_factor.type.is_int: + self.mult_factor = self.mult_factor.coerce_to_pyobject(env) + self.is_temp = 1 + # not setting self.type here, subtypes do this + return self + + def coerce_to_ctuple(self, dst_type, env): + if self.type == dst_type: + return self + assert not self.mult_factor + if len(self.args) != dst_type.size: + error(self.pos, "trying to coerce sequence to ctuple of wrong length, expected %d, got %d" % ( + dst_type.size, len(self.args))) + coerced_args = [arg.coerce_to(type, env) for arg, type in zip(self.args, dst_type.components)] + return TupleNode(self.pos, args=coerced_args, type=dst_type, is_temp=True) + + def _create_merge_node_if_necessary(self, env): + self._flatten_starred_args() + if not any(arg.is_starred for arg in self.args): + return self + # convert into MergedSequenceNode by building partial sequences + args = [] + values = [] + for arg in self.args: + if arg.is_starred: + if values: + args.append(TupleNode(values[0].pos, args=values).analyse_types(env, skip_children=True)) + values = [] + args.append(arg.target) + else: + values.append(arg) + if values: + args.append(TupleNode(values[0].pos, args=values).analyse_types(env, skip_children=True)) + node = MergedSequenceNode(self.pos, args, self.type) + if self.mult_factor: + node = binop_node( + self.pos, '*', node, self.mult_factor.coerce_to_pyobject(env), + inplace=True, type=self.type, is_temp=True) + return node + + def _flatten_starred_args(self): + args = [] + for arg in self.args: + if arg.is_starred and arg.target.is_sequence_constructor and not arg.target.mult_factor: + args.extend(arg.target.args) + else: + args.append(arg) + self.args[:] = args + + def may_be_none(self): + return False + + def analyse_target_types(self, env): + if self.mult_factor: + error(self.pos, "can't assign to multiplied sequence") + self.unpacked_items = [] + self.coerced_unpacked_items = [] + self.any_coerced_items = False + for i, arg in enumerate(self.args): + arg = self.args[i] = arg.analyse_target_types(env) + if arg.is_starred: + if not arg.type.assignable_from(list_type): + error(arg.pos, + "starred target must have Python object (list) type") + if arg.type is py_object_type: + arg.type = list_type + unpacked_item = PyTempNode(self.pos, env) + coerced_unpacked_item = unpacked_item.coerce_to(arg.type, env) + if unpacked_item is not coerced_unpacked_item: + self.any_coerced_items = True + self.unpacked_items.append(unpacked_item) + self.coerced_unpacked_items.append(coerced_unpacked_item) + self.type = py_object_type + return self + + def generate_result_code(self, code): + self.generate_operation_code(code) + + def generate_sequence_packing_code(self, code, target=None, plain=False): + if target is None: + target = self.result() + size_factor = c_mult = '' + mult_factor = None + + if self.mult_factor and not plain: + mult_factor = self.mult_factor + if mult_factor.type.is_int: + c_mult = mult_factor.result() + if (isinstance(mult_factor.constant_result, _py_int_types) and + mult_factor.constant_result > 0): + size_factor = ' * %s' % mult_factor.constant_result + elif mult_factor.type.signed: + size_factor = ' * ((%s<0) ? 0:%s)' % (c_mult, c_mult) + else: + size_factor = ' * (%s)' % (c_mult,) + + if self.type is tuple_type and (self.is_literal or self.slow) and not c_mult: + # use PyTuple_Pack() to avoid generating huge amounts of one-time code + code.putln('%s = PyTuple_Pack(%d, %s); %s' % ( + target, + len(self.args), + ', '.join(arg.py_result() for arg in self.args), + code.error_goto_if_null(target, self.pos))) + code.put_gotref(target) + elif self.type.is_ctuple: + for i, arg in enumerate(self.args): + code.putln("%s.f%s = %s;" % ( + target, i, arg.result())) + else: + # build the tuple/list step by step, potentially multiplying it as we go + if self.type is list_type: + create_func, set_item_func = 'PyList_New', 'PyList_SET_ITEM' + elif self.type is tuple_type: + create_func, set_item_func = 'PyTuple_New', 'PyTuple_SET_ITEM' + else: + raise InternalError("sequence packing for unexpected type %s" % self.type) + arg_count = len(self.args) + code.putln("%s = %s(%s%s); %s" % ( + target, create_func, arg_count, size_factor, + code.error_goto_if_null(target, self.pos))) + code.put_gotref(target) + + if c_mult: + # FIXME: can't use a temp variable here as the code may + # end up in the constant building function. Temps + # currently don't work there. + + #counter = code.funcstate.allocate_temp(mult_factor.type, manage_ref=False) + counter = Naming.quick_temp_cname + code.putln('{ Py_ssize_t %s;' % counter) + if arg_count == 1: + offset = counter + else: + offset = '%s * %s' % (counter, arg_count) + code.putln('for (%s=0; %s < %s; %s++) {' % ( + counter, counter, c_mult, counter + )) + else: + offset = '' + + for i in range(arg_count): + arg = self.args[i] + if c_mult or not arg.result_in_temp(): + code.put_incref(arg.result(), arg.ctype()) + code.put_giveref(arg.py_result()) + code.putln("%s(%s, %s, %s);" % ( + set_item_func, + target, + (offset and i) and ('%s + %s' % (offset, i)) or (offset or i), + arg.py_result())) + + if c_mult: + code.putln('}') + #code.funcstate.release_temp(counter) + code.putln('}') + + if mult_factor is not None and mult_factor.type.is_pyobject: + code.putln('{ PyObject* %s = PyNumber_InPlaceMultiply(%s, %s); %s' % ( + Naming.quick_temp_cname, target, mult_factor.py_result(), + code.error_goto_if_null(Naming.quick_temp_cname, self.pos) + )) + code.put_gotref(Naming.quick_temp_cname) + code.put_decref(target, py_object_type) + code.putln('%s = %s;' % (target, Naming.quick_temp_cname)) + code.putln('}') + + def generate_subexpr_disposal_code(self, code): + if self.mult_factor and self.mult_factor.type.is_int: + super(SequenceNode, self).generate_subexpr_disposal_code(code) + elif self.type is tuple_type and (self.is_literal or self.slow): + super(SequenceNode, self).generate_subexpr_disposal_code(code) + else: + # We call generate_post_assignment_code here instead + # of generate_disposal_code, because values were stored + # in the tuple using a reference-stealing operation. + for arg in self.args: + arg.generate_post_assignment_code(code) + # Should NOT call free_temps -- this is invoked by the default + # generate_evaluation_code which will do that. + if self.mult_factor: + self.mult_factor.generate_disposal_code(code) + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False, + exception_check=None, exception_value=None): + if self.starred_assignment: + self.generate_starred_assignment_code(rhs, code) + else: + self.generate_parallel_assignment_code(rhs, code) + + for item in self.unpacked_items: + item.release(code) + rhs.free_temps(code) + + _func_iternext_type = PyrexTypes.CPtrType(PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None), + ])) + + def generate_parallel_assignment_code(self, rhs, code): + # Need to work around the fact that generate_evaluation_code + # allocates the temps in a rather hacky way -- the assignment + # is evaluated twice, within each if-block. + for item in self.unpacked_items: + item.allocate(code) + special_unpack = (rhs.type is py_object_type + or rhs.type in (tuple_type, list_type) + or not rhs.type.is_builtin_type) + long_enough_for_a_loop = len(self.unpacked_items) > 3 + + if special_unpack: + self.generate_special_parallel_unpacking_code( + code, rhs, use_loop=long_enough_for_a_loop) + else: + code.putln("{") + self.generate_generic_parallel_unpacking_code( + code, rhs, self.unpacked_items, use_loop=long_enough_for_a_loop) + code.putln("}") + + for value_node in self.coerced_unpacked_items: + value_node.generate_evaluation_code(code) + for i in range(len(self.args)): + self.args[i].generate_assignment_code( + self.coerced_unpacked_items[i], code) + + def generate_special_parallel_unpacking_code(self, code, rhs, use_loop): + sequence_type_test = '1' + none_check = "likely(%s != Py_None)" % rhs.py_result() + if rhs.type is list_type: + sequence_types = ['List'] + if rhs.may_be_none(): + sequence_type_test = none_check + elif rhs.type is tuple_type: + sequence_types = ['Tuple'] + if rhs.may_be_none(): + sequence_type_test = none_check + else: + sequence_types = ['Tuple', 'List'] + tuple_check = 'likely(PyTuple_CheckExact(%s))' % rhs.py_result() + list_check = 'PyList_CheckExact(%s)' % rhs.py_result() + sequence_type_test = "(%s) || (%s)" % (tuple_check, list_check) + + code.putln("if (%s) {" % sequence_type_test) + code.putln("PyObject* sequence = %s;" % rhs.py_result()) + + # list/tuple => check size + code.putln("Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);") + code.putln("if (unlikely(size != %d)) {" % len(self.args)) + code.globalstate.use_utility_code(raise_too_many_values_to_unpack) + code.putln("if (size > %d) __Pyx_RaiseTooManyValuesError(%d);" % ( + len(self.args), len(self.args))) + code.globalstate.use_utility_code(raise_need_more_values_to_unpack) + code.putln("else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);") + # < 0 => exception + code.putln(code.error_goto(self.pos)) + code.putln("}") + + code.putln("#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS") + # unpack items from list/tuple in unrolled loop (can't fail) + if len(sequence_types) == 2: + code.putln("if (likely(Py%s_CheckExact(sequence))) {" % sequence_types[0]) + for i, item in enumerate(self.unpacked_items): + code.putln("%s = Py%s_GET_ITEM(sequence, %d); " % ( + item.result(), sequence_types[0], i)) + if len(sequence_types) == 2: + code.putln("} else {") + for i, item in enumerate(self.unpacked_items): + code.putln("%s = Py%s_GET_ITEM(sequence, %d); " % ( + item.result(), sequence_types[1], i)) + code.putln("}") + for item in self.unpacked_items: + code.put_incref(item.result(), item.ctype()) + + code.putln("#else") + # in non-CPython, use the PySequence protocol (which can fail) + if not use_loop: + for i, item in enumerate(self.unpacked_items): + code.putln("%s = PySequence_ITEM(sequence, %d); %s" % ( + item.result(), i, + code.error_goto_if_null(item.result(), self.pos))) + code.put_gotref(item.result()) + else: + code.putln("{") + code.putln("Py_ssize_t i;") + code.putln("PyObject** temps[%s] = {%s};" % ( + len(self.unpacked_items), + ','.join(['&%s' % item.result() for item in self.unpacked_items]))) + code.putln("for (i=0; i < %s; i++) {" % len(self.unpacked_items)) + code.putln("PyObject* item = PySequence_ITEM(sequence, i); %s" % ( + code.error_goto_if_null('item', self.pos))) + code.put_gotref('item') + code.putln("*(temps[i]) = item;") + code.putln("}") + code.putln("}") + + code.putln("#endif") + rhs.generate_disposal_code(code) + + if sequence_type_test == '1': + code.putln("}") # all done + elif sequence_type_test == none_check: + # either tuple/list or None => save some code by generating the error directly + code.putln("} else {") + code.globalstate.use_utility_code( + UtilityCode.load_cached("RaiseNoneIterError", "ObjectHandling.c")) + code.putln("__Pyx_RaiseNoneNotIterableError(); %s" % code.error_goto(self.pos)) + code.putln("}") # all done + else: + code.putln("} else {") # needs iteration fallback code + self.generate_generic_parallel_unpacking_code( + code, rhs, self.unpacked_items, use_loop=use_loop) + code.putln("}") + + def generate_generic_parallel_unpacking_code(self, code, rhs, unpacked_items, use_loop, terminate=True): + code.globalstate.use_utility_code(raise_need_more_values_to_unpack) + code.globalstate.use_utility_code(UtilityCode.load_cached("IterFinish", "ObjectHandling.c")) + code.putln("Py_ssize_t index = -1;") # must be at the start of a C block! + + if use_loop: + code.putln("PyObject** temps[%s] = {%s};" % ( + len(self.unpacked_items), + ','.join(['&%s' % item.result() for item in unpacked_items]))) + + iterator_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + code.putln( + "%s = PyObject_GetIter(%s); %s" % ( + iterator_temp, + rhs.py_result(), + code.error_goto_if_null(iterator_temp, self.pos))) + code.put_gotref(iterator_temp) + rhs.generate_disposal_code(code) + + iternext_func = code.funcstate.allocate_temp(self._func_iternext_type, manage_ref=False) + code.putln("%s = Py_TYPE(%s)->tp_iternext;" % ( + iternext_func, iterator_temp)) + + unpacking_error_label = code.new_label('unpacking_failed') + unpack_code = "%s(%s)" % (iternext_func, iterator_temp) + if use_loop: + code.putln("for (index=0; index < %s; index++) {" % len(unpacked_items)) + code.put("PyObject* item = %s; if (unlikely(!item)) " % unpack_code) + code.put_goto(unpacking_error_label) + code.put_gotref("item") + code.putln("*(temps[index]) = item;") + code.putln("}") + else: + for i, item in enumerate(unpacked_items): + code.put( + "index = %d; %s = %s; if (unlikely(!%s)) " % ( + i, + item.result(), + unpack_code, + item.result())) + code.put_goto(unpacking_error_label) + code.put_gotref(item.py_result()) + + if terminate: + code.globalstate.use_utility_code( + UtilityCode.load_cached("UnpackItemEndCheck", "ObjectHandling.c")) + code.put_error_if_neg(self.pos, "__Pyx_IternextUnpackEndCheck(%s, %d)" % ( + unpack_code, + len(unpacked_items))) + code.putln("%s = NULL;" % iternext_func) + code.put_decref_clear(iterator_temp, py_object_type) + + unpacking_done_label = code.new_label('unpacking_done') + code.put_goto(unpacking_done_label) + + code.put_label(unpacking_error_label) + code.put_decref_clear(iterator_temp, py_object_type) + code.putln("%s = NULL;" % iternext_func) + code.putln("if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);") + code.putln(code.error_goto(self.pos)) + code.put_label(unpacking_done_label) + + code.funcstate.release_temp(iternext_func) + if terminate: + code.funcstate.release_temp(iterator_temp) + iterator_temp = None + + return iterator_temp + + def generate_starred_assignment_code(self, rhs, code): + for i, arg in enumerate(self.args): + if arg.is_starred: + starred_target = self.unpacked_items[i] + unpacked_fixed_items_left = self.unpacked_items[:i] + unpacked_fixed_items_right = self.unpacked_items[i+1:] + break + else: + assert False + + iterator_temp = None + if unpacked_fixed_items_left: + for item in unpacked_fixed_items_left: + item.allocate(code) + code.putln('{') + iterator_temp = self.generate_generic_parallel_unpacking_code( + code, rhs, unpacked_fixed_items_left, + use_loop=True, terminate=False) + for i, item in enumerate(unpacked_fixed_items_left): + value_node = self.coerced_unpacked_items[i] + value_node.generate_evaluation_code(code) + code.putln('}') + + starred_target.allocate(code) + target_list = starred_target.result() + code.putln("%s = PySequence_List(%s); %s" % ( + target_list, + iterator_temp or rhs.py_result(), + code.error_goto_if_null(target_list, self.pos))) + code.put_gotref(target_list) + + if iterator_temp: + code.put_decref_clear(iterator_temp, py_object_type) + code.funcstate.release_temp(iterator_temp) + else: + rhs.generate_disposal_code(code) + + if unpacked_fixed_items_right: + code.globalstate.use_utility_code(raise_need_more_values_to_unpack) + length_temp = code.funcstate.allocate_temp(PyrexTypes.c_py_ssize_t_type, manage_ref=False) + code.putln('%s = PyList_GET_SIZE(%s);' % (length_temp, target_list)) + code.putln("if (unlikely(%s < %d)) {" % (length_temp, len(unpacked_fixed_items_right))) + code.putln("__Pyx_RaiseNeedMoreValuesError(%d+%s); %s" % ( + len(unpacked_fixed_items_left), length_temp, + code.error_goto(self.pos))) + code.putln('}') + + for item in unpacked_fixed_items_right[::-1]: + item.allocate(code) + for i, (item, coerced_arg) in enumerate(zip(unpacked_fixed_items_right[::-1], + self.coerced_unpacked_items[::-1])): + code.putln('#if CYTHON_COMPILING_IN_CPYTHON') + code.putln("%s = PyList_GET_ITEM(%s, %s-%d); " % ( + item.py_result(), target_list, length_temp, i+1)) + # resize the list the hard way + code.putln("((PyVarObject*)%s)->ob_size--;" % target_list) + code.putln('#else') + code.putln("%s = PySequence_ITEM(%s, %s-%d); " % ( + item.py_result(), target_list, length_temp, i+1)) + code.putln('#endif') + code.put_gotref(item.py_result()) + coerced_arg.generate_evaluation_code(code) + + code.putln('#if !CYTHON_COMPILING_IN_CPYTHON') + sublist_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + code.putln('%s = PySequence_GetSlice(%s, 0, %s-%d); %s' % ( + sublist_temp, target_list, length_temp, len(unpacked_fixed_items_right), + code.error_goto_if_null(sublist_temp, self.pos))) + code.put_gotref(sublist_temp) + code.funcstate.release_temp(length_temp) + code.put_decref(target_list, py_object_type) + code.putln('%s = %s; %s = NULL;' % (target_list, sublist_temp, sublist_temp)) + code.putln('#else') + code.putln('(void)%s;' % sublist_temp) # avoid warning about unused variable + code.funcstate.release_temp(sublist_temp) + code.putln('#endif') + + for i, arg in enumerate(self.args): + arg.generate_assignment_code(self.coerced_unpacked_items[i], code) + + def annotate(self, code): + for arg in self.args: + arg.annotate(code) + if self.unpacked_items: + for arg in self.unpacked_items: + arg.annotate(code) + for arg in self.coerced_unpacked_items: + arg.annotate(code) + + +class TupleNode(SequenceNode): + # Tuple constructor. + + type = tuple_type + is_partly_literal = False + + gil_message = "Constructing Python tuple" + + def infer_type(self, env): + if self.mult_factor or not self.args: + return tuple_type + arg_types = [arg.infer_type(env) for arg in self.args] + if any(type.is_pyobject or type.is_memoryviewslice or type.is_unspecified or type.is_fused + for type in arg_types): + return tuple_type + return env.declare_tuple_type(self.pos, arg_types).type + + def analyse_types(self, env, skip_children=False): + if len(self.args) == 0: + self.is_temp = False + self.is_literal = True + return self + + if not skip_children: + for i, arg in enumerate(self.args): + if arg.is_starred: + arg.starred_expr_allowed_here = True + self.args[i] = arg.analyse_types(env) + if (not self.mult_factor and + not any((arg.is_starred or arg.type.is_pyobject or arg.type.is_memoryviewslice or arg.type.is_fused) + for arg in self.args)): + self.type = env.declare_tuple_type(self.pos, (arg.type for arg in self.args)).type + self.is_temp = 1 + return self + + node = SequenceNode.analyse_types(self, env, skip_children=True) + node = node._create_merge_node_if_necessary(env) + if not node.is_sequence_constructor: + return node + + if not all(child.is_literal for child in node.args): + return node + if not node.mult_factor or ( + node.mult_factor.is_literal and + isinstance(node.mult_factor.constant_result, _py_int_types)): + node.is_temp = False + node.is_literal = True + else: + if not node.mult_factor.type.is_pyobject: + node.mult_factor = node.mult_factor.coerce_to_pyobject(env) + node.is_temp = True + node.is_partly_literal = True + return node + + def analyse_as_type(self, env): + # ctuple type + if not self.args: + return None + item_types = [arg.analyse_as_type(env) for arg in self.args] + if any(t is None for t in item_types): + return None + entry = env.declare_tuple_type(self.pos, item_types) + return entry.type + + def coerce_to(self, dst_type, env): + if self.type.is_ctuple: + if dst_type.is_ctuple and self.type.size == dst_type.size: + return self.coerce_to_ctuple(dst_type, env) + elif dst_type is tuple_type or dst_type is py_object_type: + coerced_args = [arg.coerce_to_pyobject(env) for arg in self.args] + return TupleNode(self.pos, args=coerced_args, type=tuple_type, is_temp=1).analyse_types(env, skip_children=True) + else: + return self.coerce_to_pyobject(env).coerce_to(dst_type, env) + elif dst_type.is_ctuple and not self.mult_factor: + return self.coerce_to_ctuple(dst_type, env) + else: + return SequenceNode.coerce_to(self, dst_type, env) + + def as_list(self): + t = ListNode(self.pos, args=self.args, mult_factor=self.mult_factor) + if isinstance(self.constant_result, tuple): + t.constant_result = list(self.constant_result) + return t + + def is_simple(self): + # either temp or constant => always simple + return True + + def nonlocally_immutable(self): + # either temp or constant => always safe + return True + + def calculate_result_code(self): + if len(self.args) > 0: + return self.result_code + else: + return Naming.empty_tuple + + def calculate_constant_result(self): + self.constant_result = tuple([ + arg.constant_result for arg in self.args]) + + def compile_time_value(self, denv): + values = self.compile_time_value_list(denv) + try: + return tuple(values) + except Exception as e: + self.compile_time_value_error(e) + + def generate_operation_code(self, code): + if len(self.args) == 0: + # result_code is Naming.empty_tuple + return + + if self.is_literal or self.is_partly_literal: + # The "mult_factor" is part of the deduplication if it is also constant, i.e. when + # we deduplicate the multiplied result. Otherwise, only deduplicate the constant part. + dedup_key = make_dedup_key(self.type, [self.mult_factor if self.is_literal else None] + self.args) + tuple_target = code.get_py_const(py_object_type, 'tuple', cleanup_level=2, dedup_key=dedup_key) + const_code = code.get_cached_constants_writer(tuple_target) + if const_code is not None: + # constant is not yet initialised + const_code.mark_pos(self.pos) + self.generate_sequence_packing_code(const_code, tuple_target, plain=not self.is_literal) + const_code.put_giveref(tuple_target) + if self.is_literal: + self.result_code = tuple_target + else: + code.putln('%s = PyNumber_Multiply(%s, %s); %s' % ( + self.result(), tuple_target, self.mult_factor.py_result(), + code.error_goto_if_null(self.result(), self.pos) + )) + code.put_gotref(self.py_result()) + else: + self.type.entry.used = True + self.generate_sequence_packing_code(code) + + +class ListNode(SequenceNode): + # List constructor. + + # obj_conversion_errors [PyrexError] used internally + # orignial_args [ExprNode] used internally + + obj_conversion_errors = [] + type = list_type + in_module_scope = False + + gil_message = "Constructing Python list" + + def type_dependencies(self, env): + return () + + def infer_type(self, env): + # TODO: Infer non-object list arrays. + return list_type + + def analyse_expressions(self, env): + for arg in self.args: + if arg.is_starred: + arg.starred_expr_allowed_here = True + node = SequenceNode.analyse_expressions(self, env) + return node.coerce_to_pyobject(env) + + def analyse_types(self, env): + with local_errors(ignore=True) as errors: + self.original_args = list(self.args) + node = SequenceNode.analyse_types(self, env) + node.obj_conversion_errors = errors + if env.is_module_scope: + self.in_module_scope = True + node = node._create_merge_node_if_necessary(env) + return node + + def coerce_to(self, dst_type, env): + if dst_type.is_pyobject: + for err in self.obj_conversion_errors: + report_error(err) + self.obj_conversion_errors = [] + if not self.type.subtype_of(dst_type): + error(self.pos, "Cannot coerce list to type '%s'" % dst_type) + elif (dst_type.is_array or dst_type.is_ptr) and dst_type.base_type is not PyrexTypes.c_void_type: + array_length = len(self.args) + if self.mult_factor: + if isinstance(self.mult_factor.constant_result, _py_int_types): + if self.mult_factor.constant_result <= 0: + error(self.pos, "Cannot coerce non-positively multiplied list to '%s'" % dst_type) + else: + array_length *= self.mult_factor.constant_result + else: + error(self.pos, "Cannot coerce dynamically multiplied list to '%s'" % dst_type) + base_type = dst_type.base_type + self.type = PyrexTypes.CArrayType(base_type, array_length) + for i in range(len(self.original_args)): + arg = self.args[i] + if isinstance(arg, CoerceToPyTypeNode): + arg = arg.arg + self.args[i] = arg.coerce_to(base_type, env) + elif dst_type.is_cpp_class: + # TODO(robertwb): Avoid object conversion for vector/list/set. + return TypecastNode(self.pos, operand=self, type=PyrexTypes.py_object_type).coerce_to(dst_type, env) + elif self.mult_factor: + error(self.pos, "Cannot coerce multiplied list to '%s'" % dst_type) + elif dst_type.is_struct: + if len(self.args) > len(dst_type.scope.var_entries): + error(self.pos, "Too many members for '%s'" % dst_type) + else: + if len(self.args) < len(dst_type.scope.var_entries): + warning(self.pos, "Too few members for '%s'" % dst_type, 1) + for i, (arg, member) in enumerate(zip(self.original_args, dst_type.scope.var_entries)): + if isinstance(arg, CoerceToPyTypeNode): + arg = arg.arg + self.args[i] = arg.coerce_to(member.type, env) + self.type = dst_type + elif dst_type.is_ctuple: + return self.coerce_to_ctuple(dst_type, env) + else: + self.type = error_type + error(self.pos, "Cannot coerce list to type '%s'" % dst_type) + return self + + def as_list(self): # dummy for compatibility with TupleNode + return self + + def as_tuple(self): + t = TupleNode(self.pos, args=self.args, mult_factor=self.mult_factor) + if isinstance(self.constant_result, list): + t.constant_result = tuple(self.constant_result) + return t + + def allocate_temp_result(self, code): + if self.type.is_array: + if self.in_module_scope: + self.temp_code = code.funcstate.allocate_temp( + self.type, manage_ref=False, static=True, reusable=False) + else: + # To be valid C++, we must allocate the memory on the stack + # manually and be sure not to reuse it for something else. + # Yes, this means that we leak a temp array variable. + self.temp_code = code.funcstate.allocate_temp( + self.type, manage_ref=False, reusable=False) + else: + SequenceNode.allocate_temp_result(self, code) + + def calculate_constant_result(self): + if self.mult_factor: + raise ValueError() # may exceed the compile time memory + self.constant_result = [ + arg.constant_result for arg in self.args] + + def compile_time_value(self, denv): + l = self.compile_time_value_list(denv) + if self.mult_factor: + l *= self.mult_factor.compile_time_value(denv) + return l + + def generate_operation_code(self, code): + if self.type.is_pyobject: + for err in self.obj_conversion_errors: + report_error(err) + self.generate_sequence_packing_code(code) + elif self.type.is_array: + if self.mult_factor: + code.putln("{") + code.putln("Py_ssize_t %s;" % Naming.quick_temp_cname) + code.putln("for ({i} = 0; {i} < {count}; {i}++) {{".format( + i=Naming.quick_temp_cname, count=self.mult_factor.result())) + offset = '+ (%d * %s)' % (len(self.args), Naming.quick_temp_cname) + else: + offset = '' + for i, arg in enumerate(self.args): + if arg.type.is_array: + code.globalstate.use_utility_code(UtilityCode.load_cached("IncludeStringH", "StringTools.c")) + code.putln("memcpy(&(%s[%s%s]), %s, sizeof(%s[0]));" % ( + self.result(), i, offset, + arg.result(), self.result() + )) + else: + code.putln("%s[%s%s] = %s;" % ( + self.result(), + i, + offset, + arg.result())) + if self.mult_factor: + code.putln("}") + code.putln("}") + elif self.type.is_struct: + for arg, member in zip(self.args, self.type.scope.var_entries): + code.putln("%s.%s = %s;" % ( + self.result(), + member.cname, + arg.result())) + else: + raise InternalError("List type never specified") + + +class ScopedExprNode(ExprNode): + # Abstract base class for ExprNodes that have their own local + # scope, such as generator expressions. + # + # expr_scope Scope the inner scope of the expression + + subexprs = [] + expr_scope = None + + # does this node really have a local scope, e.g. does it leak loop + # variables or not? non-leaking Py3 behaviour is default, except + # for list comprehensions where the behaviour differs in Py2 and + # Py3 (set in Parsing.py based on parser context) + has_local_scope = True + + def init_scope(self, outer_scope, expr_scope=None): + if expr_scope is not None: + self.expr_scope = expr_scope + elif self.has_local_scope: + self.expr_scope = Symtab.GeneratorExpressionScope(outer_scope) + else: + self.expr_scope = None + + def analyse_declarations(self, env): + self.init_scope(env) + + def analyse_scoped_declarations(self, env): + # this is called with the expr_scope as env + pass + + def analyse_types(self, env): + # no recursion here, the children will be analysed separately below + return self + + def analyse_scoped_expressions(self, env): + # this is called with the expr_scope as env + return self + + def generate_evaluation_code(self, code): + # set up local variables and free their references on exit + generate_inner_evaluation_code = super(ScopedExprNode, self).generate_evaluation_code + if not self.has_local_scope or not self.expr_scope.var_entries: + # no local variables => delegate, done + generate_inner_evaluation_code(code) + return + + code.putln('{ /* enter inner scope */') + py_entries = [] + for _, entry in sorted(item for item in self.expr_scope.entries.items() if item[0]): + if not entry.in_closure: + if entry.type.is_pyobject and entry.used: + py_entries.append(entry) + if not py_entries: + # no local Python references => no cleanup required + generate_inner_evaluation_code(code) + code.putln('} /* exit inner scope */') + return + + # must free all local Python references at each exit point + old_loop_labels = code.new_loop_labels() + old_error_label = code.new_error_label() + + generate_inner_evaluation_code(code) + + # normal (non-error) exit + self._generate_vars_cleanup(code, py_entries) + + # error/loop body exit points + exit_scope = code.new_label('exit_scope') + code.put_goto(exit_scope) + for label, old_label in ([(code.error_label, old_error_label)] + + list(zip(code.get_loop_labels(), old_loop_labels))): + if code.label_used(label): + code.put_label(label) + self._generate_vars_cleanup(code, py_entries) + code.put_goto(old_label) + code.put_label(exit_scope) + code.putln('} /* exit inner scope */') + + code.set_loop_labels(old_loop_labels) + code.error_label = old_error_label + + def _generate_vars_cleanup(self, code, py_entries): + for entry in py_entries: + if entry.is_cglobal: + code.put_var_gotref(entry) + code.put_decref_set(entry.cname, "Py_None") + else: + code.put_var_xdecref_clear(entry) + + +class ComprehensionNode(ScopedExprNode): + # A list/set/dict comprehension + + child_attrs = ["loop"] + + is_temp = True + constant_result = not_a_constant + + def infer_type(self, env): + return self.type + + def analyse_declarations(self, env): + self.append.target = self # this is used in the PyList_Append of the inner loop + self.init_scope(env) + + def analyse_scoped_declarations(self, env): + self.loop.analyse_declarations(env) + + def analyse_types(self, env): + if not self.has_local_scope: + self.loop = self.loop.analyse_expressions(env) + return self + + def analyse_scoped_expressions(self, env): + if self.has_local_scope: + self.loop = self.loop.analyse_expressions(env) + return self + + def may_be_none(self): + return False + + def generate_result_code(self, code): + self.generate_operation_code(code) + + def generate_operation_code(self, code): + if self.type is Builtin.list_type: + create_code = 'PyList_New(0)' + elif self.type is Builtin.set_type: + create_code = 'PySet_New(NULL)' + elif self.type is Builtin.dict_type: + create_code = 'PyDict_New()' + else: + raise InternalError("illegal type for comprehension: %s" % self.type) + code.putln('%s = %s; %s' % ( + self.result(), create_code, + code.error_goto_if_null(self.result(), self.pos))) + + code.put_gotref(self.result()) + self.loop.generate_execution_code(code) + + def annotate(self, code): + self.loop.annotate(code) + + +class ComprehensionAppendNode(Node): + # Need to be careful to avoid infinite recursion: + # target must not be in child_attrs/subexprs + + child_attrs = ['expr'] + target = None + + type = PyrexTypes.c_int_type + + def analyse_expressions(self, env): + self.expr = self.expr.analyse_expressions(env) + if not self.expr.type.is_pyobject: + self.expr = self.expr.coerce_to_pyobject(env) + return self + + def generate_execution_code(self, code): + if self.target.type is list_type: + code.globalstate.use_utility_code( + UtilityCode.load_cached("ListCompAppend", "Optimize.c")) + function = "__Pyx_ListComp_Append" + elif self.target.type is set_type: + function = "PySet_Add" + else: + raise InternalError( + "Invalid type for comprehension node: %s" % self.target.type) + + self.expr.generate_evaluation_code(code) + code.putln(code.error_goto_if("%s(%s, (PyObject*)%s)" % ( + function, + self.target.result(), + self.expr.result() + ), self.pos)) + self.expr.generate_disposal_code(code) + self.expr.free_temps(code) + + def generate_function_definitions(self, env, code): + self.expr.generate_function_definitions(env, code) + + def annotate(self, code): + self.expr.annotate(code) + +class DictComprehensionAppendNode(ComprehensionAppendNode): + child_attrs = ['key_expr', 'value_expr'] + + def analyse_expressions(self, env): + self.key_expr = self.key_expr.analyse_expressions(env) + if not self.key_expr.type.is_pyobject: + self.key_expr = self.key_expr.coerce_to_pyobject(env) + self.value_expr = self.value_expr.analyse_expressions(env) + if not self.value_expr.type.is_pyobject: + self.value_expr = self.value_expr.coerce_to_pyobject(env) + return self + + def generate_execution_code(self, code): + self.key_expr.generate_evaluation_code(code) + self.value_expr.generate_evaluation_code(code) + code.putln(code.error_goto_if("PyDict_SetItem(%s, (PyObject*)%s, (PyObject*)%s)" % ( + self.target.result(), + self.key_expr.result(), + self.value_expr.result() + ), self.pos)) + self.key_expr.generate_disposal_code(code) + self.key_expr.free_temps(code) + self.value_expr.generate_disposal_code(code) + self.value_expr.free_temps(code) + + def generate_function_definitions(self, env, code): + self.key_expr.generate_function_definitions(env, code) + self.value_expr.generate_function_definitions(env, code) + + def annotate(self, code): + self.key_expr.annotate(code) + self.value_expr.annotate(code) + + +class InlinedGeneratorExpressionNode(ExprNode): + # An inlined generator expression for which the result is calculated + # inside of the loop and returned as a single, first and only Generator + # return value. + # This will only be created by transforms when replacing safe builtin + # calls on generator expressions. + # + # gen GeneratorExpressionNode the generator, not containing any YieldExprNodes + # orig_func String the name of the builtin function this node replaces + # target ExprNode or None a 'target' for a ComprehensionAppend node + + subexprs = ["gen"] + orig_func = None + target = None + is_temp = True + type = py_object_type + + def __init__(self, pos, gen, comprehension_type=None, **kwargs): + gbody = gen.def_node.gbody + gbody.is_inlined = True + if comprehension_type is not None: + assert comprehension_type in (list_type, set_type, dict_type), comprehension_type + gbody.inlined_comprehension_type = comprehension_type + kwargs.update( + target=RawCNameExprNode(pos, comprehension_type, Naming.retval_cname), + type=comprehension_type, + ) + super(InlinedGeneratorExpressionNode, self).__init__(pos, gen=gen, **kwargs) + + def may_be_none(self): + return self.orig_func not in ('any', 'all', 'sorted') + + def infer_type(self, env): + return self.type + + def analyse_types(self, env): + self.gen = self.gen.analyse_expressions(env) + return self + + def generate_result_code(self, code): + code.putln("%s = __Pyx_Generator_Next(%s); %s" % ( + self.result(), self.gen.result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.result()) + + +class MergedSequenceNode(ExprNode): + """ + Merge a sequence of iterables into a set/list/tuple. + + The target collection is determined by self.type, which must be set externally. + + args [ExprNode] + """ + subexprs = ['args'] + is_temp = True + gil_message = "Constructing Python collection" + + def __init__(self, pos, args, type): + if type in (list_type, tuple_type) and args and args[0].is_sequence_constructor: + # construct a list directly from the first argument that we can then extend + if args[0].type is not list_type: + args[0] = ListNode(args[0].pos, args=args[0].args, is_temp=True, mult_factor=args[0].mult_factor) + ExprNode.__init__(self, pos, args=args, type=type) + + def calculate_constant_result(self): + result = [] + for item in self.args: + if item.is_sequence_constructor and item.mult_factor: + if item.mult_factor.constant_result <= 0: + continue + # otherwise, adding each item once should be enough + if item.is_set_literal or item.is_sequence_constructor: + # process items in order + items = (arg.constant_result for arg in item.args) + else: + items = item.constant_result + result.extend(items) + if self.type is set_type: + result = set(result) + elif self.type is tuple_type: + result = tuple(result) + else: + assert self.type is list_type + self.constant_result = result + + def compile_time_value(self, denv): + result = [] + for item in self.args: + if item.is_sequence_constructor and item.mult_factor: + if item.mult_factor.compile_time_value(denv) <= 0: + continue + if item.is_set_literal or item.is_sequence_constructor: + # process items in order + items = (arg.compile_time_value(denv) for arg in item.args) + else: + items = item.compile_time_value(denv) + result.extend(items) + if self.type is set_type: + try: + result = set(result) + except Exception as e: + self.compile_time_value_error(e) + elif self.type is tuple_type: + result = tuple(result) + else: + assert self.type is list_type + return result + + def type_dependencies(self, env): + return () + + def infer_type(self, env): + return self.type + + def analyse_types(self, env): + args = [ + arg.analyse_types(env).coerce_to_pyobject(env).as_none_safe_node( + # FIXME: CPython's error message starts with the runtime function name + 'argument after * must be an iterable, not NoneType') + for arg in self.args + ] + + if len(args) == 1 and args[0].type is self.type: + # strip this intermediate node and use the bare collection + return args[0] + + assert self.type in (set_type, list_type, tuple_type) + + self.args = args + return self + + def may_be_none(self): + return False + + def generate_evaluation_code(self, code): + code.mark_pos(self.pos) + self.allocate_temp_result(code) + + is_set = self.type is set_type + + args = iter(self.args) + item = next(args) + item.generate_evaluation_code(code) + if (is_set and item.is_set_literal or + not is_set and item.is_sequence_constructor and item.type is list_type): + code.putln("%s = %s;" % (self.result(), item.py_result())) + item.generate_post_assignment_code(code) + else: + code.putln("%s = %s(%s); %s" % ( + self.result(), + 'PySet_New' if is_set else 'PySequence_List', + item.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + item.generate_disposal_code(code) + item.free_temps(code) + + helpers = set() + if is_set: + add_func = "PySet_Add" + extend_func = "__Pyx_PySet_Update" + else: + add_func = "__Pyx_ListComp_Append" + extend_func = "__Pyx_PyList_Extend" + + for item in args: + if (is_set and (item.is_set_literal or item.is_sequence_constructor) or + (item.is_sequence_constructor and not item.mult_factor)): + if not is_set and item.args: + helpers.add(("ListCompAppend", "Optimize.c")) + for arg in item.args: + arg.generate_evaluation_code(code) + code.put_error_if_neg(arg.pos, "%s(%s, %s)" % ( + add_func, + self.result(), + arg.py_result())) + arg.generate_disposal_code(code) + arg.free_temps(code) + continue + + if is_set: + helpers.add(("PySet_Update", "Builtins.c")) + else: + helpers.add(("ListExtend", "Optimize.c")) + + item.generate_evaluation_code(code) + code.put_error_if_neg(item.pos, "%s(%s, %s)" % ( + extend_func, + self.result(), + item.py_result())) + item.generate_disposal_code(code) + item.free_temps(code) + + if self.type is tuple_type: + code.putln("{") + code.putln("PyObject *%s = PyList_AsTuple(%s);" % ( + Naming.quick_temp_cname, + self.result())) + code.put_decref(self.result(), py_object_type) + code.putln("%s = %s; %s" % ( + self.result(), + Naming.quick_temp_cname, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.result()) + code.putln("}") + + for helper in sorted(helpers): + code.globalstate.use_utility_code(UtilityCode.load_cached(*helper)) + + def annotate(self, code): + for item in self.args: + item.annotate(code) + + +class SetNode(ExprNode): + """ + Set constructor. + """ + subexprs = ['args'] + type = set_type + is_set_literal = True + gil_message = "Constructing Python set" + + def analyse_types(self, env): + for i in range(len(self.args)): + arg = self.args[i] + arg = arg.analyse_types(env) + self.args[i] = arg.coerce_to_pyobject(env) + self.type = set_type + self.is_temp = 1 + return self + + def may_be_none(self): + return False + + def calculate_constant_result(self): + self.constant_result = set([arg.constant_result for arg in self.args]) + + def compile_time_value(self, denv): + values = [arg.compile_time_value(denv) for arg in self.args] + try: + return set(values) + except Exception as e: + self.compile_time_value_error(e) + + def generate_evaluation_code(self, code): + for arg in self.args: + arg.generate_evaluation_code(code) + self.allocate_temp_result(code) + code.putln( + "%s = PySet_New(0); %s" % ( + self.result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + for arg in self.args: + code.put_error_if_neg( + self.pos, + "PySet_Add(%s, %s)" % (self.result(), arg.py_result())) + arg.generate_disposal_code(code) + arg.free_temps(code) + + +class DictNode(ExprNode): + # Dictionary constructor. + # + # key_value_pairs [DictItemNode] + # exclude_null_values [boolean] Do not add NULL values to dict + # + # obj_conversion_errors [PyrexError] used internally + + subexprs = ['key_value_pairs'] + is_temp = 1 + exclude_null_values = False + type = dict_type + is_dict_literal = True + reject_duplicates = False + + obj_conversion_errors = [] + + @classmethod + def from_pairs(cls, pos, pairs): + return cls(pos, key_value_pairs=[ + DictItemNode(pos, key=k, value=v) for k, v in pairs]) + + def calculate_constant_result(self): + self.constant_result = dict([ + item.constant_result for item in self.key_value_pairs]) + + def compile_time_value(self, denv): + pairs = [(item.key.compile_time_value(denv), item.value.compile_time_value(denv)) + for item in self.key_value_pairs] + try: + return dict(pairs) + except Exception as e: + self.compile_time_value_error(e) + + def type_dependencies(self, env): + return () + + def infer_type(self, env): + # TODO: Infer struct constructors. + return dict_type + + def analyse_types(self, env): + with local_errors(ignore=True) as errors: + self.key_value_pairs = [ + item.analyse_types(env) + for item in self.key_value_pairs + ] + self.obj_conversion_errors = errors + return self + + def may_be_none(self): + return False + + def coerce_to(self, dst_type, env): + if dst_type.is_pyobject: + self.release_errors() + if self.type.is_struct_or_union: + if not dict_type.subtype_of(dst_type): + error(self.pos, "Cannot interpret struct as non-dict type '%s'" % dst_type) + return DictNode(self.pos, key_value_pairs=[ + DictItemNode(item.pos, key=item.key.coerce_to_pyobject(env), + value=item.value.coerce_to_pyobject(env)) + for item in self.key_value_pairs]) + if not self.type.subtype_of(dst_type): + error(self.pos, "Cannot interpret dict as type '%s'" % dst_type) + elif dst_type.is_struct_or_union: + self.type = dst_type + if not dst_type.is_struct and len(self.key_value_pairs) != 1: + error(self.pos, "Exactly one field must be specified to convert to union '%s'" % dst_type) + elif dst_type.is_struct and len(self.key_value_pairs) < len(dst_type.scope.var_entries): + warning(self.pos, "Not all members given for struct '%s'" % dst_type, 1) + for item in self.key_value_pairs: + if isinstance(item.key, CoerceToPyTypeNode): + item.key = item.key.arg + if not item.key.is_string_literal: + error(item.key.pos, "Invalid struct field identifier") + item.key = StringNode(item.key.pos, value="<error>") + else: + key = str(item.key.value) # converts string literals to unicode in Py3 + member = dst_type.scope.lookup_here(key) + if not member: + error(item.key.pos, "struct '%s' has no field '%s'" % (dst_type, key)) + else: + value = item.value + if isinstance(value, CoerceToPyTypeNode): + value = value.arg + item.value = value.coerce_to(member.type, env) + else: + self.type = error_type + error(self.pos, "Cannot interpret dict as type '%s'" % dst_type) + return self + + def release_errors(self): + for err in self.obj_conversion_errors: + report_error(err) + self.obj_conversion_errors = [] + + gil_message = "Constructing Python dict" + + def generate_evaluation_code(self, code): + # Custom method used here because key-value + # pairs are evaluated and used one at a time. + code.mark_pos(self.pos) + self.allocate_temp_result(code) + + is_dict = self.type.is_pyobject + if is_dict: + self.release_errors() + code.putln( + "%s = __Pyx_PyDict_NewPresized(%d); %s" % ( + self.result(), + len(self.key_value_pairs), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + keys_seen = set() + key_type = None + needs_error_helper = False + + for item in self.key_value_pairs: + item.generate_evaluation_code(code) + if is_dict: + if self.exclude_null_values: + code.putln('if (%s) {' % item.value.py_result()) + key = item.key + if self.reject_duplicates: + if keys_seen is not None: + # avoid runtime 'in' checks for literals that we can do at compile time + if not key.is_string_literal: + keys_seen = None + elif key.value in keys_seen: + # FIXME: this could be a compile time error, at least in Cython code + keys_seen = None + elif key_type is not type(key.value): + if key_type is None: + key_type = type(key.value) + keys_seen.add(key.value) + else: + # different types => may not be able to compare at compile time + keys_seen = None + else: + keys_seen.add(key.value) + + if keys_seen is None: + code.putln('if (unlikely(PyDict_Contains(%s, %s))) {' % ( + self.result(), key.py_result())) + # currently only used in function calls + needs_error_helper = True + code.putln('__Pyx_RaiseDoubleKeywordsError("function", %s); %s' % ( + key.py_result(), + code.error_goto(item.pos))) + code.putln("} else {") + + code.put_error_if_neg(self.pos, "PyDict_SetItem(%s, %s, %s)" % ( + self.result(), + item.key.py_result(), + item.value.py_result())) + if self.reject_duplicates and keys_seen is None: + code.putln('}') + if self.exclude_null_values: + code.putln('}') + else: + code.putln("%s.%s = %s;" % ( + self.result(), + item.key.value, + item.value.result())) + item.generate_disposal_code(code) + item.free_temps(code) + + if needs_error_helper: + code.globalstate.use_utility_code( + UtilityCode.load_cached("RaiseDoubleKeywords", "FunctionArguments.c")) + + def annotate(self, code): + for item in self.key_value_pairs: + item.annotate(code) + + +class DictItemNode(ExprNode): + # Represents a single item in a DictNode + # + # key ExprNode + # value ExprNode + subexprs = ['key', 'value'] + + nogil_check = None # Parent DictNode takes care of it + + def calculate_constant_result(self): + self.constant_result = ( + self.key.constant_result, self.value.constant_result) + + def analyse_types(self, env): + self.key = self.key.analyse_types(env) + self.value = self.value.analyse_types(env) + self.key = self.key.coerce_to_pyobject(env) + self.value = self.value.coerce_to_pyobject(env) + return self + + def generate_evaluation_code(self, code): + self.key.generate_evaluation_code(code) + self.value.generate_evaluation_code(code) + + def generate_disposal_code(self, code): + self.key.generate_disposal_code(code) + self.value.generate_disposal_code(code) + + def free_temps(self, code): + self.key.free_temps(code) + self.value.free_temps(code) + + def __iter__(self): + return iter([self.key, self.value]) + + +class SortedDictKeysNode(ExprNode): + # build sorted list of dict keys, e.g. for dir() + subexprs = ['arg'] + + is_temp = True + + def __init__(self, arg): + ExprNode.__init__(self, arg.pos, arg=arg) + self.type = Builtin.list_type + + def analyse_types(self, env): + arg = self.arg.analyse_types(env) + if arg.type is Builtin.dict_type: + arg = arg.as_none_safe_node( + "'NoneType' object is not iterable") + self.arg = arg + return self + + def may_be_none(self): + return False + + def generate_result_code(self, code): + dict_result = self.arg.py_result() + if self.arg.type is Builtin.dict_type: + code.putln('%s = PyDict_Keys(%s); %s' % ( + self.result(), dict_result, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + else: + # originally used PyMapping_Keys() here, but that may return a tuple + code.globalstate.use_utility_code(UtilityCode.load_cached( + 'PyObjectCallMethod0', 'ObjectHandling.c')) + keys_cname = code.intern_identifier(StringEncoding.EncodedString("keys")) + code.putln('%s = __Pyx_PyObject_CallMethod0(%s, %s); %s' % ( + self.result(), dict_result, keys_cname, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + code.putln("if (unlikely(!PyList_Check(%s))) {" % self.result()) + code.put_decref_set(self.result(), "PySequence_List(%s)" % self.result()) + code.putln(code.error_goto_if_null(self.result(), self.pos)) + code.put_gotref(self.py_result()) + code.putln("}") + code.put_error_if_neg( + self.pos, 'PyList_Sort(%s)' % self.py_result()) + + +class ModuleNameMixin(object): + def get_py_mod_name(self, code): + return code.get_py_string_const( + self.module_name, identifier=True) + + def get_py_qualified_name(self, code): + return code.get_py_string_const( + self.qualname, identifier=True) + + +class ClassNode(ExprNode, ModuleNameMixin): + # Helper class used in the implementation of Python + # class definitions. Constructs a class object given + # a name, tuple of bases and class dictionary. + # + # name EncodedString Name of the class + # class_def_node PyClassDefNode PyClassDefNode defining this class + # doc ExprNode or None Doc string + # module_name EncodedString Name of defining module + + subexprs = ['doc'] + type = py_object_type + is_temp = True + + def infer_type(self, env): + # TODO: could return 'type' in some cases + return py_object_type + + def analyse_types(self, env): + if self.doc: + self.doc = self.doc.analyse_types(env) + self.doc = self.doc.coerce_to_pyobject(env) + env.use_utility_code(UtilityCode.load_cached("CreateClass", "ObjectHandling.c")) + return self + + def may_be_none(self): + return True + + gil_message = "Constructing Python class" + + def generate_result_code(self, code): + class_def_node = self.class_def_node + cname = code.intern_identifier(self.name) + + if self.doc: + code.put_error_if_neg(self.pos, + 'PyDict_SetItem(%s, %s, %s)' % ( + class_def_node.dict.py_result(), + code.intern_identifier( + StringEncoding.EncodedString("__doc__")), + self.doc.py_result())) + py_mod_name = self.get_py_mod_name(code) + qualname = self.get_py_qualified_name(code) + code.putln( + '%s = __Pyx_CreateClass(%s, %s, %s, %s, %s); %s' % ( + self.result(), + class_def_node.bases.py_result(), + class_def_node.dict.py_result(), + cname, + qualname, + py_mod_name, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class Py3ClassNode(ExprNode): + # Helper class used in the implementation of Python3+ + # class definitions. Constructs a class object given + # a name, tuple of bases and class dictionary. + # + # name EncodedString Name of the class + # module_name EncodedString Name of defining module + # class_def_node PyClassDefNode PyClassDefNode defining this class + # calculate_metaclass bool should call CalculateMetaclass() + # allow_py2_metaclass bool should look for Py2 metaclass + + subexprs = [] + type = py_object_type + is_temp = True + + def infer_type(self, env): + # TODO: could return 'type' in some cases + return py_object_type + + def analyse_types(self, env): + return self + + def may_be_none(self): + return True + + gil_message = "Constructing Python class" + + def generate_result_code(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("Py3ClassCreate", "ObjectHandling.c")) + cname = code.intern_identifier(self.name) + class_def_node = self.class_def_node + mkw = class_def_node.mkw.py_result() if class_def_node.mkw else 'NULL' + if class_def_node.metaclass: + metaclass = class_def_node.metaclass.py_result() + else: + metaclass = "((PyObject*)&__Pyx_DefaultClassType)" + code.putln( + '%s = __Pyx_Py3ClassCreate(%s, %s, %s, %s, %s, %d, %d); %s' % ( + self.result(), + metaclass, + cname, + class_def_node.bases.py_result(), + class_def_node.dict.py_result(), + mkw, + self.calculate_metaclass, + self.allow_py2_metaclass, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class PyClassMetaclassNode(ExprNode): + # Helper class holds Python3 metaclass object + # + # class_def_node PyClassDefNode PyClassDefNode defining this class + + subexprs = [] + + def analyse_types(self, env): + self.type = py_object_type + self.is_temp = True + return self + + def may_be_none(self): + return True + + def generate_result_code(self, code): + bases = self.class_def_node.bases + mkw = self.class_def_node.mkw + if mkw: + code.globalstate.use_utility_code( + UtilityCode.load_cached("Py3MetaclassGet", "ObjectHandling.c")) + call = "__Pyx_Py3MetaclassGet(%s, %s)" % ( + bases.result(), + mkw.result()) + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("CalculateMetaclass", "ObjectHandling.c")) + call = "__Pyx_CalculateMetaclass(NULL, %s)" % ( + bases.result()) + code.putln( + "%s = %s; %s" % ( + self.result(), call, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class PyClassNamespaceNode(ExprNode, ModuleNameMixin): + # Helper class holds Python3 namespace object + # + # All this are not owned by this node + # class_def_node PyClassDefNode PyClassDefNode defining this class + # doc ExprNode or None Doc string (owned) + + subexprs = ['doc'] + + def analyse_types(self, env): + if self.doc: + self.doc = self.doc.analyse_types(env).coerce_to_pyobject(env) + self.type = py_object_type + self.is_temp = 1 + return self + + def may_be_none(self): + return True + + def generate_result_code(self, code): + cname = code.intern_identifier(self.name) + py_mod_name = self.get_py_mod_name(code) + qualname = self.get_py_qualified_name(code) + class_def_node = self.class_def_node + null = "(PyObject *) NULL" + doc_code = self.doc.result() if self.doc else null + mkw = class_def_node.mkw.py_result() if class_def_node.mkw else null + metaclass = class_def_node.metaclass.py_result() if class_def_node.metaclass else null + code.putln( + "%s = __Pyx_Py3MetaclassPrepare(%s, %s, %s, %s, %s, %s, %s); %s" % ( + self.result(), + metaclass, + class_def_node.bases.result(), + cname, + qualname, + mkw, + py_mod_name, + doc_code, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class ClassCellInjectorNode(ExprNode): + # Initialize CyFunction.func_classobj + is_temp = True + type = py_object_type + subexprs = [] + is_active = False + + def analyse_expressions(self, env): + return self + + def generate_result_code(self, code): + assert self.is_active + code.putln( + '%s = PyList_New(0); %s' % ( + self.result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.result()) + + def generate_injection_code(self, code, classobj_cname): + assert self.is_active + code.globalstate.use_utility_code( + UtilityCode.load_cached("CyFunctionClassCell", "CythonFunction.c")) + code.put_error_if_neg(self.pos, '__Pyx_CyFunction_InitClassCell(%s, %s)' % ( + self.result(), classobj_cname)) + + +class ClassCellNode(ExprNode): + # Class Cell for noargs super() + subexprs = [] + is_temp = True + is_generator = False + type = py_object_type + + def analyse_types(self, env): + return self + + def generate_result_code(self, code): + if not self.is_generator: + code.putln('%s = __Pyx_CyFunction_GetClassObj(%s);' % ( + self.result(), + Naming.self_cname)) + else: + code.putln('%s = %s->classobj;' % ( + self.result(), Naming.generator_cname)) + code.putln( + 'if (!%s) { PyErr_SetString(PyExc_SystemError, ' + '"super(): empty __class__ cell"); %s }' % ( + self.result(), + code.error_goto(self.pos))) + code.put_incref(self.result(), py_object_type) + + +class PyCFunctionNode(ExprNode, ModuleNameMixin): + # Helper class used in the implementation of Python + # functions. Constructs a PyCFunction object + # from a PyMethodDef struct. + # + # pymethdef_cname string PyMethodDef structure + # self_object ExprNode or None + # binding bool + # def_node DefNode the Python function node + # module_name EncodedString Name of defining module + # code_object CodeObjectNode the PyCodeObject creator node + + subexprs = ['code_object', 'defaults_tuple', 'defaults_kwdict', + 'annotations_dict'] + + self_object = None + code_object = None + binding = False + def_node = None + defaults = None + defaults_struct = None + defaults_pyobjects = 0 + defaults_tuple = None + defaults_kwdict = None + annotations_dict = None + + type = py_object_type + is_temp = 1 + + specialized_cpdefs = None + is_specialization = False + + @classmethod + def from_defnode(cls, node, binding): + return cls(node.pos, + def_node=node, + pymethdef_cname=node.entry.pymethdef_cname, + binding=binding or node.specialized_cpdefs, + specialized_cpdefs=node.specialized_cpdefs, + code_object=CodeObjectNode(node)) + + def analyse_types(self, env): + if self.binding: + self.analyse_default_args(env) + return self + + def analyse_default_args(self, env): + """ + Handle non-literal function's default arguments. + """ + nonliteral_objects = [] + nonliteral_other = [] + default_args = [] + default_kwargs = [] + annotations = [] + + # For global cpdef functions and def/cpdef methods in cdef classes, we must use global constants + # for default arguments to avoid the dependency on the CyFunction object as 'self' argument + # in the underlying C function. Basically, cpdef functions/methods are static C functions, + # so their optional arguments must be static, too. + # TODO: change CyFunction implementation to pass both function object and owning object for method calls + must_use_constants = env.is_c_class_scope or (self.def_node.is_wrapper and env.is_module_scope) + + for arg in self.def_node.args: + if arg.default and not must_use_constants: + if not arg.default.is_literal: + arg.is_dynamic = True + if arg.type.is_pyobject: + nonliteral_objects.append(arg) + else: + nonliteral_other.append(arg) + else: + arg.default = DefaultLiteralArgNode(arg.pos, arg.default) + if arg.kw_only: + default_kwargs.append(arg) + else: + default_args.append(arg) + if arg.annotation: + arg.annotation = self.analyse_annotation(env, arg.annotation) + annotations.append((arg.pos, arg.name, arg.annotation)) + + for arg in (self.def_node.star_arg, self.def_node.starstar_arg): + if arg and arg.annotation: + arg.annotation = self.analyse_annotation(env, arg.annotation) + annotations.append((arg.pos, arg.name, arg.annotation)) + + annotation = self.def_node.return_type_annotation + if annotation: + annotation = self.analyse_annotation(env, annotation) + self.def_node.return_type_annotation = annotation + annotations.append((annotation.pos, StringEncoding.EncodedString("return"), annotation)) + + if nonliteral_objects or nonliteral_other: + module_scope = env.global_scope() + cname = module_scope.next_id(Naming.defaults_struct_prefix) + scope = Symtab.StructOrUnionScope(cname) + self.defaults = [] + for arg in nonliteral_objects: + entry = scope.declare_var(arg.name, arg.type, None, + Naming.arg_prefix + arg.name, + allow_pyobject=True) + self.defaults.append((arg, entry)) + for arg in nonliteral_other: + entry = scope.declare_var(arg.name, arg.type, None, + Naming.arg_prefix + arg.name, + allow_pyobject=False, allow_memoryview=True) + self.defaults.append((arg, entry)) + entry = module_scope.declare_struct_or_union( + None, 'struct', scope, 1, None, cname=cname) + self.defaults_struct = scope + self.defaults_pyobjects = len(nonliteral_objects) + for arg, entry in self.defaults: + arg.default_value = '%s->%s' % ( + Naming.dynamic_args_cname, entry.cname) + self.def_node.defaults_struct = self.defaults_struct.name + + if default_args or default_kwargs: + if self.defaults_struct is None: + if default_args: + defaults_tuple = TupleNode(self.pos, args=[ + arg.default for arg in default_args]) + self.defaults_tuple = defaults_tuple.analyse_types(env).coerce_to_pyobject(env) + if default_kwargs: + defaults_kwdict = DictNode(self.pos, key_value_pairs=[ + DictItemNode( + arg.pos, + key=IdentifierStringNode(arg.pos, value=arg.name), + value=arg.default) + for arg in default_kwargs]) + self.defaults_kwdict = defaults_kwdict.analyse_types(env) + else: + if default_args: + defaults_tuple = DefaultsTupleNode( + self.pos, default_args, self.defaults_struct) + else: + defaults_tuple = NoneNode(self.pos) + if default_kwargs: + defaults_kwdict = DefaultsKwDictNode( + self.pos, default_kwargs, self.defaults_struct) + else: + defaults_kwdict = NoneNode(self.pos) + + defaults_getter = Nodes.DefNode( + self.pos, args=[], star_arg=None, starstar_arg=None, + body=Nodes.ReturnStatNode( + self.pos, return_type=py_object_type, + value=TupleNode( + self.pos, args=[defaults_tuple, defaults_kwdict])), + decorators=None, + name=StringEncoding.EncodedString("__defaults__")) + # defaults getter must never live in class scopes, it's always a module function + module_scope = env.global_scope() + defaults_getter.analyse_declarations(module_scope) + defaults_getter = defaults_getter.analyse_expressions(module_scope) + defaults_getter.body = defaults_getter.body.analyse_expressions( + defaults_getter.local_scope) + defaults_getter.py_wrapper_required = False + defaults_getter.pymethdef_required = False + self.def_node.defaults_getter = defaults_getter + if annotations: + annotations_dict = DictNode(self.pos, key_value_pairs=[ + DictItemNode( + pos, key=IdentifierStringNode(pos, value=name), + value=value) + for pos, name, value in annotations]) + self.annotations_dict = annotations_dict.analyse_types(env) + + def analyse_annotation(self, env, annotation): + if annotation is None: + return None + atype = annotation.analyse_as_type(env) + if atype is not None: + # Keep parsed types as strings as they might not be Python representable. + annotation = UnicodeNode( + annotation.pos, + value=StringEncoding.EncodedString(atype.declaration_code('', for_display=True))) + annotation = annotation.analyse_types(env) + if not annotation.type.is_pyobject: + annotation = annotation.coerce_to_pyobject(env) + return annotation + + def may_be_none(self): + return False + + gil_message = "Constructing Python function" + + def self_result_code(self): + if self.self_object is None: + self_result = "NULL" + else: + self_result = self.self_object.py_result() + return self_result + + def generate_result_code(self, code): + if self.binding: + self.generate_cyfunction_code(code) + else: + self.generate_pycfunction_code(code) + + def generate_pycfunction_code(self, code): + py_mod_name = self.get_py_mod_name(code) + code.putln( + '%s = PyCFunction_NewEx(&%s, %s, %s); %s' % ( + self.result(), + self.pymethdef_cname, + self.self_result_code(), + py_mod_name, + code.error_goto_if_null(self.result(), self.pos))) + + code.put_gotref(self.py_result()) + + def generate_cyfunction_code(self, code): + if self.specialized_cpdefs: + def_node = self.specialized_cpdefs[0] + else: + def_node = self.def_node + + if self.specialized_cpdefs or self.is_specialization: + code.globalstate.use_utility_code( + UtilityCode.load_cached("FusedFunction", "CythonFunction.c")) + constructor = "__pyx_FusedFunction_New" + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("CythonFunction", "CythonFunction.c")) + constructor = "__Pyx_CyFunction_New" + + if self.code_object: + code_object_result = self.code_object.py_result() + else: + code_object_result = 'NULL' + + flags = [] + if def_node.is_staticmethod: + flags.append('__Pyx_CYFUNCTION_STATICMETHOD') + elif def_node.is_classmethod: + flags.append('__Pyx_CYFUNCTION_CLASSMETHOD') + + if def_node.local_scope.parent_scope.is_c_class_scope and not def_node.entry.is_anonymous: + flags.append('__Pyx_CYFUNCTION_CCLASS') + + if flags: + flags = ' | '.join(flags) + else: + flags = '0' + + code.putln( + '%s = %s(&%s, %s, %s, %s, %s, %s, %s); %s' % ( + self.result(), + constructor, + self.pymethdef_cname, + flags, + self.get_py_qualified_name(code), + self.self_result_code(), + self.get_py_mod_name(code), + Naming.moddict_cname, + code_object_result, + code.error_goto_if_null(self.result(), self.pos))) + + code.put_gotref(self.py_result()) + + if def_node.requires_classobj: + assert code.pyclass_stack, "pyclass_stack is empty" + class_node = code.pyclass_stack[-1] + code.put_incref(self.py_result(), py_object_type) + code.putln( + 'PyList_Append(%s, %s);' % ( + class_node.class_cell.result(), + self.result())) + code.put_giveref(self.py_result()) + + if self.defaults: + code.putln( + 'if (!__Pyx_CyFunction_InitDefaults(%s, sizeof(%s), %d)) %s' % ( + self.result(), self.defaults_struct.name, + self.defaults_pyobjects, code.error_goto(self.pos))) + defaults = '__Pyx_CyFunction_Defaults(%s, %s)' % ( + self.defaults_struct.name, self.result()) + for arg, entry in self.defaults: + arg.generate_assignment_code(code, target='%s->%s' % ( + defaults, entry.cname)) + + if self.defaults_tuple: + code.putln('__Pyx_CyFunction_SetDefaultsTuple(%s, %s);' % ( + self.result(), self.defaults_tuple.py_result())) + if self.defaults_kwdict: + code.putln('__Pyx_CyFunction_SetDefaultsKwDict(%s, %s);' % ( + self.result(), self.defaults_kwdict.py_result())) + if def_node.defaults_getter and not self.specialized_cpdefs: + # Fused functions do not support dynamic defaults, only their specialisations can have them for now. + code.putln('__Pyx_CyFunction_SetDefaultsGetter(%s, %s);' % ( + self.result(), def_node.defaults_getter.entry.pyfunc_cname)) + if self.annotations_dict: + code.putln('__Pyx_CyFunction_SetAnnotationsDict(%s, %s);' % ( + self.result(), self.annotations_dict.py_result())) + + +class InnerFunctionNode(PyCFunctionNode): + # Special PyCFunctionNode that depends on a closure class + # + + binding = True + needs_self_code = True + + def self_result_code(self): + if self.needs_self_code: + return "((PyObject*)%s)" % Naming.cur_scope_cname + return "NULL" + + +class CodeObjectNode(ExprNode): + # Create a PyCodeObject for a CyFunction instance. + # + # def_node DefNode the Python function node + # varnames TupleNode a tuple with all local variable names + + subexprs = ['varnames'] + is_temp = False + result_code = None + + def __init__(self, def_node): + ExprNode.__init__(self, def_node.pos, def_node=def_node) + args = list(def_node.args) + # if we have args/kwargs, then the first two in var_entries are those + local_vars = [arg for arg in def_node.local_scope.var_entries if arg.name] + self.varnames = TupleNode( + def_node.pos, + args=[IdentifierStringNode(arg.pos, value=arg.name) + for arg in args + local_vars], + is_temp=0, + is_literal=1) + + def may_be_none(self): + return False + + def calculate_result_code(self, code=None): + if self.result_code is None: + self.result_code = code.get_py_const(py_object_type, 'codeobj', cleanup_level=2) + return self.result_code + + def generate_result_code(self, code): + if self.result_code is None: + self.result_code = code.get_py_const(py_object_type, 'codeobj', cleanup_level=2) + + code = code.get_cached_constants_writer(self.result_code) + if code is None: + return # already initialised + code.mark_pos(self.pos) + func = self.def_node + func_name = code.get_py_string_const( + func.name, identifier=True, is_str=False, unicode_value=func.name) + # FIXME: better way to get the module file path at module init time? Encoding to use? + file_path = StringEncoding.bytes_literal(func.pos[0].get_filenametable_entry().encode('utf8'), 'utf8') + # XXX Use get_description() to set arcadia root relative filename + file_path = StringEncoding.bytes_literal(func.pos[0].get_description().encode('utf8'), 'utf8') + file_path_const = code.get_py_string_const(file_path, identifier=False, is_str=True) + + # This combination makes CPython create a new dict for "frame.f_locals" (see GH #1836). + flags = ['CO_OPTIMIZED', 'CO_NEWLOCALS'] + + if self.def_node.star_arg: + flags.append('CO_VARARGS') + if self.def_node.starstar_arg: + flags.append('CO_VARKEYWORDS') + + code.putln("%s = (PyObject*)__Pyx_PyCode_New(%d, %d, %d, 0, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s); %s" % ( + self.result_code, + len(func.args) - func.num_kwonly_args, # argcount + func.num_kwonly_args, # kwonlyargcount (Py3 only) + len(self.varnames.args), # nlocals + '|'.join(flags) or '0', # flags + Naming.empty_bytes, # code + Naming.empty_tuple, # consts + Naming.empty_tuple, # names (FIXME) + self.varnames.result(), # varnames + Naming.empty_tuple, # freevars (FIXME) + Naming.empty_tuple, # cellvars (FIXME) + file_path_const, # filename + func_name, # name + self.pos[1], # firstlineno + Naming.empty_bytes, # lnotab + code.error_goto_if_null(self.result_code, self.pos), + )) + + +class DefaultLiteralArgNode(ExprNode): + # CyFunction's literal argument default value + # + # Evaluate literal only once. + + subexprs = [] + is_literal = True + is_temp = False + + def __init__(self, pos, arg): + super(DefaultLiteralArgNode, self).__init__(pos) + self.arg = arg + self.type = self.arg.type + self.evaluated = False + + def analyse_types(self, env): + return self + + def generate_result_code(self, code): + pass + + def generate_evaluation_code(self, code): + if not self.evaluated: + self.arg.generate_evaluation_code(code) + self.evaluated = True + + def result(self): + return self.type.cast_code(self.arg.result()) + + +class DefaultNonLiteralArgNode(ExprNode): + # CyFunction's non-literal argument default value + + subexprs = [] + + def __init__(self, pos, arg, defaults_struct): + super(DefaultNonLiteralArgNode, self).__init__(pos) + self.arg = arg + self.defaults_struct = defaults_struct + + def analyse_types(self, env): + self.type = self.arg.type + self.is_temp = False + return self + + def generate_result_code(self, code): + pass + + def result(self): + return '__Pyx_CyFunction_Defaults(%s, %s)->%s' % ( + self.defaults_struct.name, Naming.self_cname, + self.defaults_struct.lookup(self.arg.name).cname) + + +class DefaultsTupleNode(TupleNode): + # CyFunction's __defaults__ tuple + + def __init__(self, pos, defaults, defaults_struct): + args = [] + for arg in defaults: + if not arg.default.is_literal: + arg = DefaultNonLiteralArgNode(pos, arg, defaults_struct) + else: + arg = arg.default + args.append(arg) + super(DefaultsTupleNode, self).__init__(pos, args=args) + + def analyse_types(self, env, skip_children=False): + return super(DefaultsTupleNode, self).analyse_types(env, skip_children).coerce_to_pyobject(env) + + +class DefaultsKwDictNode(DictNode): + # CyFunction's __kwdefaults__ dict + + def __init__(self, pos, defaults, defaults_struct): + items = [] + for arg in defaults: + name = IdentifierStringNode(arg.pos, value=arg.name) + if not arg.default.is_literal: + arg = DefaultNonLiteralArgNode(pos, arg, defaults_struct) + else: + arg = arg.default + items.append(DictItemNode(arg.pos, key=name, value=arg)) + super(DefaultsKwDictNode, self).__init__(pos, key_value_pairs=items) + + +class LambdaNode(InnerFunctionNode): + # Lambda expression node (only used as a function reference) + # + # args [CArgDeclNode] formal arguments + # star_arg PyArgDeclNode or None * argument + # starstar_arg PyArgDeclNode or None ** argument + # lambda_name string a module-globally unique lambda name + # result_expr ExprNode + # def_node DefNode the underlying function 'def' node + + child_attrs = ['def_node'] + + name = StringEncoding.EncodedString('<lambda>') + + def analyse_declarations(self, env): + self.lambda_name = self.def_node.lambda_name = env.next_id('lambda') + self.def_node.no_assignment_synthesis = True + self.def_node.pymethdef_required = True + self.def_node.analyse_declarations(env) + self.def_node.is_cyfunction = True + self.pymethdef_cname = self.def_node.entry.pymethdef_cname + env.add_lambda_def(self.def_node) + + def analyse_types(self, env): + self.def_node = self.def_node.analyse_expressions(env) + return super(LambdaNode, self).analyse_types(env) + + def generate_result_code(self, code): + self.def_node.generate_execution_code(code) + super(LambdaNode, self).generate_result_code(code) + + +class GeneratorExpressionNode(LambdaNode): + # A generator expression, e.g. (i for i in range(10)) + # + # Result is a generator. + # + # loop ForStatNode the for-loop, containing a YieldExprNode + # def_node DefNode the underlying generator 'def' node + + name = StringEncoding.EncodedString('genexpr') + binding = False + + def analyse_declarations(self, env): + self.genexpr_name = env.next_id('genexpr') + super(GeneratorExpressionNode, self).analyse_declarations(env) + # No pymethdef required + self.def_node.pymethdef_required = False + self.def_node.py_wrapper_required = False + self.def_node.is_cyfunction = False + # Force genexpr signature + self.def_node.entry.signature = TypeSlots.pyfunction_noargs + + def generate_result_code(self, code): + code.putln( + '%s = %s(%s); %s' % ( + self.result(), + self.def_node.entry.pyfunc_cname, + self.self_result_code(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + +class YieldExprNode(ExprNode): + # Yield expression node + # + # arg ExprNode the value to return from the generator + # label_num integer yield label number + # is_yield_from boolean is a YieldFromExprNode to delegate to another generator + + subexprs = ['arg'] + type = py_object_type + label_num = 0 + is_yield_from = False + is_await = False + in_async_gen = False + expr_keyword = 'yield' + + def analyse_types(self, env): + if not self.label_num or (self.is_yield_from and self.in_async_gen): + error(self.pos, "'%s' not supported here" % self.expr_keyword) + self.is_temp = 1 + if self.arg is not None: + self.arg = self.arg.analyse_types(env) + if not self.arg.type.is_pyobject: + self.coerce_yield_argument(env) + return self + + def coerce_yield_argument(self, env): + self.arg = self.arg.coerce_to_pyobject(env) + + def generate_evaluation_code(self, code): + if self.arg: + self.arg.generate_evaluation_code(code) + self.arg.make_owned_reference(code) + code.putln( + "%s = %s;" % ( + Naming.retval_cname, + self.arg.result_as(py_object_type))) + self.arg.generate_post_assignment_code(code) + self.arg.free_temps(code) + else: + code.put_init_to_py_none(Naming.retval_cname, py_object_type) + self.generate_yield_code(code) + + def generate_yield_code(self, code): + """ + Generate the code to return the argument in 'Naming.retval_cname' + and to continue at the yield label. + """ + label_num, label_name = code.new_yield_label( + self.expr_keyword.replace(' ', '_')) + code.use_label(label_name) + + saved = [] + code.funcstate.closure_temps.reset() + for cname, type, manage_ref in code.funcstate.temps_in_use(): + save_cname = code.funcstate.closure_temps.allocate_temp(type) + saved.append((cname, save_cname, type)) + if type.is_pyobject: + code.put_xgiveref(cname) + code.putln('%s->%s = %s;' % (Naming.cur_scope_cname, save_cname, cname)) + + code.put_xgiveref(Naming.retval_cname) + profile = code.globalstate.directives['profile'] + linetrace = code.globalstate.directives['linetrace'] + if profile or linetrace: + code.put_trace_return(Naming.retval_cname, + nogil=not code.funcstate.gil_owned) + code.put_finish_refcount_context() + + if code.funcstate.current_except is not None: + # inside of an except block => save away currently handled exception + code.putln("__Pyx_Coroutine_SwapException(%s);" % Naming.generator_cname) + else: + # no exceptions being handled => restore exception state of caller + code.putln("__Pyx_Coroutine_ResetAndClearException(%s);" % Naming.generator_cname) + + code.putln("/* return from %sgenerator, %sing value */" % ( + 'async ' if self.in_async_gen else '', + 'await' if self.is_await else 'yield')) + code.putln("%s->resume_label = %d;" % ( + Naming.generator_cname, label_num)) + if self.in_async_gen and not self.is_await: + # __Pyx__PyAsyncGenValueWrapperNew() steals a reference to the return value + code.putln("return __Pyx__PyAsyncGenValueWrapperNew(%s);" % Naming.retval_cname) + else: + code.putln("return %s;" % Naming.retval_cname) + + code.put_label(label_name) + for cname, save_cname, type in saved: + code.putln('%s = %s->%s;' % (cname, Naming.cur_scope_cname, save_cname)) + if type.is_pyobject: + code.putln('%s->%s = 0;' % (Naming.cur_scope_cname, save_cname)) + code.put_xgotref(cname) + self.generate_sent_value_handling_code(code, Naming.sent_value_cname) + if self.result_is_used: + self.allocate_temp_result(code) + code.put('%s = %s; ' % (self.result(), Naming.sent_value_cname)) + code.put_incref(self.result(), py_object_type) + + def generate_sent_value_handling_code(self, code, value_cname): + code.putln(code.error_goto_if_null(value_cname, self.pos)) + + +class _YieldDelegationExprNode(YieldExprNode): + def yield_from_func(self, code): + raise NotImplementedError() + + def generate_evaluation_code(self, code, source_cname=None, decref_source=False): + if source_cname is None: + self.arg.generate_evaluation_code(code) + code.putln("%s = %s(%s, %s);" % ( + Naming.retval_cname, + self.yield_from_func(code), + Naming.generator_cname, + self.arg.py_result() if source_cname is None else source_cname)) + if source_cname is None: + self.arg.generate_disposal_code(code) + self.arg.free_temps(code) + elif decref_source: + code.put_decref_clear(source_cname, py_object_type) + code.put_xgotref(Naming.retval_cname) + + code.putln("if (likely(%s)) {" % Naming.retval_cname) + self.generate_yield_code(code) + code.putln("} else {") + # either error or sub-generator has normally terminated: return value => node result + if self.result_is_used: + self.fetch_iteration_result(code) + else: + self.handle_iteration_exception(code) + code.putln("}") + + def fetch_iteration_result(self, code): + # YieldExprNode has allocated the result temp for us + code.putln("%s = NULL;" % self.result()) + code.put_error_if_neg(self.pos, "__Pyx_PyGen_FetchStopIterationValue(&%s)" % self.result()) + code.put_gotref(self.result()) + + def handle_iteration_exception(self, code): + code.putln("PyObject* exc_type = __Pyx_PyErr_Occurred();") + code.putln("if (exc_type) {") + code.putln("if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit &&" + " __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();") + code.putln("else %s" % code.error_goto(self.pos)) + code.putln("}") + + +class YieldFromExprNode(_YieldDelegationExprNode): + # "yield from GEN" expression + is_yield_from = True + expr_keyword = 'yield from' + + def coerce_yield_argument(self, env): + if not self.arg.type.is_string: + # FIXME: support C arrays and C++ iterators? + error(self.pos, "yielding from non-Python object not supported") + self.arg = self.arg.coerce_to_pyobject(env) + + def yield_from_func(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("GeneratorYieldFrom", "Coroutine.c")) + return "__Pyx_Generator_Yield_From" + + +class AwaitExprNode(_YieldDelegationExprNode): + # 'await' expression node + # + # arg ExprNode the Awaitable value to await + # label_num integer yield label number + + is_await = True + expr_keyword = 'await' + + def coerce_yield_argument(self, env): + if self.arg is not None: + # FIXME: use same check as in YieldFromExprNode.coerce_yield_argument() ? + self.arg = self.arg.coerce_to_pyobject(env) + + def yield_from_func(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("CoroutineYieldFrom", "Coroutine.c")) + return "__Pyx_Coroutine_Yield_From" + + +class AwaitIterNextExprNode(AwaitExprNode): + # 'await' expression node as part of 'async for' iteration + # + # Breaks out of loop on StopAsyncIteration exception. + + def _generate_break(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c")) + code.putln("PyObject* exc_type = __Pyx_PyErr_Occurred();") + code.putln("if (unlikely(exc_type && (exc_type == __Pyx_PyExc_StopAsyncIteration || (" + " exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit &&" + " __Pyx_PyErr_GivenExceptionMatches(exc_type, __Pyx_PyExc_StopAsyncIteration))))) {") + code.putln("PyErr_Clear();") + code.putln("break;") + code.putln("}") + + def fetch_iteration_result(self, code): + assert code.break_label, "AwaitIterNextExprNode outside of 'async for' loop" + self._generate_break(code) + super(AwaitIterNextExprNode, self).fetch_iteration_result(code) + + def generate_sent_value_handling_code(self, code, value_cname): + assert code.break_label, "AwaitIterNextExprNode outside of 'async for' loop" + code.putln("if (unlikely(!%s)) {" % value_cname) + self._generate_break(code) + # all non-break exceptions are errors, as in parent class + code.putln(code.error_goto(self.pos)) + code.putln("}") + + +class GlobalsExprNode(AtomicExprNode): + type = dict_type + is_temp = 1 + + def analyse_types(self, env): + env.use_utility_code(Builtin.globals_utility_code) + return self + + gil_message = "Constructing globals dict" + + def may_be_none(self): + return False + + def generate_result_code(self, code): + code.putln('%s = __Pyx_Globals(); %s' % ( + self.result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.result()) + + +class LocalsDictItemNode(DictItemNode): + def analyse_types(self, env): + self.key = self.key.analyse_types(env) + self.value = self.value.analyse_types(env) + self.key = self.key.coerce_to_pyobject(env) + if self.value.type.can_coerce_to_pyobject(env): + self.value = self.value.coerce_to_pyobject(env) + else: + self.value = None + return self + + +class FuncLocalsExprNode(DictNode): + def __init__(self, pos, env): + local_vars = sorted([ + entry.name for entry in env.entries.values() if entry.name]) + items = [LocalsDictItemNode( + pos, key=IdentifierStringNode(pos, value=var), + value=NameNode(pos, name=var, allow_null=True)) + for var in local_vars] + DictNode.__init__(self, pos, key_value_pairs=items, + exclude_null_values=True) + + def analyse_types(self, env): + node = super(FuncLocalsExprNode, self).analyse_types(env) + node.key_value_pairs = [ i for i in node.key_value_pairs + if i.value is not None ] + return node + + +class PyClassLocalsExprNode(AtomicExprNode): + def __init__(self, pos, pyclass_dict): + AtomicExprNode.__init__(self, pos) + self.pyclass_dict = pyclass_dict + + def analyse_types(self, env): + self.type = self.pyclass_dict.type + self.is_temp = False + return self + + def may_be_none(self): + return False + + def result(self): + return self.pyclass_dict.result() + + def generate_result_code(self, code): + pass + + +def LocalsExprNode(pos, scope_node, env): + if env.is_module_scope: + return GlobalsExprNode(pos) + if env.is_py_class_scope: + return PyClassLocalsExprNode(pos, scope_node.dict) + return FuncLocalsExprNode(pos, env) + + +#------------------------------------------------------------------- +# +# Unary operator nodes +# +#------------------------------------------------------------------- + +compile_time_unary_operators = { + 'not': operator.not_, + '~': operator.inv, + '-': operator.neg, + '+': operator.pos, +} + +class UnopNode(ExprNode): + # operator string + # operand ExprNode + # + # Processing during analyse_expressions phase: + # + # analyse_c_operation + # Called when the operand is not a pyobject. + # - Check operand type and coerce if needed. + # - Determine result type and result code fragment. + # - Allocate temporary for result if needed. + + subexprs = ['operand'] + infix = True + + def calculate_constant_result(self): + func = compile_time_unary_operators[self.operator] + self.constant_result = func(self.operand.constant_result) + + def compile_time_value(self, denv): + func = compile_time_unary_operators.get(self.operator) + if not func: + error(self.pos, + "Unary '%s' not supported in compile-time expression" + % self.operator) + operand = self.operand.compile_time_value(denv) + try: + return func(operand) + except Exception as e: + self.compile_time_value_error(e) + + def infer_type(self, env): + operand_type = self.operand.infer_type(env) + if operand_type.is_cpp_class or operand_type.is_ptr: + cpp_type = operand_type.find_cpp_operation_type(self.operator) + if cpp_type is not None: + return cpp_type + return self.infer_unop_type(env, operand_type) + + def infer_unop_type(self, env, operand_type): + if operand_type.is_pyobject: + return py_object_type + else: + return operand_type + + def may_be_none(self): + if self.operand.type and self.operand.type.is_builtin_type: + if self.operand.type is not type_type: + return False + return ExprNode.may_be_none(self) + + def analyse_types(self, env): + self.operand = self.operand.analyse_types(env) + if self.is_pythran_operation(env): + self.type = PythranExpr(pythran_unaryop_type(self.operator, self.operand.type)) + self.is_temp = 1 + elif self.is_py_operation(): + self.coerce_operand_to_pyobject(env) + self.type = py_object_type + self.is_temp = 1 + elif self.is_cpp_operation(): + self.analyse_cpp_operation(env) + else: + self.analyse_c_operation(env) + return self + + def check_const(self): + return self.operand.check_const() + + def is_py_operation(self): + return self.operand.type.is_pyobject or self.operand.type.is_ctuple + + def is_pythran_operation(self, env): + np_pythran = has_np_pythran(env) + op_type = self.operand.type + return np_pythran and (op_type.is_buffer or op_type.is_pythran_expr) + + def nogil_check(self, env): + if self.is_py_operation(): + self.gil_error() + + def is_cpp_operation(self): + type = self.operand.type + return type.is_cpp_class + + def coerce_operand_to_pyobject(self, env): + self.operand = self.operand.coerce_to_pyobject(env) + + def generate_result_code(self, code): + if self.type.is_pythran_expr: + code.putln("// Pythran unaryop") + code.putln("__Pyx_call_destructor(%s);" % self.result()) + code.putln("new (&%s) decltype(%s){%s%s};" % ( + self.result(), + self.result(), + self.operator, + self.operand.pythran_result())) + elif self.operand.type.is_pyobject: + self.generate_py_operation_code(code) + elif self.is_temp: + if self.is_cpp_operation() and self.exception_check == '+': + translate_cpp_exception(code, self.pos, + "%s = %s %s;" % (self.result(), self.operator, self.operand.result()), + self.result() if self.type.is_pyobject else None, + self.exception_value, self.in_nogil_context) + else: + code.putln("%s = %s %s;" % (self.result(), self.operator, self.operand.result())) + + def generate_py_operation_code(self, code): + function = self.py_operation_function(code) + code.putln( + "%s = %s(%s); %s" % ( + self.result(), + function, + self.operand.py_result(), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + + def type_error(self): + if not self.operand.type.is_error: + error(self.pos, "Invalid operand type for '%s' (%s)" % + (self.operator, self.operand.type)) + self.type = PyrexTypes.error_type + + def analyse_cpp_operation(self, env, overload_check=True): + entry = env.lookup_operator(self.operator, [self.operand]) + if overload_check and not entry: + self.type_error() + return + if entry: + self.exception_check = entry.type.exception_check + self.exception_value = entry.type.exception_value + if self.exception_check == '+': + self.is_temp = True + if self.exception_value is None: + env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp")) + else: + self.exception_check = '' + self.exception_value = '' + cpp_type = self.operand.type.find_cpp_operation_type(self.operator) + if overload_check and cpp_type is None: + error(self.pos, "'%s' operator not defined for %s" % ( + self.operator, type)) + self.type_error() + return + self.type = cpp_type + + +class NotNode(UnopNode): + # 'not' operator + # + # operand ExprNode + operator = '!' + + type = PyrexTypes.c_bint_type + + def calculate_constant_result(self): + self.constant_result = not self.operand.constant_result + + def compile_time_value(self, denv): + operand = self.operand.compile_time_value(denv) + try: + return not operand + except Exception as e: + self.compile_time_value_error(e) + + def infer_unop_type(self, env, operand_type): + return PyrexTypes.c_bint_type + + def analyse_types(self, env): + self.operand = self.operand.analyse_types(env) + operand_type = self.operand.type + if operand_type.is_cpp_class: + self.analyse_cpp_operation(env) + else: + self.operand = self.operand.coerce_to_boolean(env) + return self + + def calculate_result_code(self): + return "(!%s)" % self.operand.result() + + +class UnaryPlusNode(UnopNode): + # unary '+' operator + + operator = '+' + + def analyse_c_operation(self, env): + self.type = PyrexTypes.widest_numeric_type( + self.operand.type, PyrexTypes.c_int_type) + + def py_operation_function(self, code): + return "PyNumber_Positive" + + def calculate_result_code(self): + if self.is_cpp_operation(): + return "(+%s)" % self.operand.result() + else: + return self.operand.result() + + +class UnaryMinusNode(UnopNode): + # unary '-' operator + + operator = '-' + + def analyse_c_operation(self, env): + if self.operand.type.is_numeric: + self.type = PyrexTypes.widest_numeric_type( + self.operand.type, PyrexTypes.c_int_type) + elif self.operand.type.is_enum: + self.type = PyrexTypes.c_int_type + else: + self.type_error() + if self.type.is_complex: + self.infix = False + + def py_operation_function(self, code): + return "PyNumber_Negative" + + def calculate_result_code(self): + if self.infix: + return "(-%s)" % self.operand.result() + else: + return "%s(%s)" % (self.operand.type.unary_op('-'), self.operand.result()) + + def get_constant_c_result_code(self): + value = self.operand.get_constant_c_result_code() + if value: + return "(-%s)" % value + +class TildeNode(UnopNode): + # unary '~' operator + + def analyse_c_operation(self, env): + if self.operand.type.is_int: + self.type = PyrexTypes.widest_numeric_type( + self.operand.type, PyrexTypes.c_int_type) + elif self.operand.type.is_enum: + self.type = PyrexTypes.c_int_type + else: + self.type_error() + + def py_operation_function(self, code): + return "PyNumber_Invert" + + def calculate_result_code(self): + return "(~%s)" % self.operand.result() + + +class CUnopNode(UnopNode): + + def is_py_operation(self): + return False + +class DereferenceNode(CUnopNode): + # unary * operator + + operator = '*' + + def infer_unop_type(self, env, operand_type): + if operand_type.is_ptr: + return operand_type.base_type + else: + return PyrexTypes.error_type + + def analyse_c_operation(self, env): + if self.operand.type.is_ptr: + self.type = self.operand.type.base_type + else: + self.type_error() + + def calculate_result_code(self): + return "(*%s)" % self.operand.result() + + +class DecrementIncrementNode(CUnopNode): + # unary ++/-- operator + + def analyse_c_operation(self, env): + if self.operand.type.is_numeric: + self.type = PyrexTypes.widest_numeric_type( + self.operand.type, PyrexTypes.c_int_type) + elif self.operand.type.is_ptr: + self.type = self.operand.type + else: + self.type_error() + + def calculate_result_code(self): + if self.is_prefix: + return "(%s%s)" % (self.operator, self.operand.result()) + else: + return "(%s%s)" % (self.operand.result(), self.operator) + +def inc_dec_constructor(is_prefix, operator): + return lambda pos, **kwds: DecrementIncrementNode(pos, is_prefix=is_prefix, operator=operator, **kwds) + + +class AmpersandNode(CUnopNode): + # The C address-of operator. + # + # operand ExprNode + operator = '&' + + def infer_unop_type(self, env, operand_type): + return PyrexTypes.c_ptr_type(operand_type) + + def analyse_types(self, env): + self.operand = self.operand.analyse_types(env) + argtype = self.operand.type + if argtype.is_cpp_class: + self.analyse_cpp_operation(env, overload_check=False) + if not (argtype.is_cfunction or argtype.is_reference or self.operand.is_addressable()): + if argtype.is_memoryviewslice: + self.error("Cannot take address of memoryview slice") + else: + self.error("Taking address of non-lvalue (type %s)" % argtype) + return self + if argtype.is_pyobject: + self.error("Cannot take address of Python %s" % ( + "variable '%s'" % self.operand.name if self.operand.is_name else + "object attribute '%s'" % self.operand.attribute if self.operand.is_attribute else + "object")) + return self + if not argtype.is_cpp_class or not self.type: + self.type = PyrexTypes.c_ptr_type(argtype) + return self + + def check_const(self): + return self.operand.check_const_addr() + + def error(self, mess): + error(self.pos, mess) + self.type = PyrexTypes.error_type + self.result_code = "<error>" + + def calculate_result_code(self): + return "(&%s)" % self.operand.result() + + def generate_result_code(self, code): + if (self.operand.type.is_cpp_class and self.exception_check == '+'): + translate_cpp_exception(code, self.pos, + "%s = %s %s;" % (self.result(), self.operator, self.operand.result()), + self.result() if self.type.is_pyobject else None, + self.exception_value, self.in_nogil_context) + + +unop_node_classes = { + "+": UnaryPlusNode, + "-": UnaryMinusNode, + "~": TildeNode, +} + +def unop_node(pos, operator, operand): + # Construct unnop node of appropriate class for + # given operator. + if isinstance(operand, IntNode) and operator == '-': + return IntNode(pos = operand.pos, value = str(-Utils.str_to_number(operand.value)), + longness=operand.longness, unsigned=operand.unsigned) + elif isinstance(operand, UnopNode) and operand.operator == operator in '+-': + warning(pos, "Python has no increment/decrement operator: %s%sx == %s(%sx) == x" % ((operator,)*4), 5) + return unop_node_classes[operator](pos, + operator = operator, + operand = operand) + + +class TypecastNode(ExprNode): + # C type cast + # + # operand ExprNode + # base_type CBaseTypeNode + # declarator CDeclaratorNode + # typecheck boolean + # + # If used from a transform, one can if wanted specify the attribute + # "type" directly and leave base_type and declarator to None + + subexprs = ['operand'] + base_type = declarator = type = None + + def type_dependencies(self, env): + return () + + def infer_type(self, env): + if self.type is None: + base_type = self.base_type.analyse(env) + _, self.type = self.declarator.analyse(base_type, env) + return self.type + + def analyse_types(self, env): + if self.type is None: + base_type = self.base_type.analyse(env) + _, self.type = self.declarator.analyse(base_type, env) + if self.operand.has_constant_result(): + # Must be done after self.type is resolved. + self.calculate_constant_result() + if self.type.is_cfunction: + error(self.pos, + "Cannot cast to a function type") + self.type = PyrexTypes.error_type + self.operand = self.operand.analyse_types(env) + if self.type is PyrexTypes.c_bint_type: + # short circuit this to a coercion + return self.operand.coerce_to_boolean(env) + to_py = self.type.is_pyobject + from_py = self.operand.type.is_pyobject + if from_py and not to_py and self.operand.is_ephemeral(): + if not self.type.is_numeric and not self.type.is_cpp_class: + error(self.pos, "Casting temporary Python object to non-numeric non-Python type") + if to_py and not from_py: + if self.type is bytes_type and self.operand.type.is_int: + return CoerceIntToBytesNode(self.operand, env) + elif self.operand.type.can_coerce_to_pyobject(env): + self.result_ctype = py_object_type + self.operand = self.operand.coerce_to(self.type, env) + else: + if self.operand.type.is_ptr: + if not (self.operand.type.base_type.is_void or self.operand.type.base_type.is_struct): + error(self.pos, "Python objects cannot be cast from pointers of primitive types") + else: + # Should this be an error? + warning(self.pos, "No conversion from %s to %s, python object pointer used." % ( + self.operand.type, self.type)) + self.operand = self.operand.coerce_to_simple(env) + elif from_py and not to_py: + if self.type.create_from_py_utility_code(env): + self.operand = self.operand.coerce_to(self.type, env) + elif self.type.is_ptr: + if not (self.type.base_type.is_void or self.type.base_type.is_struct): + error(self.pos, "Python objects cannot be cast to pointers of primitive types") + else: + warning(self.pos, "No conversion from %s to %s, python object pointer used." % ( + self.type, self.operand.type)) + elif from_py and to_py: + if self.typecheck: + self.operand = PyTypeTestNode(self.operand, self.type, env, notnone=True) + elif isinstance(self.operand, SliceIndexNode): + # This cast can influence the created type of string slices. + self.operand = self.operand.coerce_to(self.type, env) + elif self.type.is_complex and self.operand.type.is_complex: + self.operand = self.operand.coerce_to_simple(env) + elif self.operand.type.is_fused: + self.operand = self.operand.coerce_to(self.type, env) + #self.type = self.operand.type + if self.type.is_ptr and self.type.base_type.is_cfunction and self.type.base_type.nogil: + op_type = self.operand.type + if op_type.is_ptr: + op_type = op_type.base_type + if op_type.is_cfunction and not op_type.nogil: + warning(self.pos, + "Casting a GIL-requiring function into a nogil function circumvents GIL validation", 1) + return self + + def is_simple(self): + # either temp or a C cast => no side effects other than the operand's + return self.operand.is_simple() + + def is_ephemeral(self): + # either temp or a C cast => no side effects other than the operand's + return self.operand.is_ephemeral() + + def nonlocally_immutable(self): + return self.is_temp or self.operand.nonlocally_immutable() + + def nogil_check(self, env): + if self.type and self.type.is_pyobject and self.is_temp: + self.gil_error() + + def check_const(self): + return self.operand.check_const() + + def calculate_constant_result(self): + self.constant_result = self.calculate_result_code(self.operand.constant_result) + + def calculate_result_code(self, operand_result = None): + if operand_result is None: + operand_result = self.operand.result() + if self.type.is_complex: + operand_result = self.operand.result() + if self.operand.type.is_complex: + real_part = self.type.real_type.cast_code("__Pyx_CREAL(%s)" % operand_result) + imag_part = self.type.real_type.cast_code("__Pyx_CIMAG(%s)" % operand_result) + else: + real_part = self.type.real_type.cast_code(operand_result) + imag_part = "0" + return "%s(%s, %s)" % ( + self.type.from_parts, + real_part, + imag_part) + else: + return self.type.cast_code(operand_result) + + def get_constant_c_result_code(self): + operand_result = self.operand.get_constant_c_result_code() + if operand_result: + return self.type.cast_code(operand_result) + + def result_as(self, type): + if self.type.is_pyobject and not self.is_temp: + # Optimise away some unnecessary casting + return self.operand.result_as(type) + else: + return ExprNode.result_as(self, type) + + def generate_result_code(self, code): + if self.is_temp: + code.putln( + "%s = (PyObject *)%s;" % ( + self.result(), + self.operand.result())) + code.put_incref(self.result(), self.ctype()) + + +ERR_START = "Start may not be given" +ERR_NOT_STOP = "Stop must be provided to indicate shape" +ERR_STEPS = ("Strides may only be given to indicate contiguity. " + "Consider slicing it after conversion") +ERR_NOT_POINTER = "Can only create cython.array from pointer or array" +ERR_BASE_TYPE = "Pointer base type does not match cython.array base type" + + +class CythonArrayNode(ExprNode): + """ + Used when a pointer of base_type is cast to a memoryviewslice with that + base type. i.e. + + <int[:M:1, :N]> p + + creates a fortran-contiguous cython.array. + + We leave the type set to object so coercions to object are more efficient + and less work. Acquiring a memoryviewslice from this will be just as + efficient. ExprNode.coerce_to() will do the additional typecheck on + self.compile_time_type + + This also handles <int[:, :]> my_c_array + + + operand ExprNode the thing we're casting + base_type_node MemoryViewSliceTypeNode the cast expression node + """ + + subexprs = ['operand', 'shapes'] + + shapes = None + is_temp = True + mode = "c" + array_dtype = None + + shape_type = PyrexTypes.c_py_ssize_t_type + + def analyse_types(self, env): + from . import MemoryView + + self.operand = self.operand.analyse_types(env) + if self.array_dtype: + array_dtype = self.array_dtype + else: + array_dtype = self.base_type_node.base_type_node.analyse(env) + axes = self.base_type_node.axes + + self.type = error_type + self.shapes = [] + ndim = len(axes) + + # Base type of the pointer or C array we are converting + base_type = self.operand.type + + if not self.operand.type.is_ptr and not self.operand.type.is_array: + error(self.operand.pos, ERR_NOT_POINTER) + return self + + # Dimension sizes of C array + array_dimension_sizes = [] + if base_type.is_array: + while base_type.is_array: + array_dimension_sizes.append(base_type.size) + base_type = base_type.base_type + elif base_type.is_ptr: + base_type = base_type.base_type + else: + error(self.pos, "unexpected base type %s found" % base_type) + return self + + if not (base_type.same_as(array_dtype) or base_type.is_void): + error(self.operand.pos, ERR_BASE_TYPE) + return self + elif self.operand.type.is_array and len(array_dimension_sizes) != ndim: + error(self.operand.pos, + "Expected %d dimensions, array has %d dimensions" % + (ndim, len(array_dimension_sizes))) + return self + + # Verify the start, stop and step values + # In case of a C array, use the size of C array in each dimension to + # get an automatic cast + for axis_no, axis in enumerate(axes): + if not axis.start.is_none: + error(axis.start.pos, ERR_START) + return self + + if axis.stop.is_none: + if array_dimension_sizes: + dimsize = array_dimension_sizes[axis_no] + axis.stop = IntNode(self.pos, value=str(dimsize), + constant_result=dimsize, + type=PyrexTypes.c_int_type) + else: + error(axis.pos, ERR_NOT_STOP) + return self + + axis.stop = axis.stop.analyse_types(env) + shape = axis.stop.coerce_to(self.shape_type, env) + if not shape.is_literal: + shape.coerce_to_temp(env) + + self.shapes.append(shape) + + first_or_last = axis_no in (0, ndim - 1) + if not axis.step.is_none and first_or_last: + # '1' in the first or last dimension denotes F or C contiguity + axis.step = axis.step.analyse_types(env) + if (not axis.step.type.is_int and axis.step.is_literal and not + axis.step.type.is_error): + error(axis.step.pos, "Expected an integer literal") + return self + + if axis.step.compile_time_value(env) != 1: + error(axis.step.pos, ERR_STEPS) + return self + + if axis_no == 0: + self.mode = "fortran" + + elif not axis.step.is_none and not first_or_last: + # step provided in some other dimension + error(axis.step.pos, ERR_STEPS) + return self + + if not self.operand.is_name: + self.operand = self.operand.coerce_to_temp(env) + + axes = [('direct', 'follow')] * len(axes) + if self.mode == "fortran": + axes[0] = ('direct', 'contig') + else: + axes[-1] = ('direct', 'contig') + + self.coercion_type = PyrexTypes.MemoryViewSliceType(array_dtype, axes) + self.coercion_type.validate_memslice_dtype(self.pos) + self.type = self.get_cython_array_type(env) + MemoryView.use_cython_array_utility_code(env) + env.use_utility_code(MemoryView.typeinfo_to_format_code) + return self + + def allocate_temp_result(self, code): + if self.temp_code: + raise RuntimeError("temp allocated multiple times") + + self.temp_code = code.funcstate.allocate_temp(self.type, True) + + def infer_type(self, env): + return self.get_cython_array_type(env) + + def get_cython_array_type(self, env): + cython_scope = env.global_scope().context.cython_scope + cython_scope.load_cythonscope() + return cython_scope.viewscope.lookup("array").type + + def generate_result_code(self, code): + from . import Buffer + + shapes = [self.shape_type.cast_code(shape.result()) + for shape in self.shapes] + dtype = self.coercion_type.dtype + + shapes_temp = code.funcstate.allocate_temp(py_object_type, True) + format_temp = code.funcstate.allocate_temp(py_object_type, True) + + itemsize = "sizeof(%s)" % dtype.empty_declaration_code() + type_info = Buffer.get_type_information_cname(code, dtype) + + if self.operand.type.is_ptr: + code.putln("if (!%s) {" % self.operand.result()) + code.putln( 'PyErr_SetString(PyExc_ValueError,' + '"Cannot create cython.array from NULL pointer");') + code.putln(code.error_goto(self.operand.pos)) + code.putln("}") + + code.putln("%s = __pyx_format_from_typeinfo(&%s); %s" % ( + format_temp, + type_info, + code.error_goto_if_null(format_temp, self.pos), + )) + code.put_gotref(format_temp) + + buildvalue_fmt = " __PYX_BUILD_PY_SSIZE_T " * len(shapes) + code.putln('%s = Py_BuildValue((char*) "(" %s ")", %s); %s' % ( + shapes_temp, + buildvalue_fmt, + ", ".join(shapes), + code.error_goto_if_null(shapes_temp, self.pos), + )) + code.put_gotref(shapes_temp) + + tup = (self.result(), shapes_temp, itemsize, format_temp, + self.mode, self.operand.result()) + code.putln('%s = __pyx_array_new(' + '%s, %s, PyBytes_AS_STRING(%s), ' + '(char *) "%s", (char *) %s);' % tup) + code.putln(code.error_goto_if_null(self.result(), self.pos)) + code.put_gotref(self.result()) + + def dispose(temp): + code.put_decref_clear(temp, py_object_type) + code.funcstate.release_temp(temp) + + dispose(shapes_temp) + dispose(format_temp) + + @classmethod + def from_carray(cls, src_node, env): + """ + Given a C array type, return a CythonArrayNode + """ + pos = src_node.pos + base_type = src_node.type + + none_node = NoneNode(pos) + axes = [] + + while base_type.is_array: + axes.append(SliceNode(pos, start=none_node, stop=none_node, + step=none_node)) + base_type = base_type.base_type + axes[-1].step = IntNode(pos, value="1", is_c_literal=True) + + memslicenode = Nodes.MemoryViewSliceTypeNode(pos, axes=axes, + base_type_node=base_type) + result = CythonArrayNode(pos, base_type_node=memslicenode, + operand=src_node, array_dtype=base_type) + result = result.analyse_types(env) + return result + +class SizeofNode(ExprNode): + # Abstract base class for sizeof(x) expression nodes. + + type = PyrexTypes.c_size_t_type + + def check_const(self): + return True + + def generate_result_code(self, code): + pass + + +class SizeofTypeNode(SizeofNode): + # C sizeof function applied to a type + # + # base_type CBaseTypeNode + # declarator CDeclaratorNode + + subexprs = [] + arg_type = None + + def analyse_types(self, env): + # we may have incorrectly interpreted a dotted name as a type rather than an attribute + # this could be better handled by more uniformly treating types as runtime-available objects + if 0 and self.base_type.module_path: + path = self.base_type.module_path + obj = env.lookup(path[0]) + if obj.as_module is None: + operand = NameNode(pos=self.pos, name=path[0]) + for attr in path[1:]: + operand = AttributeNode(pos=self.pos, obj=operand, attribute=attr) + operand = AttributeNode(pos=self.pos, obj=operand, attribute=self.base_type.name) + node = SizeofVarNode(self.pos, operand=operand).analyse_types(env) + return node + if self.arg_type is None: + base_type = self.base_type.analyse(env) + _, arg_type = self.declarator.analyse(base_type, env) + self.arg_type = arg_type + self.check_type() + return self + + def check_type(self): + arg_type = self.arg_type + if not arg_type: + return + if arg_type.is_pyobject and not arg_type.is_extension_type: + error(self.pos, "Cannot take sizeof Python object") + elif arg_type.is_void: + error(self.pos, "Cannot take sizeof void") + elif not arg_type.is_complete(): + error(self.pos, "Cannot take sizeof incomplete type '%s'" % arg_type) + + def calculate_result_code(self): + if self.arg_type.is_extension_type: + # the size of the pointer is boring + # we want the size of the actual struct + arg_code = self.arg_type.declaration_code("", deref=1) + else: + arg_code = self.arg_type.empty_declaration_code() + return "(sizeof(%s))" % arg_code + + +class SizeofVarNode(SizeofNode): + # C sizeof function applied to a variable + # + # operand ExprNode + + subexprs = ['operand'] + + def analyse_types(self, env): + # We may actually be looking at a type rather than a variable... + # If we are, traditional analysis would fail... + operand_as_type = self.operand.analyse_as_type(env) + if operand_as_type: + self.arg_type = operand_as_type + if self.arg_type.is_fused: + self.arg_type = self.arg_type.specialize(env.fused_to_specific) + self.__class__ = SizeofTypeNode + self.check_type() + else: + self.operand = self.operand.analyse_types(env) + return self + + def calculate_result_code(self): + return "(sizeof(%s))" % self.operand.result() + + def generate_result_code(self, code): + pass + + +class TypeidNode(ExprNode): + # C++ typeid operator applied to a type or variable + # + # operand ExprNode + # arg_type ExprNode + # is_variable boolean + + type = PyrexTypes.error_type + + subexprs = ['operand'] + + arg_type = None + is_variable = None + is_temp = 1 + + def get_type_info_type(self, env): + env_module = env + while not env_module.is_module_scope: + env_module = env_module.outer_scope + typeinfo_module = env_module.find_module('libcpp.typeinfo', self.pos) + typeinfo_entry = typeinfo_module.lookup('type_info') + return PyrexTypes.CFakeReferenceType(PyrexTypes.c_const_type(typeinfo_entry.type)) + + cpp_message = 'typeid operator' + + def analyse_types(self, env): + self.cpp_check(env) + type_info = self.get_type_info_type(env) + if not type_info: + self.error("The 'libcpp.typeinfo' module must be cimported to use the typeid() operator") + return self + self.type = type_info + as_type = self.operand.analyse_as_type(env) + if as_type: + self.arg_type = as_type + self.is_type = True + else: + self.arg_type = self.operand.analyse_types(env) + self.is_type = False + if self.arg_type.type.is_pyobject: + self.error("Cannot use typeid on a Python object") + return self + elif self.arg_type.type.is_void: + self.error("Cannot use typeid on void") + return self + elif not self.arg_type.type.is_complete(): + self.error("Cannot use typeid on incomplete type '%s'" % self.arg_type.type) + return self + env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp")) + return self + + def error(self, mess): + error(self.pos, mess) + self.type = PyrexTypes.error_type + self.result_code = "<error>" + + def check_const(self): + return True + + def calculate_result_code(self): + return self.temp_code + + def generate_result_code(self, code): + if self.is_type: + arg_code = self.arg_type.empty_declaration_code() + else: + arg_code = self.arg_type.result() + translate_cpp_exception(code, self.pos, + "%s = typeid(%s);" % (self.temp_code, arg_code), + None, None, self.in_nogil_context) + +class TypeofNode(ExprNode): + # Compile-time type of an expression, as a string. + # + # operand ExprNode + # literal StringNode # internal + + literal = None + type = py_object_type + + subexprs = ['literal'] # 'operand' will be ignored after type analysis! + + def analyse_types(self, env): + self.operand = self.operand.analyse_types(env) + value = StringEncoding.EncodedString(str(self.operand.type)) #self.operand.type.typeof_name()) + literal = StringNode(self.pos, value=value) + literal = literal.analyse_types(env) + self.literal = literal.coerce_to_pyobject(env) + return self + + def analyse_as_type(self, env): + self.operand = self.operand.analyse_types(env) + return self.operand.type + + def may_be_none(self): + return False + + def generate_evaluation_code(self, code): + self.literal.generate_evaluation_code(code) + + def calculate_result_code(self): + return self.literal.calculate_result_code() + +#------------------------------------------------------------------- +# +# Binary operator nodes +# +#------------------------------------------------------------------- + +try: + matmul_operator = operator.matmul +except AttributeError: + def matmul_operator(a, b): + try: + func = a.__matmul__ + except AttributeError: + func = b.__rmatmul__ + return func(a, b) + +compile_time_binary_operators = { + '<': operator.lt, + '<=': operator.le, + '==': operator.eq, + '!=': operator.ne, + '>=': operator.ge, + '>': operator.gt, + 'is': operator.is_, + 'is_not': operator.is_not, + '+': operator.add, + '&': operator.and_, + '/': operator.truediv, + '//': operator.floordiv, + '<<': operator.lshift, + '%': operator.mod, + '*': operator.mul, + '|': operator.or_, + '**': operator.pow, + '>>': operator.rshift, + '-': operator.sub, + '^': operator.xor, + '@': matmul_operator, + 'in': lambda x, seq: x in seq, + 'not_in': lambda x, seq: x not in seq, +} + +def get_compile_time_binop(node): + func = compile_time_binary_operators.get(node.operator) + if not func: + error(node.pos, + "Binary '%s' not supported in compile-time expression" + % node.operator) + return func + + +class BinopNode(ExprNode): + # operator string + # operand1 ExprNode + # operand2 ExprNode + # + # Processing during analyse_expressions phase: + # + # analyse_c_operation + # Called when neither operand is a pyobject. + # - Check operand types and coerce if needed. + # - Determine result type and result code fragment. + # - Allocate temporary for result if needed. + + subexprs = ['operand1', 'operand2'] + inplace = False + + def calculate_constant_result(self): + func = compile_time_binary_operators[self.operator] + self.constant_result = func( + self.operand1.constant_result, + self.operand2.constant_result) + + def compile_time_value(self, denv): + func = get_compile_time_binop(self) + operand1 = self.operand1.compile_time_value(denv) + operand2 = self.operand2.compile_time_value(denv) + try: + return func(operand1, operand2) + except Exception as e: + self.compile_time_value_error(e) + + def infer_type(self, env): + return self.result_type(self.operand1.infer_type(env), + self.operand2.infer_type(env), env) + + def analyse_types(self, env): + self.operand1 = self.operand1.analyse_types(env) + self.operand2 = self.operand2.analyse_types(env) + self.analyse_operation(env) + return self + + def analyse_operation(self, env): + if self.is_pythran_operation(env): + self.type = self.result_type(self.operand1.type, + self.operand2.type, env) + assert self.type.is_pythran_expr + self.is_temp = 1 + elif self.is_py_operation(): + self.coerce_operands_to_pyobjects(env) + self.type = self.result_type(self.operand1.type, + self.operand2.type, env) + assert self.type.is_pyobject + self.is_temp = 1 + elif self.is_cpp_operation(): + self.analyse_cpp_operation(env) + else: + self.analyse_c_operation(env) + + def is_py_operation(self): + return self.is_py_operation_types(self.operand1.type, self.operand2.type) + + def is_py_operation_types(self, type1, type2): + return type1.is_pyobject or type2.is_pyobject or type1.is_ctuple or type2.is_ctuple + + def is_pythran_operation(self, env): + return self.is_pythran_operation_types(self.operand1.type, self.operand2.type, env) + + def is_pythran_operation_types(self, type1, type2, env): + # Support only expr op supported_type, or supported_type op expr + return has_np_pythran(env) and \ + (is_pythran_supported_operation_type(type1) and is_pythran_supported_operation_type(type2)) and \ + (is_pythran_expr(type1) or is_pythran_expr(type2)) + + def is_cpp_operation(self): + return (self.operand1.type.is_cpp_class + or self.operand2.type.is_cpp_class) + + def analyse_cpp_operation(self, env): + entry = env.lookup_operator(self.operator, [self.operand1, self.operand2]) + if not entry: + self.type_error() + return + func_type = entry.type + self.exception_check = func_type.exception_check + self.exception_value = func_type.exception_value + if self.exception_check == '+': + # Used by NumBinopNodes to break up expressions involving multiple + # operators so that exceptions can be handled properly. + self.is_temp = 1 + if self.exception_value is None: + env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp")) + if func_type.is_ptr: + func_type = func_type.base_type + if len(func_type.args) == 1: + self.operand2 = self.operand2.coerce_to(func_type.args[0].type, env) + else: + self.operand1 = self.operand1.coerce_to(func_type.args[0].type, env) + self.operand2 = self.operand2.coerce_to(func_type.args[1].type, env) + self.type = func_type.return_type + + def result_type(self, type1, type2, env): + if self.is_pythran_operation_types(type1, type2, env): + return PythranExpr(pythran_binop_type(self.operator, type1, type2)) + if self.is_py_operation_types(type1, type2): + if type2.is_string: + type2 = Builtin.bytes_type + elif type2.is_pyunicode_ptr: + type2 = Builtin.unicode_type + if type1.is_string: + type1 = Builtin.bytes_type + elif type1.is_pyunicode_ptr: + type1 = Builtin.unicode_type + if type1.is_builtin_type or type2.is_builtin_type: + if type1 is type2 and self.operator in '**%+|&^': + # FIXME: at least these operators should be safe - others? + return type1 + result_type = self.infer_builtin_types_operation(type1, type2) + if result_type is not None: + return result_type + return py_object_type + elif type1.is_error or type2.is_error: + return PyrexTypes.error_type + else: + return self.compute_c_result_type(type1, type2) + + def infer_builtin_types_operation(self, type1, type2): + return None + + def nogil_check(self, env): + if self.is_py_operation(): + self.gil_error() + + def coerce_operands_to_pyobjects(self, env): + self.operand1 = self.operand1.coerce_to_pyobject(env) + self.operand2 = self.operand2.coerce_to_pyobject(env) + + def check_const(self): + return self.operand1.check_const() and self.operand2.check_const() + + def is_ephemeral(self): + return (super(BinopNode, self).is_ephemeral() or + self.operand1.is_ephemeral() or self.operand2.is_ephemeral()) + + def generate_result_code(self, code): + if self.type.is_pythran_expr: + code.putln("// Pythran binop") + code.putln("__Pyx_call_destructor(%s);" % self.result()) + if self.operator == '**': + code.putln("new (&%s) decltype(%s){pythonic::numpy::functor::power{}(%s, %s)};" % ( + self.result(), + self.result(), + self.operand1.pythran_result(), + self.operand2.pythran_result())) + else: + code.putln("new (&%s) decltype(%s){%s %s %s};" % ( + self.result(), + self.result(), + self.operand1.pythran_result(), + self.operator, + self.operand2.pythran_result())) + elif self.operand1.type.is_pyobject: + function = self.py_operation_function(code) + if self.operator == '**': + extra_args = ", Py_None" + else: + extra_args = "" + code.putln( + "%s = %s(%s, %s%s); %s" % ( + self.result(), + function, + self.operand1.py_result(), + self.operand2.py_result(), + extra_args, + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.py_result()) + elif self.is_temp: + # C++ overloaded operators with exception values are currently all + # handled through temporaries. + if self.is_cpp_operation() and self.exception_check == '+': + translate_cpp_exception(code, self.pos, + "%s = %s;" % (self.result(), self.calculate_result_code()), + self.result() if self.type.is_pyobject else None, + self.exception_value, self.in_nogil_context) + else: + code.putln("%s = %s;" % (self.result(), self.calculate_result_code())) + + def type_error(self): + if not (self.operand1.type.is_error + or self.operand2.type.is_error): + error(self.pos, "Invalid operand types for '%s' (%s; %s)" % + (self.operator, self.operand1.type, + self.operand2.type)) + self.type = PyrexTypes.error_type + + +class CBinopNode(BinopNode): + + def analyse_types(self, env): + node = BinopNode.analyse_types(self, env) + if node.is_py_operation(): + node.type = PyrexTypes.error_type + return node + + def py_operation_function(self, code): + return "" + + def calculate_result_code(self): + return "(%s %s %s)" % ( + self.operand1.result(), + self.operator, + self.operand2.result()) + + def compute_c_result_type(self, type1, type2): + cpp_type = None + if type1.is_cpp_class or type1.is_ptr: + cpp_type = type1.find_cpp_operation_type(self.operator, type2) + if cpp_type is None and (type2.is_cpp_class or type2.is_ptr): + cpp_type = type2.find_cpp_operation_type(self.operator, type1) + # FIXME: do we need to handle other cases here? + return cpp_type + + +def c_binop_constructor(operator): + def make_binop_node(pos, **operands): + return CBinopNode(pos, operator=operator, **operands) + return make_binop_node + +class NumBinopNode(BinopNode): + # Binary operation taking numeric arguments. + + infix = True + overflow_check = False + overflow_bit_node = None + + def analyse_c_operation(self, env): + type1 = self.operand1.type + type2 = self.operand2.type + self.type = self.compute_c_result_type(type1, type2) + if not self.type: + self.type_error() + return + if self.type.is_complex: + self.infix = False + if (self.type.is_int + and env.directives['overflowcheck'] + and self.operator in self.overflow_op_names): + if (self.operator in ('+', '*') + and self.operand1.has_constant_result() + and not self.operand2.has_constant_result()): + self.operand1, self.operand2 = self.operand2, self.operand1 + self.overflow_check = True + self.overflow_fold = env.directives['overflowcheck.fold'] + self.func = self.type.overflow_check_binop( + self.overflow_op_names[self.operator], + env, + const_rhs = self.operand2.has_constant_result()) + self.is_temp = True + if not self.infix or (type1.is_numeric and type2.is_numeric): + self.operand1 = self.operand1.coerce_to(self.type, env) + self.operand2 = self.operand2.coerce_to(self.type, env) + + def compute_c_result_type(self, type1, type2): + if self.c_types_okay(type1, type2): + widest_type = PyrexTypes.widest_numeric_type(type1, type2) + if widest_type is PyrexTypes.c_bint_type: + if self.operator not in '|^&': + # False + False == 0 # not False! + widest_type = PyrexTypes.c_int_type + else: + widest_type = PyrexTypes.widest_numeric_type( + widest_type, PyrexTypes.c_int_type) + return widest_type + else: + return None + + def may_be_none(self): + if self.type and self.type.is_builtin_type: + # if we know the result type, we know the operation, so it can't be None + return False + type1 = self.operand1.type + type2 = self.operand2.type + if type1 and type1.is_builtin_type and type2 and type2.is_builtin_type: + # XXX: I can't think of any case where a binary operation + # on builtin types evaluates to None - add a special case + # here if there is one. + return False + return super(NumBinopNode, self).may_be_none() + + def get_constant_c_result_code(self): + value1 = self.operand1.get_constant_c_result_code() + value2 = self.operand2.get_constant_c_result_code() + if value1 and value2: + return "(%s %s %s)" % (value1, self.operator, value2) + else: + return None + + def c_types_okay(self, type1, type2): + #print "NumBinopNode.c_types_okay:", type1, type2 ### + return (type1.is_numeric or type1.is_enum) \ + and (type2.is_numeric or type2.is_enum) + + def generate_evaluation_code(self, code): + if self.overflow_check: + self.overflow_bit_node = self + self.overflow_bit = code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) + code.putln("%s = 0;" % self.overflow_bit) + super(NumBinopNode, self).generate_evaluation_code(code) + if self.overflow_check: + code.putln("if (unlikely(%s)) {" % self.overflow_bit) + code.putln('PyErr_SetString(PyExc_OverflowError, "value too large");') + code.putln(code.error_goto(self.pos)) + code.putln("}") + code.funcstate.release_temp(self.overflow_bit) + + def calculate_result_code(self): + if self.overflow_bit_node is not None: + return "%s(%s, %s, &%s)" % ( + self.func, + self.operand1.result(), + self.operand2.result(), + self.overflow_bit_node.overflow_bit) + elif self.type.is_cpp_class or self.infix: + if is_pythran_expr(self.type): + result1, result2 = self.operand1.pythran_result(), self.operand2.pythran_result() + else: + result1, result2 = self.operand1.result(), self.operand2.result() + return "(%s %s %s)" % (result1, self.operator, result2) + else: + func = self.type.binary_op(self.operator) + if func is None: + error(self.pos, "binary operator %s not supported for %s" % (self.operator, self.type)) + return "%s(%s, %s)" % ( + func, + self.operand1.result(), + self.operand2.result()) + + def is_py_operation_types(self, type1, type2): + return (type1.is_unicode_char or + type2.is_unicode_char or + BinopNode.is_py_operation_types(self, type1, type2)) + + def py_operation_function(self, code): + function_name = self.py_functions[self.operator] + if self.inplace: + function_name = function_name.replace('PyNumber_', 'PyNumber_InPlace') + return function_name + + py_functions = { + "|": "PyNumber_Or", + "^": "PyNumber_Xor", + "&": "PyNumber_And", + "<<": "PyNumber_Lshift", + ">>": "PyNumber_Rshift", + "+": "PyNumber_Add", + "-": "PyNumber_Subtract", + "*": "PyNumber_Multiply", + "@": "__Pyx_PyNumber_MatrixMultiply", + "/": "__Pyx_PyNumber_Divide", + "//": "PyNumber_FloorDivide", + "%": "PyNumber_Remainder", + "**": "PyNumber_Power", + } + + overflow_op_names = { + "+": "add", + "-": "sub", + "*": "mul", + "<<": "lshift", + } + + +class IntBinopNode(NumBinopNode): + # Binary operation taking integer arguments. + + def c_types_okay(self, type1, type2): + #print "IntBinopNode.c_types_okay:", type1, type2 ### + return (type1.is_int or type1.is_enum) \ + and (type2.is_int or type2.is_enum) + + +class AddNode(NumBinopNode): + # '+' operator. + + def is_py_operation_types(self, type1, type2): + if type1.is_string and type2.is_string or type1.is_pyunicode_ptr and type2.is_pyunicode_ptr: + return 1 + else: + return NumBinopNode.is_py_operation_types(self, type1, type2) + + def infer_builtin_types_operation(self, type1, type2): + # b'abc' + 'abc' raises an exception in Py3, + # so we can safely infer the Py2 type for bytes here + string_types = (bytes_type, bytearray_type, str_type, basestring_type, unicode_type) + if type1 in string_types and type2 in string_types: + return string_types[max(string_types.index(type1), + string_types.index(type2))] + return None + + def compute_c_result_type(self, type1, type2): + #print "AddNode.compute_c_result_type:", type1, self.operator, type2 ### + if (type1.is_ptr or type1.is_array) and (type2.is_int or type2.is_enum): + return type1 + elif (type2.is_ptr or type2.is_array) and (type1.is_int or type1.is_enum): + return type2 + else: + return NumBinopNode.compute_c_result_type( + self, type1, type2) + + def py_operation_function(self, code): + type1, type2 = self.operand1.type, self.operand2.type + + if type1 is unicode_type or type2 is unicode_type: + if type1 in (unicode_type, str_type) and type2 in (unicode_type, str_type): + is_unicode_concat = True + elif isinstance(self.operand1, FormattedValueNode) or isinstance(self.operand2, FormattedValueNode): + # Assume that even if we don't know the second type, it's going to be a string. + is_unicode_concat = True + else: + # Operation depends on the second type. + is_unicode_concat = False + + if is_unicode_concat: + if self.operand1.may_be_none() or self.operand2.may_be_none(): + return '__Pyx_PyUnicode_ConcatSafe' + else: + return '__Pyx_PyUnicode_Concat' + + return super(AddNode, self).py_operation_function(code) + + +class SubNode(NumBinopNode): + # '-' operator. + + def compute_c_result_type(self, type1, type2): + if (type1.is_ptr or type1.is_array) and (type2.is_int or type2.is_enum): + return type1 + elif (type1.is_ptr or type1.is_array) and (type2.is_ptr or type2.is_array): + return PyrexTypes.c_ptrdiff_t_type + else: + return NumBinopNode.compute_c_result_type( + self, type1, type2) + + +class MulNode(NumBinopNode): + # '*' operator. + + def is_py_operation_types(self, type1, type2): + if ((type1.is_string and type2.is_int) or + (type2.is_string and type1.is_int)): + return 1 + else: + return NumBinopNode.is_py_operation_types(self, type1, type2) + + def infer_builtin_types_operation(self, type1, type2): + # let's assume that whatever builtin type you multiply a string with + # will either return a string of the same type or fail with an exception + string_types = (bytes_type, bytearray_type, str_type, basestring_type, unicode_type) + if type1 in string_types and type2.is_builtin_type: + return type1 + if type2 in string_types and type1.is_builtin_type: + return type2 + # multiplication of containers/numbers with an integer value + # always (?) returns the same type + if type1.is_int: + return type2 + if type2.is_int: + return type1 + return None + + +class MatMultNode(NumBinopNode): + # '@' operator. + + def is_py_operation_types(self, type1, type2): + return True + + def generate_evaluation_code(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("MatrixMultiply", "ObjectHandling.c")) + super(MatMultNode, self).generate_evaluation_code(code) + + +class DivNode(NumBinopNode): + # '/' or '//' operator. + + cdivision = None + truedivision = None # == "unknown" if operator == '/' + ctruedivision = False + cdivision_warnings = False + zerodivision_check = None + + def find_compile_time_binary_operator(self, op1, op2): + func = compile_time_binary_operators[self.operator] + if self.operator == '/' and self.truedivision is None: + # => true div for floats, floor div for integers + if isinstance(op1, _py_int_types) and isinstance(op2, _py_int_types): + func = compile_time_binary_operators['//'] + return func + + def calculate_constant_result(self): + op1 = self.operand1.constant_result + op2 = self.operand2.constant_result + func = self.find_compile_time_binary_operator(op1, op2) + self.constant_result = func( + self.operand1.constant_result, + self.operand2.constant_result) + + def compile_time_value(self, denv): + operand1 = self.operand1.compile_time_value(denv) + operand2 = self.operand2.compile_time_value(denv) + try: + func = self.find_compile_time_binary_operator( + operand1, operand2) + return func(operand1, operand2) + except Exception as e: + self.compile_time_value_error(e) + + def _check_truedivision(self, env): + if self.cdivision or env.directives['cdivision']: + self.ctruedivision = False + else: + self.ctruedivision = self.truedivision + + def infer_type(self, env): + self._check_truedivision(env) + return self.result_type( + self.operand1.infer_type(env), + self.operand2.infer_type(env), env) + + def analyse_operation(self, env): + self._check_truedivision(env) + NumBinopNode.analyse_operation(self, env) + if self.is_cpp_operation(): + self.cdivision = True + if not self.type.is_pyobject: + self.zerodivision_check = ( + self.cdivision is None and not env.directives['cdivision'] + and (not self.operand2.has_constant_result() or + self.operand2.constant_result == 0)) + if self.zerodivision_check or env.directives['cdivision_warnings']: + # Need to check ahead of time to warn or raise zero division error + self.operand1 = self.operand1.coerce_to_simple(env) + self.operand2 = self.operand2.coerce_to_simple(env) + + def compute_c_result_type(self, type1, type2): + if self.operator == '/' and self.ctruedivision and not type1.is_cpp_class and not type2.is_cpp_class: + if not type1.is_float and not type2.is_float: + widest_type = PyrexTypes.widest_numeric_type(type1, PyrexTypes.c_double_type) + widest_type = PyrexTypes.widest_numeric_type(type2, widest_type) + return widest_type + return NumBinopNode.compute_c_result_type(self, type1, type2) + + def zero_division_message(self): + if self.type.is_int: + return "integer division or modulo by zero" + else: + return "float division" + + def generate_evaluation_code(self, code): + if not self.type.is_pyobject and not self.type.is_complex: + if self.cdivision is None: + self.cdivision = ( + code.globalstate.directives['cdivision'] + or self.type.is_float + or ((self.type.is_numeric or self.type.is_enum) and not self.type.signed) + ) + if not self.cdivision: + code.globalstate.use_utility_code( + UtilityCode.load_cached("DivInt", "CMath.c").specialize(self.type)) + NumBinopNode.generate_evaluation_code(self, code) + self.generate_div_warning_code(code) + + def generate_div_warning_code(self, code): + in_nogil = self.in_nogil_context + if not self.type.is_pyobject: + if self.zerodivision_check: + if not self.infix: + zero_test = "%s(%s)" % (self.type.unary_op('zero'), self.operand2.result()) + else: + zero_test = "%s == 0" % self.operand2.result() + code.putln("if (unlikely(%s)) {" % zero_test) + if in_nogil: + code.put_ensure_gil() + code.putln('PyErr_SetString(PyExc_ZeroDivisionError, "%s");' % self.zero_division_message()) + if in_nogil: + code.put_release_ensured_gil() + code.putln(code.error_goto(self.pos)) + code.putln("}") + if self.type.is_int and self.type.signed and self.operator != '%': + code.globalstate.use_utility_code(UtilityCode.load_cached("UnaryNegOverflows", "Overflow.c")) + if self.operand2.type.signed == 2: + # explicitly signed, no runtime check needed + minus1_check = 'unlikely(%s == -1)' % self.operand2.result() + else: + type_of_op2 = self.operand2.type.empty_declaration_code() + minus1_check = '(!(((%s)-1) > 0)) && unlikely(%s == (%s)-1)' % ( + type_of_op2, self.operand2.result(), type_of_op2) + code.putln("else if (sizeof(%s) == sizeof(long) && %s " + " && unlikely(UNARY_NEG_WOULD_OVERFLOW(%s))) {" % ( + self.type.empty_declaration_code(), + minus1_check, + self.operand1.result())) + if in_nogil: + code.put_ensure_gil() + code.putln('PyErr_SetString(PyExc_OverflowError, "value too large to perform division");') + if in_nogil: + code.put_release_ensured_gil() + code.putln(code.error_goto(self.pos)) + code.putln("}") + if code.globalstate.directives['cdivision_warnings'] and self.operator != '/': + code.globalstate.use_utility_code( + UtilityCode.load_cached("CDivisionWarning", "CMath.c")) + code.putln("if (unlikely((%s < 0) ^ (%s < 0))) {" % ( + self.operand1.result(), + self.operand2.result())) + warning_code = "__Pyx_cdivision_warning(%(FILENAME)s, %(LINENO)s)" % { + 'FILENAME': Naming.filename_cname, + 'LINENO': Naming.lineno_cname, + } + + if in_nogil: + result_code = 'result' + code.putln("int %s;" % result_code) + code.put_ensure_gil() + code.putln(code.set_error_info(self.pos, used=True)) + code.putln("%s = %s;" % (result_code, warning_code)) + code.put_release_ensured_gil() + else: + result_code = warning_code + code.putln(code.set_error_info(self.pos, used=True)) + + code.put("if (unlikely(%s)) " % result_code) + code.put_goto(code.error_label) + code.putln("}") + + def calculate_result_code(self): + if self.type.is_complex or self.is_cpp_operation(): + return NumBinopNode.calculate_result_code(self) + elif self.type.is_float and self.operator == '//': + return "floor(%s / %s)" % ( + self.operand1.result(), + self.operand2.result()) + elif self.truedivision or self.cdivision: + op1 = self.operand1.result() + op2 = self.operand2.result() + if self.truedivision: + if self.type != self.operand1.type: + op1 = self.type.cast_code(op1) + if self.type != self.operand2.type: + op2 = self.type.cast_code(op2) + return "(%s / %s)" % (op1, op2) + else: + return "__Pyx_div_%s(%s, %s)" % ( + self.type.specialization_name(), + self.operand1.result(), + self.operand2.result()) + + +_find_formatting_types = re.compile( + br"%" + br"(?:%|" # %% + br"(?:\([^)]+\))?" # %(name) + br"[-+#,0-9 ]*([a-z])" # %.2f etc. + br")").findall + +# These format conversion types can never trigger a Unicode string conversion in Py2. +_safe_bytes_formats = set([ + # Excludes 's' and 'r', which can generate non-bytes strings. + b'd', b'i', b'o', b'u', b'x', b'X', b'e', b'E', b'f', b'F', b'g', b'G', b'c', b'b', b'a', +]) + + +class ModNode(DivNode): + # '%' operator. + + def is_py_operation_types(self, type1, type2): + return (type1.is_string + or type2.is_string + or NumBinopNode.is_py_operation_types(self, type1, type2)) + + def infer_builtin_types_operation(self, type1, type2): + # b'%s' % xyz raises an exception in Py3<3.5, so it's safe to infer the type for Py2 and later Py3's. + if type1 is unicode_type: + # None + xyz may be implemented by RHS + if type2.is_builtin_type or not self.operand1.may_be_none(): + return type1 + elif type1 in (bytes_type, str_type, basestring_type): + if type2 is unicode_type: + return type2 + elif type2.is_numeric: + return type1 + elif self.operand1.is_string_literal: + if type1 is str_type or type1 is bytes_type: + if set(_find_formatting_types(self.operand1.value)) <= _safe_bytes_formats: + return type1 + return basestring_type + elif type1 is bytes_type and not type2.is_builtin_type: + return None # RHS might implement '% operator differently in Py3 + else: + return basestring_type # either str or unicode, can't tell + return None + + def zero_division_message(self): + if self.type.is_int: + return "integer division or modulo by zero" + else: + return "float divmod()" + + def analyse_operation(self, env): + DivNode.analyse_operation(self, env) + if not self.type.is_pyobject: + if self.cdivision is None: + self.cdivision = env.directives['cdivision'] or not self.type.signed + if not self.cdivision and not self.type.is_int and not self.type.is_float: + error(self.pos, "mod operator not supported for type '%s'" % self.type) + + def generate_evaluation_code(self, code): + if not self.type.is_pyobject and not self.cdivision: + if self.type.is_int: + code.globalstate.use_utility_code( + UtilityCode.load_cached("ModInt", "CMath.c").specialize(self.type)) + else: # float + code.globalstate.use_utility_code( + UtilityCode.load_cached("ModFloat", "CMath.c").specialize( + self.type, math_h_modifier=self.type.math_h_modifier)) + # NOTE: skipping over DivNode here + NumBinopNode.generate_evaluation_code(self, code) + self.generate_div_warning_code(code) + + def calculate_result_code(self): + if self.cdivision: + if self.type.is_float: + return "fmod%s(%s, %s)" % ( + self.type.math_h_modifier, + self.operand1.result(), + self.operand2.result()) + else: + return "(%s %% %s)" % ( + self.operand1.result(), + self.operand2.result()) + else: + return "__Pyx_mod_%s(%s, %s)" % ( + self.type.specialization_name(), + self.operand1.result(), + self.operand2.result()) + + def py_operation_function(self, code): + type1, type2 = self.operand1.type, self.operand2.type + # ("..." % x) must call "x.__rmod__()" for string subtypes. + if type1 is unicode_type: + if self.operand1.may_be_none() or ( + type2.is_extension_type and type2.subtype_of(type1) or + type2 is py_object_type and not isinstance(self.operand2, CoerceToPyTypeNode)): + return '__Pyx_PyUnicode_FormatSafe' + else: + return 'PyUnicode_Format' + elif type1 is str_type: + if self.operand1.may_be_none() or ( + type2.is_extension_type and type2.subtype_of(type1) or + type2 is py_object_type and not isinstance(self.operand2, CoerceToPyTypeNode)): + return '__Pyx_PyString_FormatSafe' + else: + return '__Pyx_PyString_Format' + return super(ModNode, self).py_operation_function(code) + + +class PowNode(NumBinopNode): + # '**' operator. + + def analyse_types(self, env): + if not env.directives['cpow']: + # Note - the check here won't catch cpow directives that don't use '**' + # but that's probably OK for a placeholder forward compatibility directive + error(self.pos, "The 'cpow' directive is provided for forward compatibility " + "and must be True") + return super(PowNode, self).analyse_types(env) + + def analyse_c_operation(self, env): + NumBinopNode.analyse_c_operation(self, env) + if self.type.is_complex: + if self.type.real_type.is_float: + self.operand1 = self.operand1.coerce_to(self.type, env) + self.operand2 = self.operand2.coerce_to(self.type, env) + self.pow_func = self.type.binary_op('**') + else: + error(self.pos, "complex int powers not supported") + self.pow_func = "<error>" + elif self.type.is_float: + self.pow_func = "pow" + self.type.math_h_modifier + elif self.type.is_int: + self.pow_func = "__Pyx_pow_%s" % self.type.empty_declaration_code().replace(' ', '_') + env.use_utility_code( + UtilityCode.load_cached("IntPow", "CMath.c").specialize( + func_name=self.pow_func, + type=self.type.empty_declaration_code(), + signed=self.type.signed and 1 or 0)) + elif not self.type.is_error: + error(self.pos, "got unexpected types for C power operator: %s, %s" % + (self.operand1.type, self.operand2.type)) + + def calculate_result_code(self): + # Work around MSVC overloading ambiguity. + def typecast(operand): + if self.type == operand.type: + return operand.result() + else: + return self.type.cast_code(operand.result()) + return "%s(%s, %s)" % ( + self.pow_func, + typecast(self.operand1), + typecast(self.operand2)) + + def py_operation_function(self, code): + if (self.type.is_pyobject and + self.operand1.constant_result == 2 and + isinstance(self.operand1.constant_result, _py_int_types) and + self.operand2.type is py_object_type): + code.globalstate.use_utility_code(UtilityCode.load_cached('PyNumberPow2', 'Optimize.c')) + if self.inplace: + return '__Pyx_PyNumber_InPlacePowerOf2' + else: + return '__Pyx_PyNumber_PowerOf2' + return super(PowNode, self).py_operation_function(code) + + +class BoolBinopNode(ExprNode): + """ + Short-circuiting boolean operation. + + Note that this node provides the same code generation method as + BoolBinopResultNode to simplify expression nesting. + + operator string "and"/"or" + operand1 BoolBinopNode/BoolBinopResultNode left operand + operand2 BoolBinopNode/BoolBinopResultNode right operand + """ + subexprs = ['operand1', 'operand2'] + is_temp = True + operator = None + operand1 = None + operand2 = None + + def infer_type(self, env): + type1 = self.operand1.infer_type(env) + type2 = self.operand2.infer_type(env) + return PyrexTypes.independent_spanning_type(type1, type2) + + def may_be_none(self): + if self.operator == 'or': + return self.operand2.may_be_none() + else: + return self.operand1.may_be_none() or self.operand2.may_be_none() + + def calculate_constant_result(self): + operand1 = self.operand1.constant_result + operand2 = self.operand2.constant_result + if self.operator == 'and': + self.constant_result = operand1 and operand2 + else: + self.constant_result = operand1 or operand2 + + def compile_time_value(self, denv): + operand1 = self.operand1.compile_time_value(denv) + operand2 = self.operand2.compile_time_value(denv) + if self.operator == 'and': + return operand1 and operand2 + else: + return operand1 or operand2 + + def is_ephemeral(self): + return self.operand1.is_ephemeral() or self.operand2.is_ephemeral() + + def analyse_types(self, env): + # Note: we do not do any coercion here as we most likely do not know the final type anyway. + # We even accept to set self.type to ErrorType if both operands do not have a spanning type. + # The coercion to the final type and to a "simple" value is left to coerce_to(). + operand1 = self.operand1.analyse_types(env) + operand2 = self.operand2.analyse_types(env) + self.type = PyrexTypes.independent_spanning_type( + operand1.type, operand2.type) + self.operand1 = self._wrap_operand(operand1, env) + self.operand2 = self._wrap_operand(operand2, env) + return self + + def _wrap_operand(self, operand, env): + if not isinstance(operand, (BoolBinopNode, BoolBinopResultNode)): + operand = BoolBinopResultNode(operand, self.type, env) + return operand + + def wrap_operands(self, env): + """ + Must get called by transforms that want to create a correct BoolBinopNode + after the type analysis phase. + """ + self.operand1 = self._wrap_operand(self.operand1, env) + self.operand2 = self._wrap_operand(self.operand2, env) + + def coerce_to_boolean(self, env): + return self.coerce_to(PyrexTypes.c_bint_type, env) + + def coerce_to(self, dst_type, env): + operand1 = self.operand1.coerce_to(dst_type, env) + operand2 = self.operand2.coerce_to(dst_type, env) + return BoolBinopNode.from_node( + self, type=dst_type, + operator=self.operator, + operand1=operand1, operand2=operand2) + + def generate_bool_evaluation_code(self, code, final_result_temp, final_result_type, and_label, or_label, end_label, fall_through): + code.mark_pos(self.pos) + + outer_labels = (and_label, or_label) + if self.operator == 'and': + my_label = and_label = code.new_label('next_and') + else: + my_label = or_label = code.new_label('next_or') + self.operand1.generate_bool_evaluation_code( + code, final_result_temp, final_result_type, and_label, or_label, end_label, my_label) + + and_label, or_label = outer_labels + + code.put_label(my_label) + self.operand2.generate_bool_evaluation_code( + code, final_result_temp, final_result_type, and_label, or_label, end_label, fall_through) + + def generate_evaluation_code(self, code): + self.allocate_temp_result(code) + result_type = PyrexTypes.py_object_type if self.type.is_pyobject else self.type + or_label = and_label = None + end_label = code.new_label('bool_binop_done') + self.generate_bool_evaluation_code(code, self.result(), result_type, and_label, or_label, end_label, end_label) + code.put_label(end_label) + + gil_message = "Truth-testing Python object" + + def check_const(self): + return self.operand1.check_const() and self.operand2.check_const() + + def generate_subexpr_disposal_code(self, code): + pass # nothing to do here, all done in generate_evaluation_code() + + def free_subexpr_temps(self, code): + pass # nothing to do here, all done in generate_evaluation_code() + + def generate_operand1_test(self, code): + # Generate code to test the truth of the first operand. + if self.type.is_pyobject: + test_result = code.funcstate.allocate_temp( + PyrexTypes.c_bint_type, manage_ref=False) + code.putln( + "%s = __Pyx_PyObject_IsTrue(%s); %s" % ( + test_result, + self.operand1.py_result(), + code.error_goto_if_neg(test_result, self.pos))) + else: + test_result = self.operand1.result() + return (test_result, self.type.is_pyobject) + + +class BoolBinopResultNode(ExprNode): + """ + Intermediate result of a short-circuiting and/or expression. + Tests the result for 'truthiness' and takes care of coercing the final result + of the overall expression to the target type. + + Note that this node provides the same code generation method as + BoolBinopNode to simplify expression nesting. + + arg ExprNode the argument to test + value ExprNode the coerced result value node + """ + + subexprs = ['arg', 'value'] + is_temp = True + arg = None + value = None + + def __init__(self, arg, result_type, env): + # using 'arg' multiple times, so it must be a simple/temp value + arg = arg.coerce_to_simple(env) + # wrap in ProxyNode, in case a transform wants to replace self.arg later + arg = ProxyNode(arg) + super(BoolBinopResultNode, self).__init__( + arg.pos, arg=arg, type=result_type, + value=CloneNode(arg).coerce_to(result_type, env)) + + def coerce_to_boolean(self, env): + return self.coerce_to(PyrexTypes.c_bint_type, env) + + def coerce_to(self, dst_type, env): + # unwrap, coerce, rewrap + arg = self.arg.arg + if dst_type is PyrexTypes.c_bint_type: + arg = arg.coerce_to_boolean(env) + # TODO: unwrap more coercion nodes? + return BoolBinopResultNode(arg, dst_type, env) + + def nogil_check(self, env): + # let's leave all errors to BoolBinopNode + pass + + def generate_operand_test(self, code): + # Generate code to test the truth of the first operand. + if self.arg.type.is_pyobject: + test_result = code.funcstate.allocate_temp( + PyrexTypes.c_bint_type, manage_ref=False) + code.putln( + "%s = __Pyx_PyObject_IsTrue(%s); %s" % ( + test_result, + self.arg.py_result(), + code.error_goto_if_neg(test_result, self.pos))) + else: + test_result = self.arg.result() + return (test_result, self.arg.type.is_pyobject) + + def generate_bool_evaluation_code(self, code, final_result_temp, final_result_type, and_label, or_label, end_label, fall_through): + code.mark_pos(self.pos) + + # x => x + # x and ... or ... => next 'and' / 'or' + # False ... or x => next 'or' + # True and x => next 'and' + # True or x => True (operand) + + self.arg.generate_evaluation_code(code) + if and_label or or_label: + test_result, uses_temp = self.generate_operand_test(code) + if uses_temp and (and_label and or_label): + # cannot become final result => free early + # disposal: uses_temp and (and_label and or_label) + self.arg.generate_disposal_code(code) + sense = '!' if or_label else '' + code.putln("if (%s%s) {" % (sense, test_result)) + if uses_temp: + code.funcstate.release_temp(test_result) + if not uses_temp or not (and_label and or_label): + # disposal: (not uses_temp) or {not (and_label and or_label) [if]} + self.arg.generate_disposal_code(code) + + if or_label and or_label != fall_through: + # value is false => short-circuit to next 'or' + code.put_goto(or_label) + if and_label: + # value is true => go to next 'and' + if or_label: + code.putln("} else {") + if not uses_temp: + # disposal: (not uses_temp) and {(and_label and or_label) [else]} + self.arg.generate_disposal_code(code) + if and_label != fall_through: + code.put_goto(and_label) + + if not and_label or not or_label: + # if no next 'and' or 'or', we provide the result + if and_label or or_label: + code.putln("} else {") + self.value.generate_evaluation_code(code) + self.value.make_owned_reference(code) + code.putln("%s = %s;" % (final_result_temp, self.value.result_as(final_result_type))) + self.value.generate_post_assignment_code(code) + # disposal: {not (and_label and or_label) [else]} + self.arg.generate_disposal_code(code) + self.value.free_temps(code) + if end_label != fall_through: + code.put_goto(end_label) + + if and_label or or_label: + code.putln("}") + self.arg.free_temps(code) + + +class CondExprNode(ExprNode): + # Short-circuiting conditional expression. + # + # test ExprNode + # true_val ExprNode + # false_val ExprNode + + true_val = None + false_val = None + is_temp = True + + subexprs = ['test', 'true_val', 'false_val'] + + def type_dependencies(self, env): + return self.true_val.type_dependencies(env) + self.false_val.type_dependencies(env) + + def infer_type(self, env): + return PyrexTypes.independent_spanning_type( + self.true_val.infer_type(env), + self.false_val.infer_type(env)) + + def calculate_constant_result(self): + if self.test.constant_result: + self.constant_result = self.true_val.constant_result + else: + self.constant_result = self.false_val.constant_result + + def is_ephemeral(self): + return self.true_val.is_ephemeral() or self.false_val.is_ephemeral() + + def analyse_types(self, env): + self.test = self.test.analyse_types(env).coerce_to_boolean(env) + self.true_val = self.true_val.analyse_types(env) + self.false_val = self.false_val.analyse_types(env) + return self.analyse_result_type(env) + + def analyse_result_type(self, env): + true_val_type = self.true_val.type + false_val_type = self.false_val.type + self.type = PyrexTypes.independent_spanning_type(true_val_type, false_val_type) + + if self.type.is_reference: + self.type = PyrexTypes.CFakeReferenceType(self.type.ref_base_type) + if self.type.is_pyobject: + self.result_ctype = py_object_type + elif self.true_val.is_ephemeral() or self.false_val.is_ephemeral(): + error(self.pos, "Unsafe C derivative of temporary Python reference used in conditional expression") + + if true_val_type.is_pyobject or false_val_type.is_pyobject: + if true_val_type != self.type: + self.true_val = self.true_val.coerce_to(self.type, env) + if false_val_type != self.type: + self.false_val = self.false_val.coerce_to(self.type, env) + + if self.type.is_error: + self.type_error() + return self + + def coerce_to_integer(self, env): + if not self.true_val.type.is_int: + self.true_val = self.true_val.coerce_to_integer(env) + if not self.false_val.type.is_int: + self.false_val = self.false_val.coerce_to_integer(env) + self.result_ctype = None + return self.analyse_result_type(env) + + def coerce_to(self, dst_type, env): + if self.true_val.type != dst_type: + self.true_val = self.true_val.coerce_to(dst_type, env) + if self.false_val.type != dst_type: + self.false_val = self.false_val.coerce_to(dst_type, env) + self.result_ctype = None + return self.analyse_result_type(env) + + def type_error(self): + if not (self.true_val.type.is_error or self.false_val.type.is_error): + error(self.pos, "Incompatible types in conditional expression (%s; %s)" % + (self.true_val.type, self.false_val.type)) + self.type = PyrexTypes.error_type + + def check_const(self): + return (self.test.check_const() + and self.true_val.check_const() + and self.false_val.check_const()) + + def generate_evaluation_code(self, code): + # Because subexprs may not be evaluated we can use a more optimal + # subexpr allocation strategy than the default, so override evaluation_code. + + code.mark_pos(self.pos) + self.allocate_temp_result(code) + self.test.generate_evaluation_code(code) + code.putln("if (%s) {" % self.test.result()) + self.eval_and_get(code, self.true_val) + code.putln("} else {") + self.eval_and_get(code, self.false_val) + code.putln("}") + self.test.generate_disposal_code(code) + self.test.free_temps(code) + + def eval_and_get(self, code, expr): + expr.generate_evaluation_code(code) + if self.type.is_memoryviewslice: + expr.make_owned_memoryviewslice(code) + else: + expr.make_owned_reference(code) + code.putln('%s = %s;' % (self.result(), expr.result_as(self.ctype()))) + expr.generate_post_assignment_code(code) + expr.free_temps(code) + + def generate_subexpr_disposal_code(self, code): + pass # done explicitly above (cleanup must separately happen within the if/else blocks) + + def free_subexpr_temps(self, code): + pass # done explicitly above (cleanup must separately happen within the if/else blocks) + + +richcmp_constants = { + "<" : "Py_LT", + "<=": "Py_LE", + "==": "Py_EQ", + "!=": "Py_NE", + "<>": "Py_NE", + ">" : "Py_GT", + ">=": "Py_GE", + # the following are faked by special compare functions + "in" : "Py_EQ", + "not_in": "Py_NE", +} + +class CmpNode(object): + # Mixin class containing code common to PrimaryCmpNodes + # and CascadedCmpNodes. + + special_bool_cmp_function = None + special_bool_cmp_utility_code = None + + def infer_type(self, env): + # TODO: Actually implement this (after merging with -unstable). + return py_object_type + + def calculate_cascaded_constant_result(self, operand1_result): + func = compile_time_binary_operators[self.operator] + operand2_result = self.operand2.constant_result + if (isinstance(operand1_result, any_string_type) and + isinstance(operand2_result, any_string_type) and + type(operand1_result) != type(operand2_result)): + # string comparison of different types isn't portable + return + + if self.operator in ('in', 'not_in'): + if isinstance(self.operand2, (ListNode, TupleNode, SetNode)): + if not self.operand2.args: + self.constant_result = self.operator == 'not_in' + return + elif isinstance(self.operand2, ListNode) and not self.cascade: + # tuples are more efficient to store than lists + self.operand2 = self.operand2.as_tuple() + elif isinstance(self.operand2, DictNode): + if not self.operand2.key_value_pairs: + self.constant_result = self.operator == 'not_in' + return + + self.constant_result = func(operand1_result, operand2_result) + + def cascaded_compile_time_value(self, operand1, denv): + func = get_compile_time_binop(self) + operand2 = self.operand2.compile_time_value(denv) + try: + result = func(operand1, operand2) + except Exception as e: + self.compile_time_value_error(e) + result = None + if result: + cascade = self.cascade + if cascade: + result = result and cascade.cascaded_compile_time_value(operand2, denv) + return result + + def is_cpp_comparison(self): + return self.operand1.type.is_cpp_class or self.operand2.type.is_cpp_class + + def find_common_int_type(self, env, op, operand1, operand2): + # type1 != type2 and at least one of the types is not a C int + type1 = operand1.type + type2 = operand2.type + type1_can_be_int = False + type2_can_be_int = False + + if operand1.is_string_literal and operand1.can_coerce_to_char_literal(): + type1_can_be_int = True + if operand2.is_string_literal and operand2.can_coerce_to_char_literal(): + type2_can_be_int = True + + if type1.is_int: + if type2_can_be_int: + return type1 + elif type2.is_int: + if type1_can_be_int: + return type2 + elif type1_can_be_int: + if type2_can_be_int: + if Builtin.unicode_type in (type1, type2): + return PyrexTypes.c_py_ucs4_type + else: + return PyrexTypes.c_uchar_type + + return None + + def find_common_type(self, env, op, operand1, common_type=None): + operand2 = self.operand2 + type1 = operand1.type + type2 = operand2.type + + new_common_type = None + + # catch general errors + if (type1 == str_type and (type2.is_string or type2 in (bytes_type, unicode_type)) or + type2 == str_type and (type1.is_string or type1 in (bytes_type, unicode_type))): + error(self.pos, "Comparisons between bytes/unicode and str are not portable to Python 3") + new_common_type = error_type + + # try to use numeric comparisons where possible + elif type1.is_complex or type2.is_complex: + if (op not in ('==', '!=') + and (type1.is_complex or type1.is_numeric) + and (type2.is_complex or type2.is_numeric)): + error(self.pos, "complex types are unordered") + new_common_type = error_type + elif type1.is_pyobject: + new_common_type = Builtin.complex_type if type1.subtype_of(Builtin.complex_type) else py_object_type + elif type2.is_pyobject: + new_common_type = Builtin.complex_type if type2.subtype_of(Builtin.complex_type) else py_object_type + else: + new_common_type = PyrexTypes.widest_numeric_type(type1, type2) + elif type1.is_numeric and type2.is_numeric: + new_common_type = PyrexTypes.widest_numeric_type(type1, type2) + elif common_type is None or not common_type.is_pyobject: + new_common_type = self.find_common_int_type(env, op, operand1, operand2) + + if new_common_type is None: + # fall back to generic type compatibility tests + if type1.is_ctuple or type2.is_ctuple: + new_common_type = py_object_type + elif type1 == type2: + new_common_type = type1 + elif type1.is_pyobject or type2.is_pyobject: + if type2.is_numeric or type2.is_string: + if operand2.check_for_coercion_error(type1, env): + new_common_type = error_type + else: + new_common_type = py_object_type + elif type1.is_numeric or type1.is_string: + if operand1.check_for_coercion_error(type2, env): + new_common_type = error_type + else: + new_common_type = py_object_type + elif py_object_type.assignable_from(type1) and py_object_type.assignable_from(type2): + new_common_type = py_object_type + else: + # one Python type and one non-Python type, not assignable + self.invalid_types_error(operand1, op, operand2) + new_common_type = error_type + elif type1.assignable_from(type2): + new_common_type = type1 + elif type2.assignable_from(type1): + new_common_type = type2 + else: + # C types that we couldn't handle up to here are an error + self.invalid_types_error(operand1, op, operand2) + new_common_type = error_type + + if new_common_type.is_string and (isinstance(operand1, BytesNode) or + isinstance(operand2, BytesNode)): + # special case when comparing char* to bytes literal: must + # compare string values! + new_common_type = bytes_type + + # recursively merge types + if common_type is None or new_common_type.is_error: + common_type = new_common_type + else: + # we could do a lot better by splitting the comparison + # into a non-Python part and a Python part, but this is + # safer for now + common_type = PyrexTypes.spanning_type(common_type, new_common_type) + + if self.cascade: + common_type = self.cascade.find_common_type(env, self.operator, operand2, common_type) + + return common_type + + def invalid_types_error(self, operand1, op, operand2): + error(self.pos, "Invalid types for '%s' (%s, %s)" % + (op, operand1.type, operand2.type)) + + def is_python_comparison(self): + return (not self.is_ptr_contains() + and not self.is_c_string_contains() + and (self.has_python_operands() + or (self.cascade and self.cascade.is_python_comparison()) + or self.operator in ('in', 'not_in'))) + + def coerce_operands_to(self, dst_type, env): + operand2 = self.operand2 + if operand2.type != dst_type: + self.operand2 = operand2.coerce_to(dst_type, env) + if self.cascade: + self.cascade.coerce_operands_to(dst_type, env) + + def is_python_result(self): + return ((self.has_python_operands() and + self.special_bool_cmp_function is None and + self.operator not in ('is', 'is_not', 'in', 'not_in') and + not self.is_c_string_contains() and + not self.is_ptr_contains()) + or (self.cascade and self.cascade.is_python_result())) + + def is_c_string_contains(self): + return self.operator in ('in', 'not_in') and \ + ((self.operand1.type.is_int + and (self.operand2.type.is_string or self.operand2.type is bytes_type)) or + (self.operand1.type.is_unicode_char + and self.operand2.type is unicode_type)) + + def is_ptr_contains(self): + if self.operator in ('in', 'not_in'): + container_type = self.operand2.type + return (container_type.is_ptr or container_type.is_array) \ + and not container_type.is_string + + def find_special_bool_compare_function(self, env, operand1, result_is_bool=False): + # note: currently operand1 must get coerced to a Python object if we succeed here! + if self.operator in ('==', '!='): + type1, type2 = operand1.type, self.operand2.type + if result_is_bool or (type1.is_builtin_type and type2.is_builtin_type): + if type1 is Builtin.unicode_type or type2 is Builtin.unicode_type: + self.special_bool_cmp_utility_code = UtilityCode.load_cached("UnicodeEquals", "StringTools.c") + self.special_bool_cmp_function = "__Pyx_PyUnicode_Equals" + return True + elif type1 is Builtin.bytes_type or type2 is Builtin.bytes_type: + self.special_bool_cmp_utility_code = UtilityCode.load_cached("BytesEquals", "StringTools.c") + self.special_bool_cmp_function = "__Pyx_PyBytes_Equals" + return True + elif type1 is Builtin.basestring_type or type2 is Builtin.basestring_type: + self.special_bool_cmp_utility_code = UtilityCode.load_cached("UnicodeEquals", "StringTools.c") + self.special_bool_cmp_function = "__Pyx_PyUnicode_Equals" + return True + elif type1 is Builtin.str_type or type2 is Builtin.str_type: + self.special_bool_cmp_utility_code = UtilityCode.load_cached("StrEquals", "StringTools.c") + self.special_bool_cmp_function = "__Pyx_PyString_Equals" + return True + elif self.operator in ('in', 'not_in'): + if self.operand2.type is Builtin.dict_type: + self.operand2 = self.operand2.as_none_safe_node("'NoneType' object is not iterable") + self.special_bool_cmp_utility_code = UtilityCode.load_cached("PyDictContains", "ObjectHandling.c") + self.special_bool_cmp_function = "__Pyx_PyDict_ContainsTF" + return True + elif self.operand2.type is Builtin.set_type: + self.operand2 = self.operand2.as_none_safe_node("'NoneType' object is not iterable") + self.special_bool_cmp_utility_code = UtilityCode.load_cached("PySetContains", "ObjectHandling.c") + self.special_bool_cmp_function = "__Pyx_PySet_ContainsTF" + return True + elif self.operand2.type is Builtin.unicode_type: + self.operand2 = self.operand2.as_none_safe_node("'NoneType' object is not iterable") + self.special_bool_cmp_utility_code = UtilityCode.load_cached("PyUnicodeContains", "StringTools.c") + self.special_bool_cmp_function = "__Pyx_PyUnicode_ContainsTF" + return True + else: + if not self.operand2.type.is_pyobject: + self.operand2 = self.operand2.coerce_to_pyobject(env) + self.special_bool_cmp_utility_code = UtilityCode.load_cached("PySequenceContains", "ObjectHandling.c") + self.special_bool_cmp_function = "__Pyx_PySequence_ContainsTF" + return True + return False + + def generate_operation_code(self, code, result_code, + operand1, op , operand2): + if self.type.is_pyobject: + error_clause = code.error_goto_if_null + got_ref = "__Pyx_XGOTREF(%s); " % result_code + if self.special_bool_cmp_function: + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyBoolOrNullFromLong", "ObjectHandling.c")) + coerce_result = "__Pyx_PyBoolOrNull_FromLong" + else: + coerce_result = "__Pyx_PyBool_FromLong" + else: + error_clause = code.error_goto_if_neg + got_ref = "" + coerce_result = "" + + if self.special_bool_cmp_function: + if operand1.type.is_pyobject: + result1 = operand1.py_result() + else: + result1 = operand1.result() + if operand2.type.is_pyobject: + result2 = operand2.py_result() + else: + result2 = operand2.result() + if self.special_bool_cmp_utility_code: + code.globalstate.use_utility_code(self.special_bool_cmp_utility_code) + code.putln( + "%s = %s(%s(%s, %s, %s)); %s%s" % ( + result_code, + coerce_result, + self.special_bool_cmp_function, + result1, result2, richcmp_constants[op], + got_ref, + error_clause(result_code, self.pos))) + + elif operand1.type.is_pyobject and op not in ('is', 'is_not'): + assert op not in ('in', 'not_in'), op + code.putln("%s = PyObject_RichCompare(%s, %s, %s); %s%s" % ( + result_code, + operand1.py_result(), + operand2.py_result(), + richcmp_constants[op], + got_ref, + error_clause(result_code, self.pos))) + + elif operand1.type.is_complex: + code.putln("%s = %s(%s%s(%s, %s));" % ( + result_code, + coerce_result, + op == "!=" and "!" or "", + operand1.type.unary_op('eq'), + operand1.result(), + operand2.result())) + + else: + type1 = operand1.type + type2 = operand2.type + if (type1.is_extension_type or type2.is_extension_type) \ + and not type1.same_as(type2): + common_type = py_object_type + elif type1.is_numeric: + common_type = PyrexTypes.widest_numeric_type(type1, type2) + else: + common_type = type1 + code1 = operand1.result_as(common_type) + code2 = operand2.result_as(common_type) + statement = "%s = %s(%s %s %s);" % ( + result_code, + coerce_result, + code1, + self.c_operator(op), + code2) + if self.is_cpp_comparison() and self.exception_check == '+': + translate_cpp_exception( + code, + self.pos, + statement, + result_code if self.type.is_pyobject else None, + self.exception_value, + self.in_nogil_context) + else: + code.putln(statement) + + def c_operator(self, op): + if op == 'is': + return "==" + elif op == 'is_not': + return "!=" + else: + return op + +class PrimaryCmpNode(ExprNode, CmpNode): + # Non-cascaded comparison or first comparison of + # a cascaded sequence. + # + # operator string + # operand1 ExprNode + # operand2 ExprNode + # cascade CascadedCmpNode + + # We don't use the subexprs mechanism, because + # things here are too complicated for it to handle. + # Instead, we override all the framework methods + # which use it. + + child_attrs = ['operand1', 'operand2', 'coerced_operand2', 'cascade'] + + cascade = None + coerced_operand2 = None + is_memslice_nonecheck = False + + def infer_type(self, env): + type1 = self.operand1.infer_type(env) + type2 = self.operand2.infer_type(env) + + if is_pythran_expr(type1) or is_pythran_expr(type2): + if is_pythran_supported_type(type1) and is_pythran_supported_type(type2): + return PythranExpr(pythran_binop_type(self.operator, type1, type2)) + + # TODO: implement this for other types. + return py_object_type + + def type_dependencies(self, env): + return () + + def calculate_constant_result(self): + assert not self.cascade + self.calculate_cascaded_constant_result(self.operand1.constant_result) + + def compile_time_value(self, denv): + operand1 = self.operand1.compile_time_value(denv) + return self.cascaded_compile_time_value(operand1, denv) + + def analyse_types(self, env): + self.operand1 = self.operand1.analyse_types(env) + self.operand2 = self.operand2.analyse_types(env) + if self.is_cpp_comparison(): + self.analyse_cpp_comparison(env) + if self.cascade: + error(self.pos, "Cascading comparison not yet supported for cpp types.") + return self + + type1 = self.operand1.type + type2 = self.operand2.type + if is_pythran_expr(type1) or is_pythran_expr(type2): + if is_pythran_supported_type(type1) and is_pythran_supported_type(type2): + self.type = PythranExpr(pythran_binop_type(self.operator, type1, type2)) + self.is_pycmp = False + return self + + if self.analyse_memoryviewslice_comparison(env): + return self + + if self.cascade: + self.cascade = self.cascade.analyse_types(env) + + if self.operator in ('in', 'not_in'): + if self.is_c_string_contains(): + self.is_pycmp = False + common_type = None + if self.cascade: + error(self.pos, "Cascading comparison not yet supported for 'int_val in string'.") + return self + if self.operand2.type is unicode_type: + env.use_utility_code(UtilityCode.load_cached("PyUCS4InUnicode", "StringTools.c")) + else: + if self.operand1.type is PyrexTypes.c_uchar_type: + self.operand1 = self.operand1.coerce_to(PyrexTypes.c_char_type, env) + if self.operand2.type is not bytes_type: + self.operand2 = self.operand2.coerce_to(bytes_type, env) + env.use_utility_code(UtilityCode.load_cached("BytesContains", "StringTools.c")) + self.operand2 = self.operand2.as_none_safe_node( + "argument of type 'NoneType' is not iterable") + elif self.is_ptr_contains(): + if self.cascade: + error(self.pos, "Cascading comparison not supported for 'val in sliced pointer'.") + self.type = PyrexTypes.c_bint_type + # Will be transformed by IterationTransform + return self + elif self.find_special_bool_compare_function(env, self.operand1): + if not self.operand1.type.is_pyobject: + self.operand1 = self.operand1.coerce_to_pyobject(env) + common_type = None # if coercion needed, the method call above has already done it + self.is_pycmp = False # result is bint + else: + common_type = py_object_type + self.is_pycmp = True + elif self.find_special_bool_compare_function(env, self.operand1): + if not self.operand1.type.is_pyobject: + self.operand1 = self.operand1.coerce_to_pyobject(env) + common_type = None # if coercion needed, the method call above has already done it + self.is_pycmp = False # result is bint + else: + common_type = self.find_common_type(env, self.operator, self.operand1) + self.is_pycmp = common_type.is_pyobject + + if common_type is not None and not common_type.is_error: + if self.operand1.type != common_type: + self.operand1 = self.operand1.coerce_to(common_type, env) + self.coerce_operands_to(common_type, env) + + if self.cascade: + self.operand2 = self.operand2.coerce_to_simple(env) + self.cascade.coerce_cascaded_operands_to_temp(env) + operand2 = self.cascade.optimise_comparison(self.operand2, env) + if operand2 is not self.operand2: + self.coerced_operand2 = operand2 + if self.is_python_result(): + self.type = PyrexTypes.py_object_type + else: + self.type = PyrexTypes.c_bint_type + cdr = self.cascade + while cdr: + cdr.type = self.type + cdr = cdr.cascade + if self.is_pycmp or self.cascade or self.special_bool_cmp_function: + # 1) owned reference, 2) reused value, 3) potential function error return value + self.is_temp = 1 + return self + + def analyse_cpp_comparison(self, env): + type1 = self.operand1.type + type2 = self.operand2.type + self.is_pycmp = False + entry = env.lookup_operator(self.operator, [self.operand1, self.operand2]) + if entry is None: + error(self.pos, "Invalid types for '%s' (%s, %s)" % + (self.operator, type1, type2)) + self.type = PyrexTypes.error_type + self.result_code = "<error>" + return + func_type = entry.type + if func_type.is_ptr: + func_type = func_type.base_type + self.exception_check = func_type.exception_check + self.exception_value = func_type.exception_value + if self.exception_check == '+': + self.is_temp = True + if self.exception_value is None: + env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp")) + if len(func_type.args) == 1: + self.operand2 = self.operand2.coerce_to(func_type.args[0].type, env) + else: + self.operand1 = self.operand1.coerce_to(func_type.args[0].type, env) + self.operand2 = self.operand2.coerce_to(func_type.args[1].type, env) + self.type = func_type.return_type + + def analyse_memoryviewslice_comparison(self, env): + have_none = self.operand1.is_none or self.operand2.is_none + have_slice = (self.operand1.type.is_memoryviewslice or + self.operand2.type.is_memoryviewslice) + ops = ('==', '!=', 'is', 'is_not') + if have_slice and have_none and self.operator in ops: + self.is_pycmp = False + self.type = PyrexTypes.c_bint_type + self.is_memslice_nonecheck = True + return True + + return False + + def coerce_to_boolean(self, env): + if self.is_pycmp: + # coercing to bool => may allow for more efficient comparison code + if self.find_special_bool_compare_function( + env, self.operand1, result_is_bool=True): + self.is_pycmp = False + self.type = PyrexTypes.c_bint_type + self.is_temp = 1 + if self.cascade: + operand2 = self.cascade.optimise_comparison( + self.operand2, env, result_is_bool=True) + if operand2 is not self.operand2: + self.coerced_operand2 = operand2 + return self + # TODO: check if we can optimise parts of the cascade here + return ExprNode.coerce_to_boolean(self, env) + + def has_python_operands(self): + return (self.operand1.type.is_pyobject + or self.operand2.type.is_pyobject) + + def check_const(self): + if self.cascade: + self.not_const() + return False + else: + return self.operand1.check_const() and self.operand2.check_const() + + def calculate_result_code(self): + operand1, operand2 = self.operand1, self.operand2 + if operand1.type.is_complex: + if self.operator == "!=": + negation = "!" + else: + negation = "" + return "(%s%s(%s, %s))" % ( + negation, + operand1.type.binary_op('=='), + operand1.result(), + operand2.result()) + elif self.is_c_string_contains(): + if operand2.type is unicode_type: + method = "__Pyx_UnicodeContainsUCS4" + else: + method = "__Pyx_BytesContains" + if self.operator == "not_in": + negation = "!" + else: + negation = "" + return "(%s%s(%s, %s))" % ( + negation, + method, + operand2.result(), + operand1.result()) + else: + if is_pythran_expr(self.type): + result1, result2 = operand1.pythran_result(), operand2.pythran_result() + else: + result1, result2 = operand1.result(), operand2.result() + if self.is_memslice_nonecheck: + if operand1.type.is_memoryviewslice: + result1 = "((PyObject *) %s.memview)" % result1 + else: + result2 = "((PyObject *) %s.memview)" % result2 + + return "(%s %s %s)" % ( + result1, + self.c_operator(self.operator), + result2) + + def generate_evaluation_code(self, code): + self.operand1.generate_evaluation_code(code) + self.operand2.generate_evaluation_code(code) + if self.is_temp: + self.allocate_temp_result(code) + self.generate_operation_code(code, self.result(), + self.operand1, self.operator, self.operand2) + if self.cascade: + self.cascade.generate_evaluation_code( + code, self.result(), self.coerced_operand2 or self.operand2, + needs_evaluation=self.coerced_operand2 is not None) + self.operand1.generate_disposal_code(code) + self.operand1.free_temps(code) + self.operand2.generate_disposal_code(code) + self.operand2.free_temps(code) + + def generate_subexpr_disposal_code(self, code): + # If this is called, it is a non-cascaded cmp, + # so only need to dispose of the two main operands. + self.operand1.generate_disposal_code(code) + self.operand2.generate_disposal_code(code) + + def free_subexpr_temps(self, code): + # If this is called, it is a non-cascaded cmp, + # so only need to dispose of the two main operands. + self.operand1.free_temps(code) + self.operand2.free_temps(code) + + def annotate(self, code): + self.operand1.annotate(code) + self.operand2.annotate(code) + if self.cascade: + self.cascade.annotate(code) + + +class CascadedCmpNode(Node, CmpNode): + # A CascadedCmpNode is not a complete expression node. It + # hangs off the side of another comparison node, shares + # its left operand with that node, and shares its result + # with the PrimaryCmpNode at the head of the chain. + # + # operator string + # operand2 ExprNode + # cascade CascadedCmpNode + + child_attrs = ['operand2', 'coerced_operand2', 'cascade'] + + cascade = None + coerced_operand2 = None + constant_result = constant_value_not_set # FIXME: where to calculate this? + + def infer_type(self, env): + # TODO: Actually implement this (after merging with -unstable). + return py_object_type + + def type_dependencies(self, env): + return () + + def has_constant_result(self): + return self.constant_result is not constant_value_not_set and \ + self.constant_result is not not_a_constant + + def analyse_types(self, env): + self.operand2 = self.operand2.analyse_types(env) + if self.cascade: + self.cascade = self.cascade.analyse_types(env) + return self + + def has_python_operands(self): + return self.operand2.type.is_pyobject + + def is_cpp_comparison(self): + # cascaded comparisons aren't currently implemented for c++ classes. + return False + + def optimise_comparison(self, operand1, env, result_is_bool=False): + if self.find_special_bool_compare_function(env, operand1, result_is_bool): + self.is_pycmp = False + self.type = PyrexTypes.c_bint_type + if not operand1.type.is_pyobject: + operand1 = operand1.coerce_to_pyobject(env) + if self.cascade: + operand2 = self.cascade.optimise_comparison(self.operand2, env, result_is_bool) + if operand2 is not self.operand2: + self.coerced_operand2 = operand2 + return operand1 + + def coerce_operands_to_pyobjects(self, env): + self.operand2 = self.operand2.coerce_to_pyobject(env) + if self.operand2.type is dict_type and self.operator in ('in', 'not_in'): + self.operand2 = self.operand2.as_none_safe_node("'NoneType' object is not iterable") + if self.cascade: + self.cascade.coerce_operands_to_pyobjects(env) + + def coerce_cascaded_operands_to_temp(self, env): + if self.cascade: + #self.operand2 = self.operand2.coerce_to_temp(env) #CTT + self.operand2 = self.operand2.coerce_to_simple(env) + self.cascade.coerce_cascaded_operands_to_temp(env) + + def generate_evaluation_code(self, code, result, operand1, needs_evaluation=False): + if self.type.is_pyobject: + code.putln("if (__Pyx_PyObject_IsTrue(%s)) {" % result) + code.put_decref(result, self.type) + else: + code.putln("if (%s) {" % result) + if needs_evaluation: + operand1.generate_evaluation_code(code) + self.operand2.generate_evaluation_code(code) + self.generate_operation_code(code, result, + operand1, self.operator, self.operand2) + if self.cascade: + self.cascade.generate_evaluation_code( + code, result, self.coerced_operand2 or self.operand2, + needs_evaluation=self.coerced_operand2 is not None) + if needs_evaluation: + operand1.generate_disposal_code(code) + operand1.free_temps(code) + # Cascaded cmp result is always temp + self.operand2.generate_disposal_code(code) + self.operand2.free_temps(code) + code.putln("}") + + def annotate(self, code): + self.operand2.annotate(code) + if self.cascade: + self.cascade.annotate(code) + + +binop_node_classes = { + "or": BoolBinopNode, + "and": BoolBinopNode, + "|": IntBinopNode, + "^": IntBinopNode, + "&": IntBinopNode, + "<<": IntBinopNode, + ">>": IntBinopNode, + "+": AddNode, + "-": SubNode, + "*": MulNode, + "@": MatMultNode, + "/": DivNode, + "//": DivNode, + "%": ModNode, + "**": PowNode, +} + + +def binop_node(pos, operator, operand1, operand2, inplace=False, **kwargs): + # Construct binop node of appropriate class for + # given operator. + return binop_node_classes[operator]( + pos, + operator=operator, + operand1=operand1, + operand2=operand2, + inplace=inplace, + **kwargs) + + +#------------------------------------------------------------------- +# +# Coercion nodes +# +# Coercion nodes are special in that they are created during +# the analyse_types phase of parse tree processing. +# Their __init__ methods consequently incorporate some aspects +# of that phase. +# +#------------------------------------------------------------------- + +class CoercionNode(ExprNode): + # Abstract base class for coercion nodes. + # + # arg ExprNode node being coerced + + subexprs = ['arg'] + constant_result = not_a_constant + + def __init__(self, arg): + super(CoercionNode, self).__init__(arg.pos) + self.arg = arg + if debug_coercion: + print("%s Coercing %s" % (self, self.arg)) + + def calculate_constant_result(self): + # constant folding can break type coercion, so this is disabled + pass + + def annotate(self, code): + self.arg.annotate(code) + if self.arg.type != self.type: + file, line, col = self.pos + code.annotate((file, line, col-1), AnnotationItem( + style='coerce', tag='coerce', text='[%s] to [%s]' % (self.arg.type, self.type))) + + +class CoerceToMemViewSliceNode(CoercionNode): + """ + Coerce an object to a memoryview slice. This holds a new reference in + a managed temp. + """ + + def __init__(self, arg, dst_type, env): + assert dst_type.is_memoryviewslice + assert not arg.type.is_memoryviewslice + CoercionNode.__init__(self, arg) + self.type = dst_type + self.is_temp = 1 + self.use_managed_ref = True + self.arg = arg + self.type.create_from_py_utility_code(env) + + def generate_result_code(self, code): + code.putln(self.type.from_py_call_code( + self.arg.py_result(), + self.result(), + self.pos, + code + )) + + +class CastNode(CoercionNode): + # Wrap a node in a C type cast. + + def __init__(self, arg, new_type): + CoercionNode.__init__(self, arg) + self.type = new_type + + def may_be_none(self): + return self.arg.may_be_none() + + def calculate_result_code(self): + return self.arg.result_as(self.type) + + def generate_result_code(self, code): + self.arg.generate_result_code(code) + + +class PyTypeTestNode(CoercionNode): + # This node is used to check that a generic Python + # object is an instance of a particular extension type. + # This node borrows the result of its argument node. + + exact_builtin_type = True + + def __init__(self, arg, dst_type, env, notnone=False): + # The arg is know to be a Python object, and + # the dst_type is known to be an extension type. + assert dst_type.is_extension_type or dst_type.is_builtin_type, "PyTypeTest on non extension type" + CoercionNode.__init__(self, arg) + self.type = dst_type + self.result_ctype = arg.ctype() + self.notnone = notnone + + nogil_check = Node.gil_error + gil_message = "Python type test" + + def analyse_types(self, env): + return self + + def may_be_none(self): + if self.notnone: + return False + return self.arg.may_be_none() + + def is_simple(self): + return self.arg.is_simple() + + def result_in_temp(self): + return self.arg.result_in_temp() + + def is_ephemeral(self): + return self.arg.is_ephemeral() + + def nonlocally_immutable(self): + return self.arg.nonlocally_immutable() + + def reanalyse(self): + if self.type != self.arg.type or not self.arg.is_temp: + return self + if not self.type.typeobj_is_available(): + return self + if self.arg.may_be_none() and self.notnone: + return self.arg.as_none_safe_node("Cannot convert NoneType to %.200s" % self.type.name) + return self.arg + + def calculate_constant_result(self): + # FIXME + pass + + def calculate_result_code(self): + return self.arg.result() + + def generate_result_code(self, code): + if self.type.typeobj_is_available(): + if self.type.is_builtin_type: + type_test = self.type.type_test_code( + self.arg.py_result(), + self.notnone, exact=self.exact_builtin_type) + else: + type_test = self.type.type_test_code( + self.arg.py_result(), self.notnone) + code.globalstate.use_utility_code( + UtilityCode.load_cached("ExtTypeTest", "ObjectHandling.c")) + code.putln("if (!(%s)) %s" % ( + type_test, code.error_goto(self.pos))) + else: + error(self.pos, "Cannot test type of extern C class " + "without type object name specification") + + def generate_post_assignment_code(self, code): + self.arg.generate_post_assignment_code(code) + + def allocate_temp_result(self, code): + pass + + def release_temp_result(self, code): + pass + + def free_temps(self, code): + self.arg.free_temps(code) + + def free_subexpr_temps(self, code): + self.arg.free_subexpr_temps(code) + + +class NoneCheckNode(CoercionNode): + # This node is used to check that a Python object is not None and + # raises an appropriate exception (as specified by the creating + # transform). + + is_nonecheck = True + + def __init__(self, arg, exception_type_cname, exception_message, + exception_format_args=()): + CoercionNode.__init__(self, arg) + self.type = arg.type + self.result_ctype = arg.ctype() + self.exception_type_cname = exception_type_cname + self.exception_message = exception_message + self.exception_format_args = tuple(exception_format_args or ()) + + nogil_check = None # this node only guards an operation that would fail already + + def analyse_types(self, env): + return self + + def may_be_none(self): + return False + + def is_simple(self): + return self.arg.is_simple() + + def result_in_temp(self): + return self.arg.result_in_temp() + + def nonlocally_immutable(self): + return self.arg.nonlocally_immutable() + + def calculate_result_code(self): + return self.arg.result() + + def condition(self): + if self.type.is_pyobject: + return self.arg.py_result() + elif self.type.is_memoryviewslice: + return "((PyObject *) %s.memview)" % self.arg.result() + else: + raise Exception("unsupported type") + + @classmethod + def generate(cls, arg, code, exception_message, + exception_type_cname="PyExc_TypeError", exception_format_args=(), in_nogil_context=False): + node = cls(arg, exception_type_cname, exception_message, exception_format_args) + node.in_nogil_context = in_nogil_context + node.put_nonecheck(code) + + @classmethod + def generate_if_needed(cls, arg, code, exception_message, + exception_type_cname="PyExc_TypeError", exception_format_args=(), in_nogil_context=False): + if arg.may_be_none(): + cls.generate(arg, code, exception_message, exception_type_cname, exception_format_args, in_nogil_context) + + def put_nonecheck(self, code): + code.putln( + "if (unlikely(%s == Py_None)) {" % self.condition()) + + if self.in_nogil_context: + code.put_ensure_gil() + + escape = StringEncoding.escape_byte_string + if self.exception_format_args: + code.putln('PyErr_Format(%s, "%s", %s);' % ( + self.exception_type_cname, + StringEncoding.escape_byte_string( + self.exception_message.encode('UTF-8')), + ', '.join([ '"%s"' % escape(str(arg).encode('UTF-8')) + for arg in self.exception_format_args ]))) + else: + code.putln('PyErr_SetString(%s, "%s");' % ( + self.exception_type_cname, + escape(self.exception_message.encode('UTF-8')))) + + if self.in_nogil_context: + code.put_release_ensured_gil() + + code.putln(code.error_goto(self.pos)) + code.putln("}") + + def generate_result_code(self, code): + self.put_nonecheck(code) + + def generate_post_assignment_code(self, code): + self.arg.generate_post_assignment_code(code) + + def free_temps(self, code): + self.arg.free_temps(code) + + +class CoerceToPyTypeNode(CoercionNode): + # This node is used to convert a C data type + # to a Python object. + + type = py_object_type + target_type = py_object_type + is_temp = 1 + + def __init__(self, arg, env, type=py_object_type): + if not arg.type.create_to_py_utility_code(env): + error(arg.pos, "Cannot convert '%s' to Python object" % arg.type) + elif arg.type.is_complex: + # special case: complex coercion is so complex that it + # uses a macro ("__pyx_PyComplex_FromComplex()"), for + # which the argument must be simple + arg = arg.coerce_to_simple(env) + CoercionNode.__init__(self, arg) + if type is py_object_type: + # be specific about some known types + if arg.type.is_string or arg.type.is_cpp_string: + self.type = default_str_type(env) + elif arg.type.is_pyunicode_ptr or arg.type.is_unicode_char: + self.type = unicode_type + elif arg.type.is_complex: + self.type = Builtin.complex_type + self.target_type = self.type + elif arg.type.is_string or arg.type.is_cpp_string: + if (type not in (bytes_type, bytearray_type) + and not env.directives['c_string_encoding']): + error(arg.pos, + "default encoding required for conversion from '%s' to '%s'" % + (arg.type, type)) + self.type = self.target_type = type + else: + # FIXME: check that the target type and the resulting type are compatible + self.target_type = type + + gil_message = "Converting to Python object" + + def may_be_none(self): + # FIXME: is this always safe? + return False + + def coerce_to_boolean(self, env): + arg_type = self.arg.type + if (arg_type == PyrexTypes.c_bint_type or + (arg_type.is_pyobject and arg_type.name == 'bool')): + return self.arg.coerce_to_temp(env) + else: + return CoerceToBooleanNode(self, env) + + def coerce_to_integer(self, env): + # If not already some C integer type, coerce to longint. + if self.arg.type.is_int: + return self.arg + else: + return self.arg.coerce_to(PyrexTypes.c_long_type, env) + + def analyse_types(self, env): + # The arg is always already analysed + return self + + def generate_result_code(self, code): + code.putln('%s; %s' % ( + self.arg.type.to_py_call_code( + self.arg.result(), + self.result(), + self.target_type), + code.error_goto_if_null(self.result(), self.pos))) + + code.put_gotref(self.py_result()) + + +class CoerceIntToBytesNode(CoerceToPyTypeNode): + # This node is used to convert a C int type to a Python bytes + # object. + + is_temp = 1 + + def __init__(self, arg, env): + arg = arg.coerce_to_simple(env) + CoercionNode.__init__(self, arg) + self.type = Builtin.bytes_type + + def generate_result_code(self, code): + arg = self.arg + arg_result = arg.result() + if arg.type not in (PyrexTypes.c_char_type, + PyrexTypes.c_uchar_type, + PyrexTypes.c_schar_type): + if arg.type.signed: + code.putln("if ((%s < 0) || (%s > 255)) {" % ( + arg_result, arg_result)) + else: + code.putln("if (%s > 255) {" % arg_result) + code.putln('PyErr_SetString(PyExc_OverflowError, ' + '"value too large to pack into a byte"); %s' % ( + code.error_goto(self.pos))) + code.putln('}') + temp = None + if arg.type is not PyrexTypes.c_char_type: + temp = code.funcstate.allocate_temp(PyrexTypes.c_char_type, manage_ref=False) + code.putln("%s = (char)%s;" % (temp, arg_result)) + arg_result = temp + code.putln('%s = PyBytes_FromStringAndSize(&%s, 1); %s' % ( + self.result(), + arg_result, + code.error_goto_if_null(self.result(), self.pos))) + if temp is not None: + code.funcstate.release_temp(temp) + code.put_gotref(self.py_result()) + + +class CoerceFromPyTypeNode(CoercionNode): + # This node is used to convert a Python object + # to a C data type. + + def __init__(self, result_type, arg, env): + CoercionNode.__init__(self, arg) + self.type = result_type + self.is_temp = 1 + if not result_type.create_from_py_utility_code(env): + error(arg.pos, + "Cannot convert Python object to '%s'" % result_type) + if self.type.is_string or self.type.is_pyunicode_ptr: + if self.arg.is_name and self.arg.entry and self.arg.entry.is_pyglobal: + warning(arg.pos, + "Obtaining '%s' from externally modifiable global Python value" % result_type, + level=1) + + def analyse_types(self, env): + # The arg is always already analysed + return self + + def is_ephemeral(self): + return (self.type.is_ptr and not self.type.is_array) and self.arg.is_ephemeral() + + def generate_result_code(self, code): + from_py_function = None + # for certain source types, we can do better than the generic coercion + if self.type.is_string and self.arg.type is bytes_type: + if self.type.from_py_function.startswith('__Pyx_PyObject_As'): + from_py_function = '__Pyx_PyBytes' + self.type.from_py_function[len('__Pyx_PyObject'):] + NoneCheckNode.generate_if_needed(self.arg, code, "expected bytes, NoneType found") + + code.putln(self.type.from_py_call_code( + self.arg.py_result(), self.result(), self.pos, code, from_py_function=from_py_function)) + if self.type.is_pyobject: + code.put_gotref(self.py_result()) + + def nogil_check(self, env): + error(self.pos, "Coercion from Python not allowed without the GIL") + + +class CoerceToBooleanNode(CoercionNode): + # This node is used when a result needs to be used + # in a boolean context. + + type = PyrexTypes.c_bint_type + + _special_builtins = { + Builtin.list_type: 'PyList_GET_SIZE', + Builtin.tuple_type: 'PyTuple_GET_SIZE', + Builtin.set_type: 'PySet_GET_SIZE', + Builtin.frozenset_type: 'PySet_GET_SIZE', + Builtin.bytes_type: 'PyBytes_GET_SIZE', + Builtin.bytearray_type: 'PyByteArray_GET_SIZE', + Builtin.unicode_type: '__Pyx_PyUnicode_IS_TRUE', + } + + def __init__(self, arg, env): + CoercionNode.__init__(self, arg) + if arg.type.is_pyobject: + self.is_temp = 1 + + def nogil_check(self, env): + if self.arg.type.is_pyobject and self._special_builtins.get(self.arg.type) is None: + self.gil_error() + + gil_message = "Truth-testing Python object" + + def check_const(self): + if self.is_temp: + self.not_const() + return False + return self.arg.check_const() + + def calculate_result_code(self): + return "(%s != 0)" % self.arg.result() + + def generate_result_code(self, code): + if not self.is_temp: + return + test_func = self._special_builtins.get(self.arg.type) + if test_func is not None: + checks = ["(%s != Py_None)" % self.arg.py_result()] if self.arg.may_be_none() else [] + checks.append("(%s(%s) != 0)" % (test_func, self.arg.py_result())) + code.putln("%s = %s;" % (self.result(), '&&'.join(checks))) + else: + code.putln( + "%s = __Pyx_PyObject_IsTrue(%s); %s" % ( + self.result(), + self.arg.py_result(), + code.error_goto_if_neg(self.result(), self.pos))) + + +class CoerceToComplexNode(CoercionNode): + + def __init__(self, arg, dst_type, env): + if arg.type.is_complex: + arg = arg.coerce_to_simple(env) + self.type = dst_type + CoercionNode.__init__(self, arg) + dst_type.create_declaration_utility_code(env) + + def calculate_result_code(self): + if self.arg.type.is_complex: + real_part = "__Pyx_CREAL(%s)" % self.arg.result() + imag_part = "__Pyx_CIMAG(%s)" % self.arg.result() + else: + real_part = self.arg.result() + imag_part = "0" + return "%s(%s, %s)" % ( + self.type.from_parts, + real_part, + imag_part) + + def generate_result_code(self, code): + pass + +class CoerceToTempNode(CoercionNode): + # This node is used to force the result of another node + # to be stored in a temporary. It is only used if the + # argument node's result is not already in a temporary. + + def __init__(self, arg, env): + CoercionNode.__init__(self, arg) + self.type = self.arg.type.as_argument_type() + self.constant_result = self.arg.constant_result + self.is_temp = 1 + if self.type.is_pyobject: + self.result_ctype = py_object_type + + gil_message = "Creating temporary Python reference" + + def analyse_types(self, env): + # The arg is always already analysed + return self + + def coerce_to_boolean(self, env): + self.arg = self.arg.coerce_to_boolean(env) + if self.arg.is_simple(): + return self.arg + self.type = self.arg.type + self.result_ctype = self.type + return self + + def generate_result_code(self, code): + #self.arg.generate_evaluation_code(code) # Already done + # by generic generate_subexpr_evaluation_code! + code.putln("%s = %s;" % ( + self.result(), self.arg.result_as(self.ctype()))) + if self.use_managed_ref: + if self.type.is_pyobject: + code.put_incref(self.result(), self.ctype()) + elif self.type.is_memoryviewslice: + code.put_incref_memoryviewslice(self.result(), + not self.in_nogil_context) + +class ProxyNode(CoercionNode): + """ + A node that should not be replaced by transforms or other means, + and hence can be useful to wrap the argument to a clone node + + MyNode -> ProxyNode -> ArgNode + CloneNode -^ + """ + + nogil_check = None + + def __init__(self, arg): + super(ProxyNode, self).__init__(arg) + self.constant_result = arg.constant_result + self._proxy_type() + + def analyse_types(self, env): + self.arg = self.arg.analyse_expressions(env) + self._proxy_type() + return self + + def infer_type(self, env): + return self.arg.infer_type(env) + + def _proxy_type(self): + if hasattr(self.arg, 'type'): + self.type = self.arg.type + self.result_ctype = self.arg.result_ctype + if hasattr(self.arg, 'entry'): + self.entry = self.arg.entry + + def generate_result_code(self, code): + self.arg.generate_result_code(code) + + def result(self): + return self.arg.result() + + def is_simple(self): + return self.arg.is_simple() + + def may_be_none(self): + return self.arg.may_be_none() + + def generate_evaluation_code(self, code): + self.arg.generate_evaluation_code(code) + + def generate_disposal_code(self, code): + self.arg.generate_disposal_code(code) + + def free_temps(self, code): + self.arg.free_temps(code) + +class CloneNode(CoercionNode): + # This node is employed when the result of another node needs + # to be used multiple times. The argument node's result must + # be in a temporary. This node "borrows" the result from the + # argument node, and does not generate any evaluation or + # disposal code for it. The original owner of the argument + # node is responsible for doing those things. + + subexprs = [] # Arg is not considered a subexpr + nogil_check = None + + def __init__(self, arg): + CoercionNode.__init__(self, arg) + self.constant_result = arg.constant_result + if hasattr(arg, 'type'): + self.type = arg.type + self.result_ctype = arg.result_ctype + if hasattr(arg, 'entry'): + self.entry = arg.entry + + def result(self): + return self.arg.result() + + def may_be_none(self): + return self.arg.may_be_none() + + def type_dependencies(self, env): + return self.arg.type_dependencies(env) + + def infer_type(self, env): + return self.arg.infer_type(env) + + def analyse_types(self, env): + self.type = self.arg.type + self.result_ctype = self.arg.result_ctype + self.is_temp = 1 + if hasattr(self.arg, 'entry'): + self.entry = self.arg.entry + return self + + def coerce_to(self, dest_type, env): + if self.arg.is_literal: + return self.arg.coerce_to(dest_type, env) + return super(CloneNode, self).coerce_to(dest_type, env) + + def is_simple(self): + return True # result is always in a temp (or a name) + + def generate_evaluation_code(self, code): + pass + + def generate_result_code(self, code): + pass + + def generate_disposal_code(self, code): + pass + + def free_temps(self, code): + pass + + +class CMethodSelfCloneNode(CloneNode): + # Special CloneNode for the self argument of builtin C methods + # that accepts subtypes of the builtin type. This is safe only + # for 'final' subtypes, as subtypes of the declared type may + # override the C method. + + def coerce_to(self, dst_type, env): + if dst_type.is_builtin_type and self.type.subtype_of(dst_type): + return self + return CloneNode.coerce_to(self, dst_type, env) + + +class ModuleRefNode(ExprNode): + # Simple returns the module object + + type = py_object_type + is_temp = False + subexprs = [] + + def analyse_types(self, env): + return self + + def may_be_none(self): + return False + + def calculate_result_code(self): + return Naming.module_cname + + def generate_result_code(self, code): + pass + +class DocstringRefNode(ExprNode): + # Extracts the docstring of the body element + + subexprs = ['body'] + type = py_object_type + is_temp = True + + def __init__(self, pos, body): + ExprNode.__init__(self, pos) + assert body.type.is_pyobject + self.body = body + + def analyse_types(self, env): + return self + + def generate_result_code(self, code): + code.putln('%s = __Pyx_GetAttr(%s, %s); %s' % ( + self.result(), self.body.result(), + code.intern_identifier(StringEncoding.EncodedString("__doc__")), + code.error_goto_if_null(self.result(), self.pos))) + code.put_gotref(self.result()) + + + +#------------------------------------------------------------------------------------ +# +# Runtime support code +# +#------------------------------------------------------------------------------------ + +pyerr_occurred_withgil_utility_code= UtilityCode( +proto = """ +static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */ +""", +impl = """ +static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) { + int err; + #ifdef WITH_THREAD + PyGILState_STATE _save = PyGILState_Ensure(); + #endif + err = !!PyErr_Occurred(); + #ifdef WITH_THREAD + PyGILState_Release(_save); + #endif + return err; +} +""" +) + +#------------------------------------------------------------------------------------ + +raise_unbound_local_error_utility_code = UtilityCode( +proto = """ +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); +""", +impl = """ +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); +} +""") + +raise_closure_name_error_utility_code = UtilityCode( +proto = """ +static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname); +""", +impl = """ +static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) { + PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname); +} +""") + +# Don't inline the function, it should really never be called in production +raise_unbound_memoryview_utility_code_nogil = UtilityCode( +proto = """ +static void __Pyx_RaiseUnboundMemoryviewSliceNogil(const char *varname); +""", +impl = """ +static void __Pyx_RaiseUnboundMemoryviewSliceNogil(const char *varname) { + #ifdef WITH_THREAD + PyGILState_STATE gilstate = PyGILState_Ensure(); + #endif + __Pyx_RaiseUnboundLocalError(varname); + #ifdef WITH_THREAD + PyGILState_Release(gilstate); + #endif +} +""", +requires = [raise_unbound_local_error_utility_code]) + +#------------------------------------------------------------------------------------ + +raise_too_many_values_to_unpack = UtilityCode.load_cached("RaiseTooManyValuesToUnpack", "ObjectHandling.c") +raise_need_more_values_to_unpack = UtilityCode.load_cached("RaiseNeedMoreValuesToUnpack", "ObjectHandling.c") +tuple_unpacking_error_code = UtilityCode.load_cached("UnpackTupleError", "ObjectHandling.c") diff --git a/contrib/tools/cython/Cython/Compiler/FlowControl.pxd b/contrib/tools/cython/Cython/Compiler/FlowControl.pxd new file mode 100644 index 00000000000..c87370b819a --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/FlowControl.pxd @@ -0,0 +1,111 @@ +from __future__ import absolute_import + +cimport cython + +from .Visitor cimport CythonTransform, TreeVisitor + +cdef class ControlBlock: + cdef public set children + cdef public set parents + cdef public set positions + cdef public list stats + cdef public dict gen + cdef public set bounded + + # Big integer bitsets + cdef public object i_input + cdef public object i_output + cdef public object i_gen + cdef public object i_kill + cdef public object i_state + + cpdef bint empty(self) + cpdef detach(self) + cpdef add_child(self, block) + +cdef class ExitBlock(ControlBlock): + cpdef bint empty(self) + +cdef class NameAssignment: + cdef public bint is_arg + cdef public bint is_deletion + cdef public object lhs + cdef public object rhs + cdef public object entry + cdef public object pos + cdef public set refs + cdef public object bit + cdef public object inferred_type + +cdef class AssignmentList: + cdef public object bit + cdef public object mask + cdef public list stats + +cdef class AssignmentCollector(TreeVisitor): + cdef list assignments + +@cython.final +cdef class ControlFlow: + cdef public set blocks + cdef public set entries + cdef public list loops + cdef public list exceptions + + cdef public ControlBlock entry_point + cdef public ExitBlock exit_point + cdef public ControlBlock block + + cdef public dict assmts + + cpdef newblock(self, ControlBlock parent=*) + cpdef nextblock(self, ControlBlock parent=*) + cpdef bint is_tracked(self, entry) + cpdef bint is_statically_assigned(self, entry) + cpdef mark_position(self, node) + cpdef mark_assignment(self, lhs, rhs, entry) + cpdef mark_argument(self, lhs, rhs, entry) + cpdef mark_deletion(self, node, entry) + cpdef mark_reference(self, node, entry) + + @cython.locals(block=ControlBlock, parent=ControlBlock, unreachable=set) + cpdef normalize(self) + + @cython.locals(bit=object, assmts=AssignmentList, + block=ControlBlock) + cpdef initialize(self) + + @cython.locals(assmts=AssignmentList, assmt=NameAssignment) + cpdef set map_one(self, istate, entry) + + @cython.locals(block=ControlBlock, parent=ControlBlock) + cdef reaching_definitions(self) + +cdef class Uninitialized: + pass + +cdef class Unknown: + pass + + +cdef class MessageCollection: + cdef set messages + + +@cython.locals(dirty=bint, block=ControlBlock, parent=ControlBlock, + assmt=NameAssignment) +cdef check_definitions(ControlFlow flow, dict compiler_directives) + +@cython.final +cdef class ControlFlowAnalysis(CythonTransform): + cdef object gv_ctx + cdef object constant_folder + cdef set reductions + cdef list env_stack + cdef list stack + cdef object env + cdef ControlFlow flow + cdef bint in_inplace_assignment + + cpdef mark_assignment(self, lhs, rhs=*) + cpdef mark_position(self, node) diff --git a/contrib/tools/cython/Cython/Compiler/FlowControl.py b/contrib/tools/cython/Cython/Compiler/FlowControl.py new file mode 100644 index 00000000000..df04471f90e --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/FlowControl.py @@ -0,0 +1,1325 @@ +from __future__ import absolute_import + +import cython +cython.declare(PyrexTypes=object, ExprNodes=object, Nodes=object, + Builtin=object, InternalError=object, error=object, warning=object, + py_object_type=object, unspecified_type=object, + object_expr=object, fake_rhs_expr=object, TypedExprNode=object) + +from . import Builtin +from . import ExprNodes +from . import Nodes +from . import Options +from .PyrexTypes import py_object_type, unspecified_type +from . import PyrexTypes + +from .Visitor import TreeVisitor, CythonTransform +from .Errors import error, warning, InternalError +from .Optimize import ConstantFolding + + +class TypedExprNode(ExprNodes.ExprNode): + # Used for declaring assignments of a specified type without a known entry. + def __init__(self, type, may_be_none=None, pos=None): + super(TypedExprNode, self).__init__(pos) + self.type = type + self._may_be_none = may_be_none + + def may_be_none(self): + return self._may_be_none != False + +object_expr = TypedExprNode(py_object_type, may_be_none=True) +# Fake rhs to silence "unused variable" warning +fake_rhs_expr = TypedExprNode(unspecified_type) + + +class ControlBlock(object): + """Control flow graph node. Sequence of assignments and name references. + + children set of children nodes + parents set of parent nodes + positions set of position markers + + stats list of block statements + gen dict of assignments generated by this block + bounded set of entries that are definitely bounded in this block + + Example: + + a = 1 + b = a + c # 'c' is already bounded or exception here + + stats = [Assignment(a), NameReference(a), NameReference(c), + Assignment(b)] + gen = {Entry(a): Assignment(a), Entry(b): Assignment(b)} + bounded = set([Entry(a), Entry(c)]) + + """ + + def __init__(self): + self.children = set() + self.parents = set() + self.positions = set() + + self.stats = [] + self.gen = {} + self.bounded = set() + + self.i_input = 0 + self.i_output = 0 + self.i_gen = 0 + self.i_kill = 0 + self.i_state = 0 + + def empty(self): + return (not self.stats and not self.positions) + + def detach(self): + """Detach block from parents and children.""" + for child in self.children: + child.parents.remove(self) + for parent in self.parents: + parent.children.remove(self) + self.parents.clear() + self.children.clear() + + def add_child(self, block): + self.children.add(block) + block.parents.add(self) + + +class ExitBlock(ControlBlock): + """Non-empty exit point block.""" + + def empty(self): + return False + + +class AssignmentList(object): + def __init__(self): + self.stats = [] + + +class ControlFlow(object): + """Control-flow graph. + + entry_point ControlBlock entry point for this graph + exit_point ControlBlock normal exit point + block ControlBlock current block + blocks set children nodes + entries set tracked entries + loops list stack for loop descriptors + exceptions list stack for exception descriptors + """ + + def __init__(self): + self.blocks = set() + self.entries = set() + self.loops = [] + self.exceptions = [] + + self.entry_point = ControlBlock() + self.exit_point = ExitBlock() + self.blocks.add(self.exit_point) + self.block = self.entry_point + + def newblock(self, parent=None): + """Create floating block linked to `parent` if given. + + NOTE: Block is NOT added to self.blocks + """ + block = ControlBlock() + self.blocks.add(block) + if parent: + parent.add_child(block) + return block + + def nextblock(self, parent=None): + """Create block children block linked to current or `parent` if given. + + NOTE: Block is added to self.blocks + """ + block = ControlBlock() + self.blocks.add(block) + if parent: + parent.add_child(block) + elif self.block: + self.block.add_child(block) + self.block = block + return self.block + + def is_tracked(self, entry): + if entry.is_anonymous: + return False + return (entry.is_local or entry.is_pyclass_attr or entry.is_arg or + entry.from_closure or entry.in_closure or + entry.error_on_uninitialized) + + def is_statically_assigned(self, entry): + if (entry.is_local and entry.is_variable and + (entry.type.is_struct_or_union or + entry.type.is_complex or + entry.type.is_array or + entry.type.is_cpp_class)): + # stack allocated structured variable => never uninitialised + return True + return False + + def mark_position(self, node): + """Mark position, will be used to draw graph nodes.""" + if self.block: + self.block.positions.add(node.pos[:2]) + + def mark_assignment(self, lhs, rhs, entry): + if self.block and self.is_tracked(entry): + assignment = NameAssignment(lhs, rhs, entry) + self.block.stats.append(assignment) + self.block.gen[entry] = assignment + self.entries.add(entry) + + def mark_argument(self, lhs, rhs, entry): + if self.block and self.is_tracked(entry): + assignment = Argument(lhs, rhs, entry) + self.block.stats.append(assignment) + self.block.gen[entry] = assignment + self.entries.add(entry) + + def mark_deletion(self, node, entry): + if self.block and self.is_tracked(entry): + assignment = NameDeletion(node, entry) + self.block.stats.append(assignment) + self.block.gen[entry] = Uninitialized + self.entries.add(entry) + + def mark_reference(self, node, entry): + if self.block and self.is_tracked(entry): + self.block.stats.append(NameReference(node, entry)) + ## XXX: We don't track expression evaluation order so we can't use + ## XXX: successful reference as initialization sign. + ## # Local variable is definitely bound after this reference + ## if not node.allow_null: + ## self.block.bounded.add(entry) + self.entries.add(entry) + + def normalize(self): + """Delete unreachable and orphan blocks.""" + queue = set([self.entry_point]) + visited = set() + while queue: + root = queue.pop() + visited.add(root) + for child in root.children: + if child not in visited: + queue.add(child) + unreachable = self.blocks - visited + for block in unreachable: + block.detach() + visited.remove(self.entry_point) + for block in visited: + if block.empty(): + for parent in block.parents: # Re-parent + for child in block.children: + parent.add_child(child) + block.detach() + unreachable.add(block) + self.blocks -= unreachable + + def initialize(self): + """Set initial state, map assignments to bits.""" + self.assmts = {} + + bit = 1 + for entry in self.entries: + assmts = AssignmentList() + assmts.mask = assmts.bit = bit + self.assmts[entry] = assmts + bit <<= 1 + + for block in self.blocks: + for stat in block.stats: + if isinstance(stat, NameAssignment): + stat.bit = bit + assmts = self.assmts[stat.entry] + assmts.stats.append(stat) + assmts.mask |= bit + bit <<= 1 + + for block in self.blocks: + for entry, stat in block.gen.items(): + assmts = self.assmts[entry] + if stat is Uninitialized: + block.i_gen |= assmts.bit + else: + block.i_gen |= stat.bit + block.i_kill |= assmts.mask + block.i_output = block.i_gen + for entry in block.bounded: + block.i_kill |= self.assmts[entry].bit + + for assmts in self.assmts.values(): + self.entry_point.i_gen |= assmts.bit + self.entry_point.i_output = self.entry_point.i_gen + + def map_one(self, istate, entry): + ret = set() + assmts = self.assmts[entry] + if istate & assmts.bit: + if self.is_statically_assigned(entry): + ret.add(StaticAssignment(entry)) + elif entry.from_closure: + ret.add(Unknown) + else: + ret.add(Uninitialized) + for assmt in assmts.stats: + if istate & assmt.bit: + ret.add(assmt) + return ret + + def reaching_definitions(self): + """Per-block reaching definitions analysis.""" + dirty = True + while dirty: + dirty = False + for block in self.blocks: + i_input = 0 + for parent in block.parents: + i_input |= parent.i_output + i_output = (i_input & ~block.i_kill) | block.i_gen + if i_output != block.i_output: + dirty = True + block.i_input = i_input + block.i_output = i_output + + +class LoopDescr(object): + def __init__(self, next_block, loop_block): + self.next_block = next_block + self.loop_block = loop_block + self.exceptions = [] + + +class ExceptionDescr(object): + """Exception handling helper. + + entry_point ControlBlock Exception handling entry point + finally_enter ControlBlock Normal finally clause entry point + finally_exit ControlBlock Normal finally clause exit point + """ + + def __init__(self, entry_point, finally_enter=None, finally_exit=None): + self.entry_point = entry_point + self.finally_enter = finally_enter + self.finally_exit = finally_exit + + +class NameAssignment(object): + def __init__(self, lhs, rhs, entry): + if lhs.cf_state is None: + lhs.cf_state = set() + self.lhs = lhs + self.rhs = rhs + self.entry = entry + self.pos = lhs.pos + self.refs = set() + self.is_arg = False + self.is_deletion = False + self.inferred_type = None + + def __repr__(self): + return '%s(entry=%r)' % (self.__class__.__name__, self.entry) + + def infer_type(self): + self.inferred_type = self.rhs.infer_type(self.entry.scope) + return self.inferred_type + + def type_dependencies(self): + return self.rhs.type_dependencies(self.entry.scope) + + @property + def type(self): + if not self.entry.type.is_unspecified: + return self.entry.type + return self.inferred_type + + +class StaticAssignment(NameAssignment): + """Initialised at declaration time, e.g. stack allocation.""" + def __init__(self, entry): + if not entry.type.is_pyobject: + may_be_none = False + else: + may_be_none = None # unknown + lhs = TypedExprNode( + entry.type, may_be_none=may_be_none, pos=entry.pos) + super(StaticAssignment, self).__init__(lhs, lhs, entry) + + def infer_type(self): + return self.entry.type + + def type_dependencies(self): + return () + + +class Argument(NameAssignment): + def __init__(self, lhs, rhs, entry): + NameAssignment.__init__(self, lhs, rhs, entry) + self.is_arg = True + + +class NameDeletion(NameAssignment): + def __init__(self, lhs, entry): + NameAssignment.__init__(self, lhs, lhs, entry) + self.is_deletion = True + + def infer_type(self): + inferred_type = self.rhs.infer_type(self.entry.scope) + if (not inferred_type.is_pyobject and + inferred_type.can_coerce_to_pyobject(self.entry.scope)): + return py_object_type + self.inferred_type = inferred_type + return inferred_type + + +class Uninitialized(object): + """Definitely not initialised yet.""" + + +class Unknown(object): + """Coming from outer closure, might be initialised or not.""" + + +class NameReference(object): + def __init__(self, node, entry): + if node.cf_state is None: + node.cf_state = set() + self.node = node + self.entry = entry + self.pos = node.pos + + def __repr__(self): + return '%s(entry=%r)' % (self.__class__.__name__, self.entry) + + +class ControlFlowState(list): + # Keeps track of Node's entry assignments + # + # cf_is_null [boolean] It is uninitialized + # cf_maybe_null [boolean] May be uninitialized + # is_single [boolean] Has only one assignment at this point + + cf_maybe_null = False + cf_is_null = False + is_single = False + + def __init__(self, state): + if Uninitialized in state: + state.discard(Uninitialized) + self.cf_maybe_null = True + if not state: + self.cf_is_null = True + elif Unknown in state: + state.discard(Unknown) + self.cf_maybe_null = True + else: + if len(state) == 1: + self.is_single = True + # XXX: Remove fake_rhs_expr + super(ControlFlowState, self).__init__( + [i for i in state if i.rhs is not fake_rhs_expr]) + + def one(self): + return self[0] + + +class GVContext(object): + """Graphviz subgraph object.""" + + def __init__(self): + self.blockids = {} + self.nextid = 0 + self.children = [] + self.sources = {} + + def add(self, child): + self.children.append(child) + + def nodeid(self, block): + if block not in self.blockids: + self.blockids[block] = 'block%d' % self.nextid + self.nextid += 1 + return self.blockids[block] + + def extract_sources(self, block): + if not block.positions: + return '' + start = min(block.positions) + stop = max(block.positions) + srcdescr = start[0] + if not srcdescr in self.sources: + self.sources[srcdescr] = list(srcdescr.get_lines()) + lines = self.sources[srcdescr] + return '\\n'.join([l.strip() for l in lines[start[1] - 1:stop[1]]]) + + def render(self, fp, name, annotate_defs=False): + """Render graphviz dot graph""" + fp.write('digraph %s {\n' % name) + fp.write(' node [shape=box];\n') + for child in self.children: + child.render(fp, self, annotate_defs) + fp.write('}\n') + + def escape(self, text): + return text.replace('"', '\\"').replace('\n', '\\n') + + +class GV(object): + """Graphviz DOT renderer.""" + + def __init__(self, name, flow): + self.name = name + self.flow = flow + + def render(self, fp, ctx, annotate_defs=False): + fp.write(' subgraph %s {\n' % self.name) + for block in self.flow.blocks: + label = ctx.extract_sources(block) + if annotate_defs: + for stat in block.stats: + if isinstance(stat, NameAssignment): + label += '\n %s [%s %s]' % ( + stat.entry.name, 'deletion' if stat.is_deletion else 'definition', stat.pos[1]) + elif isinstance(stat, NameReference): + if stat.entry: + label += '\n %s [reference %s]' % (stat.entry.name, stat.pos[1]) + if not label: + label = 'empty' + pid = ctx.nodeid(block) + fp.write(' %s [label="%s"];\n' % (pid, ctx.escape(label))) + for block in self.flow.blocks: + pid = ctx.nodeid(block) + for child in block.children: + fp.write(' %s -> %s;\n' % (pid, ctx.nodeid(child))) + fp.write(' }\n') + + +class MessageCollection(object): + """Collect error/warnings messages first then sort""" + def __init__(self): + self.messages = set() + + def error(self, pos, message): + self.messages.add((pos, True, message)) + + def warning(self, pos, message): + self.messages.add((pos, False, message)) + + def report(self): + for pos, is_error, message in sorted(self.messages): + if is_error: + error(pos, message) + else: + warning(pos, message, 2) + + +def check_definitions(flow, compiler_directives): + flow.initialize() + flow.reaching_definitions() + + # Track down state + assignments = set() + # Node to entry map + references = {} + assmt_nodes = set() + + for block in flow.blocks: + i_state = block.i_input + for stat in block.stats: + i_assmts = flow.assmts[stat.entry] + state = flow.map_one(i_state, stat.entry) + if isinstance(stat, NameAssignment): + stat.lhs.cf_state.update(state) + assmt_nodes.add(stat.lhs) + i_state = i_state & ~i_assmts.mask + if stat.is_deletion: + i_state |= i_assmts.bit + else: + i_state |= stat.bit + assignments.add(stat) + if stat.rhs is not fake_rhs_expr: + stat.entry.cf_assignments.append(stat) + elif isinstance(stat, NameReference): + references[stat.node] = stat.entry + stat.entry.cf_references.append(stat) + stat.node.cf_state.update(state) + ## if not stat.node.allow_null: + ## i_state &= ~i_assmts.bit + ## # after successful read, the state is known to be initialised + state.discard(Uninitialized) + state.discard(Unknown) + for assmt in state: + assmt.refs.add(stat) + + # Check variable usage + warn_maybe_uninitialized = compiler_directives['warn.maybe_uninitialized'] + warn_unused_result = compiler_directives['warn.unused_result'] + warn_unused = compiler_directives['warn.unused'] + warn_unused_arg = compiler_directives['warn.unused_arg'] + + messages = MessageCollection() + + # assignment hints + for node in assmt_nodes: + if Uninitialized in node.cf_state: + node.cf_maybe_null = True + if len(node.cf_state) == 1: + node.cf_is_null = True + else: + node.cf_is_null = False + elif Unknown in node.cf_state: + node.cf_maybe_null = True + else: + node.cf_is_null = False + node.cf_maybe_null = False + + # Find uninitialized references and cf-hints + for node, entry in references.items(): + if Uninitialized in node.cf_state: + node.cf_maybe_null = True + if not entry.from_closure and len(node.cf_state) == 1: + node.cf_is_null = True + if (node.allow_null or entry.from_closure + or entry.is_pyclass_attr or entry.type.is_error): + pass # Can be uninitialized here + elif node.cf_is_null: + if entry.error_on_uninitialized or ( + Options.error_on_uninitialized and ( + entry.type.is_pyobject or entry.type.is_unspecified)): + messages.error( + node.pos, + "local variable '%s' referenced before assignment" + % entry.name) + else: + messages.warning( + node.pos, + "local variable '%s' referenced before assignment" + % entry.name) + elif warn_maybe_uninitialized: + messages.warning( + node.pos, + "local variable '%s' might be referenced before assignment" + % entry.name) + elif Unknown in node.cf_state: + # TODO: better cross-closure analysis to know when inner functions + # are being called before a variable is being set, and when + # a variable is known to be set before even defining the + # inner function, etc. + node.cf_maybe_null = True + else: + node.cf_is_null = False + node.cf_maybe_null = False + + # Unused result + for assmt in assignments: + if (not assmt.refs and not assmt.entry.is_pyclass_attr + and not assmt.entry.in_closure): + if assmt.entry.cf_references and warn_unused_result: + if assmt.is_arg: + messages.warning(assmt.pos, "Unused argument value '%s'" % + assmt.entry.name) + else: + messages.warning(assmt.pos, "Unused result in '%s'" % + assmt.entry.name) + assmt.lhs.cf_used = False + + # Unused entries + for entry in flow.entries: + if (not entry.cf_references + and not entry.is_pyclass_attr): + if entry.name != '_' and not entry.name.startswith('unused'): + # '_' is often used for unused variables, e.g. in loops + if entry.is_arg: + if warn_unused_arg: + messages.warning(entry.pos, "Unused argument '%s'" % + entry.name) + else: + if warn_unused: + messages.warning(entry.pos, "Unused entry '%s'" % + entry.name) + entry.cf_used = False + + messages.report() + + for node in assmt_nodes: + node.cf_state = ControlFlowState(node.cf_state) + for node in references: + node.cf_state = ControlFlowState(node.cf_state) + + +class AssignmentCollector(TreeVisitor): + def __init__(self): + super(AssignmentCollector, self).__init__() + self.assignments = [] + + def visit_Node(self): + self._visitchildren(self, None) + + def visit_SingleAssignmentNode(self, node): + self.assignments.append((node.lhs, node.rhs)) + + def visit_CascadedAssignmentNode(self, node): + for lhs in node.lhs_list: + self.assignments.append((lhs, node.rhs)) + + +class ControlFlowAnalysis(CythonTransform): + + def visit_ModuleNode(self, node): + self.gv_ctx = GVContext() + self.constant_folder = ConstantFolding() + + # Set of NameNode reductions + self.reductions = set() + + self.in_inplace_assignment = False + self.env_stack = [] + self.env = node.scope + self.stack = [] + self.flow = ControlFlow() + self.visitchildren(node) + + check_definitions(self.flow, self.current_directives) + + dot_output = self.current_directives['control_flow.dot_output'] + if dot_output: + annotate_defs = self.current_directives['control_flow.dot_annotate_defs'] + fp = open(dot_output, 'wt') + try: + self.gv_ctx.render(fp, 'module', annotate_defs=annotate_defs) + finally: + fp.close() + return node + + def visit_FuncDefNode(self, node): + for arg in node.args: + if arg.default: + self.visitchildren(arg) + self.visitchildren(node, ('decorators',)) + self.env_stack.append(self.env) + self.env = node.local_scope + self.stack.append(self.flow) + self.flow = ControlFlow() + + # Collect all entries + for entry in node.local_scope.entries.values(): + if self.flow.is_tracked(entry): + self.flow.entries.add(entry) + + self.mark_position(node) + # Function body block + self.flow.nextblock() + + for arg in node.args: + self._visit(arg) + if node.star_arg: + self.flow.mark_argument(node.star_arg, + TypedExprNode(Builtin.tuple_type, + may_be_none=False), + node.star_arg.entry) + if node.starstar_arg: + self.flow.mark_argument(node.starstar_arg, + TypedExprNode(Builtin.dict_type, + may_be_none=False), + node.starstar_arg.entry) + self._visit(node.body) + # Workaround for generators + if node.is_generator: + self._visit(node.gbody.body) + + # Exit point + if self.flow.block: + self.flow.block.add_child(self.flow.exit_point) + + # Cleanup graph + self.flow.normalize() + check_definitions(self.flow, self.current_directives) + self.flow.blocks.add(self.flow.entry_point) + + self.gv_ctx.add(GV(node.local_scope.name, self.flow)) + + self.flow = self.stack.pop() + self.env = self.env_stack.pop() + return node + + def visit_DefNode(self, node): + node.used = True + return self.visit_FuncDefNode(node) + + def visit_GeneratorBodyDefNode(self, node): + return node + + def visit_CTypeDefNode(self, node): + return node + + def mark_assignment(self, lhs, rhs=None): + if not self.flow.block: + return + if self.flow.exceptions: + exc_descr = self.flow.exceptions[-1] + self.flow.block.add_child(exc_descr.entry_point) + self.flow.nextblock() + + if not rhs: + rhs = object_expr + if lhs.is_name: + if lhs.entry is not None: + entry = lhs.entry + else: + entry = self.env.lookup(lhs.name) + if entry is None: # TODO: This shouldn't happen... + return + self.flow.mark_assignment(lhs, rhs, entry) + elif lhs.is_sequence_constructor: + for i, arg in enumerate(lhs.args): + if not rhs or arg.is_starred: + item_node = None + else: + item_node = rhs.inferable_item_node(i) + self.mark_assignment(arg, item_node) + else: + self._visit(lhs) + + if self.flow.exceptions: + exc_descr = self.flow.exceptions[-1] + self.flow.block.add_child(exc_descr.entry_point) + self.flow.nextblock() + + def mark_position(self, node): + """Mark position if DOT output is enabled.""" + if self.current_directives['control_flow.dot_output']: + self.flow.mark_position(node) + + def visit_FromImportStatNode(self, node): + for name, target in node.items: + if name != "*": + self.mark_assignment(target) + self.visitchildren(node) + return node + + def visit_AssignmentNode(self, node): + raise InternalError("Unhandled assignment node") + + def visit_SingleAssignmentNode(self, node): + self._visit(node.rhs) + self.mark_assignment(node.lhs, node.rhs) + return node + + def visit_CascadedAssignmentNode(self, node): + self._visit(node.rhs) + for lhs in node.lhs_list: + self.mark_assignment(lhs, node.rhs) + return node + + def visit_ParallelAssignmentNode(self, node): + collector = AssignmentCollector() + collector.visitchildren(node) + for lhs, rhs in collector.assignments: + self._visit(rhs) + for lhs, rhs in collector.assignments: + self.mark_assignment(lhs, rhs) + return node + + def visit_InPlaceAssignmentNode(self, node): + self.in_inplace_assignment = True + self.visitchildren(node) + self.in_inplace_assignment = False + self.mark_assignment(node.lhs, self.constant_folder(node.create_binop_node())) + return node + + def visit_DelStatNode(self, node): + for arg in node.args: + if arg.is_name: + entry = arg.entry or self.env.lookup(arg.name) + if entry.in_closure or entry.from_closure: + error(arg.pos, + "can not delete variable '%s' " + "referenced in nested scope" % entry.name) + if not node.ignore_nonexisting: + self._visit(arg) # mark reference + self.flow.mark_deletion(arg, entry) + else: + self._visit(arg) + return node + + def visit_CArgDeclNode(self, node): + entry = self.env.lookup(node.name) + if entry: + may_be_none = not node.not_none + self.flow.mark_argument( + node, TypedExprNode(entry.type, may_be_none), entry) + return node + + def visit_NameNode(self, node): + if self.flow.block: + entry = node.entry or self.env.lookup(node.name) + if entry: + self.flow.mark_reference(node, entry) + + if entry in self.reductions and not self.in_inplace_assignment: + error(node.pos, + "Cannot read reduction variable in loop body") + + return node + + def visit_StatListNode(self, node): + if self.flow.block: + for stat in node.stats: + self._visit(stat) + if not self.flow.block: + stat.is_terminator = True + break + return node + + def visit_Node(self, node): + self.visitchildren(node) + self.mark_position(node) + return node + + def visit_SizeofVarNode(self, node): + return node + + def visit_TypeidNode(self, node): + return node + + def visit_IfStatNode(self, node): + next_block = self.flow.newblock() + parent = self.flow.block + # If clauses + for clause in node.if_clauses: + parent = self.flow.nextblock(parent) + self._visit(clause.condition) + self.flow.nextblock() + self._visit(clause.body) + if self.flow.block: + self.flow.block.add_child(next_block) + # Else clause + if node.else_clause: + self.flow.nextblock(parent=parent) + self._visit(node.else_clause) + if self.flow.block: + self.flow.block.add_child(next_block) + else: + parent.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node + + def visit_WhileStatNode(self, node): + condition_block = self.flow.nextblock() + next_block = self.flow.newblock() + # Condition block + self.flow.loops.append(LoopDescr(next_block, condition_block)) + if node.condition: + self._visit(node.condition) + # Body block + self.flow.nextblock() + self._visit(node.body) + self.flow.loops.pop() + # Loop it + if self.flow.block: + self.flow.block.add_child(condition_block) + self.flow.block.add_child(next_block) + # Else clause + if node.else_clause: + self.flow.nextblock(parent=condition_block) + self._visit(node.else_clause) + if self.flow.block: + self.flow.block.add_child(next_block) + else: + condition_block.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node + + def mark_forloop_target(self, node): + # TODO: Remove redundancy with range optimization... + is_special = False + sequence = node.iterator.sequence + target = node.target + if isinstance(sequence, ExprNodes.SimpleCallNode): + function = sequence.function + if sequence.self is None and function.is_name: + entry = self.env.lookup(function.name) + if not entry or entry.is_builtin: + if function.name == 'reversed' and len(sequence.args) == 1: + sequence = sequence.args[0] + elif function.name == 'enumerate' and len(sequence.args) == 1: + if target.is_sequence_constructor and len(target.args) == 2: + iterator = sequence.args[0] + if iterator.is_name: + iterator_type = iterator.infer_type(self.env) + if iterator_type.is_builtin_type: + # assume that builtin types have a length within Py_ssize_t + self.mark_assignment( + target.args[0], + ExprNodes.IntNode(target.pos, value='PY_SSIZE_T_MAX', + type=PyrexTypes.c_py_ssize_t_type)) + target = target.args[1] + sequence = sequence.args[0] + if isinstance(sequence, ExprNodes.SimpleCallNode): + function = sequence.function + if sequence.self is None and function.is_name: + entry = self.env.lookup(function.name) + if not entry or entry.is_builtin: + if function.name in ('range', 'xrange'): + is_special = True + for arg in sequence.args[:2]: + self.mark_assignment(target, arg) + if len(sequence.args) > 2: + self.mark_assignment(target, self.constant_folder( + ExprNodes.binop_node(node.pos, + '+', + sequence.args[0], + sequence.args[2]))) + + if not is_special: + # A for-loop basically translates to subsequent calls to + # __getitem__(), so using an IndexNode here allows us to + # naturally infer the base type of pointers, C arrays, + # Python strings, etc., while correctly falling back to an + # object type when the base type cannot be handled. + + self.mark_assignment(target, node.item) + + def visit_AsyncForStatNode(self, node): + return self.visit_ForInStatNode(node) + + def visit_ForInStatNode(self, node): + condition_block = self.flow.nextblock() + next_block = self.flow.newblock() + # Condition with iterator + self.flow.loops.append(LoopDescr(next_block, condition_block)) + self._visit(node.iterator) + # Target assignment + self.flow.nextblock() + + if isinstance(node, Nodes.ForInStatNode): + self.mark_forloop_target(node) + elif isinstance(node, Nodes.AsyncForStatNode): + # not entirely correct, but good enough for now + self.mark_assignment(node.target, node.item) + else: # Parallel + self.mark_assignment(node.target) + + # Body block + if isinstance(node, Nodes.ParallelRangeNode): + # In case of an invalid + self._delete_privates(node, exclude=node.target.entry) + + self.flow.nextblock() + self._visit(node.body) + self.flow.loops.pop() + + # Loop it + if self.flow.block: + self.flow.block.add_child(condition_block) + # Else clause + if node.else_clause: + self.flow.nextblock(parent=condition_block) + self._visit(node.else_clause) + if self.flow.block: + self.flow.block.add_child(next_block) + else: + condition_block.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node + + def _delete_privates(self, node, exclude=None): + for private_node in node.assigned_nodes: + if not exclude or private_node.entry is not exclude: + self.flow.mark_deletion(private_node, private_node.entry) + + def visit_ParallelRangeNode(self, node): + reductions = self.reductions + + # if node.target is None or not a NameNode, an error will have + # been previously issued + if hasattr(node.target, 'entry'): + self.reductions = set(reductions) + + for private_node in node.assigned_nodes: + private_node.entry.error_on_uninitialized = True + pos, reduction = node.assignments[private_node.entry] + if reduction: + self.reductions.add(private_node.entry) + + node = self.visit_ForInStatNode(node) + + self.reductions = reductions + return node + + def visit_ParallelWithBlockNode(self, node): + for private_node in node.assigned_nodes: + private_node.entry.error_on_uninitialized = True + + self._delete_privates(node) + self.visitchildren(node) + self._delete_privates(node) + + return node + + def visit_ForFromStatNode(self, node): + condition_block = self.flow.nextblock() + next_block = self.flow.newblock() + # Condition with iterator + self.flow.loops.append(LoopDescr(next_block, condition_block)) + self._visit(node.bound1) + self._visit(node.bound2) + if node.step is not None: + self._visit(node.step) + # Target assignment + self.flow.nextblock() + self.mark_assignment(node.target, node.bound1) + if node.step is not None: + self.mark_assignment(node.target, self.constant_folder( + ExprNodes.binop_node(node.pos, '+', node.bound1, node.step))) + # Body block + self.flow.nextblock() + self._visit(node.body) + self.flow.loops.pop() + # Loop it + if self.flow.block: + self.flow.block.add_child(condition_block) + # Else clause + if node.else_clause: + self.flow.nextblock(parent=condition_block) + self._visit(node.else_clause) + if self.flow.block: + self.flow.block.add_child(next_block) + else: + condition_block.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node + + def visit_LoopNode(self, node): + raise InternalError("Generic loops are not supported") + + def visit_WithTargetAssignmentStatNode(self, node): + self.mark_assignment(node.lhs, node.with_node.enter_call) + return node + + def visit_WithStatNode(self, node): + self._visit(node.manager) + self._visit(node.enter_call) + self._visit(node.body) + return node + + def visit_TryExceptStatNode(self, node): + # After exception handling + next_block = self.flow.newblock() + # Body block + self.flow.newblock() + # Exception entry point + entry_point = self.flow.newblock() + self.flow.exceptions.append(ExceptionDescr(entry_point)) + self.flow.nextblock() + ## XXX: links to exception handling point should be added by + ## XXX: children nodes + self.flow.block.add_child(entry_point) + self.flow.nextblock() + self._visit(node.body) + self.flow.exceptions.pop() + + # After exception + if self.flow.block: + if node.else_clause: + self.flow.nextblock() + self._visit(node.else_clause) + if self.flow.block: + self.flow.block.add_child(next_block) + + for clause in node.except_clauses: + self.flow.block = entry_point + if clause.pattern: + for pattern in clause.pattern: + self._visit(pattern) + else: + # TODO: handle * pattern + pass + entry_point = self.flow.newblock(parent=self.flow.block) + self.flow.nextblock() + if clause.target: + self.mark_assignment(clause.target) + self._visit(clause.body) + if self.flow.block: + self.flow.block.add_child(next_block) + + if self.flow.exceptions: + entry_point.add_child(self.flow.exceptions[-1].entry_point) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node + + def visit_TryFinallyStatNode(self, node): + body_block = self.flow.nextblock() + + # Exception entry point + entry_point = self.flow.newblock() + self.flow.block = entry_point + self._visit(node.finally_except_clause) + + if self.flow.block and self.flow.exceptions: + self.flow.block.add_child(self.flow.exceptions[-1].entry_point) + + # Normal execution + finally_enter = self.flow.newblock() + self.flow.block = finally_enter + self._visit(node.finally_clause) + finally_exit = self.flow.block + + descr = ExceptionDescr(entry_point, finally_enter, finally_exit) + self.flow.exceptions.append(descr) + if self.flow.loops: + self.flow.loops[-1].exceptions.append(descr) + self.flow.block = body_block + body_block.add_child(entry_point) + self.flow.nextblock() + self._visit(node.body) + self.flow.exceptions.pop() + if self.flow.loops: + self.flow.loops[-1].exceptions.pop() + + if self.flow.block: + self.flow.block.add_child(finally_enter) + if finally_exit: + self.flow.block = self.flow.nextblock(parent=finally_exit) + else: + self.flow.block = None + return node + + def visit_RaiseStatNode(self, node): + self.mark_position(node) + self.visitchildren(node) + if self.flow.exceptions: + self.flow.block.add_child(self.flow.exceptions[-1].entry_point) + self.flow.block = None + return node + + def visit_ReraiseStatNode(self, node): + self.mark_position(node) + if self.flow.exceptions: + self.flow.block.add_child(self.flow.exceptions[-1].entry_point) + self.flow.block = None + return node + + def visit_ReturnStatNode(self, node): + self.mark_position(node) + self.visitchildren(node) + + outer_exception_handlers = iter(self.flow.exceptions[::-1]) + for handler in outer_exception_handlers: + if handler.finally_enter: + self.flow.block.add_child(handler.finally_enter) + if handler.finally_exit: + # 'return' goes to function exit, or to the next outer 'finally' clause + exit_point = self.flow.exit_point + for next_handler in outer_exception_handlers: + if next_handler.finally_enter: + exit_point = next_handler.finally_enter + break + handler.finally_exit.add_child(exit_point) + break + else: + if self.flow.block: + self.flow.block.add_child(self.flow.exit_point) + self.flow.block = None + return node + + def visit_BreakStatNode(self, node): + if not self.flow.loops: + #error(node.pos, "break statement not inside loop") + return node + loop = self.flow.loops[-1] + self.mark_position(node) + for exception in loop.exceptions[::-1]: + if exception.finally_enter: + self.flow.block.add_child(exception.finally_enter) + if exception.finally_exit: + exception.finally_exit.add_child(loop.next_block) + break + else: + self.flow.block.add_child(loop.next_block) + self.flow.block = None + return node + + def visit_ContinueStatNode(self, node): + if not self.flow.loops: + #error(node.pos, "continue statement not inside loop") + return node + loop = self.flow.loops[-1] + self.mark_position(node) + for exception in loop.exceptions[::-1]: + if exception.finally_enter: + self.flow.block.add_child(exception.finally_enter) + if exception.finally_exit: + exception.finally_exit.add_child(loop.loop_block) + break + else: + self.flow.block.add_child(loop.loop_block) + self.flow.block = None + return node + + def visit_ComprehensionNode(self, node): + if node.expr_scope: + self.env_stack.append(self.env) + self.env = node.expr_scope + # Skip append node here + self._visit(node.loop) + if node.expr_scope: + self.env = self.env_stack.pop() + return node + + def visit_ScopedExprNode(self, node): + if node.expr_scope: + self.env_stack.append(self.env) + self.env = node.expr_scope + self.visitchildren(node) + if node.expr_scope: + self.env = self.env_stack.pop() + return node + + def visit_PyClassDefNode(self, node): + self.visitchildren(node, ('dict', 'metaclass', + 'mkw', 'bases', 'class_result')) + self.flow.mark_assignment(node.target, node.classobj, + self.env.lookup(node.name)) + self.env_stack.append(self.env) + self.env = node.scope + self.flow.nextblock() + self.visitchildren(node, ('body',)) + self.flow.nextblock() + self.env = self.env_stack.pop() + return node + + def visit_AmpersandNode(self, node): + if node.operand.is_name: + # Fake assignment to silence warning + self.mark_assignment(node.operand, fake_rhs_expr) + self.visitchildren(node) + return node diff --git a/contrib/tools/cython/Cython/Compiler/FusedNode.py b/contrib/tools/cython/Cython/Compiler/FusedNode.py new file mode 100644 index 00000000000..26d6ffd3d65 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/FusedNode.py @@ -0,0 +1,901 @@ +from __future__ import absolute_import + +import copy + +from . import (ExprNodes, PyrexTypes, MemoryView, + ParseTreeTransforms, StringEncoding, Errors) +from .ExprNodes import CloneNode, ProxyNode, TupleNode +from .Nodes import FuncDefNode, CFuncDefNode, StatListNode, DefNode +from ..Utils import OrderedSet + + +class FusedCFuncDefNode(StatListNode): + """ + This node replaces a function with fused arguments. It deep-copies the + function for every permutation of fused types, and allocates a new local + scope for it. It keeps track of the original function in self.node, and + the entry of the original function in the symbol table is given the + 'fused_cfunction' attribute which points back to us. + Then when a function lookup occurs (to e.g. call it), the call can be + dispatched to the right function. + + node FuncDefNode the original function + nodes [FuncDefNode] list of copies of node with different specific types + py_func DefNode the fused python function subscriptable from + Python space + __signatures__ A DictNode mapping signature specialization strings + to PyCFunction nodes + resulting_fused_function PyCFunction for the fused DefNode that delegates + to specializations + fused_func_assignment Assignment of the fused function to the function name + defaults_tuple TupleNode of defaults (letting PyCFunctionNode build + defaults would result in many different tuples) + specialized_pycfuncs List of synthesized pycfunction nodes for the + specializations + code_object CodeObjectNode shared by all specializations and the + fused function + + fused_compound_types All fused (compound) types (e.g. floating[:]) + """ + + __signatures__ = None + resulting_fused_function = None + fused_func_assignment = None + defaults_tuple = None + decorators = None + + child_attrs = StatListNode.child_attrs + [ + '__signatures__', 'resulting_fused_function', 'fused_func_assignment'] + + def __init__(self, node, env): + super(FusedCFuncDefNode, self).__init__(node.pos) + + self.nodes = [] + self.node = node + + is_def = isinstance(self.node, DefNode) + if is_def: + # self.node.decorators = [] + self.copy_def(env) + else: + self.copy_cdef(env) + + # Perform some sanity checks. If anything fails, it's a bug + for n in self.nodes: + assert not n.entry.type.is_fused + assert not n.local_scope.return_type.is_fused + if node.return_type.is_fused: + assert not n.return_type.is_fused + + if not is_def and n.cfunc_declarator.optional_arg_count: + assert n.type.op_arg_struct + + node.entry.fused_cfunction = self + # Copy the nodes as AnalyseDeclarationsTransform will prepend + # self.py_func to self.stats, as we only want specialized + # CFuncDefNodes in self.nodes + self.stats = self.nodes[:] + + def copy_def(self, env): + """ + Create a copy of the original def or lambda function for specialized + versions. + """ + fused_compound_types = PyrexTypes.unique( + [arg.type for arg in self.node.args if arg.type.is_fused]) + fused_types = self._get_fused_base_types(fused_compound_types) + permutations = PyrexTypes.get_all_specialized_permutations(fused_types) + + self.fused_compound_types = fused_compound_types + + if self.node.entry in env.pyfunc_entries: + env.pyfunc_entries.remove(self.node.entry) + + for cname, fused_to_specific in permutations: + copied_node = copy.deepcopy(self.node) + # keep signature object identity for special casing in DefNode.analyse_declarations() + copied_node.entry.signature = self.node.entry.signature + + self._specialize_function_args(copied_node.args, fused_to_specific) + copied_node.return_type = self.node.return_type.specialize( + fused_to_specific) + + copied_node.analyse_declarations(env) + # copied_node.is_staticmethod = self.node.is_staticmethod + # copied_node.is_classmethod = self.node.is_classmethod + self.create_new_local_scope(copied_node, env, fused_to_specific) + self.specialize_copied_def(copied_node, cname, self.node.entry, + fused_to_specific, fused_compound_types) + + PyrexTypes.specialize_entry(copied_node.entry, cname) + copied_node.entry.used = True + env.entries[copied_node.entry.name] = copied_node.entry + + if not self.replace_fused_typechecks(copied_node): + break + + self.orig_py_func = self.node + self.py_func = self.make_fused_cpdef(self.node, env, is_def=True) + + def copy_cdef(self, env): + """ + Create a copy of the original c(p)def function for all specialized + versions. + """ + permutations = self.node.type.get_all_specialized_permutations() + # print 'Node %s has %d specializations:' % (self.node.entry.name, + # len(permutations)) + # import pprint; pprint.pprint([d for cname, d in permutations]) + + # Prevent copying of the python function + self.orig_py_func = orig_py_func = self.node.py_func + self.node.py_func = None + if orig_py_func: + env.pyfunc_entries.remove(orig_py_func.entry) + + fused_types = self.node.type.get_fused_types() + self.fused_compound_types = fused_types + + new_cfunc_entries = [] + for cname, fused_to_specific in permutations: + copied_node = copy.deepcopy(self.node) + + # Make the types in our CFuncType specific. + type = copied_node.type.specialize(fused_to_specific) + entry = copied_node.entry + type.specialize_entry(entry, cname) + + # Reuse existing Entries (e.g. from .pxd files). + for i, orig_entry in enumerate(env.cfunc_entries): + if entry.cname == orig_entry.cname and type.same_as_resolved_type(orig_entry.type): + copied_node.entry = env.cfunc_entries[i] + if not copied_node.entry.func_cname: + copied_node.entry.func_cname = entry.func_cname + entry = copied_node.entry + type = entry.type + break + else: + new_cfunc_entries.append(entry) + + copied_node.type = type + entry.type, type.entry = type, entry + + entry.used = (entry.used or + self.node.entry.defined_in_pxd or + env.is_c_class_scope or + entry.is_cmethod) + + if self.node.cfunc_declarator.optional_arg_count: + self.node.cfunc_declarator.declare_optional_arg_struct( + type, env, fused_cname=cname) + + copied_node.return_type = type.return_type + self.create_new_local_scope(copied_node, env, fused_to_specific) + + # Make the argument types in the CFuncDeclarator specific + self._specialize_function_args(copied_node.cfunc_declarator.args, + fused_to_specific) + + # If a cpdef, declare all specialized cpdefs (this + # also calls analyse_declarations) + copied_node.declare_cpdef_wrapper(env) + if copied_node.py_func: + env.pyfunc_entries.remove(copied_node.py_func.entry) + + self.specialize_copied_def( + copied_node.py_func, cname, self.node.entry.as_variable, + fused_to_specific, fused_types) + + if not self.replace_fused_typechecks(copied_node): + break + + # replace old entry with new entries + try: + cindex = env.cfunc_entries.index(self.node.entry) + except ValueError: + env.cfunc_entries.extend(new_cfunc_entries) + else: + env.cfunc_entries[cindex:cindex+1] = new_cfunc_entries + + if orig_py_func: + self.py_func = self.make_fused_cpdef(orig_py_func, env, + is_def=False) + else: + self.py_func = orig_py_func + + def _get_fused_base_types(self, fused_compound_types): + """ + Get a list of unique basic fused types, from a list of + (possibly) compound fused types. + """ + base_types = [] + seen = set() + for fused_type in fused_compound_types: + fused_type.get_fused_types(result=base_types, seen=seen) + return base_types + + def _specialize_function_args(self, args, fused_to_specific): + for arg in args: + if arg.type.is_fused: + arg.type = arg.type.specialize(fused_to_specific) + if arg.type.is_memoryviewslice: + arg.type.validate_memslice_dtype(arg.pos) + + def create_new_local_scope(self, node, env, f2s): + """ + Create a new local scope for the copied node and append it to + self.nodes. A new local scope is needed because the arguments with the + fused types are already in the local scope, and we need the specialized + entries created after analyse_declarations on each specialized version + of the (CFunc)DefNode. + f2s is a dict mapping each fused type to its specialized version + """ + node.create_local_scope(env) + node.local_scope.fused_to_specific = f2s + + # This is copied from the original function, set it to false to + # stop recursion + node.has_fused_arguments = False + self.nodes.append(node) + + def specialize_copied_def(self, node, cname, py_entry, f2s, fused_compound_types): + """Specialize the copy of a DefNode given the copied node, + the specialization cname and the original DefNode entry""" + fused_types = self._get_fused_base_types(fused_compound_types) + type_strings = [ + PyrexTypes.specialization_signature_string(fused_type, f2s) + for fused_type in fused_types + ] + + node.specialized_signature_string = '|'.join(type_strings) + + node.entry.pymethdef_cname = PyrexTypes.get_fused_cname( + cname, node.entry.pymethdef_cname) + node.entry.doc = py_entry.doc + node.entry.doc_cname = py_entry.doc_cname + + def replace_fused_typechecks(self, copied_node): + """ + Branch-prune fused type checks like + + if fused_t is int: + ... + + Returns whether an error was issued and whether we should stop in + in order to prevent a flood of errors. + """ + num_errors = Errors.num_errors + transform = ParseTreeTransforms.ReplaceFusedTypeChecks( + copied_node.local_scope) + transform(copied_node) + + if Errors.num_errors > num_errors: + return False + + return True + + def _fused_instance_checks(self, normal_types, pyx_code, env): + """ + Generate Cython code for instance checks, matching an object to + specialized types. + """ + for specialized_type in normal_types: + # all_numeric = all_numeric and specialized_type.is_numeric + pyx_code.context.update( + py_type_name=specialized_type.py_type_name(), + specialized_type_name=specialized_type.specialization_string, + ) + pyx_code.put_chunk( + u""" + if isinstance(arg, {{py_type_name}}): + dest_sig[{{dest_sig_idx}}] = '{{specialized_type_name}}'; break + """) + + def _dtype_name(self, dtype): + if dtype.is_typedef: + return '___pyx_%s' % dtype + return str(dtype).replace(' ', '_') + + def _dtype_type(self, dtype): + if dtype.is_typedef: + return self._dtype_name(dtype) + return str(dtype) + + def _sizeof_dtype(self, dtype): + if dtype.is_pyobject: + return 'sizeof(void *)' + else: + return "sizeof(%s)" % self._dtype_type(dtype) + + def _buffer_check_numpy_dtype_setup_cases(self, pyx_code): + "Setup some common cases to match dtypes against specializations" + if pyx_code.indenter("if kind in b'iu':"): + pyx_code.putln("pass") + pyx_code.named_insertion_point("dtype_int") + pyx_code.dedent() + + if pyx_code.indenter("elif kind == b'f':"): + pyx_code.putln("pass") + pyx_code.named_insertion_point("dtype_float") + pyx_code.dedent() + + if pyx_code.indenter("elif kind == b'c':"): + pyx_code.putln("pass") + pyx_code.named_insertion_point("dtype_complex") + pyx_code.dedent() + + if pyx_code.indenter("elif kind == b'O':"): + pyx_code.putln("pass") + pyx_code.named_insertion_point("dtype_object") + pyx_code.dedent() + + match = "dest_sig[{{dest_sig_idx}}] = '{{specialized_type_name}}'" + no_match = "dest_sig[{{dest_sig_idx}}] = None" + def _buffer_check_numpy_dtype(self, pyx_code, specialized_buffer_types, pythran_types): + """ + Match a numpy dtype object to the individual specializations. + """ + self._buffer_check_numpy_dtype_setup_cases(pyx_code) + + for specialized_type in pythran_types+specialized_buffer_types: + final_type = specialized_type + if specialized_type.is_pythran_expr: + specialized_type = specialized_type.org_buffer + dtype = specialized_type.dtype + pyx_code.context.update( + itemsize_match=self._sizeof_dtype(dtype) + " == itemsize", + signed_match="not (%s_is_signed ^ dtype_signed)" % self._dtype_name(dtype), + dtype=dtype, + specialized_type_name=final_type.specialization_string) + + dtypes = [ + (dtype.is_int, pyx_code.dtype_int), + (dtype.is_float, pyx_code.dtype_float), + (dtype.is_complex, pyx_code.dtype_complex) + ] + + for dtype_category, codewriter in dtypes: + if dtype_category: + cond = '{{itemsize_match}} and (<Py_ssize_t>arg.ndim) == %d' % ( + specialized_type.ndim,) + if dtype.is_int: + cond += ' and {{signed_match}}' + + if final_type.is_pythran_expr: + cond += ' and arg_is_pythran_compatible' + + if codewriter.indenter("if %s:" % cond): + #codewriter.putln("print 'buffer match found based on numpy dtype'") + codewriter.putln(self.match) + codewriter.putln("break") + codewriter.dedent() + + def _buffer_parse_format_string_check(self, pyx_code, decl_code, + specialized_type, env): + """ + For each specialized type, try to coerce the object to a memoryview + slice of that type. This means obtaining a buffer and parsing the + format string. + TODO: separate buffer acquisition from format parsing + """ + dtype = specialized_type.dtype + if specialized_type.is_buffer: + axes = [('direct', 'strided')] * specialized_type.ndim + else: + axes = specialized_type.axes + + memslice_type = PyrexTypes.MemoryViewSliceType(dtype, axes) + memslice_type.create_from_py_utility_code(env) + pyx_code.context.update( + coerce_from_py_func=memslice_type.from_py_function, + dtype=dtype) + decl_code.putln( + "{{memviewslice_cname}} {{coerce_from_py_func}}(object, int)") + + pyx_code.context.update( + specialized_type_name=specialized_type.specialization_string, + sizeof_dtype=self._sizeof_dtype(dtype)) + + pyx_code.put_chunk( + u""" + # try {{dtype}} + if itemsize == -1 or itemsize == {{sizeof_dtype}}: + memslice = {{coerce_from_py_func}}(arg, 0) + if memslice.memview: + __PYX_XDEC_MEMVIEW(&memslice, 1) + # print 'found a match for the buffer through format parsing' + %s + break + else: + __pyx_PyErr_Clear() + """ % self.match) + + def _buffer_checks(self, buffer_types, pythran_types, pyx_code, decl_code, env): + """ + Generate Cython code to match objects to buffer specializations. + First try to get a numpy dtype object and match it against the individual + specializations. If that fails, try naively to coerce the object + to each specialization, which obtains the buffer each time and tries + to match the format string. + """ + # The first thing to find a match in this loop breaks out of the loop + pyx_code.put_chunk( + u""" + """ + (u"arg_is_pythran_compatible = False" if pythran_types else u"") + u""" + if ndarray is not None: + if isinstance(arg, ndarray): + dtype = arg.dtype + """ + (u"arg_is_pythran_compatible = True" if pythran_types else u"") + u""" + elif __pyx_memoryview_check(arg): + arg_base = arg.base + if isinstance(arg_base, ndarray): + dtype = arg_base.dtype + else: + dtype = None + else: + dtype = None + + itemsize = -1 + if dtype is not None: + itemsize = dtype.itemsize + kind = ord(dtype.kind) + dtype_signed = kind == 'i' + """) + pyx_code.indent(2) + if pythran_types: + pyx_code.put_chunk( + u""" + # Pythran only supports the endianness of the current compiler + byteorder = dtype.byteorder + if byteorder == "<" and not __Pyx_Is_Little_Endian(): + arg_is_pythran_compatible = False + elif byteorder == ">" and __Pyx_Is_Little_Endian(): + arg_is_pythran_compatible = False + if arg_is_pythran_compatible: + cur_stride = itemsize + shape = arg.shape + strides = arg.strides + for i in range(arg.ndim-1, -1, -1): + if (<Py_ssize_t>strides[i]) != cur_stride: + arg_is_pythran_compatible = False + break + cur_stride *= <Py_ssize_t> shape[i] + else: + arg_is_pythran_compatible = not (arg.flags.f_contiguous and (<Py_ssize_t>arg.ndim) > 1) + """) + pyx_code.named_insertion_point("numpy_dtype_checks") + self._buffer_check_numpy_dtype(pyx_code, buffer_types, pythran_types) + pyx_code.dedent(2) + + for specialized_type in buffer_types: + self._buffer_parse_format_string_check( + pyx_code, decl_code, specialized_type, env) + + def _buffer_declarations(self, pyx_code, decl_code, all_buffer_types, pythran_types): + """ + If we have any buffer specializations, write out some variable + declarations and imports. + """ + decl_code.put_chunk( + u""" + ctypedef struct {{memviewslice_cname}}: + void *memview + + void __PYX_XDEC_MEMVIEW({{memviewslice_cname}} *, int have_gil) + bint __pyx_memoryview_check(object) + """) + + pyx_code.local_variable_declarations.put_chunk( + u""" + cdef {{memviewslice_cname}} memslice + cdef Py_ssize_t itemsize + cdef bint dtype_signed + cdef char kind + + itemsize = -1 + """) + + if pythran_types: + pyx_code.local_variable_declarations.put_chunk(u""" + cdef bint arg_is_pythran_compatible + cdef Py_ssize_t cur_stride + """) + + pyx_code.imports.put_chunk( + u""" + cdef type ndarray + ndarray = __Pyx_ImportNumPyArrayTypeIfAvailable() + """) + + seen_typedefs = set() + seen_int_dtypes = set() + for buffer_type in all_buffer_types: + dtype = buffer_type.dtype + dtype_name = self._dtype_name(dtype) + if dtype.is_typedef: + if dtype_name not in seen_typedefs: + seen_typedefs.add(dtype_name) + decl_code.putln( + 'ctypedef %s %s "%s"' % (dtype.resolve(), dtype_name, + dtype.empty_declaration_code())) + + if buffer_type.dtype.is_int: + if str(dtype) not in seen_int_dtypes: + seen_int_dtypes.add(str(dtype)) + pyx_code.context.update(dtype_name=dtype_name, + dtype_type=self._dtype_type(dtype)) + pyx_code.local_variable_declarations.put_chunk( + u""" + cdef bint {{dtype_name}}_is_signed + {{dtype_name}}_is_signed = not (<{{dtype_type}}> -1 > 0) + """) + + def _split_fused_types(self, arg): + """ + Specialize fused types and split into normal types and buffer types. + """ + specialized_types = PyrexTypes.get_specialized_types(arg.type) + + # Prefer long over int, etc by sorting (see type classes in PyrexTypes.py) + specialized_types.sort() + + seen_py_type_names = set() + normal_types, buffer_types, pythran_types = [], [], [] + has_object_fallback = False + for specialized_type in specialized_types: + py_type_name = specialized_type.py_type_name() + if py_type_name: + if py_type_name in seen_py_type_names: + continue + seen_py_type_names.add(py_type_name) + if py_type_name == 'object': + has_object_fallback = True + else: + normal_types.append(specialized_type) + elif specialized_type.is_pythran_expr: + pythran_types.append(specialized_type) + elif specialized_type.is_buffer or specialized_type.is_memoryviewslice: + buffer_types.append(specialized_type) + + return normal_types, buffer_types, pythran_types, has_object_fallback + + def _unpack_argument(self, pyx_code): + pyx_code.put_chunk( + u""" + # PROCESSING ARGUMENT {{arg_tuple_idx}} + if {{arg_tuple_idx}} < len(<tuple>args): + arg = (<tuple>args)[{{arg_tuple_idx}}] + elif kwargs is not None and '{{arg.name}}' in <dict>kwargs: + arg = (<dict>kwargs)['{{arg.name}}'] + else: + {{if arg.default}} + arg = (<tuple>defaults)[{{default_idx}}] + {{else}} + {{if arg_tuple_idx < min_positional_args}} + raise TypeError("Expected at least %d argument%s, got %d" % ( + {{min_positional_args}}, {{'"s"' if min_positional_args != 1 else '""'}}, len(<tuple>args))) + {{else}} + raise TypeError("Missing keyword-only argument: '%s'" % "{{arg.default}}") + {{endif}} + {{endif}} + """) + + def make_fused_cpdef(self, orig_py_func, env, is_def): + """ + This creates the function that is indexable from Python and does + runtime dispatch based on the argument types. The function gets the + arg tuple and kwargs dict (or None) and the defaults tuple + as arguments from the Binding Fused Function's tp_call. + """ + from . import TreeFragment, Code, UtilityCode + + fused_types = self._get_fused_base_types([ + arg.type for arg in self.node.args if arg.type.is_fused]) + + context = { + 'memviewslice_cname': MemoryView.memviewslice_cname, + 'func_args': self.node.args, + 'n_fused': len(fused_types), + 'min_positional_args': + self.node.num_required_args - self.node.num_required_kw_args + if is_def else + sum(1 for arg in self.node.args if arg.default is None), + 'name': orig_py_func.entry.name, + } + + pyx_code = Code.PyxCodeWriter(context=context) + decl_code = Code.PyxCodeWriter(context=context) + decl_code.put_chunk( + u""" + cdef extern from *: + void __pyx_PyErr_Clear "PyErr_Clear" () + type __Pyx_ImportNumPyArrayTypeIfAvailable() + int __Pyx_Is_Little_Endian() + """) + decl_code.indent() + + pyx_code.put_chunk( + u""" + def __pyx_fused_cpdef(signatures, args, kwargs, defaults): + # FIXME: use a typed signature - currently fails badly because + # default arguments inherit the types we specify here! + + dest_sig = [None] * {{n_fused}} + + if kwargs is not None and not kwargs: + kwargs = None + + cdef Py_ssize_t i + + # instance check body + """) + + pyx_code.indent() # indent following code to function body + pyx_code.named_insertion_point("imports") + pyx_code.named_insertion_point("func_defs") + pyx_code.named_insertion_point("local_variable_declarations") + + fused_index = 0 + default_idx = 0 + all_buffer_types = OrderedSet() + seen_fused_types = set() + for i, arg in enumerate(self.node.args): + if arg.type.is_fused: + arg_fused_types = arg.type.get_fused_types() + if len(arg_fused_types) > 1: + raise NotImplementedError("Determination of more than one fused base " + "type per argument is not implemented.") + fused_type = arg_fused_types[0] + + if arg.type.is_fused and fused_type not in seen_fused_types: + seen_fused_types.add(fused_type) + + context.update( + arg_tuple_idx=i, + arg=arg, + dest_sig_idx=fused_index, + default_idx=default_idx, + ) + + normal_types, buffer_types, pythran_types, has_object_fallback = self._split_fused_types(arg) + self._unpack_argument(pyx_code) + + # 'unrolled' loop, first match breaks out of it + if pyx_code.indenter("while 1:"): + if normal_types: + self._fused_instance_checks(normal_types, pyx_code, env) + if buffer_types or pythran_types: + env.use_utility_code(Code.UtilityCode.load_cached("IsLittleEndian", "ModuleSetupCode.c")) + self._buffer_checks(buffer_types, pythran_types, pyx_code, decl_code, env) + if has_object_fallback: + pyx_code.context.update(specialized_type_name='object') + pyx_code.putln(self.match) + else: + pyx_code.putln(self.no_match) + pyx_code.putln("break") + pyx_code.dedent() + + fused_index += 1 + all_buffer_types.update(buffer_types) + all_buffer_types.update(ty.org_buffer for ty in pythran_types) + + if arg.default: + default_idx += 1 + + if all_buffer_types: + self._buffer_declarations(pyx_code, decl_code, all_buffer_types, pythran_types) + env.use_utility_code(Code.UtilityCode.load_cached("Import", "ImportExport.c")) + env.use_utility_code(Code.UtilityCode.load_cached("ImportNumPyArray", "ImportExport.c")) + + pyx_code.put_chunk( + u""" + candidates = [] + for sig in <dict>signatures: + match_found = False + src_sig = sig.strip('()').split('|') + for i in range(len(dest_sig)): + dst_type = dest_sig[i] + if dst_type is not None: + if src_sig[i] == dst_type: + match_found = True + else: + match_found = False + break + + if match_found: + candidates.append(sig) + + if not candidates: + raise TypeError("No matching signature found") + elif len(candidates) > 1: + raise TypeError("Function call with ambiguous argument types") + else: + return (<dict>signatures)[candidates[0]] + """) + + fragment_code = pyx_code.getvalue() + # print decl_code.getvalue() + # print fragment_code + from .Optimize import ConstantFolding + fragment = TreeFragment.TreeFragment( + fragment_code, level='module', pipeline=[ConstantFolding()]) + ast = TreeFragment.SetPosTransform(self.node.pos)(fragment.root) + UtilityCode.declare_declarations_in_scope( + decl_code.getvalue(), env.global_scope()) + ast.scope = env + # FIXME: for static methods of cdef classes, we build the wrong signature here: first arg becomes 'self' + ast.analyse_declarations(env) + py_func = ast.stats[-1] # the DefNode + self.fragment_scope = ast.scope + + if isinstance(self.node, DefNode): + py_func.specialized_cpdefs = self.nodes[:] + else: + py_func.specialized_cpdefs = [n.py_func for n in self.nodes] + + return py_func + + def update_fused_defnode_entry(self, env): + copy_attributes = ( + 'name', 'pos', 'cname', 'func_cname', 'pyfunc_cname', + 'pymethdef_cname', 'doc', 'doc_cname', 'is_member', + 'scope' + ) + + entry = self.py_func.entry + + for attr in copy_attributes: + setattr(entry, attr, + getattr(self.orig_py_func.entry, attr)) + + self.py_func.name = self.orig_py_func.name + self.py_func.doc = self.orig_py_func.doc + + env.entries.pop('__pyx_fused_cpdef', None) + if isinstance(self.node, DefNode): + env.entries[entry.name] = entry + else: + env.entries[entry.name].as_variable = entry + + env.pyfunc_entries.append(entry) + + self.py_func.entry.fused_cfunction = self + for node in self.nodes: + if isinstance(self.node, DefNode): + node.fused_py_func = self.py_func + else: + node.py_func.fused_py_func = self.py_func + node.entry.as_variable = entry + + self.synthesize_defnodes() + self.stats.append(self.__signatures__) + + def analyse_expressions(self, env): + """ + Analyse the expressions. Take care to only evaluate default arguments + once and clone the result for all specializations + """ + for fused_compound_type in self.fused_compound_types: + for fused_type in fused_compound_type.get_fused_types(): + for specialization_type in fused_type.types: + if specialization_type.is_complex: + specialization_type.create_declaration_utility_code(env) + + if self.py_func: + self.__signatures__ = self.__signatures__.analyse_expressions(env) + self.py_func = self.py_func.analyse_expressions(env) + self.resulting_fused_function = self.resulting_fused_function.analyse_expressions(env) + self.fused_func_assignment = self.fused_func_assignment.analyse_expressions(env) + + self.defaults = defaults = [] + + for arg in self.node.args: + if arg.default: + arg.default = arg.default.analyse_expressions(env) + defaults.append(ProxyNode(arg.default)) + else: + defaults.append(None) + + for i, stat in enumerate(self.stats): + stat = self.stats[i] = stat.analyse_expressions(env) + if isinstance(stat, FuncDefNode): + for arg, default in zip(stat.args, defaults): + if default is not None: + arg.default = CloneNode(default).coerce_to(arg.type, env) + + if self.py_func: + args = [CloneNode(default) for default in defaults if default] + self.defaults_tuple = TupleNode(self.pos, args=args) + self.defaults_tuple = self.defaults_tuple.analyse_types(env, skip_children=True).coerce_to_pyobject(env) + self.defaults_tuple = ProxyNode(self.defaults_tuple) + self.code_object = ProxyNode(self.specialized_pycfuncs[0].code_object) + + fused_func = self.resulting_fused_function.arg + fused_func.defaults_tuple = CloneNode(self.defaults_tuple) + fused_func.code_object = CloneNode(self.code_object) + + for i, pycfunc in enumerate(self.specialized_pycfuncs): + pycfunc.code_object = CloneNode(self.code_object) + pycfunc = self.specialized_pycfuncs[i] = pycfunc.analyse_types(env) + pycfunc.defaults_tuple = CloneNode(self.defaults_tuple) + return self + + def synthesize_defnodes(self): + """ + Create the __signatures__ dict of PyCFunctionNode specializations. + """ + if isinstance(self.nodes[0], CFuncDefNode): + nodes = [node.py_func for node in self.nodes] + else: + nodes = self.nodes + + signatures = [StringEncoding.EncodedString(node.specialized_signature_string) + for node in nodes] + keys = [ExprNodes.StringNode(node.pos, value=sig) + for node, sig in zip(nodes, signatures)] + values = [ExprNodes.PyCFunctionNode.from_defnode(node, binding=True) + for node in nodes] + + self.__signatures__ = ExprNodes.DictNode.from_pairs(self.pos, zip(keys, values)) + + self.specialized_pycfuncs = values + for pycfuncnode in values: + pycfuncnode.is_specialization = True + + def generate_function_definitions(self, env, code): + if self.py_func: + self.py_func.pymethdef_required = True + self.fused_func_assignment.generate_function_definitions(env, code) + + for stat in self.stats: + if isinstance(stat, FuncDefNode) and stat.entry.used: + code.mark_pos(stat.pos) + stat.generate_function_definitions(env, code) + + def generate_execution_code(self, code): + # Note: all def function specialization are wrapped in PyCFunction + # nodes in the self.__signatures__ dictnode. + for default in self.defaults: + if default is not None: + default.generate_evaluation_code(code) + + if self.py_func: + self.defaults_tuple.generate_evaluation_code(code) + self.code_object.generate_evaluation_code(code) + + for stat in self.stats: + code.mark_pos(stat.pos) + if isinstance(stat, ExprNodes.ExprNode): + stat.generate_evaluation_code(code) + else: + stat.generate_execution_code(code) + + if self.__signatures__: + self.resulting_fused_function.generate_evaluation_code(code) + + code.putln( + "((__pyx_FusedFunctionObject *) %s)->__signatures__ = %s;" % + (self.resulting_fused_function.result(), + self.__signatures__.result())) + code.put_giveref(self.__signatures__.result()) + self.__signatures__.generate_post_assignment_code(code) + self.__signatures__.free_temps(code) + + self.fused_func_assignment.generate_execution_code(code) + + # Dispose of results + self.resulting_fused_function.generate_disposal_code(code) + self.resulting_fused_function.free_temps(code) + self.defaults_tuple.generate_disposal_code(code) + self.defaults_tuple.free_temps(code) + self.code_object.generate_disposal_code(code) + self.code_object.free_temps(code) + + for default in self.defaults: + if default is not None: + default.generate_disposal_code(code) + default.free_temps(code) + + def annotate(self, code): + for stat in self.stats: + stat.annotate(code) diff --git a/contrib/tools/cython/Cython/Compiler/Future.py b/contrib/tools/cython/Cython/Compiler/Future.py new file mode 100644 index 00000000000..848792e00bf --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Future.py @@ -0,0 +1,15 @@ +def _get_feature(name): + import __future__ + # fall back to a unique fake object for earlier Python versions or Python 3 + return getattr(__future__, name, object()) + +unicode_literals = _get_feature("unicode_literals") +with_statement = _get_feature("with_statement") # dummy +division = _get_feature("division") +print_function = _get_feature("print_function") +absolute_import = _get_feature("absolute_import") +nested_scopes = _get_feature("nested_scopes") # dummy +generators = _get_feature("generators") # dummy +generator_stop = _get_feature("generator_stop") + +del _get_feature diff --git a/contrib/tools/cython/Cython/Compiler/Interpreter.py b/contrib/tools/cython/Cython/Compiler/Interpreter.py new file mode 100644 index 00000000000..9ec391f2a02 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Interpreter.py @@ -0,0 +1,64 @@ +""" +This module deals with interpreting the parse tree as Python +would have done, in the compiler. + +For now this only covers parse tree to value conversion of +compile-time values. +""" + +from __future__ import absolute_import + +from .Nodes import * +from .ExprNodes import * +from .Errors import CompileError + + +class EmptyScope(object): + def lookup(self, name): + return None + +empty_scope = EmptyScope() + +def interpret_compiletime_options(optlist, optdict, type_env=None, type_args=()): + """ + Tries to interpret a list of compile time option nodes. + The result will be a tuple (optlist, optdict) but where + all expression nodes have been interpreted. The result is + in the form of tuples (value, pos). + + optlist is a list of nodes, while optdict is a DictNode (the + result optdict is a dict) + + If type_env is set, all type nodes will be analysed and the resulting + type set. Otherwise only interpretateable ExprNodes + are allowed, other nodes raises errors. + + A CompileError will be raised if there are problems. + """ + + def interpret(node, ix): + if ix in type_args: + if type_env: + type = node.analyse_as_type(type_env) + if not type: + raise CompileError(node.pos, "Invalid type.") + return (type, node.pos) + else: + raise CompileError(node.pos, "Type not allowed here.") + else: + if (sys.version_info[0] >=3 and + isinstance(node, StringNode) and + node.unicode_value is not None): + return (node.unicode_value, node.pos) + return (node.compile_time_value(empty_scope), node.pos) + + if optlist: + optlist = [interpret(x, ix) for ix, x in enumerate(optlist)] + if optdict: + assert isinstance(optdict, DictNode) + new_optdict = {} + for item in optdict.key_value_pairs: + new_key, dummy = interpret(item.key, None) + new_optdict[new_key] = interpret(item.value, item.key.value) + optdict = new_optdict + return (optlist, new_optdict) diff --git a/contrib/tools/cython/Cython/Compiler/Lexicon.py b/contrib/tools/cython/Cython/Compiler/Lexicon.py new file mode 100644 index 00000000000..72c9ceaefd5 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Lexicon.py @@ -0,0 +1,138 @@ +# cython: language_level=3, py2_import=True +# +# Cython Scanner - Lexical Definitions +# + +from __future__ import absolute_import, unicode_literals + +raw_prefixes = "rR" +bytes_prefixes = "bB" +string_prefixes = "fFuU" + bytes_prefixes +char_prefixes = "cC" +any_string_prefix = raw_prefixes + string_prefixes + char_prefixes +IDENT = 'IDENT' + + +def make_lexicon(): + from ..Plex import \ + Str, Any, AnyBut, AnyChar, Rep, Rep1, Opt, Bol, Eol, Eof, \ + TEXT, IGNORE, State, Lexicon + from .Scanning import Method + + letter = Any("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_") + digit = Any("0123456789") + bindigit = Any("01") + octdigit = Any("01234567") + hexdigit = Any("0123456789ABCDEFabcdef") + indentation = Bol + Rep(Any(" \t")) + + def underscore_digits(d): + return Rep1(d) + Rep(Str("_") + Rep1(d)) + + decimal = underscore_digits(digit) + dot = Str(".") + exponent = Any("Ee") + Opt(Any("+-")) + decimal + decimal_fract = (decimal + dot + Opt(decimal)) | (dot + decimal) + + name = letter + Rep(letter | digit) + intconst = decimal | (Str("0") + ((Any("Xx") + underscore_digits(hexdigit)) | + (Any("Oo") + underscore_digits(octdigit)) | + (Any("Bb") + underscore_digits(bindigit)) )) + intsuffix = (Opt(Any("Uu")) + Opt(Any("Ll")) + Opt(Any("Ll"))) | (Opt(Any("Ll")) + Opt(Any("Ll")) + Opt(Any("Uu"))) + intliteral = intconst + intsuffix + fltconst = (decimal_fract + Opt(exponent)) | (decimal + exponent) + imagconst = (intconst | fltconst) + Any("jJ") + + # invalid combinations of prefixes are caught in p_string_literal + beginstring = Opt(Rep(Any(string_prefixes + raw_prefixes)) | + Any(char_prefixes) + ) + (Str("'") | Str('"') | Str("'''") | Str('"""')) + two_oct = octdigit + octdigit + three_oct = octdigit + octdigit + octdigit + two_hex = hexdigit + hexdigit + four_hex = two_hex + two_hex + escapeseq = Str("\\") + (two_oct | three_oct | + Str('N{') + Rep(AnyBut('}')) + Str('}') | + Str('u') + four_hex | Str('x') + two_hex | + Str('U') + four_hex + four_hex | AnyChar) + + bra = Any("([{") + ket = Any(")]}") + punct = Any(":,;+-*/|&<>=.%`~^?!@") + diphthong = Str("==", "<>", "!=", "<=", ">=", "<<", ">>", "**", "//", + "+=", "-=", "*=", "/=", "%=", "|=", "^=", "&=", + "<<=", ">>=", "**=", "//=", "->", "@=") + spaces = Rep1(Any(" \t\f")) + escaped_newline = Str("\\\n") + lineterm = Eol + Opt(Str("\n")) + + comment = Str("#") + Rep(AnyBut("\n")) + + return Lexicon([ + (name, IDENT), + (intliteral, Method('strip_underscores', symbol='INT')), + (fltconst, Method('strip_underscores', symbol='FLOAT')), + (imagconst, Method('strip_underscores', symbol='IMAG')), + (punct | diphthong, TEXT), + + (bra, Method('open_bracket_action')), + (ket, Method('close_bracket_action')), + (lineterm, Method('newline_action')), + + (beginstring, Method('begin_string_action')), + + (comment, IGNORE), + (spaces, IGNORE), + (escaped_newline, IGNORE), + + State('INDENT', [ + (comment + lineterm, Method('commentline')), + (Opt(spaces) + Opt(comment) + lineterm, IGNORE), + (indentation, Method('indentation_action')), + (Eof, Method('eof_action')) + ]), + + State('SQ_STRING', [ + (escapeseq, 'ESCAPE'), + (Rep1(AnyBut("'\"\n\\")), 'CHARS'), + (Str('"'), 'CHARS'), + (Str("\n"), Method('unclosed_string_action')), + (Str("'"), Method('end_string_action')), + (Eof, 'EOF') + ]), + + State('DQ_STRING', [ + (escapeseq, 'ESCAPE'), + (Rep1(AnyBut('"\n\\')), 'CHARS'), + (Str("'"), 'CHARS'), + (Str("\n"), Method('unclosed_string_action')), + (Str('"'), Method('end_string_action')), + (Eof, 'EOF') + ]), + + State('TSQ_STRING', [ + (escapeseq, 'ESCAPE'), + (Rep1(AnyBut("'\"\n\\")), 'CHARS'), + (Any("'\""), 'CHARS'), + (Str("\n"), 'NEWLINE'), + (Str("'''"), Method('end_string_action')), + (Eof, 'EOF') + ]), + + State('TDQ_STRING', [ + (escapeseq, 'ESCAPE'), + (Rep1(AnyBut('"\'\n\\')), 'CHARS'), + (Any("'\""), 'CHARS'), + (Str("\n"), 'NEWLINE'), + (Str('"""'), Method('end_string_action')), + (Eof, 'EOF') + ]), + + (Eof, Method('eof_action')) + ], + + # FIXME: Plex 1.9 needs different args here from Plex 1.1.4 + #debug_flags = scanner_debug_flags, + #debug_file = scanner_dump_file + ) + diff --git a/contrib/tools/cython/Cython/Compiler/Main.py b/contrib/tools/cython/Cython/Compiler/Main.py new file mode 100644 index 00000000000..3f03b66ac9e --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Main.py @@ -0,0 +1,920 @@ +# +# Cython Top Level +# + +from __future__ import absolute_import + +import os +import re +import sys +import io + +if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[:2] < (3, 3): + sys.stderr.write("Sorry, Cython requires Python 2.6+ or 3.3+, found %d.%d\n" % tuple(sys.version_info[:2])) + sys.exit(1) + +try: + from __builtin__ import basestring +except ImportError: + basestring = str + +# Do not import Parsing here, import it when needed, because Parsing imports +# Nodes, which globally needs debug command line options initialized to set a +# conditional metaclass. These options are processed by CmdLine called from +# main() in this file. +# import Parsing +from . import Errors +from .StringEncoding import EncodedString +from .Scanning import PyrexScanner, FileSourceDescriptor +from .Errors import PyrexError, CompileError, error, warning +from .Symtab import ModuleScope +from .. import Utils +from . import Options + +from . import Version # legacy import needed by old PyTables versions +version = Version.version # legacy attribute - use "Cython.__version__" instead + +module_name_pattern = re.compile(r"[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$") + +verbose = 0 + +standard_include_path = os.path.abspath(os.path.join(os.path.dirname(__file__), + os.path.pardir, 'Includes')) + +class CompilationData(object): + # Bundles the information that is passed from transform to transform. + # (For now, this is only) + + # While Context contains every pxd ever loaded, path information etc., + # this only contains the data related to a single compilation pass + # + # pyx ModuleNode Main code tree of this compilation. + # pxds {string : ModuleNode} Trees for the pxds used in the pyx. + # codewriter CCodeWriter Where to output final code. + # options CompilationOptions + # result CompilationResult + pass + + +class Context(object): + # This class encapsulates the context needed for compiling + # one or more Cython implementation files along with their + # associated and imported declaration files. It includes + # the root of the module import namespace and the list + # of directories to search for include files. + # + # modules {string : ModuleScope} + # include_directories [string] + # future_directives [object] + # language_level int currently 2 or 3 for Python 2/3 + + cython_scope = None + language_level = None # warn when not set but default to Py2 + + def __init__(self, include_directories, compiler_directives, cpp=False, + language_level=None, options=None): + # cython_scope is a hack, set to False by subclasses, in order to break + # an infinite loop. + # Better code organization would fix it. + + from . import Builtin, CythonScope + self.modules = {"__builtin__" : Builtin.builtin_scope} + self.cython_scope = CythonScope.create_cython_scope(self) + self.modules["cython"] = self.cython_scope + self.include_directories = include_directories + self.future_directives = set() + self.compiler_directives = compiler_directives + self.cpp = cpp + self.options = options + + self.pxds = {} # full name -> node tree + self._interned = {} # (type(value), value, *key_args) -> interned_value + + if language_level is not None: + self.set_language_level(language_level) + + self.gdb_debug_outputwriter = None + + def set_language_level(self, level): + from .Future import print_function, unicode_literals, absolute_import, division + future_directives = set() + if level == '3str': + level = 3 + else: + level = int(level) + if level >= 3: + future_directives.add(unicode_literals) + if level >= 3: + future_directives.update([print_function, absolute_import, division]) + self.language_level = level + self.future_directives = future_directives + if level >= 3: + self.modules['builtins'] = self.modules['__builtin__'] + + def intern_ustring(self, value, encoding=None): + key = (EncodedString, value, encoding) + try: + return self._interned[key] + except KeyError: + pass + value = EncodedString(value) + if encoding: + value.encoding = encoding + self._interned[key] = value + return value + + def intern_value(self, value, *key): + key = (type(value), value) + key + try: + return self._interned[key] + except KeyError: + pass + self._interned[key] = value + return value + + # pipeline creation functions can now be found in Pipeline.py + + def process_pxd(self, source_desc, scope, module_name): + from . import Pipeline + if isinstance(source_desc, FileSourceDescriptor) and source_desc._file_type == 'pyx': + source = CompilationSource(source_desc, module_name, os.getcwd()) + result_sink = create_default_resultobj(source, self.options) + pipeline = Pipeline.create_pyx_as_pxd_pipeline(self, result_sink) + result = Pipeline.run_pipeline(pipeline, source) + else: + pipeline = Pipeline.create_pxd_pipeline(self, scope, module_name) + result = Pipeline.run_pipeline(pipeline, source_desc) + return result + + def nonfatal_error(self, exc): + return Errors.report_error(exc) + + def find_module(self, module_name, relative_to=None, pos=None, need_pxd=1, + absolute_fallback=True): + # Finds and returns the module scope corresponding to + # the given relative or absolute module name. If this + # is the first time the module has been requested, finds + # the corresponding .pxd file and process it. + # If relative_to is not None, it must be a module scope, + # and the module will first be searched for relative to + # that module, provided its name is not a dotted name. + debug_find_module = 0 + if debug_find_module: + print("Context.find_module: module_name = %s, relative_to = %s, pos = %s, need_pxd = %s" % ( + module_name, relative_to, pos, need_pxd)) + + scope = None + pxd_pathname = None + if relative_to: + if module_name: + # from .module import ... + qualified_name = relative_to.qualify_name(module_name) + else: + # from . import ... + qualified_name = relative_to.qualified_name + scope = relative_to + relative_to = None + else: + qualified_name = module_name + + if not module_name_pattern.match(qualified_name): + raise CompileError(pos or (module_name, 0, 0), + "'%s' is not a valid module name" % module_name) + + if relative_to: + if debug_find_module: + print("...trying relative import") + scope = relative_to.lookup_submodule(module_name) + if not scope: + pxd_pathname = self.find_pxd_file(qualified_name, pos) + if pxd_pathname: + scope = relative_to.find_submodule(module_name) + if not scope: + if debug_find_module: + print("...trying absolute import") + if absolute_fallback: + qualified_name = module_name + scope = self + for name in qualified_name.split("."): + scope = scope.find_submodule(name) + + if debug_find_module: + print("...scope = %s" % scope) + if not scope.pxd_file_loaded: + if debug_find_module: + print("...pxd not loaded") + if not pxd_pathname: + if debug_find_module: + print("...looking for pxd file") + pxd_pathname = self.find_pxd_file(qualified_name, pos) + if debug_find_module: + print("......found %s" % pxd_pathname) + if not pxd_pathname and need_pxd: + # Set pxd_file_loaded such that we don't need to + # look for the non-existing pxd file next time. + scope.pxd_file_loaded = True + package_pathname = self.search_include_directories(qualified_name, ".py", pos) + if package_pathname and package_pathname.endswith('__init__.py'): + pass + else: + error(pos, "'%s.pxd' not found" % qualified_name.replace('.', os.sep)) + if pxd_pathname: + scope.pxd_file_loaded = True + try: + if debug_find_module: + print("Context.find_module: Parsing %s" % pxd_pathname) + rel_path = module_name.replace('.', os.sep) + os.path.splitext(pxd_pathname)[1] + if not pxd_pathname.endswith(rel_path): + rel_path = pxd_pathname # safety measure to prevent printing incorrect paths + if Options.source_root: + rel_path = os.path.relpath(pxd_pathname, Options.source_root) + source_desc = FileSourceDescriptor(pxd_pathname, rel_path) + err, result = self.process_pxd(source_desc, scope, qualified_name) + if err: + raise err + (pxd_codenodes, pxd_scope) = result + self.pxds[module_name] = (pxd_codenodes, pxd_scope) + except CompileError: + pass + return scope + + def find_pxd_file(self, qualified_name, pos, sys_path=False): + # Search include path (and sys.path if sys_path is True) for + # the .pxd file corresponding to the given fully-qualified + # module name. + # Will find either a dotted filename or a file in a + # package directory. If a source file position is given, + # the directory containing the source file is searched first + # for a dotted filename, and its containing package root + # directory is searched first for a non-dotted filename. + pxd = self.search_include_directories(qualified_name, ".pxd", pos, sys_path=sys_path) + if pxd is None: # XXX Keep this until Includes/Deprecated is removed + if (qualified_name.startswith('python') or + qualified_name in ('stdlib', 'stdio', 'stl')): + standard_include_path = os.path.abspath(os.path.normpath( + os.path.join(os.path.dirname(__file__), os.path.pardir, 'Includes'))) + deprecated_include_path = os.path.join(standard_include_path, 'Deprecated') + self.include_directories.append(deprecated_include_path) + try: + pxd = self.search_include_directories(qualified_name, ".pxd", pos) + finally: + self.include_directories.pop() + if pxd: + name = qualified_name + if name.startswith('python'): + warning(pos, "'%s' is deprecated, use 'cpython'" % name, 1) + elif name in ('stdlib', 'stdio'): + warning(pos, "'%s' is deprecated, use 'libc.%s'" % (name, name), 1) + elif name in ('stl'): + warning(pos, "'%s' is deprecated, use 'libcpp.*.*'" % name, 1) + if pxd is None and Options.cimport_from_pyx: + return self.find_pyx_file(qualified_name, pos) + return pxd + + def find_pyx_file(self, qualified_name, pos): + # Search include path for the .pyx file corresponding to the + # given fully-qualified module name, as for find_pxd_file(). + return self.search_include_directories(qualified_name, ".pyx", pos) + + def find_include_file(self, filename, pos): + # Search list of include directories for filename. + # Reports an error and returns None if not found. + path = self.search_include_directories(filename, "", pos, + include=True) + if not path: + error(pos, "'%s' not found" % filename) + return path + + def search_include_directories(self, qualified_name, suffix, pos, + include=False, sys_path=False): + include_dirs = self.include_directories + if sys_path: + include_dirs = include_dirs + sys.path + # include_dirs must be hashable for caching in @cached_function + include_dirs = tuple(include_dirs + [standard_include_path]) + return search_include_directories(include_dirs, qualified_name, + suffix, pos, include) + + def find_root_package_dir(self, file_path): + return Utils.find_root_package_dir(file_path) + + def check_package_dir(self, dir, package_names): + return Utils.check_package_dir(dir, tuple(package_names)) + + def c_file_out_of_date(self, source_path, output_path): + if not os.path.exists(output_path): + return 1 + c_time = Utils.modification_time(output_path) + if Utils.file_newer_than(source_path, c_time): + return 1 + pos = [source_path] + pxd_path = Utils.replace_suffix(source_path, ".pxd") + if os.path.exists(pxd_path) and Utils.file_newer_than(pxd_path, c_time): + return 1 + for kind, name in self.read_dependency_file(source_path): + if kind == "cimport": + dep_path = self.find_pxd_file(name, pos) + elif kind == "include": + dep_path = self.search_include_directories(name, pos) + else: + continue + if dep_path and Utils.file_newer_than(dep_path, c_time): + return 1 + return 0 + + def find_cimported_module_names(self, source_path): + return [ name for kind, name in self.read_dependency_file(source_path) + if kind == "cimport" ] + + def is_package_dir(self, dir_path): + return Utils.is_package_dir(dir_path) + + def read_dependency_file(self, source_path): + dep_path = Utils.replace_suffix(source_path, ".dep") + if os.path.exists(dep_path): + f = open(dep_path, "rU") + chunks = [ line.strip().split(" ", 1) + for line in f.readlines() + if " " in line.strip() ] + f.close() + return chunks + else: + return () + + def lookup_submodule(self, name): + # Look up a top-level module. Returns None if not found. + return self.modules.get(name, None) + + def find_submodule(self, name): + # Find a top-level module, creating a new one if needed. + scope = self.lookup_submodule(name) + if not scope: + scope = ModuleScope(name, + parent_module = None, context = self) + self.modules[name] = scope + return scope + + def parse(self, source_desc, scope, pxd, full_module_name): + if not isinstance(source_desc, FileSourceDescriptor): + raise RuntimeError("Only file sources for code supported") + source_filename = source_desc.filename + scope.cpp = self.cpp + # Parse the given source file and return a parse tree. + num_errors = Errors.num_errors + try: + with Utils.open_source_file(source_filename) as f: + from . import Parsing + s = PyrexScanner(f, source_desc, source_encoding = f.encoding, + scope = scope, context = self) + tree = Parsing.p_module(s, pxd, full_module_name) + if self.options.formal_grammar: + try: + from ..Parser import ConcreteSyntaxTree + except ImportError: + raise RuntimeError( + "Formal grammar can only be used with compiled Cython with an available pgen.") + ConcreteSyntaxTree.p_module(source_filename) + except UnicodeDecodeError as e: + #import traceback + #traceback.print_exc() + raise self._report_decode_error(source_desc, e) + + if Errors.num_errors > num_errors: + raise CompileError() + return tree + + def _report_decode_error(self, source_desc, exc): + msg = exc.args[-1] + position = exc.args[2] + encoding = exc.args[0] + + line = 1 + column = idx = 0 + with io.open(source_desc.filename, "r", encoding='iso8859-1', newline='') as f: + for line, data in enumerate(f, 1): + idx += len(data) + if idx >= position: + column = position - (idx - len(data)) + 1 + break + + return error((source_desc, line, column), + "Decoding error, missing or incorrect coding=<encoding-name> " + "at top of source (cannot decode with encoding %r: %s)" % (encoding, msg)) + + def extract_module_name(self, path, options): + # Find fully_qualified module name from the full pathname + # of a source file. + dir, filename = os.path.split(path) + module_name, _ = os.path.splitext(filename) + if "." in module_name: + return module_name + names = [module_name] + while self.is_package_dir(dir): + parent, package_name = os.path.split(dir) + if parent == dir: + break + names.append(package_name) + dir = parent + names.reverse() + return ".".join(names) + + def setup_errors(self, options, result): + Errors.reset() # clear any remaining error state + if options.use_listing_file: + path = result.listing_file = Utils.replace_suffix(result.main_source_file, ".lis") + else: + path = None + Errors.open_listing_file(path=path, + echo_to_stderr=options.errors_to_stderr) + + def teardown_errors(self, err, options, result): + source_desc = result.compilation_source.source_desc + if not isinstance(source_desc, FileSourceDescriptor): + raise RuntimeError("Only file sources for code supported") + Errors.close_listing_file() + result.num_errors = Errors.num_errors + if result.num_errors > 0: + err = True + if err and result.c_file: + try: + Utils.castrate_file(result.c_file, os.stat(source_desc.filename)) + except EnvironmentError: + pass + result.c_file = None + + +def get_output_filename(source_filename, cwd, options): + if options.cplus: + c_suffix = ".cpp" + else: + c_suffix = ".c" + suggested_file_name = Utils.replace_suffix(source_filename, c_suffix) + if options.output_file: + out_path = os.path.join(cwd, options.output_file) + if os.path.isdir(out_path): + return os.path.join(out_path, os.path.basename(suggested_file_name)) + else: + return out_path + else: + return suggested_file_name + + +def create_default_resultobj(compilation_source, options): + result = CompilationResult() + result.main_source_file = compilation_source.source_desc.filename + result.compilation_source = compilation_source + source_desc = compilation_source.source_desc + result.c_file = get_output_filename(source_desc.filename, + compilation_source.cwd, options) + result.embedded_metadata = options.embedded_metadata + return result + + +def run_pipeline(source, options, full_module_name=None, context=None): + from . import Pipeline + + source_ext = os.path.splitext(source)[1] + options.configure_language_defaults(source_ext[1:]) # py/pyx + if context is None: + context = options.create_context() + + # Set up source object + cwd = os.getcwd() + abs_path = os.path.abspath(source) + full_module_name = full_module_name or options.module_name or context.extract_module_name(source, options) + + Utils.raise_error_if_module_name_forbidden(full_module_name) + + if options.relative_path_in_code_position_comments: + rel_path = full_module_name.replace('.', os.sep) + source_ext + if not abs_path.endswith(rel_path): + rel_path = source # safety measure to prevent printing incorrect paths + else: + rel_path = abs_path + if Options.source_root: + rel_path = os.path.relpath(abs_path, Options.source_root) + source_desc = FileSourceDescriptor(abs_path, rel_path) + source = CompilationSource(source_desc, full_module_name, cwd) + + # Set up result object + result = create_default_resultobj(source, options) + + if options.annotate is None: + # By default, decide based on whether an html file already exists. + html_filename = os.path.splitext(result.c_file)[0] + ".html" + if os.path.exists(html_filename): + with io.open(html_filename, "r", encoding="UTF-8") as html_file: + if u'<!-- Generated by Cython' in html_file.read(100): + options.annotate = True + + # Get pipeline + if source_ext.lower() == '.py' or not source_ext: + pipeline = Pipeline.create_py_pipeline(context, options, result) + else: + pipeline = Pipeline.create_pyx_pipeline(context, options, result) + + context.setup_errors(options, result) + err, enddata = Pipeline.run_pipeline(pipeline, source) + context.teardown_errors(err, options, result) + if err is None and options.depfile: + from ..Build.Dependencies import create_dependency_tree + dependencies = create_dependency_tree(context).all_dependencies(result.main_source_file) + Utils.write_depfile(result.c_file, result.main_source_file, dependencies) + return result + + +# ------------------------------------------------------------------------ +# +# Main Python entry points +# +# ------------------------------------------------------------------------ + +class CompilationSource(object): + """ + Contains the data necessary to start up a compilation pipeline for + a single compilation unit. + """ + def __init__(self, source_desc, full_module_name, cwd): + self.source_desc = source_desc + self.full_module_name = full_module_name + self.cwd = cwd + + +class CompilationOptions(object): + r""" + See default_options at the end of this module for a list of all possible + options and CmdLine.usage and CmdLine.parse_command_line() for their + meaning. + """ + def __init__(self, defaults=None, **kw): + self.include_path = [] + if defaults: + if isinstance(defaults, CompilationOptions): + defaults = defaults.__dict__ + else: + defaults = default_options + + options = dict(defaults) + options.update(kw) + + # let's assume 'default_options' contains a value for most known compiler options + # and validate against them + unknown_options = set(options) - set(default_options) + # ignore valid options that are not in the defaults + unknown_options.difference_update(['include_path']) + if unknown_options: + message = "got unknown compilation option%s, please remove: %s" % ( + 's' if len(unknown_options) > 1 else '', + ', '.join(unknown_options)) + raise ValueError(message) + + directive_defaults = Options.get_directive_defaults() + directives = dict(options['compiler_directives']) # copy mutable field + # check for invalid directives + unknown_directives = set(directives) - set(directive_defaults) + if unknown_directives: + message = "got unknown compiler directive%s: %s" % ( + 's' if len(unknown_directives) > 1 else '', + ', '.join(unknown_directives)) + raise ValueError(message) + options['compiler_directives'] = directives + if directives.get('np_pythran', False) and not options['cplus']: + import warnings + warnings.warn("C++ mode forced when in Pythran mode!") + options['cplus'] = True + if 'language_level' in directives and 'language_level' not in kw: + options['language_level'] = directives['language_level'] + elif not options.get('language_level'): + options['language_level'] = directive_defaults.get('language_level') + if 'formal_grammar' in directives and 'formal_grammar' not in kw: + options['formal_grammar'] = directives['formal_grammar'] + if options['cache'] is True: + options['cache'] = os.path.join(Utils.get_cython_cache_dir(), 'compiler') + + self.__dict__.update(options) + + def configure_language_defaults(self, source_extension): + if source_extension == 'py': + if self.compiler_directives.get('binding') is None: + self.compiler_directives['binding'] = True + + def create_context(self): + return Context(self.include_path, self.compiler_directives, + self.cplus, self.language_level, options=self) + + def get_fingerprint(self): + r""" + Return a string that contains all the options that are relevant for cache invalidation. + """ + # Collect only the data that can affect the generated file(s). + data = {} + + for key, value in self.__dict__.items(): + if key in ['show_version', 'errors_to_stderr', 'verbose', 'quiet']: + # verbosity flags have no influence on the compilation result + continue + elif key in ['output_file', 'output_dir']: + # ignore the exact name of the output file + continue + elif key in ['timestamps']: + # the cache cares about the content of files, not about the timestamps of sources + continue + elif key in ['cache']: + # hopefully caching has no influence on the compilation result + continue + elif key in ['compiler_directives']: + # directives passed on to the C compiler do not influence the generated C code + continue + elif key in ['include_path']: + # this path changes which headers are tracked as dependencies, + # it has no influence on the generated C code + continue + elif key in ['working_path']: + # this path changes where modules and pxd files are found; + # their content is part of the fingerprint anyway, their + # absolute path does not matter + continue + elif key in ['create_extension']: + # create_extension() has already mangled the options, e.g., + # embedded_metadata, when the fingerprint is computed so we + # ignore it here. + continue + elif key in ['build_dir']: + # the (temporary) directory where we collect dependencies + # has no influence on the C output + continue + elif key in ['use_listing_file', 'generate_pxi', 'annotate', 'annotate_coverage_xml']: + # all output files are contained in the cache so the types of + # files generated must be part of the fingerprint + data[key] = value + elif key in ['formal_grammar', 'evaluate_tree_assertions']: + # these bits can change whether compilation to C passes/fails + data[key] = value + elif key in ['embedded_metadata', 'emit_linenums', 'c_line_in_traceback', 'gdb_debug', 'relative_path_in_code_position_comments']: + # the generated code contains additional bits when these are set + data[key] = value + elif key in ['cplus', 'language_level', 'compile_time_env', 'np_pythran']: + # assorted bits that, e.g., influence the parser + data[key] = value + elif key == ['capi_reexport_cincludes']: + if self.capi_reexport_cincludes: + # our caching implementation does not yet include fingerprints of all the header files + raise NotImplementedError('capi_reexport_cincludes is not compatible with Cython caching') + elif key == ['common_utility_include_dir']: + if self.common_utility_include_dir: + raise NotImplementedError('common_utility_include_dir is not compatible with Cython caching yet') + else: + # any unexpected option should go into the fingerprint; it's better + # to recompile than to return incorrect results from the cache. + data[key] = value + + def to_fingerprint(item): + r""" + Recursively turn item into a string, turning dicts into lists with + deterministic ordering. + """ + if isinstance(item, dict): + item = sorted([(repr(key), to_fingerprint(value)) for key, value in item.items()]) + return repr(item) + + return to_fingerprint(data) + + +class CompilationResult(object): + """ + Results from the Cython compiler: + + c_file string or None The generated C source file + h_file string or None The generated C header file + i_file string or None The generated .pxi file + api_file string or None The generated C API .h file + listing_file string or None File of error messages + object_file string or None Result of compiling the C file + extension_file string or None Result of linking the object file + num_errors integer Number of compilation errors + compilation_source CompilationSource + """ + + def __init__(self): + self.c_file = None + self.h_file = None + self.i_file = None + self.api_file = None + self.listing_file = None + self.object_file = None + self.extension_file = None + self.main_source_file = None + + +class CompilationResultSet(dict): + """ + Results from compiling multiple Pyrex source files. A mapping + from source file paths to CompilationResult instances. Also + has the following attributes: + + num_errors integer Total number of compilation errors + """ + + num_errors = 0 + + def add(self, source, result): + self[source] = result + self.num_errors += result.num_errors + + +def compile_single(source, options, full_module_name = None): + """ + compile_single(source, options, full_module_name) + + Compile the given Pyrex implementation file and return a CompilationResult. + Always compiles a single file; does not perform timestamp checking or + recursion. + """ + return run_pipeline(source, options, full_module_name) + + +def compile_multiple(sources, options): + """ + compile_multiple(sources, options) + + Compiles the given sequence of Pyrex implementation files and returns + a CompilationResultSet. Performs timestamp checking and/or recursion + if these are specified in the options. + """ + if options.module_name and len(sources) > 1: + raise RuntimeError('Full module name can only be set ' + 'for single source compilation') + # run_pipeline creates the context + # context = options.create_context() + sources = [os.path.abspath(source) for source in sources] + processed = set() + results = CompilationResultSet() + timestamps = options.timestamps + verbose = options.verbose + context = None + cwd = os.getcwd() + for source in sources: + if source not in processed: + if context is None: + context = options.create_context() + output_filename = get_output_filename(source, cwd, options) + out_of_date = context.c_file_out_of_date(source, output_filename) + if (not timestamps) or out_of_date: + if verbose: + sys.stderr.write("Compiling %s\n" % source) + result = run_pipeline(source, options, + full_module_name=options.module_name, + context=context) + results.add(source, result) + # Compiling multiple sources in one context doesn't quite + # work properly yet. + context = None + processed.add(source) + return results + + +def compile(source, options = None, full_module_name = None, **kwds): + """ + compile(source [, options], [, <option> = <value>]...) + + Compile one or more Pyrex implementation files, with optional timestamp + checking and recursing on dependencies. The source argument may be a string + or a sequence of strings. If it is a string and no recursion or timestamp + checking is requested, a CompilationResult is returned, otherwise a + CompilationResultSet is returned. + """ + options = CompilationOptions(defaults = options, **kwds) + if isinstance(source, basestring) and not options.timestamps: + return compile_single(source, options, full_module_name) + else: + return compile_multiple(source, options) + + +@Utils.cached_function +def search_include_directories(dirs, qualified_name, suffix, pos, include=False): + """ + Search the list of include directories for the given file name. + + If a source file position is given, first searches the directory + containing that file. Returns None if not found, but does not + report an error. + + The 'include' option will disable package dereferencing. + """ + + if pos: + file_desc = pos[0] + if not isinstance(file_desc, FileSourceDescriptor): + raise RuntimeError("Only file sources for code supported") + if include: + dirs = (os.path.dirname(file_desc.filename),) + dirs + else: + dirs = (Utils.find_root_package_dir(file_desc.filename),) + dirs + + dotted_filename = qualified_name + if suffix: + dotted_filename += suffix + + if not include: + names = qualified_name.split('.') + package_names = tuple(names[:-1]) + module_name = names[-1] + module_filename = module_name + suffix + package_filename = "__init__" + suffix + + for dirname in dirs: + path = os.path.join(dirname, dotted_filename) + if os.path.exists(path): + return path + + # Arcadia-specific lookup: search for packages in include paths, + # ignoring existence of __init__.py files as packages markers + # (they are not required by Arcadia build system) + if not include: + package_dir = os.path.join(dirname, *package_names) + path = os.path.join(package_dir, module_filename) + if os.path.exists(path): + return path + path = os.path.join(dirname, package_dir, module_name, + package_filename) + if os.path.exists(path): + return path + + return None + + +# ------------------------------------------------------------------------ +# +# Main command-line entry point +# +# ------------------------------------------------------------------------ + +def setuptools_main(): + return main(command_line = 1) + + +def main(command_line = 0): + args = sys.argv[1:] + any_failures = 0 + if command_line: + from .CmdLine import parse_command_line + options, sources = parse_command_line(args) + else: + options = CompilationOptions(default_options) + sources = args + + if options.show_version: + sys.stderr.write("Cython version %s\n" % version) + if options.working_path!="": + os.chdir(options.working_path) + try: + result = compile(sources, options) + if result.num_errors > 0: + any_failures = 1 + except (EnvironmentError, PyrexError) as e: + sys.stderr.write(str(e) + '\n') + any_failures = 1 + if any_failures: + sys.exit(1) + + +# ------------------------------------------------------------------------ +# +# Set the default options depending on the platform +# +# ------------------------------------------------------------------------ + +default_options = dict( + show_version = 0, + use_listing_file = 0, + errors_to_stderr = 1, + cplus = 0, + output_file = None, + depfile = None, + annotate = None, + annotate_coverage_xml = None, + generate_pxi = 0, + capi_reexport_cincludes = 0, + working_path = "", + timestamps = None, + verbose = 0, + quiet = 0, + compiler_directives = {}, + embedded_metadata = {}, + evaluate_tree_assertions = False, + emit_linenums = False, + relative_path_in_code_position_comments = True, + c_line_in_traceback = True, + language_level = None, # warn but default to 2 + formal_grammar = False, + gdb_debug = False, + init_suffix = None, + compile_time_env = None, + common_utility_include_dir = None, + output_dir=None, + build_dir=None, + cache=None, + create_extension=None, + module_name=None, + np_pythran=False +) diff --git a/contrib/tools/cython/Cython/Compiler/MemoryView.py b/contrib/tools/cython/Cython/Compiler/MemoryView.py new file mode 100644 index 00000000000..0406d6c716a --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/MemoryView.py @@ -0,0 +1,858 @@ +from __future__ import absolute_import + +from .Errors import CompileError, error +from . import ExprNodes +from .ExprNodes import IntNode, NameNode, AttributeNode +from . import Options +from .Code import UtilityCode, TempitaUtilityCode +from .UtilityCode import CythonUtilityCode +from . import Buffer +from . import PyrexTypes +from . import ModuleNode + +START_ERR = "Start must not be given." +STOP_ERR = "Axis specification only allowed in the 'step' slot." +STEP_ERR = "Step must be omitted, 1, or a valid specifier." +BOTH_CF_ERR = "Cannot specify an array that is both C and Fortran contiguous." +INVALID_ERR = "Invalid axis specification." +NOT_CIMPORTED_ERR = "Variable was not cimported from cython.view" +EXPR_ERR = "no expressions allowed in axis spec, only names and literals." +CF_ERR = "Invalid axis specification for a C/Fortran contiguous array." +ERR_UNINITIALIZED = ("Cannot check if memoryview %s is initialized without the " + "GIL, consider using initializedcheck(False)") + + +def concat_flags(*flags): + return "(%s)" % "|".join(flags) + + +format_flag = "PyBUF_FORMAT" + +memview_c_contiguous = "(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT)" +memview_f_contiguous = "(PyBUF_F_CONTIGUOUS | PyBUF_FORMAT)" +memview_any_contiguous = "(PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT)" +memview_full_access = "PyBUF_FULL_RO" +#memview_strided_access = "PyBUF_STRIDED_RO" +memview_strided_access = "PyBUF_RECORDS_RO" + +MEMVIEW_DIRECT = '__Pyx_MEMVIEW_DIRECT' +MEMVIEW_PTR = '__Pyx_MEMVIEW_PTR' +MEMVIEW_FULL = '__Pyx_MEMVIEW_FULL' +MEMVIEW_CONTIG = '__Pyx_MEMVIEW_CONTIG' +MEMVIEW_STRIDED= '__Pyx_MEMVIEW_STRIDED' +MEMVIEW_FOLLOW = '__Pyx_MEMVIEW_FOLLOW' + +_spec_to_const = { + 'direct' : MEMVIEW_DIRECT, + 'ptr' : MEMVIEW_PTR, + 'full' : MEMVIEW_FULL, + 'contig' : MEMVIEW_CONTIG, + 'strided': MEMVIEW_STRIDED, + 'follow' : MEMVIEW_FOLLOW, + } + +_spec_to_abbrev = { + 'direct' : 'd', + 'ptr' : 'p', + 'full' : 'f', + 'contig' : 'c', + 'strided' : 's', + 'follow' : '_', +} + +memslice_entry_init = "{ 0, 0, { 0 }, { 0 }, { 0 } }" + +memview_name = u'memoryview' +memview_typeptr_cname = '__pyx_memoryview_type' +memview_objstruct_cname = '__pyx_memoryview_obj' +memviewslice_cname = u'__Pyx_memviewslice' + + +def put_init_entry(mv_cname, code): + code.putln("%s.data = NULL;" % mv_cname) + code.putln("%s.memview = NULL;" % mv_cname) + + +#def axes_to_str(axes): +# return "".join([access[0].upper()+packing[0] for (access, packing) in axes]) + + +def put_acquire_memoryviewslice(lhs_cname, lhs_type, lhs_pos, rhs, code, + have_gil=False, first_assignment=True): + "We can avoid decreffing the lhs if we know it is the first assignment" + assert rhs.type.is_memoryviewslice + + pretty_rhs = rhs.result_in_temp() or rhs.is_simple() + if pretty_rhs: + rhstmp = rhs.result() + else: + rhstmp = code.funcstate.allocate_temp(lhs_type, manage_ref=False) + code.putln("%s = %s;" % (rhstmp, rhs.result_as(lhs_type))) + + # Allow uninitialized assignment + #code.putln(code.put_error_if_unbound(lhs_pos, rhs.entry)) + put_assign_to_memviewslice(lhs_cname, rhs, rhstmp, lhs_type, code, + have_gil=have_gil, first_assignment=first_assignment) + + if not pretty_rhs: + code.funcstate.release_temp(rhstmp) + + +def put_assign_to_memviewslice(lhs_cname, rhs, rhs_cname, memviewslicetype, code, + have_gil=False, first_assignment=False): + if not first_assignment: + code.put_xdecref_memoryviewslice(lhs_cname, have_gil=have_gil) + + if not rhs.result_in_temp(): + rhs.make_owned_memoryviewslice(code) + + code.putln("%s = %s;" % (lhs_cname, rhs_cname)) + + +def get_buf_flags(specs): + is_c_contig, is_f_contig = is_cf_contig(specs) + + if is_c_contig: + return memview_c_contiguous + elif is_f_contig: + return memview_f_contiguous + + access, packing = zip(*specs) + + if 'full' in access or 'ptr' in access: + return memview_full_access + else: + return memview_strided_access + + +def insert_newaxes(memoryviewtype, n): + axes = [('direct', 'strided')] * n + axes.extend(memoryviewtype.axes) + return PyrexTypes.MemoryViewSliceType(memoryviewtype.dtype, axes) + + +def broadcast_types(src, dst): + n = abs(src.ndim - dst.ndim) + if src.ndim < dst.ndim: + return insert_newaxes(src, n), dst + else: + return src, insert_newaxes(dst, n) + + +def valid_memslice_dtype(dtype, i=0): + """ + Return whether type dtype can be used as the base type of a + memoryview slice. + + We support structs, numeric types and objects + """ + if dtype.is_complex and dtype.real_type.is_int: + return False + + if dtype is PyrexTypes.c_bint_type: + return False + + if dtype.is_struct and dtype.kind == 'struct': + for member in dtype.scope.var_entries: + if not valid_memslice_dtype(member.type): + return False + + return True + + return ( + dtype.is_error or + # Pointers are not valid (yet) + # (dtype.is_ptr and valid_memslice_dtype(dtype.base_type)) or + (dtype.is_array and i < 8 and + valid_memslice_dtype(dtype.base_type, i + 1)) or + dtype.is_numeric or + dtype.is_pyobject or + dtype.is_fused or # accept this as it will be replaced by specializations later + (dtype.is_typedef and valid_memslice_dtype(dtype.typedef_base_type)) + ) + + +class MemoryViewSliceBufferEntry(Buffer.BufferEntry): + """ + May be used during code generation time to be queried for + shape/strides/suboffsets attributes, or to perform indexing or slicing. + """ + def __init__(self, entry): + self.entry = entry + self.type = entry.type + self.cname = entry.cname + + self.buf_ptr = "%s.data" % self.cname + + dtype = self.entry.type.dtype + self.buf_ptr_type = PyrexTypes.CPtrType(dtype) + self.init_attributes() + + def get_buf_suboffsetvars(self): + return self._for_all_ndim("%s.suboffsets[%d]") + + def get_buf_stridevars(self): + return self._for_all_ndim("%s.strides[%d]") + + def get_buf_shapevars(self): + return self._for_all_ndim("%s.shape[%d]") + + def generate_buffer_lookup_code(self, code, index_cnames): + axes = [(dim, index_cnames[dim], access, packing) + for dim, (access, packing) in enumerate(self.type.axes)] + return self._generate_buffer_lookup_code(code, axes) + + def _generate_buffer_lookup_code(self, code, axes, cast_result=True): + """ + Generate a single expression that indexes the memory view slice + in each dimension. + """ + bufp = self.buf_ptr + type_decl = self.type.dtype.empty_declaration_code() + + for dim, index, access, packing in axes: + shape = "%s.shape[%d]" % (self.cname, dim) + stride = "%s.strides[%d]" % (self.cname, dim) + suboffset = "%s.suboffsets[%d]" % (self.cname, dim) + + flag = get_memoryview_flag(access, packing) + + if flag in ("generic", "generic_contiguous"): + # Note: we cannot do cast tricks to avoid stride multiplication + # for generic_contiguous, as we may have to do (dtype *) + # or (dtype **) arithmetic, we won't know which unless + # we check suboffsets + code.globalstate.use_utility_code(memviewslice_index_helpers) + bufp = ('__pyx_memviewslice_index_full(%s, %s, %s, %s)' % + (bufp, index, stride, suboffset)) + + elif flag == "indirect": + bufp = "(%s + %s * %s)" % (bufp, index, stride) + bufp = ("(*((char **) %s) + %s)" % (bufp, suboffset)) + + elif flag == "indirect_contiguous": + # Note: we do char ** arithmetic + bufp = "(*((char **) %s + %s) + %s)" % (bufp, index, suboffset) + + elif flag == "strided": + bufp = "(%s + %s * %s)" % (bufp, index, stride) + + else: + assert flag == 'contiguous', flag + bufp = '((char *) (((%s *) %s) + %s))' % (type_decl, bufp, index) + + bufp = '( /* dim=%d */ %s )' % (dim, bufp) + + if cast_result: + return "((%s *) %s)" % (type_decl, bufp) + + return bufp + + def generate_buffer_slice_code(self, code, indices, dst, have_gil, + have_slices, directives): + """ + Slice a memoryviewslice. + + indices - list of index nodes. If not a SliceNode, or NoneNode, + then it must be coercible to Py_ssize_t + + Simply call __pyx_memoryview_slice_memviewslice with the right + arguments, unless the dimension is omitted or a bare ':', in which + case we copy over the shape/strides/suboffsets attributes directly + for that dimension. + """ + src = self.cname + + code.putln("%(dst)s.data = %(src)s.data;" % locals()) + code.putln("%(dst)s.memview = %(src)s.memview;" % locals()) + code.put_incref_memoryviewslice(dst) + + all_dimensions_direct = all(access == 'direct' for access, packing in self.type.axes) + suboffset_dim_temp = [] + + def get_suboffset_dim(): + # create global temp variable at request + if not suboffset_dim_temp: + suboffset_dim = code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) + code.putln("%s = -1;" % suboffset_dim) + suboffset_dim_temp.append(suboffset_dim) + return suboffset_dim_temp[0] + + dim = -1 + new_ndim = 0 + for index in indices: + if index.is_none: + # newaxis + for attrib, value in [('shape', 1), ('strides', 0), ('suboffsets', -1)]: + code.putln("%s.%s[%d] = %d;" % (dst, attrib, new_ndim, value)) + + new_ndim += 1 + continue + + dim += 1 + access, packing = self.type.axes[dim] + + if isinstance(index, ExprNodes.SliceNode): + # slice, unspecified dimension, or part of ellipsis + d = dict(locals()) + for s in "start stop step".split(): + idx = getattr(index, s) + have_idx = d['have_' + s] = not idx.is_none + d[s] = idx.result() if have_idx else "0" + + if not (d['have_start'] or d['have_stop'] or d['have_step']): + # full slice (:), simply copy over the extent, stride + # and suboffset. Also update suboffset_dim if needed + d['access'] = access + util_name = "SimpleSlice" + else: + util_name = "ToughSlice" + d['error_goto'] = code.error_goto(index.pos) + + new_ndim += 1 + else: + # normal index + idx = index.result() + + indirect = access != 'direct' + if indirect: + generic = access == 'full' + if new_ndim != 0: + return error(index.pos, + "All preceding dimensions must be " + "indexed and not sliced") + + d = dict( + locals(), + wraparound=int(directives['wraparound']), + boundscheck=int(directives['boundscheck']), + ) + if d['boundscheck']: + d['error_goto'] = code.error_goto(index.pos) + util_name = "SliceIndex" + + _, impl = TempitaUtilityCode.load_as_string(util_name, "MemoryView_C.c", context=d) + code.put(impl) + + if suboffset_dim_temp: + code.funcstate.release_temp(suboffset_dim_temp[0]) + + +def empty_slice(pos): + none = ExprNodes.NoneNode(pos) + return ExprNodes.SliceNode(pos, start=none, + stop=none, step=none) + + +def unellipsify(indices, ndim): + result = [] + seen_ellipsis = False + have_slices = False + + newaxes = [newaxis for newaxis in indices if newaxis.is_none] + n_indices = len(indices) - len(newaxes) + + for index in indices: + if isinstance(index, ExprNodes.EllipsisNode): + have_slices = True + full_slice = empty_slice(index.pos) + + if seen_ellipsis: + result.append(full_slice) + else: + nslices = ndim - n_indices + 1 + result.extend([full_slice] * nslices) + seen_ellipsis = True + else: + have_slices = have_slices or index.is_slice or index.is_none + result.append(index) + + result_length = len(result) - len(newaxes) + if result_length < ndim: + have_slices = True + nslices = ndim - result_length + result.extend([empty_slice(indices[-1].pos)] * nslices) + + return have_slices, result, newaxes + + +def get_memoryview_flag(access, packing): + if access == 'full' and packing in ('strided', 'follow'): + return 'generic' + elif access == 'full' and packing == 'contig': + return 'generic_contiguous' + elif access == 'ptr' and packing in ('strided', 'follow'): + return 'indirect' + elif access == 'ptr' and packing == 'contig': + return 'indirect_contiguous' + elif access == 'direct' and packing in ('strided', 'follow'): + return 'strided' + else: + assert (access, packing) == ('direct', 'contig'), (access, packing) + return 'contiguous' + + +def get_is_contig_func_name(contig_type, ndim): + assert contig_type in ('C', 'F') + return "__pyx_memviewslice_is_contig_%s%d" % (contig_type, ndim) + + +def get_is_contig_utility(contig_type, ndim): + assert contig_type in ('C', 'F') + C = dict(context, ndim=ndim, contig_type=contig_type) + utility = load_memview_c_utility("MemviewSliceCheckContig", C, requires=[is_contig_utility]) + return utility + + +def slice_iter(slice_type, slice_result, ndim, code): + if slice_type.is_c_contig or slice_type.is_f_contig: + return ContigSliceIter(slice_type, slice_result, ndim, code) + else: + return StridedSliceIter(slice_type, slice_result, ndim, code) + + +class SliceIter(object): + def __init__(self, slice_type, slice_result, ndim, code): + self.slice_type = slice_type + self.slice_result = slice_result + self.code = code + self.ndim = ndim + + +class ContigSliceIter(SliceIter): + def start_loops(self): + code = self.code + code.begin_block() + + type_decl = self.slice_type.dtype.empty_declaration_code() + + total_size = ' * '.join("%s.shape[%d]" % (self.slice_result, i) + for i in range(self.ndim)) + code.putln("Py_ssize_t __pyx_temp_extent = %s;" % total_size) + code.putln("Py_ssize_t __pyx_temp_idx;") + code.putln("%s *__pyx_temp_pointer = (%s *) %s.data;" % ( + type_decl, type_decl, self.slice_result)) + code.putln("for (__pyx_temp_idx = 0; " + "__pyx_temp_idx < __pyx_temp_extent; " + "__pyx_temp_idx++) {") + + return "__pyx_temp_pointer" + + def end_loops(self): + self.code.putln("__pyx_temp_pointer += 1;") + self.code.putln("}") + self.code.end_block() + + +class StridedSliceIter(SliceIter): + def start_loops(self): + code = self.code + code.begin_block() + + for i in range(self.ndim): + t = i, self.slice_result, i + code.putln("Py_ssize_t __pyx_temp_extent_%d = %s.shape[%d];" % t) + code.putln("Py_ssize_t __pyx_temp_stride_%d = %s.strides[%d];" % t) + code.putln("char *__pyx_temp_pointer_%d;" % i) + code.putln("Py_ssize_t __pyx_temp_idx_%d;" % i) + + code.putln("__pyx_temp_pointer_0 = %s.data;" % self.slice_result) + + for i in range(self.ndim): + if i > 0: + code.putln("__pyx_temp_pointer_%d = __pyx_temp_pointer_%d;" % (i, i - 1)) + + code.putln("for (__pyx_temp_idx_%d = 0; " + "__pyx_temp_idx_%d < __pyx_temp_extent_%d; " + "__pyx_temp_idx_%d++) {" % (i, i, i, i)) + + return "__pyx_temp_pointer_%d" % (self.ndim - 1) + + def end_loops(self): + code = self.code + for i in range(self.ndim - 1, -1, -1): + code.putln("__pyx_temp_pointer_%d += __pyx_temp_stride_%d;" % (i, i)) + code.putln("}") + + code.end_block() + + +def copy_c_or_fortran_cname(memview): + if memview.is_c_contig: + c_or_f = 'c' + else: + c_or_f = 'f' + + return "__pyx_memoryview_copy_slice_%s_%s" % ( + memview.specialization_suffix(), c_or_f) + + +def get_copy_new_utility(pos, from_memview, to_memview): + if (from_memview.dtype != to_memview.dtype and + not (from_memview.dtype.is_const and from_memview.dtype.const_base_type == to_memview.dtype)): + error(pos, "dtypes must be the same!") + return + if len(from_memview.axes) != len(to_memview.axes): + error(pos, "number of dimensions must be same") + return + if not (to_memview.is_c_contig or to_memview.is_f_contig): + error(pos, "to_memview must be c or f contiguous.") + return + + for (access, packing) in from_memview.axes: + if access != 'direct': + error(pos, "cannot handle 'full' or 'ptr' access at this time.") + return + + if to_memview.is_c_contig: + mode = 'c' + contig_flag = memview_c_contiguous + elif to_memview.is_f_contig: + mode = 'fortran' + contig_flag = memview_f_contiguous + + return load_memview_c_utility( + "CopyContentsUtility", + context=dict( + context, + mode=mode, + dtype_decl=to_memview.dtype.empty_declaration_code(), + contig_flag=contig_flag, + ndim=to_memview.ndim, + func_cname=copy_c_or_fortran_cname(to_memview), + dtype_is_object=int(to_memview.dtype.is_pyobject)), + requires=[copy_contents_new_utility]) + + +def get_axes_specs(env, axes): + ''' + get_axes_specs(env, axes) -> list of (access, packing) specs for each axis. + access is one of 'full', 'ptr' or 'direct' + packing is one of 'contig', 'strided' or 'follow' + ''' + + cythonscope = env.global_scope().context.cython_scope + cythonscope.load_cythonscope() + viewscope = cythonscope.viewscope + + access_specs = tuple([viewscope.lookup(name) + for name in ('full', 'direct', 'ptr')]) + packing_specs = tuple([viewscope.lookup(name) + for name in ('contig', 'strided', 'follow')]) + + is_f_contig, is_c_contig = False, False + default_access, default_packing = 'direct', 'strided' + cf_access, cf_packing = default_access, 'follow' + + axes_specs = [] + # analyse all axes. + for idx, axis in enumerate(axes): + if not axis.start.is_none: + raise CompileError(axis.start.pos, START_ERR) + + if not axis.stop.is_none: + raise CompileError(axis.stop.pos, STOP_ERR) + + if axis.step.is_none: + axes_specs.append((default_access, default_packing)) + + elif isinstance(axis.step, IntNode): + # the packing for the ::1 axis is contiguous, + # all others are cf_packing. + if axis.step.compile_time_value(env) != 1: + raise CompileError(axis.step.pos, STEP_ERR) + + axes_specs.append((cf_access, 'cfcontig')) + + elif isinstance(axis.step, (NameNode, AttributeNode)): + entry = _get_resolved_spec(env, axis.step) + if entry.name in view_constant_to_access_packing: + axes_specs.append(view_constant_to_access_packing[entry.name]) + else: + raise CompileError(axis.step.pos, INVALID_ERR) + + else: + raise CompileError(axis.step.pos, INVALID_ERR) + + # First, find out if we have a ::1 somewhere + contig_dim = 0 + is_contig = False + for idx, (access, packing) in enumerate(axes_specs): + if packing == 'cfcontig': + if is_contig: + raise CompileError(axis.step.pos, BOTH_CF_ERR) + + contig_dim = idx + axes_specs[idx] = (access, 'contig') + is_contig = True + + if is_contig: + # We have a ::1 somewhere, see if we're C or Fortran contiguous + if contig_dim == len(axes) - 1: + is_c_contig = True + else: + is_f_contig = True + + if contig_dim and not axes_specs[contig_dim - 1][0] in ('full', 'ptr'): + raise CompileError(axes[contig_dim].pos, + "Fortran contiguous specifier must follow an indirect dimension") + + if is_c_contig: + # Contiguous in the last dimension, find the last indirect dimension + contig_dim = -1 + for idx, (access, packing) in enumerate(reversed(axes_specs)): + if access in ('ptr', 'full'): + contig_dim = len(axes) - idx - 1 + + # Replace 'strided' with 'follow' for any dimension following the last + # indirect dimension, the first dimension or the dimension following + # the ::1. + # int[::indirect, ::1, :, :] + # ^ ^ + # int[::indirect, :, :, ::1] + # ^ ^ + start = contig_dim + 1 + stop = len(axes) - is_c_contig + for idx, (access, packing) in enumerate(axes_specs[start:stop]): + idx = contig_dim + 1 + idx + if access != 'direct': + raise CompileError(axes[idx].pos, + "Indirect dimension may not follow " + "Fortran contiguous dimension") + if packing == 'contig': + raise CompileError(axes[idx].pos, + "Dimension may not be contiguous") + axes_specs[idx] = (access, cf_packing) + + if is_c_contig: + # For C contiguity, we need to fix the 'contig' dimension + # after the loop + a, p = axes_specs[-1] + axes_specs[-1] = a, 'contig' + + validate_axes_specs([axis.start.pos for axis in axes], + axes_specs, + is_c_contig, + is_f_contig) + + return axes_specs + + +def validate_axes(pos, axes): + if len(axes) >= Options.buffer_max_dims: + error(pos, "More dimensions than the maximum number" + " of buffer dimensions were used.") + return False + + return True + + +def is_cf_contig(specs): + is_c_contig = is_f_contig = False + + if len(specs) == 1 and specs == [('direct', 'contig')]: + is_c_contig = True + + elif (specs[-1] == ('direct','contig') and + all(axis == ('direct','follow') for axis in specs[:-1])): + # c_contiguous: 'follow', 'follow', ..., 'follow', 'contig' + is_c_contig = True + + elif (len(specs) > 1 and + specs[0] == ('direct','contig') and + all(axis == ('direct','follow') for axis in specs[1:])): + # f_contiguous: 'contig', 'follow', 'follow', ..., 'follow' + is_f_contig = True + + return is_c_contig, is_f_contig + + +def get_mode(specs): + is_c_contig, is_f_contig = is_cf_contig(specs) + + if is_c_contig: + return 'c' + elif is_f_contig: + return 'fortran' + + for access, packing in specs: + if access in ('ptr', 'full'): + return 'full' + + return 'strided' + +view_constant_to_access_packing = { + 'generic': ('full', 'strided'), + 'strided': ('direct', 'strided'), + 'indirect': ('ptr', 'strided'), + 'generic_contiguous': ('full', 'contig'), + 'contiguous': ('direct', 'contig'), + 'indirect_contiguous': ('ptr', 'contig'), +} + +def validate_axes_specs(positions, specs, is_c_contig, is_f_contig): + + packing_specs = ('contig', 'strided', 'follow') + access_specs = ('direct', 'ptr', 'full') + + # is_c_contig, is_f_contig = is_cf_contig(specs) + + has_contig = has_follow = has_strided = has_generic_contig = False + + last_indirect_dimension = -1 + for idx, (access, packing) in enumerate(specs): + if access == 'ptr': + last_indirect_dimension = idx + + for idx, (pos, (access, packing)) in enumerate(zip(positions, specs)): + + if not (access in access_specs and + packing in packing_specs): + raise CompileError(pos, "Invalid axes specification.") + + if packing == 'strided': + has_strided = True + elif packing == 'contig': + if has_contig: + raise CompileError(pos, "Only one direct contiguous " + "axis may be specified.") + + valid_contig_dims = last_indirect_dimension + 1, len(specs) - 1 + if idx not in valid_contig_dims and access != 'ptr': + if last_indirect_dimension + 1 != len(specs) - 1: + dims = "dimensions %d and %d" % valid_contig_dims + else: + dims = "dimension %d" % valid_contig_dims[0] + + raise CompileError(pos, "Only %s may be contiguous and direct" % dims) + + has_contig = access != 'ptr' + elif packing == 'follow': + if has_strided: + raise CompileError(pos, "A memoryview cannot have both follow and strided axis specifiers.") + if not (is_c_contig or is_f_contig): + raise CompileError(pos, "Invalid use of the follow specifier.") + + if access in ('ptr', 'full'): + has_strided = False + +def _get_resolved_spec(env, spec): + # spec must be a NameNode or an AttributeNode + if isinstance(spec, NameNode): + return _resolve_NameNode(env, spec) + elif isinstance(spec, AttributeNode): + return _resolve_AttributeNode(env, spec) + else: + raise CompileError(spec.pos, INVALID_ERR) + +def _resolve_NameNode(env, node): + try: + resolved_name = env.lookup(node.name).name + except AttributeError: + raise CompileError(node.pos, INVALID_ERR) + + viewscope = env.global_scope().context.cython_scope.viewscope + entry = viewscope.lookup(resolved_name) + if entry is None: + raise CompileError(node.pos, NOT_CIMPORTED_ERR) + + return entry + +def _resolve_AttributeNode(env, node): + path = [] + while isinstance(node, AttributeNode): + path.insert(0, node.attribute) + node = node.obj + if isinstance(node, NameNode): + path.insert(0, node.name) + else: + raise CompileError(node.pos, EXPR_ERR) + modnames = path[:-1] + # must be at least 1 module name, o/w not an AttributeNode. + assert modnames + + scope = env + for modname in modnames: + mod = scope.lookup(modname) + if not mod or not mod.as_module: + raise CompileError( + node.pos, "undeclared name not builtin: %s" % modname) + scope = mod.as_module + + entry = scope.lookup(path[-1]) + if not entry: + raise CompileError(node.pos, "No such attribute '%s'" % path[-1]) + + return entry + +# +### Utility loading +# + +def load_memview_cy_utility(util_code_name, context=None, **kwargs): + return CythonUtilityCode.load(util_code_name, "MemoryView.pyx", + context=context, **kwargs) + +def load_memview_c_utility(util_code_name, context=None, **kwargs): + if context is None: + return UtilityCode.load(util_code_name, "MemoryView_C.c", **kwargs) + else: + return TempitaUtilityCode.load(util_code_name, "MemoryView_C.c", + context=context, **kwargs) + +def use_cython_array_utility_code(env): + cython_scope = env.global_scope().context.cython_scope + cython_scope.load_cythonscope() + cython_scope.viewscope.lookup('array_cwrapper').used = True + +context = { + 'memview_struct_name': memview_objstruct_cname, + 'max_dims': Options.buffer_max_dims, + 'memviewslice_name': memviewslice_cname, + 'memslice_init': memslice_entry_init, +} +memviewslice_declare_code = load_memview_c_utility( + "MemviewSliceStruct", + context=context, + requires=[]) + +atomic_utility = load_memview_c_utility("Atomics", context) + +memviewslice_init_code = load_memview_c_utility( + "MemviewSliceInit", + context=dict(context, BUF_MAX_NDIMS=Options.buffer_max_dims), + requires=[memviewslice_declare_code, + atomic_utility], +) + +memviewslice_index_helpers = load_memview_c_utility("MemviewSliceIndex") + +typeinfo_to_format_code = load_memview_cy_utility( + "BufferFormatFromTypeInfo", requires=[Buffer._typeinfo_to_format_code]) + +is_contig_utility = load_memview_c_utility("MemviewSliceIsContig", context) +overlapping_utility = load_memview_c_utility("OverlappingSlices", context) +copy_contents_new_utility = load_memview_c_utility( + "MemviewSliceCopyTemplate", + context, + requires=[], # require cython_array_utility_code +) + +view_utility_code = load_memview_cy_utility( + "View.MemoryView", + context=context, + requires=[Buffer.GetAndReleaseBufferUtilityCode(), + Buffer.buffer_struct_declare_code, + Buffer.buffer_formats_declare_code, + memviewslice_init_code, + is_contig_utility, + overlapping_utility, + copy_contents_new_utility, + ModuleNode.capsule_utility_code], +) +view_utility_whitelist = ('array', 'memoryview', 'array_cwrapper', + 'generic', 'strided', 'indirect', 'contiguous', + 'indirect_contiguous') + +memviewslice_declare_code.requires.append(view_utility_code) +copy_contents_new_utility.requires.append(view_utility_code) diff --git a/contrib/tools/cython/Cython/Compiler/ModuleNode.py b/contrib/tools/cython/Cython/Compiler/ModuleNode.py new file mode 100644 index 00000000000..a9b1a492c4c --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/ModuleNode.py @@ -0,0 +1,3223 @@ +# +# Module parse tree node +# + +from __future__ import absolute_import + +import cython +cython.declare(Naming=object, Options=object, PyrexTypes=object, TypeSlots=object, + error=object, warning=object, py_object_type=object, UtilityCode=object, + EncodedString=object, re=object) + +from collections import defaultdict +import json +import operator +import os +import re + +from .PyrexTypes import CPtrType +from . import Future +from . import Annotate +from . import Code +from . import Naming +from . import Nodes +from . import Options +from . import TypeSlots +from . import PyrexTypes +from . import Pythran + +from .Errors import error, warning +from .PyrexTypes import py_object_type +from ..Utils import open_new_file, replace_suffix, decode_filename, build_hex_version +from .Code import UtilityCode, IncludeCode +from .StringEncoding import EncodedString +from .Pythran import has_np_pythran + +def check_c_declarations_pxd(module_node): + module_node.scope.check_c_classes_pxd() + return module_node + + +def check_c_declarations(module_node): + module_node.scope.check_c_classes() + module_node.scope.check_c_functions() + return module_node + + +def generate_c_code_config(env, options): + if Options.annotate or options.annotate: + emit_linenums = False + else: + emit_linenums = options.emit_linenums + + return Code.CCodeConfig( + emit_linenums=emit_linenums, + emit_code_comments=env.directives['emit_code_comments'], + c_line_in_traceback=options.c_line_in_traceback) + + +class ModuleNode(Nodes.Node, Nodes.BlockNode): + # doc string or None + # body StatListNode + # + # referenced_modules [ModuleScope] + # full_module_name string + # + # scope The module scope. + # compilation_source A CompilationSource (see Main) + # directives Top-level compiler directives + + child_attrs = ["body"] + directives = None + + def merge_in(self, tree, scope, merge_scope=False): + # Merges in the contents of another tree, and possibly scope. With the + # current implementation below, this must be done right prior + # to code generation. + # + # Note: This way of doing it seems strange -- I believe the + # right concept is to split ModuleNode into a ModuleNode and a + # CodeGenerator, and tell that CodeGenerator to generate code + # from multiple sources. + assert isinstance(self.body, Nodes.StatListNode) + if isinstance(tree, Nodes.StatListNode): + self.body.stats.extend(tree.stats) + else: + self.body.stats.append(tree) + + self.scope.utility_code_list.extend(scope.utility_code_list) + + for inc in scope.c_includes.values(): + self.scope.process_include(inc) + + def extend_if_not_in(L1, L2): + for x in L2: + if x not in L1: + L1.append(x) + + extend_if_not_in(self.scope.included_files, scope.included_files) + + if merge_scope: + # Ensure that we don't generate import code for these entries! + for entry in scope.c_class_entries: + entry.type.module_name = self.full_module_name + entry.type.scope.directives["internal"] = True + + self.scope.merge_in(scope) + + def analyse_declarations(self, env): + if has_np_pythran(env): + Pythran.include_pythran_generic(env) + if self.directives: + env.old_style_globals = self.directives['old_style_globals'] + if not Options.docstrings: + env.doc = self.doc = None + elif Options.embed_pos_in_docstring: + env.doc = EncodedString(u'File: %s (starting at line %s)' % Nodes.relative_position(self.pos)) + if self.doc is not None: + env.doc = EncodedString(env.doc + u'\n' + self.doc) + env.doc.encoding = self.doc.encoding + else: + env.doc = self.doc + env.directives = self.directives + + self.body.analyse_declarations(env) + + def prepare_utility_code(self): + # prepare any utility code that must be created before code generation + # specifically: CythonUtilityCode + env = self.scope + if env.has_import_star: + self.create_import_star_conversion_utility_code(env) + for name, entry in sorted(env.entries.items()): + if (entry.create_wrapper and entry.scope is env + and entry.is_type and entry.type.is_enum): + entry.type.create_type_wrapper(env) + + def process_implementation(self, options, result): + env = self.scope + env.return_type = PyrexTypes.c_void_type + self.referenced_modules = [] + self.find_referenced_modules(env, self.referenced_modules, {}) + self.sort_cdef_classes(env) + self.generate_c_code(env, options, result) + self.generate_h_code(env, options, result) + self.generate_api_code(env, options, result) + + def has_imported_c_functions(self): + for module in self.referenced_modules: + for entry in module.cfunc_entries: + if entry.defined_in_pxd: + return 1 + return 0 + + def generate_h_code(self, env, options, result): + def h_entries(entries, api=0, pxd=0): + return [entry for entry in entries + if ((entry.visibility == 'public') or + (api and entry.api) or + (pxd and entry.defined_in_pxd))] + h_types = h_entries(env.type_entries, api=1) + h_vars = h_entries(env.var_entries) + h_funcs = h_entries(env.cfunc_entries) + h_extension_types = h_entries(env.c_class_entries) + if h_types or h_vars or h_funcs or h_extension_types: + result.h_file = replace_suffix(result.c_file, ".h") + h_code = Code.CCodeWriter() + c_code_config = generate_c_code_config(env, options) + Code.GlobalState(h_code, self, c_code_config) + if options.generate_pxi: + result.i_file = replace_suffix(result.c_file, ".pxi") + i_code = Code.PyrexCodeWriter(result.i_file) + else: + i_code = None + + h_code.put_generated_by() + h_guard = Naming.h_guard_prefix + self.api_name(env) + h_code.put_h_guard(h_guard) + h_code.putln("") + h_code.putln('#include "Python.h"') + self.generate_type_header_code(h_types, h_code) + if options.capi_reexport_cincludes: + self.generate_includes(env, [], h_code) + h_code.putln("") + api_guard = Naming.api_guard_prefix + self.api_name(env) + h_code.putln("#ifndef %s" % api_guard) + h_code.putln("") + self.generate_extern_c_macro_definition(h_code) + h_code.putln("") + self.generate_dl_import_macro(h_code) + if h_extension_types: + h_code.putln("") + for entry in h_extension_types: + self.generate_cclass_header_code(entry.type, h_code) + if i_code: + self.generate_cclass_include_code(entry.type, i_code) + if h_funcs: + h_code.putln("") + for entry in h_funcs: + self.generate_public_declaration(entry, h_code, i_code) + if h_vars: + h_code.putln("") + for entry in h_vars: + self.generate_public_declaration(entry, h_code, i_code) + h_code.putln("") + h_code.putln("#endif /* !%s */" % api_guard) + h_code.putln("") + h_code.putln("/* WARNING: the interface of the module init function changed in CPython 3.5. */") + h_code.putln("/* It now returns a PyModuleDef instance instead of a PyModule instance. */") + h_code.putln("") + h_code.putln("#if PY_MAJOR_VERSION < 3") + init_name = 'init' + (options.init_suffix or env.module_name) + h_code.putln("PyMODINIT_FUNC %s(void);" % init_name) + h_code.putln("#else") + h_code.putln("PyMODINIT_FUNC %s(void);" % self.mod_init_func_cname('PyInit', env, options)) + h_code.putln("#endif") + h_code.putln("") + h_code.putln("#endif /* !%s */" % h_guard) + + f = open_new_file(result.h_file) + try: + h_code.copyto(f) + finally: + f.close() + + def generate_public_declaration(self, entry, h_code, i_code): + h_code.putln("%s %s;" % ( + Naming.extern_c_macro, + entry.type.declaration_code(entry.cname))) + if i_code: + i_code.putln("cdef extern %s" % ( + entry.type.declaration_code(entry.cname, pyrex=1))) + + def api_name(self, env): + return env.qualified_name.replace(".", "__") + + def generate_api_code(self, env, options, result): + def api_entries(entries, pxd=0): + return [entry for entry in entries + if entry.api or (pxd and entry.defined_in_pxd)] + api_vars = api_entries(env.var_entries) + api_funcs = api_entries(env.cfunc_entries) + api_extension_types = api_entries(env.c_class_entries) + if api_vars or api_funcs or api_extension_types: + result.api_file = replace_suffix(result.c_file, "_api.h") + h_code = Code.CCodeWriter() + c_code_config = generate_c_code_config(env, options) + Code.GlobalState(h_code, self, c_code_config) + h_code.put_generated_by() + api_guard = Naming.api_guard_prefix + self.api_name(env) + h_code.put_h_guard(api_guard) + # Work around https://bugs.python.org/issue4709 + h_code.putln('#ifdef __MINGW64__') + h_code.putln('#define MS_WIN64') + h_code.putln('#endif') + + h_code.putln('#include "Python.h"') + if result.h_file: + h_code.putln('#include "%s"' % os.path.basename(result.h_file)) + if api_extension_types: + h_code.putln("") + for entry in api_extension_types: + type = entry.type + h_code.putln("static PyTypeObject *%s = 0;" % type.typeptr_cname) + h_code.putln("#define %s (*%s)" % ( + type.typeobj_cname, type.typeptr_cname)) + if api_funcs: + h_code.putln("") + for entry in api_funcs: + type = CPtrType(entry.type) + cname = env.mangle(Naming.func_prefix_api, entry.name) + h_code.putln("static %s = 0;" % type.declaration_code(cname)) + h_code.putln("#define %s %s" % (entry.name, cname)) + if api_vars: + h_code.putln("") + for entry in api_vars: + type = CPtrType(entry.type) + cname = env.mangle(Naming.varptr_prefix_api, entry.name) + h_code.putln("static %s = 0;" % type.declaration_code(cname)) + h_code.putln("#define %s (*%s)" % (entry.name, cname)) + h_code.put(UtilityCode.load_as_string("PyIdentifierFromString", "ImportExport.c")[0]) + if api_vars: + h_code.put(UtilityCode.load_as_string("VoidPtrImport", "ImportExport.c")[1]) + if api_funcs: + h_code.put(UtilityCode.load_as_string("FunctionImport", "ImportExport.c")[1]) + if api_extension_types: + h_code.put(UtilityCode.load_as_string("TypeImport", "ImportExport.c")[0]) + h_code.put(UtilityCode.load_as_string("TypeImport", "ImportExport.c")[1]) + h_code.putln("") + h_code.putln("static int import_%s(void) {" % self.api_name(env)) + h_code.putln("PyObject *module = 0;") + h_code.putln('module = PyImport_ImportModule("%s");' % env.qualified_name) + h_code.putln("if (!module) goto bad;") + for entry in api_funcs: + cname = env.mangle(Naming.func_prefix_api, entry.name) + sig = entry.type.signature_string() + h_code.putln( + 'if (__Pyx_ImportFunction(module, "%s", (void (**)(void))&%s, "%s") < 0) goto bad;' + % (entry.name, cname, sig)) + for entry in api_vars: + cname = env.mangle(Naming.varptr_prefix_api, entry.name) + sig = entry.type.empty_declaration_code() + h_code.putln( + 'if (__Pyx_ImportVoidPtr(module, "%s", (void **)&%s, "%s") < 0) goto bad;' + % (entry.name, cname, sig)) + with ModuleImportGenerator(h_code, imported_modules={env.qualified_name: 'module'}) as import_generator: + for entry in api_extension_types: + self.generate_type_import_call(entry.type, h_code, import_generator, error_code="goto bad;") + h_code.putln("Py_DECREF(module); module = 0;") + h_code.putln("return 0;") + h_code.putln("bad:") + h_code.putln("Py_XDECREF(module);") + h_code.putln("return -1;") + h_code.putln("}") + h_code.putln("") + h_code.putln("#endif /* !%s */" % api_guard) + + f = open_new_file(result.api_file) + try: + h_code.copyto(f) + finally: + f.close() + + def generate_cclass_header_code(self, type, h_code): + h_code.putln("%s %s %s;" % ( + Naming.extern_c_macro, + PyrexTypes.public_decl("PyTypeObject", "DL_IMPORT"), + type.typeobj_cname)) + + def generate_cclass_include_code(self, type, i_code): + i_code.putln("cdef extern class %s.%s:" % ( + type.module_name, type.name)) + i_code.indent() + var_entries = type.scope.var_entries + if var_entries: + for entry in var_entries: + i_code.putln("cdef %s" % ( + entry.type.declaration_code(entry.cname, pyrex=1))) + else: + i_code.putln("pass") + i_code.dedent() + + def generate_c_code(self, env, options, result): + modules = self.referenced_modules + + if Options.annotate or options.annotate: + rootwriter = Annotate.AnnotationCCodeWriter() + else: + rootwriter = Code.CCodeWriter() + + c_code_config = generate_c_code_config(env, options) + + globalstate = Code.GlobalState( + rootwriter, self, + code_config=c_code_config, + common_utility_include_dir=options.common_utility_include_dir, + ) + globalstate.initialize_main_c_code() + h_code = globalstate['h_code'] + + self.generate_module_preamble(env, options, modules, result.embedded_metadata, h_code) + + globalstate.module_pos = self.pos + globalstate.directives = self.directives + + globalstate.use_utility_code(refnanny_utility_code) + + code = globalstate['before_global_var'] + code.putln('#define __Pyx_MODULE_NAME "%s"' % self.full_module_name) + module_is_main = "%s%s" % (Naming.module_is_main, self.full_module_name.replace('.', '__')) + code.putln("extern int %s;" % module_is_main) + code.putln("int %s = 0;" % module_is_main) + code.putln("") + code.putln("/* Implementation of '%s' */" % env.qualified_name) + + code = globalstate['late_includes'] + code.putln("/* Late includes */") + self.generate_includes(env, modules, code, early=False) + + code = globalstate['all_the_rest'] + + self.generate_cached_builtins_decls(env, code) + self.generate_lambda_definitions(env, code) + # generate normal variable and function definitions + self.generate_variable_definitions(env, code) + + self.body.generate_function_definitions(env, code) + + code.mark_pos(None) + self.generate_typeobj_definitions(env, code) + self.generate_method_table(env, code) + if env.has_import_star: + self.generate_import_star(env, code) + self.generate_pymoduledef_struct(env, options, code) + + # initialise the macro to reduce the code size of one-time functionality + code.putln(UtilityCode.load_as_string("SmallCodeConfig", "ModuleSetupCode.c")[0].strip()) + + # init_globals is inserted before this + self.generate_module_init_func(modules[:-1], env, options, globalstate['init_module']) + self.generate_module_cleanup_func(env, globalstate['cleanup_module']) + if Options.embed: + self.generate_main_method(env, globalstate['main_method']) + self.generate_filename_table(globalstate['filename_table']) + + self.generate_declarations_for_modules(env, modules, globalstate) + h_code.write('\n') + + for utilcode in env.utility_code_list[:]: + globalstate.use_utility_code(utilcode) + globalstate.finalize_main_c_code() + + f = open_new_file(result.c_file) + try: + rootwriter.copyto(f) + finally: + f.close() + result.c_file_generated = 1 + if options.gdb_debug: + self._serialize_lineno_map(env, rootwriter) + if Options.annotate or options.annotate: + self._generate_annotations(rootwriter, result, options) + + def _generate_annotations(self, rootwriter, result, options): + self.annotate(rootwriter) + + coverage_xml_filename = Options.annotate_coverage_xml or options.annotate_coverage_xml + if coverage_xml_filename and os.path.exists(coverage_xml_filename): + try: + import xml.etree.cElementTree as ET + except ImportError: + import xml.etree.ElementTree as ET + coverage_xml = ET.parse(coverage_xml_filename).getroot() + if hasattr(coverage_xml, 'iter'): + iterator = coverage_xml.iter() # Python 2.7 & 3.2+ + else: + iterator = coverage_xml.getiterator() + for el in iterator: + el.tail = None # save some memory + else: + coverage_xml = None + + rootwriter.save_annotation(result.main_source_file, result.c_file, coverage_xml=coverage_xml) + + # if we included files, additionally generate one annotation file for each + if not self.scope.included_files: + return + + search_include_file = self.scope.context.search_include_directories + target_dir = os.path.abspath(os.path.dirname(result.c_file)) + for included_file in self.scope.included_files: + target_file = os.path.abspath(os.path.join(target_dir, included_file)) + target_file_dir = os.path.dirname(target_file) + if not target_file_dir.startswith(target_dir): + # any other directories may not be writable => avoid trying + continue + source_file = search_include_file(included_file, "", self.pos, include=True) + if not source_file: + continue + if target_file_dir != target_dir and not os.path.exists(target_file_dir): + try: + os.makedirs(target_file_dir) + except OSError as e: + import errno + if e.errno != errno.EEXIST: + raise + rootwriter.save_annotation(source_file, target_file, coverage_xml=coverage_xml) + + def _serialize_lineno_map(self, env, ccodewriter): + tb = env.context.gdb_debug_outputwriter + markers = ccodewriter.buffer.allmarkers() + + d = defaultdict(list) + for c_lineno, cython_lineno in enumerate(markers): + if cython_lineno > 0: + d[cython_lineno].append(c_lineno + 1) + + tb.start('LineNumberMapping') + for cython_lineno, c_linenos in sorted(d.items()): + tb.add_entry( + 'LineNumber', + c_linenos=' '.join(map(str, c_linenos)), + cython_lineno=str(cython_lineno), + ) + tb.end('LineNumberMapping') + tb.serialize() + + def find_referenced_modules(self, env, module_list, modules_seen): + if env not in modules_seen: + modules_seen[env] = 1 + for imported_module in env.cimported_modules: + self.find_referenced_modules(imported_module, module_list, modules_seen) + module_list.append(env) + + def sort_types_by_inheritance(self, type_dict, type_order, getkey): + # copy the types into a list moving each parent type before + # its first child + type_list = [] + for i, key in enumerate(type_order): + new_entry = type_dict[key] + + # collect all base classes to check for children + hierarchy = set() + base = new_entry + while base: + base_type = base.type.base_type + if not base_type: + break + base_key = getkey(base_type) + hierarchy.add(base_key) + base = type_dict.get(base_key) + new_entry.base_keys = hierarchy + + # find the first (sub-)subclass and insert before that + for j in range(i): + entry = type_list[j] + if key in entry.base_keys: + type_list.insert(j, new_entry) + break + else: + type_list.append(new_entry) + return type_list + + def sort_type_hierarchy(self, module_list, env): + # poor developer's OrderedDict + vtab_dict, vtab_dict_order = {}, [] + vtabslot_dict, vtabslot_dict_order = {}, [] + + for module in module_list: + for entry in module.c_class_entries: + if entry.used and not entry.in_cinclude: + type = entry.type + key = type.vtabstruct_cname + if not key: + continue + if key in vtab_dict: + # FIXME: this should *never* happen, but apparently it does + # for Cython generated utility code + from .UtilityCode import NonManglingModuleScope + assert isinstance(entry.scope, NonManglingModuleScope), str(entry.scope) + assert isinstance(vtab_dict[key].scope, NonManglingModuleScope), str(vtab_dict[key].scope) + else: + vtab_dict[key] = entry + vtab_dict_order.append(key) + all_defined_here = module is env + for entry in module.type_entries: + if entry.used and (all_defined_here or entry.defined_in_pxd): + type = entry.type + if type.is_extension_type and not entry.in_cinclude: + type = entry.type + key = type.objstruct_cname + assert key not in vtabslot_dict, key + vtabslot_dict[key] = entry + vtabslot_dict_order.append(key) + + def vtabstruct_cname(entry_type): + return entry_type.vtabstruct_cname + vtab_list = self.sort_types_by_inheritance( + vtab_dict, vtab_dict_order, vtabstruct_cname) + + def objstruct_cname(entry_type): + return entry_type.objstruct_cname + vtabslot_list = self.sort_types_by_inheritance( + vtabslot_dict, vtabslot_dict_order, objstruct_cname) + + return (vtab_list, vtabslot_list) + + def sort_cdef_classes(self, env): + key_func = operator.attrgetter('objstruct_cname') + entry_dict, entry_order = {}, [] + for entry in env.c_class_entries: + key = key_func(entry.type) + assert key not in entry_dict, key + entry_dict[key] = entry + entry_order.append(key) + env.c_class_entries[:] = self.sort_types_by_inheritance( + entry_dict, entry_order, key_func) + + def generate_type_definitions(self, env, modules, vtab_list, vtabslot_list, code): + # TODO: Why are these separated out? + for entry in vtabslot_list: + self.generate_objstruct_predeclaration(entry.type, code) + vtabslot_entries = set(vtabslot_list) + ctuple_names = set() + for module in modules: + definition = module is env + type_entries = [] + for entry in module.type_entries: + if entry.type.is_ctuple and entry.used: + if entry.name not in ctuple_names: + ctuple_names.add(entry.name) + type_entries.append(entry) + elif definition or entry.defined_in_pxd: + type_entries.append(entry) + type_entries = [t for t in type_entries if t not in vtabslot_entries] + self.generate_type_header_code(type_entries, code) + for entry in vtabslot_list: + self.generate_objstruct_definition(entry.type, code) + self.generate_typeobj_predeclaration(entry, code) + for entry in vtab_list: + self.generate_typeobj_predeclaration(entry, code) + self.generate_exttype_vtable_struct(entry, code) + self.generate_exttype_vtabptr_declaration(entry, code) + self.generate_exttype_final_methods_declaration(entry, code) + + def generate_declarations_for_modules(self, env, modules, globalstate): + typecode = globalstate['type_declarations'] + typecode.putln("") + typecode.putln("/*--- Type declarations ---*/") + # This is to work around the fact that array.h isn't part of the C-API, + # but we need to declare it earlier than utility code. + if 'cpython.array' in [m.qualified_name for m in modules]: + typecode.putln('#ifndef _ARRAYARRAY_H') + typecode.putln('struct arrayobject;') + typecode.putln('typedef struct arrayobject arrayobject;') + typecode.putln('#endif') + vtab_list, vtabslot_list = self.sort_type_hierarchy(modules, env) + self.generate_type_definitions( + env, modules, vtab_list, vtabslot_list, typecode) + modulecode = globalstate['module_declarations'] + for module in modules: + defined_here = module is env + modulecode.putln("") + modulecode.putln("/* Module declarations from '%s' */" % module.qualified_name) + self.generate_c_class_declarations(module, modulecode, defined_here) + self.generate_cvariable_declarations(module, modulecode, defined_here) + self.generate_cfunction_declarations(module, modulecode, defined_here) + + def _put_setup_code(self, code, name): + code.put(UtilityCode.load_as_string(name, "ModuleSetupCode.c")[1]) + + def generate_module_preamble(self, env, options, cimported_modules, metadata, code): + code.put_generated_by() + if metadata: + code.putln("/* BEGIN: Cython Metadata") + code.putln(json.dumps(metadata, indent=4, sort_keys=True)) + code.putln("END: Cython Metadata */") + code.putln("") + + code.putln("#ifndef PY_SSIZE_T_CLEAN") + code.putln("#define PY_SSIZE_T_CLEAN") + code.putln("#endif /* PY_SSIZE_T_CLEAN */") + + for inc in sorted(env.c_includes.values(), key=IncludeCode.sortkey): + if inc.location == inc.INITIAL: + inc.write(code) + code.putln("#ifndef Py_PYTHON_H") + code.putln(" #error Python headers needed to compile C extensions, " + "please install development version of Python.") + code.putln("#elif PY_VERSION_HEX < 0x02060000 || " + "(0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)") + code.putln(" #error Cython requires Python 2.6+ or Python 3.3+.") + code.putln("#else") + code.globalstate["end"].putln("#endif /* Py_PYTHON_H */") + + from .. import __version__ + code.putln('#define CYTHON_ABI "%s"' % __version__.replace('.', '_')) + code.putln('#define CYTHON_HEX_VERSION %s' % build_hex_version(__version__)) + code.putln("#define CYTHON_FUTURE_DIVISION %d" % ( + Future.division in env.context.future_directives)) + + self._put_setup_code(code, "CModulePreamble") + if env.context.options.cplus: + self._put_setup_code(code, "CppInitCode") + else: + self._put_setup_code(code, "CInitCode") + self._put_setup_code(code, "PythonCompatibility") + self._put_setup_code(code, "MathInitCode") + + # Using "(void)cname" to prevent "unused" warnings. + if options.c_line_in_traceback: + cinfo = "%s = %s; (void)%s; " % (Naming.clineno_cname, Naming.line_c_macro, Naming.clineno_cname) + else: + cinfo = "" + code.putln("#define __PYX_MARK_ERR_POS(f_index, lineno) \\") + code.putln(" { %s = %s[f_index]; (void)%s; %s = lineno; (void)%s; %s}" % ( + Naming.filename_cname, Naming.filetable_cname, Naming.filename_cname, + Naming.lineno_cname, Naming.lineno_cname, + cinfo + )) + code.putln("#define __PYX_ERR(f_index, lineno, Ln_error) \\") + code.putln(" { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }") + + code.putln("") + self.generate_extern_c_macro_definition(code) + code.putln("") + + code.putln("#define %s" % Naming.h_guard_prefix + self.api_name(env)) + code.putln("#define %s" % Naming.api_guard_prefix + self.api_name(env)) + code.putln("/* Early includes */") + self.generate_includes(env, cimported_modules, code, late=False) + code.putln("") + code.putln("#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)") + code.putln("#define CYTHON_WITHOUT_ASSERTIONS") + code.putln("#endif") + code.putln("") + + if env.directives['ccomplex']: + code.putln("") + code.putln("#if !defined(CYTHON_CCOMPLEX)") + code.putln("#define CYTHON_CCOMPLEX 1") + code.putln("#endif") + code.putln("") + code.put(UtilityCode.load_as_string("UtilityFunctionPredeclarations", "ModuleSetupCode.c")[0]) + + c_string_type = env.directives['c_string_type'] + c_string_encoding = env.directives['c_string_encoding'] + if c_string_type not in ('bytes', 'bytearray') and not c_string_encoding: + error(self.pos, "a default encoding must be provided if c_string_type is not a byte type") + code.putln('#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII %s' % int(c_string_encoding == 'ascii')) + code.putln('#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 %s' % + int(c_string_encoding.replace('-', '').lower() == 'utf8')) + if c_string_encoding == 'default': + code.putln('#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 1') + else: + code.putln('#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT ' + '(PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)') + code.putln('#define __PYX_DEFAULT_STRING_ENCODING "%s"' % c_string_encoding) + if c_string_type == 'bytearray': + c_string_func_name = 'ByteArray' + else: + c_string_func_name = c_string_type.title() + code.putln('#define __Pyx_PyObject_FromString __Pyx_Py%s_FromString' % c_string_func_name) + code.putln('#define __Pyx_PyObject_FromStringAndSize __Pyx_Py%s_FromStringAndSize' % c_string_func_name) + code.put(UtilityCode.load_as_string("TypeConversions", "TypeConversion.c")[0]) + + # These utility functions are assumed to exist and used elsewhere. + PyrexTypes.c_long_type.create_to_py_utility_code(env) + PyrexTypes.c_long_type.create_from_py_utility_code(env) + PyrexTypes.c_int_type.create_from_py_utility_code(env) + + code.put(Nodes.branch_prediction_macros) + code.putln('static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }') + code.putln('') + code.putln('static PyObject *%s = NULL;' % env.module_cname) + code.putln('static PyObject *%s;' % env.module_dict_cname) + code.putln('static PyObject *%s;' % Naming.builtins_cname) + code.putln('static PyObject *%s = NULL;' % Naming.cython_runtime_cname) + code.putln('static PyObject *%s;' % Naming.empty_tuple) + code.putln('static PyObject *%s;' % Naming.empty_bytes) + code.putln('static PyObject *%s;' % Naming.empty_unicode) + if Options.pre_import is not None: + code.putln('static PyObject *%s;' % Naming.preimport_cname) + code.putln('static int %s;' % Naming.lineno_cname) + code.putln('static int %s = 0;' % Naming.clineno_cname) + code.putln('static const char * %s= %s;' % (Naming.cfilenm_cname, Naming.file_c_macro)) + code.putln('static const char *%s;' % Naming.filename_cname) + + env.use_utility_code(UtilityCode.load_cached("FastTypeChecks", "ModuleSetupCode.c")) + if has_np_pythran(env): + env.use_utility_code(UtilityCode.load_cached("PythranConversion", "CppSupport.cpp")) + + def generate_extern_c_macro_definition(self, code): + name = Naming.extern_c_macro + code.putln("#ifndef %s" % name) + code.putln(" #ifdef __cplusplus") + code.putln(' #define %s extern "C"' % name) + code.putln(" #else") + code.putln(" #define %s extern" % name) + code.putln(" #endif") + code.putln("#endif") + + def generate_dl_import_macro(self, code): + code.putln("#ifndef DL_IMPORT") + code.putln(" #define DL_IMPORT(_T) _T") + code.putln("#endif") + + def generate_includes(self, env, cimported_modules, code, early=True, late=True): + includes = [] + for inc in sorted(env.c_includes.values(), key=IncludeCode.sortkey): + if inc.location == inc.EARLY: + if early: + inc.write(code) + elif inc.location == inc.LATE: + if late: + inc.write(code) + if early: + code.putln_openmp("#include <omp.h>") + + def generate_filename_table(self, code): + from os.path import isabs, basename + code.putln("") + code.putln("static const char *%s[] = {" % Naming.filetable_cname) + if code.globalstate.filename_list: + for source_desc in code.globalstate.filename_list: + file_path = source_desc.get_filenametable_entry() + if Options.source_root: + # If source root specified, dump description - it's source root relative filename + file_path = source_desc.get_description() + if isabs(file_path): + file_path = basename(file_path) # never include absolute paths + escaped_filename = file_path.replace("\\", "\\\\").replace('"', r'\"') + code.putln('"%s",' % escaped_filename) + else: + # Some C compilers don't like an empty array + code.putln("0") + code.putln("};") + + def generate_type_predeclarations(self, env, code): + pass + + def generate_type_header_code(self, type_entries, code): + # Generate definitions of structs/unions/enums/typedefs/objstructs. + #self.generate_gcc33_hack(env, code) # Is this still needed? + # Forward declarations + for entry in type_entries: + if not entry.in_cinclude: + #print "generate_type_header_code:", entry.name, repr(entry.type) ### + type = entry.type + if type.is_typedef: # Must test this first! + pass + elif type.is_struct_or_union or type.is_cpp_class: + self.generate_struct_union_predeclaration(entry, code) + elif type.is_ctuple and entry.used: + self.generate_struct_union_predeclaration(entry.type.struct_entry, code) + elif type.is_extension_type: + self.generate_objstruct_predeclaration(type, code) + # Actual declarations + for entry in type_entries: + if not entry.in_cinclude: + #print "generate_type_header_code:", entry.name, repr(entry.type) ### + type = entry.type + if type.is_typedef: # Must test this first! + self.generate_typedef(entry, code) + elif type.is_enum: + self.generate_enum_definition(entry, code) + elif type.is_struct_or_union: + self.generate_struct_union_definition(entry, code) + elif type.is_ctuple and entry.used: + self.generate_struct_union_definition(entry.type.struct_entry, code) + elif type.is_cpp_class: + self.generate_cpp_class_definition(entry, code) + elif type.is_extension_type: + self.generate_objstruct_definition(type, code) + + def generate_gcc33_hack(self, env, code): + # Workaround for spurious warning generation in gcc 3.3 + code.putln("") + for entry in env.c_class_entries: + type = entry.type + if not type.typedef_flag: + name = type.objstruct_cname + if name.startswith("__pyx_"): + tail = name[6:] + else: + tail = name + code.putln("typedef struct %s __pyx_gcc33_%s;" % ( + name, tail)) + + def generate_typedef(self, entry, code): + base_type = entry.type.typedef_base_type + if base_type.is_numeric: + try: + writer = code.globalstate['numeric_typedefs'] + except KeyError: + writer = code + else: + writer = code + writer.mark_pos(entry.pos) + writer.putln("typedef %s;" % base_type.declaration_code(entry.cname)) + + def sue_predeclaration(self, type, kind, name): + if type.typedef_flag: + return "%s %s;\ntypedef %s %s %s;" % ( + kind, name, + kind, name, name) + else: + return "%s %s;" % (kind, name) + + def generate_struct_union_predeclaration(self, entry, code): + type = entry.type + if type.is_cpp_class and type.templates: + code.putln("template <typename %s>" % ", typename ".join( + [T.empty_declaration_code() for T in type.templates])) + code.putln(self.sue_predeclaration(type, type.kind, type.cname)) + + def sue_header_footer(self, type, kind, name): + header = "%s %s {" % (kind, name) + footer = "};" + return header, footer + + def generate_struct_union_definition(self, entry, code): + code.mark_pos(entry.pos) + type = entry.type + scope = type.scope + if scope: + kind = type.kind + packed = type.is_struct and type.packed + if packed: + kind = "%s %s" % (type.kind, "__Pyx_PACKED") + code.globalstate.use_utility_code(packed_struct_utility_code) + header, footer = \ + self.sue_header_footer(type, kind, type.cname) + if packed: + code.putln("#if defined(__SUNPRO_C)") + code.putln(" #pragma pack(1)") + code.putln("#elif !defined(__GNUC__)") + code.putln(" #pragma pack(push, 1)") + code.putln("#endif") + code.putln(header) + var_entries = scope.var_entries + if not var_entries: + error(entry.pos, "Empty struct or union definition not allowed outside a 'cdef extern from' block") + for attr in var_entries: + code.putln( + "%s;" % attr.type.declaration_code(attr.cname)) + code.putln(footer) + if packed: + code.putln("#if defined(__SUNPRO_C)") + code.putln(" #pragma pack()") + code.putln("#elif !defined(__GNUC__)") + code.putln(" #pragma pack(pop)") + code.putln("#endif") + + def generate_cpp_class_definition(self, entry, code): + code.mark_pos(entry.pos) + type = entry.type + scope = type.scope + if scope: + if type.templates: + code.putln("template <class %s>" % ", class ".join( + [T.empty_declaration_code() for T in type.templates])) + # Just let everything be public. + code.put("struct %s" % type.cname) + if type.base_classes: + base_class_decl = ", public ".join( + [base_class.empty_declaration_code() for base_class in type.base_classes]) + code.put(" : public %s" % base_class_decl) + code.putln(" {") + py_attrs = [e for e in scope.entries.values() + if e.type.is_pyobject and not e.is_inherited] + has_virtual_methods = False + constructor = None + destructor = None + for attr in scope.var_entries: + if attr.type.is_cfunction: + code.put("inline ") + if attr.type.is_cfunction and attr.type.is_static_method: + code.put("static ") + elif attr.name == "<init>": + constructor = attr + elif attr.name == "<del>": + destructor = attr + elif attr.type.is_cfunction: + code.put("virtual ") + has_virtual_methods = True + code.putln("%s;" % attr.type.declaration_code(attr.cname)) + is_implementing = 'init_module' in code.globalstate.parts + if constructor or py_attrs: + if constructor: + arg_decls = [] + arg_names = [] + for arg in constructor.type.original_args[ + :len(constructor.type.args)-constructor.type.optional_arg_count]: + arg_decls.append(arg.declaration_code()) + arg_names.append(arg.cname) + if constructor.type.optional_arg_count: + arg_decls.append(constructor.type.op_arg_struct.declaration_code(Naming.optional_args_cname)) + arg_names.append(Naming.optional_args_cname) + if not arg_decls: + arg_decls = ["void"] + else: + arg_decls = ["void"] + arg_names = [] + if is_implementing: + code.putln("%s(%s) {" % (type.cname, ", ".join(arg_decls))) + if py_attrs: + code.put_ensure_gil() + for attr in py_attrs: + code.put_init_var_to_py_none(attr, nanny=False); + if constructor: + code.putln("%s(%s);" % (constructor.cname, ", ".join(arg_names))) + if py_attrs: + code.put_release_ensured_gil() + code.putln("}") + else: + code.putln("%s(%s);" % (type.cname, ", ".join(arg_decls))) + if destructor or py_attrs or has_virtual_methods: + if has_virtual_methods: + code.put("virtual ") + if is_implementing: + code.putln("~%s() {" % type.cname) + if py_attrs: + code.put_ensure_gil() + if destructor: + code.putln("%s();" % destructor.cname) + if py_attrs: + for attr in py_attrs: + code.put_var_xdecref(attr, nanny=False); + code.put_release_ensured_gil() + code.putln("}") + else: + code.putln("~%s();" % type.cname) + if py_attrs: + # Also need copy constructor and assignment operators. + if is_implementing: + code.putln("%s(const %s& __Pyx_other) {" % (type.cname, type.cname)) + code.put_ensure_gil() + for attr in scope.var_entries: + if not attr.type.is_cfunction: + code.putln("%s = __Pyx_other.%s;" % (attr.cname, attr.cname)) + code.put_var_incref(attr, nanny=False) + code.put_release_ensured_gil() + code.putln("}") + code.putln("%s& operator=(const %s& __Pyx_other) {" % (type.cname, type.cname)) + code.putln("if (this != &__Pyx_other) {") + code.put_ensure_gil() + for attr in scope.var_entries: + if not attr.type.is_cfunction: + code.put_var_xdecref(attr, nanny=False); + code.putln("%s = __Pyx_other.%s;" % (attr.cname, attr.cname)) + code.put_var_incref(attr, nanny=False) + code.put_release_ensured_gil() + code.putln("}") + code.putln("return *this;") + code.putln("}") + else: + code.putln("%s(const %s& __Pyx_other);" % (type.cname, type.cname)) + code.putln("%s& operator=(const %s& __Pyx_other);" % (type.cname, type.cname)) + code.putln("};") + + def generate_enum_definition(self, entry, code): + code.mark_pos(entry.pos) + type = entry.type + name = entry.cname or entry.name or "" + header, footer = self.sue_header_footer(type, "enum", name) + code.putln(header) + enum_values = entry.enum_values + if not enum_values: + error(entry.pos, "Empty enum definition not allowed outside a 'cdef extern from' block") + else: + last_entry = enum_values[-1] + # this does not really generate code, just builds the result value + for value_entry in enum_values: + if value_entry.value_node is not None: + value_entry.value_node.generate_evaluation_code(code) + + for value_entry in enum_values: + if value_entry.value_node is None: + value_code = value_entry.cname + else: + value_code = ("%s = %s" % ( + value_entry.cname, + value_entry.value_node.result())) + if value_entry is not last_entry: + value_code += "," + code.putln(value_code) + code.putln(footer) + if entry.type.typedef_flag: + # Not pre-declared. + code.putln("typedef enum %s %s;" % (name, name)) + + def generate_typeobj_predeclaration(self, entry, code): + code.putln("") + name = entry.type.typeobj_cname + if name: + if entry.visibility == 'extern' and not entry.in_cinclude: + code.putln("%s %s %s;" % ( + Naming.extern_c_macro, + PyrexTypes.public_decl("PyTypeObject", "DL_IMPORT"), + name)) + elif entry.visibility == 'public': + code.putln("%s %s %s;" % ( + Naming.extern_c_macro, + PyrexTypes.public_decl("PyTypeObject", "DL_EXPORT"), + name)) + # ??? Do we really need the rest of this? ??? + #else: + # code.putln("static PyTypeObject %s;" % name) + + def generate_exttype_vtable_struct(self, entry, code): + if not entry.used: + return + + code.mark_pos(entry.pos) + # Generate struct declaration for an extension type's vtable. + type = entry.type + scope = type.scope + + self.specialize_fused_types(scope) + + if type.vtabstruct_cname: + code.putln("") + code.putln("struct %s {" % type.vtabstruct_cname) + if type.base_type and type.base_type.vtabstruct_cname: + code.putln("struct %s %s;" % ( + type.base_type.vtabstruct_cname, + Naming.obj_base_cname)) + for method_entry in scope.cfunc_entries: + if not method_entry.is_inherited: + code.putln("%s;" % method_entry.type.declaration_code("(*%s)" % method_entry.cname)) + code.putln("};") + + def generate_exttype_vtabptr_declaration(self, entry, code): + if not entry.used: + return + + code.mark_pos(entry.pos) + # Generate declaration of pointer to an extension type's vtable. + type = entry.type + if type.vtabptr_cname: + code.putln("static struct %s *%s;" % ( + type.vtabstruct_cname, + type.vtabptr_cname)) + + def generate_exttype_final_methods_declaration(self, entry, code): + if not entry.used: + return + + code.mark_pos(entry.pos) + # Generate final methods prototypes + type = entry.type + for method_entry in entry.type.scope.cfunc_entries: + if not method_entry.is_inherited and method_entry.final_func_cname: + declaration = method_entry.type.declaration_code( + method_entry.final_func_cname) + modifiers = code.build_function_modifiers(method_entry.func_modifiers) + code.putln("static %s%s;" % (modifiers, declaration)) + + def generate_objstruct_predeclaration(self, type, code): + if not type.scope: + return + code.putln(self.sue_predeclaration(type, "struct", type.objstruct_cname)) + + def generate_objstruct_definition(self, type, code): + code.mark_pos(type.pos) + # Generate object struct definition for an + # extension type. + if not type.scope: + return # Forward declared but never defined + header, footer = \ + self.sue_header_footer(type, "struct", type.objstruct_cname) + code.putln(header) + base_type = type.base_type + if base_type: + basestruct_cname = base_type.objstruct_cname + if basestruct_cname == "PyTypeObject": + # User-defined subclasses of type are heap allocated. + basestruct_cname = "PyHeapTypeObject" + code.putln( + "%s%s %s;" % ( + ("struct ", "")[base_type.typedef_flag], + basestruct_cname, + Naming.obj_base_cname)) + else: + code.putln( + "PyObject_HEAD") + if type.vtabslot_cname and not (type.base_type and type.base_type.vtabslot_cname): + code.putln( + "struct %s *%s;" % ( + type.vtabstruct_cname, + type.vtabslot_cname)) + for attr in type.scope.var_entries: + if attr.is_declared_generic: + attr_type = py_object_type + else: + attr_type = attr.type + code.putln( + "%s;" % attr_type.declaration_code(attr.cname)) + code.putln(footer) + if type.objtypedef_cname is not None: + # Only for exposing public typedef name. + code.putln("typedef struct %s %s;" % (type.objstruct_cname, type.objtypedef_cname)) + + def generate_c_class_declarations(self, env, code, definition): + for entry in env.c_class_entries: + if definition or entry.defined_in_pxd: + code.putln("static PyTypeObject *%s = 0;" % ( + entry.type.typeptr_cname)) + + def generate_cvariable_declarations(self, env, code, definition): + if env.is_cython_builtin: + return + for entry in env.var_entries: + if (entry.in_cinclude or entry.in_closure or + (entry.visibility == 'private' and not (entry.defined_in_pxd or entry.used))): + continue + + storage_class = None + dll_linkage = None + init = None + + if entry.visibility == 'extern': + storage_class = Naming.extern_c_macro + dll_linkage = "DL_IMPORT" + elif entry.visibility == 'public': + storage_class = Naming.extern_c_macro + if definition: + dll_linkage = "DL_EXPORT" + else: + dll_linkage = "DL_IMPORT" + elif entry.visibility == 'private': + storage_class = "static" + dll_linkage = None + if entry.init is not None: + init = entry.type.literal_code(entry.init) + type = entry.type + cname = entry.cname + + if entry.defined_in_pxd and not definition: + storage_class = "static" + dll_linkage = None + type = CPtrType(type) + cname = env.mangle(Naming.varptr_prefix, entry.name) + init = 0 + + if storage_class: + code.put("%s " % storage_class) + code.put(type.declaration_code( + cname, dll_linkage=dll_linkage)) + if init is not None: + code.put_safe(" = %s" % init) + code.putln(";") + if entry.cname != cname: + code.putln("#define %s (*%s)" % (entry.cname, cname)) + + def generate_cfunction_declarations(self, env, code, definition): + for entry in env.cfunc_entries: + if entry.used or (entry.visibility == 'public' or entry.api): + generate_cfunction_declaration(entry, env, code, definition) + + def generate_variable_definitions(self, env, code): + for entry in env.var_entries: + if not entry.in_cinclude and entry.visibility == "public": + code.put(entry.type.declaration_code(entry.cname)) + if entry.init is not None: + init = entry.type.literal_code(entry.init) + code.put_safe(" = %s" % init) + code.putln(";") + + def generate_typeobj_definitions(self, env, code): + full_module_name = env.qualified_name + for entry in env.c_class_entries: + #print "generate_typeobj_definitions:", entry.name + #print "...visibility =", entry.visibility + if entry.visibility != 'extern': + type = entry.type + scope = type.scope + if scope: # could be None if there was an error + if not scope.directives['c_api_binop_methods']: + error(self.pos, + "The 'c_api_binop_methods' directive is only supported for forward compatibility" + " and must be True.") + self.generate_exttype_vtable(scope, code) + self.generate_new_function(scope, code, entry) + self.generate_dealloc_function(scope, code) + if scope.needs_gc(): + self.generate_traverse_function(scope, code, entry) + if scope.needs_tp_clear(): + self.generate_clear_function(scope, code, entry) + if scope.defines_any_special(["__getitem__"]): + self.generate_getitem_int_function(scope, code) + if scope.defines_any_special(["__setitem__", "__delitem__"]): + self.generate_ass_subscript_function(scope, code) + if scope.defines_any_special(["__getslice__", "__setslice__", "__delslice__"]): + warning(self.pos, + "__getslice__, __setslice__, and __delslice__ are not supported by Python 3, " + "use __getitem__, __setitem__, and __delitem__ instead", 1) + code.putln("#if PY_MAJOR_VERSION >= 3") + code.putln("#error __getslice__, __setslice__, and __delslice__ not supported in Python 3.") + code.putln("#endif") + if scope.defines_any_special(["__setslice__", "__delslice__"]): + self.generate_ass_slice_function(scope, code) + if scope.defines_any_special(["__getattr__", "__getattribute__"]): + self.generate_getattro_function(scope, code) + if scope.defines_any_special(["__setattr__", "__delattr__"]): + self.generate_setattro_function(scope, code) + if scope.defines_any_special(["__get__"]): + self.generate_descr_get_function(scope, code) + if scope.defines_any_special(["__set__", "__delete__"]): + self.generate_descr_set_function(scope, code) + if not scope.is_closure_class_scope and scope.defines_any(["__dict__"]): + self.generate_dict_getter_function(scope, code) + if scope.defines_any_special(TypeSlots.richcmp_special_methods): + self.generate_richcmp_function(scope, code) + self.generate_property_accessors(scope, code) + self.generate_method_table(scope, code) + self.generate_getset_table(scope, code) + self.generate_typeobj_definition(full_module_name, entry, code) + + def generate_exttype_vtable(self, scope, code): + # Generate the definition of an extension type's vtable. + type = scope.parent_type + if type.vtable_cname: + code.putln("static struct %s %s;" % ( + type.vtabstruct_cname, + type.vtable_cname)) + + def generate_self_cast(self, scope, code): + type = scope.parent_type + code.putln( + "%s = (%s)o;" % ( + type.declaration_code("p"), + type.empty_declaration_code())) + + def generate_new_function(self, scope, code, cclass_entry): + tp_slot = TypeSlots.ConstructorSlot("tp_new", '__new__') + slot_func = scope.mangle_internal("tp_new") + type = scope.parent_type + base_type = type.base_type + + have_entries, (py_attrs, py_buffers, memoryview_slices) = \ + scope.get_refcounted_entries() + is_final_type = scope.parent_type.is_final_type + if scope.is_internal: + # internal classes (should) never need None inits, normal zeroing will do + py_attrs = [] + cpp_class_attrs = [entry for entry in scope.var_entries + if entry.type.is_cpp_class] + + new_func_entry = scope.lookup_here("__new__") + if base_type or (new_func_entry and new_func_entry.is_special + and not new_func_entry.trivial_signature): + unused_marker = '' + else: + unused_marker = 'CYTHON_UNUSED ' + + if base_type: + freelist_size = 0 # not currently supported + else: + freelist_size = scope.directives.get('freelist', 0) + freelist_name = scope.mangle_internal(Naming.freelist_name) + freecount_name = scope.mangle_internal(Naming.freecount_name) + + decls = code.globalstate['decls'] + decls.putln("static PyObject *%s(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/" % + slot_func) + code.putln("") + if freelist_size: + code.putln("static %s[%d];" % ( + scope.parent_type.declaration_code(freelist_name), + freelist_size)) + code.putln("static int %s = 0;" % freecount_name) + code.putln("") + code.putln( + "static PyObject *%s(PyTypeObject *t, %sPyObject *a, %sPyObject *k) {" % ( + slot_func, unused_marker, unused_marker)) + + need_self_cast = (type.vtabslot_cname or + (py_buffers or memoryview_slices or py_attrs) or + cpp_class_attrs) + if need_self_cast: + code.putln("%s;" % scope.parent_type.declaration_code("p")) + if base_type: + tp_new = TypeSlots.get_base_slot_function(scope, tp_slot) + if tp_new is None: + tp_new = "%s->tp_new" % base_type.typeptr_cname + code.putln("PyObject *o = %s(t, a, k);" % tp_new) + else: + code.putln("PyObject *o;") + if freelist_size: + code.globalstate.use_utility_code( + UtilityCode.load_cached("IncludeStringH", "StringTools.c")) + if is_final_type: + type_safety_check = '' + else: + type_safety_check = ' & (int)((t->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0)' + obj_struct = type.declaration_code("", deref=True) + code.putln( + "if (CYTHON_COMPILING_IN_CPYTHON & likely((int)(%s > 0) & (int)(t->tp_basicsize == sizeof(%s))%s)) {" % ( + freecount_name, obj_struct, type_safety_check)) + code.putln("o = (PyObject*)%s[--%s];" % ( + freelist_name, freecount_name)) + code.putln("memset(o, 0, sizeof(%s));" % obj_struct) + code.putln("(void) PyObject_INIT(o, t);") + if scope.needs_gc(): + code.putln("PyObject_GC_Track(o);") + code.putln("} else {") + if not is_final_type: + code.putln("if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {") + code.putln("o = (*t->tp_alloc)(t, 0);") + if not is_final_type: + code.putln("} else {") + code.putln("o = (PyObject *) PyBaseObject_Type.tp_new(t, %s, 0);" % Naming.empty_tuple) + code.putln("}") + code.putln("if (unlikely(!o)) return 0;") + if freelist_size and not base_type: + code.putln('}') + if need_self_cast: + code.putln("p = %s;" % type.cast_code("o")) + #if need_self_cast: + # self.generate_self_cast(scope, code) + + # from this point on, ensure DECREF(o) on failure + needs_error_cleanup = False + + if type.vtabslot_cname: + vtab_base_type = type + while vtab_base_type.base_type and vtab_base_type.base_type.vtabstruct_cname: + vtab_base_type = vtab_base_type.base_type + if vtab_base_type is not type: + struct_type_cast = "(struct %s*)" % vtab_base_type.vtabstruct_cname + else: + struct_type_cast = "" + code.putln("p->%s = %s%s;" % ( + type.vtabslot_cname, + struct_type_cast, type.vtabptr_cname)) + + for entry in cpp_class_attrs: + code.putln("new((void*)&(p->%s)) %s();" % ( + entry.cname, entry.type.empty_declaration_code())) + + for entry in py_attrs: + if entry.name == "__dict__": + needs_error_cleanup = True + code.put("p->%s = PyDict_New(); if (unlikely(!p->%s)) goto bad;" % ( + entry.cname, entry.cname)) + else: + code.put_init_var_to_py_none(entry, "p->%s", nanny=False) + + for entry in memoryview_slices: + code.putln("p->%s.data = NULL;" % entry.cname) + code.putln("p->%s.memview = NULL;" % entry.cname) + + for entry in py_buffers: + code.putln("p->%s.obj = NULL;" % entry.cname) + + if cclass_entry.cname == '__pyx_memoryviewslice': + code.putln("p->from_slice.memview = NULL;") + + if new_func_entry and new_func_entry.is_special: + if new_func_entry.trivial_signature: + cinit_args = "o, %s, NULL" % Naming.empty_tuple + else: + cinit_args = "o, a, k" + needs_error_cleanup = True + code.putln("if (unlikely(%s(%s) < 0)) goto bad;" % ( + new_func_entry.func_cname, cinit_args)) + + code.putln( + "return o;") + if needs_error_cleanup: + code.putln("bad:") + code.put_decref_clear("o", py_object_type, nanny=False) + code.putln("return NULL;") + code.putln( + "}") + + def generate_dealloc_function(self, scope, code): + tp_slot = TypeSlots.ConstructorSlot("tp_dealloc", '__dealloc__') + slot_func = scope.mangle_internal("tp_dealloc") + base_type = scope.parent_type.base_type + if tp_slot.slot_code(scope) != slot_func: + return # never used + + slot_func_cname = scope.mangle_internal("tp_dealloc") + code.putln("") + code.putln( + "static void %s(PyObject *o) {" % slot_func_cname) + + is_final_type = scope.parent_type.is_final_type + needs_gc = scope.needs_gc() + + weakref_slot = scope.lookup_here("__weakref__") if not scope.is_closure_class_scope else None + if weakref_slot not in scope.var_entries: + weakref_slot = None + + dict_slot = scope.lookup_here("__dict__") if not scope.is_closure_class_scope else None + if dict_slot not in scope.var_entries: + dict_slot = None + + _, (py_attrs, _, memoryview_slices) = scope.get_refcounted_entries() + cpp_class_attrs = [entry for entry in scope.var_entries + if entry.type.is_cpp_class] + + if py_attrs or cpp_class_attrs or memoryview_slices or weakref_slot or dict_slot: + self.generate_self_cast(scope, code) + + if not is_final_type: + # in Py3.4+, call tp_finalize() as early as possible + code.putln("#if CYTHON_USE_TP_FINALIZE") + if needs_gc: + finalised_check = '!_PyGC_FINALIZED(o)' + else: + finalised_check = ( + '(!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))') + code.putln( + "if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE)" + " && Py_TYPE(o)->tp_finalize) && %s) {" % finalised_check) + # if instance was resurrected by finaliser, return + code.putln("if (PyObject_CallFinalizerFromDealloc(o)) return;") + code.putln("}") + code.putln("#endif") + + if needs_gc: + # We must mark this object as (gc) untracked while tearing + # it down, lest the garbage collection is invoked while + # running this destructor. + code.putln("PyObject_GC_UnTrack(o);") + + # call the user's __dealloc__ + self.generate_usr_dealloc_call(scope, code) + + if weakref_slot: + code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);") + + if dict_slot: + code.putln("if (p->__dict__) PyDict_Clear(p->__dict__);") + + for entry in cpp_class_attrs: + code.putln("__Pyx_call_destructor(p->%s);" % entry.cname) + + for entry in py_attrs: + code.put_xdecref_clear("p->%s" % entry.cname, entry.type, nanny=False, + clear_before_decref=True) + + for entry in memoryview_slices: + code.put_xdecref_memoryviewslice("p->%s" % entry.cname, + have_gil=True) + + if base_type: + if needs_gc: + # The base class deallocator probably expects this to be tracked, + # so undo the untracking above. + if base_type.scope and base_type.scope.needs_gc(): + code.putln("PyObject_GC_Track(o);") + else: + code.putln("#if CYTHON_USE_TYPE_SLOTS") + code.putln("if (PyType_IS_GC(Py_TYPE(o)->tp_base))") + code.putln("#endif") + code.putln("PyObject_GC_Track(o);") + + tp_dealloc = TypeSlots.get_base_slot_function(scope, tp_slot) + if tp_dealloc is not None: + code.putln("%s(o);" % tp_dealloc) + elif base_type.is_builtin_type: + code.putln("%s->tp_dealloc(o);" % base_type.typeptr_cname) + else: + # This is an externally defined type. Calling through the + # cimported base type pointer directly interacts badly with + # the module cleanup, which may already have cleared it. + # In that case, fall back to traversing the type hierarchy. + base_cname = base_type.typeptr_cname + code.putln("if (likely(%s)) %s->tp_dealloc(o); " + "else __Pyx_call_next_tp_dealloc(o, %s);" % ( + base_cname, base_cname, slot_func_cname)) + code.globalstate.use_utility_code( + UtilityCode.load_cached("CallNextTpDealloc", "ExtensionTypes.c")) + else: + freelist_size = scope.directives.get('freelist', 0) + if freelist_size: + freelist_name = scope.mangle_internal(Naming.freelist_name) + freecount_name = scope.mangle_internal(Naming.freecount_name) + + if is_final_type: + type_safety_check = '' + else: + type_safety_check = ( + ' & (int)((Py_TYPE(o)->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0)') + + type = scope.parent_type + code.putln( + "if (CYTHON_COMPILING_IN_CPYTHON & ((int)(%s < %d) & (int)(Py_TYPE(o)->tp_basicsize == sizeof(%s))%s)) {" % ( + freecount_name, + freelist_size, + type.declaration_code("", deref=True), + type_safety_check)) + code.putln("%s[%s++] = %s;" % ( + freelist_name, freecount_name, type.cast_code("o"))) + code.putln("} else {") + code.putln("(*Py_TYPE(o)->tp_free)(o);") + if freelist_size: + code.putln("}") + code.putln( + "}") + + def generate_usr_dealloc_call(self, scope, code): + entry = scope.lookup_here("__dealloc__") + if not entry: + return + + code.putln("{") + code.putln("PyObject *etype, *eval, *etb;") + code.putln("PyErr_Fetch(&etype, &eval, &etb);") + # increase the refcount while we are calling into user code + # to prevent recursive deallocation + code.putln("__Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);") + code.putln("%s(o);" % entry.func_cname) + code.putln("__Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);") + code.putln("PyErr_Restore(etype, eval, etb);") + code.putln("}") + + def generate_traverse_function(self, scope, code, cclass_entry): + tp_slot = TypeSlots.GCDependentSlot("tp_traverse") + slot_func = scope.mangle_internal("tp_traverse") + base_type = scope.parent_type.base_type + if tp_slot.slot_code(scope) != slot_func: + return # never used + code.putln("") + code.putln( + "static int %s(PyObject *o, visitproc v, void *a) {" % slot_func) + + have_entries, (py_attrs, py_buffers, memoryview_slices) = ( + scope.get_refcounted_entries(include_gc_simple=False)) + + if base_type or py_attrs: + code.putln("int e;") + + if py_attrs or py_buffers: + self.generate_self_cast(scope, code) + + if base_type: + # want to call it explicitly if possible so inlining can be performed + static_call = TypeSlots.get_base_slot_function(scope, tp_slot) + if static_call: + code.putln("e = %s(o, v, a); if (e) return e;" % static_call) + elif base_type.is_builtin_type: + base_cname = base_type.typeptr_cname + code.putln("if (!%s->tp_traverse); else { e = %s->tp_traverse(o,v,a); if (e) return e; }" % ( + base_cname, base_cname)) + else: + # This is an externally defined type. Calling through the + # cimported base type pointer directly interacts badly with + # the module cleanup, which may already have cleared it. + # In that case, fall back to traversing the type hierarchy. + base_cname = base_type.typeptr_cname + code.putln( + "e = ((likely(%s)) ? ((%s->tp_traverse) ? %s->tp_traverse(o, v, a) : 0) : " + "__Pyx_call_next_tp_traverse(o, v, a, %s)); if (e) return e;" % ( + base_cname, base_cname, base_cname, slot_func)) + code.globalstate.use_utility_code( + UtilityCode.load_cached("CallNextTpTraverse", "ExtensionTypes.c")) + + for entry in py_attrs: + var_code = "p->%s" % entry.cname + var_as_pyobject = PyrexTypes.typecast(py_object_type, entry.type, var_code) + code.putln("if (%s) {" % var_code) + code.putln("e = (*v)(%s, a); if (e) return e;" % var_as_pyobject) + code.putln("}") + + # Traverse buffer exporting objects. + # Note: not traversing memoryview attributes of memoryview slices! + # When triggered by the GC, it would cause multiple visits (gc_refs + # subtractions which is not matched by its reference count!) + for entry in py_buffers: + cname = entry.cname + ".obj" + code.putln("if (p->%s) {" % cname) + code.putln("e = (*v)(p->%s, a); if (e) return e;" % cname) + code.putln("}") + + code.putln("return 0;") + code.putln("}") + + def generate_clear_function(self, scope, code, cclass_entry): + tp_slot = TypeSlots.get_slot_by_name("tp_clear") + slot_func = scope.mangle_internal("tp_clear") + base_type = scope.parent_type.base_type + if tp_slot.slot_code(scope) != slot_func: + return # never used + + have_entries, (py_attrs, py_buffers, memoryview_slices) = ( + scope.get_refcounted_entries(include_gc_simple=False)) + + if py_attrs or py_buffers or base_type: + unused = '' + else: + unused = 'CYTHON_UNUSED ' + + code.putln("") + code.putln("static int %s(%sPyObject *o) {" % (slot_func, unused)) + + if py_attrs and Options.clear_to_none: + code.putln("PyObject* tmp;") + + if py_attrs or py_buffers: + self.generate_self_cast(scope, code) + + if base_type: + # want to call it explicitly if possible so inlining can be performed + static_call = TypeSlots.get_base_slot_function(scope, tp_slot) + if static_call: + code.putln("%s(o);" % static_call) + elif base_type.is_builtin_type: + base_cname = base_type.typeptr_cname + code.putln("if (!%s->tp_clear); else %s->tp_clear(o);" % ( + base_cname, base_cname)) + else: + # This is an externally defined type. Calling through the + # cimported base type pointer directly interacts badly with + # the module cleanup, which may already have cleared it. + # In that case, fall back to traversing the type hierarchy. + base_cname = base_type.typeptr_cname + code.putln( + "if (likely(%s)) { if (%s->tp_clear) %s->tp_clear(o); } else __Pyx_call_next_tp_clear(o, %s);" % ( + base_cname, base_cname, base_cname, slot_func)) + code.globalstate.use_utility_code( + UtilityCode.load_cached("CallNextTpClear", "ExtensionTypes.c")) + + if Options.clear_to_none: + for entry in py_attrs: + name = "p->%s" % entry.cname + code.putln("tmp = ((PyObject*)%s);" % name) + if entry.is_declared_generic: + code.put_init_to_py_none(name, py_object_type, nanny=False) + else: + code.put_init_to_py_none(name, entry.type, nanny=False) + code.putln("Py_XDECREF(tmp);") + else: + for entry in py_attrs: + code.putln("Py_CLEAR(p->%s);" % entry.cname) + + for entry in py_buffers: + # Note: shouldn't this call __Pyx_ReleaseBuffer ?? + code.putln("Py_CLEAR(p->%s.obj);" % entry.cname) + + if cclass_entry.cname == '__pyx_memoryviewslice': + code.putln("__PYX_XDEC_MEMVIEW(&p->from_slice, 1);") + + code.putln("return 0;") + code.putln("}") + + def generate_getitem_int_function(self, scope, code): + # This function is put into the sq_item slot when + # a __getitem__ method is present. It converts its + # argument to a Python integer and calls mp_subscript. + code.putln( + "static PyObject *%s(PyObject *o, Py_ssize_t i) {" % ( + scope.mangle_internal("sq_item"))) + code.putln( + "PyObject *r;") + code.putln( + "PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;") + code.putln( + "r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);") + code.putln( + "Py_DECREF(x);") + code.putln( + "return r;") + code.putln( + "}") + + def generate_ass_subscript_function(self, scope, code): + # Setting and deleting an item are both done through + # the ass_subscript method, so we dispatch to user's __setitem__ + # or __delitem__, or raise an exception. + base_type = scope.parent_type.base_type + set_entry = scope.lookup_here("__setitem__") + del_entry = scope.lookup_here("__delitem__") + code.putln("") + code.putln( + "static int %s(PyObject *o, PyObject *i, PyObject *v) {" % ( + scope.mangle_internal("mp_ass_subscript"))) + code.putln( + "if (v) {") + if set_entry: + code.putln("return %s(o, i, v);" % set_entry.func_cname) + else: + self.generate_guarded_basetype_call( + base_type, "tp_as_mapping", "mp_ass_subscript", "o, i, v", code) + code.putln( + "PyErr_Format(PyExc_NotImplementedError,") + code.putln( + ' "Subscript assignment not supported by %.200s", Py_TYPE(o)->tp_name);') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "else {") + if del_entry: + code.putln( + "return %s(o, i);" % ( + del_entry.func_cname)) + else: + self.generate_guarded_basetype_call( + base_type, "tp_as_mapping", "mp_ass_subscript", "o, i, v", code) + code.putln( + "PyErr_Format(PyExc_NotImplementedError,") + code.putln( + ' "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "}") + + def generate_guarded_basetype_call( + self, base_type, substructure, slot, args, code): + if base_type: + base_tpname = base_type.typeptr_cname + if substructure: + code.putln( + "if (%s->%s && %s->%s->%s)" % ( + base_tpname, substructure, base_tpname, substructure, slot)) + code.putln( + " return %s->%s->%s(%s);" % ( + base_tpname, substructure, slot, args)) + else: + code.putln( + "if (%s->%s)" % ( + base_tpname, slot)) + code.putln( + " return %s->%s(%s);" % ( + base_tpname, slot, args)) + + def generate_ass_slice_function(self, scope, code): + # Setting and deleting a slice are both done through + # the ass_slice method, so we dispatch to user's __setslice__ + # or __delslice__, or raise an exception. + base_type = scope.parent_type.base_type + set_entry = scope.lookup_here("__setslice__") + del_entry = scope.lookup_here("__delslice__") + code.putln("") + code.putln( + "static int %s(PyObject *o, Py_ssize_t i, Py_ssize_t j, PyObject *v) {" % ( + scope.mangle_internal("sq_ass_slice"))) + code.putln( + "if (v) {") + if set_entry: + code.putln( + "return %s(o, i, j, v);" % ( + set_entry.func_cname)) + else: + self.generate_guarded_basetype_call( + base_type, "tp_as_sequence", "sq_ass_slice", "o, i, j, v", code) + code.putln( + "PyErr_Format(PyExc_NotImplementedError,") + code.putln( + ' "2-element slice assignment not supported by %.200s", Py_TYPE(o)->tp_name);') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "else {") + if del_entry: + code.putln( + "return %s(o, i, j);" % ( + del_entry.func_cname)) + else: + self.generate_guarded_basetype_call( + base_type, "tp_as_sequence", "sq_ass_slice", "o, i, j, v", code) + code.putln( + "PyErr_Format(PyExc_NotImplementedError,") + code.putln( + ' "2-element slice deletion not supported by %.200s", Py_TYPE(o)->tp_name);') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "}") + + def generate_richcmp_function(self, scope, code): + if scope.lookup_here("__richcmp__"): + # user implemented, nothing to do + return + # otherwise, we have to generate it from the Python special methods + richcmp_cfunc = scope.mangle_internal("tp_richcompare") + code.putln("") + code.putln("static PyObject *%s(PyObject *o1, PyObject *o2, int op) {" % richcmp_cfunc) + code.putln("switch (op) {") + + class_scopes = [] + cls = scope.parent_type + while cls is not None and not cls.entry.visibility == 'extern': + class_scopes.append(cls.scope) + cls = cls.scope.parent_type.base_type + assert scope in class_scopes + + extern_parent = None + if cls and cls.entry.visibility == 'extern': + # need to call up into base classes as we may not know all implemented comparison methods + extern_parent = cls if cls.typeptr_cname else scope.parent_type.base_type + + eq_entry = None + has_ne = False + for cmp_method in TypeSlots.richcmp_special_methods: + for class_scope in class_scopes: + entry = class_scope.lookup_here(cmp_method) + if entry is not None: + break + else: + continue + + cmp_type = cmp_method.strip('_').upper() # e.g. "__eq__" -> EQ + code.putln("case Py_%s: {" % cmp_type) + if cmp_method == '__eq__': + eq_entry = entry + # Python itself does not do this optimisation, it seems... + #code.putln("if (o1 == o2) return __Pyx_NewRef(Py_True);") + elif cmp_method == '__ne__': + has_ne = True + # Python itself does not do this optimisation, it seems... + #code.putln("if (o1 == o2) return __Pyx_NewRef(Py_False);") + code.putln("return %s(o1, o2);" % entry.func_cname) + code.putln("}") + + if eq_entry and not has_ne and not extern_parent: + code.putln("case Py_NE: {") + code.putln("PyObject *ret;") + # Python itself does not do this optimisation, it seems... + #code.putln("if (o1 == o2) return __Pyx_NewRef(Py_False);") + code.putln("ret = %s(o1, o2);" % eq_entry.func_cname) + code.putln("if (likely(ret && ret != Py_NotImplemented)) {") + code.putln("int b = __Pyx_PyObject_IsTrue(ret); Py_DECREF(ret);") + code.putln("if (unlikely(b < 0)) return NULL;") + code.putln("ret = (b) ? Py_False : Py_True;") + code.putln("Py_INCREF(ret);") + code.putln("}") + code.putln("return ret;") + code.putln("}") + + code.putln("default: {") + if extern_parent and extern_parent.typeptr_cname: + code.putln("if (likely(%s->tp_richcompare)) return %s->tp_richcompare(o1, o2, op);" % ( + extern_parent.typeptr_cname, extern_parent.typeptr_cname)) + code.putln("return __Pyx_NewRef(Py_NotImplemented);") + code.putln("}") + + code.putln("}") # switch + code.putln("}") + + def generate_getattro_function(self, scope, code): + # First try to get the attribute using __getattribute__, if defined, or + # PyObject_GenericGetAttr. + # + # If that raises an AttributeError, call the __getattr__ if defined. + # + # In both cases, defined can be in this class, or any base class. + def lookup_here_or_base(n, tp=None, extern_return=None): + # Recursive lookup + if tp is None: + tp = scope.parent_type + r = tp.scope.lookup_here(n) + if r is None: + if tp.is_external and extern_return is not None: + return extern_return + if tp.base_type is not None: + return lookup_here_or_base(n, tp.base_type) + return r + + has_instance_dict = lookup_here_or_base("__dict__", extern_return="extern") + getattr_entry = lookup_here_or_base("__getattr__") + getattribute_entry = lookup_here_or_base("__getattribute__") + code.putln("") + code.putln( + "static PyObject *%s(PyObject *o, PyObject *n) {" % ( + scope.mangle_internal("tp_getattro"))) + if getattribute_entry is not None: + code.putln( + "PyObject *v = %s(o, n);" % ( + getattribute_entry.func_cname)) + else: + if not has_instance_dict and scope.parent_type.is_final_type: + # Final with no dict => use faster type attribute lookup. + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObject_GenericGetAttrNoDict", "ObjectHandling.c")) + generic_getattr_cfunc = "__Pyx_PyObject_GenericGetAttrNoDict" + elif not has_instance_dict or has_instance_dict == "extern": + # No dict in the known ancestors, but don't know about extern ancestors or subtypes. + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObject_GenericGetAttr", "ObjectHandling.c")) + generic_getattr_cfunc = "__Pyx_PyObject_GenericGetAttr" + else: + generic_getattr_cfunc = "PyObject_GenericGetAttr" + code.putln( + "PyObject *v = %s(o, n);" % generic_getattr_cfunc) + if getattr_entry is not None: + code.putln( + "if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {") + code.putln( + "PyErr_Clear();") + code.putln( + "v = %s(o, n);" % ( + getattr_entry.func_cname)) + code.putln( + "}") + code.putln( + "return v;") + code.putln( + "}") + + def generate_setattro_function(self, scope, code): + # Setting and deleting an attribute are both done through + # the setattro method, so we dispatch to user's __setattr__ + # or __delattr__ or fall back on PyObject_GenericSetAttr. + base_type = scope.parent_type.base_type + set_entry = scope.lookup_here("__setattr__") + del_entry = scope.lookup_here("__delattr__") + code.putln("") + code.putln( + "static int %s(PyObject *o, PyObject *n, PyObject *v) {" % ( + scope.mangle_internal("tp_setattro"))) + code.putln( + "if (v) {") + if set_entry: + code.putln( + "return %s(o, n, v);" % ( + set_entry.func_cname)) + else: + self.generate_guarded_basetype_call( + base_type, None, "tp_setattro", "o, n, v", code) + code.putln( + "return PyObject_GenericSetAttr(o, n, v);") + code.putln( + "}") + code.putln( + "else {") + if del_entry: + code.putln( + "return %s(o, n);" % ( + del_entry.func_cname)) + else: + self.generate_guarded_basetype_call( + base_type, None, "tp_setattro", "o, n, v", code) + code.putln( + "return PyObject_GenericSetAttr(o, n, 0);") + code.putln( + "}") + code.putln( + "}") + + def generate_descr_get_function(self, scope, code): + # The __get__ function of a descriptor object can be + # called with NULL for the second or third arguments + # under some circumstances, so we replace them with + # None in that case. + user_get_entry = scope.lookup_here("__get__") + code.putln("") + code.putln( + "static PyObject *%s(PyObject *o, PyObject *i, PyObject *c) {" % ( + scope.mangle_internal("tp_descr_get"))) + code.putln( + "PyObject *r = 0;") + code.putln( + "if (!i) i = Py_None;") + code.putln( + "if (!c) c = Py_None;") + #code.put_incref("i", py_object_type) + #code.put_incref("c", py_object_type) + code.putln( + "r = %s(o, i, c);" % ( + user_get_entry.func_cname)) + #code.put_decref("i", py_object_type) + #code.put_decref("c", py_object_type) + code.putln( + "return r;") + code.putln( + "}") + + def generate_descr_set_function(self, scope, code): + # Setting and deleting are both done through the __set__ + # method of a descriptor, so we dispatch to user's __set__ + # or __delete__ or raise an exception. + base_type = scope.parent_type.base_type + user_set_entry = scope.lookup_here("__set__") + user_del_entry = scope.lookup_here("__delete__") + code.putln("") + code.putln( + "static int %s(PyObject *o, PyObject *i, PyObject *v) {" % ( + scope.mangle_internal("tp_descr_set"))) + code.putln( + "if (v) {") + if user_set_entry: + code.putln( + "return %s(o, i, v);" % ( + user_set_entry.func_cname)) + else: + self.generate_guarded_basetype_call( + base_type, None, "tp_descr_set", "o, i, v", code) + code.putln( + 'PyErr_SetString(PyExc_NotImplementedError, "__set__");') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "else {") + if user_del_entry: + code.putln( + "return %s(o, i);" % ( + user_del_entry.func_cname)) + else: + self.generate_guarded_basetype_call( + base_type, None, "tp_descr_set", "o, i, v", code) + code.putln( + 'PyErr_SetString(PyExc_NotImplementedError, "__delete__");') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "}") + + def generate_property_accessors(self, cclass_scope, code): + for entry in cclass_scope.property_entries: + property_scope = entry.scope + if property_scope.defines_any(["__get__"]): + self.generate_property_get_function(entry, code) + if property_scope.defines_any(["__set__", "__del__"]): + self.generate_property_set_function(entry, code) + + def generate_property_get_function(self, property_entry, code): + property_scope = property_entry.scope + property_entry.getter_cname = property_scope.parent_scope.mangle( + Naming.prop_get_prefix, property_entry.name) + get_entry = property_scope.lookup_here("__get__") + code.putln("") + code.putln( + "static PyObject *%s(PyObject *o, CYTHON_UNUSED void *x) {" % ( + property_entry.getter_cname)) + code.putln( + "return %s(o);" % ( + get_entry.func_cname)) + code.putln( + "}") + + def generate_property_set_function(self, property_entry, code): + property_scope = property_entry.scope + property_entry.setter_cname = property_scope.parent_scope.mangle( + Naming.prop_set_prefix, property_entry.name) + set_entry = property_scope.lookup_here("__set__") + del_entry = property_scope.lookup_here("__del__") + code.putln("") + code.putln( + "static int %s(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {" % ( + property_entry.setter_cname)) + code.putln( + "if (v) {") + if set_entry: + code.putln( + "return %s(o, v);" % ( + set_entry.func_cname)) + else: + code.putln( + 'PyErr_SetString(PyExc_NotImplementedError, "__set__");') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "else {") + if del_entry: + code.putln( + "return %s(o);" % ( + del_entry.func_cname)) + else: + code.putln( + 'PyErr_SetString(PyExc_NotImplementedError, "__del__");') + code.putln( + "return -1;") + code.putln( + "}") + code.putln( + "}") + + def generate_typeobj_definition(self, modname, entry, code): + type = entry.type + scope = type.scope + for suite in TypeSlots.substructures: + suite.generate_substructure(scope, code) + code.putln("") + if entry.visibility == 'public': + header = "DL_EXPORT(PyTypeObject) %s = {" + else: + header = "static PyTypeObject %s = {" + #code.putln(header % scope.parent_type.typeobj_cname) + code.putln(header % type.typeobj_cname) + code.putln( + "PyVarObject_HEAD_INIT(0, 0)") + code.putln( + '"%s.%s", /*tp_name*/' % ( + self.full_module_name, scope.class_name)) + if type.typedef_flag: + objstruct = type.objstruct_cname + else: + objstruct = "struct %s" % type.objstruct_cname + code.putln( + "sizeof(%s), /*tp_basicsize*/" % objstruct) + code.putln( + "0, /*tp_itemsize*/") + for slot in TypeSlots.slot_table: + slot.generate(scope, code) + code.putln( + "};") + + def generate_method_table(self, env, code): + if env.is_c_class_scope and not env.pyfunc_entries: + return + binding = env.directives['binding'] + + code.putln("") + wrapper_code_writer = code.insertion_point() + + code.putln( + "static PyMethodDef %s[] = {" % ( + env.method_table_cname)) + for entry in env.pyfunc_entries: + if not entry.fused_cfunction and not (binding and entry.is_overridable): + code.put_pymethoddef(entry, ",", wrapper_code_writer=wrapper_code_writer) + code.putln( + "{0, 0, 0, 0}") + code.putln( + "};") + + if wrapper_code_writer.getvalue(): + wrapper_code_writer.putln("") + + def generate_dict_getter_function(self, scope, code): + dict_attr = scope.lookup_here("__dict__") + if not dict_attr or not dict_attr.is_variable: + return + func_name = scope.mangle_internal("__dict__getter") + dict_name = dict_attr.cname + code.putln("") + code.putln("static PyObject *%s(PyObject *o, CYTHON_UNUSED void *x) {" % func_name) + self.generate_self_cast(scope, code) + code.putln("if (unlikely(!p->%s)){" % dict_name) + code.putln("p->%s = PyDict_New();" % dict_name) + code.putln("}") + code.putln("Py_XINCREF(p->%s);" % dict_name) + code.putln("return p->%s;" % dict_name) + code.putln("}") + + def generate_getset_table(self, env, code): + if env.property_entries: + code.putln("") + code.putln( + "static struct PyGetSetDef %s[] = {" % + env.getset_table_cname) + for entry in env.property_entries: + doc = entry.doc + if doc: + if doc.is_unicode: + doc = doc.as_utf8_string() + doc_code = doc.as_c_string_literal() + else: + doc_code = "0" + code.putln( + '{(char *)"%s", %s, %s, (char *)%s, 0},' % ( + entry.name, + entry.getter_cname or "0", + entry.setter_cname or "0", + doc_code)) + code.putln( + "{0, 0, 0, 0, 0}") + code.putln( + "};") + + def create_import_star_conversion_utility_code(self, env): + # Create all conversion helpers that are needed for "import *" assignments. + # Must be done before code generation to support CythonUtilityCode. + for name, entry in sorted(env.entries.items()): + if entry.is_cglobal and entry.used: + if not entry.type.is_pyobject: + entry.type.create_from_py_utility_code(env) + + def generate_import_star(self, env, code): + env.use_utility_code(UtilityCode.load_cached("CStringEquals", "StringTools.c")) + code.putln() + code.enter_cfunc_scope() # as we need labels + code.putln("static int %s(PyObject *o, PyObject* py_name, char *name) {" % Naming.import_star_set) + + code.putln("static const char* internal_type_names[] = {") + for name, entry in sorted(env.entries.items()): + if entry.is_type: + code.putln('"%s",' % name) + code.putln("0") + code.putln("};") + + code.putln("const char** type_name = internal_type_names;") + code.putln("while (*type_name) {") + code.putln("if (__Pyx_StrEq(name, *type_name)) {") + code.putln('PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name);') + code.putln('goto bad;') + code.putln("}") + code.putln("type_name++;") + code.putln("}") + + old_error_label = code.new_error_label() + code.putln("if (0);") # so the first one can be "else if" + msvc_count = 0 + for name, entry in sorted(env.entries.items()): + if entry.is_cglobal and entry.used and not entry.type.is_const: + msvc_count += 1 + if msvc_count % 100 == 0: + code.putln("#ifdef _MSC_VER") + code.putln("if (0); /* Workaround for MSVC C1061. */") + code.putln("#endif") + code.putln('else if (__Pyx_StrEq(name, "%s")) {' % name) + if entry.type.is_pyobject: + if entry.type.is_extension_type or entry.type.is_builtin_type: + code.putln("if (!(%s)) %s;" % ( + entry.type.type_test_code("o"), + code.error_goto(entry.pos))) + code.putln("Py_INCREF(o);") + code.put_decref(entry.cname, entry.type, nanny=False) + code.putln("%s = %s;" % ( + entry.cname, + PyrexTypes.typecast(entry.type, py_object_type, "o"))) + elif entry.type.create_from_py_utility_code(env): + # if available, utility code was already created in self.prepare_utility_code() + code.putln(entry.type.from_py_call_code( + 'o', entry.cname, entry.pos, code)) + else: + code.putln('PyErr_Format(PyExc_TypeError, "Cannot convert Python object %s to %s");' % ( + name, entry.type)) + code.putln(code.error_goto(entry.pos)) + code.putln("}") + code.putln("else {") + code.putln("if (PyObject_SetAttr(%s, py_name, o) < 0) goto bad;" % Naming.module_cname) + code.putln("}") + code.putln("return 0;") + if code.label_used(code.error_label): + code.put_label(code.error_label) + # This helps locate the offending name. + code.put_add_traceback(self.full_module_name) + code.error_label = old_error_label + code.putln("bad:") + code.putln("return -1;") + code.putln("}") + code.putln("") + code.putln(UtilityCode.load_as_string("ImportStar", "ImportExport.c")[1]) + code.exit_cfunc_scope() # done with labels + + def generate_module_init_func(self, imported_modules, env, options, code): + subfunction = self.mod_init_subfunction(self.pos, self.scope, code) + + code.enter_cfunc_scope(self.scope) + code.putln("") + code.putln(UtilityCode.load_as_string("PyModInitFuncType", "ModuleSetupCode.c")[0]) + init_name = 'init' + (options.init_suffix or env.module_name) + header2 = "__Pyx_PyMODINIT_FUNC %s(void)" % init_name + header3 = "__Pyx_PyMODINIT_FUNC %s(void)" % self.mod_init_func_cname('PyInit', env, options) + code.putln("#if PY_MAJOR_VERSION < 3") + # Optimise for small code size as the module init function is only executed once. + code.putln("%s CYTHON_SMALL_CODE; /*proto*/" % header2) + code.putln(header2) + code.putln("#else") + code.putln("%s CYTHON_SMALL_CODE; /*proto*/" % header3) + code.putln(header3) + + # CPython 3.5+ supports multi-phase module initialisation (gives access to __spec__, __file__, etc.) + code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") + code.putln("{") + code.putln("return PyModuleDef_Init(&%s);" % Naming.pymoduledef_cname) + code.putln("}") + + mod_create_func = UtilityCode.load_as_string("ModuleCreationPEP489", "ModuleSetupCode.c")[1] + code.put(mod_create_func) + + code.putln("") + # main module init code lives in Py_mod_exec function, not in PyInit function + code.putln("static CYTHON_SMALL_CODE int %s(PyObject *%s)" % ( + self.mod_init_func_cname(Naming.pymodule_exec_func_cname, env), + Naming.pymodinit_module_arg)) + code.putln("#endif") # PEP489 + + code.putln("#endif") # Py3 + + # start of module init/exec function (pre/post PEP 489) + code.putln("{") + + tempdecl_code = code.insertion_point() + + profile = code.globalstate.directives['profile'] + linetrace = code.globalstate.directives['linetrace'] + if profile or linetrace: + code.globalstate.use_utility_code(UtilityCode.load_cached("Profile", "Profile.c")) + + code.put_declare_refcount_context() + code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") + # Most extension modules simply can't deal with it, and Cython isn't ready either. + # See issues listed here: https://docs.python.org/3/c-api/init.html#sub-interpreter-support + code.putln("if (%s) {" % Naming.module_cname) + # Hack: enforce single initialisation. + code.putln("if (%s == %s) return 0;" % ( + Naming.module_cname, + Naming.pymodinit_module_arg, + )) + code.putln('PyErr_SetString(PyExc_RuntimeError,' + ' "Module \'%s\' has already been imported. Re-initialisation is not supported.");' % + env.module_name) + code.putln("return -1;") + code.putln("}") + code.putln("#elif PY_MAJOR_VERSION >= 3") + # Hack: enforce single initialisation also on reimports under different names on Python 3 (with PEP 3121/489). + code.putln("if (%s) return __Pyx_NewRef(%s);" % ( + Naming.module_cname, + Naming.module_cname, + )) + code.putln("#endif") + + if profile or linetrace: + tempdecl_code.put_trace_declarations() + code.put_trace_frame_init() + + refnanny_import_code = UtilityCode.load_as_string("ImportRefnannyAPI", "ModuleSetupCode.c")[1] + code.putln(refnanny_import_code.rstrip()) + code.put_setup_refcount_context(header3) + + env.use_utility_code(UtilityCode.load("CheckBinaryVersion", "ModuleSetupCode.c")) + code.put_error_if_neg(self.pos, "__Pyx_check_binary_version()") + + code.putln("#ifdef __Pxy_PyFrame_Initialize_Offsets") + code.putln("__Pxy_PyFrame_Initialize_Offsets();") + code.putln("#endif") + code.putln("%s = PyTuple_New(0); %s" % ( + Naming.empty_tuple, code.error_goto_if_null(Naming.empty_tuple, self.pos))) + code.putln("%s = PyBytes_FromStringAndSize(\"\", 0); %s" % ( + Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos))) + code.putln("%s = PyUnicode_FromStringAndSize(\"\", 0); %s" % ( + Naming.empty_unicode, code.error_goto_if_null(Naming.empty_unicode, self.pos))) + + for ext_type in ('CyFunction', 'FusedFunction', 'Coroutine', 'Generator', 'AsyncGen', 'StopAsyncIteration'): + code.putln("#ifdef __Pyx_%s_USED" % ext_type) + code.put_error_if_neg(self.pos, "__pyx_%s_init()" % ext_type) + code.putln("#endif") + + code.putln("/*--- Library function declarations ---*/") + if env.directives['np_pythran']: + code.put_error_if_neg(self.pos, "_import_array()") + + code.putln("/*--- Threads initialization code ---*/") + code.putln("#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 " + "&& defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS") + code.putln("PyEval_InitThreads();") + code.putln("#endif") + + code.putln("/*--- Module creation code ---*/") + self.generate_module_creation_code(env, options, code) + + code.putln("/*--- Initialize various global constants etc. ---*/") + code.put_error_if_neg(self.pos, "__Pyx_InitGlobals()") + + code.putln("#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || " + "__PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)") + code.put_error_if_neg(self.pos, "__Pyx_init_sys_getdefaultencoding_params()") + code.putln("#endif") + + code.putln("if (%s%s) {" % (Naming.module_is_main, self.full_module_name.replace('.', '__'))) + code.put_error_if_neg(self.pos, 'PyObject_SetAttr(%s, %s, %s)' % ( + env.module_cname, + code.intern_identifier(EncodedString("__name__")), + code.intern_identifier(EncodedString("__main__")))) + code.putln("}") + + # set up __file__ and __path__, then add the module to sys.modules + self.generate_module_import_setup(env, code) + + if Options.cache_builtins: + code.putln("/*--- Builtin init code ---*/") + code.put_error_if_neg(self.pos, "__Pyx_InitCachedBuiltins()") + + code.putln("/*--- Constants init code ---*/") + code.put_error_if_neg(self.pos, "__Pyx_InitCachedConstants()") + + code.putln("/*--- Global type/function init code ---*/") + + with subfunction("Global init code") as inner_code: + self.generate_global_init_code(env, inner_code) + + with subfunction("Variable export code") as inner_code: + self.generate_c_variable_export_code(env, inner_code) + + with subfunction("Function export code") as inner_code: + self.generate_c_function_export_code(env, inner_code) + + with subfunction("Type init code") as inner_code: + self.generate_type_init_code(env, inner_code) + + with subfunction("Type import code") as inner_code: + for module in imported_modules: + self.generate_type_import_code_for_module(module, env, inner_code) + + with subfunction("Variable import code") as inner_code: + for module in imported_modules: + self.generate_c_variable_import_code_for_module(module, env, inner_code) + + with subfunction("Function import code") as inner_code: + for module in imported_modules: + self.specialize_fused_types(module) + self.generate_c_function_import_code_for_module(module, env, inner_code) + + code.putln("/*--- Execution code ---*/") + code.mark_pos(None) + + code.putln("#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)") + code.put_error_if_neg(self.pos, "__Pyx_patch_abc()") + code.putln("#endif") + + if profile or linetrace: + code.put_trace_call(header3, self.pos, nogil=not code.funcstate.gil_owned) + code.funcstate.can_trace = True + + self.body.generate_execution_code(code) + + if profile or linetrace: + code.funcstate.can_trace = False + code.put_trace_return("Py_None", nogil=not code.funcstate.gil_owned) + + code.putln() + code.putln("/*--- Wrapped vars code ---*/") + self.generate_wrapped_entries_code(env, code) + code.putln() + + if Options.generate_cleanup_code: + code.globalstate.use_utility_code( + UtilityCode.load_cached("RegisterModuleCleanup", "ModuleSetupCode.c")) + code.putln("if (__Pyx_RegisterCleanup()) %s" % code.error_goto(self.pos)) + + code.put_goto(code.return_label) + code.put_label(code.error_label) + for cname, type in code.funcstate.all_managed_temps(): + code.put_xdecref(cname, type) + code.putln('if (%s) {' % env.module_cname) + code.putln('if (%s) {' % env.module_dict_cname) + code.put_add_traceback("init %s" % env.qualified_name) + code.globalstate.use_utility_code(Nodes.traceback_utility_code) + # Module reference and module dict are in global variables which might still be needed + # for cleanup, atexit code, etc., so leaking is better than crashing. + # At least clearing the module dict here might be a good idea, but could still break + # user code in atexit or other global registries. + ##code.put_decref_clear(env.module_dict_cname, py_object_type, nanny=False) + code.putln('}') + code.put_decref_clear(env.module_cname, py_object_type, nanny=False, clear_before_decref=True) + code.putln('} else if (!PyErr_Occurred()) {') + code.putln('PyErr_SetString(PyExc_ImportError, "init %s");' % env.qualified_name) + code.putln('}') + code.put_label(code.return_label) + + code.put_finish_refcount_context() + + code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") + code.putln("return (%s != NULL) ? 0 : -1;" % env.module_cname) + code.putln("#elif PY_MAJOR_VERSION >= 3") + code.putln("return %s;" % env.module_cname) + code.putln("#else") + code.putln("return;") + code.putln("#endif") + code.putln('}') + + tempdecl_code.put_temp_declarations(code.funcstate) + + code.exit_cfunc_scope() + + def mod_init_subfunction(self, pos, scope, orig_code): + """ + Return a context manager that allows deviating the module init code generation + into a separate function and instead inserts a call to it. + + Can be reused sequentially to create multiple functions. + The functions get inserted at the point where the context manager was created. + The call gets inserted where the context manager is used (on entry). + """ + prototypes = orig_code.insertion_point() + prototypes.putln("") + function_code = orig_code.insertion_point() + function_code.putln("") + + class ModInitSubfunction(object): + def __init__(self, code_type): + cname = '_'.join(code_type.lower().split()) + assert re.match("^[a-z0-9_]+$", cname) + self.cfunc_name = "__Pyx_modinit_%s" % cname + self.description = code_type + self.tempdecl_code = None + self.call_code = None + + def __enter__(self): + self.call_code = orig_code.insertion_point() + code = function_code + code.enter_cfunc_scope(scope) + prototypes.putln("static CYTHON_SMALL_CODE int %s(void); /*proto*/" % self.cfunc_name) + code.putln("static int %s(void) {" % self.cfunc_name) + code.put_declare_refcount_context() + self.tempdecl_code = code.insertion_point() + code.put_setup_refcount_context(self.cfunc_name) + # Leave a grepable marker that makes it easy to find the generator source. + code.putln("/*--- %s ---*/" % self.description) + return code + + def __exit__(self, *args): + code = function_code + code.put_finish_refcount_context() + code.putln("return 0;") + + self.tempdecl_code.put_temp_declarations(code.funcstate) + self.tempdecl_code = None + + needs_error_handling = code.label_used(code.error_label) + if needs_error_handling: + code.put_label(code.error_label) + for cname, type in code.funcstate.all_managed_temps(): + code.put_xdecref(cname, type) + code.put_finish_refcount_context() + code.putln("return -1;") + code.putln("}") + code.exit_cfunc_scope() + code.putln("") + + if needs_error_handling: + self.call_code.putln( + self.call_code.error_goto_if_neg("%s()" % self.cfunc_name, pos)) + else: + self.call_code.putln("(void)%s();" % self.cfunc_name) + self.call_code = None + + return ModInitSubfunction + + def generate_module_import_setup(self, env, code): + module_path = env.directives['set_initial_path'] + if module_path == 'SOURCEFILE': + module_path = self.pos[0].filename + + if module_path: + code.putln('if (!CYTHON_PEP489_MULTI_PHASE_INIT) {') + code.putln('if (PyObject_SetAttrString(%s, "__file__", %s) < 0) %s;' % ( + env.module_cname, + code.globalstate.get_py_string_const( + EncodedString(decode_filename(module_path))).cname, + code.error_goto(self.pos))) + code.putln("}") + + if env.is_package: + # set __path__ to mark the module as package + code.putln('if (!CYTHON_PEP489_MULTI_PHASE_INIT) {') + temp = code.funcstate.allocate_temp(py_object_type, True) + code.putln('%s = Py_BuildValue("[O]", %s); %s' % ( + temp, + code.globalstate.get_py_string_const( + EncodedString(decode_filename( + os.path.dirname(module_path)))).cname, + code.error_goto_if_null(temp, self.pos))) + code.put_gotref(temp) + code.putln( + 'if (PyObject_SetAttrString(%s, "__path__", %s) < 0) %s;' % ( + env.module_cname, temp, code.error_goto(self.pos))) + code.put_decref_clear(temp, py_object_type) + code.funcstate.release_temp(temp) + code.putln("}") + + elif env.is_package: + # packages require __path__, so all we can do is try to figure + # out the module path at runtime by rerunning the import lookup + code.putln("if (!CYTHON_PEP489_MULTI_PHASE_INIT) {") + code.globalstate.use_utility_code(UtilityCode.load( + "SetPackagePathFromImportLib", "ImportExport.c")) + code.putln(code.error_goto_if_neg( + '__Pyx_SetPackagePathFromImportLib(%s)' % ( + code.globalstate.get_py_string_const( + EncodedString(self.full_module_name)).cname), + self.pos)) + code.putln("}") + + # CPython may not have put us into sys.modules yet, but relative imports and reimports require it + fq_module_name = self.full_module_name + if fq_module_name.endswith('.__init__'): + fq_module_name = fq_module_name[:-len('.__init__')] + code.putln("#if PY_MAJOR_VERSION >= 3") + code.putln("{") + code.putln("PyObject *modules = PyImport_GetModuleDict(); %s" % + code.error_goto_if_null("modules", self.pos)) + code.putln('if (!PyDict_GetItemString(modules, "%s")) {' % fq_module_name) + code.putln(code.error_goto_if_neg('PyDict_SetItemString(modules, "%s", %s)' % ( + fq_module_name, env.module_cname), self.pos)) + code.putln("}") + code.putln("}") + code.putln("#endif") + + def generate_module_cleanup_func(self, env, code): + if not Options.generate_cleanup_code: + return + + code.putln('static void %s(CYTHON_UNUSED PyObject *self) {' % + Naming.cleanup_cname) + code.enter_cfunc_scope(env) + + if Options.generate_cleanup_code >= 2: + code.putln("/*--- Global cleanup code ---*/") + rev_entries = list(env.var_entries) + rev_entries.reverse() + for entry in rev_entries: + if entry.visibility != 'extern': + if entry.type.is_pyobject and entry.used: + code.put_xdecref_clear( + entry.cname, entry.type, + clear_before_decref=True, + nanny=False) + code.putln("__Pyx_CleanupGlobals();") + if Options.generate_cleanup_code >= 3: + code.putln("/*--- Type import cleanup code ---*/") + for ext_type in sorted(env.types_imported, key=operator.attrgetter('typeptr_cname')): + code.put_xdecref_clear( + ext_type.typeptr_cname, ext_type, + clear_before_decref=True, + nanny=False) + if Options.cache_builtins: + code.putln("/*--- Builtin cleanup code ---*/") + for entry in env.cached_builtins: + code.put_xdecref_clear( + entry.cname, PyrexTypes.py_object_type, + clear_before_decref=True, + nanny=False) + code.putln("/*--- Intern cleanup code ---*/") + code.put_decref_clear(Naming.empty_tuple, + PyrexTypes.py_object_type, + clear_before_decref=True, + nanny=False) + for entry in env.c_class_entries: + cclass_type = entry.type + if cclass_type.is_external or cclass_type.base_type: + continue + if cclass_type.scope.directives.get('freelist', 0): + scope = cclass_type.scope + freelist_name = scope.mangle_internal(Naming.freelist_name) + freecount_name = scope.mangle_internal(Naming.freecount_name) + code.putln("while (%s > 0) {" % freecount_name) + code.putln("PyObject* o = (PyObject*)%s[--%s];" % ( + freelist_name, freecount_name)) + code.putln("(*Py_TYPE(o)->tp_free)(o);") + code.putln("}") +# for entry in env.pynum_entries: +# code.put_decref_clear(entry.cname, +# PyrexTypes.py_object_type, +# nanny=False) +# for entry in env.all_pystring_entries: +# if entry.is_interned: +# code.put_decref_clear(entry.pystring_cname, +# PyrexTypes.py_object_type, +# nanny=False) +# for entry in env.default_entries: +# if entry.type.is_pyobject and entry.used: +# code.putln("Py_DECREF(%s); %s = 0;" % ( +# code.entry_as_pyobject(entry), entry.cname)) + if Options.pre_import is not None: + code.put_decref_clear(Naming.preimport_cname, py_object_type, + nanny=False, clear_before_decref=True) + for cname in [env.module_dict_cname, Naming.cython_runtime_cname, Naming.builtins_cname]: + code.put_decref_clear(cname, py_object_type, nanny=False, clear_before_decref=True) + + def generate_main_method(self, env, code): + module_is_main = "%s%s" % (Naming.module_is_main, self.full_module_name.replace('.', '__')) + if Options.embed == "main": + wmain = "wmain" + else: + wmain = Options.embed + main_method = UtilityCode.load_cached("MainFunction", "Embed.c") + code.globalstate.use_utility_code( + main_method.specialize( + module_name=env.module_name, + module_is_main=module_is_main, + main_method=Options.embed, + wmain_method=wmain)) + + def mod_init_func_cname(self, prefix, env, options=None): + return '%s_%s' % (prefix, options and options.init_suffix or env.module_name) + + def generate_pymoduledef_struct(self, env, options, code): + if env.doc: + doc = "%s" % code.get_string_const(env.doc) + else: + doc = "0" + if Options.generate_cleanup_code: + cleanup_func = "(freefunc)%s" % Naming.cleanup_cname + else: + cleanup_func = 'NULL' + + code.putln("") + code.putln("#if PY_MAJOR_VERSION >= 3") + code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") + exec_func_cname = self.mod_init_func_cname(Naming.pymodule_exec_func_cname, env) + code.putln("static PyObject* %s(PyObject *spec, PyModuleDef *def); /*proto*/" % + Naming.pymodule_create_func_cname) + code.putln("static int %s(PyObject* module); /*proto*/" % exec_func_cname) + + code.putln("static PyModuleDef_Slot %s[] = {" % Naming.pymoduledef_slots_cname) + code.putln("{Py_mod_create, (void*)%s}," % Naming.pymodule_create_func_cname) + code.putln("{Py_mod_exec, (void*)%s}," % exec_func_cname) + code.putln("{0, NULL}") + code.putln("};") + code.putln("#endif") + + code.putln("") + code.putln("static struct PyModuleDef %s = {" % Naming.pymoduledef_cname) + code.putln(" PyModuleDef_HEAD_INIT,") + code.putln(' "%s",' % (options.module_name or env.module_name)) + code.putln(" %s, /* m_doc */" % doc) + code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") + code.putln(" 0, /* m_size */") + code.putln("#else") + code.putln(" -1, /* m_size */") + code.putln("#endif") + code.putln(" %s /* m_methods */," % env.method_table_cname) + code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") + code.putln(" %s, /* m_slots */" % Naming.pymoduledef_slots_cname) + code.putln("#else") + code.putln(" NULL, /* m_reload */") + code.putln("#endif") + code.putln(" NULL, /* m_traverse */") + code.putln(" NULL, /* m_clear */") + code.putln(" %s /* m_free */" % cleanup_func) + code.putln("};") + code.putln("#endif") + + def generate_module_creation_code(self, env, options, code): + # Generate code to create the module object and + # install the builtins. + if env.doc: + doc = "%s" % code.get_string_const(env.doc) + else: + doc = "0" + + code.putln("#if CYTHON_PEP489_MULTI_PHASE_INIT") + code.putln("%s = %s;" % ( + env.module_cname, + Naming.pymodinit_module_arg)) + code.put_incref(env.module_cname, py_object_type, nanny=False) + code.putln("#else") + code.putln("#if PY_MAJOR_VERSION < 3") + code.putln( + '%s = Py_InitModule4("%s", %s, %s, 0, PYTHON_API_VERSION); Py_XINCREF(%s);' % ( + env.module_cname, + options.module_name or env.module_name, + env.method_table_cname, + doc, + env.module_cname)) + code.putln("#else") + code.putln( + "%s = PyModule_Create(&%s);" % ( + env.module_cname, + Naming.pymoduledef_cname)) + code.putln("#endif") + code.putln(code.error_goto_if_null(env.module_cname, self.pos)) + code.putln("#endif") # CYTHON_PEP489_MULTI_PHASE_INIT + + code.putln( + "%s = PyModule_GetDict(%s); %s" % ( + env.module_dict_cname, env.module_cname, + code.error_goto_if_null(env.module_dict_cname, self.pos))) + code.put_incref(env.module_dict_cname, py_object_type, nanny=False) + + code.putln( + '%s = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); %s' % ( + Naming.builtins_cname, + code.error_goto_if_null(Naming.builtins_cname, self.pos))) + code.put_incref(Naming.builtins_cname, py_object_type, nanny=False) + code.putln( + '%s = PyImport_AddModule((char *) "cython_runtime"); %s' % ( + Naming.cython_runtime_cname, + code.error_goto_if_null(Naming.cython_runtime_cname, self.pos))) + code.put_incref(Naming.cython_runtime_cname, py_object_type, nanny=False) + code.putln( + 'if (PyObject_SetAttrString(%s, "__builtins__", %s) < 0) %s' % ( + env.module_cname, + Naming.builtins_cname, + code.error_goto(self.pos))) + if Options.pre_import is not None: + code.putln( + '%s = PyImport_AddModule("%s"); %s' % ( + Naming.preimport_cname, + Options.pre_import, + code.error_goto_if_null(Naming.preimport_cname, self.pos))) + code.put_incref(Naming.preimport_cname, py_object_type, nanny=False) + + def generate_global_init_code(self, env, code): + # Generate code to initialise global PyObject * + # variables to None. + for entry in env.var_entries: + if entry.visibility != 'extern': + if entry.used: + entry.type.global_init_code(entry, code) + + def generate_wrapped_entries_code(self, env, code): + for name, entry in sorted(env.entries.items()): + if (entry.create_wrapper + and not entry.is_type + and entry.scope is env): + if not entry.type.create_to_py_utility_code(env): + error(entry.pos, "Cannot convert '%s' to Python object" % entry.type) + code.putln("{") + code.putln("PyObject* wrapped = %s(%s);" % ( + entry.type.to_py_function, + entry.cname)) + code.putln(code.error_goto_if_null("wrapped", entry.pos)) + code.putln( + 'if (PyObject_SetAttrString(%s, "%s", wrapped) < 0) %s;' % ( + env.module_cname, + name, + code.error_goto(entry.pos))) + code.putln("}") + + def generate_c_variable_export_code(self, env, code): + # Generate code to create PyCFunction wrappers for exported C functions. + entries = [] + for entry in env.var_entries: + if (entry.api + or entry.defined_in_pxd + or (Options.cimport_from_pyx and not entry.visibility == 'extern')): + entries.append(entry) + if entries: + env.use_utility_code(UtilityCode.load_cached("VoidPtrExport", "ImportExport.c")) + for entry in entries: + signature = entry.type.empty_declaration_code() + name = code.intern_identifier(entry.name) + code.putln('if (__Pyx_ExportVoidPtr(%s, (void *)&%s, "%s") < 0) %s' % ( + name, entry.cname, signature, + code.error_goto(self.pos))) + + def generate_c_function_export_code(self, env, code): + # Generate code to create PyCFunction wrappers for exported C functions. + entries = [] + for entry in env.cfunc_entries: + if (entry.api + or entry.defined_in_pxd + or (Options.cimport_from_pyx and not entry.visibility == 'extern')): + entries.append(entry) + if entries: + env.use_utility_code( + UtilityCode.load_cached("FunctionExport", "ImportExport.c")) + # Note: while this looks like it could be more cheaply stored and read from a struct array, + # investigation shows that the resulting binary is smaller with repeated functions calls. + for entry in entries: + signature = entry.type.signature_string() + code.putln('if (__Pyx_ExportFunction("%s", (void (*)(void))%s, "%s") < 0) %s' % ( + entry.name, + entry.cname, + signature, + code.error_goto(self.pos))) + + def generate_type_import_code_for_module(self, module, env, code): + # Generate type import code for all exported extension types in + # an imported module. + #if module.c_class_entries: + with ModuleImportGenerator(code) as import_generator: + for entry in module.c_class_entries: + if entry.defined_in_pxd: + self.generate_type_import_code(env, entry.type, entry.pos, code, import_generator) + + def specialize_fused_types(self, pxd_env): + """ + If fused c(p)def functions are defined in an imported pxd, but not + used in this implementation file, we still have fused entries and + not specialized ones. This method replaces any fused entries with their + specialized ones. + """ + for entry in pxd_env.cfunc_entries[:]: + if entry.type.is_fused: + # This call modifies the cfunc_entries in-place + entry.type.get_all_specialized_function_types() + + def generate_c_variable_import_code_for_module(self, module, env, code): + # Generate import code for all exported C functions in a cimported module. + entries = [] + for entry in module.var_entries: + if entry.defined_in_pxd: + entries.append(entry) + if entries: + env.use_utility_code( + UtilityCode.load_cached("VoidPtrImport", "ImportExport.c")) + temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + code.putln( + '%s = PyImport_ImportModule("%s"); if (!%s) %s' % ( + temp, + module.qualified_name, + temp, + code.error_goto(self.pos))) + code.put_gotref(temp) + for entry in entries: + if env is module: + cname = entry.cname + else: + cname = module.mangle(Naming.varptr_prefix, entry.name) + signature = entry.type.empty_declaration_code() + code.putln( + 'if (__Pyx_ImportVoidPtr(%s, "%s", (void **)&%s, "%s") < 0) %s' % ( + temp, entry.name, cname, signature, + code.error_goto(self.pos))) + code.put_decref_clear(temp, py_object_type) + code.funcstate.release_temp(temp) + + def generate_c_function_import_code_for_module(self, module, env, code): + # Generate import code for all exported C functions in a cimported module. + entries = [] + for entry in module.cfunc_entries: + if entry.defined_in_pxd and entry.used: + entries.append(entry) + if entries: + env.use_utility_code( + UtilityCode.load_cached("FunctionImport", "ImportExport.c")) + temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + code.putln( + '%s = PyImport_ImportModule("%s"); if (!%s) %s' % ( + temp, + module.qualified_name, + temp, + code.error_goto(self.pos))) + code.put_gotref(temp) + for entry in entries: + code.putln( + 'if (__Pyx_ImportFunction(%s, "%s", (void (**)(void))&%s, "%s") < 0) %s' % ( + temp, + entry.name, + entry.cname, + entry.type.signature_string(), + code.error_goto(self.pos))) + code.put_decref_clear(temp, py_object_type) + code.funcstate.release_temp(temp) + + def generate_type_init_code(self, env, code): + # Generate type import code for extern extension types + # and type ready code for non-extern ones. + with ModuleImportGenerator(code) as import_generator: + for entry in env.c_class_entries: + if entry.visibility == 'extern' and not entry.utility_code_definition: + self.generate_type_import_code(env, entry.type, entry.pos, code, import_generator) + else: + self.generate_base_type_import_code(env, entry, code, import_generator) + self.generate_exttype_vtable_init_code(entry, code) + if entry.type.early_init: + self.generate_type_ready_code(entry, code) + + def generate_base_type_import_code(self, env, entry, code, import_generator): + base_type = entry.type.base_type + if (base_type and base_type.module_name != env.qualified_name and not + base_type.is_builtin_type and not entry.utility_code_definition): + self.generate_type_import_code(env, base_type, self.pos, code, import_generator) + + def generate_type_import_code(self, env, type, pos, code, import_generator): + # If not already done, generate code to import the typeobject of an + # extension type defined in another module, and extract its C method + # table pointer if any. + if type in env.types_imported: + return + if type.name not in Code.ctypedef_builtins_map: + # see corresponding condition in generate_type_import_call() below! + code.globalstate.use_utility_code( + UtilityCode.load_cached("TypeImport", "ImportExport.c")) + self.generate_type_import_call(type, code, import_generator, error_pos=pos) + if type.vtabptr_cname: + code.globalstate.use_utility_code( + UtilityCode.load_cached('GetVTable', 'ImportExport.c')) + code.putln("%s = (struct %s*)__Pyx_GetVtable(%s->tp_dict); %s" % ( + type.vtabptr_cname, + type.vtabstruct_cname, + type.typeptr_cname, + code.error_goto_if_null(type.vtabptr_cname, pos))) + env.types_imported.add(type) + + def generate_type_import_call(self, type, code, import_generator, error_code=None, error_pos=None): + if type.typedef_flag: + objstruct = type.objstruct_cname + else: + objstruct = "struct %s" % type.objstruct_cname + sizeof_objstruct = objstruct + module_name = type.module_name + condition = replacement = None + if module_name not in ('__builtin__', 'builtins'): + module_name = '"%s"' % module_name + elif type.name in Code.ctypedef_builtins_map: + # Fast path for special builtins, don't actually import + ctypename = Code.ctypedef_builtins_map[type.name] + code.putln('%s = %s;' % (type.typeptr_cname, ctypename)) + return + else: + module_name = '__Pyx_BUILTIN_MODULE_NAME' + if type.name in Code.non_portable_builtins_map: + condition, replacement = Code.non_portable_builtins_map[type.name] + if objstruct in Code.basicsize_builtins_map: + # Some builtin types have a tp_basicsize which differs from sizeof(...): + sizeof_objstruct = Code.basicsize_builtins_map[objstruct] + + if not error_code: + assert error_pos is not None + error_code = code.error_goto(error_pos) + + module = import_generator.imported_module(module_name, error_code) + code.put('%s = __Pyx_ImportType(%s, %s,' % ( + type.typeptr_cname, + module, + module_name)) + + if condition and replacement: + code.putln("") # start in new line + code.putln("#if %s" % condition) + code.putln('"%s",' % replacement) + code.putln("#else") + code.putln('"%s",' % type.name) + code.putln("#endif") + else: + code.put(' "%s", ' % type.name) + + if sizeof_objstruct != objstruct: + if not condition: + code.putln("") # start in new line + code.putln("#if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000") + code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT(%s),' % (objstruct, objstruct)) + code.putln("#else") + code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT(%s),' % (sizeof_objstruct, sizeof_objstruct)) + code.putln("#endif") + else: + code.putln('sizeof(%s), __PYX_GET_STRUCT_ALIGNMENT(%s),' % (objstruct, objstruct)) + + # check_size + if type.check_size and type.check_size in ('error', 'warn', 'ignore'): + check_size = type.check_size + elif not type.is_external or type.is_subclassed: + check_size = 'error' + else: + raise RuntimeError("invalid value for check_size '%s' when compiling %s.%s" % ( + type.check_size, module_name, type.name)) + code.putln('__Pyx_ImportType_CheckSize_%s);' % check_size.title()) + + code.putln(' if (!%s) %s' % (type.typeptr_cname, error_code)) + + def generate_type_ready_code(self, entry, code): + Nodes.CClassDefNode.generate_type_ready_code(entry, code) + + def generate_exttype_vtable_init_code(self, entry, code): + # Generate code to initialise the C method table of an + # extension type. + type = entry.type + if type.vtable_cname: + code.putln( + "%s = &%s;" % ( + type.vtabptr_cname, + type.vtable_cname)) + if type.base_type and type.base_type.vtabptr_cname: + code.putln( + "%s.%s = *%s;" % ( + type.vtable_cname, + Naming.obj_base_cname, + type.base_type.vtabptr_cname)) + + c_method_entries = [ + entry for entry in type.scope.cfunc_entries + if entry.func_cname] + if c_method_entries: + for meth_entry in c_method_entries: + cast = meth_entry.type.signature_cast_string() + code.putln( + "%s.%s = %s%s;" % ( + type.vtable_cname, + meth_entry.cname, + cast, + meth_entry.func_cname)) + + +class ModuleImportGenerator(object): + """ + Helper to generate module import while importing external types. + This is used to avoid excessive re-imports of external modules when multiple types are looked up. + """ + def __init__(self, code, imported_modules=None): + self.code = code + self.imported = {} + if imported_modules: + for name, cname in imported_modules.items(): + self.imported['"%s"' % name] = cname + self.temps = [] # remember original import order for freeing + + def imported_module(self, module_name_string, error_code): + if module_name_string in self.imported: + return self.imported[module_name_string] + + code = self.code + temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + self.temps.append(temp) + code.putln('%s = PyImport_ImportModule(%s); if (unlikely(!%s)) %s' % ( + temp, module_name_string, temp, error_code)) + code.put_gotref(temp) + self.imported[module_name_string] = temp + return temp + + def __enter__(self): + return self + + def __exit__(self, *exc): + code = self.code + for temp in self.temps: + code.put_decref_clear(temp, py_object_type) + code.funcstate.release_temp(temp) + + +def generate_cfunction_declaration(entry, env, code, definition): + from_cy_utility = entry.used and entry.utility_code_definition + if entry.used and entry.inline_func_in_pxd or (not entry.in_cinclude and ( + definition or entry.defined_in_pxd or entry.visibility == 'extern' or from_cy_utility)): + if entry.visibility == 'extern': + storage_class = Naming.extern_c_macro + dll_linkage = "DL_IMPORT" + elif entry.visibility == 'public': + storage_class = Naming.extern_c_macro + dll_linkage = None + elif entry.visibility == 'private': + storage_class = "static" + dll_linkage = None + else: + storage_class = "static" + dll_linkage = None + type = entry.type + + if entry.defined_in_pxd and not definition: + storage_class = "static" + dll_linkage = None + type = CPtrType(type) + + header = type.declaration_code( + entry.cname, dll_linkage=dll_linkage) + modifiers = code.build_function_modifiers(entry.func_modifiers) + code.putln("%s %s%s; /*proto*/" % ( + storage_class, + modifiers, + header)) + +#------------------------------------------------------------------------------------ +# +# Runtime support code +# +#------------------------------------------------------------------------------------ + +refnanny_utility_code = UtilityCode.load("Refnanny", "ModuleSetupCode.c") + +packed_struct_utility_code = UtilityCode(proto=""" +#if defined(__GNUC__) +#define __Pyx_PACKED __attribute__((__packed__)) +#else +#define __Pyx_PACKED +#endif +""", impl="", proto_block='utility_code_proto_before_types') + +capsule_utility_code = UtilityCode.load("Capsule") diff --git a/contrib/tools/cython/Cython/Compiler/Naming.py b/contrib/tools/cython/Cython/Compiler/Naming.py new file mode 100644 index 00000000000..2c9b620788a --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Naming.py @@ -0,0 +1,162 @@ +# +# C naming conventions +# +# +# Prefixes for generating C names. +# Collected here to facilitate ensuring uniqueness. +# + +pyrex_prefix = "__pyx_" + + +codewriter_temp_prefix = pyrex_prefix + "t_" + +temp_prefix = u"__cyt_" + +builtin_prefix = pyrex_prefix + "builtin_" +arg_prefix = pyrex_prefix + "arg_" +funcdoc_prefix = pyrex_prefix + "doc_" +enum_prefix = pyrex_prefix + "e_" +func_prefix = pyrex_prefix + "f_" +func_prefix_api = pyrex_prefix + "api_f_" +pyfunc_prefix = pyrex_prefix + "pf_" +pywrap_prefix = pyrex_prefix + "pw_" +genbody_prefix = pyrex_prefix + "gb_" +gstab_prefix = pyrex_prefix + "getsets_" +prop_get_prefix = pyrex_prefix + "getprop_" +const_prefix = pyrex_prefix + "k_" +py_const_prefix = pyrex_prefix + "kp_" +label_prefix = pyrex_prefix + "L" +pymethdef_prefix = pyrex_prefix + "mdef_" +method_wrapper_prefix = pyrex_prefix + "specialmethod_" +methtab_prefix = pyrex_prefix + "methods_" +memtab_prefix = pyrex_prefix + "members_" +objstruct_prefix = pyrex_prefix + "obj_" +typeptr_prefix = pyrex_prefix + "ptype_" +prop_set_prefix = pyrex_prefix + "setprop_" +type_prefix = pyrex_prefix + "t_" +typeobj_prefix = pyrex_prefix + "type_" +var_prefix = pyrex_prefix + "v_" +varptr_prefix = pyrex_prefix + "vp_" +varptr_prefix_api = pyrex_prefix + "api_vp_" +wrapperbase_prefix= pyrex_prefix + "wrapperbase_" +pybuffernd_prefix = pyrex_prefix + "pybuffernd_" +pybufferstruct_prefix = pyrex_prefix + "pybuffer_" +vtable_prefix = pyrex_prefix + "vtable_" +vtabptr_prefix = pyrex_prefix + "vtabptr_" +vtabstruct_prefix = pyrex_prefix + "vtabstruct_" +opt_arg_prefix = pyrex_prefix + "opt_args_" +convert_func_prefix = pyrex_prefix + "convert_" +closure_scope_prefix = pyrex_prefix + "scope_" +closure_class_prefix = pyrex_prefix + "scope_struct_" +lambda_func_prefix = pyrex_prefix + "lambda_" +module_is_main = pyrex_prefix + "module_is_main_" +defaults_struct_prefix = pyrex_prefix + "defaults" +dynamic_args_cname = pyrex_prefix + "dynamic_args" + +interned_prefixes = { + 'str': pyrex_prefix + "n_", + 'int': pyrex_prefix + "int_", + 'float': pyrex_prefix + "float_", + 'tuple': pyrex_prefix + "tuple_", + 'codeobj': pyrex_prefix + "codeobj_", + 'slice': pyrex_prefix + "slice_", + 'ustring': pyrex_prefix + "ustring_", + 'umethod': pyrex_prefix + "umethod_", +} + +ctuple_type_prefix = pyrex_prefix + "ctuple_" +args_cname = pyrex_prefix + "args" +generator_cname = pyrex_prefix + "generator" +sent_value_cname = pyrex_prefix + "sent_value" +pykwdlist_cname = pyrex_prefix + "pyargnames" +obj_base_cname = pyrex_prefix + "base" +builtins_cname = pyrex_prefix + "b" +preimport_cname = pyrex_prefix + "i" +moddict_cname = pyrex_prefix + "d" +dummy_cname = pyrex_prefix + "dummy" +filename_cname = pyrex_prefix + "filename" +modulename_cname = pyrex_prefix + "modulename" +filetable_cname = pyrex_prefix + "f" +intern_tab_cname = pyrex_prefix + "intern_tab" +kwds_cname = pyrex_prefix + "kwds" +lineno_cname = pyrex_prefix + "lineno" +clineno_cname = pyrex_prefix + "clineno" +cfilenm_cname = pyrex_prefix + "cfilenm" +local_tstate_cname = pyrex_prefix + "tstate" +module_cname = pyrex_prefix + "m" +moddoc_cname = pyrex_prefix + "mdoc" +methtable_cname = pyrex_prefix + "methods" +retval_cname = pyrex_prefix + "r" +reqd_kwds_cname = pyrex_prefix + "reqd_kwds" +self_cname = pyrex_prefix + "self" +stringtab_cname = pyrex_prefix + "string_tab" +vtabslot_cname = pyrex_prefix + "vtab" +c_api_tab_cname = pyrex_prefix + "c_api_tab" +gilstate_cname = pyrex_prefix + "state" +skip_dispatch_cname = pyrex_prefix + "skip_dispatch" +empty_tuple = pyrex_prefix + "empty_tuple" +empty_bytes = pyrex_prefix + "empty_bytes" +empty_unicode = pyrex_prefix + "empty_unicode" +print_function = pyrex_prefix + "print" +print_function_kwargs = pyrex_prefix + "print_kwargs" +cleanup_cname = pyrex_prefix + "module_cleanup" +pymoduledef_cname = pyrex_prefix + "moduledef" +pymoduledef_slots_cname = pyrex_prefix + "moduledef_slots" +pymodinit_module_arg = pyrex_prefix + "pyinit_module" +pymodule_create_func_cname = pyrex_prefix + "pymod_create" +pymodule_exec_func_cname = pyrex_prefix + "pymod_exec" +optional_args_cname = pyrex_prefix + "optional_args" +import_star = pyrex_prefix + "import_star" +import_star_set = pyrex_prefix + "import_star_set" +outer_scope_cname= pyrex_prefix + "outer_scope" +cur_scope_cname = pyrex_prefix + "cur_scope" +enc_scope_cname = pyrex_prefix + "enc_scope" +frame_cname = pyrex_prefix + "frame" +frame_code_cname = pyrex_prefix + "frame_code" +binding_cfunc = pyrex_prefix + "binding_PyCFunctionType" +fused_func_prefix = pyrex_prefix + 'fuse_' +quick_temp_cname = pyrex_prefix + "temp" # temp variable for quick'n'dirty temping +tp_dict_version_temp = pyrex_prefix + "tp_dict_version" +obj_dict_version_temp = pyrex_prefix + "obj_dict_version" +type_dict_guard_temp = pyrex_prefix + "type_dict_guard" +cython_runtime_cname = pyrex_prefix + "cython_runtime" + +global_code_object_cache_find = pyrex_prefix + 'find_code_object' +global_code_object_cache_insert = pyrex_prefix + 'insert_code_object' + +genexpr_id_ref = 'genexpr' +freelist_name = 'freelist' +freecount_name = 'freecount' + +line_c_macro = "__LINE__" + +file_c_macro = "__FILE__" + +extern_c_macro = pyrex_prefix.upper() + "EXTERN_C" + +exc_type_name = pyrex_prefix + "exc_type" +exc_value_name = pyrex_prefix + "exc_value" +exc_tb_name = pyrex_prefix + "exc_tb" +exc_lineno_name = pyrex_prefix + "exc_lineno" + +parallel_exc_type = pyrex_prefix + "parallel_exc_type" +parallel_exc_value = pyrex_prefix + "parallel_exc_value" +parallel_exc_tb = pyrex_prefix + "parallel_exc_tb" +parallel_filename = pyrex_prefix + "parallel_filename" +parallel_lineno = pyrex_prefix + "parallel_lineno" +parallel_clineno = pyrex_prefix + "parallel_clineno" +parallel_why = pyrex_prefix + "parallel_why" + +exc_vars = (exc_type_name, exc_value_name, exc_tb_name) + +api_name = pyrex_prefix + "capi__" + +h_guard_prefix = "__PYX_HAVE__" +api_guard_prefix = "__PYX_HAVE_API__" +api_func_guard = "__PYX_HAVE_API_FUNC_" + +PYX_NAN = "__PYX_NAN()" + +def py_version_hex(major, minor=0, micro=0, release_level=0, release_serial=0): + return (major << 24) | (minor << 16) | (micro << 8) | (release_level << 4) | (release_serial) diff --git a/contrib/tools/cython/Cython/Compiler/Nodes.py b/contrib/tools/cython/Cython/Compiler/Nodes.py new file mode 100644 index 00000000000..f57ddf3dd34 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Nodes.py @@ -0,0 +1,9456 @@ +# +# Parse tree nodes +# + +from __future__ import absolute_import + +import cython +cython.declare(sys=object, os=object, copy=object, + Builtin=object, error=object, warning=object, Naming=object, PyrexTypes=object, + py_object_type=object, ModuleScope=object, LocalScope=object, ClosureScope=object, + StructOrUnionScope=object, PyClassScope=object, + CppClassScope=object, UtilityCode=object, EncodedString=object, + error_type=object, _py_int_types=object) + +import sys, os, copy +from itertools import chain + +from . import Builtin +from .Errors import error, warning, InternalError, CompileError +from . import Naming +from . import PyrexTypes +from . import TypeSlots +from .PyrexTypes import py_object_type, error_type +from .Symtab import (ModuleScope, LocalScope, ClosureScope, + StructOrUnionScope, PyClassScope, CppClassScope, TemplateScope) +from .Code import UtilityCode +from .StringEncoding import EncodedString +from . import Future +from . import Options +from . import DebugFlags +from .Pythran import has_np_pythran, pythran_type, is_pythran_buffer +from ..Utils import add_metaclass + + +if sys.version_info[0] >= 3: + _py_int_types = int +else: + _py_int_types = (int, long) + + +def relative_position(pos): + return (pos[0].get_filenametable_entry(), pos[1]) + + +def embed_position(pos, docstring): + if not Options.embed_pos_in_docstring: + return docstring + pos_line = u'File: %s (starting at line %s)' % relative_position(pos) + if docstring is None: + # unicode string + return EncodedString(pos_line) + + # make sure we can encode the filename in the docstring encoding + # otherwise make the docstring a unicode string + encoding = docstring.encoding + if encoding is not None: + try: + pos_line.encode(encoding) + except UnicodeEncodeError: + encoding = None + + if not docstring: + # reuse the string encoding of the original docstring + doc = EncodedString(pos_line) + else: + doc = EncodedString(pos_line + u'\n' + docstring) + doc.encoding = encoding + return doc + + +def analyse_type_annotation(annotation, env, assigned_value=None): + base_type = None + is_ambiguous = False + explicit_pytype = explicit_ctype = False + if annotation.is_dict_literal: + warning(annotation.pos, + "Dicts should no longer be used as type annotations. Use 'cython.int' etc. directly.") + for name, value in annotation.key_value_pairs: + if not name.is_string_literal: + continue + if name.value in ('type', b'type'): + explicit_pytype = True + if not explicit_ctype: + annotation = value + elif name.value in ('ctype', b'ctype'): + explicit_ctype = True + annotation = value + if explicit_pytype and explicit_ctype: + warning(annotation.pos, "Duplicate type declarations found in signature annotation") + arg_type = annotation.analyse_as_type(env) + if annotation.is_name and not annotation.cython_attribute and annotation.name in ('int', 'long', 'float'): + # Map builtin numeric Python types to C types in safe cases. + if assigned_value is not None and arg_type is not None and not arg_type.is_pyobject: + assigned_type = assigned_value.infer_type(env) + if assigned_type and assigned_type.is_pyobject: + # C type seems unsafe, e.g. due to 'None' default value => ignore annotation type + is_ambiguous = True + arg_type = None + # ignore 'int' and require 'cython.int' to avoid unsafe integer declarations + if arg_type in (PyrexTypes.c_long_type, PyrexTypes.c_int_type, PyrexTypes.c_float_type): + arg_type = PyrexTypes.c_double_type if annotation.name == 'float' else py_object_type + elif arg_type is not None and annotation.is_string_literal: + warning(annotation.pos, + "Strings should no longer be used for type declarations. Use 'cython.int' etc. directly.") + if arg_type is not None: + if explicit_pytype and not explicit_ctype and not arg_type.is_pyobject: + warning(annotation.pos, + "Python type declaration in signature annotation does not refer to a Python type") + base_type = CAnalysedBaseTypeNode( + annotation.pos, type=arg_type, is_arg=True) + elif is_ambiguous: + warning(annotation.pos, "Ambiguous types in annotation, ignoring") + else: + warning(annotation.pos, "Unknown type declaration in annotation, ignoring") + return base_type, arg_type + + +def write_func_call(func, codewriter_class): + def f(*args, **kwds): + if len(args) > 1 and isinstance(args[1], codewriter_class): + # here we annotate the code with this function call + # but only if new code is generated + node, code = args[:2] + marker = ' /* %s -> %s.%s %s */' % ( + ' ' * code.call_level, + node.__class__.__name__, + func.__name__, + node.pos[1:]) + pristine = code.buffer.stream.tell() + code.putln(marker) + start = code.buffer.stream.tell() + code.call_level += 4 + res = func(*args, **kwds) + code.call_level -= 4 + if start == code.buffer.stream.tell(): + # no code written => undo writing marker + code.buffer.stream.truncate(pristine) + else: + marker = marker.replace('->', '<-', 1) + code.putln(marker) + return res + else: + return func(*args, **kwds) + return f + + +class VerboseCodeWriter(type): + # Set this as a metaclass to trace function calls in code. + # This slows down code generation and makes much larger files. + def __new__(cls, name, bases, attrs): + from types import FunctionType + from .Code import CCodeWriter + attrs = dict(attrs) + for mname, m in attrs.items(): + if isinstance(m, FunctionType): + attrs[mname] = write_func_call(m, CCodeWriter) + return super(VerboseCodeWriter, cls).__new__(cls, name, bases, attrs) + + +class CheckAnalysers(type): + """Metaclass to check that type analysis functions return a node. + """ + methods = set(['analyse_types', + 'analyse_expressions', + 'analyse_target_types']) + + def __new__(cls, name, bases, attrs): + from types import FunctionType + def check(name, func): + def call(*args, **kwargs): + retval = func(*args, **kwargs) + if retval is None: + print('%s %s %s' % (name, args, kwargs)) + return retval + return call + + attrs = dict(attrs) + for mname, m in attrs.items(): + if isinstance(m, FunctionType) and mname in cls.methods: + attrs[mname] = check(mname, m) + return super(CheckAnalysers, cls).__new__(cls, name, bases, attrs) + + +def _with_metaclass(cls): + if DebugFlags.debug_trace_code_generation: + return add_metaclass(VerboseCodeWriter)(cls) + #return add_metaclass(CheckAnalysers)(cls) + return cls + + +@_with_metaclass +class Node(object): + # pos (string, int, int) Source file position + # is_name boolean Is a NameNode + # is_literal boolean Is a ConstNode + + is_name = 0 + is_none = 0 + is_nonecheck = 0 + is_literal = 0 + is_terminator = 0 + is_wrapper = False # is a DefNode wrapper for a C function + temps = None + + # All descendants should set child_attrs to a list of the attributes + # containing nodes considered "children" in the tree. Each such attribute + # can either contain a single node or a list of nodes. See Visitor.py. + child_attrs = None + + # Subset of attributes that are evaluated in the outer scope (e.g. function default arguments). + outer_attrs = None + + cf_state = None + + # This may be an additional (or 'actual') type that will be checked when + # this node is coerced to another type. This could be useful to set when + # the actual type to which it can coerce is known, but you want to leave + # the type a py_object_type + coercion_type = None + + def __init__(self, pos, **kw): + self.pos = pos + self.__dict__.update(kw) + + gil_message = "Operation" + + nogil_check = None + in_nogil_context = False # For use only during code generation. + + def gil_error(self, env=None): + error(self.pos, "%s not allowed without gil" % self.gil_message) + + cpp_message = "Operation" + + def cpp_check(self, env): + if not env.is_cpp(): + self.cpp_error() + + def cpp_error(self): + error(self.pos, "%s only allowed in c++" % self.cpp_message) + + def clone_node(self): + """Clone the node. This is defined as a shallow copy, except for member lists + amongst the child attributes (from get_child_accessors) which are also + copied. Lists containing child nodes are thus seen as a way for the node + to hold multiple children directly; the list is not treated as a separate + level in the tree.""" + result = copy.copy(self) + for attrname in result.child_attrs: + value = getattr(result, attrname) + if isinstance(value, list): + setattr(result, attrname, [x for x in value]) + return result + + + # + # There are 3 phases of parse tree processing, applied in order to + # all the statements in a given scope-block: + # + # (0) analyse_declarations + # Make symbol table entries for all declarations at the current + # level, both explicit (def, cdef, etc.) and implicit (assignment + # to an otherwise undeclared name). + # + # (1) analyse_expressions + # Determine the result types of expressions and fill in the + # 'type' attribute of each ExprNode. Insert coercion nodes into the + # tree where needed to convert to and from Python objects. + # Allocate temporary locals for intermediate results. Fill + # in the 'result_code' attribute of each ExprNode with a C code + # fragment. + # + # (2) generate_code + # Emit C code for all declarations, statements and expressions. + # Recursively applies the 3 processing phases to the bodies of + # functions. + # + + def analyse_declarations(self, env): + pass + + def analyse_expressions(self, env): + raise InternalError("analyse_expressions not implemented for %s" % \ + self.__class__.__name__) + + def generate_code(self, code): + raise InternalError("generate_code not implemented for %s" % \ + self.__class__.__name__) + + def annotate(self, code): + # mro does the wrong thing + if isinstance(self, BlockNode): + self.body.annotate(code) + + def end_pos(self): + try: + return self._end_pos + except AttributeError: + pos = self.pos + if not self.child_attrs: + self._end_pos = pos + return pos + for attr in self.child_attrs: + child = getattr(self, attr) + # Sometimes lists, sometimes nodes + if child is None: + pass + elif isinstance(child, list): + for c in child: + pos = max(pos, c.end_pos()) + else: + pos = max(pos, child.end_pos()) + self._end_pos = pos + return pos + + def dump(self, level=0, filter_out=("pos",), cutoff=100, encountered=None): + """Debug helper method that returns a recursive string representation of this node. + """ + if cutoff == 0: + return "<...nesting level cutoff...>" + if encountered is None: + encountered = set() + if id(self) in encountered: + return "<%s (0x%x) -- already output>" % (self.__class__.__name__, id(self)) + encountered.add(id(self)) + + def dump_child(x, level): + if isinstance(x, Node): + return x.dump(level, filter_out, cutoff-1, encountered) + elif isinstance(x, list): + return "[%s]" % ", ".join([dump_child(item, level) for item in x]) + else: + return repr(x) + + attrs = [(key, value) for key, value in self.__dict__.items() if key not in filter_out] + if len(attrs) == 0: + return "<%s (0x%x)>" % (self.__class__.__name__, id(self)) + else: + indent = " " * level + res = "<%s (0x%x)\n" % (self.__class__.__name__, id(self)) + for key, value in attrs: + res += "%s %s: %s\n" % (indent, key, dump_child(value, level + 1)) + res += "%s>" % indent + return res + + def dump_pos(self, mark_column=False, marker='(#)'): + """Debug helper method that returns the source code context of this node as a string. + """ + if not self.pos: + return u'' + source_desc, line, col = self.pos + contents = source_desc.get_lines(encoding='ASCII', error_handling='ignore') + # line numbers start at 1 + lines = contents[max(0, line-3):line] + current = lines[-1] + if mark_column: + current = current[:col] + marker + current[col:] + lines[-1] = current.rstrip() + u' # <<<<<<<<<<<<<<\n' + lines += contents[line:line+2] + return u'"%s":%d:%d\n%s\n' % ( + source_desc.get_escaped_description(), line, col, u''.join(lines)) + +class CompilerDirectivesNode(Node): + """ + Sets compiler directives for the children nodes + """ + # directives {string:value} A dictionary holding the right value for + # *all* possible directives. + # body Node + child_attrs = ["body"] + + def analyse_declarations(self, env): + old = env.directives + env.directives = self.directives + self.body.analyse_declarations(env) + env.directives = old + + def analyse_expressions(self, env): + old = env.directives + env.directives = self.directives + self.body = self.body.analyse_expressions(env) + env.directives = old + return self + + def generate_function_definitions(self, env, code): + env_old = env.directives + code_old = code.globalstate.directives + code.globalstate.directives = self.directives + self.body.generate_function_definitions(env, code) + env.directives = env_old + code.globalstate.directives = code_old + + def generate_execution_code(self, code): + old = code.globalstate.directives + code.globalstate.directives = self.directives + self.body.generate_execution_code(code) + code.globalstate.directives = old + + def annotate(self, code): + old = code.globalstate.directives + code.globalstate.directives = self.directives + self.body.annotate(code) + code.globalstate.directives = old + +class BlockNode(object): + # Mixin class for nodes representing a declaration block. + + def generate_cached_builtins_decls(self, env, code): + entries = env.global_scope().undeclared_cached_builtins + for entry in entries: + code.globalstate.add_cached_builtin_decl(entry) + del entries[:] + + def generate_lambda_definitions(self, env, code): + for node in env.lambda_defs: + node.generate_function_definitions(env, code) + +class StatListNode(Node): + # stats a list of StatNode + + child_attrs = ["stats"] + + @staticmethod + def create_analysed(pos, env, *args, **kw): + node = StatListNode(pos, *args, **kw) + return node # No node-specific analysis needed + + def analyse_declarations(self, env): + #print "StatListNode.analyse_declarations" ### + for stat in self.stats: + stat.analyse_declarations(env) + + def analyse_expressions(self, env): + #print "StatListNode.analyse_expressions" ### + self.stats = [stat.analyse_expressions(env) + for stat in self.stats] + return self + + def generate_function_definitions(self, env, code): + #print "StatListNode.generate_function_definitions" ### + for stat in self.stats: + stat.generate_function_definitions(env, code) + + def generate_execution_code(self, code): + #print "StatListNode.generate_execution_code" ### + for stat in self.stats: + code.mark_pos(stat.pos) + stat.generate_execution_code(code) + + def annotate(self, code): + for stat in self.stats: + stat.annotate(code) + + +class StatNode(Node): + # + # Code generation for statements is split into the following subphases: + # + # (1) generate_function_definitions + # Emit C code for the definitions of any structs, + # unions, enums and functions defined in the current + # scope-block. + # + # (2) generate_execution_code + # Emit C code for executable statements. + # + + def generate_function_definitions(self, env, code): + pass + + def generate_execution_code(self, code): + raise InternalError("generate_execution_code not implemented for %s" % \ + self.__class__.__name__) + + +class CDefExternNode(StatNode): + # include_file string or None + # verbatim_include string or None + # body StatListNode + + child_attrs = ["body"] + + def analyse_declarations(self, env): + old_cinclude_flag = env.in_cinclude + env.in_cinclude = 1 + self.body.analyse_declarations(env) + env.in_cinclude = old_cinclude_flag + + if self.include_file or self.verbatim_include: + # Determine whether include should be late + stats = self.body.stats + if not env.directives['preliminary_late_includes_cy28']: + late = False + elif not stats: + # Special case: empty 'cdef extern' blocks are early + late = False + else: + late = all(isinstance(node, CVarDefNode) for node in stats) + env.add_include_file(self.include_file, self.verbatim_include, late) + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + def annotate(self, code): + self.body.annotate(code) + + +class CDeclaratorNode(Node): + # Part of a C declaration. + # + # Processing during analyse_declarations phase: + # + # analyse + # Returns (name, type) pair where name is the + # CNameDeclaratorNode of the name being declared + # and type is the type it is being declared as. + # + # calling_convention string Calling convention of CFuncDeclaratorNode + # for which this is a base + + child_attrs = [] + + calling_convention = "" + + def analyse_templates(self): + # Only C++ functions have templates. + return None + + +class CNameDeclaratorNode(CDeclaratorNode): + # name string The Cython name being declared + # cname string or None C name, if specified + # default ExprNode or None the value assigned on declaration + + child_attrs = ['default'] + + default = None + + def analyse(self, base_type, env, nonempty=0, visibility=None, in_pxd=False): + if nonempty and self.name == '': + # May have mistaken the name for the type. + if base_type.is_ptr or base_type.is_array or base_type.is_buffer: + error(self.pos, "Missing argument name") + elif base_type.is_void: + error(self.pos, "Use spam() rather than spam(void) to declare a function with no arguments.") + else: + self.name = base_type.declaration_code("", for_display=1, pyrex=1) + base_type = py_object_type + + if base_type.is_fused and env.fused_to_specific: + base_type = base_type.specialize(env.fused_to_specific) + + self.type = base_type + return self, base_type + + +class CPtrDeclaratorNode(CDeclaratorNode): + # base CDeclaratorNode + + child_attrs = ["base"] + + def analyse_templates(self): + return self.base.analyse_templates() + + def analyse(self, base_type, env, nonempty=0, visibility=None, in_pxd=False): + if base_type.is_pyobject: + error(self.pos, "Pointer base type cannot be a Python object") + ptr_type = PyrexTypes.c_ptr_type(base_type) + return self.base.analyse(ptr_type, env, nonempty=nonempty, visibility=visibility, in_pxd=in_pxd) + + +class CReferenceDeclaratorNode(CDeclaratorNode): + # base CDeclaratorNode + + child_attrs = ["base"] + + def analyse_templates(self): + return self.base.analyse_templates() + + def analyse(self, base_type, env, nonempty=0, visibility=None, in_pxd=False): + if base_type.is_pyobject: + error(self.pos, "Reference base type cannot be a Python object") + ref_type = PyrexTypes.c_ref_type(base_type) + return self.base.analyse(ref_type, env, nonempty=nonempty, visibility=visibility, in_pxd=in_pxd) + + +class CArrayDeclaratorNode(CDeclaratorNode): + # base CDeclaratorNode + # dimension ExprNode + + child_attrs = ["base", "dimension"] + + def analyse(self, base_type, env, nonempty=0, visibility=None, in_pxd=False): + if (base_type.is_cpp_class and base_type.is_template_type()) or base_type.is_cfunction: + from .ExprNodes import TupleNode + if isinstance(self.dimension, TupleNode): + args = self.dimension.args + else: + args = self.dimension, + values = [v.analyse_as_type(env) for v in args] + if None in values: + ix = values.index(None) + error(args[ix].pos, "Template parameter not a type") + base_type = error_type + else: + base_type = base_type.specialize_here(self.pos, values) + return self.base.analyse(base_type, env, nonempty=nonempty, visibility=visibility, in_pxd=in_pxd) + if self.dimension: + self.dimension = self.dimension.analyse_const_expression(env) + if not self.dimension.type.is_int: + error(self.dimension.pos, "Array dimension not integer") + size = self.dimension.get_constant_c_result_code() + if size is not None: + try: + size = int(size) + except ValueError: + # runtime constant? + pass + else: + size = None + if not base_type.is_complete(): + error(self.pos, "Array element type '%s' is incomplete" % base_type) + if base_type.is_pyobject: + error(self.pos, "Array element cannot be a Python object") + if base_type.is_cfunction: + error(self.pos, "Array element cannot be a function") + array_type = PyrexTypes.c_array_type(base_type, size) + return self.base.analyse(array_type, env, nonempty=nonempty, visibility=visibility, in_pxd=in_pxd) + + +class CFuncDeclaratorNode(CDeclaratorNode): + # base CDeclaratorNode + # args [CArgDeclNode] + # templates [TemplatePlaceholderType] + # has_varargs boolean + # exception_value ConstNode + # exception_check boolean True if PyErr_Occurred check needed + # nogil boolean Can be called without gil + # with_gil boolean Acquire gil around function body + # is_const_method boolean Whether this is a const method + + child_attrs = ["base", "args", "exception_value"] + + overridable = 0 + optional_arg_count = 0 + is_const_method = 0 + templates = None + + def analyse_templates(self): + if isinstance(self.base, CArrayDeclaratorNode): + from .ExprNodes import TupleNode, NameNode + template_node = self.base.dimension + if isinstance(template_node, TupleNode): + template_nodes = template_node.args + elif isinstance(template_node, NameNode): + template_nodes = [template_node] + else: + error(template_node.pos, "Template arguments must be a list of names") + return None + self.templates = [] + for template in template_nodes: + if isinstance(template, NameNode): + self.templates.append(PyrexTypes.TemplatePlaceholderType(template.name)) + else: + error(template.pos, "Template arguments must be a list of names") + self.base = self.base.base + return self.templates + else: + return None + + def analyse(self, return_type, env, nonempty=0, directive_locals=None, visibility=None, in_pxd=False): + if directive_locals is None: + directive_locals = {} + if nonempty: + nonempty -= 1 + func_type_args = [] + for i, arg_node in enumerate(self.args): + name_declarator, type = arg_node.analyse( + env, nonempty=nonempty, + is_self_arg=(i == 0 and env.is_c_class_scope and 'staticmethod' not in env.directives)) + name = name_declarator.name + if name in directive_locals: + type_node = directive_locals[name] + other_type = type_node.analyse_as_type(env) + if other_type is None: + error(type_node.pos, "Not a type") + elif (type is not PyrexTypes.py_object_type + and not type.same_as(other_type)): + error(self.base.pos, "Signature does not agree with previous declaration") + error(type_node.pos, "Previous declaration here") + else: + type = other_type + if name_declarator.cname: + error(self.pos, "Function argument cannot have C name specification") + if i == 0 and env.is_c_class_scope and type.is_unspecified: + # fix the type of self + type = env.parent_type + # Turn *[] argument into ** + if type.is_array: + type = PyrexTypes.c_ptr_type(type.base_type) + # Catch attempted C-style func(void) decl + if type.is_void: + error(arg_node.pos, "Use spam() rather than spam(void) to declare a function with no arguments.") + func_type_args.append( + PyrexTypes.CFuncTypeArg(name, type, arg_node.pos)) + if arg_node.default: + self.optional_arg_count += 1 + elif self.optional_arg_count: + error(self.pos, "Non-default argument follows default argument") + + exc_val = None + exc_check = 0 + if self.exception_check == '+': + env.add_include_file('ios') # for std::ios_base::failure + env.add_include_file('new') # for std::bad_alloc + env.add_include_file('stdexcept') + env.add_include_file('typeinfo') # for std::bad_cast + if (return_type.is_pyobject + and (self.exception_value or self.exception_check) + and self.exception_check != '+'): + error(self.pos, "Exception clause not allowed for function returning Python object") + else: + if self.exception_value is None and self.exception_check and self.exception_check != '+': + # Use an explicit exception return value to speed up exception checks. + # Even if it is not declared, we can use the default exception value of the return type, + # unless the function is some kind of external function that we do not control. + if return_type.exception_value is not None and (visibility != 'extern' and not in_pxd): + # Extension types are more difficult because the signature must match the base type signature. + if not env.is_c_class_scope: + from .ExprNodes import ConstNode + self.exception_value = ConstNode( + self.pos, value=return_type.exception_value, type=return_type) + if self.exception_value: + self.exception_value = self.exception_value.analyse_const_expression(env) + if self.exception_check == '+': + exc_val_type = self.exception_value.type + if (not exc_val_type.is_error + and not exc_val_type.is_pyobject + and not (exc_val_type.is_cfunction + and not exc_val_type.return_type.is_pyobject + and not exc_val_type.args) + and not (exc_val_type == PyrexTypes.c_char_type + and self.exception_value.value == '*')): + error(self.exception_value.pos, + "Exception value must be a Python exception or cdef function with no arguments or *.") + exc_val = self.exception_value + else: + self.exception_value = self.exception_value.coerce_to( + return_type, env).analyse_const_expression(env) + exc_val = self.exception_value.get_constant_c_result_code() + if exc_val is None: + raise InternalError( + "get_constant_c_result_code not implemented for %s" % + self.exception_value.__class__.__name__) + if not return_type.assignable_from(self.exception_value.type): + error(self.exception_value.pos, + "Exception value incompatible with function return type") + exc_check = self.exception_check + if return_type.is_cfunction: + error(self.pos, "Function cannot return a function") + func_type = PyrexTypes.CFuncType( + return_type, func_type_args, self.has_varargs, + optional_arg_count=self.optional_arg_count, + exception_value=exc_val, exception_check=exc_check, + calling_convention=self.base.calling_convention, + nogil=self.nogil, with_gil=self.with_gil, is_overridable=self.overridable, + is_const_method=self.is_const_method, + templates=self.templates) + + if self.optional_arg_count: + if func_type.is_fused: + # This is a bit of a hack... When we need to create specialized CFuncTypes + # on the fly because the cdef is defined in a pxd, we need to declare the specialized optional arg + # struct + def declare_opt_arg_struct(func_type, fused_cname): + self.declare_optional_arg_struct(func_type, env, fused_cname) + + func_type.declare_opt_arg_struct = declare_opt_arg_struct + else: + self.declare_optional_arg_struct(func_type, env) + + callspec = env.directives['callspec'] + if callspec: + current = func_type.calling_convention + if current and current != callspec: + error(self.pos, "cannot have both '%s' and '%s' " + "calling conventions" % (current, callspec)) + func_type.calling_convention = callspec + return self.base.analyse(func_type, env, visibility=visibility, in_pxd=in_pxd) + + def declare_optional_arg_struct(self, func_type, env, fused_cname=None): + """ + Declares the optional argument struct (the struct used to hold the + values for optional arguments). For fused cdef functions, this is + deferred as analyse_declarations is called only once (on the fused + cdef function). + """ + scope = StructOrUnionScope() + arg_count_member = '%sn' % Naming.pyrex_prefix + scope.declare_var(arg_count_member, PyrexTypes.c_int_type, self.pos) + + for arg in func_type.args[len(func_type.args) - self.optional_arg_count:]: + scope.declare_var(arg.name, arg.type, arg.pos, allow_pyobject=True, allow_memoryview=True) + + struct_cname = env.mangle(Naming.opt_arg_prefix, self.base.name) + + if fused_cname is not None: + struct_cname = PyrexTypes.get_fused_cname(fused_cname, struct_cname) + + op_args_struct = env.global_scope().declare_struct_or_union( + name=struct_cname, + kind='struct', + scope=scope, + typedef_flag=0, + pos=self.pos, + cname=struct_cname) + + op_args_struct.defined_in_pxd = 1 + op_args_struct.used = 1 + + func_type.op_arg_struct = PyrexTypes.c_ptr_type(op_args_struct.type) + + +class CConstDeclaratorNode(CDeclaratorNode): + # base CDeclaratorNode + + child_attrs = ["base"] + + def analyse(self, base_type, env, nonempty=0, visibility=None, in_pxd=False): + if base_type.is_pyobject: + error(self.pos, + "Const base type cannot be a Python object") + const = PyrexTypes.c_const_type(base_type) + return self.base.analyse(const, env, nonempty=nonempty, visibility=visibility, in_pxd=in_pxd) + + +class CArgDeclNode(Node): + # Item in a function declaration argument list. + # + # base_type CBaseTypeNode + # declarator CDeclaratorNode + # not_none boolean Tagged with 'not None' + # or_none boolean Tagged with 'or None' + # accept_none boolean Resolved boolean for not_none/or_none + # default ExprNode or None + # default_value PyObjectConst constant for default value + # annotation ExprNode or None Py3 function arg annotation + # is_self_arg boolean Is the "self" arg of an extension type method + # is_type_arg boolean Is the "class" arg of an extension type classmethod + # is_kw_only boolean Is a keyword-only argument + # is_dynamic boolean Non-literal arg stored inside CyFunction + + child_attrs = ["base_type", "declarator", "default", "annotation"] + outer_attrs = ["default", "annotation"] + + is_self_arg = 0 + is_type_arg = 0 + is_generic = 1 + kw_only = 0 + not_none = 0 + or_none = 0 + type = None + name_declarator = None + default_value = None + annotation = None + is_dynamic = 0 + + def analyse(self, env, nonempty=0, is_self_arg=False): + if is_self_arg: + self.base_type.is_self_arg = self.is_self_arg = True + if self.type is None: + # The parser may misinterpret names as types. We fix that here. + if isinstance(self.declarator, CNameDeclaratorNode) and self.declarator.name == '': + if nonempty: + if self.base_type.is_basic_c_type: + # char, short, long called "int" + type = self.base_type.analyse(env, could_be_name=True) + arg_name = type.empty_declaration_code() + else: + arg_name = self.base_type.name + self.declarator.name = EncodedString(arg_name) + self.base_type.name = None + self.base_type.is_basic_c_type = False + could_be_name = True + else: + could_be_name = False + self.base_type.is_arg = True + base_type = self.base_type.analyse(env, could_be_name=could_be_name) + if hasattr(self.base_type, 'arg_name') and self.base_type.arg_name: + self.declarator.name = self.base_type.arg_name + + # The parser is unable to resolve the ambiguity of [] as part of the + # type (e.g. in buffers) or empty declarator (as with arrays). + # This is only arises for empty multi-dimensional arrays. + if (base_type.is_array + and isinstance(self.base_type, TemplatedTypeNode) + and isinstance(self.declarator, CArrayDeclaratorNode)): + declarator = self.declarator + while isinstance(declarator.base, CArrayDeclaratorNode): + declarator = declarator.base + declarator.base = self.base_type.array_declarator + base_type = base_type.base_type + + # inject type declaration from annotations + # this is called without 'env' by AdjustDefByDirectives transform before declaration analysis + if self.annotation and env and env.directives['annotation_typing'] and self.base_type.name is None: + arg_type = self.inject_type_from_annotations(env) + if arg_type is not None: + base_type = arg_type + return self.declarator.analyse(base_type, env, nonempty=nonempty) + else: + return self.name_declarator, self.type + + def inject_type_from_annotations(self, env): + annotation = self.annotation + if not annotation: + return None + base_type, arg_type = analyse_type_annotation(annotation, env, assigned_value=self.default) + if base_type is not None: + self.base_type = base_type + return arg_type + + def calculate_default_value_code(self, code): + if self.default_value is None: + if self.default: + if self.default.is_literal: + # will not output any code, just assign the result_code + self.default.generate_evaluation_code(code) + return self.type.cast_code(self.default.result()) + self.default_value = code.get_argument_default_const(self.type) + return self.default_value + + def annotate(self, code): + if self.default: + self.default.annotate(code) + + def generate_assignment_code(self, code, target=None, overloaded_assignment=False): + default = self.default + if default is None or default.is_literal: + return + if target is None: + target = self.calculate_default_value_code(code) + default.generate_evaluation_code(code) + default.make_owned_reference(code) + result = default.result() if overloaded_assignment else default.result_as(self.type) + code.putln("%s = %s;" % (target, result)) + if self.type.is_pyobject: + code.put_giveref(default.result()) + default.generate_post_assignment_code(code) + default.free_temps(code) + + +class CBaseTypeNode(Node): + # Abstract base class for C base type nodes. + # + # Processing during analyse_declarations phase: + # + # analyse + # Returns the type. + + def analyse_as_type(self, env): + return self.analyse(env) + + +class CAnalysedBaseTypeNode(Node): + # type type + + child_attrs = [] + + def analyse(self, env, could_be_name=False): + return self.type + + +class CSimpleBaseTypeNode(CBaseTypeNode): + # name string + # module_path [string] Qualifying name components + # is_basic_c_type boolean + # signed boolean + # longness integer + # complex boolean + # is_self_arg boolean Is self argument of C method + # ##is_type_arg boolean Is type argument of class method + + child_attrs = [] + arg_name = None # in case the argument name was interpreted as a type + module_path = [] + is_basic_c_type = False + complex = False + + def analyse(self, env, could_be_name=False): + # Return type descriptor. + #print "CSimpleBaseTypeNode.analyse: is_self_arg =", self.is_self_arg ### + type = None + if self.is_basic_c_type: + type = PyrexTypes.simple_c_type(self.signed, self.longness, self.name) + if not type: + error(self.pos, "Unrecognised type modifier combination") + elif self.name == "object" and not self.module_path: + type = py_object_type + elif self.name is None: + if self.is_self_arg and env.is_c_class_scope: + #print "CSimpleBaseTypeNode.analyse: defaulting to parent type" ### + type = env.parent_type + ## elif self.is_type_arg and env.is_c_class_scope: + ## type = Builtin.type_type + else: + type = py_object_type + else: + if self.module_path: + # Maybe it's a nested C++ class. + scope = env + for item in self.module_path: + entry = scope.lookup(item) + if entry is not None and entry.is_cpp_class: + scope = entry.type.scope + else: + scope = None + break + + if scope is None: + # Maybe it's a cimport. + scope = env.find_imported_module(self.module_path, self.pos) + else: + scope = env + + if scope: + if scope.is_c_class_scope: + scope = scope.global_scope() + + type = scope.lookup_type(self.name) + if type is not None: + pass + elif could_be_name: + if self.is_self_arg and env.is_c_class_scope: + type = env.parent_type + ## elif self.is_type_arg and env.is_c_class_scope: + ## type = Builtin.type_type + else: + type = py_object_type + self.arg_name = EncodedString(self.name) + else: + if self.templates: + if not self.name in self.templates: + error(self.pos, "'%s' is not a type identifier" % self.name) + type = PyrexTypes.TemplatePlaceholderType(self.name) + else: + error(self.pos, "'%s' is not a type identifier" % self.name) + if type and type.is_fused and env.fused_to_specific: + type = type.specialize(env.fused_to_specific) + if self.complex: + if not type.is_numeric or type.is_complex: + error(self.pos, "can only complexify c numeric types") + type = PyrexTypes.CComplexType(type) + type.create_declaration_utility_code(env) + elif type is Builtin.complex_type: + # Special case: optimise builtin complex type into C's + # double complex. The parser cannot do this (as for the + # normal scalar types) as the user may have redeclared the + # 'complex' type. Testing for the exact type here works. + type = PyrexTypes.c_double_complex_type + type.create_declaration_utility_code(env) + self.complex = True + if type: + return type + else: + return PyrexTypes.error_type + +class MemoryViewSliceTypeNode(CBaseTypeNode): + + name = 'memoryview' + child_attrs = ['base_type_node', 'axes'] + + def analyse(self, env, could_be_name=False): + + base_type = self.base_type_node.analyse(env) + if base_type.is_error: return base_type + + from . import MemoryView + + try: + axes_specs = MemoryView.get_axes_specs(env, self.axes) + except CompileError as e: + error(e.position, e.message_only) + self.type = PyrexTypes.ErrorType() + return self.type + + if not MemoryView.validate_axes(self.pos, axes_specs): + self.type = error_type + else: + self.type = PyrexTypes.MemoryViewSliceType(base_type, axes_specs) + self.type.validate_memslice_dtype(self.pos) + self.use_memview_utilities(env) + + return self.type + + def use_memview_utilities(self, env): + from . import MemoryView + env.use_utility_code(MemoryView.view_utility_code) + + +class CNestedBaseTypeNode(CBaseTypeNode): + # For C++ classes that live inside other C++ classes. + + # name string + # base_type CBaseTypeNode + + child_attrs = ['base_type'] + + def analyse(self, env, could_be_name=None): + base_type = self.base_type.analyse(env) + if base_type is PyrexTypes.error_type: + return PyrexTypes.error_type + if not base_type.is_cpp_class: + error(self.pos, "'%s' is not a valid type scope" % base_type) + return PyrexTypes.error_type + type_entry = base_type.scope.lookup_here(self.name) + if not type_entry or not type_entry.is_type: + error(self.pos, "'%s.%s' is not a type identifier" % (base_type, self.name)) + return PyrexTypes.error_type + return type_entry.type + + +class TemplatedTypeNode(CBaseTypeNode): + # After parsing: + # positional_args [ExprNode] List of positional arguments + # keyword_args DictNode Keyword arguments + # base_type_node CBaseTypeNode + + # After analysis: + # type PyrexTypes.BufferType or PyrexTypes.CppClassType ...containing the right options + + child_attrs = ["base_type_node", "positional_args", + "keyword_args", "dtype_node"] + + dtype_node = None + + name = None + + def analyse(self, env, could_be_name=False, base_type=None): + if base_type is None: + base_type = self.base_type_node.analyse(env) + if base_type.is_error: return base_type + + if base_type.is_cpp_class and base_type.is_template_type(): + # Templated class + if self.keyword_args and self.keyword_args.key_value_pairs: + error(self.pos, "c++ templates cannot take keyword arguments") + self.type = PyrexTypes.error_type + else: + template_types = [] + for template_node in self.positional_args: + type = template_node.analyse_as_type(env) + if type is None: + error(template_node.pos, "unknown type in template argument") + type = error_type + template_types.append(type) + self.type = base_type.specialize_here(self.pos, template_types) + + elif base_type.is_pyobject: + # Buffer + from . import Buffer + + options = Buffer.analyse_buffer_options( + self.pos, + env, + self.positional_args, + self.keyword_args, + base_type.buffer_defaults) + + if sys.version_info[0] < 3: + # Py 2.x enforces byte strings as keyword arguments ... + options = dict([(name.encode('ASCII'), value) + for name, value in options.items()]) + + self.type = PyrexTypes.BufferType(base_type, **options) + if has_np_pythran(env) and is_pythran_buffer(self.type): + self.type = PyrexTypes.PythranExpr(pythran_type(self.type), self.type) + + else: + # Array + empty_declarator = CNameDeclaratorNode(self.pos, name="", cname=None) + if len(self.positional_args) > 1 or self.keyword_args.key_value_pairs: + error(self.pos, "invalid array declaration") + self.type = PyrexTypes.error_type + else: + # It would be nice to merge this class with CArrayDeclaratorNode, + # but arrays are part of the declaration, not the type... + if not self.positional_args: + dimension = None + else: + dimension = self.positional_args[0] + self.array_declarator = CArrayDeclaratorNode( + self.pos, + base=empty_declarator, + dimension=dimension) + self.type = self.array_declarator.analyse(base_type, env)[1] + + if self.type.is_fused and env.fused_to_specific: + self.type = self.type.specialize(env.fused_to_specific) + + return self.type + + +class CComplexBaseTypeNode(CBaseTypeNode): + # base_type CBaseTypeNode + # declarator CDeclaratorNode + + child_attrs = ["base_type", "declarator"] + + def analyse(self, env, could_be_name=False): + base = self.base_type.analyse(env, could_be_name) + _, type = self.declarator.analyse(base, env) + return type + + +class CTupleBaseTypeNode(CBaseTypeNode): + # components [CBaseTypeNode] + + child_attrs = ["components"] + + def analyse(self, env, could_be_name=False): + component_types = [] + for c in self.components: + type = c.analyse(env) + if type.is_pyobject: + error(c.pos, "Tuple types can't (yet) contain Python objects.") + return error_type + component_types.append(type) + entry = env.declare_tuple_type(self.pos, component_types) + entry.used = True + return entry.type + + +class FusedTypeNode(CBaseTypeNode): + """ + Represents a fused type in a ctypedef statement: + + ctypedef cython.fused_type(int, long, long long) integral + + name str name of this fused type + types [CSimpleBaseTypeNode] is the list of types to be fused + """ + + child_attrs = [] + + def analyse_declarations(self, env): + type = self.analyse(env) + entry = env.declare_typedef(self.name, type, self.pos) + + # Omit the typedef declaration that self.declarator would produce + entry.in_cinclude = True + + def analyse(self, env, could_be_name=False): + types = [] + for type_node in self.types: + type = type_node.analyse_as_type(env) + + if not type: + error(type_node.pos, "Not a type") + continue + + if type in types: + error(type_node.pos, "Type specified multiple times") + else: + types.append(type) + + # if len(self.types) == 1: + # return types[0] + + return PyrexTypes.FusedType(types, name=self.name) + + +class CConstTypeNode(CBaseTypeNode): + # base_type CBaseTypeNode + + child_attrs = ["base_type"] + + def analyse(self, env, could_be_name=False): + base = self.base_type.analyse(env, could_be_name) + if base.is_pyobject: + error(self.pos, + "Const base type cannot be a Python object") + return PyrexTypes.c_const_type(base) + + +class CVarDefNode(StatNode): + # C variable definition or forward/extern function declaration. + # + # visibility 'private' or 'public' or 'extern' + # base_type CBaseTypeNode + # declarators [CDeclaratorNode] + # in_pxd boolean + # api boolean + # overridable boolean whether it is a cpdef + # modifiers ['inline'] + + # decorators [cython.locals(...)] or None + # directive_locals { string : NameNode } locals defined by cython.locals(...) + + child_attrs = ["base_type", "declarators"] + + decorators = None + directive_locals = None + + def analyse_declarations(self, env, dest_scope=None): + if self.directive_locals is None: + self.directive_locals = {} + if not dest_scope: + dest_scope = env + self.dest_scope = dest_scope + + if self.declarators: + templates = self.declarators[0].analyse_templates() + else: + templates = None + if templates is not None: + if self.visibility != 'extern': + error(self.pos, "Only extern functions allowed") + if len(self.declarators) > 1: + error(self.declarators[1].pos, "Can't multiply declare template types") + env = TemplateScope('func_template', env) + env.directives = env.outer_scope.directives + for template_param in templates: + env.declare_type(template_param.name, template_param, self.pos) + + base_type = self.base_type.analyse(env) + + if base_type.is_fused and not self.in_pxd and (env.is_c_class_scope or + env.is_module_scope): + error(self.pos, "Fused types not allowed here") + return error_type + + self.entry = None + visibility = self.visibility + + for declarator in self.declarators: + + if (len(self.declarators) > 1 + and not isinstance(declarator, CNameDeclaratorNode) + and env.directives['warn.multiple_declarators']): + warning( + declarator.pos, + "Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). " + "Each pointer declaration should be on its own line.", 1) + + create_extern_wrapper = (self.overridable + and self.visibility == 'extern' + and env.is_module_scope) + if create_extern_wrapper: + declarator.overridable = False + if isinstance(declarator, CFuncDeclaratorNode): + name_declarator, type = declarator.analyse( + base_type, env, directive_locals=self.directive_locals, visibility=visibility, in_pxd=self.in_pxd) + else: + name_declarator, type = declarator.analyse( + base_type, env, visibility=visibility, in_pxd=self.in_pxd) + if not type.is_complete(): + if not (self.visibility == 'extern' and type.is_array or type.is_memoryviewslice): + error(declarator.pos, "Variable type '%s' is incomplete" % type) + if self.visibility == 'extern' and type.is_pyobject: + error(declarator.pos, "Python object cannot be declared extern") + name = name_declarator.name + cname = name_declarator.cname + if name == '': + error(declarator.pos, "Missing name in declaration.") + return + if type.is_reference and self.visibility != 'extern': + error(declarator.pos, "C++ references cannot be declared; use a pointer instead") + if type.is_cfunction: + if 'staticmethod' in env.directives: + type.is_static_method = True + self.entry = dest_scope.declare_cfunction( + name, type, declarator.pos, + cname=cname, visibility=self.visibility, in_pxd=self.in_pxd, + api=self.api, modifiers=self.modifiers, overridable=self.overridable) + if self.entry is not None: + self.entry.directive_locals = copy.copy(self.directive_locals) + if create_extern_wrapper: + self.entry.type.create_to_py_utility_code(env) + self.entry.create_wrapper = True + else: + if self.overridable: + warning(self.pos, "cpdef variables will not be supported in Cython 3; " + "currently they are no different from cdef variables", 2) + if self.directive_locals: + error(self.pos, "Decorators can only be followed by functions") + self.entry = dest_scope.declare_var( + name, type, declarator.pos, + cname=cname, visibility=visibility, in_pxd=self.in_pxd, + api=self.api, is_cdef=1) + if Options.docstrings: + self.entry.doc = embed_position(self.pos, self.doc) + + +class CStructOrUnionDefNode(StatNode): + # name string + # cname string or None + # kind "struct" or "union" + # typedef_flag boolean + # visibility "public" or "private" + # api boolean + # in_pxd boolean + # attributes [CVarDefNode] or None + # entry Entry + # packed boolean + + child_attrs = ["attributes"] + + def declare(self, env, scope=None): + self.entry = env.declare_struct_or_union( + self.name, self.kind, scope, self.typedef_flag, self.pos, + self.cname, visibility=self.visibility, api=self.api, + packed=self.packed) + + def analyse_declarations(self, env): + scope = None + if self.attributes is not None: + scope = StructOrUnionScope(self.name) + self.declare(env, scope) + if self.attributes is not None: + if self.in_pxd and not env.in_cinclude: + self.entry.defined_in_pxd = 1 + for attr in self.attributes: + attr.analyse_declarations(env, scope) + if self.visibility != 'extern': + for attr in scope.var_entries: + type = attr.type + while type.is_array: + type = type.base_type + if type == self.entry.type: + error(attr.pos, "Struct cannot contain itself as a member.") + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + +class CppClassNode(CStructOrUnionDefNode, BlockNode): + + # name string + # cname string or None + # visibility "extern" + # in_pxd boolean + # attributes [CVarDefNode] or None + # entry Entry + # base_classes [CBaseTypeNode] + # templates [(string, bool)] or None + # decorators [DecoratorNode] or None + + decorators = None + + def declare(self, env): + if self.templates is None: + template_types = None + else: + template_types = [PyrexTypes.TemplatePlaceholderType(template_name, not required) + for template_name, required in self.templates] + num_optional_templates = sum(not required for _, required in self.templates) + if num_optional_templates and not all(required for _, required in self.templates[:-num_optional_templates]): + error(self.pos, "Required template parameters must precede optional template parameters.") + self.entry = env.declare_cpp_class( + self.name, None, self.pos, self.cname, + base_classes=[], visibility=self.visibility, templates=template_types) + + def analyse_declarations(self, env): + if self.templates is None: + template_types = template_names = None + else: + template_names = [template_name for template_name, _ in self.templates] + template_types = [PyrexTypes.TemplatePlaceholderType(template_name, not required) + for template_name, required in self.templates] + scope = None + if self.attributes is not None: + scope = CppClassScope(self.name, env, templates=template_names) + def base_ok(base_class): + if base_class.is_cpp_class or base_class.is_struct: + return True + else: + error(self.pos, "Base class '%s' not a struct or class." % base_class) + base_class_types = filter(base_ok, [b.analyse(scope or env) for b in self.base_classes]) + self.entry = env.declare_cpp_class( + self.name, scope, self.pos, + self.cname, base_class_types, visibility=self.visibility, templates=template_types) + if self.entry is None: + return + self.entry.is_cpp_class = 1 + if scope is not None: + scope.type = self.entry.type + defined_funcs = [] + def func_attributes(attributes): + for attr in attributes: + if isinstance(attr, CFuncDefNode): + yield attr + elif isinstance(attr, CompilerDirectivesNode): + for sub_attr in func_attributes(attr.body.stats): + yield sub_attr + if self.attributes is not None: + if self.in_pxd and not env.in_cinclude: + self.entry.defined_in_pxd = 1 + for attr in self.attributes: + declare = getattr(attr, 'declare', None) + if declare: + attr.declare(scope) + attr.analyse_declarations(scope) + for func in func_attributes(self.attributes): + defined_funcs.append(func) + if self.templates is not None: + func.template_declaration = "template <typename %s>" % ", typename ".join(template_names) + self.body = StatListNode(self.pos, stats=defined_funcs) + self.scope = scope + + def analyse_expressions(self, env): + self.body = self.body.analyse_expressions(self.entry.type.scope) + return self + + def generate_function_definitions(self, env, code): + self.body.generate_function_definitions(self.entry.type.scope, code) + + def generate_execution_code(self, code): + self.body.generate_execution_code(code) + + def annotate(self, code): + self.body.annotate(code) + + +class CEnumDefNode(StatNode): + # name string or None + # cname string or None + # items [CEnumDefItemNode] + # typedef_flag boolean + # visibility "public" or "private" or "extern" + # api boolean + # in_pxd boolean + # create_wrapper boolean + # entry Entry + + child_attrs = ["items"] + + def declare(self, env): + self.entry = env.declare_enum( + self.name, self.pos, + cname=self.cname, typedef_flag=self.typedef_flag, + visibility=self.visibility, api=self.api, + create_wrapper=self.create_wrapper) + + def analyse_declarations(self, env): + if self.items is not None: + if self.in_pxd and not env.in_cinclude: + self.entry.defined_in_pxd = 1 + for item in self.items: + item.analyse_declarations(env, self.entry) + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + if self.visibility == 'public' or self.api: + code.mark_pos(self.pos) + temp = code.funcstate.allocate_temp(PyrexTypes.py_object_type, manage_ref=True) + for item in self.entry.enum_values: + code.putln("%s = PyInt_FromLong(%s); %s" % ( + temp, + item.cname, + code.error_goto_if_null(temp, item.pos))) + code.put_gotref(temp) + code.putln('if (PyDict_SetItemString(%s, "%s", %s) < 0) %s' % ( + Naming.moddict_cname, + item.name, + temp, + code.error_goto(item.pos))) + code.put_decref_clear(temp, PyrexTypes.py_object_type) + code.funcstate.release_temp(temp) + + +class CEnumDefItemNode(StatNode): + # name string + # cname string or None + # value ExprNode or None + + child_attrs = ["value"] + + def analyse_declarations(self, env, enum_entry): + if self.value: + self.value = self.value.analyse_const_expression(env) + if not self.value.type.is_int: + self.value = self.value.coerce_to(PyrexTypes.c_int_type, env) + self.value = self.value.analyse_const_expression(env) + entry = env.declare_const( + self.name, enum_entry.type, + self.value, self.pos, cname=self.cname, + visibility=enum_entry.visibility, api=enum_entry.api, + create_wrapper=enum_entry.create_wrapper and enum_entry.name is None) + enum_entry.enum_values.append(entry) + if enum_entry.name: + enum_entry.type.values.append(entry.name) + + +class CTypeDefNode(StatNode): + # base_type CBaseTypeNode + # declarator CDeclaratorNode + # visibility "public" or "private" + # api boolean + # in_pxd boolean + + child_attrs = ["base_type", "declarator"] + + def analyse_declarations(self, env): + base = self.base_type.analyse(env) + name_declarator, type = self.declarator.analyse( + base, env, visibility=self.visibility, in_pxd=self.in_pxd) + name = name_declarator.name + cname = name_declarator.cname + + entry = env.declare_typedef( + name, type, self.pos, + cname=cname, visibility=self.visibility, api=self.api) + + if type.is_fused: + entry.in_cinclude = True + + if self.in_pxd and not env.in_cinclude: + entry.defined_in_pxd = 1 + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + +class FuncDefNode(StatNode, BlockNode): + # Base class for function definition nodes. + # + # return_type PyrexType + # #filename string C name of filename string const + # entry Symtab.Entry + # needs_closure boolean Whether or not this function has inner functions/classes/yield + # needs_outer_scope boolean Whether or not this function requires outer scope + # pymethdef_required boolean Force Python method struct generation + # directive_locals { string : ExprNode } locals defined by cython.locals(...) + # directive_returns [ExprNode] type defined by cython.returns(...) + # star_arg PyArgDeclNode or None * argument + # starstar_arg PyArgDeclNode or None ** argument + # + # is_async_def boolean is a Coroutine function + # + # has_fused_arguments boolean + # Whether this cdef function has fused parameters. This is needed + # by AnalyseDeclarationsTransform, so it can replace CFuncDefNodes + # with fused argument types with a FusedCFuncDefNode + + py_func = None + needs_closure = False + needs_outer_scope = False + pymethdef_required = False + is_generator = False + is_generator_body = False + is_async_def = False + modifiers = [] + has_fused_arguments = False + star_arg = None + starstar_arg = None + is_cyfunction = False + code_object = None + + def analyse_default_values(self, env): + default_seen = 0 + for arg in self.args: + if arg.default: + default_seen = 1 + if arg.is_generic: + arg.default = arg.default.analyse_types(env) + arg.default = arg.default.coerce_to(arg.type, env) + else: + error(arg.pos, "This argument cannot have a default value") + arg.default = None + elif arg.kw_only: + default_seen = 1 + elif default_seen: + error(arg.pos, "Non-default argument following default argument") + + def analyse_annotation(self, env, annotation): + # Annotations can not only contain valid Python expressions but arbitrary type references. + if annotation is None: + return None + if not env.directives['annotation_typing'] or annotation.analyse_as_type(env) is None: + annotation = annotation.analyse_types(env) + return annotation + + def analyse_annotations(self, env): + for arg in self.args: + if arg.annotation: + arg.annotation = self.analyse_annotation(env, arg.annotation) + + def align_argument_type(self, env, arg): + # @cython.locals() + directive_locals = self.directive_locals + orig_type = arg.type + if arg.name in directive_locals: + type_node = directive_locals[arg.name] + other_type = type_node.analyse_as_type(env) + elif isinstance(arg, CArgDeclNode) and arg.annotation and env.directives['annotation_typing']: + type_node = arg.annotation + other_type = arg.inject_type_from_annotations(env) + if other_type is None: + return arg + else: + return arg + if other_type is None: + error(type_node.pos, "Not a type") + elif orig_type is not py_object_type and not orig_type.same_as(other_type): + error(arg.base_type.pos, "Signature does not agree with previous declaration") + error(type_node.pos, "Previous declaration here") + else: + arg.type = other_type + return arg + + def need_gil_acquisition(self, lenv): + return 0 + + def create_local_scope(self, env): + genv = env + while genv.is_py_class_scope or genv.is_c_class_scope: + genv = genv.outer_scope + if self.needs_closure: + lenv = ClosureScope(name=self.entry.name, + outer_scope=genv, + parent_scope=env, + scope_name=self.entry.cname) + else: + lenv = LocalScope(name=self.entry.name, + outer_scope=genv, + parent_scope=env) + lenv.return_type = self.return_type + type = self.entry.type + if type.is_cfunction: + lenv.nogil = type.nogil and not type.with_gil + self.local_scope = lenv + lenv.directives = env.directives + return lenv + + def generate_function_body(self, env, code): + self.body.generate_execution_code(code) + + def generate_function_definitions(self, env, code): + from . import Buffer + if self.return_type.is_memoryviewslice: + from . import MemoryView + + lenv = self.local_scope + if lenv.is_closure_scope and not lenv.is_passthrough: + outer_scope_cname = "%s->%s" % (Naming.cur_scope_cname, + Naming.outer_scope_cname) + else: + outer_scope_cname = Naming.outer_scope_cname + lenv.mangle_closure_cnames(outer_scope_cname) + # Generate closure function definitions + self.body.generate_function_definitions(lenv, code) + # generate lambda function definitions + self.generate_lambda_definitions(lenv, code) + + is_getbuffer_slot = (self.entry.name == "__getbuffer__" and + self.entry.scope.is_c_class_scope) + is_releasebuffer_slot = (self.entry.name == "__releasebuffer__" and + self.entry.scope.is_c_class_scope) + is_buffer_slot = is_getbuffer_slot or is_releasebuffer_slot + if is_buffer_slot: + if 'cython_unused' not in self.modifiers: + self.modifiers = self.modifiers + ['cython_unused'] + + preprocessor_guard = self.get_preprocessor_guard() + + profile = code.globalstate.directives['profile'] + linetrace = code.globalstate.directives['linetrace'] + if profile or linetrace: + code.globalstate.use_utility_code( + UtilityCode.load_cached("Profile", "Profile.c")) + + # Generate C code for header and body of function + code.enter_cfunc_scope(lenv) + code.return_from_error_cleanup_label = code.new_label() + code.funcstate.gil_owned = not lenv.nogil + + # ----- Top-level constants used by this function + code.mark_pos(self.pos) + self.generate_cached_builtins_decls(lenv, code) + # ----- Function header + code.putln("") + + if preprocessor_guard: + code.putln(preprocessor_guard) + + with_pymethdef = (self.needs_assignment_synthesis(env, code) or + self.pymethdef_required) + if self.py_func: + self.py_func.generate_function_header( + code, with_pymethdef=with_pymethdef, proto_only=True) + self.generate_function_header(code, with_pymethdef=with_pymethdef) + # ----- Local variable declarations + # Find function scope + cenv = env + while cenv.is_py_class_scope or cenv.is_c_class_scope: + cenv = cenv.outer_scope + if self.needs_closure: + code.put(lenv.scope_class.type.declaration_code(Naming.cur_scope_cname)) + code.putln(";") + elif self.needs_outer_scope: + if lenv.is_passthrough: + code.put(lenv.scope_class.type.declaration_code(Naming.cur_scope_cname)) + code.putln(";") + code.put(cenv.scope_class.type.declaration_code(Naming.outer_scope_cname)) + code.putln(";") + self.generate_argument_declarations(lenv, code) + + for entry in lenv.var_entries: + if not (entry.in_closure or entry.is_arg): + code.put_var_declaration(entry) + + # Initialize the return variable __pyx_r + init = "" + if not self.return_type.is_void: + if self.return_type.is_pyobject: + init = " = NULL" + elif self.return_type.is_memoryviewslice: + init = ' = ' + MemoryView.memslice_entry_init + + code.putln("%s%s;" % ( + self.return_type.declaration_code(Naming.retval_cname), + init)) + + tempvardecl_code = code.insertion_point() + self.generate_keyword_list(code) + + # ----- GIL acquisition + acquire_gil = self.acquire_gil + + # See if we need to acquire the GIL for variable declarations, or for + # refnanny only + + # Closures are not currently possible for cdef nogil functions, + # but check them anyway + have_object_args = self.needs_closure or self.needs_outer_scope + for arg in lenv.arg_entries: + if arg.type.is_pyobject: + have_object_args = True + break + + used_buffer_entries = [entry for entry in lenv.buffer_entries if entry.used] + + acquire_gil_for_var_decls_only = ( + lenv.nogil and lenv.has_with_gil_block and + (have_object_args or used_buffer_entries)) + + acquire_gil_for_refnanny_only = ( + lenv.nogil and lenv.has_with_gil_block and not + acquire_gil_for_var_decls_only) + + use_refnanny = not lenv.nogil or lenv.has_with_gil_block + + if acquire_gil or acquire_gil_for_var_decls_only: + code.put_ensure_gil() + code.funcstate.gil_owned = True + elif lenv.nogil and lenv.has_with_gil_block: + code.declare_gilstate() + + if profile or linetrace: + if not self.is_generator: + # generators are traced when iterated, not at creation + tempvardecl_code.put_trace_declarations() + code_object = self.code_object.calculate_result_code(code) if self.code_object else None + code.put_trace_frame_init(code_object) + + # ----- Special check for getbuffer + if is_getbuffer_slot: + self.getbuffer_check(code) + + # ----- set up refnanny + if use_refnanny: + tempvardecl_code.put_declare_refcount_context() + code.put_setup_refcount_context( + self.entry.name, acquire_gil=acquire_gil_for_refnanny_only) + + # ----- Automatic lead-ins for certain special functions + if is_getbuffer_slot: + self.getbuffer_init(code) + # ----- Create closure scope object + if self.needs_closure: + tp_slot = TypeSlots.ConstructorSlot("tp_new", '__new__') + slot_func_cname = TypeSlots.get_slot_function(lenv.scope_class.type.scope, tp_slot) + if not slot_func_cname: + slot_func_cname = '%s->tp_new' % lenv.scope_class.type.typeptr_cname + code.putln("%s = (%s)%s(%s, %s, NULL);" % ( + Naming.cur_scope_cname, + lenv.scope_class.type.empty_declaration_code(), + slot_func_cname, + lenv.scope_class.type.typeptr_cname, + Naming.empty_tuple)) + code.putln("if (unlikely(!%s)) {" % Naming.cur_scope_cname) + # Scope unconditionally DECREFed on return. + code.putln("%s = %s;" % ( + Naming.cur_scope_cname, + lenv.scope_class.type.cast_code("Py_None"))) + code.put_incref("Py_None", py_object_type) + code.putln(code.error_goto(self.pos)) + code.putln("} else {") + code.put_gotref(Naming.cur_scope_cname) + code.putln("}") + # Note that it is unsafe to decref the scope at this point. + if self.needs_outer_scope: + if self.is_cyfunction: + code.putln("%s = (%s) __Pyx_CyFunction_GetClosure(%s);" % ( + outer_scope_cname, + cenv.scope_class.type.empty_declaration_code(), + Naming.self_cname)) + else: + code.putln("%s = (%s) %s;" % ( + outer_scope_cname, + cenv.scope_class.type.empty_declaration_code(), + Naming.self_cname)) + if lenv.is_passthrough: + code.putln("%s = %s;" % (Naming.cur_scope_cname, outer_scope_cname)) + elif self.needs_closure: + # inner closures own a reference to their outer parent + code.put_incref(outer_scope_cname, cenv.scope_class.type) + code.put_giveref(outer_scope_cname) + # ----- Trace function call + if profile or linetrace: + # this looks a bit late, but if we don't get here due to a + # fatal error before hand, it's not really worth tracing + if not self.is_generator: + # generators are traced when iterated, not at creation + if self.is_wrapper: + trace_name = self.entry.name + " (wrapper)" + else: + trace_name = self.entry.name + code.put_trace_call( + trace_name, self.pos, nogil=not code.funcstate.gil_owned) + code.funcstate.can_trace = True + # ----- Fetch arguments + self.generate_argument_parsing_code(env, code) + # If an argument is assigned to in the body, we must + # incref it to properly keep track of refcounts. + is_cdef = isinstance(self, CFuncDefNode) + for entry in lenv.arg_entries: + if entry.type.is_pyobject: + if (acquire_gil or len(entry.cf_assignments) > 1) and not entry.in_closure: + code.put_var_incref(entry) + + # Note: defaults are always incref-ed. For def functions, we + # we acquire arguments from object conversion, so we have + # new references. If we are a cdef function, we need to + # incref our arguments + elif is_cdef and entry.type.is_memoryviewslice and len(entry.cf_assignments) > 1: + code.put_incref_memoryviewslice(entry.cname, have_gil=code.funcstate.gil_owned) + for entry in lenv.var_entries: + if entry.is_arg and len(entry.cf_assignments) > 1 and not entry.in_closure: + if entry.xdecref_cleanup: + code.put_var_xincref(entry) + else: + code.put_var_incref(entry) + + # ----- Initialise local buffer auxiliary variables + for entry in lenv.var_entries + lenv.arg_entries: + if entry.type.is_buffer and entry.buffer_aux.buflocal_nd_var.used: + Buffer.put_init_vars(entry, code) + + # ----- Check and convert arguments + self.generate_argument_type_tests(code) + # ----- Acquire buffer arguments + for entry in lenv.arg_entries: + if entry.type.is_buffer: + Buffer.put_acquire_arg_buffer(entry, code, self.pos) + + if acquire_gil_for_var_decls_only: + code.put_release_ensured_gil() + code.funcstate.gil_owned = False + + # ------------------------- + # ----- Function body ----- + # ------------------------- + self.generate_function_body(env, code) + + code.mark_pos(self.pos, trace=False) + code.putln("") + code.putln("/* function exit code */") + + # ----- Default return value + if not self.body.is_terminator: + if self.return_type.is_pyobject: + #if self.return_type.is_extension_type: + # lhs = "(PyObject *)%s" % Naming.retval_cname + #else: + lhs = Naming.retval_cname + code.put_init_to_py_none(lhs, self.return_type) + else: + val = self.return_type.default_value + if val: + code.putln("%s = %s;" % (Naming.retval_cname, val)) + elif not self.return_type.is_void: + code.putln("__Pyx_pretend_to_initialize(&%s);" % Naming.retval_cname) + # ----- Error cleanup + if code.error_label in code.labels_used: + if not self.body.is_terminator: + code.put_goto(code.return_label) + code.put_label(code.error_label) + for cname, type in code.funcstate.all_managed_temps(): + code.put_xdecref(cname, type, have_gil=not lenv.nogil) + + # Clean up buffers -- this calls a Python function + # so need to save and restore error state + buffers_present = len(used_buffer_entries) > 0 + #memslice_entries = [e for e in lenv.entries.values() if e.type.is_memoryviewslice] + if buffers_present: + code.globalstate.use_utility_code(restore_exception_utility_code) + code.putln("{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;") + code.putln("__Pyx_PyThreadState_declare") + code.putln("__Pyx_PyThreadState_assign") + code.putln("__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);") + for entry in used_buffer_entries: + Buffer.put_release_buffer_code(code, entry) + #code.putln("%s = 0;" % entry.cname) + code.putln("__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}") + + if self.return_type.is_memoryviewslice: + MemoryView.put_init_entry(Naming.retval_cname, code) + err_val = Naming.retval_cname + else: + err_val = self.error_value() + + exc_check = self.caller_will_check_exceptions() + if err_val is not None or exc_check: + # TODO: Fix exception tracing (though currently unused by cProfile). + # code.globalstate.use_utility_code(get_exception_tuple_utility_code) + # code.put_trace_exception() + + if lenv.nogil and not lenv.has_with_gil_block: + code.putln("{") + code.put_ensure_gil() + + code.put_add_traceback(self.entry.qualified_name) + + if lenv.nogil and not lenv.has_with_gil_block: + code.put_release_ensured_gil() + code.putln("}") + else: + warning(self.entry.pos, + "Unraisable exception in function '%s'." % + self.entry.qualified_name, 0) + code.put_unraisable(self.entry.qualified_name, lenv.nogil) + default_retval = self.return_type.default_value + if err_val is None and default_retval: + err_val = default_retval + if err_val is not None: + if err_val != Naming.retval_cname: + code.putln("%s = %s;" % (Naming.retval_cname, err_val)) + elif not self.return_type.is_void: + code.putln("__Pyx_pretend_to_initialize(&%s);" % Naming.retval_cname) + + if is_getbuffer_slot: + self.getbuffer_error_cleanup(code) + + # If we are using the non-error cleanup section we should + # jump past it if we have an error. The if-test below determine + # whether this section is used. + if buffers_present or is_getbuffer_slot or self.return_type.is_memoryviewslice: + code.put_goto(code.return_from_error_cleanup_label) + + # ----- Non-error return cleanup + code.put_label(code.return_label) + for entry in used_buffer_entries: + Buffer.put_release_buffer_code(code, entry) + if is_getbuffer_slot: + self.getbuffer_normal_cleanup(code) + + if self.return_type.is_memoryviewslice: + # See if our return value is uninitialized on non-error return + # from . import MemoryView + # MemoryView.err_if_nogil_initialized_check(self.pos, env) + cond = code.unlikely(self.return_type.error_condition(Naming.retval_cname)) + code.putln( + 'if (%s) {' % cond) + if env.nogil: + code.put_ensure_gil() + code.putln( + 'PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");') + if env.nogil: + code.put_release_ensured_gil() + code.putln( + '}') + + # ----- Return cleanup for both error and no-error return + code.put_label(code.return_from_error_cleanup_label) + + for entry in lenv.var_entries: + if not entry.used or entry.in_closure: + continue + + if entry.type.is_memoryviewslice: + code.put_xdecref_memoryviewslice(entry.cname, have_gil=not lenv.nogil) + elif entry.type.is_pyobject: + if not entry.is_arg or len(entry.cf_assignments) > 1: + if entry.xdecref_cleanup: + code.put_var_xdecref(entry) + else: + code.put_var_decref(entry) + + # Decref any increfed args + for entry in lenv.arg_entries: + if entry.type.is_pyobject: + if (acquire_gil or len(entry.cf_assignments) > 1) and not entry.in_closure: + code.put_var_decref(entry) + elif (entry.type.is_memoryviewslice and + (not is_cdef or len(entry.cf_assignments) > 1)): + # decref slices of def functions and acquired slices from cdef + # functions, but not borrowed slices from cdef functions. + code.put_xdecref_memoryviewslice(entry.cname, + have_gil=not lenv.nogil) + if self.needs_closure: + code.put_decref(Naming.cur_scope_cname, lenv.scope_class.type) + + # ----- Return + # This code is duplicated in ModuleNode.generate_module_init_func + if not lenv.nogil: + default_retval = self.return_type.default_value + err_val = self.error_value() + if err_val is None and default_retval: + err_val = default_retval # FIXME: why is err_val not used? + if self.return_type.is_pyobject: + code.put_xgiveref(self.return_type.as_pyobject(Naming.retval_cname)) + + if self.entry.is_special and self.entry.name == "__hash__": + # Returning -1 for __hash__ is supposed to signal an error + # We do as Python instances and coerce -1 into -2. + code.putln("if (unlikely(%s == -1) && !PyErr_Occurred()) %s = -2;" % ( + Naming.retval_cname, Naming.retval_cname)) + + if profile or linetrace: + code.funcstate.can_trace = False + if not self.is_generator: + # generators are traced when iterated, not at creation + if self.return_type.is_pyobject: + code.put_trace_return( + Naming.retval_cname, nogil=not code.funcstate.gil_owned) + else: + code.put_trace_return( + "Py_None", nogil=not code.funcstate.gil_owned) + + if not lenv.nogil: + # GIL holding function + code.put_finish_refcount_context() + + if acquire_gil or (lenv.nogil and lenv.has_with_gil_block): + # release the GIL (note that with-gil blocks acquire it on exit in their EnsureGILNode) + code.put_release_ensured_gil() + code.funcstate.gil_owned = False + + if not self.return_type.is_void: + code.putln("return %s;" % Naming.retval_cname) + + code.putln("}") + + if preprocessor_guard: + code.putln("#endif /*!(%s)*/" % preprocessor_guard) + + # ----- Go back and insert temp variable declarations + tempvardecl_code.put_temp_declarations(code.funcstate) + + # ----- Python version + code.exit_cfunc_scope() + if self.py_func: + self.py_func.generate_function_definitions(env, code) + self.generate_wrapper_functions(code) + + def declare_argument(self, env, arg): + if arg.type.is_void: + error(arg.pos, "Invalid use of 'void'") + elif not arg.type.is_complete() and not (arg.type.is_array or arg.type.is_memoryviewslice): + error(arg.pos, "Argument type '%s' is incomplete" % arg.type) + entry = env.declare_arg(arg.name, arg.type, arg.pos) + if arg.annotation: + entry.annotation = arg.annotation + return entry + + def generate_arg_type_test(self, arg, code): + # Generate type test for one argument. + if arg.type.typeobj_is_available(): + code.globalstate.use_utility_code( + UtilityCode.load_cached("ArgTypeTest", "FunctionArguments.c")) + typeptr_cname = arg.type.typeptr_cname + arg_code = "((PyObject *)%s)" % arg.entry.cname + code.putln( + 'if (unlikely(!__Pyx_ArgTypeTest(%s, %s, %d, "%s", %s))) %s' % ( + arg_code, + typeptr_cname, + arg.accept_none, + arg.name, + arg.type.is_builtin_type and arg.type.require_exact, + code.error_goto(arg.pos))) + else: + error(arg.pos, "Cannot test type of extern C class without type object name specification") + + def generate_arg_none_check(self, arg, code): + # Generate None check for one argument. + if arg.type.is_memoryviewslice: + cname = "%s.memview" % arg.entry.cname + else: + cname = arg.entry.cname + + code.putln('if (unlikely(((PyObject *)%s) == Py_None)) {' % cname) + code.putln('''PyErr_Format(PyExc_TypeError, "Argument '%%.%ds' must not be None", "%s"); %s''' % ( + max(200, len(arg.name)), arg.name, + code.error_goto(arg.pos))) + code.putln('}') + + def generate_wrapper_functions(self, code): + pass + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + # Evaluate and store argument default values + for arg in self.args: + if not arg.is_dynamic: + arg.generate_assignment_code(code) + + # + # Special code for the __getbuffer__ function + # + def _get_py_buffer_info(self): + py_buffer = self.local_scope.arg_entries[1] + try: + # Check builtin definition of struct Py_buffer + obj_type = py_buffer.type.base_type.scope.entries['obj'].type + except (AttributeError, KeyError): + # User code redeclared struct Py_buffer + obj_type = None + return py_buffer, obj_type + + # Old Python 3 used to support write-locks on buffer-like objects by + # calling PyObject_GetBuffer() with a view==NULL parameter. This obscure + # feature is obsolete, it was almost never used (only one instance in + # `Modules/posixmodule.c` in Python 3.1) and it is now officially removed + # (see bpo-14203). We add an extra check here to prevent legacy code from + # from trying to use the feature and prevent segmentation faults. + def getbuffer_check(self, code): + py_buffer, _ = self._get_py_buffer_info() + view = py_buffer.cname + code.putln("if (%s == NULL) {" % view) + code.putln("PyErr_SetString(PyExc_BufferError, " + "\"PyObject_GetBuffer: view==NULL argument is obsolete\");") + code.putln("return -1;") + code.putln("}") + + def getbuffer_init(self, code): + py_buffer, obj_type = self._get_py_buffer_info() + view = py_buffer.cname + if obj_type and obj_type.is_pyobject: + code.put_init_to_py_none("%s->obj" % view, obj_type) + code.put_giveref("%s->obj" % view) # Do not refnanny object within structs + else: + code.putln("%s->obj = NULL;" % view) + + def getbuffer_error_cleanup(self, code): + py_buffer, obj_type = self._get_py_buffer_info() + view = py_buffer.cname + if obj_type and obj_type.is_pyobject: + code.putln("if (%s->obj != NULL) {" % view) + code.put_gotref("%s->obj" % view) + code.put_decref_clear("%s->obj" % view, obj_type) + code.putln("}") + else: + code.putln("Py_CLEAR(%s->obj);" % view) + + def getbuffer_normal_cleanup(self, code): + py_buffer, obj_type = self._get_py_buffer_info() + view = py_buffer.cname + if obj_type and obj_type.is_pyobject: + code.putln("if (%s->obj == Py_None) {" % view) + code.put_gotref("%s->obj" % view) + code.put_decref_clear("%s->obj" % view, obj_type) + code.putln("}") + + def get_preprocessor_guard(self): + if not self.entry.is_special: + return None + name = self.entry.name + slot = TypeSlots.method_name_to_slot.get(name) + if not slot: + return None + if name == '__long__' and not self.entry.scope.lookup_here('__int__'): + return None + if name in ("__getbuffer__", "__releasebuffer__") and self.entry.scope.is_c_class_scope: + return None + return slot.preprocessor_guard_code() + + +class CFuncDefNode(FuncDefNode): + # C function definition. + # + # modifiers ['inline'] + # visibility 'private' or 'public' or 'extern' + # base_type CBaseTypeNode + # declarator CDeclaratorNode + # cfunc_declarator the CFuncDeclarator of this function + # (this is also available through declarator or a + # base thereof) + # body StatListNode + # api boolean + # decorators [DecoratorNode] list of decorators + # + # with_gil boolean Acquire GIL around body + # type CFuncType + # py_func wrapper for calling from Python + # overridable whether or not this is a cpdef function + # inline_in_pxd whether this is an inline function in a pxd file + # template_declaration String or None Used for c++ class methods + # is_const_method whether this is a const method + # is_static_method whether this is a static method + # is_c_class_method whether this is a cclass method + + child_attrs = ["base_type", "declarator", "body", "py_func_stat"] + + inline_in_pxd = False + decorators = None + directive_locals = None + directive_returns = None + override = None + template_declaration = None + is_const_method = False + py_func_stat = None + + def unqualified_name(self): + return self.entry.name + + @property + def code_object(self): + # share the CodeObject with the cpdef wrapper (if available) + return self.py_func.code_object if self.py_func else None + + def analyse_declarations(self, env): + self.is_c_class_method = env.is_c_class_scope + if self.directive_locals is None: + self.directive_locals = {} + self.directive_locals.update(env.directives.get('locals', {})) + if self.directive_returns is not None: + base_type = self.directive_returns.analyse_as_type(env) + if base_type is None: + error(self.directive_returns.pos, "Not a type") + base_type = PyrexTypes.error_type + else: + base_type = self.base_type.analyse(env) + self.is_static_method = 'staticmethod' in env.directives and not env.lookup_here('staticmethod') + # The 2 here is because we need both function and argument names. + if isinstance(self.declarator, CFuncDeclaratorNode): + name_declarator, type = self.declarator.analyse( + base_type, env, nonempty=2 * (self.body is not None), + directive_locals=self.directive_locals, visibility=self.visibility) + else: + name_declarator, type = self.declarator.analyse( + base_type, env, nonempty=2 * (self.body is not None), visibility=self.visibility) + if not type.is_cfunction: + error(self.pos, "Suite attached to non-function declaration") + # Remember the actual type according to the function header + # written here, because the type in the symbol table entry + # may be different if we're overriding a C method inherited + # from the base type of an extension type. + self.type = type + type.is_overridable = self.overridable + declarator = self.declarator + while not hasattr(declarator, 'args'): + declarator = declarator.base + + self.cfunc_declarator = declarator + self.args = declarator.args + + opt_arg_count = self.cfunc_declarator.optional_arg_count + if (self.visibility == 'public' or self.api) and opt_arg_count: + error(self.cfunc_declarator.pos, + "Function with optional arguments may not be declared public or api") + + if type.exception_check == '+' and self.visibility != 'extern': + warning(self.cfunc_declarator.pos, + "Only extern functions can throw C++ exceptions.") + + for formal_arg, type_arg in zip(self.args, type.args): + self.align_argument_type(env, type_arg) + formal_arg.type = type_arg.type + formal_arg.name = type_arg.name + formal_arg.cname = type_arg.cname + + self._validate_type_visibility(type_arg.type, type_arg.pos, env) + + if type_arg.type.is_fused: + self.has_fused_arguments = True + + if type_arg.type.is_buffer and 'inline' in self.modifiers: + warning(formal_arg.pos, "Buffer unpacking not optimized away.", 1) + + if type_arg.type.is_buffer or type_arg.type.is_pythran_expr: + if self.type.nogil: + error(formal_arg.pos, + "Buffer may not be acquired without the GIL. Consider using memoryview slices instead.") + elif 'inline' in self.modifiers: + warning(formal_arg.pos, "Buffer unpacking not optimized away.", 1) + + self._validate_type_visibility(type.return_type, self.pos, env) + + name = name_declarator.name + cname = name_declarator.cname + + type.is_const_method = self.is_const_method + type.is_static_method = self.is_static_method + self.entry = env.declare_cfunction( + name, type, self.pos, + cname=cname, visibility=self.visibility, api=self.api, + defining=self.body is not None, modifiers=self.modifiers, + overridable=self.overridable) + self.entry.inline_func_in_pxd = self.inline_in_pxd + self.return_type = type.return_type + if self.return_type.is_array and self.visibility != 'extern': + error(self.pos, "Function cannot return an array") + if self.return_type.is_cpp_class: + self.return_type.check_nullary_constructor(self.pos, "used as a return value") + + if self.overridable and not env.is_module_scope and not self.is_static_method: + if len(self.args) < 1 or not self.args[0].type.is_pyobject: + # An error will be produced in the cdef function + self.overridable = False + + self.declare_cpdef_wrapper(env) + self.create_local_scope(env) + + def declare_cpdef_wrapper(self, env): + if self.overridable: + if self.is_static_method: + # TODO(robertwb): Finish this up, perhaps via more function refactoring. + error(self.pos, "static cpdef methods not yet supported") + name = self.entry.name + py_func_body = self.call_self_node(is_module_scope=env.is_module_scope) + if self.is_static_method: + from .ExprNodes import NameNode + decorators = [DecoratorNode(self.pos, decorator=NameNode(self.pos, name='staticmethod'))] + decorators[0].decorator.analyse_types(env) + else: + decorators = [] + self.py_func = DefNode(pos=self.pos, + name=self.entry.name, + args=self.args, + star_arg=None, + starstar_arg=None, + doc=self.doc, + body=py_func_body, + decorators=decorators, + is_wrapper=1) + self.py_func.is_module_scope = env.is_module_scope + self.py_func.analyse_declarations(env) + self.py_func.entry.is_overridable = True + self.py_func_stat = StatListNode(self.pos, stats=[self.py_func]) + self.py_func.type = PyrexTypes.py_object_type + self.entry.as_variable = self.py_func.entry + self.entry.used = self.entry.as_variable.used = True + # Reset scope entry the above cfunction + env.entries[name] = self.entry + if (not self.entry.is_final_cmethod and + (not env.is_module_scope or Options.lookup_module_cpdef)): + self.override = OverrideCheckNode(self.pos, py_func=self.py_func) + self.body = StatListNode(self.pos, stats=[self.override, self.body]) + + def _validate_type_visibility(self, type, pos, env): + """ + Ensure that types used in cdef functions are public or api, or + defined in a C header. + """ + public_or_api = (self.visibility == 'public' or self.api) + entry = getattr(type, 'entry', None) + if public_or_api and entry and env.is_module_scope: + if not (entry.visibility in ('public', 'extern') or + entry.api or entry.in_cinclude): + error(pos, "Function declared public or api may not have private types") + + def call_self_node(self, omit_optional_args=0, is_module_scope=0): + from . import ExprNodes + args = self.type.args + if omit_optional_args: + args = args[:len(args) - self.type.optional_arg_count] + arg_names = [arg.name for arg in args] + if is_module_scope: + cfunc = ExprNodes.NameNode(self.pos, name=self.entry.name) + call_arg_names = arg_names + skip_dispatch = Options.lookup_module_cpdef + elif self.type.is_static_method: + class_entry = self.entry.scope.parent_type.entry + class_node = ExprNodes.NameNode(self.pos, name=class_entry.name) + class_node.entry = class_entry + cfunc = ExprNodes.AttributeNode(self.pos, obj=class_node, attribute=self.entry.name) + # Calling static c(p)def methods on an instance disallowed. + # TODO(robertwb): Support by passing self to check for override? + skip_dispatch = True + else: + type_entry = self.type.args[0].type.entry + type_arg = ExprNodes.NameNode(self.pos, name=type_entry.name) + type_arg.entry = type_entry + cfunc = ExprNodes.AttributeNode(self.pos, obj=type_arg, attribute=self.entry.name) + skip_dispatch = not is_module_scope or Options.lookup_module_cpdef + c_call = ExprNodes.SimpleCallNode( + self.pos, + function=cfunc, + args=[ExprNodes.NameNode(self.pos, name=n) for n in arg_names], + wrapper_call=skip_dispatch) + return ReturnStatNode(pos=self.pos, return_type=PyrexTypes.py_object_type, value=c_call) + + def declare_arguments(self, env): + for arg in self.type.args: + if not arg.name: + error(arg.pos, "Missing argument name") + self.declare_argument(env, arg) + + def need_gil_acquisition(self, lenv): + return self.type.with_gil + + def nogil_check(self, env): + type = self.type + with_gil = type.with_gil + if type.nogil and not with_gil: + if type.return_type.is_pyobject: + error(self.pos, + "Function with Python return type cannot be declared nogil") + for entry in self.local_scope.var_entries: + if entry.type.is_pyobject and not entry.in_with_gil_block: + error(self.pos, "Function declared nogil has Python locals or temporaries") + + def analyse_expressions(self, env): + self.local_scope.directives = env.directives + if self.py_func_stat is not None: + # this will also analyse the default values and the function name assignment + self.py_func_stat = self.py_func_stat.analyse_expressions(env) + elif self.py_func is not None: + # this will also analyse the default values + self.py_func = self.py_func.analyse_expressions(env) + else: + self.analyse_default_values(env) + self.analyse_annotations(env) + self.acquire_gil = self.need_gil_acquisition(self.local_scope) + return self + + def needs_assignment_synthesis(self, env, code=None): + return False + + def generate_function_header(self, code, with_pymethdef, with_opt_args=1, with_dispatch=1, cname=None): + scope = self.local_scope + arg_decls = [] + type = self.type + for arg in type.args[:len(type.args)-type.optional_arg_count]: + arg_decl = arg.declaration_code() + entry = scope.lookup(arg.name) + if not entry.cf_used: + arg_decl = 'CYTHON_UNUSED %s' % arg_decl + arg_decls.append(arg_decl) + if with_dispatch and self.overridable: + dispatch_arg = PyrexTypes.c_int_type.declaration_code( + Naming.skip_dispatch_cname) + if self.override: + arg_decls.append(dispatch_arg) + else: + arg_decls.append('CYTHON_UNUSED %s' % dispatch_arg) + if type.optional_arg_count and with_opt_args: + arg_decls.append(type.op_arg_struct.declaration_code(Naming.optional_args_cname)) + if type.has_varargs: + arg_decls.append("...") + if not arg_decls: + arg_decls = ["void"] + if cname is None: + cname = self.entry.func_cname + entity = type.function_header_code(cname, ', '.join(arg_decls)) + if self.entry.visibility == 'private' and '::' not in cname: + storage_class = "static " + else: + storage_class = "" + dll_linkage = None + modifiers = code.build_function_modifiers(self.entry.func_modifiers) + + header = self.return_type.declaration_code(entity, dll_linkage=dll_linkage) + #print (storage_class, modifiers, header) + needs_proto = self.is_c_class_method + if self.template_declaration: + if needs_proto: + code.globalstate.parts['module_declarations'].putln(self.template_declaration) + code.putln(self.template_declaration) + if needs_proto: + code.globalstate.parts['module_declarations'].putln( + "%s%s%s; /* proto*/" % (storage_class, modifiers, header)) + code.putln("%s%s%s {" % (storage_class, modifiers, header)) + + def generate_argument_declarations(self, env, code): + scope = self.local_scope + for arg in self.args: + if arg.default: + entry = scope.lookup(arg.name) + if self.override or entry.cf_used: + result = arg.calculate_default_value_code(code) + code.putln('%s = %s;' % ( + arg.type.declaration_code(arg.cname), result)) + + def generate_keyword_list(self, code): + pass + + def generate_argument_parsing_code(self, env, code): + i = 0 + used = 0 + scope = self.local_scope + if self.type.optional_arg_count: + code.putln('if (%s) {' % Naming.optional_args_cname) + for arg in self.args: + if arg.default: + entry = scope.lookup(arg.name) + if self.override or entry.cf_used: + code.putln('if (%s->%sn > %s) {' % + (Naming.optional_args_cname, + Naming.pyrex_prefix, i)) + declarator = arg.declarator + while not hasattr(declarator, 'name'): + declarator = declarator.base + code.putln('%s = %s->%s;' % + (arg.cname, Naming.optional_args_cname, + self.type.opt_arg_cname(declarator.name))) + used += 1 + i += 1 + for _ in range(used): + code.putln('}') + code.putln('}') + + # Move arguments into closure if required + def put_into_closure(entry): + if entry.in_closure and not arg.default: + code.putln('%s = %s;' % (entry.cname, entry.original_cname)) + if entry.type.is_memoryviewslice: + code.put_incref_memoryviewslice(entry.cname, have_gil=True) + else: + code.put_var_incref(entry) + code.put_var_giveref(entry) + for arg in self.args: + put_into_closure(scope.lookup_here(arg.name)) + + + def generate_argument_conversion_code(self, code): + pass + + def generate_argument_type_tests(self, code): + # Generate type tests for args whose type in a parent + # class is a supertype of the declared type. + for arg in self.type.args: + if arg.needs_type_test: + self.generate_arg_type_test(arg, code) + elif arg.type.is_pyobject and not arg.accept_none: + self.generate_arg_none_check(arg, code) + + def generate_execution_code(self, code): + if code.globalstate.directives['linetrace']: + code.mark_pos(self.pos) + code.putln("") # generate line tracing code + super(CFuncDefNode, self).generate_execution_code(code) + if self.py_func_stat: + self.py_func_stat.generate_execution_code(code) + + def error_value(self): + if self.return_type.is_pyobject: + return "0" + else: + #return None + return self.entry.type.exception_value + + def caller_will_check_exceptions(self): + return self.entry.type.exception_check + + def generate_wrapper_functions(self, code): + # If the C signature of a function has changed, we need to generate + # wrappers to put in the slots here. + k = 0 + entry = self.entry + func_type = entry.type + while entry.prev_entry is not None: + k += 1 + entry = entry.prev_entry + entry.func_cname = "%s%swrap_%s" % (self.entry.func_cname, Naming.pyrex_prefix, k) + code.putln() + self.generate_function_header( + code, 0, + with_dispatch=entry.type.is_overridable, + with_opt_args=entry.type.optional_arg_count, + cname=entry.func_cname) + if not self.return_type.is_void: + code.put('return ') + args = self.type.args + arglist = [arg.cname for arg in args[:len(args)-self.type.optional_arg_count]] + if entry.type.is_overridable: + arglist.append(Naming.skip_dispatch_cname) + elif func_type.is_overridable: + arglist.append('0') + if entry.type.optional_arg_count: + arglist.append(Naming.optional_args_cname) + elif func_type.optional_arg_count: + arglist.append('NULL') + code.putln('%s(%s);' % (self.entry.func_cname, ', '.join(arglist))) + code.putln('}') + + +class PyArgDeclNode(Node): + # Argument which must be a Python object (used + # for * and ** arguments). + # + # name string + # entry Symtab.Entry + # annotation ExprNode or None Py3 argument annotation + child_attrs = [] + is_self_arg = False + is_type_arg = False + + def generate_function_definitions(self, env, code): + self.entry.generate_function_definitions(env, code) + + +class DecoratorNode(Node): + # A decorator + # + # decorator NameNode or CallNode or AttributeNode + child_attrs = ['decorator'] + + +class DefNode(FuncDefNode): + # A Python function definition. + # + # name string the Python name of the function + # lambda_name string the internal name of a lambda 'function' + # decorators [DecoratorNode] list of decorators + # args [CArgDeclNode] formal arguments + # doc EncodedString or None + # body StatListNode + # return_type_annotation + # ExprNode or None the Py3 return type annotation + # + # The following subnode is constructed internally + # when the def statement is inside a Python class definition. + # + # fused_py_func DefNode The original fused cpdef DefNode + # (in case this is a specialization) + # specialized_cpdefs [DefNode] list of specialized cpdef DefNodes + # py_cfunc_node PyCFunctionNode/InnerFunctionNode The PyCFunction to create and assign + # + # decorator_indirection IndirectionNode Used to remove __Pyx_Method_ClassMethod for fused functions + + child_attrs = ["args", "star_arg", "starstar_arg", "body", "decorators", "return_type_annotation"] + outer_attrs = ["decorators", "return_type_annotation"] + + is_staticmethod = False + is_classmethod = False + + lambda_name = None + reqd_kw_flags_cname = "0" + is_wrapper = 0 + no_assignment_synthesis = 0 + decorators = None + return_type_annotation = None + entry = None + acquire_gil = 0 + self_in_stararg = 0 + py_cfunc_node = None + requires_classobj = False + defaults_struct = None # Dynamic kwrds structure name + doc = None + + fused_py_func = False + specialized_cpdefs = None + py_wrapper = None + py_wrapper_required = True + func_cname = None + + defaults_getter = None + + def __init__(self, pos, **kwds): + FuncDefNode.__init__(self, pos, **kwds) + k = rk = r = 0 + for arg in self.args: + if arg.kw_only: + k += 1 + if not arg.default: + rk += 1 + if not arg.default: + r += 1 + self.num_kwonly_args = k + self.num_required_kw_args = rk + self.num_required_args = r + + def as_cfunction(self, cfunc=None, scope=None, overridable=True, returns=None, except_val=None, modifiers=None, + nogil=False, with_gil=False): + if self.star_arg: + error(self.star_arg.pos, "cdef function cannot have star argument") + if self.starstar_arg: + error(self.starstar_arg.pos, "cdef function cannot have starstar argument") + exception_value, exception_check = except_val or (None, False) + + if cfunc is None: + cfunc_args = [] + for formal_arg in self.args: + name_declarator, type = formal_arg.analyse(scope, nonempty=1) + cfunc_args.append(PyrexTypes.CFuncTypeArg(name=name_declarator.name, + cname=None, + annotation=formal_arg.annotation, + type=py_object_type, + pos=formal_arg.pos)) + cfunc_type = PyrexTypes.CFuncType(return_type=py_object_type, + args=cfunc_args, + has_varargs=False, + exception_value=None, + exception_check=exception_check, + nogil=nogil, + with_gil=with_gil, + is_overridable=overridable) + cfunc = CVarDefNode(self.pos, type=cfunc_type) + else: + if scope is None: + scope = cfunc.scope + cfunc_type = cfunc.type + if len(self.args) != len(cfunc_type.args) or cfunc_type.has_varargs: + error(self.pos, "wrong number of arguments") + error(cfunc.pos, "previous declaration here") + for i, (formal_arg, type_arg) in enumerate(zip(self.args, cfunc_type.args)): + name_declarator, type = formal_arg.analyse(scope, nonempty=1, + is_self_arg=(i == 0 and scope.is_c_class_scope)) + if type is None or type is PyrexTypes.py_object_type: + formal_arg.type = type_arg.type + formal_arg.name_declarator = name_declarator + + if exception_value is None and cfunc_type.exception_value is not None: + from .ExprNodes import ConstNode + exception_value = ConstNode( + self.pos, value=cfunc_type.exception_value, type=cfunc_type.return_type) + declarator = CFuncDeclaratorNode(self.pos, + base=CNameDeclaratorNode(self.pos, name=self.name, cname=None), + args=self.args, + has_varargs=False, + exception_check=cfunc_type.exception_check, + exception_value=exception_value, + with_gil=cfunc_type.with_gil, + nogil=cfunc_type.nogil) + return CFuncDefNode(self.pos, + modifiers=modifiers or [], + base_type=CAnalysedBaseTypeNode(self.pos, type=cfunc_type.return_type), + declarator=declarator, + body=self.body, + doc=self.doc, + overridable=cfunc_type.is_overridable, + type=cfunc_type, + with_gil=cfunc_type.with_gil, + nogil=cfunc_type.nogil, + visibility='private', + api=False, + directive_locals=getattr(cfunc, 'directive_locals', {}), + directive_returns=returns) + + def is_cdef_func_compatible(self): + """Determines if the function's signature is compatible with a + cdef function. This can be used before calling + .as_cfunction() to see if that will be successful. + """ + if self.needs_closure: + return False + if self.star_arg or self.starstar_arg: + return False + return True + + def analyse_declarations(self, env): + if self.decorators: + for decorator in self.decorators: + func = decorator.decorator + if func.is_name: + self.is_classmethod |= func.name == 'classmethod' + self.is_staticmethod |= func.name == 'staticmethod' + + if self.is_classmethod and env.lookup_here('classmethod'): + # classmethod() was overridden - not much we can do here ... + self.is_classmethod = False + if self.is_staticmethod and env.lookup_here('staticmethod'): + # staticmethod() was overridden - not much we can do here ... + self.is_staticmethod = False + + if self.name == '__new__' and env.is_py_class_scope: + self.is_staticmethod = 1 + + self.analyse_argument_types(env) + if self.name == '<lambda>': + self.declare_lambda_function(env) + else: + self.declare_pyfunction(env) + + self.analyse_signature(env) + self.return_type = self.entry.signature.return_type() + # if a signature annotation provides a more specific return object type, use it + if self.return_type is py_object_type and self.return_type_annotation: + if env.directives['annotation_typing'] and not self.entry.is_special: + _, return_type = analyse_type_annotation(self.return_type_annotation, env) + if return_type and return_type.is_pyobject: + self.return_type = return_type + + self.create_local_scope(env) + + self.py_wrapper = DefNodeWrapper( + self.pos, + target=self, + name=self.entry.name, + args=self.args, + star_arg=self.star_arg, + starstar_arg=self.starstar_arg, + return_type=self.return_type) + self.py_wrapper.analyse_declarations(env) + + def analyse_argument_types(self, env): + self.directive_locals = env.directives.get('locals', {}) + allow_none_for_extension_args = env.directives['allow_none_for_extension_args'] + + f2s = env.fused_to_specific + env.fused_to_specific = None + + for arg in self.args: + if hasattr(arg, 'name'): + name_declarator = None + else: + base_type = arg.base_type.analyse(env) + # If we hare in pythran mode and we got a buffer supported by + # Pythran, we change this node to a fused type + if has_np_pythran(env) and base_type.is_pythran_expr: + base_type = PyrexTypes.FusedType([ + base_type, + #PyrexTypes.PythranExpr(pythran_type(self.type, "numpy_texpr")), + base_type.org_buffer]) + name_declarator, type = \ + arg.declarator.analyse(base_type, env) + arg.name = name_declarator.name + arg.type = type + + if type.is_fused: + self.has_fused_arguments = True + + self.align_argument_type(env, arg) + if name_declarator and name_declarator.cname: + error(self.pos, "Python function argument cannot have C name specification") + arg.type = arg.type.as_argument_type() + arg.hdr_type = None + arg.needs_conversion = 0 + arg.needs_type_test = 0 + arg.is_generic = 1 + if arg.type.is_pyobject or arg.type.is_buffer or arg.type.is_memoryviewslice: + if arg.or_none: + arg.accept_none = True + elif arg.not_none: + arg.accept_none = False + elif (arg.type.is_extension_type or arg.type.is_builtin_type + or arg.type.is_buffer or arg.type.is_memoryviewslice): + if arg.default and arg.default.constant_result is None: + # special case: def func(MyType obj = None) + arg.accept_none = True + else: + # default depends on compiler directive + arg.accept_none = allow_none_for_extension_args + else: + # probably just a plain 'object' + arg.accept_none = True + else: + arg.accept_none = True # won't be used, but must be there + if arg.not_none: + error(arg.pos, "Only Python type arguments can have 'not None'") + if arg.or_none: + error(arg.pos, "Only Python type arguments can have 'or None'") + env.fused_to_specific = f2s + + if has_np_pythran(env): + self.np_args_idx = [i for i,a in enumerate(self.args) if a.type.is_numpy_buffer] + else: + self.np_args_idx = [] + + def analyse_signature(self, env): + if self.entry.is_special: + if self.decorators: + error(self.pos, "special functions of cdef classes cannot have decorators") + self.entry.trivial_signature = len(self.args) == 1 and not (self.star_arg or self.starstar_arg) + elif not env.directives['always_allow_keywords'] and not (self.star_arg or self.starstar_arg): + # Use the simpler calling signature for zero- and one-argument functions. + if self.entry.signature is TypeSlots.pyfunction_signature: + if len(self.args) == 0: + self.entry.signature = TypeSlots.pyfunction_noargs + elif len(self.args) == 1: + if self.args[0].default is None and not self.args[0].kw_only: + self.entry.signature = TypeSlots.pyfunction_onearg + elif self.entry.signature is TypeSlots.pymethod_signature: + if len(self.args) == 1: + self.entry.signature = TypeSlots.unaryfunc + elif len(self.args) == 2: + if self.args[1].default is None and not self.args[1].kw_only: + self.entry.signature = TypeSlots.ibinaryfunc + + sig = self.entry.signature + nfixed = sig.num_fixed_args() + if (sig is TypeSlots.pymethod_signature and nfixed == 1 + and len(self.args) == 0 and self.star_arg): + # this is the only case where a diverging number of + # arguments is not an error - when we have no explicit + # 'self' parameter as in method(*args) + sig = self.entry.signature = TypeSlots.pyfunction_signature # self is not 'really' used + self.self_in_stararg = 1 + nfixed = 0 + + if self.is_staticmethod and env.is_c_class_scope: + nfixed = 0 + self.self_in_stararg = True # FIXME: why for staticmethods? + + self.entry.signature = sig = copy.copy(sig) + sig.fixed_arg_format = "*" + sig.is_staticmethod = True + sig.has_generic_args = True + + if ((self.is_classmethod or self.is_staticmethod) and + self.has_fused_arguments and env.is_c_class_scope): + del self.decorator_indirection.stats[:] + + for i in range(min(nfixed, len(self.args))): + arg = self.args[i] + arg.is_generic = 0 + if sig.is_self_arg(i) and not self.is_staticmethod: + if self.is_classmethod: + arg.is_type_arg = 1 + arg.hdr_type = arg.type = Builtin.type_type + else: + arg.is_self_arg = 1 + arg.hdr_type = arg.type = env.parent_type + arg.needs_conversion = 0 + else: + arg.hdr_type = sig.fixed_arg_type(i) + if not arg.type.same_as(arg.hdr_type): + if arg.hdr_type.is_pyobject and arg.type.is_pyobject: + arg.needs_type_test = 1 + else: + arg.needs_conversion = 1 + if arg.needs_conversion: + arg.hdr_cname = Naming.arg_prefix + arg.name + else: + arg.hdr_cname = Naming.var_prefix + arg.name + + if nfixed > len(self.args): + self.bad_signature() + return + elif nfixed < len(self.args): + if not sig.has_generic_args: + self.bad_signature() + for arg in self.args: + if arg.is_generic and (arg.type.is_extension_type or arg.type.is_builtin_type): + arg.needs_type_test = 1 + + def bad_signature(self): + sig = self.entry.signature + expected_str = "%d" % sig.num_fixed_args() + if sig.has_generic_args: + expected_str += " or more" + name = self.name + if name.startswith("__") and name.endswith("__"): + desc = "Special method" + else: + desc = "Method" + error(self.pos, "%s %s has wrong number of arguments (%d declared, %s expected)" % ( + desc, self.name, len(self.args), expected_str)) + + def declare_pyfunction(self, env): + #print "DefNode.declare_pyfunction:", self.name, "in", env ### + name = self.name + entry = env.lookup_here(name) + if entry: + if entry.is_final_cmethod and not env.parent_type.is_final_type: + error(self.pos, "Only final types can have final Python (def/cpdef) methods") + if entry.type.is_cfunction and not entry.is_builtin_cmethod and not self.is_wrapper: + warning(self.pos, "Overriding cdef method with def method.", 5) + entry = env.declare_pyfunction(name, self.pos, allow_redefine=not self.is_wrapper) + self.entry = entry + prefix = env.next_id(env.scope_prefix) + self.entry.pyfunc_cname = Naming.pyfunc_prefix + prefix + name + if Options.docstrings: + entry.doc = embed_position(self.pos, self.doc) + entry.doc_cname = Naming.funcdoc_prefix + prefix + name + if entry.is_special: + if entry.name in TypeSlots.invisible or not entry.doc or ( + entry.name in '__getattr__' and env.directives['fast_getattr']): + entry.wrapperbase_cname = None + else: + entry.wrapperbase_cname = Naming.wrapperbase_prefix + prefix + name + else: + entry.doc = None + + def declare_lambda_function(self, env): + entry = env.declare_lambda_function(self.lambda_name, self.pos) + entry.doc = None + self.entry = entry + self.entry.pyfunc_cname = entry.cname + + def declare_arguments(self, env): + for arg in self.args: + if not arg.name: + error(arg.pos, "Missing argument name") + if arg.needs_conversion: + arg.entry = env.declare_var(arg.name, arg.type, arg.pos) + if arg.type.is_pyobject: + arg.entry.init = "0" + else: + arg.entry = self.declare_argument(env, arg) + arg.entry.is_arg = 1 + arg.entry.used = 1 + arg.entry.is_self_arg = arg.is_self_arg + self.declare_python_arg(env, self.star_arg) + self.declare_python_arg(env, self.starstar_arg) + + def declare_python_arg(self, env, arg): + if arg: + if env.directives['infer_types'] != False: + type = PyrexTypes.unspecified_type + else: + type = py_object_type + entry = env.declare_var(arg.name, type, arg.pos) + entry.is_arg = 1 + entry.used = 1 + entry.init = "0" + entry.xdecref_cleanup = 1 + arg.entry = entry + + def analyse_expressions(self, env): + self.local_scope.directives = env.directives + self.analyse_default_values(env) + self.analyse_annotations(env) + if self.return_type_annotation: + self.return_type_annotation = self.analyse_annotation(env, self.return_type_annotation) + + if not self.needs_assignment_synthesis(env) and self.decorators: + for decorator in self.decorators[::-1]: + decorator.decorator = decorator.decorator.analyse_expressions(env) + + self.py_wrapper.prepare_argument_coercion(env) + return self + + def needs_assignment_synthesis(self, env, code=None): + if self.is_staticmethod: + return True + if self.specialized_cpdefs or self.entry.is_fused_specialized: + return False + if self.no_assignment_synthesis: + return False + if self.entry.is_special: + return False + if self.entry.is_anonymous: + return True + if env.is_module_scope or env.is_c_class_scope: + if code is None: + return self.local_scope.directives['binding'] + else: + return code.globalstate.directives['binding'] + return env.is_py_class_scope or env.is_closure_scope + + def error_value(self): + return self.entry.signature.error_value + + def caller_will_check_exceptions(self): + return self.entry.signature.exception_check + + def generate_function_definitions(self, env, code): + if self.defaults_getter: + # defaults getter must never live in class scopes, it's always a module function + self.defaults_getter.generate_function_definitions(env.global_scope(), code) + + # Before closure cnames are mangled + if self.py_wrapper_required: + # func_cname might be modified by @cname + self.py_wrapper.func_cname = self.entry.func_cname + self.py_wrapper.generate_function_definitions(env, code) + FuncDefNode.generate_function_definitions(self, env, code) + + def generate_function_header(self, code, with_pymethdef, proto_only=0): + if proto_only: + if self.py_wrapper_required: + self.py_wrapper.generate_function_header( + code, with_pymethdef, True) + return + arg_code_list = [] + if self.entry.signature.has_dummy_arg: + self_arg = 'PyObject *%s' % Naming.self_cname + if not self.needs_outer_scope: + self_arg = 'CYTHON_UNUSED ' + self_arg + arg_code_list.append(self_arg) + + def arg_decl_code(arg): + entry = arg.entry + if entry.in_closure: + cname = entry.original_cname + else: + cname = entry.cname + decl = entry.type.declaration_code(cname) + if not entry.cf_used: + decl = 'CYTHON_UNUSED ' + decl + return decl + + for arg in self.args: + arg_code_list.append(arg_decl_code(arg)) + if self.star_arg: + arg_code_list.append(arg_decl_code(self.star_arg)) + if self.starstar_arg: + arg_code_list.append(arg_decl_code(self.starstar_arg)) + if arg_code_list: + arg_code = ', '.join(arg_code_list) + else: + arg_code = 'void' # No arguments + dc = self.return_type.declaration_code(self.entry.pyfunc_cname) + + decls_code = code.globalstate['decls'] + preprocessor_guard = self.get_preprocessor_guard() + if preprocessor_guard: + decls_code.putln(preprocessor_guard) + decls_code.putln( + "static %s(%s); /* proto */" % (dc, arg_code)) + if preprocessor_guard: + decls_code.putln("#endif") + code.putln("static %s(%s) {" % (dc, arg_code)) + + def generate_argument_declarations(self, env, code): + pass + + def generate_keyword_list(self, code): + pass + + def generate_argument_parsing_code(self, env, code): + # Move arguments into closure if required + def put_into_closure(entry): + if entry.in_closure: + code.putln('%s = %s;' % (entry.cname, entry.original_cname)) + if entry.xdecref_cleanup: + # mostly applies to the starstar arg - this can sometimes be NULL + # so must be xincrefed instead + code.put_var_xincref(entry) + code.put_var_xgiveref(entry) + else: + code.put_var_incref(entry) + code.put_var_giveref(entry) + for arg in self.args: + put_into_closure(arg.entry) + for arg in self.star_arg, self.starstar_arg: + if arg: + put_into_closure(arg.entry) + + def generate_argument_type_tests(self, code): + pass + + +class DefNodeWrapper(FuncDefNode): + # DefNode python wrapper code generator + + defnode = None + target = None # Target DefNode + + def __init__(self, *args, **kwargs): + FuncDefNode.__init__(self, *args, **kwargs) + self.num_kwonly_args = self.target.num_kwonly_args + self.num_required_kw_args = self.target.num_required_kw_args + self.num_required_args = self.target.num_required_args + self.self_in_stararg = self.target.self_in_stararg + self.signature = None + + def analyse_declarations(self, env): + target_entry = self.target.entry + name = self.name + prefix = env.next_id(env.scope_prefix) + target_entry.func_cname = Naming.pywrap_prefix + prefix + name + target_entry.pymethdef_cname = Naming.pymethdef_prefix + prefix + name + + self.signature = target_entry.signature + + self.np_args_idx = self.target.np_args_idx + + def prepare_argument_coercion(self, env): + # This is only really required for Cython utility code at this time, + # everything else can be done during code generation. But we expand + # all utility code here, simply because we cannot easily distinguish + # different code types. + for arg in self.args: + if not arg.type.is_pyobject: + if not arg.type.create_from_py_utility_code(env): + pass # will fail later + elif arg.hdr_type and not arg.hdr_type.is_pyobject: + if not arg.hdr_type.create_to_py_utility_code(env): + pass # will fail later + + if self.starstar_arg and not self.starstar_arg.entry.cf_used: + # we will set the kwargs argument to NULL instead of a new dict + # and must therefore correct the control flow state + entry = self.starstar_arg.entry + entry.xdecref_cleanup = 1 + for ass in entry.cf_assignments: + if not ass.is_arg and ass.lhs.is_name: + ass.lhs.cf_maybe_null = True + + def signature_has_nongeneric_args(self): + argcount = len(self.args) + if argcount == 0 or ( + argcount == 1 and (self.args[0].is_self_arg or + self.args[0].is_type_arg)): + return 0 + return 1 + + def signature_has_generic_args(self): + return self.signature.has_generic_args + + def generate_function_body(self, code): + args = [] + if self.signature.has_dummy_arg: + args.append(Naming.self_cname) + for arg in self.args: + if arg.hdr_type and not (arg.type.is_memoryviewslice or + arg.type.is_struct or + arg.type.is_complex): + args.append(arg.type.cast_code(arg.entry.cname)) + else: + args.append(arg.entry.cname) + if self.star_arg: + args.append(self.star_arg.entry.cname) + if self.starstar_arg: + args.append(self.starstar_arg.entry.cname) + args = ', '.join(args) + if not self.return_type.is_void: + code.put('%s = ' % Naming.retval_cname) + code.putln('%s(%s);' % ( + self.target.entry.pyfunc_cname, args)) + + def generate_function_definitions(self, env, code): + lenv = self.target.local_scope + # Generate C code for header and body of function + code.mark_pos(self.pos) + code.putln("") + code.putln("/* Python wrapper */") + preprocessor_guard = self.target.get_preprocessor_guard() + if preprocessor_guard: + code.putln(preprocessor_guard) + + code.enter_cfunc_scope(lenv) + code.return_from_error_cleanup_label = code.new_label() + + with_pymethdef = (self.target.needs_assignment_synthesis(env, code) or + self.target.pymethdef_required) + self.generate_function_header(code, with_pymethdef) + self.generate_argument_declarations(lenv, code) + tempvardecl_code = code.insertion_point() + + if self.return_type.is_pyobject: + retval_init = ' = 0' + else: + retval_init = '' + if not self.return_type.is_void: + code.putln('%s%s;' % ( + self.return_type.declaration_code(Naming.retval_cname), + retval_init)) + code.put_declare_refcount_context() + code.put_setup_refcount_context('%s (wrapper)' % self.name) + + self.generate_argument_parsing_code(lenv, code) + self.generate_argument_type_tests(code) + self.generate_function_body(code) + + # ----- Go back and insert temp variable declarations + tempvardecl_code.put_temp_declarations(code.funcstate) + + code.mark_pos(self.pos) + code.putln("") + code.putln("/* function exit code */") + + # ----- Error cleanup + if code.error_label in code.labels_used: + code.put_goto(code.return_label) + code.put_label(code.error_label) + for cname, type in code.funcstate.all_managed_temps(): + code.put_xdecref(cname, type) + err_val = self.error_value() + if err_val is not None: + code.putln("%s = %s;" % (Naming.retval_cname, err_val)) + + # ----- Non-error return cleanup + code.put_label(code.return_label) + for entry in lenv.var_entries: + if entry.is_arg and entry.type.is_pyobject: + code.put_var_decref(entry) + + code.put_finish_refcount_context() + if not self.return_type.is_void: + code.putln("return %s;" % Naming.retval_cname) + code.putln('}') + code.exit_cfunc_scope() + if preprocessor_guard: + code.putln("#endif /*!(%s)*/" % preprocessor_guard) + + def generate_function_header(self, code, with_pymethdef, proto_only=0): + arg_code_list = [] + sig = self.signature + + if sig.has_dummy_arg or self.self_in_stararg: + arg_code = "PyObject *%s" % Naming.self_cname + if not sig.has_dummy_arg: + arg_code = 'CYTHON_UNUSED ' + arg_code + arg_code_list.append(arg_code) + + for arg in self.args: + if not arg.is_generic: + if arg.is_self_arg or arg.is_type_arg: + arg_code_list.append("PyObject *%s" % arg.hdr_cname) + else: + arg_code_list.append( + arg.hdr_type.declaration_code(arg.hdr_cname)) + entry = self.target.entry + if not entry.is_special and sig.method_flags() == [TypeSlots.method_noargs]: + arg_code_list.append("CYTHON_UNUSED PyObject *unused") + if entry.scope.is_c_class_scope and entry.name == "__ipow__": + arg_code_list.append("CYTHON_UNUSED PyObject *unused") + if sig.has_generic_args: + arg_code_list.append( + "PyObject *%s, PyObject *%s" % ( + Naming.args_cname, Naming.kwds_cname)) + arg_code = ", ".join(arg_code_list) + + # Prevent warning: unused function '__pyx_pw_5numpy_7ndarray_1__getbuffer__' + mf = "" + if (entry.name in ("__getbuffer__", "__releasebuffer__") + and entry.scope.is_c_class_scope): + mf = "CYTHON_UNUSED " + with_pymethdef = False + + dc = self.return_type.declaration_code(entry.func_cname) + header = "static %s%s(%s)" % (mf, dc, arg_code) + code.putln("%s; /*proto*/" % header) + + if proto_only: + if self.target.fused_py_func: + # If we are the specialized version of the cpdef, we still + # want the prototype for the "fused cpdef", in case we're + # checking to see if our method was overridden in Python + self.target.fused_py_func.generate_function_header( + code, with_pymethdef, proto_only=True) + return + + if (Options.docstrings and entry.doc and + not self.target.fused_py_func and + not entry.scope.is_property_scope and + (not entry.is_special or entry.wrapperbase_cname)): + # h_code = code.globalstate['h_code'] + docstr = entry.doc + + if docstr.is_unicode: + docstr = docstr.as_utf8_string() + + if not (entry.is_special and entry.name in ('__getbuffer__', '__releasebuffer__')): + code.putln('static char %s[] = %s;' % ( + entry.doc_cname, + docstr.as_c_string_literal())) + + if entry.is_special: + code.putln('#if CYTHON_UPDATE_DESCRIPTOR_DOC') + code.putln( + "struct wrapperbase %s;" % entry.wrapperbase_cname) + code.putln('#endif') + + if with_pymethdef or self.target.fused_py_func: + code.put( + "static PyMethodDef %s = " % entry.pymethdef_cname) + code.put_pymethoddef(self.target.entry, ";", allow_skip=False) + code.putln("%s {" % header) + + def generate_argument_declarations(self, env, code): + for arg in self.args: + if arg.is_generic: + if arg.needs_conversion: + code.putln("PyObject *%s = 0;" % arg.hdr_cname) + else: + code.put_var_declaration(arg.entry) + for entry in env.var_entries: + if entry.is_arg: + code.put_var_declaration(entry) + + def generate_argument_parsing_code(self, env, code): + # Generate fast equivalent of PyArg_ParseTuple call for + # generic arguments, if any, including args/kwargs + old_error_label = code.new_error_label() + our_error_label = code.error_label + end_label = code.new_label("argument_unpacking_done") + + has_kwonly_args = self.num_kwonly_args > 0 + has_star_or_kw_args = self.star_arg is not None \ + or self.starstar_arg is not None or has_kwonly_args + + for arg in self.args: + if not arg.type.is_pyobject: + if not arg.type.create_from_py_utility_code(env): + pass # will fail later + + if not self.signature_has_generic_args(): + if has_star_or_kw_args: + error(self.pos, "This method cannot have * or keyword arguments") + self.generate_argument_conversion_code(code) + + elif not self.signature_has_nongeneric_args(): + # func(*args) or func(**kw) or func(*args, **kw) + self.generate_stararg_copy_code(code) + + else: + self.generate_tuple_and_keyword_parsing_code(self.args, end_label, code) + + code.error_label = old_error_label + if code.label_used(our_error_label): + if not code.label_used(end_label): + code.put_goto(end_label) + code.put_label(our_error_label) + if has_star_or_kw_args: + self.generate_arg_decref(self.star_arg, code) + if self.starstar_arg: + if self.starstar_arg.entry.xdecref_cleanup: + code.put_var_xdecref_clear(self.starstar_arg.entry) + else: + code.put_var_decref_clear(self.starstar_arg.entry) + code.put_add_traceback(self.target.entry.qualified_name) + code.put_finish_refcount_context() + code.putln("return %s;" % self.error_value()) + if code.label_used(end_label): + code.put_label(end_label) + + def generate_arg_xdecref(self, arg, code): + if arg: + code.put_var_xdecref_clear(arg.entry) + + def generate_arg_decref(self, arg, code): + if arg: + code.put_var_decref_clear(arg.entry) + + def generate_stararg_copy_code(self, code): + if not self.star_arg: + code.globalstate.use_utility_code( + UtilityCode.load_cached("RaiseArgTupleInvalid", "FunctionArguments.c")) + code.putln("if (unlikely(PyTuple_GET_SIZE(%s) > 0)) {" % + Naming.args_cname) + code.put('__Pyx_RaiseArgtupleInvalid("%s", 1, 0, 0, PyTuple_GET_SIZE(%s)); return %s;' % ( + self.name, Naming.args_cname, self.error_value())) + code.putln("}") + + if self.starstar_arg: + if self.star_arg or not self.starstar_arg.entry.cf_used: + kwarg_check = "unlikely(%s)" % Naming.kwds_cname + else: + kwarg_check = "%s" % Naming.kwds_cname + else: + kwarg_check = "unlikely(%s) && unlikely(PyDict_Size(%s) > 0)" % ( + Naming.kwds_cname, Naming.kwds_cname) + code.globalstate.use_utility_code( + UtilityCode.load_cached("KeywordStringCheck", "FunctionArguments.c")) + code.putln( + "if (%s && unlikely(!__Pyx_CheckKeywordStrings(%s, \"%s\", %d))) return %s;" % ( + kwarg_check, Naming.kwds_cname, self.name, + bool(self.starstar_arg), self.error_value())) + + if self.starstar_arg and self.starstar_arg.entry.cf_used: + if all(ref.node.allow_null for ref in self.starstar_arg.entry.cf_references): + code.putln("if (%s) {" % kwarg_check) + code.putln("%s = PyDict_Copy(%s); if (unlikely(!%s)) return %s;" % ( + self.starstar_arg.entry.cname, + Naming.kwds_cname, + self.starstar_arg.entry.cname, + self.error_value())) + code.put_gotref(self.starstar_arg.entry.cname) + code.putln("} else {") + code.putln("%s = NULL;" % (self.starstar_arg.entry.cname,)) + code.putln("}") + self.starstar_arg.entry.xdecref_cleanup = 1 + else: + code.put("%s = (%s) ? PyDict_Copy(%s) : PyDict_New(); " % ( + self.starstar_arg.entry.cname, + Naming.kwds_cname, + Naming.kwds_cname)) + code.putln("if (unlikely(!%s)) return %s;" % ( + self.starstar_arg.entry.cname, self.error_value())) + self.starstar_arg.entry.xdecref_cleanup = 0 + code.put_gotref(self.starstar_arg.entry.cname) + + if self.self_in_stararg and not self.target.is_staticmethod: + # need to create a new tuple with 'self' inserted as first item + code.put("%s = PyTuple_New(PyTuple_GET_SIZE(%s)+1); if (unlikely(!%s)) " % ( + self.star_arg.entry.cname, + Naming.args_cname, + self.star_arg.entry.cname)) + if self.starstar_arg and self.starstar_arg.entry.cf_used: + code.putln("{") + code.put_xdecref_clear(self.starstar_arg.entry.cname, py_object_type) + code.putln("return %s;" % self.error_value()) + code.putln("}") + else: + code.putln("return %s;" % self.error_value()) + code.put_gotref(self.star_arg.entry.cname) + code.put_incref(Naming.self_cname, py_object_type) + code.put_giveref(Naming.self_cname) + code.putln("PyTuple_SET_ITEM(%s, 0, %s);" % ( + self.star_arg.entry.cname, Naming.self_cname)) + temp = code.funcstate.allocate_temp(PyrexTypes.c_py_ssize_t_type, manage_ref=False) + code.putln("for (%s=0; %s < PyTuple_GET_SIZE(%s); %s++) {" % ( + temp, temp, Naming.args_cname, temp)) + code.putln("PyObject* item = PyTuple_GET_ITEM(%s, %s);" % ( + Naming.args_cname, temp)) + code.put_incref("item", py_object_type) + code.put_giveref("item") + code.putln("PyTuple_SET_ITEM(%s, %s+1, item);" % ( + self.star_arg.entry.cname, temp)) + code.putln("}") + code.funcstate.release_temp(temp) + self.star_arg.entry.xdecref_cleanup = 0 + elif self.star_arg: + code.put_incref(Naming.args_cname, py_object_type) + code.putln("%s = %s;" % ( + self.star_arg.entry.cname, + Naming.args_cname)) + self.star_arg.entry.xdecref_cleanup = 0 + + def generate_tuple_and_keyword_parsing_code(self, args, success_label, code): + argtuple_error_label = code.new_label("argtuple_error") + + positional_args = [] + required_kw_only_args = [] + optional_kw_only_args = [] + for arg in args: + if arg.is_generic: + if arg.default: + if not arg.is_self_arg and not arg.is_type_arg: + if arg.kw_only: + optional_kw_only_args.append(arg) + else: + positional_args.append(arg) + elif arg.kw_only: + required_kw_only_args.append(arg) + elif not arg.is_self_arg and not arg.is_type_arg: + positional_args.append(arg) + + # sort required kw-only args before optional ones to avoid special + # cases in the unpacking code + kw_only_args = required_kw_only_args + optional_kw_only_args + + min_positional_args = self.num_required_args - self.num_required_kw_args + if len(args) > 0 and (args[0].is_self_arg or args[0].is_type_arg): + min_positional_args -= 1 + max_positional_args = len(positional_args) + has_fixed_positional_count = not self.star_arg and \ + min_positional_args == max_positional_args + has_kw_only_args = bool(kw_only_args) + + if self.starstar_arg or self.star_arg: + self.generate_stararg_init_code(max_positional_args, code) + + code.putln('{') + all_args = tuple(positional_args) + tuple(kw_only_args) + code.putln("static PyObject **%s[] = {%s,0};" % ( + Naming.pykwdlist_cname, + ','.join(['&%s' % code.intern_identifier(arg.name) + for arg in all_args]))) + + # Before being converted and assigned to the target variables, + # borrowed references to all unpacked argument values are + # collected into a local PyObject* array called "values", + # regardless if they were taken from default arguments, + # positional arguments or keyword arguments. Note that + # C-typed default arguments are handled at conversion time, + # so their array value is NULL in the end if no argument + # was passed for them. + self.generate_argument_values_setup_code(all_args, code) + + # --- optimised code when we receive keyword arguments + code.putln("if (%s(%s)) {" % ( + (self.num_required_kw_args > 0) and "likely" or "unlikely", + Naming.kwds_cname)) + self.generate_keyword_unpacking_code( + min_positional_args, max_positional_args, + has_fixed_positional_count, has_kw_only_args, + all_args, argtuple_error_label, code) + + # --- optimised code when we do not receive any keyword arguments + if (self.num_required_kw_args and min_positional_args > 0) or min_positional_args == max_positional_args: + # Python raises arg tuple related errors first, so we must + # check the length here + if min_positional_args == max_positional_args and not self.star_arg: + compare = '!=' + else: + compare = '<' + code.putln('} else if (PyTuple_GET_SIZE(%s) %s %d) {' % ( + Naming.args_cname, compare, min_positional_args)) + code.put_goto(argtuple_error_label) + + if self.num_required_kw_args: + # pure error case: keywords required but not passed + if max_positional_args > min_positional_args and not self.star_arg: + code.putln('} else if (PyTuple_GET_SIZE(%s) > %d) {' % ( + Naming.args_cname, max_positional_args)) + code.put_goto(argtuple_error_label) + code.putln('} else {') + for i, arg in enumerate(kw_only_args): + if not arg.default: + pystring_cname = code.intern_identifier(arg.name) + # required keyword-only argument missing + code.globalstate.use_utility_code( + UtilityCode.load_cached("RaiseKeywordRequired", "FunctionArguments.c")) + code.put('__Pyx_RaiseKeywordRequired("%s", %s); ' % ( + self.name, + pystring_cname)) + code.putln(code.error_goto(self.pos)) + break + + else: + # optimised tuple unpacking code + code.putln('} else {') + if min_positional_args == max_positional_args: + # parse the exact number of positional arguments from + # the args tuple + for i, arg in enumerate(positional_args): + code.putln("values[%d] = PyTuple_GET_ITEM(%s, %d);" % (i, Naming.args_cname, i)) + else: + # parse the positional arguments from the variable length + # args tuple and reject illegal argument tuple sizes + code.putln('switch (PyTuple_GET_SIZE(%s)) {' % Naming.args_cname) + if self.star_arg: + code.putln('default:') + reversed_args = list(enumerate(positional_args))[::-1] + for i, arg in reversed_args: + if i >= min_positional_args-1: + if i != reversed_args[0][0]: + code.putln('CYTHON_FALLTHROUGH;') + code.put('case %2d: ' % (i+1)) + code.putln("values[%d] = PyTuple_GET_ITEM(%s, %d);" % (i, Naming.args_cname, i)) + if min_positional_args == 0: + code.putln('CYTHON_FALLTHROUGH;') + code.put('case 0: ') + code.putln('break;') + if self.star_arg: + if min_positional_args: + for i in range(min_positional_args-1, -1, -1): + code.putln('case %2d:' % i) + code.put_goto(argtuple_error_label) + else: + code.put('default: ') + code.put_goto(argtuple_error_label) + code.putln('}') + + code.putln('}') # end of the conditional unpacking blocks + + # Convert arg values to their final type and assign them. + # Also inject non-Python default arguments, which do cannot + # live in the values[] array. + for i, arg in enumerate(all_args): + self.generate_arg_assignment(arg, "values[%d]" % i, code) + + code.putln('}') # end of the whole argument unpacking block + + if code.label_used(argtuple_error_label): + code.put_goto(success_label) + code.put_label(argtuple_error_label) + code.globalstate.use_utility_code( + UtilityCode.load_cached("RaiseArgTupleInvalid", "FunctionArguments.c")) + code.put('__Pyx_RaiseArgtupleInvalid("%s", %d, %d, %d, PyTuple_GET_SIZE(%s)); ' % ( + self.name, has_fixed_positional_count, + min_positional_args, max_positional_args, + Naming.args_cname)) + code.putln(code.error_goto(self.pos)) + + def generate_arg_assignment(self, arg, item, code): + if arg.type.is_pyobject: + # Python default arguments were already stored in 'item' at the very beginning + if arg.is_generic: + item = PyrexTypes.typecast(arg.type, PyrexTypes.py_object_type, item) + entry = arg.entry + code.putln("%s = %s;" % (entry.cname, item)) + else: + if arg.type.from_py_function: + if arg.default: + # C-typed default arguments must be handled here + code.putln('if (%s) {' % item) + code.putln(arg.type.from_py_call_code( + item, arg.entry.cname, arg.pos, code)) + if arg.default: + code.putln('} else {') + code.putln("%s = %s;" % ( + arg.entry.cname, + arg.calculate_default_value_code(code))) + if arg.type.is_memoryviewslice: + code.put_incref_memoryviewslice(arg.entry.cname, + have_gil=True) + code.putln('}') + else: + error(arg.pos, "Cannot convert Python object argument to type '%s'" % arg.type) + + def generate_stararg_init_code(self, max_positional_args, code): + if self.starstar_arg: + self.starstar_arg.entry.xdecref_cleanup = 0 + code.putln('%s = PyDict_New(); if (unlikely(!%s)) return %s;' % ( + self.starstar_arg.entry.cname, + self.starstar_arg.entry.cname, + self.error_value())) + code.put_gotref(self.starstar_arg.entry.cname) + if self.star_arg: + self.star_arg.entry.xdecref_cleanup = 0 + code.putln('if (PyTuple_GET_SIZE(%s) > %d) {' % ( + Naming.args_cname, + max_positional_args)) + code.putln('%s = PyTuple_GetSlice(%s, %d, PyTuple_GET_SIZE(%s));' % ( + self.star_arg.entry.cname, Naming.args_cname, + max_positional_args, Naming.args_cname)) + code.putln("if (unlikely(!%s)) {" % self.star_arg.entry.cname) + if self.starstar_arg: + code.put_decref_clear(self.starstar_arg.entry.cname, py_object_type) + code.put_finish_refcount_context() + code.putln('return %s;' % self.error_value()) + code.putln('}') + code.put_gotref(self.star_arg.entry.cname) + code.putln('} else {') + code.put("%s = %s; " % (self.star_arg.entry.cname, Naming.empty_tuple)) + code.put_incref(Naming.empty_tuple, py_object_type) + code.putln('}') + + def generate_argument_values_setup_code(self, args, code): + max_args = len(args) + # the 'values' array collects borrowed references to arguments + # before doing any type coercion etc. + code.putln("PyObject* values[%d] = {%s};" % ( + max_args, ','.join('0'*max_args))) + + if self.target.defaults_struct: + code.putln('%s *%s = __Pyx_CyFunction_Defaults(%s, %s);' % ( + self.target.defaults_struct, Naming.dynamic_args_cname, + self.target.defaults_struct, Naming.self_cname)) + + # assign borrowed Python default values to the values array, + # so that they can be overwritten by received arguments below + for i, arg in enumerate(args): + if arg.default and arg.type.is_pyobject: + default_value = arg.calculate_default_value_code(code) + code.putln('values[%d] = %s;' % (i, arg.type.as_pyobject(default_value))) + + def generate_keyword_unpacking_code(self, min_positional_args, max_positional_args, + has_fixed_positional_count, has_kw_only_args, + all_args, argtuple_error_label, code): + code.putln('Py_ssize_t kw_args;') + code.putln('const Py_ssize_t pos_args = PyTuple_GET_SIZE(%s);' % Naming.args_cname) + # copy the values from the args tuple and check that it's not too long + code.putln('switch (pos_args) {') + if self.star_arg: + code.putln('default:') + for i in range(max_positional_args-1, -1, -1): + code.put('case %2d: ' % (i+1)) + code.putln("values[%d] = PyTuple_GET_ITEM(%s, %d);" % ( + i, Naming.args_cname, i)) + code.putln('CYTHON_FALLTHROUGH;') + code.putln('case 0: break;') + if not self.star_arg: + code.put('default: ') # more arguments than allowed + code.put_goto(argtuple_error_label) + code.putln('}') + + # The code above is very often (but not always) the same as + # the optimised non-kwargs tuple unpacking code, so we keep + # the code block above at the very top, before the following + # 'external' PyDict_Size() call, to make it easy for the C + # compiler to merge the two separate tuple unpacking + # implementations into one when they turn out to be identical. + + # If we received kwargs, fill up the positional/required + # arguments with values from the kw dict + code.putln('kw_args = PyDict_Size(%s);' % Naming.kwds_cname) + if self.num_required_args or max_positional_args > 0: + last_required_arg = -1 + for i, arg in enumerate(all_args): + if not arg.default: + last_required_arg = i + if last_required_arg < max_positional_args: + last_required_arg = max_positional_args-1 + if max_positional_args > 0: + code.putln('switch (pos_args) {') + for i, arg in enumerate(all_args[:last_required_arg+1]): + if max_positional_args > 0 and i <= max_positional_args: + if i != 0: + code.putln('CYTHON_FALLTHROUGH;') + if self.star_arg and i == max_positional_args: + code.putln('default:') + else: + code.putln('case %2d:' % i) + pystring_cname = code.intern_identifier(arg.name) + if arg.default: + if arg.kw_only: + # optional kw-only args are handled separately below + continue + code.putln('if (kw_args > 0) {') + # don't overwrite default argument + code.putln('PyObject* value = __Pyx_PyDict_GetItemStr(%s, %s);' % ( + Naming.kwds_cname, pystring_cname)) + code.putln('if (value) { values[%d] = value; kw_args--; }' % i) + code.putln('}') + else: + code.putln('if (likely((values[%d] = __Pyx_PyDict_GetItemStr(%s, %s)) != 0)) kw_args--;' % ( + i, Naming.kwds_cname, pystring_cname)) + if i < min_positional_args: + if i == 0: + # special case: we know arg 0 is missing + code.put('else ') + code.put_goto(argtuple_error_label) + else: + # print the correct number of values (args or + # kwargs) that were passed into positional + # arguments up to this point + code.putln('else {') + code.globalstate.use_utility_code( + UtilityCode.load_cached("RaiseArgTupleInvalid", "FunctionArguments.c")) + code.put('__Pyx_RaiseArgtupleInvalid("%s", %d, %d, %d, %d); ' % ( + self.name, has_fixed_positional_count, + min_positional_args, max_positional_args, i)) + code.putln(code.error_goto(self.pos)) + code.putln('}') + elif arg.kw_only: + code.putln('else {') + code.globalstate.use_utility_code( + UtilityCode.load_cached("RaiseKeywordRequired", "FunctionArguments.c")) + code.put('__Pyx_RaiseKeywordRequired("%s", %s); ' % ( + self.name, pystring_cname)) + code.putln(code.error_goto(self.pos)) + code.putln('}') + if max_positional_args > 0: + code.putln('}') + + if has_kw_only_args: + # unpack optional keyword-only arguments separately because + # checking for interned strings in a dict is faster than iterating + self.generate_optional_kwonly_args_unpacking_code(all_args, code) + + code.putln('if (unlikely(kw_args > 0)) {') + # non-positional/-required kw args left in dict: default args, + # kw-only args, **kwargs or error + # + # This is sort of a catch-all: except for checking required + # arguments, this will always do the right thing for unpacking + # keyword arguments, so that we can concentrate on optimising + # common cases above. + if max_positional_args == 0: + pos_arg_count = "0" + elif self.star_arg: + code.putln("const Py_ssize_t used_pos_args = (pos_args < %d) ? pos_args : %d;" % ( + max_positional_args, max_positional_args)) + pos_arg_count = "used_pos_args" + else: + pos_arg_count = "pos_args" + code.globalstate.use_utility_code( + UtilityCode.load_cached("ParseKeywords", "FunctionArguments.c")) + code.putln('if (unlikely(__Pyx_ParseOptionalKeywords(%s, %s, %s, values, %s, "%s") < 0)) %s' % ( + Naming.kwds_cname, + Naming.pykwdlist_cname, + self.starstar_arg and self.starstar_arg.entry.cname or '0', + pos_arg_count, + self.name, + code.error_goto(self.pos))) + code.putln('}') + + def generate_optional_kwonly_args_unpacking_code(self, all_args, code): + optional_args = [] + first_optional_arg = -1 + for i, arg in enumerate(all_args): + if not arg.kw_only or not arg.default: + continue + if not optional_args: + first_optional_arg = i + optional_args.append(arg.name) + if optional_args: + if len(optional_args) > 1: + # if we receive more than the named kwargs, we either have **kwargs + # (in which case we must iterate anyway) or it's an error (which we + # also handle during iteration) => skip this part if there are more + code.putln('if (kw_args > 0 && %s(kw_args <= %d)) {' % ( + not self.starstar_arg and 'likely' or '', + len(optional_args))) + code.putln('Py_ssize_t index;') + # not unrolling the loop here reduces the C code overhead + code.putln('for (index = %d; index < %d && kw_args > 0; index++) {' % ( + first_optional_arg, first_optional_arg + len(optional_args))) + else: + code.putln('if (kw_args == 1) {') + code.putln('const Py_ssize_t index = %d;' % first_optional_arg) + code.putln('PyObject* value = __Pyx_PyDict_GetItemStr(%s, *%s[index]);' % ( + Naming.kwds_cname, Naming.pykwdlist_cname)) + code.putln('if (value) { values[index] = value; kw_args--; }') + if len(optional_args) > 1: + code.putln('}') + code.putln('}') + + def generate_argument_conversion_code(self, code): + # Generate code to convert arguments from signature type to + # declared type, if needed. Also copies signature arguments + # into closure fields. + for arg in self.args: + if arg.needs_conversion: + self.generate_arg_conversion(arg, code) + + def generate_arg_conversion(self, arg, code): + # Generate conversion code for one argument. + old_type = arg.hdr_type + new_type = arg.type + if old_type.is_pyobject: + if arg.default: + code.putln("if (%s) {" % arg.hdr_cname) + else: + code.putln("assert(%s); {" % arg.hdr_cname) + self.generate_arg_conversion_from_pyobject(arg, code) + code.putln("}") + elif new_type.is_pyobject: + self.generate_arg_conversion_to_pyobject(arg, code) + else: + if new_type.assignable_from(old_type): + code.putln("%s = %s;" % (arg.entry.cname, arg.hdr_cname)) + else: + error(arg.pos, "Cannot convert 1 argument from '%s' to '%s'" % (old_type, new_type)) + + def generate_arg_conversion_from_pyobject(self, arg, code): + new_type = arg.type + # copied from CoerceFromPyTypeNode + if new_type.from_py_function: + code.putln(new_type.from_py_call_code( + arg.hdr_cname, + arg.entry.cname, + arg.pos, + code, + )) + else: + error(arg.pos, "Cannot convert Python object argument to type '%s'" % new_type) + + def generate_arg_conversion_to_pyobject(self, arg, code): + old_type = arg.hdr_type + func = old_type.to_py_function + if func: + code.putln("%s = %s(%s); %s" % ( + arg.entry.cname, + func, + arg.hdr_cname, + code.error_goto_if_null(arg.entry.cname, arg.pos))) + code.put_var_gotref(arg.entry) + else: + error(arg.pos, "Cannot convert argument of type '%s' to Python object" % old_type) + + def generate_argument_type_tests(self, code): + # Generate type tests for args whose signature + # type is PyObject * and whose declared type is + # a subtype thereof. + for arg in self.args: + if arg.needs_type_test: + self.generate_arg_type_test(arg, code) + elif not arg.accept_none and (arg.type.is_pyobject or + arg.type.is_buffer or + arg.type.is_memoryviewslice): + self.generate_arg_none_check(arg, code) + + def error_value(self): + return self.signature.error_value + + +class GeneratorDefNode(DefNode): + # Generator function node that creates a new generator instance when called. + # + # gbody GeneratorBodyDefNode the function implementing the generator + # + + is_generator = True + is_coroutine = False + is_iterable_coroutine = False + is_asyncgen = False + gen_type_name = 'Generator' + needs_closure = True + + child_attrs = DefNode.child_attrs + ["gbody"] + + def __init__(self, pos, **kwargs): + # XXX: don't actually needs a body + kwargs['body'] = StatListNode(pos, stats=[], is_terminator=True) + super(GeneratorDefNode, self).__init__(pos, **kwargs) + + def analyse_declarations(self, env): + super(GeneratorDefNode, self).analyse_declarations(env) + self.gbody.local_scope = self.local_scope + self.gbody.analyse_declarations(env) + + def generate_function_body(self, env, code): + body_cname = self.gbody.entry.func_cname + name = code.intern_identifier(self.name) + qualname = code.intern_identifier(self.qualname) + module_name = code.intern_identifier(self.module_name) + + code.putln('{') + code.putln('__pyx_CoroutineObject *gen = __Pyx_%s_New(' + '(__pyx_coroutine_body_t) %s, %s, (PyObject *) %s, %s, %s, %s); %s' % ( + self.gen_type_name, + body_cname, self.code_object.calculate_result_code(code) if self.code_object else 'NULL', + Naming.cur_scope_cname, name, qualname, module_name, + code.error_goto_if_null('gen', self.pos))) + code.put_decref(Naming.cur_scope_cname, py_object_type) + if self.requires_classobj: + classobj_cname = 'gen->classobj' + code.putln('%s = __Pyx_CyFunction_GetClassObj(%s);' % ( + classobj_cname, Naming.self_cname)) + code.put_incref(classobj_cname, py_object_type) + code.put_giveref(classobj_cname) + code.put_finish_refcount_context() + code.putln('return (PyObject *) gen;') + code.putln('}') + + def generate_function_definitions(self, env, code): + env.use_utility_code(UtilityCode.load_cached(self.gen_type_name, "Coroutine.c")) + self.gbody.generate_function_header(code, proto=True) + super(GeneratorDefNode, self).generate_function_definitions(env, code) + self.gbody.generate_function_definitions(env, code) + + +class AsyncDefNode(GeneratorDefNode): + gen_type_name = 'Coroutine' + is_coroutine = True + + +class IterableAsyncDefNode(AsyncDefNode): + gen_type_name = 'IterableCoroutine' + is_iterable_coroutine = True + + +class AsyncGenNode(AsyncDefNode): + gen_type_name = 'AsyncGen' + is_asyncgen = True + + +class GeneratorBodyDefNode(DefNode): + # Main code body of a generator implemented as a DefNode. + # + + is_generator_body = True + is_inlined = False + is_async_gen_body = False + inlined_comprehension_type = None # container type for inlined comprehensions + + def __init__(self, pos=None, name=None, body=None, is_async_gen_body=False): + super(GeneratorBodyDefNode, self).__init__( + pos=pos, body=body, name=name, is_async_gen_body=is_async_gen_body, + doc=None, args=[], star_arg=None, starstar_arg=None) + + def declare_generator_body(self, env): + prefix = env.next_id(env.scope_prefix) + name = env.next_id('generator') + cname = Naming.genbody_prefix + prefix + name + entry = env.declare_var(None, py_object_type, self.pos, + cname=cname, visibility='private') + entry.func_cname = cname + entry.qualified_name = EncodedString(self.name) + # Work-around for https://github.com/cython/cython/issues/1699 + # We don't currently determine whether the generator entry is used or not, + # so mark it as used to avoid false warnings. + entry.used = True + self.entry = entry + + def analyse_declarations(self, env): + self.analyse_argument_types(env) + self.declare_generator_body(env) + + def generate_function_header(self, code, proto=False): + header = "static PyObject *%s(PyObject *%s_obj, CYTHON_UNUSED PyThreadState *%s, PyObject *%s)" % ( + self.entry.func_cname, + Naming.generator_cname, + Naming.local_tstate_cname, + Naming.sent_value_cname) + if proto: + code.putln('%s; /* proto */' % header) + else: + code.putln('%s /* generator body */\n{' % header) + + def generate_function_definitions(self, env, code): + lenv = self.local_scope + + # Generate closure function definitions + self.body.generate_function_definitions(lenv, code) + + # Generate C code for header and body of function + code.enter_cfunc_scope(lenv) + code.return_from_error_cleanup_label = code.new_label() + + # ----- Top-level constants used by this function + code.mark_pos(self.pos) + self.generate_cached_builtins_decls(lenv, code) + # ----- Function header + code.putln("") + self.generate_function_header(code) + code.putln("__pyx_CoroutineObject *%s = (__pyx_CoroutineObject *)%s_obj;" % (Naming.generator_cname, Naming.generator_cname)) + closure_init_code = code.insertion_point() + # ----- Local variables + code.putln("PyObject *%s = NULL;" % Naming.retval_cname) + tempvardecl_code = code.insertion_point() + code.put_declare_refcount_context() + code.put_setup_refcount_context(self.entry.name or self.entry.qualified_name) + profile = code.globalstate.directives['profile'] + linetrace = code.globalstate.directives['linetrace'] + if profile or linetrace: + tempvardecl_code.put_trace_declarations() + code.funcstate.can_trace = True + code_object = self.code_object.calculate_result_code(code) if self.code_object else None + code.put_trace_frame_init(code_object) + + # ----- Resume switch point. + code.funcstate.init_closure_temps(lenv.scope_class.type.scope) + resume_code = code.insertion_point() + first_run_label = code.new_label('first_run') + code.use_label(first_run_label) + code.put_label(first_run_label) + code.putln('%s' % + (code.error_goto_if_null(Naming.sent_value_cname, self.pos))) + + # ----- prepare target container for inlined comprehension + if self.is_inlined and self.inlined_comprehension_type is not None: + target_type = self.inlined_comprehension_type + if target_type is Builtin.list_type: + comp_init = 'PyList_New(0)' + elif target_type is Builtin.set_type: + comp_init = 'PySet_New(NULL)' + elif target_type is Builtin.dict_type: + comp_init = 'PyDict_New()' + else: + raise InternalError( + "invalid type of inlined comprehension: %s" % target_type) + code.putln("%s = %s; %s" % ( + Naming.retval_cname, comp_init, + code.error_goto_if_null(Naming.retval_cname, self.pos))) + code.put_gotref(Naming.retval_cname) + + # ----- Function body + self.generate_function_body(env, code) + # ----- Closure initialization + if lenv.scope_class.type.scope.var_entries: + closure_init_code.putln('%s = %s;' % ( + lenv.scope_class.type.declaration_code(Naming.cur_scope_cname), + lenv.scope_class.type.cast_code('%s->closure' % + Naming.generator_cname))) + # FIXME: this silences a potential "unused" warning => try to avoid unused closures in more cases + code.putln("CYTHON_MAYBE_UNUSED_VAR(%s);" % Naming.cur_scope_cname) + + if profile or linetrace: + code.funcstate.can_trace = False + + code.mark_pos(self.pos) + code.putln("") + code.putln("/* function exit code */") + + # on normal generator termination, we do not take the exception propagation + # path: no traceback info is required and not creating it is much faster + if not self.is_inlined and not self.body.is_terminator: + if self.is_async_gen_body: + code.globalstate.use_utility_code( + UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c")) + code.putln('PyErr_SetNone(%s);' % ( + '__Pyx_PyExc_StopAsyncIteration' if self.is_async_gen_body else 'PyExc_StopIteration')) + # ----- Error cleanup + if code.label_used(code.error_label): + if not self.body.is_terminator: + code.put_goto(code.return_label) + code.put_label(code.error_label) + if self.is_inlined and self.inlined_comprehension_type is not None: + code.put_xdecref_clear(Naming.retval_cname, py_object_type) + if Future.generator_stop in env.global_scope().context.future_directives: + # PEP 479: turn accidental StopIteration exceptions into a RuntimeError + code.globalstate.use_utility_code(UtilityCode.load_cached("pep479", "Coroutine.c")) + code.putln("__Pyx_Generator_Replace_StopIteration(%d);" % bool(self.is_async_gen_body)) + for cname, type in code.funcstate.all_managed_temps(): + code.put_xdecref(cname, type) + code.put_add_traceback(self.entry.qualified_name) + + # ----- Non-error return cleanup + code.put_label(code.return_label) + if self.is_inlined: + code.put_xgiveref(Naming.retval_cname) + else: + code.put_xdecref_clear(Naming.retval_cname, py_object_type) + # For Py3.7, clearing is already done below. + code.putln("#if !CYTHON_USE_EXC_INFO_STACK") + code.putln("__Pyx_Coroutine_ResetAndClearException(%s);" % Naming.generator_cname) + code.putln("#endif") + code.putln('%s->resume_label = -1;' % Naming.generator_cname) + # clean up as early as possible to help breaking any reference cycles + code.putln('__Pyx_Coroutine_clear((PyObject*)%s);' % Naming.generator_cname) + if profile or linetrace: + code.put_trace_return(Naming.retval_cname, + nogil=not code.funcstate.gil_owned) + code.put_finish_refcount_context() + code.putln("return %s;" % Naming.retval_cname) + code.putln("}") + + # ----- Go back and insert temp variable declarations + tempvardecl_code.put_temp_declarations(code.funcstate) + # ----- Generator resume code + if profile or linetrace: + resume_code.put_trace_call(self.entry.qualified_name, self.pos, + nogil=not code.funcstate.gil_owned) + resume_code.putln("switch (%s->resume_label) {" % ( + Naming.generator_cname)) + + resume_code.putln("case 0: goto %s;" % first_run_label) + + for i, label in code.yield_labels: + resume_code.putln("case %d: goto %s;" % (i, label)) + resume_code.putln("default: /* CPython raises the right error here */") + if profile or linetrace: + resume_code.put_trace_return("Py_None", + nogil=not code.funcstate.gil_owned) + resume_code.put_finish_refcount_context() + resume_code.putln("return NULL;") + resume_code.putln("}") + + code.exit_cfunc_scope() + + +class OverrideCheckNode(StatNode): + # A Node for dispatching to the def method if it + # is overridden. + # + # py_func + # + # args + # func_temp + # body + + child_attrs = ['body'] + + body = None + + def analyse_expressions(self, env): + self.args = env.arg_entries + if self.py_func.is_module_scope: + first_arg = 0 + else: + first_arg = 1 + from . import ExprNodes + self.func_node = ExprNodes.RawCNameExprNode(self.pos, py_object_type) + call_node = ExprNodes.SimpleCallNode( + self.pos, function=self.func_node, + args=[ExprNodes.NameNode(self.pos, name=arg.name) + for arg in self.args[first_arg:]]) + if env.return_type.is_void or env.return_type.is_returncode: + self.body = StatListNode(self.pos, stats=[ + ExprStatNode(self.pos, expr=call_node), + ReturnStatNode(self.pos, value=None)]) + else: + self.body = ReturnStatNode(self.pos, value=call_node) + self.body = self.body.analyse_expressions(env) + return self + + def generate_execution_code(self, code): + interned_attr_cname = code.intern_identifier(self.py_func.entry.name) + # Check to see if we are an extension type + if self.py_func.is_module_scope: + self_arg = "((PyObject *)%s)" % Naming.module_cname + else: + self_arg = "((PyObject *)%s)" % self.args[0].cname + code.putln("/* Check if called by wrapper */") + code.putln("if (unlikely(%s)) ;" % Naming.skip_dispatch_cname) + code.putln("/* Check if overridden in Python */") + if self.py_func.is_module_scope: + code.putln("else {") + else: + code.putln("else if (unlikely((Py_TYPE(%s)->tp_dictoffset != 0)" + " || (Py_TYPE(%s)->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {" % ( + self_arg, self_arg)) + + code.putln("#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS") + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyDictVersioning", "ObjectHandling.c")) + # TODO: remove the object dict version check by 'inlining' the getattr implementation for methods. + # This would allow checking the dict versions around _PyType_Lookup() if it returns a descriptor, + # and would (tada!) make this check a pure type based thing instead of supporting only a single + # instance at a time. + code.putln("static PY_UINT64_T %s = __PYX_DICT_VERSION_INIT, %s = __PYX_DICT_VERSION_INIT;" % ( + Naming.tp_dict_version_temp, Naming.obj_dict_version_temp)) + code.putln("if (unlikely(!__Pyx_object_dict_version_matches(%s, %s, %s))) {" % ( + self_arg, Naming.tp_dict_version_temp, Naming.obj_dict_version_temp)) + code.putln("PY_UINT64_T %s = __Pyx_get_tp_dict_version(%s);" % ( + Naming.type_dict_guard_temp, self_arg)) + code.putln("#endif") + + func_node_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + self.func_node.set_cname(func_node_temp) + # need to get attribute manually--scope would return cdef method + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectGetAttrStr", "ObjectHandling.c")) + err = code.error_goto_if_null(func_node_temp, self.pos) + code.putln("%s = __Pyx_PyObject_GetAttrStr(%s, %s); %s" % ( + func_node_temp, self_arg, interned_attr_cname, err)) + code.put_gotref(func_node_temp) + + is_builtin_function_or_method = "PyCFunction_Check(%s)" % func_node_temp + is_overridden = "(PyCFunction_GET_FUNCTION(%s) != (PyCFunction)(void*)%s)" % ( + func_node_temp, self.py_func.entry.func_cname) + code.putln("if (!%s || %s) {" % (is_builtin_function_or_method, is_overridden)) + self.body.generate_execution_code(code) + code.putln("}") + + # NOTE: it's not 100% sure that we catch the exact versions here that were used for the lookup, + # but it is very unlikely that the versions change during lookup, and the type dict safe guard + # should increase the chance of detecting such a case. + code.putln("#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS") + code.putln("%s = __Pyx_get_tp_dict_version(%s);" % ( + Naming.tp_dict_version_temp, self_arg)) + code.putln("%s = __Pyx_get_object_dict_version(%s);" % ( + Naming.obj_dict_version_temp, self_arg)) + # Safety check that the type dict didn't change during the lookup. Since CPython looks up the + # attribute (descriptor) first in the type dict and then in the instance dict or through the + # descriptor, the only really far-away lookup when we get here is one in the type dict. So we + # double check the type dict version before and afterwards to guard against later changes of + # the type dict during the lookup process. + code.putln("if (unlikely(%s != %s)) {" % ( + Naming.type_dict_guard_temp, Naming.tp_dict_version_temp)) + code.putln("%s = %s = __PYX_DICT_VERSION_INIT;" % ( + Naming.tp_dict_version_temp, Naming.obj_dict_version_temp)) + code.putln("}") + code.putln("#endif") + + code.put_decref_clear(func_node_temp, PyrexTypes.py_object_type) + code.funcstate.release_temp(func_node_temp) + + code.putln("#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS") + code.putln("}") + code.putln("#endif") + + code.putln("}") + + +class ClassDefNode(StatNode, BlockNode): + pass + + +class PyClassDefNode(ClassDefNode): + # A Python class definition. + # + # name EncodedString Name of the class + # doc string or None + # body StatNode Attribute definition code + # entry Symtab.Entry + # scope PyClassScope + # decorators [DecoratorNode] list of decorators or None + # + # The following subnodes are constructed internally: + # + # dict DictNode Class dictionary or Py3 namespace + # classobj ClassNode Class object + # target NameNode Variable to assign class object to + + child_attrs = ["body", "dict", "metaclass", "mkw", "bases", "class_result", + "target", "class_cell", "decorators"] + decorators = None + class_result = None + is_py3_style_class = False # Python3 style class (kwargs) + metaclass = None + mkw = None + + def __init__(self, pos, name, bases, doc, body, decorators=None, + keyword_args=None, force_py3_semantics=False): + StatNode.__init__(self, pos) + self.name = name + self.doc = doc + self.body = body + self.decorators = decorators + self.bases = bases + from . import ExprNodes + if self.doc and Options.docstrings: + doc = embed_position(self.pos, self.doc) + doc_node = ExprNodes.StringNode(pos, value=doc) + else: + doc_node = None + + allow_py2_metaclass = not force_py3_semantics + if keyword_args: + allow_py2_metaclass = False + self.is_py3_style_class = True + if keyword_args.is_dict_literal: + if keyword_args.key_value_pairs: + for i, item in list(enumerate(keyword_args.key_value_pairs))[::-1]: + if item.key.value == 'metaclass': + if self.metaclass is not None: + error(item.pos, "keyword argument 'metaclass' passed multiple times") + # special case: we already know the metaclass, + # so we don't need to do the "build kwargs, + # find metaclass" dance at runtime + self.metaclass = item.value + del keyword_args.key_value_pairs[i] + self.mkw = keyword_args + else: + assert self.metaclass is not None + else: + # MergedDictNode + self.mkw = ExprNodes.ProxyNode(keyword_args) + + if force_py3_semantics or self.bases or self.mkw or self.metaclass: + if self.metaclass is None: + if keyword_args and not keyword_args.is_dict_literal: + # **kwargs may contain 'metaclass' arg + mkdict = self.mkw + else: + mkdict = None + if (not mkdict and + self.bases.is_sequence_constructor and + not self.bases.args): + pass # no base classes => no inherited metaclass + else: + self.metaclass = ExprNodes.PyClassMetaclassNode( + pos, class_def_node=self) + needs_metaclass_calculation = False + else: + needs_metaclass_calculation = True + + self.dict = ExprNodes.PyClassNamespaceNode( + pos, name=name, doc=doc_node, class_def_node=self) + self.classobj = ExprNodes.Py3ClassNode( + pos, name=name, class_def_node=self, doc=doc_node, + calculate_metaclass=needs_metaclass_calculation, + allow_py2_metaclass=allow_py2_metaclass) + else: + # no bases, no metaclass => old style class creation + self.dict = ExprNodes.DictNode(pos, key_value_pairs=[]) + self.classobj = ExprNodes.ClassNode( + pos, name=name, class_def_node=self, doc=doc_node) + + self.target = ExprNodes.NameNode(pos, name=name) + self.class_cell = ExprNodes.ClassCellInjectorNode(self.pos) + + def as_cclass(self): + """ + Return this node as if it were declared as an extension class + """ + if self.is_py3_style_class: + error(self.classobj.pos, "Python3 style class could not be represented as C class") + return + + from . import ExprNodes + return CClassDefNode(self.pos, + visibility='private', + module_name=None, + class_name=self.name, + bases=self.bases or ExprNodes.TupleNode(self.pos, args=[]), + decorators=self.decorators, + body=self.body, + in_pxd=False, + doc=self.doc) + + def create_scope(self, env): + genv = env + while genv.is_py_class_scope or genv.is_c_class_scope: + genv = genv.outer_scope + cenv = self.scope = PyClassScope(name=self.name, outer_scope=genv) + return cenv + + def analyse_declarations(self, env): + class_result = self.classobj + if self.decorators: + from .ExprNodes import SimpleCallNode + for decorator in self.decorators[::-1]: + class_result = SimpleCallNode( + decorator.pos, + function=decorator.decorator, + args=[class_result]) + self.decorators = None + self.class_result = class_result + if self.bases: + self.bases.analyse_declarations(env) + if self.mkw: + self.mkw.analyse_declarations(env) + self.class_result.analyse_declarations(env) + self.target.analyse_target_declaration(env) + cenv = self.create_scope(env) + cenv.directives = env.directives + cenv.class_obj_cname = self.target.entry.cname + self.body.analyse_declarations(cenv) + + def analyse_expressions(self, env): + if self.bases: + self.bases = self.bases.analyse_expressions(env) + if self.mkw: + self.mkw = self.mkw.analyse_expressions(env) + if self.metaclass: + self.metaclass = self.metaclass.analyse_expressions(env) + self.dict = self.dict.analyse_expressions(env) + self.class_result = self.class_result.analyse_expressions(env) + cenv = self.scope + self.body = self.body.analyse_expressions(cenv) + self.target.analyse_target_expression(env, self.classobj) + self.class_cell = self.class_cell.analyse_expressions(cenv) + return self + + def generate_function_definitions(self, env, code): + self.generate_lambda_definitions(self.scope, code) + self.body.generate_function_definitions(self.scope, code) + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + code.pyclass_stack.append(self) + cenv = self.scope + if self.bases: + self.bases.generate_evaluation_code(code) + if self.mkw: + self.mkw.generate_evaluation_code(code) + if self.metaclass: + self.metaclass.generate_evaluation_code(code) + self.dict.generate_evaluation_code(code) + cenv.namespace_cname = cenv.class_obj_cname = self.dict.result() + + class_cell = self.class_cell + if class_cell is not None and not class_cell.is_active: + class_cell = None + + if class_cell is not None: + class_cell.generate_evaluation_code(code) + self.body.generate_execution_code(code) + self.class_result.generate_evaluation_code(code) + if class_cell is not None: + class_cell.generate_injection_code( + code, self.class_result.result()) + if class_cell is not None: + class_cell.generate_disposal_code(code) + class_cell.free_temps(code) + + cenv.namespace_cname = cenv.class_obj_cname = self.classobj.result() + self.target.generate_assignment_code(self.class_result, code) + self.dict.generate_disposal_code(code) + self.dict.free_temps(code) + if self.metaclass: + self.metaclass.generate_disposal_code(code) + self.metaclass.free_temps(code) + if self.mkw: + self.mkw.generate_disposal_code(code) + self.mkw.free_temps(code) + if self.bases: + self.bases.generate_disposal_code(code) + self.bases.free_temps(code) + code.pyclass_stack.pop() + + +class CClassDefNode(ClassDefNode): + # An extension type definition. + # + # visibility 'private' or 'public' or 'extern' + # typedef_flag boolean + # api boolean + # module_name string or None For import of extern type objects + # class_name string Unqualified name of class + # as_name string or None Name to declare as in this scope + # bases TupleNode Base class(es) + # objstruct_name string or None Specified C name of object struct + # typeobj_name string or None Specified C name of type object + # check_size 'warn', 'error', 'ignore' What to do if tp_basicsize does not match + # in_pxd boolean Is in a .pxd file + # decorators [DecoratorNode] list of decorators or None + # doc string or None + # body StatNode or None + # entry Symtab.Entry + # base_type PyExtensionType or None + # buffer_defaults_node DictNode or None Declares defaults for a buffer + # buffer_defaults_pos + + child_attrs = ["body"] + buffer_defaults_node = None + buffer_defaults_pos = None + typedef_flag = False + api = False + objstruct_name = None + typeobj_name = None + check_size = None + decorators = None + shadow = False + + def buffer_defaults(self, env): + if not hasattr(self, '_buffer_defaults'): + from . import Buffer + if self.buffer_defaults_node: + self._buffer_defaults = Buffer.analyse_buffer_options( + self.buffer_defaults_pos, + env, [], self.buffer_defaults_node, + need_complete=False) + else: + self._buffer_defaults = None + return self._buffer_defaults + + def declare(self, env): + if self.module_name and self.visibility != 'extern': + module_path = self.module_name.split(".") + home_scope = env.find_imported_module(module_path, self.pos) + if not home_scope: + return None + else: + home_scope = env + + self.entry = home_scope.declare_c_class( + name=self.class_name, + pos=self.pos, + defining=0, + implementing=0, + module_name=self.module_name, + base_type=None, + objstruct_cname=self.objstruct_name, + typeobj_cname=self.typeobj_name, + visibility=self.visibility, + typedef_flag=self.typedef_flag, + check_size = self.check_size, + api=self.api, + buffer_defaults=self.buffer_defaults(env), + shadow=self.shadow) + + def analyse_declarations(self, env): + #print "CClassDefNode.analyse_declarations:", self.class_name + #print "...visibility =", self.visibility + #print "...module_name =", self.module_name + + if env.in_cinclude and not self.objstruct_name: + error(self.pos, "Object struct name specification required for C class defined in 'extern from' block") + if self.decorators: + error(self.pos, "Decorators not allowed on cdef classes (used on type '%s')" % self.class_name) + self.base_type = None + # Now that module imports are cached, we need to + # import the modules for extern classes. + if self.module_name: + self.module = None + for module in env.cimported_modules: + if module.name == self.module_name: + self.module = module + if self.module is None: + self.module = ModuleScope(self.module_name, None, env.context) + self.module.has_extern_class = 1 + env.add_imported_module(self.module) + + if self.bases.args: + base = self.bases.args[0] + base_type = base.analyse_as_type(env) + if base_type in (PyrexTypes.c_int_type, PyrexTypes.c_long_type, PyrexTypes.c_float_type): + # Use the Python rather than C variant of these types. + base_type = env.lookup(base_type.sign_and_name()).type + if base_type is None: + error(base.pos, "First base of '%s' is not an extension type" % self.class_name) + elif base_type == PyrexTypes.py_object_type: + base_class_scope = None + elif not base_type.is_extension_type and \ + not (base_type.is_builtin_type and base_type.objstruct_cname): + error(base.pos, "'%s' is not an extension type" % base_type) + elif not base_type.is_complete(): + error(base.pos, "Base class '%s' of type '%s' is incomplete" % ( + base_type.name, self.class_name)) + elif base_type.scope and base_type.scope.directives and \ + base_type.is_final_type: + error(base.pos, "Base class '%s' of type '%s' is final" % ( + base_type, self.class_name)) + elif base_type.is_builtin_type and \ + base_type.name in ('tuple', 'str', 'bytes'): + error(base.pos, "inheritance from PyVarObject types like '%s' is not currently supported" + % base_type.name) + else: + self.base_type = base_type + if env.directives.get('freelist', 0) > 0 and base_type != PyrexTypes.py_object_type: + warning(self.pos, "freelists cannot be used on subtypes, only the base class can manage them", 1) + + has_body = self.body is not None + if has_body and self.base_type and not self.base_type.scope: + # To properly initialize inherited attributes, the base type must + # be analysed before this type. + self.base_type.defered_declarations.append(lambda : self.analyse_declarations(env)) + return + + if self.module_name and self.visibility != 'extern': + module_path = self.module_name.split(".") + home_scope = env.find_imported_module(module_path, self.pos) + if not home_scope: + return + else: + home_scope = env + + if self.visibility == 'extern': + if (self.module_name == '__builtin__' and + self.class_name in Builtin.builtin_types and + env.qualified_name[:8] != 'cpython.'): # allow overloaded names for cimporting from cpython + warning(self.pos, "%s already a builtin Cython type" % self.class_name, 1) + + self.entry = home_scope.declare_c_class( + name=self.class_name, + pos=self.pos, + defining=has_body and self.in_pxd, + implementing=has_body and not self.in_pxd, + module_name=self.module_name, + base_type=self.base_type, + objstruct_cname=self.objstruct_name, + typeobj_cname=self.typeobj_name, + check_size=self.check_size, + visibility=self.visibility, + typedef_flag=self.typedef_flag, + api=self.api, + buffer_defaults=self.buffer_defaults(env), + shadow=self.shadow) + + if self.shadow: + home_scope.lookup(self.class_name).as_variable = self.entry + if home_scope is not env and self.visibility == 'extern': + env.add_imported_entry(self.class_name, self.entry, self.pos) + self.scope = scope = self.entry.type.scope + if scope is not None: + scope.directives = env.directives + + if self.doc and Options.docstrings: + scope.doc = embed_position(self.pos, self.doc) + + if has_body: + self.body.analyse_declarations(scope) + dict_entry = self.scope.lookup_here("__dict__") + if dict_entry and dict_entry.is_variable and (not scope.defined and not scope.implemented): + dict_entry.getter_cname = self.scope.mangle_internal("__dict__getter") + self.scope.declare_property("__dict__", dict_entry.doc, dict_entry.pos) + if self.in_pxd: + scope.defined = 1 + else: + scope.implemented = 1 + + if len(self.bases.args) > 1: + if not has_body or self.in_pxd: + error(self.bases.args[1].pos, "Only declare first base in declaration.") + # At runtime, we check that the other bases are heap types + # and that a __dict__ is added if required. + for other_base in self.bases.args[1:]: + if other_base.analyse_as_type(env): + error(other_base.pos, "Only one extension type base class allowed.") + self.entry.type.early_init = 0 + from . import ExprNodes + self.type_init_args = ExprNodes.TupleNode( + self.pos, + args=[ExprNodes.IdentifierStringNode(self.pos, value=self.class_name), + self.bases, + ExprNodes.DictNode(self.pos, key_value_pairs=[])]) + elif self.base_type: + self.entry.type.early_init = self.base_type.is_external or self.base_type.early_init + self.type_init_args = None + else: + self.entry.type.early_init = 1 + self.type_init_args = None + + env.allocate_vtable_names(self.entry) + + for thunk in self.entry.type.defered_declarations: + thunk() + + def analyse_expressions(self, env): + if self.body: + scope = self.entry.type.scope + self.body = self.body.analyse_expressions(scope) + if self.type_init_args: + self.type_init_args.analyse_expressions(env) + return self + + def generate_function_definitions(self, env, code): + if self.body: + self.generate_lambda_definitions(self.scope, code) + self.body.generate_function_definitions(self.scope, code) + + def generate_execution_code(self, code): + # This is needed to generate evaluation code for + # default values of method arguments. + code.mark_pos(self.pos) + if self.body: + self.body.generate_execution_code(code) + if not self.entry.type.early_init: + if self.type_init_args: + self.type_init_args.generate_evaluation_code(code) + bases = "PyTuple_GET_ITEM(%s, 1)" % self.type_init_args.result() + first_base = "((PyTypeObject*)PyTuple_GET_ITEM(%s, 0))" % bases + # Let Python do the base types compatibility checking. + trial_type = code.funcstate.allocate_temp(PyrexTypes.py_object_type, True) + code.putln("%s = PyType_Type.tp_new(&PyType_Type, %s, NULL);" % ( + trial_type, self.type_init_args.result())) + code.putln(code.error_goto_if_null(trial_type, self.pos)) + code.put_gotref(trial_type) + code.putln("if (((PyTypeObject*) %s)->tp_base != %s) {" % ( + trial_type, first_base)) + code.putln("PyErr_Format(PyExc_TypeError, \"best base '%s' must be equal to first base '%s'\",") + code.putln(" ((PyTypeObject*) %s)->tp_base->tp_name, %s->tp_name);" % ( + trial_type, first_base)) + code.putln(code.error_goto(self.pos)) + code.putln("}") + code.funcstate.release_temp(trial_type) + code.put_incref(bases, PyrexTypes.py_object_type) + code.put_giveref(bases) + code.putln("%s.tp_bases = %s;" % (self.entry.type.typeobj_cname, bases)) + code.put_decref_clear(trial_type, PyrexTypes.py_object_type) + self.type_init_args.generate_disposal_code(code) + self.type_init_args.free_temps(code) + + self.generate_type_ready_code(self.entry, code, True) + + # Also called from ModuleNode for early init types. + @staticmethod + def generate_type_ready_code(entry, code, heap_type_bases=False): + # Generate a call to PyType_Ready for an extension + # type defined in this module. + type = entry.type + typeobj_cname = type.typeobj_cname + scope = type.scope + if not scope: # could be None if there was an error + return + if entry.visibility != 'extern': + for slot in TypeSlots.slot_table: + slot.generate_dynamic_init_code(scope, code) + if heap_type_bases: + code.globalstate.use_utility_code( + UtilityCode.load_cached('PyType_Ready', 'ExtensionTypes.c')) + readyfunc = "__Pyx_PyType_Ready" + else: + readyfunc = "PyType_Ready" + code.putln( + "if (%s(&%s) < 0) %s" % ( + readyfunc, + typeobj_cname, + code.error_goto(entry.pos))) + # Don't inherit tp_print from builtin types, restoring the + # behavior of using tp_repr or tp_str instead. + # ("tp_print" was renamed to "tp_vectorcall_offset" in Py3.8b1) + code.putln("#if PY_VERSION_HEX < 0x030800B1") + code.putln("%s.tp_print = 0;" % typeobj_cname) + code.putln("#endif") + + # Use specialised attribute lookup for types with generic lookup but no instance dict. + getattr_slot_func = TypeSlots.get_slot_code_by_name(scope, 'tp_getattro') + dictoffset_slot_func = TypeSlots.get_slot_code_by_name(scope, 'tp_dictoffset') + if getattr_slot_func == '0' and dictoffset_slot_func == '0': + if type.is_final_type: + py_cfunc = "__Pyx_PyObject_GenericGetAttrNoDict" # grepable + utility_func = "PyObject_GenericGetAttrNoDict" + else: + py_cfunc = "__Pyx_PyObject_GenericGetAttr" + utility_func = "PyObject_GenericGetAttr" + code.globalstate.use_utility_code(UtilityCode.load_cached(utility_func, "ObjectHandling.c")) + + code.putln("if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) &&" + " likely(!%s.tp_dictoffset && %s.tp_getattro == PyObject_GenericGetAttr)) {" % ( + typeobj_cname, typeobj_cname)) + code.putln("%s.tp_getattro = %s;" % ( + typeobj_cname, py_cfunc)) + code.putln("}") + + # Fix special method docstrings. This is a bit of a hack, but + # unless we let PyType_Ready create the slot wrappers we have + # a significant performance hit. (See trac #561.) + for func in entry.type.scope.pyfunc_entries: + is_buffer = func.name in ('__getbuffer__', '__releasebuffer__') + if (func.is_special and Options.docstrings and + func.wrapperbase_cname and not is_buffer): + slot = TypeSlots.method_name_to_slot.get(func.name) + preprocessor_guard = slot.preprocessor_guard_code() if slot else None + if preprocessor_guard: + code.putln(preprocessor_guard) + code.putln('#if CYTHON_UPDATE_DESCRIPTOR_DOC') + code.putln("{") + code.putln( + 'PyObject *wrapper = PyObject_GetAttrString((PyObject *)&%s, "%s"); %s' % ( + typeobj_cname, + func.name, + code.error_goto_if_null('wrapper', entry.pos))) + code.putln( + "if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {") + code.putln( + "%s = *((PyWrapperDescrObject *)wrapper)->d_base;" % ( + func.wrapperbase_cname)) + code.putln( + "%s.doc = %s;" % (func.wrapperbase_cname, func.doc_cname)) + code.putln( + "((PyWrapperDescrObject *)wrapper)->d_base = &%s;" % ( + func.wrapperbase_cname)) + code.putln("}") + code.putln("}") + code.putln('#endif') + if preprocessor_guard: + code.putln('#endif') + if type.vtable_cname: + code.globalstate.use_utility_code( + UtilityCode.load_cached('SetVTable', 'ImportExport.c')) + code.putln( + "if (__Pyx_SetVtable(%s.tp_dict, %s) < 0) %s" % ( + typeobj_cname, + type.vtabptr_cname, + code.error_goto(entry.pos))) + if heap_type_bases: + code.globalstate.use_utility_code( + UtilityCode.load_cached('MergeVTables', 'ImportExport.c')) + code.putln("if (__Pyx_MergeVtables(&%s) < 0) %s" % ( + typeobj_cname, + code.error_goto(entry.pos))) + if not type.scope.is_internal and not type.scope.directives.get('internal'): + # scope.is_internal is set for types defined by + # Cython (such as closures), the 'internal' + # directive is set by users + code.putln( + 'if (PyObject_SetAttr(%s, %s, (PyObject *)&%s) < 0) %s' % ( + Naming.module_cname, + code.intern_identifier(scope.class_name), + typeobj_cname, + code.error_goto(entry.pos))) + weakref_entry = scope.lookup_here("__weakref__") if not scope.is_closure_class_scope else None + if weakref_entry: + if weakref_entry.type is py_object_type: + tp_weaklistoffset = "%s.tp_weaklistoffset" % typeobj_cname + if type.typedef_flag: + objstruct = type.objstruct_cname + else: + objstruct = "struct %s" % type.objstruct_cname + code.putln("if (%s == 0) %s = offsetof(%s, %s);" % ( + tp_weaklistoffset, + tp_weaklistoffset, + objstruct, + weakref_entry.cname)) + else: + error(weakref_entry.pos, "__weakref__ slot must be of type 'object'") + if scope.lookup_here("__reduce_cython__") if not scope.is_closure_class_scope else None: + # Unfortunately, we cannot reliably detect whether a + # superclass defined __reduce__ at compile time, so we must + # do so at runtime. + code.globalstate.use_utility_code( + UtilityCode.load_cached('SetupReduce', 'ExtensionTypes.c')) + code.putln('if (__Pyx_setup_reduce((PyObject*)&%s) < 0) %s' % ( + typeobj_cname, + code.error_goto(entry.pos))) + # Generate code to initialise the typeptr of an extension + # type defined in this module to point to its type object. + if type.typeobj_cname: + code.putln( + "%s = &%s;" % ( + type.typeptr_cname, type.typeobj_cname)) + + def annotate(self, code): + if self.type_init_args: + self.type_init_args.annotate(code) + if self.body: + self.body.annotate(code) + + +class PropertyNode(StatNode): + # Definition of a property in an extension type. + # + # name string + # doc EncodedString or None Doc string + # entry Symtab.Entry + # body StatListNode + + child_attrs = ["body"] + + def analyse_declarations(self, env): + self.entry = env.declare_property(self.name, self.doc, self.pos) + self.entry.scope.directives = env.directives + self.body.analyse_declarations(self.entry.scope) + + def analyse_expressions(self, env): + self.body = self.body.analyse_expressions(env) + return self + + def generate_function_definitions(self, env, code): + self.body.generate_function_definitions(env, code) + + def generate_execution_code(self, code): + pass + + def annotate(self, code): + self.body.annotate(code) + + +class GlobalNode(StatNode): + # Global variable declaration. + # + # names [string] + + child_attrs = [] + + def analyse_declarations(self, env): + for name in self.names: + env.declare_global(name, self.pos) + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + +class NonlocalNode(StatNode): + # Nonlocal variable declaration via the 'nonlocal' keyword. + # + # names [string] + + child_attrs = [] + + def analyse_declarations(self, env): + for name in self.names: + env.declare_nonlocal(name, self.pos) + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + +class ExprStatNode(StatNode): + # Expression used as a statement. + # + # expr ExprNode + + child_attrs = ["expr"] + + def analyse_declarations(self, env): + from . import ExprNodes + expr = self.expr + if isinstance(expr, ExprNodes.GeneralCallNode): + func = expr.function.as_cython_attribute() + if func == u'declare': + args, kwds = expr.explicit_args_kwds() + if len(args): + error(expr.pos, "Variable names must be specified.") + for var, type_node in kwds.key_value_pairs: + type = type_node.analyse_as_type(env) + if type is None: + error(type_node.pos, "Unknown type") + else: + env.declare_var(var.value, type, var.pos, is_cdef=True) + self.__class__ = PassStatNode + elif getattr(expr, 'annotation', None) is not None: + if expr.is_name: + # non-code variable annotation, e.g. "name: type" + expr.declare_from_annotation(env) + self.__class__ = PassStatNode + elif expr.is_attribute or expr.is_subscript: + # unused expression with annotation, e.g. "a[0]: type" or "a.xyz : type" + self.__class__ = PassStatNode + + def analyse_expressions(self, env): + self.expr.result_is_used = False # hint that .result() may safely be left empty + self.expr = self.expr.analyse_expressions(env) + # Repeat in case of node replacement. + self.expr.result_is_used = False # hint that .result() may safely be left empty + return self + + def nogil_check(self, env): + if self.expr.type.is_pyobject and self.expr.is_temp: + self.gil_error() + + gil_message = "Discarding owned Python object" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + self.expr.result_is_used = False # hint that .result() may safely be left empty + self.expr.generate_evaluation_code(code) + if not self.expr.is_temp and self.expr.result(): + result = self.expr.result() + if not self.expr.type.is_void: + result = "(void)(%s)" % result + code.putln("%s;" % result) + self.expr.generate_disposal_code(code) + self.expr.free_temps(code) + + def generate_function_definitions(self, env, code): + self.expr.generate_function_definitions(env, code) + + def annotate(self, code): + self.expr.annotate(code) + + +class AssignmentNode(StatNode): + # Abstract base class for assignment nodes. + # + # The analyse_expressions and generate_execution_code + # phases of assignments are split into two sub-phases + # each, to enable all the right hand sides of a + # parallel assignment to be evaluated before assigning + # to any of the left hand sides. + + def analyse_expressions(self, env): + node = self.analyse_types(env) + if isinstance(node, AssignmentNode) and not isinstance(node, ParallelAssignmentNode): + if node.rhs.type.is_ptr and node.rhs.is_ephemeral(): + error(self.pos, "Storing unsafe C derivative of temporary Python reference") + return node + +# def analyse_expressions(self, env): +# self.analyse_expressions_1(env) +# self.analyse_expressions_2(env) + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + self.generate_rhs_evaluation_code(code) + self.generate_assignment_code(code) + + +class SingleAssignmentNode(AssignmentNode): + # The simplest case: + # + # a = b + # + # lhs ExprNode Left hand side + # rhs ExprNode Right hand side + # first bool Is this guaranteed the first assignment to lhs? + # is_overloaded_assignment bool Is this assignment done via an overloaded operator= + # exception_check + # exception_value + + child_attrs = ["lhs", "rhs"] + first = False + is_overloaded_assignment = False + declaration_only = False + + def analyse_declarations(self, env): + from . import ExprNodes + + # handle declarations of the form x = cython.foo() + if isinstance(self.rhs, ExprNodes.CallNode): + func_name = self.rhs.function.as_cython_attribute() + if func_name: + args, kwds = self.rhs.explicit_args_kwds() + if func_name in ['declare', 'typedef']: + if len(args) > 2: + error(args[2].pos, "Invalid positional argument.") + return + if kwds is not None: + kwdict = kwds.compile_time_value(None) + if func_name == 'typedef' or 'visibility' not in kwdict: + error(kwds.pos, "Invalid keyword argument.") + return + visibility = kwdict['visibility'] + else: + visibility = 'private' + type = args[0].analyse_as_type(env) + if type is None: + error(args[0].pos, "Unknown type") + return + lhs = self.lhs + if func_name == 'declare': + if isinstance(lhs, ExprNodes.NameNode): + vars = [(lhs.name, lhs.pos)] + elif isinstance(lhs, ExprNodes.TupleNode): + vars = [(var.name, var.pos) for var in lhs.args] + else: + error(lhs.pos, "Invalid declaration") + return + for var, pos in vars: + env.declare_var(var, type, pos, is_cdef=True, visibility=visibility) + if len(args) == 2: + # we have a value + self.rhs = args[1] + else: + self.declaration_only = True + else: + self.declaration_only = True + if not isinstance(lhs, ExprNodes.NameNode): + error(lhs.pos, "Invalid declaration.") + env.declare_typedef(lhs.name, type, self.pos, visibility='private') + + elif func_name in ['struct', 'union']: + self.declaration_only = True + if len(args) > 0 or kwds is None: + error(self.rhs.pos, "Struct or union members must be given by name.") + return + members = [] + for member, type_node in kwds.key_value_pairs: + type = type_node.analyse_as_type(env) + if type is None: + error(type_node.pos, "Unknown type") + else: + members.append((member.value, type, member.pos)) + if len(members) < len(kwds.key_value_pairs): + return + if not isinstance(self.lhs, ExprNodes.NameNode): + error(self.lhs.pos, "Invalid declaration.") + name = self.lhs.name + scope = StructOrUnionScope(name) + env.declare_struct_or_union(name, func_name, scope, False, self.rhs.pos) + for member, type, pos in members: + scope.declare_var(member, type, pos) + + elif func_name == 'fused_type': + # dtype = cython.fused_type(...) + self.declaration_only = True + if kwds: + error(self.rhs.function.pos, + "fused_type does not take keyword arguments") + + fusednode = FusedTypeNode(self.rhs.pos, + name=self.lhs.name, types=args) + fusednode.analyse_declarations(env) + + if self.declaration_only: + return + else: + self.lhs.analyse_target_declaration(env) + + def analyse_types(self, env, use_temp=0): + from . import ExprNodes + + self.rhs = self.rhs.analyse_types(env) + + unrolled_assignment = self.unroll_rhs(env) + if unrolled_assignment: + return unrolled_assignment + + self.lhs = self.lhs.analyse_target_types(env) + self.lhs.gil_assignment_check(env) + unrolled_assignment = self.unroll_lhs(env) + if unrolled_assignment: + return unrolled_assignment + + if isinstance(self.lhs, ExprNodes.MemoryViewIndexNode): + self.lhs.analyse_broadcast_operation(self.rhs) + self.lhs = self.lhs.analyse_as_memview_scalar_assignment(self.rhs) + elif self.lhs.type.is_array: + if not isinstance(self.lhs, ExprNodes.SliceIndexNode): + # cannot assign to C array, only to its full slice + self.lhs = ExprNodes.SliceIndexNode(self.lhs.pos, base=self.lhs, start=None, stop=None) + self.lhs = self.lhs.analyse_target_types(env) + + if self.lhs.type.is_cpp_class: + op = env.lookup_operator_for_types(self.pos, '=', [self.lhs.type, self.rhs.type]) + if op: + rhs = self.rhs + self.is_overloaded_assignment = True + self.exception_check = op.type.exception_check + self.exception_value = op.type.exception_value + if self.exception_check == '+' and self.exception_value is None: + env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp")) + else: + rhs = self.rhs.coerce_to(self.lhs.type, env) + else: + rhs = self.rhs.coerce_to(self.lhs.type, env) + + if use_temp or rhs.is_attribute or ( + not rhs.is_name and not rhs.is_literal and + rhs.type.is_pyobject): + # things like (cdef) attribute access are not safe (traverses pointers) + rhs = rhs.coerce_to_temp(env) + elif rhs.type.is_pyobject: + rhs = rhs.coerce_to_simple(env) + self.rhs = rhs + return self + + def unroll(self, node, target_size, env): + from . import ExprNodes, UtilNodes + + base = node + start_node = stop_node = step_node = check_node = None + + if node.type.is_ctuple: + slice_size = node.type.size + + elif node.type.is_ptr or node.type.is_array: + while isinstance(node, ExprNodes.SliceIndexNode) and not (node.start or node.stop): + base = node = node.base + if isinstance(node, ExprNodes.SliceIndexNode): + base = node.base + start_node = node.start + if start_node: + start_node = start_node.coerce_to(PyrexTypes.c_py_ssize_t_type, env) + stop_node = node.stop + if stop_node: + stop_node = stop_node.coerce_to(PyrexTypes.c_py_ssize_t_type, env) + else: + if node.type.is_array and node.type.size: + stop_node = ExprNodes.IntNode( + self.pos, value=str(node.type.size), + constant_result=(node.type.size if isinstance(node.type.size, _py_int_types) + else ExprNodes.constant_value_not_set)) + else: + error(self.pos, "C array iteration requires known end index") + return + step_node = None #node.step + if step_node: + step_node = step_node.coerce_to(PyrexTypes.c_py_ssize_t_type, env) + + # TODO: Factor out SliceIndexNode.generate_slice_guard_code() for use here. + def get_const(node, none_value): + if node is None: + return none_value + elif node.has_constant_result(): + return node.constant_result + else: + raise ValueError("Not a constant.") + + try: + slice_size = (get_const(stop_node, None) - get_const(start_node, 0)) / get_const(step_node, 1) + except ValueError: + error(self.pos, "C array assignment currently requires known endpoints") + return + + elif node.type.is_array: + slice_size = node.type.size + if not isinstance(slice_size, _py_int_types): + return # might still work when coercing to Python + else: + return + + else: + return + + if slice_size != target_size: + error(self.pos, "Assignment to/from slice of wrong length, expected %s, got %s" % ( + slice_size, target_size)) + return + + items = [] + base = UtilNodes.LetRefNode(base) + refs = [base] + if start_node and not start_node.is_literal: + start_node = UtilNodes.LetRefNode(start_node) + refs.append(start_node) + if stop_node and not stop_node.is_literal: + stop_node = UtilNodes.LetRefNode(stop_node) + refs.append(stop_node) + if step_node and not step_node.is_literal: + step_node = UtilNodes.LetRefNode(step_node) + refs.append(step_node) + + for ix in range(target_size): + ix_node = ExprNodes.IntNode(self.pos, value=str(ix), constant_result=ix, type=PyrexTypes.c_py_ssize_t_type) + if step_node is not None: + if step_node.has_constant_result(): + step_value = ix_node.constant_result * step_node.constant_result + ix_node = ExprNodes.IntNode(self.pos, value=str(step_value), constant_result=step_value) + else: + ix_node = ExprNodes.MulNode(self.pos, operator='*', operand1=step_node, operand2=ix_node) + if start_node is not None: + if start_node.has_constant_result() and ix_node.has_constant_result(): + index_value = ix_node.constant_result + start_node.constant_result + ix_node = ExprNodes.IntNode(self.pos, value=str(index_value), constant_result=index_value) + else: + ix_node = ExprNodes.AddNode( + self.pos, operator='+', operand1=start_node, operand2=ix_node) + items.append(ExprNodes.IndexNode(self.pos, base=base, index=ix_node.analyse_types(env))) + return check_node, refs, items + + def unroll_assignments(self, refs, check_node, lhs_list, rhs_list, env): + from . import UtilNodes + assignments = [] + for lhs, rhs in zip(lhs_list, rhs_list): + assignments.append(SingleAssignmentNode(self.pos, lhs=lhs, rhs=rhs, first=self.first)) + node = ParallelAssignmentNode(pos=self.pos, stats=assignments).analyse_expressions(env) + if check_node: + node = StatListNode(pos=self.pos, stats=[check_node, node]) + for ref in refs[::-1]: + node = UtilNodes.LetNode(ref, node) + return node + + def unroll_rhs(self, env): + from . import ExprNodes + if not isinstance(self.lhs, ExprNodes.TupleNode): + return + if any(arg.is_starred for arg in self.lhs.args): + return + + unrolled = self.unroll(self.rhs, len(self.lhs.args), env) + if not unrolled: + return + check_node, refs, rhs = unrolled + return self.unroll_assignments(refs, check_node, self.lhs.args, rhs, env) + + def unroll_lhs(self, env): + if self.lhs.type.is_ctuple: + # Handled directly. + return + from . import ExprNodes + if not isinstance(self.rhs, ExprNodes.TupleNode): + return + + unrolled = self.unroll(self.lhs, len(self.rhs.args), env) + if not unrolled: + return + check_node, refs, lhs = unrolled + return self.unroll_assignments(refs, check_node, lhs, self.rhs.args, env) + + def generate_rhs_evaluation_code(self, code): + self.rhs.generate_evaluation_code(code) + + def generate_assignment_code(self, code, overloaded_assignment=False): + if self.is_overloaded_assignment: + self.lhs.generate_assignment_code( + self.rhs, + code, + overloaded_assignment=self.is_overloaded_assignment, + exception_check=self.exception_check, + exception_value=self.exception_value) + else: + self.lhs.generate_assignment_code(self.rhs, code) + + def generate_function_definitions(self, env, code): + self.rhs.generate_function_definitions(env, code) + + def annotate(self, code): + self.lhs.annotate(code) + self.rhs.annotate(code) + + +class CascadedAssignmentNode(AssignmentNode): + # An assignment with multiple left hand sides: + # + # a = b = c + # + # lhs_list [ExprNode] Left hand sides + # rhs ExprNode Right hand sides + # + # Used internally: + # + # coerced_values [ExprNode] RHS coerced to all distinct LHS types + # cloned_values [ExprNode] cloned RHS value for each LHS + # assignment_overloads [Bool] If each assignment uses a C++ operator= + + child_attrs = ["lhs_list", "rhs", "coerced_values", "cloned_values"] + cloned_values = None + coerced_values = None + assignment_overloads = None + + def analyse_declarations(self, env): + for lhs in self.lhs_list: + lhs.analyse_target_declaration(env) + + def analyse_types(self, env, use_temp=0): + from .ExprNodes import CloneNode, ProxyNode + + # collect distinct types used on the LHS + lhs_types = set() + for i, lhs in enumerate(self.lhs_list): + lhs = self.lhs_list[i] = lhs.analyse_target_types(env) + lhs.gil_assignment_check(env) + lhs_types.add(lhs.type) + + rhs = self.rhs.analyse_types(env) + # common special case: only one type needed on the LHS => coerce only once + if len(lhs_types) == 1: + # Avoid coercion for overloaded assignment operators. + if next(iter(lhs_types)).is_cpp_class: + op = env.lookup_operator('=', [lhs, self.rhs]) + if not op: + rhs = rhs.coerce_to(lhs_types.pop(), env) + else: + rhs = rhs.coerce_to(lhs_types.pop(), env) + + if not rhs.is_name and not rhs.is_literal and ( + use_temp or rhs.is_attribute or rhs.type.is_pyobject): + rhs = rhs.coerce_to_temp(env) + else: + rhs = rhs.coerce_to_simple(env) + self.rhs = ProxyNode(rhs) if rhs.is_temp else rhs + + # clone RHS and coerce it to all distinct LHS types + self.coerced_values = [] + coerced_values = {} + self.assignment_overloads = [] + for lhs in self.lhs_list: + overloaded = lhs.type.is_cpp_class and env.lookup_operator('=', [lhs, self.rhs]) + self.assignment_overloads.append(overloaded) + if lhs.type not in coerced_values and lhs.type != rhs.type: + rhs = CloneNode(self.rhs) + if not overloaded: + rhs = rhs.coerce_to(lhs.type, env) + self.coerced_values.append(rhs) + coerced_values[lhs.type] = rhs + + # clone coerced values for all LHS assignments + self.cloned_values = [] + for lhs in self.lhs_list: + rhs = coerced_values.get(lhs.type, self.rhs) + self.cloned_values.append(CloneNode(rhs)) + return self + + def generate_rhs_evaluation_code(self, code): + self.rhs.generate_evaluation_code(code) + + def generate_assignment_code(self, code, overloaded_assignment=False): + # prepare all coercions + for rhs in self.coerced_values: + rhs.generate_evaluation_code(code) + # assign clones to LHS + for lhs, rhs, overload in zip(self.lhs_list, self.cloned_values, self.assignment_overloads): + rhs.generate_evaluation_code(code) + lhs.generate_assignment_code(rhs, code, overloaded_assignment=overload) + # dispose of coerced values and original RHS + for rhs_value in self.coerced_values: + rhs_value.generate_disposal_code(code) + rhs_value.free_temps(code) + self.rhs.generate_disposal_code(code) + self.rhs.free_temps(code) + + def generate_function_definitions(self, env, code): + self.rhs.generate_function_definitions(env, code) + + def annotate(self, code): + for rhs in self.coerced_values: + rhs.annotate(code) + for lhs, rhs in zip(self.lhs_list, self.cloned_values): + lhs.annotate(code) + rhs.annotate(code) + self.rhs.annotate(code) + + +class ParallelAssignmentNode(AssignmentNode): + # A combined packing/unpacking assignment: + # + # a, b, c = d, e, f + # + # This has been rearranged by the parser into + # + # a = d ; b = e ; c = f + # + # but we must evaluate all the right hand sides + # before assigning to any of the left hand sides. + # + # stats [AssignmentNode] The constituent assignments + + child_attrs = ["stats"] + + def analyse_declarations(self, env): + for stat in self.stats: + stat.analyse_declarations(env) + + def analyse_expressions(self, env): + self.stats = [stat.analyse_types(env, use_temp=1) + for stat in self.stats] + return self + +# def analyse_expressions(self, env): +# for stat in self.stats: +# stat.analyse_expressions_1(env, use_temp=1) +# for stat in self.stats: +# stat.analyse_expressions_2(env) + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + for stat in self.stats: + stat.generate_rhs_evaluation_code(code) + for stat in self.stats: + stat.generate_assignment_code(code) + + def generate_function_definitions(self, env, code): + for stat in self.stats: + stat.generate_function_definitions(env, code) + + def annotate(self, code): + for stat in self.stats: + stat.annotate(code) + + +class InPlaceAssignmentNode(AssignmentNode): + # An in place arithmetic operand: + # + # a += b + # a -= b + # ... + # + # lhs ExprNode Left hand side + # rhs ExprNode Right hand side + # operator char one of "+-*/%^&|" + # + # This code is a bit tricky because in order to obey Python + # semantics the sub-expressions (e.g. indices) of the lhs must + # not be evaluated twice. So we must re-use the values calculated + # in evaluation phase for the assignment phase as well. + # Fortunately, the type of the lhs node is fairly constrained + # (it must be a NameNode, AttributeNode, or IndexNode). + + child_attrs = ["lhs", "rhs"] + + def analyse_declarations(self, env): + self.lhs.analyse_target_declaration(env) + + def analyse_types(self, env): + self.rhs = self.rhs.analyse_types(env) + self.lhs = self.lhs.analyse_target_types(env) + + # When assigning to a fully indexed buffer or memoryview, coerce the rhs + if self.lhs.is_memview_index or self.lhs.is_buffer_access: + self.rhs = self.rhs.coerce_to(self.lhs.type, env) + elif self.lhs.type.is_string and self.operator in '+-': + # use pointer arithmetic for char* LHS instead of string concat + self.rhs = self.rhs.coerce_to(PyrexTypes.c_py_ssize_t_type, env) + return self + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + lhs, rhs = self.lhs, self.rhs + rhs.generate_evaluation_code(code) + lhs.generate_subexpr_evaluation_code(code) + c_op = self.operator + if c_op == "//": + c_op = "/" + elif c_op == "**": + error(self.pos, "No C inplace power operator") + if lhs.is_buffer_access or lhs.is_memview_index: + if lhs.type.is_pyobject: + error(self.pos, "In-place operators not allowed on object buffers in this release.") + if c_op in ('/', '%') and lhs.type.is_int and not code.globalstate.directives['cdivision']: + error(self.pos, "In-place non-c divide operators not allowed on int buffers.") + lhs.generate_buffer_setitem_code(rhs, code, c_op) + elif lhs.is_memview_slice: + error(self.pos, "Inplace operators not supported on memoryview slices") + else: + # C++ + # TODO: make sure overload is declared + code.putln("%s %s= %s;" % (lhs.result(), c_op, rhs.result())) + lhs.generate_subexpr_disposal_code(code) + lhs.free_subexpr_temps(code) + rhs.generate_disposal_code(code) + rhs.free_temps(code) + + def annotate(self, code): + self.lhs.annotate(code) + self.rhs.annotate(code) + + def create_binop_node(self): + from . import ExprNodes + return ExprNodes.binop_node(self.pos, self.operator, self.lhs, self.rhs) + + +class PrintStatNode(StatNode): + # print statement + # + # arg_tuple TupleNode + # stream ExprNode or None (stdout) + # append_newline boolean + + child_attrs = ["arg_tuple", "stream"] + + def analyse_expressions(self, env): + if self.stream: + stream = self.stream.analyse_expressions(env) + self.stream = stream.coerce_to_pyobject(env) + arg_tuple = self.arg_tuple.analyse_expressions(env) + self.arg_tuple = arg_tuple.coerce_to_pyobject(env) + env.use_utility_code(printing_utility_code) + if len(self.arg_tuple.args) == 1 and self.append_newline: + env.use_utility_code(printing_one_utility_code) + return self + + nogil_check = Node.gil_error + gil_message = "Python print statement" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + if self.stream: + self.stream.generate_evaluation_code(code) + stream_result = self.stream.py_result() + else: + stream_result = '0' + if len(self.arg_tuple.args) == 1 and self.append_newline: + arg = self.arg_tuple.args[0] + arg.generate_evaluation_code(code) + + code.putln( + "if (__Pyx_PrintOne(%s, %s) < 0) %s" % ( + stream_result, + arg.py_result(), + code.error_goto(self.pos))) + arg.generate_disposal_code(code) + arg.free_temps(code) + else: + self.arg_tuple.generate_evaluation_code(code) + code.putln( + "if (__Pyx_Print(%s, %s, %d) < 0) %s" % ( + stream_result, + self.arg_tuple.py_result(), + self.append_newline, + code.error_goto(self.pos))) + self.arg_tuple.generate_disposal_code(code) + self.arg_tuple.free_temps(code) + + if self.stream: + self.stream.generate_disposal_code(code) + self.stream.free_temps(code) + + def generate_function_definitions(self, env, code): + if self.stream: + self.stream.generate_function_definitions(env, code) + self.arg_tuple.generate_function_definitions(env, code) + + def annotate(self, code): + if self.stream: + self.stream.annotate(code) + self.arg_tuple.annotate(code) + + +class ExecStatNode(StatNode): + # exec statement + # + # args [ExprNode] + + child_attrs = ["args"] + + def analyse_expressions(self, env): + for i, arg in enumerate(self.args): + arg = arg.analyse_expressions(env) + arg = arg.coerce_to_pyobject(env) + self.args[i] = arg + env.use_utility_code(Builtin.pyexec_utility_code) + return self + + nogil_check = Node.gil_error + gil_message = "Python exec statement" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + args = [] + for arg in self.args: + arg.generate_evaluation_code(code) + args.append(arg.py_result()) + args = tuple(args + ['0', '0'][:3-len(args)]) + temp_result = code.funcstate.allocate_temp(PyrexTypes.py_object_type, manage_ref=True) + code.putln("%s = __Pyx_PyExec3(%s, %s, %s);" % ((temp_result,) + args)) + for arg in self.args: + arg.generate_disposal_code(code) + arg.free_temps(code) + code.putln( + code.error_goto_if_null(temp_result, self.pos)) + code.put_gotref(temp_result) + code.put_decref_clear(temp_result, py_object_type) + code.funcstate.release_temp(temp_result) + + def annotate(self, code): + for arg in self.args: + arg.annotate(code) + + +class DelStatNode(StatNode): + # del statement + # + # args [ExprNode] + + child_attrs = ["args"] + ignore_nonexisting = False + + def analyse_declarations(self, env): + for arg in self.args: + arg.analyse_target_declaration(env) + + def analyse_expressions(self, env): + for i, arg in enumerate(self.args): + arg = self.args[i] = arg.analyse_target_expression(env, None) + if arg.type.is_pyobject or (arg.is_name and arg.type.is_memoryviewslice): + if arg.is_name and arg.entry.is_cglobal: + error(arg.pos, "Deletion of global C variable") + elif arg.type.is_ptr and arg.type.base_type.is_cpp_class: + self.cpp_check(env) + elif arg.type.is_cpp_class: + error(arg.pos, "Deletion of non-heap C++ object") + elif arg.is_subscript and arg.base.type is Builtin.bytearray_type: + pass # del ba[i] + else: + error(arg.pos, "Deletion of non-Python, non-C++ object") + #arg.release_target_temp(env) + return self + + def nogil_check(self, env): + for arg in self.args: + if arg.type.is_pyobject: + self.gil_error() + + gil_message = "Deleting Python object" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + for arg in self.args: + if (arg.type.is_pyobject or + arg.type.is_memoryviewslice or + arg.is_subscript and arg.base.type is Builtin.bytearray_type): + arg.generate_deletion_code( + code, ignore_nonexisting=self.ignore_nonexisting) + elif arg.type.is_ptr and arg.type.base_type.is_cpp_class: + arg.generate_evaluation_code(code) + code.putln("delete %s;" % arg.result()) + arg.generate_disposal_code(code) + arg.free_temps(code) + # else error reported earlier + + def annotate(self, code): + for arg in self.args: + arg.annotate(code) + + +class PassStatNode(StatNode): + # pass statement + + child_attrs = [] + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + +class IndirectionNode(StatListNode): + """ + This adds an indirection so that the node can be shared and a subtree can + be removed at any time by clearing self.stats. + """ + + def __init__(self, stats): + super(IndirectionNode, self).__init__(stats[0].pos, stats=stats) + + +class BreakStatNode(StatNode): + + child_attrs = [] + is_terminator = True + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + if not code.break_label: + error(self.pos, "break statement not inside loop") + else: + code.put_goto(code.break_label) + + +class ContinueStatNode(StatNode): + + child_attrs = [] + is_terminator = True + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + if not code.continue_label: + error(self.pos, "continue statement not inside loop") + return + code.mark_pos(self.pos) + code.put_goto(code.continue_label) + + +class ReturnStatNode(StatNode): + # return statement + # + # value ExprNode or None + # return_type PyrexType + # in_generator return inside of generator => raise StopIteration + # in_async_gen return inside of async generator + + child_attrs = ["value"] + is_terminator = True + in_generator = False + in_async_gen = False + + # Whether we are in a parallel section + in_parallel = False + + def analyse_expressions(self, env): + return_type = env.return_type + self.return_type = return_type + if not return_type: + error(self.pos, "Return not inside a function body") + return self + if self.value: + if self.in_async_gen: + error(self.pos, "Return with value in async generator") + self.value = self.value.analyse_types(env) + if return_type.is_void or return_type.is_returncode: + error(self.value.pos, "Return with value in void function") + else: + self.value = self.value.coerce_to(env.return_type, env) + else: + if (not return_type.is_void + and not return_type.is_pyobject + and not return_type.is_returncode): + error(self.pos, "Return value required") + return self + + def nogil_check(self, env): + if self.return_type.is_pyobject: + self.gil_error() + + gil_message = "Returning Python object" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + if not self.return_type: + # error reported earlier + return + + value = self.value + if self.return_type.is_pyobject: + code.put_xdecref(Naming.retval_cname, self.return_type) + if value and value.is_none: + # Use specialised default handling for "return None". + value = None + + if value: + value.generate_evaluation_code(code) + if self.return_type.is_memoryviewslice: + from . import MemoryView + MemoryView.put_acquire_memoryviewslice( + lhs_cname=Naming.retval_cname, + lhs_type=self.return_type, + lhs_pos=value.pos, + rhs=value, + code=code, + have_gil=self.in_nogil_context) + value.generate_post_assignment_code(code) + elif self.in_generator: + # return value == raise StopIteration(value), but uncatchable + code.globalstate.use_utility_code( + UtilityCode.load_cached("ReturnWithStopIteration", "Coroutine.c")) + code.putln("%s = NULL; __Pyx_ReturnWithStopIteration(%s);" % ( + Naming.retval_cname, + value.py_result())) + value.generate_disposal_code(code) + else: + value.make_owned_reference(code) + code.putln("%s = %s;" % ( + Naming.retval_cname, + value.result_as(self.return_type))) + value.generate_post_assignment_code(code) + value.free_temps(code) + else: + if self.return_type.is_pyobject: + if self.in_generator: + if self.in_async_gen: + code.globalstate.use_utility_code( + UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c")) + code.put("PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); ") + code.putln("%s = NULL;" % Naming.retval_cname) + else: + code.put_init_to_py_none(Naming.retval_cname, self.return_type) + elif self.return_type.is_returncode: + self.put_return(code, self.return_type.default_value) + + for cname, type in code.funcstate.temps_holding_reference(): + code.put_decref_clear(cname, type) + + code.put_goto(code.return_label) + + def put_return(self, code, value): + if self.in_parallel: + code.putln_openmp("#pragma omp critical(__pyx_returning)") + code.putln("%s = %s;" % (Naming.retval_cname, value)) + + def generate_function_definitions(self, env, code): + if self.value is not None: + self.value.generate_function_definitions(env, code) + + def annotate(self, code): + if self.value: + self.value.annotate(code) + + +class RaiseStatNode(StatNode): + # raise statement + # + # exc_type ExprNode or None + # exc_value ExprNode or None + # exc_tb ExprNode or None + # cause ExprNode or None + + child_attrs = ["exc_type", "exc_value", "exc_tb", "cause"] + is_terminator = True + + def analyse_expressions(self, env): + if self.exc_type: + exc_type = self.exc_type.analyse_types(env) + self.exc_type = exc_type.coerce_to_pyobject(env) + if self.exc_value: + exc_value = self.exc_value.analyse_types(env) + self.exc_value = exc_value.coerce_to_pyobject(env) + if self.exc_tb: + exc_tb = self.exc_tb.analyse_types(env) + self.exc_tb = exc_tb.coerce_to_pyobject(env) + if self.cause: + cause = self.cause.analyse_types(env) + self.cause = cause.coerce_to_pyobject(env) + # special cases for builtin exceptions + self.builtin_exc_name = None + if self.exc_type and not self.exc_value and not self.exc_tb: + exc = self.exc_type + from . import ExprNodes + if (isinstance(exc, ExprNodes.SimpleCallNode) and + not (exc.args or (exc.arg_tuple is not None and exc.arg_tuple.args))): + exc = exc.function # extract the exception type + if exc.is_name and exc.entry.is_builtin: + self.builtin_exc_name = exc.name + if self.builtin_exc_name == 'MemoryError': + self.exc_type = None # has a separate implementation + return self + + nogil_check = Node.gil_error + gil_message = "Raising exception" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + if self.builtin_exc_name == 'MemoryError': + code.putln('PyErr_NoMemory(); %s' % code.error_goto(self.pos)) + return + + if self.exc_type: + self.exc_type.generate_evaluation_code(code) + type_code = self.exc_type.py_result() + if self.exc_type.is_name: + code.globalstate.use_entry_utility_code(self.exc_type.entry) + else: + type_code = "0" + if self.exc_value: + self.exc_value.generate_evaluation_code(code) + value_code = self.exc_value.py_result() + else: + value_code = "0" + if self.exc_tb: + self.exc_tb.generate_evaluation_code(code) + tb_code = self.exc_tb.py_result() + else: + tb_code = "0" + if self.cause: + self.cause.generate_evaluation_code(code) + cause_code = self.cause.py_result() + else: + cause_code = "0" + code.globalstate.use_utility_code(raise_utility_code) + code.putln( + "__Pyx_Raise(%s, %s, %s, %s);" % ( + type_code, + value_code, + tb_code, + cause_code)) + for obj in (self.exc_type, self.exc_value, self.exc_tb, self.cause): + if obj: + obj.generate_disposal_code(code) + obj.free_temps(code) + code.putln( + code.error_goto(self.pos)) + + def generate_function_definitions(self, env, code): + if self.exc_type is not None: + self.exc_type.generate_function_definitions(env, code) + if self.exc_value is not None: + self.exc_value.generate_function_definitions(env, code) + if self.exc_tb is not None: + self.exc_tb.generate_function_definitions(env, code) + if self.cause is not None: + self.cause.generate_function_definitions(env, code) + + def annotate(self, code): + if self.exc_type: + self.exc_type.annotate(code) + if self.exc_value: + self.exc_value.annotate(code) + if self.exc_tb: + self.exc_tb.annotate(code) + if self.cause: + self.cause.annotate(code) + + +class ReraiseStatNode(StatNode): + + child_attrs = [] + is_terminator = True + + def analyse_expressions(self, env): + return self + + nogil_check = Node.gil_error + gil_message = "Raising exception" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + vars = code.funcstate.exc_vars + if vars: + code.globalstate.use_utility_code(restore_exception_utility_code) + code.put_giveref(vars[0]) + code.put_giveref(vars[1]) + # fresh exceptions may not have a traceback yet (-> finally!) + code.put_xgiveref(vars[2]) + code.putln("__Pyx_ErrRestoreWithState(%s, %s, %s);" % tuple(vars)) + for varname in vars: + code.put("%s = 0; " % varname) + code.putln() + code.putln(code.error_goto(self.pos)) + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("ReRaiseException", "Exceptions.c")) + code.putln("__Pyx_ReraiseException(); %s" % code.error_goto(self.pos)) + +class AssertStatNode(StatNode): + # assert statement + # + # cond ExprNode + # value ExprNode or None + + child_attrs = ["cond", "value"] + + def analyse_expressions(self, env): + self.cond = self.cond.analyse_boolean_expression(env) + if self.value: + value = self.value.analyse_types(env) + if value.type is Builtin.tuple_type or not value.type.is_builtin_type: + # prevent tuple values from being interpreted as argument value tuples + from .ExprNodes import TupleNode + value = TupleNode(value.pos, args=[value], slow=True) + self.value = value.analyse_types(env, skip_children=True).coerce_to_pyobject(env) + else: + self.value = value.coerce_to_pyobject(env) + return self + + nogil_check = Node.gil_error + gil_message = "Raising exception" + + def generate_execution_code(self, code): + code.putln("#ifndef CYTHON_WITHOUT_ASSERTIONS") + code.putln("if (unlikely(!Py_OptimizeFlag)) {") + code.mark_pos(self.pos) + self.cond.generate_evaluation_code(code) + code.putln( + "if (unlikely(!%s)) {" % self.cond.result()) + if self.value: + self.value.generate_evaluation_code(code) + code.putln( + "PyErr_SetObject(PyExc_AssertionError, %s);" % self.value.py_result()) + self.value.generate_disposal_code(code) + self.value.free_temps(code) + else: + code.putln( + "PyErr_SetNone(PyExc_AssertionError);") + code.putln( + code.error_goto(self.pos)) + code.putln( + "}") + self.cond.generate_disposal_code(code) + self.cond.free_temps(code) + code.putln( + "}") + code.putln("#endif") + + def generate_function_definitions(self, env, code): + self.cond.generate_function_definitions(env, code) + if self.value is not None: + self.value.generate_function_definitions(env, code) + + def annotate(self, code): + self.cond.annotate(code) + if self.value: + self.value.annotate(code) + + +class IfStatNode(StatNode): + # if statement + # + # if_clauses [IfClauseNode] + # else_clause StatNode or None + + child_attrs = ["if_clauses", "else_clause"] + + def analyse_declarations(self, env): + for if_clause in self.if_clauses: + if_clause.analyse_declarations(env) + if self.else_clause: + self.else_clause.analyse_declarations(env) + + def analyse_expressions(self, env): + self.if_clauses = [if_clause.analyse_expressions(env) for if_clause in self.if_clauses] + if self.else_clause: + self.else_clause = self.else_clause.analyse_expressions(env) + return self + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + end_label = code.new_label() + last = len(self.if_clauses) + if self.else_clause: + # If the 'else' clause is 'unlikely', then set the preceding 'if' clause to 'likely' to reflect that. + self._set_branch_hint(self.if_clauses[-1], self.else_clause, inverse=True) + else: + last -= 1 # avoid redundant goto at end of last if-clause + for i, if_clause in enumerate(self.if_clauses): + self._set_branch_hint(if_clause, if_clause.body) + if_clause.generate_execution_code(code, end_label, is_last=i == last) + if self.else_clause: + code.mark_pos(self.else_clause.pos) + code.putln("/*else*/ {") + self.else_clause.generate_execution_code(code) + code.putln("}") + code.put_label(end_label) + + def _set_branch_hint(self, clause, statements_node, inverse=False): + if not statements_node.is_terminator: + return + if not isinstance(statements_node, StatListNode) or not statements_node.stats: + return + # Anything that unconditionally raises exceptions should be considered unlikely. + if isinstance(statements_node.stats[-1], (RaiseStatNode, ReraiseStatNode)): + if len(statements_node.stats) > 1: + # Allow simple statements before the 'raise', but no conditions, loops, etc. + non_branch_nodes = (ExprStatNode, AssignmentNode, DelStatNode, GlobalNode, NonlocalNode) + for node in statements_node.stats[:-1]: + if not isinstance(node, non_branch_nodes): + return + clause.branch_hint = 'likely' if inverse else 'unlikely' + + def generate_function_definitions(self, env, code): + for clause in self.if_clauses: + clause.generate_function_definitions(env, code) + if self.else_clause is not None: + self.else_clause.generate_function_definitions(env, code) + + def annotate(self, code): + for if_clause in self.if_clauses: + if_clause.annotate(code) + if self.else_clause: + self.else_clause.annotate(code) + + +class IfClauseNode(Node): + # if or elif clause in an if statement + # + # condition ExprNode + # body StatNode + + child_attrs = ["condition", "body"] + branch_hint = None + + def analyse_declarations(self, env): + self.body.analyse_declarations(env) + + def analyse_expressions(self, env): + self.condition = self.condition.analyse_temp_boolean_expression(env) + self.body = self.body.analyse_expressions(env) + return self + + def generate_execution_code(self, code, end_label, is_last): + self.condition.generate_evaluation_code(code) + code.mark_pos(self.pos) + condition = self.condition.result() + if self.branch_hint: + condition = '%s(%s)' % (self.branch_hint, condition) + code.putln("if (%s) {" % condition) + self.condition.generate_disposal_code(code) + self.condition.free_temps(code) + self.body.generate_execution_code(code) + code.mark_pos(self.pos, trace=False) + if not (is_last or self.body.is_terminator): + code.put_goto(end_label) + code.putln("}") + + def generate_function_definitions(self, env, code): + self.condition.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + + def annotate(self, code): + self.condition.annotate(code) + self.body.annotate(code) + + +class SwitchCaseNode(StatNode): + # Generated in the optimization of an if-elif-else node + # + # conditions [ExprNode] + # body StatNode + + child_attrs = ['conditions', 'body'] + + def generate_condition_evaluation_code(self, code): + for cond in self.conditions: + cond.generate_evaluation_code(code) + + def generate_execution_code(self, code): + num_conditions = len(self.conditions) + line_tracing_enabled = code.globalstate.directives['linetrace'] + for i, cond in enumerate(self.conditions, 1): + code.putln("case %s:" % cond.result()) + code.mark_pos(cond.pos) # Tracing code must appear *after* the 'case' statement. + if line_tracing_enabled and i < num_conditions: + # Allow fall-through after the line tracing code. + code.putln('CYTHON_FALLTHROUGH;') + self.body.generate_execution_code(code) + code.mark_pos(self.pos, trace=False) + code.putln("break;") + + def generate_function_definitions(self, env, code): + for cond in self.conditions: + cond.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + + def annotate(self, code): + for cond in self.conditions: + cond.annotate(code) + self.body.annotate(code) + + +class SwitchStatNode(StatNode): + # Generated in the optimization of an if-elif-else node + # + # test ExprNode + # cases [SwitchCaseNode] + # else_clause StatNode or None + + child_attrs = ['test', 'cases', 'else_clause'] + + def generate_execution_code(self, code): + self.test.generate_evaluation_code(code) + # Make sure all conditions are evaluated before going into the switch() statement. + # This is required in order to prevent any execution code from leaking into the space between the cases. + for case in self.cases: + case.generate_condition_evaluation_code(code) + code.mark_pos(self.pos) + code.putln("switch (%s) {" % self.test.result()) + for case in self.cases: + case.generate_execution_code(code) + if self.else_clause is not None: + code.putln("default:") + self.else_clause.generate_execution_code(code) + code.putln("break;") + else: + # Always generate a default clause to prevent C compiler warnings + # about unmatched enum values (it was not the user who decided to + # generate the switch statement, so shouldn't be bothered). + code.putln("default: break;") + code.putln("}") + self.test.generate_disposal_code(code) + self.test.free_temps(code) + + def generate_function_definitions(self, env, code): + self.test.generate_function_definitions(env, code) + for case in self.cases: + case.generate_function_definitions(env, code) + if self.else_clause is not None: + self.else_clause.generate_function_definitions(env, code) + + def annotate(self, code): + self.test.annotate(code) + for case in self.cases: + case.annotate(code) + if self.else_clause is not None: + self.else_clause.annotate(code) + + +class LoopNode(object): + pass + + +class WhileStatNode(LoopNode, StatNode): + # while statement + # + # condition ExprNode + # body StatNode + # else_clause StatNode + + child_attrs = ["condition", "body", "else_clause"] + + def analyse_declarations(self, env): + self.body.analyse_declarations(env) + if self.else_clause: + self.else_clause.analyse_declarations(env) + + def analyse_expressions(self, env): + if self.condition: + self.condition = self.condition.analyse_temp_boolean_expression(env) + self.body = self.body.analyse_expressions(env) + if self.else_clause: + self.else_clause = self.else_clause.analyse_expressions(env) + return self + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + old_loop_labels = code.new_loop_labels() + code.putln( + "while (1) {") + if self.condition: + self.condition.generate_evaluation_code(code) + self.condition.generate_disposal_code(code) + code.putln( + "if (!%s) break;" % self.condition.result()) + self.condition.free_temps(code) + self.body.generate_execution_code(code) + code.put_label(code.continue_label) + code.putln("}") + break_label = code.break_label + code.set_loop_labels(old_loop_labels) + if self.else_clause: + code.mark_pos(self.else_clause.pos) + code.putln("/*else*/ {") + self.else_clause.generate_execution_code(code) + code.putln("}") + code.put_label(break_label) + + def generate_function_definitions(self, env, code): + if self.condition: + self.condition.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + if self.else_clause is not None: + self.else_clause.generate_function_definitions(env, code) + + def annotate(self, code): + if self.condition: + self.condition.annotate(code) + self.body.annotate(code) + if self.else_clause: + self.else_clause.annotate(code) + + +class DictIterationNextNode(Node): + # Helper node for calling PyDict_Next() inside of a WhileStatNode + # and checking the dictionary size for changes. Created in + # Optimize.py. + child_attrs = ['dict_obj', 'expected_size', 'pos_index_var', + 'coerced_key_var', 'coerced_value_var', 'coerced_tuple_var', + 'key_target', 'value_target', 'tuple_target', 'is_dict_flag'] + + coerced_key_var = key_ref = None + coerced_value_var = value_ref = None + coerced_tuple_var = tuple_ref = None + + def __init__(self, dict_obj, expected_size, pos_index_var, + key_target, value_target, tuple_target, is_dict_flag): + Node.__init__( + self, dict_obj.pos, + dict_obj=dict_obj, + expected_size=expected_size, + pos_index_var=pos_index_var, + key_target=key_target, + value_target=value_target, + tuple_target=tuple_target, + is_dict_flag=is_dict_flag, + is_temp=True, + type=PyrexTypes.c_bint_type) + + def analyse_expressions(self, env): + from . import ExprNodes + self.dict_obj = self.dict_obj.analyse_types(env) + self.expected_size = self.expected_size.analyse_types(env) + if self.pos_index_var: + self.pos_index_var = self.pos_index_var.analyse_types(env) + if self.key_target: + self.key_target = self.key_target.analyse_target_types(env) + self.key_ref = ExprNodes.TempNode(self.key_target.pos, PyrexTypes.py_object_type) + self.coerced_key_var = self.key_ref.coerce_to(self.key_target.type, env) + if self.value_target: + self.value_target = self.value_target.analyse_target_types(env) + self.value_ref = ExprNodes.TempNode(self.value_target.pos, type=PyrexTypes.py_object_type) + self.coerced_value_var = self.value_ref.coerce_to(self.value_target.type, env) + if self.tuple_target: + self.tuple_target = self.tuple_target.analyse_target_types(env) + self.tuple_ref = ExprNodes.TempNode(self.tuple_target.pos, PyrexTypes.py_object_type) + self.coerced_tuple_var = self.tuple_ref.coerce_to(self.tuple_target.type, env) + self.is_dict_flag = self.is_dict_flag.analyse_types(env) + return self + + def generate_function_definitions(self, env, code): + self.dict_obj.generate_function_definitions(env, code) + + def generate_execution_code(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("dict_iter", "Optimize.c")) + self.dict_obj.generate_evaluation_code(code) + + assignments = [] + temp_addresses = [] + for var, result, target in [(self.key_ref, self.coerced_key_var, self.key_target), + (self.value_ref, self.coerced_value_var, self.value_target), + (self.tuple_ref, self.coerced_tuple_var, self.tuple_target)]: + if target is None: + addr = 'NULL' + else: + assignments.append((var, result, target)) + var.allocate(code) + addr = '&%s' % var.result() + temp_addresses.append(addr) + + result_temp = code.funcstate.allocate_temp(PyrexTypes.c_int_type, False) + code.putln("%s = __Pyx_dict_iter_next(%s, %s, &%s, %s, %s, %s, %s);" % ( + result_temp, + self.dict_obj.py_result(), + self.expected_size.result(), + self.pos_index_var.result(), + temp_addresses[0], + temp_addresses[1], + temp_addresses[2], + self.is_dict_flag.result() + )) + code.putln("if (unlikely(%s == 0)) break;" % result_temp) + code.putln(code.error_goto_if("%s == -1" % result_temp, self.pos)) + code.funcstate.release_temp(result_temp) + + # evaluate all coercions before the assignments + for var, result, target in assignments: + code.put_gotref(var.result()) + for var, result, target in assignments: + result.generate_evaluation_code(code) + for var, result, target in assignments: + target.generate_assignment_code(result, code) + var.release(code) + + +class SetIterationNextNode(Node): + # Helper node for calling _PySet_NextEntry() inside of a WhileStatNode + # and checking the set size for changes. Created in Optimize.py. + child_attrs = ['set_obj', 'expected_size', 'pos_index_var', + 'coerced_value_var', 'value_target', 'is_set_flag'] + + coerced_value_var = value_ref = None + + def __init__(self, set_obj, expected_size, pos_index_var, value_target, is_set_flag): + Node.__init__( + self, set_obj.pos, + set_obj=set_obj, + expected_size=expected_size, + pos_index_var=pos_index_var, + value_target=value_target, + is_set_flag=is_set_flag, + is_temp=True, + type=PyrexTypes.c_bint_type) + + def analyse_expressions(self, env): + from . import ExprNodes + self.set_obj = self.set_obj.analyse_types(env) + self.expected_size = self.expected_size.analyse_types(env) + self.pos_index_var = self.pos_index_var.analyse_types(env) + self.value_target = self.value_target.analyse_target_types(env) + self.value_ref = ExprNodes.TempNode(self.value_target.pos, type=PyrexTypes.py_object_type) + self.coerced_value_var = self.value_ref.coerce_to(self.value_target.type, env) + self.is_set_flag = self.is_set_flag.analyse_types(env) + return self + + def generate_function_definitions(self, env, code): + self.set_obj.generate_function_definitions(env, code) + + def generate_execution_code(self, code): + code.globalstate.use_utility_code(UtilityCode.load_cached("set_iter", "Optimize.c")) + self.set_obj.generate_evaluation_code(code) + + value_ref = self.value_ref + value_ref.allocate(code) + + result_temp = code.funcstate.allocate_temp(PyrexTypes.c_int_type, False) + code.putln("%s = __Pyx_set_iter_next(%s, %s, &%s, &%s, %s);" % ( + result_temp, + self.set_obj.py_result(), + self.expected_size.result(), + self.pos_index_var.result(), + value_ref.result(), + self.is_set_flag.result() + )) + code.putln("if (unlikely(%s == 0)) break;" % result_temp) + code.putln(code.error_goto_if("%s == -1" % result_temp, self.pos)) + code.funcstate.release_temp(result_temp) + + # evaluate all coercions before the assignments + code.put_gotref(value_ref.result()) + self.coerced_value_var.generate_evaluation_code(code) + self.value_target.generate_assignment_code(self.coerced_value_var, code) + value_ref.release(code) + + +def ForStatNode(pos, **kw): + if 'iterator' in kw: + if kw['iterator'].is_async: + return AsyncForStatNode(pos, **kw) + else: + return ForInStatNode(pos, **kw) + else: + return ForFromStatNode(pos, **kw) + + +class _ForInStatNode(LoopNode, StatNode): + # Base class of 'for-in' statements. + # + # target ExprNode + # iterator IteratorNode | AIterAwaitExprNode(AsyncIteratorNode) + # body StatNode + # else_clause StatNode + # item NextNode | AwaitExprNode(AsyncNextNode) + # is_async boolean true for 'async for' statements + + child_attrs = ["target", "item", "iterator", "body", "else_clause"] + item = None + is_async = False + + def _create_item_node(self): + raise NotImplementedError("must be implemented by subclasses") + + def analyse_declarations(self, env): + self.target.analyse_target_declaration(env) + self.body.analyse_declarations(env) + if self.else_clause: + self.else_clause.analyse_declarations(env) + self._create_item_node() + + def analyse_expressions(self, env): + self.target = self.target.analyse_target_types(env) + self.iterator = self.iterator.analyse_expressions(env) + self._create_item_node() # must rewrap self.item after analysis + self.item = self.item.analyse_expressions(env) + if (not self.is_async and + (self.iterator.type.is_ptr or self.iterator.type.is_array) and + self.target.type.assignable_from(self.iterator.type)): + # C array slice optimization. + pass + else: + self.item = self.item.coerce_to(self.target.type, env) + self.body = self.body.analyse_expressions(env) + if self.else_clause: + self.else_clause = self.else_clause.analyse_expressions(env) + return self + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + old_loop_labels = code.new_loop_labels() + self.iterator.generate_evaluation_code(code) + code.putln("for (;;) {") + self.item.generate_evaluation_code(code) + self.target.generate_assignment_code(self.item, code) + self.body.generate_execution_code(code) + code.mark_pos(self.pos) + code.put_label(code.continue_label) + code.putln("}") + break_label = code.break_label + code.set_loop_labels(old_loop_labels) + + if self.else_clause: + # In nested loops, the 'else' block can contain 'continue' or 'break' + # statements for the outer loop, but we may need to generate cleanup code + # before taking those paths, so we intercept them here. + orig_exit_labels = (code.continue_label, code.break_label) + code.continue_label = code.new_label('outer_continue') + code.break_label = code.new_label('outer_break') + + code.putln("/*else*/ {") + self.else_clause.generate_execution_code(code) + code.putln("}") + + needs_goto_end = not self.else_clause.is_terminator + for exit_label, orig_exit_label in zip([code.continue_label, code.break_label], orig_exit_labels): + if not code.label_used(exit_label): + continue + if needs_goto_end: + code.put_goto(break_label) + needs_goto_end = False + code.mark_pos(self.pos) + code.put_label(exit_label) + self.iterator.generate_disposal_code(code) + code.put_goto(orig_exit_label) + code.set_loop_labels(old_loop_labels) + + code.mark_pos(self.pos) + if code.label_used(break_label): + code.put_label(break_label) + self.iterator.generate_disposal_code(code) + self.iterator.free_temps(code) + + def generate_function_definitions(self, env, code): + self.target.generate_function_definitions(env, code) + self.iterator.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + if self.else_clause is not None: + self.else_clause.generate_function_definitions(env, code) + + def annotate(self, code): + self.target.annotate(code) + self.iterator.annotate(code) + self.body.annotate(code) + if self.else_clause: + self.else_clause.annotate(code) + self.item.annotate(code) + + +class ForInStatNode(_ForInStatNode): + # 'for' statement + + is_async = False + + def _create_item_node(self): + from .ExprNodes import NextNode + self.item = NextNode(self.iterator) + + +class AsyncForStatNode(_ForInStatNode): + # 'async for' statement + # + # iterator AIterAwaitExprNode(AsyncIteratorNode) + # item AwaitIterNextExprNode(AsyncIteratorNode) + + is_async = True + + def __init__(self, pos, **kw): + assert 'item' not in kw + from . import ExprNodes + # AwaitExprNodes must appear before running MarkClosureVisitor + kw['item'] = ExprNodes.AwaitIterNextExprNode(kw['iterator'].pos, arg=None) + _ForInStatNode.__init__(self, pos, **kw) + + def _create_item_node(self): + from . import ExprNodes + self.item.arg = ExprNodes.AsyncNextNode(self.iterator) + + +class ForFromStatNode(LoopNode, StatNode): + # for name from expr rel name rel expr + # + # target NameNode + # bound1 ExprNode + # relation1 string + # relation2 string + # bound2 ExprNode + # step ExprNode or None + # body StatNode + # else_clause StatNode or None + # + # Used internally: + # + # from_range bool + # is_py_target bool + # loopvar_node ExprNode (usually a NameNode or temp node) + # py_loopvar_node PyTempNode or None + child_attrs = ["target", "bound1", "bound2", "step", "body", "else_clause"] + + is_py_target = False + loopvar_node = None + py_loopvar_node = None + from_range = False + + gil_message = "For-loop using object bounds or target" + + def nogil_check(self, env): + for x in (self.target, self.bound1, self.bound2): + if x.type.is_pyobject: + self.gil_error() + + def analyse_declarations(self, env): + self.target.analyse_target_declaration(env) + self.body.analyse_declarations(env) + if self.else_clause: + self.else_clause.analyse_declarations(env) + + def analyse_expressions(self, env): + from . import ExprNodes + self.target = self.target.analyse_target_types(env) + self.bound1 = self.bound1.analyse_types(env) + self.bound2 = self.bound2.analyse_types(env) + if self.step is not None: + if isinstance(self.step, ExprNodes.UnaryMinusNode): + warning(self.step.pos, "Probable infinite loop in for-from-by statement. " + "Consider switching the directions of the relations.", 2) + self.step = self.step.analyse_types(env) + + self.set_up_loop(env) + target_type = self.target.type + if not (target_type.is_pyobject or target_type.is_numeric): + error(self.target.pos, "for-from loop variable must be c numeric type or Python object") + + self.body = self.body.analyse_expressions(env) + if self.else_clause: + self.else_clause = self.else_clause.analyse_expressions(env) + return self + + def set_up_loop(self, env): + from . import ExprNodes + + target_type = self.target.type + if target_type.is_numeric: + loop_type = target_type + else: + if target_type.is_enum: + warning(self.target.pos, + "Integer loops over enum values are fragile. Please cast to a safe integer type instead.") + loop_type = PyrexTypes.c_long_type if target_type.is_pyobject else PyrexTypes.c_int_type + if not self.bound1.type.is_pyobject: + loop_type = PyrexTypes.widest_numeric_type(loop_type, self.bound1.type) + if not self.bound2.type.is_pyobject: + loop_type = PyrexTypes.widest_numeric_type(loop_type, self.bound2.type) + if self.step is not None and not self.step.type.is_pyobject: + loop_type = PyrexTypes.widest_numeric_type(loop_type, self.step.type) + self.bound1 = self.bound1.coerce_to(loop_type, env) + self.bound2 = self.bound2.coerce_to(loop_type, env) + if not self.bound2.is_literal: + self.bound2 = self.bound2.coerce_to_temp(env) + if self.step is not None: + self.step = self.step.coerce_to(loop_type, env) + if not self.step.is_literal: + self.step = self.step.coerce_to_temp(env) + + if target_type.is_numeric or target_type.is_enum: + self.is_py_target = False + if isinstance(self.target, ExprNodes.BufferIndexNode): + raise error(self.pos, "Buffer or memoryview slicing/indexing not allowed as for-loop target.") + self.loopvar_node = self.target + self.py_loopvar_node = None + else: + self.is_py_target = True + c_loopvar_node = ExprNodes.TempNode(self.pos, loop_type, env) + self.loopvar_node = c_loopvar_node + self.py_loopvar_node = ExprNodes.CloneNode(c_loopvar_node).coerce_to_pyobject(env) + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + old_loop_labels = code.new_loop_labels() + from_range = self.from_range + self.bound1.generate_evaluation_code(code) + self.bound2.generate_evaluation_code(code) + offset, incop = self.relation_table[self.relation1] + if self.step is not None: + self.step.generate_evaluation_code(code) + step = self.step.result() + incop = "%s=%s" % (incop[0], step) # e.g. '++' => '+= STEP' + else: + step = '1' + + from . import ExprNodes + if isinstance(self.loopvar_node, ExprNodes.TempNode): + self.loopvar_node.allocate(code) + if isinstance(self.py_loopvar_node, ExprNodes.TempNode): + self.py_loopvar_node.allocate(code) + + loopvar_type = PyrexTypes.c_long_type if self.target.type.is_enum else self.target.type + + if from_range and not self.is_py_target: + loopvar_name = code.funcstate.allocate_temp(loopvar_type, False) + else: + loopvar_name = self.loopvar_node.result() + if loopvar_type.is_int and not loopvar_type.signed and self.relation2[0] == '>': + # Handle the case where the endpoint of an unsigned int iteration + # is within step of 0. + code.putln("for (%s = %s%s + %s; %s %s %s + %s; ) { %s%s;" % ( + loopvar_name, + self.bound1.result(), offset, step, + loopvar_name, self.relation2, self.bound2.result(), step, + loopvar_name, incop)) + else: + code.putln("for (%s = %s%s; %s %s %s; %s%s) {" % ( + loopvar_name, + self.bound1.result(), offset, + loopvar_name, self.relation2, self.bound2.result(), + loopvar_name, incop)) + + coerced_loopvar_node = self.py_loopvar_node + if coerced_loopvar_node is None and from_range: + coerced_loopvar_node = ExprNodes.RawCNameExprNode(self.target.pos, loopvar_type, loopvar_name) + if coerced_loopvar_node is not None: + coerced_loopvar_node.generate_evaluation_code(code) + self.target.generate_assignment_code(coerced_loopvar_node, code) + + self.body.generate_execution_code(code) + code.put_label(code.continue_label) + + if not from_range and self.py_loopvar_node: + # This mess is to make for..from loops with python targets behave + # exactly like those with C targets with regards to re-assignment + # of the loop variable. + if self.target.entry.is_pyglobal: + # We know target is a NameNode, this is the only ugly case. + target_node = ExprNodes.PyTempNode(self.target.pos, None) + target_node.allocate(code) + interned_cname = code.intern_identifier(self.target.entry.name) + if self.target.entry.scope.is_module_scope: + code.globalstate.use_utility_code( + UtilityCode.load_cached("GetModuleGlobalName", "ObjectHandling.c")) + lookup_func = '__Pyx_GetModuleGlobalName(%s, %s); %s' + else: + code.globalstate.use_utility_code( + UtilityCode.load_cached("GetNameInClass", "ObjectHandling.c")) + lookup_func = '__Pyx_GetNameInClass(%s, {}, %s); %s'.format( + self.target.entry.scope.namespace_cname) + code.putln(lookup_func % ( + target_node.result(), + interned_cname, + code.error_goto_if_null(target_node.result(), self.target.pos))) + code.put_gotref(target_node.result()) + else: + target_node = self.target + from_py_node = ExprNodes.CoerceFromPyTypeNode( + self.loopvar_node.type, target_node, self.target.entry.scope) + from_py_node.temp_code = loopvar_name + from_py_node.generate_result_code(code) + if self.target.entry.is_pyglobal: + code.put_decref(target_node.result(), target_node.type) + target_node.release(code) + + code.putln("}") + + if not from_range and self.py_loopvar_node: + # This is potentially wasteful, but we don't want the semantics to + # depend on whether or not the loop is a python type. + self.py_loopvar_node.generate_evaluation_code(code) + self.target.generate_assignment_code(self.py_loopvar_node, code) + if from_range and not self.is_py_target: + code.funcstate.release_temp(loopvar_name) + + break_label = code.break_label + code.set_loop_labels(old_loop_labels) + if self.else_clause: + code.putln("/*else*/ {") + self.else_clause.generate_execution_code(code) + code.putln("}") + code.put_label(break_label) + self.bound1.generate_disposal_code(code) + self.bound1.free_temps(code) + self.bound2.generate_disposal_code(code) + self.bound2.free_temps(code) + if isinstance(self.loopvar_node, ExprNodes.TempNode): + self.loopvar_node.release(code) + if isinstance(self.py_loopvar_node, ExprNodes.TempNode): + self.py_loopvar_node.release(code) + if self.step is not None: + self.step.generate_disposal_code(code) + self.step.free_temps(code) + + relation_table = { + # {relop : (initial offset, increment op)} + '<=': ("", "++"), + '<' : ("+1", "++"), + '>=': ("", "--"), + '>' : ("-1", "--"), + } + + def generate_function_definitions(self, env, code): + self.target.generate_function_definitions(env, code) + self.bound1.generate_function_definitions(env, code) + self.bound2.generate_function_definitions(env, code) + if self.step is not None: + self.step.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + if self.else_clause is not None: + self.else_clause.generate_function_definitions(env, code) + + def annotate(self, code): + self.target.annotate(code) + self.bound1.annotate(code) + self.bound2.annotate(code) + if self.step: + self.step.annotate(code) + self.body.annotate(code) + if self.else_clause: + self.else_clause.annotate(code) + + +class WithStatNode(StatNode): + """ + Represents a Python with statement. + + Implemented by the WithTransform as follows: + + MGR = EXPR + EXIT = MGR.__exit__ + VALUE = MGR.__enter__() + EXC = True + try: + try: + TARGET = VALUE # optional + BODY + except: + EXC = False + if not EXIT(*EXCINFO): + raise + finally: + if EXC: + EXIT(None, None, None) + MGR = EXIT = VALUE = None + """ + # manager The with statement manager object + # target ExprNode the target lhs of the __enter__() call + # body StatNode + # enter_call ExprNode the call to the __enter__() method + # exit_var String the cname of the __exit__() method reference + + child_attrs = ["manager", "enter_call", "target", "body"] + + enter_call = None + target_temp = None + + def analyse_declarations(self, env): + self.manager.analyse_declarations(env) + self.enter_call.analyse_declarations(env) + self.body.analyse_declarations(env) + + def analyse_expressions(self, env): + self.manager = self.manager.analyse_types(env) + self.enter_call = self.enter_call.analyse_types(env) + if self.target: + # set up target_temp before descending into body (which uses it) + from .ExprNodes import TempNode + self.target_temp = TempNode(self.enter_call.pos, self.enter_call.type) + self.body = self.body.analyse_expressions(env) + return self + + def generate_function_definitions(self, env, code): + self.manager.generate_function_definitions(env, code) + self.enter_call.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + code.putln("/*with:*/ {") + self.manager.generate_evaluation_code(code) + self.exit_var = code.funcstate.allocate_temp(py_object_type, manage_ref=False) + code.globalstate.use_utility_code( + UtilityCode.load_cached("PyObjectLookupSpecial", "ObjectHandling.c")) + code.putln("%s = __Pyx_PyObject_LookupSpecial(%s, %s); %s" % ( + self.exit_var, + self.manager.py_result(), + code.intern_identifier(EncodedString('__aexit__' if self.is_async else '__exit__')), + code.error_goto_if_null(self.exit_var, self.pos), + )) + code.put_gotref(self.exit_var) + + # need to free exit_var in the face of exceptions during setup + old_error_label = code.new_error_label() + intermediate_error_label = code.error_label + + self.enter_call.generate_evaluation_code(code) + if self.target: + # The temp result will be cleaned up by the WithTargetAssignmentStatNode + # after assigning its result to the target of the 'with' statement. + self.target_temp.allocate(code) + self.enter_call.make_owned_reference(code) + code.putln("%s = %s;" % (self.target_temp.result(), self.enter_call.result())) + self.enter_call.generate_post_assignment_code(code) + else: + self.enter_call.generate_disposal_code(code) + self.enter_call.free_temps(code) + + self.manager.generate_disposal_code(code) + self.manager.free_temps(code) + + code.error_label = old_error_label + self.body.generate_execution_code(code) + + if code.label_used(intermediate_error_label): + step_over_label = code.new_label() + code.put_goto(step_over_label) + code.put_label(intermediate_error_label) + code.put_decref_clear(self.exit_var, py_object_type) + code.put_goto(old_error_label) + code.put_label(step_over_label) + + code.funcstate.release_temp(self.exit_var) + code.putln('}') + + +class WithTargetAssignmentStatNode(AssignmentNode): + # The target assignment of the 'with' statement value (return + # value of the __enter__() call). + # + # This is a special cased assignment that properly cleans up the RHS. + # + # lhs ExprNode the assignment target + # rhs ExprNode a (coerced) TempNode for the rhs (from WithStatNode) + # with_node WithStatNode the surrounding with-statement + + child_attrs = ["rhs", "lhs"] + with_node = None + rhs = None + + def analyse_declarations(self, env): + self.lhs.analyse_target_declaration(env) + + def analyse_expressions(self, env): + self.lhs = self.lhs.analyse_target_types(env) + self.lhs.gil_assignment_check(env) + self.rhs = self.with_node.target_temp.coerce_to(self.lhs.type, env) + return self + + def generate_execution_code(self, code): + self.rhs.generate_evaluation_code(code) + self.lhs.generate_assignment_code(self.rhs, code) + self.with_node.target_temp.release(code) + + def annotate(self, code): + self.lhs.annotate(code) + self.rhs.annotate(code) + + +class TryExceptStatNode(StatNode): + # try .. except statement + # + # body StatNode + # except_clauses [ExceptClauseNode] + # else_clause StatNode or None + + child_attrs = ["body", "except_clauses", "else_clause"] + in_generator = False + + def analyse_declarations(self, env): + self.body.analyse_declarations(env) + for except_clause in self.except_clauses: + except_clause.analyse_declarations(env) + if self.else_clause: + self.else_clause.analyse_declarations(env) + + def analyse_expressions(self, env): + self.body = self.body.analyse_expressions(env) + default_clause_seen = 0 + for i, except_clause in enumerate(self.except_clauses): + except_clause = self.except_clauses[i] = except_clause.analyse_expressions(env) + if default_clause_seen: + error(except_clause.pos, "default 'except:' must be last") + if not except_clause.pattern: + default_clause_seen = 1 + self.has_default_clause = default_clause_seen + if self.else_clause: + self.else_clause = self.else_clause.analyse_expressions(env) + return self + + nogil_check = Node.gil_error + gil_message = "Try-except statement" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) # before changing the error label, in case of tracing errors + code.putln("{") + + old_return_label = code.return_label + old_break_label = code.break_label + old_continue_label = code.continue_label + old_error_label = code.new_error_label() + our_error_label = code.error_label + except_end_label = code.new_label('exception_handled') + except_error_label = code.new_label('except_error') + except_return_label = code.new_label('except_return') + try_return_label = code.new_label('try_return') + try_break_label = code.new_label('try_break') if old_break_label else None + try_continue_label = code.new_label('try_continue') if old_continue_label else None + try_end_label = code.new_label('try_end') + + exc_save_vars = [code.funcstate.allocate_temp(py_object_type, False) + for _ in range(3)] + save_exc = code.insertion_point() + code.putln( + "/*try:*/ {") + code.return_label = try_return_label + code.break_label = try_break_label + code.continue_label = try_continue_label + self.body.generate_execution_code(code) + code.mark_pos(self.pos, trace=False) + code.putln( + "}") + temps_to_clean_up = code.funcstate.all_free_managed_temps() + can_raise = code.label_used(our_error_label) + + if can_raise: + # inject code before the try block to save away the exception state + code.globalstate.use_utility_code(reset_exception_utility_code) + if not self.in_generator: + save_exc.putln("__Pyx_PyThreadState_declare") + save_exc.putln("__Pyx_PyThreadState_assign") + save_exc.putln("__Pyx_ExceptionSave(%s);" % ( + ', '.join(['&%s' % var for var in exc_save_vars]))) + for var in exc_save_vars: + save_exc.put_xgotref(var) + + def restore_saved_exception(): + for name in exc_save_vars: + code.put_xgiveref(name) + code.putln("__Pyx_ExceptionReset(%s);" % + ', '.join(exc_save_vars)) + else: + # try block cannot raise exceptions, but we had to allocate the temps above, + # so just keep the C compiler from complaining about them being unused + mark_vars_used = ["(void)%s;" % var for var in exc_save_vars] + save_exc.putln("%s /* mark used */" % ' '.join(mark_vars_used)) + + def restore_saved_exception(): + pass + + code.error_label = except_error_label + code.return_label = except_return_label + normal_case_terminates = self.body.is_terminator + if self.else_clause: + code.mark_pos(self.else_clause.pos) + code.putln( + "/*else:*/ {") + self.else_clause.generate_execution_code(code) + code.putln( + "}") + if not normal_case_terminates: + normal_case_terminates = self.else_clause.is_terminator + + if can_raise: + if not normal_case_terminates: + for var in exc_save_vars: + code.put_xdecref_clear(var, py_object_type) + code.put_goto(try_end_label) + code.put_label(our_error_label) + for temp_name, temp_type in temps_to_clean_up: + code.put_xdecref_clear(temp_name, temp_type) + + outer_except = code.funcstate.current_except + # Currently points to self, but the ExceptClauseNode would also be ok. Change if needed. + code.funcstate.current_except = self + for except_clause in self.except_clauses: + except_clause.generate_handling_code(code, except_end_label) + code.funcstate.current_except = outer_except + + if not self.has_default_clause: + code.put_goto(except_error_label) + + for exit_label, old_label in [(except_error_label, old_error_label), + (try_break_label, old_break_label), + (try_continue_label, old_continue_label), + (try_return_label, old_return_label), + (except_return_label, old_return_label)]: + if code.label_used(exit_label): + if not normal_case_terminates and not code.label_used(try_end_label): + code.put_goto(try_end_label) + code.put_label(exit_label) + code.mark_pos(self.pos, trace=False) + if can_raise: + restore_saved_exception() + code.put_goto(old_label) + + if code.label_used(except_end_label): + if not normal_case_terminates and not code.label_used(try_end_label): + code.put_goto(try_end_label) + code.put_label(except_end_label) + if can_raise: + restore_saved_exception() + if code.label_used(try_end_label): + code.put_label(try_end_label) + code.putln("}") + + for cname in exc_save_vars: + code.funcstate.release_temp(cname) + + code.return_label = old_return_label + code.break_label = old_break_label + code.continue_label = old_continue_label + code.error_label = old_error_label + + def generate_function_definitions(self, env, code): + self.body.generate_function_definitions(env, code) + for except_clause in self.except_clauses: + except_clause.generate_function_definitions(env, code) + if self.else_clause is not None: + self.else_clause.generate_function_definitions(env, code) + + def annotate(self, code): + self.body.annotate(code) + for except_node in self.except_clauses: + except_node.annotate(code) + if self.else_clause: + self.else_clause.annotate(code) + + +class ExceptClauseNode(Node): + # Part of try ... except statement. + # + # pattern [ExprNode] + # target ExprNode or None + # body StatNode + # excinfo_target TupleNode(3*ResultRefNode) or None optional target for exception info (not owned here!) + # match_flag string result of exception match + # exc_value ExcValueNode used internally + # function_name string qualified name of enclosing function + # exc_vars (string * 3) local exception variables + # is_except_as bool Py3-style "except ... as xyz" + + # excinfo_target is never set by the parser, but can be set by a transform + # in order to extract more extensive information about the exception as a + # sys.exc_info()-style tuple into a target variable + + child_attrs = ["pattern", "target", "body", "exc_value"] + + exc_value = None + excinfo_target = None + is_except_as = False + + def analyse_declarations(self, env): + if self.target: + self.target.analyse_target_declaration(env) + self.body.analyse_declarations(env) + + def analyse_expressions(self, env): + self.function_name = env.qualified_name + if self.pattern: + # normalise/unpack self.pattern into a list + for i, pattern in enumerate(self.pattern): + pattern = pattern.analyse_expressions(env) + self.pattern[i] = pattern.coerce_to_pyobject(env) + + if self.target: + from . import ExprNodes + self.exc_value = ExprNodes.ExcValueNode(self.pos) + self.target = self.target.analyse_target_expression(env, self.exc_value) + + self.body = self.body.analyse_expressions(env) + return self + + def generate_handling_code(self, code, end_label): + code.mark_pos(self.pos) + + if self.pattern: + has_non_literals = not all( + pattern.is_literal or pattern.is_simple() and not pattern.is_temp + for pattern in self.pattern) + + if has_non_literals: + # For non-trivial exception check expressions, hide the live exception from C-API calls. + exc_vars = [code.funcstate.allocate_temp(py_object_type, manage_ref=True) + for _ in range(3)] + code.globalstate.use_utility_code(UtilityCode.load_cached("PyErrFetchRestore", "Exceptions.c")) + code.putln("__Pyx_ErrFetch(&%s, &%s, &%s);" % tuple(exc_vars)) + code.globalstate.use_utility_code(UtilityCode.load_cached("FastTypeChecks", "ModuleSetupCode.c")) + exc_test_func = "__Pyx_PyErr_GivenExceptionMatches(%s, %%s)" % exc_vars[0] + else: + exc_vars = () + code.globalstate.use_utility_code(UtilityCode.load_cached("PyErrExceptionMatches", "Exceptions.c")) + exc_test_func = "__Pyx_PyErr_ExceptionMatches(%s)" + + exc_tests = [] + for pattern in self.pattern: + pattern.generate_evaluation_code(code) + exc_tests.append(exc_test_func % pattern.py_result()) + + match_flag = code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) + code.putln("%s = %s;" % (match_flag, ' || '.join(exc_tests))) + for pattern in self.pattern: + pattern.generate_disposal_code(code) + pattern.free_temps(code) + + if has_non_literals: + code.putln("__Pyx_ErrRestore(%s, %s, %s);" % tuple(exc_vars)) + code.putln(' '.join(["%s = 0;" % var for var in exc_vars])) + for temp in exc_vars: + code.funcstate.release_temp(temp) + + code.putln( + "if (%s) {" % + match_flag) + code.funcstate.release_temp(match_flag) + else: + code.putln("/*except:*/ {") + + if (not getattr(self.body, 'stats', True) + and self.excinfo_target is None + and self.target is None): + # most simple case: no exception variable, empty body (pass) + # => reset the exception state, done + code.globalstate.use_utility_code(UtilityCode.load_cached("PyErrFetchRestore", "Exceptions.c")) + code.putln("__Pyx_ErrRestore(0,0,0);") + code.put_goto(end_label) + code.putln("}") + return + + exc_vars = [code.funcstate.allocate_temp(py_object_type, manage_ref=True) + for _ in range(3)] + code.put_add_traceback(self.function_name) + # We always have to fetch the exception value even if + # there is no target, because this also normalises the + # exception and stores it in the thread state. + code.globalstate.use_utility_code(get_exception_utility_code) + exc_args = "&%s, &%s, &%s" % tuple(exc_vars) + code.putln("if (__Pyx_GetException(%s) < 0) %s" % ( + exc_args, code.error_goto(self.pos))) + for var in exc_vars: + code.put_gotref(var) + if self.target: + self.exc_value.set_var(exc_vars[1]) + self.exc_value.generate_evaluation_code(code) + self.target.generate_assignment_code(self.exc_value, code) + if self.excinfo_target is not None: + for tempvar, node in zip(exc_vars, self.excinfo_target.args): + node.set_var(tempvar) + + old_break_label, old_continue_label = code.break_label, code.continue_label + code.break_label = code.new_label('except_break') + code.continue_label = code.new_label('except_continue') + + old_exc_vars = code.funcstate.exc_vars + code.funcstate.exc_vars = exc_vars + self.body.generate_execution_code(code) + code.funcstate.exc_vars = old_exc_vars + + if not self.body.is_terminator: + for var in exc_vars: + # FIXME: XDECREF() is needed to allow re-raising (which clears the exc_vars), + # but I don't think it's the right solution. + code.put_xdecref_clear(var, py_object_type) + code.put_goto(end_label) + + for new_label, old_label in [(code.break_label, old_break_label), + (code.continue_label, old_continue_label)]: + if code.label_used(new_label): + code.put_label(new_label) + for var in exc_vars: + code.put_decref_clear(var, py_object_type) + code.put_goto(old_label) + code.break_label = old_break_label + code.continue_label = old_continue_label + + for temp in exc_vars: + code.funcstate.release_temp(temp) + + code.putln( + "}") + + def generate_function_definitions(self, env, code): + if self.target is not None: + self.target.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + + def annotate(self, code): + if self.pattern: + for pattern in self.pattern: + pattern.annotate(code) + if self.target: + self.target.annotate(code) + self.body.annotate(code) + + +class TryFinallyStatNode(StatNode): + # try ... finally statement + # + # body StatNode + # finally_clause StatNode + # finally_except_clause deep-copy of finally_clause for exception case + # in_generator inside of generator => must store away current exception also in return case + # + # Each of the continue, break, return and error gotos runs + # into its own deep-copy of the finally block code. + # In addition, if we're doing an error, we save the + # exception on entry to the finally block and restore + # it on exit. + + child_attrs = ["body", "finally_clause", "finally_except_clause"] + + preserve_exception = 1 + + # handle exception case, in addition to return/break/continue + handle_error_case = True + func_return_type = None + finally_except_clause = None + + is_try_finally_in_nogil = False + in_generator = False + + @staticmethod + def create_analysed(pos, env, body, finally_clause): + node = TryFinallyStatNode(pos, body=body, finally_clause=finally_clause) + return node + + def analyse_declarations(self, env): + self.body.analyse_declarations(env) + self.finally_except_clause = copy.deepcopy(self.finally_clause) + self.finally_except_clause.analyse_declarations(env) + self.finally_clause.analyse_declarations(env) + + def analyse_expressions(self, env): + self.body = self.body.analyse_expressions(env) + self.finally_clause = self.finally_clause.analyse_expressions(env) + self.finally_except_clause = self.finally_except_clause.analyse_expressions(env) + if env.return_type and not env.return_type.is_void: + self.func_return_type = env.return_type + return self + + nogil_check = Node.gil_error + gil_message = "Try-finally statement" + + def generate_execution_code(self, code): + code.mark_pos(self.pos) # before changing the error label, in case of tracing errors + code.putln("/*try:*/ {") + + old_error_label = code.error_label + old_labels = code.all_new_labels() + new_labels = code.get_all_labels() + new_error_label = code.error_label + if not self.handle_error_case: + code.error_label = old_error_label + catch_label = code.new_label() + + was_in_try_finally = code.funcstate.in_try_finally + code.funcstate.in_try_finally = 1 + + self.body.generate_execution_code(code) + + code.funcstate.in_try_finally = was_in_try_finally + code.putln("}") + + temps_to_clean_up = code.funcstate.all_free_managed_temps() + code.mark_pos(self.finally_clause.pos) + code.putln("/*finally:*/ {") + + # Reset labels only after writing out a potential line trace call for correct nogil error handling. + code.set_all_labels(old_labels) + + def fresh_finally_clause(_next=[self.finally_clause]): + # generate the original subtree once and always keep a fresh copy + node = _next[0] + node_copy = copy.deepcopy(node) + if node is self.finally_clause: + _next[0] = node_copy + else: + node = node_copy + return node + + preserve_error = self.preserve_exception and code.label_used(new_error_label) + needs_success_cleanup = not self.finally_clause.is_terminator + + if not self.body.is_terminator: + code.putln('/*normal exit:*/{') + fresh_finally_clause().generate_execution_code(code) + if not self.finally_clause.is_terminator: + code.put_goto(catch_label) + code.putln('}') + + if preserve_error: + code.put_label(new_error_label) + code.putln('/*exception exit:*/{') + if not self.in_generator: + code.putln("__Pyx_PyThreadState_declare") + if self.is_try_finally_in_nogil: + code.declare_gilstate() + if needs_success_cleanup: + exc_lineno_cnames = tuple([ + code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) + for _ in range(2)]) + exc_filename_cname = code.funcstate.allocate_temp( + PyrexTypes.CPtrType(PyrexTypes.c_const_type(PyrexTypes.c_char_type)), + manage_ref=False) + else: + exc_lineno_cnames = exc_filename_cname = None + exc_vars = tuple([ + code.funcstate.allocate_temp(py_object_type, manage_ref=False) + for _ in range(6)]) + self.put_error_catcher( + code, temps_to_clean_up, exc_vars, exc_lineno_cnames, exc_filename_cname) + finally_old_labels = code.all_new_labels() + + code.putln('{') + old_exc_vars = code.funcstate.exc_vars + code.funcstate.exc_vars = exc_vars[:3] + self.finally_except_clause.generate_execution_code(code) + code.funcstate.exc_vars = old_exc_vars + code.putln('}') + + if needs_success_cleanup: + self.put_error_uncatcher(code, exc_vars, exc_lineno_cnames, exc_filename_cname) + if exc_lineno_cnames: + for cname in exc_lineno_cnames: + code.funcstate.release_temp(cname) + if exc_filename_cname: + code.funcstate.release_temp(exc_filename_cname) + code.put_goto(old_error_label) + + for new_label, old_label in zip(code.get_all_labels(), finally_old_labels): + if not code.label_used(new_label): + continue + code.put_label(new_label) + self.put_error_cleaner(code, exc_vars) + code.put_goto(old_label) + + for cname in exc_vars: + code.funcstate.release_temp(cname) + code.putln('}') + + code.set_all_labels(old_labels) + return_label = code.return_label + exc_vars = () + + for i, (new_label, old_label) in enumerate(zip(new_labels, old_labels)): + if not code.label_used(new_label): + continue + if new_label == new_error_label and preserve_error: + continue # handled above + + code.putln('%s: {' % new_label) + ret_temp = None + if old_label == return_label: + # return actually raises an (uncatchable) exception in generators that we must preserve + if self.in_generator: + exc_vars = tuple([ + code.funcstate.allocate_temp(py_object_type, manage_ref=False) + for _ in range(6)]) + self.put_error_catcher(code, [], exc_vars) + if not self.finally_clause.is_terminator: + # store away return value for later reuse + if (self.func_return_type and + not self.is_try_finally_in_nogil and + not isinstance(self.finally_clause, GILExitNode)): + ret_temp = code.funcstate.allocate_temp( + self.func_return_type, manage_ref=False) + code.putln("%s = %s;" % (ret_temp, Naming.retval_cname)) + if self.func_return_type.is_pyobject: + code.putln("%s = 0;" % Naming.retval_cname) + + fresh_finally_clause().generate_execution_code(code) + + if old_label == return_label: + if ret_temp: + code.putln("%s = %s;" % (Naming.retval_cname, ret_temp)) + if self.func_return_type.is_pyobject: + code.putln("%s = 0;" % ret_temp) + code.funcstate.release_temp(ret_temp) + if self.in_generator: + self.put_error_uncatcher(code, exc_vars) + for cname in exc_vars: + code.funcstate.release_temp(cname) + + if not self.finally_clause.is_terminator: + code.put_goto(old_label) + code.putln('}') + + # End finally + code.put_label(catch_label) + code.putln( + "}") + + def generate_function_definitions(self, env, code): + self.body.generate_function_definitions(env, code) + self.finally_clause.generate_function_definitions(env, code) + if self.finally_except_clause: + self.finally_except_clause.generate_function_definitions(env, code) + + def put_error_catcher(self, code, temps_to_clean_up, exc_vars, + exc_lineno_cnames=None, exc_filename_cname=None): + code.globalstate.use_utility_code(restore_exception_utility_code) + code.globalstate.use_utility_code(get_exception_utility_code) + code.globalstate.use_utility_code(swap_exception_utility_code) + + if self.is_try_finally_in_nogil: + code.put_ensure_gil(declare_gilstate=False) + code.putln("__Pyx_PyThreadState_assign") + + code.putln(' '.join(["%s = 0;" % var for var in exc_vars])) + for temp_name, type in temps_to_clean_up: + code.put_xdecref_clear(temp_name, type) + + # not using preprocessor here to avoid warnings about + # unused utility functions and/or temps + code.putln("if (PY_MAJOR_VERSION >= 3)" + " __Pyx_ExceptionSwap(&%s, &%s, &%s);" % exc_vars[3:]) + code.putln("if ((PY_MAJOR_VERSION < 3) ||" + # if __Pyx_GetException() fails in Py3, + # store the newly raised exception instead + " unlikely(__Pyx_GetException(&%s, &%s, &%s) < 0)) " + "__Pyx_ErrFetch(&%s, &%s, &%s);" % (exc_vars[:3] * 2)) + for var in exc_vars: + code.put_xgotref(var) + if exc_lineno_cnames: + code.putln("%s = %s; %s = %s; %s = %s;" % ( + exc_lineno_cnames[0], Naming.lineno_cname, + exc_lineno_cnames[1], Naming.clineno_cname, + exc_filename_cname, Naming.filename_cname)) + + if self.is_try_finally_in_nogil: + code.put_release_ensured_gil() + + def put_error_uncatcher(self, code, exc_vars, exc_lineno_cnames=None, exc_filename_cname=None): + code.globalstate.use_utility_code(restore_exception_utility_code) + code.globalstate.use_utility_code(reset_exception_utility_code) + + if self.is_try_finally_in_nogil: + code.put_ensure_gil(declare_gilstate=False) + + # not using preprocessor here to avoid warnings about + # unused utility functions and/or temps + code.putln("if (PY_MAJOR_VERSION >= 3) {") + for var in exc_vars[3:]: + code.put_xgiveref(var) + code.putln("__Pyx_ExceptionReset(%s, %s, %s);" % exc_vars[3:]) + code.putln("}") + for var in exc_vars[:3]: + code.put_xgiveref(var) + code.putln("__Pyx_ErrRestore(%s, %s, %s);" % exc_vars[:3]) + + if self.is_try_finally_in_nogil: + code.put_release_ensured_gil() + + code.putln(' '.join(["%s = 0;" % var for var in exc_vars])) + if exc_lineno_cnames: + code.putln("%s = %s; %s = %s; %s = %s;" % ( + Naming.lineno_cname, exc_lineno_cnames[0], + Naming.clineno_cname, exc_lineno_cnames[1], + Naming.filename_cname, exc_filename_cname)) + + def put_error_cleaner(self, code, exc_vars): + code.globalstate.use_utility_code(reset_exception_utility_code) + if self.is_try_finally_in_nogil: + code.put_ensure_gil(declare_gilstate=False) + + # not using preprocessor here to avoid warnings about + # unused utility functions and/or temps + code.putln("if (PY_MAJOR_VERSION >= 3) {") + for var in exc_vars[3:]: + code.put_xgiveref(var) + code.putln("__Pyx_ExceptionReset(%s, %s, %s);" % exc_vars[3:]) + code.putln("}") + for var in exc_vars[:3]: + code.put_xdecref_clear(var, py_object_type) + if self.is_try_finally_in_nogil: + code.put_release_ensured_gil() + code.putln(' '.join(["%s = 0;"]*3) % exc_vars[3:]) + + def annotate(self, code): + self.body.annotate(code) + self.finally_clause.annotate(code) + + +class NogilTryFinallyStatNode(TryFinallyStatNode): + """ + A try/finally statement that may be used in nogil code sections. + """ + + preserve_exception = False + nogil_check = None + + +class GILStatNode(NogilTryFinallyStatNode): + # 'with gil' or 'with nogil' statement + # + # state string 'gil' or 'nogil' + + state_temp = None + + def __init__(self, pos, state, body): + self.state = state + self.create_state_temp_if_needed(pos, state, body) + TryFinallyStatNode.__init__( + self, pos, + body=body, + finally_clause=GILExitNode( + pos, state=state, state_temp=self.state_temp)) + + def create_state_temp_if_needed(self, pos, state, body): + from .ParseTreeTransforms import YieldNodeCollector + collector = YieldNodeCollector() + collector.visitchildren(body) + if not collector.yields: + return + + if state == 'gil': + temp_type = PyrexTypes.c_gilstate_type + else: + temp_type = PyrexTypes.c_threadstate_ptr_type + from . import ExprNodes + self.state_temp = ExprNodes.TempNode(pos, temp_type) + + def analyse_declarations(self, env): + env._in_with_gil_block = (self.state == 'gil') + if self.state == 'gil': + env.has_with_gil_block = True + + return super(GILStatNode, self).analyse_declarations(env) + + def analyse_expressions(self, env): + env.use_utility_code( + UtilityCode.load_cached("ForceInitThreads", "ModuleSetupCode.c")) + was_nogil = env.nogil + env.nogil = self.state == 'nogil' + node = TryFinallyStatNode.analyse_expressions(self, env) + env.nogil = was_nogil + return node + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + code.begin_block() + if self.state_temp: + self.state_temp.allocate(code) + variable = self.state_temp.result() + else: + variable = None + + old_gil_config = code.funcstate.gil_owned + if self.state == 'gil': + code.put_ensure_gil(variable=variable) + code.funcstate.gil_owned = True + else: + code.put_release_gil(variable=variable) + code.funcstate.gil_owned = False + + TryFinallyStatNode.generate_execution_code(self, code) + + if self.state_temp: + self.state_temp.release(code) + + code.funcstate.gil_owned = old_gil_config + code.end_block() + + +class GILExitNode(StatNode): + """ + Used as the 'finally' block in a GILStatNode + + state string 'gil' or 'nogil' + """ + + child_attrs = [] + state_temp = None + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + if self.state_temp: + variable = self.state_temp.result() + else: + variable = None + + if self.state == 'gil': + code.put_release_ensured_gil(variable) + else: + code.put_acquire_gil(variable) + + +class EnsureGILNode(GILExitNode): + """ + Ensure the GIL in nogil functions for cleanup before returning. + """ + + def generate_execution_code(self, code): + code.put_ensure_gil(declare_gilstate=False) + + +def cython_view_utility_code(): + from . import MemoryView + return MemoryView.view_utility_code + + +utility_code_for_cimports = { + # utility code (or inlining c) in a pxd (or pyx) file. + # TODO: Consider a generic user-level mechanism for importing + 'cpython.array' : lambda : UtilityCode.load_cached("ArrayAPI", "arrayarray.h"), + 'cpython.array.array' : lambda : UtilityCode.load_cached("ArrayAPI", "arrayarray.h"), + 'cython.view' : cython_view_utility_code, +} + +utility_code_for_imports = { + # utility code used when special modules are imported. + # TODO: Consider a generic user-level mechanism for importing + 'asyncio': ("__Pyx_patch_asyncio", "PatchAsyncIO", "Coroutine.c"), + 'inspect': ("__Pyx_patch_inspect", "PatchInspect", "Coroutine.c"), +} + + +class CImportStatNode(StatNode): + # cimport statement + # + # module_name string Qualified name of module being imported + # as_name string or None Name specified in "as" clause, if any + # is_absolute bool True for absolute imports, False otherwise + + child_attrs = [] + is_absolute = False + + def analyse_declarations(self, env): + if not env.is_module_scope: + error(self.pos, "cimport only allowed at module level") + return + module_scope = env.find_module( + self.module_name, self.pos, relative_level=0 if self.is_absolute else -1) + if "." in self.module_name: + names = [EncodedString(name) for name in self.module_name.split(".")] + top_name = names[0] + top_module_scope = env.context.find_submodule(top_name) + module_scope = top_module_scope + for name in names[1:]: + submodule_scope = module_scope.find_submodule(name) + module_scope.declare_module(name, submodule_scope, self.pos) + module_scope = submodule_scope + if self.as_name: + env.declare_module(self.as_name, module_scope, self.pos) + else: + env.add_imported_module(module_scope) + env.declare_module(top_name, top_module_scope, self.pos) + else: + name = self.as_name or self.module_name + env.declare_module(name, module_scope, self.pos) + if self.module_name in utility_code_for_cimports: + env.use_utility_code(utility_code_for_cimports[self.module_name]()) + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + +class FromCImportStatNode(StatNode): + # from ... cimport statement + # + # module_name string Qualified name of module + # relative_level int or None Relative import: number of dots before module_name + # imported_names [(pos, name, as_name, kind)] Names to be imported + + child_attrs = [] + module_name = None + relative_level = None + imported_names = None + + def analyse_declarations(self, env): + if not env.is_module_scope: + error(self.pos, "cimport only allowed at module level") + return + if self.relative_level and self.relative_level > env.qualified_name.count('.'): + error(self.pos, "relative cimport beyond main package is not allowed") + return + module_scope = env.find_module(self.module_name, self.pos, relative_level=self.relative_level, need_pxd=0) + module_name = module_scope.qualified_name + env.add_imported_module(module_scope) + for pos, name, as_name, kind in self.imported_names: + if name == "*": + for local_name, entry in list(module_scope.entries.items()): + env.add_imported_entry(local_name, entry, pos) + else: + entry = module_scope.lookup(name) + if entry: + if kind and not self.declaration_matches(entry, kind): + entry.redeclared(pos) + entry.used = 1 + else: + if kind == 'struct' or kind == 'union': + entry = module_scope.declare_struct_or_union( + name, kind=kind, scope=None, typedef_flag=0, pos=pos) + elif kind == 'class': + entry = module_scope.declare_c_class(name, pos=pos, module_name=module_name) + else: + submodule_scope = env.context.find_module( + name, relative_to=module_scope, pos=self.pos, absolute_fallback=False) + if submodule_scope.parent_module is module_scope: + env.declare_module(as_name or name, submodule_scope, self.pos) + else: + error(pos, "Name '%s' not declared in module '%s'" % (name, module_name)) + + if entry: + local_name = as_name or name + env.add_imported_entry(local_name, entry, pos) + + if module_name.startswith('cpython') or module_name.startswith('cython'): # enough for now + if module_name in utility_code_for_cimports: + env.use_utility_code(utility_code_for_cimports[module_name]()) + for _, name, _, _ in self.imported_names: + fqname = '%s.%s' % (module_name, name) + if fqname in utility_code_for_cimports: + env.use_utility_code(utility_code_for_cimports[fqname]()) + + def declaration_matches(self, entry, kind): + if not entry.is_type: + return 0 + type = entry.type + if kind == 'class': + if not type.is_extension_type: + return 0 + else: + if not type.is_struct_or_union: + return 0 + if kind != type.kind: + return 0 + return 1 + + def analyse_expressions(self, env): + return self + + def generate_execution_code(self, code): + pass + + +class FromImportStatNode(StatNode): + # from ... import statement + # + # module ImportNode + # items [(string, NameNode)] + # interned_items [(string, NameNode, ExprNode)] + # item PyTempNode used internally + # import_star boolean used internally + + child_attrs = ["module"] + import_star = 0 + + def analyse_declarations(self, env): + for name, target in self.items: + if name == "*": + if not env.is_module_scope: + error(self.pos, "import * only allowed at module level") + return + env.has_import_star = 1 + self.import_star = 1 + else: + target.analyse_target_declaration(env) + + def analyse_expressions(self, env): + from . import ExprNodes + self.module = self.module.analyse_expressions(env) + self.item = ExprNodes.RawCNameExprNode(self.pos, py_object_type) + self.interned_items = [] + for name, target in self.items: + if name == '*': + for _, entry in env.entries.items(): + if not entry.is_type and entry.type.is_extension_type: + env.use_utility_code(UtilityCode.load_cached("ExtTypeTest", "ObjectHandling.c")) + break + else: + entry = env.lookup(target.name) + # check whether or not entry is already cimported + if (entry.is_type and entry.type.name == name + and hasattr(entry.type, 'module_name')): + if entry.type.module_name == self.module.module_name.value: + # cimported with absolute name + continue + try: + # cimported with relative name + module = env.find_module(self.module.module_name.value, pos=self.pos, + relative_level=self.module.level) + if entry.type.module_name == module.qualified_name: + continue + except AttributeError: + pass + target = target.analyse_target_expression(env, None) # FIXME? + if target.type is py_object_type: + coerced_item = None + else: + coerced_item = self.item.coerce_to(target.type, env) + self.interned_items.append((name, target, coerced_item)) + return self + + def generate_execution_code(self, code): + code.mark_pos(self.pos) + self.module.generate_evaluation_code(code) + if self.import_star: + code.putln( + 'if (%s(%s) < 0) %s;' % ( + Naming.import_star, + self.module.py_result(), + code.error_goto(self.pos))) + item_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + self.item.set_cname(item_temp) + if self.interned_items: + code.globalstate.use_utility_code( + UtilityCode.load_cached("ImportFrom", "ImportExport.c")) + for name, target, coerced_item in self.interned_items: + code.putln( + '%s = __Pyx_ImportFrom(%s, %s); %s' % ( + item_temp, + self.module.py_result(), + code.intern_identifier(name), + code.error_goto_if_null(item_temp, self.pos))) + code.put_gotref(item_temp) + if coerced_item is None: + target.generate_assignment_code(self.item, code) + else: + coerced_item.allocate_temp_result(code) + coerced_item.generate_result_code(code) + target.generate_assignment_code(coerced_item, code) + code.put_decref_clear(item_temp, py_object_type) + code.funcstate.release_temp(item_temp) + self.module.generate_disposal_code(code) + self.module.free_temps(code) + + +class ParallelNode(Node): + """ + Base class for cython.parallel constructs. + """ + + nogil_check = None + + +class ParallelStatNode(StatNode, ParallelNode): + """ + Base class for 'with cython.parallel.parallel():' and 'for i in prange():'. + + assignments { Entry(var) : (var.pos, inplace_operator_or_None) } + assignments to variables in this parallel section + + parent parent ParallelStatNode or None + is_parallel indicates whether this node is OpenMP parallel + (true for #pragma omp parallel for and + #pragma omp parallel) + + is_parallel is true for: + + #pragma omp parallel + #pragma omp parallel for + + sections, but NOT for + + #pragma omp for + + We need this to determine the sharing attributes. + + privatization_insertion_point a code insertion point used to make temps + private (esp. the "nsteps" temp) + + args tuple the arguments passed to the parallel construct + kwargs DictNode the keyword arguments passed to the parallel + construct (replaced by its compile time value) + """ + + child_attrs = ['body', 'num_threads'] + + body = None + + is_prange = False + is_nested_prange = False + + error_label_used = False + + num_threads = None + chunksize = None + + parallel_exc = ( + Naming.parallel_exc_type, + Naming.parallel_exc_value, + Naming.parallel_exc_tb, + ) + + parallel_pos_info = ( + Naming.parallel_filename, + Naming.parallel_lineno, + Naming.parallel_clineno, + ) + + pos_info = ( + Naming.filename_cname, + Naming.lineno_cname, + Naming.clineno_cname, + ) + + critical_section_counter = 0 + + def __init__(self, pos, **kwargs): + super(ParallelStatNode, self).__init__(pos, **kwargs) + + # All assignments in this scope + self.assignments = kwargs.get('assignments') or {} + + # All seen closure cnames and their temporary cnames + self.seen_closure_vars = set() + + # Dict of variables that should be declared (first|last|)private or + # reduction { Entry: (op, lastprivate) }. + # If op is not None, it's a reduction. + self.privates = {} + + # [NameNode] + self.assigned_nodes = [] + + def analyse_declarations(self, env): + self.body.analyse_declarations(env) + + self.num_threads = None + + if self.kwargs: + # Try to find num_threads and chunksize keyword arguments + pairs = [] + seen = set() + for dictitem in self.kwargs.key_value_pairs: + if dictitem.key.value in seen: + error(self.pos, "Duplicate keyword argument found: %s" % dictitem.key.value) + seen.add(dictitem.key.value) + if dictitem.key.value == 'num_threads': + if not dictitem.value.is_none: + self.num_threads = dictitem.value + elif self.is_prange and dictitem.key.value == 'chunksize': + if not dictitem.value.is_none: + self.chunksize = dictitem.value + else: + pairs.append(dictitem) + + self.kwargs.key_value_pairs = pairs + + try: + self.kwargs = self.kwargs.compile_time_value(env) + except Exception as e: + error(self.kwargs.pos, "Only compile-time values may be " + "supplied as keyword arguments") + else: + self.kwargs = {} + + for kw, val in self.kwargs.items(): + if kw not in self.valid_keyword_arguments: + error(self.pos, "Invalid keyword argument: %s" % kw) + else: + setattr(self, kw, val) + + def analyse_expressions(self, env): + if self.num_threads: + self.num_threads = self.num_threads.analyse_expressions(env) + + if self.chunksize: + self.chunksize = self.chunksize.analyse_expressions(env) + + self.body = self.body.analyse_expressions(env) + self.analyse_sharing_attributes(env) + + if self.num_threads is not None: + if self.parent and self.parent.num_threads is not None and not self.parent.is_prange: + error(self.pos, "num_threads already declared in outer section") + elif self.parent and not self.parent.is_prange: + error(self.pos, "num_threads must be declared in the parent parallel section") + elif (self.num_threads.type.is_int and + self.num_threads.is_literal and + self.num_threads.compile_time_value(env) <= 0): + error(self.pos, "argument to num_threads must be greater than 0") + + if not self.num_threads.is_simple() or self.num_threads.type.is_pyobject: + self.num_threads = self.num_threads.coerce_to( + PyrexTypes.c_int_type, env).coerce_to_temp(env) + return self + + def analyse_sharing_attributes(self, env): + """ + Analyse the privates for this block and set them in self.privates. + This should be called in a post-order fashion during the + analyse_expressions phase + """ + for entry, (pos, op) in self.assignments.items(): + + if self.is_prange and not self.is_parallel: + # closely nested prange in a with parallel block, disallow + # assigning to privates in the with parallel block (we + # consider it too implicit and magicky for users) + if entry in self.parent.assignments: + error(pos, "Cannot assign to private of outer parallel block") + continue + + if not self.is_prange and op: + # Again possible, but considered to magicky + error(pos, "Reductions not allowed for parallel blocks") + continue + + # By default all variables should have the same values as if + # executed sequentially + lastprivate = True + self.propagate_var_privatization(entry, pos, op, lastprivate) + + def propagate_var_privatization(self, entry, pos, op, lastprivate): + """ + Propagate the sharing attributes of a variable. If the privatization is + determined by a parent scope, done propagate further. + + If we are a prange, we propagate our sharing attributes outwards to + other pranges. If we are a prange in parallel block and the parallel + block does not determine the variable private, we propagate to the + parent of the parent. Recursion stops at parallel blocks, as they have + no concept of lastprivate or reduction. + + So the following cases propagate: + + sum is a reduction for all loops: + + for i in prange(n): + for j in prange(n): + for k in prange(n): + sum += i * j * k + + sum is a reduction for both loops, local_var is private to the + parallel with block: + + for i in prange(n): + with parallel: + local_var = ... # private to the parallel + for j in prange(n): + sum += i * j + + Nested with parallel blocks are disallowed, because they wouldn't + allow you to propagate lastprivates or reductions: + + #pragma omp parallel for lastprivate(i) + for i in prange(n): + + sum = 0 + + #pragma omp parallel private(j, sum) + with parallel: + + #pragma omp parallel + with parallel: + + #pragma omp for lastprivate(j) reduction(+:sum) + for j in prange(n): + sum += i + + # sum and j are well-defined here + + # sum and j are undefined here + + # sum and j are undefined here + """ + self.privates[entry] = (op, lastprivate) + + if entry.type.is_memoryviewslice: + error(pos, "Memoryview slices can only be shared in parallel sections") + return + + if self.is_prange: + if not self.is_parallel and entry not in self.parent.assignments: + # Parent is a parallel with block + parent = self.parent.parent + else: + parent = self.parent + + # We don't need to propagate privates, only reductions and + # lastprivates + if parent and (op or lastprivate): + parent.propagate_var_privatization(entry, pos, op, lastprivate) + + def _allocate_closure_temp(self, code, entry): + """ + Helper function that allocate a temporary for a closure variable that + is assigned to. + """ + if self.parent: + return self.parent._allocate_closure_temp(code, entry) + + if entry.cname in self.seen_closure_vars: + return entry.cname + + cname = code.funcstate.allocate_temp(entry.type, True) + + # Add both the actual cname and the temp cname, as the actual cname + # will be replaced with the temp cname on the entry + self.seen_closure_vars.add(entry.cname) + self.seen_closure_vars.add(cname) + + self.modified_entries.append((entry, entry.cname)) + code.putln("%s = %s;" % (cname, entry.cname)) + entry.cname = cname + + def initialize_privates_to_nan(self, code, exclude=None): + first = True + + for entry, (op, lastprivate) in sorted(self.privates.items()): + if not op and (not exclude or entry != exclude): + invalid_value = entry.type.invalid_value() + + if invalid_value: + if first: + code.putln("/* Initialize private variables to " + "invalid values */") + first = False + code.putln("%s = %s;" % (entry.cname, + entry.type.cast_code(invalid_value))) + + def evaluate_before_block(self, code, expr): + c = self.begin_of_parallel_control_block_point_after_decls + # we need to set the owner to ourselves temporarily, as + # allocate_temp may generate a comment in the middle of our pragma + # otherwise when DebugFlags.debug_temp_code_comments is in effect + owner = c.funcstate.owner + c.funcstate.owner = c + expr.generate_evaluation_code(c) + c.funcstate.owner = owner + + return expr.result() + + def put_num_threads(self, code): + """ + Write self.num_threads if set as the num_threads OpenMP directive + """ + if self.num_threads is not None: + code.put(" num_threads(%s)" % self.evaluate_before_block(code, self.num_threads)) + + + def declare_closure_privates(self, code): + """ + If a variable is in a scope object, we need to allocate a temp and + assign the value from the temp to the variable in the scope object + after the parallel section. This kind of copying should be done only + in the outermost parallel section. + """ + self.modified_entries = [] + + for entry in sorted(self.assignments): + if entry.from_closure or entry.in_closure: + self._allocate_closure_temp(code, entry) + + def release_closure_privates(self, code): + """ + Release any temps used for variables in scope objects. As this is the + outermost parallel block, we don't need to delete the cnames from + self.seen_closure_vars. + """ + for entry, original_cname in self.modified_entries: + code.putln("%s = %s;" % (original_cname, entry.cname)) + code.funcstate.release_temp(entry.cname) + entry.cname = original_cname + + def privatize_temps(self, code, exclude_temps=()): + """ + Make any used temporaries private. Before the relevant code block + code.start_collecting_temps() should have been called. + """ + c = self.privatization_insertion_point + self.privatization_insertion_point = None + + if self.is_parallel: + self.temps = temps = code.funcstate.stop_collecting_temps() + privates, firstprivates = [], [] + for temp, type in sorted(temps): + if type.is_pyobject or type.is_memoryviewslice: + firstprivates.append(temp) + else: + privates.append(temp) + + if privates: + c.put(" private(%s)" % ", ".join(privates)) + if firstprivates: + c.put(" firstprivate(%s)" % ", ".join(firstprivates)) + + if self.breaking_label_used: + shared_vars = [Naming.parallel_why] + if self.error_label_used: + shared_vars.extend(self.parallel_exc) + c.put(" private(%s, %s, %s)" % self.pos_info) + + c.put(" shared(%s)" % ', '.join(shared_vars)) + + def cleanup_temps(self, code): + # Now clean up any memoryview slice and object temporaries + if self.is_parallel and not self.is_nested_prange: + code.putln("/* Clean up any temporaries */") + for temp, type in sorted(self.temps): + if type.is_memoryviewslice: + code.put_xdecref_memoryviewslice(temp, have_gil=False) + elif type.is_pyobject: + code.put_xdecref(temp, type) + code.putln("%s = NULL;" % temp) + + def setup_parallel_control_flow_block(self, code): + """ + Sets up a block that surrounds the parallel block to determine + how the parallel section was exited. Any kind of return is + trapped (break, continue, return, exceptions). This is the idea: + + { + int why = 0; + + #pragma omp parallel + { + return # -> goto new_return_label; + goto end_parallel; + + new_return_label: + why = 3; + goto end_parallel; + + end_parallel:; + #pragma omp flush(why) # we need to flush for every iteration + } + + if (why == 3) + goto old_return_label; + } + """ + self.old_loop_labels = code.new_loop_labels() + self.old_error_label = code.new_error_label() + self.old_return_label = code.return_label + code.return_label = code.new_label(name="return") + + code.begin_block() # parallel control flow block + self.begin_of_parallel_control_block_point = code.insertion_point() + self.begin_of_parallel_control_block_point_after_decls = code.insertion_point() + + self.undef_builtin_expect_apple_gcc_bug(code) + + def begin_parallel_block(self, code): + """ + Each OpenMP thread in a parallel section that contains a with gil block + must have the thread-state initialized. The call to + PyGILState_Release() then deallocates our threadstate. If we wouldn't + do this, each with gil block would allocate and deallocate one, thereby + losing exception information before it can be saved before leaving the + parallel section. + """ + self.begin_of_parallel_block = code.insertion_point() + + def end_parallel_block(self, code): + """ + To ensure all OpenMP threads have thread states, we ensure the GIL + in each thread (which creates a thread state if it doesn't exist), + after which we release the GIL. + On exit, reacquire the GIL and release the thread state. + + If compiled without OpenMP support (at the C level), then we still have + to acquire the GIL to decref any object temporaries. + """ + begin_code = self.begin_of_parallel_block + self.begin_of_parallel_block = None + + if self.error_label_used: + end_code = code + + begin_code.putln("#ifdef _OPENMP") + begin_code.put_ensure_gil(declare_gilstate=True) + begin_code.putln("Py_BEGIN_ALLOW_THREADS") + begin_code.putln("#endif /* _OPENMP */") + + end_code.putln("#ifdef _OPENMP") + end_code.putln("Py_END_ALLOW_THREADS") + end_code.putln("#else") + end_code.put_safe("{\n") + end_code.put_ensure_gil() + end_code.putln("#endif /* _OPENMP */") + self.cleanup_temps(end_code) + end_code.put_release_ensured_gil() + end_code.putln("#ifndef _OPENMP") + end_code.put_safe("}\n") + end_code.putln("#endif /* _OPENMP */") + + def trap_parallel_exit(self, code, should_flush=False): + """ + Trap any kind of return inside a parallel construct. 'should_flush' + indicates whether the variable should be flushed, which is needed by + prange to skip the loop. It also indicates whether we need to register + a continue (we need this for parallel blocks, but not for prange + loops, as it is a direct jump there). + + It uses the same mechanism as try/finally: + 1 continue + 2 break + 3 return + 4 error + """ + save_lastprivates_label = code.new_label() + dont_return_label = code.new_label() + + self.any_label_used = False + self.breaking_label_used = False + self.error_label_used = False + + self.parallel_private_temps = [] + + all_labels = code.get_all_labels() + + # Figure this out before starting to generate any code + for label in all_labels: + if code.label_used(label): + self.breaking_label_used = (self.breaking_label_used or + label != code.continue_label) + self.any_label_used = True + + if self.any_label_used: + code.put_goto(dont_return_label) + + for i, label in enumerate(all_labels): + if not code.label_used(label): + continue + + is_continue_label = label == code.continue_label + + code.put_label(label) + + if not (should_flush and is_continue_label): + if label == code.error_label: + self.error_label_used = True + self.fetch_parallel_exception(code) + + code.putln("%s = %d;" % (Naming.parallel_why, i + 1)) + + if (self.breaking_label_used and self.is_prange and not + is_continue_label): + code.put_goto(save_lastprivates_label) + else: + code.put_goto(dont_return_label) + + if self.any_label_used: + if self.is_prange and self.breaking_label_used: + # Don't rely on lastprivate, save our lastprivates + code.put_label(save_lastprivates_label) + self.save_parallel_vars(code) + + code.put_label(dont_return_label) + + if should_flush and self.breaking_label_used: + code.putln_openmp("#pragma omp flush(%s)" % Naming.parallel_why) + + def save_parallel_vars(self, code): + """ + The following shenanigans are instated when we break, return or + propagate errors from a prange. In this case we cannot rely on + lastprivate() to do its job, as no iterations may have executed yet + in the last thread, leaving the values undefined. It is most likely + that the breaking thread has well-defined values of the lastprivate + variables, so we keep those values. + """ + section_name = "__pyx_parallel_lastprivates%d" % self.critical_section_counter + code.putln_openmp("#pragma omp critical(%s)" % section_name) + ParallelStatNode.critical_section_counter += 1 + + code.begin_block() # begin critical section + + c = self.begin_of_parallel_control_block_point + + temp_count = 0 + for entry, (op, lastprivate) in sorted(self.privates.items()): + if not lastprivate or entry.type.is_pyobject: + continue + + type_decl = entry.type.empty_declaration_code() + temp_cname = "__pyx_parallel_temp%d" % temp_count + private_cname = entry.cname + + temp_count += 1 + + invalid_value = entry.type.invalid_value() + if invalid_value: + init = ' = ' + entry.type.cast_code(invalid_value) + else: + init = '' + # Declare the parallel private in the outer block + c.putln("%s %s%s;" % (type_decl, temp_cname, init)) + + # Initialize before escaping + code.putln("%s = %s;" % (temp_cname, private_cname)) + + self.parallel_private_temps.append((temp_cname, private_cname)) + + code.end_block() # end critical section + + def fetch_parallel_exception(self, code): + """ + As each OpenMP thread may raise an exception, we need to fetch that + exception from the threadstate and save it for after the parallel + section where it can be re-raised in the master thread. + + Although it would seem that __pyx_filename, __pyx_lineno and + __pyx_clineno are only assigned to under exception conditions (i.e., + when we have the GIL), and thus should be allowed to be shared without + any race condition, they are in fact subject to the same race + conditions that they were previously when they were global variables + and functions were allowed to release the GIL: + + thread A thread B + acquire + set lineno + release + acquire + set lineno + release + acquire + fetch exception + release + skip the fetch + + deallocate threadstate deallocate threadstate + """ + code.begin_block() + code.put_ensure_gil(declare_gilstate=True) + + code.putln_openmp("#pragma omp flush(%s)" % Naming.parallel_exc_type) + code.putln( + "if (!%s) {" % Naming.parallel_exc_type) + + code.putln("__Pyx_ErrFetchWithState(&%s, &%s, &%s);" % self.parallel_exc) + pos_info = chain(*zip(self.parallel_pos_info, self.pos_info)) + code.funcstate.uses_error_indicator = True + code.putln("%s = %s; %s = %s; %s = %s;" % tuple(pos_info)) + code.put_gotref(Naming.parallel_exc_type) + + code.putln( + "}") + + code.put_release_ensured_gil() + code.end_block() + + def restore_parallel_exception(self, code): + "Re-raise a parallel exception" + code.begin_block() + code.put_ensure_gil(declare_gilstate=True) + + code.put_giveref(Naming.parallel_exc_type) + code.putln("__Pyx_ErrRestoreWithState(%s, %s, %s);" % self.parallel_exc) + pos_info = chain(*zip(self.pos_info, self.parallel_pos_info)) + code.putln("%s = %s; %s = %s; %s = %s;" % tuple(pos_info)) + + code.put_release_ensured_gil() + code.end_block() + + def restore_labels(self, code): + """ + Restore all old labels. Call this before the 'else' clause to for + loops and always before ending the parallel control flow block. + """ + code.set_all_labels(self.old_loop_labels + (self.old_return_label, + self.old_error_label)) + + def end_parallel_control_flow_block( + self, code, break_=False, continue_=False, return_=False): + """ + This ends the parallel control flow block and based on how the parallel + section was exited, takes the corresponding action. The break_ and + continue_ parameters indicate whether these should be propagated + outwards: + + for i in prange(...): + with cython.parallel.parallel(): + continue + + Here break should be trapped in the parallel block, and propagated to + the for loop. + """ + c = self.begin_of_parallel_control_block_point + self.begin_of_parallel_control_block_point = None + self.begin_of_parallel_control_block_point_after_decls = None + + if self.num_threads is not None: + # FIXME: is it the right place? should not normally produce code. + self.num_threads.generate_disposal_code(code) + self.num_threads.free_temps(code) + + # Firstly, always prefer errors over returning, continue or break + if self.error_label_used: + c.putln("const char *%s = NULL; int %s = 0, %s = 0;" % self.parallel_pos_info) + c.putln("PyObject *%s = NULL, *%s = NULL, *%s = NULL;" % self.parallel_exc) + + code.putln( + "if (%s) {" % Naming.parallel_exc_type) + code.putln("/* This may have been overridden by a continue, " + "break or return in another thread. Prefer the error. */") + code.putln("%s = 4;" % Naming.parallel_why) + code.putln( + "}") + + if continue_: + any_label_used = self.any_label_used + else: + any_label_used = self.breaking_label_used + + if any_label_used: + # __pyx_parallel_why is used, declare and initialize + c.putln("int %s;" % Naming.parallel_why) + c.putln("%s = 0;" % Naming.parallel_why) + + code.putln( + "if (%s) {" % Naming.parallel_why) + + for temp_cname, private_cname in self.parallel_private_temps: + code.putln("%s = %s;" % (private_cname, temp_cname)) + + code.putln("switch (%s) {" % Naming.parallel_why) + if continue_: + code.put(" case 1: ") + code.put_goto(code.continue_label) + + if break_: + code.put(" case 2: ") + code.put_goto(code.break_label) + + if return_: + code.put(" case 3: ") + code.put_goto(code.return_label) + + if self.error_label_used: + code.globalstate.use_utility_code(restore_exception_utility_code) + code.putln(" case 4:") + self.restore_parallel_exception(code) + code.put_goto(code.error_label) + + code.putln("}") # end switch + code.putln( + "}") # end if + + code.end_block() # end parallel control flow block + self.redef_builtin_expect_apple_gcc_bug(code) + + # FIXME: improve with version number for OS X Lion + buggy_platform_macro_condition = "(defined(__APPLE__) || defined(__OSX__))" + have_expect_condition = "(defined(__GNUC__) && " \ + "(__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))" + redef_condition = "(%s && %s)" % (buggy_platform_macro_condition, have_expect_condition) + + def undef_builtin_expect_apple_gcc_bug(self, code): + """ + A bug on OS X Lion disallows __builtin_expect macros. This code avoids them + """ + if not self.parent: + code.undef_builtin_expect(self.redef_condition) + + def redef_builtin_expect_apple_gcc_bug(self, code): + if not self.parent: + code.redef_builtin_expect(self.redef_condition) + + +class ParallelWithBlockNode(ParallelStatNode): + """ + This node represents a 'with cython.parallel.parallel():' block + """ + + valid_keyword_arguments = ['num_threads'] + + num_threads = None + + def analyse_declarations(self, env): + super(ParallelWithBlockNode, self).analyse_declarations(env) + if self.args: + error(self.pos, "cython.parallel.parallel() does not take " + "positional arguments") + + def generate_execution_code(self, code): + self.declare_closure_privates(code) + self.setup_parallel_control_flow_block(code) + + code.putln("#ifdef _OPENMP") + code.put("#pragma omp parallel ") + + if self.privates: + privates = [e.cname for e in self.privates + if not e.type.is_pyobject] + code.put('private(%s)' % ', '.join(sorted(privates))) + + self.privatization_insertion_point = code.insertion_point() + self.put_num_threads(code) + code.putln("") + + code.putln("#endif /* _OPENMP */") + + code.begin_block() # parallel block + self.begin_parallel_block(code) + self.initialize_privates_to_nan(code) + code.funcstate.start_collecting_temps() + self.body.generate_execution_code(code) + self.trap_parallel_exit(code) + self.privatize_temps(code) + self.end_parallel_block(code) + code.end_block() # end parallel block + + continue_ = code.label_used(code.continue_label) + break_ = code.label_used(code.break_label) + return_ = code.label_used(code.return_label) + + self.restore_labels(code) + self.end_parallel_control_flow_block(code, break_=break_, + continue_=continue_, + return_=return_) + self.release_closure_privates(code) + + +class ParallelRangeNode(ParallelStatNode): + """ + This node represents a 'for i in cython.parallel.prange():' construct. + + target NameNode the target iteration variable + else_clause Node or None the else clause of this loop + """ + + child_attrs = ['body', 'target', 'else_clause', 'args', 'num_threads', + 'chunksize'] + + body = target = else_clause = args = None + + start = stop = step = None + + is_prange = True + + nogil = None + schedule = None + + valid_keyword_arguments = ['schedule', 'nogil', 'num_threads', 'chunksize'] + + def __init__(self, pos, **kwds): + super(ParallelRangeNode, self).__init__(pos, **kwds) + # Pretend to be a ForInStatNode for control flow analysis + self.iterator = PassStatNode(pos) + + def analyse_declarations(self, env): + super(ParallelRangeNode, self).analyse_declarations(env) + self.target.analyse_target_declaration(env) + if self.else_clause is not None: + self.else_clause.analyse_declarations(env) + + if not self.args or len(self.args) > 3: + error(self.pos, "Invalid number of positional arguments to prange") + return + + if len(self.args) == 1: + self.stop, = self.args + elif len(self.args) == 2: + self.start, self.stop = self.args + else: + self.start, self.stop, self.step = self.args + + if hasattr(self.schedule, 'decode'): + self.schedule = self.schedule.decode('ascii') + + if self.schedule not in (None, 'static', 'dynamic', 'guided', 'runtime'): + error(self.pos, "Invalid schedule argument to prange: %s" % (self.schedule,)) + + def analyse_expressions(self, env): + was_nogil = env.nogil + if self.nogil: + env.nogil = True + + if self.target is None: + error(self.pos, "prange() can only be used as part of a for loop") + return self + + self.target = self.target.analyse_target_types(env) + + if not self.target.type.is_numeric: + # Not a valid type, assume one for now anyway + + if not self.target.type.is_pyobject: + # nogil_check will catch the is_pyobject case + error(self.target.pos, + "Must be of numeric type, not %s" % self.target.type) + + self.index_type = PyrexTypes.c_py_ssize_t_type + else: + self.index_type = self.target.type + + # Setup start, stop and step, allocating temps if needed + self.names = 'start', 'stop', 'step' + start_stop_step = self.start, self.stop, self.step + + for node, name in zip(start_stop_step, self.names): + if node is not None: + node.analyse_types(env) + if not node.type.is_numeric: + error(node.pos, "%s argument must be numeric" % name) + continue + + if not node.is_literal: + node = node.coerce_to_temp(env) + setattr(self, name, node) + + # As we range from 0 to nsteps, computing the index along the + # way, we need a fitting type for 'i' and 'nsteps' + self.index_type = PyrexTypes.widest_numeric_type( + self.index_type, node.type) + + if self.else_clause is not None: + self.else_clause = self.else_clause.analyse_expressions(env) + + # Although not actually an assignment in this scope, it should be + # treated as such to ensure it is unpacked if a closure temp, and to + # ensure lastprivate behaviour and propagation. If the target index is + # not a NameNode, it won't have an entry, and an error was issued by + # ParallelRangeTransform + if hasattr(self.target, 'entry'): + self.assignments[self.target.entry] = self.target.pos, None + + node = super(ParallelRangeNode, self).analyse_expressions(env) + + if node.chunksize: + if not node.schedule: + error(node.chunksize.pos, + "Must provide schedule with chunksize") + elif node.schedule == 'runtime': + error(node.chunksize.pos, + "Chunksize not valid for the schedule runtime") + elif (node.chunksize.type.is_int and + node.chunksize.is_literal and + node.chunksize.compile_time_value(env) <= 0): + error(node.chunksize.pos, "Chunksize must not be negative") + + node.chunksize = node.chunksize.coerce_to( + PyrexTypes.c_int_type, env).coerce_to_temp(env) + + if node.nogil: + env.nogil = was_nogil + + node.is_nested_prange = node.parent and node.parent.is_prange + if node.is_nested_prange: + parent = node + while parent.parent and parent.parent.is_prange: + parent = parent.parent + + parent.assignments.update(node.assignments) + parent.privates.update(node.privates) + parent.assigned_nodes.extend(node.assigned_nodes) + return node + + def nogil_check(self, env): + names = 'start', 'stop', 'step', 'target' + nodes = self.start, self.stop, self.step, self.target + for name, node in zip(names, nodes): + if node is not None and node.type.is_pyobject: + error(node.pos, "%s may not be a Python object " + "as we don't have the GIL" % name) + + def generate_execution_code(self, code): + """ + Generate code in the following steps + + 1) copy any closure variables determined thread-private + into temporaries + + 2) allocate temps for start, stop and step + + 3) generate a loop that calculates the total number of steps, + which then computes the target iteration variable for every step: + + for i in prange(start, stop, step): + ... + + becomes + + nsteps = (stop - start) / step; + i = start; + + #pragma omp parallel for lastprivate(i) + for (temp = 0; temp < nsteps; temp++) { + i = start + step * temp; + ... + } + + Note that accumulation of 'i' would have a data dependency + between iterations. + + Also, you can't do this + + for (i = start; i < stop; i += step) + ... + + as the '<' operator should become '>' for descending loops. + 'for i from x < i < y:' does not suffer from this problem + as the relational operator is known at compile time! + + 4) release our temps and write back any private closure variables + """ + self.declare_closure_privates(code) + + # This can only be a NameNode + target_index_cname = self.target.entry.cname + + # This will be used as the dict to format our code strings, holding + # the start, stop , step, temps and target cnames + fmt_dict = { + 'target': target_index_cname, + 'target_type': self.target.type.empty_declaration_code() + } + + # Setup start, stop and step, allocating temps if needed + start_stop_step = self.start, self.stop, self.step + defaults = '0', '0', '1' + for node, name, default in zip(start_stop_step, self.names, defaults): + if node is None: + result = default + elif node.is_literal: + result = node.get_constant_c_result_code() + else: + node.generate_evaluation_code(code) + result = node.result() + + fmt_dict[name] = result + + fmt_dict['i'] = code.funcstate.allocate_temp(self.index_type, False) + fmt_dict['nsteps'] = code.funcstate.allocate_temp(self.index_type, False) + + # TODO: check if the step is 0 and if so, raise an exception in a + # 'with gil' block. For now, just abort + code.putln("if ((%(step)s == 0)) abort();" % fmt_dict) + + self.setup_parallel_control_flow_block(code) # parallel control flow block + + # Note: nsteps is private in an outer scope if present + code.putln("%(nsteps)s = (%(stop)s - %(start)s + %(step)s - %(step)s/abs(%(step)s)) / %(step)s;" % fmt_dict) + + # The target iteration variable might not be initialized, do it only if + # we are executing at least 1 iteration, otherwise we should leave the + # target unaffected. The target iteration variable is firstprivate to + # shut up compiler warnings caused by lastprivate, as the compiler + # erroneously believes that nsteps may be <= 0, leaving the private + # target index uninitialized + code.putln("if (%(nsteps)s > 0)" % fmt_dict) + code.begin_block() # if block + self.generate_loop(code, fmt_dict) + code.end_block() # end if block + + self.restore_labels(code) + + if self.else_clause: + if self.breaking_label_used: + code.put("if (%s < 2)" % Naming.parallel_why) + + code.begin_block() # else block + code.putln("/* else */") + self.else_clause.generate_execution_code(code) + code.end_block() # end else block + + # ------ cleanup ------ + self.end_parallel_control_flow_block(code) # end parallel control flow block + + # And finally, release our privates and write back any closure + # variables + for temp in start_stop_step + (self.chunksize,): + if temp is not None: + temp.generate_disposal_code(code) + temp.free_temps(code) + + code.funcstate.release_temp(fmt_dict['i']) + code.funcstate.release_temp(fmt_dict['nsteps']) + + self.release_closure_privates(code) + + def generate_loop(self, code, fmt_dict): + if self.is_nested_prange: + code.putln("#if 0") + else: + code.putln("#ifdef _OPENMP") + + if not self.is_parallel: + code.put("#pragma omp for") + self.privatization_insertion_point = code.insertion_point() + reduction_codepoint = self.parent.privatization_insertion_point + else: + code.put("#pragma omp parallel") + self.privatization_insertion_point = code.insertion_point() + reduction_codepoint = self.privatization_insertion_point + code.putln("") + code.putln("#endif /* _OPENMP */") + + code.begin_block() # pragma omp parallel begin block + + # Initialize the GIL if needed for this thread + self.begin_parallel_block(code) + + if self.is_nested_prange: + code.putln("#if 0") + else: + code.putln("#ifdef _OPENMP") + code.put("#pragma omp for") + + for entry, (op, lastprivate) in sorted(self.privates.items()): + # Don't declare the index variable as a reduction + if op and op in "+*-&^|" and entry != self.target.entry: + if entry.type.is_pyobject: + error(self.pos, "Python objects cannot be reductions") + else: + #code.put(" reduction(%s:%s)" % (op, entry.cname)) + # This is the only way reductions + nesting works in gcc4.5 + reduction_codepoint.put( + " reduction(%s:%s)" % (op, entry.cname)) + else: + if entry == self.target.entry: + code.put(" firstprivate(%s)" % entry.cname) + code.put(" lastprivate(%s)" % entry.cname) + continue + + if not entry.type.is_pyobject: + if lastprivate: + private = 'lastprivate' + else: + private = 'private' + + code.put(" %s(%s)" % (private, entry.cname)) + + if self.schedule: + if self.chunksize: + chunksize = ", %s" % self.evaluate_before_block(code, self.chunksize) + else: + chunksize = "" + + code.put(" schedule(%s%s)" % (self.schedule, chunksize)) + + self.put_num_threads(reduction_codepoint) + + code.putln("") + code.putln("#endif /* _OPENMP */") + + code.put("for (%(i)s = 0; %(i)s < %(nsteps)s; %(i)s++)" % fmt_dict) + code.begin_block() # for loop block + + guard_around_body_codepoint = code.insertion_point() + + # Start if guard block around the body. This may be unnecessary, but + # at least it doesn't spoil indentation + code.begin_block() + + code.putln("%(target)s = (%(target_type)s)(%(start)s + %(step)s * %(i)s);" % fmt_dict) + self.initialize_privates_to_nan(code, exclude=self.target.entry) + + if self.is_parallel and not self.is_nested_prange: + # nested pranges are not omp'ified, temps go to outer loops + code.funcstate.start_collecting_temps() + + self.body.generate_execution_code(code) + self.trap_parallel_exit(code, should_flush=True) + if self.is_parallel and not self.is_nested_prange: + # nested pranges are not omp'ified, temps go to outer loops + self.privatize_temps(code) + + if self.breaking_label_used: + # Put a guard around the loop body in case return, break or + # exceptions might be used + guard_around_body_codepoint.putln("if (%s < 2)" % Naming.parallel_why) + + code.end_block() # end guard around loop body + code.end_block() # end for loop block + + if self.is_parallel: + # Release the GIL and deallocate the thread state + self.end_parallel_block(code) + code.end_block() # pragma omp parallel end block + + +class CnameDecoratorNode(StatNode): + """ + This node is for the cname decorator in CythonUtilityCode: + + @cname('the_cname') + cdef func(...): + ... + + In case of a cdef class the cname specifies the objstruct_cname. + + node the node to which the cname decorator is applied + cname the cname the node should get + """ + + child_attrs = ['node'] + + def analyse_declarations(self, env): + self.node.analyse_declarations(env) + + node = self.node + if isinstance(node, CompilerDirectivesNode): + node = node.body.stats[0] + + self.is_function = isinstance(node, FuncDefNode) + is_struct_or_enum = isinstance(node, (CStructOrUnionDefNode, CEnumDefNode)) + e = node.entry + + if self.is_function: + e.cname = self.cname + e.func_cname = self.cname + e.used = True + if e.pyfunc_cname and '.' in e.pyfunc_cname: + e.pyfunc_cname = self.mangle(e.pyfunc_cname) + elif is_struct_or_enum: + e.cname = e.type.cname = self.cname + else: + scope = node.scope + + e.cname = self.cname + e.type.objstruct_cname = self.cname + '_obj' + e.type.typeobj_cname = Naming.typeobj_prefix + self.cname + e.type.typeptr_cname = self.cname + '_type' + e.type.scope.namespace_cname = e.type.typeptr_cname + + e.as_variable.cname = e.type.typeptr_cname + + scope.scope_prefix = self.cname + "_" + + for name, entry in scope.entries.items(): + if entry.func_cname: + entry.func_cname = self.mangle(entry.cname) + if entry.pyfunc_cname: + entry.pyfunc_cname = self.mangle(entry.pyfunc_cname) + + def mangle(self, cname): + if '.' in cname: + # remove __pyx_base from func_cname + cname = cname.split('.')[-1] + return '%s_%s' % (self.cname, cname) + + def analyse_expressions(self, env): + self.node = self.node.analyse_expressions(env) + return self + + def generate_function_definitions(self, env, code): + "Ensure a prototype for every @cname method in the right place" + if self.is_function and env.is_c_class_scope: + # method in cdef class, generate a prototype in the header + h_code = code.globalstate['utility_code_proto'] + + if isinstance(self.node, DefNode): + self.node.generate_function_header( + h_code, with_pymethdef=False, proto_only=True) + else: + from . import ModuleNode + entry = self.node.entry + cname = entry.cname + entry.cname = entry.func_cname + + ModuleNode.generate_cfunction_declaration( + entry, + env.global_scope(), + h_code, + definition=True) + + entry.cname = cname + + self.node.generate_function_definitions(env, code) + + def generate_execution_code(self, code): + self.node.generate_execution_code(code) + + +#------------------------------------------------------------------------------------ +# +# Runtime support code +# +#------------------------------------------------------------------------------------ + +if Options.gcc_branch_hints: + branch_prediction_macros = """ +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) \ + && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ +""" +else: + branch_prediction_macros = """ +#define likely(x) (x) +#define unlikely(x) (x) +""" + +#------------------------------------------------------------------------------------ + +printing_utility_code = UtilityCode.load_cached("Print", "Printing.c") +printing_one_utility_code = UtilityCode.load_cached("PrintOne", "Printing.c") + +#------------------------------------------------------------------------------------ + +# Exception raising code +# +# Exceptions are raised by __Pyx_Raise() and stored as plain +# type/value/tb in PyThreadState->curexc_*. When being caught by an +# 'except' statement, curexc_* is moved over to exc_* by +# __Pyx_GetException() + +restore_exception_utility_code = UtilityCode.load_cached("PyErrFetchRestore", "Exceptions.c") +raise_utility_code = UtilityCode.load_cached("RaiseException", "Exceptions.c") +get_exception_utility_code = UtilityCode.load_cached("GetException", "Exceptions.c") +swap_exception_utility_code = UtilityCode.load_cached("SwapException", "Exceptions.c") +reset_exception_utility_code = UtilityCode.load_cached("SaveResetException", "Exceptions.c") +traceback_utility_code = UtilityCode.load_cached("AddTraceback", "Exceptions.c") + +#------------------------------------------------------------------------------------ + +get_exception_tuple_utility_code = UtilityCode( + proto=""" +static PyObject *__Pyx_GetExceptionTuple(PyThreadState *__pyx_tstate); /*proto*/ +""", + # I doubt that calling __Pyx_GetException() here is correct as it moves + # the exception from tstate->curexc_* to tstate->exc_*, which prevents + # exception handlers later on from receiving it. + # NOTE: "__pyx_tstate" may be used by __Pyx_GetException() macro + impl = """ +static PyObject *__Pyx_GetExceptionTuple(CYTHON_UNUSED PyThreadState *__pyx_tstate) { + PyObject *type = NULL, *value = NULL, *tb = NULL; + if (__Pyx_GetException(&type, &value, &tb) == 0) { + PyObject* exc_info = PyTuple_New(3); + if (exc_info) { + Py_INCREF(type); + Py_INCREF(value); + Py_INCREF(tb); + PyTuple_SET_ITEM(exc_info, 0, type); + PyTuple_SET_ITEM(exc_info, 1, value); + PyTuple_SET_ITEM(exc_info, 2, tb); + return exc_info; + } + } + return NULL; +} +""", + requires=[get_exception_utility_code]) diff --git a/contrib/tools/cython/Cython/Compiler/Optimize.py b/contrib/tools/cython/Cython/Compiler/Optimize.py new file mode 100644 index 00000000000..7e9435ba0aa --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Optimize.py @@ -0,0 +1,4857 @@ +from __future__ import absolute_import + +import re +import sys +import copy +import codecs +import itertools + +from . import TypeSlots +from .ExprNodes import not_a_constant +import cython +cython.declare(UtilityCode=object, EncodedString=object, bytes_literal=object, encoded_string=object, + Nodes=object, ExprNodes=object, PyrexTypes=object, Builtin=object, + UtilNodes=object, _py_int_types=object) + +if sys.version_info[0] >= 3: + _py_int_types = int + _py_string_types = (bytes, str) +else: + _py_int_types = (int, long) + _py_string_types = (bytes, unicode) + +from . import Nodes +from . import ExprNodes +from . import PyrexTypes +from . import Visitor +from . import Builtin +from . import UtilNodes +from . import Options + +from .Code import UtilityCode, TempitaUtilityCode +from .StringEncoding import EncodedString, bytes_literal, encoded_string +from .Errors import error, warning +from .ParseTreeTransforms import SkipDeclarations + +try: + from __builtin__ import reduce +except ImportError: + from functools import reduce + +try: + from __builtin__ import basestring +except ImportError: + basestring = str # Python 3 + + +def load_c_utility(name): + return UtilityCode.load_cached(name, "Optimize.c") + + +def unwrap_coerced_node(node, coercion_nodes=(ExprNodes.CoerceToPyTypeNode, ExprNodes.CoerceFromPyTypeNode)): + if isinstance(node, coercion_nodes): + return node.arg + return node + + +def unwrap_node(node): + while isinstance(node, UtilNodes.ResultRefNode): + node = node.expression + return node + + +def is_common_value(a, b): + a = unwrap_node(a) + b = unwrap_node(b) + if isinstance(a, ExprNodes.NameNode) and isinstance(b, ExprNodes.NameNode): + return a.name == b.name + if isinstance(a, ExprNodes.AttributeNode) and isinstance(b, ExprNodes.AttributeNode): + return not a.is_py_attr and is_common_value(a.obj, b.obj) and a.attribute == b.attribute + return False + + +def filter_none_node(node): + if node is not None and node.constant_result is None: + return None + return node + + +class _YieldNodeCollector(Visitor.TreeVisitor): + """ + YieldExprNode finder for generator expressions. + """ + def __init__(self): + Visitor.TreeVisitor.__init__(self) + self.yield_stat_nodes = {} + self.yield_nodes = [] + + visit_Node = Visitor.TreeVisitor.visitchildren + + def visit_YieldExprNode(self, node): + self.yield_nodes.append(node) + self.visitchildren(node) + + def visit_ExprStatNode(self, node): + self.visitchildren(node) + if node.expr in self.yield_nodes: + self.yield_stat_nodes[node.expr] = node + + # everything below these nodes is out of scope: + + def visit_GeneratorExpressionNode(self, node): + pass + + def visit_LambdaNode(self, node): + pass + + def visit_FuncDefNode(self, node): + pass + + +def _find_single_yield_expression(node): + yield_statements = _find_yield_statements(node) + if len(yield_statements) != 1: + return None, None + return yield_statements[0] + + +def _find_yield_statements(node): + collector = _YieldNodeCollector() + collector.visitchildren(node) + try: + yield_statements = [ + (yield_node.arg, collector.yield_stat_nodes[yield_node]) + for yield_node in collector.yield_nodes + ] + except KeyError: + # found YieldExprNode without ExprStatNode (i.e. a non-statement usage of 'yield') + yield_statements = [] + return yield_statements + + +class IterationTransform(Visitor.EnvTransform): + """Transform some common for-in loop patterns into efficient C loops: + + - for-in-dict loop becomes a while loop calling PyDict_Next() + - for-in-enumerate is replaced by an external counter variable + - for-in-range loop becomes a plain C for loop + """ + def visit_PrimaryCmpNode(self, node): + if node.is_ptr_contains(): + + # for t in operand2: + # if operand1 == t: + # res = True + # break + # else: + # res = False + + pos = node.pos + result_ref = UtilNodes.ResultRefNode(node) + if node.operand2.is_subscript: + base_type = node.operand2.base.type.base_type + else: + base_type = node.operand2.type.base_type + target_handle = UtilNodes.TempHandle(base_type) + target = target_handle.ref(pos) + cmp_node = ExprNodes.PrimaryCmpNode( + pos, operator=u'==', operand1=node.operand1, operand2=target) + if_body = Nodes.StatListNode( + pos, + stats = [Nodes.SingleAssignmentNode(pos, lhs=result_ref, rhs=ExprNodes.BoolNode(pos, value=1)), + Nodes.BreakStatNode(pos)]) + if_node = Nodes.IfStatNode( + pos, + if_clauses=[Nodes.IfClauseNode(pos, condition=cmp_node, body=if_body)], + else_clause=None) + for_loop = UtilNodes.TempsBlockNode( + pos, + temps = [target_handle], + body = Nodes.ForInStatNode( + pos, + target=target, + iterator=ExprNodes.IteratorNode(node.operand2.pos, sequence=node.operand2), + body=if_node, + else_clause=Nodes.SingleAssignmentNode(pos, lhs=result_ref, rhs=ExprNodes.BoolNode(pos, value=0)))) + for_loop = for_loop.analyse_expressions(self.current_env()) + for_loop = self.visit(for_loop) + new_node = UtilNodes.TempResultFromStatNode(result_ref, for_loop) + + if node.operator == 'not_in': + new_node = ExprNodes.NotNode(pos, operand=new_node) + return new_node + + else: + self.visitchildren(node) + return node + + def visit_ForInStatNode(self, node): + self.visitchildren(node) + return self._optimise_for_loop(node, node.iterator.sequence) + + def _optimise_for_loop(self, node, iterable, reversed=False): + annotation_type = None + if (iterable.is_name or iterable.is_attribute) and iterable.entry and iterable.entry.annotation: + annotation = iterable.entry.annotation + if annotation.is_subscript: + annotation = annotation.base # container base type + # FIXME: generalise annotation evaluation => maybe provide a "qualified name" also for imported names? + if annotation.is_name: + if annotation.entry and annotation.entry.qualified_name == 'typing.Dict': + annotation_type = Builtin.dict_type + elif annotation.name == 'Dict': + annotation_type = Builtin.dict_type + if annotation.entry and annotation.entry.qualified_name in ('typing.Set', 'typing.FrozenSet'): + annotation_type = Builtin.set_type + elif annotation.name in ('Set', 'FrozenSet'): + annotation_type = Builtin.set_type + + if Builtin.dict_type in (iterable.type, annotation_type): + # like iterating over dict.keys() + if reversed: + # CPython raises an error here: not a sequence + return node + return self._transform_dict_iteration( + node, dict_obj=iterable, method=None, keys=True, values=False) + + if (Builtin.set_type in (iterable.type, annotation_type) or + Builtin.frozenset_type in (iterable.type, annotation_type)): + if reversed: + # CPython raises an error here: not a sequence + return node + return self._transform_set_iteration(node, iterable) + + # C array (slice) iteration? + if iterable.type.is_ptr or iterable.type.is_array: + return self._transform_carray_iteration(node, iterable, reversed=reversed) + if iterable.type is Builtin.bytes_type: + return self._transform_bytes_iteration(node, iterable, reversed=reversed) + if iterable.type is Builtin.unicode_type: + return self._transform_unicode_iteration(node, iterable, reversed=reversed) + + # the rest is based on function calls + if not isinstance(iterable, ExprNodes.SimpleCallNode): + return node + + if iterable.args is None: + arg_count = iterable.arg_tuple and len(iterable.arg_tuple.args) or 0 + else: + arg_count = len(iterable.args) + if arg_count and iterable.self is not None: + arg_count -= 1 + + function = iterable.function + # dict iteration? + if function.is_attribute and not reversed and not arg_count: + base_obj = iterable.self or function.obj + method = function.attribute + # in Py3, items() is equivalent to Py2's iteritems() + is_safe_iter = self.global_scope().context.language_level >= 3 + + if not is_safe_iter and method in ('keys', 'values', 'items'): + # try to reduce this to the corresponding .iter*() methods + if isinstance(base_obj, ExprNodes.CallNode): + inner_function = base_obj.function + if (inner_function.is_name and inner_function.name == 'dict' + and inner_function.entry + and inner_function.entry.is_builtin): + # e.g. dict(something).items() => safe to use .iter*() + is_safe_iter = True + + keys = values = False + if method == 'iterkeys' or (is_safe_iter and method == 'keys'): + keys = True + elif method == 'itervalues' or (is_safe_iter and method == 'values'): + values = True + elif method == 'iteritems' or (is_safe_iter and method == 'items'): + keys = values = True + + if keys or values: + return self._transform_dict_iteration( + node, base_obj, method, keys, values) + + # enumerate/reversed ? + if iterable.self is None and function.is_name and \ + function.entry and function.entry.is_builtin: + if function.name == 'enumerate': + if reversed: + # CPython raises an error here: not a sequence + return node + return self._transform_enumerate_iteration(node, iterable) + elif function.name == 'reversed': + if reversed: + # CPython raises an error here: not a sequence + return node + return self._transform_reversed_iteration(node, iterable) + + # range() iteration? + if Options.convert_range and 1 <= arg_count <= 3 and ( + iterable.self is None and + function.is_name and function.name in ('range', 'xrange') and + function.entry and function.entry.is_builtin): + if node.target.type.is_int or node.target.type.is_enum: + return self._transform_range_iteration(node, iterable, reversed=reversed) + if node.target.type.is_pyobject: + # Assume that small integer ranges (C long >= 32bit) are best handled in C as well. + for arg in (iterable.arg_tuple.args if iterable.args is None else iterable.args): + if isinstance(arg, ExprNodes.IntNode): + if arg.has_constant_result() and -2**30 <= arg.constant_result < 2**30: + continue + break + else: + return self._transform_range_iteration(node, iterable, reversed=reversed) + + return node + + def _transform_reversed_iteration(self, node, reversed_function): + args = reversed_function.arg_tuple.args + if len(args) == 0: + error(reversed_function.pos, + "reversed() requires an iterable argument") + return node + elif len(args) > 1: + error(reversed_function.pos, + "reversed() takes exactly 1 argument") + return node + arg = args[0] + + # reversed(list/tuple) ? + if arg.type in (Builtin.tuple_type, Builtin.list_type): + node.iterator.sequence = arg.as_none_safe_node("'NoneType' object is not iterable") + node.iterator.reversed = True + return node + + return self._optimise_for_loop(node, arg, reversed=True) + + PyBytes_AS_STRING_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_char_ptr_type, [ + PyrexTypes.CFuncTypeArg("s", Builtin.bytes_type, None) + ]) + + PyBytes_GET_SIZE_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_py_ssize_t_type, [ + PyrexTypes.CFuncTypeArg("s", Builtin.bytes_type, None) + ]) + + def _transform_bytes_iteration(self, node, slice_node, reversed=False): + target_type = node.target.type + if not target_type.is_int and target_type is not Builtin.bytes_type: + # bytes iteration returns bytes objects in Py2, but + # integers in Py3 + return node + + unpack_temp_node = UtilNodes.LetRefNode( + slice_node.as_none_safe_node("'NoneType' is not iterable")) + + slice_base_node = ExprNodes.PythonCapiCallNode( + slice_node.pos, "PyBytes_AS_STRING", + self.PyBytes_AS_STRING_func_type, + args = [unpack_temp_node], + is_temp = 0, + ) + len_node = ExprNodes.PythonCapiCallNode( + slice_node.pos, "PyBytes_GET_SIZE", + self.PyBytes_GET_SIZE_func_type, + args = [unpack_temp_node], + is_temp = 0, + ) + + return UtilNodes.LetNode( + unpack_temp_node, + self._transform_carray_iteration( + node, + ExprNodes.SliceIndexNode( + slice_node.pos, + base = slice_base_node, + start = None, + step = None, + stop = len_node, + type = slice_base_node.type, + is_temp = 1, + ), + reversed = reversed)) + + PyUnicode_READ_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_py_ucs4_type, [ + PyrexTypes.CFuncTypeArg("kind", PyrexTypes.c_int_type, None), + PyrexTypes.CFuncTypeArg("data", PyrexTypes.c_void_ptr_type, None), + PyrexTypes.CFuncTypeArg("index", PyrexTypes.c_py_ssize_t_type, None) + ]) + + init_unicode_iteration_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_int_type, [ + PyrexTypes.CFuncTypeArg("s", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("length", PyrexTypes.c_py_ssize_t_ptr_type, None), + PyrexTypes.CFuncTypeArg("data", PyrexTypes.c_void_ptr_ptr_type, None), + PyrexTypes.CFuncTypeArg("kind", PyrexTypes.c_int_ptr_type, None) + ], + exception_value = '-1') + + def _transform_unicode_iteration(self, node, slice_node, reversed=False): + if slice_node.is_literal: + # try to reduce to byte iteration for plain Latin-1 strings + try: + bytes_value = bytes_literal(slice_node.value.encode('latin1'), 'iso8859-1') + except UnicodeEncodeError: + pass + else: + bytes_slice = ExprNodes.SliceIndexNode( + slice_node.pos, + base=ExprNodes.BytesNode( + slice_node.pos, value=bytes_value, + constant_result=bytes_value, + type=PyrexTypes.c_const_char_ptr_type).coerce_to( + PyrexTypes.c_const_uchar_ptr_type, self.current_env()), + start=None, + stop=ExprNodes.IntNode( + slice_node.pos, value=str(len(bytes_value)), + constant_result=len(bytes_value), + type=PyrexTypes.c_py_ssize_t_type), + type=Builtin.unicode_type, # hint for Python conversion + ) + return self._transform_carray_iteration(node, bytes_slice, reversed) + + unpack_temp_node = UtilNodes.LetRefNode( + slice_node.as_none_safe_node("'NoneType' is not iterable")) + + start_node = ExprNodes.IntNode( + node.pos, value='0', constant_result=0, type=PyrexTypes.c_py_ssize_t_type) + length_temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) + end_node = length_temp.ref(node.pos) + if reversed: + relation1, relation2 = '>', '>=' + start_node, end_node = end_node, start_node + else: + relation1, relation2 = '<=', '<' + + kind_temp = UtilNodes.TempHandle(PyrexTypes.c_int_type) + data_temp = UtilNodes.TempHandle(PyrexTypes.c_void_ptr_type) + counter_temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) + + target_value = ExprNodes.PythonCapiCallNode( + slice_node.pos, "__Pyx_PyUnicode_READ", + self.PyUnicode_READ_func_type, + args = [kind_temp.ref(slice_node.pos), + data_temp.ref(slice_node.pos), + counter_temp.ref(node.target.pos)], + is_temp = False, + ) + if target_value.type != node.target.type: + target_value = target_value.coerce_to(node.target.type, + self.current_env()) + target_assign = Nodes.SingleAssignmentNode( + pos = node.target.pos, + lhs = node.target, + rhs = target_value) + body = Nodes.StatListNode( + node.pos, + stats = [target_assign, node.body]) + + loop_node = Nodes.ForFromStatNode( + node.pos, + bound1=start_node, relation1=relation1, + target=counter_temp.ref(node.target.pos), + relation2=relation2, bound2=end_node, + step=None, body=body, + else_clause=node.else_clause, + from_range=True) + + setup_node = Nodes.ExprStatNode( + node.pos, + expr = ExprNodes.PythonCapiCallNode( + slice_node.pos, "__Pyx_init_unicode_iteration", + self.init_unicode_iteration_func_type, + args = [unpack_temp_node, + ExprNodes.AmpersandNode(slice_node.pos, operand=length_temp.ref(slice_node.pos), + type=PyrexTypes.c_py_ssize_t_ptr_type), + ExprNodes.AmpersandNode(slice_node.pos, operand=data_temp.ref(slice_node.pos), + type=PyrexTypes.c_void_ptr_ptr_type), + ExprNodes.AmpersandNode(slice_node.pos, operand=kind_temp.ref(slice_node.pos), + type=PyrexTypes.c_int_ptr_type), + ], + is_temp = True, + result_is_used = False, + utility_code=UtilityCode.load_cached("unicode_iter", "Optimize.c"), + )) + return UtilNodes.LetNode( + unpack_temp_node, + UtilNodes.TempsBlockNode( + node.pos, temps=[counter_temp, length_temp, data_temp, kind_temp], + body=Nodes.StatListNode(node.pos, stats=[setup_node, loop_node]))) + + def _transform_carray_iteration(self, node, slice_node, reversed=False): + neg_step = False + if isinstance(slice_node, ExprNodes.SliceIndexNode): + slice_base = slice_node.base + start = filter_none_node(slice_node.start) + stop = filter_none_node(slice_node.stop) + step = None + if not stop: + if not slice_base.type.is_pyobject: + error(slice_node.pos, "C array iteration requires known end index") + return node + + elif slice_node.is_subscript: + assert isinstance(slice_node.index, ExprNodes.SliceNode) + slice_base = slice_node.base + index = slice_node.index + start = filter_none_node(index.start) + stop = filter_none_node(index.stop) + step = filter_none_node(index.step) + if step: + if not isinstance(step.constant_result, _py_int_types) \ + or step.constant_result == 0 \ + or step.constant_result > 0 and not stop \ + or step.constant_result < 0 and not start: + if not slice_base.type.is_pyobject: + error(step.pos, "C array iteration requires known step size and end index") + return node + else: + # step sign is handled internally by ForFromStatNode + step_value = step.constant_result + if reversed: + step_value = -step_value + neg_step = step_value < 0 + step = ExprNodes.IntNode(step.pos, type=PyrexTypes.c_py_ssize_t_type, + value=str(abs(step_value)), + constant_result=abs(step_value)) + + elif slice_node.type.is_array: + if slice_node.type.size is None: + error(slice_node.pos, "C array iteration requires known end index") + return node + slice_base = slice_node + start = None + stop = ExprNodes.IntNode( + slice_node.pos, value=str(slice_node.type.size), + type=PyrexTypes.c_py_ssize_t_type, constant_result=slice_node.type.size) + step = None + + else: + if not slice_node.type.is_pyobject: + error(slice_node.pos, "C array iteration requires known end index") + return node + + if start: + start = start.coerce_to(PyrexTypes.c_py_ssize_t_type, self.current_env()) + if stop: + stop = stop.coerce_to(PyrexTypes.c_py_ssize_t_type, self.current_env()) + if stop is None: + if neg_step: + stop = ExprNodes.IntNode( + slice_node.pos, value='-1', type=PyrexTypes.c_py_ssize_t_type, constant_result=-1) + else: + error(slice_node.pos, "C array iteration requires known step size and end index") + return node + + if reversed: + if not start: + start = ExprNodes.IntNode(slice_node.pos, value="0", constant_result=0, + type=PyrexTypes.c_py_ssize_t_type) + # if step was provided, it was already negated above + start, stop = stop, start + + ptr_type = slice_base.type + if ptr_type.is_array: + ptr_type = ptr_type.element_ptr_type() + carray_ptr = slice_base.coerce_to_simple(self.current_env()) + + if start and start.constant_result != 0: + start_ptr_node = ExprNodes.AddNode( + start.pos, + operand1=carray_ptr, + operator='+', + operand2=start, + type=ptr_type) + else: + start_ptr_node = carray_ptr + + if stop and stop.constant_result != 0: + stop_ptr_node = ExprNodes.AddNode( + stop.pos, + operand1=ExprNodes.CloneNode(carray_ptr), + operator='+', + operand2=stop, + type=ptr_type + ).coerce_to_simple(self.current_env()) + else: + stop_ptr_node = ExprNodes.CloneNode(carray_ptr) + + counter = UtilNodes.TempHandle(ptr_type) + counter_temp = counter.ref(node.target.pos) + + if slice_base.type.is_string and node.target.type.is_pyobject: + # special case: char* -> bytes/unicode + if slice_node.type is Builtin.unicode_type: + target_value = ExprNodes.CastNode( + ExprNodes.DereferenceNode( + node.target.pos, operand=counter_temp, + type=ptr_type.base_type), + PyrexTypes.c_py_ucs4_type).coerce_to( + node.target.type, self.current_env()) + else: + # char* -> bytes coercion requires slicing, not indexing + target_value = ExprNodes.SliceIndexNode( + node.target.pos, + start=ExprNodes.IntNode(node.target.pos, value='0', + constant_result=0, + type=PyrexTypes.c_int_type), + stop=ExprNodes.IntNode(node.target.pos, value='1', + constant_result=1, + type=PyrexTypes.c_int_type), + base=counter_temp, + type=Builtin.bytes_type, + is_temp=1) + elif node.target.type.is_ptr and not node.target.type.assignable_from(ptr_type.base_type): + # Allow iteration with pointer target to avoid copy. + target_value = counter_temp + else: + # TODO: can this safely be replaced with DereferenceNode() as above? + target_value = ExprNodes.IndexNode( + node.target.pos, + index=ExprNodes.IntNode(node.target.pos, value='0', + constant_result=0, + type=PyrexTypes.c_int_type), + base=counter_temp, + type=ptr_type.base_type) + + if target_value.type != node.target.type: + target_value = target_value.coerce_to(node.target.type, + self.current_env()) + + target_assign = Nodes.SingleAssignmentNode( + pos = node.target.pos, + lhs = node.target, + rhs = target_value) + + body = Nodes.StatListNode( + node.pos, + stats = [target_assign, node.body]) + + relation1, relation2 = self._find_for_from_node_relations(neg_step, reversed) + + for_node = Nodes.ForFromStatNode( + node.pos, + bound1=start_ptr_node, relation1=relation1, + target=counter_temp, + relation2=relation2, bound2=stop_ptr_node, + step=step, body=body, + else_clause=node.else_clause, + from_range=True) + + return UtilNodes.TempsBlockNode( + node.pos, temps=[counter], + body=for_node) + + def _transform_enumerate_iteration(self, node, enumerate_function): + args = enumerate_function.arg_tuple.args + if len(args) == 0: + error(enumerate_function.pos, + "enumerate() requires an iterable argument") + return node + elif len(args) > 2: + error(enumerate_function.pos, + "enumerate() takes at most 2 arguments") + return node + + if not node.target.is_sequence_constructor: + # leave this untouched for now + return node + targets = node.target.args + if len(targets) != 2: + # leave this untouched for now + return node + + enumerate_target, iterable_target = targets + counter_type = enumerate_target.type + + if not counter_type.is_pyobject and not counter_type.is_int: + # nothing we can do here, I guess + return node + + if len(args) == 2: + start = unwrap_coerced_node(args[1]).coerce_to(counter_type, self.current_env()) + else: + start = ExprNodes.IntNode(enumerate_function.pos, + value='0', + type=counter_type, + constant_result=0) + temp = UtilNodes.LetRefNode(start) + + inc_expression = ExprNodes.AddNode( + enumerate_function.pos, + operand1 = temp, + operand2 = ExprNodes.IntNode(node.pos, value='1', + type=counter_type, + constant_result=1), + operator = '+', + type = counter_type, + #inplace = True, # not worth using in-place operation for Py ints + is_temp = counter_type.is_pyobject + ) + + loop_body = [ + Nodes.SingleAssignmentNode( + pos = enumerate_target.pos, + lhs = enumerate_target, + rhs = temp), + Nodes.SingleAssignmentNode( + pos = enumerate_target.pos, + lhs = temp, + rhs = inc_expression) + ] + + if isinstance(node.body, Nodes.StatListNode): + node.body.stats = loop_body + node.body.stats + else: + loop_body.append(node.body) + node.body = Nodes.StatListNode( + node.body.pos, + stats = loop_body) + + node.target = iterable_target + node.item = node.item.coerce_to(iterable_target.type, self.current_env()) + node.iterator.sequence = args[0] + + # recurse into loop to check for further optimisations + return UtilNodes.LetNode(temp, self._optimise_for_loop(node, node.iterator.sequence)) + + def _find_for_from_node_relations(self, neg_step_value, reversed): + if reversed: + if neg_step_value: + return '<', '<=' + else: + return '>', '>=' + else: + if neg_step_value: + return '>=', '>' + else: + return '<=', '<' + + def _transform_range_iteration(self, node, range_function, reversed=False): + args = range_function.arg_tuple.args + if len(args) < 3: + step_pos = range_function.pos + step_value = 1 + step = ExprNodes.IntNode(step_pos, value='1', constant_result=1) + else: + step = args[2] + step_pos = step.pos + if not isinstance(step.constant_result, _py_int_types): + # cannot determine step direction + return node + step_value = step.constant_result + if step_value == 0: + # will lead to an error elsewhere + return node + step = ExprNodes.IntNode(step_pos, value=str(step_value), + constant_result=step_value) + + if len(args) == 1: + bound1 = ExprNodes.IntNode(range_function.pos, value='0', + constant_result=0) + bound2 = args[0].coerce_to_integer(self.current_env()) + else: + bound1 = args[0].coerce_to_integer(self.current_env()) + bound2 = args[1].coerce_to_integer(self.current_env()) + + relation1, relation2 = self._find_for_from_node_relations(step_value < 0, reversed) + + bound2_ref_node = None + if reversed: + bound1, bound2 = bound2, bound1 + abs_step = abs(step_value) + if abs_step != 1: + if (isinstance(bound1.constant_result, _py_int_types) and + isinstance(bound2.constant_result, _py_int_types)): + # calculate final bounds now + if step_value < 0: + begin_value = bound2.constant_result + end_value = bound1.constant_result + bound1_value = begin_value - abs_step * ((begin_value - end_value - 1) // abs_step) - 1 + else: + begin_value = bound1.constant_result + end_value = bound2.constant_result + bound1_value = end_value + abs_step * ((begin_value - end_value - 1) // abs_step) + 1 + + bound1 = ExprNodes.IntNode( + bound1.pos, value=str(bound1_value), constant_result=bound1_value, + type=PyrexTypes.spanning_type(bound1.type, bound2.type)) + else: + # evaluate the same expression as above at runtime + bound2_ref_node = UtilNodes.LetRefNode(bound2) + bound1 = self._build_range_step_calculation( + bound1, bound2_ref_node, step, step_value) + + if step_value < 0: + step_value = -step_value + step.value = str(step_value) + step.constant_result = step_value + step = step.coerce_to_integer(self.current_env()) + + if not bound2.is_literal: + # stop bound must be immutable => keep it in a temp var + bound2_is_temp = True + bound2 = bound2_ref_node or UtilNodes.LetRefNode(bound2) + else: + bound2_is_temp = False + + for_node = Nodes.ForFromStatNode( + node.pos, + target=node.target, + bound1=bound1, relation1=relation1, + relation2=relation2, bound2=bound2, + step=step, body=node.body, + else_clause=node.else_clause, + from_range=True) + for_node.set_up_loop(self.current_env()) + + if bound2_is_temp: + for_node = UtilNodes.LetNode(bound2, for_node) + + return for_node + + def _build_range_step_calculation(self, bound1, bound2_ref_node, step, step_value): + abs_step = abs(step_value) + spanning_type = PyrexTypes.spanning_type(bound1.type, bound2_ref_node.type) + if step.type.is_int and abs_step < 0x7FFF: + # Avoid loss of integer precision warnings. + spanning_step_type = PyrexTypes.spanning_type(spanning_type, PyrexTypes.c_int_type) + else: + spanning_step_type = PyrexTypes.spanning_type(spanning_type, step.type) + if step_value < 0: + begin_value = bound2_ref_node + end_value = bound1 + final_op = '-' + else: + begin_value = bound1 + end_value = bound2_ref_node + final_op = '+' + + step_calculation_node = ExprNodes.binop_node( + bound1.pos, + operand1=ExprNodes.binop_node( + bound1.pos, + operand1=bound2_ref_node, + operator=final_op, # +/- + operand2=ExprNodes.MulNode( + bound1.pos, + operand1=ExprNodes.IntNode( + bound1.pos, + value=str(abs_step), + constant_result=abs_step, + type=spanning_step_type), + operator='*', + operand2=ExprNodes.DivNode( + bound1.pos, + operand1=ExprNodes.SubNode( + bound1.pos, + operand1=ExprNodes.SubNode( + bound1.pos, + operand1=begin_value, + operator='-', + operand2=end_value, + type=spanning_type), + operator='-', + operand2=ExprNodes.IntNode( + bound1.pos, + value='1', + constant_result=1), + type=spanning_step_type), + operator='//', + operand2=ExprNodes.IntNode( + bound1.pos, + value=str(abs_step), + constant_result=abs_step, + type=spanning_step_type), + type=spanning_step_type), + type=spanning_step_type), + type=spanning_step_type), + operator=final_op, # +/- + operand2=ExprNodes.IntNode( + bound1.pos, + value='1', + constant_result=1), + type=spanning_type) + return step_calculation_node + + def _transform_dict_iteration(self, node, dict_obj, method, keys, values): + temps = [] + temp = UtilNodes.TempHandle(PyrexTypes.py_object_type) + temps.append(temp) + dict_temp = temp.ref(dict_obj.pos) + temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) + temps.append(temp) + pos_temp = temp.ref(node.pos) + + key_target = value_target = tuple_target = None + if keys and values: + if node.target.is_sequence_constructor: + if len(node.target.args) == 2: + key_target, value_target = node.target.args + else: + # unusual case that may or may not lead to an error + return node + else: + tuple_target = node.target + elif keys: + key_target = node.target + else: + value_target = node.target + + if isinstance(node.body, Nodes.StatListNode): + body = node.body + else: + body = Nodes.StatListNode(pos = node.body.pos, + stats = [node.body]) + + # keep original length to guard against dict modification + dict_len_temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) + temps.append(dict_len_temp) + dict_len_temp_addr = ExprNodes.AmpersandNode( + node.pos, operand=dict_len_temp.ref(dict_obj.pos), + type=PyrexTypes.c_ptr_type(dict_len_temp.type)) + temp = UtilNodes.TempHandle(PyrexTypes.c_int_type) + temps.append(temp) + is_dict_temp = temp.ref(node.pos) + is_dict_temp_addr = ExprNodes.AmpersandNode( + node.pos, operand=is_dict_temp, + type=PyrexTypes.c_ptr_type(temp.type)) + + iter_next_node = Nodes.DictIterationNextNode( + dict_temp, dict_len_temp.ref(dict_obj.pos), pos_temp, + key_target, value_target, tuple_target, + is_dict_temp) + iter_next_node = iter_next_node.analyse_expressions(self.current_env()) + body.stats[0:0] = [iter_next_node] + + if method: + method_node = ExprNodes.StringNode( + dict_obj.pos, is_identifier=True, value=method) + dict_obj = dict_obj.as_none_safe_node( + "'NoneType' object has no attribute '%{0}s'".format('.30' if len(method) <= 30 else ''), + error = "PyExc_AttributeError", + format_args = [method]) + else: + method_node = ExprNodes.NullNode(dict_obj.pos) + dict_obj = dict_obj.as_none_safe_node("'NoneType' object is not iterable") + + def flag_node(value): + value = value and 1 or 0 + return ExprNodes.IntNode(node.pos, value=str(value), constant_result=value) + + result_code = [ + Nodes.SingleAssignmentNode( + node.pos, + lhs = pos_temp, + rhs = ExprNodes.IntNode(node.pos, value='0', + constant_result=0)), + Nodes.SingleAssignmentNode( + dict_obj.pos, + lhs = dict_temp, + rhs = ExprNodes.PythonCapiCallNode( + dict_obj.pos, + "__Pyx_dict_iterator", + self.PyDict_Iterator_func_type, + utility_code = UtilityCode.load_cached("dict_iter", "Optimize.c"), + args = [dict_obj, flag_node(dict_obj.type is Builtin.dict_type), + method_node, dict_len_temp_addr, is_dict_temp_addr, + ], + is_temp=True, + )), + Nodes.WhileStatNode( + node.pos, + condition = None, + body = body, + else_clause = node.else_clause + ) + ] + + return UtilNodes.TempsBlockNode( + node.pos, temps=temps, + body=Nodes.StatListNode( + node.pos, + stats = result_code + )) + + PyDict_Iterator_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("dict", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("is_dict", PyrexTypes.c_int_type, None), + PyrexTypes.CFuncTypeArg("method_name", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("p_orig_length", PyrexTypes.c_py_ssize_t_ptr_type, None), + PyrexTypes.CFuncTypeArg("p_is_dict", PyrexTypes.c_int_ptr_type, None), + ]) + + PySet_Iterator_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("set", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("is_set", PyrexTypes.c_int_type, None), + PyrexTypes.CFuncTypeArg("p_orig_length", PyrexTypes.c_py_ssize_t_ptr_type, None), + PyrexTypes.CFuncTypeArg("p_is_set", PyrexTypes.c_int_ptr_type, None), + ]) + + def _transform_set_iteration(self, node, set_obj): + temps = [] + temp = UtilNodes.TempHandle(PyrexTypes.py_object_type) + temps.append(temp) + set_temp = temp.ref(set_obj.pos) + temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) + temps.append(temp) + pos_temp = temp.ref(node.pos) + + if isinstance(node.body, Nodes.StatListNode): + body = node.body + else: + body = Nodes.StatListNode(pos = node.body.pos, + stats = [node.body]) + + # keep original length to guard against set modification + set_len_temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) + temps.append(set_len_temp) + set_len_temp_addr = ExprNodes.AmpersandNode( + node.pos, operand=set_len_temp.ref(set_obj.pos), + type=PyrexTypes.c_ptr_type(set_len_temp.type)) + temp = UtilNodes.TempHandle(PyrexTypes.c_int_type) + temps.append(temp) + is_set_temp = temp.ref(node.pos) + is_set_temp_addr = ExprNodes.AmpersandNode( + node.pos, operand=is_set_temp, + type=PyrexTypes.c_ptr_type(temp.type)) + + value_target = node.target + iter_next_node = Nodes.SetIterationNextNode( + set_temp, set_len_temp.ref(set_obj.pos), pos_temp, value_target, is_set_temp) + iter_next_node = iter_next_node.analyse_expressions(self.current_env()) + body.stats[0:0] = [iter_next_node] + + def flag_node(value): + value = value and 1 or 0 + return ExprNodes.IntNode(node.pos, value=str(value), constant_result=value) + + result_code = [ + Nodes.SingleAssignmentNode( + node.pos, + lhs=pos_temp, + rhs=ExprNodes.IntNode(node.pos, value='0', constant_result=0)), + Nodes.SingleAssignmentNode( + set_obj.pos, + lhs=set_temp, + rhs=ExprNodes.PythonCapiCallNode( + set_obj.pos, + "__Pyx_set_iterator", + self.PySet_Iterator_func_type, + utility_code=UtilityCode.load_cached("set_iter", "Optimize.c"), + args=[set_obj, flag_node(set_obj.type is Builtin.set_type), + set_len_temp_addr, is_set_temp_addr, + ], + is_temp=True, + )), + Nodes.WhileStatNode( + node.pos, + condition=None, + body=body, + else_clause=node.else_clause, + ) + ] + + return UtilNodes.TempsBlockNode( + node.pos, temps=temps, + body=Nodes.StatListNode( + node.pos, + stats = result_code + )) + + +class SwitchTransform(Visitor.EnvTransform): + """ + This transformation tries to turn long if statements into C switch statements. + The requirement is that every clause be an (or of) var == value, where the var + is common among all clauses and both var and value are ints. + """ + NO_MATCH = (None, None, None) + + def extract_conditions(self, cond, allow_not_in): + while True: + if isinstance(cond, (ExprNodes.CoerceToTempNode, + ExprNodes.CoerceToBooleanNode)): + cond = cond.arg + elif isinstance(cond, ExprNodes.BoolBinopResultNode): + cond = cond.arg.arg + elif isinstance(cond, UtilNodes.EvalWithTempExprNode): + # this is what we get from the FlattenInListTransform + cond = cond.subexpression + elif isinstance(cond, ExprNodes.TypecastNode): + cond = cond.operand + else: + break + + if isinstance(cond, ExprNodes.PrimaryCmpNode): + if cond.cascade is not None: + return self.NO_MATCH + elif cond.is_c_string_contains() and \ + isinstance(cond.operand2, (ExprNodes.UnicodeNode, ExprNodes.BytesNode)): + not_in = cond.operator == 'not_in' + if not_in and not allow_not_in: + return self.NO_MATCH + if isinstance(cond.operand2, ExprNodes.UnicodeNode) and \ + cond.operand2.contains_surrogates(): + # dealing with surrogates leads to different + # behaviour on wide and narrow Unicode + # platforms => refuse to optimise this case + return self.NO_MATCH + return not_in, cond.operand1, self.extract_in_string_conditions(cond.operand2) + elif not cond.is_python_comparison(): + if cond.operator == '==': + not_in = False + elif allow_not_in and cond.operator == '!=': + not_in = True + else: + return self.NO_MATCH + # this looks somewhat silly, but it does the right + # checks for NameNode and AttributeNode + if is_common_value(cond.operand1, cond.operand1): + if cond.operand2.is_literal: + return not_in, cond.operand1, [cond.operand2] + elif getattr(cond.operand2, 'entry', None) \ + and cond.operand2.entry.is_const: + return not_in, cond.operand1, [cond.operand2] + if is_common_value(cond.operand2, cond.operand2): + if cond.operand1.is_literal: + return not_in, cond.operand2, [cond.operand1] + elif getattr(cond.operand1, 'entry', None) \ + and cond.operand1.entry.is_const: + return not_in, cond.operand2, [cond.operand1] + elif isinstance(cond, ExprNodes.BoolBinopNode): + if cond.operator == 'or' or (allow_not_in and cond.operator == 'and'): + allow_not_in = (cond.operator == 'and') + not_in_1, t1, c1 = self.extract_conditions(cond.operand1, allow_not_in) + not_in_2, t2, c2 = self.extract_conditions(cond.operand2, allow_not_in) + if t1 is not None and not_in_1 == not_in_2 and is_common_value(t1, t2): + if (not not_in_1) or allow_not_in: + return not_in_1, t1, c1+c2 + return self.NO_MATCH + + def extract_in_string_conditions(self, string_literal): + if isinstance(string_literal, ExprNodes.UnicodeNode): + charvals = list(map(ord, set(string_literal.value))) + charvals.sort() + return [ ExprNodes.IntNode(string_literal.pos, value=str(charval), + constant_result=charval) + for charval in charvals ] + else: + # this is a bit tricky as Py3's bytes type returns + # integers on iteration, whereas Py2 returns 1-char byte + # strings + characters = string_literal.value + characters = list(set([ characters[i:i+1] for i in range(len(characters)) ])) + characters.sort() + return [ ExprNodes.CharNode(string_literal.pos, value=charval, + constant_result=charval) + for charval in characters ] + + def extract_common_conditions(self, common_var, condition, allow_not_in): + not_in, var, conditions = self.extract_conditions(condition, allow_not_in) + if var is None: + return self.NO_MATCH + elif common_var is not None and not is_common_value(var, common_var): + return self.NO_MATCH + elif not (var.type.is_int or var.type.is_enum) or sum([not (cond.type.is_int or cond.type.is_enum) for cond in conditions]): + return self.NO_MATCH + return not_in, var, conditions + + def has_duplicate_values(self, condition_values): + # duplicated values don't work in a switch statement + seen = set() + for value in condition_values: + if value.has_constant_result(): + if value.constant_result in seen: + return True + seen.add(value.constant_result) + else: + # this isn't completely safe as we don't know the + # final C value, but this is about the best we can do + try: + if value.entry.cname in seen: + return True + except AttributeError: + return True # play safe + seen.add(value.entry.cname) + return False + + def visit_IfStatNode(self, node): + if not self.current_directives.get('optimize.use_switch'): + self.visitchildren(node) + return node + + common_var = None + cases = [] + for if_clause in node.if_clauses: + _, common_var, conditions = self.extract_common_conditions( + common_var, if_clause.condition, False) + if common_var is None: + self.visitchildren(node) + return node + cases.append(Nodes.SwitchCaseNode(pos=if_clause.pos, + conditions=conditions, + body=if_clause.body)) + + condition_values = [ + cond for case in cases for cond in case.conditions] + if len(condition_values) < 2: + self.visitchildren(node) + return node + if self.has_duplicate_values(condition_values): + self.visitchildren(node) + return node + + # Recurse into body subtrees that we left untouched so far. + self.visitchildren(node, 'else_clause') + for case in cases: + self.visitchildren(case, 'body') + + common_var = unwrap_node(common_var) + switch_node = Nodes.SwitchStatNode(pos=node.pos, + test=common_var, + cases=cases, + else_clause=node.else_clause) + return switch_node + + def visit_CondExprNode(self, node): + if not self.current_directives.get('optimize.use_switch'): + self.visitchildren(node) + return node + + not_in, common_var, conditions = self.extract_common_conditions( + None, node.test, True) + if common_var is None \ + or len(conditions) < 2 \ + or self.has_duplicate_values(conditions): + self.visitchildren(node) + return node + + return self.build_simple_switch_statement( + node, common_var, conditions, not_in, + node.true_val, node.false_val) + + def visit_BoolBinopNode(self, node): + if not self.current_directives.get('optimize.use_switch'): + self.visitchildren(node) + return node + + not_in, common_var, conditions = self.extract_common_conditions( + None, node, True) + if common_var is None \ + or len(conditions) < 2 \ + or self.has_duplicate_values(conditions): + self.visitchildren(node) + node.wrap_operands(self.current_env()) # in case we changed the operands + return node + + return self.build_simple_switch_statement( + node, common_var, conditions, not_in, + ExprNodes.BoolNode(node.pos, value=True, constant_result=True), + ExprNodes.BoolNode(node.pos, value=False, constant_result=False)) + + def visit_PrimaryCmpNode(self, node): + if not self.current_directives.get('optimize.use_switch'): + self.visitchildren(node) + return node + + not_in, common_var, conditions = self.extract_common_conditions( + None, node, True) + if common_var is None \ + or len(conditions) < 2 \ + or self.has_duplicate_values(conditions): + self.visitchildren(node) + return node + + return self.build_simple_switch_statement( + node, common_var, conditions, not_in, + ExprNodes.BoolNode(node.pos, value=True, constant_result=True), + ExprNodes.BoolNode(node.pos, value=False, constant_result=False)) + + def build_simple_switch_statement(self, node, common_var, conditions, + not_in, true_val, false_val): + result_ref = UtilNodes.ResultRefNode(node) + true_body = Nodes.SingleAssignmentNode( + node.pos, + lhs=result_ref, + rhs=true_val.coerce_to(node.type, self.current_env()), + first=True) + false_body = Nodes.SingleAssignmentNode( + node.pos, + lhs=result_ref, + rhs=false_val.coerce_to(node.type, self.current_env()), + first=True) + + if not_in: + true_body, false_body = false_body, true_body + + cases = [Nodes.SwitchCaseNode(pos = node.pos, + conditions = conditions, + body = true_body)] + + common_var = unwrap_node(common_var) + switch_node = Nodes.SwitchStatNode(pos = node.pos, + test = common_var, + cases = cases, + else_clause = false_body) + replacement = UtilNodes.TempResultFromStatNode(result_ref, switch_node) + return replacement + + def visit_EvalWithTempExprNode(self, node): + if not self.current_directives.get('optimize.use_switch'): + self.visitchildren(node) + return node + + # drop unused expression temp from FlattenInListTransform + orig_expr = node.subexpression + temp_ref = node.lazy_temp + self.visitchildren(node) + if node.subexpression is not orig_expr: + # node was restructured => check if temp is still used + if not Visitor.tree_contains(node.subexpression, temp_ref): + return node.subexpression + return node + + visit_Node = Visitor.VisitorTransform.recurse_to_children + + +class FlattenInListTransform(Visitor.VisitorTransform, SkipDeclarations): + """ + This transformation flattens "x in [val1, ..., valn]" into a sequential list + of comparisons. + """ + + def visit_PrimaryCmpNode(self, node): + self.visitchildren(node) + if node.cascade is not None: + return node + elif node.operator == 'in': + conjunction = 'or' + eq_or_neq = '==' + elif node.operator == 'not_in': + conjunction = 'and' + eq_or_neq = '!=' + else: + return node + + if not isinstance(node.operand2, (ExprNodes.TupleNode, + ExprNodes.ListNode, + ExprNodes.SetNode)): + return node + + args = node.operand2.args + if len(args) == 0: + # note: lhs may have side effects + return node + + if any([arg.is_starred for arg in args]): + # Starred arguments do not directly translate to comparisons or "in" tests. + return node + + lhs = UtilNodes.ResultRefNode(node.operand1) + + conds = [] + temps = [] + for arg in args: + try: + # Trial optimisation to avoid redundant temp + # assignments. However, since is_simple() is meant to + # be called after type analysis, we ignore any errors + # and just play safe in that case. + is_simple_arg = arg.is_simple() + except Exception: + is_simple_arg = False + if not is_simple_arg: + # must evaluate all non-simple RHS before doing the comparisons + arg = UtilNodes.LetRefNode(arg) + temps.append(arg) + cond = ExprNodes.PrimaryCmpNode( + pos = node.pos, + operand1 = lhs, + operator = eq_or_neq, + operand2 = arg, + cascade = None) + conds.append(ExprNodes.TypecastNode( + pos = node.pos, + operand = cond, + type = PyrexTypes.c_bint_type)) + def concat(left, right): + return ExprNodes.BoolBinopNode( + pos = node.pos, + operator = conjunction, + operand1 = left, + operand2 = right) + + condition = reduce(concat, conds) + new_node = UtilNodes.EvalWithTempExprNode(lhs, condition) + for temp in temps[::-1]: + new_node = UtilNodes.EvalWithTempExprNode(temp, new_node) + return new_node + + visit_Node = Visitor.VisitorTransform.recurse_to_children + + +class DropRefcountingTransform(Visitor.VisitorTransform): + """Drop ref-counting in safe places. + """ + visit_Node = Visitor.VisitorTransform.recurse_to_children + + def visit_ParallelAssignmentNode(self, node): + """ + Parallel swap assignments like 'a,b = b,a' are safe. + """ + left_names, right_names = [], [] + left_indices, right_indices = [], [] + temps = [] + + for stat in node.stats: + if isinstance(stat, Nodes.SingleAssignmentNode): + if not self._extract_operand(stat.lhs, left_names, + left_indices, temps): + return node + if not self._extract_operand(stat.rhs, right_names, + right_indices, temps): + return node + elif isinstance(stat, Nodes.CascadedAssignmentNode): + # FIXME + return node + else: + return node + + if left_names or right_names: + # lhs/rhs names must be a non-redundant permutation + lnames = [ path for path, n in left_names ] + rnames = [ path for path, n in right_names ] + if set(lnames) != set(rnames): + return node + if len(set(lnames)) != len(right_names): + return node + + if left_indices or right_indices: + # base name and index of index nodes must be a + # non-redundant permutation + lindices = [] + for lhs_node in left_indices: + index_id = self._extract_index_id(lhs_node) + if not index_id: + return node + lindices.append(index_id) + rindices = [] + for rhs_node in right_indices: + index_id = self._extract_index_id(rhs_node) + if not index_id: + return node + rindices.append(index_id) + + if set(lindices) != set(rindices): + return node + if len(set(lindices)) != len(right_indices): + return node + + # really supporting IndexNode requires support in + # __Pyx_GetItemInt(), so let's stop short for now + return node + + temp_args = [t.arg for t in temps] + for temp in temps: + temp.use_managed_ref = False + + for _, name_node in left_names + right_names: + if name_node not in temp_args: + name_node.use_managed_ref = False + + for index_node in left_indices + right_indices: + index_node.use_managed_ref = False + + return node + + def _extract_operand(self, node, names, indices, temps): + node = unwrap_node(node) + if not node.type.is_pyobject: + return False + if isinstance(node, ExprNodes.CoerceToTempNode): + temps.append(node) + node = node.arg + name_path = [] + obj_node = node + while obj_node.is_attribute: + if obj_node.is_py_attr: + return False + name_path.append(obj_node.member) + obj_node = obj_node.obj + if obj_node.is_name: + name_path.append(obj_node.name) + names.append( ('.'.join(name_path[::-1]), node) ) + elif node.is_subscript: + if node.base.type != Builtin.list_type: + return False + if not node.index.type.is_int: + return False + if not node.base.is_name: + return False + indices.append(node) + else: + return False + return True + + def _extract_index_id(self, index_node): + base = index_node.base + index = index_node.index + if isinstance(index, ExprNodes.NameNode): + index_val = index.name + elif isinstance(index, ExprNodes.ConstNode): + # FIXME: + return None + else: + return None + return (base.name, index_val) + + +class EarlyReplaceBuiltinCalls(Visitor.EnvTransform): + """Optimize some common calls to builtin types *before* the type + analysis phase and *after* the declarations analysis phase. + + This transform cannot make use of any argument types, but it can + restructure the tree in a way that the type analysis phase can + respond to. + + Introducing C function calls here may not be a good idea. Move + them to the OptimizeBuiltinCalls transform instead, which runs + after type analysis. + """ + # only intercept on call nodes + visit_Node = Visitor.VisitorTransform.recurse_to_children + + def visit_SimpleCallNode(self, node): + self.visitchildren(node) + function = node.function + if not self._function_is_builtin_name(function): + return node + return self._dispatch_to_handler(node, function, node.args) + + def visit_GeneralCallNode(self, node): + self.visitchildren(node) + function = node.function + if not self._function_is_builtin_name(function): + return node + arg_tuple = node.positional_args + if not isinstance(arg_tuple, ExprNodes.TupleNode): + return node + args = arg_tuple.args + return self._dispatch_to_handler( + node, function, args, node.keyword_args) + + def _function_is_builtin_name(self, function): + if not function.is_name: + return False + env = self.current_env() + entry = env.lookup(function.name) + if entry is not env.builtin_scope().lookup_here(function.name): + return False + # if entry is None, it's at least an undeclared name, so likely builtin + return True + + def _dispatch_to_handler(self, node, function, args, kwargs=None): + if kwargs is None: + handler_name = '_handle_simple_function_%s' % function.name + else: + handler_name = '_handle_general_function_%s' % function.name + handle_call = getattr(self, handler_name, None) + if handle_call is not None: + if kwargs is None: + return handle_call(node, args) + else: + return handle_call(node, args, kwargs) + return node + + def _inject_capi_function(self, node, cname, func_type, utility_code=None): + node.function = ExprNodes.PythonCapiFunctionNode( + node.function.pos, node.function.name, cname, func_type, + utility_code = utility_code) + + def _error_wrong_arg_count(self, function_name, node, args, expected=None): + if not expected: # None or 0 + arg_str = '' + elif isinstance(expected, basestring) or expected > 1: + arg_str = '...' + elif expected == 1: + arg_str = 'x' + else: + arg_str = '' + if expected is not None: + expected_str = 'expected %s, ' % expected + else: + expected_str = '' + error(node.pos, "%s(%s) called with wrong number of args, %sfound %d" % ( + function_name, arg_str, expected_str, len(args))) + + # specific handlers for simple call nodes + + def _handle_simple_function_float(self, node, pos_args): + if not pos_args: + return ExprNodes.FloatNode(node.pos, value='0.0') + if len(pos_args) > 1: + self._error_wrong_arg_count('float', node, pos_args, 1) + arg_type = getattr(pos_args[0], 'type', None) + if arg_type in (PyrexTypes.c_double_type, Builtin.float_type): + return pos_args[0] + return node + + def _handle_simple_function_slice(self, node, pos_args): + arg_count = len(pos_args) + start = step = None + if arg_count == 1: + stop, = pos_args + elif arg_count == 2: + start, stop = pos_args + elif arg_count == 3: + start, stop, step = pos_args + else: + self._error_wrong_arg_count('slice', node, pos_args) + return node + return ExprNodes.SliceNode( + node.pos, + start=start or ExprNodes.NoneNode(node.pos), + stop=stop, + step=step or ExprNodes.NoneNode(node.pos)) + + def _handle_simple_function_ord(self, node, pos_args): + """Unpack ord('X'). + """ + if len(pos_args) != 1: + return node + arg = pos_args[0] + if isinstance(arg, (ExprNodes.UnicodeNode, ExprNodes.BytesNode)): + if len(arg.value) == 1: + return ExprNodes.IntNode( + arg.pos, type=PyrexTypes.c_long_type, + value=str(ord(arg.value)), + constant_result=ord(arg.value) + ) + elif isinstance(arg, ExprNodes.StringNode): + if arg.unicode_value and len(arg.unicode_value) == 1 \ + and ord(arg.unicode_value) <= 255: # Py2/3 portability + return ExprNodes.IntNode( + arg.pos, type=PyrexTypes.c_int_type, + value=str(ord(arg.unicode_value)), + constant_result=ord(arg.unicode_value) + ) + return node + + # sequence processing + + def _handle_simple_function_all(self, node, pos_args): + """Transform + + _result = all(p(x) for L in LL for x in L) + + into + + for L in LL: + for x in L: + if not p(x): + return False + else: + return True + """ + return self._transform_any_all(node, pos_args, False) + + def _handle_simple_function_any(self, node, pos_args): + """Transform + + _result = any(p(x) for L in LL for x in L) + + into + + for L in LL: + for x in L: + if p(x): + return True + else: + return False + """ + return self._transform_any_all(node, pos_args, True) + + def _transform_any_all(self, node, pos_args, is_any): + if len(pos_args) != 1: + return node + if not isinstance(pos_args[0], ExprNodes.GeneratorExpressionNode): + return node + gen_expr_node = pos_args[0] + generator_body = gen_expr_node.def_node.gbody + loop_node = generator_body.body + yield_expression, yield_stat_node = _find_single_yield_expression(loop_node) + if yield_expression is None: + return node + + if is_any: + condition = yield_expression + else: + condition = ExprNodes.NotNode(yield_expression.pos, operand=yield_expression) + + test_node = Nodes.IfStatNode( + yield_expression.pos, else_clause=None, if_clauses=[ + Nodes.IfClauseNode( + yield_expression.pos, + condition=condition, + body=Nodes.ReturnStatNode( + node.pos, + value=ExprNodes.BoolNode(yield_expression.pos, value=is_any, constant_result=is_any)) + )] + ) + loop_node.else_clause = Nodes.ReturnStatNode( + node.pos, + value=ExprNodes.BoolNode(yield_expression.pos, value=not is_any, constant_result=not is_any)) + + Visitor.recursively_replace_node(gen_expr_node, yield_stat_node, test_node) + + return ExprNodes.InlinedGeneratorExpressionNode( + gen_expr_node.pos, gen=gen_expr_node, orig_func='any' if is_any else 'all') + + PySequence_List_func_type = PyrexTypes.CFuncType( + Builtin.list_type, + [PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None)]) + + def _handle_simple_function_sorted(self, node, pos_args): + """Transform sorted(genexpr) and sorted([listcomp]) into + [listcomp].sort(). CPython just reads the iterable into a + list and calls .sort() on it. Expanding the iterable in a + listcomp is still faster and the result can be sorted in + place. + """ + if len(pos_args) != 1: + return node + + arg = pos_args[0] + if isinstance(arg, ExprNodes.ComprehensionNode) and arg.type is Builtin.list_type: + list_node = pos_args[0] + loop_node = list_node.loop + + elif isinstance(arg, ExprNodes.GeneratorExpressionNode): + gen_expr_node = arg + loop_node = gen_expr_node.loop + yield_statements = _find_yield_statements(loop_node) + if not yield_statements: + return node + + list_node = ExprNodes.InlinedGeneratorExpressionNode( + node.pos, gen_expr_node, orig_func='sorted', + comprehension_type=Builtin.list_type) + + for yield_expression, yield_stat_node in yield_statements: + append_node = ExprNodes.ComprehensionAppendNode( + yield_expression.pos, + expr=yield_expression, + target=list_node.target) + Visitor.recursively_replace_node(gen_expr_node, yield_stat_node, append_node) + + elif arg.is_sequence_constructor: + # sorted([a, b, c]) or sorted((a, b, c)). The result is always a list, + # so starting off with a fresh one is more efficient. + list_node = loop_node = arg.as_list() + + else: + # Interestingly, PySequence_List works on a lot of non-sequence + # things as well. + list_node = loop_node = ExprNodes.PythonCapiCallNode( + node.pos, "PySequence_List", self.PySequence_List_func_type, + args=pos_args, is_temp=True) + + result_node = UtilNodes.ResultRefNode( + pos=loop_node.pos, type=Builtin.list_type, may_hold_none=False) + list_assign_node = Nodes.SingleAssignmentNode( + node.pos, lhs=result_node, rhs=list_node, first=True) + + sort_method = ExprNodes.AttributeNode( + node.pos, obj=result_node, attribute=EncodedString('sort'), + # entry ? type ? + needs_none_check=False) + sort_node = Nodes.ExprStatNode( + node.pos, expr=ExprNodes.SimpleCallNode( + node.pos, function=sort_method, args=[])) + + sort_node.analyse_declarations(self.current_env()) + + return UtilNodes.TempResultFromStatNode( + result_node, + Nodes.StatListNode(node.pos, stats=[list_assign_node, sort_node])) + + def __handle_simple_function_sum(self, node, pos_args): + """Transform sum(genexpr) into an equivalent inlined aggregation loop. + """ + if len(pos_args) not in (1,2): + return node + if not isinstance(pos_args[0], (ExprNodes.GeneratorExpressionNode, + ExprNodes.ComprehensionNode)): + return node + gen_expr_node = pos_args[0] + loop_node = gen_expr_node.loop + + if isinstance(gen_expr_node, ExprNodes.GeneratorExpressionNode): + yield_expression, yield_stat_node = _find_single_yield_expression(loop_node) + # FIXME: currently nonfunctional + yield_expression = None + if yield_expression is None: + return node + else: # ComprehensionNode + yield_stat_node = gen_expr_node.append + yield_expression = yield_stat_node.expr + try: + if not yield_expression.is_literal or not yield_expression.type.is_int: + return node + except AttributeError: + return node # in case we don't have a type yet + # special case: old Py2 backwards compatible "sum([int_const for ...])" + # can safely be unpacked into a genexpr + + if len(pos_args) == 1: + start = ExprNodes.IntNode(node.pos, value='0', constant_result=0) + else: + start = pos_args[1] + + result_ref = UtilNodes.ResultRefNode(pos=node.pos, type=PyrexTypes.py_object_type) + add_node = Nodes.SingleAssignmentNode( + yield_expression.pos, + lhs = result_ref, + rhs = ExprNodes.binop_node(node.pos, '+', result_ref, yield_expression) + ) + + Visitor.recursively_replace_node(gen_expr_node, yield_stat_node, add_node) + + exec_code = Nodes.StatListNode( + node.pos, + stats = [ + Nodes.SingleAssignmentNode( + start.pos, + lhs = UtilNodes.ResultRefNode(pos=node.pos, expression=result_ref), + rhs = start, + first = True), + loop_node + ]) + + return ExprNodes.InlinedGeneratorExpressionNode( + gen_expr_node.pos, loop = exec_code, result_node = result_ref, + expr_scope = gen_expr_node.expr_scope, orig_func = 'sum', + has_local_scope = gen_expr_node.has_local_scope) + + def _handle_simple_function_min(self, node, pos_args): + return self._optimise_min_max(node, pos_args, '<') + + def _handle_simple_function_max(self, node, pos_args): + return self._optimise_min_max(node, pos_args, '>') + + def _optimise_min_max(self, node, args, operator): + """Replace min(a,b,...) and max(a,b,...) by explicit comparison code. + """ + if len(args) <= 1: + if len(args) == 1 and args[0].is_sequence_constructor: + args = args[0].args + if len(args) <= 1: + # leave this to Python + return node + + cascaded_nodes = list(map(UtilNodes.ResultRefNode, args[1:])) + + last_result = args[0] + for arg_node in cascaded_nodes: + result_ref = UtilNodes.ResultRefNode(last_result) + last_result = ExprNodes.CondExprNode( + arg_node.pos, + true_val = arg_node, + false_val = result_ref, + test = ExprNodes.PrimaryCmpNode( + arg_node.pos, + operand1 = arg_node, + operator = operator, + operand2 = result_ref, + ) + ) + last_result = UtilNodes.EvalWithTempExprNode(result_ref, last_result) + + for ref_node in cascaded_nodes[::-1]: + last_result = UtilNodes.EvalWithTempExprNode(ref_node, last_result) + + return last_result + + # builtin type creation + + def _DISABLED_handle_simple_function_tuple(self, node, pos_args): + if not pos_args: + return ExprNodes.TupleNode(node.pos, args=[], constant_result=()) + # This is a bit special - for iterables (including genexps), + # Python actually overallocates and resizes a newly created + # tuple incrementally while reading items, which we can't + # easily do without explicit node support. Instead, we read + # the items into a list and then copy them into a tuple of the + # final size. This takes up to twice as much memory, but will + # have to do until we have real support for genexps. + result = self._transform_list_set_genexpr(node, pos_args, Builtin.list_type) + if result is not node: + return ExprNodes.AsTupleNode(node.pos, arg=result) + return node + + def _handle_simple_function_frozenset(self, node, pos_args): + """Replace frozenset([...]) by frozenset((...)) as tuples are more efficient. + """ + if len(pos_args) != 1: + return node + if pos_args[0].is_sequence_constructor and not pos_args[0].args: + del pos_args[0] + elif isinstance(pos_args[0], ExprNodes.ListNode): + pos_args[0] = pos_args[0].as_tuple() + return node + + def _handle_simple_function_list(self, node, pos_args): + if not pos_args: + return ExprNodes.ListNode(node.pos, args=[], constant_result=[]) + return self._transform_list_set_genexpr(node, pos_args, Builtin.list_type) + + def _handle_simple_function_set(self, node, pos_args): + if not pos_args: + return ExprNodes.SetNode(node.pos, args=[], constant_result=set()) + return self._transform_list_set_genexpr(node, pos_args, Builtin.set_type) + + def _transform_list_set_genexpr(self, node, pos_args, target_type): + """Replace set(genexpr) and list(genexpr) by an inlined comprehension. + """ + if len(pos_args) > 1: + return node + if not isinstance(pos_args[0], ExprNodes.GeneratorExpressionNode): + return node + gen_expr_node = pos_args[0] + loop_node = gen_expr_node.loop + + yield_statements = _find_yield_statements(loop_node) + if not yield_statements: + return node + + result_node = ExprNodes.InlinedGeneratorExpressionNode( + node.pos, gen_expr_node, + orig_func='set' if target_type is Builtin.set_type else 'list', + comprehension_type=target_type) + + for yield_expression, yield_stat_node in yield_statements: + append_node = ExprNodes.ComprehensionAppendNode( + yield_expression.pos, + expr=yield_expression, + target=result_node.target) + Visitor.recursively_replace_node(gen_expr_node, yield_stat_node, append_node) + + return result_node + + def _handle_simple_function_dict(self, node, pos_args): + """Replace dict( (a,b) for ... ) by an inlined { a:b for ... } + """ + if len(pos_args) == 0: + return ExprNodes.DictNode(node.pos, key_value_pairs=[], constant_result={}) + if len(pos_args) > 1: + return node + if not isinstance(pos_args[0], ExprNodes.GeneratorExpressionNode): + return node + gen_expr_node = pos_args[0] + loop_node = gen_expr_node.loop + + yield_statements = _find_yield_statements(loop_node) + if not yield_statements: + return node + + for yield_expression, _ in yield_statements: + if not isinstance(yield_expression, ExprNodes.TupleNode): + return node + if len(yield_expression.args) != 2: + return node + + result_node = ExprNodes.InlinedGeneratorExpressionNode( + node.pos, gen_expr_node, orig_func='dict', + comprehension_type=Builtin.dict_type) + + for yield_expression, yield_stat_node in yield_statements: + append_node = ExprNodes.DictComprehensionAppendNode( + yield_expression.pos, + key_expr=yield_expression.args[0], + value_expr=yield_expression.args[1], + target=result_node.target) + Visitor.recursively_replace_node(gen_expr_node, yield_stat_node, append_node) + + return result_node + + # specific handlers for general call nodes + + def _handle_general_function_dict(self, node, pos_args, kwargs): + """Replace dict(a=b,c=d,...) by the underlying keyword dict + construction which is done anyway. + """ + if len(pos_args) > 0: + return node + if not isinstance(kwargs, ExprNodes.DictNode): + return node + return kwargs + + +class InlineDefNodeCalls(Visitor.NodeRefCleanupMixin, Visitor.EnvTransform): + visit_Node = Visitor.VisitorTransform.recurse_to_children + + def get_constant_value_node(self, name_node): + if name_node.cf_state is None: + return None + if name_node.cf_state.cf_is_null: + return None + entry = self.current_env().lookup(name_node.name) + if not entry or (not entry.cf_assignments + or len(entry.cf_assignments) != 1): + # not just a single assignment in all closures + return None + return entry.cf_assignments[0].rhs + + def visit_SimpleCallNode(self, node): + self.visitchildren(node) + if not self.current_directives.get('optimize.inline_defnode_calls'): + return node + function_name = node.function + if not function_name.is_name: + return node + function = self.get_constant_value_node(function_name) + if not isinstance(function, ExprNodes.PyCFunctionNode): + return node + inlined = ExprNodes.InlinedDefNodeCallNode( + node.pos, function_name=function_name, + function=function, args=node.args) + if inlined.can_be_inlined(): + return self.replace(node, inlined) + return node + + +class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin, + Visitor.MethodDispatcherTransform): + """Optimize some common methods calls and instantiation patterns + for builtin types *after* the type analysis phase. + + Running after type analysis, this transform can only perform + function replacements that do not alter the function return type + in a way that was not anticipated by the type analysis. + """ + ### cleanup to avoid redundant coercions to/from Python types + + def visit_PyTypeTestNode(self, node): + """Flatten redundant type checks after tree changes. + """ + self.visitchildren(node) + return node.reanalyse() + + def _visit_TypecastNode(self, node): + # disabled - the user may have had a reason to put a type + # cast, even if it looks redundant to Cython + """ + Drop redundant type casts. + """ + self.visitchildren(node) + if node.type == node.operand.type: + return node.operand + return node + + def visit_ExprStatNode(self, node): + """ + Drop dead code and useless coercions. + """ + self.visitchildren(node) + if isinstance(node.expr, ExprNodes.CoerceToPyTypeNode): + node.expr = node.expr.arg + expr = node.expr + if expr is None or expr.is_none or expr.is_literal: + # Expression was removed or is dead code => remove ExprStatNode as well. + return None + if expr.is_name and expr.entry and (expr.entry.is_local or expr.entry.is_arg): + # Ignore dead references to local variables etc. + return None + return node + + def visit_CoerceToBooleanNode(self, node): + """Drop redundant conversion nodes after tree changes. + """ + self.visitchildren(node) + arg = node.arg + if isinstance(arg, ExprNodes.PyTypeTestNode): + arg = arg.arg + if isinstance(arg, ExprNodes.CoerceToPyTypeNode): + if arg.type in (PyrexTypes.py_object_type, Builtin.bool_type): + return arg.arg.coerce_to_boolean(self.current_env()) + return node + + PyNumber_Float_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("o", PyrexTypes.py_object_type, None) + ]) + + def visit_CoerceToPyTypeNode(self, node): + """Drop redundant conversion nodes after tree changes.""" + self.visitchildren(node) + arg = node.arg + if isinstance(arg, ExprNodes.CoerceFromPyTypeNode): + arg = arg.arg + if isinstance(arg, ExprNodes.PythonCapiCallNode): + if arg.function.name == 'float' and len(arg.args) == 1: + # undo redundant Py->C->Py coercion + func_arg = arg.args[0] + if func_arg.type is Builtin.float_type: + return func_arg.as_none_safe_node("float() argument must be a string or a number, not 'NoneType'") + elif func_arg.type.is_pyobject: + return ExprNodes.PythonCapiCallNode( + node.pos, '__Pyx_PyNumber_Float', self.PyNumber_Float_func_type, + args=[func_arg], + py_name='float', + is_temp=node.is_temp, + result_is_used=node.result_is_used, + ).coerce_to(node.type, self.current_env()) + return node + + def visit_CoerceFromPyTypeNode(self, node): + """Drop redundant conversion nodes after tree changes. + + Also, optimise away calls to Python's builtin int() and + float() if the result is going to be coerced back into a C + type anyway. + """ + self.visitchildren(node) + arg = node.arg + if not arg.type.is_pyobject: + # no Python conversion left at all, just do a C coercion instead + if node.type != arg.type: + arg = arg.coerce_to(node.type, self.current_env()) + return arg + if isinstance(arg, ExprNodes.PyTypeTestNode): + arg = arg.arg + if arg.is_literal: + if (node.type.is_int and isinstance(arg, ExprNodes.IntNode) or + node.type.is_float and isinstance(arg, ExprNodes.FloatNode) or + node.type.is_int and isinstance(arg, ExprNodes.BoolNode)): + return arg.coerce_to(node.type, self.current_env()) + elif isinstance(arg, ExprNodes.CoerceToPyTypeNode): + if arg.type is PyrexTypes.py_object_type: + if node.type.assignable_from(arg.arg.type): + # completely redundant C->Py->C coercion + return arg.arg.coerce_to(node.type, self.current_env()) + elif arg.type is Builtin.unicode_type: + if arg.arg.type.is_unicode_char and node.type.is_unicode_char: + return arg.arg.coerce_to(node.type, self.current_env()) + elif isinstance(arg, ExprNodes.SimpleCallNode): + if node.type.is_int or node.type.is_float: + return self._optimise_numeric_cast_call(node, arg) + elif arg.is_subscript: + index_node = arg.index + if isinstance(index_node, ExprNodes.CoerceToPyTypeNode): + index_node = index_node.arg + if index_node.type.is_int: + return self._optimise_int_indexing(node, arg, index_node) + return node + + PyBytes_GetItemInt_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_char_type, [ + PyrexTypes.CFuncTypeArg("bytes", Builtin.bytes_type, None), + PyrexTypes.CFuncTypeArg("index", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("check_bounds", PyrexTypes.c_int_type, None), + ], + exception_value = "((char)-1)", + exception_check = True) + + def _optimise_int_indexing(self, coerce_node, arg, index_node): + env = self.current_env() + bound_check_bool = env.directives['boundscheck'] and 1 or 0 + if arg.base.type is Builtin.bytes_type: + if coerce_node.type in (PyrexTypes.c_char_type, PyrexTypes.c_uchar_type): + # bytes[index] -> char + bound_check_node = ExprNodes.IntNode( + coerce_node.pos, value=str(bound_check_bool), + constant_result=bound_check_bool) + node = ExprNodes.PythonCapiCallNode( + coerce_node.pos, "__Pyx_PyBytes_GetItemInt", + self.PyBytes_GetItemInt_func_type, + args=[ + arg.base.as_none_safe_node("'NoneType' object is not subscriptable"), + index_node.coerce_to(PyrexTypes.c_py_ssize_t_type, env), + bound_check_node, + ], + is_temp=True, + utility_code=UtilityCode.load_cached( + 'bytes_index', 'StringTools.c')) + if coerce_node.type is not PyrexTypes.c_char_type: + node = node.coerce_to(coerce_node.type, env) + return node + return coerce_node + + float_float_func_types = dict( + (float_type, PyrexTypes.CFuncType( + float_type, [ + PyrexTypes.CFuncTypeArg("arg", float_type, None) + ])) + for float_type in (PyrexTypes.c_float_type, PyrexTypes.c_double_type, PyrexTypes.c_longdouble_type)) + + def _optimise_numeric_cast_call(self, node, arg): + function = arg.function + args = None + if isinstance(arg, ExprNodes.PythonCapiCallNode): + args = arg.args + elif isinstance(function, ExprNodes.NameNode): + if function.type.is_builtin_type and isinstance(arg.arg_tuple, ExprNodes.TupleNode): + args = arg.arg_tuple.args + + if args is None or len(args) != 1: + return node + func_arg = args[0] + if isinstance(func_arg, ExprNodes.CoerceToPyTypeNode): + func_arg = func_arg.arg + elif func_arg.type.is_pyobject: + # play it safe: Python conversion might work on all sorts of things + return node + + if function.name == 'int': + if func_arg.type.is_int or node.type.is_int: + if func_arg.type == node.type: + return func_arg + elif node.type.assignable_from(func_arg.type) or func_arg.type.is_float: + return ExprNodes.TypecastNode(node.pos, operand=func_arg, type=node.type) + elif func_arg.type.is_float and node.type.is_numeric: + if func_arg.type.math_h_modifier == 'l': + # Work around missing Cygwin definition. + truncl = '__Pyx_truncl' + else: + truncl = 'trunc' + func_arg.type.math_h_modifier + return ExprNodes.PythonCapiCallNode( + node.pos, truncl, + func_type=self.float_float_func_types[func_arg.type], + args=[func_arg], + py_name='int', + is_temp=node.is_temp, + result_is_used=node.result_is_used, + ).coerce_to(node.type, self.current_env()) + elif function.name == 'float': + if func_arg.type.is_float or node.type.is_float: + if func_arg.type == node.type: + return func_arg + elif node.type.assignable_from(func_arg.type) or func_arg.type.is_float: + return ExprNodes.TypecastNode( + node.pos, operand=func_arg, type=node.type) + return node + + def _error_wrong_arg_count(self, function_name, node, args, expected=None): + if not expected: # None or 0 + arg_str = '' + elif isinstance(expected, basestring) or expected > 1: + arg_str = '...' + elif expected == 1: + arg_str = 'x' + else: + arg_str = '' + if expected is not None: + expected_str = 'expected %s, ' % expected + else: + expected_str = '' + error(node.pos, "%s(%s) called with wrong number of args, %sfound %d" % ( + function_name, arg_str, expected_str, len(args))) + + ### generic fallbacks + + def _handle_function(self, node, function_name, function, arg_list, kwargs): + return node + + def _handle_method(self, node, type_name, attr_name, function, + arg_list, is_unbound_method, kwargs): + """ + Try to inject C-API calls for unbound method calls to builtin types. + While the method declarations in Builtin.py already handle this, we + can additionally resolve bound and unbound methods here that were + assigned to variables ahead of time. + """ + if kwargs: + return node + if not function or not function.is_attribute or not function.obj.is_name: + # cannot track unbound method calls over more than one indirection as + # the names might have been reassigned in the meantime + return node + type_entry = self.current_env().lookup(type_name) + if not type_entry: + return node + method = ExprNodes.AttributeNode( + node.function.pos, + obj=ExprNodes.NameNode( + function.pos, + name=type_name, + entry=type_entry, + type=type_entry.type), + attribute=attr_name, + is_called=True).analyse_as_type_attribute(self.current_env()) + if method is None: + return self._optimise_generic_builtin_method_call( + node, attr_name, function, arg_list, is_unbound_method) + args = node.args + if args is None and node.arg_tuple: + args = node.arg_tuple.args + call_node = ExprNodes.SimpleCallNode( + node.pos, + function=method, + args=args) + if not is_unbound_method: + call_node.self = function.obj + call_node.analyse_c_function_call(self.current_env()) + call_node.analysed = True + return call_node.coerce_to(node.type, self.current_env()) + + ### builtin types + + def _optimise_generic_builtin_method_call(self, node, attr_name, function, arg_list, is_unbound_method): + """ + Try to inject an unbound method call for a call to a method of a known builtin type. + This enables caching the underlying C function of the method at runtime. + """ + arg_count = len(arg_list) + if is_unbound_method or arg_count >= 3 or not (function.is_attribute and function.is_py_attr): + return node + if not function.obj.type.is_builtin_type: + return node + if function.obj.type.name in ('basestring', 'type'): + # these allow different actual types => unsafe + return node + return ExprNodes.CachedBuiltinMethodCallNode( + node, function.obj, attr_name, arg_list) + + PyObject_Unicode_func_type = PyrexTypes.CFuncType( + Builtin.unicode_type, [ + PyrexTypes.CFuncTypeArg("obj", PyrexTypes.py_object_type, None) + ]) + + def _handle_simple_function_unicode(self, node, function, pos_args): + """Optimise single argument calls to unicode(). + """ + if len(pos_args) != 1: + if len(pos_args) == 0: + return ExprNodes.UnicodeNode(node.pos, value=EncodedString(), constant_result=u'') + return node + arg = pos_args[0] + if arg.type is Builtin.unicode_type: + if not arg.may_be_none(): + return arg + cname = "__Pyx_PyUnicode_Unicode" + utility_code = UtilityCode.load_cached('PyUnicode_Unicode', 'StringTools.c') + else: + cname = "__Pyx_PyObject_Unicode" + utility_code = UtilityCode.load_cached('PyObject_Unicode', 'StringTools.c') + return ExprNodes.PythonCapiCallNode( + node.pos, cname, self.PyObject_Unicode_func_type, + args=pos_args, + is_temp=node.is_temp, + utility_code=utility_code, + py_name="unicode") + + def visit_FormattedValueNode(self, node): + """Simplify or avoid plain string formatting of a unicode value. + This seems misplaced here, but plain unicode formatting is essentially + a call to the unicode() builtin, which is optimised right above. + """ + self.visitchildren(node) + if node.value.type is Builtin.unicode_type and not node.c_format_spec and not node.format_spec: + if not node.conversion_char or node.conversion_char == 's': + # value is definitely a unicode string and we don't format it any special + return self._handle_simple_function_unicode(node, None, [node.value]) + return node + + PyDict_Copy_func_type = PyrexTypes.CFuncType( + Builtin.dict_type, [ + PyrexTypes.CFuncTypeArg("dict", Builtin.dict_type, None) + ]) + + def _handle_simple_function_dict(self, node, function, pos_args): + """Replace dict(some_dict) by PyDict_Copy(some_dict). + """ + if len(pos_args) != 1: + return node + arg = pos_args[0] + if arg.type is Builtin.dict_type: + arg = arg.as_none_safe_node("'NoneType' is not iterable") + return ExprNodes.PythonCapiCallNode( + node.pos, "PyDict_Copy", self.PyDict_Copy_func_type, + args = [arg], + is_temp = node.is_temp + ) + return node + + PySequence_List_func_type = PyrexTypes.CFuncType( + Builtin.list_type, + [PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None)]) + + def _handle_simple_function_list(self, node, function, pos_args): + """Turn list(ob) into PySequence_List(ob). + """ + if len(pos_args) != 1: + return node + arg = pos_args[0] + return ExprNodes.PythonCapiCallNode( + node.pos, "PySequence_List", self.PySequence_List_func_type, + args=pos_args, is_temp=node.is_temp) + + PyList_AsTuple_func_type = PyrexTypes.CFuncType( + Builtin.tuple_type, [ + PyrexTypes.CFuncTypeArg("list", Builtin.list_type, None) + ]) + + def _handle_simple_function_tuple(self, node, function, pos_args): + """Replace tuple([...]) by PyList_AsTuple or PySequence_Tuple. + """ + if len(pos_args) != 1 or not node.is_temp: + return node + arg = pos_args[0] + if arg.type is Builtin.tuple_type and not arg.may_be_none(): + return arg + if arg.type is Builtin.list_type: + pos_args[0] = arg.as_none_safe_node( + "'NoneType' object is not iterable") + + return ExprNodes.PythonCapiCallNode( + node.pos, "PyList_AsTuple", self.PyList_AsTuple_func_type, + args=pos_args, is_temp=node.is_temp) + else: + return ExprNodes.AsTupleNode(node.pos, arg=arg, type=Builtin.tuple_type) + + PySet_New_func_type = PyrexTypes.CFuncType( + Builtin.set_type, [ + PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None) + ]) + + def _handle_simple_function_set(self, node, function, pos_args): + if len(pos_args) != 1: + return node + if pos_args[0].is_sequence_constructor: + # We can optimise set([x,y,z]) safely into a set literal, + # but only if we create all items before adding them - + # adding an item may raise an exception if it is not + # hashable, but creating the later items may have + # side-effects. + args = [] + temps = [] + for arg in pos_args[0].args: + if not arg.is_simple(): + arg = UtilNodes.LetRefNode(arg) + temps.append(arg) + args.append(arg) + result = ExprNodes.SetNode(node.pos, is_temp=1, args=args) + self.replace(node, result) + for temp in temps[::-1]: + result = UtilNodes.EvalWithTempExprNode(temp, result) + return result + else: + # PySet_New(it) is better than a generic Python call to set(it) + return self.replace(node, ExprNodes.PythonCapiCallNode( + node.pos, "PySet_New", + self.PySet_New_func_type, + args=pos_args, + is_temp=node.is_temp, + py_name="set")) + + PyFrozenSet_New_func_type = PyrexTypes.CFuncType( + Builtin.frozenset_type, [ + PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None) + ]) + + def _handle_simple_function_frozenset(self, node, function, pos_args): + if not pos_args: + pos_args = [ExprNodes.NullNode(node.pos)] + elif len(pos_args) > 1: + return node + elif pos_args[0].type is Builtin.frozenset_type and not pos_args[0].may_be_none(): + return pos_args[0] + # PyFrozenSet_New(it) is better than a generic Python call to frozenset(it) + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_PyFrozenSet_New", + self.PyFrozenSet_New_func_type, + args=pos_args, + is_temp=node.is_temp, + utility_code=UtilityCode.load_cached('pyfrozenset_new', 'Builtins.c'), + py_name="frozenset") + + PyObject_AsDouble_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_double_type, [ + PyrexTypes.CFuncTypeArg("obj", PyrexTypes.py_object_type, None), + ], + exception_value = "((double)-1)", + exception_check = True) + + def _handle_simple_function_float(self, node, function, pos_args): + """Transform float() into either a C type cast or a faster C + function call. + """ + # Note: this requires the float() function to be typed as + # returning a C 'double' + if len(pos_args) == 0: + return ExprNodes.FloatNode( + node, value="0.0", constant_result=0.0 + ).coerce_to(Builtin.float_type, self.current_env()) + elif len(pos_args) != 1: + self._error_wrong_arg_count('float', node, pos_args, '0 or 1') + return node + func_arg = pos_args[0] + if isinstance(func_arg, ExprNodes.CoerceToPyTypeNode): + func_arg = func_arg.arg + if func_arg.type is PyrexTypes.c_double_type: + return func_arg + elif node.type.assignable_from(func_arg.type) or func_arg.type.is_numeric: + return ExprNodes.TypecastNode( + node.pos, operand=func_arg, type=node.type) + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_PyObject_AsDouble", + self.PyObject_AsDouble_func_type, + args = pos_args, + is_temp = node.is_temp, + utility_code = load_c_utility('pyobject_as_double'), + py_name = "float") + + PyNumber_Int_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("o", PyrexTypes.py_object_type, None) + ]) + + PyInt_FromDouble_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("value", PyrexTypes.c_double_type, None) + ]) + + def _handle_simple_function_int(self, node, function, pos_args): + """Transform int() into a faster C function call. + """ + if len(pos_args) == 0: + return ExprNodes.IntNode(node.pos, value="0", constant_result=0, + type=PyrexTypes.py_object_type) + elif len(pos_args) != 1: + return node # int(x, base) + func_arg = pos_args[0] + if isinstance(func_arg, ExprNodes.CoerceToPyTypeNode): + if func_arg.arg.type.is_float: + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_PyInt_FromDouble", self.PyInt_FromDouble_func_type, + args=[func_arg.arg], is_temp=True, py_name='int', + utility_code=UtilityCode.load_cached("PyIntFromDouble", "TypeConversion.c")) + else: + return node # handled in visit_CoerceFromPyTypeNode() + if func_arg.type.is_pyobject and node.type.is_pyobject: + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_PyNumber_Int", self.PyNumber_Int_func_type, + args=pos_args, is_temp=True, py_name='int') + return node + + def _handle_simple_function_bool(self, node, function, pos_args): + """Transform bool(x) into a type coercion to a boolean. + """ + if len(pos_args) == 0: + return ExprNodes.BoolNode( + node.pos, value=False, constant_result=False + ).coerce_to(Builtin.bool_type, self.current_env()) + elif len(pos_args) != 1: + self._error_wrong_arg_count('bool', node, pos_args, '0 or 1') + return node + else: + # => !!<bint>(x) to make sure it's exactly 0 or 1 + operand = pos_args[0].coerce_to_boolean(self.current_env()) + operand = ExprNodes.NotNode(node.pos, operand = operand) + operand = ExprNodes.NotNode(node.pos, operand = operand) + # coerce back to Python object as that's the result we are expecting + return operand.coerce_to_pyobject(self.current_env()) + + ### builtin functions + + Pyx_strlen_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_size_t_type, [ + PyrexTypes.CFuncTypeArg("bytes", PyrexTypes.c_const_char_ptr_type, None) + ]) + + Pyx_Py_UNICODE_strlen_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_size_t_type, [ + PyrexTypes.CFuncTypeArg("unicode", PyrexTypes.c_const_py_unicode_ptr_type, None) + ]) + + PyObject_Size_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_py_ssize_t_type, [ + PyrexTypes.CFuncTypeArg("obj", PyrexTypes.py_object_type, None) + ], + exception_value="-1") + + _map_to_capi_len_function = { + Builtin.unicode_type: "__Pyx_PyUnicode_GET_LENGTH", + Builtin.bytes_type: "PyBytes_GET_SIZE", + Builtin.bytearray_type: 'PyByteArray_GET_SIZE', + Builtin.list_type: "PyList_GET_SIZE", + Builtin.tuple_type: "PyTuple_GET_SIZE", + Builtin.set_type: "PySet_GET_SIZE", + Builtin.frozenset_type: "PySet_GET_SIZE", + Builtin.dict_type: "PyDict_Size", + }.get + + _ext_types_with_pysize = set(["cpython.array.array"]) + + def _handle_simple_function_len(self, node, function, pos_args): + """Replace len(char*) by the equivalent call to strlen(), + len(Py_UNICODE) by the equivalent Py_UNICODE_strlen() and + len(known_builtin_type) by an equivalent C-API call. + """ + if len(pos_args) != 1: + self._error_wrong_arg_count('len', node, pos_args, 1) + return node + arg = pos_args[0] + if isinstance(arg, ExprNodes.CoerceToPyTypeNode): + arg = arg.arg + if arg.type.is_string: + new_node = ExprNodes.PythonCapiCallNode( + node.pos, "strlen", self.Pyx_strlen_func_type, + args = [arg], + is_temp = node.is_temp, + utility_code = UtilityCode.load_cached("IncludeStringH", "StringTools.c")) + elif arg.type.is_pyunicode_ptr: + new_node = ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_Py_UNICODE_strlen", self.Pyx_Py_UNICODE_strlen_func_type, + args = [arg], + is_temp = node.is_temp) + elif arg.type.is_memoryviewslice: + func_type = PyrexTypes.CFuncType( + PyrexTypes.c_size_t_type, [ + PyrexTypes.CFuncTypeArg("memoryviewslice", arg.type, None) + ], nogil=True) + new_node = ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_MemoryView_Len", func_type, + args=[arg], is_temp=node.is_temp) + elif arg.type.is_pyobject: + cfunc_name = self._map_to_capi_len_function(arg.type) + if cfunc_name is None: + arg_type = arg.type + if ((arg_type.is_extension_type or arg_type.is_builtin_type) + and arg_type.entry.qualified_name in self._ext_types_with_pysize): + cfunc_name = 'Py_SIZE' + else: + return node + arg = arg.as_none_safe_node( + "object of type 'NoneType' has no len()") + new_node = ExprNodes.PythonCapiCallNode( + node.pos, cfunc_name, self.PyObject_Size_func_type, + args=[arg], is_temp=node.is_temp) + elif arg.type.is_unicode_char: + return ExprNodes.IntNode(node.pos, value='1', constant_result=1, + type=node.type) + else: + return node + if node.type not in (PyrexTypes.c_size_t_type, PyrexTypes.c_py_ssize_t_type): + new_node = new_node.coerce_to(node.type, self.current_env()) + return new_node + + Pyx_Type_func_type = PyrexTypes.CFuncType( + Builtin.type_type, [ + PyrexTypes.CFuncTypeArg("object", PyrexTypes.py_object_type, None) + ]) + + def _handle_simple_function_type(self, node, function, pos_args): + """Replace type(o) by a macro call to Py_TYPE(o). + """ + if len(pos_args) != 1: + return node + node = ExprNodes.PythonCapiCallNode( + node.pos, "Py_TYPE", self.Pyx_Type_func_type, + args = pos_args, + is_temp = False) + return ExprNodes.CastNode(node, PyrexTypes.py_object_type) + + Py_type_check_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_bint_type, [ + PyrexTypes.CFuncTypeArg("arg", PyrexTypes.py_object_type, None) + ]) + + def _handle_simple_function_isinstance(self, node, function, pos_args): + """Replace isinstance() checks against builtin types by the + corresponding C-API call. + """ + if len(pos_args) != 2: + return node + arg, types = pos_args + temps = [] + if isinstance(types, ExprNodes.TupleNode): + types = types.args + if len(types) == 1 and not types[0].type is Builtin.type_type: + return node # nothing to improve here + if arg.is_attribute or not arg.is_simple(): + arg = UtilNodes.ResultRefNode(arg) + temps.append(arg) + elif types.type is Builtin.type_type: + types = [types] + else: + return node + + tests = [] + test_nodes = [] + env = self.current_env() + for test_type_node in types: + builtin_type = None + if test_type_node.is_name: + if test_type_node.entry: + entry = env.lookup(test_type_node.entry.name) + if entry and entry.type and entry.type.is_builtin_type: + builtin_type = entry.type + if builtin_type is Builtin.type_type: + # all types have type "type", but there's only one 'type' + if entry.name != 'type' or not ( + entry.scope and entry.scope.is_builtin_scope): + builtin_type = None + if builtin_type is not None: + type_check_function = entry.type.type_check_function(exact=False) + if type_check_function in tests: + continue + tests.append(type_check_function) + type_check_args = [arg] + elif test_type_node.type is Builtin.type_type: + type_check_function = '__Pyx_TypeCheck' + type_check_args = [arg, test_type_node] + else: + if not test_type_node.is_literal: + test_type_node = UtilNodes.ResultRefNode(test_type_node) + temps.append(test_type_node) + type_check_function = 'PyObject_IsInstance' + type_check_args = [arg, test_type_node] + test_nodes.append( + ExprNodes.PythonCapiCallNode( + test_type_node.pos, type_check_function, self.Py_type_check_func_type, + args=type_check_args, + is_temp=True, + )) + + def join_with_or(a, b, make_binop_node=ExprNodes.binop_node): + or_node = make_binop_node(node.pos, 'or', a, b) + or_node.type = PyrexTypes.c_bint_type + or_node.wrap_operands(env) + return or_node + + test_node = reduce(join_with_or, test_nodes).coerce_to(node.type, env) + for temp in temps[::-1]: + test_node = UtilNodes.EvalWithTempExprNode(temp, test_node) + return test_node + + def _handle_simple_function_ord(self, node, function, pos_args): + """Unpack ord(Py_UNICODE) and ord('X'). + """ + if len(pos_args) != 1: + return node + arg = pos_args[0] + if isinstance(arg, ExprNodes.CoerceToPyTypeNode): + if arg.arg.type.is_unicode_char: + return ExprNodes.TypecastNode( + arg.pos, operand=arg.arg, type=PyrexTypes.c_long_type + ).coerce_to(node.type, self.current_env()) + elif isinstance(arg, ExprNodes.UnicodeNode): + if len(arg.value) == 1: + return ExprNodes.IntNode( + arg.pos, type=PyrexTypes.c_int_type, + value=str(ord(arg.value)), + constant_result=ord(arg.value) + ).coerce_to(node.type, self.current_env()) + elif isinstance(arg, ExprNodes.StringNode): + if arg.unicode_value and len(arg.unicode_value) == 1 \ + and ord(arg.unicode_value) <= 255: # Py2/3 portability + return ExprNodes.IntNode( + arg.pos, type=PyrexTypes.c_int_type, + value=str(ord(arg.unicode_value)), + constant_result=ord(arg.unicode_value) + ).coerce_to(node.type, self.current_env()) + return node + + ### special methods + + Pyx_tp_new_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("type", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("args", Builtin.tuple_type, None), + ]) + + Pyx_tp_new_kwargs_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("type", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("args", Builtin.tuple_type, None), + PyrexTypes.CFuncTypeArg("kwargs", Builtin.dict_type, None), + ]) + + def _handle_any_slot__new__(self, node, function, args, + is_unbound_method, kwargs=None): + """Replace 'exttype.__new__(exttype, ...)' by a call to exttype->tp_new() + """ + obj = function.obj + if not is_unbound_method or len(args) < 1: + return node + type_arg = args[0] + if not obj.is_name or not type_arg.is_name: + # play safe + return node + if obj.type != Builtin.type_type or type_arg.type != Builtin.type_type: + # not a known type, play safe + return node + if not type_arg.type_entry or not obj.type_entry: + if obj.name != type_arg.name: + return node + # otherwise, we know it's a type and we know it's the same + # type for both - that should do + elif type_arg.type_entry != obj.type_entry: + # different types - may or may not lead to an error at runtime + return node + + args_tuple = ExprNodes.TupleNode(node.pos, args=args[1:]) + args_tuple = args_tuple.analyse_types( + self.current_env(), skip_children=True) + + if type_arg.type_entry: + ext_type = type_arg.type_entry.type + if (ext_type.is_extension_type and ext_type.typeobj_cname and + ext_type.scope.global_scope() == self.current_env().global_scope()): + # known type in current module + tp_slot = TypeSlots.ConstructorSlot("tp_new", '__new__') + slot_func_cname = TypeSlots.get_slot_function(ext_type.scope, tp_slot) + if slot_func_cname: + cython_scope = self.context.cython_scope + PyTypeObjectPtr = PyrexTypes.CPtrType( + cython_scope.lookup('PyTypeObject').type) + pyx_tp_new_kwargs_func_type = PyrexTypes.CFuncType( + ext_type, [ + PyrexTypes.CFuncTypeArg("type", PyTypeObjectPtr, None), + PyrexTypes.CFuncTypeArg("args", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("kwargs", PyrexTypes.py_object_type, None), + ]) + + type_arg = ExprNodes.CastNode(type_arg, PyTypeObjectPtr) + if not kwargs: + kwargs = ExprNodes.NullNode(node.pos, type=PyrexTypes.py_object_type) # hack? + return ExprNodes.PythonCapiCallNode( + node.pos, slot_func_cname, + pyx_tp_new_kwargs_func_type, + args=[type_arg, args_tuple, kwargs], + may_return_none=False, + is_temp=True) + else: + # arbitrary variable, needs a None check for safety + type_arg = type_arg.as_none_safe_node( + "object.__new__(X): X is not a type object (NoneType)") + + utility_code = UtilityCode.load_cached('tp_new', 'ObjectHandling.c') + if kwargs: + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_tp_new_kwargs", self.Pyx_tp_new_kwargs_func_type, + args=[type_arg, args_tuple, kwargs], + utility_code=utility_code, + is_temp=node.is_temp + ) + else: + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_tp_new", self.Pyx_tp_new_func_type, + args=[type_arg, args_tuple], + utility_code=utility_code, + is_temp=node.is_temp + ) + + ### methods of builtin types + + PyObject_Append_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_returncode_type, [ + PyrexTypes.CFuncTypeArg("list", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("item", PyrexTypes.py_object_type, None), + ], + exception_value="-1") + + def _handle_simple_method_object_append(self, node, function, args, is_unbound_method): + """Optimistic optimisation as X.append() is almost always + referring to a list. + """ + if len(args) != 2 or node.result_is_used or node.function.entry: + return node + + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_PyObject_Append", self.PyObject_Append_func_type, + args=args, + may_return_none=False, + is_temp=node.is_temp, + result_is_used=False, + utility_code=load_c_utility('append') + ) + + def _handle_simple_method_list_extend(self, node, function, args, is_unbound_method): + """Replace list.extend([...]) for short sequence literals values by sequential appends + to avoid creating an intermediate sequence argument. + """ + if len(args) != 2: + return node + obj, value = args + if not value.is_sequence_constructor: + return node + items = list(value.args) + if value.mult_factor is not None or len(items) > 8: + # Appending wins for short sequences but slows down when multiple resize operations are needed. + # This seems to be a good enough limit that avoids repeated resizing. + if False and isinstance(value, ExprNodes.ListNode): + # One would expect that tuples are more efficient here, but benchmarking with + # Py3.5 and Py3.7 suggests that they are not. Probably worth revisiting at some point. + # Might be related to the usage of PySequence_FAST() in CPython's list.extend(), + # which is probably tuned more towards lists than tuples (and rightly so). + tuple_node = args[1].as_tuple().analyse_types(self.current_env(), skip_children=True) + Visitor.recursively_replace_node(node, args[1], tuple_node) + return node + wrapped_obj = self._wrap_self_arg(obj, function, is_unbound_method, 'extend') + if not items: + # Empty sequences are not likely to occur, but why waste a call to list.extend() for them? + wrapped_obj.result_is_used = node.result_is_used + return wrapped_obj + cloned_obj = obj = wrapped_obj + if len(items) > 1 and not obj.is_simple(): + cloned_obj = UtilNodes.LetRefNode(obj) + # Use ListComp_Append() for all but the last item and finish with PyList_Append() + # to shrink the list storage size at the very end if necessary. + temps = [] + arg = items[-1] + if not arg.is_simple(): + arg = UtilNodes.LetRefNode(arg) + temps.append(arg) + new_node = ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_PyList_Append", self.PyObject_Append_func_type, + args=[cloned_obj, arg], + is_temp=True, + utility_code=load_c_utility("ListAppend")) + for arg in items[-2::-1]: + if not arg.is_simple(): + arg = UtilNodes.LetRefNode(arg) + temps.append(arg) + new_node = ExprNodes.binop_node( + node.pos, '|', + ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_ListComp_Append", self.PyObject_Append_func_type, + args=[cloned_obj, arg], py_name="extend", + is_temp=True, + utility_code=load_c_utility("ListCompAppend")), + new_node, + type=PyrexTypes.c_returncode_type, + ) + new_node.result_is_used = node.result_is_used + if cloned_obj is not obj: + temps.append(cloned_obj) + for temp in temps: + new_node = UtilNodes.EvalWithTempExprNode(temp, new_node) + new_node.result_is_used = node.result_is_used + return new_node + + PyByteArray_Append_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_returncode_type, [ + PyrexTypes.CFuncTypeArg("bytearray", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("value", PyrexTypes.c_int_type, None), + ], + exception_value="-1") + + PyByteArray_AppendObject_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_returncode_type, [ + PyrexTypes.CFuncTypeArg("bytearray", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("value", PyrexTypes.py_object_type, None), + ], + exception_value="-1") + + def _handle_simple_method_bytearray_append(self, node, function, args, is_unbound_method): + if len(args) != 2: + return node + func_name = "__Pyx_PyByteArray_Append" + func_type = self.PyByteArray_Append_func_type + + value = unwrap_coerced_node(args[1]) + if value.type.is_int or isinstance(value, ExprNodes.IntNode): + value = value.coerce_to(PyrexTypes.c_int_type, self.current_env()) + utility_code = UtilityCode.load_cached("ByteArrayAppend", "StringTools.c") + elif value.is_string_literal: + if not value.can_coerce_to_char_literal(): + return node + value = value.coerce_to(PyrexTypes.c_char_type, self.current_env()) + utility_code = UtilityCode.load_cached("ByteArrayAppend", "StringTools.c") + elif value.type.is_pyobject: + func_name = "__Pyx_PyByteArray_AppendObject" + func_type = self.PyByteArray_AppendObject_func_type + utility_code = UtilityCode.load_cached("ByteArrayAppendObject", "StringTools.c") + else: + return node + + new_node = ExprNodes.PythonCapiCallNode( + node.pos, func_name, func_type, + args=[args[0], value], + may_return_none=False, + is_temp=node.is_temp, + utility_code=utility_code, + ) + if node.result_is_used: + new_node = new_node.coerce_to(node.type, self.current_env()) + return new_node + + PyObject_Pop_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("list", PyrexTypes.py_object_type, None), + ]) + + PyObject_PopIndex_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("list", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("py_index", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("c_index", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("is_signed", PyrexTypes.c_int_type, None), + ], + has_varargs=True) # to fake the additional macro args that lack a proper C type + + def _handle_simple_method_list_pop(self, node, function, args, is_unbound_method): + return self._handle_simple_method_object_pop( + node, function, args, is_unbound_method, is_list=True) + + def _handle_simple_method_object_pop(self, node, function, args, is_unbound_method, is_list=False): + """Optimistic optimisation as X.pop([n]) is almost always + referring to a list. + """ + if not args: + return node + obj = args[0] + if is_list: + type_name = 'List' + obj = obj.as_none_safe_node( + "'NoneType' object has no attribute '%.30s'", + error="PyExc_AttributeError", + format_args=['pop']) + else: + type_name = 'Object' + if len(args) == 1: + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_Py%s_Pop" % type_name, + self.PyObject_Pop_func_type, + args=[obj], + may_return_none=True, + is_temp=node.is_temp, + utility_code=load_c_utility('pop'), + ) + elif len(args) == 2: + index = unwrap_coerced_node(args[1]) + py_index = ExprNodes.NoneNode(index.pos) + orig_index_type = index.type + if not index.type.is_int: + if isinstance(index, ExprNodes.IntNode): + py_index = index.coerce_to_pyobject(self.current_env()) + index = index.coerce_to(PyrexTypes.c_py_ssize_t_type, self.current_env()) + elif is_list: + if index.type.is_pyobject: + py_index = index.coerce_to_simple(self.current_env()) + index = ExprNodes.CloneNode(py_index) + index = index.coerce_to(PyrexTypes.c_py_ssize_t_type, self.current_env()) + else: + return node + elif not PyrexTypes.numeric_type_fits(index.type, PyrexTypes.c_py_ssize_t_type): + return node + elif isinstance(index, ExprNodes.IntNode): + py_index = index.coerce_to_pyobject(self.current_env()) + # real type might still be larger at runtime + if not orig_index_type.is_int: + orig_index_type = index.type + if not orig_index_type.create_to_py_utility_code(self.current_env()): + return node + convert_func = orig_index_type.to_py_function + conversion_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [PyrexTypes.CFuncTypeArg("intval", orig_index_type, None)]) + return ExprNodes.PythonCapiCallNode( + node.pos, "__Pyx_Py%s_PopIndex" % type_name, + self.PyObject_PopIndex_func_type, + args=[obj, py_index, index, + ExprNodes.IntNode(index.pos, value=str(orig_index_type.signed and 1 or 0), + constant_result=orig_index_type.signed and 1 or 0, + type=PyrexTypes.c_int_type), + ExprNodes.RawCNameExprNode(index.pos, PyrexTypes.c_void_type, + orig_index_type.empty_declaration_code()), + ExprNodes.RawCNameExprNode(index.pos, conversion_type, convert_func)], + may_return_none=True, + is_temp=node.is_temp, + utility_code=load_c_utility("pop_index"), + ) + + return node + + single_param_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_returncode_type, [ + PyrexTypes.CFuncTypeArg("obj", PyrexTypes.py_object_type, None), + ], + exception_value = "-1") + + def _handle_simple_method_list_sort(self, node, function, args, is_unbound_method): + """Call PyList_Sort() instead of the 0-argument l.sort(). + """ + if len(args) != 1: + return node + return self._substitute_method_call( + node, function, "PyList_Sort", self.single_param_func_type, + 'sort', is_unbound_method, args).coerce_to(node.type, self.current_env) + + Pyx_PyDict_GetItem_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("dict", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("key", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("default", PyrexTypes.py_object_type, None), + ]) + + def _handle_simple_method_dict_get(self, node, function, args, is_unbound_method): + """Replace dict.get() by a call to PyDict_GetItem(). + """ + if len(args) == 2: + args.append(ExprNodes.NoneNode(node.pos)) + elif len(args) != 3: + self._error_wrong_arg_count('dict.get', node, args, "2 or 3") + return node + + return self._substitute_method_call( + node, function, + "__Pyx_PyDict_GetItemDefault", self.Pyx_PyDict_GetItem_func_type, + 'get', is_unbound_method, args, + may_return_none = True, + utility_code = load_c_utility("dict_getitem_default")) + + Pyx_PyDict_SetDefault_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("dict", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("key", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("default", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("is_safe_type", PyrexTypes.c_int_type, None), + ]) + + def _handle_simple_method_dict_setdefault(self, node, function, args, is_unbound_method): + """Replace dict.setdefault() by calls to PyDict_GetItem() and PyDict_SetItem(). + """ + if len(args) == 2: + args.append(ExprNodes.NoneNode(node.pos)) + elif len(args) != 3: + self._error_wrong_arg_count('dict.setdefault', node, args, "2 or 3") + return node + key_type = args[1].type + if key_type.is_builtin_type: + is_safe_type = int(key_type.name in + 'str bytes unicode float int long bool') + elif key_type is PyrexTypes.py_object_type: + is_safe_type = -1 # don't know + else: + is_safe_type = 0 # definitely not + args.append(ExprNodes.IntNode( + node.pos, value=str(is_safe_type), constant_result=is_safe_type)) + + return self._substitute_method_call( + node, function, + "__Pyx_PyDict_SetDefault", self.Pyx_PyDict_SetDefault_func_type, + 'setdefault', is_unbound_method, args, + may_return_none=True, + utility_code=load_c_utility('dict_setdefault')) + + PyDict_Pop_func_type = PyrexTypes.CFuncType( + PyrexTypes.py_object_type, [ + PyrexTypes.CFuncTypeArg("dict", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("key", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("default", PyrexTypes.py_object_type, None), + ]) + + def _handle_simple_method_dict_pop(self, node, function, args, is_unbound_method): + """Replace dict.pop() by a call to _PyDict_Pop(). + """ + if len(args) == 2: + args.append(ExprNodes.NullNode(node.pos)) + elif len(args) != 3: + self._error_wrong_arg_count('dict.pop', node, args, "2 or 3") + return node + + return self._substitute_method_call( + node, function, + "__Pyx_PyDict_Pop", self.PyDict_Pop_func_type, + 'pop', is_unbound_method, args, + may_return_none=True, + utility_code=load_c_utility('py_dict_pop')) + + Pyx_BinopInt_func_types = dict( + ((ctype, ret_type), PyrexTypes.CFuncType( + ret_type, [ + PyrexTypes.CFuncTypeArg("op1", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("op2", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("cval", ctype, None), + PyrexTypes.CFuncTypeArg("inplace", PyrexTypes.c_bint_type, None), + PyrexTypes.CFuncTypeArg("zerodiv_check", PyrexTypes.c_bint_type, None), + ], exception_value=None if ret_type.is_pyobject else ret_type.exception_value)) + for ctype in (PyrexTypes.c_long_type, PyrexTypes.c_double_type) + for ret_type in (PyrexTypes.py_object_type, PyrexTypes.c_bint_type) + ) + + def _handle_simple_method_object___add__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Add', node, function, args, is_unbound_method) + + def _handle_simple_method_object___sub__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Subtract', node, function, args, is_unbound_method) + + def _handle_simple_method_object___eq__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Eq', node, function, args, is_unbound_method) + + def _handle_simple_method_object___ne__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Ne', node, function, args, is_unbound_method) + + def _handle_simple_method_object___and__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('And', node, function, args, is_unbound_method) + + def _handle_simple_method_object___or__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Or', node, function, args, is_unbound_method) + + def _handle_simple_method_object___xor__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Xor', node, function, args, is_unbound_method) + + def _handle_simple_method_object___rshift__(self, node, function, args, is_unbound_method): + if len(args) != 2 or not isinstance(args[1], ExprNodes.IntNode): + return node + if not args[1].has_constant_result() or not (1 <= args[1].constant_result <= 63): + return node + return self._optimise_num_binop('Rshift', node, function, args, is_unbound_method) + + def _handle_simple_method_object___lshift__(self, node, function, args, is_unbound_method): + if len(args) != 2 or not isinstance(args[1], ExprNodes.IntNode): + return node + if not args[1].has_constant_result() or not (1 <= args[1].constant_result <= 63): + return node + return self._optimise_num_binop('Lshift', node, function, args, is_unbound_method) + + def _handle_simple_method_object___mod__(self, node, function, args, is_unbound_method): + return self._optimise_num_div('Remainder', node, function, args, is_unbound_method) + + def _handle_simple_method_object___floordiv__(self, node, function, args, is_unbound_method): + return self._optimise_num_div('FloorDivide', node, function, args, is_unbound_method) + + def _handle_simple_method_object___truediv__(self, node, function, args, is_unbound_method): + return self._optimise_num_div('TrueDivide', node, function, args, is_unbound_method) + + def _handle_simple_method_object___div__(self, node, function, args, is_unbound_method): + return self._optimise_num_div('Divide', node, function, args, is_unbound_method) + + def _optimise_num_div(self, operator, node, function, args, is_unbound_method): + if len(args) != 2 or not args[1].has_constant_result() or args[1].constant_result == 0: + return node + if isinstance(args[1], ExprNodes.IntNode): + if not (-2**30 <= args[1].constant_result <= 2**30): + return node + elif isinstance(args[1], ExprNodes.FloatNode): + if not (-2**53 <= args[1].constant_result <= 2**53): + return node + else: + return node + return self._optimise_num_binop(operator, node, function, args, is_unbound_method) + + def _handle_simple_method_float___add__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Add', node, function, args, is_unbound_method) + + def _handle_simple_method_float___sub__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Subtract', node, function, args, is_unbound_method) + + def _handle_simple_method_float___truediv__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('TrueDivide', node, function, args, is_unbound_method) + + def _handle_simple_method_float___div__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Divide', node, function, args, is_unbound_method) + + def _handle_simple_method_float___mod__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Remainder', node, function, args, is_unbound_method) + + def _handle_simple_method_float___eq__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Eq', node, function, args, is_unbound_method) + + def _handle_simple_method_float___ne__(self, node, function, args, is_unbound_method): + return self._optimise_num_binop('Ne', node, function, args, is_unbound_method) + + def _optimise_num_binop(self, operator, node, function, args, is_unbound_method): + """ + Optimise math operators for (likely) float or small integer operations. + """ + if len(args) != 2: + return node + + if node.type.is_pyobject: + ret_type = PyrexTypes.py_object_type + elif node.type is PyrexTypes.c_bint_type and operator in ('Eq', 'Ne'): + ret_type = PyrexTypes.c_bint_type + else: + return node + + # When adding IntNode/FloatNode to something else, assume other operand is also numeric. + # Prefer constants on RHS as they allows better size control for some operators. + num_nodes = (ExprNodes.IntNode, ExprNodes.FloatNode) + if isinstance(args[1], num_nodes): + if args[0].type is not PyrexTypes.py_object_type: + return node + numval = args[1] + arg_order = 'ObjC' + elif isinstance(args[0], num_nodes): + if args[1].type is not PyrexTypes.py_object_type: + return node + numval = args[0] + arg_order = 'CObj' + else: + return node + + if not numval.has_constant_result(): + return node + + is_float = isinstance(numval, ExprNodes.FloatNode) + num_type = PyrexTypes.c_double_type if is_float else PyrexTypes.c_long_type + if is_float: + if operator not in ('Add', 'Subtract', 'Remainder', 'TrueDivide', 'Divide', 'Eq', 'Ne'): + return node + elif operator == 'Divide': + # mixed old-/new-style division is not currently optimised for integers + return node + elif abs(numval.constant_result) > 2**30: + # Cut off at an integer border that is still safe for all operations. + return node + + if operator in ('TrueDivide', 'FloorDivide', 'Divide', 'Remainder'): + if args[1].constant_result == 0: + # Don't optimise division by 0. :) + return node + + args = list(args) + args.append((ExprNodes.FloatNode if is_float else ExprNodes.IntNode)( + numval.pos, value=numval.value, constant_result=numval.constant_result, + type=num_type)) + inplace = node.inplace if isinstance(node, ExprNodes.NumBinopNode) else False + args.append(ExprNodes.BoolNode(node.pos, value=inplace, constant_result=inplace)) + if is_float or operator not in ('Eq', 'Ne'): + # "PyFloatBinop" and "PyIntBinop" take an additional "check for zero division" argument. + zerodivision_check = arg_order == 'CObj' and ( + not node.cdivision if isinstance(node, ExprNodes.DivNode) else False) + args.append(ExprNodes.BoolNode(node.pos, value=zerodivision_check, constant_result=zerodivision_check)) + + utility_code = TempitaUtilityCode.load_cached( + "PyFloatBinop" if is_float else "PyIntCompare" if operator in ('Eq', 'Ne') else "PyIntBinop", + "Optimize.c", + context=dict(op=operator, order=arg_order, ret_type=ret_type)) + + call_node = self._substitute_method_call( + node, function, + "__Pyx_Py%s_%s%s%s" % ( + 'Float' if is_float else 'Int', + '' if ret_type.is_pyobject else 'Bool', + operator, + arg_order), + self.Pyx_BinopInt_func_types[(num_type, ret_type)], + '__%s__' % operator[:3].lower(), is_unbound_method, args, + may_return_none=True, + with_none_check=False, + utility_code=utility_code) + + if node.type.is_pyobject and not ret_type.is_pyobject: + call_node = ExprNodes.CoerceToPyTypeNode(call_node, self.current_env(), node.type) + return call_node + + ### unicode type methods + + PyUnicode_uchar_predicate_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_bint_type, [ + PyrexTypes.CFuncTypeArg("uchar", PyrexTypes.c_py_ucs4_type, None), + ]) + + def _inject_unicode_predicate(self, node, function, args, is_unbound_method): + if is_unbound_method or len(args) != 1: + return node + ustring = args[0] + if not isinstance(ustring, ExprNodes.CoerceToPyTypeNode) or \ + not ustring.arg.type.is_unicode_char: + return node + uchar = ustring.arg + method_name = function.attribute + if method_name == 'istitle': + # istitle() doesn't directly map to Py_UNICODE_ISTITLE() + utility_code = UtilityCode.load_cached( + "py_unicode_istitle", "StringTools.c") + function_name = '__Pyx_Py_UNICODE_ISTITLE' + else: + utility_code = None + function_name = 'Py_UNICODE_%s' % method_name.upper() + func_call = self._substitute_method_call( + node, function, + function_name, self.PyUnicode_uchar_predicate_func_type, + method_name, is_unbound_method, [uchar], + utility_code = utility_code) + if node.type.is_pyobject: + func_call = func_call.coerce_to_pyobject(self.current_env) + return func_call + + _handle_simple_method_unicode_isalnum = _inject_unicode_predicate + _handle_simple_method_unicode_isalpha = _inject_unicode_predicate + _handle_simple_method_unicode_isdecimal = _inject_unicode_predicate + _handle_simple_method_unicode_isdigit = _inject_unicode_predicate + _handle_simple_method_unicode_islower = _inject_unicode_predicate + _handle_simple_method_unicode_isnumeric = _inject_unicode_predicate + _handle_simple_method_unicode_isspace = _inject_unicode_predicate + _handle_simple_method_unicode_istitle = _inject_unicode_predicate + _handle_simple_method_unicode_isupper = _inject_unicode_predicate + + PyUnicode_uchar_conversion_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_py_ucs4_type, [ + PyrexTypes.CFuncTypeArg("uchar", PyrexTypes.c_py_ucs4_type, None), + ]) + + def _inject_unicode_character_conversion(self, node, function, args, is_unbound_method): + if is_unbound_method or len(args) != 1: + return node + ustring = args[0] + if not isinstance(ustring, ExprNodes.CoerceToPyTypeNode) or \ + not ustring.arg.type.is_unicode_char: + return node + uchar = ustring.arg + method_name = function.attribute + function_name = 'Py_UNICODE_TO%s' % method_name.upper() + func_call = self._substitute_method_call( + node, function, + function_name, self.PyUnicode_uchar_conversion_func_type, + method_name, is_unbound_method, [uchar]) + if node.type.is_pyobject: + func_call = func_call.coerce_to_pyobject(self.current_env) + return func_call + + _handle_simple_method_unicode_lower = _inject_unicode_character_conversion + _handle_simple_method_unicode_upper = _inject_unicode_character_conversion + _handle_simple_method_unicode_title = _inject_unicode_character_conversion + + PyUnicode_Splitlines_func_type = PyrexTypes.CFuncType( + Builtin.list_type, [ + PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None), + PyrexTypes.CFuncTypeArg("keepends", PyrexTypes.c_bint_type, None), + ]) + + def _handle_simple_method_unicode_splitlines(self, node, function, args, is_unbound_method): + """Replace unicode.splitlines(...) by a direct call to the + corresponding C-API function. + """ + if len(args) not in (1,2): + self._error_wrong_arg_count('unicode.splitlines', node, args, "1 or 2") + return node + self._inject_bint_default_argument(node, args, 1, False) + + return self._substitute_method_call( + node, function, + "PyUnicode_Splitlines", self.PyUnicode_Splitlines_func_type, + 'splitlines', is_unbound_method, args) + + PyUnicode_Split_func_type = PyrexTypes.CFuncType( + Builtin.list_type, [ + PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None), + PyrexTypes.CFuncTypeArg("sep", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("maxsplit", PyrexTypes.c_py_ssize_t_type, None), + ] + ) + + def _handle_simple_method_unicode_split(self, node, function, args, is_unbound_method): + """Replace unicode.split(...) by a direct call to the + corresponding C-API function. + """ + if len(args) not in (1,2,3): + self._error_wrong_arg_count('unicode.split', node, args, "1-3") + return node + if len(args) < 2: + args.append(ExprNodes.NullNode(node.pos)) + self._inject_int_default_argument( + node, args, 2, PyrexTypes.c_py_ssize_t_type, "-1") + + return self._substitute_method_call( + node, function, + "PyUnicode_Split", self.PyUnicode_Split_func_type, + 'split', is_unbound_method, args) + + PyUnicode_Join_func_type = PyrexTypes.CFuncType( + Builtin.unicode_type, [ + PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None), + PyrexTypes.CFuncTypeArg("seq", PyrexTypes.py_object_type, None), + ]) + + def _handle_simple_method_unicode_join(self, node, function, args, is_unbound_method): + """ + unicode.join() builds a list first => see if we can do this more efficiently + """ + if len(args) != 2: + self._error_wrong_arg_count('unicode.join', node, args, "2") + return node + if isinstance(args[1], ExprNodes.GeneratorExpressionNode): + gen_expr_node = args[1] + loop_node = gen_expr_node.loop + + yield_statements = _find_yield_statements(loop_node) + if yield_statements: + inlined_genexpr = ExprNodes.InlinedGeneratorExpressionNode( + node.pos, gen_expr_node, orig_func='list', + comprehension_type=Builtin.list_type) + + for yield_expression, yield_stat_node in yield_statements: + append_node = ExprNodes.ComprehensionAppendNode( + yield_expression.pos, + expr=yield_expression, + target=inlined_genexpr.target) + + Visitor.recursively_replace_node(gen_expr_node, yield_stat_node, append_node) + + args[1] = inlined_genexpr + + return self._substitute_method_call( + node, function, + "PyUnicode_Join", self.PyUnicode_Join_func_type, + 'join', is_unbound_method, args) + + PyString_Tailmatch_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_bint_type, [ + PyrexTypes.CFuncTypeArg("str", PyrexTypes.py_object_type, None), # bytes/str/unicode + PyrexTypes.CFuncTypeArg("substring", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("start", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("end", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("direction", PyrexTypes.c_int_type, None), + ], + exception_value = '-1') + + def _handle_simple_method_unicode_endswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'unicode', 'endswith', + unicode_tailmatch_utility_code, +1) + + def _handle_simple_method_unicode_startswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'unicode', 'startswith', + unicode_tailmatch_utility_code, -1) + + def _inject_tailmatch(self, node, function, args, is_unbound_method, type_name, + method_name, utility_code, direction): + """Replace unicode.startswith(...) and unicode.endswith(...) + by a direct call to the corresponding C-API function. + """ + if len(args) not in (2,3,4): + self._error_wrong_arg_count('%s.%s' % (type_name, method_name), node, args, "2-4") + return node + self._inject_int_default_argument( + node, args, 2, PyrexTypes.c_py_ssize_t_type, "0") + self._inject_int_default_argument( + node, args, 3, PyrexTypes.c_py_ssize_t_type, "PY_SSIZE_T_MAX") + args.append(ExprNodes.IntNode( + node.pos, value=str(direction), type=PyrexTypes.c_int_type)) + + method_call = self._substitute_method_call( + node, function, + "__Pyx_Py%s_Tailmatch" % type_name.capitalize(), + self.PyString_Tailmatch_func_type, + method_name, is_unbound_method, args, + utility_code = utility_code) + return method_call.coerce_to(Builtin.bool_type, self.current_env()) + + PyUnicode_Find_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_py_ssize_t_type, [ + PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None), + PyrexTypes.CFuncTypeArg("substring", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("start", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("end", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("direction", PyrexTypes.c_int_type, None), + ], + exception_value = '-2') + + def _handle_simple_method_unicode_find(self, node, function, args, is_unbound_method): + return self._inject_unicode_find( + node, function, args, is_unbound_method, 'find', +1) + + def _handle_simple_method_unicode_rfind(self, node, function, args, is_unbound_method): + return self._inject_unicode_find( + node, function, args, is_unbound_method, 'rfind', -1) + + def _inject_unicode_find(self, node, function, args, is_unbound_method, + method_name, direction): + """Replace unicode.find(...) and unicode.rfind(...) by a + direct call to the corresponding C-API function. + """ + if len(args) not in (2,3,4): + self._error_wrong_arg_count('unicode.%s' % method_name, node, args, "2-4") + return node + self._inject_int_default_argument( + node, args, 2, PyrexTypes.c_py_ssize_t_type, "0") + self._inject_int_default_argument( + node, args, 3, PyrexTypes.c_py_ssize_t_type, "PY_SSIZE_T_MAX") + args.append(ExprNodes.IntNode( + node.pos, value=str(direction), type=PyrexTypes.c_int_type)) + + method_call = self._substitute_method_call( + node, function, "PyUnicode_Find", self.PyUnicode_Find_func_type, + method_name, is_unbound_method, args) + return method_call.coerce_to_pyobject(self.current_env()) + + PyUnicode_Count_func_type = PyrexTypes.CFuncType( + PyrexTypes.c_py_ssize_t_type, [ + PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None), + PyrexTypes.CFuncTypeArg("substring", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("start", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("end", PyrexTypes.c_py_ssize_t_type, None), + ], + exception_value = '-1') + + def _handle_simple_method_unicode_count(self, node, function, args, is_unbound_method): + """Replace unicode.count(...) by a direct call to the + corresponding C-API function. + """ + if len(args) not in (2,3,4): + self._error_wrong_arg_count('unicode.count', node, args, "2-4") + return node + self._inject_int_default_argument( + node, args, 2, PyrexTypes.c_py_ssize_t_type, "0") + self._inject_int_default_argument( + node, args, 3, PyrexTypes.c_py_ssize_t_type, "PY_SSIZE_T_MAX") + + method_call = self._substitute_method_call( + node, function, "PyUnicode_Count", self.PyUnicode_Count_func_type, + 'count', is_unbound_method, args) + return method_call.coerce_to_pyobject(self.current_env()) + + PyUnicode_Replace_func_type = PyrexTypes.CFuncType( + Builtin.unicode_type, [ + PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None), + PyrexTypes.CFuncTypeArg("substring", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("replstr", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("maxcount", PyrexTypes.c_py_ssize_t_type, None), + ]) + + def _handle_simple_method_unicode_replace(self, node, function, args, is_unbound_method): + """Replace unicode.replace(...) by a direct call to the + corresponding C-API function. + """ + if len(args) not in (3,4): + self._error_wrong_arg_count('unicode.replace', node, args, "3-4") + return node + self._inject_int_default_argument( + node, args, 3, PyrexTypes.c_py_ssize_t_type, "-1") + + return self._substitute_method_call( + node, function, "PyUnicode_Replace", self.PyUnicode_Replace_func_type, + 'replace', is_unbound_method, args) + + PyUnicode_AsEncodedString_func_type = PyrexTypes.CFuncType( + Builtin.bytes_type, [ + PyrexTypes.CFuncTypeArg("obj", Builtin.unicode_type, None), + PyrexTypes.CFuncTypeArg("encoding", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("errors", PyrexTypes.c_const_char_ptr_type, None), + ]) + + PyUnicode_AsXyzString_func_type = PyrexTypes.CFuncType( + Builtin.bytes_type, [ + PyrexTypes.CFuncTypeArg("obj", Builtin.unicode_type, None), + ]) + + _special_encodings = ['UTF8', 'UTF16', 'UTF-16LE', 'UTF-16BE', 'Latin1', 'ASCII', + 'unicode_escape', 'raw_unicode_escape'] + + _special_codecs = [ (name, codecs.getencoder(name)) + for name in _special_encodings ] + + def _handle_simple_method_unicode_encode(self, node, function, args, is_unbound_method): + """Replace unicode.encode(...) by a direct C-API call to the + corresponding codec. + """ + if len(args) < 1 or len(args) > 3: + self._error_wrong_arg_count('unicode.encode', node, args, '1-3') + return node + + string_node = args[0] + + if len(args) == 1: + null_node = ExprNodes.NullNode(node.pos) + return self._substitute_method_call( + node, function, "PyUnicode_AsEncodedString", + self.PyUnicode_AsEncodedString_func_type, + 'encode', is_unbound_method, [string_node, null_node, null_node]) + + parameters = self._unpack_encoding_and_error_mode(node.pos, args) + if parameters is None: + return node + encoding, encoding_node, error_handling, error_handling_node = parameters + + if encoding and isinstance(string_node, ExprNodes.UnicodeNode): + # constant, so try to do the encoding at compile time + try: + value = string_node.value.encode(encoding, error_handling) + except: + # well, looks like we can't + pass + else: + value = bytes_literal(value, encoding) + return ExprNodes.BytesNode(string_node.pos, value=value, type=Builtin.bytes_type) + + if encoding and error_handling == 'strict': + # try to find a specific encoder function + codec_name = self._find_special_codec_name(encoding) + if codec_name is not None and '-' not in codec_name: + encode_function = "PyUnicode_As%sString" % codec_name + return self._substitute_method_call( + node, function, encode_function, + self.PyUnicode_AsXyzString_func_type, + 'encode', is_unbound_method, [string_node]) + + return self._substitute_method_call( + node, function, "PyUnicode_AsEncodedString", + self.PyUnicode_AsEncodedString_func_type, + 'encode', is_unbound_method, + [string_node, encoding_node, error_handling_node]) + + PyUnicode_DecodeXyz_func_ptr_type = PyrexTypes.CPtrType(PyrexTypes.CFuncType( + Builtin.unicode_type, [ + PyrexTypes.CFuncTypeArg("string", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("size", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("errors", PyrexTypes.c_const_char_ptr_type, None), + ])) + + _decode_c_string_func_type = PyrexTypes.CFuncType( + Builtin.unicode_type, [ + PyrexTypes.CFuncTypeArg("string", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("start", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("stop", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("encoding", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("errors", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("decode_func", PyUnicode_DecodeXyz_func_ptr_type, None), + ]) + + _decode_bytes_func_type = PyrexTypes.CFuncType( + Builtin.unicode_type, [ + PyrexTypes.CFuncTypeArg("string", PyrexTypes.py_object_type, None), + PyrexTypes.CFuncTypeArg("start", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("stop", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("encoding", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("errors", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("decode_func", PyUnicode_DecodeXyz_func_ptr_type, None), + ]) + + _decode_cpp_string_func_type = None # lazy init + + def _handle_simple_method_bytes_decode(self, node, function, args, is_unbound_method): + """Replace char*.decode() by a direct C-API call to the + corresponding codec, possibly resolving a slice on the char*. + """ + if not (1 <= len(args) <= 3): + self._error_wrong_arg_count('bytes.decode', node, args, '1-3') + return node + + # normalise input nodes + string_node = args[0] + start = stop = None + if isinstance(string_node, ExprNodes.SliceIndexNode): + index_node = string_node + string_node = index_node.base + start, stop = index_node.start, index_node.stop + if not start or start.constant_result == 0: + start = None + if isinstance(string_node, ExprNodes.CoerceToPyTypeNode): + string_node = string_node.arg + + string_type = string_node.type + if string_type in (Builtin.bytes_type, Builtin.bytearray_type): + if is_unbound_method: + string_node = string_node.as_none_safe_node( + "descriptor '%s' requires a '%s' object but received a 'NoneType'", + format_args=['decode', string_type.name]) + else: + string_node = string_node.as_none_safe_node( + "'NoneType' object has no attribute '%.30s'", + error="PyExc_AttributeError", + format_args=['decode']) + elif not string_type.is_string and not string_type.is_cpp_string: + # nothing to optimise here + return node + + parameters = self._unpack_encoding_and_error_mode(node.pos, args) + if parameters is None: + return node + encoding, encoding_node, error_handling, error_handling_node = parameters + + if not start: + start = ExprNodes.IntNode(node.pos, value='0', constant_result=0) + elif not start.type.is_int: + start = start.coerce_to(PyrexTypes.c_py_ssize_t_type, self.current_env()) + if stop and not stop.type.is_int: + stop = stop.coerce_to(PyrexTypes.c_py_ssize_t_type, self.current_env()) + + # try to find a specific encoder function + codec_name = None + if encoding is not None: + codec_name = self._find_special_codec_name(encoding) + if codec_name is not None: + if codec_name in ('UTF16', 'UTF-16LE', 'UTF-16BE'): + codec_cname = "__Pyx_PyUnicode_Decode%s" % codec_name.replace('-', '') + else: + codec_cname = "PyUnicode_Decode%s" % codec_name + decode_function = ExprNodes.RawCNameExprNode( + node.pos, type=self.PyUnicode_DecodeXyz_func_ptr_type, cname=codec_cname) + encoding_node = ExprNodes.NullNode(node.pos) + else: + decode_function = ExprNodes.NullNode(node.pos) + + # build the helper function call + temps = [] + if string_type.is_string: + # C string + if not stop: + # use strlen() to find the string length, just as CPython would + if not string_node.is_name: + string_node = UtilNodes.LetRefNode(string_node) # used twice + temps.append(string_node) + stop = ExprNodes.PythonCapiCallNode( + string_node.pos, "strlen", self.Pyx_strlen_func_type, + args=[string_node], + is_temp=False, + utility_code=UtilityCode.load_cached("IncludeStringH", "StringTools.c"), + ).coerce_to(PyrexTypes.c_py_ssize_t_type, self.current_env()) + helper_func_type = self._decode_c_string_func_type + utility_code_name = 'decode_c_string' + elif string_type.is_cpp_string: + # C++ std::string + if not stop: + stop = ExprNodes.IntNode(node.pos, value='PY_SSIZE_T_MAX', + constant_result=ExprNodes.not_a_constant) + if self._decode_cpp_string_func_type is None: + # lazy init to reuse the C++ string type + self._decode_cpp_string_func_type = PyrexTypes.CFuncType( + Builtin.unicode_type, [ + PyrexTypes.CFuncTypeArg("string", string_type, None), + PyrexTypes.CFuncTypeArg("start", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("stop", PyrexTypes.c_py_ssize_t_type, None), + PyrexTypes.CFuncTypeArg("encoding", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("errors", PyrexTypes.c_const_char_ptr_type, None), + PyrexTypes.CFuncTypeArg("decode_func", self.PyUnicode_DecodeXyz_func_ptr_type, None), + ]) + helper_func_type = self._decode_cpp_string_func_type + utility_code_name = 'decode_cpp_string' + else: + # Python bytes/bytearray object + if not stop: + stop = ExprNodes.IntNode(node.pos, value='PY_SSIZE_T_MAX', + constant_result=ExprNodes.not_a_constant) + helper_func_type = self._decode_bytes_func_type + if string_type is Builtin.bytes_type: + utility_code_name = 'decode_bytes' + else: + utility_code_name = 'decode_bytearray' + + node = ExprNodes.PythonCapiCallNode( + node.pos, '__Pyx_%s' % utility_code_name, helper_func_type, + args=[string_node, start, stop, encoding_node, error_handling_node, decode_function], + is_temp=node.is_temp, + utility_code=UtilityCode.load_cached(utility_code_name, 'StringTools.c'), + ) + + for temp in temps[::-1]: + node = UtilNodes.EvalWithTempExprNode(temp, node) + return node + + _handle_simple_method_bytearray_decode = _handle_simple_method_bytes_decode + + def _find_special_codec_name(self, encoding): + try: + requested_codec = codecs.getencoder(encoding) + except LookupError: + return None + for name, codec in self._special_codecs: + if codec == requested_codec: + if '_' in name: + name = ''.join([s.capitalize() + for s in name.split('_')]) + return name + return None + + def _unpack_encoding_and_error_mode(self, pos, args): + null_node = ExprNodes.NullNode(pos) + + if len(args) >= 2: + encoding, encoding_node = self._unpack_string_and_cstring_node(args[1]) + if encoding_node is None: + return None + else: + encoding = None + encoding_node = null_node + + if len(args) == 3: + error_handling, error_handling_node = self._unpack_string_and_cstring_node(args[2]) + if error_handling_node is None: + return None + if error_handling == 'strict': + error_handling_node = null_node + else: + error_handling = 'strict' + error_handling_node = null_node + + return (encoding, encoding_node, error_handling, error_handling_node) + + def _unpack_string_and_cstring_node(self, node): + if isinstance(node, ExprNodes.CoerceToPyTypeNode): + node = node.arg + if isinstance(node, ExprNodes.UnicodeNode): + encoding = node.value + node = ExprNodes.BytesNode( + node.pos, value=encoding.as_utf8_string(), type=PyrexTypes.c_const_char_ptr_type) + elif isinstance(node, (ExprNodes.StringNode, ExprNodes.BytesNode)): + encoding = node.value.decode('ISO-8859-1') + node = ExprNodes.BytesNode( + node.pos, value=node.value, type=PyrexTypes.c_const_char_ptr_type) + elif node.type is Builtin.bytes_type: + encoding = None + node = node.coerce_to(PyrexTypes.c_const_char_ptr_type, self.current_env()) + elif node.type.is_string: + encoding = None + else: + encoding = node = None + return encoding, node + + def _handle_simple_method_str_endswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'str', 'endswith', + str_tailmatch_utility_code, +1) + + def _handle_simple_method_str_startswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'str', 'startswith', + str_tailmatch_utility_code, -1) + + def _handle_simple_method_bytes_endswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'bytes', 'endswith', + bytes_tailmatch_utility_code, +1) + + def _handle_simple_method_bytes_startswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'bytes', 'startswith', + bytes_tailmatch_utility_code, -1) + + ''' # disabled for now, enable when we consider it worth it (see StringTools.c) + def _handle_simple_method_bytearray_endswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'bytearray', 'endswith', + bytes_tailmatch_utility_code, +1) + + def _handle_simple_method_bytearray_startswith(self, node, function, args, is_unbound_method): + return self._inject_tailmatch( + node, function, args, is_unbound_method, 'bytearray', 'startswith', + bytes_tailmatch_utility_code, -1) + ''' + + ### helpers + + def _substitute_method_call(self, node, function, name, func_type, + attr_name, is_unbound_method, args=(), + utility_code=None, is_temp=None, + may_return_none=ExprNodes.PythonCapiCallNode.may_return_none, + with_none_check=True): + args = list(args) + if with_none_check and args: + args[0] = self._wrap_self_arg(args[0], function, is_unbound_method, attr_name) + if is_temp is None: + is_temp = node.is_temp + return ExprNodes.PythonCapiCallNode( + node.pos, name, func_type, + args = args, + is_temp = is_temp, + utility_code = utility_code, + may_return_none = may_return_none, + result_is_used = node.result_is_used, + ) + + def _wrap_self_arg(self, self_arg, function, is_unbound_method, attr_name): + if self_arg.is_literal: + return self_arg + if is_unbound_method: + self_arg = self_arg.as_none_safe_node( + "descriptor '%s' requires a '%s' object but received a 'NoneType'", + format_args=[attr_name, self_arg.type.name]) + else: + self_arg = self_arg.as_none_safe_node( + "'NoneType' object has no attribute '%{0}s'".format('.30' if len(attr_name) <= 30 else ''), + error="PyExc_AttributeError", + format_args=[attr_name]) + return self_arg + + def _inject_int_default_argument(self, node, args, arg_index, type, default_value): + assert len(args) >= arg_index + if len(args) == arg_index: + args.append(ExprNodes.IntNode(node.pos, value=str(default_value), + type=type, constant_result=default_value)) + else: + args[arg_index] = args[arg_index].coerce_to(type, self.current_env()) + + def _inject_bint_default_argument(self, node, args, arg_index, default_value): + assert len(args) >= arg_index + if len(args) == arg_index: + default_value = bool(default_value) + args.append(ExprNodes.BoolNode(node.pos, value=default_value, + constant_result=default_value)) + else: + args[arg_index] = args[arg_index].coerce_to_boolean(self.current_env()) + + +unicode_tailmatch_utility_code = UtilityCode.load_cached('unicode_tailmatch', 'StringTools.c') +bytes_tailmatch_utility_code = UtilityCode.load_cached('bytes_tailmatch', 'StringTools.c') +str_tailmatch_utility_code = UtilityCode.load_cached('str_tailmatch', 'StringTools.c') + + +class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): + """Calculate the result of constant expressions to store it in + ``expr_node.constant_result``, and replace trivial cases by their + constant result. + + General rules: + + - We calculate float constants to make them available to the + compiler, but we do not aggregate them into a single literal + node to prevent any loss of precision. + + - We recursively calculate constants from non-literal nodes to + make them available to the compiler, but we only aggregate + literal nodes at each step. Non-literal nodes are never merged + into a single node. + """ + + def __init__(self, reevaluate=False): + """ + The reevaluate argument specifies whether constant values that were + previously computed should be recomputed. + """ + super(ConstantFolding, self).__init__() + self.reevaluate = reevaluate + + def _calculate_const(self, node): + if (not self.reevaluate and + node.constant_result is not ExprNodes.constant_value_not_set): + return + + # make sure we always set the value + not_a_constant = ExprNodes.not_a_constant + node.constant_result = not_a_constant + + # check if all children are constant + children = self.visitchildren(node) + for child_result in children.values(): + if type(child_result) is list: + for child in child_result: + if getattr(child, 'constant_result', not_a_constant) is not_a_constant: + return + elif getattr(child_result, 'constant_result', not_a_constant) is not_a_constant: + return + + # now try to calculate the real constant value + try: + node.calculate_constant_result() +# if node.constant_result is not ExprNodes.not_a_constant: +# print node.__class__.__name__, node.constant_result + except (ValueError, TypeError, KeyError, IndexError, AttributeError, ArithmeticError): + # ignore all 'normal' errors here => no constant result + pass + except Exception: + # this looks like a real error + import traceback, sys + traceback.print_exc(file=sys.stdout) + + NODE_TYPE_ORDER = [ExprNodes.BoolNode, ExprNodes.CharNode, + ExprNodes.IntNode, ExprNodes.FloatNode] + + def _widest_node_class(self, *nodes): + try: + return self.NODE_TYPE_ORDER[ + max(map(self.NODE_TYPE_ORDER.index, map(type, nodes)))] + except ValueError: + return None + + def _bool_node(self, node, value): + value = bool(value) + return ExprNodes.BoolNode(node.pos, value=value, constant_result=value) + + def visit_ExprNode(self, node): + self._calculate_const(node) + return node + + def visit_UnopNode(self, node): + self._calculate_const(node) + if not node.has_constant_result(): + if node.operator == '!': + return self._handle_NotNode(node) + return node + if not node.operand.is_literal: + return node + if node.operator == '!': + return self._bool_node(node, node.constant_result) + elif isinstance(node.operand, ExprNodes.BoolNode): + return ExprNodes.IntNode(node.pos, value=str(int(node.constant_result)), + type=PyrexTypes.c_int_type, + constant_result=int(node.constant_result)) + elif node.operator == '+': + return self._handle_UnaryPlusNode(node) + elif node.operator == '-': + return self._handle_UnaryMinusNode(node) + return node + + _negate_operator = { + 'in': 'not_in', + 'not_in': 'in', + 'is': 'is_not', + 'is_not': 'is' + }.get + + def _handle_NotNode(self, node): + operand = node.operand + if isinstance(operand, ExprNodes.PrimaryCmpNode): + operator = self._negate_operator(operand.operator) + if operator: + node = copy.copy(operand) + node.operator = operator + node = self.visit_PrimaryCmpNode(node) + return node + + def _handle_UnaryMinusNode(self, node): + def _negate(value): + if value.startswith('-'): + value = value[1:] + else: + value = '-' + value + return value + + node_type = node.operand.type + if isinstance(node.operand, ExprNodes.FloatNode): + # this is a safe operation + return ExprNodes.FloatNode(node.pos, value=_negate(node.operand.value), + type=node_type, + constant_result=node.constant_result) + if node_type.is_int and node_type.signed or \ + isinstance(node.operand, ExprNodes.IntNode) and node_type.is_pyobject: + return ExprNodes.IntNode(node.pos, value=_negate(node.operand.value), + type=node_type, + longness=node.operand.longness, + constant_result=node.constant_result) + return node + + def _handle_UnaryPlusNode(self, node): + if (node.operand.has_constant_result() and + node.constant_result == node.operand.constant_result): + return node.operand + return node + + def visit_BoolBinopNode(self, node): + self._calculate_const(node) + if not node.operand1.has_constant_result(): + return node + if node.operand1.constant_result: + if node.operator == 'and': + return node.operand2 + else: + return node.operand1 + else: + if node.operator == 'and': + return node.operand1 + else: + return node.operand2 + + def visit_BinopNode(self, node): + self._calculate_const(node) + if node.constant_result is ExprNodes.not_a_constant: + return node + if isinstance(node.constant_result, float): + return node + operand1, operand2 = node.operand1, node.operand2 + if not operand1.is_literal or not operand2.is_literal: + return node + + # now inject a new constant node with the calculated value + try: + type1, type2 = operand1.type, operand2.type + if type1 is None or type2 is None: + return node + except AttributeError: + return node + + if type1.is_numeric and type2.is_numeric: + widest_type = PyrexTypes.widest_numeric_type(type1, type2) + else: + widest_type = PyrexTypes.py_object_type + + target_class = self._widest_node_class(operand1, operand2) + if target_class is None: + return node + elif target_class is ExprNodes.BoolNode and node.operator in '+-//<<%**>>': + # C arithmetic results in at least an int type + target_class = ExprNodes.IntNode + elif target_class is ExprNodes.CharNode and node.operator in '+-//<<%**>>&|^': + # C arithmetic results in at least an int type + target_class = ExprNodes.IntNode + + if target_class is ExprNodes.IntNode: + unsigned = getattr(operand1, 'unsigned', '') and \ + getattr(operand2, 'unsigned', '') + longness = "LL"[:max(len(getattr(operand1, 'longness', '')), + len(getattr(operand2, 'longness', '')))] + new_node = ExprNodes.IntNode(pos=node.pos, + unsigned=unsigned, longness=longness, + value=str(int(node.constant_result)), + constant_result=int(node.constant_result)) + # IntNode is smart about the type it chooses, so we just + # make sure we were not smarter this time + if widest_type.is_pyobject or new_node.type.is_pyobject: + new_node.type = PyrexTypes.py_object_type + else: + new_node.type = PyrexTypes.widest_numeric_type(widest_type, new_node.type) + else: + if target_class is ExprNodes.BoolNode: + node_value = node.constant_result + else: + node_value = str(node.constant_result) + new_node = target_class(pos=node.pos, type = widest_type, + value = node_value, + constant_result = node.constant_result) + return new_node + + def visit_AddNode(self, node): + self._calculate_const(node) + if node.constant_result is ExprNodes.not_a_constant: + return node + if node.operand1.is_string_literal and node.operand2.is_string_literal: + # some people combine string literals with a '+' + str1, str2 = node.operand1, node.operand2 + if isinstance(str1, ExprNodes.UnicodeNode) and isinstance(str2, ExprNodes.UnicodeNode): + bytes_value = None + if str1.bytes_value is not None and str2.bytes_value is not None: + if str1.bytes_value.encoding == str2.bytes_value.encoding: + bytes_value = bytes_literal( + str1.bytes_value + str2.bytes_value, + str1.bytes_value.encoding) + string_value = EncodedString(node.constant_result) + return ExprNodes.UnicodeNode( + str1.pos, value=string_value, constant_result=node.constant_result, bytes_value=bytes_value) + elif isinstance(str1, ExprNodes.BytesNode) and isinstance(str2, ExprNodes.BytesNode): + if str1.value.encoding == str2.value.encoding: + bytes_value = bytes_literal(node.constant_result, str1.value.encoding) + return ExprNodes.BytesNode(str1.pos, value=bytes_value, constant_result=node.constant_result) + # all other combinations are rather complicated + # to get right in Py2/3: encodings, unicode escapes, ... + return self.visit_BinopNode(node) + + def visit_MulNode(self, node): + self._calculate_const(node) + if node.operand1.is_sequence_constructor: + return self._calculate_constant_seq(node, node.operand1, node.operand2) + if isinstance(node.operand1, ExprNodes.IntNode) and \ + node.operand2.is_sequence_constructor: + return self._calculate_constant_seq(node, node.operand2, node.operand1) + if node.operand1.is_string_literal: + return self._multiply_string(node, node.operand1, node.operand2) + elif node.operand2.is_string_literal: + return self._multiply_string(node, node.operand2, node.operand1) + return self.visit_BinopNode(node) + + def _multiply_string(self, node, string_node, multiplier_node): + multiplier = multiplier_node.constant_result + if not isinstance(multiplier, _py_int_types): + return node + if not (node.has_constant_result() and isinstance(node.constant_result, _py_string_types)): + return node + if len(node.constant_result) > 256: + # Too long for static creation, leave it to runtime. (-> arbitrary limit) + return node + + build_string = encoded_string + if isinstance(string_node, ExprNodes.BytesNode): + build_string = bytes_literal + elif isinstance(string_node, ExprNodes.StringNode): + if string_node.unicode_value is not None: + string_node.unicode_value = encoded_string( + string_node.unicode_value * multiplier, + string_node.unicode_value.encoding) + build_string = encoded_string if string_node.value.is_unicode else bytes_literal + elif isinstance(string_node, ExprNodes.UnicodeNode): + if string_node.bytes_value is not None: + string_node.bytes_value = bytes_literal( + string_node.bytes_value * multiplier, + string_node.bytes_value.encoding) + else: + assert False, "unknown string node type: %s" % type(string_node) + string_node.value = build_string( + string_node.value * multiplier, + string_node.value.encoding) + # follow constant-folding and use unicode_value in preference + if isinstance(string_node, ExprNodes.StringNode) and string_node.unicode_value is not None: + string_node.constant_result = string_node.unicode_value + else: + string_node.constant_result = string_node.value + return string_node + + def _calculate_constant_seq(self, node, sequence_node, factor): + if factor.constant_result != 1 and sequence_node.args: + if isinstance(factor.constant_result, _py_int_types) and factor.constant_result <= 0: + del sequence_node.args[:] + sequence_node.mult_factor = None + elif sequence_node.mult_factor is not None: + if (isinstance(factor.constant_result, _py_int_types) and + isinstance(sequence_node.mult_factor.constant_result, _py_int_types)): + value = sequence_node.mult_factor.constant_result * factor.constant_result + sequence_node.mult_factor = ExprNodes.IntNode( + sequence_node.mult_factor.pos, + value=str(value), constant_result=value) + else: + # don't know if we can combine the factors, so don't + return self.visit_BinopNode(node) + else: + sequence_node.mult_factor = factor + return sequence_node + + def visit_ModNode(self, node): + self.visitchildren(node) + if isinstance(node.operand1, ExprNodes.UnicodeNode) and isinstance(node.operand2, ExprNodes.TupleNode): + if not node.operand2.mult_factor: + fstring = self._build_fstring(node.operand1.pos, node.operand1.value, node.operand2.args) + if fstring is not None: + return fstring + return self.visit_BinopNode(node) + + _parse_string_format_regex = ( + u'(%(?:' # %... + u'(?:[-0-9]+|[ ])?' # width (optional) or space prefix fill character (optional) + u'(?:[.][0-9]+)?' # precision (optional) + u')?.)' # format type (or something different for unsupported formats) + ) + + def _build_fstring(self, pos, ustring, format_args): + # Issues formatting warnings instead of errors since we really only catch a few errors by accident. + args = iter(format_args) + substrings = [] + can_be_optimised = True + for s in re.split(self._parse_string_format_regex, ustring): + if not s: + continue + if s == u'%%': + substrings.append(ExprNodes.UnicodeNode(pos, value=EncodedString(u'%'), constant_result=u'%')) + continue + if s[0] != u'%': + if s[-1] == u'%': + warning(pos, "Incomplete format: '...%s'" % s[-3:], level=1) + can_be_optimised = False + substrings.append(ExprNodes.UnicodeNode(pos, value=EncodedString(s), constant_result=s)) + continue + format_type = s[-1] + try: + arg = next(args) + except StopIteration: + warning(pos, "Too few arguments for format placeholders", level=1) + can_be_optimised = False + break + if arg.is_starred: + can_be_optimised = False + break + if format_type in u'asrfdoxX': + format_spec = s[1:] + conversion_char = None + if format_type in u'doxX' and u'.' in format_spec: + # Precision is not allowed for integers in format(), but ok in %-formatting. + can_be_optimised = False + elif format_type in u'ars': + format_spec = format_spec[:-1] + conversion_char = format_type + if format_spec.startswith('0'): + format_spec = '>' + format_spec[1:] # right-alignment '%05s' spells '{:>5}' + elif format_type == u'd': + # '%d' formatting supports float, but '{obj:d}' does not => convert to int first. + conversion_char = 'd' + + if format_spec.startswith('-'): + format_spec = '<' + format_spec[1:] # left-alignment '%-5s' spells '{:<5}' + + substrings.append(ExprNodes.FormattedValueNode( + arg.pos, value=arg, + conversion_char=conversion_char, + format_spec=ExprNodes.UnicodeNode( + pos, value=EncodedString(format_spec), constant_result=format_spec) + if format_spec else None, + )) + else: + # keep it simple for now ... + can_be_optimised = False + break + + if not can_be_optimised: + # Print all warnings we can find before finally giving up here. + return None + + try: + next(args) + except StopIteration: pass + else: + warning(pos, "Too many arguments for format placeholders", level=1) + return None + + node = ExprNodes.JoinedStrNode(pos, values=substrings) + return self.visit_JoinedStrNode(node) + + def visit_FormattedValueNode(self, node): + self.visitchildren(node) + conversion_char = node.conversion_char or 's' + if isinstance(node.format_spec, ExprNodes.UnicodeNode) and not node.format_spec.value: + node.format_spec = None + if node.format_spec is None and isinstance(node.value, ExprNodes.IntNode): + value = EncodedString(node.value.value) + if value.isdigit(): + return ExprNodes.UnicodeNode(node.value.pos, value=value, constant_result=value) + if node.format_spec is None and conversion_char == 's': + value = None + if isinstance(node.value, ExprNodes.UnicodeNode): + value = node.value.value + elif isinstance(node.value, ExprNodes.StringNode): + value = node.value.unicode_value + if value is not None: + return ExprNodes.UnicodeNode(node.value.pos, value=value, constant_result=value) + return node + + def visit_JoinedStrNode(self, node): + """ + Clean up after the parser by discarding empty Unicode strings and merging + substring sequences. Empty or single-value join lists are not uncommon + because f-string format specs are always parsed into JoinedStrNodes. + """ + self.visitchildren(node) + unicode_node = ExprNodes.UnicodeNode + + values = [] + for is_unode_group, substrings in itertools.groupby(node.values, lambda v: isinstance(v, unicode_node)): + if is_unode_group: + substrings = list(substrings) + unode = substrings[0] + if len(substrings) > 1: + value = EncodedString(u''.join(value.value for value in substrings)) + unode = ExprNodes.UnicodeNode(unode.pos, value=value, constant_result=value) + # ignore empty Unicode strings + if unode.value: + values.append(unode) + else: + values.extend(substrings) + + if not values: + value = EncodedString('') + node = ExprNodes.UnicodeNode(node.pos, value=value, constant_result=value) + elif len(values) == 1: + node = values[0] + elif len(values) == 2: + # reduce to string concatenation + node = ExprNodes.binop_node(node.pos, '+', *values) + else: + node.values = values + return node + + def visit_MergedDictNode(self, node): + """Unpack **args in place if we can.""" + self.visitchildren(node) + args = [] + items = [] + + def add(arg): + if arg.is_dict_literal: + if items: + items[0].key_value_pairs.extend(arg.key_value_pairs) + else: + items.append(arg) + elif isinstance(arg, ExprNodes.MergedDictNode): + for child_arg in arg.keyword_args: + add(child_arg) + else: + if items: + args.append(items[0]) + del items[:] + args.append(arg) + + for arg in node.keyword_args: + add(arg) + if items: + args.append(items[0]) + + if len(args) == 1: + arg = args[0] + if arg.is_dict_literal or isinstance(arg, ExprNodes.MergedDictNode): + return arg + node.keyword_args[:] = args + self._calculate_const(node) + return node + + def visit_MergedSequenceNode(self, node): + """Unpack *args in place if we can.""" + self.visitchildren(node) + + is_set = node.type is Builtin.set_type + args = [] + values = [] + + def add(arg): + if (is_set and arg.is_set_literal) or (arg.is_sequence_constructor and not arg.mult_factor): + if values: + values[0].args.extend(arg.args) + else: + values.append(arg) + elif isinstance(arg, ExprNodes.MergedSequenceNode): + for child_arg in arg.args: + add(child_arg) + else: + if values: + args.append(values[0]) + del values[:] + args.append(arg) + + for arg in node.args: + add(arg) + if values: + args.append(values[0]) + + if len(args) == 1: + arg = args[0] + if ((is_set and arg.is_set_literal) or + (arg.is_sequence_constructor and arg.type is node.type) or + isinstance(arg, ExprNodes.MergedSequenceNode)): + return arg + node.args[:] = args + self._calculate_const(node) + return node + + def visit_SequenceNode(self, node): + """Unpack *args in place if we can.""" + self.visitchildren(node) + args = [] + for arg in node.args: + if not arg.is_starred: + args.append(arg) + elif arg.target.is_sequence_constructor and not arg.target.mult_factor: + args.extend(arg.target.args) + else: + args.append(arg) + node.args[:] = args + self._calculate_const(node) + return node + + def visit_PrimaryCmpNode(self, node): + # calculate constant partial results in the comparison cascade + self.visitchildren(node, ['operand1']) + left_node = node.operand1 + cmp_node = node + while cmp_node is not None: + self.visitchildren(cmp_node, ['operand2']) + right_node = cmp_node.operand2 + cmp_node.constant_result = not_a_constant + if left_node.has_constant_result() and right_node.has_constant_result(): + try: + cmp_node.calculate_cascaded_constant_result(left_node.constant_result) + except (ValueError, TypeError, KeyError, IndexError, AttributeError, ArithmeticError): + pass # ignore all 'normal' errors here => no constant result + left_node = right_node + cmp_node = cmp_node.cascade + + if not node.cascade: + if node.has_constant_result(): + return self._bool_node(node, node.constant_result) + return node + + # collect partial cascades: [[value, CmpNode...], [value, CmpNode, ...], ...] + cascades = [[node.operand1]] + final_false_result = [] + + def split_cascades(cmp_node): + if cmp_node.has_constant_result(): + if not cmp_node.constant_result: + # False => short-circuit + final_false_result.append(self._bool_node(cmp_node, False)) + return + else: + # True => discard and start new cascade + cascades.append([cmp_node.operand2]) + else: + # not constant => append to current cascade + cascades[-1].append(cmp_node) + if cmp_node.cascade: + split_cascades(cmp_node.cascade) + + split_cascades(node) + + cmp_nodes = [] + for cascade in cascades: + if len(cascade) < 2: + continue + cmp_node = cascade[1] + pcmp_node = ExprNodes.PrimaryCmpNode( + cmp_node.pos, + operand1=cascade[0], + operator=cmp_node.operator, + operand2=cmp_node.operand2, + constant_result=not_a_constant) + cmp_nodes.append(pcmp_node) + + last_cmp_node = pcmp_node + for cmp_node in cascade[2:]: + last_cmp_node.cascade = cmp_node + last_cmp_node = cmp_node + last_cmp_node.cascade = None + + if final_false_result: + # last cascade was constant False + cmp_nodes.append(final_false_result[0]) + elif not cmp_nodes: + # only constants, but no False result + return self._bool_node(node, True) + node = cmp_nodes[0] + if len(cmp_nodes) == 1: + if node.has_constant_result(): + return self._bool_node(node, node.constant_result) + else: + for cmp_node in cmp_nodes[1:]: + node = ExprNodes.BoolBinopNode( + node.pos, + operand1=node, + operator='and', + operand2=cmp_node, + constant_result=not_a_constant) + return node + + def visit_CondExprNode(self, node): + self._calculate_const(node) + if not node.test.has_constant_result(): + return node + if node.test.constant_result: + return node.true_val + else: + return node.false_val + + def visit_IfStatNode(self, node): + self.visitchildren(node) + # eliminate dead code based on constant condition results + if_clauses = [] + for if_clause in node.if_clauses: + condition = if_clause.condition + if condition.has_constant_result(): + if condition.constant_result: + # always true => subsequent clauses can safely be dropped + node.else_clause = if_clause.body + break + # else: false => drop clause + else: + # unknown result => normal runtime evaluation + if_clauses.append(if_clause) + if if_clauses: + node.if_clauses = if_clauses + return node + elif node.else_clause: + return node.else_clause + else: + return Nodes.StatListNode(node.pos, stats=[]) + + def visit_SliceIndexNode(self, node): + self._calculate_const(node) + # normalise start/stop values + if node.start is None or node.start.constant_result is None: + start = node.start = None + else: + start = node.start.constant_result + if node.stop is None or node.stop.constant_result is None: + stop = node.stop = None + else: + stop = node.stop.constant_result + # cut down sliced constant sequences + if node.constant_result is not not_a_constant: + base = node.base + if base.is_sequence_constructor and base.mult_factor is None: + base.args = base.args[start:stop] + return base + elif base.is_string_literal: + base = base.as_sliced_node(start, stop) + if base is not None: + return base + return node + + def visit_ComprehensionNode(self, node): + self.visitchildren(node) + if isinstance(node.loop, Nodes.StatListNode) and not node.loop.stats: + # loop was pruned already => transform into literal + if node.type is Builtin.list_type: + return ExprNodes.ListNode( + node.pos, args=[], constant_result=[]) + elif node.type is Builtin.set_type: + return ExprNodes.SetNode( + node.pos, args=[], constant_result=set()) + elif node.type is Builtin.dict_type: + return ExprNodes.DictNode( + node.pos, key_value_pairs=[], constant_result={}) + return node + + def visit_ForInStatNode(self, node): + self.visitchildren(node) + sequence = node.iterator.sequence + if isinstance(sequence, ExprNodes.SequenceNode): + if not sequence.args: + if node.else_clause: + return node.else_clause + else: + # don't break list comprehensions + return Nodes.StatListNode(node.pos, stats=[]) + # iterating over a list literal? => tuples are more efficient + if isinstance(sequence, ExprNodes.ListNode): + node.iterator.sequence = sequence.as_tuple() + return node + + def visit_WhileStatNode(self, node): + self.visitchildren(node) + if node.condition and node.condition.has_constant_result(): + if node.condition.constant_result: + node.condition = None + node.else_clause = None + else: + return node.else_clause + return node + + def visit_ExprStatNode(self, node): + self.visitchildren(node) + if not isinstance(node.expr, ExprNodes.ExprNode): + # ParallelRangeTransform does this ... + return node + # drop unused constant expressions + if node.expr.has_constant_result(): + return None + return node + + # in the future, other nodes can have their own handler method here + # that can replace them with a constant result node + + visit_Node = Visitor.VisitorTransform.recurse_to_children + + +class FinalOptimizePhase(Visitor.EnvTransform, Visitor.NodeRefCleanupMixin): + """ + This visitor handles several commuting optimizations, and is run + just before the C code generation phase. + + The optimizations currently implemented in this class are: + - eliminate None assignment and refcounting for first assignment. + - isinstance -> typecheck for cdef types + - eliminate checks for None and/or types that became redundant after tree changes + - eliminate useless string formatting steps + - replace Python function calls that look like method calls by a faster PyMethodCallNode + """ + in_loop = False + + def visit_SingleAssignmentNode(self, node): + """Avoid redundant initialisation of local variables before their + first assignment. + """ + self.visitchildren(node) + if node.first: + lhs = node.lhs + lhs.lhs_of_first_assignment = True + return node + + def visit_SimpleCallNode(self, node): + """ + Replace generic calls to isinstance(x, type) by a more efficient type check. + Replace likely Python method calls by a specialised PyMethodCallNode. + """ + self.visitchildren(node) + function = node.function + if function.type.is_cfunction and function.is_name: + if function.name == 'isinstance' and len(node.args) == 2: + type_arg = node.args[1] + if type_arg.type.is_builtin_type and type_arg.type.name == 'type': + cython_scope = self.context.cython_scope + function.entry = cython_scope.lookup('PyObject_TypeCheck') + function.type = function.entry.type + PyTypeObjectPtr = PyrexTypes.CPtrType(cython_scope.lookup('PyTypeObject').type) + node.args[1] = ExprNodes.CastNode(node.args[1], PyTypeObjectPtr) + elif (node.is_temp and function.type.is_pyobject and self.current_directives.get( + "optimize.unpack_method_calls_in_pyinit" + if not self.in_loop and self.current_env().is_module_scope + else "optimize.unpack_method_calls")): + # optimise simple Python methods calls + if isinstance(node.arg_tuple, ExprNodes.TupleNode) and not ( + node.arg_tuple.mult_factor or (node.arg_tuple.is_literal and len(node.arg_tuple.args) > 1)): + # simple call, now exclude calls to objects that are definitely not methods + may_be_a_method = True + if function.type is Builtin.type_type: + may_be_a_method = False + elif function.is_attribute: + if function.entry and function.entry.type.is_cfunction: + # optimised builtin method + may_be_a_method = False + elif function.is_name: + entry = function.entry + if entry.is_builtin or entry.type.is_cfunction: + may_be_a_method = False + elif entry.cf_assignments: + # local functions/classes are definitely not methods + non_method_nodes = (ExprNodes.PyCFunctionNode, ExprNodes.ClassNode, ExprNodes.Py3ClassNode) + may_be_a_method = any( + assignment.rhs and not isinstance(assignment.rhs, non_method_nodes) + for assignment in entry.cf_assignments) + if may_be_a_method: + if (node.self and function.is_attribute and + isinstance(function.obj, ExprNodes.CloneNode) and function.obj.arg is node.self): + # function self object was moved into a CloneNode => undo + function.obj = function.obj.arg + node = self.replace(node, ExprNodes.PyMethodCallNode.from_node( + node, function=function, arg_tuple=node.arg_tuple, type=node.type)) + return node + + def visit_NumPyMethodCallNode(self, node): + # Exclude from replacement above. + self.visitchildren(node) + return node + + def visit_PyTypeTestNode(self, node): + """Remove tests for alternatively allowed None values from + type tests when we know that the argument cannot be None + anyway. + """ + self.visitchildren(node) + if not node.notnone: + if not node.arg.may_be_none(): + node.notnone = True + return node + + def visit_NoneCheckNode(self, node): + """Remove None checks from expressions that definitely do not + carry a None value. + """ + self.visitchildren(node) + if not node.arg.may_be_none(): + return node.arg + return node + + def visit_LoopNode(self, node): + """Remember when we enter a loop as some expensive optimisations might still be worth it there. + """ + old_val = self.in_loop + self.in_loop = True + self.visitchildren(node) + self.in_loop = old_val + return node + + +class ConsolidateOverflowCheck(Visitor.CythonTransform): + """ + This class facilitates the sharing of overflow checking among all nodes + of a nested arithmetic expression. For example, given the expression + a*b + c, where a, b, and x are all possibly overflowing ints, the entire + sequence will be evaluated and the overflow bit checked only at the end. + """ + overflow_bit_node = None + + def visit_Node(self, node): + if self.overflow_bit_node is not None: + saved = self.overflow_bit_node + self.overflow_bit_node = None + self.visitchildren(node) + self.overflow_bit_node = saved + else: + self.visitchildren(node) + return node + + def visit_NumBinopNode(self, node): + if node.overflow_check and node.overflow_fold: + top_level_overflow = self.overflow_bit_node is None + if top_level_overflow: + self.overflow_bit_node = node + else: + node.overflow_bit_node = self.overflow_bit_node + node.overflow_check = False + self.visitchildren(node) + if top_level_overflow: + self.overflow_bit_node = None + else: + self.visitchildren(node) + return node diff --git a/contrib/tools/cython/Cython/Compiler/Options.py b/contrib/tools/cython/Cython/Compiler/Options.py new file mode 100644 index 00000000000..6c9103bb140 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Options.py @@ -0,0 +1,555 @@ +# +# Cython - Compilation-wide options and pragma declarations +# + +from __future__ import absolute_import + + +class ShouldBeFromDirective(object): + + known_directives = [] + + def __init__(self, options_name, directive_name=None, disallow=False): + self.options_name = options_name + self.directive_name = directive_name or options_name + self.disallow = disallow + self.known_directives.append(self) + + def __nonzero__(self): + self._bad_access() + + def __int__(self): + self._bad_access() + + def _bad_access(self): + raise RuntimeError(repr(self)) + + def __repr__(self): + return ( + "Illegal access of '%s' from Options module rather than directive '%s'" + % (self.options_name, self.directive_name)) + + +""" +The members of this module are documented using autodata in +Cython/docs/src/reference/compilation.rst. +See http://www.sphinx-doc.org/en/master/ext/autodoc.html#directive-autoattribute +for how autodata works. +Descriptions of those members should start with a #: +Donc forget to keep the docs in sync by removing and adding +the members in both this file and the .rst file. +""" + +#: Whether or not to include docstring in the Python extension. If False, the binary size +#: will be smaller, but the ``__doc__`` attribute of any class or function will be an +#: empty string. +docstrings = True + +#: Embed the source code position in the docstrings of functions and classes. +embed_pos_in_docstring = False + +#: Copy the original source code line by line into C code comments +#: in the generated code file to help with understanding the output. +#: This is also required for coverage analysis. +emit_code_comments = True + +# undocumented +pre_import = None + +#: Decref global variables in each module on exit for garbage collection. +#: 0: None, 1+: interned objects, 2+: cdef globals, 3+: types objects +#: Mostly for reducing noise in Valgrind as it typically executes at process exit +#: (when all memory will be reclaimed anyways). +#: Note that directly or indirectly executed cleanup code that makes use of global +#: variables or types may no longer be safe when enabling the respective level since +#: there is no guaranteed order in which the (reference counted) objects will +#: be cleaned up. The order can change due to live references and reference cycles. +generate_cleanup_code = False + +#: Should tp_clear() set object fields to None instead of clearing them to NULL? +clear_to_none = True + +#: Generate an annotated HTML version of the input source files for debugging and optimisation purposes. +#: This has the same effect as the ``annotate`` argument in :func:`cythonize`. +annotate = False + +# When annotating source files in HTML, include coverage information from +# this file. +annotate_coverage_xml = None + +#: This will abort the compilation on the first error occurred rather than trying +#: to keep going and printing further error messages. +fast_fail = False + +#: Turn all warnings into errors. +warning_errors = False + +#: Make unknown names an error. Python raises a NameError when +#: encountering unknown names at runtime, whereas this option makes +#: them a compile time error. If you want full Python compatibility, +#: you should disable this option and also 'cache_builtins'. +error_on_unknown_names = True + +#: Make uninitialized local variable reference a compile time error. +#: Python raises UnboundLocalError at runtime, whereas this option makes +#: them a compile time error. Note that this option affects only variables +#: of "python object" type. +error_on_uninitialized = True + +#: This will convert statements of the form ``for i in range(...)`` +#: to ``for i from ...`` when ``i`` is a C integer type, and the direction +#: (i.e. sign of step) can be determined. +#: WARNING: This may change the semantics if the range causes assignment to +#: i to overflow. Specifically, if this option is set, an error will be +#: raised before the loop is entered, whereas without this option the loop +#: will execute until an overflowing value is encountered. +convert_range = True + +#: Perform lookups on builtin names only once, at module initialisation +#: time. This will prevent the module from getting imported if a +#: builtin name that it uses cannot be found during initialisation. +#: Default is True. +#: Note that some legacy builtins are automatically remapped +#: from their Python 2 names to their Python 3 names by Cython +#: when building in Python 3.x, +#: so that they do not get in the way even if this option is enabled. +cache_builtins = True + +#: Generate branch prediction hints to speed up error handling etc. +gcc_branch_hints = True + +#: Enable this to allow one to write ``your_module.foo = ...`` to overwrite the +#: definition if the cpdef function foo, at the cost of an extra dictionary +#: lookup on every call. +#: If this is false it generates only the Python wrapper and no override check. +lookup_module_cpdef = False + +#: Whether or not to embed the Python interpreter, for use in making a +#: standalone executable or calling from external libraries. +#: This will provide a C function which initialises the interpreter and +#: executes the body of this module. +#: See `this demo <https://github.com/cython/cython/tree/master/Demos/embed>`_ +#: for a concrete example. +#: If true, the initialisation function is the C main() function, but +#: this option can also be set to a non-empty string to provide a function name explicitly. +#: Default is False. +embed = None + +# In previous iterations of Cython, globals() gave the first non-Cython module +# globals in the call stack. Sage relies on this behavior for variable injection. +old_style_globals = ShouldBeFromDirective('old_style_globals') + +#: Allows cimporting from a pyx file without a pxd file. +cimport_from_pyx = False + +#: Maximum number of dimensions for buffers -- set lower than number of +#: dimensions in numpy, as +#: slices are passed by value and involve a lot of copying. +buffer_max_dims = 8 + +#: Number of function closure instances to keep in a freelist (0: no freelists) +closure_freelist_size = 8 + +# Arcadia specific +source_root = None + + +def get_directive_defaults(): + # To add an item to this list, all accesses should be changed to use the new + # directive, and the global option itself should be set to an instance of + # ShouldBeFromDirective. + for old_option in ShouldBeFromDirective.known_directives: + value = globals().get(old_option.options_name) + assert old_option.directive_name in _directive_defaults + if not isinstance(value, ShouldBeFromDirective): + if old_option.disallow: + raise RuntimeError( + "Option '%s' must be set from directive '%s'" % ( + old_option.option_name, old_option.directive_name)) + else: + # Warn? + _directive_defaults[old_option.directive_name] = value + return _directive_defaults + +# Declare compiler directives +_directive_defaults = { + 'boundscheck' : True, + 'nonecheck' : False, + 'initializedcheck' : True, + 'embedsignature' : False, + 'auto_cpdef': False, + 'auto_pickle': None, + 'cdivision': False, # was True before 0.12 + 'cdivision_warnings': False, + 'c_api_binop_methods': True, + 'cpow': True, + 'overflowcheck': False, + 'overflowcheck.fold': True, + 'always_allow_keywords': False, + 'allow_none_for_extension_args': True, + 'wraparound' : True, + 'ccomplex' : False, # use C99/C++ for complex types and arith + 'callspec' : "", + 'nogil' : False, + 'profile': False, + 'linetrace': False, + 'emit_code_comments': True, # copy original source code into C code comments + 'annotation_typing': True, # read type declarations from Python function annotations + 'infer_types': None, + 'infer_types.verbose': False, + 'autotestdict': True, + 'autotestdict.cdef': False, + 'autotestdict.all': False, + 'language_level': None, + 'fast_getattr': False, # Undocumented until we come up with a better way to handle this everywhere. + 'py2_import': False, # For backward compatibility of Cython's source code in Py3 source mode + 'preliminary_late_includes_cy28': False, # Temporary directive in 0.28, to be removed in a later version (see GH#2079). + 'iterable_coroutine': False, # Make async coroutines backwards compatible with the old asyncio yield-from syntax. + 'c_string_type': 'bytes', + 'c_string_encoding': '', + 'type_version_tag': True, # enables Py_TPFLAGS_HAVE_VERSION_TAG on extension types + 'unraisable_tracebacks': True, + 'old_style_globals': False, + 'np_pythran': False, + 'fast_gil': False, + + # set __file__ and/or __path__ to known source/target path at import time (instead of not having them available) + 'set_initial_path' : None, # SOURCEFILE or "/full/path/to/module" + + 'warn': None, + 'warn.undeclared': False, + 'warn.unreachable': True, + 'warn.maybe_uninitialized': False, + 'warn.unused': False, + 'warn.unused_arg': False, + 'warn.unused_result': False, + 'warn.multiple_declarators': True, + +# optimizations + 'optimize.inline_defnode_calls': True, + 'optimize.unpack_method_calls': True, # increases code size when True + 'optimize.unpack_method_calls_in_pyinit': False, # uselessly increases code size when True + 'optimize.use_switch': True, + +# remove unreachable code + 'remove_unreachable': True, + +# control flow debug directives + 'control_flow.dot_output': "", # Graphviz output filename + 'control_flow.dot_annotate_defs': False, # Annotate definitions + +# test support + 'test_assert_path_exists' : [], + 'test_fail_if_path_exists' : [], + +# experimental, subject to change + 'binding': None, + + 'formal_grammar': False, +} + +# Extra warning directives +extra_warnings = { + 'warn.maybe_uninitialized': True, + 'warn.unreachable': True, + 'warn.unused': True, +} + +def one_of(*args): + def validate(name, value): + if value not in args: + raise ValueError("%s directive must be one of %s, got '%s'" % ( + name, args, value)) + else: + return value + return validate + + +def normalise_encoding_name(option_name, encoding): + """ + >>> normalise_encoding_name('c_string_encoding', 'ascii') + 'ascii' + >>> normalise_encoding_name('c_string_encoding', 'AsCIi') + 'ascii' + >>> normalise_encoding_name('c_string_encoding', 'us-ascii') + 'ascii' + >>> normalise_encoding_name('c_string_encoding', 'utF8') + 'utf8' + >>> normalise_encoding_name('c_string_encoding', 'utF-8') + 'utf8' + >>> normalise_encoding_name('c_string_encoding', 'deFAuLT') + 'default' + >>> normalise_encoding_name('c_string_encoding', 'default') + 'default' + >>> normalise_encoding_name('c_string_encoding', 'SeriousLyNoSuch--Encoding') + 'SeriousLyNoSuch--Encoding' + """ + if not encoding: + return '' + if encoding.lower() in ('default', 'ascii', 'utf8'): + return encoding.lower() + import codecs + try: + decoder = codecs.getdecoder(encoding) + except LookupError: + return encoding # may exists at runtime ... + for name in ('ascii', 'utf8'): + if codecs.getdecoder(name) == decoder: + return name + return encoding + + +# Override types possibilities above, if needed +directive_types = { + 'language_level': str, # values can be None/2/3/'3str', where None == 2+warning + 'auto_pickle': bool, + 'locals': dict, + 'final' : bool, # final cdef classes and methods + 'nogil' : bool, + 'internal' : bool, # cdef class visibility in the module dict + 'infer_types' : bool, # values can be True/None/False + 'binding' : bool, + 'cfunc' : None, # decorators do not take directive value + 'ccall' : None, + 'inline' : None, + 'staticmethod' : None, + 'cclass' : None, + 'no_gc_clear' : bool, + 'no_gc' : bool, + 'returns' : type, + 'exceptval': type, # actually (type, check=True/False), but has its own parser + 'set_initial_path': str, + 'freelist': int, + 'c_string_type': one_of('bytes', 'bytearray', 'str', 'unicode'), + 'c_string_encoding': normalise_encoding_name, + 'cpow': bool +} + +for key, val in _directive_defaults.items(): + if key not in directive_types: + directive_types[key] = type(val) + +directive_scopes = { # defaults to available everywhere + # 'module', 'function', 'class', 'with statement' + 'auto_pickle': ('module', 'cclass'), + 'final' : ('cclass', 'function'), + 'nogil' : ('function', 'with statement'), + 'inline' : ('function',), + 'cfunc' : ('function', 'with statement'), + 'ccall' : ('function', 'with statement'), + 'returns' : ('function',), + 'exceptval' : ('function',), + 'locals' : ('function',), + 'staticmethod' : ('function',), # FIXME: analysis currently lacks more specific function scope + 'no_gc_clear' : ('cclass',), + 'no_gc' : ('cclass',), + 'internal' : ('cclass',), + 'cclass' : ('class', 'cclass', 'with statement'), + 'autotestdict' : ('module',), + 'autotestdict.all' : ('module',), + 'autotestdict.cdef' : ('module',), + 'set_initial_path' : ('module',), + 'test_assert_path_exists' : ('function', 'class', 'cclass'), + 'test_fail_if_path_exists' : ('function', 'class', 'cclass'), + 'freelist': ('cclass',), + 'emit_code_comments': ('module',), + 'annotation_typing': ('module',), # FIXME: analysis currently lacks more specific function scope + # Avoid scope-specific to/from_py_functions for c_string. + 'c_string_type': ('module',), + 'c_string_encoding': ('module',), + 'type_version_tag': ('module', 'cclass'), + 'language_level': ('module',), + # globals() could conceivably be controlled at a finer granularity, + # but that would complicate the implementation + 'old_style_globals': ('module',), + 'np_pythran': ('module',), + 'fast_gil': ('module',), + 'iterable_coroutine': ('module', 'function'), +} + + +def parse_directive_value(name, value, relaxed_bool=False): + """ + Parses value as an option value for the given name and returns + the interpreted value. None is returned if the option does not exist. + + >>> print(parse_directive_value('nonexisting', 'asdf asdfd')) + None + >>> parse_directive_value('boundscheck', 'True') + True + >>> parse_directive_value('boundscheck', 'true') + Traceback (most recent call last): + ... + ValueError: boundscheck directive must be set to True or False, got 'true' + + >>> parse_directive_value('c_string_encoding', 'us-ascii') + 'ascii' + >>> parse_directive_value('c_string_type', 'str') + 'str' + >>> parse_directive_value('c_string_type', 'bytes') + 'bytes' + >>> parse_directive_value('c_string_type', 'bytearray') + 'bytearray' + >>> parse_directive_value('c_string_type', 'unicode') + 'unicode' + >>> parse_directive_value('c_string_type', 'unnicode') + Traceback (most recent call last): + ValueError: c_string_type directive must be one of ('bytes', 'bytearray', 'str', 'unicode'), got 'unnicode' + """ + type = directive_types.get(name) + if not type: + return None + orig_value = value + if type is bool: + value = str(value) + if value == 'True': + return True + if value == 'False': + return False + if relaxed_bool: + value = value.lower() + if value in ("true", "yes"): + return True + elif value in ("false", "no"): + return False + raise ValueError("%s directive must be set to True or False, got '%s'" % ( + name, orig_value)) + elif type is int: + try: + return int(value) + except ValueError: + raise ValueError("%s directive must be set to an integer, got '%s'" % ( + name, orig_value)) + elif type is str: + return str(value) + elif callable(type): + return type(name, value) + else: + assert False + + +def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False, + current_settings=None): + """ + Parses a comma-separated list of pragma options. Whitespace + is not considered. + + >>> parse_directive_list(' ') + {} + >>> (parse_directive_list('boundscheck=True') == + ... {'boundscheck': True}) + True + >>> parse_directive_list(' asdf') + Traceback (most recent call last): + ... + ValueError: Expected "=" in option "asdf" + >>> parse_directive_list('boundscheck=hey') + Traceback (most recent call last): + ... + ValueError: boundscheck directive must be set to True or False, got 'hey' + >>> parse_directive_list('unknown=True') + Traceback (most recent call last): + ... + ValueError: Unknown option: "unknown" + >>> warnings = parse_directive_list('warn.all=True') + >>> len(warnings) > 1 + True + >>> sum(warnings.values()) == len(warnings) # all true. + True + """ + if current_settings is None: + result = {} + else: + result = current_settings + for item in s.split(','): + item = item.strip() + if not item: + continue + if '=' not in item: + raise ValueError('Expected "=" in option "%s"' % item) + name, value = [s.strip() for s in item.strip().split('=', 1)] + if name not in _directive_defaults: + found = False + if name.endswith('.all'): + prefix = name[:-3] + for directive in _directive_defaults: + if directive.startswith(prefix): + found = True + parsed_value = parse_directive_value(directive, value, relaxed_bool=relaxed_bool) + result[directive] = parsed_value + if not found and not ignore_unknown: + raise ValueError('Unknown option: "%s"' % name) + else: + parsed_value = parse_directive_value(name, value, relaxed_bool=relaxed_bool) + result[name] = parsed_value + return result + + +def parse_variable_value(value): + """ + Parses value as an option value for the given name and returns + the interpreted value. + + >>> parse_variable_value('True') + True + >>> parse_variable_value('true') + 'true' + >>> parse_variable_value('us-ascii') + 'us-ascii' + >>> parse_variable_value('str') + 'str' + >>> parse_variable_value('123') + 123 + >>> parse_variable_value('1.23') + 1.23 + + """ + if value == "True": + return True + elif value == "False": + return False + elif value == "None": + return None + elif value.isdigit(): + return int(value) + else: + try: + value = float(value) + except Exception: + # Not a float + pass + return value + + +def parse_compile_time_env(s, current_settings=None): + """ + Parses a comma-separated list of pragma options. Whitespace + is not considered. + + >>> parse_compile_time_env(' ') + {} + >>> (parse_compile_time_env('HAVE_OPENMP=True') == + ... {'HAVE_OPENMP': True}) + True + >>> parse_compile_time_env(' asdf') + Traceback (most recent call last): + ... + ValueError: Expected "=" in option "asdf" + >>> parse_compile_time_env('NUM_THREADS=4') == {'NUM_THREADS': 4} + True + >>> parse_compile_time_env('unknown=anything') == {'unknown': 'anything'} + True + """ + if current_settings is None: + result = {} + else: + result = current_settings + for item in s.split(','): + item = item.strip() + if not item: + continue + if '=' not in item: + raise ValueError('Expected "=" in option "%s"' % item) + name, value = [s.strip() for s in item.split('=', 1)] + result[name] = parse_variable_value(value) + return result diff --git a/contrib/tools/cython/Cython/Compiler/ParseTreeTransforms.pxd b/contrib/tools/cython/Cython/Compiler/ParseTreeTransforms.pxd new file mode 100644 index 00000000000..2c17901fa4f --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/ParseTreeTransforms.pxd @@ -0,0 +1,82 @@ + +from __future__ import absolute_import + +cimport cython + +from .Visitor cimport ( + CythonTransform, VisitorTransform, TreeVisitor, + ScopeTrackingTransform, EnvTransform) + +cdef class SkipDeclarations: # (object): + pass + +cdef class NormalizeTree(CythonTransform): + cdef bint is_in_statlist + cdef bint is_in_expr + cpdef visit_StatNode(self, node, is_listcontainer=*) + +cdef class PostParse(ScopeTrackingTransform): + cdef dict specialattribute_handlers + cdef size_t lambda_counter + cdef size_t genexpr_counter + cdef _visit_assignment_node(self, node, list expr_list) + + +#def eliminate_rhs_duplicates(list expr_list_list, list ref_node_sequence) +#def sort_common_subsequences(list items) +@cython.locals(starred_targets=Py_ssize_t, lhs_size=Py_ssize_t, rhs_size=Py_ssize_t) +cdef flatten_parallel_assignments(list input, list output) +cdef map_starred_assignment(list lhs_targets, list starred_assignments, list lhs_args, list rhs_args) + +#class PxdPostParse(CythonTransform, SkipDeclarations): +#class InterpretCompilerDirectives(CythonTransform, SkipDeclarations): +#class WithTransform(CythonTransform, SkipDeclarations): +#class DecoratorTransform(CythonTransform, SkipDeclarations): + +#class AnalyseDeclarationsTransform(EnvTransform): + +cdef class AnalyseExpressionsTransform(CythonTransform): + pass + +cdef class ExpandInplaceOperators(EnvTransform): + pass + +cdef class AlignFunctionDefinitions(CythonTransform): + cdef dict directives + cdef set imported_names + cdef object scope + +@cython.final +cdef class YieldNodeCollector(TreeVisitor): + cdef public list yields + cdef public list returns + cdef public list finallys + cdef public list excepts + cdef public bint has_return_value + cdef public bint has_yield + cdef public bint has_await + +@cython.final +cdef class MarkClosureVisitor(CythonTransform): + cdef bint needs_closure + +@cython.final +cdef class CreateClosureClasses(CythonTransform): + cdef list path + cdef bint in_lambda + cdef module_scope + cdef generator_class + + cdef create_class_from_scope(self, node, target_module_scope, inner_node=*) + cdef find_entries_used_in_closures(self, node) + +#cdef class InjectGilHandling(VisitorTransform, SkipDeclarations): +# cdef bint nogil + +cdef class GilCheck(VisitorTransform): + cdef list env_stack + cdef bint nogil + cdef bint nogil_declarator_only + +cdef class TransformBuiltinMethods(EnvTransform): + cdef visit_cython_attribute(self, node) diff --git a/contrib/tools/cython/Cython/Compiler/ParseTreeTransforms.py b/contrib/tools/cython/Cython/Compiler/ParseTreeTransforms.py new file mode 100644 index 00000000000..0e86d5b0e82 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/ParseTreeTransforms.py @@ -0,0 +1,3535 @@ +from __future__ import absolute_import + +import cython +cython.declare(PyrexTypes=object, Naming=object, ExprNodes=object, Nodes=object, + Options=object, UtilNodes=object, LetNode=object, + LetRefNode=object, TreeFragment=object, EncodedString=object, + error=object, warning=object, copy=object, hashlib=object, sys=object, + _unicode=object) + +import copy +import hashlib +import sys + +from . import PyrexTypes +from . import Naming +from . import ExprNodes +from . import Nodes +from . import Options +from . import Builtin +from . import Errors + +from .Visitor import VisitorTransform, TreeVisitor +from .Visitor import CythonTransform, EnvTransform, ScopeTrackingTransform +from .UtilNodes import LetNode, LetRefNode +from .TreeFragment import TreeFragment +from .StringEncoding import EncodedString, _unicode +from .Errors import error, warning, CompileError, InternalError +from .Code import UtilityCode + + +class SkipDeclarations(object): + """ + Variable and function declarations can often have a deep tree structure, + and yet most transformations don't need to descend to this depth. + + Declaration nodes are removed after AnalyseDeclarationsTransform, so there + is no need to use this for transformations after that point. + """ + def visit_CTypeDefNode(self, node): + return node + + def visit_CVarDefNode(self, node): + return node + + def visit_CDeclaratorNode(self, node): + return node + + def visit_CBaseTypeNode(self, node): + return node + + def visit_CEnumDefNode(self, node): + return node + + def visit_CStructOrUnionDefNode(self, node): + return node + + +class NormalizeTree(CythonTransform): + """ + This transform fixes up a few things after parsing + in order to make the parse tree more suitable for + transforms. + + a) After parsing, blocks with only one statement will + be represented by that statement, not by a StatListNode. + When doing transforms this is annoying and inconsistent, + as one cannot in general remove a statement in a consistent + way and so on. This transform wraps any single statements + in a StatListNode containing a single statement. + + b) The PassStatNode is a noop and serves no purpose beyond + plugging such one-statement blocks; i.e., once parsed a +` "pass" can just as well be represented using an empty + StatListNode. This means less special cases to worry about + in subsequent transforms (one always checks to see if a + StatListNode has no children to see if the block is empty). + """ + + def __init__(self, context): + super(NormalizeTree, self).__init__(context) + self.is_in_statlist = False + self.is_in_expr = False + + def visit_ExprNode(self, node): + stacktmp = self.is_in_expr + self.is_in_expr = True + self.visitchildren(node) + self.is_in_expr = stacktmp + return node + + def visit_StatNode(self, node, is_listcontainer=False): + stacktmp = self.is_in_statlist + self.is_in_statlist = is_listcontainer + self.visitchildren(node) + self.is_in_statlist = stacktmp + if not self.is_in_statlist and not self.is_in_expr: + return Nodes.StatListNode(pos=node.pos, stats=[node]) + else: + return node + + def visit_StatListNode(self, node): + self.is_in_statlist = True + self.visitchildren(node) + self.is_in_statlist = False + return node + + def visit_ParallelAssignmentNode(self, node): + return self.visit_StatNode(node, True) + + def visit_CEnumDefNode(self, node): + return self.visit_StatNode(node, True) + + def visit_CStructOrUnionDefNode(self, node): + return self.visit_StatNode(node, True) + + def visit_PassStatNode(self, node): + """Eliminate PassStatNode""" + if not self.is_in_statlist: + return Nodes.StatListNode(pos=node.pos, stats=[]) + else: + return [] + + def visit_ExprStatNode(self, node): + """Eliminate useless string literals""" + if node.expr.is_string_literal: + return self.visit_PassStatNode(node) + else: + return self.visit_StatNode(node) + + def visit_CDeclaratorNode(self, node): + return node + + +class PostParseError(CompileError): pass + +# error strings checked by unit tests, so define them +ERR_CDEF_INCLASS = 'Cannot assign default value to fields in cdef classes, structs or unions' +ERR_BUF_DEFAULTS = 'Invalid buffer defaults specification (see docs)' +ERR_INVALID_SPECIALATTR_TYPE = 'Special attributes must not have a type declared' +class PostParse(ScopeTrackingTransform): + """ + Basic interpretation of the parse tree, as well as validity + checking that can be done on a very basic level on the parse + tree (while still not being a problem with the basic syntax, + as such). + + Specifically: + - Default values to cdef assignments are turned into single + assignments following the declaration (everywhere but in class + bodies, where they raise a compile error) + + - Interpret some node structures into Python runtime values. + Some nodes take compile-time arguments (currently: + TemplatedTypeNode[args] and __cythonbufferdefaults__ = {args}), + which should be interpreted. This happens in a general way + and other steps should be taken to ensure validity. + + Type arguments cannot be interpreted in this way. + + - For __cythonbufferdefaults__ the arguments are checked for + validity. + + TemplatedTypeNode has its directives interpreted: + Any first positional argument goes into the "dtype" attribute, + any "ndim" keyword argument goes into the "ndim" attribute and + so on. Also it is checked that the directive combination is valid. + - __cythonbufferdefaults__ attributes are parsed and put into the + type information. + + Note: Currently Parsing.py does a lot of interpretation and + reorganization that can be refactored into this transform + if a more pure Abstract Syntax Tree is wanted. + """ + + def __init__(self, context): + super(PostParse, self).__init__(context) + self.specialattribute_handlers = { + '__cythonbufferdefaults__' : self.handle_bufferdefaults + } + + def visit_LambdaNode(self, node): + # unpack a lambda expression into the corresponding DefNode + collector = YieldNodeCollector() + collector.visitchildren(node.result_expr) + if collector.has_yield or collector.has_await or isinstance(node.result_expr, ExprNodes.YieldExprNode): + body = Nodes.ExprStatNode( + node.result_expr.pos, expr=node.result_expr) + else: + body = Nodes.ReturnStatNode( + node.result_expr.pos, value=node.result_expr) + node.def_node = Nodes.DefNode( + node.pos, name=node.name, + args=node.args, star_arg=node.star_arg, + starstar_arg=node.starstar_arg, + body=body, doc=None) + self.visitchildren(node) + return node + + def visit_GeneratorExpressionNode(self, node): + # unpack a generator expression into the corresponding DefNode + collector = YieldNodeCollector() + collector.visitchildren(node.loop) + node.def_node = Nodes.DefNode( + node.pos, name=node.name, doc=None, + args=[], star_arg=None, starstar_arg=None, + body=node.loop, is_async_def=collector.has_await) + self.visitchildren(node) + return node + + def visit_ComprehensionNode(self, node): + # enforce local scope also in Py2 for async generators (seriously, that's a Py3.6 feature...) + if not node.has_local_scope: + collector = YieldNodeCollector() + collector.visitchildren(node.loop) + if collector.has_await: + node.has_local_scope = True + self.visitchildren(node) + return node + + # cdef variables + def handle_bufferdefaults(self, decl): + if not isinstance(decl.default, ExprNodes.DictNode): + raise PostParseError(decl.pos, ERR_BUF_DEFAULTS) + self.scope_node.buffer_defaults_node = decl.default + self.scope_node.buffer_defaults_pos = decl.pos + + def visit_CVarDefNode(self, node): + # This assumes only plain names and pointers are assignable on + # declaration. Also, it makes use of the fact that a cdef decl + # must appear before the first use, so we don't have to deal with + # "i = 3; cdef int i = i" and can simply move the nodes around. + try: + self.visitchildren(node) + stats = [node] + newdecls = [] + for decl in node.declarators: + declbase = decl + while isinstance(declbase, Nodes.CPtrDeclaratorNode): + declbase = declbase.base + if isinstance(declbase, Nodes.CNameDeclaratorNode): + if declbase.default is not None: + if self.scope_type in ('cclass', 'pyclass', 'struct'): + if isinstance(self.scope_node, Nodes.CClassDefNode): + handler = self.specialattribute_handlers.get(decl.name) + if handler: + if decl is not declbase: + raise PostParseError(decl.pos, ERR_INVALID_SPECIALATTR_TYPE) + handler(decl) + continue # Remove declaration + raise PostParseError(decl.pos, ERR_CDEF_INCLASS) + first_assignment = self.scope_type != 'module' + stats.append(Nodes.SingleAssignmentNode(node.pos, + lhs=ExprNodes.NameNode(node.pos, name=declbase.name), + rhs=declbase.default, first=first_assignment)) + declbase.default = None + newdecls.append(decl) + node.declarators = newdecls + return stats + except PostParseError as e: + # An error in a cdef clause is ok, simply remove the declaration + # and try to move on to report more errors + self.context.nonfatal_error(e) + return None + + # Split parallel assignments (a,b = b,a) into separate partial + # assignments that are executed rhs-first using temps. This + # restructuring must be applied before type analysis so that known + # types on rhs and lhs can be matched directly. It is required in + # the case that the types cannot be coerced to a Python type in + # order to assign from a tuple. + + def visit_SingleAssignmentNode(self, node): + self.visitchildren(node) + return self._visit_assignment_node(node, [node.lhs, node.rhs]) + + def visit_CascadedAssignmentNode(self, node): + self.visitchildren(node) + return self._visit_assignment_node(node, node.lhs_list + [node.rhs]) + + def _visit_assignment_node(self, node, expr_list): + """Flatten parallel assignments into separate single + assignments or cascaded assignments. + """ + if sum([ 1 for expr in expr_list + if expr.is_sequence_constructor or expr.is_string_literal ]) < 2: + # no parallel assignments => nothing to do + return node + + expr_list_list = [] + flatten_parallel_assignments(expr_list, expr_list_list) + temp_refs = [] + eliminate_rhs_duplicates(expr_list_list, temp_refs) + + nodes = [] + for expr_list in expr_list_list: + lhs_list = expr_list[:-1] + rhs = expr_list[-1] + if len(lhs_list) == 1: + node = Nodes.SingleAssignmentNode(rhs.pos, + lhs = lhs_list[0], rhs = rhs) + else: + node = Nodes.CascadedAssignmentNode(rhs.pos, + lhs_list = lhs_list, rhs = rhs) + nodes.append(node) + + if len(nodes) == 1: + assign_node = nodes[0] + else: + assign_node = Nodes.ParallelAssignmentNode(nodes[0].pos, stats = nodes) + + if temp_refs: + duplicates_and_temps = [ (temp.expression, temp) + for temp in temp_refs ] + sort_common_subsequences(duplicates_and_temps) + for _, temp_ref in duplicates_and_temps[::-1]: + assign_node = LetNode(temp_ref, assign_node) + + return assign_node + + def _flatten_sequence(self, seq, result): + for arg in seq.args: + if arg.is_sequence_constructor: + self._flatten_sequence(arg, result) + else: + result.append(arg) + return result + + def visit_DelStatNode(self, node): + self.visitchildren(node) + node.args = self._flatten_sequence(node, []) + return node + + def visit_ExceptClauseNode(self, node): + if node.is_except_as: + # except-as must delete NameNode target at the end + del_target = Nodes.DelStatNode( + node.pos, + args=[ExprNodes.NameNode( + node.target.pos, name=node.target.name)], + ignore_nonexisting=True) + node.body = Nodes.StatListNode( + node.pos, + stats=[Nodes.TryFinallyStatNode( + node.pos, + body=node.body, + finally_clause=Nodes.StatListNode( + node.pos, + stats=[del_target]))]) + self.visitchildren(node) + return node + + +def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence): + """Replace rhs items by LetRefNodes if they appear more than once. + Creates a sequence of LetRefNodes that set up the required temps + and appends them to ref_node_sequence. The input list is modified + in-place. + """ + seen_nodes = set() + ref_nodes = {} + def find_duplicates(node): + if node.is_literal or node.is_name: + # no need to replace those; can't include attributes here + # as their access is not necessarily side-effect free + return + if node in seen_nodes: + if node not in ref_nodes: + ref_node = LetRefNode(node) + ref_nodes[node] = ref_node + ref_node_sequence.append(ref_node) + else: + seen_nodes.add(node) + if node.is_sequence_constructor: + for item in node.args: + find_duplicates(item) + + for expr_list in expr_list_list: + rhs = expr_list[-1] + find_duplicates(rhs) + if not ref_nodes: + return + + def substitute_nodes(node): + if node in ref_nodes: + return ref_nodes[node] + elif node.is_sequence_constructor: + node.args = list(map(substitute_nodes, node.args)) + return node + + # replace nodes inside of the common subexpressions + for node in ref_nodes: + if node.is_sequence_constructor: + node.args = list(map(substitute_nodes, node.args)) + + # replace common subexpressions on all rhs items + for expr_list in expr_list_list: + expr_list[-1] = substitute_nodes(expr_list[-1]) + +def sort_common_subsequences(items): + """Sort items/subsequences so that all items and subsequences that + an item contains appear before the item itself. This is needed + because each rhs item must only be evaluated once, so its value + must be evaluated first and then reused when packing sequences + that contain it. + + This implies a partial order, and the sort must be stable to + preserve the original order as much as possible, so we use a + simple insertion sort (which is very fast for short sequences, the + normal case in practice). + """ + def contains(seq, x): + for item in seq: + if item is x: + return True + elif item.is_sequence_constructor and contains(item.args, x): + return True + return False + def lower_than(a,b): + return b.is_sequence_constructor and contains(b.args, a) + + for pos, item in enumerate(items): + key = item[1] # the ResultRefNode which has already been injected into the sequences + new_pos = pos + for i in range(pos-1, -1, -1): + if lower_than(key, items[i][0]): + new_pos = i + if new_pos != pos: + for i in range(pos, new_pos, -1): + items[i] = items[i-1] + items[new_pos] = item + +def unpack_string_to_character_literals(literal): + chars = [] + pos = literal.pos + stype = literal.__class__ + sval = literal.value + sval_type = sval.__class__ + for char in sval: + cval = sval_type(char) + chars.append(stype(pos, value=cval, constant_result=cval)) + return chars + +def flatten_parallel_assignments(input, output): + # The input is a list of expression nodes, representing the LHSs + # and RHS of one (possibly cascaded) assignment statement. For + # sequence constructors, rearranges the matching parts of both + # sides into a list of equivalent assignments between the + # individual elements. This transformation is applied + # recursively, so that nested structures get matched as well. + rhs = input[-1] + if (not (rhs.is_sequence_constructor or isinstance(rhs, ExprNodes.UnicodeNode)) + or not sum([lhs.is_sequence_constructor for lhs in input[:-1]])): + output.append(input) + return + + complete_assignments = [] + + if rhs.is_sequence_constructor: + rhs_args = rhs.args + elif rhs.is_string_literal: + rhs_args = unpack_string_to_character_literals(rhs) + + rhs_size = len(rhs_args) + lhs_targets = [[] for _ in range(rhs_size)] + starred_assignments = [] + for lhs in input[:-1]: + if not lhs.is_sequence_constructor: + if lhs.is_starred: + error(lhs.pos, "starred assignment target must be in a list or tuple") + complete_assignments.append(lhs) + continue + lhs_size = len(lhs.args) + starred_targets = sum([1 for expr in lhs.args if expr.is_starred]) + if starred_targets > 1: + error(lhs.pos, "more than 1 starred expression in assignment") + output.append([lhs,rhs]) + continue + elif lhs_size - starred_targets > rhs_size: + error(lhs.pos, "need more than %d value%s to unpack" + % (rhs_size, (rhs_size != 1) and 's' or '')) + output.append([lhs,rhs]) + continue + elif starred_targets: + map_starred_assignment(lhs_targets, starred_assignments, + lhs.args, rhs_args) + elif lhs_size < rhs_size: + error(lhs.pos, "too many values to unpack (expected %d, got %d)" + % (lhs_size, rhs_size)) + output.append([lhs,rhs]) + continue + else: + for targets, expr in zip(lhs_targets, lhs.args): + targets.append(expr) + + if complete_assignments: + complete_assignments.append(rhs) + output.append(complete_assignments) + + # recursively flatten partial assignments + for cascade, rhs in zip(lhs_targets, rhs_args): + if cascade: + cascade.append(rhs) + flatten_parallel_assignments(cascade, output) + + # recursively flatten starred assignments + for cascade in starred_assignments: + if cascade[0].is_sequence_constructor: + flatten_parallel_assignments(cascade, output) + else: + output.append(cascade) + +def map_starred_assignment(lhs_targets, starred_assignments, lhs_args, rhs_args): + # Appends the fixed-position LHS targets to the target list that + # appear left and right of the starred argument. + # + # The starred_assignments list receives a new tuple + # (lhs_target, rhs_values_list) that maps the remaining arguments + # (those that match the starred target) to a list. + + # left side of the starred target + for i, (targets, expr) in enumerate(zip(lhs_targets, lhs_args)): + if expr.is_starred: + starred = i + lhs_remaining = len(lhs_args) - i - 1 + break + targets.append(expr) + else: + raise InternalError("no starred arg found when splitting starred assignment") + + # right side of the starred target + for i, (targets, expr) in enumerate(zip(lhs_targets[-lhs_remaining:], + lhs_args[starred + 1:])): + targets.append(expr) + + # the starred target itself, must be assigned a (potentially empty) list + target = lhs_args[starred].target # unpack starred node + starred_rhs = rhs_args[starred:] + if lhs_remaining: + starred_rhs = starred_rhs[:-lhs_remaining] + if starred_rhs: + pos = starred_rhs[0].pos + else: + pos = target.pos + starred_assignments.append([ + target, ExprNodes.ListNode(pos=pos, args=starred_rhs)]) + + +class PxdPostParse(CythonTransform, SkipDeclarations): + """ + Basic interpretation/validity checking that should only be + done on pxd trees. + + A lot of this checking currently happens in the parser; but + what is listed below happens here. + + - "def" functions are let through only if they fill the + getbuffer/releasebuffer slots + + - cdef functions are let through only if they are on the + top level and are declared "inline" + """ + ERR_INLINE_ONLY = "function definition in pxd file must be declared 'cdef inline'" + ERR_NOGO_WITH_INLINE = "inline function definition in pxd file cannot be '%s'" + + def __call__(self, node): + self.scope_type = 'pxd' + return super(PxdPostParse, self).__call__(node) + + def visit_CClassDefNode(self, node): + old = self.scope_type + self.scope_type = 'cclass' + self.visitchildren(node) + self.scope_type = old + return node + + def visit_FuncDefNode(self, node): + # FuncDefNode always come with an implementation (without + # an imp they are CVarDefNodes..) + err = self.ERR_INLINE_ONLY + + if (isinstance(node, Nodes.DefNode) and self.scope_type == 'cclass' + and node.name in ('__getbuffer__', '__releasebuffer__')): + err = None # allow these slots + + if isinstance(node, Nodes.CFuncDefNode): + if (u'inline' in node.modifiers and + self.scope_type in ('pxd', 'cclass')): + node.inline_in_pxd = True + if node.visibility != 'private': + err = self.ERR_NOGO_WITH_INLINE % node.visibility + elif node.api: + err = self.ERR_NOGO_WITH_INLINE % 'api' + else: + err = None # allow inline function + else: + err = self.ERR_INLINE_ONLY + + if err: + self.context.nonfatal_error(PostParseError(node.pos, err)) + return None + else: + return node + + +class TrackNumpyAttributes(VisitorTransform, SkipDeclarations): + # TODO: Make name handling as good as in InterpretCompilerDirectives() below - probably best to merge the two. + def __init__(self): + super(TrackNumpyAttributes, self).__init__() + self.numpy_module_names = set() + + def visit_CImportStatNode(self, node): + if node.module_name == u"numpy": + self.numpy_module_names.add(node.as_name or u"numpy") + return node + + def visit_AttributeNode(self, node): + self.visitchildren(node) + obj = node.obj + if (obj.is_name and obj.name in self.numpy_module_names) or obj.is_numpy_attribute: + node.is_numpy_attribute = True + return node + + visit_Node = VisitorTransform.recurse_to_children + + +class InterpretCompilerDirectives(CythonTransform): + """ + After parsing, directives can be stored in a number of places: + - #cython-comments at the top of the file (stored in ModuleNode) + - Command-line arguments overriding these + - @cython.directivename decorators + - with cython.directivename: statements + + This transform is responsible for interpreting these various sources + and store the directive in two ways: + - Set the directives attribute of the ModuleNode for global directives. + - Use a CompilerDirectivesNode to override directives for a subtree. + + (The first one is primarily to not have to modify with the tree + structure, so that ModuleNode stay on top.) + + The directives are stored in dictionaries from name to value in effect. + Each such dictionary is always filled in for all possible directives, + using default values where no value is given by the user. + + The available directives are controlled in Options.py. + + Note that we have to run this prior to analysis, and so some minor + duplication of functionality has to occur: We manually track cimports + and which names the "cython" module may have been imported to. + """ + unop_method_nodes = { + 'typeof': ExprNodes.TypeofNode, + + 'operator.address': ExprNodes.AmpersandNode, + 'operator.dereference': ExprNodes.DereferenceNode, + 'operator.preincrement' : ExprNodes.inc_dec_constructor(True, '++'), + 'operator.predecrement' : ExprNodes.inc_dec_constructor(True, '--'), + 'operator.postincrement': ExprNodes.inc_dec_constructor(False, '++'), + 'operator.postdecrement': ExprNodes.inc_dec_constructor(False, '--'), + 'operator.typeid' : ExprNodes.TypeidNode, + + # For backwards compatibility. + 'address': ExprNodes.AmpersandNode, + } + + binop_method_nodes = { + 'operator.comma' : ExprNodes.c_binop_constructor(','), + } + + special_methods = set(['declare', 'union', 'struct', 'typedef', + 'sizeof', 'cast', 'pointer', 'compiled', + 'NULL', 'fused_type', 'parallel']) + special_methods.update(unop_method_nodes) + + valid_parallel_directives = set([ + "parallel", + "prange", + "threadid", + #"threadsavailable", + ]) + + def __init__(self, context, compilation_directive_defaults): + super(InterpretCompilerDirectives, self).__init__(context) + self.cython_module_names = set() + self.directive_names = {'staticmethod': 'staticmethod'} + self.parallel_directives = {} + directives = copy.deepcopy(Options.get_directive_defaults()) + for key, value in compilation_directive_defaults.items(): + directives[_unicode(key)] = copy.deepcopy(value) + self.directives = directives + + def check_directive_scope(self, pos, directive, scope): + legal_scopes = Options.directive_scopes.get(directive, None) + if legal_scopes and scope not in legal_scopes: + self.context.nonfatal_error(PostParseError(pos, 'The %s compiler directive ' + 'is not allowed in %s scope' % (directive, scope))) + return False + else: + if directive not in Options.directive_types: + error(pos, "Invalid directive: '%s'." % (directive,)) + return True + + # Set up processing and handle the cython: comments. + def visit_ModuleNode(self, node): + for key in sorted(node.directive_comments): + if not self.check_directive_scope(node.pos, key, 'module'): + self.wrong_scope_error(node.pos, key, 'module') + del node.directive_comments[key] + + self.module_scope = node.scope + + self.directives.update(node.directive_comments) + node.directives = self.directives + node.parallel_directives = self.parallel_directives + self.visitchildren(node) + node.cython_module_names = self.cython_module_names + return node + + # The following four functions track imports and cimports that + # begin with "cython" + def is_cython_directive(self, name): + return (name in Options.directive_types or + name in self.special_methods or + PyrexTypes.parse_basic_type(name)) + + def is_parallel_directive(self, full_name, pos): + """ + Checks to see if fullname (e.g. cython.parallel.prange) is a valid + parallel directive. If it is a star import it also updates the + parallel_directives. + """ + result = (full_name + ".").startswith("cython.parallel.") + + if result: + directive = full_name.split('.') + if full_name == u"cython.parallel": + self.parallel_directives[u"parallel"] = u"cython.parallel" + elif full_name == u"cython.parallel.*": + for name in self.valid_parallel_directives: + self.parallel_directives[name] = u"cython.parallel.%s" % name + elif (len(directive) != 3 or + directive[-1] not in self.valid_parallel_directives): + error(pos, "No such directive: %s" % full_name) + + self.module_scope.use_utility_code( + UtilityCode.load_cached("InitThreads", "ModuleSetupCode.c")) + + return result + + def visit_CImportStatNode(self, node): + if node.module_name == u"cython": + self.cython_module_names.add(node.as_name or u"cython") + elif node.module_name.startswith(u"cython."): + if node.module_name.startswith(u"cython.parallel."): + error(node.pos, node.module_name + " is not a module") + if node.module_name == u"cython.parallel": + if node.as_name and node.as_name != u"cython": + self.parallel_directives[node.as_name] = node.module_name + else: + self.cython_module_names.add(u"cython") + self.parallel_directives[ + u"cython.parallel"] = node.module_name + self.module_scope.use_utility_code( + UtilityCode.load_cached("InitThreads", "ModuleSetupCode.c")) + elif node.as_name: + self.directive_names[node.as_name] = node.module_name[7:] + else: + self.cython_module_names.add(u"cython") + # if this cimport was a compiler directive, we don't + # want to leave the cimport node sitting in the tree + return None + return node + + def visit_FromCImportStatNode(self, node): + if not node.relative_level and ( + node.module_name == u"cython" or node.module_name.startswith(u"cython.")): + submodule = (node.module_name + u".")[7:] + newimp = [] + + for pos, name, as_name, kind in node.imported_names: + full_name = submodule + name + qualified_name = u"cython." + full_name + + if self.is_parallel_directive(qualified_name, node.pos): + # from cython cimport parallel, or + # from cython.parallel cimport parallel, prange, ... + self.parallel_directives[as_name or name] = qualified_name + elif self.is_cython_directive(full_name): + self.directive_names[as_name or name] = full_name + if kind is not None: + self.context.nonfatal_error(PostParseError(pos, + "Compiler directive imports must be plain imports")) + else: + newimp.append((pos, name, as_name, kind)) + + if not newimp: + return None + + node.imported_names = newimp + return node + + def visit_FromImportStatNode(self, node): + if (node.module.module_name.value == u"cython") or \ + node.module.module_name.value.startswith(u"cython."): + submodule = (node.module.module_name.value + u".")[7:] + newimp = [] + for name, name_node in node.items: + full_name = submodule + name + qualified_name = u"cython." + full_name + if self.is_parallel_directive(qualified_name, node.pos): + self.parallel_directives[name_node.name] = qualified_name + elif self.is_cython_directive(full_name): + self.directive_names[name_node.name] = full_name + else: + newimp.append((name, name_node)) + if not newimp: + return None + node.items = newimp + return node + + def visit_SingleAssignmentNode(self, node): + if isinstance(node.rhs, ExprNodes.ImportNode): + module_name = node.rhs.module_name.value + is_parallel = (module_name + u".").startswith(u"cython.parallel.") + + if module_name != u"cython" and not is_parallel: + return node + + module_name = node.rhs.module_name.value + as_name = node.lhs.name + + node = Nodes.CImportStatNode(node.pos, + module_name = module_name, + as_name = as_name) + node = self.visit_CImportStatNode(node) + else: + self.visitchildren(node) + + return node + + def visit_NameNode(self, node): + if node.name in self.cython_module_names: + node.is_cython_module = True + else: + directive = self.directive_names.get(node.name) + if directive is not None: + node.cython_attribute = directive + return node + + def visit_NewExprNode(self, node): + self.visit(node.cppclass) + self.visitchildren(node) + return node + + def try_to_parse_directives(self, node): + # If node is the contents of an directive (in a with statement or + # decorator), returns a list of (directivename, value) pairs. + # Otherwise, returns None + if isinstance(node, ExprNodes.CallNode): + self.visit(node.function) + optname = node.function.as_cython_attribute() + if optname: + directivetype = Options.directive_types.get(optname) + if directivetype: + args, kwds = node.explicit_args_kwds() + directives = [] + key_value_pairs = [] + if kwds is not None and directivetype is not dict: + for keyvalue in kwds.key_value_pairs: + key, value = keyvalue + sub_optname = "%s.%s" % (optname, key.value) + if Options.directive_types.get(sub_optname): + directives.append(self.try_to_parse_directive(sub_optname, [value], None, keyvalue.pos)) + else: + key_value_pairs.append(keyvalue) + if not key_value_pairs: + kwds = None + else: + kwds.key_value_pairs = key_value_pairs + if directives and not kwds and not args: + return directives + directives.append(self.try_to_parse_directive(optname, args, kwds, node.function.pos)) + return directives + elif isinstance(node, (ExprNodes.AttributeNode, ExprNodes.NameNode)): + self.visit(node) + optname = node.as_cython_attribute() + if optname: + directivetype = Options.directive_types.get(optname) + if directivetype is bool: + arg = ExprNodes.BoolNode(node.pos, value=True) + return [self.try_to_parse_directive(optname, [arg], None, node.pos)] + elif directivetype is None: + return [(optname, None)] + else: + raise PostParseError( + node.pos, "The '%s' directive should be used as a function call." % optname) + return None + + def try_to_parse_directive(self, optname, args, kwds, pos): + if optname == 'np_pythran' and not self.context.cpp: + raise PostParseError(pos, 'The %s directive can only be used in C++ mode.' % optname) + elif optname == 'exceptval': + # default: exceptval(None, check=True) + arg_error = len(args) > 1 + check = True + if kwds and kwds.key_value_pairs: + kw = kwds.key_value_pairs[0] + if (len(kwds.key_value_pairs) == 1 and + kw.key.is_string_literal and kw.key.value == 'check' and + isinstance(kw.value, ExprNodes.BoolNode)): + check = kw.value.value + else: + arg_error = True + if arg_error: + raise PostParseError( + pos, 'The exceptval directive takes 0 or 1 positional arguments and the boolean keyword "check"') + return ('exceptval', (args[0] if args else None, check)) + + directivetype = Options.directive_types.get(optname) + if len(args) == 1 and isinstance(args[0], ExprNodes.NoneNode): + return optname, Options.get_directive_defaults()[optname] + elif directivetype is bool: + if kwds is not None or len(args) != 1 or not isinstance(args[0], ExprNodes.BoolNode): + raise PostParseError(pos, + 'The %s directive takes one compile-time boolean argument' % optname) + return (optname, args[0].value) + elif directivetype is int: + if kwds is not None or len(args) != 1 or not isinstance(args[0], ExprNodes.IntNode): + raise PostParseError(pos, + 'The %s directive takes one compile-time integer argument' % optname) + return (optname, int(args[0].value)) + elif directivetype is str: + if kwds is not None or len(args) != 1 or not isinstance( + args[0], (ExprNodes.StringNode, ExprNodes.UnicodeNode)): + raise PostParseError(pos, + 'The %s directive takes one compile-time string argument' % optname) + return (optname, str(args[0].value)) + elif directivetype is type: + if kwds is not None or len(args) != 1: + raise PostParseError(pos, + 'The %s directive takes one type argument' % optname) + return (optname, args[0]) + elif directivetype is dict: + if len(args) != 0: + raise PostParseError(pos, + 'The %s directive takes no prepositional arguments' % optname) + return optname, dict([(key.value, value) for key, value in kwds.key_value_pairs]) + elif directivetype is list: + if kwds and len(kwds.key_value_pairs) != 0: + raise PostParseError(pos, + 'The %s directive takes no keyword arguments' % optname) + return optname, [ str(arg.value) for arg in args ] + elif callable(directivetype): + if kwds is not None or len(args) != 1 or not isinstance( + args[0], (ExprNodes.StringNode, ExprNodes.UnicodeNode)): + raise PostParseError(pos, + 'The %s directive takes one compile-time string argument' % optname) + return (optname, directivetype(optname, str(args[0].value))) + else: + assert False + + def visit_with_directives(self, node, directives): + if not directives: + return self.visit_Node(node) + + old_directives = self.directives + new_directives = dict(old_directives) + new_directives.update(directives) + + if new_directives == old_directives: + return self.visit_Node(node) + + self.directives = new_directives + retbody = self.visit_Node(node) + self.directives = old_directives + + if not isinstance(retbody, Nodes.StatListNode): + retbody = Nodes.StatListNode(node.pos, stats=[retbody]) + return Nodes.CompilerDirectivesNode( + pos=retbody.pos, body=retbody, directives=new_directives) + + # Handle decorators + def visit_FuncDefNode(self, node): + directives = self._extract_directives(node, 'function') + return self.visit_with_directives(node, directives) + + def visit_CVarDefNode(self, node): + directives = self._extract_directives(node, 'function') + for name, value in directives.items(): + if name == 'locals': + node.directive_locals = value + elif name not in ('final', 'staticmethod'): + self.context.nonfatal_error(PostParseError( + node.pos, + "Cdef functions can only take cython.locals(), " + "staticmethod, or final decorators, got %s." % name)) + return self.visit_with_directives(node, directives) + + def visit_CClassDefNode(self, node): + directives = self._extract_directives(node, 'cclass') + return self.visit_with_directives(node, directives) + + def visit_CppClassNode(self, node): + directives = self._extract_directives(node, 'cppclass') + return self.visit_with_directives(node, directives) + + def visit_PyClassDefNode(self, node): + directives = self._extract_directives(node, 'class') + return self.visit_with_directives(node, directives) + + def _extract_directives(self, node, scope_name): + if not node.decorators: + return {} + # Split the decorators into two lists -- real decorators and directives + directives = [] + realdecs = [] + both = [] + # Decorators coming first take precedence. + for dec in node.decorators[::-1]: + new_directives = self.try_to_parse_directives(dec.decorator) + if new_directives is not None: + for directive in new_directives: + if self.check_directive_scope(node.pos, directive[0], scope_name): + name, value = directive + if self.directives.get(name, object()) != value: + directives.append(directive) + if directive[0] == 'staticmethod': + both.append(dec) + # Adapt scope type based on decorators that change it. + if directive[0] == 'cclass' and scope_name == 'class': + scope_name = 'cclass' + else: + realdecs.append(dec) + if realdecs and (scope_name == 'cclass' or + isinstance(node, (Nodes.CFuncDefNode, Nodes.CClassDefNode, Nodes.CVarDefNode))): + raise PostParseError(realdecs[0].pos, "Cdef functions/classes cannot take arbitrary decorators.") + node.decorators = realdecs[::-1] + both[::-1] + # merge or override repeated directives + optdict = {} + for directive in directives: + name, value = directive + if name in optdict: + old_value = optdict[name] + # keywords and arg lists can be merged, everything + # else overrides completely + if isinstance(old_value, dict): + old_value.update(value) + elif isinstance(old_value, list): + old_value.extend(value) + else: + optdict[name] = value + else: + optdict[name] = value + return optdict + + # Handle with-statements + def visit_WithStatNode(self, node): + directive_dict = {} + for directive in self.try_to_parse_directives(node.manager) or []: + if directive is not None: + if node.target is not None: + self.context.nonfatal_error( + PostParseError(node.pos, "Compiler directive with statements cannot contain 'as'")) + else: + name, value = directive + if name in ('nogil', 'gil'): + # special case: in pure mode, "with nogil" spells "with cython.nogil" + node = Nodes.GILStatNode(node.pos, state = name, body = node.body) + return self.visit_Node(node) + if self.check_directive_scope(node.pos, name, 'with statement'): + directive_dict[name] = value + if directive_dict: + return self.visit_with_directives(node.body, directive_dict) + return self.visit_Node(node) + + +class ParallelRangeTransform(CythonTransform, SkipDeclarations): + """ + Transform cython.parallel stuff. The parallel_directives come from the + module node, set there by InterpretCompilerDirectives. + + x = cython.parallel.threadavailable() -> ParallelThreadAvailableNode + with nogil, cython.parallel.parallel(): -> ParallelWithBlockNode + print cython.parallel.threadid() -> ParallelThreadIdNode + for i in cython.parallel.prange(...): -> ParallelRangeNode + ... + """ + + # a list of names, maps 'cython.parallel.prange' in the code to + # ['cython', 'parallel', 'prange'] + parallel_directive = None + + # Indicates whether a namenode in an expression is the cython module + namenode_is_cython_module = False + + # Keep track of whether we are the context manager of a 'with' statement + in_context_manager_section = False + + # One of 'prange' or 'with parallel'. This is used to disallow closely + # nested 'with parallel:' blocks + state = None + + directive_to_node = { + u"cython.parallel.parallel": Nodes.ParallelWithBlockNode, + # u"cython.parallel.threadsavailable": ExprNodes.ParallelThreadsAvailableNode, + u"cython.parallel.threadid": ExprNodes.ParallelThreadIdNode, + u"cython.parallel.prange": Nodes.ParallelRangeNode, + } + + def node_is_parallel_directive(self, node): + return node.name in self.parallel_directives or node.is_cython_module + + def get_directive_class_node(self, node): + """ + Figure out which parallel directive was used and return the associated + Node class. + + E.g. for a cython.parallel.prange() call we return ParallelRangeNode + """ + if self.namenode_is_cython_module: + directive = '.'.join(self.parallel_directive) + else: + directive = self.parallel_directives[self.parallel_directive[0]] + directive = '%s.%s' % (directive, + '.'.join(self.parallel_directive[1:])) + directive = directive.rstrip('.') + + cls = self.directive_to_node.get(directive) + if cls is None and not (self.namenode_is_cython_module and + self.parallel_directive[0] != 'parallel'): + error(node.pos, "Invalid directive: %s" % directive) + + self.namenode_is_cython_module = False + self.parallel_directive = None + + return cls + + def visit_ModuleNode(self, node): + """ + If any parallel directives were imported, copy them over and visit + the AST + """ + if node.parallel_directives: + self.parallel_directives = node.parallel_directives + return self.visit_Node(node) + + # No parallel directives were imported, so they can't be used :) + return node + + def visit_NameNode(self, node): + if self.node_is_parallel_directive(node): + self.parallel_directive = [node.name] + self.namenode_is_cython_module = node.is_cython_module + return node + + def visit_AttributeNode(self, node): + self.visitchildren(node) + if self.parallel_directive: + self.parallel_directive.append(node.attribute) + return node + + def visit_CallNode(self, node): + self.visit(node.function) + if not self.parallel_directive: + self.visitchildren(node, exclude=('function',)) + return node + + # We are a parallel directive, replace this node with the + # corresponding ParallelSomethingSomething node + + if isinstance(node, ExprNodes.GeneralCallNode): + args = node.positional_args.args + kwargs = node.keyword_args + else: + args = node.args + kwargs = {} + + parallel_directive_class = self.get_directive_class_node(node) + if parallel_directive_class: + # Note: in case of a parallel() the body is set by + # visit_WithStatNode + node = parallel_directive_class(node.pos, args=args, kwargs=kwargs) + + return node + + def visit_WithStatNode(self, node): + "Rewrite with cython.parallel.parallel() blocks" + newnode = self.visit(node.manager) + + if isinstance(newnode, Nodes.ParallelWithBlockNode): + if self.state == 'parallel with': + error(node.manager.pos, + "Nested parallel with blocks are disallowed") + + self.state = 'parallel with' + body = self.visit(node.body) + self.state = None + + newnode.body = body + return newnode + elif self.parallel_directive: + parallel_directive_class = self.get_directive_class_node(node) + + if not parallel_directive_class: + # There was an error, stop here and now + return None + + if parallel_directive_class is Nodes.ParallelWithBlockNode: + error(node.pos, "The parallel directive must be called") + return None + + node.body = self.visit(node.body) + return node + + def visit_ForInStatNode(self, node): + "Rewrite 'for i in cython.parallel.prange(...):'" + self.visit(node.iterator) + self.visit(node.target) + + in_prange = isinstance(node.iterator.sequence, + Nodes.ParallelRangeNode) + previous_state = self.state + + if in_prange: + # This will replace the entire ForInStatNode, so copy the + # attributes + parallel_range_node = node.iterator.sequence + + parallel_range_node.target = node.target + parallel_range_node.body = node.body + parallel_range_node.else_clause = node.else_clause + + node = parallel_range_node + + if not isinstance(node.target, ExprNodes.NameNode): + error(node.target.pos, + "Can only iterate over an iteration variable") + + self.state = 'prange' + + self.visit(node.body) + self.state = previous_state + self.visit(node.else_clause) + return node + + def visit(self, node): + "Visit a node that may be None" + if node is not None: + return super(ParallelRangeTransform, self).visit(node) + + +class WithTransform(CythonTransform, SkipDeclarations): + def visit_WithStatNode(self, node): + self.visitchildren(node, 'body') + pos = node.pos + is_async = node.is_async + body, target, manager = node.body, node.target, node.manager + node.enter_call = ExprNodes.SimpleCallNode( + pos, function=ExprNodes.AttributeNode( + pos, obj=ExprNodes.CloneNode(manager), + attribute=EncodedString('__aenter__' if is_async else '__enter__'), + is_special_lookup=True), + args=[], + is_temp=True) + + if is_async: + node.enter_call = ExprNodes.AwaitExprNode(pos, arg=node.enter_call) + + if target is not None: + body = Nodes.StatListNode( + pos, stats=[ + Nodes.WithTargetAssignmentStatNode( + pos, lhs=target, with_node=node), + body]) + + excinfo_target = ExprNodes.TupleNode(pos, slow=True, args=[ + ExprNodes.ExcValueNode(pos) for _ in range(3)]) + except_clause = Nodes.ExceptClauseNode( + pos, body=Nodes.IfStatNode( + pos, if_clauses=[ + Nodes.IfClauseNode( + pos, condition=ExprNodes.NotNode( + pos, operand=ExprNodes.WithExitCallNode( + pos, with_stat=node, + test_if_run=False, + args=excinfo_target, + await_expr=ExprNodes.AwaitExprNode(pos, arg=None) if is_async else None)), + body=Nodes.ReraiseStatNode(pos), + ), + ], + else_clause=None), + pattern=None, + target=None, + excinfo_target=excinfo_target, + ) + + node.body = Nodes.TryFinallyStatNode( + pos, body=Nodes.TryExceptStatNode( + pos, body=body, + except_clauses=[except_clause], + else_clause=None, + ), + finally_clause=Nodes.ExprStatNode( + pos, expr=ExprNodes.WithExitCallNode( + pos, with_stat=node, + test_if_run=True, + args=ExprNodes.TupleNode( + pos, args=[ExprNodes.NoneNode(pos) for _ in range(3)]), + await_expr=ExprNodes.AwaitExprNode(pos, arg=None) if is_async else None)), + handle_error_case=False, + ) + return node + + def visit_ExprNode(self, node): + # With statements are never inside expressions. + return node + + +class DecoratorTransform(ScopeTrackingTransform, SkipDeclarations): + """ + Transforms method decorators in cdef classes into nested calls or properties. + + Python-style decorator properties are transformed into a PropertyNode + with up to the three getter, setter and deleter DefNodes. + The functional style isn't supported yet. + """ + _properties = None + + _map_property_attribute = { + 'getter': '__get__', + 'setter': '__set__', + 'deleter': '__del__', + }.get + + def visit_CClassDefNode(self, node): + if self._properties is None: + self._properties = [] + self._properties.append({}) + super(DecoratorTransform, self).visit_CClassDefNode(node) + self._properties.pop() + return node + + def visit_PropertyNode(self, node): + # Low-level warning for other code until we can convert all our uses over. + level = 2 if isinstance(node.pos[0], str) else 0 + warning(node.pos, "'property %s:' syntax is deprecated, use '@property'" % node.name, level) + return node + + def visit_DefNode(self, node): + scope_type = self.scope_type + node = self.visit_FuncDefNode(node) + if scope_type != 'cclass' or not node.decorators: + return node + + # transform @property decorators + properties = self._properties[-1] + for decorator_node in node.decorators[::-1]: + decorator = decorator_node.decorator + if decorator.is_name and decorator.name == 'property': + if len(node.decorators) > 1: + return self._reject_decorated_property(node, decorator_node) + name = node.name + node.name = EncodedString('__get__') + node.decorators.remove(decorator_node) + stat_list = [node] + if name in properties: + prop = properties[name] + prop.pos = node.pos + prop.doc = node.doc + prop.body.stats = stat_list + return [] + prop = Nodes.PropertyNode(node.pos, name=name) + prop.doc = node.doc + prop.body = Nodes.StatListNode(node.pos, stats=stat_list) + properties[name] = prop + return [prop] + elif decorator.is_attribute and decorator.obj.name in properties: + handler_name = self._map_property_attribute(decorator.attribute) + if handler_name: + if decorator.obj.name != node.name: + # CPython does not generate an error or warning, but not something useful either. + error(decorator_node.pos, + "Mismatching property names, expected '%s', got '%s'" % ( + decorator.obj.name, node.name)) + elif len(node.decorators) > 1: + return self._reject_decorated_property(node, decorator_node) + else: + return self._add_to_property(properties, node, handler_name, decorator_node) + + # we clear node.decorators, so we need to set the + # is_staticmethod/is_classmethod attributes now + for decorator in node.decorators: + func = decorator.decorator + if func.is_name: + node.is_classmethod |= func.name == 'classmethod' + node.is_staticmethod |= func.name == 'staticmethod' + + # transform normal decorators + decs = node.decorators + node.decorators = None + return self.chain_decorators(node, decs, node.name) + + @staticmethod + def _reject_decorated_property(node, decorator_node): + # restrict transformation to outermost decorator as wrapped properties will probably not work + for deco in node.decorators: + if deco != decorator_node: + error(deco.pos, "Property methods with additional decorators are not supported") + return node + + @staticmethod + def _add_to_property(properties, node, name, decorator): + prop = properties[node.name] + node.name = name + node.decorators.remove(decorator) + stats = prop.body.stats + for i, stat in enumerate(stats): + if stat.name == name: + stats[i] = node + break + else: + stats.append(node) + return [] + + @staticmethod + def chain_decorators(node, decorators, name): + """ + Decorators are applied directly in DefNode and PyClassDefNode to avoid + reassignments to the function/class name - except for cdef class methods. + For those, the reassignment is required as methods are originally + defined in the PyMethodDef struct. + + The IndirectionNode allows DefNode to override the decorator. + """ + decorator_result = ExprNodes.NameNode(node.pos, name=name) + for decorator in decorators[::-1]: + decorator_result = ExprNodes.SimpleCallNode( + decorator.pos, + function=decorator.decorator, + args=[decorator_result]) + + name_node = ExprNodes.NameNode(node.pos, name=name) + reassignment = Nodes.SingleAssignmentNode( + node.pos, + lhs=name_node, + rhs=decorator_result) + + reassignment = Nodes.IndirectionNode([reassignment]) + node.decorator_indirection = reassignment + return [node, reassignment] + + +class CnameDirectivesTransform(CythonTransform, SkipDeclarations): + """ + Only part of the CythonUtilityCode pipeline. Must be run before + DecoratorTransform in case this is a decorator for a cdef class. + It filters out @cname('my_cname') decorators and rewrites them to + CnameDecoratorNodes. + """ + + def handle_function(self, node): + if not getattr(node, 'decorators', None): + return self.visit_Node(node) + + for i, decorator in enumerate(node.decorators): + decorator = decorator.decorator + + if (isinstance(decorator, ExprNodes.CallNode) and + decorator.function.is_name and + decorator.function.name == 'cname'): + args, kwargs = decorator.explicit_args_kwds() + + if kwargs: + raise AssertionError( + "cname decorator does not take keyword arguments") + + if len(args) != 1: + raise AssertionError( + "cname decorator takes exactly one argument") + + if not (args[0].is_literal and + args[0].type == Builtin.str_type): + raise AssertionError( + "argument to cname decorator must be a string literal") + + cname = args[0].compile_time_value(None) + del node.decorators[i] + node = Nodes.CnameDecoratorNode(pos=node.pos, node=node, + cname=cname) + break + + return self.visit_Node(node) + + visit_FuncDefNode = handle_function + visit_CClassDefNode = handle_function + visit_CEnumDefNode = handle_function + visit_CStructOrUnionDefNode = handle_function + + +class ForwardDeclareTypes(CythonTransform): + + def visit_CompilerDirectivesNode(self, node): + env = self.module_scope + old = env.directives + env.directives = node.directives + self.visitchildren(node) + env.directives = old + return node + + def visit_ModuleNode(self, node): + self.module_scope = node.scope + self.module_scope.directives = node.directives + self.visitchildren(node) + return node + + def visit_CDefExternNode(self, node): + old_cinclude_flag = self.module_scope.in_cinclude + self.module_scope.in_cinclude = 1 + self.visitchildren(node) + self.module_scope.in_cinclude = old_cinclude_flag + return node + + def visit_CEnumDefNode(self, node): + node.declare(self.module_scope) + return node + + def visit_CStructOrUnionDefNode(self, node): + if node.name not in self.module_scope.entries: + node.declare(self.module_scope) + return node + + def visit_CClassDefNode(self, node): + if node.class_name not in self.module_scope.entries: + node.declare(self.module_scope) + # Expand fused methods of .pxd declared types to construct the final vtable order. + type = self.module_scope.entries[node.class_name].type + if type is not None and type.is_extension_type and not type.is_builtin_type and type.scope: + scope = type.scope + for entry in scope.cfunc_entries: + if entry.type and entry.type.is_fused: + entry.type.get_all_specialized_function_types() + return node + + +class AnalyseDeclarationsTransform(EnvTransform): + + basic_property = TreeFragment(u""" +property NAME: + def __get__(self): + return ATTR + def __set__(self, value): + ATTR = value + """, level='c_class', pipeline=[NormalizeTree(None)]) + basic_pyobject_property = TreeFragment(u""" +property NAME: + def __get__(self): + return ATTR + def __set__(self, value): + ATTR = value + def __del__(self): + ATTR = None + """, level='c_class', pipeline=[NormalizeTree(None)]) + basic_property_ro = TreeFragment(u""" +property NAME: + def __get__(self): + return ATTR + """, level='c_class', pipeline=[NormalizeTree(None)]) + + struct_or_union_wrapper = TreeFragment(u""" +cdef class NAME: + cdef TYPE value + def __init__(self, MEMBER=None): + cdef int count + count = 0 + INIT_ASSIGNMENTS + if IS_UNION and count > 1: + raise ValueError, "At most one union member should be specified." + def __str__(self): + return STR_FORMAT % MEMBER_TUPLE + def __repr__(self): + return REPR_FORMAT % MEMBER_TUPLE + """, pipeline=[NormalizeTree(None)]) + + init_assignment = TreeFragment(u""" +if VALUE is not None: + ATTR = VALUE + count += 1 + """, pipeline=[NormalizeTree(None)]) + + fused_function = None + in_lambda = 0 + + def __call__(self, root): + # needed to determine if a cdef var is declared after it's used. + self.seen_vars_stack = [] + self.fused_error_funcs = set() + super_class = super(AnalyseDeclarationsTransform, self) + self._super_visit_FuncDefNode = super_class.visit_FuncDefNode + return super_class.__call__(root) + + def visit_NameNode(self, node): + self.seen_vars_stack[-1].add(node.name) + return node + + def visit_ModuleNode(self, node): + # Pickling support requires injecting module-level nodes. + self.extra_module_declarations = [] + self.seen_vars_stack.append(set()) + node.analyse_declarations(self.current_env()) + self.visitchildren(node) + self.seen_vars_stack.pop() + node.body.stats.extend(self.extra_module_declarations) + return node + + def visit_LambdaNode(self, node): + self.in_lambda += 1 + node.analyse_declarations(self.current_env()) + self.visitchildren(node) + self.in_lambda -= 1 + return node + + def visit_CClassDefNode(self, node): + node = self.visit_ClassDefNode(node) + if node.scope and node.scope.implemented and node.body: + stats = [] + for entry in node.scope.var_entries: + if entry.needs_property: + property = self.create_Property(entry) + property.analyse_declarations(node.scope) + self.visit(property) + stats.append(property) + if stats: + node.body.stats += stats + if (node.visibility != 'extern' + and not node.scope.lookup('__reduce__') + and not node.scope.lookup('__reduce_ex__')): + self._inject_pickle_methods(node) + return node + + def _inject_pickle_methods(self, node): + env = self.current_env() + if node.scope.directives['auto_pickle'] is False: # None means attempt it. + # Old behavior of not doing anything. + return + auto_pickle_forced = node.scope.directives['auto_pickle'] is True + + all_members = [] + cls = node.entry.type + cinit = None + inherited_reduce = None + while cls is not None: + all_members.extend(e for e in cls.scope.var_entries if e.name not in ('__weakref__', '__dict__')) + cinit = cinit or cls.scope.lookup('__cinit__') + inherited_reduce = inherited_reduce or cls.scope.lookup('__reduce__') or cls.scope.lookup('__reduce_ex__') + cls = cls.base_type + all_members.sort(key=lambda e: e.name) + + if inherited_reduce: + # This is not failsafe, as we may not know whether a cimported class defines a __reduce__. + # This is why we define __reduce_cython__ and only replace __reduce__ + # (via ExtensionTypes.SetupReduce utility code) at runtime on class creation. + return + + non_py = [ + e for e in all_members + if not e.type.is_pyobject and (not e.type.can_coerce_to_pyobject(env) + or not e.type.can_coerce_from_pyobject(env)) + ] + + structs = [e for e in all_members if e.type.is_struct_or_union] + + if cinit or non_py or (structs and not auto_pickle_forced): + if cinit: + # TODO(robertwb): We could allow this if __cinit__ has no require arguments. + msg = 'no default __reduce__ due to non-trivial __cinit__' + elif non_py: + msg = "%s cannot be converted to a Python object for pickling" % ','.join("self.%s" % e.name for e in non_py) + else: + # Extern structs may be only partially defined. + # TODO(robertwb): Limit the restriction to extern + # (and recursively extern-containing) structs. + msg = ("Pickling of struct members such as %s must be explicitly requested " + "with @auto_pickle(True)" % ','.join("self.%s" % e.name for e in structs)) + + if auto_pickle_forced: + error(node.pos, msg) + + pickle_func = TreeFragment(u""" + def __reduce_cython__(self): + raise TypeError("%(msg)s") + def __setstate_cython__(self, __pyx_state): + raise TypeError("%(msg)s") + """ % {'msg': msg}, + level='c_class', pipeline=[NormalizeTree(None)]).substitute({}) + pickle_func.analyse_declarations(node.scope) + self.visit(pickle_func) + node.body.stats.append(pickle_func) + + else: + for e in all_members: + if not e.type.is_pyobject: + e.type.create_to_py_utility_code(env) + e.type.create_from_py_utility_code(env) + all_members_names = [e.name for e in all_members] + checksums = _calculate_pickle_checksums(all_members_names) + + unpickle_func_name = '__pyx_unpickle_%s' % node.class_name + + # TODO(robertwb): Move the state into the third argument + # so it can be pickled *after* self is memoized. + unpickle_func = TreeFragment(u""" + def %(unpickle_func_name)s(__pyx_type, long __pyx_checksum, __pyx_state): + cdef object __pyx_PickleError + cdef object __pyx_result + if __pyx_checksum not in %(checksums)s: + from pickle import PickleError as __pyx_PickleError + raise __pyx_PickleError("Incompatible checksums (0x%%x vs %(checksums)s = (%(members)s))" %% __pyx_checksum) + __pyx_result = %(class_name)s.__new__(__pyx_type) + if __pyx_state is not None: + %(unpickle_func_name)s__set_state(<%(class_name)s> __pyx_result, __pyx_state) + return __pyx_result + + cdef %(unpickle_func_name)s__set_state(%(class_name)s __pyx_result, tuple __pyx_state): + %(assignments)s + if len(__pyx_state) > %(num_members)d and hasattr(__pyx_result, '__dict__'): + __pyx_result.__dict__.update(__pyx_state[%(num_members)d]) + """ % { + 'unpickle_func_name': unpickle_func_name, + 'checksums': "(%s)" % ', '.join(checksums), + 'members': ', '.join(all_members_names), + 'class_name': node.class_name, + 'assignments': '; '.join( + '__pyx_result.%s = __pyx_state[%s]' % (v, ix) + for ix, v in enumerate(all_members_names)), + 'num_members': len(all_members_names), + }, level='module', pipeline=[NormalizeTree(None)]).substitute({}) + unpickle_func.analyse_declarations(node.entry.scope) + self.visit(unpickle_func) + self.extra_module_declarations.append(unpickle_func) + + pickle_func = TreeFragment(u""" + def __reduce_cython__(self): + cdef tuple state + cdef object _dict + cdef bint use_setstate + state = (%(members)s) + _dict = getattr(self, '__dict__', None) + if _dict is not None: + state += (_dict,) + use_setstate = True + else: + use_setstate = %(any_notnone_members)s + if use_setstate: + return %(unpickle_func_name)s, (type(self), %(checksum)s, None), state + else: + return %(unpickle_func_name)s, (type(self), %(checksum)s, state) + + def __setstate_cython__(self, __pyx_state): + %(unpickle_func_name)s__set_state(self, __pyx_state) + """ % { + 'unpickle_func_name': unpickle_func_name, + 'checksum': checksums[0], + 'members': ', '.join('self.%s' % v for v in all_members_names) + (',' if len(all_members_names) == 1 else ''), + # Even better, we could check PyType_IS_GC. + 'any_notnone_members' : ' or '.join(['self.%s is not None' % e.name for e in all_members if e.type.is_pyobject] or ['False']), + }, + level='c_class', pipeline=[NormalizeTree(None)]).substitute({}) + pickle_func.analyse_declarations(node.scope) + self.enter_scope(node, node.scope) # functions should be visited in the class scope + self.visit(pickle_func) + self.exit_scope() + node.body.stats.append(pickle_func) + + def _handle_fused_def_decorators(self, old_decorators, env, node): + """ + Create function calls to the decorators and reassignments to + the function. + """ + # Delete staticmethod and classmethod decorators, this is + # handled directly by the fused function object. + decorators = [] + for decorator in old_decorators: + func = decorator.decorator + if (not func.is_name or + func.name not in ('staticmethod', 'classmethod') or + env.lookup_here(func.name)): + # not a static or classmethod + decorators.append(decorator) + + if decorators: + transform = DecoratorTransform(self.context) + def_node = node.node + _, reassignments = transform.chain_decorators( + def_node, decorators, def_node.name) + reassignments.analyse_declarations(env) + node = [node, reassignments] + + return node + + def _handle_def(self, decorators, env, node): + "Handle def or cpdef fused functions" + # Create PyCFunction nodes for each specialization + node.stats.insert(0, node.py_func) + node.py_func = self.visit(node.py_func) + node.update_fused_defnode_entry(env) + pycfunc = ExprNodes.PyCFunctionNode.from_defnode(node.py_func, binding=True) + pycfunc = ExprNodes.ProxyNode(pycfunc.coerce_to_temp(env)) + node.resulting_fused_function = pycfunc + # Create assignment node for our def function + node.fused_func_assignment = self._create_assignment( + node.py_func, ExprNodes.CloneNode(pycfunc), env) + + if decorators: + node = self._handle_fused_def_decorators(decorators, env, node) + + return node + + def _create_fused_function(self, env, node): + "Create a fused function for a DefNode with fused arguments" + from . import FusedNode + + if self.fused_function or self.in_lambda: + if self.fused_function not in self.fused_error_funcs: + if self.in_lambda: + error(node.pos, "Fused lambdas not allowed") + else: + error(node.pos, "Cannot nest fused functions") + + self.fused_error_funcs.add(self.fused_function) + + node.body = Nodes.PassStatNode(node.pos) + for arg in node.args: + if arg.type.is_fused: + arg.type = arg.type.get_fused_types()[0] + + return node + + decorators = getattr(node, 'decorators', None) + node = FusedNode.FusedCFuncDefNode(node, env) + self.fused_function = node + self.visitchildren(node) + self.fused_function = None + if node.py_func: + node = self._handle_def(decorators, env, node) + + return node + + def _handle_nogil_cleanup(self, lenv, node): + "Handle cleanup for 'with gil' blocks in nogil functions." + if lenv.nogil and lenv.has_with_gil_block: + # Acquire the GIL for cleanup in 'nogil' functions, by wrapping + # the entire function body in try/finally. + # The corresponding release will be taken care of by + # Nodes.FuncDefNode.generate_function_definitions() + node.body = Nodes.NogilTryFinallyStatNode( + node.body.pos, + body=node.body, + finally_clause=Nodes.EnsureGILNode(node.body.pos), + finally_except_clause=Nodes.EnsureGILNode(node.body.pos)) + + def _handle_fused(self, node): + if node.is_generator and node.has_fused_arguments: + node.has_fused_arguments = False + error(node.pos, "Fused generators not supported") + node.gbody = Nodes.StatListNode(node.pos, + stats=[], + body=Nodes.PassStatNode(node.pos)) + + return node.has_fused_arguments + + def visit_FuncDefNode(self, node): + """ + Analyse a function and its body, as that hasn't happened yet. Also + analyse the directive_locals set by @cython.locals(). + + Then, if we are a function with fused arguments, replace the function + (after it has declared itself in the symbol table!) with a + FusedCFuncDefNode, and analyse its children (which are in turn normal + functions). If we're a normal function, just analyse the body of the + function. + """ + env = self.current_env() + + self.seen_vars_stack.append(set()) + lenv = node.local_scope + node.declare_arguments(lenv) + + # @cython.locals(...) + for var, type_node in node.directive_locals.items(): + if not lenv.lookup_here(var): # don't redeclare args + type = type_node.analyse_as_type(lenv) + if type: + lenv.declare_var(var, type, type_node.pos) + else: + error(type_node.pos, "Not a type") + + if self._handle_fused(node): + node = self._create_fused_function(env, node) + else: + node.body.analyse_declarations(lenv) + self._handle_nogil_cleanup(lenv, node) + self._super_visit_FuncDefNode(node) + + self.seen_vars_stack.pop() + return node + + def visit_DefNode(self, node): + node = self.visit_FuncDefNode(node) + env = self.current_env() + if isinstance(node, Nodes.DefNode) and node.is_wrapper: + env = env.parent_scope + if (not isinstance(node, Nodes.DefNode) or + node.fused_py_func or node.is_generator_body or + not node.needs_assignment_synthesis(env)): + return node + return [node, self._synthesize_assignment(node, env)] + + def visit_GeneratorBodyDefNode(self, node): + return self.visit_FuncDefNode(node) + + def _synthesize_assignment(self, node, env): + # Synthesize assignment node and put it right after defnode + genv = env + while genv.is_py_class_scope or genv.is_c_class_scope: + genv = genv.outer_scope + + if genv.is_closure_scope: + rhs = node.py_cfunc_node = ExprNodes.InnerFunctionNode( + node.pos, def_node=node, + pymethdef_cname=node.entry.pymethdef_cname, + code_object=ExprNodes.CodeObjectNode(node)) + else: + binding = self.current_directives.get('binding') + rhs = ExprNodes.PyCFunctionNode.from_defnode(node, binding) + node.code_object = rhs.code_object + if node.is_generator: + node.gbody.code_object = node.code_object + + if env.is_py_class_scope: + rhs.binding = True + + node.is_cyfunction = rhs.binding + return self._create_assignment(node, rhs, env) + + def _create_assignment(self, def_node, rhs, env): + if def_node.decorators: + for decorator in def_node.decorators[::-1]: + rhs = ExprNodes.SimpleCallNode( + decorator.pos, + function = decorator.decorator, + args = [rhs]) + def_node.decorators = None + + assmt = Nodes.SingleAssignmentNode( + def_node.pos, + lhs=ExprNodes.NameNode(def_node.pos, name=def_node.name), + rhs=rhs) + assmt.analyse_declarations(env) + return assmt + + def visit_ScopedExprNode(self, node): + env = self.current_env() + node.analyse_declarations(env) + # the node may or may not have a local scope + if node.has_local_scope: + self.seen_vars_stack.append(set(self.seen_vars_stack[-1])) + self.enter_scope(node, node.expr_scope) + node.analyse_scoped_declarations(node.expr_scope) + self.visitchildren(node) + self.exit_scope() + self.seen_vars_stack.pop() + else: + node.analyse_scoped_declarations(env) + self.visitchildren(node) + return node + + def visit_TempResultFromStatNode(self, node): + self.visitchildren(node) + node.analyse_declarations(self.current_env()) + return node + + def visit_CppClassNode(self, node): + if node.visibility == 'extern': + return None + else: + return self.visit_ClassDefNode(node) + + def visit_CStructOrUnionDefNode(self, node): + # Create a wrapper node if needed. + # We want to use the struct type information (so it can't happen + # before this phase) but also create new objects to be declared + # (so it can't happen later). + # Note that we don't return the original node, as it is + # never used after this phase. + if True: # private (default) + return None + + self_value = ExprNodes.AttributeNode( + pos = node.pos, + obj = ExprNodes.NameNode(pos=node.pos, name=u"self"), + attribute = EncodedString(u"value")) + var_entries = node.entry.type.scope.var_entries + attributes = [] + for entry in var_entries: + attributes.append(ExprNodes.AttributeNode(pos = entry.pos, + obj = self_value, + attribute = entry.name)) + # __init__ assignments + init_assignments = [] + for entry, attr in zip(var_entries, attributes): + # TODO: branch on visibility + init_assignments.append(self.init_assignment.substitute({ + u"VALUE": ExprNodes.NameNode(entry.pos, name = entry.name), + u"ATTR": attr, + }, pos = entry.pos)) + + # create the class + str_format = u"%s(%s)" % (node.entry.type.name, ("%s, " * len(attributes))[:-2]) + wrapper_class = self.struct_or_union_wrapper.substitute({ + u"INIT_ASSIGNMENTS": Nodes.StatListNode(node.pos, stats = init_assignments), + u"IS_UNION": ExprNodes.BoolNode(node.pos, value = not node.entry.type.is_struct), + u"MEMBER_TUPLE": ExprNodes.TupleNode(node.pos, args=attributes), + u"STR_FORMAT": ExprNodes.StringNode(node.pos, value = EncodedString(str_format)), + u"REPR_FORMAT": ExprNodes.StringNode(node.pos, value = EncodedString(str_format.replace("%s", "%r"))), + }, pos = node.pos).stats[0] + wrapper_class.class_name = node.name + wrapper_class.shadow = True + class_body = wrapper_class.body.stats + + # fix value type + assert isinstance(class_body[0].base_type, Nodes.CSimpleBaseTypeNode) + class_body[0].base_type.name = node.name + + # fix __init__ arguments + init_method = class_body[1] + assert isinstance(init_method, Nodes.DefNode) and init_method.name == '__init__' + arg_template = init_method.args[1] + if not node.entry.type.is_struct: + arg_template.kw_only = True + del init_method.args[1] + for entry, attr in zip(var_entries, attributes): + arg = copy.deepcopy(arg_template) + arg.declarator.name = entry.name + init_method.args.append(arg) + + # setters/getters + for entry, attr in zip(var_entries, attributes): + # TODO: branch on visibility + if entry.type.is_pyobject: + template = self.basic_pyobject_property + else: + template = self.basic_property + property = template.substitute({ + u"ATTR": attr, + }, pos = entry.pos).stats[0] + property.name = entry.name + wrapper_class.body.stats.append(property) + + wrapper_class.analyse_declarations(self.current_env()) + return self.visit_CClassDefNode(wrapper_class) + + # Some nodes are no longer needed after declaration + # analysis and can be dropped. The analysis was performed + # on these nodes in a separate recursive process from the + # enclosing function or module, so we can simply drop them. + def visit_CDeclaratorNode(self, node): + # necessary to ensure that all CNameDeclaratorNodes are visited. + self.visitchildren(node) + return node + + def visit_CTypeDefNode(self, node): + return node + + def visit_CBaseTypeNode(self, node): + return None + + def visit_CEnumDefNode(self, node): + if node.visibility == 'public': + return node + else: + return None + + def visit_CNameDeclaratorNode(self, node): + if node.name in self.seen_vars_stack[-1]: + entry = self.current_env().lookup(node.name) + if (entry is None or entry.visibility != 'extern' + and not entry.scope.is_c_class_scope): + warning(node.pos, "cdef variable '%s' declared after it is used" % node.name, 2) + self.visitchildren(node) + return node + + def visit_CVarDefNode(self, node): + # to ensure all CNameDeclaratorNodes are visited. + self.visitchildren(node) + return None + + def visit_CnameDecoratorNode(self, node): + child_node = self.visit(node.node) + if not child_node: + return None + if type(child_node) is list: # Assignment synthesized + node.child_node = child_node[0] + return [node] + child_node[1:] + node.node = child_node + return node + + def create_Property(self, entry): + if entry.visibility == 'public': + if entry.type.is_pyobject: + template = self.basic_pyobject_property + else: + template = self.basic_property + elif entry.visibility == 'readonly': + template = self.basic_property_ro + property = template.substitute({ + u"ATTR": ExprNodes.AttributeNode(pos=entry.pos, + obj=ExprNodes.NameNode(pos=entry.pos, name="self"), + attribute=entry.name), + }, pos=entry.pos).stats[0] + property.name = entry.name + property.doc = entry.doc + return property + + +def _calculate_pickle_checksums(member_names): + # Cython 0.x used MD5 for the checksum, which a few Python installations remove for security reasons. + # SHA-256 should be ok for years to come, but early Cython 3.0 alpha releases used SHA-1, + # which may not be. + member_names_string = ' '.join(member_names).encode('utf-8') + hash_kwargs = {'usedforsecurity': False} if sys.version_info >= (3, 9) else {} + checksums = [] + for algo_name in ['md5', 'sha256', 'sha1']: + try: + mkchecksum = getattr(hashlib, algo_name) + checksum = mkchecksum(member_names_string, **hash_kwargs).hexdigest() + except (AttributeError, ValueError): + # The algorithm (i.e. MD5) might not be there at all, or might be blocked at runtime. + continue + checksums.append('0x' + checksum[:7]) + return checksums + + +class CalculateQualifiedNamesTransform(EnvTransform): + """ + Calculate and store the '__qualname__' and the global + module name on some nodes. + """ + def visit_ModuleNode(self, node): + self.module_name = self.global_scope().qualified_name + self.qualified_name = [] + _super = super(CalculateQualifiedNamesTransform, self) + self._super_visit_FuncDefNode = _super.visit_FuncDefNode + self._super_visit_ClassDefNode = _super.visit_ClassDefNode + self.visitchildren(node) + return node + + def _set_qualname(self, node, name=None): + if name: + qualname = self.qualified_name[:] + qualname.append(name) + else: + qualname = self.qualified_name + node.qualname = EncodedString('.'.join(qualname)) + node.module_name = self.module_name + + def _append_entry(self, entry): + if entry.is_pyglobal and not entry.is_pyclass_attr: + self.qualified_name = [entry.name] + else: + self.qualified_name.append(entry.name) + + def visit_ClassNode(self, node): + self._set_qualname(node, node.name) + self.visitchildren(node) + return node + + def visit_PyClassNamespaceNode(self, node): + # class name was already added by parent node + self._set_qualname(node) + self.visitchildren(node) + return node + + def visit_PyCFunctionNode(self, node): + orig_qualified_name = self.qualified_name[:] + if node.def_node.is_wrapper and self.qualified_name and self.qualified_name[-1] == '<locals>': + self.qualified_name.pop() + self._set_qualname(node) + else: + self._set_qualname(node, node.def_node.name) + self.visitchildren(node) + self.qualified_name = orig_qualified_name + return node + + def visit_DefNode(self, node): + if node.is_wrapper and self.qualified_name: + assert self.qualified_name[-1] == '<locals>', self.qualified_name + orig_qualified_name = self.qualified_name[:] + self.qualified_name.pop() + self._set_qualname(node) + self._super_visit_FuncDefNode(node) + self.qualified_name = orig_qualified_name + else: + self._set_qualname(node, node.name) + self.visit_FuncDefNode(node) + return node + + def visit_FuncDefNode(self, node): + orig_qualified_name = self.qualified_name[:] + if getattr(node, 'name', None) == '<lambda>': + self.qualified_name.append('<lambda>') + else: + self._append_entry(node.entry) + self.qualified_name.append('<locals>') + self._super_visit_FuncDefNode(node) + self.qualified_name = orig_qualified_name + return node + + def visit_ClassDefNode(self, node): + orig_qualified_name = self.qualified_name[:] + entry = (getattr(node, 'entry', None) or # PyClass + self.current_env().lookup_here(node.name)) # CClass + self._append_entry(entry) + self._super_visit_ClassDefNode(node) + self.qualified_name = orig_qualified_name + return node + + +class AnalyseExpressionsTransform(CythonTransform): + + def visit_ModuleNode(self, node): + node.scope.infer_types() + node.body = node.body.analyse_expressions(node.scope) + self.visitchildren(node) + return node + + def visit_FuncDefNode(self, node): + node.local_scope.infer_types() + node.body = node.body.analyse_expressions(node.local_scope) + self.visitchildren(node) + return node + + def visit_ScopedExprNode(self, node): + if node.has_local_scope: + node.expr_scope.infer_types() + node = node.analyse_scoped_expressions(node.expr_scope) + self.visitchildren(node) + return node + + def visit_IndexNode(self, node): + """ + Replace index nodes used to specialize cdef functions with fused + argument types with the Attribute- or NameNode referring to the + function. We then need to copy over the specialization properties to + the attribute or name node. + + Because the indexing might be a Python indexing operation on a fused + function, or (usually) a Cython indexing operation, we need to + re-analyse the types. + """ + self.visit_Node(node) + if node.is_fused_index and not node.type.is_error: + node = node.base + return node + + +class FindInvalidUseOfFusedTypes(CythonTransform): + + def visit_FuncDefNode(self, node): + # Errors related to use in functions with fused args will already + # have been detected + if not node.has_fused_arguments: + if not node.is_generator_body and node.return_type.is_fused: + error(node.pos, "Return type is not specified as argument type") + else: + self.visitchildren(node) + + return node + + def visit_ExprNode(self, node): + if node.type and node.type.is_fused: + error(node.pos, "Invalid use of fused types, type cannot be specialized") + else: + self.visitchildren(node) + + return node + + +class ExpandInplaceOperators(EnvTransform): + + def visit_InPlaceAssignmentNode(self, node): + lhs = node.lhs + rhs = node.rhs + if lhs.type.is_cpp_class: + # No getting around this exact operator here. + return node + if isinstance(lhs, ExprNodes.BufferIndexNode): + # There is code to handle this case in InPlaceAssignmentNode + return node + + env = self.current_env() + def side_effect_free_reference(node, setting=False): + if node.is_name: + return node, [] + elif node.type.is_pyobject and not setting: + node = LetRefNode(node) + return node, [node] + elif node.is_subscript: + base, temps = side_effect_free_reference(node.base) + index = LetRefNode(node.index) + return ExprNodes.IndexNode(node.pos, base=base, index=index), temps + [index] + elif node.is_attribute: + obj, temps = side_effect_free_reference(node.obj) + return ExprNodes.AttributeNode(node.pos, obj=obj, attribute=node.attribute), temps + elif isinstance(node, ExprNodes.BufferIndexNode): + raise ValueError("Don't allow things like attributes of buffer indexing operations") + else: + node = LetRefNode(node) + return node, [node] + try: + lhs, let_ref_nodes = side_effect_free_reference(lhs, setting=True) + except ValueError: + return node + dup = lhs.__class__(**lhs.__dict__) + binop = ExprNodes.binop_node(node.pos, + operator = node.operator, + operand1 = dup, + operand2 = rhs, + inplace=True) + # Manually analyse types for new node. + lhs.analyse_target_types(env) + dup.analyse_types(env) + binop.analyse_operation(env) + node = Nodes.SingleAssignmentNode( + node.pos, + lhs = lhs, + rhs=binop.coerce_to(lhs.type, env)) + # Use LetRefNode to avoid side effects. + let_ref_nodes.reverse() + for t in let_ref_nodes: + node = LetNode(t, node) + return node + + def visit_ExprNode(self, node): + # In-place assignments can't happen within an expression. + return node + + +class AdjustDefByDirectives(CythonTransform, SkipDeclarations): + """ + Adjust function and class definitions by the decorator directives: + + @cython.cfunc + @cython.cclass + @cython.ccall + @cython.inline + @cython.nogil + """ + + def visit_ModuleNode(self, node): + self.directives = node.directives + self.in_py_class = False + self.visitchildren(node) + return node + + def visit_CompilerDirectivesNode(self, node): + old_directives = self.directives + self.directives = node.directives + self.visitchildren(node) + self.directives = old_directives + return node + + def visit_DefNode(self, node): + modifiers = [] + if 'inline' in self.directives: + modifiers.append('inline') + nogil = self.directives.get('nogil') + except_val = self.directives.get('exceptval') + return_type_node = self.directives.get('returns') + if return_type_node is None and self.directives['annotation_typing']: + return_type_node = node.return_type_annotation + # for Python anntations, prefer safe exception handling by default + if return_type_node is not None and except_val is None: + except_val = (None, True) # except * + elif except_val is None: + # backward compatible default: no exception check + except_val = (None, False) + if 'ccall' in self.directives: + node = node.as_cfunction( + overridable=True, modifiers=modifiers, nogil=nogil, + returns=return_type_node, except_val=except_val) + return self.visit(node) + if 'cfunc' in self.directives: + if self.in_py_class: + error(node.pos, "cfunc directive is not allowed here") + else: + node = node.as_cfunction( + overridable=False, modifiers=modifiers, nogil=nogil, + returns=return_type_node, except_val=except_val) + return self.visit(node) + if 'inline' in modifiers: + error(node.pos, "Python functions cannot be declared 'inline'") + if nogil: + # TODO: turn this into a "with gil" declaration. + error(node.pos, "Python functions cannot be declared 'nogil'") + self.visitchildren(node) + return node + + def visit_LambdaNode(self, node): + # No directives should modify lambdas or generator expressions (and also nothing in them). + return node + + def visit_PyClassDefNode(self, node): + if 'cclass' in self.directives: + node = node.as_cclass() + return self.visit(node) + else: + old_in_pyclass = self.in_py_class + self.in_py_class = True + self.visitchildren(node) + self.in_py_class = old_in_pyclass + return node + + def visit_CClassDefNode(self, node): + old_in_pyclass = self.in_py_class + self.in_py_class = False + self.visitchildren(node) + self.in_py_class = old_in_pyclass + return node + + +class AlignFunctionDefinitions(CythonTransform): + """ + This class takes the signatures from a .pxd file and applies them to + the def methods in a .py file. + """ + + def visit_ModuleNode(self, node): + self.scope = node.scope + self.directives = node.directives + self.imported_names = set() # hack, see visit_FromImportStatNode() + self.visitchildren(node) + return node + + def visit_PyClassDefNode(self, node): + pxd_def = self.scope.lookup(node.name) + if pxd_def: + if pxd_def.is_cclass: + return self.visit_CClassDefNode(node.as_cclass(), pxd_def) + elif not pxd_def.scope or not pxd_def.scope.is_builtin_scope: + error(node.pos, "'%s' redeclared" % node.name) + if pxd_def.pos: + error(pxd_def.pos, "previous declaration here") + return None + return node + + def visit_CClassDefNode(self, node, pxd_def=None): + if pxd_def is None: + pxd_def = self.scope.lookup(node.class_name) + if pxd_def: + if not pxd_def.defined_in_pxd: + return node + outer_scope = self.scope + self.scope = pxd_def.type.scope + self.visitchildren(node) + if pxd_def: + self.scope = outer_scope + return node + + def visit_DefNode(self, node): + pxd_def = self.scope.lookup(node.name) + if pxd_def and (not pxd_def.scope or not pxd_def.scope.is_builtin_scope): + if not pxd_def.is_cfunction: + error(node.pos, "'%s' redeclared" % node.name) + if pxd_def.pos: + error(pxd_def.pos, "previous declaration here") + return None + node = node.as_cfunction(pxd_def) + elif (self.scope.is_module_scope and self.directives['auto_cpdef'] + and not node.name in self.imported_names + and node.is_cdef_func_compatible()): + # FIXME: cpdef-ing should be done in analyse_declarations() + node = node.as_cfunction(scope=self.scope) + # Enable this when nested cdef functions are allowed. + # self.visitchildren(node) + return node + + def visit_FromImportStatNode(self, node): + # hack to prevent conditional import fallback functions from + # being cdpef-ed (global Python variables currently conflict + # with imports) + if self.scope.is_module_scope: + for name, _ in node.items: + self.imported_names.add(name) + return node + + def visit_ExprNode(self, node): + # ignore lambdas and everything else that appears in expressions + return node + + +class RemoveUnreachableCode(CythonTransform): + def visit_StatListNode(self, node): + if not self.current_directives['remove_unreachable']: + return node + self.visitchildren(node) + for idx, stat in enumerate(node.stats): + idx += 1 + if stat.is_terminator: + if idx < len(node.stats): + if self.current_directives['warn.unreachable']: + warning(node.stats[idx].pos, "Unreachable code", 2) + node.stats = node.stats[:idx] + node.is_terminator = True + break + return node + + def visit_IfClauseNode(self, node): + self.visitchildren(node) + if node.body.is_terminator: + node.is_terminator = True + return node + + def visit_IfStatNode(self, node): + self.visitchildren(node) + if node.else_clause and node.else_clause.is_terminator: + for clause in node.if_clauses: + if not clause.is_terminator: + break + else: + node.is_terminator = True + return node + + def visit_TryExceptStatNode(self, node): + self.visitchildren(node) + if node.body.is_terminator and node.else_clause: + if self.current_directives['warn.unreachable']: + warning(node.else_clause.pos, "Unreachable code", 2) + node.else_clause = None + return node + + def visit_TryFinallyStatNode(self, node): + self.visitchildren(node) + if node.finally_clause.is_terminator: + node.is_terminator = True + return node + + +class YieldNodeCollector(TreeVisitor): + + def __init__(self): + super(YieldNodeCollector, self).__init__() + self.yields = [] + self.returns = [] + self.finallys = [] + self.excepts = [] + self.has_return_value = False + self.has_yield = False + self.has_await = False + + def visit_Node(self, node): + self.visitchildren(node) + + def visit_YieldExprNode(self, node): + self.yields.append(node) + self.has_yield = True + self.visitchildren(node) + + def visit_AwaitExprNode(self, node): + self.yields.append(node) + self.has_await = True + self.visitchildren(node) + + def visit_ReturnStatNode(self, node): + self.visitchildren(node) + if node.value: + self.has_return_value = True + self.returns.append(node) + + def visit_TryFinallyStatNode(self, node): + self.visitchildren(node) + self.finallys.append(node) + + def visit_TryExceptStatNode(self, node): + self.visitchildren(node) + self.excepts.append(node) + + def visit_ClassDefNode(self, node): + pass + + def visit_FuncDefNode(self, node): + pass + + def visit_LambdaNode(self, node): + pass + + def visit_GeneratorExpressionNode(self, node): + pass + + def visit_CArgDeclNode(self, node): + # do not look into annotations + # FIXME: support (yield) in default arguments (currently crashes) + pass + + +class MarkClosureVisitor(CythonTransform): + + def visit_ModuleNode(self, node): + self.needs_closure = False + self.visitchildren(node) + return node + + def visit_FuncDefNode(self, node): + self.needs_closure = False + self.visitchildren(node) + node.needs_closure = self.needs_closure + self.needs_closure = True + + collector = YieldNodeCollector() + collector.visitchildren(node) + + if node.is_async_def: + coroutine_type = Nodes.AsyncDefNode + if collector.has_yield: + coroutine_type = Nodes.AsyncGenNode + for yield_expr in collector.yields + collector.returns: + yield_expr.in_async_gen = True + elif self.current_directives['iterable_coroutine']: + coroutine_type = Nodes.IterableAsyncDefNode + elif collector.has_await: + found = next(y for y in collector.yields if y.is_await) + error(found.pos, "'await' not allowed in generators (use 'yield')") + return node + elif collector.has_yield: + coroutine_type = Nodes.GeneratorDefNode + else: + return node + + for i, yield_expr in enumerate(collector.yields, 1): + yield_expr.label_num = i + for retnode in collector.returns + collector.finallys + collector.excepts: + retnode.in_generator = True + + gbody = Nodes.GeneratorBodyDefNode( + pos=node.pos, name=node.name, body=node.body, + is_async_gen_body=node.is_async_def and collector.has_yield) + coroutine = coroutine_type( + pos=node.pos, name=node.name, args=node.args, + star_arg=node.star_arg, starstar_arg=node.starstar_arg, + doc=node.doc, decorators=node.decorators, + gbody=gbody, lambda_name=node.lambda_name, + return_type_annotation=node.return_type_annotation) + return coroutine + + def visit_CFuncDefNode(self, node): + self.needs_closure = False + self.visitchildren(node) + node.needs_closure = self.needs_closure + self.needs_closure = True + if node.needs_closure and node.overridable: + error(node.pos, "closures inside cpdef functions not yet supported") + return node + + def visit_LambdaNode(self, node): + self.needs_closure = False + self.visitchildren(node) + node.needs_closure = self.needs_closure + self.needs_closure = True + return node + + def visit_ClassDefNode(self, node): + self.visitchildren(node) + self.needs_closure = True + return node + + +class CreateClosureClasses(CythonTransform): + # Output closure classes in module scope for all functions + # that really need it. + + def __init__(self, context): + super(CreateClosureClasses, self).__init__(context) + self.path = [] + self.in_lambda = False + + def visit_ModuleNode(self, node): + self.module_scope = node.scope + self.visitchildren(node) + return node + + def find_entries_used_in_closures(self, node): + from_closure = [] + in_closure = [] + for scope in node.local_scope.iter_local_scopes(): + for name, entry in scope.entries.items(): + if not name: + continue + if entry.from_closure: + from_closure.append((name, entry)) + elif entry.in_closure: + in_closure.append((name, entry)) + return from_closure, in_closure + + def create_class_from_scope(self, node, target_module_scope, inner_node=None): + # move local variables into closure + if node.is_generator: + for scope in node.local_scope.iter_local_scopes(): + for entry in scope.entries.values(): + if not (entry.from_closure or entry.is_pyglobal or entry.is_cglobal): + entry.in_closure = True + + from_closure, in_closure = self.find_entries_used_in_closures(node) + in_closure.sort() + + # Now from the beginning + node.needs_closure = False + node.needs_outer_scope = False + + func_scope = node.local_scope + cscope = node.entry.scope + while cscope.is_py_class_scope or cscope.is_c_class_scope: + cscope = cscope.outer_scope + + if not from_closure and (self.path or inner_node): + if not inner_node: + if not node.py_cfunc_node: + raise InternalError("DefNode does not have assignment node") + inner_node = node.py_cfunc_node + inner_node.needs_self_code = False + node.needs_outer_scope = False + + if node.is_generator: + pass + elif not in_closure and not from_closure: + return + elif not in_closure: + func_scope.is_passthrough = True + func_scope.scope_class = cscope.scope_class + node.needs_outer_scope = True + return + + # entry.cname can contain periods (eg. a derived C method of a class). + # We want to use the cname as part of a C struct name, so we replace + # periods with double underscores. + as_name = '%s_%s' % ( + target_module_scope.next_id(Naming.closure_class_prefix), + node.entry.cname.replace('.','__')) + + entry = target_module_scope.declare_c_class( + name=as_name, pos=node.pos, defining=True, + implementing=True) + entry.type.is_final_type = True + + func_scope.scope_class = entry + class_scope = entry.type.scope + class_scope.is_internal = True + class_scope.is_closure_class_scope = True + if node.is_async_def or node.is_generator: + # Generators need their closure intact during cleanup as they resume to handle GeneratorExit + class_scope.directives['no_gc_clear'] = True + if Options.closure_freelist_size: + class_scope.directives['freelist'] = Options.closure_freelist_size + + if from_closure: + assert cscope.is_closure_scope + class_scope.declare_var(pos=node.pos, + name=Naming.outer_scope_cname, + cname=Naming.outer_scope_cname, + type=cscope.scope_class.type, + is_cdef=True) + node.needs_outer_scope = True + for name, entry in in_closure: + closure_entry = class_scope.declare_var( + pos=entry.pos, + name=entry.name if not entry.in_subscope else None, + cname=entry.cname, + type=entry.type, + is_cdef=True) + if entry.is_declared_generic: + closure_entry.is_declared_generic = 1 + node.needs_closure = True + # Do it here because other classes are already checked + target_module_scope.check_c_class(func_scope.scope_class) + + def visit_LambdaNode(self, node): + if not isinstance(node.def_node, Nodes.DefNode): + # fused function, an error has been previously issued + return node + + was_in_lambda = self.in_lambda + self.in_lambda = True + self.create_class_from_scope(node.def_node, self.module_scope, node) + self.visitchildren(node) + self.in_lambda = was_in_lambda + return node + + def visit_FuncDefNode(self, node): + if self.in_lambda: + self.visitchildren(node) + return node + if node.needs_closure or self.path: + self.create_class_from_scope(node, self.module_scope) + self.path.append(node) + self.visitchildren(node) + self.path.pop() + return node + + def visit_GeneratorBodyDefNode(self, node): + self.visitchildren(node) + return node + + def visit_CFuncDefNode(self, node): + if not node.overridable: + return self.visit_FuncDefNode(node) + else: + self.visitchildren(node) + return node + + +class InjectGilHandling(VisitorTransform, SkipDeclarations): + """ + Allow certain Python operations inside of nogil blocks by implicitly acquiring the GIL. + + Must run before the AnalyseDeclarationsTransform to make sure the GILStatNodes get + set up, parallel sections know that the GIL is acquired inside of them, etc. + """ + def __call__(self, root): + self.nogil = False + return super(InjectGilHandling, self).__call__(root) + + # special node handling + + def visit_RaiseStatNode(self, node): + """Allow raising exceptions in nogil sections by wrapping them in a 'with gil' block.""" + if self.nogil: + node = Nodes.GILStatNode(node.pos, state='gil', body=node) + return node + + # further candidates: + # def visit_AssertStatNode(self, node): + # def visit_ReraiseStatNode(self, node): + + # nogil tracking + + def visit_GILStatNode(self, node): + was_nogil = self.nogil + self.nogil = (node.state == 'nogil') + self.visitchildren(node) + self.nogil = was_nogil + return node + + def visit_CFuncDefNode(self, node): + was_nogil = self.nogil + if isinstance(node.declarator, Nodes.CFuncDeclaratorNode): + self.nogil = node.declarator.nogil and not node.declarator.with_gil + self.visitchildren(node) + self.nogil = was_nogil + return node + + def visit_ParallelRangeNode(self, node): + was_nogil = self.nogil + self.nogil = node.nogil + self.visitchildren(node) + self.nogil = was_nogil + return node + + def visit_ExprNode(self, node): + # No special GIL handling inside of expressions for now. + return node + + visit_Node = VisitorTransform.recurse_to_children + + +class GilCheck(VisitorTransform): + """ + Call `node.gil_check(env)` on each node to make sure we hold the + GIL when we need it. Raise an error when on Python operations + inside a `nogil` environment. + + Additionally, raise exceptions for closely nested with gil or with nogil + statements. The latter would abort Python. + """ + + def __call__(self, root): + self.env_stack = [root.scope] + self.nogil = False + + # True for 'cdef func() nogil:' functions, as the GIL may be held while + # calling this function (thus contained 'nogil' blocks may be valid). + self.nogil_declarator_only = False + return super(GilCheck, self).__call__(root) + + def _visit_scoped_children(self, node, gil_state): + was_nogil = self.nogil + outer_attrs = node.outer_attrs + if outer_attrs and len(self.env_stack) > 1: + self.nogil = self.env_stack[-2].nogil + self.visitchildren(node, outer_attrs) + + self.nogil = gil_state + self.visitchildren(node, attrs=None, exclude=outer_attrs) + self.nogil = was_nogil + + def visit_FuncDefNode(self, node): + self.env_stack.append(node.local_scope) + inner_nogil = node.local_scope.nogil + + if inner_nogil: + self.nogil_declarator_only = True + + if inner_nogil and node.nogil_check: + node.nogil_check(node.local_scope) + + self._visit_scoped_children(node, inner_nogil) + + # This cannot be nested, so it doesn't need backup/restore + self.nogil_declarator_only = False + + self.env_stack.pop() + return node + + def visit_GILStatNode(self, node): + if self.nogil and node.nogil_check: + node.nogil_check() + + was_nogil = self.nogil + is_nogil = (node.state == 'nogil') + + if was_nogil == is_nogil and not self.nogil_declarator_only: + if not was_nogil: + error(node.pos, "Trying to acquire the GIL while it is " + "already held.") + else: + error(node.pos, "Trying to release the GIL while it was " + "previously released.") + + if isinstance(node.finally_clause, Nodes.StatListNode): + # The finally clause of the GILStatNode is a GILExitNode, + # which is wrapped in a StatListNode. Just unpack that. + node.finally_clause, = node.finally_clause.stats + + self._visit_scoped_children(node, is_nogil) + return node + + def visit_ParallelRangeNode(self, node): + if node.nogil: + node.nogil = False + node = Nodes.GILStatNode(node.pos, state='nogil', body=node) + return self.visit_GILStatNode(node) + + if not self.nogil: + error(node.pos, "prange() can only be used without the GIL") + # Forget about any GIL-related errors that may occur in the body + return None + + node.nogil_check(self.env_stack[-1]) + self.visitchildren(node) + return node + + def visit_ParallelWithBlockNode(self, node): + if not self.nogil: + error(node.pos, "The parallel section may only be used without " + "the GIL") + return None + + if node.nogil_check: + # It does not currently implement this, but test for it anyway to + # avoid potential future surprises + node.nogil_check(self.env_stack[-1]) + + self.visitchildren(node) + return node + + def visit_TryFinallyStatNode(self, node): + """ + Take care of try/finally statements in nogil code sections. + """ + if not self.nogil or isinstance(node, Nodes.GILStatNode): + return self.visit_Node(node) + + node.nogil_check = None + node.is_try_finally_in_nogil = True + self.visitchildren(node) + return node + + def visit_Node(self, node): + if self.env_stack and self.nogil and node.nogil_check: + node.nogil_check(self.env_stack[-1]) + if node.outer_attrs: + self._visit_scoped_children(node, self.nogil) + else: + self.visitchildren(node) + if self.nogil: + node.in_nogil_context = True + return node + + +class TransformBuiltinMethods(EnvTransform): + """ + Replace Cython's own cython.* builtins by the corresponding tree nodes. + """ + + def visit_SingleAssignmentNode(self, node): + if node.declaration_only: + return None + else: + self.visitchildren(node) + return node + + def visit_AttributeNode(self, node): + self.visitchildren(node) + return self.visit_cython_attribute(node) + + def visit_NameNode(self, node): + return self.visit_cython_attribute(node) + + def visit_cython_attribute(self, node): + attribute = node.as_cython_attribute() + if attribute: + if attribute == u'compiled': + node = ExprNodes.BoolNode(node.pos, value=True) + elif attribute == u'__version__': + from .. import __version__ as version + node = ExprNodes.StringNode(node.pos, value=EncodedString(version)) + elif attribute == u'NULL': + node = ExprNodes.NullNode(node.pos) + elif attribute in (u'set', u'frozenset', u'staticmethod'): + node = ExprNodes.NameNode(node.pos, name=EncodedString(attribute), + entry=self.current_env().builtin_scope().lookup_here(attribute)) + elif PyrexTypes.parse_basic_type(attribute): + pass + elif self.context.cython_scope.lookup_qualified_name(attribute): + pass + else: + error(node.pos, u"'%s' not a valid cython attribute or is being used incorrectly" % attribute) + return node + + def visit_ExecStatNode(self, node): + lenv = self.current_env() + self.visitchildren(node) + if len(node.args) == 1: + node.args.append(ExprNodes.GlobalsExprNode(node.pos)) + if not lenv.is_module_scope: + node.args.append( + ExprNodes.LocalsExprNode( + node.pos, self.current_scope_node(), lenv)) + return node + + def _inject_locals(self, node, func_name): + # locals()/dir()/vars() builtins + lenv = self.current_env() + entry = lenv.lookup_here(func_name) + if entry: + # not the builtin + return node + pos = node.pos + if func_name in ('locals', 'vars'): + if func_name == 'locals' and len(node.args) > 0: + error(self.pos, "Builtin 'locals()' called with wrong number of args, expected 0, got %d" + % len(node.args)) + return node + elif func_name == 'vars': + if len(node.args) > 1: + error(self.pos, "Builtin 'vars()' called with wrong number of args, expected 0-1, got %d" + % len(node.args)) + if len(node.args) > 0: + return node # nothing to do + return ExprNodes.LocalsExprNode(pos, self.current_scope_node(), lenv) + else: # dir() + if len(node.args) > 1: + error(self.pos, "Builtin 'dir()' called with wrong number of args, expected 0-1, got %d" + % len(node.args)) + if len(node.args) > 0: + # optimised in Builtin.py + return node + if lenv.is_py_class_scope or lenv.is_module_scope: + if lenv.is_py_class_scope: + pyclass = self.current_scope_node() + locals_dict = ExprNodes.CloneNode(pyclass.dict) + else: + locals_dict = ExprNodes.GlobalsExprNode(pos) + return ExprNodes.SortedDictKeysNode(locals_dict) + local_names = sorted(var.name for var in lenv.entries.values() if var.name) + items = [ExprNodes.IdentifierStringNode(pos, value=var) + for var in local_names] + return ExprNodes.ListNode(pos, args=items) + + def visit_PrimaryCmpNode(self, node): + # special case: for in/not-in test, we do not need to sort locals() + self.visitchildren(node) + if node.operator in 'not_in': # in/not_in + if isinstance(node.operand2, ExprNodes.SortedDictKeysNode): + arg = node.operand2.arg + if isinstance(arg, ExprNodes.NoneCheckNode): + arg = arg.arg + node.operand2 = arg + return node + + def visit_CascadedCmpNode(self, node): + return self.visit_PrimaryCmpNode(node) + + def _inject_eval(self, node, func_name): + lenv = self.current_env() + entry = lenv.lookup_here(func_name) + if entry or len(node.args) != 1: + return node + # Inject globals and locals + node.args.append(ExprNodes.GlobalsExprNode(node.pos)) + if not lenv.is_module_scope: + node.args.append( + ExprNodes.LocalsExprNode( + node.pos, self.current_scope_node(), lenv)) + return node + + def _inject_super(self, node, func_name): + lenv = self.current_env() + entry = lenv.lookup_here(func_name) + if entry or node.args: + return node + # Inject no-args super + def_node = self.current_scope_node() + if (not isinstance(def_node, Nodes.DefNode) or not def_node.args or + len(self.env_stack) < 2): + return node + class_node, class_scope = self.env_stack[-2] + if class_scope.is_py_class_scope: + def_node.requires_classobj = True + class_node.class_cell.is_active = True + node.args = [ + ExprNodes.ClassCellNode( + node.pos, is_generator=def_node.is_generator), + ExprNodes.NameNode(node.pos, name=def_node.args[0].name) + ] + elif class_scope.is_c_class_scope: + node.args = [ + ExprNodes.NameNode( + node.pos, name=class_node.scope.name, + entry=class_node.entry), + ExprNodes.NameNode(node.pos, name=def_node.args[0].name) + ] + return node + + def visit_SimpleCallNode(self, node): + # cython.foo + function = node.function.as_cython_attribute() + if function: + if function in InterpretCompilerDirectives.unop_method_nodes: + if len(node.args) != 1: + error(node.function.pos, u"%s() takes exactly one argument" % function) + else: + node = InterpretCompilerDirectives.unop_method_nodes[function]( + node.function.pos, operand=node.args[0]) + elif function in InterpretCompilerDirectives.binop_method_nodes: + if len(node.args) != 2: + error(node.function.pos, u"%s() takes exactly two arguments" % function) + else: + node = InterpretCompilerDirectives.binop_method_nodes[function]( + node.function.pos, operand1=node.args[0], operand2=node.args[1]) + elif function == u'cast': + if len(node.args) != 2: + error(node.function.pos, + u"cast() takes exactly two arguments and an optional typecheck keyword") + else: + type = node.args[0].analyse_as_type(self.current_env()) + if type: + node = ExprNodes.TypecastNode( + node.function.pos, type=type, operand=node.args[1], typecheck=False) + else: + error(node.args[0].pos, "Not a type") + elif function == u'sizeof': + if len(node.args) != 1: + error(node.function.pos, u"sizeof() takes exactly one argument") + else: + type = node.args[0].analyse_as_type(self.current_env()) + if type: + node = ExprNodes.SizeofTypeNode(node.function.pos, arg_type=type) + else: + node = ExprNodes.SizeofVarNode(node.function.pos, operand=node.args[0]) + elif function == 'cmod': + if len(node.args) != 2: + error(node.function.pos, u"cmod() takes exactly two arguments") + else: + node = ExprNodes.binop_node(node.function.pos, '%', node.args[0], node.args[1]) + node.cdivision = True + elif function == 'cdiv': + if len(node.args) != 2: + error(node.function.pos, u"cdiv() takes exactly two arguments") + else: + node = ExprNodes.binop_node(node.function.pos, '/', node.args[0], node.args[1]) + node.cdivision = True + elif function == u'set': + node.function = ExprNodes.NameNode(node.pos, name=EncodedString('set')) + elif function == u'staticmethod': + node.function = ExprNodes.NameNode(node.pos, name=EncodedString('staticmethod')) + elif self.context.cython_scope.lookup_qualified_name(function): + pass + else: + error(node.function.pos, + u"'%s' not a valid cython language construct" % function) + + self.visitchildren(node) + + if isinstance(node, ExprNodes.SimpleCallNode) and node.function.is_name: + func_name = node.function.name + if func_name in ('dir', 'locals', 'vars'): + return self._inject_locals(node, func_name) + if func_name == 'eval': + return self._inject_eval(node, func_name) + if func_name == 'super': + return self._inject_super(node, func_name) + return node + + def visit_GeneralCallNode(self, node): + function = node.function.as_cython_attribute() + if function == u'cast': + # NOTE: assuming simple tuple/dict nodes for positional_args and keyword_args + args = node.positional_args.args + kwargs = node.keyword_args.compile_time_value(None) + if (len(args) != 2 or len(kwargs) > 1 or + (len(kwargs) == 1 and 'typecheck' not in kwargs)): + error(node.function.pos, + u"cast() takes exactly two arguments and an optional typecheck keyword") + else: + type = args[0].analyse_as_type(self.current_env()) + if type: + typecheck = kwargs.get('typecheck', False) + node = ExprNodes.TypecastNode( + node.function.pos, type=type, operand=args[1], typecheck=typecheck) + else: + error(args[0].pos, "Not a type") + + self.visitchildren(node) + return node + + +class ReplaceFusedTypeChecks(VisitorTransform): + """ + This is not a transform in the pipeline. It is invoked on the specific + versions of a cdef function with fused argument types. It filters out any + type branches that don't match. e.g. + + if fused_t is mytype: + ... + elif fused_t in other_fused_type: + ... + """ + def __init__(self, local_scope): + super(ReplaceFusedTypeChecks, self).__init__() + self.local_scope = local_scope + # defer the import until now to avoid circular import time dependencies + from .Optimize import ConstantFolding + self.transform = ConstantFolding(reevaluate=True) + + def visit_IfStatNode(self, node): + """ + Filters out any if clauses with false compile time type check + expression. + """ + self.visitchildren(node) + return self.transform(node) + + def visit_PrimaryCmpNode(self, node): + with Errors.local_errors(ignore=True): + type1 = node.operand1.analyse_as_type(self.local_scope) + type2 = node.operand2.analyse_as_type(self.local_scope) + + if type1 and type2: + false_node = ExprNodes.BoolNode(node.pos, value=False) + true_node = ExprNodes.BoolNode(node.pos, value=True) + + type1 = self.specialize_type(type1, node.operand1.pos) + op = node.operator + + if op in ('is', 'is_not', '==', '!='): + type2 = self.specialize_type(type2, node.operand2.pos) + + is_same = type1.same_as(type2) + eq = op in ('is', '==') + + if (is_same and eq) or (not is_same and not eq): + return true_node + + elif op in ('in', 'not_in'): + # We have to do an instance check directly, as operand2 + # needs to be a fused type and not a type with a subtype + # that is fused. First unpack the typedef + if isinstance(type2, PyrexTypes.CTypedefType): + type2 = type2.typedef_base_type + + if type1.is_fused: + error(node.operand1.pos, "Type is fused") + elif not type2.is_fused: + error(node.operand2.pos, + "Can only use 'in' or 'not in' on a fused type") + else: + types = PyrexTypes.get_specialized_types(type2) + + for specialized_type in types: + if type1.same_as(specialized_type): + if op == 'in': + return true_node + else: + return false_node + + if op == 'not_in': + return true_node + + return false_node + + return node + + def specialize_type(self, type, pos): + try: + return type.specialize(self.local_scope.fused_to_specific) + except KeyError: + error(pos, "Type is not specific") + return type + + def visit_Node(self, node): + self.visitchildren(node) + return node + + +class DebugTransform(CythonTransform): + """ + Write debug information for this Cython module. + """ + + def __init__(self, context, options, result): + super(DebugTransform, self).__init__(context) + self.visited = set() + # our treebuilder and debug output writer + # (see Cython.Debugger.debug_output.CythonDebugWriter) + self.tb = self.context.gdb_debug_outputwriter + #self.c_output_file = options.output_file + self.c_output_file = result.c_file + + # Closure support, basically treat nested functions as if the AST were + # never nested + self.nested_funcdefs = [] + + # tells visit_NameNode whether it should register step-into functions + self.register_stepinto = False + + def visit_ModuleNode(self, node): + self.tb.module_name = node.full_module_name + attrs = dict( + module_name=node.full_module_name, + filename=node.pos[0].filename, + c_filename=self.c_output_file) + + self.tb.start('Module', attrs) + + # serialize functions + self.tb.start('Functions') + # First, serialize functions normally... + self.visitchildren(node) + + # ... then, serialize nested functions + for nested_funcdef in self.nested_funcdefs: + self.visit_FuncDefNode(nested_funcdef) + + self.register_stepinto = True + self.serialize_modulenode_as_function(node) + self.register_stepinto = False + self.tb.end('Functions') + + # 2.3 compatibility. Serialize global variables + self.tb.start('Globals') + entries = {} + + for k, v in node.scope.entries.items(): + if (v.qualified_name not in self.visited and not + v.name.startswith('__pyx_') and not + v.type.is_cfunction and not + v.type.is_extension_type): + entries[k]= v + + self.serialize_local_variables(entries) + self.tb.end('Globals') + # self.tb.end('Module') # end Module after the line number mapping in + # Cython.Compiler.ModuleNode.ModuleNode._serialize_lineno_map + return node + + def visit_FuncDefNode(self, node): + self.visited.add(node.local_scope.qualified_name) + + if getattr(node, 'is_wrapper', False): + return node + + if self.register_stepinto: + self.nested_funcdefs.append(node) + return node + + # node.entry.visibility = 'extern' + if node.py_func is None: + pf_cname = '' + else: + pf_cname = node.py_func.entry.func_cname + + attrs = dict( + name=node.entry.name or getattr(node, 'name', '<unknown>'), + cname=node.entry.func_cname, + pf_cname=pf_cname, + qualified_name=node.local_scope.qualified_name, + lineno=str(node.pos[1])) + + self.tb.start('Function', attrs=attrs) + + self.tb.start('Locals') + self.serialize_local_variables(node.local_scope.entries) + self.tb.end('Locals') + + self.tb.start('Arguments') + for arg in node.local_scope.arg_entries: + self.tb.start(arg.name) + self.tb.end(arg.name) + self.tb.end('Arguments') + + self.tb.start('StepIntoFunctions') + self.register_stepinto = True + self.visitchildren(node) + self.register_stepinto = False + self.tb.end('StepIntoFunctions') + self.tb.end('Function') + + return node + + def visit_NameNode(self, node): + if (self.register_stepinto and + node.type is not None and + node.type.is_cfunction and + getattr(node, 'is_called', False) and + node.entry.func_cname is not None): + # don't check node.entry.in_cinclude, as 'cdef extern: ...' + # declared functions are not 'in_cinclude'. + # This means we will list called 'cdef' functions as + # "step into functions", but this is not an issue as they will be + # recognized as Cython functions anyway. + attrs = dict(name=node.entry.func_cname) + self.tb.start('StepIntoFunction', attrs=attrs) + self.tb.end('StepIntoFunction') + + self.visitchildren(node) + return node + + def serialize_modulenode_as_function(self, node): + """ + Serialize the module-level code as a function so the debugger will know + it's a "relevant frame" and it will know where to set the breakpoint + for 'break modulename'. + """ + name = node.full_module_name.rpartition('.')[-1] + + cname_py2 = 'init' + name + cname_py3 = 'PyInit_' + name + + py2_attrs = dict( + name=name, + cname=cname_py2, + pf_cname='', + # Ignore the qualified_name, breakpoints should be set using + # `cy break modulename:lineno` for module-level breakpoints. + qualified_name='', + lineno='1', + is_initmodule_function="True", + ) + + py3_attrs = dict(py2_attrs, cname=cname_py3) + + self._serialize_modulenode_as_function(node, py2_attrs) + self._serialize_modulenode_as_function(node, py3_attrs) + + def _serialize_modulenode_as_function(self, node, attrs): + self.tb.start('Function', attrs=attrs) + + self.tb.start('Locals') + self.serialize_local_variables(node.scope.entries) + self.tb.end('Locals') + + self.tb.start('Arguments') + self.tb.end('Arguments') + + self.tb.start('StepIntoFunctions') + self.register_stepinto = True + self.visitchildren(node) + self.register_stepinto = False + self.tb.end('StepIntoFunctions') + + self.tb.end('Function') + + def serialize_local_variables(self, entries): + for entry in entries.values(): + if not entry.cname: + # not a local variable + continue + if entry.type.is_pyobject: + vartype = 'PythonObject' + else: + vartype = 'CObject' + + if entry.from_closure: + # We're dealing with a closure where a variable from an outer + # scope is accessed, get it from the scope object. + cname = '%s->%s' % (Naming.cur_scope_cname, + entry.outer_entry.cname) + + qname = '%s.%s.%s' % (entry.scope.outer_scope.qualified_name, + entry.scope.name, + entry.name) + elif entry.in_closure: + cname = '%s->%s' % (Naming.cur_scope_cname, + entry.cname) + qname = entry.qualified_name + else: + cname = entry.cname + qname = entry.qualified_name + + if not entry.pos: + # this happens for variables that are not in the user's code, + # e.g. for the global __builtins__, __doc__, etc. We can just + # set the lineno to 0 for those. + lineno = '0' + else: + lineno = str(entry.pos[1]) + + attrs = dict( + name=entry.name, + cname=cname, + qualified_name=qname, + type=vartype, + lineno=lineno) + + self.tb.start('LocalVar', attrs) + self.tb.end('LocalVar') diff --git a/contrib/tools/cython/Cython/Compiler/Parsing.pxd b/contrib/tools/cython/Cython/Compiler/Parsing.pxd new file mode 100644 index 00000000000..25453b39aba --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Parsing.pxd @@ -0,0 +1,199 @@ +# We declare all of these here to type the first argument. + +from __future__ import absolute_import + +cimport cython +from .Scanning cimport PyrexScanner + +ctypedef object (*p_sub_expr_func)(PyrexScanner obj) + +# entry points + +cpdef p_module(PyrexScanner s, pxd, full_module_name, ctx=*) +cpdef p_code(PyrexScanner s, level= *, ctx=*) + +# internal parser states + +cdef p_ident(PyrexScanner s, message =*) +cdef p_ident_list(PyrexScanner s) + +cdef tuple p_binop_operator(PyrexScanner s) +cdef p_binop_expr(PyrexScanner s, ops, p_sub_expr_func p_sub_expr) +cdef p_lambdef(PyrexScanner s, bint allow_conditional=*) +cdef p_lambdef_nocond(PyrexScanner s) +cdef p_test(PyrexScanner s) +cdef p_test_nocond(PyrexScanner s) +cdef p_or_test(PyrexScanner s) +cdef p_rassoc_binop_expr(PyrexScanner s, ops, p_sub_expr_func p_subexpr) +cdef p_and_test(PyrexScanner s) +cdef p_not_test(PyrexScanner s) +cdef p_comparison(PyrexScanner s) +cdef p_test_or_starred_expr(PyrexScanner s) +cdef p_starred_expr(PyrexScanner s) +cdef p_cascaded_cmp(PyrexScanner s) +cdef p_cmp_op(PyrexScanner s) +cdef p_bit_expr(PyrexScanner s) +cdef p_xor_expr(PyrexScanner s) +cdef p_and_expr(PyrexScanner s) +cdef p_shift_expr(PyrexScanner s) +cdef p_arith_expr(PyrexScanner s) +cdef p_term(PyrexScanner s) +cdef p_factor(PyrexScanner s) +cdef _p_factor(PyrexScanner s) +cdef p_typecast(PyrexScanner s) +cdef p_sizeof(PyrexScanner s) +cdef p_yield_expression(PyrexScanner s) +cdef p_yield_statement(PyrexScanner s) +cdef p_async_statement(PyrexScanner s, ctx, decorators) +cdef p_power(PyrexScanner s) +cdef p_new_expr(PyrexScanner s) +cdef p_trailer(PyrexScanner s, node1) +cdef p_call_parse_args(PyrexScanner s, bint allow_genexp = *) +cdef p_call_build_packed_args(pos, positional_args, keyword_args) +cdef p_call(PyrexScanner s, function) +cdef p_index(PyrexScanner s, base) +cdef tuple p_subscript_list(PyrexScanner s) +cdef p_subscript(PyrexScanner s) +cdef p_slice_element(PyrexScanner s, follow_set) +cdef expect_ellipsis(PyrexScanner s) +cdef make_slice_nodes(pos, subscripts) +cpdef make_slice_node(pos, start, stop = *, step = *) +cdef p_atom(PyrexScanner s) +@cython.locals(value=unicode) +cdef p_int_literal(PyrexScanner s) +cdef p_name(PyrexScanner s, name) +cdef wrap_compile_time_constant(pos, value) +cdef p_cat_string_literal(PyrexScanner s) +cdef p_opt_string_literal(PyrexScanner s, required_type=*) +cdef bint check_for_non_ascii_characters(unicode string) +@cython.locals(systr=unicode, is_python3_source=bint, is_raw=bint) +cdef p_string_literal(PyrexScanner s, kind_override=*) +cdef _append_escape_sequence(kind, builder, unicode escape_sequence, PyrexScanner s) +cdef tuple _f_string_error_pos(pos, string, Py_ssize_t i) +@cython.locals(i=Py_ssize_t, size=Py_ssize_t, c=Py_UCS4, next_start=Py_ssize_t) +cdef list p_f_string(PyrexScanner s, unicode_value, pos, bint is_raw) +@cython.locals(i=Py_ssize_t, size=Py_ssize_t, c=Py_UCS4, quote_char=Py_UCS4, NO_CHAR=Py_UCS4) +cdef tuple p_f_string_expr(PyrexScanner s, unicode_value, pos, Py_ssize_t starting_index, bint is_raw) +cdef p_list_maker(PyrexScanner s) +cdef p_comp_iter(PyrexScanner s, body) +cdef p_comp_for(PyrexScanner s, body) +cdef p_comp_if(PyrexScanner s, body) +cdef p_dict_or_set_maker(PyrexScanner s) +cdef p_backquote_expr(PyrexScanner s) +cdef p_simple_expr_list(PyrexScanner s, expr=*) +cdef p_test_or_starred_expr_list(PyrexScanner s, expr=*) +cdef p_testlist(PyrexScanner s) +cdef p_testlist_star_expr(PyrexScanner s) +cdef p_testlist_comp(PyrexScanner s) +cdef p_genexp(PyrexScanner s, expr) + +#------------------------------------------------------- +# +# Statements +# +#------------------------------------------------------- + +cdef p_global_statement(PyrexScanner s) +cdef p_nonlocal_statement(PyrexScanner s) +cdef p_expression_or_assignment(PyrexScanner s) +cdef p_print_statement(PyrexScanner s) +cdef p_exec_statement(PyrexScanner s) +cdef p_del_statement(PyrexScanner s) +cdef p_pass_statement(PyrexScanner s, bint with_newline = *) +cdef p_break_statement(PyrexScanner s) +cdef p_continue_statement(PyrexScanner s) +cdef p_return_statement(PyrexScanner s) +cdef p_raise_statement(PyrexScanner s) +cdef p_import_statement(PyrexScanner s) +cdef p_from_import_statement(PyrexScanner s, bint first_statement = *) +cdef p_imported_name(PyrexScanner s, bint is_cimport) +cdef p_dotted_name(PyrexScanner s, bint as_allowed) +cdef p_as_name(PyrexScanner s) +cdef p_assert_statement(PyrexScanner s) +cdef p_if_statement(PyrexScanner s) +cdef p_if_clause(PyrexScanner s) +cdef p_else_clause(PyrexScanner s) +cdef p_while_statement(PyrexScanner s) +cdef p_for_statement(PyrexScanner s, bint is_async=*) +cdef dict p_for_bounds(PyrexScanner s, bint allow_testlist=*, bint is_async=*) +cdef p_for_from_relation(PyrexScanner s) +cdef p_for_from_step(PyrexScanner s) +cdef p_target(PyrexScanner s, terminator) +cdef p_for_target(PyrexScanner s) +cdef p_for_iterator(PyrexScanner s, bint allow_testlist=*, bint is_async=*) +cdef p_try_statement(PyrexScanner s) +cdef p_except_clause(PyrexScanner s) +cdef p_include_statement(PyrexScanner s, ctx) +cdef p_with_statement(PyrexScanner s) +cdef p_with_items(PyrexScanner s, bint is_async=*) +cdef p_with_template(PyrexScanner s) +cdef p_simple_statement(PyrexScanner s, bint first_statement = *) +cdef p_simple_statement_list(PyrexScanner s, ctx, bint first_statement = *) +cdef p_compile_time_expr(PyrexScanner s) +cdef p_DEF_statement(PyrexScanner s) +cdef p_IF_statement(PyrexScanner s, ctx) +cdef p_statement(PyrexScanner s, ctx, bint first_statement = *) +cdef p_statement_list(PyrexScanner s, ctx, bint first_statement = *) +cdef p_suite(PyrexScanner s, ctx = *) +cdef tuple p_suite_with_docstring(PyrexScanner s, ctx, bint with_doc_only=*) +cdef tuple _extract_docstring(node) +cdef p_positional_and_keyword_args(PyrexScanner s, end_sy_set, templates = *) + +cpdef p_c_base_type(PyrexScanner s, bint self_flag = *, bint nonempty = *, templates = *) +cdef p_calling_convention(PyrexScanner s) +cdef p_c_complex_base_type(PyrexScanner s, templates = *) +cdef p_c_simple_base_type(PyrexScanner s, bint self_flag, bint nonempty, templates = *) +cdef p_buffer_or_template(PyrexScanner s, base_type_node, templates) +cdef p_bracketed_base_type(PyrexScanner s, base_type_node, nonempty, empty) +cdef is_memoryviewslice_access(PyrexScanner s) +cdef p_memoryviewslice_access(PyrexScanner s, base_type_node) +cdef bint looking_at_name(PyrexScanner s) except -2 +cdef object looking_at_expr(PyrexScanner s)# except -2 +cdef bint looking_at_base_type(PyrexScanner s) except -2 +cdef bint looking_at_dotted_name(PyrexScanner s) except -2 +cdef bint looking_at_call(PyrexScanner s) except -2 +cdef p_sign_and_longness(PyrexScanner s) +cdef p_opt_cname(PyrexScanner s) +cpdef p_c_declarator(PyrexScanner s, ctx = *, bint empty = *, bint is_type = *, bint cmethod_flag = *, + bint assignable = *, bint nonempty = *, + bint calling_convention_allowed = *) +cdef p_c_array_declarator(PyrexScanner s, base) +cdef p_c_func_declarator(PyrexScanner s, pos, ctx, base, bint cmethod_flag) +cdef p_c_simple_declarator(PyrexScanner s, ctx, bint empty, bint is_type, bint cmethod_flag, + bint assignable, bint nonempty) +cdef p_nogil(PyrexScanner s) +cdef p_with_gil(PyrexScanner s) +cdef p_exception_value_clause(PyrexScanner s) +cpdef p_c_arg_list(PyrexScanner s, ctx = *, bint in_pyfunc = *, bint cmethod_flag = *, + bint nonempty_declarators = *, bint kw_only = *, bint annotated = *) +cdef p_optional_ellipsis(PyrexScanner s) +cdef p_c_arg_decl(PyrexScanner s, ctx, in_pyfunc, bint cmethod_flag = *, bint nonempty = *, bint kw_only = *, bint annotated = *) +cdef p_api(PyrexScanner s) +cdef p_cdef_statement(PyrexScanner s, ctx) +cdef p_cdef_block(PyrexScanner s, ctx) +cdef p_cdef_extern_block(PyrexScanner s, pos, ctx) +cdef p_c_enum_definition(PyrexScanner s, pos, ctx) +cdef p_c_enum_line(PyrexScanner s, ctx, list items) +cdef p_c_enum_item(PyrexScanner s, ctx, list items) +cdef p_c_struct_or_union_definition(PyrexScanner s, pos, ctx) +cdef p_fused_definition(PyrexScanner s, pos, ctx) +cdef p_struct_enum(PyrexScanner s, pos, ctx) +cdef p_visibility(PyrexScanner s, prev_visibility) +cdef p_c_modifiers(PyrexScanner s) +cdef p_c_func_or_var_declaration(PyrexScanner s, pos, ctx) +cdef p_ctypedef_statement(PyrexScanner s, ctx) +cdef p_decorators(PyrexScanner s) +cdef _reject_cdef_modifier_in_py(PyrexScanner s, name) +cdef p_def_statement(PyrexScanner s, list decorators=*, bint is_async_def=*) +cdef p_varargslist(PyrexScanner s, terminator=*, bint annotated = *) +cdef p_py_arg_decl(PyrexScanner s, bint annotated = *) +cdef p_class_statement(PyrexScanner s, decorators) +cdef p_c_class_definition(PyrexScanner s, pos, ctx) +cdef tuple p_c_class_options(PyrexScanner s) +cdef p_property_decl(PyrexScanner s) +cdef p_doc_string(PyrexScanner s) +cdef p_ignorable_statement(PyrexScanner s) +cdef dict p_compiler_directive_comments(PyrexScanner s) +cdef p_template_definition(PyrexScanner s) +cdef p_cpp_class_definition(PyrexScanner s, pos, ctx) +cdef p_cpp_class_attribute(PyrexScanner s, ctx) diff --git a/contrib/tools/cython/Cython/Compiler/Parsing.py b/contrib/tools/cython/Cython/Compiler/Parsing.py new file mode 100644 index 00000000000..20dbc9bbf95 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Parsing.py @@ -0,0 +1,3860 @@ +# cython: auto_cpdef=True, infer_types=True, language_level=3, py2_import=True +# +# Parser +# + +from __future__ import absolute_import + +# This should be done automatically +import cython +cython.declare(Nodes=object, ExprNodes=object, EncodedString=object, + bytes_literal=object, StringEncoding=object, + FileSourceDescriptor=object, lookup_unicodechar=object, unicode_category=object, + Future=object, Options=object, error=object, warning=object, + Builtin=object, ModuleNode=object, Utils=object, _unicode=object, _bytes=object, + re=object, sys=object, _parse_escape_sequences=object, _parse_escape_sequences_raw=object, + partial=object, reduce=object, _IS_PY3=cython.bint, _IS_2BYTE_UNICODE=cython.bint, + _CDEF_MODIFIERS=tuple) + +from io import StringIO +import re +import sys +from unicodedata import lookup as lookup_unicodechar, category as unicode_category +from functools import partial, reduce + +from .Scanning import PyrexScanner, FileSourceDescriptor, StringSourceDescriptor +from . import Nodes +from . import ExprNodes +from . import Builtin +from . import StringEncoding +from .StringEncoding import EncodedString, bytes_literal, _unicode, _bytes +from .ModuleNode import ModuleNode +from .Errors import error, warning +from .. import Utils +from . import Future +from . import Options + +_IS_PY3 = sys.version_info[0] >= 3 +_IS_2BYTE_UNICODE = sys.maxunicode == 0xffff +_CDEF_MODIFIERS = ('inline', 'nogil', 'api') + + +class Ctx(object): + # Parsing context + level = 'other' + visibility = 'private' + cdef_flag = 0 + typedef_flag = 0 + api = 0 + overridable = 0 + nogil = 0 + namespace = None + templates = None + allow_struct_enum_decorator = False + + def __init__(self, **kwds): + self.__dict__.update(kwds) + + def __call__(self, **kwds): + ctx = Ctx() + d = ctx.__dict__ + d.update(self.__dict__) + d.update(kwds) + return ctx + + +def p_ident(s, message="Expected an identifier"): + if s.sy == 'IDENT': + name = s.systring + s.next() + return name + else: + s.error(message) + +def p_ident_list(s): + names = [] + while s.sy == 'IDENT': + names.append(s.systring) + s.next() + if s.sy != ',': + break + s.next() + return names + +#------------------------------------------ +# +# Expressions +# +#------------------------------------------ + +def p_binop_operator(s): + pos = s.position() + op = s.sy + s.next() + return op, pos + +def p_binop_expr(s, ops, p_sub_expr): + n1 = p_sub_expr(s) + while s.sy in ops: + op, pos = p_binop_operator(s) + n2 = p_sub_expr(s) + n1 = ExprNodes.binop_node(pos, op, n1, n2) + if op == '/': + if Future.division in s.context.future_directives: + n1.truedivision = True + else: + n1.truedivision = None # unknown + return n1 + +#lambdef: 'lambda' [varargslist] ':' test + +def p_lambdef(s, allow_conditional=True): + # s.sy == 'lambda' + pos = s.position() + s.next() + if s.sy == ':': + args = [] + star_arg = starstar_arg = None + else: + args, star_arg, starstar_arg = p_varargslist( + s, terminator=':', annotated=False) + s.expect(':') + if allow_conditional: + expr = p_test(s) + else: + expr = p_test_nocond(s) + return ExprNodes.LambdaNode( + pos, args = args, + star_arg = star_arg, starstar_arg = starstar_arg, + result_expr = expr) + +#lambdef_nocond: 'lambda' [varargslist] ':' test_nocond + +def p_lambdef_nocond(s): + return p_lambdef(s, allow_conditional=False) + +#test: or_test ['if' or_test 'else' test] | lambdef + +def p_test(s): + if s.sy == 'lambda': + return p_lambdef(s) + pos = s.position() + expr = p_or_test(s) + if s.sy == 'if': + s.next() + test = p_or_test(s) + s.expect('else') + other = p_test(s) + return ExprNodes.CondExprNode(pos, test=test, true_val=expr, false_val=other) + else: + return expr + +#test_nocond: or_test | lambdef_nocond + +def p_test_nocond(s): + if s.sy == 'lambda': + return p_lambdef_nocond(s) + else: + return p_or_test(s) + +#or_test: and_test ('or' and_test)* + +def p_or_test(s): + return p_rassoc_binop_expr(s, ('or',), p_and_test) + +def p_rassoc_binop_expr(s, ops, p_subexpr): + n1 = p_subexpr(s) + if s.sy in ops: + pos = s.position() + op = s.sy + s.next() + n2 = p_rassoc_binop_expr(s, ops, p_subexpr) + n1 = ExprNodes.binop_node(pos, op, n1, n2) + return n1 + +#and_test: not_test ('and' not_test)* + +def p_and_test(s): + #return p_binop_expr(s, ('and',), p_not_test) + return p_rassoc_binop_expr(s, ('and',), p_not_test) + +#not_test: 'not' not_test | comparison + +def p_not_test(s): + if s.sy == 'not': + pos = s.position() + s.next() + return ExprNodes.NotNode(pos, operand = p_not_test(s)) + else: + return p_comparison(s) + +#comparison: expr (comp_op expr)* +#comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' + +def p_comparison(s): + n1 = p_starred_expr(s) + if s.sy in comparison_ops: + pos = s.position() + op = p_cmp_op(s) + n2 = p_starred_expr(s) + n1 = ExprNodes.PrimaryCmpNode(pos, + operator = op, operand1 = n1, operand2 = n2) + if s.sy in comparison_ops: + n1.cascade = p_cascaded_cmp(s) + return n1 + +def p_test_or_starred_expr(s): + if s.sy == '*': + return p_starred_expr(s) + else: + return p_test(s) + +def p_starred_expr(s): + pos = s.position() + if s.sy == '*': + starred = True + s.next() + else: + starred = False + expr = p_bit_expr(s) + if starred: + expr = ExprNodes.StarredUnpackingNode(pos, expr) + return expr + +def p_cascaded_cmp(s): + pos = s.position() + op = p_cmp_op(s) + n2 = p_starred_expr(s) + result = ExprNodes.CascadedCmpNode(pos, + operator = op, operand2 = n2) + if s.sy in comparison_ops: + result.cascade = p_cascaded_cmp(s) + return result + +def p_cmp_op(s): + if s.sy == 'not': + s.next() + s.expect('in') + op = 'not_in' + elif s.sy == 'is': + s.next() + if s.sy == 'not': + s.next() + op = 'is_not' + else: + op = 'is' + else: + op = s.sy + s.next() + if op == '<>': + op = '!=' + return op + +comparison_ops = cython.declare(set, set([ + '<', '>', '==', '>=', '<=', '<>', '!=', + 'in', 'is', 'not' +])) + +#expr: xor_expr ('|' xor_expr)* + +def p_bit_expr(s): + return p_binop_expr(s, ('|',), p_xor_expr) + +#xor_expr: and_expr ('^' and_expr)* + +def p_xor_expr(s): + return p_binop_expr(s, ('^',), p_and_expr) + +#and_expr: shift_expr ('&' shift_expr)* + +def p_and_expr(s): + return p_binop_expr(s, ('&',), p_shift_expr) + +#shift_expr: arith_expr (('<<'|'>>') arith_expr)* + +def p_shift_expr(s): + return p_binop_expr(s, ('<<', '>>'), p_arith_expr) + +#arith_expr: term (('+'|'-') term)* + +def p_arith_expr(s): + return p_binop_expr(s, ('+', '-'), p_term) + +#term: factor (('*'|'@'|'/'|'%'|'//') factor)* + +def p_term(s): + return p_binop_expr(s, ('*', '@', '/', '%', '//'), p_factor) + +#factor: ('+'|'-'|'~'|'&'|typecast|sizeof) factor | power + +def p_factor(s): + # little indirection for C-ification purposes + return _p_factor(s) + +def _p_factor(s): + sy = s.sy + if sy in ('+', '-', '~'): + op = s.sy + pos = s.position() + s.next() + return ExprNodes.unop_node(pos, op, p_factor(s)) + elif not s.in_python_file: + if sy == '&': + pos = s.position() + s.next() + arg = p_factor(s) + return ExprNodes.AmpersandNode(pos, operand = arg) + elif sy == "<": + return p_typecast(s) + elif sy == 'IDENT' and s.systring == "sizeof": + return p_sizeof(s) + return p_power(s) + +def p_typecast(s): + # s.sy == "<" + pos = s.position() + s.next() + base_type = p_c_base_type(s) + is_memslice = isinstance(base_type, Nodes.MemoryViewSliceTypeNode) + is_template = isinstance(base_type, Nodes.TemplatedTypeNode) + is_const = isinstance(base_type, Nodes.CConstTypeNode) + if (not is_memslice and not is_template and not is_const + and base_type.name is None): + s.error("Unknown type") + declarator = p_c_declarator(s, empty = 1) + if s.sy == '?': + s.next() + typecheck = 1 + else: + typecheck = 0 + s.expect(">") + operand = p_factor(s) + if is_memslice: + return ExprNodes.CythonArrayNode(pos, base_type_node=base_type, + operand=operand) + + return ExprNodes.TypecastNode(pos, + base_type = base_type, + declarator = declarator, + operand = operand, + typecheck = typecheck) + +def p_sizeof(s): + # s.sy == ident "sizeof" + pos = s.position() + s.next() + s.expect('(') + # Here we decide if we are looking at an expression or type + # If it is actually a type, but parsable as an expression, + # we treat it as an expression here. + if looking_at_expr(s): + operand = p_test(s) + node = ExprNodes.SizeofVarNode(pos, operand = operand) + else: + base_type = p_c_base_type(s) + declarator = p_c_declarator(s, empty = 1) + node = ExprNodes.SizeofTypeNode(pos, + base_type = base_type, declarator = declarator) + s.expect(')') + return node + + +def p_yield_expression(s): + # s.sy == "yield" + pos = s.position() + s.next() + is_yield_from = False + if s.sy == 'from': + is_yield_from = True + s.next() + if s.sy != ')' and s.sy not in statement_terminators: + # "yield from" does not support implicit tuples, but "yield" does ("yield 1,2") + arg = p_test(s) if is_yield_from else p_testlist(s) + else: + if is_yield_from: + s.error("'yield from' requires a source argument", + pos=pos, fatal=False) + arg = None + if is_yield_from: + return ExprNodes.YieldFromExprNode(pos, arg=arg) + else: + return ExprNodes.YieldExprNode(pos, arg=arg) + + +def p_yield_statement(s): + # s.sy == "yield" + yield_expr = p_yield_expression(s) + return Nodes.ExprStatNode(yield_expr.pos, expr=yield_expr) + + +def p_async_statement(s, ctx, decorators): + # s.sy >> 'async' ... + if s.sy == 'def': + # 'async def' statements aren't allowed in pxd files + if 'pxd' in ctx.level: + s.error('def statement not allowed here') + s.level = ctx.level + return p_def_statement(s, decorators, is_async_def=True) + elif decorators: + s.error("Decorators can only be followed by functions or classes") + elif s.sy == 'for': + return p_for_statement(s, is_async=True) + elif s.sy == 'with': + s.next() + return p_with_items(s, is_async=True) + else: + s.error("expected one of 'def', 'for', 'with' after 'async'") + + +#power: atom_expr ('**' factor)* +#atom_expr: ['await'] atom trailer* + +def p_power(s): + if s.systring == 'new' and s.peek()[0] == 'IDENT': + return p_new_expr(s) + await_pos = None + if s.sy == 'await': + await_pos = s.position() + s.next() + n1 = p_atom(s) + while s.sy in ('(', '[', '.'): + n1 = p_trailer(s, n1) + if await_pos: + n1 = ExprNodes.AwaitExprNode(await_pos, arg=n1) + if s.sy == '**': + pos = s.position() + s.next() + n2 = p_factor(s) + n1 = ExprNodes.binop_node(pos, '**', n1, n2) + return n1 + + +def p_new_expr(s): + # s.systring == 'new'. + pos = s.position() + s.next() + cppclass = p_c_base_type(s) + return p_call(s, ExprNodes.NewExprNode(pos, cppclass = cppclass)) + +#trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME + +def p_trailer(s, node1): + pos = s.position() + if s.sy == '(': + return p_call(s, node1) + elif s.sy == '[': + return p_index(s, node1) + else: # s.sy == '.' + s.next() + name = p_ident(s) + return ExprNodes.AttributeNode(pos, + obj=node1, attribute=name) + + +# arglist: argument (',' argument)* [','] +# argument: [test '='] test # Really [keyword '='] test + +# since PEP 448: +# argument: ( test [comp_for] | +# test '=' test | +# '**' expr | +# star_expr ) + +def p_call_parse_args(s, allow_genexp=True): + # s.sy == '(' + pos = s.position() + s.next() + positional_args = [] + keyword_args = [] + starstar_seen = False + last_was_tuple_unpack = False + while s.sy != ')': + if s.sy == '*': + if starstar_seen: + s.error("Non-keyword arg following keyword arg", pos=s.position()) + s.next() + positional_args.append(p_test(s)) + last_was_tuple_unpack = True + elif s.sy == '**': + s.next() + keyword_args.append(p_test(s)) + starstar_seen = True + else: + arg = p_test(s) + if s.sy == '=': + s.next() + if not arg.is_name: + s.error("Expected an identifier before '='", + pos=arg.pos) + encoded_name = s.context.intern_ustring(arg.name) + keyword = ExprNodes.IdentifierStringNode( + arg.pos, value=encoded_name) + arg = p_test(s) + keyword_args.append((keyword, arg)) + else: + if keyword_args: + s.error("Non-keyword arg following keyword arg", pos=arg.pos) + if positional_args and not last_was_tuple_unpack: + positional_args[-1].append(arg) + else: + positional_args.append([arg]) + last_was_tuple_unpack = False + if s.sy != ',': + break + s.next() + + if s.sy in ('for', 'async'): + if not keyword_args and not last_was_tuple_unpack: + if len(positional_args) == 1 and len(positional_args[0]) == 1: + positional_args = [[p_genexp(s, positional_args[0][0])]] + s.expect(')') + return positional_args or [[]], keyword_args + + +def p_call_build_packed_args(pos, positional_args, keyword_args): + keyword_dict = None + + subtuples = [ + ExprNodes.TupleNode(pos, args=arg) if isinstance(arg, list) else ExprNodes.AsTupleNode(pos, arg=arg) + for arg in positional_args + ] + # TODO: implement a faster way to join tuples than creating each one and adding them + arg_tuple = reduce(partial(ExprNodes.binop_node, pos, '+'), subtuples) + + if keyword_args: + kwargs = [] + dict_items = [] + for item in keyword_args: + if isinstance(item, tuple): + key, value = item + dict_items.append(ExprNodes.DictItemNode(pos=key.pos, key=key, value=value)) + elif item.is_dict_literal: + # unpack "**{a:b}" directly + dict_items.extend(item.key_value_pairs) + else: + if dict_items: + kwargs.append(ExprNodes.DictNode( + dict_items[0].pos, key_value_pairs=dict_items, reject_duplicates=True)) + dict_items = [] + kwargs.append(item) + + if dict_items: + kwargs.append(ExprNodes.DictNode( + dict_items[0].pos, key_value_pairs=dict_items, reject_duplicates=True)) + + if kwargs: + if len(kwargs) == 1 and kwargs[0].is_dict_literal: + # only simple keyword arguments found -> one dict + keyword_dict = kwargs[0] + else: + # at least one **kwargs + keyword_dict = ExprNodes.MergedDictNode(pos, keyword_args=kwargs) + + return arg_tuple, keyword_dict + + +def p_call(s, function): + # s.sy == '(' + pos = s.position() + positional_args, keyword_args = p_call_parse_args(s) + + if not keyword_args and len(positional_args) == 1 and isinstance(positional_args[0], list): + return ExprNodes.SimpleCallNode(pos, function=function, args=positional_args[0]) + else: + arg_tuple, keyword_dict = p_call_build_packed_args(pos, positional_args, keyword_args) + return ExprNodes.GeneralCallNode( + pos, function=function, positional_args=arg_tuple, keyword_args=keyword_dict) + + +#lambdef: 'lambda' [varargslist] ':' test + +#subscriptlist: subscript (',' subscript)* [','] + +def p_index(s, base): + # s.sy == '[' + pos = s.position() + s.next() + subscripts, is_single_value = p_subscript_list(s) + if is_single_value and len(subscripts[0]) == 2: + start, stop = subscripts[0] + result = ExprNodes.SliceIndexNode(pos, + base = base, start = start, stop = stop) + else: + indexes = make_slice_nodes(pos, subscripts) + if is_single_value: + index = indexes[0] + else: + index = ExprNodes.TupleNode(pos, args = indexes) + result = ExprNodes.IndexNode(pos, + base = base, index = index) + s.expect(']') + return result + +def p_subscript_list(s): + is_single_value = True + items = [p_subscript(s)] + while s.sy == ',': + is_single_value = False + s.next() + if s.sy == ']': + break + items.append(p_subscript(s)) + return items, is_single_value + +#subscript: '.' '.' '.' | test | [test] ':' [test] [':' [test]] + +def p_subscript(s): + # Parse a subscript and return a list of + # 1, 2 or 3 ExprNodes, depending on how + # many slice elements were encountered. + pos = s.position() + start = p_slice_element(s, (':',)) + if s.sy != ':': + return [start] + s.next() + stop = p_slice_element(s, (':', ',', ']')) + if s.sy != ':': + return [start, stop] + s.next() + step = p_slice_element(s, (':', ',', ']')) + return [start, stop, step] + +def p_slice_element(s, follow_set): + # Simple expression which may be missing iff + # it is followed by something in follow_set. + if s.sy not in follow_set: + return p_test(s) + else: + return None + +def expect_ellipsis(s): + s.expect('.') + s.expect('.') + s.expect('.') + +def make_slice_nodes(pos, subscripts): + # Convert a list of subscripts as returned + # by p_subscript_list into a list of ExprNodes, + # creating SliceNodes for elements with 2 or + # more components. + result = [] + for subscript in subscripts: + if len(subscript) == 1: + result.append(subscript[0]) + else: + result.append(make_slice_node(pos, *subscript)) + return result + +def make_slice_node(pos, start, stop = None, step = None): + if not start: + start = ExprNodes.NoneNode(pos) + if not stop: + stop = ExprNodes.NoneNode(pos) + if not step: + step = ExprNodes.NoneNode(pos) + return ExprNodes.SliceNode(pos, + start = start, stop = stop, step = step) + +#atom: '(' [yield_expr|testlist_comp] ')' | '[' [listmaker] ']' | '{' [dict_or_set_maker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+ + +def p_atom(s): + pos = s.position() + sy = s.sy + if sy == '(': + s.next() + if s.sy == ')': + result = ExprNodes.TupleNode(pos, args = []) + elif s.sy == 'yield': + result = p_yield_expression(s) + else: + result = p_testlist_comp(s) + s.expect(')') + return result + elif sy == '[': + return p_list_maker(s) + elif sy == '{': + return p_dict_or_set_maker(s) + elif sy == '`': + return p_backquote_expr(s) + elif sy == '.': + expect_ellipsis(s) + return ExprNodes.EllipsisNode(pos) + elif sy == 'INT': + return p_int_literal(s) + elif sy == 'FLOAT': + value = s.systring + s.next() + return ExprNodes.FloatNode(pos, value = value) + elif sy == 'IMAG': + value = s.systring[:-1] + s.next() + return ExprNodes.ImagNode(pos, value = value) + elif sy == 'BEGIN_STRING': + kind, bytes_value, unicode_value = p_cat_string_literal(s) + if kind == 'c': + return ExprNodes.CharNode(pos, value = bytes_value) + elif kind == 'u': + return ExprNodes.UnicodeNode(pos, value = unicode_value, bytes_value = bytes_value) + elif kind == 'b': + return ExprNodes.BytesNode(pos, value = bytes_value) + elif kind == 'f': + return ExprNodes.JoinedStrNode(pos, values = unicode_value) + elif kind == '': + return ExprNodes.StringNode(pos, value = bytes_value, unicode_value = unicode_value) + else: + s.error("invalid string kind '%s'" % kind) + elif sy == 'IDENT': + name = s.systring + if name == "None": + result = ExprNodes.NoneNode(pos) + elif name == "True": + result = ExprNodes.BoolNode(pos, value=True) + elif name == "False": + result = ExprNodes.BoolNode(pos, value=False) + elif name == "NULL" and not s.in_python_file: + result = ExprNodes.NullNode(pos) + else: + result = p_name(s, name) + s.next() + return result + else: + s.error("Expected an identifier or literal") + +def p_int_literal(s): + pos = s.position() + value = s.systring + s.next() + unsigned = "" + longness = "" + while value[-1] in u"UuLl": + if value[-1] in u"Ll": + longness += "L" + else: + unsigned += "U" + value = value[:-1] + # '3L' is ambiguous in Py2 but not in Py3. '3U' and '3LL' are + # illegal in Py2 Python files. All suffixes are illegal in Py3 + # Python files. + is_c_literal = None + if unsigned: + is_c_literal = True + elif longness: + if longness == 'LL' or s.context.language_level >= 3: + is_c_literal = True + if s.in_python_file: + if is_c_literal: + error(pos, "illegal integer literal syntax in Python source file") + is_c_literal = False + return ExprNodes.IntNode(pos, + is_c_literal = is_c_literal, + value = value, + unsigned = unsigned, + longness = longness) + + +def p_name(s, name): + pos = s.position() + if not s.compile_time_expr and name in s.compile_time_env: + value = s.compile_time_env.lookup_here(name) + node = wrap_compile_time_constant(pos, value) + if node is not None: + return node + return ExprNodes.NameNode(pos, name=name) + + +def wrap_compile_time_constant(pos, value): + rep = repr(value) + if value is None: + return ExprNodes.NoneNode(pos) + elif value is Ellipsis: + return ExprNodes.EllipsisNode(pos) + elif isinstance(value, bool): + return ExprNodes.BoolNode(pos, value=value) + elif isinstance(value, int): + return ExprNodes.IntNode(pos, value=rep, constant_result=value) + elif isinstance(value, float): + return ExprNodes.FloatNode(pos, value=rep, constant_result=value) + elif isinstance(value, complex): + node = ExprNodes.ImagNode(pos, value=repr(value.imag), constant_result=complex(0.0, value.imag)) + if value.real: + # FIXME: should we care about -0.0 ? + # probably not worth using the '-' operator for negative imag values + node = ExprNodes.binop_node( + pos, '+', ExprNodes.FloatNode(pos, value=repr(value.real), constant_result=value.real), node, + constant_result=value) + return node + elif isinstance(value, _unicode): + return ExprNodes.UnicodeNode(pos, value=EncodedString(value)) + elif isinstance(value, _bytes): + bvalue = bytes_literal(value, 'ascii') # actually: unknown encoding, but BytesLiteral requires one + return ExprNodes.BytesNode(pos, value=bvalue, constant_result=value) + elif isinstance(value, tuple): + args = [wrap_compile_time_constant(pos, arg) + for arg in value] + if None not in args: + return ExprNodes.TupleNode(pos, args=args) + else: + # error already reported + return None + elif not _IS_PY3 and isinstance(value, long): + return ExprNodes.IntNode(pos, value=rep.rstrip('L'), constant_result=value) + error(pos, "Invalid type for compile-time constant: %r (type %s)" + % (value, value.__class__.__name__)) + return None + + +def p_cat_string_literal(s): + # A sequence of one or more adjacent string literals. + # Returns (kind, bytes_value, unicode_value) + # where kind in ('b', 'c', 'u', 'f', '') + pos = s.position() + kind, bytes_value, unicode_value = p_string_literal(s) + if kind == 'c' or s.sy != 'BEGIN_STRING': + return kind, bytes_value, unicode_value + bstrings, ustrings, positions = [bytes_value], [unicode_value], [pos] + bytes_value = unicode_value = None + while s.sy == 'BEGIN_STRING': + pos = s.position() + next_kind, next_bytes_value, next_unicode_value = p_string_literal(s) + if next_kind == 'c': + error(pos, "Cannot concatenate char literal with another string or char literal") + continue + elif next_kind != kind: + # concatenating f strings and normal strings is allowed and leads to an f string + if set([kind, next_kind]) in (set(['f', 'u']), set(['f', ''])): + kind = 'f' + else: + error(pos, "Cannot mix string literals of different types, expected %s'', got %s''" % ( + kind, next_kind)) + continue + bstrings.append(next_bytes_value) + ustrings.append(next_unicode_value) + positions.append(pos) + # join and rewrap the partial literals + if kind in ('b', 'c', '') or kind == 'u' and None not in bstrings: + # Py3 enforced unicode literals are parsed as bytes/unicode combination + bytes_value = bytes_literal(StringEncoding.join_bytes(bstrings), s.source_encoding) + if kind in ('u', ''): + unicode_value = EncodedString(u''.join([u for u in ustrings if u is not None])) + if kind == 'f': + unicode_value = [] + for u, pos in zip(ustrings, positions): + if isinstance(u, list): + unicode_value += u + else: + # non-f-string concatenated into the f-string + unicode_value.append(ExprNodes.UnicodeNode(pos, value=EncodedString(u))) + return kind, bytes_value, unicode_value + + +def p_opt_string_literal(s, required_type='u'): + if s.sy != 'BEGIN_STRING': + return None + pos = s.position() + kind, bytes_value, unicode_value = p_string_literal(s, required_type) + if required_type == 'u': + if kind == 'f': + s.error("f-string not allowed here", pos) + return unicode_value + elif required_type == 'b': + return bytes_value + else: + s.error("internal parser configuration error") + + +def check_for_non_ascii_characters(string): + for c in string: + if c >= u'\x80': + return True + return False + + +def p_string_literal(s, kind_override=None): + # A single string or char literal. Returns (kind, bvalue, uvalue) + # where kind in ('b', 'c', 'u', 'f', ''). The 'bvalue' is the source + # code byte sequence of the string literal, 'uvalue' is the + # decoded Unicode string. Either of the two may be None depending + # on the 'kind' of string, only unprefixed strings have both + # representations. In f-strings, the uvalue is a list of the Unicode + # strings and f-string expressions that make up the f-string. + + # s.sy == 'BEGIN_STRING' + pos = s.position() + is_python3_source = s.context.language_level >= 3 + has_non_ascii_literal_characters = False + string_start_pos = (pos[0], pos[1], pos[2] + len(s.systring)) + kind_string = s.systring.rstrip('"\'').lower() + if len(kind_string) > 1: + if len(set(kind_string)) != len(kind_string): + error(pos, 'Duplicate string prefix character') + if 'b' in kind_string and 'u' in kind_string: + error(pos, 'String prefixes b and u cannot be combined') + if 'b' in kind_string and 'f' in kind_string: + error(pos, 'String prefixes b and f cannot be combined') + if 'u' in kind_string and 'f' in kind_string: + error(pos, 'String prefixes u and f cannot be combined') + + is_raw = 'r' in kind_string + + if 'c' in kind_string: + # this should never happen, since the lexer does not allow combining c + # with other prefix characters + if len(kind_string) != 1: + error(pos, 'Invalid string prefix for character literal') + kind = 'c' + elif 'f' in kind_string: + kind = 'f' # u is ignored + is_raw = True # postpone the escape resolution + elif 'b' in kind_string: + kind = 'b' + elif 'u' in kind_string: + kind = 'u' + else: + kind = '' + + if kind == '' and kind_override is None and Future.unicode_literals in s.context.future_directives: + chars = StringEncoding.StrLiteralBuilder(s.source_encoding) + kind = 'u' + else: + if kind_override is not None and kind_override in 'ub': + kind = kind_override + if kind in ('u', 'f'): # f-strings are scanned exactly like Unicode literals, but are parsed further later + chars = StringEncoding.UnicodeLiteralBuilder() + elif kind == '': + chars = StringEncoding.StrLiteralBuilder(s.source_encoding) + else: + chars = StringEncoding.BytesLiteralBuilder(s.source_encoding) + + while 1: + s.next() + sy = s.sy + systr = s.systring + # print "p_string_literal: sy =", sy, repr(s.systring) ### + if sy == 'CHARS': + chars.append(systr) + if is_python3_source and not has_non_ascii_literal_characters and check_for_non_ascii_characters(systr): + has_non_ascii_literal_characters = True + elif sy == 'ESCAPE': + # in Py2, 'ur' raw unicode strings resolve unicode escapes but nothing else + if is_raw and (is_python3_source or kind != 'u' or systr[1] not in u'Uu'): + chars.append(systr) + if is_python3_source and not has_non_ascii_literal_characters and check_for_non_ascii_characters(systr): + has_non_ascii_literal_characters = True + else: + _append_escape_sequence(kind, chars, systr, s) + elif sy == 'NEWLINE': + chars.append(u'\n') + elif sy == 'END_STRING': + break + elif sy == 'EOF': + s.error("Unclosed string literal", pos=pos) + else: + s.error("Unexpected token %r:%r in string literal" % ( + sy, s.systring)) + + if kind == 'c': + unicode_value = None + bytes_value = chars.getchar() + if len(bytes_value) != 1: + error(pos, u"invalid character literal: %r" % bytes_value) + else: + bytes_value, unicode_value = chars.getstrings() + if (has_non_ascii_literal_characters + and is_python3_source and Future.unicode_literals in s.context.future_directives): + # Python 3 forbids literal non-ASCII characters in byte strings + if kind == 'b': + s.error("bytes can only contain ASCII literal characters.", pos=pos) + bytes_value = None + if kind == 'f': + unicode_value = p_f_string(s, unicode_value, string_start_pos, is_raw='r' in kind_string) + s.next() + return (kind, bytes_value, unicode_value) + + +def _append_escape_sequence(kind, builder, escape_sequence, s): + c = escape_sequence[1] + if c in u"01234567": + builder.append_charval(int(escape_sequence[1:], 8)) + elif c in u"'\"\\": + builder.append(c) + elif c in u"abfnrtv": + builder.append(StringEncoding.char_from_escape_sequence(escape_sequence)) + elif c == u'\n': + pass # line continuation + elif c == u'x': # \xXX + if len(escape_sequence) == 4: + builder.append_charval(int(escape_sequence[2:], 16)) + else: + s.error("Invalid hex escape '%s'" % escape_sequence, fatal=False) + elif c in u'NUu' and kind in ('u', 'f', ''): # \uxxxx, \Uxxxxxxxx, \N{...} + chrval = -1 + if c == u'N': + uchar = None + try: + uchar = lookup_unicodechar(escape_sequence[3:-1]) + chrval = ord(uchar) + except KeyError: + s.error("Unknown Unicode character name %s" % + repr(escape_sequence[3:-1]).lstrip('u'), fatal=False) + except TypeError: + # 2-byte unicode build of CPython? + if (uchar is not None and _IS_2BYTE_UNICODE and len(uchar) == 2 and + unicode_category(uchar[0]) == 'Cs' and unicode_category(uchar[1]) == 'Cs'): + # surrogate pair instead of single character + chrval = 0x10000 + (ord(uchar[0]) - 0xd800) >> 10 + (ord(uchar[1]) - 0xdc00) + else: + raise + elif len(escape_sequence) in (6, 10): + chrval = int(escape_sequence[2:], 16) + if chrval > 1114111: # sys.maxunicode: + s.error("Invalid unicode escape '%s'" % escape_sequence) + chrval = -1 + else: + s.error("Invalid unicode escape '%s'" % escape_sequence, fatal=False) + if chrval >= 0: + builder.append_uescape(chrval, escape_sequence) + else: + builder.append(escape_sequence) + + +_parse_escape_sequences_raw, _parse_escape_sequences = [re.compile(( + # escape sequences: + br'(\\(?:' + + (br'\\?' if is_raw else ( + br'[\\abfnrtv"\'{]|' + br'[0-7]{2,3}|' + br'N\{[^}]*\}|' + br'x[0-9a-fA-F]{2}|' + br'u[0-9a-fA-F]{4}|' + br'U[0-9a-fA-F]{8}|' + br'[NxuU]|' # detect invalid escape sequences that do not match above + )) + + br')?|' + # non-escape sequences: + br'\{\{?|' + br'\}\}?|' + br'[^\\{}]+)' + ).decode('us-ascii')).match + for is_raw in (True, False)] + + +def _f_string_error_pos(pos, string, i): + return (pos[0], pos[1], pos[2] + i + 1) # FIXME: handle newlines in string + + +def p_f_string(s, unicode_value, pos, is_raw): + # Parses a PEP 498 f-string literal into a list of nodes. Nodes are either UnicodeNodes + # or FormattedValueNodes. + values = [] + next_start = 0 + size = len(unicode_value) + builder = StringEncoding.UnicodeLiteralBuilder() + _parse_seq = _parse_escape_sequences_raw if is_raw else _parse_escape_sequences + + while next_start < size: + end = next_start + match = _parse_seq(unicode_value, next_start) + if match is None: + error(_f_string_error_pos(pos, unicode_value, next_start), "Invalid escape sequence") + + next_start = match.end() + part = match.group() + c = part[0] + if c == '\\': + if not is_raw and len(part) > 1: + _append_escape_sequence('f', builder, part, s) + else: + builder.append(part) + elif c == '{': + if part == '{{': + builder.append('{') + else: + # start of an expression + if builder.chars: + values.append(ExprNodes.UnicodeNode(pos, value=builder.getstring())) + builder = StringEncoding.UnicodeLiteralBuilder() + next_start, expr_node = p_f_string_expr(s, unicode_value, pos, next_start, is_raw) + values.append(expr_node) + elif c == '}': + if part == '}}': + builder.append('}') + else: + error(_f_string_error_pos(pos, unicode_value, end), + "f-string: single '}' is not allowed") + else: + builder.append(part) + + if builder.chars: + values.append(ExprNodes.UnicodeNode(pos, value=builder.getstring())) + return values + + +def p_f_string_expr(s, unicode_value, pos, starting_index, is_raw): + # Parses a {}-delimited expression inside an f-string. Returns a FormattedValueNode + # and the index in the string that follows the expression. + i = starting_index + size = len(unicode_value) + conversion_char = terminal_char = format_spec = None + format_spec_str = None + NO_CHAR = 2**30 + + nested_depth = 0 + quote_char = NO_CHAR + in_triple_quotes = False + backslash_reported = False + + while True: + if i >= size: + break # error will be reported below + c = unicode_value[i] + + if quote_char != NO_CHAR: + if c == '\\': + # avoid redundant error reports along '\' sequences + if not backslash_reported: + error(_f_string_error_pos(pos, unicode_value, i), + "backslashes not allowed in f-strings") + backslash_reported = True + elif c == quote_char: + if in_triple_quotes: + if i + 2 < size and unicode_value[i + 1] == c and unicode_value[i + 2] == c: + in_triple_quotes = False + quote_char = NO_CHAR + i += 2 + else: + quote_char = NO_CHAR + elif c in '\'"': + quote_char = c + if i + 2 < size and unicode_value[i + 1] == c and unicode_value[i + 2] == c: + in_triple_quotes = True + i += 2 + elif c in '{[(': + nested_depth += 1 + elif nested_depth != 0 and c in '}])': + nested_depth -= 1 + elif c == '#': + error(_f_string_error_pos(pos, unicode_value, i), + "format string cannot include #") + elif nested_depth == 0 and c in '!:}': + # allow != as a special case + if c == '!' and i + 1 < size and unicode_value[i + 1] == '=': + i += 1 + continue + + terminal_char = c + break + i += 1 + + # normalise line endings as the parser expects that + expr_str = unicode_value[starting_index:i].replace('\r\n', '\n').replace('\r', '\n') + expr_pos = (pos[0], pos[1], pos[2] + starting_index + 2) # TODO: find exact code position (concat, multi-line, ...) + + if not expr_str.strip(): + error(_f_string_error_pos(pos, unicode_value, starting_index), + "empty expression not allowed in f-string") + + if terminal_char == '!': + i += 1 + if i + 2 > size: + pass # error will be reported below + else: + conversion_char = unicode_value[i] + i += 1 + terminal_char = unicode_value[i] + + if terminal_char == ':': + in_triple_quotes = False + in_string = False + nested_depth = 0 + start_format_spec = i + 1 + while True: + if i >= size: + break # error will be reported below + c = unicode_value[i] + if not in_triple_quotes and not in_string: + if c == '{': + nested_depth += 1 + elif c == '}': + if nested_depth > 0: + nested_depth -= 1 + else: + terminal_char = c + break + if c in '\'"': + if not in_string and i + 2 < size and unicode_value[i + 1] == c and unicode_value[i + 2] == c: + in_triple_quotes = not in_triple_quotes + i += 2 + elif not in_triple_quotes: + in_string = not in_string + i += 1 + + format_spec_str = unicode_value[start_format_spec:i] + + if terminal_char != '}': + error(_f_string_error_pos(pos, unicode_value, i), + "missing '}' in format string expression" + ( + ", found '%s'" % terminal_char if terminal_char else "")) + + # parse the expression as if it was surrounded by parentheses + buf = StringIO('(%s)' % expr_str) + scanner = PyrexScanner(buf, expr_pos[0], parent_scanner=s, source_encoding=s.source_encoding, initial_pos=expr_pos) + expr = p_testlist(scanner) # TODO is testlist right here? + + # validate the conversion char + if conversion_char is not None and not ExprNodes.FormattedValueNode.find_conversion_func(conversion_char): + error(expr_pos, "invalid conversion character '%s'" % conversion_char) + + # the format spec is itself treated like an f-string + if format_spec_str: + format_spec = ExprNodes.JoinedStrNode(pos, values=p_f_string(s, format_spec_str, pos, is_raw)) + + return i + 1, ExprNodes.FormattedValueNode( + pos, value=expr, conversion_char=conversion_char, format_spec=format_spec) + + +# since PEP 448: +# list_display ::= "[" [listmaker] "]" +# listmaker ::= (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) +# comp_iter ::= comp_for | comp_if +# comp_for ::= ["async"] "for" expression_list "in" testlist [comp_iter] +# comp_if ::= "if" test [comp_iter] + +def p_list_maker(s): + # s.sy == '[' + pos = s.position() + s.next() + if s.sy == ']': + s.expect(']') + return ExprNodes.ListNode(pos, args=[]) + + expr = p_test_or_starred_expr(s) + if s.sy in ('for', 'async'): + if expr.is_starred: + s.error("iterable unpacking cannot be used in comprehension") + append = ExprNodes.ComprehensionAppendNode(pos, expr=expr) + loop = p_comp_for(s, append) + s.expect(']') + return ExprNodes.ComprehensionNode( + pos, loop=loop, append=append, type=Builtin.list_type, + # list comprehensions leak their loop variable in Py2 + has_local_scope=s.context.language_level >= 3) + + # (merged) list literal + if s.sy == ',': + s.next() + exprs = p_test_or_starred_expr_list(s, expr) + else: + exprs = [expr] + s.expect(']') + return ExprNodes.ListNode(pos, args=exprs) + + +def p_comp_iter(s, body): + if s.sy in ('for', 'async'): + return p_comp_for(s, body) + elif s.sy == 'if': + return p_comp_if(s, body) + else: + # insert the 'append' operation into the loop + return body + +def p_comp_for(s, body): + pos = s.position() + # [async] for ... + is_async = False + if s.sy == 'async': + is_async = True + s.next() + + # s.sy == 'for' + s.expect('for') + kw = p_for_bounds(s, allow_testlist=False, is_async=is_async) + kw.update(else_clause=None, body=p_comp_iter(s, body), is_async=is_async) + return Nodes.ForStatNode(pos, **kw) + +def p_comp_if(s, body): + # s.sy == 'if' + pos = s.position() + s.next() + test = p_test_nocond(s) + return Nodes.IfStatNode(pos, + if_clauses = [Nodes.IfClauseNode(pos, condition = test, + body = p_comp_iter(s, body))], + else_clause = None ) + + +# since PEP 448: +#dictorsetmaker: ( ((test ':' test | '**' expr) +# (comp_for | (',' (test ':' test | '**' expr))* [','])) | +# ((test | star_expr) +# (comp_for | (',' (test | star_expr))* [','])) ) + +def p_dict_or_set_maker(s): + # s.sy == '{' + pos = s.position() + s.next() + if s.sy == '}': + s.next() + return ExprNodes.DictNode(pos, key_value_pairs=[]) + + parts = [] + target_type = 0 + last_was_simple_item = False + while True: + if s.sy in ('*', '**'): + # merged set/dict literal + if target_type == 0: + target_type = 1 if s.sy == '*' else 2 # 'stars' + elif target_type != len(s.sy): + s.error("unexpected %sitem found in %s literal" % ( + s.sy, 'set' if target_type == 1 else 'dict')) + s.next() + if s.sy == '*': + s.error("expected expression, found '*'") + item = p_starred_expr(s) + parts.append(item) + last_was_simple_item = False + else: + item = p_test(s) + if target_type == 0: + target_type = 2 if s.sy == ':' else 1 # dict vs. set + if target_type == 2: + # dict literal + s.expect(':') + key = item + value = p_test(s) + item = ExprNodes.DictItemNode(key.pos, key=key, value=value) + if last_was_simple_item: + parts[-1].append(item) + else: + parts.append([item]) + last_was_simple_item = True + + if s.sy == ',': + s.next() + if s.sy == '}': + break + else: + break + + if s.sy in ('for', 'async'): + # dict/set comprehension + if len(parts) == 1 and isinstance(parts[0], list) and len(parts[0]) == 1: + item = parts[0][0] + if target_type == 2: + assert isinstance(item, ExprNodes.DictItemNode), type(item) + comprehension_type = Builtin.dict_type + append = ExprNodes.DictComprehensionAppendNode( + item.pos, key_expr=item.key, value_expr=item.value) + else: + comprehension_type = Builtin.set_type + append = ExprNodes.ComprehensionAppendNode(item.pos, expr=item) + loop = p_comp_for(s, append) + s.expect('}') + return ExprNodes.ComprehensionNode(pos, loop=loop, append=append, type=comprehension_type) + else: + # syntax error, try to find a good error message + if len(parts) == 1 and not isinstance(parts[0], list): + s.error("iterable unpacking cannot be used in comprehension") + else: + # e.g. "{1,2,3 for ..." + s.expect('}') + return ExprNodes.DictNode(pos, key_value_pairs=[]) + + s.expect('}') + if target_type == 1: + # (merged) set literal + items = [] + set_items = [] + for part in parts: + if isinstance(part, list): + set_items.extend(part) + else: + if set_items: + items.append(ExprNodes.SetNode(set_items[0].pos, args=set_items)) + set_items = [] + items.append(part) + if set_items: + items.append(ExprNodes.SetNode(set_items[0].pos, args=set_items)) + if len(items) == 1 and items[0].is_set_literal: + return items[0] + return ExprNodes.MergedSequenceNode(pos, args=items, type=Builtin.set_type) + else: + # (merged) dict literal + items = [] + dict_items = [] + for part in parts: + if isinstance(part, list): + dict_items.extend(part) + else: + if dict_items: + items.append(ExprNodes.DictNode(dict_items[0].pos, key_value_pairs=dict_items)) + dict_items = [] + items.append(part) + if dict_items: + items.append(ExprNodes.DictNode(dict_items[0].pos, key_value_pairs=dict_items)) + if len(items) == 1 and items[0].is_dict_literal: + return items[0] + return ExprNodes.MergedDictNode(pos, keyword_args=items, reject_duplicates=False) + + +# NOTE: no longer in Py3 :) +def p_backquote_expr(s): + # s.sy == '`' + pos = s.position() + s.next() + args = [p_test(s)] + while s.sy == ',': + s.next() + args.append(p_test(s)) + s.expect('`') + if len(args) == 1: + arg = args[0] + else: + arg = ExprNodes.TupleNode(pos, args = args) + return ExprNodes.BackquoteNode(pos, arg = arg) + +def p_simple_expr_list(s, expr=None): + exprs = expr is not None and [expr] or [] + while s.sy not in expr_terminators: + exprs.append( p_test(s) ) + if s.sy != ',': + break + s.next() + return exprs + + +def p_test_or_starred_expr_list(s, expr=None): + exprs = expr is not None and [expr] or [] + while s.sy not in expr_terminators: + exprs.append(p_test_or_starred_expr(s)) + if s.sy != ',': + break + s.next() + return exprs + + +#testlist: test (',' test)* [','] + +def p_testlist(s): + pos = s.position() + expr = p_test(s) + if s.sy == ',': + s.next() + exprs = p_simple_expr_list(s, expr) + return ExprNodes.TupleNode(pos, args = exprs) + else: + return expr + +# testlist_star_expr: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) + +def p_testlist_star_expr(s): + pos = s.position() + expr = p_test_or_starred_expr(s) + if s.sy == ',': + s.next() + exprs = p_test_or_starred_expr_list(s, expr) + return ExprNodes.TupleNode(pos, args = exprs) + else: + return expr + +# testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) + +def p_testlist_comp(s): + pos = s.position() + expr = p_test_or_starred_expr(s) + if s.sy == ',': + s.next() + exprs = p_test_or_starred_expr_list(s, expr) + return ExprNodes.TupleNode(pos, args = exprs) + elif s.sy in ('for', 'async'): + return p_genexp(s, expr) + else: + return expr + +def p_genexp(s, expr): + # s.sy == 'async' | 'for' + loop = p_comp_for(s, Nodes.ExprStatNode( + expr.pos, expr = ExprNodes.YieldExprNode(expr.pos, arg=expr))) + return ExprNodes.GeneratorExpressionNode(expr.pos, loop=loop) + +expr_terminators = cython.declare(set, set([ + ')', ']', '}', ':', '=', 'NEWLINE'])) + + +#------------------------------------------------------- +# +# Statements +# +#------------------------------------------------------- + +def p_global_statement(s): + # assume s.sy == 'global' + pos = s.position() + s.next() + names = p_ident_list(s) + return Nodes.GlobalNode(pos, names = names) + + +def p_nonlocal_statement(s): + pos = s.position() + s.next() + names = p_ident_list(s) + return Nodes.NonlocalNode(pos, names = names) + + +def p_expression_or_assignment(s): + expr = p_testlist_star_expr(s) + if s.sy == ':' and (expr.is_name or expr.is_subscript or expr.is_attribute): + s.next() + expr.annotation = p_test(s) + if s.sy == '=' and expr.is_starred: + # This is a common enough error to make when learning Cython to let + # it fail as early as possible and give a very clear error message. + s.error("a starred assignment target must be in a list or tuple" + " - maybe you meant to use an index assignment: var[0] = ...", + pos=expr.pos) + expr_list = [expr] + while s.sy == '=': + s.next() + if s.sy == 'yield': + expr = p_yield_expression(s) + else: + expr = p_testlist_star_expr(s) + expr_list.append(expr) + if len(expr_list) == 1: + if re.match(r"([-+*/%^&|]|<<|>>|\*\*|//|@)=", s.sy): + lhs = expr_list[0] + if isinstance(lhs, ExprNodes.SliceIndexNode): + # implementation requires IndexNode + lhs = ExprNodes.IndexNode( + lhs.pos, + base=lhs.base, + index=make_slice_node(lhs.pos, lhs.start, lhs.stop)) + elif not isinstance(lhs, (ExprNodes.AttributeNode, ExprNodes.IndexNode, ExprNodes.NameNode)): + error(lhs.pos, "Illegal operand for inplace operation.") + operator = s.sy[:-1] + s.next() + if s.sy == 'yield': + rhs = p_yield_expression(s) + else: + rhs = p_testlist(s) + return Nodes.InPlaceAssignmentNode(lhs.pos, operator=operator, lhs=lhs, rhs=rhs) + expr = expr_list[0] + return Nodes.ExprStatNode(expr.pos, expr=expr) + + rhs = expr_list[-1] + if len(expr_list) == 2: + return Nodes.SingleAssignmentNode(rhs.pos, lhs=expr_list[0], rhs=rhs) + else: + return Nodes.CascadedAssignmentNode(rhs.pos, lhs_list=expr_list[:-1], rhs=rhs) + + +def p_print_statement(s): + # s.sy == 'print' + pos = s.position() + ends_with_comma = 0 + s.next() + if s.sy == '>>': + s.next() + stream = p_test(s) + if s.sy == ',': + s.next() + ends_with_comma = s.sy in ('NEWLINE', 'EOF') + else: + stream = None + args = [] + if s.sy not in ('NEWLINE', 'EOF'): + args.append(p_test(s)) + while s.sy == ',': + s.next() + if s.sy in ('NEWLINE', 'EOF'): + ends_with_comma = 1 + break + args.append(p_test(s)) + arg_tuple = ExprNodes.TupleNode(pos, args=args) + return Nodes.PrintStatNode(pos, + arg_tuple=arg_tuple, stream=stream, + append_newline=not ends_with_comma) + + +def p_exec_statement(s): + # s.sy == 'exec' + pos = s.position() + s.next() + code = p_bit_expr(s) + if isinstance(code, ExprNodes.TupleNode): + # Py3 compatibility syntax + tuple_variant = True + args = code.args + if len(args) not in (2, 3): + s.error("expected tuple of length 2 or 3, got length %d" % len(args), + pos=pos, fatal=False) + args = [code] + else: + tuple_variant = False + args = [code] + if s.sy == 'in': + if tuple_variant: + s.error("tuple variant of exec does not support additional 'in' arguments", + fatal=False) + s.next() + args.append(p_test(s)) + if s.sy == ',': + s.next() + args.append(p_test(s)) + return Nodes.ExecStatNode(pos, args=args) + +def p_del_statement(s): + # s.sy == 'del' + pos = s.position() + s.next() + # FIXME: 'exprlist' in Python + args = p_simple_expr_list(s) + return Nodes.DelStatNode(pos, args = args) + +def p_pass_statement(s, with_newline = 0): + pos = s.position() + s.expect('pass') + if with_newline: + s.expect_newline("Expected a newline", ignore_semicolon=True) + return Nodes.PassStatNode(pos) + +def p_break_statement(s): + # s.sy == 'break' + pos = s.position() + s.next() + return Nodes.BreakStatNode(pos) + +def p_continue_statement(s): + # s.sy == 'continue' + pos = s.position() + s.next() + return Nodes.ContinueStatNode(pos) + +def p_return_statement(s): + # s.sy == 'return' + pos = s.position() + s.next() + if s.sy not in statement_terminators: + value = p_testlist(s) + else: + value = None + return Nodes.ReturnStatNode(pos, value = value) + +def p_raise_statement(s): + # s.sy == 'raise' + pos = s.position() + s.next() + exc_type = None + exc_value = None + exc_tb = None + cause = None + if s.sy not in statement_terminators: + exc_type = p_test(s) + if s.sy == ',': + s.next() + exc_value = p_test(s) + if s.sy == ',': + s.next() + exc_tb = p_test(s) + elif s.sy == 'from': + s.next() + cause = p_test(s) + if exc_type or exc_value or exc_tb: + return Nodes.RaiseStatNode(pos, + exc_type = exc_type, + exc_value = exc_value, + exc_tb = exc_tb, + cause = cause) + else: + return Nodes.ReraiseStatNode(pos) + + +def p_import_statement(s): + # s.sy in ('import', 'cimport') + pos = s.position() + kind = s.sy + s.next() + items = [p_dotted_name(s, as_allowed=1)] + while s.sy == ',': + s.next() + items.append(p_dotted_name(s, as_allowed=1)) + stats = [] + is_absolute = Future.absolute_import in s.context.future_directives + for pos, target_name, dotted_name, as_name in items: + if kind == 'cimport': + stat = Nodes.CImportStatNode( + pos, + module_name=dotted_name, + as_name=as_name, + is_absolute=is_absolute) + else: + if as_name and "." in dotted_name: + name_list = ExprNodes.ListNode(pos, args=[ + ExprNodes.IdentifierStringNode(pos, value=s.context.intern_ustring("*"))]) + else: + name_list = None + stat = Nodes.SingleAssignmentNode( + pos, + lhs=ExprNodes.NameNode(pos, name=as_name or target_name), + rhs=ExprNodes.ImportNode( + pos, + module_name=ExprNodes.IdentifierStringNode(pos, value=dotted_name), + level=0 if is_absolute else None, + name_list=name_list)) + stats.append(stat) + return Nodes.StatListNode(pos, stats=stats) + + +def p_from_import_statement(s, first_statement = 0): + # s.sy == 'from' + pos = s.position() + s.next() + if s.sy == '.': + # count relative import level + level = 0 + while s.sy == '.': + level += 1 + s.next() + else: + level = None + if level is not None and s.sy in ('import', 'cimport'): + # we are dealing with "from .. import foo, bar" + dotted_name_pos, dotted_name = s.position(), s.context.intern_ustring('') + else: + if level is None and Future.absolute_import in s.context.future_directives: + level = 0 + (dotted_name_pos, _, dotted_name, _) = p_dotted_name(s, as_allowed=False) + if s.sy not in ('import', 'cimport'): + s.error("Expected 'import' or 'cimport'") + kind = s.sy + s.next() + + is_cimport = kind == 'cimport' + is_parenthesized = False + if s.sy == '*': + imported_names = [(s.position(), s.context.intern_ustring("*"), None, None)] + s.next() + else: + if s.sy == '(': + is_parenthesized = True + s.next() + imported_names = [p_imported_name(s, is_cimport)] + while s.sy == ',': + s.next() + if is_parenthesized and s.sy == ')': + break + imported_names.append(p_imported_name(s, is_cimport)) + if is_parenthesized: + s.expect(')') + if dotted_name == '__future__': + if not first_statement: + s.error("from __future__ imports must occur at the beginning of the file") + elif level: + s.error("invalid syntax") + else: + for (name_pos, name, as_name, kind) in imported_names: + if name == "braces": + s.error("not a chance", name_pos) + break + try: + directive = getattr(Future, name) + except AttributeError: + s.error("future feature %s is not defined" % name, name_pos) + break + s.context.future_directives.add(directive) + return Nodes.PassStatNode(pos) + elif kind == 'cimport': + return Nodes.FromCImportStatNode( + pos, module_name=dotted_name, + relative_level=level, + imported_names=imported_names) + else: + imported_name_strings = [] + items = [] + for (name_pos, name, as_name, kind) in imported_names: + imported_name_strings.append( + ExprNodes.IdentifierStringNode(name_pos, value=name)) + items.append( + (name, ExprNodes.NameNode(name_pos, name=as_name or name))) + import_list = ExprNodes.ListNode( + imported_names[0][0], args=imported_name_strings) + return Nodes.FromImportStatNode(pos, + module = ExprNodes.ImportNode(dotted_name_pos, + module_name = ExprNodes.IdentifierStringNode(pos, value = dotted_name), + level = level, + name_list = import_list), + items = items) + + +imported_name_kinds = cython.declare(set, set(['class', 'struct', 'union'])) + +def p_imported_name(s, is_cimport): + pos = s.position() + kind = None + if is_cimport and s.systring in imported_name_kinds: + kind = s.systring + warning(pos, 'the "from module cimport %s name" syntax is deprecated and ' + 'will be removed in Cython 3.0' % kind, 2) + s.next() + name = p_ident(s) + as_name = p_as_name(s) + return (pos, name, as_name, kind) + + +def p_dotted_name(s, as_allowed): + pos = s.position() + target_name = p_ident(s) + as_name = None + names = [target_name] + while s.sy == '.': + s.next() + names.append(p_ident(s)) + if as_allowed: + as_name = p_as_name(s) + return (pos, target_name, s.context.intern_ustring(u'.'.join(names)), as_name) + + +def p_as_name(s): + if s.sy == 'IDENT' and s.systring == 'as': + s.next() + return p_ident(s) + else: + return None + + +def p_assert_statement(s): + # s.sy == 'assert' + pos = s.position() + s.next() + cond = p_test(s) + if s.sy == ',': + s.next() + value = p_test(s) + else: + value = None + return Nodes.AssertStatNode(pos, cond = cond, value = value) + + +statement_terminators = cython.declare(set, set([';', 'NEWLINE', 'EOF'])) + +def p_if_statement(s): + # s.sy == 'if' + pos = s.position() + s.next() + if_clauses = [p_if_clause(s)] + while s.sy == 'elif': + s.next() + if_clauses.append(p_if_clause(s)) + else_clause = p_else_clause(s) + return Nodes.IfStatNode(pos, + if_clauses = if_clauses, else_clause = else_clause) + +def p_if_clause(s): + pos = s.position() + test = p_test(s) + body = p_suite(s) + return Nodes.IfClauseNode(pos, + condition = test, body = body) + +def p_else_clause(s): + if s.sy == 'else': + s.next() + return p_suite(s) + else: + return None + +def p_while_statement(s): + # s.sy == 'while' + pos = s.position() + s.next() + test = p_test(s) + body = p_suite(s) + else_clause = p_else_clause(s) + return Nodes.WhileStatNode(pos, + condition = test, body = body, + else_clause = else_clause) + + +def p_for_statement(s, is_async=False): + # s.sy == 'for' + pos = s.position() + s.next() + kw = p_for_bounds(s, allow_testlist=True, is_async=is_async) + body = p_suite(s) + else_clause = p_else_clause(s) + kw.update(body=body, else_clause=else_clause, is_async=is_async) + return Nodes.ForStatNode(pos, **kw) + + +def p_for_bounds(s, allow_testlist=True, is_async=False): + target = p_for_target(s) + if s.sy == 'in': + s.next() + iterator = p_for_iterator(s, allow_testlist, is_async=is_async) + return dict(target=target, iterator=iterator) + elif not s.in_python_file and not is_async: + if s.sy == 'from': + s.next() + bound1 = p_bit_expr(s) + else: + # Support shorter "for a <= x < b" syntax + bound1, target = target, None + rel1 = p_for_from_relation(s) + name2_pos = s.position() + name2 = p_ident(s) + rel2_pos = s.position() + rel2 = p_for_from_relation(s) + bound2 = p_bit_expr(s) + step = p_for_from_step(s) + if target is None: + target = ExprNodes.NameNode(name2_pos, name = name2) + else: + if not target.is_name: + error(target.pos, + "Target of for-from statement must be a variable name") + elif name2 != target.name: + error(name2_pos, + "Variable name in for-from range does not match target") + if rel1[0] != rel2[0]: + error(rel2_pos, + "Relation directions in for-from do not match") + return dict(target = target, + bound1 = bound1, + relation1 = rel1, + relation2 = rel2, + bound2 = bound2, + step = step, + ) + else: + s.expect('in') + return {} + +def p_for_from_relation(s): + if s.sy in inequality_relations: + op = s.sy + s.next() + return op + else: + s.error("Expected one of '<', '<=', '>' '>='") + +def p_for_from_step(s): + if s.sy == 'IDENT' and s.systring == 'by': + s.next() + step = p_bit_expr(s) + return step + else: + return None + +inequality_relations = cython.declare(set, set(['<', '<=', '>', '>='])) + +def p_target(s, terminator): + pos = s.position() + expr = p_starred_expr(s) + if s.sy == ',': + s.next() + exprs = [expr] + while s.sy != terminator: + exprs.append(p_starred_expr(s)) + if s.sy != ',': + break + s.next() + return ExprNodes.TupleNode(pos, args = exprs) + else: + return expr + + +def p_for_target(s): + return p_target(s, 'in') + + +def p_for_iterator(s, allow_testlist=True, is_async=False): + pos = s.position() + if allow_testlist: + expr = p_testlist(s) + else: + expr = p_or_test(s) + return (ExprNodes.AsyncIteratorNode if is_async else ExprNodes.IteratorNode)(pos, sequence=expr) + + +def p_try_statement(s): + # s.sy == 'try' + pos = s.position() + s.next() + body = p_suite(s) + except_clauses = [] + else_clause = None + if s.sy in ('except', 'else'): + while s.sy == 'except': + except_clauses.append(p_except_clause(s)) + if s.sy == 'else': + s.next() + else_clause = p_suite(s) + body = Nodes.TryExceptStatNode(pos, + body = body, except_clauses = except_clauses, + else_clause = else_clause) + if s.sy != 'finally': + return body + # try-except-finally is equivalent to nested try-except/try-finally + if s.sy == 'finally': + s.next() + finally_clause = p_suite(s) + return Nodes.TryFinallyStatNode(pos, + body = body, finally_clause = finally_clause) + else: + s.error("Expected 'except' or 'finally'") + +def p_except_clause(s): + # s.sy == 'except' + pos = s.position() + s.next() + exc_type = None + exc_value = None + is_except_as = False + if s.sy != ':': + exc_type = p_test(s) + # normalise into list of single exception tests + if isinstance(exc_type, ExprNodes.TupleNode): + exc_type = exc_type.args + else: + exc_type = [exc_type] + if s.sy == ',' or (s.sy == 'IDENT' and s.systring == 'as' + and s.context.language_level == 2): + s.next() + exc_value = p_test(s) + elif s.sy == 'IDENT' and s.systring == 'as': + # Py3 syntax requires a name here + s.next() + pos2 = s.position() + name = p_ident(s) + exc_value = ExprNodes.NameNode(pos2, name = name) + is_except_as = True + body = p_suite(s) + return Nodes.ExceptClauseNode(pos, + pattern = exc_type, target = exc_value, + body = body, is_except_as=is_except_as) + +def p_include_statement(s, ctx): + pos = s.position() + s.next() # 'include' + unicode_include_file_name = p_string_literal(s, 'u')[2] + s.expect_newline("Syntax error in include statement") + if s.compile_time_eval: + include_file_name = unicode_include_file_name + include_file_path = s.context.find_include_file(include_file_name, pos) + if include_file_path: + s.included_files.append(include_file_name) + with Utils.open_source_file(include_file_path) as f: + if Options.source_root: + import os + rel_path = os.path.relpath(include_file_path, Options.source_root) + else: + rel_path = None + source_desc = FileSourceDescriptor(include_file_path, rel_path) + s2 = PyrexScanner(f, source_desc, s, source_encoding=f.encoding, parse_comments=s.parse_comments) + tree = p_statement_list(s2, ctx) + return tree + else: + return None + else: + return Nodes.PassStatNode(pos) + + +def p_with_statement(s): + s.next() # 'with' + if s.systring == 'template' and not s.in_python_file: + node = p_with_template(s) + else: + node = p_with_items(s) + return node + + +def p_with_items(s, is_async=False): + pos = s.position() + if not s.in_python_file and s.sy == 'IDENT' and s.systring in ('nogil', 'gil'): + if is_async: + s.error("with gil/nogil cannot be async") + state = s.systring + s.next() + if s.sy == ',': + s.next() + body = p_with_items(s) + else: + body = p_suite(s) + return Nodes.GILStatNode(pos, state=state, body=body) + else: + manager = p_test(s) + target = None + if s.sy == 'IDENT' and s.systring == 'as': + s.next() + target = p_starred_expr(s) + if s.sy == ',': + s.next() + body = p_with_items(s, is_async=is_async) + else: + body = p_suite(s) + return Nodes.WithStatNode(pos, manager=manager, target=target, body=body, is_async=is_async) + + +def p_with_template(s): + pos = s.position() + templates = [] + s.next() + s.expect('[') + templates.append(s.systring) + s.next() + while s.systring == ',': + s.next() + templates.append(s.systring) + s.next() + s.expect(']') + if s.sy == ':': + s.next() + s.expect_newline("Syntax error in template function declaration") + s.expect_indent() + body_ctx = Ctx() + body_ctx.templates = templates + func_or_var = p_c_func_or_var_declaration(s, pos, body_ctx) + s.expect_dedent() + return func_or_var + else: + error(pos, "Syntax error in template function declaration") + +def p_simple_statement(s, first_statement = 0): + #print "p_simple_statement:", s.sy, s.systring ### + if s.sy == 'global': + node = p_global_statement(s) + elif s.sy == 'nonlocal': + node = p_nonlocal_statement(s) + elif s.sy == 'print': + node = p_print_statement(s) + elif s.sy == 'exec': + node = p_exec_statement(s) + elif s.sy == 'del': + node = p_del_statement(s) + elif s.sy == 'break': + node = p_break_statement(s) + elif s.sy == 'continue': + node = p_continue_statement(s) + elif s.sy == 'return': + node = p_return_statement(s) + elif s.sy == 'raise': + node = p_raise_statement(s) + elif s.sy in ('import', 'cimport'): + node = p_import_statement(s) + elif s.sy == 'from': + node = p_from_import_statement(s, first_statement = first_statement) + elif s.sy == 'yield': + node = p_yield_statement(s) + elif s.sy == 'assert': + node = p_assert_statement(s) + elif s.sy == 'pass': + node = p_pass_statement(s) + else: + node = p_expression_or_assignment(s) + return node + +def p_simple_statement_list(s, ctx, first_statement = 0): + # Parse a series of simple statements on one line + # separated by semicolons. + stat = p_simple_statement(s, first_statement = first_statement) + pos = stat.pos + stats = [] + if not isinstance(stat, Nodes.PassStatNode): + stats.append(stat) + while s.sy == ';': + #print "p_simple_statement_list: maybe more to follow" ### + s.next() + if s.sy in ('NEWLINE', 'EOF'): + break + stat = p_simple_statement(s, first_statement = first_statement) + if isinstance(stat, Nodes.PassStatNode): + continue + stats.append(stat) + first_statement = False + + if not stats: + stat = Nodes.PassStatNode(pos) + elif len(stats) == 1: + stat = stats[0] + else: + stat = Nodes.StatListNode(pos, stats = stats) + + if s.sy not in ('NEWLINE', 'EOF'): + # provide a better error message for users who accidentally write Cython code in .py files + if isinstance(stat, Nodes.ExprStatNode): + if stat.expr.is_name and stat.expr.name == 'cdef': + s.error("The 'cdef' keyword is only allowed in Cython files (pyx/pxi/pxd)", pos) + s.expect_newline("Syntax error in simple statement list") + + return stat + +def p_compile_time_expr(s): + old = s.compile_time_expr + s.compile_time_expr = 1 + expr = p_testlist(s) + s.compile_time_expr = old + return expr + +def p_DEF_statement(s): + pos = s.position() + denv = s.compile_time_env + s.next() # 'DEF' + name = p_ident(s) + s.expect('=') + expr = p_compile_time_expr(s) + if s.compile_time_eval: + value = expr.compile_time_value(denv) + #print "p_DEF_statement: %s = %r" % (name, value) ### + denv.declare(name, value) + s.expect_newline("Expected a newline", ignore_semicolon=True) + return Nodes.PassStatNode(pos) + +def p_IF_statement(s, ctx): + pos = s.position() + saved_eval = s.compile_time_eval + current_eval = saved_eval + denv = s.compile_time_env + result = None + while 1: + s.next() # 'IF' or 'ELIF' + expr = p_compile_time_expr(s) + s.compile_time_eval = current_eval and bool(expr.compile_time_value(denv)) + body = p_suite(s, ctx) + if s.compile_time_eval: + result = body + current_eval = 0 + if s.sy != 'ELIF': + break + if s.sy == 'ELSE': + s.next() + s.compile_time_eval = current_eval + body = p_suite(s, ctx) + if current_eval: + result = body + if not result: + result = Nodes.PassStatNode(pos) + s.compile_time_eval = saved_eval + return result + +def p_statement(s, ctx, first_statement = 0): + cdef_flag = ctx.cdef_flag + decorators = None + if s.sy == 'ctypedef': + if ctx.level not in ('module', 'module_pxd'): + s.error("ctypedef statement not allowed here") + #if ctx.api: + # error(s.position(), "'api' not allowed with 'ctypedef'") + return p_ctypedef_statement(s, ctx) + elif s.sy == 'DEF': + return p_DEF_statement(s) + elif s.sy == 'IF': + return p_IF_statement(s, ctx) + elif s.sy == '@': + if ctx.level not in ('module', 'class', 'c_class', 'function', 'property', 'module_pxd', 'c_class_pxd', 'other'): + s.error('decorator not allowed here') + s.level = ctx.level + decorators = p_decorators(s) + if not ctx.allow_struct_enum_decorator and s.sy not in ('def', 'cdef', 'cpdef', 'class', 'async'): + if s.sy == 'IDENT' and s.systring == 'async': + pass # handled below + else: + s.error("Decorators can only be followed by functions or classes") + elif s.sy == 'pass' and cdef_flag: + # empty cdef block + return p_pass_statement(s, with_newline=1) + + overridable = 0 + if s.sy == 'cdef': + cdef_flag = 1 + s.next() + elif s.sy == 'cpdef': + cdef_flag = 1 + overridable = 1 + s.next() + if cdef_flag: + if ctx.level not in ('module', 'module_pxd', 'function', 'c_class', 'c_class_pxd'): + s.error('cdef statement not allowed here') + s.level = ctx.level + node = p_cdef_statement(s, ctx(overridable=overridable)) + if decorators is not None: + tup = (Nodes.CFuncDefNode, Nodes.CVarDefNode, Nodes.CClassDefNode) + if ctx.allow_struct_enum_decorator: + tup += (Nodes.CStructOrUnionDefNode, Nodes.CEnumDefNode) + if not isinstance(node, tup): + s.error("Decorators can only be followed by functions or classes") + node.decorators = decorators + return node + else: + if ctx.api: + s.error("'api' not allowed with this statement", fatal=False) + elif s.sy == 'def': + # def statements aren't allowed in pxd files, except + # as part of a cdef class + if ('pxd' in ctx.level) and (ctx.level != 'c_class_pxd'): + s.error('def statement not allowed here') + s.level = ctx.level + return p_def_statement(s, decorators) + elif s.sy == 'class': + if ctx.level not in ('module', 'function', 'class', 'other'): + s.error("class definition not allowed here") + return p_class_statement(s, decorators) + elif s.sy == 'include': + if ctx.level not in ('module', 'module_pxd'): + s.error("include statement not allowed here") + return p_include_statement(s, ctx) + elif ctx.level == 'c_class' and s.sy == 'IDENT' and s.systring == 'property': + return p_property_decl(s) + elif s.sy == 'pass' and ctx.level != 'property': + return p_pass_statement(s, with_newline=True) + else: + if ctx.level in ('c_class_pxd', 'property'): + node = p_ignorable_statement(s) + if node is not None: + return node + s.error("Executable statement not allowed here") + if s.sy == 'if': + return p_if_statement(s) + elif s.sy == 'while': + return p_while_statement(s) + elif s.sy == 'for': + return p_for_statement(s) + elif s.sy == 'try': + return p_try_statement(s) + elif s.sy == 'with': + return p_with_statement(s) + elif s.sy == 'async': + s.next() + return p_async_statement(s, ctx, decorators) + else: + if s.sy == 'IDENT' and s.systring == 'async': + ident_name = s.systring + # PEP 492 enables the async/await keywords when it spots "async def ..." + s.next() + if s.sy == 'def': + return p_async_statement(s, ctx, decorators) + elif decorators: + s.error("Decorators can only be followed by functions or classes") + s.put_back('IDENT', ident_name) # re-insert original token + return p_simple_statement_list(s, ctx, first_statement=first_statement) + + +def p_statement_list(s, ctx, first_statement = 0): + # Parse a series of statements separated by newlines. + pos = s.position() + stats = [] + while s.sy not in ('DEDENT', 'EOF'): + stat = p_statement(s, ctx, first_statement = first_statement) + if isinstance(stat, Nodes.PassStatNode): + continue + stats.append(stat) + first_statement = False + if not stats: + return Nodes.PassStatNode(pos) + elif len(stats) == 1: + return stats[0] + else: + return Nodes.StatListNode(pos, stats = stats) + + +def p_suite(s, ctx=Ctx()): + return p_suite_with_docstring(s, ctx, with_doc_only=False)[1] + + +def p_suite_with_docstring(s, ctx, with_doc_only=False): + s.expect(':') + doc = None + if s.sy == 'NEWLINE': + s.next() + s.expect_indent() + if with_doc_only: + doc = p_doc_string(s) + body = p_statement_list(s, ctx) + s.expect_dedent() + else: + if ctx.api: + s.error("'api' not allowed with this statement", fatal=False) + if ctx.level in ('module', 'class', 'function', 'other'): + body = p_simple_statement_list(s, ctx) + else: + body = p_pass_statement(s) + s.expect_newline("Syntax error in declarations", ignore_semicolon=True) + if not with_doc_only: + doc, body = _extract_docstring(body) + return doc, body + + +def p_positional_and_keyword_args(s, end_sy_set, templates = None): + """ + Parses positional and keyword arguments. end_sy_set + should contain any s.sy that terminate the argument list. + Argument expansion (* and **) are not allowed. + + Returns: (positional_args, keyword_args) + """ + positional_args = [] + keyword_args = [] + pos_idx = 0 + + while s.sy not in end_sy_set: + if s.sy == '*' or s.sy == '**': + s.error('Argument expansion not allowed here.', fatal=False) + + parsed_type = False + if s.sy == 'IDENT' and s.peek()[0] == '=': + ident = s.systring + s.next() # s.sy is '=' + s.next() + if looking_at_expr(s): + arg = p_test(s) + else: + base_type = p_c_base_type(s, templates = templates) + declarator = p_c_declarator(s, empty = 1) + arg = Nodes.CComplexBaseTypeNode(base_type.pos, + base_type = base_type, declarator = declarator) + parsed_type = True + keyword_node = ExprNodes.IdentifierStringNode(arg.pos, value=ident) + keyword_args.append((keyword_node, arg)) + was_keyword = True + + else: + if looking_at_expr(s): + arg = p_test(s) + else: + base_type = p_c_base_type(s, templates = templates) + declarator = p_c_declarator(s, empty = 1) + arg = Nodes.CComplexBaseTypeNode(base_type.pos, + base_type = base_type, declarator = declarator) + parsed_type = True + positional_args.append(arg) + pos_idx += 1 + if len(keyword_args) > 0: + s.error("Non-keyword arg following keyword arg", + pos=arg.pos) + + if s.sy != ',': + if s.sy not in end_sy_set: + if parsed_type: + s.error("Unmatched %s" % " or ".join(end_sy_set)) + break + s.next() + return positional_args, keyword_args + +def p_c_base_type(s, self_flag = 0, nonempty = 0, templates = None): + # If self_flag is true, this is the base type for the + # self argument of a C method of an extension type. + if s.sy == '(': + return p_c_complex_base_type(s, templates = templates) + else: + return p_c_simple_base_type(s, self_flag, nonempty = nonempty, templates = templates) + +def p_calling_convention(s): + if s.sy == 'IDENT' and s.systring in calling_convention_words: + result = s.systring + s.next() + return result + else: + return "" + + +calling_convention_words = cython.declare( + set, set(["__stdcall", "__cdecl", "__fastcall"])) + + +def p_c_complex_base_type(s, templates = None): + # s.sy == '(' + pos = s.position() + s.next() + base_type = p_c_base_type(s, templates=templates) + declarator = p_c_declarator(s, empty=True) + type_node = Nodes.CComplexBaseTypeNode( + pos, base_type=base_type, declarator=declarator) + if s.sy == ',': + components = [type_node] + while s.sy == ',': + s.next() + if s.sy == ')': + break + base_type = p_c_base_type(s, templates=templates) + declarator = p_c_declarator(s, empty=True) + components.append(Nodes.CComplexBaseTypeNode( + pos, base_type=base_type, declarator=declarator)) + type_node = Nodes.CTupleBaseTypeNode(pos, components = components) + + s.expect(')') + if s.sy == '[': + if is_memoryviewslice_access(s): + type_node = p_memoryviewslice_access(s, type_node) + else: + type_node = p_buffer_or_template(s, type_node, templates) + return type_node + + +def p_c_simple_base_type(s, self_flag, nonempty, templates = None): + #print "p_c_simple_base_type: self_flag =", self_flag, nonempty + is_basic = 0 + signed = 1 + longness = 0 + complex = 0 + module_path = [] + pos = s.position() + if not s.sy == 'IDENT': + error(pos, "Expected an identifier, found '%s'" % s.sy) + if s.systring == 'const': + s.next() + base_type = p_c_base_type(s, self_flag=self_flag, nonempty=nonempty, templates=templates) + if isinstance(base_type, Nodes.MemoryViewSliceTypeNode): + # reverse order to avoid having to write "(const int)[:]" + base_type.base_type_node = Nodes.CConstTypeNode(pos, base_type=base_type.base_type_node) + return base_type + return Nodes.CConstTypeNode(pos, base_type=base_type) + if looking_at_base_type(s): + #print "p_c_simple_base_type: looking_at_base_type at", s.position() + is_basic = 1 + if s.sy == 'IDENT' and s.systring in special_basic_c_types: + signed, longness = special_basic_c_types[s.systring] + name = s.systring + s.next() + else: + signed, longness = p_sign_and_longness(s) + if s.sy == 'IDENT' and s.systring in basic_c_type_names: + name = s.systring + s.next() + else: + name = 'int' # long [int], short [int], long [int] complex, etc. + if s.sy == 'IDENT' and s.systring == 'complex': + complex = 1 + s.next() + elif looking_at_dotted_name(s): + #print "p_c_simple_base_type: looking_at_type_name at", s.position() + name = s.systring + s.next() + while s.sy == '.': + module_path.append(name) + s.next() + name = p_ident(s) + else: + name = s.systring + s.next() + if nonempty and s.sy != 'IDENT': + # Make sure this is not a declaration of a variable or function. + if s.sy == '(': + s.next() + if (s.sy == '*' or s.sy == '**' or s.sy == '&' + or (s.sy == 'IDENT' and s.systring in calling_convention_words)): + s.put_back('(', '(') + else: + s.put_back('(', '(') + s.put_back('IDENT', name) + name = None + elif s.sy not in ('*', '**', '[', '&'): + s.put_back('IDENT', name) + name = None + + type_node = Nodes.CSimpleBaseTypeNode(pos, + name = name, module_path = module_path, + is_basic_c_type = is_basic, signed = signed, + complex = complex, longness = longness, + is_self_arg = self_flag, templates = templates) + + # declarations here. + if s.sy == '[': + if is_memoryviewslice_access(s): + type_node = p_memoryviewslice_access(s, type_node) + else: + type_node = p_buffer_or_template(s, type_node, templates) + + if s.sy == '.': + s.next() + name = p_ident(s) + type_node = Nodes.CNestedBaseTypeNode(pos, base_type = type_node, name = name) + + return type_node + +def p_buffer_or_template(s, base_type_node, templates): + # s.sy == '[' + pos = s.position() + s.next() + # Note that buffer_positional_options_count=1, so the only positional argument is dtype. + # For templated types, all parameters are types. + positional_args, keyword_args = ( + p_positional_and_keyword_args(s, (']',), templates) + ) + s.expect(']') + + if s.sy == '[': + base_type_node = p_buffer_or_template(s, base_type_node, templates) + + keyword_dict = ExprNodes.DictNode(pos, + key_value_pairs = [ + ExprNodes.DictItemNode(pos=key.pos, key=key, value=value) + for key, value in keyword_args + ]) + result = Nodes.TemplatedTypeNode(pos, + positional_args = positional_args, + keyword_args = keyword_dict, + base_type_node = base_type_node) + return result + +def p_bracketed_base_type(s, base_type_node, nonempty, empty): + # s.sy == '[' + if empty and not nonempty: + # sizeof-like thing. Only anonymous C arrays allowed (int[SIZE]). + return base_type_node + elif not empty and nonempty: + # declaration of either memoryview slice or buffer. + if is_memoryviewslice_access(s): + return p_memoryviewslice_access(s, base_type_node) + else: + return p_buffer_or_template(s, base_type_node, None) + # return p_buffer_access(s, base_type_node) + elif not empty and not nonempty: + # only anonymous C arrays and memoryview slice arrays here. We + # disallow buffer declarations for now, due to ambiguity with anonymous + # C arrays. + if is_memoryviewslice_access(s): + return p_memoryviewslice_access(s, base_type_node) + else: + return base_type_node + +def is_memoryviewslice_access(s): + # s.sy == '[' + # a memoryview slice declaration is distinguishable from a buffer access + # declaration by the first entry in the bracketed list. The buffer will + # not have an unnested colon in the first entry; the memoryview slice will. + saved = [(s.sy, s.systring)] + s.next() + retval = False + if s.systring == ':': + retval = True + elif s.sy == 'INT': + saved.append((s.sy, s.systring)) + s.next() + if s.sy == ':': + retval = True + + for sv in saved[::-1]: + s.put_back(*sv) + + return retval + +def p_memoryviewslice_access(s, base_type_node): + # s.sy == '[' + pos = s.position() + s.next() + subscripts, _ = p_subscript_list(s) + # make sure each entry in subscripts is a slice + for subscript in subscripts: + if len(subscript) < 2: + s.error("An axis specification in memoryview declaration does not have a ':'.") + s.expect(']') + indexes = make_slice_nodes(pos, subscripts) + result = Nodes.MemoryViewSliceTypeNode(pos, + base_type_node = base_type_node, + axes = indexes) + return result + +def looking_at_name(s): + return s.sy == 'IDENT' and not s.systring in calling_convention_words + +def looking_at_expr(s): + if s.systring in base_type_start_words: + return False + elif s.sy == 'IDENT': + is_type = False + name = s.systring + dotted_path = [] + s.next() + + while s.sy == '.': + s.next() + dotted_path.append(s.systring) + s.expect('IDENT') + + saved = s.sy, s.systring + if s.sy == 'IDENT': + is_type = True + elif s.sy == '*' or s.sy == '**': + s.next() + is_type = s.sy in (')', ']') + s.put_back(*saved) + elif s.sy == '(': + s.next() + is_type = s.sy == '*' + s.put_back(*saved) + elif s.sy == '[': + s.next() + is_type = s.sy == ']' or not looking_at_expr(s) # could be a nested template type + s.put_back(*saved) + + dotted_path.reverse() + for p in dotted_path: + s.put_back('IDENT', p) + s.put_back('.', '.') + + s.put_back('IDENT', name) + return not is_type and saved[0] + else: + return True + +def looking_at_base_type(s): + #print "looking_at_base_type?", s.sy, s.systring, s.position() + return s.sy == 'IDENT' and s.systring in base_type_start_words + +def looking_at_dotted_name(s): + if s.sy == 'IDENT': + name = s.systring + s.next() + result = s.sy == '.' + s.put_back('IDENT', name) + return result + else: + return 0 + +def looking_at_call(s): + "See if we're looking at a.b.c(" + # Don't mess up the original position, so save and restore it. + # Unfortunately there's no good way to handle this, as a subsequent call + # to next() will not advance the position until it reads a new token. + position = s.start_line, s.start_col + result = looking_at_expr(s) == u'(' + if not result: + s.start_line, s.start_col = position + return result + +basic_c_type_names = cython.declare( + set, set(["void", "char", "int", "float", "double", "bint"])) + +special_basic_c_types = cython.declare(dict, { + # name : (signed, longness) + "Py_UNICODE" : (0, 0), + "Py_UCS4" : (0, 0), + "Py_hash_t" : (2, 0), + "Py_ssize_t" : (2, 0), + "ssize_t" : (2, 0), + "size_t" : (0, 0), + "ptrdiff_t" : (2, 0), + "Py_tss_t" : (1, 0), +}) + +sign_and_longness_words = cython.declare( + set, set(["short", "long", "signed", "unsigned"])) + +base_type_start_words = cython.declare( + set, + basic_c_type_names + | sign_and_longness_words + | set(special_basic_c_types)) + +struct_enum_union = cython.declare( + set, set(["struct", "union", "enum", "packed"])) + +def p_sign_and_longness(s): + signed = 1 + longness = 0 + while s.sy == 'IDENT' and s.systring in sign_and_longness_words: + if s.systring == 'unsigned': + signed = 0 + elif s.systring == 'signed': + signed = 2 + elif s.systring == 'short': + longness = -1 + elif s.systring == 'long': + longness += 1 + s.next() + return signed, longness + +def p_opt_cname(s): + literal = p_opt_string_literal(s, 'u') + if literal is not None: + cname = EncodedString(literal) + cname.encoding = s.source_encoding + else: + cname = None + return cname + +def p_c_declarator(s, ctx = Ctx(), empty = 0, is_type = 0, cmethod_flag = 0, + assignable = 0, nonempty = 0, + calling_convention_allowed = 0): + # If empty is true, the declarator must be empty. If nonempty is true, + # the declarator must be nonempty. Otherwise we don't care. + # If cmethod_flag is true, then if this declarator declares + # a function, it's a C method of an extension type. + pos = s.position() + if s.sy == '(': + s.next() + if s.sy == ')' or looking_at_name(s): + base = Nodes.CNameDeclaratorNode(pos, name=s.context.intern_ustring(u""), cname=None) + result = p_c_func_declarator(s, pos, ctx, base, cmethod_flag) + else: + result = p_c_declarator(s, ctx, empty = empty, is_type = is_type, + cmethod_flag = cmethod_flag, + nonempty = nonempty, + calling_convention_allowed = 1) + s.expect(')') + else: + result = p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag, + assignable, nonempty) + if not calling_convention_allowed and result.calling_convention and s.sy != '(': + error(s.position(), "%s on something that is not a function" + % result.calling_convention) + while s.sy in ('[', '('): + pos = s.position() + if s.sy == '[': + result = p_c_array_declarator(s, result) + else: # sy == '(' + s.next() + result = p_c_func_declarator(s, pos, ctx, result, cmethod_flag) + cmethod_flag = 0 + return result + +def p_c_array_declarator(s, base): + pos = s.position() + s.next() # '[' + if s.sy != ']': + dim = p_testlist(s) + else: + dim = None + s.expect(']') + return Nodes.CArrayDeclaratorNode(pos, base = base, dimension = dim) + +def p_c_func_declarator(s, pos, ctx, base, cmethod_flag): + # Opening paren has already been skipped + args = p_c_arg_list(s, ctx, cmethod_flag = cmethod_flag, + nonempty_declarators = 0) + ellipsis = p_optional_ellipsis(s) + s.expect(')') + nogil = p_nogil(s) + exc_val, exc_check = p_exception_value_clause(s) + # TODO - warning to enforce preferred exception specification order + nogil = nogil or p_nogil(s) + with_gil = p_with_gil(s) + return Nodes.CFuncDeclaratorNode(pos, + base = base, args = args, has_varargs = ellipsis, + exception_value = exc_val, exception_check = exc_check, + nogil = nogil or ctx.nogil or with_gil, with_gil = with_gil) + +supported_overloaded_operators = cython.declare(set, set([ + '+', '-', '*', '/', '%', + '++', '--', '~', '|', '&', '^', '<<', '>>', ',', + '==', '!=', '>=', '>', '<=', '<', + '[]', '()', '!', '=', + 'bool', +])) + +def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag, + assignable, nonempty): + pos = s.position() + calling_convention = p_calling_convention(s) + if s.sy == '*': + s.next() + if s.systring == 'const': + const_pos = s.position() + s.next() + const_base = p_c_declarator(s, ctx, empty = empty, + is_type = is_type, + cmethod_flag = cmethod_flag, + assignable = assignable, + nonempty = nonempty) + base = Nodes.CConstDeclaratorNode(const_pos, base = const_base) + else: + base = p_c_declarator(s, ctx, empty = empty, is_type = is_type, + cmethod_flag = cmethod_flag, + assignable = assignable, nonempty = nonempty) + result = Nodes.CPtrDeclaratorNode(pos, + base = base) + elif s.sy == '**': # scanner returns this as a single token + s.next() + base = p_c_declarator(s, ctx, empty = empty, is_type = is_type, + cmethod_flag = cmethod_flag, + assignable = assignable, nonempty = nonempty) + result = Nodes.CPtrDeclaratorNode(pos, + base = Nodes.CPtrDeclaratorNode(pos, + base = base)) + elif s.sy == '&': + s.next() + base = p_c_declarator(s, ctx, empty = empty, is_type = is_type, + cmethod_flag = cmethod_flag, + assignable = assignable, nonempty = nonempty) + result = Nodes.CReferenceDeclaratorNode(pos, base = base) + else: + rhs = None + if s.sy == 'IDENT': + name = s.systring + if empty: + error(s.position(), "Declarator should be empty") + s.next() + cname = p_opt_cname(s) + if name != 'operator' and s.sy == '=' and assignable: + s.next() + rhs = p_test(s) + else: + if nonempty: + error(s.position(), "Empty declarator") + name = "" + cname = None + if cname is None and ctx.namespace is not None and nonempty: + cname = ctx.namespace + "::" + name + if name == 'operator' and ctx.visibility == 'extern' and nonempty: + op = s.sy + if [1 for c in op if c in '+-*/<=>!%&|([^~,']: + s.next() + # Handle diphthong operators. + if op == '(': + s.expect(')') + op = '()' + elif op == '[': + s.expect(']') + op = '[]' + elif op in ('-', '+', '|', '&') and s.sy == op: + op *= 2 # ++, --, ... + s.next() + elif s.sy == '=': + op += s.sy # +=, -=, ... + s.next() + if op not in supported_overloaded_operators: + s.error("Overloading operator '%s' not yet supported." % op, + fatal=False) + name += op + elif op == 'IDENT': + op = s.systring; + if op not in supported_overloaded_operators: + s.error("Overloading operator '%s' not yet supported." % op, + fatal=False) + name = name + ' ' + op + s.next() + result = Nodes.CNameDeclaratorNode(pos, + name = name, cname = cname, default = rhs) + result.calling_convention = calling_convention + return result + +def p_nogil(s): + if s.sy == 'IDENT' and s.systring == 'nogil': + s.next() + return 1 + else: + return 0 + +def p_with_gil(s): + if s.sy == 'with': + s.next() + s.expect_keyword('gil') + return 1 + else: + return 0 + +def p_exception_value_clause(s): + exc_val = None + exc_check = 0 + + if s.sy == 'IDENT' and s.systring == 'noexcept': + s.next() + exc_check = False # No-op in Cython 0.29.x + elif s.sy == 'except': + s.next() + if s.sy == '*': + exc_check = 1 + s.next() + elif s.sy == '+': + exc_check = '+' + s.next() + if s.sy == 'IDENT': + name = s.systring + s.next() + exc_val = p_name(s, name) + elif s.sy == '*': + exc_val = ExprNodes.CharNode(s.position(), value=u'*') + s.next() + else: + if s.sy == '?': + exc_check = 1 + s.next() + exc_val = p_test(s) + return exc_val, exc_check + +c_arg_list_terminators = cython.declare(set, set(['*', '**', '.', ')', ':'])) + +def p_c_arg_list(s, ctx = Ctx(), in_pyfunc = 0, cmethod_flag = 0, + nonempty_declarators = 0, kw_only = 0, annotated = 1): + # Comma-separated list of C argument declarations, possibly empty. + # May have a trailing comma. + args = [] + is_self_arg = cmethod_flag + while s.sy not in c_arg_list_terminators: + args.append(p_c_arg_decl(s, ctx, in_pyfunc, is_self_arg, + nonempty = nonempty_declarators, kw_only = kw_only, + annotated = annotated)) + if s.sy != ',': + break + s.next() + is_self_arg = 0 + return args + +def p_optional_ellipsis(s): + if s.sy == '.': + expect_ellipsis(s) + return 1 + else: + return 0 + +def p_c_arg_decl(s, ctx, in_pyfunc, cmethod_flag = 0, nonempty = 0, + kw_only = 0, annotated = 1): + pos = s.position() + not_none = or_none = 0 + default = None + annotation = None + if s.in_python_file: + # empty type declaration + base_type = Nodes.CSimpleBaseTypeNode(pos, + name = None, module_path = [], + is_basic_c_type = 0, signed = 0, + complex = 0, longness = 0, + is_self_arg = cmethod_flag, templates = None) + else: + base_type = p_c_base_type(s, cmethod_flag, nonempty = nonempty) + declarator = p_c_declarator(s, ctx, nonempty = nonempty) + if s.sy in ('not', 'or') and not s.in_python_file: + kind = s.sy + s.next() + if s.sy == 'IDENT' and s.systring == 'None': + s.next() + else: + s.error("Expected 'None'") + if not in_pyfunc: + error(pos, "'%s None' only allowed in Python functions" % kind) + or_none = kind == 'or' + not_none = kind == 'not' + if annotated and s.sy == ':': + s.next() + annotation = p_test(s) + if s.sy == '=': + s.next() + if 'pxd' in ctx.level: + if s.sy in ['*', '?']: + # TODO(github/1736): Make this an error for inline declarations. + default = ExprNodes.NoneNode(pos) + s.next() + elif 'inline' in ctx.modifiers: + default = p_test(s) + else: + error(pos, "default values cannot be specified in pxd files, use ? or *") + else: + default = p_test(s) + return Nodes.CArgDeclNode(pos, + base_type = base_type, + declarator = declarator, + not_none = not_none, + or_none = or_none, + default = default, + annotation = annotation, + kw_only = kw_only) + +def p_api(s): + if s.sy == 'IDENT' and s.systring == 'api': + s.next() + return 1 + else: + return 0 + +def p_cdef_statement(s, ctx): + pos = s.position() + ctx.visibility = p_visibility(s, ctx.visibility) + ctx.api = ctx.api or p_api(s) + if ctx.api: + if ctx.visibility not in ('private', 'public'): + error(pos, "Cannot combine 'api' with '%s'" % ctx.visibility) + if (ctx.visibility == 'extern') and s.sy == 'from': + return p_cdef_extern_block(s, pos, ctx) + elif s.sy == 'import': + s.next() + return p_cdef_extern_block(s, pos, ctx) + elif p_nogil(s): + ctx.nogil = 1 + if ctx.overridable: + error(pos, "cdef blocks cannot be declared cpdef") + return p_cdef_block(s, ctx) + elif s.sy == ':': + if ctx.overridable: + error(pos, "cdef blocks cannot be declared cpdef") + return p_cdef_block(s, ctx) + elif s.sy == 'class': + if ctx.level not in ('module', 'module_pxd'): + error(pos, "Extension type definition not allowed here") + if ctx.overridable: + error(pos, "Extension types cannot be declared cpdef") + return p_c_class_definition(s, pos, ctx) + elif s.sy == 'IDENT' and s.systring == 'cppclass': + return p_cpp_class_definition(s, pos, ctx) + elif s.sy == 'IDENT' and s.systring in struct_enum_union: + if ctx.level not in ('module', 'module_pxd'): + error(pos, "C struct/union/enum definition not allowed here") + if ctx.overridable: + if s.systring != 'enum': + error(pos, "C struct/union cannot be declared cpdef") + return p_struct_enum(s, pos, ctx) + elif s.sy == 'IDENT' and s.systring == 'fused': + return p_fused_definition(s, pos, ctx) + else: + return p_c_func_or_var_declaration(s, pos, ctx) + +def p_cdef_block(s, ctx): + return p_suite(s, ctx(cdef_flag = 1)) + +def p_cdef_extern_block(s, pos, ctx): + if ctx.overridable: + error(pos, "cdef extern blocks cannot be declared cpdef") + include_file = None + s.expect('from') + if s.sy == '*': + s.next() + else: + include_file = p_string_literal(s, 'u')[2] + ctx = ctx(cdef_flag = 1, visibility = 'extern') + if s.systring == "namespace": + s.next() + ctx.namespace = p_string_literal(s, 'u')[2] + if p_nogil(s): + ctx.nogil = 1 + + # Use "docstring" as verbatim string to include + verbatim_include, body = p_suite_with_docstring(s, ctx, True) + + return Nodes.CDefExternNode(pos, + include_file = include_file, + verbatim_include = verbatim_include, + body = body, + namespace = ctx.namespace) + +def p_c_enum_definition(s, pos, ctx): + # s.sy == ident 'enum' + s.next() + if s.sy == 'IDENT': + name = s.systring + s.next() + cname = p_opt_cname(s) + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + name + else: + name = None + cname = None + items = None + s.expect(':') + items = [] + if s.sy != 'NEWLINE': + p_c_enum_line(s, ctx, items) + else: + s.next() # 'NEWLINE' + s.expect_indent() + while s.sy not in ('DEDENT', 'EOF'): + p_c_enum_line(s, ctx, items) + s.expect_dedent() + return Nodes.CEnumDefNode( + pos, name = name, cname = cname, items = items, + typedef_flag = ctx.typedef_flag, visibility = ctx.visibility, + create_wrapper = ctx.overridable, + api = ctx.api, in_pxd = ctx.level == 'module_pxd') + +def p_c_enum_line(s, ctx, items): + if s.sy != 'pass': + p_c_enum_item(s, ctx, items) + while s.sy == ',': + s.next() + if s.sy in ('NEWLINE', 'EOF'): + break + p_c_enum_item(s, ctx, items) + else: + s.next() + s.expect_newline("Syntax error in enum item list") + +def p_c_enum_item(s, ctx, items): + pos = s.position() + name = p_ident(s) + cname = p_opt_cname(s) + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + name + value = None + if s.sy == '=': + s.next() + value = p_test(s) + items.append(Nodes.CEnumDefItemNode(pos, + name = name, cname = cname, value = value)) + +def p_c_struct_or_union_definition(s, pos, ctx): + packed = False + if s.systring == 'packed': + packed = True + s.next() + if s.sy != 'IDENT' or s.systring != 'struct': + s.expected('struct') + # s.sy == ident 'struct' or 'union' + kind = s.systring + s.next() + name = p_ident(s) + cname = p_opt_cname(s) + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + name + attributes = None + if s.sy == ':': + s.next() + s.expect('NEWLINE') + s.expect_indent() + attributes = [] + body_ctx = Ctx() + while s.sy != 'DEDENT': + if s.sy != 'pass': + attributes.append( + p_c_func_or_var_declaration(s, s.position(), body_ctx)) + else: + s.next() + s.expect_newline("Expected a newline") + s.expect_dedent() + else: + s.expect_newline("Syntax error in struct or union definition") + return Nodes.CStructOrUnionDefNode(pos, + name = name, cname = cname, kind = kind, attributes = attributes, + typedef_flag = ctx.typedef_flag, visibility = ctx.visibility, + api = ctx.api, in_pxd = ctx.level == 'module_pxd', packed = packed) + +def p_fused_definition(s, pos, ctx): + """ + c(type)def fused my_fused_type: + ... + """ + # s.systring == 'fused' + + if ctx.level not in ('module', 'module_pxd'): + error(pos, "Fused type definition not allowed here") + + s.next() + name = p_ident(s) + + s.expect(":") + s.expect_newline() + s.expect_indent() + + types = [] + while s.sy != 'DEDENT': + if s.sy != 'pass': + #types.append(p_c_declarator(s)) + types.append(p_c_base_type(s)) #, nonempty=1)) + else: + s.next() + + s.expect_newline() + + s.expect_dedent() + + if not types: + error(pos, "Need at least one type") + + return Nodes.FusedTypeNode(pos, name=name, types=types) + +def p_struct_enum(s, pos, ctx): + if s.systring == 'enum': + return p_c_enum_definition(s, pos, ctx) + else: + return p_c_struct_or_union_definition(s, pos, ctx) + +def p_visibility(s, prev_visibility): + pos = s.position() + visibility = prev_visibility + if s.sy == 'IDENT' and s.systring in ('extern', 'public', 'readonly'): + visibility = s.systring + if prev_visibility != 'private' and visibility != prev_visibility: + s.error("Conflicting visibility options '%s' and '%s'" + % (prev_visibility, visibility), fatal=False) + s.next() + return visibility + +def p_c_modifiers(s): + if s.sy == 'IDENT' and s.systring in ('inline',): + modifier = s.systring + s.next() + return [modifier] + p_c_modifiers(s) + return [] + +def p_c_func_or_var_declaration(s, pos, ctx): + cmethod_flag = ctx.level in ('c_class', 'c_class_pxd') + modifiers = p_c_modifiers(s) + base_type = p_c_base_type(s, nonempty = 1, templates = ctx.templates) + declarator = p_c_declarator(s, ctx(modifiers=modifiers), cmethod_flag = cmethod_flag, + assignable = 1, nonempty = 1) + declarator.overridable = ctx.overridable + if s.sy == 'IDENT' and s.systring == 'const' and ctx.level == 'cpp_class': + s.next() + is_const_method = 1 + else: + is_const_method = 0 + if s.sy == '->': + # Special enough to give a better error message and keep going. + s.error( + "Return type annotation is not allowed in cdef/cpdef signatures. " + "Please define it before the function name, as in C signatures.", + fatal=False) + s.next() + p_test(s) # Keep going, but ignore result. + if s.sy == ':': + if ctx.level not in ('module', 'c_class', 'module_pxd', 'c_class_pxd', 'cpp_class') and not ctx.templates: + s.error("C function definition not allowed here") + doc, suite = p_suite_with_docstring(s, Ctx(level='function')) + result = Nodes.CFuncDefNode(pos, + visibility = ctx.visibility, + base_type = base_type, + declarator = declarator, + body = suite, + doc = doc, + modifiers = modifiers, + api = ctx.api, + overridable = ctx.overridable, + is_const_method = is_const_method) + else: + #if api: + # s.error("'api' not allowed with variable declaration") + if is_const_method: + declarator.is_const_method = is_const_method + declarators = [declarator] + while s.sy == ',': + s.next() + if s.sy == 'NEWLINE': + break + declarator = p_c_declarator(s, ctx, cmethod_flag = cmethod_flag, + assignable = 1, nonempty = 1) + declarators.append(declarator) + doc_line = s.start_line + 1 + s.expect_newline("Syntax error in C variable declaration", ignore_semicolon=True) + if ctx.level in ('c_class', 'c_class_pxd') and s.start_line == doc_line: + doc = p_doc_string(s) + else: + doc = None + result = Nodes.CVarDefNode(pos, + visibility = ctx.visibility, + base_type = base_type, + declarators = declarators, + in_pxd = ctx.level in ('module_pxd', 'c_class_pxd'), + doc = doc, + api = ctx.api, + modifiers = modifiers, + overridable = ctx.overridable) + return result + +def p_ctypedef_statement(s, ctx): + # s.sy == 'ctypedef' + pos = s.position() + s.next() + visibility = p_visibility(s, ctx.visibility) + api = p_api(s) + ctx = ctx(typedef_flag = 1, visibility = visibility) + if api: + ctx.api = 1 + if s.sy == 'class': + return p_c_class_definition(s, pos, ctx) + elif s.sy == 'IDENT' and s.systring in struct_enum_union: + return p_struct_enum(s, pos, ctx) + elif s.sy == 'IDENT' and s.systring == 'fused': + return p_fused_definition(s, pos, ctx) + else: + base_type = p_c_base_type(s, nonempty = 1) + declarator = p_c_declarator(s, ctx, is_type = 1, nonempty = 1) + s.expect_newline("Syntax error in ctypedef statement", ignore_semicolon=True) + return Nodes.CTypeDefNode( + pos, base_type = base_type, + declarator = declarator, + visibility = visibility, api = api, + in_pxd = ctx.level == 'module_pxd') + +def p_decorators(s): + decorators = [] + while s.sy == '@': + pos = s.position() + s.next() + decstring = p_dotted_name(s, as_allowed=0)[2] + names = decstring.split('.') + decorator = ExprNodes.NameNode(pos, name=s.context.intern_ustring(names[0])) + for name in names[1:]: + decorator = ExprNodes.AttributeNode( + pos, attribute=s.context.intern_ustring(name), obj=decorator) + if s.sy == '(': + decorator = p_call(s, decorator) + decorators.append(Nodes.DecoratorNode(pos, decorator=decorator)) + s.expect_newline("Expected a newline after decorator") + return decorators + + +def _reject_cdef_modifier_in_py(s, name): + """Step over incorrectly placed cdef modifiers (@see _CDEF_MODIFIERS) to provide a good error message for them. + """ + if s.sy == 'IDENT' and name in _CDEF_MODIFIERS: + # Special enough to provide a good error message. + s.error("Cannot use cdef modifier '%s' in Python function signature. Use a decorator instead." % name, fatal=False) + return p_ident(s) # Keep going, in case there are other errors. + return name + + +def p_def_statement(s, decorators=None, is_async_def=False): + # s.sy == 'def' + pos = s.position() + # PEP 492 switches the async/await keywords on in "async def" functions + if is_async_def: + s.enter_async() + s.next() + name = _reject_cdef_modifier_in_py(s, p_ident(s)) + s.expect( + '(', + "Expected '(', found '%s'. Did you use cdef syntax in a Python declaration? " + "Use decorators and Python type annotations instead." % ( + s.systring if s.sy == 'IDENT' else s.sy)) + args, star_arg, starstar_arg = p_varargslist(s, terminator=')') + s.expect(')') + _reject_cdef_modifier_in_py(s, s.systring) + return_type_annotation = None + if s.sy == '->': + s.next() + return_type_annotation = p_test(s) + _reject_cdef_modifier_in_py(s, s.systring) + + doc, body = p_suite_with_docstring(s, Ctx(level='function')) + if is_async_def: + s.exit_async() + + return Nodes.DefNode( + pos, name=name, args=args, star_arg=star_arg, starstar_arg=starstar_arg, + doc=doc, body=body, decorators=decorators, is_async_def=is_async_def, + return_type_annotation=return_type_annotation) + + +def p_varargslist(s, terminator=')', annotated=1): + args = p_c_arg_list(s, in_pyfunc = 1, nonempty_declarators = 1, + annotated = annotated) + star_arg = None + starstar_arg = None + if s.sy == '*': + s.next() + if s.sy == 'IDENT': + star_arg = p_py_arg_decl(s, annotated=annotated) + if s.sy == ',': + s.next() + args.extend(p_c_arg_list(s, in_pyfunc = 1, + nonempty_declarators = 1, kw_only = 1, annotated = annotated)) + elif s.sy != terminator: + s.error("Syntax error in Python function argument list") + if s.sy == '**': + s.next() + starstar_arg = p_py_arg_decl(s, annotated=annotated) + if s.sy == ',': + s.next() + return (args, star_arg, starstar_arg) + +def p_py_arg_decl(s, annotated = 1): + pos = s.position() + name = p_ident(s) + annotation = None + if annotated and s.sy == ':': + s.next() + annotation = p_test(s) + return Nodes.PyArgDeclNode(pos, name = name, annotation = annotation) + + +def p_class_statement(s, decorators): + # s.sy == 'class' + pos = s.position() + s.next() + class_name = EncodedString(p_ident(s)) + class_name.encoding = s.source_encoding # FIXME: why is this needed? + arg_tuple = None + keyword_dict = None + if s.sy == '(': + positional_args, keyword_args = p_call_parse_args(s, allow_genexp=False) + arg_tuple, keyword_dict = p_call_build_packed_args(pos, positional_args, keyword_args) + if arg_tuple is None: + # XXX: empty arg_tuple + arg_tuple = ExprNodes.TupleNode(pos, args=[]) + doc, body = p_suite_with_docstring(s, Ctx(level='class')) + return Nodes.PyClassDefNode( + pos, name=class_name, + bases=arg_tuple, + keyword_args=keyword_dict, + doc=doc, body=body, decorators=decorators, + force_py3_semantics=s.context.language_level >= 3) + + +def p_c_class_definition(s, pos, ctx): + # s.sy == 'class' + s.next() + module_path = [] + class_name = p_ident(s) + while s.sy == '.': + s.next() + module_path.append(class_name) + class_name = p_ident(s) + if module_path and ctx.visibility != 'extern': + error(pos, "Qualified class name only allowed for 'extern' C class") + if module_path and s.sy == 'IDENT' and s.systring == 'as': + s.next() + as_name = p_ident(s) + else: + as_name = class_name + objstruct_name = None + typeobj_name = None + bases = None + check_size = None + if s.sy == '(': + positional_args, keyword_args = p_call_parse_args(s, allow_genexp=False) + if keyword_args: + s.error("C classes cannot take keyword bases.") + bases, _ = p_call_build_packed_args(pos, positional_args, keyword_args) + if bases is None: + bases = ExprNodes.TupleNode(pos, args=[]) + + if s.sy == '[': + if ctx.visibility not in ('public', 'extern') and not ctx.api: + error(s.position(), "Name options only allowed for 'public', 'api', or 'extern' C class") + objstruct_name, typeobj_name, check_size = p_c_class_options(s) + if s.sy == ':': + if ctx.level == 'module_pxd': + body_level = 'c_class_pxd' + else: + body_level = 'c_class' + doc, body = p_suite_with_docstring(s, Ctx(level=body_level)) + else: + s.expect_newline("Syntax error in C class definition") + doc = None + body = None + if ctx.visibility == 'extern': + if not module_path: + error(pos, "Module name required for 'extern' C class") + if typeobj_name: + error(pos, "Type object name specification not allowed for 'extern' C class") + elif ctx.visibility == 'public': + if not objstruct_name: + error(pos, "Object struct name specification required for 'public' C class") + if not typeobj_name: + error(pos, "Type object name specification required for 'public' C class") + elif ctx.visibility == 'private': + if ctx.api: + if not objstruct_name: + error(pos, "Object struct name specification required for 'api' C class") + if not typeobj_name: + error(pos, "Type object name specification required for 'api' C class") + else: + error(pos, "Invalid class visibility '%s'" % ctx.visibility) + return Nodes.CClassDefNode(pos, + visibility = ctx.visibility, + typedef_flag = ctx.typedef_flag, + api = ctx.api, + module_name = ".".join(module_path), + class_name = class_name, + as_name = as_name, + bases = bases, + objstruct_name = objstruct_name, + typeobj_name = typeobj_name, + check_size = check_size, + in_pxd = ctx.level == 'module_pxd', + doc = doc, + body = body) + + +def p_c_class_options(s): + objstruct_name = None + typeobj_name = None + check_size = None + s.expect('[') + while 1: + if s.sy != 'IDENT': + break + if s.systring == 'object': + s.next() + objstruct_name = p_ident(s) + elif s.systring == 'type': + s.next() + typeobj_name = p_ident(s) + elif s.systring == 'check_size': + s.next() + check_size = p_ident(s) + if check_size not in ('ignore', 'warn', 'error'): + s.error("Expected one of ignore, warn or error, found %r" % check_size) + if s.sy != ',': + break + s.next() + s.expect(']', "Expected 'object', 'type' or 'check_size'") + return objstruct_name, typeobj_name, check_size + + +def p_property_decl(s): + pos = s.position() + s.next() # 'property' + name = p_ident(s) + doc, body = p_suite_with_docstring( + s, Ctx(level='property'), with_doc_only=True) + return Nodes.PropertyNode(pos, name=name, doc=doc, body=body) + + +def p_ignorable_statement(s): + """ + Parses any kind of ignorable statement that is allowed in .pxd files. + """ + if s.sy == 'BEGIN_STRING': + pos = s.position() + string_node = p_atom(s) + s.expect_newline("Syntax error in string", ignore_semicolon=True) + return Nodes.ExprStatNode(pos, expr=string_node) + return None + + +def p_doc_string(s): + if s.sy == 'BEGIN_STRING': + pos = s.position() + kind, bytes_result, unicode_result = p_cat_string_literal(s) + s.expect_newline("Syntax error in doc string", ignore_semicolon=True) + if kind in ('u', ''): + return unicode_result + warning(pos, "Python 3 requires docstrings to be unicode strings") + return bytes_result + else: + return None + + +def _extract_docstring(node): + """ + Extract a docstring from a statement or from the first statement + in a list. Remove the statement if found. Return a tuple + (plain-docstring or None, node). + """ + doc_node = None + if node is None: + pass + elif isinstance(node, Nodes.ExprStatNode): + if node.expr.is_string_literal: + doc_node = node.expr + node = Nodes.StatListNode(node.pos, stats=[]) + elif isinstance(node, Nodes.StatListNode) and node.stats: + stats = node.stats + if isinstance(stats[0], Nodes.ExprStatNode): + if stats[0].expr.is_string_literal: + doc_node = stats[0].expr + del stats[0] + + if doc_node is None: + doc = None + elif isinstance(doc_node, ExprNodes.BytesNode): + warning(node.pos, + "Python 3 requires docstrings to be unicode strings") + doc = doc_node.value + elif isinstance(doc_node, ExprNodes.StringNode): + doc = doc_node.unicode_value + if doc is None: + doc = doc_node.value + else: + doc = doc_node.value + return doc, node + + +def p_code(s, level=None, ctx=Ctx): + body = p_statement_list(s, ctx(level = level), first_statement = 1) + if s.sy != 'EOF': + s.error("Syntax error in statement [%s,%s]" % ( + repr(s.sy), repr(s.systring))) + return body + + +_match_compiler_directive_comment = cython.declare(object, re.compile( + r"^#\s*cython\s*:\s*((\w|[.])+\s*=.*)$").match) + + +def p_compiler_directive_comments(s): + result = {} + while s.sy == 'commentline': + pos = s.position() + m = _match_compiler_directive_comment(s.systring) + if m: + directives_string = m.group(1).strip() + try: + new_directives = Options.parse_directive_list(directives_string, ignore_unknown=True) + except ValueError as e: + s.error(e.args[0], fatal=False) + s.next() + continue + + for name in new_directives: + if name not in result: + pass + elif new_directives[name] == result[name]: + warning(pos, "Duplicate directive found: %s" % (name,)) + else: + s.error("Conflicting settings found for top-level directive %s: %r and %r" % ( + name, result[name], new_directives[name]), pos=pos) + + if 'language_level' in new_directives: + # Make sure we apply the language level already to the first token that follows the comments. + s.context.set_language_level(new_directives['language_level']) + + result.update(new_directives) + + s.next() + return result + + +def p_module(s, pxd, full_module_name, ctx=Ctx): + pos = s.position() + + directive_comments = p_compiler_directive_comments(s) + s.parse_comments = False + + if s.context.language_level is None: + s.context.set_language_level(2) # Arcadia default. + + if s.context.language_level is None: + s.context.set_language_level(2) + if pos[0].filename: + import warnings + warnings.warn( + "Cython directive 'language_level' not set, using 2 for now (Py2). " + "This will change in a later release! File: %s" % pos[0].filename, + FutureWarning, + stacklevel=1 if cython.compiled else 2, + ) + + doc = p_doc_string(s) + if pxd: + level = 'module_pxd' + else: + level = 'module' + + body = p_statement_list(s, ctx(level=level), first_statement = 1) + if s.sy != 'EOF': + s.error("Syntax error in statement [%s,%s]" % ( + repr(s.sy), repr(s.systring))) + return ModuleNode(pos, doc = doc, body = body, + full_module_name = full_module_name, + directive_comments = directive_comments) + +def p_template_definition(s): + name = p_ident(s) + if s.sy == '=': + s.expect('=') + s.expect('*') + required = False + else: + required = True + return name, required + +def p_cpp_class_definition(s, pos, ctx): + # s.sy == 'cppclass' + s.next() + module_path = [] + class_name = p_ident(s) + cname = p_opt_cname(s) + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + class_name + if s.sy == '.': + error(pos, "Qualified class name not allowed C++ class") + if s.sy == '[': + s.next() + templates = [p_template_definition(s)] + while s.sy == ',': + s.next() + templates.append(p_template_definition(s)) + s.expect(']') + template_names = [name for name, required in templates] + else: + templates = None + template_names = None + if s.sy == '(': + s.next() + base_classes = [p_c_base_type(s, templates = template_names)] + while s.sy == ',': + s.next() + base_classes.append(p_c_base_type(s, templates = template_names)) + s.expect(')') + else: + base_classes = [] + if s.sy == '[': + error(s.position(), "Name options not allowed for C++ class") + nogil = p_nogil(s) + if s.sy == ':': + s.next() + s.expect('NEWLINE') + s.expect_indent() + attributes = [] + body_ctx = Ctx(visibility = ctx.visibility, level='cpp_class', nogil=nogil or ctx.nogil) + body_ctx.templates = template_names + while s.sy != 'DEDENT': + if s.sy != 'pass': + attributes.append(p_cpp_class_attribute(s, body_ctx)) + else: + s.next() + s.expect_newline("Expected a newline") + s.expect_dedent() + else: + attributes = None + s.expect_newline("Syntax error in C++ class definition") + return Nodes.CppClassNode(pos, + name = class_name, + cname = cname, + base_classes = base_classes, + visibility = ctx.visibility, + in_pxd = ctx.level == 'module_pxd', + attributes = attributes, + templates = templates) + +def p_cpp_class_attribute(s, ctx): + decorators = None + if s.sy == '@': + decorators = p_decorators(s) + if s.systring == 'cppclass': + return p_cpp_class_definition(s, s.position(), ctx) + elif s.systring == 'ctypedef': + return p_ctypedef_statement(s, ctx) + elif s.sy == 'IDENT' and s.systring in struct_enum_union: + if s.systring != 'enum': + return p_cpp_class_definition(s, s.position(), ctx) + else: + return p_struct_enum(s, s.position(), ctx) + else: + node = p_c_func_or_var_declaration(s, s.position(), ctx) + if decorators is not None: + tup = Nodes.CFuncDefNode, Nodes.CVarDefNode, Nodes.CClassDefNode + if ctx.allow_struct_enum_decorator: + tup += Nodes.CStructOrUnionDefNode, Nodes.CEnumDefNode + if not isinstance(node, tup): + s.error("Decorators can only be followed by functions or classes") + node.decorators = decorators + return node + + +#---------------------------------------------- +# +# Debugging +# +#---------------------------------------------- + +def print_parse_tree(f, node, level, key = None): + ind = " " * level + if node: + f.write(ind) + if key: + f.write("%s: " % key) + t = type(node) + if t is tuple: + f.write("(%s @ %s\n" % (node[0], node[1])) + for i in range(2, len(node)): + print_parse_tree(f, node[i], level+1) + f.write("%s)\n" % ind) + return + elif isinstance(node, Nodes.Node): + try: + tag = node.tag + except AttributeError: + tag = node.__class__.__name__ + f.write("%s @ %s\n" % (tag, node.pos)) + for name, value in node.__dict__.items(): + if name != 'tag' and name != 'pos': + print_parse_tree(f, value, level+1, name) + return + elif t is list: + f.write("[\n") + for i in range(len(node)): + print_parse_tree(f, node[i], level+1) + f.write("%s]\n" % ind) + return + f.write("%s%s\n" % (ind, node)) diff --git a/contrib/tools/cython/Cython/Compiler/Pipeline.py b/contrib/tools/cython/Cython/Compiler/Pipeline.py new file mode 100644 index 00000000000..5194c3e49b9 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Pipeline.py @@ -0,0 +1,369 @@ +from __future__ import absolute_import + +import itertools +from time import time + +from . import Errors +from . import DebugFlags +from . import Options +from .Errors import CompileError, InternalError, AbortError +from . import Naming + +# +# Really small pipeline stages +# +def dumptree(t): + # For quick debugging in pipelines + print(t.dump()) + return t + +def abort_on_errors(node): + # Stop the pipeline if there are any errors. + if Errors.num_errors != 0: + raise AbortError("pipeline break") + return node + +def parse_stage_factory(context): + def parse(compsrc): + source_desc = compsrc.source_desc + full_module_name = compsrc.full_module_name + initial_pos = (source_desc, 1, 0) + saved_cimport_from_pyx, Options.cimport_from_pyx = Options.cimport_from_pyx, False + scope = context.find_module(full_module_name, pos = initial_pos, need_pxd = 0) + Options.cimport_from_pyx = saved_cimport_from_pyx + tree = context.parse(source_desc, scope, pxd = 0, full_module_name = full_module_name) + tree.compilation_source = compsrc + tree.scope = scope + tree.is_pxd = False + return tree + return parse + +def parse_pxd_stage_factory(context, scope, module_name): + def parse(source_desc): + tree = context.parse(source_desc, scope, pxd=True, + full_module_name=module_name) + tree.scope = scope + tree.is_pxd = True + return tree + return parse + +def generate_pyx_code_stage_factory(options, result): + def generate_pyx_code_stage(module_node): + module_node.process_implementation(options, result) + result.compilation_source = module_node.compilation_source + return result + return generate_pyx_code_stage + + +def inject_pxd_code_stage_factory(context): + def inject_pxd_code_stage(module_node): + for name, (statlistnode, scope) in context.pxds.items(): + module_node.merge_in(statlistnode, scope) + return module_node + return inject_pxd_code_stage + + +def use_utility_code_definitions(scope, target, seen=None): + if seen is None: + seen = set() + + for entry in scope.entries.values(): + if entry in seen: + continue + + seen.add(entry) + if entry.used and entry.utility_code_definition: + target.use_utility_code(entry.utility_code_definition) + for required_utility in entry.utility_code_definition.requires: + target.use_utility_code(required_utility) + elif entry.as_module: + use_utility_code_definitions(entry.as_module, target, seen) + + +def sort_utility_codes(utilcodes): + ranks = {} + def get_rank(utilcode): + if utilcode not in ranks: + ranks[utilcode] = 0 # prevent infinite recursion on circular dependencies + original_order = len(ranks) + ranks[utilcode] = 1 + min([get_rank(dep) for dep in utilcode.requires or ()] or [-1]) + original_order * 1e-8 + return ranks[utilcode] + for utilcode in utilcodes: + get_rank(utilcode) + return [utilcode for utilcode, _ in sorted(ranks.items(), key=lambda kv: kv[1])] + + +def normalize_deps(utilcodes): + deps = {} + for utilcode in utilcodes: + deps[utilcode] = utilcode + + def unify_dep(dep): + if dep in deps: + return deps[dep] + else: + deps[dep] = dep + return dep + + for utilcode in utilcodes: + utilcode.requires = [unify_dep(dep) for dep in utilcode.requires or ()] + + +def inject_utility_code_stage_factory(context): + def inject_utility_code_stage(module_node): + module_node.prepare_utility_code() + use_utility_code_definitions(context.cython_scope, module_node.scope) + module_node.scope.utility_code_list = sort_utility_codes(module_node.scope.utility_code_list) + normalize_deps(module_node.scope.utility_code_list) + added = [] + # Note: the list might be extended inside the loop (if some utility code + # pulls in other utility code, explicitly or implicitly) + for utilcode in module_node.scope.utility_code_list: + if utilcode in added: + continue + added.append(utilcode) + if utilcode.requires: + for dep in utilcode.requires: + if dep not in added and dep not in module_node.scope.utility_code_list: + module_node.scope.utility_code_list.append(dep) + tree = utilcode.get_tree(cython_scope=context.cython_scope) + if tree: + module_node.merge_in(tree.body, tree.scope, merge_scope=True) + return module_node + return inject_utility_code_stage + + +# +# Pipeline factories +# + +def create_pipeline(context, mode, exclude_classes=()): + assert mode in ('pyx', 'py', 'pxd') + from .Visitor import PrintTree + from .ParseTreeTransforms import WithTransform, NormalizeTree, PostParse, PxdPostParse + from .ParseTreeTransforms import ForwardDeclareTypes, InjectGilHandling, AnalyseDeclarationsTransform + from .ParseTreeTransforms import AnalyseExpressionsTransform, FindInvalidUseOfFusedTypes + from .ParseTreeTransforms import CreateClosureClasses, MarkClosureVisitor, DecoratorTransform + from .ParseTreeTransforms import TrackNumpyAttributes, InterpretCompilerDirectives, TransformBuiltinMethods + from .ParseTreeTransforms import ExpandInplaceOperators, ParallelRangeTransform + from .ParseTreeTransforms import CalculateQualifiedNamesTransform + from .TypeInference import MarkParallelAssignments, MarkOverflowingArithmetic + from .ParseTreeTransforms import AdjustDefByDirectives, AlignFunctionDefinitions + from .ParseTreeTransforms import RemoveUnreachableCode, GilCheck + from .FlowControl import ControlFlowAnalysis + from .AnalysedTreeTransforms import AutoTestDictTransform + from .AutoDocTransforms import EmbedSignature + from .Optimize import FlattenInListTransform, SwitchTransform, IterationTransform + from .Optimize import EarlyReplaceBuiltinCalls, OptimizeBuiltinCalls + from .Optimize import InlineDefNodeCalls + from .Optimize import ConstantFolding, FinalOptimizePhase + from .Optimize import DropRefcountingTransform + from .Optimize import ConsolidateOverflowCheck + from .Buffer import IntroduceBufferAuxiliaryVars + from .ModuleNode import check_c_declarations, check_c_declarations_pxd + + + if mode == 'pxd': + _check_c_declarations = check_c_declarations_pxd + _specific_post_parse = PxdPostParse(context) + else: + _check_c_declarations = check_c_declarations + _specific_post_parse = None + + if mode == 'py': + _align_function_definitions = AlignFunctionDefinitions(context) + else: + _align_function_definitions = None + + # NOTE: This is the "common" parts of the pipeline, which is also + # code in pxd files. So it will be run multiple times in a + # compilation stage. + stages = [ + NormalizeTree(context), + PostParse(context), + _specific_post_parse, + TrackNumpyAttributes(), + InterpretCompilerDirectives(context, context.compiler_directives), + ParallelRangeTransform(context), + AdjustDefByDirectives(context), + WithTransform(context), + MarkClosureVisitor(context), + _align_function_definitions, + RemoveUnreachableCode(context), + ConstantFolding(), + FlattenInListTransform(), + DecoratorTransform(context), + ForwardDeclareTypes(context), + InjectGilHandling(), + AnalyseDeclarationsTransform(context), + AutoTestDictTransform(context), + EmbedSignature(context), + EarlyReplaceBuiltinCalls(context), ## Necessary? + TransformBuiltinMethods(context), + MarkParallelAssignments(context), + ControlFlowAnalysis(context), + RemoveUnreachableCode(context), + # MarkParallelAssignments(context), + MarkOverflowingArithmetic(context), + IntroduceBufferAuxiliaryVars(context), + _check_c_declarations, + InlineDefNodeCalls(context), + AnalyseExpressionsTransform(context), + FindInvalidUseOfFusedTypes(context), + ExpandInplaceOperators(context), + IterationTransform(context), + SwitchTransform(context), + OptimizeBuiltinCalls(context), ## Necessary? + CreateClosureClasses(context), ## After all lookups and type inference + CalculateQualifiedNamesTransform(context), + ConsolidateOverflowCheck(context), + DropRefcountingTransform(), + FinalOptimizePhase(context), + GilCheck(), + ] + filtered_stages = [] + for s in stages: + if s.__class__ not in exclude_classes: + filtered_stages.append(s) + return filtered_stages + +def create_pyx_pipeline(context, options, result, py=False, exclude_classes=()): + if py: + mode = 'py' + else: + mode = 'pyx' + test_support = [] + if options.evaluate_tree_assertions: + from ..TestUtils import TreeAssertVisitor + test_support.append(TreeAssertVisitor()) + + if options.gdb_debug: + from ..Debugger import DebugWriter # requires Py2.5+ + from .ParseTreeTransforms import DebugTransform + context.gdb_debug_outputwriter = DebugWriter.CythonDebugWriter( + options.output_dir) + debug_transform = [DebugTransform(context, options, result)] + else: + debug_transform = [] + + return list(itertools.chain( + [parse_stage_factory(context)], + create_pipeline(context, mode, exclude_classes=exclude_classes), + test_support, + [inject_pxd_code_stage_factory(context), + inject_utility_code_stage_factory(context), + abort_on_errors], + debug_transform, + [generate_pyx_code_stage_factory(options, result)])) + +def create_pxd_pipeline(context, scope, module_name): + from .CodeGeneration import ExtractPxdCode + + # The pxd pipeline ends up with a CCodeWriter containing the + # code of the pxd, as well as a pxd scope. + return [ + parse_pxd_stage_factory(context, scope, module_name) + ] + create_pipeline(context, 'pxd') + [ + ExtractPxdCode() + ] + +def create_py_pipeline(context, options, result): + return create_pyx_pipeline(context, options, result, py=True) + +def create_pyx_as_pxd_pipeline(context, result): + from .ParseTreeTransforms import AlignFunctionDefinitions, \ + MarkClosureVisitor, WithTransform, AnalyseDeclarationsTransform + from .Optimize import ConstantFolding, FlattenInListTransform + from .Nodes import StatListNode + pipeline = [] + pyx_pipeline = create_pyx_pipeline(context, context.options, result, + exclude_classes=[ + AlignFunctionDefinitions, + MarkClosureVisitor, + ConstantFolding, + FlattenInListTransform, + WithTransform + ]) + for stage in pyx_pipeline: + pipeline.append(stage) + if isinstance(stage, AnalyseDeclarationsTransform): + # This is the last stage we need. + break + def fake_pxd(root): + for entry in root.scope.entries.values(): + if not entry.in_cinclude: + entry.defined_in_pxd = 1 + if entry.name == entry.cname and entry.visibility != 'extern': + # Always mangle non-extern cimported entries. + entry.cname = entry.scope.mangle(Naming.func_prefix, entry.name) + return StatListNode(root.pos, stats=[]), root.scope + pipeline.append(fake_pxd) + return pipeline + +def insert_into_pipeline(pipeline, transform, before=None, after=None): + """ + Insert a new transform into the pipeline after or before an instance of + the given class. e.g. + + pipeline = insert_into_pipeline(pipeline, transform, + after=AnalyseDeclarationsTransform) + """ + assert before or after + + cls = before or after + for i, t in enumerate(pipeline): + if isinstance(t, cls): + break + + if after: + i += 1 + + return pipeline[:i] + [transform] + pipeline[i:] + +# +# Running a pipeline +# + +_pipeline_entry_points = {} + + +def run_pipeline(pipeline, source, printtree=True): + from .Visitor import PrintTree + exec_ns = globals().copy() if DebugFlags.debug_verbose_pipeline else None + + def run(phase, data): + return phase(data) + + error = None + data = source + try: + try: + for phase in pipeline: + if phase is not None: + if not printtree and isinstance(phase, PrintTree): + continue + if DebugFlags.debug_verbose_pipeline: + t = time() + print("Entering pipeline phase %r" % phase) + # create a new wrapper for each step to show the name in profiles + phase_name = getattr(phase, '__name__', type(phase).__name__) + try: + run = _pipeline_entry_points[phase_name] + except KeyError: + exec("def %s(phase, data): return phase(data)" % phase_name, exec_ns) + run = _pipeline_entry_points[phase_name] = exec_ns[phase_name] + data = run(phase, data) + if DebugFlags.debug_verbose_pipeline: + print(" %.3f seconds" % (time() - t)) + except CompileError as err: + # err is set + Errors.report_error(err, use_stack=False) + error = err + except InternalError as err: + # Only raise if there was not an earlier error + if Errors.num_errors == 0: + raise + error = err + except AbortError as err: + error = err + return (error, data) diff --git a/contrib/tools/cython/Cython/Compiler/PyrexTypes.py b/contrib/tools/cython/Cython/Compiler/PyrexTypes.py new file mode 100644 index 00000000000..b2c92989ff2 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/PyrexTypes.py @@ -0,0 +1,4745 @@ +# +# Cython/Python language types +# + +from __future__ import absolute_import + +import copy +import hashlib +import re + +try: + reduce +except NameError: + from functools import reduce + +from Cython.Utils import cached_function +from .Code import UtilityCode, LazyUtilityCode, TempitaUtilityCode +from . import StringEncoding +from . import Naming + +from .Errors import error, warning + + +class BaseType(object): + # + # Base class for all Cython types including pseudo-types. + + # List of attribute names of any subtypes + subtypes = [] + _empty_declaration = None + _specialization_name = None + default_format_spec = None + + def can_coerce_to_pyobject(self, env): + return False + + def can_coerce_from_pyobject(self, env): + return False + + def can_coerce_to_pystring(self, env, format_spec=None): + return False + + def convert_to_pystring(self, cvalue, code, format_spec=None): + raise NotImplementedError("C types that support string formatting must override this method") + + def cast_code(self, expr_code): + return "((%s)%s)" % (self.empty_declaration_code(), expr_code) + + def empty_declaration_code(self): + if self._empty_declaration is None: + self._empty_declaration = self.declaration_code('') + return self._empty_declaration + + def specialization_name(self): + if self._specialization_name is None: + # This is not entirely robust. + common_subs = (self.empty_declaration_code() + .replace("unsigned ", "unsigned_") + .replace("long long", "long_long") + .replace(" ", "__")) + self._specialization_name = re.sub( + '[^a-zA-Z0-9_]', lambda x: '_%x_' % ord(x.group(0)), common_subs) + return self._specialization_name + + def base_declaration_code(self, base_code, entity_code): + if entity_code: + return "%s %s" % (base_code, entity_code) + else: + return base_code + + def __deepcopy__(self, memo): + """ + Types never need to be copied, if we do copy, Unfortunate Things + Will Happen! + """ + return self + + def get_fused_types(self, result=None, seen=None, subtypes=None): + subtypes = subtypes or self.subtypes + if not subtypes: + return None + + if result is None: + result = [] + seen = set() + + for attr in subtypes: + list_or_subtype = getattr(self, attr) + if list_or_subtype: + if isinstance(list_or_subtype, BaseType): + list_or_subtype.get_fused_types(result, seen) + else: + for subtype in list_or_subtype: + subtype.get_fused_types(result, seen) + + return result + + def specialize_fused(self, env): + if env.fused_to_specific: + return self.specialize(env.fused_to_specific) + + return self + + @property + def is_fused(self): + """ + Whether this type or any of its subtypes is a fused type + """ + # Add this indirection for the is_fused property to allow overriding + # get_fused_types in subclasses. + return self.get_fused_types() + + def deduce_template_params(self, actual): + """ + Deduce any template params in this (argument) type given the actual + argument type. + + http://en.cppreference.com/w/cpp/language/function_template#Template_argument_deduction + """ + return {} + + def __lt__(self, other): + """ + For sorting. The sorting order should correspond to the preference of + conversion from Python types. + + Override to provide something sensible. This is only implemented so that + python 3 doesn't trip + """ + return id(type(self)) < id(type(other)) + + def py_type_name(self): + """ + Return the name of the Python type that can coerce to this type. + """ + + def typeof_name(self): + """ + Return the string with which fused python functions can be indexed. + """ + if self.is_builtin_type or self.py_type_name() == 'object': + index_name = self.py_type_name() + else: + index_name = str(self) + + return index_name + + def check_for_null_code(self, cname): + """ + Return the code for a NULL-check in case an UnboundLocalError should + be raised if an entry of this type is referenced before assignment. + Returns None if no check should be performed. + """ + return None + + def invalid_value(self): + """ + Returns the most invalid value an object of this type can assume as a + C expression string. Returns None if no such value exists. + """ + + +class PyrexType(BaseType): + # + # Base class for all Cython types + # + # is_pyobject boolean Is a Python object type + # is_extension_type boolean Is a Python extension type + # is_final_type boolean Is a final extension type + # is_numeric boolean Is a C numeric type + # is_int boolean Is a C integer type + # is_float boolean Is a C floating point type + # is_complex boolean Is a C complex type + # is_void boolean Is the C void type + # is_array boolean Is a C array type + # is_ptr boolean Is a C pointer type + # is_null_ptr boolean Is the type of NULL + # is_reference boolean Is a C reference type + # is_const boolean Is a C const type. + # is_cfunction boolean Is a C function type + # is_struct_or_union boolean Is a C struct or union type + # is_struct boolean Is a C struct type + # is_enum boolean Is a C enum type + # is_typedef boolean Is a typedef type + # is_string boolean Is a C char * type + # is_pyunicode_ptr boolean Is a C PyUNICODE * type + # is_cpp_string boolean Is a C++ std::string type + # is_unicode_char boolean Is either Py_UCS4 or Py_UNICODE + # is_returncode boolean Is used only to signal exceptions + # is_error boolean Is the dummy error type + # is_buffer boolean Is buffer access type + # is_pythran_expr boolean Is Pythran expr + # is_numpy_buffer boolean Is Numpy array buffer + # has_attributes boolean Has C dot-selectable attributes + # default_value string Initial value that can be assigned before first user assignment. + # declaration_value string The value statically assigned on declaration (if any). + # entry Entry The Entry for this type + # + # declaration_code(entity_code, + # for_display = 0, dll_linkage = None, pyrex = 0) + # Returns a code fragment for the declaration of an entity + # of this type, given a code fragment for the entity. + # * If for_display, this is for reading by a human in an error + # message; otherwise it must be valid C code. + # * If dll_linkage is not None, it must be 'DL_EXPORT' or + # 'DL_IMPORT', and will be added to the base type part of + # the declaration. + # * If pyrex = 1, this is for use in a 'cdef extern' + # statement of a Cython include file. + # + # assignable_from(src_type) + # Tests whether a variable of this type can be + # assigned a value of type src_type. + # + # same_as(other_type) + # Tests whether this type represents the same type + # as other_type. + # + # as_argument_type(): + # Coerces array and C function types into pointer type for use as + # a formal argument type. + # + + is_pyobject = 0 + is_unspecified = 0 + is_extension_type = 0 + is_final_type = 0 + is_builtin_type = 0 + is_numeric = 0 + is_int = 0 + is_float = 0 + is_complex = 0 + is_void = 0 + is_array = 0 + is_ptr = 0 + is_null_ptr = 0 + is_reference = 0 + is_const = 0 + is_cfunction = 0 + is_struct_or_union = 0 + is_cpp_class = 0 + is_cpp_string = 0 + is_struct = 0 + is_enum = 0 + is_typedef = 0 + is_string = 0 + is_pyunicode_ptr = 0 + is_unicode_char = 0 + is_returncode = 0 + is_error = 0 + is_buffer = 0 + is_ctuple = 0 + is_memoryviewslice = 0 + is_pythran_expr = 0 + is_numpy_buffer = 0 + has_attributes = 0 + default_value = "" + declaration_value = "" + + def resolve(self): + # If a typedef, returns the base type. + return self + + def specialize(self, values): + # TODO(danilo): Override wherever it makes sense. + return self + + def literal_code(self, value): + # Returns a C code fragment representing a literal + # value of this type. + return str(value) + + def __str__(self): + return self.declaration_code("", for_display = 1).strip() + + def same_as(self, other_type, **kwds): + return self.same_as_resolved_type(other_type.resolve(), **kwds) + + def same_as_resolved_type(self, other_type): + return self == other_type or other_type is error_type + + def subtype_of(self, other_type): + return self.subtype_of_resolved_type(other_type.resolve()) + + def subtype_of_resolved_type(self, other_type): + return self.same_as(other_type) + + def assignable_from(self, src_type): + return self.assignable_from_resolved_type(src_type.resolve()) + + def assignable_from_resolved_type(self, src_type): + return self.same_as(src_type) + + def as_argument_type(self): + return self + + def is_complete(self): + # A type is incomplete if it is an unsized array, + # a struct whose attributes are not defined, etc. + return 1 + + def is_simple_buffer_dtype(self): + return (self.is_int or self.is_float or self.is_complex or self.is_pyobject or + self.is_extension_type or self.is_ptr) + + def struct_nesting_depth(self): + # Returns the number levels of nested structs. This is + # used for constructing a stack for walking the run-time + # type information of the struct. + return 1 + + def global_init_code(self, entry, code): + # abstract + pass + + def needs_nonecheck(self): + return 0 + + def _assign_from_py_code(self, source_code, result_code, error_pos, code, + from_py_function=None, error_condition=None, extra_args=None): + args = ', ' + ', '.join('%s' % arg for arg in extra_args) if extra_args else '' + convert_call = "%s(%s%s)" % ( + from_py_function or self.from_py_function, + source_code, + args, + ) + if self.is_enum: + convert_call = typecast(self, c_long_type, convert_call) + return '%s = %s; %s' % ( + result_code, + convert_call, + code.error_goto_if(error_condition or self.error_condition(result_code), error_pos)) + + +def public_decl(base_code, dll_linkage): + if dll_linkage: + return "%s(%s)" % (dll_linkage, base_code.replace(',', ' __PYX_COMMA ')) + else: + return base_code + +def create_typedef_type(name, base_type, cname, is_external=0, namespace=None): + is_fused = base_type.is_fused + if base_type.is_complex or is_fused: + if is_external: + if is_fused: + msg = "Fused" + else: + msg = "Complex" + + raise ValueError("%s external typedefs not supported" % msg) + + return base_type + else: + return CTypedefType(name, base_type, cname, is_external, namespace) + + +class CTypedefType(BaseType): + # + # Pseudo-type defined with a ctypedef statement in a + # 'cdef extern from' block. + # Delegates most attribute lookups to the base type. + # (Anything not defined here or in the BaseType is delegated.) + # + # qualified_name string + # typedef_name string + # typedef_cname string + # typedef_base_type PyrexType + # typedef_is_external bool + + is_typedef = 1 + typedef_is_external = 0 + + to_py_utility_code = None + from_py_utility_code = None + + subtypes = ['typedef_base_type'] + + def __init__(self, name, base_type, cname, is_external=0, namespace=None): + assert not base_type.is_complex + self.typedef_name = name + self.typedef_cname = cname + self.typedef_base_type = base_type + self.typedef_is_external = is_external + self.typedef_namespace = namespace + + def invalid_value(self): + return self.typedef_base_type.invalid_value() + + def resolve(self): + return self.typedef_base_type.resolve() + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + base_code = self.typedef_name + else: + base_code = public_decl(self.typedef_cname, dll_linkage) + if self.typedef_namespace is not None and not pyrex: + base_code = "%s::%s" % (self.typedef_namespace.empty_declaration_code(), base_code) + return self.base_declaration_code(base_code, entity_code) + + def as_argument_type(self): + return self + + def cast_code(self, expr_code): + # If self is really an array (rather than pointer), we can't cast. + # For example, the gmp mpz_t. + if self.typedef_base_type.is_array: + base_type = self.typedef_base_type.base_type + return CPtrType(base_type).cast_code(expr_code) + else: + return BaseType.cast_code(self, expr_code) + + def specialize(self, values): + base_type = self.typedef_base_type.specialize(values) + namespace = self.typedef_namespace.specialize(values) if self.typedef_namespace else None + if base_type is self.typedef_base_type and namespace is self.typedef_namespace: + return self + else: + return create_typedef_type(self.typedef_name, base_type, self.typedef_cname, + 0, namespace) + + def __repr__(self): + return "<CTypedefType %s>" % self.typedef_cname + + def __str__(self): + return self.typedef_name + + def _create_utility_code(self, template_utility_code, + template_function_name): + type_name = type_identifier(self.typedef_cname) + utility_code = template_utility_code.specialize( + type = self.typedef_cname, + TypeName = type_name) + function_name = template_function_name % type_name + return utility_code, function_name + + def create_to_py_utility_code(self, env): + if self.typedef_is_external: + if not self.to_py_utility_code: + base_type = self.typedef_base_type + if type(base_type) is CIntType: + self.to_py_function = "__Pyx_PyInt_From_" + self.specialization_name() + env.use_utility_code(TempitaUtilityCode.load_cached( + "CIntToPy", "TypeConversion.c", + context={"TYPE": self.empty_declaration_code(), + "TO_PY_FUNCTION": self.to_py_function})) + return True + elif base_type.is_float: + pass # XXX implement! + elif base_type.is_complex: + pass # XXX implement! + pass + elif base_type.is_cpp_string: + cname = "__pyx_convert_PyObject_string_to_py_%s" % type_identifier(self) + context = { + 'cname': cname, + 'type': self.typedef_cname, + } + from .UtilityCode import CythonUtilityCode + env.use_utility_code(CythonUtilityCode.load( + "string.to_py", "CppConvert.pyx", context=context)) + self.to_py_function = cname + return True + if self.to_py_utility_code: + env.use_utility_code(self.to_py_utility_code) + return True + # delegation + return self.typedef_base_type.create_to_py_utility_code(env) + + def create_from_py_utility_code(self, env): + if self.typedef_is_external: + if not self.from_py_utility_code: + base_type = self.typedef_base_type + if type(base_type) is CIntType: + self.from_py_function = "__Pyx_PyInt_As_" + self.specialization_name() + env.use_utility_code(TempitaUtilityCode.load_cached( + "CIntFromPy", "TypeConversion.c", + context={"TYPE": self.empty_declaration_code(), + "FROM_PY_FUNCTION": self.from_py_function})) + return True + elif base_type.is_float: + pass # XXX implement! + elif base_type.is_complex: + pass # XXX implement! + elif base_type.is_cpp_string: + cname = '__pyx_convert_string_from_py_%s' % type_identifier(self) + context = { + 'cname': cname, + 'type': self.typedef_cname, + } + from .UtilityCode import CythonUtilityCode + env.use_utility_code(CythonUtilityCode.load( + "string.from_py", "CppConvert.pyx", context=context)) + self.from_py_function = cname + return True + if self.from_py_utility_code: + env.use_utility_code(self.from_py_utility_code) + return True + # delegation + return self.typedef_base_type.create_from_py_utility_code(env) + + def to_py_call_code(self, source_code, result_code, result_type, to_py_function=None): + if to_py_function is None: + to_py_function = self.to_py_function + return self.typedef_base_type.to_py_call_code( + source_code, result_code, result_type, to_py_function) + + def from_py_call_code(self, source_code, result_code, error_pos, code, + from_py_function=None, error_condition=None): + return self.typedef_base_type.from_py_call_code( + source_code, result_code, error_pos, code, + from_py_function or self.from_py_function, + error_condition or self.error_condition(result_code) + ) + + def overflow_check_binop(self, binop, env, const_rhs=False): + env.use_utility_code(UtilityCode.load("Common", "Overflow.c")) + type = self.empty_declaration_code() + name = self.specialization_name() + if binop == "lshift": + env.use_utility_code(TempitaUtilityCode.load_cached( + "LeftShift", "Overflow.c", + context={'TYPE': type, 'NAME': name, 'SIGNED': self.signed})) + else: + if const_rhs: + binop += "_const" + _load_overflow_base(env) + env.use_utility_code(TempitaUtilityCode.load_cached( + "SizeCheck", "Overflow.c", + context={'TYPE': type, 'NAME': name})) + env.use_utility_code(TempitaUtilityCode.load_cached( + "Binop", "Overflow.c", + context={'TYPE': type, 'NAME': name, 'BINOP': binop})) + return "__Pyx_%s_%s_checking_overflow" % (binop, name) + + def error_condition(self, result_code): + if self.typedef_is_external: + if self.exception_value: + condition = "(%s == %s)" % ( + result_code, self.cast_code(self.exception_value)) + if self.exception_check: + condition += " && PyErr_Occurred()" + return condition + # delegation + return self.typedef_base_type.error_condition(result_code) + + def __getattr__(self, name): + return getattr(self.typedef_base_type, name) + + def py_type_name(self): + return self.typedef_base_type.py_type_name() + + def can_coerce_to_pyobject(self, env): + return self.typedef_base_type.can_coerce_to_pyobject(env) + + def can_coerce_from_pyobject(self, env): + return self.typedef_base_type.can_coerce_from_pyobject(env) + + +class MemoryViewSliceType(PyrexType): + + is_memoryviewslice = 1 + + has_attributes = 1 + scope = None + + # These are special cased in Defnode + from_py_function = None + to_py_function = None + + exception_value = None + exception_check = True + + subtypes = ['dtype'] + + def __init__(self, base_dtype, axes): + """ + MemoryViewSliceType(base, axes) + + Base is the C base type; axes is a list of (access, packing) strings, + where access is one of 'full', 'direct' or 'ptr' and packing is one of + 'contig', 'strided' or 'follow'. There is one (access, packing) tuple + for each dimension. + + the access specifiers determine whether the array data contains + pointers that need to be dereferenced along that axis when + retrieving/setting: + + 'direct' -- No pointers stored in this dimension. + 'ptr' -- Pointer stored in this dimension. + 'full' -- Check along this dimension, don't assume either. + + the packing specifiers specify how the array elements are layed-out + in memory. + + 'contig' -- The data is contiguous in memory along this dimension. + At most one dimension may be specified as 'contig'. + 'strided' -- The data isn't contiguous along this dimension. + 'follow' -- Used for C/Fortran contiguous arrays, a 'follow' dimension + has its stride automatically computed from extents of the other + dimensions to ensure C or Fortran memory layout. + + C-contiguous memory has 'direct' as the access spec, 'contig' as the + *last* axis' packing spec and 'follow' for all other packing specs. + + Fortran-contiguous memory has 'direct' as the access spec, 'contig' as + the *first* axis' packing spec and 'follow' for all other packing + specs. + """ + from . import Buffer, MemoryView + + self.dtype = base_dtype + self.axes = axes + self.ndim = len(axes) + self.flags = MemoryView.get_buf_flags(self.axes) + + self.is_c_contig, self.is_f_contig = MemoryView.is_cf_contig(self.axes) + assert not (self.is_c_contig and self.is_f_contig) + + self.mode = MemoryView.get_mode(axes) + self.writable_needed = False + + if not self.dtype.is_fused: + self.dtype_name = Buffer.mangle_dtype_name(self.dtype) + + def __hash__(self): + return hash(self.__class__) ^ hash(self.dtype) ^ hash(tuple(self.axes)) + + def __eq__(self, other): + if isinstance(other, BaseType): + return self.same_as_resolved_type(other) + else: + return False + + def same_as_resolved_type(self, other_type): + return ((other_type.is_memoryviewslice and + #self.writable_needed == other_type.writable_needed and # FIXME: should be only uni-directional + self.dtype.same_as(other_type.dtype) and + self.axes == other_type.axes) or + other_type is error_type) + + def needs_nonecheck(self): + return True + + def is_complete(self): + # incomplete since the underlying struct doesn't have a cython.memoryview object. + return 0 + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + # XXX: we put these guards in for now... + assert not pyrex + assert not dll_linkage + from . import MemoryView + base_code = str(self) if for_display else MemoryView.memviewslice_cname + return self.base_declaration_code( + base_code, + entity_code) + + def attributes_known(self): + if self.scope is None: + from . import Symtab + + self.scope = scope = Symtab.CClassScope( + 'mvs_class_'+self.specialization_suffix(), + None, + visibility='extern') + + scope.parent_type = self + scope.directives = {} + + scope.declare_var('_data', c_char_ptr_type, None, + cname='data', is_cdef=1) + + return True + + def declare_attribute(self, attribute, env, pos): + from . import MemoryView, Options + + scope = self.scope + + if attribute == 'shape': + scope.declare_var('shape', + c_array_type(c_py_ssize_t_type, + Options.buffer_max_dims), + pos, + cname='shape', + is_cdef=1) + + elif attribute == 'strides': + scope.declare_var('strides', + c_array_type(c_py_ssize_t_type, + Options.buffer_max_dims), + pos, + cname='strides', + is_cdef=1) + + elif attribute == 'suboffsets': + scope.declare_var('suboffsets', + c_array_type(c_py_ssize_t_type, + Options.buffer_max_dims), + pos, + cname='suboffsets', + is_cdef=1) + + elif attribute in ("copy", "copy_fortran"): + ndim = len(self.axes) + + follow_dim = [('direct', 'follow')] + contig_dim = [('direct', 'contig')] + to_axes_c = follow_dim * (ndim - 1) + contig_dim + to_axes_f = contig_dim + follow_dim * (ndim -1) + + dtype = self.dtype + if dtype.is_const: + dtype = dtype.const_base_type + + to_memview_c = MemoryViewSliceType(dtype, to_axes_c) + to_memview_f = MemoryViewSliceType(dtype, to_axes_f) + + for to_memview, cython_name in [(to_memview_c, "copy"), + (to_memview_f, "copy_fortran")]: + copy_func_type = CFuncType( + to_memview, + [CFuncTypeArg("memviewslice", self, None)]) + copy_cname = MemoryView.copy_c_or_fortran_cname(to_memview) + + entry = scope.declare_cfunction( + cython_name, + copy_func_type, pos=pos, defining=1, + cname=copy_cname) + + utility = MemoryView.get_copy_new_utility(pos, self, to_memview) + env.use_utility_code(utility) + + MemoryView.use_cython_array_utility_code(env) + + elif attribute in ("is_c_contig", "is_f_contig"): + # is_c_contig and is_f_contig functions + for (c_or_f, cython_name) in (('C', 'is_c_contig'), ('F', 'is_f_contig')): + + is_contig_name = MemoryView.get_is_contig_func_name(c_or_f, self.ndim) + + cfunctype = CFuncType( + return_type=c_bint_type, + args=[CFuncTypeArg("memviewslice", self, None)], + exception_value="-1", + ) + + entry = scope.declare_cfunction(cython_name, + cfunctype, + pos=pos, + defining=1, + cname=is_contig_name) + + entry.utility_code_definition = MemoryView.get_is_contig_utility(c_or_f, self.ndim) + + return True + + def get_entry(self, node, cname=None, type=None): + from . import MemoryView, Symtab + + if cname is None: + assert node.is_simple() or node.is_temp or node.is_elemental + cname = node.result() + + if type is None: + type = node.type + + entry = Symtab.Entry(cname, cname, type, node.pos) + return MemoryView.MemoryViewSliceBufferEntry(entry) + + def conforms_to(self, dst, broadcast=False, copying=False): + """ + Returns True if src conforms to dst, False otherwise. + + If conformable, the types are the same, the ndims are equal, and each axis spec is conformable. + + Any packing/access spec is conformable to itself. + + 'direct' and 'ptr' are conformable to 'full'. + 'contig' and 'follow' are conformable to 'strided'. + Any other combo is not conformable. + """ + from . import MemoryView + + src = self + + #if not copying and self.writable_needed and not dst.writable_needed: + # return False + + src_dtype, dst_dtype = src.dtype, dst.dtype + if dst_dtype.is_const: + # Requesting read-only views is always ok => consider only the non-const base type. + dst_dtype = dst_dtype.const_base_type + if src_dtype.is_const: + # When assigning between read-only views, compare only the non-const base types. + src_dtype = src_dtype.const_base_type + elif copying and src_dtype.is_const: + # Copying by value => ignore const on source. + src_dtype = src_dtype.const_base_type + + if src_dtype != dst_dtype: + return False + + if src.ndim != dst.ndim: + if broadcast: + src, dst = MemoryView.broadcast_types(src, dst) + else: + return False + + for src_spec, dst_spec in zip(src.axes, dst.axes): + src_access, src_packing = src_spec + dst_access, dst_packing = dst_spec + if src_access != dst_access and dst_access != 'full': + return False + if src_packing != dst_packing and dst_packing != 'strided' and not copying: + return False + + return True + + def valid_dtype(self, dtype, i=0): + """ + Return whether type dtype can be used as the base type of a + memoryview slice. + + We support structs, numeric types and objects + """ + if dtype.is_complex and dtype.real_type.is_int: + return False + + if dtype.is_struct and dtype.kind == 'struct': + for member in dtype.scope.var_entries: + if not self.valid_dtype(member.type): + return False + + return True + + return ( + dtype.is_error or + # Pointers are not valid (yet) + # (dtype.is_ptr and valid_memslice_dtype(dtype.base_type)) or + (dtype.is_array and i < 8 and self.valid_dtype(dtype.base_type, i + 1)) or + dtype.is_numeric or + dtype.is_pyobject or + dtype.is_fused or # accept this as it will be replaced by specializations later + (dtype.is_typedef and self.valid_dtype(dtype.typedef_base_type)) + ) + + def validate_memslice_dtype(self, pos): + if not self.valid_dtype(self.dtype): + error(pos, "Invalid base type for memoryview slice: %s" % self.dtype) + + def assert_direct_dims(self, pos): + for access, packing in self.axes: + if access != 'direct': + error(pos, "All dimensions must be direct") + return False + return True + + def transpose(self, pos): + if not self.assert_direct_dims(pos): + return error_type + return MemoryViewSliceType(self.dtype, self.axes[::-1]) + + def specialization_name(self): + return '%s_%s' % ( + super(MemoryViewSliceType,self).specialization_name(), + self.specialization_suffix()) + + def specialization_suffix(self): + return "%s_%s" % (self.axes_to_name(), self.dtype_name) + + def can_coerce_to_pyobject(self, env): + return True + + def can_coerce_from_pyobject(self, env): + return True + + def check_for_null_code(self, cname): + return cname + '.memview' + + def create_from_py_utility_code(self, env): + from . import MemoryView, Buffer + + # We don't have 'code', so use a LazyUtilityCode with a callback. + def lazy_utility_callback(code): + context['dtype_typeinfo'] = Buffer.get_type_information_cname(code, self.dtype) + return TempitaUtilityCode.load( + "ObjectToMemviewSlice", "MemoryView_C.c", context=context) + + env.use_utility_code(MemoryView.memviewslice_init_code) + env.use_utility_code(LazyUtilityCode(lazy_utility_callback)) + + if self.is_c_contig: + c_or_f_flag = "__Pyx_IS_C_CONTIG" + elif self.is_f_contig: + c_or_f_flag = "__Pyx_IS_F_CONTIG" + else: + c_or_f_flag = "0" + + suffix = self.specialization_suffix() + funcname = "__Pyx_PyObject_to_MemoryviewSlice_" + suffix + + context = dict( + MemoryView.context, + buf_flag = self.flags, + ndim = self.ndim, + axes_specs = ', '.join(self.axes_to_code()), + dtype_typedecl = self.dtype.empty_declaration_code(), + struct_nesting_depth = self.dtype.struct_nesting_depth(), + c_or_f_flag = c_or_f_flag, + funcname = funcname, + ) + + self.from_py_function = funcname + return True + + def from_py_call_code(self, source_code, result_code, error_pos, code, + from_py_function=None, error_condition=None): + # NOTE: auto-detection of readonly buffers is disabled: + # writable = self.writable_needed or not self.dtype.is_const + writable = not self.dtype.is_const + return self._assign_from_py_code( + source_code, result_code, error_pos, code, from_py_function, error_condition, + extra_args=['PyBUF_WRITABLE' if writable else '0']) + + def create_to_py_utility_code(self, env): + self._dtype_to_py_func, self._dtype_from_py_func = self.dtype_object_conversion_funcs(env) + return True + + def to_py_call_code(self, source_code, result_code, result_type, to_py_function=None): + assert self._dtype_to_py_func + assert self._dtype_from_py_func + + to_py_func = "(PyObject *(*)(char *)) " + self._dtype_to_py_func + from_py_func = "(int (*)(char *, PyObject *)) " + self._dtype_from_py_func + + tup = (result_code, source_code, self.ndim, to_py_func, from_py_func, self.dtype.is_pyobject) + return "%s = __pyx_memoryview_fromslice(%s, %s, %s, %s, %d);" % tup + + def dtype_object_conversion_funcs(self, env): + get_function = "__pyx_memview_get_%s" % self.dtype_name + set_function = "__pyx_memview_set_%s" % self.dtype_name + + context = dict( + get_function = get_function, + set_function = set_function, + ) + + if self.dtype.is_pyobject: + utility_name = "MemviewObjectToObject" + else: + self.dtype.create_to_py_utility_code(env) + to_py_function = self.dtype.to_py_function + + from_py_function = None + if not self.dtype.is_const: + self.dtype.create_from_py_utility_code(env) + from_py_function = self.dtype.from_py_function + + if not (to_py_function or from_py_function): + return "NULL", "NULL" + if not to_py_function: + get_function = "NULL" + if not from_py_function: + set_function = "NULL" + + utility_name = "MemviewDtypeToObject" + error_condition = (self.dtype.error_condition('value') or + 'PyErr_Occurred()') + context.update( + to_py_function=to_py_function, + from_py_function=from_py_function, + dtype=self.dtype.empty_declaration_code(), + error_condition=error_condition, + ) + + utility = TempitaUtilityCode.load_cached( + utility_name, "MemoryView_C.c", context=context) + env.use_utility_code(utility) + return get_function, set_function + + def axes_to_code(self): + """Return a list of code constants for each axis""" + from . import MemoryView + d = MemoryView._spec_to_const + return ["(%s | %s)" % (d[a], d[p]) for a, p in self.axes] + + def axes_to_name(self): + """Return an abbreviated name for our axes""" + from . import MemoryView + d = MemoryView._spec_to_abbrev + return "".join(["%s%s" % (d[a], d[p]) for a, p in self.axes]) + + def error_condition(self, result_code): + return "!%s.memview" % result_code + + def __str__(self): + from . import MemoryView + + axes_code_list = [] + for idx, (access, packing) in enumerate(self.axes): + flag = MemoryView.get_memoryview_flag(access, packing) + if flag == "strided": + axes_code_list.append(":") + else: + if flag == 'contiguous': + have_follow = [p for a, p in self.axes[idx - 1:idx + 2] + if p == 'follow'] + if have_follow or self.ndim == 1: + flag = '1' + + axes_code_list.append("::" + flag) + + if self.dtype.is_pyobject: + dtype_name = self.dtype.name + else: + dtype_name = self.dtype + + return "%s[%s]" % (dtype_name, ", ".join(axes_code_list)) + + def specialize(self, values): + """This does not validate the base type!!""" + dtype = self.dtype.specialize(values) + if dtype is not self.dtype: + return MemoryViewSliceType(dtype, self.axes) + + return self + + def cast_code(self, expr_code): + return expr_code + + +class BufferType(BaseType): + # + # Delegates most attribute lookups to the base type. + # (Anything not defined here or in the BaseType is delegated.) + # + # dtype PyrexType + # ndim int + # mode str + # negative_indices bool + # cast bool + # is_buffer bool + # writable bool + + is_buffer = 1 + writable = True + + subtypes = ['dtype'] + + def __init__(self, base, dtype, ndim, mode, negative_indices, cast): + self.base = base + self.dtype = dtype + self.ndim = ndim + self.buffer_ptr_type = CPtrType(dtype) + self.mode = mode + self.negative_indices = negative_indices + self.cast = cast + self.is_numpy_buffer = self.base.name == "ndarray" + + def can_coerce_to_pyobject(self,env): + return True + + def can_coerce_from_pyobject(self,env): + return True + + def as_argument_type(self): + return self + + def specialize(self, values): + dtype = self.dtype.specialize(values) + if dtype is not self.dtype: + return BufferType(self.base, dtype, self.ndim, self.mode, + self.negative_indices, self.cast) + return self + + def get_entry(self, node): + from . import Buffer + assert node.is_name + return Buffer.BufferEntry(node.entry) + + def __getattr__(self, name): + return getattr(self.base, name) + + def __repr__(self): + return "<BufferType %r>" % self.base + + def __str__(self): + # avoid ', ', as fused functions split the signature string on ', ' + cast_str = '' + if self.cast: + cast_str = ',cast=True' + + return "%s[%s,ndim=%d%s]" % (self.base, self.dtype, self.ndim, + cast_str) + + def assignable_from(self, other_type): + if other_type.is_buffer: + return (self.same_as(other_type, compare_base=False) and + self.base.assignable_from(other_type.base)) + + return self.base.assignable_from(other_type) + + def same_as(self, other_type, compare_base=True): + if not other_type.is_buffer: + return other_type.same_as(self.base) + + return (self.dtype.same_as(other_type.dtype) and + self.ndim == other_type.ndim and + self.mode == other_type.mode and + self.cast == other_type.cast and + (not compare_base or self.base.same_as(other_type.base))) + + +class PyObjectType(PyrexType): + # + # Base class for all Python object types (reference-counted). + # + # buffer_defaults dict or None Default options for bu + + name = "object" + is_pyobject = 1 + default_value = "0" + declaration_value = "0" + buffer_defaults = None + is_extern = False + is_subclassed = False + is_gc_simple = False + + def __str__(self): + return "Python object" + + def __repr__(self): + return "<PyObjectType>" + + def can_coerce_to_pyobject(self, env): + return True + + def can_coerce_from_pyobject(self, env): + return True + + def default_coerced_ctype(self): + """The default C type that this Python type coerces to, or None.""" + return None + + def assignable_from(self, src_type): + # except for pointers, conversion will be attempted + return not src_type.is_ptr or src_type.is_string or src_type.is_pyunicode_ptr + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + base_code = "object" + else: + base_code = public_decl("PyObject", dll_linkage) + entity_code = "*%s" % entity_code + return self.base_declaration_code(base_code, entity_code) + + def as_pyobject(self, cname): + if (not self.is_complete()) or self.is_extension_type: + return "(PyObject *)" + cname + else: + return cname + + def py_type_name(self): + return "object" + + def __lt__(self, other): + """ + Make sure we sort highest, as instance checking on py_type_name + ('object') is always true + """ + return False + + def global_init_code(self, entry, code): + code.put_init_var_to_py_none(entry, nanny=False) + + def check_for_null_code(self, cname): + return cname + + +builtin_types_that_cannot_create_refcycles = set([ + 'bool', 'int', 'long', 'float', 'complex', + 'bytearray', 'bytes', 'unicode', 'str', 'basestring' +]) + + +class BuiltinObjectType(PyObjectType): + # objstruct_cname string Name of PyObject struct + + is_builtin_type = 1 + has_attributes = 1 + base_type = None + module_name = '__builtin__' + require_exact = 1 + + # fields that let it look like an extension type + vtabslot_cname = None + vtabstruct_cname = None + vtabptr_cname = None + typedef_flag = True + is_external = True + decl_type = 'PyObject' + + def __init__(self, name, cname, objstruct_cname=None): + self.name = name + self.cname = cname + self.typeptr_cname = "(&%s)" % cname + self.objstruct_cname = objstruct_cname + self.is_gc_simple = name in builtin_types_that_cannot_create_refcycles + if name == 'type': + # Special case the type type, as many C API calls (and other + # libraries) actually expect a PyTypeObject* for type arguments. + self.decl_type = objstruct_cname + if name == 'Exception': + self.require_exact = 0 + + def set_scope(self, scope): + self.scope = scope + if scope: + scope.parent_type = self + + def __str__(self): + return "%s object" % self.name + + def __repr__(self): + return "<%s>"% self.cname + + def default_coerced_ctype(self): + if self.name in ('bytes', 'bytearray'): + return c_char_ptr_type + elif self.name == 'bool': + return c_bint_type + elif self.name == 'float': + return c_double_type + return None + + def assignable_from(self, src_type): + if isinstance(src_type, BuiltinObjectType): + if self.name == 'basestring': + return src_type.name in ('str', 'unicode', 'basestring') + else: + return src_type.name == self.name + elif src_type.is_extension_type: + # FIXME: This is an ugly special case that we currently + # keep supporting. It allows users to specify builtin + # types as external extension types, while keeping them + # compatible with the real builtin types. We already + # generate a warning for it. Big TODO: remove! + return (src_type.module_name == '__builtin__' and + src_type.name == self.name) + else: + return True + + def typeobj_is_available(self): + return True + + def attributes_known(self): + return True + + def subtype_of(self, type): + return type.is_pyobject and type.assignable_from(self) + + def type_check_function(self, exact=True): + type_name = self.name + if type_name == 'str': + type_check = 'PyString_Check' + elif type_name == 'basestring': + type_check = '__Pyx_PyBaseString_Check' + elif type_name == 'Exception': + type_check = '__Pyx_PyException_Check' + elif type_name == 'bytearray': + type_check = 'PyByteArray_Check' + elif type_name == 'frozenset': + type_check = 'PyFrozenSet_Check' + else: + type_check = 'Py%s_Check' % type_name.capitalize() + if exact and type_name not in ('bool', 'slice', 'Exception'): + type_check += 'Exact' + return type_check + + def isinstance_code(self, arg): + return '%s(%s)' % (self.type_check_function(exact=False), arg) + + def type_test_code(self, arg, notnone=False, exact=True): + type_check = self.type_check_function(exact=exact) + check = 'likely(%s(%s))' % (type_check, arg) + if not notnone: + check += '||((%s) == Py_None)' % arg + if self.name == 'basestring': + name = '(PY_MAJOR_VERSION < 3 ? "basestring" : "str")' + space_for_name = 16 + else: + name = '"%s"' % self.name + # avoid wasting too much space but limit number of different format strings + space_for_name = (len(self.name) // 16 + 1) * 16 + error = '((void)PyErr_Format(PyExc_TypeError, "Expected %%.%ds, got %%.200s", %s, Py_TYPE(%s)->tp_name), 0)' % ( + space_for_name, name, arg) + return check + '||' + error + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + base_code = self.name + else: + base_code = public_decl(self.decl_type, dll_linkage) + entity_code = "*%s" % entity_code + return self.base_declaration_code(base_code, entity_code) + + def as_pyobject(self, cname): + if self.decl_type == 'PyObject': + return cname + else: + return "(PyObject *)" + cname + + def cast_code(self, expr_code, to_object_struct = False): + return "((%s*)%s)" % ( + to_object_struct and self.objstruct_cname or self.decl_type, # self.objstruct_cname may be None + expr_code) + + def py_type_name(self): + return self.name + + + +class PyExtensionType(PyObjectType): + # + # A Python extension type. + # + # name string + # scope CClassScope Attribute namespace + # visibility string + # typedef_flag boolean + # base_type PyExtensionType or None + # module_name string or None Qualified name of defining module + # objstruct_cname string Name of PyObject struct + # objtypedef_cname string Name of PyObject struct typedef + # typeobj_cname string or None C code fragment referring to type object + # typeptr_cname string or None Name of pointer to external type object + # vtabslot_cname string Name of C method table member + # vtabstruct_cname string Name of C method table struct + # vtabptr_cname string Name of pointer to C method table + # vtable_cname string Name of C method table definition + # early_init boolean Whether to initialize early (as opposed to during module execution). + # defered_declarations [thunk] Used to declare class hierarchies in order + # check_size 'warn', 'error', 'ignore' What to do if tp_basicsize does not match + + is_extension_type = 1 + has_attributes = 1 + early_init = 1 + + objtypedef_cname = None + + def __init__(self, name, typedef_flag, base_type, is_external=0, check_size=None): + self.name = name + self.scope = None + self.typedef_flag = typedef_flag + if base_type is not None: + base_type.is_subclassed = True + self.base_type = base_type + self.module_name = None + self.objstruct_cname = None + self.typeobj_cname = None + self.typeptr_cname = None + self.vtabslot_cname = None + self.vtabstruct_cname = None + self.vtabptr_cname = None + self.vtable_cname = None + self.is_external = is_external + self.check_size = check_size or 'warn' + self.defered_declarations = [] + + def set_scope(self, scope): + self.scope = scope + if scope: + scope.parent_type = self + + def needs_nonecheck(self): + return True + + def subtype_of_resolved_type(self, other_type): + if other_type.is_extension_type or other_type.is_builtin_type: + return self is other_type or ( + self.base_type and self.base_type.subtype_of(other_type)) + else: + return other_type is py_object_type + + def typeobj_is_available(self): + # Do we have a pointer to the type object? + return self.typeptr_cname + + def typeobj_is_imported(self): + # If we don't know the C name of the type object but we do + # know which module it's defined in, it will be imported. + return self.typeobj_cname is None and self.module_name is not None + + def assignable_from(self, src_type): + if self == src_type: + return True + if isinstance(src_type, PyExtensionType): + if src_type.base_type is not None: + return self.assignable_from(src_type.base_type) + if isinstance(src_type, BuiltinObjectType): + # FIXME: This is an ugly special case that we currently + # keep supporting. It allows users to specify builtin + # types as external extension types, while keeping them + # compatible with the real builtin types. We already + # generate a warning for it. Big TODO: remove! + return (self.module_name == '__builtin__' and + self.name == src_type.name) + return False + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0, deref = 0): + if pyrex or for_display: + base_code = self.name + else: + if self.typedef_flag: + objstruct = self.objstruct_cname + else: + objstruct = "struct %s" % self.objstruct_cname + base_code = public_decl(objstruct, dll_linkage) + if deref: + assert not entity_code + else: + entity_code = "*%s" % entity_code + return self.base_declaration_code(base_code, entity_code) + + def type_test_code(self, py_arg, notnone=False): + + none_check = "((%s) == Py_None)" % py_arg + type_check = "likely(__Pyx_TypeTest(%s, %s))" % ( + py_arg, self.typeptr_cname) + if notnone: + return type_check + else: + return "likely(%s || %s)" % (none_check, type_check) + + def attributes_known(self): + return self.scope is not None + + def __str__(self): + return self.name + + def __repr__(self): + return "<PyExtensionType %s%s>" % (self.scope.class_name, + ("", " typedef")[self.typedef_flag]) + + def py_type_name(self): + if not self.module_name: + return self.name + + return "__import__(%r, None, None, ['']).%s" % (self.module_name, + self.name) + +class CType(PyrexType): + # + # Base class for all C types (non-reference-counted). + # + # to_py_function string C function for converting to Python object + # from_py_function string C function for constructing from Python object + # + + to_py_function = None + from_py_function = None + exception_value = None + exception_check = 1 + + def create_to_py_utility_code(self, env): + return self.to_py_function is not None + + def create_from_py_utility_code(self, env): + return self.from_py_function is not None + + def can_coerce_to_pyobject(self, env): + return self.create_to_py_utility_code(env) + + def can_coerce_from_pyobject(self, env): + return self.create_from_py_utility_code(env) + + def error_condition(self, result_code): + conds = [] + if self.is_string or self.is_pyunicode_ptr: + conds.append("(!%s)" % result_code) + elif self.exception_value is not None: + conds.append("(%s == (%s)%s)" % (result_code, self.sign_and_name(), self.exception_value)) + if self.exception_check: + conds.append("PyErr_Occurred()") + if len(conds) > 0: + return " && ".join(conds) + else: + return 0 + + def to_py_call_code(self, source_code, result_code, result_type, to_py_function=None): + func = self.to_py_function if to_py_function is None else to_py_function + assert func + if self.is_string or self.is_cpp_string: + if result_type.is_builtin_type: + result_type_name = result_type.name + if result_type_name in ('bytes', 'str', 'unicode'): + func = func.replace("Object", result_type_name.title(), 1) + elif result_type_name == 'bytearray': + func = func.replace("Object", "ByteArray", 1) + return '%s = %s(%s)' % ( + result_code, + func, + source_code or 'NULL') + + def from_py_call_code(self, source_code, result_code, error_pos, code, + from_py_function=None, error_condition=None): + return self._assign_from_py_code( + source_code, result_code, error_pos, code, from_py_function, error_condition) + + + +class PythranExpr(CType): + # Pythran object of a given type + + to_py_function = "__Pyx_pythran_to_python" + is_pythran_expr = True + writable = True + has_attributes = 1 + + def __init__(self, pythran_type, org_buffer=None): + self.org_buffer = org_buffer + self.pythran_type = pythran_type + self.name = self.pythran_type + self.cname = self.pythran_type + self.from_py_function = "from_python<%s>" % (self.pythran_type) + self.scope = None + + def declaration_code(self, entity_code, for_display=0, dll_linkage=None, pyrex=0): + assert not pyrex + return "%s %s" % (self.cname, entity_code) + + def attributes_known(self): + if self.scope is None: + from . import Symtab + # FIXME: fake C scope, might be better represented by a struct or C++ class scope + self.scope = scope = Symtab.CClassScope('', None, visibility="extern") + scope.parent_type = self + scope.directives = {} + scope.declare_var("shape", CPtrType(c_long_type), None, cname="_shape", is_cdef=True) + scope.declare_var("ndim", c_long_type, None, cname="value", is_cdef=True) + + return True + + def __eq__(self, other): + return isinstance(other, PythranExpr) and self.pythran_type == other.pythran_type + + def __ne__(self, other): + return not (isinstance(other, PythranExpr) and self.pythran_type == other.pythran_type) + + def __hash__(self): + return hash(self.pythran_type) + + +class CConstType(BaseType): + + is_const = 1 + subtypes = ['const_base_type'] + + def __init__(self, const_base_type): + self.const_base_type = const_base_type + if const_base_type.has_attributes and const_base_type.scope is not None: + from . import Symtab + self.scope = Symtab.CConstScope(const_base_type.scope) + + def __repr__(self): + return "<CConstType %s>" % repr(self.const_base_type) + + def __str__(self): + return self.declaration_code("", for_display=1) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if for_display or pyrex: + return "const " + self.const_base_type.declaration_code(entity_code, for_display, dll_linkage, pyrex) + else: + return self.const_base_type.declaration_code("const %s" % entity_code, for_display, dll_linkage, pyrex) + + def specialize(self, values): + base_type = self.const_base_type.specialize(values) + if base_type == self.const_base_type: + return self + else: + return CConstType(base_type) + + def deduce_template_params(self, actual): + return self.const_base_type.deduce_template_params(actual) + + def can_coerce_to_pyobject(self, env): + return self.const_base_type.can_coerce_to_pyobject(env) + + def can_coerce_from_pyobject(self, env): + return self.const_base_type.can_coerce_from_pyobject(env) + + def create_to_py_utility_code(self, env): + if self.const_base_type.create_to_py_utility_code(env): + self.to_py_function = self.const_base_type.to_py_function + return True + + def same_as_resolved_type(self, other_type): + if other_type.is_const: + return self.const_base_type.same_as_resolved_type(other_type.const_base_type) + # Accept const LHS <- non-const RHS. + return self.const_base_type.same_as_resolved_type(other_type) + + def __getattr__(self, name): + return getattr(self.const_base_type, name) + + +class FusedType(CType): + """ + Represents a Fused Type. All it needs to do is keep track of the types + it aggregates, as it will be replaced with its specific version wherever + needed. + + See http://wiki.cython.org/enhancements/fusedtypes + + types [PyrexType] is the list of types to be fused + name str the name of the ctypedef + """ + + is_fused = 1 + exception_check = 0 + + def __init__(self, types, name=None): + # Use list rather than set to preserve order (list should be short). + flattened_types = [] + for t in types: + if t.is_fused: + # recursively merge in subtypes + for subtype in t.types: + if subtype not in flattened_types: + flattened_types.append(subtype) + elif t not in flattened_types: + flattened_types.append(t) + self.types = flattened_types + self.name = name + + def declaration_code(self, entity_code, for_display = 0, + dll_linkage = None, pyrex = 0): + if pyrex or for_display: + return self.name + + raise Exception("This may never happen, please report a bug") + + def __repr__(self): + return 'FusedType(name=%r)' % self.name + + def specialize(self, values): + return values[self] + + def get_fused_types(self, result=None, seen=None): + if result is None: + return [self] + + if self not in seen: + result.append(self) + seen.add(self) + + +class CVoidType(CType): + # + # C "void" type + # + + is_void = 1 + to_py_function = "__Pyx_void_to_None" + + def __repr__(self): + return "<CVoidType>" + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + base_code = "void" + else: + base_code = public_decl("void", dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + def is_complete(self): + return 0 + +class InvisibleVoidType(CVoidType): + # + # For use with C++ constructors and destructors return types. + # Acts like void, but does not print out a declaration. + # + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + base_code = "[void]" + else: + base_code = public_decl("", dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + +class CNumericType(CType): + # + # Base class for all C numeric types. + # + # rank integer Relative size + # signed integer 0 = unsigned, 1 = unspecified, 2 = explicitly signed + # + + is_numeric = 1 + default_value = "0" + has_attributes = True + scope = None + + sign_words = ("unsigned ", "", "signed ") + + def __init__(self, rank, signed = 1): + self.rank = rank + if rank > 0 and signed == SIGNED: + # Signed is meaningless for anything but char, and complicates + # type promotion. + signed = 1 + self.signed = signed + + def sign_and_name(self): + s = self.sign_words[self.signed] + n = rank_to_type_name[self.rank] + return s + n + + def __repr__(self): + return "<CNumericType %s>" % self.sign_and_name() + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + type_name = self.sign_and_name() + if pyrex or for_display: + base_code = type_name.replace('PY_LONG_LONG', 'long long') + else: + base_code = public_decl(type_name, dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + def attributes_known(self): + if self.scope is None: + from . import Symtab + self.scope = scope = Symtab.CClassScope( + '', + None, + visibility="extern") + scope.parent_type = self + scope.directives = {} + scope.declare_cfunction( + "conjugate", + CFuncType(self, [CFuncTypeArg("self", self, None)], nogil=True), + pos=None, + defining=1, + cname=" ") + return True + + def __lt__(self, other): + """Sort based on rank, preferring signed over unsigned""" + if other.is_numeric: + return self.rank > other.rank and self.signed >= other.signed + + # Prefer numeric types over others + return True + + def py_type_name(self): + if self.rank <= 4: + return "(int, long)" + return "float" + + +class ForbidUseClass: + def __repr__(self): + raise RuntimeError() + def __str__(self): + raise RuntimeError() +ForbidUse = ForbidUseClass() + + +class CIntLike(object): + """Mixin for shared behaviour of C integers and enums. + """ + to_py_function = None + from_py_function = None + to_pyunicode_utility = None + default_format_spec = 'd' + + def can_coerce_to_pyobject(self, env): + return True + + def can_coerce_from_pyobject(self, env): + return True + + def create_to_py_utility_code(self, env): + if type(self).to_py_function is None: + self.to_py_function = "__Pyx_PyInt_From_" + self.specialization_name() + env.use_utility_code(TempitaUtilityCode.load_cached( + "CIntToPy", "TypeConversion.c", + context={"TYPE": self.empty_declaration_code(), + "TO_PY_FUNCTION": self.to_py_function})) + return True + + def create_from_py_utility_code(self, env): + if type(self).from_py_function is None: + self.from_py_function = "__Pyx_PyInt_As_" + self.specialization_name() + env.use_utility_code(TempitaUtilityCode.load_cached( + "CIntFromPy", "TypeConversion.c", + context={"TYPE": self.empty_declaration_code(), + "FROM_PY_FUNCTION": self.from_py_function})) + return True + + @staticmethod + def _parse_format(format_spec): + padding = ' ' + if not format_spec: + return ('d', 0, padding) + format_type = format_spec[-1] + if format_type in ('o', 'd', 'x', 'X'): + prefix = format_spec[:-1] + elif format_type.isdigit(): + format_type = 'd' + prefix = format_spec + else: + return (None, 0, padding) + if not prefix: + return (format_type, 0, padding) + if prefix[0] == '-': + prefix = prefix[1:] + if prefix and prefix[0] == '0': + padding = '0' + prefix = prefix.lstrip('0') + if prefix.isdigit(): + return (format_type, int(prefix), padding) + return (None, 0, padding) + + def can_coerce_to_pystring(self, env, format_spec=None): + format_type, width, padding = self._parse_format(format_spec) + return format_type is not None and width <= 2**30 + + def convert_to_pystring(self, cvalue, code, format_spec=None): + if self.to_pyunicode_utility is None: + utility_code_name = "__Pyx_PyUnicode_From_" + self.specialization_name() + to_pyunicode_utility = TempitaUtilityCode.load_cached( + "CIntToPyUnicode", "TypeConversion.c", + context={"TYPE": self.empty_declaration_code(), + "TO_PY_FUNCTION": utility_code_name}) + self.to_pyunicode_utility = (utility_code_name, to_pyunicode_utility) + else: + utility_code_name, to_pyunicode_utility = self.to_pyunicode_utility + code.globalstate.use_utility_code(to_pyunicode_utility) + format_type, width, padding_char = self._parse_format(format_spec) + return "%s(%s, %d, '%s', '%s')" % (utility_code_name, cvalue, width, padding_char, format_type) + + +class CIntType(CIntLike, CNumericType): + + is_int = 1 + typedef_flag = 0 + exception_value = -1 + + def get_to_py_type_conversion(self): + if self.rank < list(rank_to_type_name).index('int'): + # This assumes sizeof(short) < sizeof(int) + return "PyInt_FromLong" + else: + # Py{Int|Long}_From[Unsigned]Long[Long] + Prefix = "Int" + SignWord = "" + TypeName = "Long" + if not self.signed: + Prefix = "Long" + SignWord = "Unsigned" + if self.rank >= list(rank_to_type_name).index('PY_LONG_LONG'): + Prefix = "Long" + TypeName = "LongLong" + return "Py%s_From%s%s" % (Prefix, SignWord, TypeName) + + def assignable_from_resolved_type(self, src_type): + return src_type.is_int or src_type.is_enum or src_type is error_type + + def invalid_value(self): + if rank_to_type_name[int(self.rank)] == 'char': + return "'?'" + else: + # We do not really know the size of the type, so return + # a 32-bit literal and rely on casting to final type. It will + # be negative for signed ints, which is good. + return "0xbad0bad0" + + def overflow_check_binop(self, binop, env, const_rhs=False): + env.use_utility_code(UtilityCode.load("Common", "Overflow.c")) + type = self.empty_declaration_code() + name = self.specialization_name() + if binop == "lshift": + env.use_utility_code(TempitaUtilityCode.load_cached( + "LeftShift", "Overflow.c", + context={'TYPE': type, 'NAME': name, 'SIGNED': self.signed})) + else: + if const_rhs: + binop += "_const" + if type in ('int', 'long', 'long long'): + env.use_utility_code(TempitaUtilityCode.load_cached( + "BaseCaseSigned", "Overflow.c", + context={'INT': type, 'NAME': name})) + elif type in ('unsigned int', 'unsigned long', 'unsigned long long'): + env.use_utility_code(TempitaUtilityCode.load_cached( + "BaseCaseUnsigned", "Overflow.c", + context={'UINT': type, 'NAME': name})) + elif self.rank <= 1: + # sizeof(short) < sizeof(int) + return "__Pyx_%s_%s_no_overflow" % (binop, name) + else: + _load_overflow_base(env) + env.use_utility_code(TempitaUtilityCode.load_cached( + "SizeCheck", "Overflow.c", + context={'TYPE': type, 'NAME': name})) + env.use_utility_code(TempitaUtilityCode.load_cached( + "Binop", "Overflow.c", + context={'TYPE': type, 'NAME': name, 'BINOP': binop})) + return "__Pyx_%s_%s_checking_overflow" % (binop, name) + + +def _load_overflow_base(env): + env.use_utility_code(UtilityCode.load("Common", "Overflow.c")) + for type in ('int', 'long', 'long long'): + env.use_utility_code(TempitaUtilityCode.load_cached( + "BaseCaseSigned", "Overflow.c", + context={'INT': type, 'NAME': type.replace(' ', '_')})) + for type in ('unsigned int', 'unsigned long', 'unsigned long long'): + env.use_utility_code(TempitaUtilityCode.load_cached( + "BaseCaseUnsigned", "Overflow.c", + context={'UINT': type, 'NAME': type.replace(' ', '_')})) + + +class CAnonEnumType(CIntType): + + is_enum = 1 + + def sign_and_name(self): + return 'int' + + +class CReturnCodeType(CIntType): + + to_py_function = "__Pyx_Owned_Py_None" + + is_returncode = True + exception_check = False + default_format_spec = '' + + def can_coerce_to_pystring(self, env, format_spec=None): + return not format_spec + + def convert_to_pystring(self, cvalue, code, format_spec=None): + return "__Pyx_NewRef(%s)" % code.globalstate.get_py_string_const(StringEncoding.EncodedString("None")).cname + + +class CBIntType(CIntType): + + to_py_function = "__Pyx_PyBool_FromLong" + from_py_function = "__Pyx_PyObject_IsTrue" + exception_check = 1 # for C++ bool + default_format_spec = '' + + def can_coerce_to_pystring(self, env, format_spec=None): + return not format_spec or super(CBIntType, self).can_coerce_to_pystring(env, format_spec) + + def convert_to_pystring(self, cvalue, code, format_spec=None): + if format_spec: + return super(CBIntType, self).convert_to_pystring(cvalue, code, format_spec) + # NOTE: no caching here as the string constant cnames depend on the current module + utility_code_name = "__Pyx_PyUnicode_FromBInt_" + self.specialization_name() + to_pyunicode_utility = TempitaUtilityCode.load_cached( + "CBIntToPyUnicode", "TypeConversion.c", context={ + "TRUE_CONST": code.globalstate.get_py_string_const(StringEncoding.EncodedString("True")).cname, + "FALSE_CONST": code.globalstate.get_py_string_const(StringEncoding.EncodedString("False")).cname, + "TO_PY_FUNCTION": utility_code_name, + }) + code.globalstate.use_utility_code(to_pyunicode_utility) + return "%s(%s)" % (utility_code_name, cvalue) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if for_display: + base_code = 'bool' + elif pyrex: + base_code = 'bint' + else: + base_code = public_decl('int', dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + def __repr__(self): + return "<CNumericType bint>" + + def __str__(self): + return 'bint' + + def py_type_name(self): + return "bool" + + +class CPyUCS4IntType(CIntType): + # Py_UCS4 + + is_unicode_char = True + + # Py_UCS4 coerces from and to single character unicode strings (or + # at most two characters on 16bit Unicode builds), but we also + # allow Python integers as input. The value range for Py_UCS4 + # is 0..1114111, which is checked when converting from an integer + # value. + + to_py_function = "PyUnicode_FromOrdinal" + from_py_function = "__Pyx_PyObject_AsPy_UCS4" + + def can_coerce_to_pystring(self, env, format_spec=None): + return False # does the right thing anyway + + def create_from_py_utility_code(self, env): + env.use_utility_code(UtilityCode.load_cached("ObjectAsUCS4", "TypeConversion.c")) + return True + + def sign_and_name(self): + return "Py_UCS4" + + +class CPyUnicodeIntType(CIntType): + # Py_UNICODE + + is_unicode_char = True + + # Py_UNICODE coerces from and to single character unicode strings, + # but we also allow Python integers as input. The value range for + # Py_UNICODE is 0..1114111, which is checked when converting from + # an integer value. + + to_py_function = "PyUnicode_FromOrdinal" + from_py_function = "__Pyx_PyObject_AsPy_UNICODE" + + def can_coerce_to_pystring(self, env, format_spec=None): + return False # does the right thing anyway + + def create_from_py_utility_code(self, env): + env.use_utility_code(UtilityCode.load_cached("ObjectAsPyUnicode", "TypeConversion.c")) + return True + + def sign_and_name(self): + return "Py_UNICODE" + + +class CPyHashTType(CIntType): + + to_py_function = "__Pyx_PyInt_FromHash_t" + from_py_function = "__Pyx_PyInt_AsHash_t" + + def sign_and_name(self): + return "Py_hash_t" + +class CPySSizeTType(CIntType): + + to_py_function = "PyInt_FromSsize_t" + from_py_function = "__Pyx_PyIndex_AsSsize_t" + + def sign_and_name(self): + return "Py_ssize_t" + +class CSSizeTType(CIntType): + + to_py_function = "PyInt_FromSsize_t" + from_py_function = "PyInt_AsSsize_t" + + def sign_and_name(self): + return "Py_ssize_t" + +class CSizeTType(CIntType): + + to_py_function = "__Pyx_PyInt_FromSize_t" + + def sign_and_name(self): + return "size_t" + +class CPtrdiffTType(CIntType): + + def sign_and_name(self): + return "ptrdiff_t" + + +class CFloatType(CNumericType): + + is_float = 1 + to_py_function = "PyFloat_FromDouble" + from_py_function = "__pyx_PyFloat_AsDouble" + + exception_value = -1 + + def __init__(self, rank, math_h_modifier = ''): + CNumericType.__init__(self, rank, 1) + self.math_h_modifier = math_h_modifier + if rank == RANK_FLOAT: + self.from_py_function = "__pyx_PyFloat_AsFloat" + + def assignable_from_resolved_type(self, src_type): + return (src_type.is_numeric and not src_type.is_complex) or src_type is error_type + + def invalid_value(self): + return Naming.PYX_NAN + +class CComplexType(CNumericType): + + is_complex = 1 + to_py_function = "__pyx_PyComplex_FromComplex" + has_attributes = 1 + scope = None + + def __init__(self, real_type): + while real_type.is_typedef and not real_type.typedef_is_external: + real_type = real_type.typedef_base_type + self.funcsuffix = "_%s" % real_type.specialization_name() + if real_type.is_float: + self.math_h_modifier = real_type.math_h_modifier + else: + self.math_h_modifier = "_UNUSED" + + self.real_type = real_type + CNumericType.__init__(self, real_type.rank + 0.5, real_type.signed) + self.binops = {} + self.from_parts = "%s_from_parts" % self.specialization_name() + self.default_value = "%s(0, 0)" % self.from_parts + + def __eq__(self, other): + if isinstance(self, CComplexType) and isinstance(other, CComplexType): + return self.real_type == other.real_type + else: + return False + + def __ne__(self, other): + if isinstance(self, CComplexType) and isinstance(other, CComplexType): + return self.real_type != other.real_type + else: + return True + + def __lt__(self, other): + if isinstance(self, CComplexType) and isinstance(other, CComplexType): + return self.real_type < other.real_type + else: + # this is arbitrary, but it makes sure we always have + # *some* kind of order + return False + + def __hash__(self): + return ~hash(self.real_type) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + real_code = self.real_type.declaration_code("", for_display, dll_linkage, pyrex) + base_code = "%s complex" % real_code + else: + base_code = public_decl(self.sign_and_name(), dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + def sign_and_name(self): + real_type_name = self.real_type.specialization_name() + real_type_name = real_type_name.replace('long__double','long_double') + real_type_name = real_type_name.replace('PY_LONG_LONG','long_long') + return Naming.type_prefix + real_type_name + "_complex" + + def assignable_from(self, src_type): + # Temporary hack/feature disabling, see #441 + if (not src_type.is_complex and src_type.is_numeric and src_type.is_typedef + and src_type.typedef_is_external): + return False + elif src_type.is_pyobject: + return True + else: + return super(CComplexType, self).assignable_from(src_type) + + def assignable_from_resolved_type(self, src_type): + return (src_type.is_complex and self.real_type.assignable_from_resolved_type(src_type.real_type) + or src_type.is_numeric and self.real_type.assignable_from_resolved_type(src_type) + or src_type is error_type) + + def attributes_known(self): + if self.scope is None: + from . import Symtab + self.scope = scope = Symtab.CClassScope( + '', + None, + visibility="extern") + scope.parent_type = self + scope.directives = {} + scope.declare_var("real", self.real_type, None, cname="real", is_cdef=True) + scope.declare_var("imag", self.real_type, None, cname="imag", is_cdef=True) + scope.declare_cfunction( + "conjugate", + CFuncType(self, [CFuncTypeArg("self", self, None)], nogil=True), + pos=None, + defining=1, + cname="__Pyx_c_conj%s" % self.funcsuffix) + + return True + + def _utility_code_context(self): + return { + 'type': self.empty_declaration_code(), + 'type_name': self.specialization_name(), + 'real_type': self.real_type.empty_declaration_code(), + 'func_suffix': self.funcsuffix, + 'm': self.math_h_modifier, + 'is_float': int(self.real_type.is_float) + } + + def create_declaration_utility_code(self, env): + # This must always be run, because a single CComplexType instance can be shared + # across multiple compilations (the one created in the module scope) + env.use_utility_code(UtilityCode.load_cached('Header', 'Complex.c')) + env.use_utility_code(UtilityCode.load_cached('RealImag', 'Complex.c')) + env.use_utility_code(TempitaUtilityCode.load_cached( + 'Declarations', 'Complex.c', self._utility_code_context())) + env.use_utility_code(TempitaUtilityCode.load_cached( + 'Arithmetic', 'Complex.c', self._utility_code_context())) + return True + + def can_coerce_to_pyobject(self, env): + return True + + def can_coerce_from_pyobject(self, env): + return True + + def create_to_py_utility_code(self, env): + env.use_utility_code(UtilityCode.load_cached('ToPy', 'Complex.c')) + return True + + def create_from_py_utility_code(self, env): + env.use_utility_code(TempitaUtilityCode.load_cached( + 'FromPy', 'Complex.c', self._utility_code_context())) + self.from_py_function = "__Pyx_PyComplex_As_" + self.specialization_name() + return True + + def lookup_op(self, nargs, op): + try: + return self.binops[nargs, op] + except KeyError: + pass + try: + op_name = complex_ops[nargs, op] + self.binops[nargs, op] = func_name = "__Pyx_c_%s%s" % (op_name, self.funcsuffix) + return func_name + except KeyError: + return None + + def unary_op(self, op): + return self.lookup_op(1, op) + + def binary_op(self, op): + return self.lookup_op(2, op) + + def py_type_name(self): + return "complex" + + def cast_code(self, expr_code): + return expr_code + +complex_ops = { + (1, '-'): 'neg', + (1, 'zero'): 'is_zero', + (2, '+'): 'sum', + (2, '-'): 'diff', + (2, '*'): 'prod', + (2, '/'): 'quot', + (2, '**'): 'pow', + (2, '=='): 'eq', +} + + +class CPyTSSTType(CType): + # + # PEP-539 "Py_tss_t" type + # + + declaration_value = "Py_tss_NEEDS_INIT" + + def __repr__(self): + return "<Py_tss_t>" + + def declaration_code(self, entity_code, + for_display=0, dll_linkage=None, pyrex=0): + if pyrex or for_display: + base_code = "Py_tss_t" + else: + base_code = public_decl("Py_tss_t", dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + +class CPointerBaseType(CType): + # common base type for pointer/array types + # + # base_type CType Reference type + + subtypes = ['base_type'] + + def __init__(self, base_type): + self.base_type = base_type + if base_type.is_const: + base_type = base_type.const_base_type + for char_type in (c_char_type, c_uchar_type, c_schar_type): + if base_type.same_as(char_type): + self.is_string = 1 + break + else: + if base_type.same_as(c_py_unicode_type): + self.is_pyunicode_ptr = 1 + + if self.is_string and not base_type.is_error: + if base_type.signed == 2: + self.to_py_function = "__Pyx_PyObject_FromCString" + if self.is_ptr: + self.from_py_function = "__Pyx_PyObject_As%sSString" + elif base_type.signed: + self.to_py_function = "__Pyx_PyObject_FromString" + if self.is_ptr: + self.from_py_function = "__Pyx_PyObject_As%sString" + else: + self.to_py_function = "__Pyx_PyObject_FromCString" + if self.is_ptr: + self.from_py_function = "__Pyx_PyObject_As%sUString" + if self.is_ptr: + self.from_py_function %= '' if self.base_type.is_const else 'Writable' + self.exception_value = "NULL" + elif self.is_pyunicode_ptr and not base_type.is_error: + self.to_py_function = "__Pyx_PyUnicode_FromUnicode" + if self.is_ptr: + self.from_py_function = "__Pyx_PyUnicode_AsUnicode" + self.exception_value = "NULL" + + def py_type_name(self): + if self.is_string: + return "bytes" + elif self.is_pyunicode_ptr: + return "unicode" + else: + return super(CPointerBaseType, self).py_type_name() + + def literal_code(self, value): + if self.is_string: + assert isinstance(value, str) + return '"%s"' % StringEncoding.escape_byte_string(value) + + +class CArrayType(CPointerBaseType): + # base_type CType Element type + # size integer or None Number of elements + + is_array = 1 + to_tuple_function = None + + def __init__(self, base_type, size): + super(CArrayType, self).__init__(base_type) + self.size = size + + def __eq__(self, other): + if isinstance(other, CType) and other.is_array and self.size == other.size: + return self.base_type.same_as(other.base_type) + return False + + def __hash__(self): + return hash(self.base_type) + 28 # arbitrarily chosen offset + + def __repr__(self): + return "<CArrayType %s %s>" % (self.size, repr(self.base_type)) + + def same_as_resolved_type(self, other_type): + return ((other_type.is_array and + self.base_type.same_as(other_type.base_type)) + or other_type is error_type) + + def assignable_from_resolved_type(self, src_type): + # C arrays are assigned by value, either Python containers or C arrays/pointers + if src_type.is_pyobject: + return True + if src_type.is_ptr or src_type.is_array: + return self.base_type.assignable_from(src_type.base_type) + return False + + def element_ptr_type(self): + return c_ptr_type(self.base_type) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if self.size is not None: + dimension_code = self.size + else: + dimension_code = "" + if entity_code.startswith("*"): + entity_code = "(%s)" % entity_code + return self.base_type.declaration_code( + "%s[%s]" % (entity_code, dimension_code), + for_display, dll_linkage, pyrex) + + def as_argument_type(self): + return c_ptr_type(self.base_type) + + def is_complete(self): + return self.size is not None + + def specialize(self, values): + base_type = self.base_type.specialize(values) + if base_type == self.base_type: + return self + else: + return CArrayType(base_type, self.size) + + def deduce_template_params(self, actual): + if isinstance(actual, CArrayType): + return self.base_type.deduce_template_params(actual.base_type) + else: + return {} + + def can_coerce_to_pyobject(self, env): + return self.base_type.can_coerce_to_pyobject(env) + + def can_coerce_from_pyobject(self, env): + return self.base_type.can_coerce_from_pyobject(env) + + def create_to_py_utility_code(self, env): + if self.to_py_function is not None: + return self.to_py_function + if not self.base_type.create_to_py_utility_code(env): + return False + + safe_typename = self.base_type.specialization_name() + to_py_function = "__Pyx_carray_to_py_%s" % safe_typename + to_tuple_function = "__Pyx_carray_to_tuple_%s" % safe_typename + + from .UtilityCode import CythonUtilityCode + context = { + 'cname': to_py_function, + 'to_tuple_cname': to_tuple_function, + 'base_type': self.base_type, + } + env.use_utility_code(CythonUtilityCode.load( + "carray.to_py", "CConvert.pyx", + outer_module_scope=env.global_scope(), # need access to types declared in module + context=context, compiler_directives=dict(env.global_scope().directives))) + self.to_tuple_function = to_tuple_function + self.to_py_function = to_py_function + return True + + def to_py_call_code(self, source_code, result_code, result_type, to_py_function=None): + func = self.to_py_function if to_py_function is None else to_py_function + if self.is_string or self.is_pyunicode_ptr: + return '%s = %s(%s)' % ( + result_code, + func, + source_code) + target_is_tuple = result_type.is_builtin_type and result_type.name == 'tuple' + return '%s = %s(%s, %s)' % ( + result_code, + self.to_tuple_function if target_is_tuple else func, + source_code, + self.size) + + def create_from_py_utility_code(self, env): + if self.from_py_function is not None: + return self.from_py_function + if not self.base_type.create_from_py_utility_code(env): + return False + + from_py_function = "__Pyx_carray_from_py_%s" % self.base_type.specialization_name() + + from .UtilityCode import CythonUtilityCode + context = { + 'cname': from_py_function, + 'base_type': self.base_type, + } + env.use_utility_code(CythonUtilityCode.load( + "carray.from_py", "CConvert.pyx", + outer_module_scope=env.global_scope(), # need access to types declared in module + context=context, compiler_directives=dict(env.global_scope().directives))) + self.from_py_function = from_py_function + return True + + def from_py_call_code(self, source_code, result_code, error_pos, code, + from_py_function=None, error_condition=None): + assert not error_condition, '%s: %s' % (error_pos, error_condition) + call_code = "%s(%s, %s, %s)" % ( + from_py_function or self.from_py_function, + source_code, result_code, self.size) + return code.error_goto_if_neg(call_code, error_pos) + + +class CPtrType(CPointerBaseType): + # base_type CType Reference type + + is_ptr = 1 + default_value = "0" + + def __hash__(self): + return hash(self.base_type) + 27 # arbitrarily chosen offset + + def __eq__(self, other): + if isinstance(other, CType) and other.is_ptr: + return self.base_type.same_as(other.base_type) + return False + + def __ne__(self, other): + return not (self == other) + + def __repr__(self): + return "<CPtrType %s>" % repr(self.base_type) + + def same_as_resolved_type(self, other_type): + return ((other_type.is_ptr and + self.base_type.same_as(other_type.base_type)) + or other_type is error_type) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + #print "CPtrType.declaration_code: pointer to", self.base_type ### + return self.base_type.declaration_code( + "*%s" % entity_code, + for_display, dll_linkage, pyrex) + + def assignable_from_resolved_type(self, other_type): + if other_type is error_type: + return 1 + if other_type.is_null_ptr: + return 1 + if self.base_type.is_const: + self = CPtrType(self.base_type.const_base_type) + if self.base_type.is_cfunction: + if other_type.is_ptr: + other_type = other_type.base_type.resolve() + if other_type.is_cfunction: + return self.base_type.pointer_assignable_from_resolved_type(other_type) + else: + return 0 + if (self.base_type.is_cpp_class and other_type.is_ptr + and other_type.base_type.is_cpp_class and other_type.base_type.is_subclass(self.base_type)): + return 1 + if other_type.is_array or other_type.is_ptr: + return self.base_type.is_void or self.base_type.same_as(other_type.base_type) + return 0 + + def specialize(self, values): + base_type = self.base_type.specialize(values) + if base_type == self.base_type: + return self + else: + return CPtrType(base_type) + + def deduce_template_params(self, actual): + if isinstance(actual, CPtrType): + return self.base_type.deduce_template_params(actual.base_type) + else: + return {} + + def invalid_value(self): + return "1" + + def find_cpp_operation_type(self, operator, operand_type=None): + if self.base_type.is_cpp_class: + return self.base_type.find_cpp_operation_type(operator, operand_type) + return None + + +class CNullPtrType(CPtrType): + + is_null_ptr = 1 + + +class CReferenceType(BaseType): + + is_reference = 1 + is_fake_reference = 0 + + def __init__(self, base_type): + self.ref_base_type = base_type + + def __repr__(self): + return "<CReferenceType %s>" % repr(self.ref_base_type) + + def __str__(self): + return "%s &" % self.ref_base_type + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + #print "CReferenceType.declaration_code: pointer to", self.base_type ### + return self.ref_base_type.declaration_code( + "&%s" % entity_code, + for_display, dll_linkage, pyrex) + + def specialize(self, values): + base_type = self.ref_base_type.specialize(values) + if base_type == self.ref_base_type: + return self + else: + return type(self)(base_type) + + def deduce_template_params(self, actual): + return self.ref_base_type.deduce_template_params(actual) + + def __getattr__(self, name): + return getattr(self.ref_base_type, name) + + +class CFakeReferenceType(CReferenceType): + + is_fake_reference = 1 + + def __repr__(self): + return "<CFakeReferenceType %s>" % repr(self.ref_base_type) + + def __str__(self): + return "%s [&]" % self.ref_base_type + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + #print "CReferenceType.declaration_code: pointer to", self.base_type ### + return "__Pyx_FakeReference<%s> %s" % (self.ref_base_type.empty_declaration_code(), entity_code) + + +class CFuncType(CType): + # return_type CType + # args [CFuncTypeArg] + # has_varargs boolean + # exception_value string + # exception_check boolean True if PyErr_Occurred check needed + # calling_convention string Function calling convention + # nogil boolean Can be called without gil + # with_gil boolean Acquire gil around function body + # templates [string] or None + # cached_specialized_types [CFuncType] cached specialized versions of the CFuncType if defined in a pxd + # from_fused boolean Indicates whether this is a specialized + # C function + # is_strict_signature boolean function refuses to accept coerced arguments + # (used for optimisation overrides) + # is_const_method boolean + # is_static_method boolean + + is_cfunction = 1 + original_sig = None + cached_specialized_types = None + from_fused = False + is_const_method = False + + subtypes = ['return_type', 'args'] + + def __init__(self, return_type, args, has_varargs = 0, + exception_value = None, exception_check = 0, calling_convention = "", + nogil = 0, with_gil = 0, is_overridable = 0, optional_arg_count = 0, + is_const_method = False, is_static_method=False, + templates = None, is_strict_signature = False): + self.return_type = return_type + self.args = args + self.has_varargs = has_varargs + self.optional_arg_count = optional_arg_count + self.exception_value = exception_value + self.exception_check = exception_check + self.calling_convention = calling_convention + self.nogil = nogil + self.with_gil = with_gil + self.is_overridable = is_overridable + self.is_const_method = is_const_method + self.is_static_method = is_static_method + self.templates = templates + self.is_strict_signature = is_strict_signature + + def __repr__(self): + arg_reprs = list(map(repr, self.args)) + if self.has_varargs: + arg_reprs.append("...") + if self.exception_value: + except_clause = " %r" % self.exception_value + else: + except_clause = "" + if self.exception_check: + except_clause += "?" + return "<CFuncType %s %s[%s]%s>" % ( + repr(self.return_type), + self.calling_convention_prefix(), + ",".join(arg_reprs), + except_clause) + + def with_with_gil(self, with_gil): + if with_gil == self.with_gil: + return self + else: + return CFuncType( + self.return_type, self.args, self.has_varargs, + self.exception_value, self.exception_check, + self.calling_convention, self.nogil, + with_gil, + self.is_overridable, self.optional_arg_count, + self.is_const_method, self.is_static_method, + self.templates, self.is_strict_signature) + + def calling_convention_prefix(self): + cc = self.calling_convention + if cc: + return cc + " " + else: + return "" + + def as_argument_type(self): + return c_ptr_type(self) + + def same_c_signature_as(self, other_type, as_cmethod = 0): + return self.same_c_signature_as_resolved_type( + other_type.resolve(), as_cmethod) + + def same_c_signature_as_resolved_type(self, other_type, as_cmethod=False, as_pxd_definition=False, + exact_semantics=True): + # If 'exact_semantics' is false, allow any equivalent C signatures + # if the Cython semantics are compatible, i.e. the same or wider for 'other_type'. + + #print "CFuncType.same_c_signature_as_resolved_type:", \ + # self, other_type, "as_cmethod =", as_cmethod ### + if other_type is error_type: + return 1 + if not other_type.is_cfunction: + return 0 + if self.is_overridable != other_type.is_overridable: + return 0 + nargs = len(self.args) + if nargs != len(other_type.args): + return 0 + # When comparing C method signatures, the first argument + # is exempt from compatibility checking (the proper check + # is performed elsewhere). + for i in range(as_cmethod, nargs): + if not self.args[i].type.same_as(other_type.args[i].type): + return 0 + if self.has_varargs != other_type.has_varargs: + return 0 + if self.optional_arg_count != other_type.optional_arg_count: + return 0 + if as_pxd_definition: + # A narrowing of the return type declared in the pxd is allowed. + if not self.return_type.subtype_of_resolved_type(other_type.return_type): + return 0 + else: + if not self.return_type.same_as(other_type.return_type): + return 0 + if not self.same_calling_convention_as(other_type): + return 0 + if exact_semantics: + if self.exception_check != other_type.exception_check: + return 0 + if not self._same_exception_value(other_type.exception_value): + return 0 + elif not self._is_exception_compatible_with(other_type): + return 0 + return 1 + + def _same_exception_value(self, other_exc_value): + if self.exception_value == other_exc_value: + return 1 + if self.exception_check != '+': + return 0 + if not self.exception_value or not other_exc_value: + return 0 + if self.exception_value.type != other_exc_value.type: + return 0 + if self.exception_value.entry and other_exc_value.entry: + if self.exception_value.entry.cname != other_exc_value.entry.cname: + return 0 + if self.exception_value.name != other_exc_value.name: + return 0 + return 1 + + def compatible_signature_with(self, other_type, as_cmethod = 0): + return self.compatible_signature_with_resolved_type(other_type.resolve(), as_cmethod) + + def compatible_signature_with_resolved_type(self, other_type, as_cmethod): + #print "CFuncType.same_c_signature_as_resolved_type:", \ + # self, other_type, "as_cmethod =", as_cmethod ### + if other_type is error_type: + return 1 + if not other_type.is_cfunction: + return 0 + if not self.is_overridable and other_type.is_overridable: + return 0 + nargs = len(self.args) + if nargs - self.optional_arg_count != len(other_type.args) - other_type.optional_arg_count: + return 0 + if self.optional_arg_count < other_type.optional_arg_count: + return 0 + # When comparing C method signatures, the first argument + # is exempt from compatibility checking (the proper check + # is performed elsewhere). + for i in range(as_cmethod, len(other_type.args)): + if not self.args[i].type.same_as( + other_type.args[i].type): + return 0 + if self.has_varargs != other_type.has_varargs: + return 0 + if not self.return_type.subtype_of_resolved_type(other_type.return_type): + return 0 + if not self.same_calling_convention_as(other_type): + return 0 + if self.nogil != other_type.nogil: + return 0 + if not self._is_exception_compatible_with(other_type): + return 0 + self.original_sig = other_type.original_sig or other_type + return 1 + + def _is_exception_compatible_with(self, other_type): + # narrower exception checks are ok, but prevent mismatches + if self.exception_check == '+' and other_type.exception_check != '+': + # must catch C++ exceptions if we raise them + return 0 + if not other_type.exception_check or other_type.exception_value is not None: + # if other does not *always* check exceptions, self must comply + if not self._same_exception_value(other_type.exception_value): + return 0 + if self.exception_check and self.exception_check != other_type.exception_check: + # a redundant exception check doesn't make functions incompatible, but a missing one does + return 0 + return 1 + + def narrower_c_signature_than(self, other_type, as_cmethod = 0): + return self.narrower_c_signature_than_resolved_type(other_type.resolve(), as_cmethod) + + def narrower_c_signature_than_resolved_type(self, other_type, as_cmethod): + if other_type is error_type: + return 1 + if not other_type.is_cfunction: + return 0 + nargs = len(self.args) + if nargs != len(other_type.args): + return 0 + for i in range(as_cmethod, nargs): + if not self.args[i].type.subtype_of_resolved_type(other_type.args[i].type): + return 0 + else: + self.args[i].needs_type_test = other_type.args[i].needs_type_test \ + or not self.args[i].type.same_as(other_type.args[i].type) + if self.has_varargs != other_type.has_varargs: + return 0 + if self.optional_arg_count != other_type.optional_arg_count: + return 0 + if not self.return_type.subtype_of_resolved_type(other_type.return_type): + return 0 + if not self.exception_check and other_type.exception_check: + # a redundant exception check doesn't make functions incompatible, but a missing one does + return 0 + if not self._same_exception_value(other_type.exception_value): + return 0 + return 1 + + def same_calling_convention_as(self, other): + ## XXX Under discussion ... + ## callspec_words = ("__stdcall", "__cdecl", "__fastcall") + ## cs1 = self.calling_convention + ## cs2 = other.calling_convention + ## if (cs1 in callspec_words or + ## cs2 in callspec_words): + ## return cs1 == cs2 + ## else: + ## return True + sc1 = self.calling_convention == '__stdcall' + sc2 = other.calling_convention == '__stdcall' + return sc1 == sc2 + + def same_as_resolved_type(self, other_type, as_cmethod=False): + return self.same_c_signature_as_resolved_type(other_type, as_cmethod=as_cmethod) \ + and self.nogil == other_type.nogil + + def pointer_assignable_from_resolved_type(self, rhs_type): + # Accept compatible exception/nogil declarations for the RHS. + if rhs_type is error_type: + return 1 + if not rhs_type.is_cfunction: + return 0 + return rhs_type.same_c_signature_as_resolved_type(self, exact_semantics=False) \ + and not (self.nogil and not rhs_type.nogil) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0, + with_calling_convention = 1): + arg_decl_list = [] + for arg in self.args[:len(self.args)-self.optional_arg_count]: + arg_decl_list.append( + arg.type.declaration_code("", for_display, pyrex = pyrex)) + if self.is_overridable: + arg_decl_list.append("int %s" % Naming.skip_dispatch_cname) + if self.optional_arg_count: + arg_decl_list.append(self.op_arg_struct.declaration_code(Naming.optional_args_cname)) + if self.has_varargs: + arg_decl_list.append("...") + arg_decl_code = ", ".join(arg_decl_list) + if not arg_decl_code and not pyrex: + arg_decl_code = "void" + trailer = "" + if (pyrex or for_display) and not self.return_type.is_pyobject: + if self.exception_value and self.exception_check: + trailer = " except? %s" % self.exception_value + elif self.exception_value: + trailer = " except %s" % self.exception_value + elif self.exception_check == '+': + trailer = " except +" + elif self.exception_check and for_display: + # not spelled out by default, unless for human eyes + trailer = " except *" + if self.nogil: + trailer += " nogil" + if not with_calling_convention: + cc = '' + else: + cc = self.calling_convention_prefix() + if (not entity_code and cc) or entity_code.startswith("*"): + entity_code = "(%s%s)" % (cc, entity_code) + cc = "" + if self.is_const_method: + trailer += " const" + return self.return_type.declaration_code( + "%s%s(%s)%s" % (cc, entity_code, arg_decl_code, trailer), + for_display, dll_linkage, pyrex) + + def function_header_code(self, func_name, arg_code): + if self.is_const_method: + trailer = " const" + else: + trailer = "" + return "%s%s(%s)%s" % (self.calling_convention_prefix(), + func_name, arg_code, trailer) + + def signature_string(self): + s = self.empty_declaration_code() + return s + + def signature_cast_string(self): + s = self.declaration_code("(*)", with_calling_convention=False) + return '(%s)' % s + + def specialize(self, values): + result = CFuncType(self.return_type.specialize(values), + [arg.specialize(values) for arg in self.args], + has_varargs = self.has_varargs, + exception_value = self.exception_value, + exception_check = self.exception_check, + calling_convention = self.calling_convention, + nogil = self.nogil, + with_gil = self.with_gil, + is_overridable = self.is_overridable, + optional_arg_count = self.optional_arg_count, + is_const_method = self.is_const_method, + is_static_method = self.is_static_method, + templates = self.templates) + + result.from_fused = self.is_fused + return result + + def opt_arg_cname(self, arg_name): + return self.op_arg_struct.base_type.scope.lookup(arg_name).cname + + # Methods that deal with Fused Types + # All but map_with_specific_entries should be called only on functions + # with fused types (and not on their corresponding specific versions). + + def get_all_specialized_permutations(self, fused_types=None): + """ + Permute all the types. For every specific instance of a fused type, we + want all other specific instances of all other fused types. + + It returns an iterable of two-tuples of the cname that should prefix + the cname of the function, and a dict mapping any fused types to their + respective specific types. + """ + assert self.is_fused + + if fused_types is None: + fused_types = self.get_fused_types() + + return get_all_specialized_permutations(fused_types) + + def get_all_specialized_function_types(self): + """ + Get all the specific function types of this one. + """ + assert self.is_fused + + if self.entry.fused_cfunction: + return [n.type for n in self.entry.fused_cfunction.nodes] + elif self.cached_specialized_types is not None: + return self.cached_specialized_types + + result = [] + permutations = self.get_all_specialized_permutations() + + new_cfunc_entries = [] + for cname, fused_to_specific in permutations: + new_func_type = self.entry.type.specialize(fused_to_specific) + + if self.optional_arg_count: + # Remember, this method is set by CFuncDeclaratorNode + self.declare_opt_arg_struct(new_func_type, cname) + + new_entry = copy.deepcopy(self.entry) + new_func_type.specialize_entry(new_entry, cname) + + new_entry.type = new_func_type + new_func_type.entry = new_entry + result.append(new_func_type) + + new_cfunc_entries.append(new_entry) + + cfunc_entries = self.entry.scope.cfunc_entries + try: + cindex = cfunc_entries.index(self.entry) + except ValueError: + cfunc_entries.extend(new_cfunc_entries) + else: + cfunc_entries[cindex:cindex+1] = new_cfunc_entries + + self.cached_specialized_types = result + + return result + + def get_fused_types(self, result=None, seen=None, subtypes=None): + """Return fused types in the order they appear as parameter types""" + return super(CFuncType, self).get_fused_types(result, seen, + subtypes=['args']) + + def specialize_entry(self, entry, cname): + assert not self.is_fused + specialize_entry(entry, cname) + + def can_coerce_to_pyobject(self, env): + # duplicating the decisions from create_to_py_utility_code() here avoids writing out unused code + if self.has_varargs or self.optional_arg_count: + return False + if self.to_py_function is not None: + return self.to_py_function + for arg in self.args: + if not arg.type.is_pyobject and not arg.type.can_coerce_to_pyobject(env): + return False + if not self.return_type.is_pyobject and not self.return_type.can_coerce_to_pyobject(env): + return False + return True + + def create_to_py_utility_code(self, env): + # FIXME: it seems we're trying to coerce in more cases than we should + if self.to_py_function is not None: + return self.to_py_function + if not self.can_coerce_to_pyobject(env): + return False + from .UtilityCode import CythonUtilityCode + safe_typename = re.sub('[^a-zA-Z0-9]', '__', self.declaration_code("", pyrex=1)) + to_py_function = "__Pyx_CFunc_%s_to_py" % safe_typename + + for arg in self.args: + if not arg.type.is_pyobject and not arg.type.create_from_py_utility_code(env): + return False + if not self.return_type.is_pyobject and not self.return_type.create_to_py_utility_code(env): + return False + + def declared_type(ctype): + type_displayname = str(ctype.declaration_code("", for_display=True)) + if ctype.is_pyobject: + arg_ctype = type_name = type_displayname + if ctype.is_builtin_type: + arg_ctype = ctype.name + elif not ctype.is_extension_type: + type_name = 'object' + type_displayname = None + else: + type_displayname = repr(type_displayname) + elif ctype is c_bint_type: + type_name = arg_ctype = 'bint' + else: + type_name = arg_ctype = type_displayname + if ctype is c_double_type: + type_displayname = 'float' + else: + type_displayname = repr(type_displayname) + return type_name, arg_ctype, type_displayname + + class Arg(object): + def __init__(self, arg_name, arg_type): + self.name = arg_name + self.type = arg_type + self.type_cname, self.ctype, self.type_displayname = declared_type(arg_type) + + if self.return_type.is_void: + except_clause = 'except *' + elif self.return_type.is_pyobject: + except_clause = '' + elif self.exception_value: + except_clause = ('except? %s' if self.exception_check else 'except %s') % self.exception_value + else: + except_clause = 'except *' + + context = { + 'cname': to_py_function, + 'args': [Arg(arg.name or 'arg%s' % ix, arg.type) for ix, arg in enumerate(self.args)], + 'return_type': Arg('return', self.return_type), + 'except_clause': except_clause, + } + # FIXME: directives come from first defining environment and do not adapt for reuse + env.use_utility_code(CythonUtilityCode.load( + "cfunc.to_py", "CConvert.pyx", + outer_module_scope=env.global_scope(), # need access to types declared in module + context=context, compiler_directives=dict(env.global_scope().directives))) + self.to_py_function = to_py_function + return True + + +def specialize_entry(entry, cname): + """ + Specialize an entry of a copied fused function or method + """ + entry.is_fused_specialized = True + entry.name = get_fused_cname(cname, entry.name) + + if entry.is_cmethod: + entry.cname = entry.name + if entry.is_inherited: + entry.cname = StringEncoding.EncodedString( + "%s.%s" % (Naming.obj_base_cname, entry.cname)) + else: + entry.cname = get_fused_cname(cname, entry.cname) + + if entry.func_cname: + entry.func_cname = get_fused_cname(cname, entry.func_cname) + +def get_fused_cname(fused_cname, orig_cname): + """ + Given the fused cname id and an original cname, return a specialized cname + """ + assert fused_cname and orig_cname + return StringEncoding.EncodedString('%s%s%s' % (Naming.fused_func_prefix, + fused_cname, orig_cname)) + +def unique(somelist): + seen = set() + result = [] + for obj in somelist: + if obj not in seen: + result.append(obj) + seen.add(obj) + + return result + +def get_all_specialized_permutations(fused_types): + return _get_all_specialized_permutations(unique(fused_types)) + +def _get_all_specialized_permutations(fused_types, id="", f2s=()): + fused_type, = fused_types[0].get_fused_types() + result = [] + + for newid, specific_type in enumerate(fused_type.types): + # f2s = dict(f2s, **{ fused_type: specific_type }) + f2s = dict(f2s) + f2s.update({ fused_type: specific_type }) + + if id: + cname = '%s_%s' % (id, newid) + else: + cname = str(newid) + + if len(fused_types) > 1: + result.extend(_get_all_specialized_permutations( + fused_types[1:], cname, f2s)) + else: + result.append((cname, f2s)) + + return result + +def specialization_signature_string(fused_compound_type, fused_to_specific): + """ + Return the signature for a specialization of a fused type. e.g. + + floating[:] -> + 'float' or 'double' + + cdef fused ft: + float[:] + double[:] + + ft -> + 'float[:]' or 'double[:]' + + integral func(floating) -> + 'int (*func)(float)' or ... + """ + fused_types = fused_compound_type.get_fused_types() + if len(fused_types) == 1: + fused_type = fused_types[0] + else: + fused_type = fused_compound_type + + return fused_type.specialize(fused_to_specific).typeof_name() + + +def get_specialized_types(type): + """ + Return a list of specialized types in their declared order. + """ + assert type.is_fused + + if isinstance(type, FusedType): + result = list(type.types) + for specialized_type in result: + specialized_type.specialization_string = specialized_type.typeof_name() + else: + result = [] + for cname, f2s in get_all_specialized_permutations(type.get_fused_types()): + specialized_type = type.specialize(f2s) + specialized_type.specialization_string = ( + specialization_signature_string(type, f2s)) + result.append(specialized_type) + + return result + + +class CFuncTypeArg(BaseType): + # name string + # cname string + # type PyrexType + # pos source file position + + # FIXME: is this the right setup? should None be allowed here? + not_none = False + or_none = False + accept_none = True + accept_builtin_subtypes = False + annotation = None + + subtypes = ['type'] + + def __init__(self, name, type, pos, cname=None, annotation=None): + self.name = name + if cname is not None: + self.cname = cname + else: + self.cname = Naming.var_prefix + name + if annotation is not None: + self.annotation = annotation + self.type = type + self.pos = pos + self.needs_type_test = False # TODO: should these defaults be set in analyse_types()? + + def __repr__(self): + return "%s:%s" % (self.name, repr(self.type)) + + def declaration_code(self, for_display = 0): + return self.type.declaration_code(self.cname, for_display) + + def specialize(self, values): + return CFuncTypeArg(self.name, self.type.specialize(values), self.pos, self.cname) + + +class ToPyStructUtilityCode(object): + + requires = None + + def __init__(self, type, forward_decl, env): + self.type = type + self.header = "static PyObject* %s(%s)" % (type.to_py_function, + type.declaration_code('s')) + self.forward_decl = forward_decl + self.env = env + + def __eq__(self, other): + return isinstance(other, ToPyStructUtilityCode) and self.header == other.header + + def __hash__(self): + return hash(self.header) + + def get_tree(self, **kwargs): + pass + + def put_code(self, output): + code = output['utility_code_def'] + proto = output['utility_code_proto'] + + code.putln("%s {" % self.header) + code.putln("PyObject* res;") + code.putln("PyObject* member;") + code.putln("res = __Pyx_PyDict_NewPresized(%d); if (unlikely(!res)) return NULL;" % + len(self.type.scope.var_entries)) + for member in self.type.scope.var_entries: + nameconst_cname = code.get_py_string_const(member.name, identifier=True) + code.putln("%s; if (unlikely(!member)) goto bad;" % ( + member.type.to_py_call_code('s.%s' % member.cname, 'member', member.type))) + code.putln("if (unlikely(PyDict_SetItem(res, %s, member) < 0)) goto bad;" % nameconst_cname) + code.putln("Py_DECREF(member);") + code.putln("return res;") + code.putln("bad:") + code.putln("Py_XDECREF(member);") + code.putln("Py_DECREF(res);") + code.putln("return NULL;") + code.putln("}") + + # This is a bit of a hack, we need a forward declaration + # due to the way things are ordered in the module... + if self.forward_decl: + proto.putln(self.type.empty_declaration_code() + ';') + proto.putln(self.header + ";") + + def inject_tree_and_scope_into(self, module_node): + pass + + +class CStructOrUnionType(CType): + # name string + # cname string + # kind string "struct" or "union" + # scope StructOrUnionScope, or None if incomplete + # typedef_flag boolean + # packed boolean + + # entry Entry + + is_struct_or_union = 1 + has_attributes = 1 + exception_check = True + + def __init__(self, name, kind, scope, typedef_flag, cname, packed=False): + self.name = name + self.cname = cname + self.kind = kind + self.scope = scope + self.typedef_flag = typedef_flag + self.is_struct = kind == 'struct' + self.to_py_function = "%s_to_py_%s" % ( + Naming.convert_func_prefix, self.specialization_name()) + self.from_py_function = "%s_from_py_%s" % ( + Naming.convert_func_prefix, self.specialization_name()) + self.exception_check = True + self._convert_to_py_code = None + self._convert_from_py_code = None + self.packed = packed + + def can_coerce_to_pyobject(self, env): + if self._convert_to_py_code is False: + return None # tri-state-ish + + if env.outer_scope is None: + return False + + if self._convert_to_py_code is None: + is_union = not self.is_struct + unsafe_union_types = set() + safe_union_types = set() + for member in self.scope.var_entries: + member_type = member.type + if not member_type.can_coerce_to_pyobject(env): + self.to_py_function = None + self._convert_to_py_code = False + return False + if is_union: + if member_type.is_ptr or member_type.is_cpp_class: + unsafe_union_types.add(member_type) + else: + safe_union_types.add(member_type) + + if unsafe_union_types and (safe_union_types or len(unsafe_union_types) > 1): + # unsafe mix of safe and unsafe to convert types + self.from_py_function = None + self._convert_from_py_code = False + return False + + return True + + def create_to_py_utility_code(self, env): + if not self.can_coerce_to_pyobject(env): + return False + + if self._convert_to_py_code is None: + for member in self.scope.var_entries: + member.type.create_to_py_utility_code(env) + forward_decl = self.entry.visibility != 'extern' and not self.typedef_flag + self._convert_to_py_code = ToPyStructUtilityCode(self, forward_decl, env) + + env.use_utility_code(self._convert_to_py_code) + return True + + def can_coerce_from_pyobject(self, env): + if env.outer_scope is None or self._convert_from_py_code is False: + return False + for member in self.scope.var_entries: + if not member.type.can_coerce_from_pyobject(env): + return False + return True + + def create_from_py_utility_code(self, env): + if env.outer_scope is None: + return False + + if self._convert_from_py_code is False: + return None # tri-state-ish + + if self._convert_from_py_code is None: + if not self.scope.var_entries: + # There are obviously missing fields; don't allow instantiation + # where absolutely no content is provided. + return False + + for member in self.scope.var_entries: + if not member.type.create_from_py_utility_code(env): + self.from_py_function = None + self._convert_from_py_code = False + return False + + context = dict( + struct_type=self, + var_entries=self.scope.var_entries, + funcname=self.from_py_function, + ) + from .UtilityCode import CythonUtilityCode + self._convert_from_py_code = CythonUtilityCode.load( + "FromPyStructUtility" if self.is_struct else "FromPyUnionUtility", + "CConvert.pyx", + outer_module_scope=env.global_scope(), # need access to types declared in module + context=context) + + env.use_utility_code(self._convert_from_py_code) + return True + + def __repr__(self): + return "<CStructOrUnionType %s %s%s>" % ( + self.name, self.cname, + ("", " typedef")[self.typedef_flag]) + + def declaration_code(self, entity_code, + for_display=0, dll_linkage=None, pyrex=0): + if pyrex or for_display: + base_code = self.name + else: + if self.typedef_flag: + base_code = self.cname + else: + base_code = "%s %s" % (self.kind, self.cname) + base_code = public_decl(base_code, dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + def __eq__(self, other): + try: + return (isinstance(other, CStructOrUnionType) and + self.name == other.name) + except AttributeError: + return False + + def __lt__(self, other): + try: + return self.name < other.name + except AttributeError: + # this is arbitrary, but it makes sure we always have + # *some* kind of order + return False + + def __hash__(self): + return hash(self.cname) ^ hash(self.kind) + + def is_complete(self): + return self.scope is not None + + def attributes_known(self): + return self.is_complete() + + def can_be_complex(self): + # Does the struct consist of exactly two identical floats? + fields = self.scope.var_entries + if len(fields) != 2: return False + a, b = fields + return (a.type.is_float and b.type.is_float and + a.type.empty_declaration_code() == + b.type.empty_declaration_code()) + + def struct_nesting_depth(self): + child_depths = [x.type.struct_nesting_depth() + for x in self.scope.var_entries] + return max(child_depths) + 1 + + def cast_code(self, expr_code): + if self.is_struct: + return expr_code + return super(CStructOrUnionType, self).cast_code(expr_code) + +cpp_string_conversions = ("std::string", "TString", "TStringBuf") + +builtin_cpp_conversions = { + # type element template params + "std::pair": 2, + "std::vector": 1, + "std::list": 1, + "std::set": 1, + "std::unordered_set": 1, + "std::map": 2, + "std::unordered_map": 2, + "std::complex": 1, + # arcadia_cpp_conversions + "TMaybe": 1, + "TVector": 1, + "THashMap": 2, + "TMap": 2, +} + +class CppClassType(CType): + # name string + # cname string + # scope CppClassScope + # templates [string] or None + + is_cpp_class = 1 + has_attributes = 1 + exception_check = True + namespace = None + + # For struct-like declaration. + kind = "struct" + packed = False + typedef_flag = False + + subtypes = ['templates'] + + def __init__(self, name, scope, cname, base_classes, templates=None, template_type=None): + self.name = name + self.cname = cname + self.scope = scope + self.base_classes = base_classes + self.operators = [] + self.templates = templates + self.template_type = template_type + self.num_optional_templates = sum(is_optional_template_param(T) for T in templates or ()) + if templates and False: # https://github.com/cython/cython/issues/1868 + self.specializations = {tuple(zip(templates, templates)): self} + else: + self.specializations = {} + self.is_cpp_string = cname in cpp_string_conversions + + def use_conversion_utility(self, from_or_to): + pass + + def maybe_unordered(self): + if 'unordered' in self.cname: + return 'unordered_' + else: + return '' + + def can_coerce_from_pyobject(self, env): + if self.cname in builtin_cpp_conversions: + template_count = builtin_cpp_conversions[self.cname] + for ix, T in enumerate(self.templates or []): + if ix >= template_count: + break + if T.is_pyobject or not T.can_coerce_from_pyobject(env): + return False + return True + elif self.cname in cpp_string_conversions: + return True + return False + + def create_from_py_utility_code(self, env): + if self.from_py_function is not None: + return True + if self.cname in builtin_cpp_conversions or self.cname in cpp_string_conversions: + X = "XYZABC" + tags = [] + context = {} + for ix, T in enumerate(self.templates or []): + if ix >= builtin_cpp_conversions[self.cname]: + break + if T.is_pyobject or not T.create_from_py_utility_code(env): + return False + tags.append(T.specialization_name()) + context[X[ix]] = T + + if self.cname in cpp_string_conversions: + cls = 'string' + tags = type_identifier(self), + elif self.cname.startswith('std::'): + cls = self.cname[5:] + else: + cls = 'arcadia_' + self.cname + cname = '__pyx_convert_%s_from_py_%s' % (cls, '__and_'.join(tags)) + context.update({ + 'cname': cname, + 'maybe_unordered': self.maybe_unordered(), + 'type': self.cname, + }) + from .UtilityCode import CythonUtilityCode + env.use_utility_code(CythonUtilityCode.load( + cls.replace('unordered_', '') + ".from_py", "CppConvert.pyx", + context=context, compiler_directives=env.directives)) + self.from_py_function = cname + return True + + def can_coerce_to_pyobject(self, env): + if self.cname in builtin_cpp_conversions or self.cname in cpp_string_conversions: + for ix, T in enumerate(self.templates or []): + if ix >= builtin_cpp_conversions[self.cname]: + break + if T.is_pyobject or not T.can_coerce_to_pyobject(env): + return False + return True + + def create_to_py_utility_code(self, env): + if self.to_py_function is not None: + return True + if self.cname in builtin_cpp_conversions or self.cname in cpp_string_conversions: + X = "XYZABC" + tags = [] + context = {} + for ix, T in enumerate(self.templates or []): + if ix >= builtin_cpp_conversions[self.cname]: + break + if not T.create_to_py_utility_code(env): + return False + tags.append(T.specialization_name()) + context[X[ix]] = T + + if self.cname in cpp_string_conversions: + cls = 'string' + prefix = 'PyObject_' # gets specialised by explicit type casts in CoerceToPyTypeNode + tags = type_identifier(self), + elif self.cname.startswith('std::'): + cls = self.cname[5:] + prefix = '' + else: + cls = 'arcadia_' + self.cname + prefix = '' + cname = "__pyx_convert_%s%s_to_py_%s" % (prefix, cls, "____".join(tags)) + context.update({ + 'cname': cname, + 'maybe_unordered': self.maybe_unordered(), + 'type': self.cname, + }) + from .UtilityCode import CythonUtilityCode + env.use_utility_code(CythonUtilityCode.load( + cls.replace('unordered_', '') + ".to_py", "CppConvert.pyx", + context=context, compiler_directives=env.directives)) + self.to_py_function = cname + return True + + def is_template_type(self): + return self.templates is not None and self.template_type is None + + def get_fused_types(self, result=None, seen=None): + if result is None: + result = [] + seen = set() + if self.namespace: + self.namespace.get_fused_types(result, seen) + if self.templates: + for T in self.templates: + T.get_fused_types(result, seen) + return result + + def specialize_here(self, pos, template_values=None): + if not self.is_template_type(): + error(pos, "'%s' type is not a template" % self) + return error_type + if len(self.templates) - self.num_optional_templates <= len(template_values) < len(self.templates): + num_defaults = len(self.templates) - len(template_values) + partial_specialization = self.declaration_code('', template_params=template_values) + # Most of the time we don't need to declare anything typed to these + # default template arguments, but when we do there's no way in C++ + # to reference this directly. However, it is common convention to + # provide a typedef in the template class that resolves to each + # template type. For now, allow the user to specify this name as + # the template parameter. + # TODO: Allow typedefs in cpp classes and search for it in this + # classes scope as a concrete name we could use. + template_values = template_values + [ + TemplatePlaceholderType( + "%s::%s" % (partial_specialization, param.name), True) + for param in self.templates[-num_defaults:]] + if len(self.templates) != len(template_values): + error(pos, "%s templated type receives %d arguments, got %d" % + (self.name, len(self.templates), len(template_values))) + return error_type + has_object_template_param = False + for value in template_values: + if value.is_pyobject: + has_object_template_param = True + error(pos, + "Python object type '%s' cannot be used as a template argument" % value) + if has_object_template_param: + return error_type + return self.specialize(dict(zip(self.templates, template_values))) + + def specialize(self, values): + if not self.templates and not self.namespace: + return self + if self.templates is None: + self.templates = [] + key = tuple(values.items()) + if key in self.specializations: + return self.specializations[key] + template_values = [t.specialize(values) for t in self.templates] + specialized = self.specializations[key] = \ + CppClassType(self.name, None, self.cname, [], template_values, template_type=self) + # Need to do these *after* self.specializations[key] is set + # to avoid infinite recursion on circular references. + specialized.base_classes = [b.specialize(values) for b in self.base_classes] + if self.namespace is not None: + specialized.namespace = self.namespace.specialize(values) + specialized.scope = self.scope.specialize(values, specialized) + if self.cname == 'std::vector': + # vector<bool> is special cased in the C++ standard, and its + # accessors do not necessarily return references to the underlying + # elements (which may be bit-packed). + # http://www.cplusplus.com/reference/vector/vector-bool/ + # Here we pretend that the various methods return bool values + # (as the actual returned values are coercable to such, and + # we don't support call expressions as lvalues). + T = values.get(self.templates[0], None) + if T and not T.is_fused and T.empty_declaration_code() == 'bool': + for bit_ref_returner in ('at', 'back', 'front'): + if bit_ref_returner in specialized.scope.entries: + specialized.scope.entries[bit_ref_returner].type.return_type = T + return specialized + + def deduce_template_params(self, actual): + if actual.is_const: + actual = actual.const_base_type + if actual.is_reference: + actual = actual.ref_base_type + if self == actual: + return {} + elif actual.is_cpp_class: + self_template_type = self + while getattr(self_template_type, 'template_type', None): + self_template_type = self_template_type.template_type + def all_bases(cls): + yield cls + for parent in cls.base_classes: + for base in all_bases(parent): + yield base + for actual_base in all_bases(actual): + template_type = actual_base + while getattr(template_type, 'template_type', None): + template_type = template_type.template_type + if (self_template_type.empty_declaration_code() + == template_type.empty_declaration_code()): + return reduce( + merge_template_deductions, + [formal_param.deduce_template_params(actual_param) + for (formal_param, actual_param) + in zip(self.templates, actual_base.templates)], + {}) + else: + return {} + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0, + template_params = None): + if template_params is None: + template_params = self.templates + if self.templates: + template_strings = [param.declaration_code('', for_display, None, pyrex) + for param in template_params + if not is_optional_template_param(param) and not param.is_fused] + if for_display: + brackets = "[%s]" + else: + brackets = "<%s> " + templates = brackets % ",".join(template_strings) + else: + templates = "" + if pyrex or for_display: + base_code = "%s%s" % (self.name, templates) + else: + base_code = "%s%s" % (self.cname, templates) + if self.namespace is not None: + base_code = "%s::%s" % (self.namespace.empty_declaration_code(), base_code) + base_code = public_decl(base_code, dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + def is_subclass(self, other_type): + if self.same_as_resolved_type(other_type): + return 1 + for base_class in self.base_classes: + if base_class.is_subclass(other_type): + return 1 + return 0 + + def subclass_dist(self, super_type): + if self.same_as_resolved_type(super_type): + return 0 + elif not self.base_classes: + return float('inf') + else: + return 1 + min(b.subclass_dist(super_type) for b in self.base_classes) + + def same_as_resolved_type(self, other_type): + if other_type.is_cpp_class: + if self == other_type: + return 1 + # This messy logic is needed due to GH Issue #1852. + elif (self.cname == other_type.cname and + (self.template_type and other_type.template_type + or self.templates + or other_type.templates)): + if self.templates == other_type.templates: + return 1 + for t1, t2 in zip(self.templates, other_type.templates): + if is_optional_template_param(t1) and is_optional_template_param(t2): + break + if not t1.same_as_resolved_type(t2): + return 0 + return 1 + return 0 + + def assignable_from_resolved_type(self, other_type): + # TODO: handle operator=(...) here? + if other_type is error_type: + return True + elif other_type.is_cpp_class: + return other_type.is_subclass(self) + elif other_type.is_string and self.cname in cpp_string_conversions: + return True + + def attributes_known(self): + return self.scope is not None + + def find_cpp_operation_type(self, operator, operand_type=None): + operands = [self] + if operand_type is not None: + operands.append(operand_type) + # pos == None => no errors + operator_entry = self.scope.lookup_operator_for_types(None, operator, operands) + if not operator_entry: + return None + func_type = operator_entry.type + if func_type.is_ptr: + func_type = func_type.base_type + return func_type.return_type + + def get_constructor(self, pos): + constructor = self.scope.lookup('<init>') + if constructor is not None: + return constructor + + # Otherwise: automatically declare no-args default constructor. + # Make it "nogil" if the base classes allow it. + nogil = True + for base in self.base_classes: + base_constructor = base.scope.lookup('<init>') + if base_constructor and not base_constructor.type.nogil: + nogil = False + break + + func_type = CFuncType(self, [], exception_check='+', nogil=nogil) + return self.scope.declare_cfunction(u'<init>', func_type, pos) + + def check_nullary_constructor(self, pos, msg="stack allocated"): + constructor = self.scope.lookup(u'<init>') + if constructor is not None and best_match([], constructor.all_alternatives()) is None: + error(pos, "C++ class must have a nullary constructor to be %s" % msg) + + +class TemplatePlaceholderType(CType): + + def __init__(self, name, optional=False): + self.name = name + self.optional = optional + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if entity_code: + return self.name + " " + entity_code + else: + return self.name + + def specialize(self, values): + if self in values: + return values[self] + else: + return self + + def deduce_template_params(self, actual): + return {self: actual} + + def same_as_resolved_type(self, other_type): + if isinstance(other_type, TemplatePlaceholderType): + return self.name == other_type.name + else: + return 0 + + def __hash__(self): + return hash(self.name) + + def __cmp__(self, other): + if isinstance(other, TemplatePlaceholderType): + return cmp(self.name, other.name) + else: + return cmp(type(self), type(other)) + + def __eq__(self, other): + if isinstance(other, TemplatePlaceholderType): + return self.name == other.name + else: + return False + +def is_optional_template_param(type): + return isinstance(type, TemplatePlaceholderType) and type.optional + + +class CEnumType(CIntLike, CType): + # name string + # cname string or None + # typedef_flag boolean + # values [string], populated during declaration analysis + + is_enum = 1 + signed = 1 + rank = -1 # Ranks below any integer type + + def __init__(self, name, cname, typedef_flag, namespace=None): + self.name = name + self.cname = cname + self.values = [] + self.typedef_flag = typedef_flag + self.namespace = namespace + self.default_value = "(%s) 0" % self.empty_declaration_code() + + def __str__(self): + return self.name + + def __repr__(self): + return "<CEnumType %s %s%s>" % (self.name, self.cname, + ("", " typedef")[self.typedef_flag]) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + base_code = self.name + else: + if self.namespace: + base_code = "%s::%s" % ( + self.namespace.empty_declaration_code(), self.cname) + elif self.typedef_flag: + base_code = self.cname + else: + base_code = "enum %s" % self.cname + base_code = public_decl(base_code, dll_linkage) + return self.base_declaration_code(base_code, entity_code) + + def specialize(self, values): + if self.namespace: + namespace = self.namespace.specialize(values) + if namespace != self.namespace: + return CEnumType( + self.name, self.cname, self.typedef_flag, namespace) + return self + + def create_type_wrapper(self, env): + from .UtilityCode import CythonUtilityCode + env.use_utility_code(CythonUtilityCode.load( + "EnumType", "CpdefEnums.pyx", + context={"name": self.name, + "items": tuple(self.values)}, + outer_module_scope=env.global_scope())) + + +class CTupleType(CType): + # components [PyrexType] + + is_ctuple = True + + def __init__(self, cname, components): + self.cname = cname + self.components = components + self.size = len(components) + self.to_py_function = "%s_to_py_%s" % (Naming.convert_func_prefix, self.cname) + self.from_py_function = "%s_from_py_%s" % (Naming.convert_func_prefix, self.cname) + self.exception_check = True + self._convert_to_py_code = None + self._convert_from_py_code = None + + def __str__(self): + return "(%s)" % ", ".join(str(c) for c in self.components) + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + if pyrex or for_display: + return str(self) + else: + return self.base_declaration_code(self.cname, entity_code) + + def can_coerce_to_pyobject(self, env): + for component in self.components: + if not component.can_coerce_to_pyobject(env): + return False + return True + + def can_coerce_from_pyobject(self, env): + for component in self.components: + if not component.can_coerce_from_pyobject(env): + return False + return True + + def create_to_py_utility_code(self, env): + if self._convert_to_py_code is False: + return None # tri-state-ish + + if self._convert_to_py_code is None: + for component in self.components: + if not component.create_to_py_utility_code(env): + self.to_py_function = None + self._convert_to_py_code = False + return False + + context = dict( + struct_type_decl=self.empty_declaration_code(), + components=self.components, + funcname=self.to_py_function, + size=len(self.components) + ) + self._convert_to_py_code = TempitaUtilityCode.load( + "ToPyCTupleUtility", "TypeConversion.c", context=context) + + env.use_utility_code(self._convert_to_py_code) + return True + + def create_from_py_utility_code(self, env): + if self._convert_from_py_code is False: + return None # tri-state-ish + + if self._convert_from_py_code is None: + for component in self.components: + if not component.create_from_py_utility_code(env): + self.from_py_function = None + self._convert_from_py_code = False + return False + + context = dict( + struct_type_decl=self.empty_declaration_code(), + components=self.components, + funcname=self.from_py_function, + size=len(self.components) + ) + self._convert_from_py_code = TempitaUtilityCode.load( + "FromPyCTupleUtility", "TypeConversion.c", context=context) + + env.use_utility_code(self._convert_from_py_code) + return True + + def cast_code(self, expr_code): + return expr_code + + +def c_tuple_type(components): + components = tuple(components) + cname = Naming.ctuple_type_prefix + type_list_identifier(components) + tuple_type = CTupleType(cname, components) + return tuple_type + + +class UnspecifiedType(PyrexType): + # Used as a placeholder until the type can be determined. + + is_unspecified = 1 + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + return "<unspecified>" + + def same_as_resolved_type(self, other_type): + return False + + +class ErrorType(PyrexType): + # Used to prevent propagation of error messages. + + is_error = 1 + exception_value = "0" + exception_check = 0 + to_py_function = "dummy" + from_py_function = "dummy" + + def create_to_py_utility_code(self, env): + return True + + def create_from_py_utility_code(self, env): + return True + + def declaration_code(self, entity_code, + for_display = 0, dll_linkage = None, pyrex = 0): + return "<error>" + + def same_as_resolved_type(self, other_type): + return 1 + + def error_condition(self, result_code): + return "dummy" + + +rank_to_type_name = ( + "char", # 0 + "short", # 1 + "int", # 2 + "long", # 3 + "PY_LONG_LONG", # 4 + "float", # 5 + "double", # 6 + "long double", # 7 +) + +_rank_to_type_name = list(rank_to_type_name) +RANK_INT = _rank_to_type_name.index('int') +RANK_LONG = _rank_to_type_name.index('long') +RANK_FLOAT = _rank_to_type_name.index('float') +UNSIGNED = 0 +SIGNED = 2 + +error_type = ErrorType() +unspecified_type = UnspecifiedType() + +py_object_type = PyObjectType() + +c_void_type = CVoidType() + +c_uchar_type = CIntType(0, UNSIGNED) +c_ushort_type = CIntType(1, UNSIGNED) +c_uint_type = CIntType(2, UNSIGNED) +c_ulong_type = CIntType(3, UNSIGNED) +c_ulonglong_type = CIntType(4, UNSIGNED) + +c_char_type = CIntType(0) +c_short_type = CIntType(1) +c_int_type = CIntType(2) +c_long_type = CIntType(3) +c_longlong_type = CIntType(4) + +c_schar_type = CIntType(0, SIGNED) +c_sshort_type = CIntType(1, SIGNED) +c_sint_type = CIntType(2, SIGNED) +c_slong_type = CIntType(3, SIGNED) +c_slonglong_type = CIntType(4, SIGNED) + +c_float_type = CFloatType(5, math_h_modifier='f') +c_double_type = CFloatType(6) +c_longdouble_type = CFloatType(7, math_h_modifier='l') + +c_float_complex_type = CComplexType(c_float_type) +c_double_complex_type = CComplexType(c_double_type) +c_longdouble_complex_type = CComplexType(c_longdouble_type) + +c_anon_enum_type = CAnonEnumType(-1) +c_returncode_type = CReturnCodeType(RANK_INT) +c_bint_type = CBIntType(RANK_INT) +c_py_unicode_type = CPyUnicodeIntType(RANK_INT-0.5, UNSIGNED) +c_py_ucs4_type = CPyUCS4IntType(RANK_LONG-0.5, UNSIGNED) +c_py_hash_t_type = CPyHashTType(RANK_LONG+0.5, SIGNED) +c_py_ssize_t_type = CPySSizeTType(RANK_LONG+0.5, SIGNED) +c_ssize_t_type = CSSizeTType(RANK_LONG+0.5, SIGNED) +c_size_t_type = CSizeTType(RANK_LONG+0.5, UNSIGNED) +c_ptrdiff_t_type = CPtrdiffTType(RANK_LONG+0.75, SIGNED) + +c_null_ptr_type = CNullPtrType(c_void_type) +c_void_ptr_type = CPtrType(c_void_type) +c_void_ptr_ptr_type = CPtrType(c_void_ptr_type) +c_char_ptr_type = CPtrType(c_char_type) +c_const_char_ptr_type = CPtrType(CConstType(c_char_type)) +c_uchar_ptr_type = CPtrType(c_uchar_type) +c_const_uchar_ptr_type = CPtrType(CConstType(c_uchar_type)) +c_char_ptr_ptr_type = CPtrType(c_char_ptr_type) +c_int_ptr_type = CPtrType(c_int_type) +c_py_unicode_ptr_type = CPtrType(c_py_unicode_type) +c_const_py_unicode_ptr_type = CPtrType(CConstType(c_py_unicode_type)) +c_py_ssize_t_ptr_type = CPtrType(c_py_ssize_t_type) +c_ssize_t_ptr_type = CPtrType(c_ssize_t_type) +c_size_t_ptr_type = CPtrType(c_size_t_type) + +# GIL state +c_gilstate_type = CEnumType("PyGILState_STATE", "PyGILState_STATE", True) +c_threadstate_type = CStructOrUnionType("PyThreadState", "struct", None, 1, "PyThreadState") +c_threadstate_ptr_type = CPtrType(c_threadstate_type) + +# PEP-539 "Py_tss_t" type +c_pytss_t_type = CPyTSSTType() + +# the Py_buffer type is defined in Builtin.py +c_py_buffer_type = CStructOrUnionType("Py_buffer", "struct", None, 1, "Py_buffer") +c_py_buffer_ptr_type = CPtrType(c_py_buffer_type) + +# Not sure whether the unsigned versions and 'long long' should be in there +# long long requires C99 and might be slow, and would always get preferred +# when specialization happens through calling and not indexing +cy_integral_type = FusedType([c_short_type, c_int_type, c_long_type], + name="integral") +# Omitting long double as it might be slow +cy_floating_type = FusedType([c_float_type, c_double_type], name="floating") +cy_numeric_type = FusedType([c_short_type, + c_int_type, + c_long_type, + c_float_type, + c_double_type, + c_float_complex_type, + c_double_complex_type], name="numeric") + +# buffer-related structs +c_buf_diminfo_type = CStructOrUnionType("__Pyx_Buf_DimInfo", "struct", + None, 1, "__Pyx_Buf_DimInfo") +c_pyx_buffer_type = CStructOrUnionType("__Pyx_Buffer", "struct", None, 1, "__Pyx_Buffer") +c_pyx_buffer_ptr_type = CPtrType(c_pyx_buffer_type) +c_pyx_buffer_nd_type = CStructOrUnionType("__Pyx_LocalBuf_ND", "struct", + None, 1, "__Pyx_LocalBuf_ND") + +cython_memoryview_type = CStructOrUnionType("__pyx_memoryview_obj", "struct", + None, 0, "__pyx_memoryview_obj") + +memoryviewslice_type = CStructOrUnionType("memoryviewslice", "struct", + None, 1, "__Pyx_memviewslice") + +modifiers_and_name_to_type = { + #(signed, longness, name) : type + (0, 0, "char"): c_uchar_type, + (1, 0, "char"): c_char_type, + (2, 0, "char"): c_schar_type, + + (0, -1, "int"): c_ushort_type, + (0, 0, "int"): c_uint_type, + (0, 1, "int"): c_ulong_type, + (0, 2, "int"): c_ulonglong_type, + + (1, -1, "int"): c_short_type, + (1, 0, "int"): c_int_type, + (1, 1, "int"): c_long_type, + (1, 2, "int"): c_longlong_type, + + (2, -1, "int"): c_sshort_type, + (2, 0, "int"): c_sint_type, + (2, 1, "int"): c_slong_type, + (2, 2, "int"): c_slonglong_type, + + (1, 0, "float"): c_float_type, + (1, 0, "double"): c_double_type, + (1, 1, "double"): c_longdouble_type, + + (1, 0, "complex"): c_double_complex_type, # C: float, Python: double => Python wins + (1, 0, "floatcomplex"): c_float_complex_type, + (1, 0, "doublecomplex"): c_double_complex_type, + (1, 1, "doublecomplex"): c_longdouble_complex_type, + + # + (1, 0, "void"): c_void_type, + (1, 0, "Py_tss_t"): c_pytss_t_type, + + (1, 0, "bint"): c_bint_type, + (0, 0, "Py_UNICODE"): c_py_unicode_type, + (0, 0, "Py_UCS4"): c_py_ucs4_type, + (2, 0, "Py_hash_t"): c_py_hash_t_type, + (2, 0, "Py_ssize_t"): c_py_ssize_t_type, + (2, 0, "ssize_t") : c_ssize_t_type, + (0, 0, "size_t") : c_size_t_type, + (2, 0, "ptrdiff_t") : c_ptrdiff_t_type, + + (1, 0, "object"): py_object_type, +} + +def is_promotion(src_type, dst_type): + # It's hard to find a hard definition of promotion, but empirical + # evidence suggests that the below is all that's allowed. + if src_type.is_numeric: + if dst_type.same_as(c_int_type): + unsigned = (not src_type.signed) + return (src_type.is_enum or + (src_type.is_int and + unsigned + src_type.rank < dst_type.rank)) + elif dst_type.same_as(c_double_type): + return src_type.is_float and src_type.rank <= dst_type.rank + return False + +def best_match(arg_types, functions, pos=None, env=None, args=None): + """ + Given a list args of arguments and a list of functions, choose one + to call which seems to be the "best" fit for this list of arguments. + This function is used, e.g., when deciding which overloaded method + to dispatch for C++ classes. + + We first eliminate functions based on arity, and if only one + function has the correct arity, we return it. Otherwise, we weight + functions based on how much work must be done to convert the + arguments, with the following priorities: + * identical types or pointers to identical types + * promotions + * non-Python types + That is, we prefer functions where no arguments need converted, + and failing that, functions where only promotions are required, and + so on. + + If no function is deemed a good fit, or if two or more functions have + the same weight, we return None (as there is no best match). If pos + is not None, we also generate an error. + """ + # TODO: args should be a list of types, not a list of Nodes. + actual_nargs = len(arg_types) + + candidates = [] + errors = [] + for func in functions: + error_mesg = "" + func_type = func.type + if func_type.is_ptr: + func_type = func_type.base_type + # Check function type + if not func_type.is_cfunction: + if not func_type.is_error and pos is not None: + error_mesg = "Calling non-function type '%s'" % func_type + errors.append((func, error_mesg)) + continue + # Check no. of args + max_nargs = len(func_type.args) + min_nargs = max_nargs - func_type.optional_arg_count + if actual_nargs < min_nargs or \ + (not func_type.has_varargs and actual_nargs > max_nargs): + if max_nargs == min_nargs and not func_type.has_varargs: + expectation = max_nargs + elif actual_nargs < min_nargs: + expectation = "at least %s" % min_nargs + else: + expectation = "at most %s" % max_nargs + error_mesg = "Call with wrong number of arguments (expected %s, got %s)" \ + % (expectation, actual_nargs) + errors.append((func, error_mesg)) + continue + if func_type.templates: + deductions = reduce( + merge_template_deductions, + [pattern.type.deduce_template_params(actual) for (pattern, actual) in zip(func_type.args, arg_types)], + {}) + if deductions is None: + errors.append((func, "Unable to deduce type parameters for %s given (%s)" % (func_type, ', '.join(map(str, arg_types))))) + elif len(deductions) < len(func_type.templates): + errors.append((func, "Unable to deduce type parameter %s" % ( + ", ".join([param.name for param in set(func_type.templates) - set(deductions.keys())])))) + else: + type_list = [deductions[param] for param in func_type.templates] + from .Symtab import Entry + specialization = Entry( + name = func.name + "[%s]" % ",".join([str(t) for t in type_list]), + cname = func.cname + "<%s>" % ",".join([t.empty_declaration_code() for t in type_list]), + type = func_type.specialize(deductions), + pos = func.pos) + candidates.append((specialization, specialization.type)) + else: + candidates.append((func, func_type)) + + # Optimize the most common case of no overloading... + if len(candidates) == 1: + return candidates[0][0] + elif len(candidates) == 0: + if pos is not None: + func, errmsg = errors[0] + if len(errors) == 1 or [1 for func, e in errors if e == errmsg]: + error(pos, errmsg) + else: + error(pos, "no suitable method found") + return None + + possibilities = [] + bad_types = [] + needed_coercions = {} + + for index, (func, func_type) in enumerate(candidates): + score = [0,0,0,0,0,0,0] + for i in range(min(actual_nargs, len(func_type.args))): + src_type = arg_types[i] + dst_type = func_type.args[i].type + + assignable = dst_type.assignable_from(src_type) + + # Now take care of unprefixed string literals. So when you call a cdef + # function that takes a char *, the coercion will mean that the + # type will simply become bytes. We need to do this coercion + # manually for overloaded and fused functions + if not assignable: + c_src_type = None + if src_type.is_pyobject: + if src_type.is_builtin_type and src_type.name == 'str' and dst_type.resolve().is_string: + c_src_type = dst_type.resolve() + else: + c_src_type = src_type.default_coerced_ctype() + elif src_type.is_pythran_expr: + c_src_type = src_type.org_buffer + + if c_src_type is not None: + assignable = dst_type.assignable_from(c_src_type) + if assignable: + src_type = c_src_type + needed_coercions[func] = (i, dst_type) + + if assignable: + if src_type == dst_type or dst_type.same_as(src_type): + pass # score 0 + elif func_type.is_strict_signature: + break # exact match requested but not found + elif is_promotion(src_type, dst_type): + score[2] += 1 + elif ((src_type.is_int and dst_type.is_int) or + (src_type.is_float and dst_type.is_float)): + score[2] += abs(dst_type.rank + (not dst_type.signed) - + (src_type.rank + (not src_type.signed))) + 1 + elif dst_type.is_ptr and src_type.is_ptr: + if dst_type.base_type == c_void_type: + score[4] += 1 + elif src_type.base_type.is_cpp_class and src_type.base_type.is_subclass(dst_type.base_type): + score[6] += src_type.base_type.subclass_dist(dst_type.base_type) + else: + score[5] += 1 + elif not src_type.is_pyobject: + score[1] += 1 + else: + score[0] += 1 + else: + error_mesg = "Invalid conversion from '%s' to '%s'" % (src_type, dst_type) + bad_types.append((func, error_mesg)) + break + else: + possibilities.append((score, index, func)) # so we can sort it + + if possibilities: + possibilities.sort() + if len(possibilities) > 1: + score1 = possibilities[0][0] + score2 = possibilities[1][0] + if score1 == score2: + if pos is not None: + error(pos, "ambiguous overloaded method") + return None + + function = possibilities[0][-1] + + if function in needed_coercions and env: + arg_i, coerce_to_type = needed_coercions[function] + args[arg_i] = args[arg_i].coerce_to(coerce_to_type, env) + + return function + + if pos is not None: + if len(bad_types) == 1: + error(pos, bad_types[0][1]) + else: + error(pos, "no suitable method found") + + return None + +def merge_template_deductions(a, b): + if a is None or b is None: + return None + all = a + for param, value in b.items(): + if param in all: + if a[param] != b[param]: + return None + else: + all[param] = value + return all + + +def widest_numeric_type(type1, type2): + """Given two numeric types, return the narrowest type encompassing both of them. + """ + if type1.is_reference: + type1 = type1.ref_base_type + if type2.is_reference: + type2 = type2.ref_base_type + if type1.is_const: + type1 = type1.const_base_type + if type2.is_const: + type2 = type2.const_base_type + if type1 == type2: + widest_type = type1 + elif type1.is_complex or type2.is_complex: + def real_type(ntype): + if ntype.is_complex: + return ntype.real_type + return ntype + widest_type = CComplexType( + widest_numeric_type( + real_type(type1), + real_type(type2))) + elif type1.is_enum and type2.is_enum: + widest_type = c_int_type + elif type1.rank < type2.rank: + widest_type = type2 + elif type1.rank > type2.rank: + widest_type = type1 + elif type1.signed < type2.signed: + widest_type = type1 + elif type1.signed > type2.signed: + widest_type = type2 + elif type1.is_typedef > type2.is_typedef: + widest_type = type1 + else: + widest_type = type2 + return widest_type + + +def numeric_type_fits(small_type, large_type): + return widest_numeric_type(small_type, large_type) == large_type + + +def independent_spanning_type(type1, type2): + # Return a type assignable independently from both type1 and + # type2, but do not require any interoperability between the two. + # For example, in "True * 2", it is safe to assume an integer + # result type (so spanning_type() will do the right thing), + # whereas "x = True or 2" must evaluate to a type that can hold + # both a boolean value and an integer, so this function works + # better. + if type1.is_reference ^ type2.is_reference: + if type1.is_reference: + type1 = type1.ref_base_type + else: + type2 = type2.ref_base_type + if type1 == type2: + return type1 + elif (type1 is c_bint_type or type2 is c_bint_type) and (type1.is_numeric and type2.is_numeric): + # special case: if one of the results is a bint and the other + # is another C integer, we must prevent returning a numeric + # type so that we do not lose the ability to coerce to a + # Python bool if we have to. + return py_object_type + span_type = _spanning_type(type1, type2) + if span_type is None: + return error_type + return span_type + +def spanning_type(type1, type2): + # Return a type assignable from both type1 and type2, or + # py_object_type if no better type is found. Assumes that the + # code that calls this will try a coercion afterwards, which will + # fail if the types cannot actually coerce to a py_object_type. + if type1 == type2: + return type1 + elif type1 is py_object_type or type2 is py_object_type: + return py_object_type + elif type1 is c_py_unicode_type or type2 is c_py_unicode_type: + # Py_UNICODE behaves more like a string than an int + return py_object_type + span_type = _spanning_type(type1, type2) + if span_type is None: + return py_object_type + return span_type + +def _spanning_type(type1, type2): + if type1.is_numeric and type2.is_numeric: + return widest_numeric_type(type1, type2) + elif type1.is_builtin_type and type1.name == 'float' and type2.is_numeric: + return widest_numeric_type(c_double_type, type2) + elif type2.is_builtin_type and type2.name == 'float' and type1.is_numeric: + return widest_numeric_type(type1, c_double_type) + elif type1.is_extension_type and type2.is_extension_type: + return widest_extension_type(type1, type2) + elif type1.is_pyobject or type2.is_pyobject: + return py_object_type + elif type1.assignable_from(type2): + if type1.is_extension_type and type1.typeobj_is_imported(): + # external types are unsafe, so we use PyObject instead + return py_object_type + return type1 + elif type2.assignable_from(type1): + if type2.is_extension_type and type2.typeobj_is_imported(): + # external types are unsafe, so we use PyObject instead + return py_object_type + return type2 + elif type1.is_ptr and type2.is_ptr: + if type1.base_type.is_cpp_class and type2.base_type.is_cpp_class: + common_base = widest_cpp_type(type1.base_type, type2.base_type) + if common_base: + return CPtrType(common_base) + # incompatible pointers, void* will do as a result + return c_void_ptr_type + else: + return None + +def widest_extension_type(type1, type2): + if type1.typeobj_is_imported() or type2.typeobj_is_imported(): + return py_object_type + while True: + if type1.subtype_of(type2): + return type2 + elif type2.subtype_of(type1): + return type1 + type1, type2 = type1.base_type, type2.base_type + if type1 is None or type2 is None: + return py_object_type + +def widest_cpp_type(type1, type2): + @cached_function + def bases(type): + all = set() + for base in type.base_classes: + all.add(base) + all.update(bases(base)) + return all + common_bases = bases(type1).intersection(bases(type2)) + common_bases_bases = reduce(set.union, [bases(b) for b in common_bases], set()) + candidates = [b for b in common_bases if b not in common_bases_bases] + if len(candidates) == 1: + return candidates[0] + else: + # Fall back to void* for now. + return None + + +def simple_c_type(signed, longness, name): + # Find type descriptor for simple type given name and modifiers. + # Returns None if arguments don't make sense. + return modifiers_and_name_to_type.get((signed, longness, name)) + +def parse_basic_type(name): + base = None + if name.startswith('p_'): + base = parse_basic_type(name[2:]) + elif name.startswith('p'): + base = parse_basic_type(name[1:]) + elif name.endswith('*'): + base = parse_basic_type(name[:-1]) + if base: + return CPtrType(base) + # + basic_type = simple_c_type(1, 0, name) + if basic_type: + return basic_type + # + signed = 1 + longness = 0 + if name == 'Py_UNICODE': + signed = 0 + elif name == 'Py_UCS4': + signed = 0 + elif name == 'Py_hash_t': + signed = 2 + elif name == 'Py_ssize_t': + signed = 2 + elif name == 'ssize_t': + signed = 2 + elif name == 'size_t': + signed = 0 + else: + if name.startswith('u'): + name = name[1:] + signed = 0 + elif (name.startswith('s') and + not name.startswith('short')): + name = name[1:] + signed = 2 + longness = 0 + while name.startswith('short'): + name = name.replace('short', '', 1).strip() + longness -= 1 + while name.startswith('long'): + name = name.replace('long', '', 1).strip() + longness += 1 + if longness != 0 and not name: + name = 'int' + return simple_c_type(signed, longness, name) + +def c_array_type(base_type, size): + # Construct a C array type. + if base_type is error_type: + return error_type + else: + return CArrayType(base_type, size) + +def c_ptr_type(base_type): + # Construct a C pointer type. + if base_type is error_type: + return error_type + elif base_type.is_reference: + return CPtrType(base_type.ref_base_type) + else: + return CPtrType(base_type) + +def c_ref_type(base_type): + # Construct a C reference type + if base_type is error_type: + return error_type + else: + return CReferenceType(base_type) + +def c_const_type(base_type): + # Construct a C const type. + if base_type is error_type: + return error_type + else: + return CConstType(base_type) + +def same_type(type1, type2): + return type1.same_as(type2) + +def assignable_from(type1, type2): + return type1.assignable_from(type2) + +def typecast(to_type, from_type, expr_code): + # Return expr_code cast to a C type which can be + # assigned to to_type, assuming its existing C type + # is from_type. + if (to_type is from_type or + (not to_type.is_pyobject and assignable_from(to_type, from_type))): + return expr_code + elif (to_type is py_object_type and from_type and + from_type.is_builtin_type and from_type.name != 'type'): + # no cast needed, builtins are PyObject* already + return expr_code + else: + #print "typecast: to", to_type, "from", from_type ### + return to_type.cast_code(expr_code) + +def type_list_identifier(types): + return cap_length('__and_'.join(type_identifier(type) for type in types)) + +_type_identifier_cache = {} +def type_identifier(type): + decl = type.empty_declaration_code() + safe = _type_identifier_cache.get(decl) + if safe is None: + safe = decl + safe = re.sub(' +', ' ', safe) + safe = re.sub(' ([^a-zA-Z0-9_])', r'\1', safe) + safe = re.sub('([^a-zA-Z0-9_]) ', r'\1', safe) + safe = (safe.replace('__', '__dunder') + .replace('const ', '__const_') + .replace(' ', '__space_') + .replace('*', '__ptr') + .replace('&', '__ref') + .replace('[', '__lArr') + .replace(']', '__rArr') + .replace('<', '__lAng') + .replace('>', '__rAng') + .replace('(', '__lParen') + .replace(')', '__rParen') + .replace(',', '__comma_') + .replace('::', '__in_')) + safe = cap_length(re.sub('[^a-zA-Z0-9_]', lambda x: '__%X' % ord(x.group(0)), safe)) + _type_identifier_cache[decl] = safe + return safe + +def cap_length(s, max_prefix=63, max_len=1024): + if len(s) <= max_prefix: + return s + hash_prefix = hashlib.sha256(s.encode('ascii')).hexdigest()[:6] + return '%s__%s__etc' % (hash_prefix, s[:max_len-17]) diff --git a/contrib/tools/cython/Cython/Compiler/Pythran.py b/contrib/tools/cython/Cython/Compiler/Pythran.py new file mode 100644 index 00000000000..c02704a918c --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Pythran.py @@ -0,0 +1,227 @@ +# cython: language_level=3 + +from __future__ import absolute_import + +from .PyrexTypes import CType, CTypedefType, CStructOrUnionType + +import cython + +try: + import pythran + pythran_is_pre_0_9 = tuple(map(int, pythran.__version__.split('.')[0:2])) < (0, 9) + pythran_is_pre_0_9_6 = tuple(map(int, pythran.__version__.split('.')[0:3])) < (0, 9, 6) +except ImportError: + pythran = None + pythran_is_pre_0_9 = True + pythran_is_pre_0_9_6 = True + +if pythran_is_pre_0_9_6: + pythran_builtins = '__builtin__' +else: + pythran_builtins = 'builtins' + + +# Pythran/Numpy specific operations + +def has_np_pythran(env): + if env is None: + return False + directives = getattr(env, 'directives', None) + return (directives and directives.get('np_pythran', False)) + +@cython.ccall +def is_pythran_supported_dtype(type_): + if isinstance(type_, CTypedefType): + return is_pythran_supported_type(type_.typedef_base_type) + return type_.is_numeric + + +def pythran_type(Ty, ptype="ndarray"): + if Ty.is_buffer: + ndim,dtype = Ty.ndim, Ty.dtype + if isinstance(dtype, CStructOrUnionType): + ctype = dtype.cname + elif isinstance(dtype, CType): + ctype = dtype.sign_and_name() + elif isinstance(dtype, CTypedefType): + ctype = dtype.typedef_cname + else: + raise ValueError("unsupported type %s!" % dtype) + if pythran_is_pre_0_9: + return "pythonic::types::%s<%s,%d>" % (ptype,ctype, ndim) + else: + return "pythonic::types::%s<%s,pythonic::types::pshape<%s>>" % (ptype,ctype, ",".join(("long",)*ndim)) + if Ty.is_pythran_expr: + return Ty.pythran_type + #if Ty.is_none: + # return "decltype(pythonic::builtins::None)" + if Ty.is_numeric: + return Ty.sign_and_name() + raise ValueError("unsupported pythran type %s (%s)" % (Ty, type(Ty))) + + +@cython.cfunc +def type_remove_ref(ty): + return "typename std::remove_reference<%s>::type" % ty + + +def pythran_binop_type(op, tA, tB): + if op == '**': + return 'decltype(pythonic::numpy::functor::power{}(std::declval<%s>(), std::declval<%s>()))' % ( + pythran_type(tA), pythran_type(tB)) + else: + return "decltype(std::declval<%s>() %s std::declval<%s>())" % ( + pythran_type(tA), op, pythran_type(tB)) + + +def pythran_unaryop_type(op, type_): + return "decltype(%sstd::declval<%s>())" % ( + op, pythran_type(type_)) + + +@cython.cfunc +def _index_access(index_code, indices): + indexing = ",".join([index_code(idx) for idx in indices]) + return ('[%s]' if len(indices) == 1 else '(%s)') % indexing + + +def _index_type_code(index_with_type): + idx, index_type = index_with_type + if idx.is_slice: + n = 2 + int(not idx.step.is_none) + return "pythonic::%s::functor::slice{}(%s)" % ( + pythran_builtins, + ",".join(["0"]*n)) + elif index_type.is_int: + return "std::declval<%s>()" % index_type.sign_and_name() + elif index_type.is_pythran_expr: + return "std::declval<%s>()" % index_type.pythran_type + raise ValueError("unsupported indexing type %s!" % index_type) + + +def _index_code(idx): + if idx.is_slice: + values = idx.start, idx.stop, idx.step + if idx.step.is_none: + func = "contiguous_slice" + values = values[:2] + else: + func = "slice" + return "pythonic::types::%s(%s)" % ( + func, ",".join((v.pythran_result() for v in values))) + elif idx.type.is_int: + return to_pythran(idx) + elif idx.type.is_pythran_expr: + return idx.pythran_result() + raise ValueError("unsupported indexing type %s" % idx.type) + + +def pythran_indexing_type(type_, indices): + return type_remove_ref("decltype(std::declval<%s>()%s)" % ( + pythran_type(type_), + _index_access(_index_type_code, indices), + )) + + +def pythran_indexing_code(indices): + return _index_access(_index_code, indices) + +def np_func_to_list(func): + if not func.is_numpy_attribute: + return [] + return np_func_to_list(func.obj) + [func.attribute] + +if pythran is None: + def pythran_is_numpy_func_supported(name): + return False +else: + def pythran_is_numpy_func_supported(func): + CurF = pythran.tables.MODULES['numpy'] + FL = np_func_to_list(func) + for F in FL: + CurF = CurF.get(F, None) + if CurF is None: + return False + return True + +def pythran_functor(func): + func = np_func_to_list(func) + submodules = "::".join(func[:-1] + ["functor"]) + return "pythonic::numpy::%s::%s" % (submodules, func[-1]) + +def pythran_func_type(func, args): + args = ",".join(("std::declval<%s>()" % pythran_type(a.type) for a in args)) + return "decltype(%s{}(%s))" % (pythran_functor(func), args) + + +@cython.ccall +def to_pythran(op, ptype=None): + op_type = op.type + if op_type.is_int: + # Make sure that integer literals always have exactly the type that the templates expect. + return op_type.cast_code(op.result()) + if is_type(op_type, ["is_pythran_expr", "is_numeric", "is_float", "is_complex"]): + return op.result() + if op.is_none: + return "pythonic::%s::None" % pythran_builtins + if ptype is None: + ptype = pythran_type(op_type) + + assert op.type.is_pyobject + return "from_python<%s>(%s)" % (ptype, op.py_result()) + + +@cython.cfunc +def is_type(type_, types): + for attr in types: + if getattr(type_, attr, False): + return True + return False + + +def is_pythran_supported_node_or_none(node): + return node.is_none or is_pythran_supported_type(node.type) + + +@cython.ccall +def is_pythran_supported_type(type_): + pythran_supported = ( + "is_pythran_expr", "is_int", "is_numeric", "is_float", "is_none", "is_complex") + return is_type(type_, pythran_supported) or is_pythran_expr(type_) + + +def is_pythran_supported_operation_type(type_): + pythran_supported = ( + "is_pythran_expr", "is_int", "is_numeric", "is_float", "is_complex") + return is_type(type_,pythran_supported) or is_pythran_expr(type_) + + +@cython.ccall +def is_pythran_expr(type_): + return type_.is_pythran_expr + + +def is_pythran_buffer(type_): + return (type_.is_numpy_buffer and is_pythran_supported_dtype(type_.dtype) and + type_.mode in ("c", "strided") and not type_.cast) + +def pythran_get_func_include_file(func): + func = np_func_to_list(func) + return "pythonic/numpy/%s.hpp" % "/".join(func) + +def include_pythran_generic(env): + # Generic files + env.add_include_file("pythonic/core.hpp") + env.add_include_file("pythonic/python/core.hpp") + env.add_include_file("pythonic/types/bool.hpp") + env.add_include_file("pythonic/types/ndarray.hpp") + env.add_include_file("pythonic/numpy/power.hpp") + env.add_include_file("pythonic/%s/slice.hpp" % pythran_builtins) + env.add_include_file("<new>") # for placement new + + for i in (8, 16, 32, 64): + env.add_include_file("pythonic/types/uint%d.hpp" % i) + env.add_include_file("pythonic/types/int%d.hpp" % i) + for t in ("float", "float32", "float64", "set", "slice", "tuple", "int", + "complex", "complex64", "complex128"): + env.add_include_file("pythonic/types/%s.hpp" % t) diff --git a/contrib/tools/cython/Cython/Compiler/Scanning.pxd b/contrib/tools/cython/Cython/Compiler/Scanning.pxd new file mode 100644 index 00000000000..59593f88a29 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Scanning.pxd @@ -0,0 +1,67 @@ +from __future__ import absolute_import + +import cython + +from ..Plex.Scanners cimport Scanner + +cdef unicode any_string_prefix, IDENT + +cdef get_lexicon() +cdef initial_compile_time_env() + +cdef class Method: + cdef object name + cdef dict kwargs + cdef readonly object __name__ # for tracing the scanner + +## methods commented with '##' out are used by Parsing.py when compiled. + +@cython.final +cdef class CompileTimeScope: + cdef public dict entries + cdef public CompileTimeScope outer + ##cdef declare(self, name, value) + ##cdef lookup_here(self, name) + ##cpdef lookup(self, name) + +@cython.final +cdef class PyrexScanner(Scanner): + cdef public context + cdef public list included_files + cdef public CompileTimeScope compile_time_env + cdef public bint compile_time_eval + cdef public bint compile_time_expr + cdef public bint parse_comments + cdef public bint in_python_file + cdef public source_encoding + cdef set keywords + cdef public list indentation_stack + cdef public indentation_char + cdef public int bracket_nesting_level + cdef readonly bint async_enabled + cdef public sy + cdef public systring + + cdef long current_level(self) + #cpdef commentline(self, text) + #cpdef open_bracket_action(self, text) + #cpdef close_bracket_action(self, text) + #cpdef newline_action(self, text) + #cpdef begin_string_action(self, text) + #cpdef end_string_action(self, text) + #cpdef unclosed_string_action(self, text) + @cython.locals(current_level=cython.long, new_level=cython.long) + cpdef indentation_action(self, text) + #cpdef eof_action(self, text) + ##cdef next(self) + ##cdef peek(self) + #cpdef put_back(self, sy, systring) + #cdef unread(self, token, value) + ##cdef bint expect(self, what, message = *) except -2 + ##cdef expect_keyword(self, what, message = *) + ##cdef expected(self, what, message = *) + ##cdef expect_indent(self) + ##cdef expect_dedent(self) + ##cdef expect_newline(self, message=*, bint ignore_semicolon=*) + ##cdef int enter_async(self) except -1 + ##cdef int exit_async(self) except -1 diff --git a/contrib/tools/cython/Cython/Compiler/Scanning.py b/contrib/tools/cython/Cython/Compiler/Scanning.py new file mode 100644 index 00000000000..c721bba69b0 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Scanning.py @@ -0,0 +1,553 @@ +# cython: infer_types=True, language_level=3, py2_import=True, auto_pickle=False +# +# Cython Scanner +# + +from __future__ import absolute_import + +import cython +cython.declare(make_lexicon=object, lexicon=object, + print_function=object, error=object, warning=object, + os=object, platform=object) + +import os +import platform + +from .. import Utils +from ..Plex.Scanners import Scanner +from ..Plex.Errors import UnrecognizedInput +from .Errors import error, warning +from .Lexicon import any_string_prefix, make_lexicon, IDENT +from .Future import print_function + +debug_scanner = 0 +trace_scanner = 0 +scanner_debug_flags = 0 +scanner_dump_file = None + +lexicon = None + + +def get_lexicon(): + global lexicon + if not lexicon: + lexicon = make_lexicon() + return lexicon + + +#------------------------------------------------------------------ + +py_reserved_words = [ + "global", "nonlocal", "def", "class", "print", "del", "pass", "break", + "continue", "return", "raise", "import", "exec", "try", + "except", "finally", "while", "if", "elif", "else", "for", + "in", "assert", "and", "or", "not", "is", "lambda", + "from", "yield", "with", +] + +pyx_reserved_words = py_reserved_words + [ + "include", "ctypedef", "cdef", "cpdef", + "cimport", "DEF", "IF", "ELIF", "ELSE" +] + + +class Method(object): + + def __init__(self, name, **kwargs): + self.name = name + self.kwargs = kwargs or None + self.__name__ = name # for Plex tracing + + def __call__(self, stream, text): + method = getattr(stream, self.name) + # self.kwargs is almost always unused => avoid call overhead + return method(text, **self.kwargs) if self.kwargs is not None else method(text) + + def __copy__(self): + return self # immutable, no need to copy + + def __deepcopy__(self, memo): + return self # immutable, no need to copy + + +#------------------------------------------------------------------ + +class CompileTimeScope(object): + + def __init__(self, outer=None): + self.entries = {} + self.outer = outer + + def declare(self, name, value): + self.entries[name] = value + + def update(self, other): + self.entries.update(other) + + def lookup_here(self, name): + return self.entries[name] + + def __contains__(self, name): + return name in self.entries + + def lookup(self, name): + try: + return self.lookup_here(name) + except KeyError: + outer = self.outer + if outer: + return outer.lookup(name) + else: + raise + + +def initial_compile_time_env(): + benv = CompileTimeScope() + names = ('UNAME_SYSNAME', 'UNAME_NODENAME', 'UNAME_RELEASE', 'UNAME_VERSION', 'UNAME_MACHINE') + for name, value in zip(names, platform.uname()): + benv.declare(name, value) + try: + import __builtin__ as builtins + except ImportError: + import builtins + + names = ( + 'False', 'True', + 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', + 'chr', 'cmp', 'complex', 'dict', 'divmod', 'enumerate', 'filter', + 'float', 'format', 'frozenset', 'hash', 'hex', 'int', 'len', + 'list', 'map', 'max', 'min', 'oct', 'ord', 'pow', 'range', + 'repr', 'reversed', 'round', 'set', 'slice', 'sorted', 'str', + 'sum', 'tuple', 'zip', + ### defined below in a platform independent way + # 'long', 'unicode', 'reduce', 'xrange' + ) + + for name in names: + try: + benv.declare(name, getattr(builtins, name)) + except AttributeError: + # ignore, likely Py3 + pass + + # Py2/3 adaptations + from functools import reduce + benv.declare('reduce', reduce) + benv.declare('unicode', getattr(builtins, 'unicode', getattr(builtins, 'str'))) + benv.declare('long', getattr(builtins, 'long', getattr(builtins, 'int'))) + benv.declare('xrange', getattr(builtins, 'xrange', getattr(builtins, 'range'))) + + denv = CompileTimeScope(benv) + return denv + + +#------------------------------------------------------------------ + +class SourceDescriptor(object): + """ + A SourceDescriptor should be considered immutable. + """ + filename = None + + _file_type = 'pyx' + + _escaped_description = None + _cmp_name = '' + def __str__(self): + assert False # To catch all places where a descriptor is used directly as a filename + + def set_file_type_from_name(self, filename): + name, ext = os.path.splitext(filename) + self._file_type = ext in ('.pyx', '.pxd', '.py') and ext[1:] or 'pyx' + + def is_cython_file(self): + return self._file_type in ('pyx', 'pxd') + + def is_python_file(self): + return self._file_type == 'py' + + def get_escaped_description(self): + if self._escaped_description is None: + esc_desc = \ + self.get_description().encode('ASCII', 'replace').decode("ASCII") + # Use forward slashes on Windows since these paths + # will be used in the #line directives in the C/C++ files. + self._escaped_description = esc_desc.replace('\\', '/') + return self._escaped_description + + def __gt__(self, other): + # this is only used to provide some sort of order + try: + return self._cmp_name > other._cmp_name + except AttributeError: + return False + + def __lt__(self, other): + # this is only used to provide some sort of order + try: + return self._cmp_name < other._cmp_name + except AttributeError: + return False + + def __le__(self, other): + # this is only used to provide some sort of order + try: + return self._cmp_name <= other._cmp_name + except AttributeError: + return False + + def __copy__(self): + return self # immutable, no need to copy + + def __deepcopy__(self, memo): + return self # immutable, no need to copy + + +class FileSourceDescriptor(SourceDescriptor): + """ + Represents a code source. A code source is a more generic abstraction + for a "filename" (as sometimes the code doesn't come from a file). + Instances of code sources are passed to Scanner.__init__ as the + optional name argument and will be passed back when asking for + the position()-tuple. + """ + def __init__(self, filename, path_description=None): + filename = Utils.decode_filename(filename) + self.path_description = path_description or filename + self.filename = filename + # Prefer relative paths to current directory (which is most likely the project root) over absolute paths. + workdir = os.path.abspath('.') + os.sep + self.file_path = filename[len(workdir):] if filename.startswith(workdir) else filename + self.set_file_type_from_name(filename) + self._cmp_name = filename + self._lines = {} + + def get_lines(self, encoding=None, error_handling=None): + # we cache the lines only the second time this is called, in + # order to save memory when they are only used once + key = (encoding, error_handling) + try: + lines = self._lines[key] + if lines is not None: + return lines + except KeyError: + pass + + with Utils.open_source_file(self.filename, encoding=encoding, error_handling=error_handling) as f: + lines = list(f) + + if key in self._lines: + self._lines[key] = lines + else: + # do not cache the first access, but remember that we + # already read it once + self._lines[key] = None + return lines + + def get_description(self): + # Dump path_description, it's already arcadia root relative (required for proper file matching in coverage) + return self.path_description + try: + return os.path.relpath(self.path_description) + except ValueError: + # path not under current directory => use complete file path + return self.path_description + + def get_error_description(self): + path = self.filename + cwd = Utils.decode_filename(os.getcwd() + os.path.sep) + if path.startswith(cwd): + return path[len(cwd):] + return path + + def get_filenametable_entry(self): + return self.file_path + + def __eq__(self, other): + return isinstance(other, FileSourceDescriptor) and self.filename == other.filename + + def __hash__(self): + return hash(self.filename) + + def __repr__(self): + return "<FileSourceDescriptor:%s>" % self.filename + + +class StringSourceDescriptor(SourceDescriptor): + """ + Instances of this class can be used instead of a filenames if the + code originates from a string object. + """ + def __init__(self, name, code): + self.name = name + #self.set_file_type_from_name(name) + self.codelines = [x + "\n" for x in code.split("\n")] + self._cmp_name = name + + def get_lines(self, encoding=None, error_handling=None): + if not encoding: + return self.codelines + else: + return [line.encode(encoding, error_handling).decode(encoding) + for line in self.codelines] + + def get_description(self): + return self.name + + get_error_description = get_description + + def get_filenametable_entry(self): + return "stringsource" + + def __hash__(self): + return id(self) + # Do not hash on the name, an identical string source should be the + # same object (name is often defaulted in other places) + # return hash(self.name) + + def __eq__(self, other): + return isinstance(other, StringSourceDescriptor) and self.name == other.name + + def __repr__(self): + return "<StringSourceDescriptor:%s>" % self.name + + +#------------------------------------------------------------------ + +class PyrexScanner(Scanner): + # context Context Compilation context + # included_files [string] Files included with 'include' statement + # compile_time_env dict Environment for conditional compilation + # compile_time_eval boolean In a true conditional compilation context + # compile_time_expr boolean In a compile-time expression context + + def __init__(self, file, filename, parent_scanner=None, + scope=None, context=None, source_encoding=None, parse_comments=True, initial_pos=None): + Scanner.__init__(self, get_lexicon(), file, filename, initial_pos) + + if filename.is_python_file(): + self.in_python_file = True + self.keywords = set(py_reserved_words) + else: + self.in_python_file = False + self.keywords = set(pyx_reserved_words) + + self.async_enabled = 0 + + if parent_scanner: + self.context = parent_scanner.context + self.included_files = parent_scanner.included_files + self.compile_time_env = parent_scanner.compile_time_env + self.compile_time_eval = parent_scanner.compile_time_eval + self.compile_time_expr = parent_scanner.compile_time_expr + + if parent_scanner.async_enabled: + self.enter_async() + else: + self.context = context + self.included_files = scope.included_files + self.compile_time_env = initial_compile_time_env() + self.compile_time_eval = 1 + self.compile_time_expr = 0 + if getattr(context.options, 'compile_time_env', None): + self.compile_time_env.update(context.options.compile_time_env) + self.parse_comments = parse_comments + self.source_encoding = source_encoding + self.trace = trace_scanner + self.indentation_stack = [0] + self.indentation_char = None + self.bracket_nesting_level = 0 + + self.begin('INDENT') + self.sy = '' + self.next() + + def commentline(self, text): + if self.parse_comments: + self.produce('commentline', text) + + def strip_underscores(self, text, symbol): + self.produce(symbol, text.replace('_', '')) + + def current_level(self): + return self.indentation_stack[-1] + + def open_bracket_action(self, text): + self.bracket_nesting_level += 1 + return text + + def close_bracket_action(self, text): + self.bracket_nesting_level -= 1 + return text + + def newline_action(self, text): + if self.bracket_nesting_level == 0: + self.begin('INDENT') + self.produce('NEWLINE', '') + + string_states = { + "'": 'SQ_STRING', + '"': 'DQ_STRING', + "'''": 'TSQ_STRING', + '"""': 'TDQ_STRING' + } + + def begin_string_action(self, text): + while text[:1] in any_string_prefix: + text = text[1:] + self.begin(self.string_states[text]) + self.produce('BEGIN_STRING') + + def end_string_action(self, text): + self.begin('') + self.produce('END_STRING') + + def unclosed_string_action(self, text): + self.end_string_action(text) + self.error("Unclosed string literal") + + def indentation_action(self, text): + self.begin('') + # Indentation within brackets should be ignored. + #if self.bracket_nesting_level > 0: + # return + # Check that tabs and spaces are being used consistently. + if text: + c = text[0] + #print "Scanner.indentation_action: indent with", repr(c) ### + if self.indentation_char is None: + self.indentation_char = c + #print "Scanner.indentation_action: setting indent_char to", repr(c) + else: + if self.indentation_char != c: + self.error("Mixed use of tabs and spaces") + if text.replace(c, "") != "": + self.error("Mixed use of tabs and spaces") + # Figure out how many indents/dedents to do + current_level = self.current_level() + new_level = len(text) + #print "Changing indent level from", current_level, "to", new_level ### + if new_level == current_level: + return + elif new_level > current_level: + #print "...pushing level", new_level ### + self.indentation_stack.append(new_level) + self.produce('INDENT', '') + else: + while new_level < self.current_level(): + #print "...popping level", self.indentation_stack[-1] ### + self.indentation_stack.pop() + self.produce('DEDENT', '') + #print "...current level now", self.current_level() ### + if new_level != self.current_level(): + self.error("Inconsistent indentation") + + def eof_action(self, text): + while len(self.indentation_stack) > 1: + self.produce('DEDENT', '') + self.indentation_stack.pop() + self.produce('EOF', '') + + def next(self): + try: + sy, systring = self.read() + except UnrecognizedInput: + self.error("Unrecognized character") + return # just a marker, error() always raises + if sy == IDENT: + if systring in self.keywords: + if systring == u'print' and print_function in self.context.future_directives: + self.keywords.discard('print') + elif systring == u'exec' and self.context.language_level >= 3: + self.keywords.discard('exec') + else: + sy = systring + systring = self.context.intern_ustring(systring) + self.sy = sy + self.systring = systring + if False: # debug_scanner: + _, line, col = self.position() + if not self.systring or self.sy == self.systring: + t = self.sy + else: + t = "%s %s" % (self.sy, self.systring) + print("--- %3d %2d %s" % (line, col, t)) + + def peek(self): + saved = self.sy, self.systring + self.next() + next = self.sy, self.systring + self.unread(*next) + self.sy, self.systring = saved + return next + + def put_back(self, sy, systring): + self.unread(self.sy, self.systring) + self.sy = sy + self.systring = systring + + def unread(self, token, value): + # This method should be added to Plex + self.queue.insert(0, (token, value)) + + def error(self, message, pos=None, fatal=True): + if pos is None: + pos = self.position() + if self.sy == 'INDENT': + error(pos, "Possible inconsistent indentation") + err = error(pos, message) + if fatal: raise err + + def expect(self, what, message=None): + if self.sy == what: + self.next() + else: + self.expected(what, message) + + def expect_keyword(self, what, message=None): + if self.sy == IDENT and self.systring == what: + self.next() + else: + self.expected(what, message) + + def expected(self, what, message=None): + if message: + self.error(message) + else: + if self.sy == IDENT: + found = self.systring + else: + found = self.sy + self.error("Expected '%s', found '%s'" % (what, found)) + + def expect_indent(self): + self.expect('INDENT', "Expected an increase in indentation level") + + def expect_dedent(self): + self.expect('DEDENT', "Expected a decrease in indentation level") + + def expect_newline(self, message="Expected a newline", ignore_semicolon=False): + # Expect either a newline or end of file + useless_trailing_semicolon = None + if ignore_semicolon and self.sy == ';': + useless_trailing_semicolon = self.position() + self.next() + if self.sy != 'EOF': + self.expect('NEWLINE', message) + if useless_trailing_semicolon is not None: + warning(useless_trailing_semicolon, "useless trailing semicolon") + + def enter_async(self): + self.async_enabled += 1 + if self.async_enabled == 1: + self.keywords.add('async') + self.keywords.add('await') + + def exit_async(self): + assert self.async_enabled > 0 + self.async_enabled -= 1 + if not self.async_enabled: + self.keywords.discard('await') + self.keywords.discard('async') + if self.sy in ('async', 'await'): + self.sy, self.systring = IDENT, self.context.intern_ustring(self.sy) diff --git a/contrib/tools/cython/Cython/Compiler/StringEncoding.py b/contrib/tools/cython/Cython/Compiler/StringEncoding.py new file mode 100644 index 00000000000..c37e8aab799 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/StringEncoding.py @@ -0,0 +1,363 @@ +# +# Cython -- encoding related tools +# + +from __future__ import absolute_import + +import re +import sys + +if sys.version_info[0] >= 3: + _unicode, _str, _bytes, _unichr = str, str, bytes, chr + IS_PYTHON3 = True +else: + _unicode, _str, _bytes, _unichr = unicode, str, str, unichr + IS_PYTHON3 = False + +empty_bytes = _bytes() +empty_unicode = _unicode() + +join_bytes = empty_bytes.join + + +class UnicodeLiteralBuilder(object): + """Assemble a unicode string. + """ + def __init__(self): + self.chars = [] + + def append(self, characters): + if isinstance(characters, _bytes): + # this came from a Py2 string literal in the parser code + characters = characters.decode("ASCII") + assert isinstance(characters, _unicode), str(type(characters)) + self.chars.append(characters) + + if sys.maxunicode == 65535: + def append_charval(self, char_number): + if char_number > 65535: + # wide Unicode character on narrow platform => replace + # by surrogate pair + char_number -= 0x10000 + self.chars.append( _unichr((char_number // 1024) + 0xD800) ) + self.chars.append( _unichr((char_number % 1024) + 0xDC00) ) + else: + self.chars.append( _unichr(char_number) ) + else: + def append_charval(self, char_number): + self.chars.append( _unichr(char_number) ) + + def append_uescape(self, char_number, escape_string): + self.append_charval(char_number) + + def getstring(self): + return EncodedString(u''.join(self.chars)) + + def getstrings(self): + return (None, self.getstring()) + + +class BytesLiteralBuilder(object): + """Assemble a byte string or char value. + """ + def __init__(self, target_encoding): + self.chars = [] + self.target_encoding = target_encoding + + def append(self, characters): + if isinstance(characters, _unicode): + characters = characters.encode(self.target_encoding) + assert isinstance(characters, _bytes), str(type(characters)) + self.chars.append(characters) + + def append_charval(self, char_number): + self.chars.append( _unichr(char_number).encode('ISO-8859-1') ) + + def append_uescape(self, char_number, escape_string): + self.append(escape_string) + + def getstring(self): + # this *must* return a byte string! + return bytes_literal(join_bytes(self.chars), self.target_encoding) + + def getchar(self): + # this *must* return a byte string! + return self.getstring() + + def getstrings(self): + return (self.getstring(), None) + + +class StrLiteralBuilder(object): + """Assemble both a bytes and a unicode representation of a string. + """ + def __init__(self, target_encoding): + self._bytes = BytesLiteralBuilder(target_encoding) + self._unicode = UnicodeLiteralBuilder() + + def append(self, characters): + self._bytes.append(characters) + self._unicode.append(characters) + + def append_charval(self, char_number): + self._bytes.append_charval(char_number) + self._unicode.append_charval(char_number) + + def append_uescape(self, char_number, escape_string): + self._bytes.append(escape_string) + self._unicode.append_charval(char_number) + + def getstrings(self): + return (self._bytes.getstring(), self._unicode.getstring()) + + +class EncodedString(_unicode): + # unicode string subclass to keep track of the original encoding. + # 'encoding' is None for unicode strings and the source encoding + # otherwise + encoding = None + + def __deepcopy__(self, memo): + return self + + def byteencode(self): + assert self.encoding is not None + return self.encode(self.encoding) + + def utf8encode(self): + assert self.encoding is None + return self.encode("UTF-8") + + @property + def is_unicode(self): + return self.encoding is None + + def contains_surrogates(self): + return string_contains_surrogates(self) + + def as_utf8_string(self): + return bytes_literal(self.utf8encode(), 'utf8') + + +def string_contains_surrogates(ustring): + """ + Check if the unicode string contains surrogate code points + on a CPython platform with wide (UCS-4) or narrow (UTF-16) + Unicode, i.e. characters that would be spelled as two + separate code units on a narrow platform. + """ + for c in map(ord, ustring): + if c > 65535: # can only happen on wide platforms + return True + if 0xD800 <= c <= 0xDFFF: + return True + return False + + +def string_contains_lone_surrogates(ustring): + """ + Check if the unicode string contains lone surrogate code points + on a CPython platform with wide (UCS-4) or narrow (UTF-16) + Unicode, i.e. characters that would be spelled as two + separate code units on a narrow platform, but that do not form a pair. + """ + last_was_start = False + unicode_uses_surrogate_encoding = sys.maxunicode == 65535 + for c in map(ord, ustring): + # surrogates tend to be rare + if c < 0xD800 or c > 0xDFFF: + if last_was_start: + return True + elif not unicode_uses_surrogate_encoding: + # on 32bit Unicode platforms, there is never a pair + return True + elif c <= 0xDBFF: + if last_was_start: + return True # lone start + last_was_start = True + else: + if not last_was_start: + return True # lone end + last_was_start = False + return last_was_start + + +class BytesLiteral(_bytes): + # bytes subclass that is compatible with EncodedString + encoding = None + + def __deepcopy__(self, memo): + return self + + def byteencode(self): + if IS_PYTHON3: + return _bytes(self) + else: + # fake-recode the string to make it a plain bytes object + return self.decode('ISO-8859-1').encode('ISO-8859-1') + + def utf8encode(self): + assert False, "this is not a unicode string: %r" % self + + def __str__(self): + """Fake-decode the byte string to unicode to support % + formatting of unicode strings. + """ + return self.decode('ISO-8859-1') + + is_unicode = False + + def as_c_string_literal(self): + value = split_string_literal(escape_byte_string(self)) + return '"%s"' % value + + +def bytes_literal(s, encoding): + assert isinstance(s, bytes) + s = BytesLiteral(s) + s.encoding = encoding + return s + + +def encoded_string(s, encoding): + assert isinstance(s, (_unicode, bytes)) + s = EncodedString(s) + if encoding is not None: + s.encoding = encoding + return s + + +char_from_escape_sequence = { + r'\a' : u'\a', + r'\b' : u'\b', + r'\f' : u'\f', + r'\n' : u'\n', + r'\r' : u'\r', + r'\t' : u'\t', + r'\v' : u'\v', + }.get + +_c_special = ('\\', '??', '"') + tuple(map(chr, range(32))) + + +def _to_escape_sequence(s): + if s in '\n\r\t': + return repr(s)[1:-1] + elif s == '"': + return r'\"' + elif s == '\\': + return r'\\' + else: + # within a character sequence, oct passes much better than hex + return ''.join(['\\%03o' % ord(c) for c in s]) + + +def _build_specials_replacer(): + subexps = [] + replacements = {} + for special in _c_special: + regexp = ''.join(['[%s]' % c.replace('\\', '\\\\') for c in special]) + subexps.append(regexp) + replacements[special.encode('ASCII')] = _to_escape_sequence(special).encode('ASCII') + sub = re.compile(('(%s)' % '|'.join(subexps)).encode('ASCII')).sub + def replace_specials(m): + return replacements[m.group(1)] + def replace(s): + return sub(replace_specials, s) + return replace + +_replace_specials = _build_specials_replacer() + + +def escape_char(c): + if IS_PYTHON3: + c = c.decode('ISO-8859-1') + if c in '\n\r\t\\': + return repr(c)[1:-1] + elif c == "'": + return "\\'" + n = ord(c) + if n < 32 or n > 127: + # hex works well for characters + return "\\x%02X" % n + else: + return c + +def escape_byte_string(s): + """Escape a byte string so that it can be written into C code. + Note that this returns a Unicode string instead which, when + encoded as ISO-8859-1, will result in the correct byte sequence + being written. + """ + s = _replace_specials(s) + try: + return s.decode("ASCII") # trial decoding: plain ASCII => done + except UnicodeDecodeError: + pass + if IS_PYTHON3: + s_new = bytearray() + append, extend = s_new.append, s_new.extend + for b in s: + if b >= 128: + extend(('\\%3o' % b).encode('ASCII')) + else: + append(b) + return s_new.decode('ISO-8859-1') + else: + l = [] + append = l.append + for c in s: + o = ord(c) + if o >= 128: + append('\\%3o' % o) + else: + append(c) + return join_bytes(l).decode('ISO-8859-1') + +def split_string_literal(s, limit=2000): + # MSVC can't handle long string literals. + if len(s) < limit: + return s + else: + start = 0 + chunks = [] + while start < len(s): + end = start + limit + if len(s) > end-4 and '\\' in s[end-4:end]: + end -= 4 - s[end-4:end].find('\\') # just before the backslash + while s[end-1] == '\\': + end -= 1 + if end == start: + # must have been a long line of backslashes + end = start + limit - (limit % 2) - 4 + break + chunks.append(s[start:end]) + start = end + return '""'.join(chunks) + +def encode_pyunicode_string(s): + """Create Py_UNICODE[] representation of a given unicode string. + """ + s = list(map(ord, s)) + [0] + + if sys.maxunicode >= 0x10000: # Wide build or Py3.3 + utf16, utf32 = [], s + for code_point in s: + if code_point >= 0x10000: # outside of BMP + high, low = divmod(code_point - 0x10000, 1024) + utf16.append(high + 0xD800) + utf16.append(low + 0xDC00) + else: + utf16.append(code_point) + else: + utf16, utf32 = s, [] + for code_unit in s: + if 0xDC00 <= code_unit <= 0xDFFF and utf32 and 0xD800 <= utf32[-1] <= 0xDBFF: + high, low = utf32[-1], code_unit + utf32[-1] = ((high & 0x3FF) << 10) + (low & 0x3FF) + 0x10000 + else: + utf32.append(code_unit) + + if utf16 == utf32: + utf16 = [] + return ",".join(map(_unicode, utf16)), ",".join(map(_unicode, utf32)) diff --git a/contrib/tools/cython/Cython/Compiler/Symtab.py b/contrib/tools/cython/Cython/Compiler/Symtab.py new file mode 100644 index 00000000000..57d2188cc75 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Symtab.py @@ -0,0 +1,2552 @@ +# +# Symbol Table +# + +from __future__ import absolute_import + +import re +import copy +import operator + +try: + import __builtin__ as builtins +except ImportError: # Py3 + import builtins + +from .Errors import warning, error, InternalError +from .StringEncoding import EncodedString +from . import Options, Naming +from . import PyrexTypes +from .PyrexTypes import py_object_type, unspecified_type +from .TypeSlots import ( + pyfunction_signature, pymethod_signature, richcmp_special_methods, + get_special_method_signature, get_property_accessor_signature) +from . import Future + +from . import Code + +iso_c99_keywords = set( +['auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', + 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', + 'int', 'long', 'register', 'return', 'short', 'signed', 'sizeof', + 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', 'void', + 'volatile', 'while', + '_Bool', '_Complex'', _Imaginary', 'inline', 'restrict']) + + +def c_safe_identifier(cname): + # There are some C limitations on struct entry names. + if ((cname[:2] == '__' and not (cname.startswith(Naming.pyrex_prefix) + or cname in ('__weakref__', '__dict__'))) + or cname in iso_c99_keywords): + cname = Naming.pyrex_prefix + cname + return cname + + +class BufferAux(object): + writable_needed = False + + def __init__(self, buflocal_nd_var, rcbuf_var): + self.buflocal_nd_var = buflocal_nd_var + self.rcbuf_var = rcbuf_var + + def __repr__(self): + return "<BufferAux %r>" % self.__dict__ + + +class Entry(object): + # A symbol table entry in a Scope or ModuleNamespace. + # + # name string Python name of entity + # cname string C name of entity + # type PyrexType Type of entity + # doc string Doc string + # annotation ExprNode PEP 484/526 annotation + # init string Initial value + # visibility 'private' or 'public' or 'extern' + # is_builtin boolean Is an entry in the Python builtins dict + # is_cglobal boolean Is a C global variable + # is_pyglobal boolean Is a Python module-level variable + # or class attribute during + # class construction + # is_member boolean Is an assigned class member + # is_pyclass_attr boolean Is a name in a Python class namespace + # is_variable boolean Is a variable + # is_cfunction boolean Is a C function + # is_cmethod boolean Is a C method of an extension type + # is_builtin_cmethod boolean Is a C method of a builtin type (implies is_cmethod) + # is_unbound_cmethod boolean Is an unbound C method of an extension type + # is_final_cmethod boolean Is non-overridable C method + # is_inline_cmethod boolean Is inlined C method + # is_anonymous boolean Is a anonymous pyfunction entry + # is_type boolean Is a type definition + # is_cclass boolean Is an extension class + # is_cpp_class boolean Is a C++ class + # is_const boolean Is a constant + # is_property boolean Is a property of an extension type: + # doc_cname string or None C const holding the docstring + # getter_cname string C func for getting property + # setter_cname string C func for setting or deleting property + # is_self_arg boolean Is the "self" arg of an exttype method + # is_arg boolean Is the arg of a method + # is_local boolean Is a local variable + # in_closure boolean Is referenced in an inner scope + # in_subscope boolean Belongs to a generator expression scope + # is_readonly boolean Can't be assigned to + # func_cname string C func implementing Python func + # func_modifiers [string] C function modifiers ('inline') + # pos position Source position where declared + # namespace_cname string If is_pyglobal, the C variable + # holding its home namespace + # pymethdef_cname string PyMethodDef structure + # signature Signature Arg & return types for Python func + # as_variable Entry Alternative interpretation of extension + # type name or builtin C function as a variable + # xdecref_cleanup boolean Use Py_XDECREF for error cleanup + # in_cinclude boolean Suppress C declaration code + # enum_values [Entry] For enum types, list of values + # qualified_name string "modname.funcname" or "modname.classname" + # or "modname.classname.funcname" + # is_declared_generic boolean Is declared as PyObject * even though its + # type is an extension type + # as_module None Module scope, if a cimported module + # is_inherited boolean Is an inherited attribute of an extension type + # pystring_cname string C name of Python version of string literal + # is_interned boolean For string const entries, value is interned + # is_identifier boolean For string const entries, value is an identifier + # used boolean + # is_special boolean Is a special method or property accessor + # of an extension type + # defined_in_pxd boolean Is defined in a .pxd file (not just declared) + # api boolean Generate C API for C class or function + # utility_code string Utility code needed when this entry is used + # + # buffer_aux BufferAux or None Extra information needed for buffer variables + # inline_func_in_pxd boolean Hacky special case for inline function in pxd file. + # Ideally this should not be necessary. + # might_overflow boolean In an arithmetic expression that could cause + # overflow (used for type inference). + # utility_code_definition For some Cython builtins, the utility code + # which contains the definition of the entry. + # Currently only supported for CythonScope entries. + # error_on_uninitialized Have Control Flow issue an error when this entry is + # used uninitialized + # cf_used boolean Entry is used + # is_fused_specialized boolean Whether this entry of a cdef or def function + # is a specialization + + # TODO: utility_code and utility_code_definition serves the same purpose... + + inline_func_in_pxd = False + borrowed = 0 + init = "" + annotation = None + visibility = 'private' + is_builtin = 0 + is_cglobal = 0 + is_pyglobal = 0 + is_member = 0 + is_pyclass_attr = 0 + is_variable = 0 + is_cfunction = 0 + is_cmethod = 0 + is_builtin_cmethod = False + is_unbound_cmethod = 0 + is_final_cmethod = 0 + is_inline_cmethod = 0 + is_anonymous = 0 + is_type = 0 + is_cclass = 0 + is_cpp_class = 0 + is_const = 0 + is_property = 0 + doc_cname = None + getter_cname = None + setter_cname = None + is_self_arg = 0 + is_arg = 0 + is_local = 0 + in_closure = 0 + from_closure = 0 + in_subscope = 0 + is_declared_generic = 0 + is_readonly = 0 + pyfunc_cname = None + func_cname = None + func_modifiers = [] + final_func_cname = None + doc = None + as_variable = None + xdecref_cleanup = 0 + in_cinclude = 0 + as_module = None + is_inherited = 0 + pystring_cname = None + is_identifier = 0 + is_interned = 0 + used = 0 + is_special = 0 + defined_in_pxd = 0 + is_implemented = 0 + api = 0 + utility_code = None + is_overridable = 0 + buffer_aux = None + prev_entry = None + might_overflow = 0 + fused_cfunction = None + is_fused_specialized = False + utility_code_definition = None + needs_property = False + in_with_gil_block = 0 + from_cython_utility_code = None + error_on_uninitialized = False + cf_used = True + outer_entry = None + + def __init__(self, name, cname, type, pos = None, init = None): + self.name = name + self.cname = cname + self.type = type + self.pos = pos + self.init = init + self.overloaded_alternatives = [] + self.cf_assignments = [] + self.cf_references = [] + self.inner_entries = [] + self.defining_entry = self + + def __repr__(self): + return "%s(<%x>, name=%s, type=%s)" % (type(self).__name__, id(self), self.name, self.type) + + def already_declared_here(self): + error(self.pos, "Previous declaration is here") + + def redeclared(self, pos): + error(pos, "'%s' does not match previous declaration" % self.name) + self.already_declared_here() + + def all_alternatives(self): + return [self] + self.overloaded_alternatives + + def all_entries(self): + return [self] + self.inner_entries + + def __lt__(left, right): + if isinstance(left, Entry) and isinstance(right, Entry): + return (left.name, left.cname) < (right.name, right.cname) + else: + return NotImplemented + + +class InnerEntry(Entry): + """ + An entry in a closure scope that represents the real outer Entry. + """ + from_closure = True + + def __init__(self, outer_entry, scope): + Entry.__init__(self, outer_entry.name, + outer_entry.cname, + outer_entry.type, + outer_entry.pos) + self.outer_entry = outer_entry + self.scope = scope + + # share state with (outermost) defining entry + outermost_entry = outer_entry + while outermost_entry.outer_entry: + outermost_entry = outermost_entry.outer_entry + self.defining_entry = outermost_entry + self.inner_entries = outermost_entry.inner_entries + self.cf_assignments = outermost_entry.cf_assignments + self.cf_references = outermost_entry.cf_references + self.overloaded_alternatives = outermost_entry.overloaded_alternatives + self.inner_entries.append(self) + + def __getattr__(self, name): + if name.startswith('__'): + # we wouldn't have been called if it was there + raise AttributeError(name) + return getattr(self.defining_entry, name) + + def all_entries(self): + return self.defining_entry.all_entries() + + +class Scope(object): + # name string Unqualified name + # outer_scope Scope or None Enclosing scope + # entries {string : Entry} Python name to entry, non-types + # const_entries [Entry] Constant entries + # type_entries [Entry] Struct/union/enum/typedef/exttype entries + # sue_entries [Entry] Struct/union/enum entries + # arg_entries [Entry] Function argument entries + # var_entries [Entry] User-defined variable entries + # pyfunc_entries [Entry] Python function entries + # cfunc_entries [Entry] C function entries + # c_class_entries [Entry] All extension type entries + # cname_to_entry {string : Entry} Temp cname to entry mapping + # return_type PyrexType or None Return type of function owning scope + # is_builtin_scope boolean Is the builtin scope of Python/Cython + # is_py_class_scope boolean Is a Python class scope + # is_c_class_scope boolean Is an extension type scope + # is_closure_scope boolean Is a closure scope + # is_passthrough boolean Outer scope is passed directly + # is_cpp_class_scope boolean Is a C++ class scope + # is_property_scope boolean Is a extension type property scope + # scope_prefix string Disambiguator for C names + # in_cinclude boolean Suppress C declaration code + # qualified_name string "modname" or "modname.classname" + # Python strings in this scope + # nogil boolean In a nogil section + # directives dict Helper variable for the recursive + # analysis, contains directive values. + # is_internal boolean Is only used internally (simpler setup) + + is_builtin_scope = 0 + is_py_class_scope = 0 + is_c_class_scope = 0 + is_closure_scope = 0 + is_genexpr_scope = 0 + is_passthrough = 0 + is_cpp_class_scope = 0 + is_property_scope = 0 + is_module_scope = 0 + is_internal = 0 + scope_prefix = "" + in_cinclude = 0 + nogil = 0 + fused_to_specific = None + return_type = None + + def __init__(self, name, outer_scope, parent_scope): + # The outer_scope is the next scope in the lookup chain. + # The parent_scope is used to derive the qualified name of this scope. + self.name = name + self.outer_scope = outer_scope + self.parent_scope = parent_scope + mangled_name = "%d%s_" % (len(name), name.replace('.', '_dot_')) + qual_scope = self.qualifying_scope() + if qual_scope: + self.qualified_name = qual_scope.qualify_name(name) + self.scope_prefix = qual_scope.scope_prefix + mangled_name + else: + self.qualified_name = EncodedString(name) + self.scope_prefix = mangled_name + self.entries = {} + self.subscopes = set() + self.const_entries = [] + self.type_entries = [] + self.sue_entries = [] + self.arg_entries = [] + self.var_entries = [] + self.pyfunc_entries = [] + self.cfunc_entries = [] + self.c_class_entries = [] + self.defined_c_classes = [] + self.imported_c_classes = {} + self.cname_to_entry = {} + self.string_to_entry = {} + self.identifier_to_entry = {} + self.num_to_entry = {} + self.obj_to_entry = {} + self.buffer_entries = [] + self.lambda_defs = [] + self.id_counters = {} + + def __deepcopy__(self, memo): + return self + + def merge_in(self, other, merge_unused=True, whitelist=None): + # Use with care... + entries = [] + for name, entry in other.entries.items(): + if not whitelist or name in whitelist: + if entry.used or merge_unused: + entries.append((name, entry)) + + self.entries.update(entries) + + for attr in ('const_entries', + 'type_entries', + 'sue_entries', + 'arg_entries', + 'var_entries', + 'pyfunc_entries', + 'cfunc_entries', + 'c_class_entries'): + self_entries = getattr(self, attr) + names = set(e.name for e in self_entries) + for entry in getattr(other, attr): + if (entry.used or merge_unused) and entry.name not in names: + self_entries.append(entry) + + def __str__(self): + return "<%s %s>" % (self.__class__.__name__, self.qualified_name) + + def qualifying_scope(self): + return self.parent_scope + + def mangle(self, prefix, name = None): + if name: + return "%s%s%s" % (prefix, self.scope_prefix, name) + else: + return self.parent_scope.mangle(prefix, self.name) + + def mangle_internal(self, name): + # Mangle an internal name so as not to clash with any + # user-defined name in this scope. + prefix = "%s%s_" % (Naming.pyrex_prefix, name) + return self.mangle(prefix) + #return self.parent_scope.mangle(prefix, self.name) + + def mangle_class_private_name(self, name): + if self.parent_scope: + return self.parent_scope.mangle_class_private_name(name) + return name + + def next_id(self, name=None): + # Return a cname fragment that is unique for this module + counters = self.global_scope().id_counters + try: + count = counters[name] + 1 + except KeyError: + count = 0 + counters[name] = count + if name: + if not count: + # unique names don't need a suffix, reoccurrences will get one + return name + return '%s%d' % (name, count) + else: + return '%d' % count + + def global_scope(self): + """ Return the module-level scope containing this scope. """ + return self.outer_scope.global_scope() + + def builtin_scope(self): + """ Return the module-level scope containing this scope. """ + return self.outer_scope.builtin_scope() + + def iter_local_scopes(self): + yield self + if self.subscopes: + for scope in sorted(self.subscopes, key=operator.attrgetter('scope_prefix')): + yield scope + + def declare(self, name, cname, type, pos, visibility, shadow = 0, is_type = 0, create_wrapper = 0): + # Create new entry, and add to dictionary if + # name is not None. Reports a warning if already + # declared. + if type.is_buffer and not isinstance(self, LocalScope): # and not is_type: + error(pos, 'Buffer types only allowed as function local variables') + if not self.in_cinclude and cname and re.match("^_[_A-Z]+$", cname): + # See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names + warning(pos, "'%s' is a reserved name in C." % cname, -1) + entries = self.entries + if name and name in entries and not shadow: + old_entry = entries[name] + + # Reject redeclared C++ functions only if they have the same type signature. + cpp_override_allowed = False + if type.is_cfunction and old_entry.type.is_cfunction and self.is_cpp(): + for alt_entry in old_entry.all_alternatives(): + if type == alt_entry.type: + if name == '<init>' and not type.args: + # Cython pre-declares the no-args constructor - allow later user definitions. + cpp_override_allowed = True + break + else: + cpp_override_allowed = True + + if cpp_override_allowed: + # C++ function/method overrides with different signatures are ok. + pass + elif self.is_cpp_class_scope and entries[name].is_inherited: + # Likewise ignore inherited classes. + pass + elif visibility == 'extern': + # Silenced outside of "cdef extern" blocks, until we have a safe way to + # prevent pxd-defined cpdef functions from ending up here. + warning(pos, "'%s' redeclared " % name, 1 if self.in_cinclude else 0) + elif visibility != 'ignore': + error(pos, "'%s' redeclared " % name) + entries[name].already_declared_here() + entry = Entry(name, cname, type, pos = pos) + entry.in_cinclude = self.in_cinclude + entry.create_wrapper = create_wrapper + if name: + entry.qualified_name = self.qualify_name(name) +# if name in entries and self.is_cpp(): +# entries[name].overloaded_alternatives.append(entry) +# else: +# entries[name] = entry + if not shadow: + entries[name] = entry + + if type.is_memoryviewslice: + from . import MemoryView + entry.init = MemoryView.memslice_entry_init + + entry.scope = self + entry.visibility = visibility + return entry + + def qualify_name(self, name): + return EncodedString("%s.%s" % (self.qualified_name, name)) + + def declare_const(self, name, type, value, pos, cname = None, visibility = 'private', api = 0, create_wrapper = 0): + # Add an entry for a named constant. + if not cname: + if self.in_cinclude or (visibility == 'public' or api): + cname = name + else: + cname = self.mangle(Naming.enum_prefix, name) + entry = self.declare(name, cname, type, pos, visibility, create_wrapper = create_wrapper) + entry.is_const = 1 + entry.value_node = value + return entry + + def declare_type(self, name, type, pos, + cname = None, visibility = 'private', api = 0, defining = 1, + shadow = 0, template = 0): + # Add an entry for a type definition. + if not cname: + cname = name + entry = self.declare(name, cname, type, pos, visibility, shadow, + is_type=True) + entry.is_type = 1 + entry.api = api + if defining: + self.type_entries.append(entry) + + if not template: + type.entry = entry + + # here we would set as_variable to an object representing this type + return entry + + def declare_typedef(self, name, base_type, pos, cname = None, + visibility = 'private', api = 0): + if not cname: + if self.in_cinclude or (visibility != 'private' or api): + cname = name + else: + cname = self.mangle(Naming.type_prefix, name) + try: + if self.is_cpp_class_scope: + namespace = self.outer_scope.lookup(self.name).type + else: + namespace = None + type = PyrexTypes.create_typedef_type(name, base_type, cname, + (visibility == 'extern'), + namespace) + except ValueError as e: + error(pos, e.args[0]) + type = PyrexTypes.error_type + entry = self.declare_type(name, type, pos, cname, + visibility = visibility, api = api) + type.qualified_name = entry.qualified_name + return entry + + def declare_struct_or_union(self, name, kind, scope, + typedef_flag, pos, cname = None, + visibility = 'private', api = 0, + packed = False): + # Add an entry for a struct or union definition. + if not cname: + if self.in_cinclude or (visibility == 'public' or api): + cname = name + else: + cname = self.mangle(Naming.type_prefix, name) + entry = self.lookup_here(name) + if not entry: + type = PyrexTypes.CStructOrUnionType( + name, kind, scope, typedef_flag, cname, packed) + entry = self.declare_type(name, type, pos, cname, + visibility = visibility, api = api, + defining = scope is not None) + self.sue_entries.append(entry) + type.entry = entry + else: + if not (entry.is_type and entry.type.is_struct_or_union + and entry.type.kind == kind): + warning(pos, "'%s' redeclared " % name, 0) + elif scope and entry.type.scope: + warning(pos, "'%s' already defined (ignoring second definition)" % name, 0) + else: + self.check_previous_typedef_flag(entry, typedef_flag, pos) + self.check_previous_visibility(entry, visibility, pos) + if scope: + entry.type.scope = scope + self.type_entries.append(entry) + if self.is_cpp_class_scope: + entry.type.namespace = self.outer_scope.lookup(self.name).type + return entry + + def declare_cpp_class(self, name, scope, + pos, cname = None, base_classes = (), + visibility = 'extern', templates = None): + if cname is None: + if self.in_cinclude or (visibility != 'private'): + cname = name + else: + cname = self.mangle(Naming.type_prefix, name) + base_classes = list(base_classes) + entry = self.lookup_here(name) + if not entry: + type = PyrexTypes.CppClassType( + name, scope, cname, base_classes, templates = templates) + entry = self.declare_type(name, type, pos, cname, + visibility = visibility, defining = scope is not None) + self.sue_entries.append(entry) + else: + if not (entry.is_type and entry.type.is_cpp_class): + error(pos, "'%s' redeclared " % name) + entry.already_declared_here() + return None + elif scope and entry.type.scope: + warning(pos, "'%s' already defined (ignoring second definition)" % name, 0) + else: + if scope: + entry.type.scope = scope + self.type_entries.append(entry) + if base_classes: + if entry.type.base_classes and entry.type.base_classes != base_classes: + error(pos, "Base type does not match previous declaration") + entry.already_declared_here() + else: + entry.type.base_classes = base_classes + if templates or entry.type.templates: + if templates != entry.type.templates: + error(pos, "Template parameters do not match previous declaration") + entry.already_declared_here() + + def declare_inherited_attributes(entry, base_classes): + for base_class in base_classes: + if base_class is PyrexTypes.error_type: + continue + if base_class.scope is None: + error(pos, "Cannot inherit from incomplete type") + else: + declare_inherited_attributes(entry, base_class.base_classes) + entry.type.scope.declare_inherited_cpp_attributes(base_class) + if scope: + declare_inherited_attributes(entry, base_classes) + scope.declare_var(name="this", cname="this", type=PyrexTypes.CPtrType(entry.type), pos=entry.pos) + if self.is_cpp_class_scope: + entry.type.namespace = self.outer_scope.lookup(self.name).type + return entry + + def check_previous_typedef_flag(self, entry, typedef_flag, pos): + if typedef_flag != entry.type.typedef_flag: + error(pos, "'%s' previously declared using '%s'" % ( + entry.name, ("cdef", "ctypedef")[entry.type.typedef_flag])) + + def check_previous_visibility(self, entry, visibility, pos): + if entry.visibility != visibility: + error(pos, "'%s' previously declared as '%s'" % ( + entry.name, entry.visibility)) + + def declare_enum(self, name, pos, cname, typedef_flag, + visibility = 'private', api = 0, create_wrapper = 0): + if name: + if not cname: + if (self.in_cinclude or visibility == 'public' + or visibility == 'extern' or api): + cname = name + else: + cname = self.mangle(Naming.type_prefix, name) + if self.is_cpp_class_scope: + namespace = self.outer_scope.lookup(self.name).type + else: + namespace = None + type = PyrexTypes.CEnumType(name, cname, typedef_flag, namespace) + else: + type = PyrexTypes.c_anon_enum_type + entry = self.declare_type(name, type, pos, cname = cname, + visibility = visibility, api = api) + entry.create_wrapper = create_wrapper + entry.enum_values = [] + self.sue_entries.append(entry) + return entry + + def declare_tuple_type(self, pos, components): + return self.outer_scope.declare_tuple_type(pos, components) + + def declare_var(self, name, type, pos, + cname = None, visibility = 'private', + api = 0, in_pxd = 0, is_cdef = 0): + # Add an entry for a variable. + if not cname: + if visibility != 'private' or api: + cname = name + else: + cname = self.mangle(Naming.var_prefix, name) + if type.is_cpp_class and visibility != 'extern': + type.check_nullary_constructor(pos) + entry = self.declare(name, cname, type, pos, visibility) + entry.is_variable = 1 + if in_pxd and visibility != 'extern': + entry.defined_in_pxd = 1 + entry.used = 1 + if api: + entry.api = 1 + entry.used = 1 + return entry + + def declare_builtin(self, name, pos): + return self.outer_scope.declare_builtin(name, pos) + + def _declare_pyfunction(self, name, pos, visibility='extern', entry=None): + if entry and not entry.type.is_cfunction: + error(pos, "'%s' already declared" % name) + error(entry.pos, "Previous declaration is here") + entry = self.declare_var(name, py_object_type, pos, visibility=visibility) + entry.signature = pyfunction_signature + self.pyfunc_entries.append(entry) + return entry + + def declare_pyfunction(self, name, pos, allow_redefine=False, visibility='extern'): + # Add an entry for a Python function. + entry = self.lookup_here(name) + if not allow_redefine: + return self._declare_pyfunction(name, pos, visibility=visibility, entry=entry) + if entry: + if entry.type.is_unspecified: + entry.type = py_object_type + elif entry.type is not py_object_type: + return self._declare_pyfunction(name, pos, visibility=visibility, entry=entry) + else: # declare entry stub + self.declare_var(name, py_object_type, pos, visibility=visibility) + entry = self.declare_var(None, py_object_type, pos, + cname=name, visibility='private') + entry.name = EncodedString(name) + entry.qualified_name = self.qualify_name(name) + entry.signature = pyfunction_signature + entry.is_anonymous = True + return entry + + def declare_lambda_function(self, lambda_name, pos): + # Add an entry for an anonymous Python function. + func_cname = self.mangle(Naming.lambda_func_prefix + u'funcdef_', lambda_name) + pymethdef_cname = self.mangle(Naming.lambda_func_prefix + u'methdef_', lambda_name) + qualified_name = self.qualify_name(lambda_name) + + entry = self.declare(None, func_cname, py_object_type, pos, 'private') + entry.name = lambda_name + entry.qualified_name = qualified_name + entry.pymethdef_cname = pymethdef_cname + entry.func_cname = func_cname + entry.signature = pyfunction_signature + entry.is_anonymous = True + return entry + + def add_lambda_def(self, def_node): + self.lambda_defs.append(def_node) + + def register_pyfunction(self, entry): + self.pyfunc_entries.append(entry) + + def declare_cfunction(self, name, type, pos, + cname=None, visibility='private', api=0, in_pxd=0, + defining=0, modifiers=(), utility_code=None, overridable=False): + # Add an entry for a C function. + if not cname: + if visibility != 'private' or api: + cname = name + else: + cname = self.mangle(Naming.func_prefix, name) + entry = self.lookup_here(name) + if entry: + if not in_pxd and visibility != entry.visibility and visibility == 'extern': + # Previously declared, but now extern => treat this + # as implementing the function, using the new cname + defining = True + visibility = entry.visibility + entry.cname = cname + entry.func_cname = cname + if visibility != 'private' and visibility != entry.visibility: + warning(pos, "Function '%s' previously declared as '%s', now as '%s'" % (name, entry.visibility, visibility), 1) + if overridable != entry.is_overridable: + warning(pos, "Function '%s' previously declared as '%s'" % ( + name, 'cpdef' if overridable else 'cdef'), 1) + if entry.type.same_as(type): + # Fix with_gil vs nogil. + entry.type = entry.type.with_with_gil(type.with_gil) + else: + if visibility == 'extern' and entry.visibility == 'extern': + can_override = False + if self.is_cpp(): + can_override = True + elif cname: + # if all alternatives have different cnames, + # it's safe to allow signature overrides + for alt_entry in entry.all_alternatives(): + if not alt_entry.cname or cname == alt_entry.cname: + break # cname not unique! + else: + can_override = True + if can_override: + temp = self.add_cfunction(name, type, pos, cname, visibility, modifiers) + temp.overloaded_alternatives = entry.all_alternatives() + entry = temp + else: + warning(pos, "Function signature does not match previous declaration", 1) + entry.type = type + elif not in_pxd and entry.defined_in_pxd and type.compatible_signature_with(entry.type): + # TODO: check that this was done by a signature optimisation and not a user error. + #warning(pos, "Function signature does not match previous declaration", 1) + entry.type = type + else: + error(pos, "Function signature does not match previous declaration") + else: + entry = self.add_cfunction(name, type, pos, cname, visibility, modifiers) + entry.func_cname = cname + entry.is_overridable = overridable + if in_pxd and visibility != 'extern': + entry.defined_in_pxd = 1 + if api: + entry.api = 1 + if not defining and not in_pxd and visibility != 'extern': + error(pos, "Non-extern C function '%s' declared but not defined" % name) + if defining: + entry.is_implemented = True + if modifiers: + entry.func_modifiers = modifiers + if utility_code: + assert not entry.utility_code, "duplicate utility code definition in entry %s (%s)" % (name, cname) + entry.utility_code = utility_code + if overridable: + # names of cpdef functions can be used as variables and can be assigned to + var_entry = Entry(name, cname, py_object_type) # FIXME: cname? + var_entry.qualified_name = self.qualify_name(name) + var_entry.is_variable = 1 + var_entry.is_pyglobal = 1 + var_entry.scope = entry.scope + entry.as_variable = var_entry + type.entry = entry + return entry + + def add_cfunction(self, name, type, pos, cname, visibility, modifiers, inherited=False): + # Add a C function entry without giving it a func_cname. + entry = self.declare(name, cname, type, pos, visibility) + entry.is_cfunction = 1 + if modifiers: + entry.func_modifiers = modifiers + if inherited or type.is_fused: + self.cfunc_entries.append(entry) + else: + # For backwards compatibility reasons, we must keep all non-fused methods + # before all fused methods, but separately for each type. + i = len(self.cfunc_entries) + for cfunc_entry in reversed(self.cfunc_entries): + if cfunc_entry.is_inherited or not cfunc_entry.type.is_fused: + break + i -= 1 + self.cfunc_entries.insert(i, entry) + return entry + + def find(self, name, pos): + # Look up name, report error if not found. + entry = self.lookup(name) + if entry: + return entry + else: + error(pos, "'%s' is not declared" % name) + + def find_imported_module(self, path, pos): + # Look up qualified name, must be a module, report error if not found. + # Path is a list of names. + scope = self + for name in path: + entry = scope.find(name, pos) + if not entry: + return None + if entry.as_module: + scope = entry.as_module + else: + error(pos, "'%s' is not a cimported module" % '.'.join(path)) + return None + return scope + + def lookup(self, name): + # Look up name in this scope or an enclosing one. + # Return None if not found. + return (self.lookup_here(name) + or (self.outer_scope and self.outer_scope.lookup(name)) + or None) + + def lookup_here(self, name): + # Look up in this scope only, return None if not found. + return self.entries.get(name, None) + + def lookup_target(self, name): + # Look up name in this scope only. Declare as Python + # variable if not found. + entry = self.lookup_here(name) + if not entry: + entry = self.declare_var(name, py_object_type, None) + return entry + + def lookup_type(self, name): + entry = self.lookup(name) + if entry and entry.is_type: + if entry.type.is_fused and self.fused_to_specific: + return entry.type.specialize(self.fused_to_specific) + return entry.type + + def lookup_operator(self, operator, operands): + if operands[0].type.is_cpp_class: + obj_type = operands[0].type + method = obj_type.scope.lookup("operator%s" % operator) + if method is not None: + arg_types = [arg.type for arg in operands[1:]] + res = PyrexTypes.best_match([arg.type for arg in operands[1:]], + method.all_alternatives()) + if res is not None: + return res + function = self.lookup("operator%s" % operator) + function_alternatives = [] + if function is not None: + function_alternatives = function.all_alternatives() + + # look-up nonmember methods listed within a class + method_alternatives = [] + if len(operands)==2: # binary operators only + for n in range(2): + if operands[n].type.is_cpp_class: + obj_type = operands[n].type + method = obj_type.scope.lookup("operator%s" % operator) + if method is not None: + method_alternatives += method.all_alternatives() + + if (not method_alternatives) and (not function_alternatives): + return None + + # select the unique alternatives + all_alternatives = list(set(method_alternatives + function_alternatives)) + + return PyrexTypes.best_match([arg.type for arg in operands], + all_alternatives) + + def lookup_operator_for_types(self, pos, operator, types): + from .Nodes import Node + class FakeOperand(Node): + pass + operands = [FakeOperand(pos, type=type) for type in types] + return self.lookup_operator(operator, operands) + + def use_utility_code(self, new_code): + self.global_scope().use_utility_code(new_code) + + def use_entry_utility_code(self, entry): + self.global_scope().use_entry_utility_code(entry) + + def defines_any(self, names): + # Test whether any of the given names are defined in this scope. + for name in names: + if name in self.entries: + return 1 + return 0 + + def defines_any_special(self, names): + # Test whether any of the given names are defined as special methods in this scope. + for name in names: + if name in self.entries and self.entries[name].is_special: + return 1 + return 0 + + def infer_types(self): + from .TypeInference import get_type_inferer + get_type_inferer().infer_types(self) + + def is_cpp(self): + outer = self.outer_scope + if outer is None: + return False + else: + return outer.is_cpp() + + def add_include_file(self, filename, verbatim_include=None, late=False): + self.outer_scope.add_include_file(filename, verbatim_include, late) + + +class PreImportScope(Scope): + + namespace_cname = Naming.preimport_cname + + def __init__(self): + Scope.__init__(self, Options.pre_import, None, None) + + def declare_builtin(self, name, pos): + entry = self.declare(name, name, py_object_type, pos, 'private') + entry.is_variable = True + entry.is_pyglobal = True + return entry + + +class BuiltinScope(Scope): + # The builtin namespace. + + is_builtin_scope = True + + def __init__(self): + if Options.pre_import is None: + Scope.__init__(self, "__builtin__", None, None) + else: + Scope.__init__(self, "__builtin__", PreImportScope(), None) + self.type_names = {} + + for name, definition in sorted(self.builtin_entries.items()): + cname, type = definition + self.declare_var(name, type, None, cname) + + def lookup(self, name, language_level=None, str_is_str=None): + # 'language_level' and 'str_is_str' are passed by ModuleScope + if name == 'str': + if str_is_str is None: + str_is_str = language_level in (None, 2) + if not str_is_str: + name = 'unicode' + return Scope.lookup(self, name) + + def declare_builtin(self, name, pos): + if not hasattr(builtins, name): + if self.outer_scope is not None: + return self.outer_scope.declare_builtin(name, pos) + else: + if Options.error_on_unknown_names: + error(pos, "undeclared name not builtin: %s" % name) + else: + warning(pos, "undeclared name not builtin: %s" % name, 2) + + def declare_builtin_cfunction(self, name, type, cname, python_equiv=None, utility_code=None): + # If python_equiv == "*", the Python equivalent has the same name + # as the entry, otherwise it has the name specified by python_equiv. + name = EncodedString(name) + entry = self.declare_cfunction(name, type, None, cname, visibility='extern', + utility_code=utility_code) + if python_equiv: + if python_equiv == "*": + python_equiv = name + else: + python_equiv = EncodedString(python_equiv) + var_entry = Entry(python_equiv, python_equiv, py_object_type) + var_entry.qualified_name = self.qualify_name(name) + var_entry.is_variable = 1 + var_entry.is_builtin = 1 + var_entry.utility_code = utility_code + var_entry.scope = entry.scope + entry.as_variable = var_entry + return entry + + def declare_builtin_type(self, name, cname, utility_code = None, objstruct_cname = None): + name = EncodedString(name) + type = PyrexTypes.BuiltinObjectType(name, cname, objstruct_cname) + scope = CClassScope(name, outer_scope=None, visibility='extern') + scope.directives = {} + if name == 'bool': + type.is_final_type = True + type.set_scope(scope) + self.type_names[name] = 1 + entry = self.declare_type(name, type, None, visibility='extern') + entry.utility_code = utility_code + + var_entry = Entry(name = entry.name, + type = self.lookup('type').type, # make sure "type" is the first type declared... + pos = entry.pos, + cname = entry.type.typeptr_cname) + var_entry.qualified_name = self.qualify_name(name) + var_entry.is_variable = 1 + var_entry.is_cglobal = 1 + var_entry.is_readonly = 1 + var_entry.is_builtin = 1 + var_entry.utility_code = utility_code + var_entry.scope = self + if Options.cache_builtins: + var_entry.is_const = True + entry.as_variable = var_entry + + return type + + def builtin_scope(self): + return self + + builtin_entries = { + + "type": ["((PyObject*)&PyType_Type)", py_object_type], + + "bool": ["((PyObject*)&PyBool_Type)", py_object_type], + "int": ["((PyObject*)&PyInt_Type)", py_object_type], + "long": ["((PyObject*)&PyLong_Type)", py_object_type], + "float": ["((PyObject*)&PyFloat_Type)", py_object_type], + "complex":["((PyObject*)&PyComplex_Type)", py_object_type], + + "bytes": ["((PyObject*)&PyBytes_Type)", py_object_type], + "bytearray": ["((PyObject*)&PyByteArray_Type)", py_object_type], + "str": ["((PyObject*)&PyString_Type)", py_object_type], + "unicode":["((PyObject*)&PyUnicode_Type)", py_object_type], + + "tuple": ["((PyObject*)&PyTuple_Type)", py_object_type], + "list": ["((PyObject*)&PyList_Type)", py_object_type], + "dict": ["((PyObject*)&PyDict_Type)", py_object_type], + "set": ["((PyObject*)&PySet_Type)", py_object_type], + "frozenset": ["((PyObject*)&PyFrozenSet_Type)", py_object_type], + + "slice": ["((PyObject*)&PySlice_Type)", py_object_type], +# "file": ["((PyObject*)&PyFile_Type)", py_object_type], # not in Py3 + + "None": ["Py_None", py_object_type], + "False": ["Py_False", py_object_type], + "True": ["Py_True", py_object_type], + } + +const_counter = 1 # As a temporary solution for compiling code in pxds + +class ModuleScope(Scope): + # module_name string Python name of the module + # module_cname string C name of Python module object + # #module_dict_cname string C name of module dict object + # method_table_cname string C name of method table + # doc string Module doc string + # doc_cname string C name of module doc string + # utility_code_list [UtilityCode] Queuing utility codes for forwarding to Code.py + # c_includes {key: IncludeCode} C headers or verbatim code to be generated + # See process_include() for more documentation + # string_to_entry {string : Entry} Map string const to entry + # identifier_to_entry {string : Entry} Map identifier string const to entry + # context Context + # parent_module Scope Parent in the import namespace + # module_entries {string : Entry} For cimport statements + # type_names {string : 1} Set of type names (used during parsing) + # included_files [string] Cython sources included with 'include' + # pxd_file_loaded boolean Corresponding .pxd file has been processed + # cimported_modules [ModuleScope] Modules imported with cimport + # types_imported {PyrexType} Set of types for which import code generated + # has_import_star boolean Module contains import * + # cpp boolean Compiling a C++ file + # is_cython_builtin boolean Is this the Cython builtin scope (or a child scope) + # is_package boolean Is this a package module? (__init__) + + is_module_scope = 1 + has_import_star = 0 + is_cython_builtin = 0 + old_style_globals = 0 + + def __init__(self, name, parent_module, context): + from . import Builtin + self.parent_module = parent_module + outer_scope = Builtin.builtin_scope + Scope.__init__(self, name, outer_scope, parent_module) + if name == "__init__": + # Treat Spam/__init__.pyx specially, so that when Python loads + # Spam/__init__.so, initSpam() is defined. + self.module_name = parent_module.module_name + self.is_package = True + else: + self.module_name = name + self.is_package = False + self.module_name = EncodedString(self.module_name) + self.context = context + self.module_cname = Naming.module_cname + self.module_dict_cname = Naming.moddict_cname + self.method_table_cname = Naming.methtable_cname + self.doc = "" + self.doc_cname = Naming.moddoc_cname + self.utility_code_list = [] + self.module_entries = {} + self.c_includes = {} + self.type_names = dict(outer_scope.type_names) + self.pxd_file_loaded = 0 + self.cimported_modules = [] + self.types_imported = set() + self.included_files = [] + self.has_extern_class = 0 + self.cached_builtins = [] + self.undeclared_cached_builtins = [] + self.namespace_cname = self.module_cname + self._cached_tuple_types = {} + for var_name in ['__builtins__', '__name__', '__file__', '__doc__', '__path__', + '__spec__', '__loader__', '__package__', '__cached__']: + self.declare_var(EncodedString(var_name), py_object_type, None) + self.process_include(Code.IncludeCode("Python.h", initial=True)) + + def qualifying_scope(self): + return self.parent_module + + def global_scope(self): + return self + + def lookup(self, name, language_level=None, str_is_str=None): + entry = self.lookup_here(name) + if entry is not None: + return entry + + if language_level is None: + language_level = self.context.language_level if self.context is not None else 3 + if str_is_str is None: + str_is_str = language_level == 2 or ( + self.context is not None and Future.unicode_literals not in self.context.future_directives) + + return self.outer_scope.lookup(name, language_level=language_level, str_is_str=str_is_str) + + def declare_tuple_type(self, pos, components): + components = tuple(components) + try: + ttype = self._cached_tuple_types[components] + except KeyError: + ttype = self._cached_tuple_types[components] = PyrexTypes.c_tuple_type(components) + cname = ttype.cname + entry = self.lookup_here(cname) + if not entry: + scope = StructOrUnionScope(cname) + for ix, component in enumerate(components): + scope.declare_var(name="f%s" % ix, type=component, pos=pos) + struct_entry = self.declare_struct_or_union( + cname + '_struct', 'struct', scope, typedef_flag=True, pos=pos, cname=cname) + self.type_entries.remove(struct_entry) + ttype.struct_entry = struct_entry + entry = self.declare_type(cname, ttype, pos, cname) + ttype.entry = entry + return entry + + def declare_builtin(self, name, pos): + if not hasattr(builtins, name) \ + and name not in Code.non_portable_builtins_map \ + and name not in Code.uncachable_builtins: + if self.has_import_star: + entry = self.declare_var(name, py_object_type, pos) + return entry + else: + if Options.error_on_unknown_names: + error(pos, "undeclared name not builtin: %s" % name) + else: + warning(pos, "undeclared name not builtin: %s" % name, 2) + # unknown - assume it's builtin and look it up at runtime + entry = self.declare(name, None, py_object_type, pos, 'private') + entry.is_builtin = 1 + return entry + if Options.cache_builtins: + for entry in self.cached_builtins: + if entry.name == name: + return entry + if name == 'globals' and not self.old_style_globals: + return self.outer_scope.lookup('__Pyx_Globals') + else: + entry = self.declare(None, None, py_object_type, pos, 'private') + if Options.cache_builtins and name not in Code.uncachable_builtins: + entry.is_builtin = 1 + entry.is_const = 1 # cached + entry.name = name + entry.cname = Naming.builtin_prefix + name + self.cached_builtins.append(entry) + self.undeclared_cached_builtins.append(entry) + else: + entry.is_builtin = 1 + entry.name = name + entry.qualified_name = self.builtin_scope().qualify_name(name) + return entry + + def find_module(self, module_name, pos, relative_level=-1, need_pxd=1): + # Find a module in the import namespace, interpreting + # relative imports relative to this module's parent. + # Finds and parses the module's .pxd file if the module + # has not been referenced before. + relative_to = None + absolute_fallback = False + if relative_level is not None and relative_level > 0: + # explicit relative cimport + # error of going beyond top-level is handled in cimport node + relative_to = self + while relative_level > 0 and relative_to: + relative_to = relative_to.parent_module + relative_level -= 1 + elif relative_level != 0: + # -1 or None: try relative cimport first, then absolute + relative_to = self.parent_module + absolute_fallback = True + + module_scope = self.global_scope() + return module_scope.context.find_module( + module_name, relative_to=relative_to, pos=pos, absolute_fallback=absolute_fallback, need_pxd=need_pxd) + + def find_submodule(self, name): + # Find and return scope for a submodule of this module, + # creating a new empty one if necessary. Doesn't parse .pxd. + if '.' in name: + name, submodule = name.split('.', 1) + else: + submodule = None + scope = self.lookup_submodule(name) + if not scope: + scope = ModuleScope(name, parent_module=self, context=self.context) + self.module_entries[name] = scope + if submodule: + scope = scope.find_submodule(submodule) + return scope + + def lookup_submodule(self, name): + # Return scope for submodule of this module, or None. + if '.' in name: + name, submodule = name.split('.', 1) + else: + submodule = None + module = self.module_entries.get(name, None) + if submodule and module is not None: + module = module.lookup_submodule(submodule) + return module + + def add_include_file(self, filename, verbatim_include=None, late=False): + """ + Add `filename` as include file. Add `verbatim_include` as + verbatim text in the C file. + Both `filename` and `verbatim_include` can be `None` or empty. + """ + inc = Code.IncludeCode(filename, verbatim_include, late=late) + self.process_include(inc) + + def process_include(self, inc): + """ + Add `inc`, which is an instance of `IncludeCode`, to this + `ModuleScope`. This either adds a new element to the + `c_includes` dict or it updates an existing entry. + + In detail: the values of the dict `self.c_includes` are + instances of `IncludeCode` containing the code to be put in the + generated C file. The keys of the dict are needed to ensure + uniqueness in two ways: if an include file is specified in + multiple "cdef extern" blocks, only one `#include` statement is + generated. Second, the same include might occur multiple times + if we find it through multiple "cimport" paths. So we use the + generated code (of the form `#include "header.h"`) as dict key. + + If verbatim code does not belong to any include file (i.e. it + was put in a `cdef extern from *` block), then we use a unique + dict key: namely, the `sortkey()`. + + One `IncludeCode` object can contain multiple pieces of C code: + one optional "main piece" for the include file and several other + pieces for the verbatim code. The `IncludeCode.dict_update` + method merges the pieces of two different `IncludeCode` objects + if needed. + """ + key = inc.mainpiece() + if key is None: + key = inc.sortkey() + inc.dict_update(self.c_includes, key) + inc = self.c_includes[key] + + def add_imported_module(self, scope): + if scope not in self.cimported_modules: + for inc in scope.c_includes.values(): + self.process_include(inc) + self.cimported_modules.append(scope) + for m in scope.cimported_modules: + self.add_imported_module(m) + + def add_imported_entry(self, name, entry, pos): + if entry.is_pyglobal: + # Allow cimports to follow imports. + entry.is_variable = True + if entry not in self.entries: + self.entries[name] = entry + else: + warning(pos, "'%s' redeclared " % name, 0) + + def declare_module(self, name, scope, pos): + # Declare a cimported module. This is represented as a + # Python module-level variable entry with a module + # scope attached to it. Reports an error and returns + # None if previously declared as something else. + entry = self.lookup_here(name) + if entry: + if entry.is_pyglobal and entry.as_module is scope: + return entry # Already declared as the same module + if not (entry.is_pyglobal and not entry.as_module): + # SAGE -- I put this here so Pyrex + # cimport's work across directories. + # Currently it tries to multiply define + # every module appearing in an import list. + # It shouldn't be an error for a module + # name to appear again, and indeed the generated + # code compiles fine. + return entry + else: + entry = self.declare_var(name, py_object_type, pos) + entry.is_variable = 0 + entry.as_module = scope + self.add_imported_module(scope) + return entry + + def declare_var(self, name, type, pos, + cname = None, visibility = 'private', + api = 0, in_pxd = 0, is_cdef = 0): + # Add an entry for a global variable. If it is a Python + # object type, and not declared with cdef, it will live + # in the module dictionary, otherwise it will be a C + # global variable. + if not visibility in ('private', 'public', 'extern'): + error(pos, "Module-level variable cannot be declared %s" % visibility) + if not is_cdef: + if type is unspecified_type: + type = py_object_type + if not (type.is_pyobject and not type.is_extension_type): + raise InternalError( + "Non-cdef global variable is not a generic Python object") + + if not cname: + defining = not in_pxd + if visibility == 'extern' or (visibility == 'public' and defining): + cname = name + else: + cname = self.mangle(Naming.var_prefix, name) + + entry = self.lookup_here(name) + if entry and entry.defined_in_pxd: + #if visibility != 'private' and visibility != entry.visibility: + # warning(pos, "Variable '%s' previously declared as '%s'" % (name, entry.visibility), 1) + if not entry.type.same_as(type): + if visibility == 'extern' and entry.visibility == 'extern': + warning(pos, "Variable '%s' type does not match previous declaration" % name, 1) + entry.type = type + #else: + # error(pos, "Variable '%s' type does not match previous declaration" % name) + if entry.visibility != "private": + mangled_cname = self.mangle(Naming.var_prefix, name) + if entry.cname == mangled_cname: + cname = name + entry.cname = name + if not entry.is_implemented: + entry.is_implemented = True + return entry + + entry = Scope.declare_var(self, name, type, pos, + cname=cname, visibility=visibility, + api=api, in_pxd=in_pxd, is_cdef=is_cdef) + if is_cdef: + entry.is_cglobal = 1 + if entry.type.declaration_value: + entry.init = entry.type.declaration_value + self.var_entries.append(entry) + else: + entry.is_pyglobal = 1 + if Options.cimport_from_pyx: + entry.used = 1 + return entry + + def declare_cfunction(self, name, type, pos, + cname=None, visibility='private', api=0, in_pxd=0, + defining=0, modifiers=(), utility_code=None, overridable=False): + if not defining and 'inline' in modifiers: + # TODO(github/1736): Make this an error. + warning(pos, "Declarations should not be declared inline.", 1) + # Add an entry for a C function. + if not cname: + if visibility == 'extern' or (visibility == 'public' and defining): + cname = name + else: + cname = self.mangle(Naming.func_prefix, name) + if visibility == 'extern' and type.optional_arg_count: + error(pos, "Extern functions cannot have default arguments values.") + entry = self.lookup_here(name) + if entry and entry.defined_in_pxd: + if entry.visibility != "private": + mangled_cname = self.mangle(Naming.var_prefix, name) + if entry.cname == mangled_cname: + cname = name + entry.cname = cname + entry.func_cname = cname + entry = Scope.declare_cfunction( + self, name, type, pos, + cname=cname, visibility=visibility, api=api, in_pxd=in_pxd, + defining=defining, modifiers=modifiers, utility_code=utility_code, + overridable=overridable) + return entry + + def declare_global(self, name, pos): + entry = self.lookup_here(name) + if not entry: + self.declare_var(name, py_object_type, pos) + + def use_utility_code(self, new_code): + if new_code is not None: + self.utility_code_list.append(new_code) + + def use_entry_utility_code(self, entry): + if entry is None: + return + if entry.utility_code: + self.utility_code_list.append(entry.utility_code) + if entry.utility_code_definition: + self.utility_code_list.append(entry.utility_code_definition) + + def declare_c_class(self, name, pos, defining=0, implementing=0, + module_name=None, base_type=None, objstruct_cname=None, + typeobj_cname=None, typeptr_cname=None, visibility='private', + typedef_flag=0, api=0, check_size=None, + buffer_defaults=None, shadow=0): + # If this is a non-extern typedef class, expose the typedef, but use + # the non-typedef struct internally to avoid needing forward + # declarations for anonymous structs. + if typedef_flag and visibility != 'extern': + if not (visibility == 'public' or api): + warning(pos, "ctypedef only valid for 'extern' , 'public', and 'api'", 2) + objtypedef_cname = objstruct_cname + typedef_flag = 0 + else: + objtypedef_cname = None + # + # Look for previous declaration as a type + # + entry = self.lookup_here(name) + if entry and not shadow: + type = entry.type + if not (entry.is_type and type.is_extension_type): + entry = None # Will cause redeclaration and produce an error + else: + scope = type.scope + if typedef_flag and (not scope or scope.defined): + self.check_previous_typedef_flag(entry, typedef_flag, pos) + if (scope and scope.defined) or (base_type and type.base_type): + if base_type and base_type is not type.base_type: + error(pos, "Base type does not match previous declaration") + if base_type and not type.base_type: + type.base_type = base_type + # + # Make a new entry if needed + # + if not entry or shadow: + type = PyrexTypes.PyExtensionType( + name, typedef_flag, base_type, visibility == 'extern', check_size=check_size) + type.pos = pos + type.buffer_defaults = buffer_defaults + if objtypedef_cname is not None: + type.objtypedef_cname = objtypedef_cname + if visibility == 'extern': + type.module_name = module_name + else: + type.module_name = self.qualified_name + if typeptr_cname: + type.typeptr_cname = typeptr_cname + else: + type.typeptr_cname = self.mangle(Naming.typeptr_prefix, name) + entry = self.declare_type(name, type, pos, visibility = visibility, + defining = 0, shadow = shadow) + entry.is_cclass = True + if objstruct_cname: + type.objstruct_cname = objstruct_cname + elif not entry.in_cinclude: + type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name) + else: + error(entry.pos, + "Object name required for 'public' or 'extern' C class") + self.attach_var_entry_to_c_class(entry) + self.c_class_entries.append(entry) + # + # Check for re-definition and create scope if needed + # + if not type.scope: + if defining or implementing: + scope = CClassScope(name = name, outer_scope = self, + visibility = visibility) + scope.directives = self.directives.copy() + if base_type and base_type.scope: + scope.declare_inherited_c_attributes(base_type.scope) + type.set_scope(scope) + self.type_entries.append(entry) + else: + if defining and type.scope.defined: + error(pos, "C class '%s' already defined" % name) + elif implementing and type.scope.implemented: + error(pos, "C class '%s' already implemented" % name) + # + # Fill in options, checking for compatibility with any previous declaration + # + if defining: + entry.defined_in_pxd = 1 + if implementing: # So that filenames in runtime exceptions refer to + entry.pos = pos # the .pyx file and not the .pxd file + if visibility != 'private' and entry.visibility != visibility: + error(pos, "Class '%s' previously declared as '%s'" + % (name, entry.visibility)) + if api: + entry.api = 1 + if objstruct_cname: + if type.objstruct_cname and type.objstruct_cname != objstruct_cname: + error(pos, "Object struct name differs from previous declaration") + type.objstruct_cname = objstruct_cname + if typeobj_cname: + if type.typeobj_cname and type.typeobj_cname != typeobj_cname: + error(pos, "Type object name differs from previous declaration") + type.typeobj_cname = typeobj_cname + + if self.directives.get('final'): + entry.type.is_final_type = True + + # cdef classes are always exported, but we need to set it to + # distinguish between unused Cython utility code extension classes + entry.used = True + + # + # Return new or existing entry + # + return entry + + def allocate_vtable_names(self, entry): + # If extension type has a vtable, allocate vtable struct and + # slot names for it. + type = entry.type + if type.base_type and type.base_type.vtabslot_cname: + #print "...allocating vtabslot_cname because base type has one" ### + type.vtabslot_cname = "%s.%s" % ( + Naming.obj_base_cname, type.base_type.vtabslot_cname) + elif type.scope and type.scope.cfunc_entries: + # one special case here: when inheriting from builtin + # types, the methods may also be built-in, in which + # case they won't need a vtable + entry_count = len(type.scope.cfunc_entries) + base_type = type.base_type + while base_type: + # FIXME: this will break if we ever get non-inherited C methods + if not base_type.scope or entry_count > len(base_type.scope.cfunc_entries): + break + if base_type.is_builtin_type: + # builtin base type defines all methods => no vtable needed + return + base_type = base_type.base_type + #print "...allocating vtabslot_cname because there are C methods" ### + type.vtabslot_cname = Naming.vtabslot_cname + if type.vtabslot_cname: + #print "...allocating other vtable related cnames" ### + type.vtabstruct_cname = self.mangle(Naming.vtabstruct_prefix, entry.name) + type.vtabptr_cname = self.mangle(Naming.vtabptr_prefix, entry.name) + + def check_c_classes_pxd(self): + # Performs post-analysis checking and finishing up of extension types + # being implemented in this module. This is called only for the .pxd. + # + # Checks all extension types declared in this scope to + # make sure that: + # + # * The extension type is fully declared + # + # Also allocates a name for the vtable if needed. + # + for entry in self.c_class_entries: + # Check defined + if not entry.type.scope: + error(entry.pos, "C class '%s' is declared but not defined" % entry.name) + + def check_c_class(self, entry): + type = entry.type + name = entry.name + visibility = entry.visibility + # Check defined + if not type.scope: + error(entry.pos, "C class '%s' is declared but not defined" % name) + # Generate typeobj_cname + if visibility != 'extern' and not type.typeobj_cname: + type.typeobj_cname = self.mangle(Naming.typeobj_prefix, name) + ## Generate typeptr_cname + #type.typeptr_cname = self.mangle(Naming.typeptr_prefix, name) + # Check C methods defined + if type.scope: + for method_entry in type.scope.cfunc_entries: + if not method_entry.is_inherited and not method_entry.func_cname: + error(method_entry.pos, "C method '%s' is declared but not defined" % + method_entry.name) + # Allocate vtable name if necessary + if type.vtabslot_cname: + #print "ModuleScope.check_c_classes: allocating vtable cname for", self ### + type.vtable_cname = self.mangle(Naming.vtable_prefix, entry.name) + + def check_c_classes(self): + # Performs post-analysis checking and finishing up of extension types + # being implemented in this module. This is called only for the main + # .pyx file scope, not for cimported .pxd scopes. + # + # Checks all extension types declared in this scope to + # make sure that: + # + # * The extension type is implemented + # * All required object and type names have been specified or generated + # * All non-inherited C methods are implemented + # + # Also allocates a name for the vtable if needed. + # + debug_check_c_classes = 0 + if debug_check_c_classes: + print("Scope.check_c_classes: checking scope " + self.qualified_name) + for entry in self.c_class_entries: + if debug_check_c_classes: + print("...entry %s %s" % (entry.name, entry)) + print("......type = ", entry.type) + print("......visibility = ", entry.visibility) + self.check_c_class(entry) + + def check_c_functions(self): + # Performs post-analysis checking making sure all + # defined c functions are actually implemented. + for name, entry in self.entries.items(): + if entry.is_cfunction: + if (entry.defined_in_pxd + and entry.scope is self + and entry.visibility != 'extern' + and not entry.in_cinclude + and not entry.is_implemented): + error(entry.pos, "Non-extern C function '%s' declared but not defined" % name) + + def attach_var_entry_to_c_class(self, entry): + # The name of an extension class has to serve as both a type + # name and a variable name holding the type object. It is + # represented in the symbol table by a type entry with a + # variable entry attached to it. For the variable entry, + # we use a read-only C global variable whose name is an + # expression that refers to the type object. + from . import Builtin + var_entry = Entry(name = entry.name, + type = Builtin.type_type, + pos = entry.pos, + cname = entry.type.typeptr_cname) + var_entry.qualified_name = entry.qualified_name + var_entry.is_variable = 1 + var_entry.is_cglobal = 1 + var_entry.is_readonly = 1 + var_entry.scope = entry.scope + entry.as_variable = var_entry + + def is_cpp(self): + return self.cpp + + def infer_types(self): + from .TypeInference import PyObjectTypeInferer + PyObjectTypeInferer().infer_types(self) + + +class LocalScope(Scope): + + # Does the function have a 'with gil:' block? + has_with_gil_block = False + + # Transient attribute, used for symbol table variable declarations + _in_with_gil_block = False + + def __init__(self, name, outer_scope, parent_scope = None): + if parent_scope is None: + parent_scope = outer_scope + Scope.__init__(self, name, outer_scope, parent_scope) + + def mangle(self, prefix, name): + return prefix + name + + def declare_arg(self, name, type, pos): + # Add an entry for an argument of a function. + cname = self.mangle(Naming.var_prefix, name) + entry = self.declare(name, cname, type, pos, 'private') + entry.is_variable = 1 + if type.is_pyobject: + entry.init = "0" + entry.is_arg = 1 + #entry.borrowed = 1 # Not using borrowed arg refs for now + self.arg_entries.append(entry) + return entry + + def declare_var(self, name, type, pos, + cname = None, visibility = 'private', + api = 0, in_pxd = 0, is_cdef = 0): + # Add an entry for a local variable. + if visibility in ('public', 'readonly'): + error(pos, "Local variable cannot be declared %s" % visibility) + entry = Scope.declare_var(self, name, type, pos, + cname=cname, visibility=visibility, + api=api, in_pxd=in_pxd, is_cdef=is_cdef) + if entry.type.declaration_value: + entry.init = entry.type.declaration_value + entry.is_local = 1 + + entry.in_with_gil_block = self._in_with_gil_block + self.var_entries.append(entry) + return entry + + def declare_global(self, name, pos): + # Pull entry from global scope into local scope. + if self.lookup_here(name): + warning(pos, "'%s' redeclared ", 0) + else: + entry = self.global_scope().lookup_target(name) + self.entries[name] = entry + + def declare_nonlocal(self, name, pos): + # Pull entry from outer scope into local scope + orig_entry = self.lookup_here(name) + if orig_entry and orig_entry.scope is self and not orig_entry.from_closure: + error(pos, "'%s' redeclared as nonlocal" % name) + orig_entry.already_declared_here() + else: + entry = self.lookup(name) + if entry is None or not entry.from_closure: + error(pos, "no binding for nonlocal '%s' found" % name) + + def lookup(self, name): + # Look up name in this scope or an enclosing one. + # Return None if not found. + entry = Scope.lookup(self, name) + if entry is not None: + entry_scope = entry.scope + while entry_scope.is_genexpr_scope: + entry_scope = entry_scope.outer_scope + if entry_scope is not self and entry_scope.is_closure_scope: + if hasattr(entry.scope, "scope_class"): + raise InternalError("lookup() after scope class created.") + # The actual c fragment for the different scopes differs + # on the outside and inside, so we make a new entry + entry.in_closure = True + inner_entry = InnerEntry(entry, self) + inner_entry.is_variable = True + self.entries[name] = inner_entry + return inner_entry + return entry + + def mangle_closure_cnames(self, outer_scope_cname): + for scope in self.iter_local_scopes(): + for entry in scope.entries.values(): + if entry.from_closure: + cname = entry.outer_entry.cname + if self.is_passthrough: + entry.cname = cname + else: + if cname.startswith(Naming.cur_scope_cname): + cname = cname[len(Naming.cur_scope_cname)+2:] + entry.cname = "%s->%s" % (outer_scope_cname, cname) + elif entry.in_closure: + entry.original_cname = entry.cname + entry.cname = "%s->%s" % (Naming.cur_scope_cname, entry.cname) + + +class GeneratorExpressionScope(Scope): + """Scope for generator expressions and comprehensions. As opposed + to generators, these can be easily inlined in some cases, so all + we really need is a scope that holds the loop variable(s). + """ + is_genexpr_scope = True + + def __init__(self, outer_scope): + parent_scope = outer_scope + # TODO: also ignore class scopes? + while parent_scope.is_genexpr_scope: + parent_scope = parent_scope.parent_scope + name = parent_scope.global_scope().next_id(Naming.genexpr_id_ref) + Scope.__init__(self, name, outer_scope, parent_scope) + self.directives = outer_scope.directives + self.genexp_prefix = "%s%d%s" % (Naming.pyrex_prefix, len(name), name) + + # Class/ExtType scopes are filled at class creation time, i.e. from the + # module init function or surrounding function. + while outer_scope.is_genexpr_scope or outer_scope.is_c_class_scope or outer_scope.is_py_class_scope: + outer_scope = outer_scope.outer_scope + self.var_entries = outer_scope.var_entries # keep declarations outside + outer_scope.subscopes.add(self) + + def mangle(self, prefix, name): + return '%s%s' % (self.genexp_prefix, self.parent_scope.mangle(prefix, name)) + + def declare_var(self, name, type, pos, + cname = None, visibility = 'private', + api = 0, in_pxd = 0, is_cdef = True): + if type is unspecified_type: + # if the outer scope defines a type for this variable, inherit it + outer_entry = self.outer_scope.lookup(name) + if outer_entry and outer_entry.is_variable: + type = outer_entry.type # may still be 'unspecified_type' ! + # the parent scope needs to generate code for the variable, but + # this scope must hold its name exclusively + cname = '%s%s' % (self.genexp_prefix, self.parent_scope.mangle(Naming.var_prefix, name or self.next_id())) + entry = self.declare(name, cname, type, pos, visibility) + entry.is_variable = True + if self.parent_scope.is_module_scope: + entry.is_cglobal = True + else: + entry.is_local = True + entry.in_subscope = True + self.var_entries.append(entry) + self.entries[name] = entry + return entry + + def declare_pyfunction(self, name, pos, allow_redefine=False): + return self.outer_scope.declare_pyfunction( + name, pos, allow_redefine) + + def declare_lambda_function(self, func_cname, pos): + return self.outer_scope.declare_lambda_function(func_cname, pos) + + def add_lambda_def(self, def_node): + return self.outer_scope.add_lambda_def(def_node) + + +class ClosureScope(LocalScope): + + is_closure_scope = True + + def __init__(self, name, scope_name, outer_scope, parent_scope=None): + LocalScope.__init__(self, name, outer_scope, parent_scope) + self.closure_cname = "%s%s" % (Naming.closure_scope_prefix, scope_name) + +# def mangle_closure_cnames(self, scope_var): +# for entry in self.entries.values() + self.temp_entries: +# entry.in_closure = 1 +# LocalScope.mangle_closure_cnames(self, scope_var) + +# def mangle(self, prefix, name): +# return "%s->%s" % (self.cur_scope_cname, name) +# return "%s->%s" % (self.closure_cname, name) + + def declare_pyfunction(self, name, pos, allow_redefine=False): + return LocalScope.declare_pyfunction(self, name, pos, allow_redefine, visibility='private') + + +class StructOrUnionScope(Scope): + # Namespace of a C struct or union. + + def __init__(self, name="?"): + Scope.__init__(self, name, None, None) + + def declare_var(self, name, type, pos, + cname = None, visibility = 'private', + api = 0, in_pxd = 0, is_cdef = 0, + allow_pyobject=False, allow_memoryview=False): + # Add an entry for an attribute. + if not cname: + cname = name + if visibility == 'private': + cname = c_safe_identifier(cname) + if type.is_cfunction: + type = PyrexTypes.CPtrType(type) + entry = self.declare(name, cname, type, pos, visibility) + entry.is_variable = 1 + self.var_entries.append(entry) + if type.is_pyobject and not allow_pyobject: + error(pos, "C struct/union member cannot be a Python object") + elif type.is_memoryviewslice and not allow_memoryview: + # Memory views wrap their buffer owner as a Python object. + error(pos, "C struct/union member cannot be a memory view") + if visibility != 'private': + error(pos, "C struct/union member cannot be declared %s" % visibility) + return entry + + def declare_cfunction(self, name, type, pos, + cname=None, visibility='private', api=0, in_pxd=0, + defining=0, modifiers=(), overridable=False): # currently no utility code ... + if overridable: + error(pos, "C struct/union member cannot be declared 'cpdef'") + return self.declare_var(name, type, pos, + cname=cname, visibility=visibility) + + +class ClassScope(Scope): + # Abstract base class for namespace of + # Python class or extension type. + # + # class_name string Python name of the class + # scope_prefix string Additional prefix for names + # declared in the class + # doc string or None Doc string + + def __init__(self, name, outer_scope): + Scope.__init__(self, name, outer_scope, outer_scope) + self.class_name = name + self.doc = None + + def lookup(self, name): + entry = Scope.lookup(self, name) + if entry: + return entry + if name == "classmethod": + # We don't want to use the builtin classmethod here 'cause it won't do the + # right thing in this scope (as the class members aren't still functions). + # Don't want to add a cfunction to this scope 'cause that would mess with + # the type definition, so we just return the right entry. + entry = Entry( + "classmethod", + "__Pyx_Method_ClassMethod", + PyrexTypes.CFuncType( + py_object_type, + [PyrexTypes.CFuncTypeArg("", py_object_type, None)], 0, 0)) + entry.utility_code_definition = Code.UtilityCode.load_cached("ClassMethod", "CythonFunction.c") + self.use_entry_utility_code(entry) + entry.is_cfunction = 1 + return entry + + +class PyClassScope(ClassScope): + # Namespace of a Python class. + # + # class_obj_cname string C variable holding class object + + is_py_class_scope = 1 + + def mangle_class_private_name(self, name): + return self.mangle_special_name(name) + + def mangle_special_name(self, name): + if name and name.startswith('__') and not name.endswith('__'): + name = EncodedString('_%s%s' % (self.class_name.lstrip('_'), name)) + return name + + def lookup_here(self, name): + name = self.mangle_special_name(name) + return ClassScope.lookup_here(self, name) + + def declare_var(self, name, type, pos, + cname = None, visibility = 'private', + api = 0, in_pxd = 0, is_cdef = 0): + name = self.mangle_special_name(name) + if type is unspecified_type: + type = py_object_type + # Add an entry for a class attribute. + entry = Scope.declare_var(self, name, type, pos, + cname=cname, visibility=visibility, + api=api, in_pxd=in_pxd, is_cdef=is_cdef) + entry.is_pyglobal = 1 + entry.is_pyclass_attr = 1 + return entry + + def declare_nonlocal(self, name, pos): + # Pull entry from outer scope into local scope + orig_entry = self.lookup_here(name) + if orig_entry and orig_entry.scope is self and not orig_entry.from_closure: + error(pos, "'%s' redeclared as nonlocal" % name) + orig_entry.already_declared_here() + else: + entry = self.lookup(name) + if entry is None: + error(pos, "no binding for nonlocal '%s' found" % name) + else: + # FIXME: this works, but it's unclear if it's the + # right thing to do + self.entries[name] = entry + + def declare_global(self, name, pos): + # Pull entry from global scope into local scope. + if self.lookup_here(name): + warning(pos, "'%s' redeclared ", 0) + else: + entry = self.global_scope().lookup_target(name) + self.entries[name] = entry + + def add_default_value(self, type): + return self.outer_scope.add_default_value(type) + + +class CClassScope(ClassScope): + # Namespace of an extension type. + # + # parent_type CClassType + # #typeobj_cname string or None + # #objstruct_cname string + # method_table_cname string + # getset_table_cname string + # has_pyobject_attrs boolean Any PyObject attributes? + # has_memoryview_attrs boolean Any memory view attributes? + # has_cpp_class_attrs boolean Any (non-pointer) C++ attributes? + # has_cyclic_pyobject_attrs boolean Any PyObject attributes that may need GC? + # property_entries [Entry] + # defined boolean Defined in .pxd file + # implemented boolean Defined in .pyx file + # inherited_var_entries [Entry] Adapted var entries from base class + + is_c_class_scope = 1 + is_closure_class_scope = False + + has_pyobject_attrs = False + has_memoryview_attrs = False + has_cpp_class_attrs = False + has_cyclic_pyobject_attrs = False + defined = False + implemented = False + + def __init__(self, name, outer_scope, visibility): + ClassScope.__init__(self, name, outer_scope) + if visibility != 'extern': + self.method_table_cname = outer_scope.mangle(Naming.methtab_prefix, name) + self.getset_table_cname = outer_scope.mangle(Naming.gstab_prefix, name) + self.property_entries = [] + self.inherited_var_entries = [] + + def needs_gc(self): + # If the type or any of its base types have Python-valued + # C attributes, then it needs to participate in GC. + if self.has_cyclic_pyobject_attrs and not self.directives.get('no_gc', False): + return True + base_type = self.parent_type.base_type + if base_type and base_type.scope is not None: + return base_type.scope.needs_gc() + elif self.parent_type.is_builtin_type: + return not self.parent_type.is_gc_simple + return False + + def needs_tp_clear(self): + """ + Do we need to generate an implementation for the tp_clear slot? Can + be disabled to keep references for the __dealloc__ cleanup function. + """ + return self.needs_gc() and not self.directives.get('no_gc_clear', False) + + def get_refcounted_entries(self, include_weakref=False, + include_gc_simple=True): + py_attrs = [] + py_buffers = [] + memoryview_slices = [] + + for entry in self.var_entries: + if entry.type.is_pyobject: + if include_weakref or (self.is_closure_class_scope or entry.name != "__weakref__"): + if include_gc_simple or not entry.type.is_gc_simple: + py_attrs.append(entry) + elif entry.type == PyrexTypes.c_py_buffer_type: + py_buffers.append(entry) + elif entry.type.is_memoryviewslice: + memoryview_slices.append(entry) + + have_entries = py_attrs or py_buffers or memoryview_slices + return have_entries, (py_attrs, py_buffers, memoryview_slices) + + def declare_var(self, name, type, pos, + cname = None, visibility = 'private', + api = 0, in_pxd = 0, is_cdef = 0): + if is_cdef: + # Add an entry for an attribute. + if self.defined: + error(pos, + "C attributes cannot be added in implementation part of" + " extension type defined in a pxd") + if not self.is_closure_class_scope and get_special_method_signature(name): + error(pos, + "The name '%s' is reserved for a special method." + % name) + if not cname: + cname = name + if visibility == 'private': + cname = c_safe_identifier(cname) + if type.is_cpp_class and visibility != 'extern': + type.check_nullary_constructor(pos) + self.use_utility_code(Code.UtilityCode("#include <new>")) + entry = self.declare(name, cname, type, pos, visibility) + entry.is_variable = 1 + self.var_entries.append(entry) + if type.is_memoryviewslice: + self.has_memoryview_attrs = True + elif type.is_cpp_class: + self.has_cpp_class_attrs = True + elif type.is_pyobject and (self.is_closure_class_scope or name != '__weakref__'): + self.has_pyobject_attrs = True + if (not type.is_builtin_type + or not type.scope or type.scope.needs_gc()): + self.has_cyclic_pyobject_attrs = True + if visibility not in ('private', 'public', 'readonly'): + error(pos, + "Attribute of extension type cannot be declared %s" % visibility) + if visibility in ('public', 'readonly'): + # If the field is an external typedef, we cannot be sure about the type, + # so do conversion ourself rather than rely on the CPython mechanism (through + # a property; made in AnalyseDeclarationsTransform). + entry.needs_property = True + if not self.is_closure_class_scope and name == "__weakref__": + error(pos, "Special attribute __weakref__ cannot be exposed to Python") + if not (type.is_pyobject or type.can_coerce_to_pyobject(self)): + # we're not testing for coercion *from* Python here - that would fail later + error(pos, "C attribute of type '%s' cannot be accessed from Python" % type) + else: + entry.needs_property = False + return entry + else: + if type is unspecified_type: + type = py_object_type + # Add an entry for a class attribute. + entry = Scope.declare_var(self, name, type, pos, + cname=cname, visibility=visibility, + api=api, in_pxd=in_pxd, is_cdef=is_cdef) + entry.is_member = 1 + entry.is_pyglobal = 1 # xxx: is_pyglobal changes behaviour in so many places that + # I keep it in for now. is_member should be enough + # later on + self.namespace_cname = "(PyObject *)%s" % self.parent_type.typeptr_cname + return entry + + def declare_pyfunction(self, name, pos, allow_redefine=False): + # Add an entry for a method. + if name in richcmp_special_methods: + if self.lookup_here('__richcmp__'): + error(pos, "Cannot define both % and __richcmp__" % name) + elif name == '__richcmp__': + for n in richcmp_special_methods: + if self.lookup_here(n): + error(pos, "Cannot define both % and __richcmp__" % n) + if name == "__new__": + error(pos, "__new__ method of extension type will change semantics " + "in a future version of Pyrex and Cython. Use __cinit__ instead.") + entry = self.declare_var(name, py_object_type, pos, + visibility='extern') + special_sig = get_special_method_signature(name) + if special_sig: + # Special methods get put in the method table with a particular + # signature declared in advance. + entry.signature = special_sig + entry.is_special = 1 + else: + entry.signature = pymethod_signature + entry.is_special = 0 + + self.pyfunc_entries.append(entry) + return entry + + def lookup_here(self, name): + if not self.is_closure_class_scope and name == "__new__": + name = EncodedString("__cinit__") + entry = ClassScope.lookup_here(self, name) + if entry and entry.is_builtin_cmethod: + if not self.parent_type.is_builtin_type: + # For subtypes of builtin types, we can only return + # optimised C methods if the type if final. + # Otherwise, subtypes may choose to override the + # method, but the optimisation would prevent the + # subtype method from being called. + if not self.parent_type.is_final_type: + return None + return entry + + def declare_cfunction(self, name, type, pos, + cname=None, visibility='private', api=0, in_pxd=0, + defining=0, modifiers=(), utility_code=None, overridable=False): + if get_special_method_signature(name) and not self.parent_type.is_builtin_type: + error(pos, "Special methods must be declared with 'def', not 'cdef'") + args = type.args + if not type.is_static_method: + if not args: + error(pos, "C method has no self argument") + elif not self.parent_type.assignable_from(args[0].type): + error(pos, "Self argument (%s) of C method '%s' does not match parent type (%s)" % + (args[0].type, name, self.parent_type)) + entry = self.lookup_here(name) + if cname is None: + cname = c_safe_identifier(name) + if entry: + if not entry.is_cfunction: + warning(pos, "'%s' redeclared " % name, 0) + else: + if defining and entry.func_cname: + error(pos, "'%s' already defined" % name) + #print "CClassScope.declare_cfunction: checking signature" ### + if entry.is_final_cmethod and entry.is_inherited: + error(pos, "Overriding final methods is not allowed") + elif type.same_c_signature_as(entry.type, as_cmethod = 1) and type.nogil == entry.type.nogil: + # Fix with_gil vs nogil. + entry.type = entry.type.with_with_gil(type.with_gil) + elif type.compatible_signature_with(entry.type, as_cmethod = 1) and type.nogil == entry.type.nogil: + if (self.defined and not in_pxd + and not type.same_c_signature_as_resolved_type(entry.type, as_cmethod = 1, as_pxd_definition = 1)): + # TODO(robertwb): Make this an error. + warning(pos, + "Compatible but non-identical C method '%s' not redeclared " + "in definition part of extension type '%s'. " + "This may cause incorrect vtables to be generated." % ( + name, self.class_name), 2) + warning(entry.pos, "Previous declaration is here", 2) + entry = self.add_cfunction(name, type, pos, cname, visibility='ignore', modifiers=modifiers) + else: + error(pos, "Signature not compatible with previous declaration") + error(entry.pos, "Previous declaration is here") + else: + if self.defined: + error(pos, + "C method '%s' not previously declared in definition part of" + " extension type '%s'" % (name, self.class_name)) + entry = self.add_cfunction(name, type, pos, cname, visibility, modifiers) + if defining: + entry.func_cname = self.mangle(Naming.func_prefix, name) + entry.utility_code = utility_code + type.entry = entry + + if u'inline' in modifiers: + entry.is_inline_cmethod = True + + if (self.parent_type.is_final_type or entry.is_inline_cmethod or + self.directives.get('final')): + entry.is_final_cmethod = True + entry.final_func_cname = entry.func_cname + + return entry + + def add_cfunction(self, name, type, pos, cname, visibility, modifiers, inherited=False): + # Add a cfunction entry without giving it a func_cname. + prev_entry = self.lookup_here(name) + entry = ClassScope.add_cfunction(self, name, type, pos, cname, + visibility, modifiers, inherited=inherited) + entry.is_cmethod = 1 + entry.prev_entry = prev_entry + return entry + + def declare_builtin_cfunction(self, name, type, cname, utility_code = None): + # overridden methods of builtin types still have their Python + # equivalent that must be accessible to support bound methods + name = EncodedString(name) + entry = self.declare_cfunction(name, type, None, cname, visibility='extern', + utility_code=utility_code) + var_entry = Entry(name, name, py_object_type) + var_entry.qualified_name = name + var_entry.is_variable = 1 + var_entry.is_builtin = 1 + var_entry.utility_code = utility_code + var_entry.scope = entry.scope + entry.as_variable = var_entry + return entry + + def declare_property(self, name, doc, pos): + entry = self.lookup_here(name) + if entry is None: + entry = self.declare(name, name, py_object_type, pos, 'private') + entry.is_property = 1 + entry.doc = doc + entry.scope = PropertyScope(name, + outer_scope = self.global_scope(), parent_scope = self) + entry.scope.parent_type = self.parent_type + self.property_entries.append(entry) + return entry + + def declare_inherited_c_attributes(self, base_scope): + # Declare entries for all the C attributes of an + # inherited type, with cnames modified appropriately + # to work with this type. + def adapt(cname): + return "%s.%s" % (Naming.obj_base_cname, base_entry.cname) + + entries = base_scope.inherited_var_entries + base_scope.var_entries + for base_entry in entries: + entry = self.declare( + base_entry.name, adapt(base_entry.cname), + base_entry.type, None, 'private') + entry.is_variable = 1 + self.inherited_var_entries.append(entry) + + # If the class defined in a pxd, specific entries have not been added. + # Ensure now that the parent (base) scope has specific entries + # Iterate over a copy as get_all_specialized_function_types() will mutate + for base_entry in base_scope.cfunc_entries[:]: + if base_entry.type.is_fused: + base_entry.type.get_all_specialized_function_types() + + for base_entry in base_scope.cfunc_entries: + cname = base_entry.cname + var_entry = base_entry.as_variable + is_builtin = var_entry and var_entry.is_builtin + if not is_builtin: + cname = adapt(cname) + entry = self.add_cfunction(base_entry.name, base_entry.type, + base_entry.pos, cname, + base_entry.visibility, base_entry.func_modifiers, inherited=True) + entry.is_inherited = 1 + if base_entry.is_final_cmethod: + entry.is_final_cmethod = True + entry.is_inline_cmethod = base_entry.is_inline_cmethod + if (self.parent_scope == base_scope.parent_scope or + entry.is_inline_cmethod): + entry.final_func_cname = base_entry.final_func_cname + if is_builtin: + entry.is_builtin_cmethod = True + entry.as_variable = var_entry + if base_entry.utility_code: + entry.utility_code = base_entry.utility_code + + +class CppClassScope(Scope): + # Namespace of a C++ class. + + is_cpp_class_scope = 1 + + default_constructor = None + type = None + + def __init__(self, name, outer_scope, templates=None): + Scope.__init__(self, name, outer_scope, None) + self.directives = outer_scope.directives + self.inherited_var_entries = [] + if templates is not None: + for T in templates: + template_entry = self.declare( + T, T, PyrexTypes.TemplatePlaceholderType(T), None, 'extern') + template_entry.is_type = 1 + + def declare_var(self, name, type, pos, + cname = None, visibility = 'extern', + api = 0, in_pxd = 0, is_cdef = 0, defining = 0): + # Add an entry for an attribute. + if not cname: + cname = name + entry = self.lookup_here(name) + if defining and entry is not None: + if entry.type.same_as(type): + # Fix with_gil vs nogil. + entry.type = entry.type.with_with_gil(type.with_gil) + elif type.is_cfunction and type.compatible_signature_with(entry.type): + entry.type = type + else: + error(pos, "Function signature does not match previous declaration") + else: + entry = self.declare(name, cname, type, pos, visibility) + entry.is_variable = 1 + if type.is_cfunction and self.type: + if not self.type.get_fused_types(): + entry.func_cname = "%s::%s" % (self.type.empty_declaration_code(), cname) + if name != "this" and (defining or name != "<init>"): + self.var_entries.append(entry) + return entry + + def declare_cfunction(self, name, type, pos, + cname=None, visibility='extern', api=0, in_pxd=0, + defining=0, modifiers=(), utility_code=None, overridable=False): + class_name = self.name.split('::')[-1] + if name in (class_name, '__init__') and cname is None: + cname = "%s__init__%s" % (Naming.func_prefix, class_name) + name = '<init>' + type.return_type = PyrexTypes.CVoidType() + # This is called by the actual constructor, but need to support + # arguments that cannot by called by value. + type.original_args = type.args + def maybe_ref(arg): + if arg.type.is_cpp_class and not arg.type.is_reference: + return PyrexTypes.CFuncTypeArg( + arg.name, PyrexTypes.c_ref_type(arg.type), arg.pos) + else: + return arg + type.args = [maybe_ref(arg) for arg in type.args] + elif name == '__dealloc__' and cname is None: + cname = "%s__dealloc__%s" % (Naming.func_prefix, class_name) + name = '<del>' + type.return_type = PyrexTypes.CVoidType() + if name in ('<init>', '<del>') and type.nogil: + for base in self.type.base_classes: + base_entry = base.scope.lookup(name) + if base_entry and not base_entry.type.nogil: + error(pos, "Constructor cannot be called without GIL unless all base constructors can also be called without GIL") + error(base_entry.pos, "Base constructor defined here.") + prev_entry = self.lookup_here(name) + entry = self.declare_var(name, type, pos, + defining=defining, + cname=cname, visibility=visibility) + if prev_entry and not defining: + entry.overloaded_alternatives = prev_entry.all_alternatives() + entry.utility_code = utility_code + type.entry = entry + return entry + + def declare_inherited_cpp_attributes(self, base_class): + base_scope = base_class.scope + template_type = base_class + while getattr(template_type, 'template_type', None): + template_type = template_type.template_type + if getattr(template_type, 'templates', None): + base_templates = [T.name for T in template_type.templates] + else: + base_templates = () + # Declare entries for all the C++ attributes of an + # inherited type, with cnames modified appropriately + # to work with this type. + for base_entry in \ + base_scope.inherited_var_entries + base_scope.var_entries: + #constructor/destructor is not inherited + if base_entry.name in ("<init>", "<del>"): + continue + #print base_entry.name, self.entries + if base_entry.name in self.entries: + base_entry.name # FIXME: is there anything to do in this case? + entry = self.declare(base_entry.name, base_entry.cname, + base_entry.type, None, 'extern') + entry.is_variable = 1 + entry.is_inherited = 1 + self.inherited_var_entries.append(entry) + for base_entry in base_scope.cfunc_entries: + entry = self.declare_cfunction(base_entry.name, base_entry.type, + base_entry.pos, base_entry.cname, + base_entry.visibility, api=0, + modifiers=base_entry.func_modifiers, + utility_code=base_entry.utility_code) + entry.is_inherited = 1 + for base_entry in base_scope.type_entries: + if base_entry.name not in base_templates: + entry = self.declare_type(base_entry.name, base_entry.type, + base_entry.pos, base_entry.cname, + base_entry.visibility) + entry.is_inherited = 1 + + def specialize(self, values, type_entry): + scope = CppClassScope(self.name, self.outer_scope) + scope.type = type_entry + for entry in self.entries.values(): + if entry.is_type: + scope.declare_type(entry.name, + entry.type.specialize(values), + entry.pos, + entry.cname, + template=1) + elif entry.type.is_cfunction: + for e in entry.all_alternatives(): + scope.declare_cfunction(e.name, + e.type.specialize(values), + e.pos, + e.cname, + utility_code=e.utility_code) + else: + scope.declare_var(entry.name, + entry.type.specialize(values), + entry.pos, + entry.cname, + entry.visibility) + + return scope + + +class PropertyScope(Scope): + # Scope holding the __get__, __set__ and __del__ methods for + # a property of an extension type. + # + # parent_type PyExtensionType The type to which the property belongs + + is_property_scope = 1 + + def declare_pyfunction(self, name, pos, allow_redefine=False): + # Add an entry for a method. + signature = get_property_accessor_signature(name) + if signature: + entry = self.declare(name, name, py_object_type, pos, 'private') + entry.is_special = 1 + entry.signature = signature + return entry + else: + error(pos, "Only __get__, __set__ and __del__ methods allowed " + "in a property declaration") + return None + + +class CConstScope(Scope): + + def __init__(self, const_base_type_scope): + Scope.__init__( + self, + 'const_' + const_base_type_scope.name, + const_base_type_scope.outer_scope, + const_base_type_scope.parent_scope) + self.const_base_type_scope = const_base_type_scope + + def lookup_here(self, name): + entry = self.const_base_type_scope.lookup_here(name) + if entry is not None: + entry = copy.copy(entry) + entry.type = PyrexTypes.c_const_type(entry.type) + return entry + +class TemplateScope(Scope): + def __init__(self, name, outer_scope): + Scope.__init__(self, name, outer_scope, None) + self.directives = outer_scope.directives diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestBuffer.py b/contrib/tools/cython/Cython/Compiler/Tests/TestBuffer.py new file mode 100644 index 00000000000..1f69d96524d --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestBuffer.py @@ -0,0 +1,105 @@ +from Cython.TestUtils import CythonTest +import Cython.Compiler.Errors as Errors +from Cython.Compiler.Nodes import * +from Cython.Compiler.ParseTreeTransforms import * +from Cython.Compiler.Buffer import * + + +class TestBufferParsing(CythonTest): + # First, we only test the raw parser, i.e. + # the number and contents of arguments are NOT checked. + # However "dtype"/the first positional argument is special-cased + # to parse a type argument rather than an expression + + def parse(self, s): + return self.should_not_fail(lambda: self.fragment(s)).root + + def not_parseable(self, expected_error, s): + e = self.should_fail(lambda: self.fragment(s), Errors.CompileError) + self.assertEqual(expected_error, e.message_only) + + def test_basic(self): + t = self.parse(u"cdef object[float, 4, ndim=2, foo=foo] x") + bufnode = t.stats[0].base_type + self.assertTrue(isinstance(bufnode, TemplatedTypeNode)) + self.assertEqual(2, len(bufnode.positional_args)) +# print bufnode.dump() + # should put more here... + + def test_type_pos(self): + self.parse(u"cdef object[short unsigned int, 3] x") + + def test_type_keyword(self): + self.parse(u"cdef object[foo=foo, dtype=short unsigned int] x") + + def test_pos_after_key(self): + self.not_parseable("Non-keyword arg following keyword arg", + u"cdef object[foo=1, 2] x") + + +# See also tests/error/e_bufaccess.pyx and tets/run/bufaccess.pyx +# THESE TESTS ARE NOW DISABLED, the code they test was pretty much +# refactored away +class TestBufferOptions(CythonTest): + # Tests the full parsing of the options within the brackets + + def nonfatal_error(self, error): + # We're passing self as context to transform to trap this + self.error = error + self.assertTrue(self.expect_error) + + def parse_opts(self, opts, expect_error=False): + assert opts != "" + s = u"def f():\n cdef object[%s] x" % opts + self.expect_error = expect_error + root = self.fragment(s, pipeline=[NormalizeTree(self), PostParse(self)]).root + if not expect_error: + vardef = root.stats[0].body.stats[0] + assert isinstance(vardef, CVarDefNode) # use normal assert as this is to validate the test code + buftype = vardef.base_type + self.assertTrue(isinstance(buftype, TemplatedTypeNode)) + self.assertTrue(isinstance(buftype.base_type_node, CSimpleBaseTypeNode)) + self.assertEqual(u"object", buftype.base_type_node.name) + return buftype + else: + self.assertTrue(len(root.stats[0].body.stats) == 0) + + def non_parse(self, expected_err, opts): + self.parse_opts(opts, expect_error=True) +# e = self.should_fail(lambda: self.parse_opts(opts)) + self.assertEqual(expected_err, self.error.message_only) + + def __test_basic(self): + buf = self.parse_opts(u"unsigned short int, 3") + self.assertTrue(isinstance(buf.dtype_node, CSimpleBaseTypeNode)) + self.assertTrue(buf.dtype_node.signed == 0 and buf.dtype_node.longness == -1) + self.assertEqual(3, buf.ndim) + + def __test_dict(self): + buf = self.parse_opts(u"ndim=3, dtype=unsigned short int") + self.assertTrue(isinstance(buf.dtype_node, CSimpleBaseTypeNode)) + self.assertTrue(buf.dtype_node.signed == 0 and buf.dtype_node.longness == -1) + self.assertEqual(3, buf.ndim) + + def __test_ndim(self): + self.parse_opts(u"int, 2") + self.non_parse(ERR_BUF_NDIM, u"int, 'a'") + self.non_parse(ERR_BUF_NDIM, u"int, -34") + + def __test_use_DEF(self): + t = self.fragment(u""" + DEF ndim = 3 + def f(): + cdef object[int, ndim] x + cdef object[ndim=ndim, dtype=int] y + """, pipeline=[NormalizeTree(self), PostParse(self)]).root + stats = t.stats[0].body.stats + self.assertTrue(stats[0].base_type.ndim == 3) + self.assertTrue(stats[1].base_type.ndim == 3) + + # add exotic and impossible combinations as they come along... + +if __name__ == '__main__': + import unittest + unittest.main() + diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py b/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py new file mode 100644 index 00000000000..bd31da00076 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py @@ -0,0 +1,170 @@ + +import sys +import re +from unittest import TestCase +try: + from StringIO import StringIO +except ImportError: + from io import StringIO # doesn't accept 'str' in Py2 + +from .. import Options +from ..CmdLine import parse_command_line + + +def check_global_options(expected_options, white_list=[]): + """ + returns error message of "" if check Ok + """ + no_value = object() + for name, orig_value in expected_options.items(): + if name not in white_list: + if getattr(Options, name, no_value) != orig_value: + return "error in option " + name + return "" + + +class CmdLineParserTest(TestCase): + def setUp(self): + backup = {} + for name, value in vars(Options).items(): + backup[name] = value + self._options_backup = backup + + def tearDown(self): + no_value = object() + for name, orig_value in self._options_backup.items(): + if getattr(Options, name, no_value) != orig_value: + setattr(Options, name, orig_value) + + def check_default_global_options(self, white_list=[]): + self.assertEqual(check_global_options(self._options_backup, white_list), "") + + def check_default_options(self, options, white_list=[]): + from ..Main import CompilationOptions, default_options + default_options = CompilationOptions(default_options) + no_value = object() + for name in default_options.__dict__.keys(): + if name not in white_list: + self.assertEqual(getattr(options, name, no_value), getattr(default_options, name), msg="error in option " + name) + + def test_short_options(self): + options, sources = parse_command_line([ + '-V', '-l', '-+', '-t', '-v', '-v', '-v', '-p', '-D', '-a', '-3', + ]) + self.assertFalse(sources) + self.assertTrue(options.show_version) + self.assertTrue(options.use_listing_file) + self.assertTrue(options.cplus) + self.assertTrue(options.timestamps) + self.assertTrue(options.verbose >= 3) + self.assertTrue(Options.embed_pos_in_docstring) + self.assertFalse(Options.docstrings) + self.assertTrue(Options.annotate) + self.assertEqual(options.language_level, 3) + + options, sources = parse_command_line([ + '-f', '-2', 'source.pyx', + ]) + self.assertTrue(sources) + self.assertTrue(len(sources) == 1) + self.assertFalse(options.timestamps) + self.assertEqual(options.language_level, 2) + + def test_long_options(self): + options, sources = parse_command_line([ + '--version', '--create-listing', '--cplus', '--embed', '--timestamps', + '--verbose', '--verbose', '--verbose', + '--embed-positions', '--no-docstrings', '--annotate', '--lenient', + ]) + self.assertFalse(sources) + self.assertTrue(options.show_version) + self.assertTrue(options.use_listing_file) + self.assertTrue(options.cplus) + self.assertEqual(Options.embed, 'main') + self.assertTrue(options.timestamps) + self.assertTrue(options.verbose >= 3) + self.assertTrue(Options.embed_pos_in_docstring) + self.assertFalse(Options.docstrings) + self.assertTrue(Options.annotate) + self.assertFalse(Options.error_on_unknown_names) + self.assertFalse(Options.error_on_uninitialized) + + options, sources = parse_command_line([ + '--force', 'source.pyx', + ]) + self.assertTrue(sources) + self.assertTrue(len(sources) == 1) + self.assertFalse(options.timestamps) + + def test_options_with_values(self): + options, sources = parse_command_line([ + '--embed=huhu', + '-I/test/include/dir1', '--include-dir=/test/include/dir2', + '--include-dir', '/test/include/dir3', + '--working=/work/dir', + 'source.pyx', + '--output-file=/output/dir', + '--pre-import=/pre/import', + '--cleanup=3', + '--annotate-coverage=cov.xml', + '--gdb-outdir=/gdb/outdir', + '--directive=wraparound=false', + ]) + self.assertEqual(sources, ['source.pyx']) + self.assertEqual(Options.embed, 'huhu') + self.assertEqual(options.include_path, ['/test/include/dir1', '/test/include/dir2', '/test/include/dir3']) + self.assertEqual(options.working_path, '/work/dir') + self.assertEqual(options.output_file, '/output/dir') + self.assertEqual(Options.pre_import, '/pre/import') + self.assertEqual(Options.generate_cleanup_code, 3) + self.assertTrue(Options.annotate) + self.assertEqual(Options.annotate_coverage_xml, 'cov.xml') + self.assertTrue(options.gdb_debug) + self.assertEqual(options.output_dir, '/gdb/outdir') + + def test_module_name(self): + options, sources = parse_command_line([ + 'source.pyx' + ]) + self.assertEqual(options.module_name, None) + self.check_default_global_options() + self.check_default_options(options) + options, sources = parse_command_line([ + '--module-name', 'foo.bar', + 'source.pyx' + ]) + self.assertEqual(options.module_name, 'foo.bar') + self.check_default_global_options() + self.check_default_options(options, ['module_name']) + + def test_errors(self): + def error(args, regex=None): + old_stderr = sys.stderr + stderr = sys.stderr = StringIO() + try: + self.assertRaises(SystemExit, parse_command_line, list(args)) + finally: + sys.stderr = old_stderr + msg = stderr.getvalue().strip() + self.assertTrue(msg) + if regex: + self.assertTrue(re.search(regex, msg), + '"%s" does not match search "%s"' % + (msg, regex)) + + error(['-1'], + 'Unknown compiler flag: -1') + error(['-I']) + error(['--version=-a']) + error(['--version=--annotate=true']) + error(['--working']) + error(['--verbose=1']) + error(['--cleanup']) + error(['--debug-disposal-code-wrong-name', 'file3.pyx'], + "Unknown debug flag: debug_disposal_code_wrong_name") + error(['--module-name', 'foo.pyx']) + error(['--module-name', 'foo.bar']) + error(['--module-name', 'foo.bar', 'foo.pyx', 'bar.pyx'], + "Only one source file allowed when using --module-name") + error(['--module-name', 'foo.bar', '--timestamps', 'foo.pyx'], + "Cannot use --module-name with --timestamps") diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py b/contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py new file mode 100644 index 00000000000..443551ab88c --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py @@ -0,0 +1,68 @@ + +from __future__ import absolute_import + +from copy import deepcopy +from unittest import TestCase + +from Cython.Compiler.FlowControl import ( + NameAssignment, StaticAssignment, Argument, NameDeletion) + + +class FakeType(object): + is_pyobject = True + + +class FakeNode(object): + pos = ('filename.pyx', 1, 2) + cf_state = None + type = FakeType() + + def infer_type(self, scope): + return self.type + + +class FakeEntry(object): + type = FakeType() + + +class TestGraph(TestCase): + def test_deepcopy(self): + lhs, rhs = FakeNode(), FakeNode() + entry = FakeEntry() + entry.pos = lhs.pos + + name_ass = NameAssignment(lhs, rhs, entry) + ass = deepcopy(name_ass) + self.assertTrue(ass.lhs) + self.assertTrue(ass.rhs) + self.assertTrue(ass.entry) + self.assertEqual(ass.pos, name_ass.pos) + self.assertFalse(ass.is_arg) + self.assertFalse(ass.is_deletion) + + static_ass = StaticAssignment(entry) + ass = deepcopy(static_ass) + self.assertTrue(ass.lhs) + self.assertTrue(ass.rhs) + self.assertTrue(ass.entry) + self.assertEqual(ass.pos, static_ass.pos) + self.assertFalse(ass.is_arg) + self.assertFalse(ass.is_deletion) + + arg_ass = Argument(lhs, rhs, entry) + ass = deepcopy(arg_ass) + self.assertTrue(ass.lhs) + self.assertTrue(ass.rhs) + self.assertTrue(ass.entry) + self.assertEqual(ass.pos, arg_ass.pos) + self.assertTrue(ass.is_arg) + self.assertFalse(ass.is_deletion) + + name_del = NameDeletion(lhs, entry) + ass = deepcopy(name_del) + self.assertTrue(ass.lhs) + self.assertTrue(ass.rhs) + self.assertTrue(ass.entry) + self.assertEqual(ass.pos, name_del.pos) + self.assertFalse(ass.is_arg) + self.assertTrue(ass.is_deletion) diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestGrammar.py b/contrib/tools/cython/Cython/Compiler/Tests/TestGrammar.py new file mode 100644 index 00000000000..3dddc960b3a --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestGrammar.py @@ -0,0 +1,129 @@ +# mode: run +# tag: syntax + +""" +Uses TreeFragment to test invalid syntax. +""" + +from __future__ import absolute_import + +from ...TestUtils import CythonTest +from ..Errors import CompileError +from .. import ExprNodes + +# Copied from CPython's test_grammar.py +VALID_UNDERSCORE_LITERALS = [ + '0_0_0', + '4_2', + '1_0000_0000', + '0b1001_0100', + '0xffff_ffff', + '0o5_7_7', + '1_00_00.5', + '1_00_00.5j', + '1_00_00.5e5', + '1_00_00j', + '1_00_00e5_1', + '1e1_0', + '.1_4', + '.1_4e1', + '.1_4j', +] + +# Copied from CPython's test_grammar.py +INVALID_UNDERSCORE_LITERALS = [ + # Trailing underscores: + '0_', + '42_', + '1.4j_', + '0b1_', + '0xf_', + '0o5_', + # Underscores in the base selector: + '0_b0', + '0_xf', + '0_o5', + # Underscore right after the base selector: + '0b_0', + '0x_f', + '0o_5', + # Old-style octal, still disallowed: + #'0_7', + #'09_99', + # Special case with exponent: + '0 if 1_Else 1', + # Underscore right before a dot: + '1_.4', + '1_.4j', + # Underscore right after a dot: + '1._4', + '1._4j', + '._5', + # Underscore right after a sign: + '1.0e+_1', + # Multiple consecutive underscores: + '4_______2', + '0.1__4', + '0b1001__0100', + '0xffff__ffff', + '0o5__77', + '1e1__0', + # Underscore right before j: + '1.4_j', + '1.4e5_j', + # Underscore right before e: + '1_e1', + '1.4_e1', + # Underscore right after e: + '1e_1', + '1.4e_1', + # Whitespace in literals + '1_ 2', + '1 _2', + '1_2.2_ 1', + '1_2.2 _1', + '1_2e _1', + '1_2e2 _1', + '1_2e 2_1', +] + + +class TestGrammar(CythonTest): + + def test_invalid_number_literals(self): + for literal in INVALID_UNDERSCORE_LITERALS: + for expression in ['%s', '1 + %s', '%s + 1', '2 * %s', '%s * 2']: + code = 'x = ' + expression % literal + try: + self.fragment(u'''\ + # cython: language_level=3 + ''' + code) + except CompileError as exc: + assert code in [s.strip() for s in str(exc).splitlines()], str(exc) + else: + assert False, "Invalid Cython code '%s' failed to raise an exception" % code + + def test_valid_number_literals(self): + for literal in VALID_UNDERSCORE_LITERALS: + for i, expression in enumerate(['%s', '1 + %s', '%s + 1', '2 * %s', '%s * 2']): + code = 'x = ' + expression % literal + node = self.fragment(u'''\ + # cython: language_level=3 + ''' + code).root + assert node is not None + + literal_node = node.stats[0].rhs # StatListNode([SingleAssignmentNode('x', expr)]) + if i > 0: + # Add/MulNode() -> literal is first or second operand + literal_node = literal_node.operand2 if i % 2 else literal_node.operand1 + if 'j' in literal or 'J' in literal: + assert isinstance(literal_node, ExprNodes.ImagNode) + elif '.' in literal or 'e' in literal or 'E' in literal and not ('0x' in literal or '0X' in literal): + assert isinstance(literal_node, ExprNodes.FloatNode) + else: + assert isinstance(literal_node, ExprNodes.IntNode) + + +if __name__ == "__main__": + import unittest + unittest.main() diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py b/contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py new file mode 100644 index 00000000000..3792f26e994 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py @@ -0,0 +1,71 @@ +from Cython.TestUtils import CythonTest +import Cython.Compiler.Errors as Errors +from Cython.Compiler.Nodes import * +from Cython.Compiler.ParseTreeTransforms import * +from Cython.Compiler.Buffer import * + + +class TestMemviewParsing(CythonTest): + + def parse(self, s): + return self.should_not_fail(lambda: self.fragment(s)).root + + def not_parseable(self, expected_error, s): + e = self.should_fail(lambda: self.fragment(s), Errors.CompileError) + self.assertEqual(expected_error, e.message_only) + + def test_default_1dim(self): + self.parse(u"cdef int[:] x") + self.parse(u"cdef short int[:] x") + + def test_default_ndim(self): + self.parse(u"cdef int[:,:,:,:,:] x") + self.parse(u"cdef unsigned long int[:,:,:,:,:] x") + self.parse(u"cdef unsigned int[:,:,:,:,:] x") + + def test_zero_offset(self): + self.parse(u"cdef long double[0:] x") + self.parse(u"cdef int[0:] x") + + def test_zero_offset_ndim(self): + self.parse(u"cdef int[0:,0:,0:,0:] x") + + def test_def_arg(self): + self.parse(u"def foo(int[:,:] x): pass") + + def test_cdef_arg(self): + self.parse(u"cdef foo(int[:,:] x): pass") + + def test_general_slice(self): + self.parse(u'cdef float[::ptr, ::direct & contig, 0::full & strided] x') + + def test_non_slice_memview(self): + self.not_parseable(u"An axis specification in memoryview declaration does not have a ':'.", + u"cdef double[:foo, bar] x") + self.not_parseable(u"An axis specification in memoryview declaration does not have a ':'.", + u"cdef double[0:foo, bar] x") + + def test_basic(self): + t = self.parse(u"cdef int[:] x") + memv_node = t.stats[0].base_type + self.assertTrue(isinstance(memv_node, MemoryViewSliceTypeNode)) + + # we also test other similar declarations (buffers, anonymous C arrays) + # since the parsing has to distinguish between them. + + def disable_test_no_buf_arg(self): # TODO + self.not_parseable(u"Expected ']'", + u"cdef extern foo(object[int, ndim=2])") + + def disable_test_parse_sizeof(self): # TODO + self.parse(u"sizeof(int[NN])") + self.parse(u"sizeof(int[])") + self.parse(u"sizeof(int[][NN])") + self.not_parseable(u"Expected an identifier or literal", + u"sizeof(int[:NN])") + self.not_parseable(u"Expected ']'", + u"sizeof(foo[dtype=bar]") + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestParseTreeTransforms.py b/contrib/tools/cython/Cython/Compiler/Tests/TestParseTreeTransforms.py new file mode 100644 index 00000000000..8a16f98ccca --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestParseTreeTransforms.py @@ -0,0 +1,289 @@ +import os.path +import unittest + +from Cython.TestUtils import TransformTest +from Cython.Compiler.ParseTreeTransforms import * +from Cython.Compiler.ParseTreeTransforms import _calculate_pickle_checksums +from Cython.Compiler.Nodes import * +from Cython.Compiler import Main, Symtab + + +class TestNormalizeTree(TransformTest): + def test_parserbehaviour_is_what_we_coded_for(self): + t = self.fragment(u"if x: y").root + self.assertLines(u""" +(root): StatListNode + stats[0]: IfStatNode + if_clauses[0]: IfClauseNode + condition: NameNode + body: ExprStatNode + expr: NameNode +""", self.treetypes(t)) + + def test_wrap_singlestat(self): + t = self.run_pipeline([NormalizeTree(None)], u"if x: y") + self.assertLines(u""" +(root): StatListNode + stats[0]: IfStatNode + if_clauses[0]: IfClauseNode + condition: NameNode + body: StatListNode + stats[0]: ExprStatNode + expr: NameNode +""", self.treetypes(t)) + + def test_wrap_multistat(self): + t = self.run_pipeline([NormalizeTree(None)], u""" + if z: + x + y + """) + self.assertLines(u""" +(root): StatListNode + stats[0]: IfStatNode + if_clauses[0]: IfClauseNode + condition: NameNode + body: StatListNode + stats[0]: ExprStatNode + expr: NameNode + stats[1]: ExprStatNode + expr: NameNode +""", self.treetypes(t)) + + def test_statinexpr(self): + t = self.run_pipeline([NormalizeTree(None)], u""" + a, b = x, y + """) + self.assertLines(u""" +(root): StatListNode + stats[0]: SingleAssignmentNode + lhs: TupleNode + args[0]: NameNode + args[1]: NameNode + rhs: TupleNode + args[0]: NameNode + args[1]: NameNode +""", self.treetypes(t)) + + def test_wrap_offagain(self): + t = self.run_pipeline([NormalizeTree(None)], u""" + x + y + if z: + x + """) + self.assertLines(u""" +(root): StatListNode + stats[0]: ExprStatNode + expr: NameNode + stats[1]: ExprStatNode + expr: NameNode + stats[2]: IfStatNode + if_clauses[0]: IfClauseNode + condition: NameNode + body: StatListNode + stats[0]: ExprStatNode + expr: NameNode +""", self.treetypes(t)) + + + def test_pass_eliminated(self): + t = self.run_pipeline([NormalizeTree(None)], u"pass") + self.assertTrue(len(t.stats) == 0) + +class TestWithTransform(object): # (TransformTest): # Disabled! + + def test_simplified(self): + t = self.run_pipeline([WithTransform(None)], u""" + with x: + y = z ** 3 + """) + + self.assertCode(u""" + + $0_0 = x + $0_2 = $0_0.__exit__ + $0_0.__enter__() + $0_1 = True + try: + try: + $1_0 = None + y = z ** 3 + except: + $0_1 = False + if (not $0_2($1_0)): + raise + finally: + if $0_1: + $0_2(None, None, None) + + """, t) + + def test_basic(self): + t = self.run_pipeline([WithTransform(None)], u""" + with x as y: + y = z ** 3 + """) + self.assertCode(u""" + + $0_0 = x + $0_2 = $0_0.__exit__ + $0_3 = $0_0.__enter__() + $0_1 = True + try: + try: + $1_0 = None + y = $0_3 + y = z ** 3 + except: + $0_1 = False + if (not $0_2($1_0)): + raise + finally: + if $0_1: + $0_2(None, None, None) + + """, t) + + +class TestInterpretCompilerDirectives(TransformTest): + """ + This class tests the parallel directives AST-rewriting and importing. + """ + + # Test the parallel directives (c)importing + + import_code = u""" + cimport cython.parallel + cimport cython.parallel as par + from cython cimport parallel as par2 + from cython cimport parallel + + from cython.parallel cimport threadid as tid + from cython.parallel cimport threadavailable as tavail + from cython.parallel cimport prange + """ + + expected_directives_dict = { + u'cython.parallel': u'cython.parallel', + u'par': u'cython.parallel', + u'par2': u'cython.parallel', + u'parallel': u'cython.parallel', + + u"tid": u"cython.parallel.threadid", + u"tavail": u"cython.parallel.threadavailable", + u"prange": u"cython.parallel.prange", + } + + + def setUp(self): + super(TestInterpretCompilerDirectives, self).setUp() + + compilation_options = Main.CompilationOptions(Main.default_options) + ctx = compilation_options.create_context() + + transform = InterpretCompilerDirectives(ctx, ctx.compiler_directives) + transform.module_scope = Symtab.ModuleScope('__main__', None, ctx) + self.pipeline = [transform] + + self.debug_exception_on_error = DebugFlags.debug_exception_on_error + + def tearDown(self): + DebugFlags.debug_exception_on_error = self.debug_exception_on_error + + def test_parallel_directives_cimports(self): + self.run_pipeline(self.pipeline, self.import_code) + parallel_directives = self.pipeline[0].parallel_directives + self.assertEqual(parallel_directives, self.expected_directives_dict) + + def test_parallel_directives_imports(self): + self.run_pipeline(self.pipeline, + self.import_code.replace(u'cimport', u'import')) + parallel_directives = self.pipeline[0].parallel_directives + self.assertEqual(parallel_directives, self.expected_directives_dict) + + +# TODO: Re-enable once they're more robust. +if False: + from Cython.Debugger import DebugWriter + from Cython.Debugger.Tests.TestLibCython import DebuggerTestCase +else: + # skip test, don't let it inherit unittest.TestCase + DebuggerTestCase = object + + +class TestDebugTransform(DebuggerTestCase): + + def elem_hasattrs(self, elem, attrs): + return all(attr in elem.attrib for attr in attrs) + + def test_debug_info(self): + try: + assert os.path.exists(self.debug_dest) + + t = DebugWriter.etree.parse(self.debug_dest) + # the xpath of the standard ElementTree is primitive, don't use + # anything fancy + L = list(t.find('/Module/Globals')) + assert L + xml_globals = dict((e.attrib['name'], e.attrib['type']) for e in L) + self.assertEqual(len(L), len(xml_globals)) + + L = list(t.find('/Module/Functions')) + assert L + xml_funcs = dict((e.attrib['qualified_name'], e) for e in L) + self.assertEqual(len(L), len(xml_funcs)) + + # test globals + self.assertEqual('CObject', xml_globals.get('c_var')) + self.assertEqual('PythonObject', xml_globals.get('python_var')) + + # test functions + funcnames = ('codefile.spam', 'codefile.ham', 'codefile.eggs', + 'codefile.closure', 'codefile.inner') + required_xml_attrs = 'name', 'cname', 'qualified_name' + assert all(f in xml_funcs for f in funcnames) + spam, ham, eggs = [xml_funcs[funcname] for funcname in funcnames] + + self.assertEqual(spam.attrib['name'], 'spam') + self.assertNotEqual('spam', spam.attrib['cname']) + assert self.elem_hasattrs(spam, required_xml_attrs) + + # test locals of functions + spam_locals = list(spam.find('Locals')) + assert spam_locals + spam_locals.sort(key=lambda e: e.attrib['name']) + names = [e.attrib['name'] for e in spam_locals] + self.assertEqual(list('abcd'), names) + assert self.elem_hasattrs(spam_locals[0], required_xml_attrs) + + # test arguments of functions + spam_arguments = list(spam.find('Arguments')) + assert spam_arguments + self.assertEqual(1, len(list(spam_arguments))) + + # test step-into functions + step_into = spam.find('StepIntoFunctions') + spam_stepinto = [x.attrib['name'] for x in step_into] + assert spam_stepinto + self.assertEqual(2, len(spam_stepinto)) + assert 'puts' in spam_stepinto + assert 'some_c_function' in spam_stepinto + except: + f = open(self.debug_dest) + try: + print(f.read()) + finally: + f.close() + raise + + +class TestAnalyseDeclarationsTransform(unittest.TestCase): + def test_calculate_pickle_checksums(self): + checksums = _calculate_pickle_checksums(['member1', 'member2', 'member3']) + assert 2 <= len(checksums) <= 3, checksums # expecting ['0xc0af380' (MD5), '0x0c75bd4', '0xa7a7b94'] + + +if __name__ == "__main__": + import unittest + unittest.main() diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestSignatureMatching.py b/contrib/tools/cython/Cython/Compiler/Tests/TestSignatureMatching.py new file mode 100644 index 00000000000..166bb225b9b --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestSignatureMatching.py @@ -0,0 +1,73 @@ +import unittest + +from Cython.Compiler import PyrexTypes as pt +from Cython.Compiler.ExprNodes import NameNode +from Cython.Compiler.PyrexTypes import CFuncTypeArg + +def cfunctype(*arg_types): + return pt.CFuncType(pt.c_int_type, + [ CFuncTypeArg("name", arg_type, None) for arg_type in arg_types ]) + +def cppclasstype(name, base_classes): + return pt.CppClassType(name, None, 'CPP_'+name, base_classes) + +class SignatureMatcherTest(unittest.TestCase): + """ + Test the signature matching algorithm for overloaded signatures. + """ + def assertMatches(self, expected_type, arg_types, functions): + match = pt.best_match(arg_types, functions) + if expected_type is not None: + self.assertNotEqual(None, match) + self.assertEqual(expected_type, match.type) + + def test_cpp_reference_single_arg(self): + function_types = [ + cfunctype(pt.CReferenceType(pt.c_int_type)), + cfunctype(pt.CReferenceType(pt.c_long_type)), + cfunctype(pt.CReferenceType(pt.c_double_type)), + ] + + functions = [ NameNode(None, type=t) for t in function_types ] + self.assertMatches(function_types[0], [pt.c_int_type], functions) + self.assertMatches(function_types[1], [pt.c_long_type], functions) + self.assertMatches(function_types[2], [pt.c_double_type], functions) + + def test_cpp_reference_two_args(self): + function_types = [ + cfunctype( + pt.CReferenceType(pt.c_int_type), pt.CReferenceType(pt.c_long_type)), + cfunctype( + pt.CReferenceType(pt.c_long_type), pt.CReferenceType(pt.c_long_type)), + ] + + functions = [ NameNode(None, type=t) for t in function_types ] + self.assertMatches(function_types[0], [pt.c_int_type, pt.c_long_type], functions) + self.assertMatches(function_types[1], [pt.c_long_type, pt.c_long_type], functions) + self.assertMatches(function_types[1], [pt.c_long_type, pt.c_int_type], functions) + + def test_cpp_reference_cpp_class(self): + classes = [ cppclasstype("Test%d"%i, []) for i in range(2) ] + function_types = [ + cfunctype(pt.CReferenceType(classes[0])), + cfunctype(pt.CReferenceType(classes[1])), + ] + + functions = [ NameNode(None, type=t) for t in function_types ] + self.assertMatches(function_types[0], [classes[0]], functions) + self.assertMatches(function_types[1], [classes[1]], functions) + + def test_cpp_reference_cpp_class_and_int(self): + classes = [ cppclasstype("Test%d"%i, []) for i in range(2) ] + function_types = [ + cfunctype(pt.CReferenceType(classes[0]), pt.c_int_type), + cfunctype(pt.CReferenceType(classes[0]), pt.c_long_type), + cfunctype(pt.CReferenceType(classes[1]), pt.c_int_type), + cfunctype(pt.CReferenceType(classes[1]), pt.c_long_type), + ] + + functions = [ NameNode(None, type=t) for t in function_types ] + self.assertMatches(function_types[0], [classes[0], pt.c_int_type], functions) + self.assertMatches(function_types[1], [classes[0], pt.c_long_type], functions) + self.assertMatches(function_types[2], [classes[1], pt.c_int_type], functions) + self.assertMatches(function_types[3], [classes[1], pt.c_long_type], functions) diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py b/contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py new file mode 100644 index 00000000000..91d099333a0 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +import sys +import unittest + +import Cython.Compiler.StringEncoding as StringEncoding + + +class StringEncodingTest(unittest.TestCase): + """ + Test the StringEncoding module. + """ + def test_string_contains_lone_surrogates(self): + self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"abc")) + self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"\uABCD")) + self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"\N{SNOWMAN}")) + + # This behaves differently in Py2 when freshly parsed and read from a .pyc file, + # but it seems to be a marshalling bug in Py2, which doesn't hurt us in Cython. + if sys.version_info[0] != 2: + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800\uDFFF")) + + # In Py2 with 16bit Unicode, the following is indistinguishable from the 32bit character. + obfuscated_surrogate_pair = (u"\uDFFF" + "\uD800")[::-1] + if sys.version_info[0] == 2 and sys.maxunicode == 65565: + self.assertFalse(StringEncoding.string_contains_lone_surrogates(obfuscated_surrogate_pair)) + else: + self.assertTrue(StringEncoding.string_contains_lone_surrogates(obfuscated_surrogate_pair)) + + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800")) + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uDFFF")) + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uDFFF\uD800")) + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800x\uDFFF")) + + def test_string_contains_surrogates(self): + self.assertFalse(StringEncoding.string_contains_surrogates(u"abc")) + self.assertFalse(StringEncoding.string_contains_surrogates(u"\uABCD")) + self.assertFalse(StringEncoding.string_contains_surrogates(u"\N{SNOWMAN}")) + + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uDFFF")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800\uDFFF")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uDFFF\uD800")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800x\uDFFF")) diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestTreeFragment.py b/contrib/tools/cython/Cython/Compiler/Tests/TestTreeFragment.py new file mode 100644 index 00000000000..9ee8da5478c --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestTreeFragment.py @@ -0,0 +1,64 @@ +from Cython.TestUtils import CythonTest +from Cython.Compiler.TreeFragment import * +from Cython.Compiler.Nodes import * +from Cython.Compiler.UtilNodes import * +import Cython.Compiler.Naming as Naming + +class TestTreeFragments(CythonTest): + + def test_basic(self): + F = self.fragment(u"x = 4") + T = F.copy() + self.assertCode(u"x = 4", T) + + def test_copy_is_taken(self): + F = self.fragment(u"if True: x = 4") + T1 = F.root + T2 = F.copy() + self.assertEqual("x", T2.stats[0].if_clauses[0].body.lhs.name) + T2.stats[0].if_clauses[0].body.lhs.name = "other" + self.assertEqual("x", T1.stats[0].if_clauses[0].body.lhs.name) + + def test_substitutions_are_copied(self): + T = self.fragment(u"y + y").substitute({"y": NameNode(pos=None, name="x")}) + self.assertEqual("x", T.stats[0].expr.operand1.name) + self.assertEqual("x", T.stats[0].expr.operand2.name) + self.assertTrue(T.stats[0].expr.operand1 is not T.stats[0].expr.operand2) + + def test_substitution(self): + F = self.fragment(u"x = 4") + y = NameNode(pos=None, name=u"y") + T = F.substitute({"x" : y}) + self.assertCode(u"y = 4", T) + + def test_exprstat(self): + F = self.fragment(u"PASS") + pass_stat = PassStatNode(pos=None) + T = F.substitute({"PASS" : pass_stat}) + self.assertTrue(isinstance(T.stats[0], PassStatNode), T) + + def test_pos_is_transferred(self): + F = self.fragment(u""" + x = y + x = u * v ** w + """) + T = F.substitute({"v" : NameNode(pos=None, name="a")}) + v = F.root.stats[1].rhs.operand2.operand1 + a = T.stats[1].rhs.operand2.operand1 + self.assertEqual(v.pos, a.pos) + + def test_temps(self): + TemplateTransform.temp_name_counter = 0 + F = self.fragment(u""" + TMP + x = TMP + """) + T = F.substitute(temps=[u"TMP"]) + s = T.body.stats + self.assertTrue(isinstance(s[0].expr, TempRefNode)) + self.assertTrue(isinstance(s[1].rhs, TempRefNode)) + self.assertTrue(s[0].expr.handle is s[1].rhs.handle) + +if __name__ == "__main__": + import unittest + unittest.main() diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestTreePath.py b/contrib/tools/cython/Cython/Compiler/Tests/TestTreePath.py new file mode 100644 index 00000000000..bee53b3d2bf --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestTreePath.py @@ -0,0 +1,94 @@ +import unittest +from Cython.Compiler.Visitor import PrintTree +from Cython.TestUtils import TransformTest +from Cython.Compiler.TreePath import find_first, find_all +from Cython.Compiler import Nodes, ExprNodes + +class TestTreePath(TransformTest): + _tree = None + + def _build_tree(self): + if self._tree is None: + self._tree = self.run_pipeline([], u""" + def decorator(fun): # DefNode + return fun # ReturnStatNode, NameNode + @decorator # NameNode + def decorated(): # DefNode + pass + """) + return self._tree + + def test_node_path(self): + t = self._build_tree() + self.assertEqual(2, len(find_all(t, "//DefNode"))) + self.assertEqual(2, len(find_all(t, "//NameNode"))) + self.assertEqual(1, len(find_all(t, "//ReturnStatNode"))) + self.assertEqual(1, len(find_all(t, "//DefNode//ReturnStatNode"))) + + def test_node_path_star(self): + t = self._build_tree() + self.assertEqual(10, len(find_all(t, "//*"))) + self.assertEqual(8, len(find_all(t, "//DefNode//*"))) + self.assertEqual(0, len(find_all(t, "//NameNode//*"))) + + def test_node_path_attribute(self): + t = self._build_tree() + self.assertEqual(2, len(find_all(t, "//NameNode/@name"))) + self.assertEqual(['fun', 'decorator'], find_all(t, "//NameNode/@name")) + + def test_node_path_attribute_dotted(self): + t = self._build_tree() + self.assertEqual(1, len(find_all(t, "//ReturnStatNode/@value.name"))) + self.assertEqual(['fun'], find_all(t, "//ReturnStatNode/@value.name")) + + def test_node_path_child(self): + t = self._build_tree() + self.assertEqual(1, len(find_all(t, "//DefNode/ReturnStatNode/NameNode"))) + self.assertEqual(1, len(find_all(t, "//ReturnStatNode/NameNode"))) + + def test_node_path_node_predicate(self): + t = self._build_tree() + self.assertEqual(0, len(find_all(t, "//DefNode[.//ForInStatNode]"))) + self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode]"))) + self.assertEqual(1, len(find_all(t, "//ReturnStatNode[./NameNode]"))) + self.assertEqual(Nodes.ReturnStatNode, + type(find_first(t, "//ReturnStatNode[./NameNode]"))) + + def test_node_path_node_predicate_step(self): + t = self._build_tree() + self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode]"))) + self.assertEqual(8, len(find_all(t, "//DefNode[.//NameNode]//*"))) + self.assertEqual(1, len(find_all(t, "//DefNode[.//NameNode]//ReturnStatNode"))) + self.assertEqual(Nodes.ReturnStatNode, + type(find_first(t, "//DefNode[.//NameNode]//ReturnStatNode"))) + + def test_node_path_attribute_exists(self): + t = self._build_tree() + self.assertEqual(2, len(find_all(t, "//NameNode[@name]"))) + self.assertEqual(ExprNodes.NameNode, + type(find_first(t, "//NameNode[@name]"))) + + def test_node_path_attribute_exists_not(self): + t = self._build_tree() + self.assertEqual(0, len(find_all(t, "//NameNode[not(@name)]"))) + self.assertEqual(2, len(find_all(t, "//NameNode[not(@honking)]"))) + + def test_node_path_and(self): + t = self._build_tree() + self.assertEqual(1, len(find_all(t, "//DefNode[.//ReturnStatNode and .//NameNode]"))) + self.assertEqual(0, len(find_all(t, "//NameNode[@honking and @name]"))) + self.assertEqual(0, len(find_all(t, "//NameNode[@name and @honking]"))) + self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode[@name] and @name]"))) + + def test_node_path_attribute_string_predicate(self): + t = self._build_tree() + self.assertEqual(1, len(find_all(t, "//NameNode[@name = 'decorator']"))) + + def test_node_path_recursive_predicate(self): + t = self._build_tree() + self.assertEqual(2, len(find_all(t, "//DefNode[.//NameNode[@name]]"))) + self.assertEqual(1, len(find_all(t, "//DefNode[.//NameNode[@name = 'decorator']]"))) + self.assertEqual(1, len(find_all(t, "//DefNode[.//ReturnStatNode[./NameNode[@name = 'fun']]/NameNode]"))) + +if __name__ == '__main__': + unittest.main() diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestTypes.py b/contrib/tools/cython/Cython/Compiler/Tests/TestTypes.py new file mode 100644 index 00000000000..f2f6f3773b9 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestTypes.py @@ -0,0 +1,19 @@ +from __future__ import absolute_import + +import unittest + +import Cython.Compiler.PyrexTypes as PT + + +class TestMethodDispatcherTransform(unittest.TestCase): + + def test_widest_numeric_type(self): + def assert_widest(type1, type2, widest): + self.assertEqual(widest, PT.widest_numeric_type(type1, type2)) + + assert_widest(PT.c_int_type, PT.c_long_type, PT.c_long_type) + assert_widest(PT.c_double_type, PT.c_long_type, PT.c_double_type) + assert_widest(PT.c_longdouble_type, PT.c_long_type, PT.c_longdouble_type) + + cenum = PT.CEnumType("E", "cenum", typedef_flag=False) + assert_widest(PT.c_int_type, cenum, PT.c_int_type) diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestUtilityLoad.py b/contrib/tools/cython/Cython/Compiler/Tests/TestUtilityLoad.py new file mode 100644 index 00000000000..3d1906ca0b4 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestUtilityLoad.py @@ -0,0 +1,101 @@ +import unittest + +from Cython.Compiler import Code, UtilityCode + + +def strip_2tup(tup): + return tup[0] and tup[0].strip(), tup[1] and tup[1].strip() + +class TestUtilityLoader(unittest.TestCase): + """ + Test loading UtilityCodes + """ + + expected = "test {{loader}} prototype", "test {{loader}} impl" + + required = "req {{loader}} proto", "req {{loader}} impl" + + context = dict(loader='Loader') + + name = "TestUtilityLoader" + filename = "TestUtilityLoader.c" + cls = Code.UtilityCode + + def test_load_as_string(self): + got = strip_2tup(self.cls.load_as_string(self.name)) + self.assertEqual(got, self.expected) + + got = strip_2tup(self.cls.load_as_string(self.name, self.filename)) + self.assertEqual(got, self.expected) + + def test_load(self): + utility = self.cls.load(self.name) + got = strip_2tup((utility.proto, utility.impl)) + self.assertEqual(got, self.expected) + + required, = utility.requires + got = strip_2tup((required.proto, required.impl)) + self.assertEqual(got, self.required) + + utility = self.cls.load(self.name, from_file=self.filename) + got = strip_2tup((utility.proto, utility.impl)) + self.assertEqual(got, self.expected) + + utility = self.cls.load_cached(self.name, from_file=self.filename) + got = strip_2tup((utility.proto, utility.impl)) + self.assertEqual(got, self.expected) + + +class TestTempitaUtilityLoader(TestUtilityLoader): + """ + Test loading UtilityCodes with Tempita substitution + """ + expected_tempita = (TestUtilityLoader.expected[0].replace('{{loader}}', 'Loader'), + TestUtilityLoader.expected[1].replace('{{loader}}', 'Loader')) + + required_tempita = (TestUtilityLoader.required[0].replace('{{loader}}', 'Loader'), + TestUtilityLoader.required[1].replace('{{loader}}', 'Loader')) + + cls = Code.TempitaUtilityCode + + def test_load_as_string(self): + got = strip_2tup(self.cls.load_as_string(self.name, context=self.context)) + self.assertEqual(got, self.expected_tempita) + + def test_load(self): + utility = self.cls.load(self.name, context=self.context) + got = strip_2tup((utility.proto, utility.impl)) + self.assertEqual(got, self.expected_tempita) + + required, = utility.requires + got = strip_2tup((required.proto, required.impl)) + self.assertEqual(got, self.required_tempita) + + utility = self.cls.load(self.name, from_file=self.filename, context=self.context) + got = strip_2tup((utility.proto, utility.impl)) + self.assertEqual(got, self.expected_tempita) + + +class TestCythonUtilityLoader(TestTempitaUtilityLoader): + """ + Test loading CythonUtilityCodes + """ + + # Just change the attributes and run the same tests + expected = None, "test {{cy_loader}} impl" + expected_tempita = None, "test CyLoader impl" + + required = None, "req {{cy_loader}} impl" + required_tempita = None, "req CyLoader impl" + + context = dict(cy_loader='CyLoader') + + name = "TestCyUtilityLoader" + filename = "TestCyUtilityLoader.pyx" + cls = UtilityCode.CythonUtilityCode + + # Small hack to pass our tests above + cls.proto = None + + test_load = TestUtilityLoader.test_load + test_load_tempita = TestTempitaUtilityLoader.test_load diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestVisitor.py b/contrib/tools/cython/Cython/Compiler/Tests/TestVisitor.py new file mode 100644 index 00000000000..dbc8e0c03ab --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestVisitor.py @@ -0,0 +1,61 @@ +from Cython.Compiler.ModuleNode import ModuleNode +from Cython.Compiler.Symtab import ModuleScope +from Cython.TestUtils import TransformTest +from Cython.Compiler.Visitor import MethodDispatcherTransform +from Cython.Compiler.ParseTreeTransforms import ( + NormalizeTree, AnalyseDeclarationsTransform, + AnalyseExpressionsTransform, InterpretCompilerDirectives) + + +class TestMethodDispatcherTransform(TransformTest): + _tree = None + + def _build_tree(self): + if self._tree is None: + context = None + + def fake_module(node): + scope = ModuleScope('test', None, None) + return ModuleNode(node.pos, doc=None, body=node, + scope=scope, full_module_name='test', + directive_comments={}) + pipeline = [ + fake_module, + NormalizeTree(context), + InterpretCompilerDirectives(context, {}), + AnalyseDeclarationsTransform(context), + AnalyseExpressionsTransform(context), + ] + self._tree = self.run_pipeline(pipeline, u""" + cdef bytes s = b'asdfg' + cdef dict d = {1:2} + x = s * 3 + d.get('test') + """) + return self._tree + + def test_builtin_method(self): + calls = [0] + class Test(MethodDispatcherTransform): + def _handle_simple_method_dict_get(self, node, func, args, unbound): + calls[0] += 1 + return node + + tree = self._build_tree() + Test(None)(tree) + self.assertEqual(1, calls[0]) + + def test_binop_method(self): + calls = {'bytes': 0, 'object': 0} + class Test(MethodDispatcherTransform): + def _handle_simple_method_bytes___mul__(self, node, func, args, unbound): + calls['bytes'] += 1 + return node + def _handle_simple_method_object___mul__(self, node, func, args, unbound): + calls['object'] += 1 + return node + + tree = self._build_tree() + Test(None)(tree) + self.assertEqual(1, calls['bytes']) + self.assertEqual(0, calls['object']) diff --git a/contrib/tools/cython/Cython/Compiler/Tests/__init__.py b/contrib/tools/cython/Cython/Compiler/Tests/__init__.py new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Tests/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Compiler/TreeFragment.py b/contrib/tools/cython/Cython/Compiler/TreeFragment.py new file mode 100644 index 00000000000..b85da8191a5 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/TreeFragment.py @@ -0,0 +1,275 @@ +# +# TreeFragments - parsing of strings to trees +# + +""" +Support for parsing strings into code trees. +""" + +from __future__ import absolute_import + +import re +from io import StringIO + +from .Scanning import PyrexScanner, StringSourceDescriptor +from .Symtab import ModuleScope +from . import PyrexTypes +from .Visitor import VisitorTransform +from .Nodes import Node, StatListNode +from .ExprNodes import NameNode +from .StringEncoding import _unicode +from . import Parsing +from . import Main +from . import UtilNodes + + +class StringParseContext(Main.Context): + def __init__(self, name, include_directories=None, compiler_directives=None, cpp=False): + if include_directories is None: + include_directories = [] + if compiler_directives is None: + compiler_directives = {} + # TODO: see if "language_level=3" also works for our internal code here. + Main.Context.__init__(self, include_directories, compiler_directives, cpp=cpp, language_level=2) + self.module_name = name + + def find_module(self, module_name, relative_to=None, pos=None, need_pxd=1, absolute_fallback=True): + if module_name not in (self.module_name, 'cython'): + raise AssertionError("Not yet supporting any cimports/includes from string code snippets") + return ModuleScope(module_name, parent_module=None, context=self) + + +def parse_from_strings(name, code, pxds=None, level=None, initial_pos=None, + context=None, allow_struct_enum_decorator=False): + """ + Utility method to parse a (unicode) string of code. This is mostly + used for internal Cython compiler purposes (creating code snippets + that transforms should emit, as well as unit testing). + + code - a unicode string containing Cython (module-level) code + name - a descriptive name for the code source (to use in error messages etc.) + + RETURNS + + The tree, i.e. a ModuleNode. The ModuleNode's scope attribute is + set to the scope used when parsing. + """ + if context is None: + context = StringParseContext(name) + # Since source files carry an encoding, it makes sense in this context + # to use a unicode string so that code fragments don't have to bother + # with encoding. This means that test code passed in should not have an + # encoding header. + assert isinstance(code, _unicode), "unicode code snippets only please" + encoding = "UTF-8" + + module_name = name + if initial_pos is None: + initial_pos = (name, 1, 0) + code_source = StringSourceDescriptor(name, code) + + scope = context.find_module(module_name, pos=initial_pos, need_pxd=False) + + buf = StringIO(code) + + scanner = PyrexScanner(buf, code_source, source_encoding = encoding, + scope = scope, context = context, initial_pos = initial_pos) + ctx = Parsing.Ctx(allow_struct_enum_decorator=allow_struct_enum_decorator) + + if level is None: + tree = Parsing.p_module(scanner, 0, module_name, ctx=ctx) + tree.scope = scope + tree.is_pxd = False + else: + tree = Parsing.p_code(scanner, level=level, ctx=ctx) + + tree.scope = scope + return tree + + +class TreeCopier(VisitorTransform): + def visit_Node(self, node): + if node is None: + return node + else: + c = node.clone_node() + self.visitchildren(c) + return c + + +class ApplyPositionAndCopy(TreeCopier): + def __init__(self, pos): + super(ApplyPositionAndCopy, self).__init__() + self.pos = pos + + def visit_Node(self, node): + copy = super(ApplyPositionAndCopy, self).visit_Node(node) + copy.pos = self.pos + return copy + + +class TemplateTransform(VisitorTransform): + """ + Makes a copy of a template tree while doing substitutions. + + A dictionary "substitutions" should be passed in when calling + the transform; mapping names to replacement nodes. Then replacement + happens like this: + - If an ExprStatNode contains a single NameNode, whose name is + a key in the substitutions dictionary, the ExprStatNode is + replaced with a copy of the tree given in the dictionary. + It is the responsibility of the caller that the replacement + node is a valid statement. + - If a single NameNode is otherwise encountered, it is replaced + if its name is listed in the substitutions dictionary in the + same way. It is the responsibility of the caller to make sure + that the replacement nodes is a valid expression. + + Also a list "temps" should be passed. Any names listed will + be transformed into anonymous, temporary names. + + Currently supported for tempnames is: + NameNode + (various function and class definition nodes etc. should be added to this) + + Each replacement node gets the position of the substituted node + recursively applied to every member node. + """ + + temp_name_counter = 0 + + def __call__(self, node, substitutions, temps, pos): + self.substitutions = substitutions + self.pos = pos + tempmap = {} + temphandles = [] + for temp in temps: + TemplateTransform.temp_name_counter += 1 + handle = UtilNodes.TempHandle(PyrexTypes.py_object_type) + tempmap[temp] = handle + temphandles.append(handle) + self.tempmap = tempmap + result = super(TemplateTransform, self).__call__(node) + if temps: + result = UtilNodes.TempsBlockNode(self.get_pos(node), + temps=temphandles, + body=result) + return result + + def get_pos(self, node): + if self.pos: + return self.pos + else: + return node.pos + + def visit_Node(self, node): + if node is None: + return None + else: + c = node.clone_node() + if self.pos is not None: + c.pos = self.pos + self.visitchildren(c) + return c + + def try_substitution(self, node, key): + sub = self.substitutions.get(key) + if sub is not None: + pos = self.pos + if pos is None: pos = node.pos + return ApplyPositionAndCopy(pos)(sub) + else: + return self.visit_Node(node) # make copy as usual + + def visit_NameNode(self, node): + temphandle = self.tempmap.get(node.name) + if temphandle: + # Replace name with temporary + return temphandle.ref(self.get_pos(node)) + else: + return self.try_substitution(node, node.name) + + def visit_ExprStatNode(self, node): + # If an expression-as-statement consists of only a replaceable + # NameNode, we replace the entire statement, not only the NameNode + if isinstance(node.expr, NameNode): + return self.try_substitution(node, node.expr.name) + else: + return self.visit_Node(node) + + +def copy_code_tree(node): + return TreeCopier()(node) + + +_match_indent = re.compile(u"^ *").match + + +def strip_common_indent(lines): + """Strips empty lines and common indentation from the list of strings given in lines""" + # TODO: Facilitate textwrap.indent instead + lines = [x for x in lines if x.strip() != u""] + if lines: + minindent = min([len(_match_indent(x).group(0)) for x in lines]) + lines = [x[minindent:] for x in lines] + return lines + + +class TreeFragment(object): + def __init__(self, code, name=None, pxds=None, temps=None, pipeline=None, level=None, initial_pos=None): + if pxds is None: + pxds = {} + if temps is None: + temps = [] + if pipeline is None: + pipeline = [] + if not name: + name = "(tree fragment)" + + if isinstance(code, _unicode): + def fmt(x): return u"\n".join(strip_common_indent(x.split(u"\n"))) + + fmt_code = fmt(code) + fmt_pxds = {} + for key, value in pxds.items(): + fmt_pxds[key] = fmt(value) + mod = t = parse_from_strings(name, fmt_code, fmt_pxds, level=level, initial_pos=initial_pos) + if level is None: + t = t.body # Make sure a StatListNode is at the top + if not isinstance(t, StatListNode): + t = StatListNode(pos=mod.pos, stats=[t]) + for transform in pipeline: + if transform is None: + continue + t = transform(t) + self.root = t + elif isinstance(code, Node): + if pxds: + raise NotImplementedError() + self.root = code + else: + raise ValueError("Unrecognized code format (accepts unicode and Node)") + self.temps = temps + + def copy(self): + return copy_code_tree(self.root) + + def substitute(self, nodes=None, temps=None, pos = None): + if nodes is None: + nodes = {} + if temps is None: + temps = [] + return TemplateTransform()(self.root, + substitutions = nodes, + temps = self.temps + temps, pos = pos) + + +class SetPosTransform(VisitorTransform): + def __init__(self, pos): + super(SetPosTransform, self).__init__() + self.pos = pos + + def visit_Node(self, node): + node.pos = self.pos + self.visitchildren(node) + return node diff --git a/contrib/tools/cython/Cython/Compiler/TreePath.py b/contrib/tools/cython/Cython/Compiler/TreePath.py new file mode 100644 index 00000000000..8585905557b --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/TreePath.py @@ -0,0 +1,296 @@ +""" +A simple XPath-like language for tree traversal. + +This works by creating a filter chain of generator functions. Each +function selects a part of the expression, e.g. a child node, a +specific descendant or a node that holds an attribute. +""" + +from __future__ import absolute_import + +import re +import operator +import sys + +if sys.version_info[0] >= 3: + _unicode = str +else: + _unicode = unicode + +path_tokenizer = re.compile( + r"(" + r"'[^']*'|\"[^\"]*\"|" + r"//?|" + r"\(\)|" + r"==?|" + r"[/.*\[\]()@])|" + r"([^/\[\]()@=\s]+)|" + r"\s+" + ).findall + +def iterchildren(node, attr_name): + # returns an iterable of all child nodes of that name + child = getattr(node, attr_name) + if child is not None: + if type(child) is list: + return child + else: + return [child] + else: + return () + +def _get_first_or_none(it): + try: + try: + _next = it.next + except AttributeError: + return next(it) + else: + return _next() + except StopIteration: + return None + +def type_name(node): + return node.__class__.__name__.split('.')[-1] + +def parse_func(next, token): + name = token[1] + token = next() + if token[0] != '(': + raise ValueError("Expected '(' after function name '%s'" % name) + predicate = handle_predicate(next, token) + return name, predicate + +def handle_func_not(next, token): + """ + not(...) + """ + name, predicate = parse_func(next, token) + + def select(result): + for node in result: + if _get_first_or_none(predicate([node])) is None: + yield node + return select + +def handle_name(next, token): + """ + /NodeName/ + or + func(...) + """ + name = token[1] + if name in functions: + return functions[name](next, token) + def select(result): + for node in result: + for attr_name in node.child_attrs: + for child in iterchildren(node, attr_name): + if type_name(child) == name: + yield child + return select + +def handle_star(next, token): + """ + /*/ + """ + def select(result): + for node in result: + for name in node.child_attrs: + for child in iterchildren(node, name): + yield child + return select + +def handle_dot(next, token): + """ + /./ + """ + def select(result): + return result + return select + +def handle_descendants(next, token): + """ + //... + """ + token = next() + if token[0] == "*": + def iter_recursive(node): + for name in node.child_attrs: + for child in iterchildren(node, name): + yield child + for c in iter_recursive(child): + yield c + elif not token[0]: + node_name = token[1] + def iter_recursive(node): + for name in node.child_attrs: + for child in iterchildren(node, name): + if type_name(child) == node_name: + yield child + for c in iter_recursive(child): + yield c + else: + raise ValueError("Expected node name after '//'") + + def select(result): + for node in result: + for child in iter_recursive(node): + yield child + + return select + + +def handle_attribute(next, token): + token = next() + if token[0]: + raise ValueError("Expected attribute name") + name = token[1] + value = None + try: + token = next() + except StopIteration: + pass + else: + if token[0] == '=': + value = parse_path_value(next) + readattr = operator.attrgetter(name) + if value is None: + def select(result): + for node in result: + try: + attr_value = readattr(node) + except AttributeError: + continue + if attr_value is not None: + yield attr_value + else: + def select(result): + for node in result: + try: + attr_value = readattr(node) + except AttributeError: + continue + if attr_value == value: + yield attr_value + elif (isinstance(attr_value, bytes) and isinstance(value, _unicode) and + attr_value == value.encode()): + # allow a bytes-to-string comparison too + yield attr_value + + return select + + +def parse_path_value(next): + token = next() + value = token[0] + if value: + if value[:1] == "'" or value[:1] == '"': + return value[1:-1] + try: + return int(value) + except ValueError: + pass + elif token[1].isdigit(): + return int(token[1]) + else: + name = token[1].lower() + if name == 'true': + return True + elif name == 'false': + return False + raise ValueError("Invalid attribute predicate: '%s'" % value) + +def handle_predicate(next, token): + token = next() + selector = [] + while token[0] != ']': + selector.append( operations[token[0]](next, token) ) + try: + token = next() + except StopIteration: + break + else: + if token[0] == "/": + token = next() + + if not token[0] and token[1] == 'and': + return logical_and(selector, handle_predicate(next, token)) + + def select(result): + for node in result: + subresult = iter((node,)) + for select in selector: + subresult = select(subresult) + predicate_result = _get_first_or_none(subresult) + if predicate_result is not None: + yield node + return select + +def logical_and(lhs_selects, rhs_select): + def select(result): + for node in result: + subresult = iter((node,)) + for select in lhs_selects: + subresult = select(subresult) + predicate_result = _get_first_or_none(subresult) + subresult = iter((node,)) + if predicate_result is not None: + for result_node in rhs_select(subresult): + yield node + return select + + +operations = { + "@": handle_attribute, + "": handle_name, + "*": handle_star, + ".": handle_dot, + "//": handle_descendants, + "[": handle_predicate, + } + +functions = { + 'not' : handle_func_not + } + +def _build_path_iterator(path): + # parse pattern + stream = iter([ (special,text) + for (special,text) in path_tokenizer(path) + if special or text ]) + try: + _next = stream.next + except AttributeError: + # Python 3 + def _next(): + return next(stream) + token = _next() + selector = [] + while 1: + try: + selector.append(operations[token[0]](_next, token)) + except StopIteration: + raise ValueError("invalid path") + try: + token = _next() + if token[0] == "/": + token = _next() + except StopIteration: + break + return selector + +# main module API + +def iterfind(node, path): + selector_chain = _build_path_iterator(path) + result = iter((node,)) + for select in selector_chain: + result = select(result) + return result + +def find_first(node, path): + return _get_first_or_none(iterfind(node, path)) + +def find_all(node, path): + return list(iterfind(node, path)) diff --git a/contrib/tools/cython/Cython/Compiler/TypeInference.py b/contrib/tools/cython/Cython/Compiler/TypeInference.py new file mode 100644 index 00000000000..c7ffee7d244 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/TypeInference.py @@ -0,0 +1,591 @@ +from __future__ import absolute_import + +from .Errors import error, message +from . import ExprNodes +from . import Nodes +from . import Builtin +from . import PyrexTypes +from .. import Utils +from .PyrexTypes import py_object_type, unspecified_type +from .Visitor import CythonTransform, EnvTransform + +try: + reduce +except NameError: + from functools import reduce + + +class TypedExprNode(ExprNodes.ExprNode): + # Used for declaring assignments of a specified type without a known entry. + subexprs = [] + + def __init__(self, type, pos=None): + super(TypedExprNode, self).__init__(pos, type=type) + +object_expr = TypedExprNode(py_object_type) + + +class MarkParallelAssignments(EnvTransform): + # Collects assignments inside parallel blocks prange, with parallel. + # Perhaps it's better to move it to ControlFlowAnalysis. + + # tells us whether we're in a normal loop + in_loop = False + + parallel_errors = False + + def __init__(self, context): + # Track the parallel block scopes (with parallel, for i in prange()) + self.parallel_block_stack = [] + super(MarkParallelAssignments, self).__init__(context) + + def mark_assignment(self, lhs, rhs, inplace_op=None): + if isinstance(lhs, (ExprNodes.NameNode, Nodes.PyArgDeclNode)): + if lhs.entry is None: + # TODO: This shouldn't happen... + return + + if self.parallel_block_stack: + parallel_node = self.parallel_block_stack[-1] + previous_assignment = parallel_node.assignments.get(lhs.entry) + + # If there was a previous assignment to the variable, keep the + # previous assignment position + if previous_assignment: + pos, previous_inplace_op = previous_assignment + + if (inplace_op and previous_inplace_op and + inplace_op != previous_inplace_op): + # x += y; x *= y + t = (inplace_op, previous_inplace_op) + error(lhs.pos, + "Reduction operator '%s' is inconsistent " + "with previous reduction operator '%s'" % t) + else: + pos = lhs.pos + + parallel_node.assignments[lhs.entry] = (pos, inplace_op) + parallel_node.assigned_nodes.append(lhs) + + elif isinstance(lhs, ExprNodes.SequenceNode): + for i, arg in enumerate(lhs.args): + if not rhs or arg.is_starred: + item_node = None + else: + item_node = rhs.inferable_item_node(i) + self.mark_assignment(arg, item_node) + else: + # Could use this info to infer cdef class attributes... + pass + + def visit_WithTargetAssignmentStatNode(self, node): + self.mark_assignment(node.lhs, node.with_node.enter_call) + self.visitchildren(node) + return node + + def visit_SingleAssignmentNode(self, node): + self.mark_assignment(node.lhs, node.rhs) + self.visitchildren(node) + return node + + def visit_CascadedAssignmentNode(self, node): + for lhs in node.lhs_list: + self.mark_assignment(lhs, node.rhs) + self.visitchildren(node) + return node + + def visit_InPlaceAssignmentNode(self, node): + self.mark_assignment(node.lhs, node.create_binop_node(), node.operator) + self.visitchildren(node) + return node + + def visit_ForInStatNode(self, node): + # TODO: Remove redundancy with range optimization... + is_special = False + sequence = node.iterator.sequence + target = node.target + if isinstance(sequence, ExprNodes.SimpleCallNode): + function = sequence.function + if sequence.self is None and function.is_name: + entry = self.current_env().lookup(function.name) + if not entry or entry.is_builtin: + if function.name == 'reversed' and len(sequence.args) == 1: + sequence = sequence.args[0] + elif function.name == 'enumerate' and len(sequence.args) == 1: + if target.is_sequence_constructor and len(target.args) == 2: + iterator = sequence.args[0] + if iterator.is_name: + iterator_type = iterator.infer_type(self.current_env()) + if iterator_type.is_builtin_type: + # assume that builtin types have a length within Py_ssize_t + self.mark_assignment( + target.args[0], + ExprNodes.IntNode(target.pos, value='PY_SSIZE_T_MAX', + type=PyrexTypes.c_py_ssize_t_type)) + target = target.args[1] + sequence = sequence.args[0] + if isinstance(sequence, ExprNodes.SimpleCallNode): + function = sequence.function + if sequence.self is None and function.is_name: + entry = self.current_env().lookup(function.name) + if not entry or entry.is_builtin: + if function.name in ('range', 'xrange'): + is_special = True + for arg in sequence.args[:2]: + self.mark_assignment(target, arg) + if len(sequence.args) > 2: + self.mark_assignment( + target, + ExprNodes.binop_node(node.pos, + '+', + sequence.args[0], + sequence.args[2])) + + if not is_special: + # A for-loop basically translates to subsequent calls to + # __getitem__(), so using an IndexNode here allows us to + # naturally infer the base type of pointers, C arrays, + # Python strings, etc., while correctly falling back to an + # object type when the base type cannot be handled. + self.mark_assignment(target, ExprNodes.IndexNode( + node.pos, + base=sequence, + index=ExprNodes.IntNode(target.pos, value='PY_SSIZE_T_MAX', + type=PyrexTypes.c_py_ssize_t_type))) + + self.visitchildren(node) + return node + + def visit_ForFromStatNode(self, node): + self.mark_assignment(node.target, node.bound1) + if node.step is not None: + self.mark_assignment(node.target, + ExprNodes.binop_node(node.pos, + '+', + node.bound1, + node.step)) + self.visitchildren(node) + return node + + def visit_WhileStatNode(self, node): + self.visitchildren(node) + return node + + def visit_ExceptClauseNode(self, node): + if node.target is not None: + self.mark_assignment(node.target, object_expr) + self.visitchildren(node) + return node + + def visit_FromCImportStatNode(self, node): + pass # Can't be assigned to... + + def visit_FromImportStatNode(self, node): + for name, target in node.items: + if name != "*": + self.mark_assignment(target, object_expr) + self.visitchildren(node) + return node + + def visit_DefNode(self, node): + # use fake expressions with the right result type + if node.star_arg: + self.mark_assignment( + node.star_arg, TypedExprNode(Builtin.tuple_type, node.pos)) + if node.starstar_arg: + self.mark_assignment( + node.starstar_arg, TypedExprNode(Builtin.dict_type, node.pos)) + EnvTransform.visit_FuncDefNode(self, node) + return node + + def visit_DelStatNode(self, node): + for arg in node.args: + self.mark_assignment(arg, arg) + self.visitchildren(node) + return node + + def visit_ParallelStatNode(self, node): + if self.parallel_block_stack: + node.parent = self.parallel_block_stack[-1] + else: + node.parent = None + + nested = False + if node.is_prange: + if not node.parent: + node.is_parallel = True + else: + node.is_parallel = (node.parent.is_prange or not + node.parent.is_parallel) + nested = node.parent.is_prange + else: + node.is_parallel = True + # Note: nested with parallel() blocks are handled by + # ParallelRangeTransform! + # nested = node.parent + nested = node.parent and node.parent.is_prange + + self.parallel_block_stack.append(node) + + nested = nested or len(self.parallel_block_stack) > 2 + if not self.parallel_errors and nested and not node.is_prange: + error(node.pos, "Only prange() may be nested") + self.parallel_errors = True + + if node.is_prange: + child_attrs = node.child_attrs + node.child_attrs = ['body', 'target', 'args'] + self.visitchildren(node) + node.child_attrs = child_attrs + + self.parallel_block_stack.pop() + if node.else_clause: + node.else_clause = self.visit(node.else_clause) + else: + self.visitchildren(node) + self.parallel_block_stack.pop() + + self.parallel_errors = False + return node + + def visit_YieldExprNode(self, node): + if self.parallel_block_stack: + error(node.pos, "'%s' not allowed in parallel sections" % node.expr_keyword) + return node + + def visit_ReturnStatNode(self, node): + node.in_parallel = bool(self.parallel_block_stack) + return node + + +class MarkOverflowingArithmetic(CythonTransform): + + # It may be possible to integrate this with the above for + # performance improvements (though likely not worth it). + + might_overflow = False + + def __call__(self, root): + self.env_stack = [] + self.env = root.scope + return super(MarkOverflowingArithmetic, self).__call__(root) + + def visit_safe_node(self, node): + self.might_overflow, saved = False, self.might_overflow + self.visitchildren(node) + self.might_overflow = saved + return node + + def visit_neutral_node(self, node): + self.visitchildren(node) + return node + + def visit_dangerous_node(self, node): + self.might_overflow, saved = True, self.might_overflow + self.visitchildren(node) + self.might_overflow = saved + return node + + def visit_FuncDefNode(self, node): + self.env_stack.append(self.env) + self.env = node.local_scope + self.visit_safe_node(node) + self.env = self.env_stack.pop() + return node + + def visit_NameNode(self, node): + if self.might_overflow: + entry = node.entry or self.env.lookup(node.name) + if entry: + entry.might_overflow = True + return node + + def visit_BinopNode(self, node): + if node.operator in '&|^': + return self.visit_neutral_node(node) + else: + return self.visit_dangerous_node(node) + + def visit_SimpleCallNode(self, node): + if node.function.is_name and node.function.name == 'abs': + # Overflows for minimum value of fixed size ints. + return self.visit_dangerous_node(node) + else: + return self.visit_neutral_node(node) + + visit_UnopNode = visit_neutral_node + + visit_UnaryMinusNode = visit_dangerous_node + + visit_InPlaceAssignmentNode = visit_dangerous_node + + visit_Node = visit_safe_node + + def visit_assignment(self, lhs, rhs): + if (isinstance(rhs, ExprNodes.IntNode) + and isinstance(lhs, ExprNodes.NameNode) + and Utils.long_literal(rhs.value)): + entry = lhs.entry or self.env.lookup(lhs.name) + if entry: + entry.might_overflow = True + + def visit_SingleAssignmentNode(self, node): + self.visit_assignment(node.lhs, node.rhs) + self.visitchildren(node) + return node + + def visit_CascadedAssignmentNode(self, node): + for lhs in node.lhs_list: + self.visit_assignment(lhs, node.rhs) + self.visitchildren(node) + return node + +class PyObjectTypeInferer(object): + """ + If it's not declared, it's a PyObject. + """ + def infer_types(self, scope): + """ + Given a dict of entries, map all unspecified types to a specified type. + """ + for name, entry in scope.entries.items(): + if entry.type is unspecified_type: + entry.type = py_object_type + +class SimpleAssignmentTypeInferer(object): + """ + Very basic type inference. + + Note: in order to support cross-closure type inference, this must be + applies to nested scopes in top-down order. + """ + def set_entry_type(self, entry, entry_type): + entry.type = entry_type + for e in entry.all_entries(): + e.type = entry_type + + def infer_types(self, scope): + enabled = scope.directives['infer_types'] + verbose = scope.directives['infer_types.verbose'] + + if enabled == True: + spanning_type = aggressive_spanning_type + elif enabled is None: # safe mode + spanning_type = safe_spanning_type + else: + for entry in scope.entries.values(): + if entry.type is unspecified_type: + self.set_entry_type(entry, py_object_type) + return + + # Set of assignments + assignments = set() + assmts_resolved = set() + dependencies = {} + assmt_to_names = {} + + for name, entry in scope.entries.items(): + for assmt in entry.cf_assignments: + names = assmt.type_dependencies() + assmt_to_names[assmt] = names + assmts = set() + for node in names: + assmts.update(node.cf_state) + dependencies[assmt] = assmts + if entry.type is unspecified_type: + assignments.update(entry.cf_assignments) + else: + assmts_resolved.update(entry.cf_assignments) + + def infer_name_node_type(node): + types = [assmt.inferred_type for assmt in node.cf_state] + if not types: + node_type = py_object_type + else: + entry = node.entry + node_type = spanning_type( + types, entry.might_overflow, entry.pos, scope) + node.inferred_type = node_type + + def infer_name_node_type_partial(node): + types = [assmt.inferred_type for assmt in node.cf_state + if assmt.inferred_type is not None] + if not types: + return + entry = node.entry + return spanning_type(types, entry.might_overflow, entry.pos, scope) + + def inferred_types(entry): + has_none = False + has_pyobjects = False + types = [] + for assmt in entry.cf_assignments: + if assmt.rhs.is_none: + has_none = True + else: + rhs_type = assmt.inferred_type + if rhs_type and rhs_type.is_pyobject: + has_pyobjects = True + types.append(rhs_type) + # Ignore None assignments as long as there are concrete Python type assignments. + # but include them if None is the only assigned Python object. + if has_none and not has_pyobjects: + types.append(py_object_type) + return types + + def resolve_assignments(assignments): + resolved = set() + for assmt in assignments: + deps = dependencies[assmt] + # All assignments are resolved + if assmts_resolved.issuperset(deps): + for node in assmt_to_names[assmt]: + infer_name_node_type(node) + # Resolve assmt + inferred_type = assmt.infer_type() + assmts_resolved.add(assmt) + resolved.add(assmt) + assignments.difference_update(resolved) + return resolved + + def partial_infer(assmt): + partial_types = [] + for node in assmt_to_names[assmt]: + partial_type = infer_name_node_type_partial(node) + if partial_type is None: + return False + partial_types.append((node, partial_type)) + for node, partial_type in partial_types: + node.inferred_type = partial_type + assmt.infer_type() + return True + + partial_assmts = set() + def resolve_partial(assignments): + # try to handle circular references + partials = set() + for assmt in assignments: + if assmt in partial_assmts: + continue + if partial_infer(assmt): + partials.add(assmt) + assmts_resolved.add(assmt) + partial_assmts.update(partials) + return partials + + # Infer assignments + while True: + if not resolve_assignments(assignments): + if not resolve_partial(assignments): + break + inferred = set() + # First pass + for entry in scope.entries.values(): + if entry.type is not unspecified_type: + continue + entry_type = py_object_type + if assmts_resolved.issuperset(entry.cf_assignments): + types = inferred_types(entry) + if types and all(types): + entry_type = spanning_type( + types, entry.might_overflow, entry.pos, scope) + inferred.add(entry) + self.set_entry_type(entry, entry_type) + + def reinfer(): + dirty = False + for entry in inferred: + for assmt in entry.cf_assignments: + assmt.infer_type() + types = inferred_types(entry) + new_type = spanning_type(types, entry.might_overflow, entry.pos, scope) + if new_type != entry.type: + self.set_entry_type(entry, new_type) + dirty = True + return dirty + + # types propagation + while reinfer(): + pass + + if verbose: + for entry in inferred: + message(entry.pos, "inferred '%s' to be of type '%s'" % ( + entry.name, entry.type)) + + +def find_spanning_type(type1, type2): + if type1 is type2: + result_type = type1 + elif type1 is PyrexTypes.c_bint_type or type2 is PyrexTypes.c_bint_type: + # type inference can break the coercion back to a Python bool + # if it returns an arbitrary int type here + return py_object_type + else: + result_type = PyrexTypes.spanning_type(type1, type2) + if result_type in (PyrexTypes.c_double_type, PyrexTypes.c_float_type, + Builtin.float_type): + # Python's float type is just a C double, so it's safe to + # use the C type instead + return PyrexTypes.c_double_type + return result_type + +def simply_type(result_type, pos): + if result_type.is_reference: + result_type = result_type.ref_base_type + if result_type.is_const: + result_type = result_type.const_base_type + if result_type.is_cpp_class: + result_type.check_nullary_constructor(pos) + if result_type.is_array: + result_type = PyrexTypes.c_ptr_type(result_type.base_type) + return result_type + +def aggressive_spanning_type(types, might_overflow, pos, scope): + return simply_type(reduce(find_spanning_type, types), pos) + +def safe_spanning_type(types, might_overflow, pos, scope): + result_type = simply_type(reduce(find_spanning_type, types), pos) + if result_type.is_pyobject: + # In theory, any specific Python type is always safe to + # infer. However, inferring str can cause some existing code + # to break, since we are also now much more strict about + # coercion from str to char *. See trac #553. + if result_type.name == 'str': + return py_object_type + else: + return result_type + elif result_type is PyrexTypes.c_double_type: + # Python's float type is just a C double, so it's safe to use + # the C type instead + return result_type + elif result_type is PyrexTypes.c_bint_type: + # find_spanning_type() only returns 'bint' for clean boolean + # operations without other int types, so this is safe, too + return result_type + elif result_type.is_pythran_expr: + return result_type + elif result_type.is_ptr: + # Any pointer except (signed|unsigned|) char* can't implicitly + # become a PyObject, and inferring char* is now accepted, too. + return result_type + elif result_type.is_cpp_class: + # These can't implicitly become Python objects either. + return result_type + elif result_type.is_struct: + # Though we have struct -> object for some structs, this is uncommonly + # used, won't arise in pure Python, and there shouldn't be side + # effects, so I'm declaring this safe. + return result_type + # TODO: double complex should be OK as well, but we need + # to make sure everything is supported. + elif (result_type.is_int or result_type.is_enum) and not might_overflow: + return result_type + elif (not result_type.can_coerce_to_pyobject(scope) + and not result_type.is_error): + return result_type + return py_object_type + + +def get_type_inferer(): + return SimpleAssignmentTypeInferer() diff --git a/contrib/tools/cython/Cython/Compiler/TypeSlots.py b/contrib/tools/cython/Cython/Compiler/TypeSlots.py new file mode 100644 index 00000000000..c6867447d25 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/TypeSlots.py @@ -0,0 +1,941 @@ +# +# Tables describing slots in the CPython type object +# and associated know-how. +# + +from __future__ import absolute_import + +from . import Naming +from . import PyrexTypes +from .Errors import error + +invisible = ['__cinit__', '__dealloc__', '__richcmp__', + '__nonzero__', '__bool__'] + +richcmp_special_methods = ['__eq__', '__ne__', '__lt__', '__gt__', '__le__', '__ge__'] + + +class Signature(object): + # Method slot signature descriptor. + # + # has_dummy_arg boolean + # has_generic_args boolean + # fixed_arg_format string + # ret_format string + # error_value string + # + # The formats are strings made up of the following + # characters: + # + # 'O' Python object + # 'T' Python object of the type of 'self' + # 'v' void + # 'p' void * + # 'P' void ** + # 'i' int + # 'b' bint + # 'I' int * + # 'l' long + # 'f' float + # 'd' double + # 'h' Py_hash_t + # 'z' Py_ssize_t + # 'Z' Py_ssize_t * + # 's' char * + # 'S' char ** + # 'r' int used only to signal exception + # 'B' Py_buffer * + # '-' dummy 'self' argument (not used) + # '*' rest of args passed as generic Python + # arg tuple and kw dict (must be last + # char in format string) + + format_map = { + 'O': PyrexTypes.py_object_type, + 'v': PyrexTypes.c_void_type, + 'p': PyrexTypes.c_void_ptr_type, + 'P': PyrexTypes.c_void_ptr_ptr_type, + 'i': PyrexTypes.c_int_type, + 'b': PyrexTypes.c_bint_type, + 'I': PyrexTypes.c_int_ptr_type, + 'l': PyrexTypes.c_long_type, + 'f': PyrexTypes.c_float_type, + 'd': PyrexTypes.c_double_type, + 'h': PyrexTypes.c_py_hash_t_type, + 'z': PyrexTypes.c_py_ssize_t_type, + 'Z': PyrexTypes.c_py_ssize_t_ptr_type, + 's': PyrexTypes.c_char_ptr_type, + 'S': PyrexTypes.c_char_ptr_ptr_type, + 'r': PyrexTypes.c_returncode_type, + 'B': PyrexTypes.c_py_buffer_ptr_type, + # 'T', '-' and '*' are handled otherwise + # and are not looked up in here + } + + type_to_format_map = dict( + (type_, format_) for format_, type_ in format_map.items()) + + error_value_map = { + 'O': "NULL", + 'T': "NULL", + 'i': "-1", + 'b': "-1", + 'l': "-1", + 'r': "-1", + 'h': "-1", + 'z': "-1", + } + + def __init__(self, arg_format, ret_format): + self.has_dummy_arg = 0 + self.has_generic_args = 0 + if arg_format[:1] == '-': + self.has_dummy_arg = 1 + arg_format = arg_format[1:] + if arg_format[-1:] == '*': + self.has_generic_args = 1 + arg_format = arg_format[:-1] + self.fixed_arg_format = arg_format + self.ret_format = ret_format + self.error_value = self.error_value_map.get(ret_format, None) + self.exception_check = ret_format != 'r' and self.error_value is not None + self.is_staticmethod = False + + def __repr__(self): + return '<Signature[%s(%s%s)]>' % ( + self.ret_format, + ', '.join(self.fixed_arg_format), + '*' if self.has_generic_args else '') + + def num_fixed_args(self): + return len(self.fixed_arg_format) + + def is_self_arg(self, i): + # argument is 'self' for methods or 'class' for classmethods + return self.fixed_arg_format[i] == 'T' + + def returns_self_type(self): + # return type is same as 'self' argument type + return self.ret_format == 'T' + + def fixed_arg_type(self, i): + return self.format_map[self.fixed_arg_format[i]] + + def return_type(self): + return self.format_map[self.ret_format] + + def format_from_type(self, arg_type): + if arg_type.is_pyobject: + arg_type = PyrexTypes.py_object_type + return self.type_to_format_map[arg_type] + + def exception_value(self): + return self.error_value_map.get(self.ret_format) + + def function_type(self, self_arg_override=None): + # Construct a C function type descriptor for this signature + args = [] + for i in range(self.num_fixed_args()): + if self_arg_override is not None and self.is_self_arg(i): + assert isinstance(self_arg_override, PyrexTypes.CFuncTypeArg) + args.append(self_arg_override) + else: + arg_type = self.fixed_arg_type(i) + args.append(PyrexTypes.CFuncTypeArg("", arg_type, None)) + if self_arg_override is not None and self.returns_self_type(): + ret_type = self_arg_override.type + else: + ret_type = self.return_type() + exc_value = self.exception_value() + return PyrexTypes.CFuncType( + ret_type, args, exception_value=exc_value, + exception_check=self.exception_check) + + def method_flags(self): + if self.ret_format == "O": + full_args = self.fixed_arg_format + if self.has_dummy_arg: + full_args = "O" + full_args + if full_args in ["O", "T"]: + if self.has_generic_args: + return [method_varargs, method_keywords] + else: + return [method_noargs] + elif full_args in ["OO", "TO"] and not self.has_generic_args: + return [method_onearg] + + if self.is_staticmethod: + return [method_varargs, method_keywords] + return None + + +class SlotDescriptor(object): + # Abstract base class for type slot descriptors. + # + # slot_name string Member name of the slot in the type object + # is_initialised_dynamically Is initialised by code in the module init function + # is_inherited Is inherited by subtypes (see PyType_Ready()) + # py3 Indicates presence of slot in Python 3 + # py2 Indicates presence of slot in Python 2 + # ifdef Full #ifdef string that slot is wrapped in. Using this causes py3, py2 and flags to be ignored.) + + def __init__(self, slot_name, dynamic=False, inherited=False, + py3=True, py2=True, ifdef=None): + self.slot_name = slot_name + self.is_initialised_dynamically = dynamic + self.is_inherited = inherited + self.ifdef = ifdef + self.py3 = py3 + self.py2 = py2 + + def preprocessor_guard_code(self): + ifdef = self.ifdef + py2 = self.py2 + py3 = self.py3 + guard = None + if ifdef: + guard = ("#if %s" % ifdef) + elif not py3 or py3 == '<RESERVED>': + guard = ("#if PY_MAJOR_VERSION < 3") + elif not py2: + guard = ("#if PY_MAJOR_VERSION >= 3") + return guard + + def generate(self, scope, code): + preprocessor_guard = self.preprocessor_guard_code() + if preprocessor_guard: + code.putln(preprocessor_guard) + + end_pypy_guard = False + if self.is_initialised_dynamically: + value = "0" + else: + value = self.slot_code(scope) + if value == "0" and self.is_inherited: + # PyPy currently has a broken PyType_Ready() that fails to + # inherit some slots. To work around this, we explicitly + # set inherited slots here, but only in PyPy since CPython + # handles this better than we do. + inherited_value = value + current_scope = scope + while (inherited_value == "0" + and current_scope.parent_type + and current_scope.parent_type.base_type + and current_scope.parent_type.base_type.scope): + current_scope = current_scope.parent_type.base_type.scope + inherited_value = self.slot_code(current_scope) + if inherited_value != "0": + code.putln("#if CYTHON_COMPILING_IN_PYPY") + code.putln("%s, /*%s*/" % (inherited_value, self.slot_name)) + code.putln("#else") + end_pypy_guard = True + + code.putln("%s, /*%s*/" % (value, self.slot_name)) + + if end_pypy_guard: + code.putln("#endif") + + if self.py3 == '<RESERVED>': + code.putln("#else") + code.putln("0, /*reserved*/") + if preprocessor_guard: + code.putln("#endif") + + # Some C implementations have trouble statically + # initialising a global with a pointer to an extern + # function, so we initialise some of the type slots + # in the module init function instead. + + def generate_dynamic_init_code(self, scope, code): + if self.is_initialised_dynamically: + value = self.slot_code(scope) + if value != "0": + code.putln("%s.%s = %s;" % ( + scope.parent_type.typeobj_cname, + self.slot_name, + value + ) + ) + + +class FixedSlot(SlotDescriptor): + # Descriptor for a type slot with a fixed value. + # + # value string + + def __init__(self, slot_name, value, py3=True, py2=True, ifdef=None): + SlotDescriptor.__init__(self, slot_name, py3=py3, py2=py2, ifdef=ifdef) + self.value = value + + def slot_code(self, scope): + return self.value + + +class EmptySlot(FixedSlot): + # Descriptor for a type slot whose value is always 0. + + def __init__(self, slot_name, py3=True, py2=True, ifdef=None): + FixedSlot.__init__(self, slot_name, "0", py3=py3, py2=py2, ifdef=ifdef) + + +class MethodSlot(SlotDescriptor): + # Type slot descriptor for a user-definable method. + # + # signature Signature + # method_name string The __xxx__ name of the method + # alternatives [string] Alternative list of __xxx__ names for the method + + def __init__(self, signature, slot_name, method_name, fallback=None, + py3=True, py2=True, ifdef=None, inherited=True): + SlotDescriptor.__init__(self, slot_name, py3=py3, py2=py2, + ifdef=ifdef, inherited=inherited) + self.signature = signature + self.slot_name = slot_name + self.method_name = method_name + self.alternatives = [] + method_name_to_slot[method_name] = self + # + if fallback: + self.alternatives.append(fallback) + for alt in (self.py2, self.py3): + if isinstance(alt, (tuple, list)): + slot_name, method_name = alt + self.alternatives.append(method_name) + method_name_to_slot[method_name] = self + + def slot_code(self, scope): + entry = scope.lookup_here(self.method_name) + if entry and entry.is_special and entry.func_cname: + return entry.func_cname + for method_name in self.alternatives: + entry = scope.lookup_here(method_name) + if entry and entry.is_special and entry.func_cname: + return entry.func_cname + return "0" + + +class InternalMethodSlot(SlotDescriptor): + # Type slot descriptor for a method which is always + # synthesized by Cython. + # + # slot_name string Member name of the slot in the type object + + def __init__(self, slot_name, **kargs): + SlotDescriptor.__init__(self, slot_name, **kargs) + + def slot_code(self, scope): + return scope.mangle_internal(self.slot_name) + + +class GCDependentSlot(InternalMethodSlot): + # Descriptor for a slot whose value depends on whether + # the type participates in GC. + + def __init__(self, slot_name, **kargs): + InternalMethodSlot.__init__(self, slot_name, **kargs) + + def slot_code(self, scope): + if not scope.needs_gc(): + return "0" + if not scope.has_cyclic_pyobject_attrs: + # if the type does not have GC relevant object attributes, it can + # delegate GC methods to its parent - iff the parent functions + # are defined in the same module + parent_type_scope = scope.parent_type.base_type.scope + if scope.parent_scope is parent_type_scope.parent_scope: + entry = scope.parent_scope.lookup_here(scope.parent_type.base_type.name) + if entry.visibility != 'extern': + return self.slot_code(parent_type_scope) + return InternalMethodSlot.slot_code(self, scope) + + +class GCClearReferencesSlot(GCDependentSlot): + + def slot_code(self, scope): + if scope.needs_tp_clear(): + return GCDependentSlot.slot_code(self, scope) + return "0" + + +class ConstructorSlot(InternalMethodSlot): + # Descriptor for tp_new and tp_dealloc. + + def __init__(self, slot_name, method, **kargs): + InternalMethodSlot.__init__(self, slot_name, **kargs) + self.method = method + + def slot_code(self, scope): + entry = scope.lookup_here(self.method) + if (self.slot_name != 'tp_new' + and scope.parent_type.base_type + and not scope.has_pyobject_attrs + and not scope.has_memoryview_attrs + and not scope.has_cpp_class_attrs + and not (entry and entry.is_special)): + # if the type does not have object attributes, it can + # delegate GC methods to its parent - iff the parent + # functions are defined in the same module + parent_type_scope = scope.parent_type.base_type.scope + if scope.parent_scope is parent_type_scope.parent_scope: + entry = scope.parent_scope.lookup_here(scope.parent_type.base_type.name) + if entry.visibility != 'extern': + return self.slot_code(parent_type_scope) + if entry and not entry.is_special: + return "0" + return InternalMethodSlot.slot_code(self, scope) + + +class SyntheticSlot(InternalMethodSlot): + # Type slot descriptor for a synthesized method which + # dispatches to one or more user-defined methods depending + # on its arguments. If none of the relevant methods are + # defined, the method will not be synthesized and an + # alternative default value will be placed in the type + # slot. + + def __init__(self, slot_name, user_methods, default_value, **kargs): + InternalMethodSlot.__init__(self, slot_name, **kargs) + self.user_methods = user_methods + self.default_value = default_value + + def slot_code(self, scope): + if scope.defines_any_special(self.user_methods): + return InternalMethodSlot.slot_code(self, scope) + else: + return self.default_value + + +class RichcmpSlot(MethodSlot): + def slot_code(self, scope): + entry = scope.lookup_here(self.method_name) + if entry and entry.is_special and entry.func_cname: + return entry.func_cname + elif scope.defines_any_special(richcmp_special_methods): + return scope.mangle_internal(self.slot_name) + else: + return "0" + + +class TypeFlagsSlot(SlotDescriptor): + # Descriptor for the type flags slot. + + def slot_code(self, scope): + value = "Py_TPFLAGS_DEFAULT" + if scope.directives['type_version_tag']: + # it's not in 'Py_TPFLAGS_DEFAULT' in Py2 + value += "|Py_TPFLAGS_HAVE_VERSION_TAG" + else: + # it's enabled in 'Py_TPFLAGS_DEFAULT' in Py3 + value = "(%s&~Py_TPFLAGS_HAVE_VERSION_TAG)" % value + value += "|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER" + if not scope.parent_type.is_final_type: + value += "|Py_TPFLAGS_BASETYPE" + if scope.needs_gc(): + value += "|Py_TPFLAGS_HAVE_GC" + return value + + +class DocStringSlot(SlotDescriptor): + # Descriptor for the docstring slot. + + def slot_code(self, scope): + doc = scope.doc + if doc is None: + return "0" + if doc.is_unicode: + doc = doc.as_utf8_string() + return doc.as_c_string_literal() + + +class SuiteSlot(SlotDescriptor): + # Descriptor for a substructure of the type object. + # + # sub_slots [SlotDescriptor] + + def __init__(self, sub_slots, slot_type, slot_name, ifdef=None): + SlotDescriptor.__init__(self, slot_name, ifdef=ifdef) + self.sub_slots = sub_slots + self.slot_type = slot_type + substructures.append(self) + + def is_empty(self, scope): + for slot in self.sub_slots: + if slot.slot_code(scope) != "0": + return False + return True + + def substructure_cname(self, scope): + return "%s%s_%s" % (Naming.pyrex_prefix, self.slot_name, scope.class_name) + + def slot_code(self, scope): + if not self.is_empty(scope): + return "&%s" % self.substructure_cname(scope) + return "0" + + def generate_substructure(self, scope, code): + if not self.is_empty(scope): + code.putln("") + if self.ifdef: + code.putln("#if %s" % self.ifdef) + code.putln( + "static %s %s = {" % ( + self.slot_type, + self.substructure_cname(scope))) + for slot in self.sub_slots: + slot.generate(scope, code) + code.putln("};") + if self.ifdef: + code.putln("#endif") + +substructures = [] # List of all SuiteSlot instances + +class MethodTableSlot(SlotDescriptor): + # Slot descriptor for the method table. + + def slot_code(self, scope): + if scope.pyfunc_entries: + return scope.method_table_cname + else: + return "0" + + +class MemberTableSlot(SlotDescriptor): + # Slot descriptor for the table of Python-accessible attributes. + + def slot_code(self, scope): + return "0" + + +class GetSetSlot(SlotDescriptor): + # Slot descriptor for the table of attribute get & set methods. + + def slot_code(self, scope): + if scope.property_entries: + return scope.getset_table_cname + else: + return "0" + + +class BaseClassSlot(SlotDescriptor): + # Slot descriptor for the base class slot. + + def __init__(self, name): + SlotDescriptor.__init__(self, name, dynamic = 1) + + def generate_dynamic_init_code(self, scope, code): + base_type = scope.parent_type.base_type + if base_type: + code.putln("%s.%s = %s;" % ( + scope.parent_type.typeobj_cname, + self.slot_name, + base_type.typeptr_cname)) + + +class DictOffsetSlot(SlotDescriptor): + # Slot descriptor for a class' dict offset, for dynamic attributes. + + def slot_code(self, scope): + dict_entry = scope.lookup_here("__dict__") if not scope.is_closure_class_scope else None + if dict_entry and dict_entry.is_variable: + if getattr(dict_entry.type, 'cname', None) != 'PyDict_Type': + error(dict_entry.pos, "__dict__ slot must be of type 'dict'") + return "0" + type = scope.parent_type + if type.typedef_flag: + objstruct = type.objstruct_cname + else: + objstruct = "struct %s" % type.objstruct_cname + return ("offsetof(%s, %s)" % ( + objstruct, + dict_entry.cname)) + else: + return "0" + + +# The following dictionary maps __xxx__ method names to slot descriptors. + +method_name_to_slot = {} + +## The following slots are (or could be) initialised with an +## extern function pointer. +# +#slots_initialised_from_extern = ( +# "tp_free", +#) + +#------------------------------------------------------------------------------------------ +# +# Utility functions for accessing slot table data structures +# +#------------------------------------------------------------------------------------------ + +def get_special_method_signature(name): + # Given a method name, if it is a special method, + # return its signature, else return None. + slot = method_name_to_slot.get(name) + if slot: + return slot.signature + elif name in richcmp_special_methods: + return ibinaryfunc + else: + return None + + +def get_property_accessor_signature(name): + # Return signature of accessor for an extension type + # property, else None. + return property_accessor_signatures.get(name) + + +def get_base_slot_function(scope, slot): + # Returns the function implementing this slot in the baseclass. + # This is useful for enabling the compiler to optimize calls + # that recursively climb the class hierarchy. + base_type = scope.parent_type.base_type + if scope.parent_scope is base_type.scope.parent_scope: + parent_slot = slot.slot_code(base_type.scope) + if parent_slot != '0': + entry = scope.parent_scope.lookup_here(scope.parent_type.base_type.name) + if entry.visibility != 'extern': + return parent_slot + return None + + +def get_slot_function(scope, slot): + # Returns the function implementing this slot in the baseclass. + # This is useful for enabling the compiler to optimize calls + # that recursively climb the class hierarchy. + slot_code = slot.slot_code(scope) + if slot_code != '0': + entry = scope.parent_scope.lookup_here(scope.parent_type.name) + if entry.visibility != 'extern': + return slot_code + return None + + +def get_slot_by_name(slot_name): + # For now, only search the type struct, no referenced sub-structs. + for slot in slot_table: + if slot.slot_name == slot_name: + return slot + assert False, "Slot not found: %s" % slot_name + + +def get_slot_code_by_name(scope, slot_name): + slot = get_slot_by_name(slot_name) + return slot.slot_code(scope) + +def is_reverse_number_slot(name): + """ + Tries to identify __radd__ and friends (so the METH_COEXIST flag can be applied). + + There's no great consequence if it inadvertently identifies a few other methods + so just use a simple rule rather than an exact list. + """ + if name.startswith("__r") and name.endswith("__"): + forward_name = name.replace("r", "", 1) + for meth in PyNumberMethods: + if getattr(meth, "method_name", None) == forward_name: + return True + return False + + +#------------------------------------------------------------------------------------------ +# +# Signatures for generic Python functions and methods. +# +#------------------------------------------------------------------------------------------ + +pyfunction_signature = Signature("-*", "O") +pymethod_signature = Signature("T*", "O") + +#------------------------------------------------------------------------------------------ +# +# Signatures for simple Python functions. +# +#------------------------------------------------------------------------------------------ + +pyfunction_noargs = Signature("-", "O") +pyfunction_onearg = Signature("-O", "O") + +#------------------------------------------------------------------------------------------ +# +# Signatures for the various kinds of function that +# can appear in the type object and its substructures. +# +#------------------------------------------------------------------------------------------ + +unaryfunc = Signature("T", "O") # typedef PyObject * (*unaryfunc)(PyObject *); +binaryfunc = Signature("OO", "O") # typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); +ibinaryfunc = Signature("TO", "O") # typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); +ternaryfunc = Signature("OOO", "O") # typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); +iternaryfunc = Signature("TOO", "O") # typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); +callfunc = Signature("T*", "O") # typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); +inquiry = Signature("T", "i") # typedef int (*inquiry)(PyObject *); +lenfunc = Signature("T", "z") # typedef Py_ssize_t (*lenfunc)(PyObject *); + + # typedef int (*coercion)(PyObject **, PyObject **); +intargfunc = Signature("Ti", "O") # typedef PyObject *(*intargfunc)(PyObject *, int); +ssizeargfunc = Signature("Tz", "O") # typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); +intintargfunc = Signature("Tii", "O") # typedef PyObject *(*intintargfunc)(PyObject *, int, int); +ssizessizeargfunc = Signature("Tzz", "O") # typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); +intobjargproc = Signature("TiO", 'r') # typedef int(*intobjargproc)(PyObject *, int, PyObject *); +ssizeobjargproc = Signature("TzO", 'r') # typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); +intintobjargproc = Signature("TiiO", 'r') # typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *); +ssizessizeobjargproc = Signature("TzzO", 'r') # typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); + +intintargproc = Signature("Tii", 'r') +ssizessizeargproc = Signature("Tzz", 'r') +objargfunc = Signature("TO", "O") +objobjargproc = Signature("TOO", 'r') # typedef int (*objobjargproc)(PyObject *, PyObject *, PyObject *); +readbufferproc = Signature("TzP", "z") # typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **); +writebufferproc = Signature("TzP", "z") # typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **); +segcountproc = Signature("TZ", "z") # typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *); +charbufferproc = Signature("TzS", "z") # typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **); +objargproc = Signature("TO", 'r') # typedef int (*objobjproc)(PyObject *, PyObject *); + # typedef int (*visitproc)(PyObject *, void *); + # typedef int (*traverseproc)(PyObject *, visitproc, void *); + +destructor = Signature("T", "v") # typedef void (*destructor)(PyObject *); +# printfunc = Signature("TFi", 'r') # typedef int (*printfunc)(PyObject *, FILE *, int); + # typedef PyObject *(*getattrfunc)(PyObject *, char *); +getattrofunc = Signature("TO", "O") # typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); + # typedef int (*setattrfunc)(PyObject *, char *, PyObject *); +setattrofunc = Signature("TOO", 'r') # typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); +delattrofunc = Signature("TO", 'r') +cmpfunc = Signature("TO", "i") # typedef int (*cmpfunc)(PyObject *, PyObject *); +reprfunc = Signature("T", "O") # typedef PyObject *(*reprfunc)(PyObject *); +hashfunc = Signature("T", "h") # typedef Py_hash_t (*hashfunc)(PyObject *); +richcmpfunc = Signature("TOi", "O") # typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); +getiterfunc = Signature("T", "O") # typedef PyObject *(*getiterfunc) (PyObject *); +iternextfunc = Signature("T", "O") # typedef PyObject *(*iternextfunc) (PyObject *); +descrgetfunc = Signature("TOO", "O") # typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); +descrsetfunc = Signature("TOO", 'r') # typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); +descrdelfunc = Signature("TO", 'r') +initproc = Signature("T*", 'r') # typedef int (*initproc)(PyObject *, PyObject *, PyObject *); + # typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); + # typedef PyObject *(*allocfunc)(struct _typeobject *, int); + +getbufferproc = Signature("TBi", "r") # typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); +releasebufferproc = Signature("TB", "v") # typedef void (*releasebufferproc)(PyObject *, Py_buffer *); + + +#------------------------------------------------------------------------------------------ +# +# Signatures for accessor methods of properties. +# +#------------------------------------------------------------------------------------------ + +property_accessor_signatures = { + '__get__': Signature("T", "O"), + '__set__': Signature("TO", 'r'), + '__del__': Signature("T", 'r') +} + +#------------------------------------------------------------------------------------------ +# +# Descriptor tables for the slots of the various type object +# substructures, in the order they appear in the structure. +# +#------------------------------------------------------------------------------------------ + +PyNumberMethods_Py3_GUARD = "PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)" + +PyNumberMethods = ( + MethodSlot(binaryfunc, "nb_add", "__add__"), + MethodSlot(binaryfunc, "nb_subtract", "__sub__"), + MethodSlot(binaryfunc, "nb_multiply", "__mul__"), + MethodSlot(binaryfunc, "nb_divide", "__div__", ifdef = PyNumberMethods_Py3_GUARD), + MethodSlot(binaryfunc, "nb_remainder", "__mod__"), + MethodSlot(binaryfunc, "nb_divmod", "__divmod__"), + MethodSlot(ternaryfunc, "nb_power", "__pow__"), + MethodSlot(unaryfunc, "nb_negative", "__neg__"), + MethodSlot(unaryfunc, "nb_positive", "__pos__"), + MethodSlot(unaryfunc, "nb_absolute", "__abs__"), + MethodSlot(inquiry, "nb_nonzero", "__nonzero__", py3 = ("nb_bool", "__bool__")), + MethodSlot(unaryfunc, "nb_invert", "__invert__"), + MethodSlot(binaryfunc, "nb_lshift", "__lshift__"), + MethodSlot(binaryfunc, "nb_rshift", "__rshift__"), + MethodSlot(binaryfunc, "nb_and", "__and__"), + MethodSlot(binaryfunc, "nb_xor", "__xor__"), + MethodSlot(binaryfunc, "nb_or", "__or__"), + EmptySlot("nb_coerce", ifdef = PyNumberMethods_Py3_GUARD), + MethodSlot(unaryfunc, "nb_int", "__int__", fallback="__long__"), + MethodSlot(unaryfunc, "nb_long", "__long__", fallback="__int__", py3 = "<RESERVED>"), + MethodSlot(unaryfunc, "nb_float", "__float__"), + MethodSlot(unaryfunc, "nb_oct", "__oct__", ifdef = PyNumberMethods_Py3_GUARD), + MethodSlot(unaryfunc, "nb_hex", "__hex__", ifdef = PyNumberMethods_Py3_GUARD), + + # Added in release 2.0 + MethodSlot(ibinaryfunc, "nb_inplace_add", "__iadd__"), + MethodSlot(ibinaryfunc, "nb_inplace_subtract", "__isub__"), + MethodSlot(ibinaryfunc, "nb_inplace_multiply", "__imul__"), + MethodSlot(ibinaryfunc, "nb_inplace_divide", "__idiv__", ifdef = PyNumberMethods_Py3_GUARD), + MethodSlot(ibinaryfunc, "nb_inplace_remainder", "__imod__"), + MethodSlot(ibinaryfunc, "nb_inplace_power", "__ipow__"), # actually ternaryfunc!!! + MethodSlot(ibinaryfunc, "nb_inplace_lshift", "__ilshift__"), + MethodSlot(ibinaryfunc, "nb_inplace_rshift", "__irshift__"), + MethodSlot(ibinaryfunc, "nb_inplace_and", "__iand__"), + MethodSlot(ibinaryfunc, "nb_inplace_xor", "__ixor__"), + MethodSlot(ibinaryfunc, "nb_inplace_or", "__ior__"), + + # Added in release 2.2 + # The following require the Py_TPFLAGS_HAVE_CLASS flag + MethodSlot(binaryfunc, "nb_floor_divide", "__floordiv__"), + MethodSlot(binaryfunc, "nb_true_divide", "__truediv__"), + MethodSlot(ibinaryfunc, "nb_inplace_floor_divide", "__ifloordiv__"), + MethodSlot(ibinaryfunc, "nb_inplace_true_divide", "__itruediv__"), + + # Added in release 2.5 + MethodSlot(unaryfunc, "nb_index", "__index__"), + + # Added in release 3.5 + MethodSlot(binaryfunc, "nb_matrix_multiply", "__matmul__", ifdef="PY_VERSION_HEX >= 0x03050000"), + MethodSlot(ibinaryfunc, "nb_inplace_matrix_multiply", "__imatmul__", ifdef="PY_VERSION_HEX >= 0x03050000"), +) + +PySequenceMethods = ( + MethodSlot(lenfunc, "sq_length", "__len__"), + EmptySlot("sq_concat"), # nb_add used instead + EmptySlot("sq_repeat"), # nb_multiply used instead + SyntheticSlot("sq_item", ["__getitem__"], "0"), #EmptySlot("sq_item"), # mp_subscript used instead + MethodSlot(ssizessizeargfunc, "sq_slice", "__getslice__"), + EmptySlot("sq_ass_item"), # mp_ass_subscript used instead + SyntheticSlot("sq_ass_slice", ["__setslice__", "__delslice__"], "0"), + MethodSlot(cmpfunc, "sq_contains", "__contains__"), + EmptySlot("sq_inplace_concat"), # nb_inplace_add used instead + EmptySlot("sq_inplace_repeat"), # nb_inplace_multiply used instead +) + +PyMappingMethods = ( + MethodSlot(lenfunc, "mp_length", "__len__"), + MethodSlot(objargfunc, "mp_subscript", "__getitem__"), + SyntheticSlot("mp_ass_subscript", ["__setitem__", "__delitem__"], "0"), +) + +PyBufferProcs = ( + MethodSlot(readbufferproc, "bf_getreadbuffer", "__getreadbuffer__", py3 = False), + MethodSlot(writebufferproc, "bf_getwritebuffer", "__getwritebuffer__", py3 = False), + MethodSlot(segcountproc, "bf_getsegcount", "__getsegcount__", py3 = False), + MethodSlot(charbufferproc, "bf_getcharbuffer", "__getcharbuffer__", py3 = False), + + MethodSlot(getbufferproc, "bf_getbuffer", "__getbuffer__"), + MethodSlot(releasebufferproc, "bf_releasebuffer", "__releasebuffer__") +) + +PyAsyncMethods = ( + MethodSlot(unaryfunc, "am_await", "__await__"), + MethodSlot(unaryfunc, "am_aiter", "__aiter__"), + MethodSlot(unaryfunc, "am_anext", "__anext__"), + EmptySlot("am_send", ifdef="PY_VERSION_HEX >= 0x030A00A3"), +) + +#------------------------------------------------------------------------------------------ +# +# The main slot table. This table contains descriptors for all the +# top-level type slots, beginning with tp_dealloc, in the order they +# appear in the type object. +# +#------------------------------------------------------------------------------------------ + +slot_table = ( + ConstructorSlot("tp_dealloc", '__dealloc__'), + EmptySlot("tp_print", ifdef="PY_VERSION_HEX < 0x030800b4"), + EmptySlot("tp_vectorcall_offset", ifdef="PY_VERSION_HEX >= 0x030800b4"), + EmptySlot("tp_getattr"), + EmptySlot("tp_setattr"), + + # tp_compare (Py2) / tp_reserved (Py3<3.5) / tp_as_async (Py3.5+) is always used as tp_as_async in Py3 + MethodSlot(cmpfunc, "tp_compare", "__cmp__", ifdef="PY_MAJOR_VERSION < 3"), + SuiteSlot(PyAsyncMethods, "__Pyx_PyAsyncMethodsStruct", "tp_as_async", ifdef="PY_MAJOR_VERSION >= 3"), + + MethodSlot(reprfunc, "tp_repr", "__repr__"), + + SuiteSlot(PyNumberMethods, "PyNumberMethods", "tp_as_number"), + SuiteSlot(PySequenceMethods, "PySequenceMethods", "tp_as_sequence"), + SuiteSlot(PyMappingMethods, "PyMappingMethods", "tp_as_mapping"), + + MethodSlot(hashfunc, "tp_hash", "__hash__", inherited=False), # Py3 checks for __richcmp__ + MethodSlot(callfunc, "tp_call", "__call__"), + MethodSlot(reprfunc, "tp_str", "__str__"), + + SyntheticSlot("tp_getattro", ["__getattr__","__getattribute__"], "0"), #"PyObject_GenericGetAttr"), + SyntheticSlot("tp_setattro", ["__setattr__", "__delattr__"], "0"), #"PyObject_GenericSetAttr"), + + SuiteSlot(PyBufferProcs, "PyBufferProcs", "tp_as_buffer"), + + TypeFlagsSlot("tp_flags"), + DocStringSlot("tp_doc"), + + GCDependentSlot("tp_traverse"), + GCClearReferencesSlot("tp_clear"), + + RichcmpSlot(richcmpfunc, "tp_richcompare", "__richcmp__", inherited=False), # Py3 checks for __hash__ + + EmptySlot("tp_weaklistoffset"), + + MethodSlot(getiterfunc, "tp_iter", "__iter__"), + MethodSlot(iternextfunc, "tp_iternext", "__next__"), + + MethodTableSlot("tp_methods"), + MemberTableSlot("tp_members"), + GetSetSlot("tp_getset"), + + BaseClassSlot("tp_base"), #EmptySlot("tp_base"), + EmptySlot("tp_dict"), + + SyntheticSlot("tp_descr_get", ["__get__"], "0"), + SyntheticSlot("tp_descr_set", ["__set__", "__delete__"], "0"), + + DictOffsetSlot("tp_dictoffset"), + + MethodSlot(initproc, "tp_init", "__init__"), + EmptySlot("tp_alloc"), #FixedSlot("tp_alloc", "PyType_GenericAlloc"), + InternalMethodSlot("tp_new"), + EmptySlot("tp_free"), + + EmptySlot("tp_is_gc"), + EmptySlot("tp_bases"), + EmptySlot("tp_mro"), + EmptySlot("tp_cache"), + EmptySlot("tp_subclasses"), + EmptySlot("tp_weaklist"), + EmptySlot("tp_del"), + EmptySlot("tp_version_tag"), + EmptySlot("tp_finalize", ifdef="PY_VERSION_HEX >= 0x030400a1"), + EmptySlot("tp_vectorcall", ifdef="PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)"), + EmptySlot("tp_print", ifdef="PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000"), + # PyPy specific extension - only here to avoid C compiler warnings. + EmptySlot("tp_pypy_flags", ifdef="CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000"), +) + +#------------------------------------------------------------------------------------------ +# +# Descriptors for special methods which don't appear directly +# in the type object or its substructures. These methods are +# called from slot functions synthesized by Cython. +# +#------------------------------------------------------------------------------------------ + +MethodSlot(initproc, "", "__cinit__") +MethodSlot(destructor, "", "__dealloc__") +MethodSlot(objobjargproc, "", "__setitem__") +MethodSlot(objargproc, "", "__delitem__") +MethodSlot(ssizessizeobjargproc, "", "__setslice__") +MethodSlot(ssizessizeargproc, "", "__delslice__") +MethodSlot(getattrofunc, "", "__getattr__") +MethodSlot(getattrofunc, "", "__getattribute__") +MethodSlot(setattrofunc, "", "__setattr__") +MethodSlot(delattrofunc, "", "__delattr__") +MethodSlot(descrgetfunc, "", "__get__") +MethodSlot(descrsetfunc, "", "__set__") +MethodSlot(descrdelfunc, "", "__delete__") + + +# Method flags for python-exposed methods. + +method_noargs = "METH_NOARGS" +method_onearg = "METH_O" +method_varargs = "METH_VARARGS" +method_keywords = "METH_KEYWORDS" +method_coexist = "METH_COEXIST" diff --git a/contrib/tools/cython/Cython/Compiler/UtilNodes.py b/contrib/tools/cython/Cython/Compiler/UtilNodes.py new file mode 100644 index 00000000000..c41748ace08 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/UtilNodes.py @@ -0,0 +1,359 @@ +# +# Nodes used as utilities and support for transforms etc. +# These often make up sets including both Nodes and ExprNodes +# so it is convenient to have them in a separate module. +# + +from __future__ import absolute_import + +from . import Nodes +from . import ExprNodes +from .Nodes import Node +from .ExprNodes import AtomicExprNode +from .PyrexTypes import c_ptr_type + + +class TempHandle(object): + # THIS IS DEPRECATED, USE LetRefNode instead + temp = None + needs_xdecref = False + def __init__(self, type, needs_cleanup=None): + self.type = type + if needs_cleanup is None: + self.needs_cleanup = type.is_pyobject + else: + self.needs_cleanup = needs_cleanup + + def ref(self, pos): + return TempRefNode(pos, handle=self, type=self.type) + + +class TempRefNode(AtomicExprNode): + # THIS IS DEPRECATED, USE LetRefNode instead + # handle TempHandle + + def analyse_types(self, env): + assert self.type == self.handle.type + return self + + def analyse_target_types(self, env): + assert self.type == self.handle.type + return self + + def analyse_target_declaration(self, env): + pass + + def calculate_result_code(self): + result = self.handle.temp + if result is None: result = "<error>" # might be called and overwritten + return result + + def generate_result_code(self, code): + pass + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False): + if self.type.is_pyobject: + rhs.make_owned_reference(code) + # TODO: analyse control flow to see if this is necessary + code.put_xdecref(self.result(), self.ctype()) + code.putln('%s = %s;' % ( + self.result(), + rhs.result() if overloaded_assignment else rhs.result_as(self.ctype()), + )) + rhs.generate_post_assignment_code(code) + rhs.free_temps(code) + + +class TempsBlockNode(Node): + # THIS IS DEPRECATED, USE LetNode instead + + """ + Creates a block which allocates temporary variables. + This is used by transforms to output constructs that need + to make use of a temporary variable. Simply pass the types + of the needed temporaries to the constructor. + + The variables can be referred to using a TempRefNode + (which can be constructed by calling get_ref_node). + """ + + # temps [TempHandle] + # body StatNode + + child_attrs = ["body"] + + def generate_execution_code(self, code): + for handle in self.temps: + handle.temp = code.funcstate.allocate_temp( + handle.type, manage_ref=handle.needs_cleanup) + self.body.generate_execution_code(code) + for handle in self.temps: + if handle.needs_cleanup: + if handle.needs_xdecref: + code.put_xdecref_clear(handle.temp, handle.type) + else: + code.put_decref_clear(handle.temp, handle.type) + code.funcstate.release_temp(handle.temp) + + def analyse_declarations(self, env): + self.body.analyse_declarations(env) + + def analyse_expressions(self, env): + self.body = self.body.analyse_expressions(env) + return self + + def generate_function_definitions(self, env, code): + self.body.generate_function_definitions(env, code) + + def annotate(self, code): + self.body.annotate(code) + + +class ResultRefNode(AtomicExprNode): + # A reference to the result of an expression. The result_code + # must be set externally (usually a temp name). + + subexprs = [] + lhs_of_first_assignment = False + + def __init__(self, expression=None, pos=None, type=None, may_hold_none=True, is_temp=False): + self.expression = expression + self.pos = None + self.may_hold_none = may_hold_none + if expression is not None: + self.pos = expression.pos + if hasattr(expression, "type"): + self.type = expression.type + if pos is not None: + self.pos = pos + if type is not None: + self.type = type + if is_temp: + self.is_temp = True + assert self.pos is not None + + def clone_node(self): + # nothing to do here + return self + + def type_dependencies(self, env): + if self.expression: + return self.expression.type_dependencies(env) + else: + return () + + def update_expression(self, expression): + self.expression = expression + if hasattr(expression, "type"): + self.type = expression.type + + def analyse_types(self, env): + if self.expression is not None: + if not self.expression.type: + self.expression = self.expression.analyse_types(env) + self.type = self.expression.type + return self + + def infer_type(self, env): + if self.type is not None: + return self.type + if self.expression is not None: + if self.expression.type is not None: + return self.expression.type + return self.expression.infer_type(env) + assert False, "cannot infer type of ResultRefNode" + + def may_be_none(self): + if not self.type.is_pyobject: + return False + return self.may_hold_none + + def _DISABLED_may_be_none(self): + # not sure if this is safe - the expression may not be the + # only value that gets assigned + if self.expression is not None: + return self.expression.may_be_none() + if self.type is not None: + return self.type.is_pyobject + return True # play safe + + def is_simple(self): + return True + + def result(self): + try: + return self.result_code + except AttributeError: + if self.expression is not None: + self.result_code = self.expression.result() + return self.result_code + + def generate_evaluation_code(self, code): + pass + + def generate_result_code(self, code): + pass + + def generate_disposal_code(self, code): + pass + + def generate_assignment_code(self, rhs, code, overloaded_assignment=False): + if self.type.is_pyobject: + rhs.make_owned_reference(code) + if not self.lhs_of_first_assignment: + code.put_decref(self.result(), self.ctype()) + code.putln('%s = %s;' % ( + self.result(), + rhs.result() if overloaded_assignment else rhs.result_as(self.ctype()), + )) + rhs.generate_post_assignment_code(code) + rhs.free_temps(code) + + def allocate_temps(self, env): + pass + + def release_temp(self, env): + pass + + def free_temps(self, code): + pass + + +class LetNodeMixin: + def set_temp_expr(self, lazy_temp): + self.lazy_temp = lazy_temp + self.temp_expression = lazy_temp.expression + + def setup_temp_expr(self, code): + self.temp_expression.generate_evaluation_code(code) + self.temp_type = self.temp_expression.type + if self.temp_type.is_array: + self.temp_type = c_ptr_type(self.temp_type.base_type) + self._result_in_temp = self.temp_expression.result_in_temp() + if self._result_in_temp: + self.temp = self.temp_expression.result() + else: + self.temp_expression.make_owned_reference(code) + self.temp = code.funcstate.allocate_temp( + self.temp_type, manage_ref=True) + code.putln("%s = %s;" % (self.temp, self.temp_expression.result())) + self.temp_expression.generate_disposal_code(code) + self.temp_expression.free_temps(code) + self.lazy_temp.result_code = self.temp + + def teardown_temp_expr(self, code): + if self._result_in_temp: + self.temp_expression.generate_disposal_code(code) + self.temp_expression.free_temps(code) + else: + if self.temp_type.is_pyobject: + code.put_decref_clear(self.temp, self.temp_type) + code.funcstate.release_temp(self.temp) + + +class EvalWithTempExprNode(ExprNodes.ExprNode, LetNodeMixin): + # A wrapper around a subexpression that moves an expression into a + # temp variable and provides it to the subexpression. + + subexprs = ['temp_expression', 'subexpression'] + + def __init__(self, lazy_temp, subexpression): + self.set_temp_expr(lazy_temp) + self.pos = subexpression.pos + self.subexpression = subexpression + # if called after type analysis, we already know the type here + self.type = self.subexpression.type + + def infer_type(self, env): + return self.subexpression.infer_type(env) + + def may_be_none(self): + return self.subexpression.may_be_none() + + def result(self): + return self.subexpression.result() + + def analyse_types(self, env): + self.temp_expression = self.temp_expression.analyse_types(env) + self.lazy_temp.update_expression(self.temp_expression) # overwrite in case it changed + self.subexpression = self.subexpression.analyse_types(env) + self.type = self.subexpression.type + return self + + def free_subexpr_temps(self, code): + self.subexpression.free_temps(code) + + def generate_subexpr_disposal_code(self, code): + self.subexpression.generate_disposal_code(code) + + def generate_evaluation_code(self, code): + self.setup_temp_expr(code) + self.subexpression.generate_evaluation_code(code) + self.teardown_temp_expr(code) + + +LetRefNode = ResultRefNode + + +class LetNode(Nodes.StatNode, LetNodeMixin): + # Implements a local temporary variable scope. Imagine this + # syntax being present: + # let temp = VALUE: + # BLOCK (can modify temp) + # if temp is an object, decref + # + # Usually used after analysis phase, but forwards analysis methods + # to its children + + child_attrs = ['temp_expression', 'body'] + + def __init__(self, lazy_temp, body): + self.set_temp_expr(lazy_temp) + self.pos = body.pos + self.body = body + + def analyse_declarations(self, env): + self.temp_expression.analyse_declarations(env) + self.body.analyse_declarations(env) + + def analyse_expressions(self, env): + self.temp_expression = self.temp_expression.analyse_expressions(env) + self.body = self.body.analyse_expressions(env) + return self + + def generate_execution_code(self, code): + self.setup_temp_expr(code) + self.body.generate_execution_code(code) + self.teardown_temp_expr(code) + + def generate_function_definitions(self, env, code): + self.temp_expression.generate_function_definitions(env, code) + self.body.generate_function_definitions(env, code) + + +class TempResultFromStatNode(ExprNodes.ExprNode): + # An ExprNode wrapper around a StatNode that executes the StatNode + # body. Requires a ResultRefNode that it sets up to refer to its + # own temp result. The StatNode must assign a value to the result + # node, which then becomes the result of this node. + + subexprs = [] + child_attrs = ['body'] + + def __init__(self, result_ref, body): + self.result_ref = result_ref + self.pos = body.pos + self.body = body + self.type = result_ref.type + self.is_temp = 1 + + def analyse_declarations(self, env): + self.body.analyse_declarations(env) + + def analyse_types(self, env): + self.body = self.body.analyse_expressions(env) + return self + + def generate_result_code(self, code): + self.result_ref.result_code = self.result() + self.body.generate_execution_code(code) diff --git a/contrib/tools/cython/Cython/Compiler/UtilityCode.py b/contrib/tools/cython/Cython/Compiler/UtilityCode.py new file mode 100644 index 00000000000..98e9ab5bfbf --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/UtilityCode.py @@ -0,0 +1,237 @@ +from __future__ import absolute_import + +from .TreeFragment import parse_from_strings, StringParseContext +from . import Symtab +from . import Naming +from . import Code + + +class NonManglingModuleScope(Symtab.ModuleScope): + + def __init__(self, prefix, *args, **kw): + self.prefix = prefix + self.cython_scope = None + self.cpp = kw.pop('cpp', False) + Symtab.ModuleScope.__init__(self, *args, **kw) + + def add_imported_entry(self, name, entry, pos): + entry.used = True + return super(NonManglingModuleScope, self).add_imported_entry(name, entry, pos) + + def mangle(self, prefix, name=None): + if name: + if prefix in (Naming.typeobj_prefix, Naming.func_prefix, Naming.var_prefix, Naming.pyfunc_prefix): + # Functions, classes etc. gets a manually defined prefix easily + # manually callable instead (the one passed to CythonUtilityCode) + prefix = self.prefix + return "%s%s" % (prefix, name) + else: + return Symtab.ModuleScope.mangle(self, prefix) + + +class CythonUtilityCodeContext(StringParseContext): + scope = None + + def find_module(self, module_name, relative_to=None, pos=None, need_pxd=True, absolute_fallback=True): + if relative_to: + raise AssertionError("Relative imports not supported in utility code.") + if module_name != self.module_name: + if module_name not in self.modules: + raise AssertionError("Only the cython cimport is supported.") + else: + return self.modules[module_name] + + if self.scope is None: + self.scope = NonManglingModuleScope( + self.prefix, module_name, parent_module=None, context=self, cpp=self.cpp) + + return self.scope + + +class CythonUtilityCode(Code.UtilityCodeBase): + """ + Utility code written in the Cython language itself. + + The @cname decorator can set the cname for a function, method of cdef class. + Functions decorated with @cname('c_func_name') get the given cname. + + For cdef classes the rules are as follows: + obj struct -> <cname>_obj + obj type ptr -> <cname>_type + methods -> <class_cname>_<method_cname> + + For methods the cname decorator is optional, but without the decorator the + methods will not be prototyped. See Cython.Compiler.CythonScope and + tests/run/cythonscope.pyx for examples. + """ + + is_cython_utility = True + + def __init__(self, impl, name="__pyxutil", prefix="", requires=None, + file=None, from_scope=None, context=None, compiler_directives=None, + outer_module_scope=None): + # 1) We need to delay the parsing/processing, so that all modules can be + # imported without import loops + # 2) The same utility code object can be used for multiple source files; + # while the generated node trees can be altered in the compilation of a + # single file. + # Hence, delay any processing until later. + context_types = {} + if context is not None: + from .PyrexTypes import BaseType + for key, value in context.items(): + if isinstance(value, BaseType): + context[key] = key + context_types[key] = value + impl = Code.sub_tempita(impl, context, file, name) + self.impl = impl + self.name = name + self.file = file + self.prefix = prefix + self.requires = requires or [] + self.from_scope = from_scope + self.outer_module_scope = outer_module_scope + self.compiler_directives = compiler_directives + self.context_types = context_types + + def __eq__(self, other): + if isinstance(other, CythonUtilityCode): + return self._equality_params() == other._equality_params() + else: + return False + + def _equality_params(self): + outer_scope = self.outer_module_scope + while isinstance(outer_scope, NonManglingModuleScope): + outer_scope = outer_scope.outer_scope + return self.impl, outer_scope, self.compiler_directives + + def __hash__(self): + return hash(self.impl) + + def get_tree(self, entries_only=False, cython_scope=None): + from .AnalysedTreeTransforms import AutoTestDictTransform + # The AutoTestDictTransform creates the statement "__test__ = {}", + # which when copied into the main ModuleNode overwrites + # any __test__ in user code; not desired + excludes = [AutoTestDictTransform] + + from . import Pipeline, ParseTreeTransforms + context = CythonUtilityCodeContext( + self.name, compiler_directives=self.compiler_directives, + cpp=cython_scope.is_cpp() if cython_scope else False) + context.prefix = self.prefix + context.cython_scope = cython_scope + #context = StringParseContext(self.name) + tree = parse_from_strings( + self.name, self.impl, context=context, allow_struct_enum_decorator=True) + pipeline = Pipeline.create_pipeline(context, 'pyx', exclude_classes=excludes) + + if entries_only: + p = [] + for t in pipeline: + p.append(t) + if isinstance(p, ParseTreeTransforms.AnalyseDeclarationsTransform): + break + + pipeline = p + + transform = ParseTreeTransforms.CnameDirectivesTransform(context) + # InterpretCompilerDirectives already does a cdef declarator check + #before = ParseTreeTransforms.DecoratorTransform + before = ParseTreeTransforms.InterpretCompilerDirectives + pipeline = Pipeline.insert_into_pipeline(pipeline, transform, + before=before) + + def merge_scope(scope): + def merge_scope_transform(module_node): + module_node.scope.merge_in(scope) + return module_node + return merge_scope_transform + + if self.from_scope: + pipeline = Pipeline.insert_into_pipeline( + pipeline, merge_scope(self.from_scope), + before=ParseTreeTransforms.AnalyseDeclarationsTransform) + + for dep in self.requires: + if isinstance(dep, CythonUtilityCode) and hasattr(dep, 'tree') and not cython_scope: + pipeline = Pipeline.insert_into_pipeline( + pipeline, merge_scope(dep.tree.scope), + before=ParseTreeTransforms.AnalyseDeclarationsTransform) + + if self.outer_module_scope: + # inject outer module between utility code module and builtin module + def scope_transform(module_node): + module_node.scope.outer_scope = self.outer_module_scope + return module_node + + pipeline = Pipeline.insert_into_pipeline( + pipeline, scope_transform, + before=ParseTreeTransforms.AnalyseDeclarationsTransform) + + if self.context_types: + # inject types into module scope + def scope_transform(module_node): + for name, type in self.context_types.items(): + entry = module_node.scope.declare_type(name, type, None, visibility='extern') + entry.in_cinclude = True + return module_node + + pipeline = Pipeline.insert_into_pipeline( + pipeline, scope_transform, + before=ParseTreeTransforms.AnalyseDeclarationsTransform) + + (err, tree) = Pipeline.run_pipeline(pipeline, tree, printtree=False) + assert not err, err + self.tree = tree + return tree + + def put_code(self, output): + pass + + @classmethod + def load_as_string(cls, util_code_name, from_file=None, **kwargs): + """ + Load a utility code as a string. Returns (proto, implementation) + """ + util = cls.load(util_code_name, from_file, **kwargs) + return util.proto, util.impl # keep line numbers => no lstrip() + + def declare_in_scope(self, dest_scope, used=False, cython_scope=None, + whitelist=None): + """ + Declare all entries from the utility code in dest_scope. Code will only + be included for used entries. If module_name is given, declare the + type entries with that name. + """ + tree = self.get_tree(entries_only=True, cython_scope=cython_scope) + + entries = tree.scope.entries + entries.pop('__name__') + entries.pop('__file__') + entries.pop('__builtins__') + entries.pop('__doc__') + + for entry in entries.values(): + entry.utility_code_definition = self + entry.used = used + + original_scope = tree.scope + dest_scope.merge_in(original_scope, merge_unused=True, whitelist=whitelist) + tree.scope = dest_scope + + for dep in self.requires: + if dep.is_cython_utility: + dep.declare_in_scope(dest_scope, cython_scope=cython_scope) + + return original_scope + + +def declare_declarations_in_scope(declaration_string, env, private_type=True, + *args, **kwargs): + """ + Declare some declarations given as Cython code in declaration_string + in scope env. + """ + CythonUtilityCode(declaration_string, *args, **kwargs).declare_in_scope(env) diff --git a/contrib/tools/cython/Cython/Compiler/Version.py b/contrib/tools/cython/Cython/Compiler/Version.py new file mode 100644 index 00000000000..dcb561f78c0 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Version.py @@ -0,0 +1,9 @@ +# for backwards compatibility + +from __future__ import absolute_import + +from .. import __version__ as version + +# For 'generated by' header line in C files. + +watermark = str(version) diff --git a/contrib/tools/cython/Cython/Compiler/Visitor.pxd b/contrib/tools/cython/Cython/Compiler/Visitor.pxd new file mode 100644 index 00000000000..d5d5692aa71 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Visitor.pxd @@ -0,0 +1,55 @@ +from __future__ import absolute_import + +cimport cython + +cdef class TreeVisitor: + cdef public list access_path + cdef dict dispatch_table + + cpdef visit(self, obj) + cdef _visit(self, obj) + cdef find_handler(self, obj) + cdef _visitchild(self, child, parent, attrname, idx) + cdef dict _visitchildren(self, parent, attrs) + cpdef visitchildren(self, parent, attrs=*) + cdef _raise_compiler_error(self, child, e) + +cdef class VisitorTransform(TreeVisitor): + cdef dict _process_children(self, parent, attrs=*) + cpdef visitchildren(self, parent, attrs=*, exclude=*) + cdef list _flatten_list(self, list orig_list) + cdef list _select_attrs(self, attrs, exclude) + +cdef class CythonTransform(VisitorTransform): + cdef public context + cdef public current_directives + +cdef class ScopeTrackingTransform(CythonTransform): + cdef public scope_type + cdef public scope_node + cdef visit_scope(self, node, scope_type) + +cdef class EnvTransform(CythonTransform): + cdef public list env_stack + +cdef class MethodDispatcherTransform(EnvTransform): + @cython.final + cdef _visit_binop_node(self, node) + @cython.final + cdef _find_handler(self, match_name, bint has_kwargs) + @cython.final + cdef _delegate_to_assigned_value(self, node, function, arg_list, kwargs) + @cython.final + cdef _dispatch_to_handler(self, node, function, arg_list, kwargs) + @cython.final + cdef _dispatch_to_method_handler(self, attr_name, self_arg, + is_unbound_method, type_name, + node, function, arg_list, kwargs) + +cdef class RecursiveNodeReplacer(VisitorTransform): + cdef public orig_node + cdef public new_node + +cdef class NodeFinder(TreeVisitor): + cdef node + cdef public bint found diff --git a/contrib/tools/cython/Cython/Compiler/Visitor.py b/contrib/tools/cython/Cython/Compiler/Visitor.py new file mode 100644 index 00000000000..a35d13e1d00 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/Visitor.py @@ -0,0 +1,840 @@ +# cython: infer_types=True +# cython: language_level=3 +# cython: auto_pickle=False + +# +# Tree visitor and transform framework +# + +from __future__ import absolute_import, print_function + +import sys +import inspect + +from . import TypeSlots +from . import Builtin +from . import Nodes +from . import ExprNodes +from . import Errors +from . import DebugFlags +from . import Future + +import cython + + +cython.declare(_PRINTABLE=tuple) + +if sys.version_info[0] >= 3: + _PRINTABLE = (bytes, str, int, float) +else: + _PRINTABLE = (str, unicode, long, int, float) + + +class TreeVisitor(object): + """ + Base class for writing visitors for a Cython tree, contains utilities for + recursing such trees using visitors. Each node is + expected to have a child_attrs iterable containing the names of attributes + containing child nodes or lists of child nodes. Lists are not considered + part of the tree structure (i.e. contained nodes are considered direct + children of the parent node). + + visit_children visits each of the children of a given node (see the visit_children + documentation). When recursing the tree using visit_children, an attribute + access_path is maintained which gives information about the current location + in the tree as a stack of tuples: (parent_node, attrname, index), representing + the node, attribute and optional list index that was taken in each step in the path to + the current node. + + Example: + + >>> class SampleNode(object): + ... child_attrs = ["head", "body"] + ... def __init__(self, value, head=None, body=None): + ... self.value = value + ... self.head = head + ... self.body = body + ... def __repr__(self): return "SampleNode(%s)" % self.value + ... + >>> tree = SampleNode(0, SampleNode(1), [SampleNode(2), SampleNode(3)]) + >>> class MyVisitor(TreeVisitor): + ... def visit_SampleNode(self, node): + ... print("in %s %s" % (node.value, self.access_path)) + ... self.visitchildren(node) + ... print("out %s" % node.value) + ... + >>> MyVisitor().visit(tree) + in 0 [] + in 1 [(SampleNode(0), 'head', None)] + out 1 + in 2 [(SampleNode(0), 'body', 0)] + out 2 + in 3 [(SampleNode(0), 'body', 1)] + out 3 + out 0 + """ + def __init__(self): + super(TreeVisitor, self).__init__() + self.dispatch_table = {} + self.access_path = [] + + def dump_node(self, node): + ignored = list(node.child_attrs or []) + [ + u'child_attrs', u'pos', u'gil_message', u'cpp_message', u'subexprs'] + values = [] + pos = getattr(node, 'pos', None) + if pos: + source = pos[0] + if source: + import os.path + source = os.path.basename(source.get_description()) + values.append(u'%s:%s:%s' % (source, pos[1], pos[2])) + attribute_names = dir(node) + for attr in attribute_names: + if attr in ignored: + continue + if attr.startswith('_') or attr.endswith('_'): + continue + try: + value = getattr(node, attr) + except AttributeError: + continue + if value is None or value == 0: + continue + elif isinstance(value, list): + value = u'[...]/%d' % len(value) + elif not isinstance(value, _PRINTABLE): + continue + else: + value = repr(value) + values.append(u'%s = %s' % (attr, value)) + return u'%s(%s)' % (node.__class__.__name__, u',\n '.join(values)) + + def _find_node_path(self, stacktrace): + import os.path + last_traceback = stacktrace + nodes = [] + while hasattr(stacktrace, 'tb_frame'): + frame = stacktrace.tb_frame + node = frame.f_locals.get(u'self') + if isinstance(node, Nodes.Node): + code = frame.f_code + method_name = code.co_name + pos = (os.path.basename(code.co_filename), + frame.f_lineno) + nodes.append((node, method_name, pos)) + last_traceback = stacktrace + stacktrace = stacktrace.tb_next + return (last_traceback, nodes) + + def _raise_compiler_error(self, child, e): + trace = [''] + for parent, attribute, index in self.access_path: + node = getattr(parent, attribute) + if index is None: + index = '' + else: + node = node[index] + index = u'[%d]' % index + trace.append(u'%s.%s%s = %s' % ( + parent.__class__.__name__, attribute, index, + self.dump_node(node))) + stacktrace, called_nodes = self._find_node_path(sys.exc_info()[2]) + last_node = child + for node, method_name, pos in called_nodes: + last_node = node + trace.append(u"File '%s', line %d, in %s: %s" % ( + pos[0], pos[1], method_name, self.dump_node(node))) + raise Errors.CompilerCrash( + getattr(last_node, 'pos', None), self.__class__.__name__, + u'\n'.join(trace), e, stacktrace) + + @cython.final + def find_handler(self, obj): + # to resolve, try entire hierarchy + cls = type(obj) + pattern = "visit_%s" + mro = inspect.getmro(cls) + for mro_cls in mro: + handler_method = getattr(self, pattern % mro_cls.__name__, None) + if handler_method is not None: + return handler_method + print(type(self), cls) + if self.access_path: + print(self.access_path) + print(self.access_path[-1][0].pos) + print(self.access_path[-1][0].__dict__) + raise RuntimeError("Visitor %r does not accept object: %s" % (self, obj)) + + def visit(self, obj): + return self._visit(obj) + + @cython.final + def _visit(self, obj): + try: + try: + handler_method = self.dispatch_table[type(obj)] + except KeyError: + handler_method = self.find_handler(obj) + self.dispatch_table[type(obj)] = handler_method + return handler_method(obj) + except Errors.CompileError: + raise + except Errors.AbortError: + raise + except Exception as e: + if DebugFlags.debug_no_exception_intercept: + raise + self._raise_compiler_error(obj, e) + + @cython.final + def _visitchild(self, child, parent, attrname, idx): + self.access_path.append((parent, attrname, idx)) + result = self._visit(child) + self.access_path.pop() + return result + + def visitchildren(self, parent, attrs=None): + return self._visitchildren(parent, attrs) + + @cython.final + @cython.locals(idx=cython.Py_ssize_t) + def _visitchildren(self, parent, attrs): + """ + Visits the children of the given parent. If parent is None, returns + immediately (returning None). + + The return value is a dictionary giving the results for each + child (mapping the attribute name to either the return value + or a list of return values (in the case of multiple children + in an attribute)). + """ + if parent is None: return None + result = {} + for attr in parent.child_attrs: + if attrs is not None and attr not in attrs: continue + child = getattr(parent, attr) + if child is not None: + if type(child) is list: + childretval = [self._visitchild(x, parent, attr, idx) for idx, x in enumerate(child)] + else: + childretval = self._visitchild(child, parent, attr, None) + assert not isinstance(childretval, list), 'Cannot insert list here: %s in %r' % (attr, parent) + result[attr] = childretval + return result + + +class VisitorTransform(TreeVisitor): + """ + A tree transform is a base class for visitors that wants to do stream + processing of the structure (rather than attributes etc.) of a tree. + + It implements __call__ to simply visit the argument node. + + It requires the visitor methods to return the nodes which should take + the place of the visited node in the result tree (which can be the same + or one or more replacement). Specifically, if the return value from + a visitor method is: + + - [] or None; the visited node will be removed (set to None if an attribute and + removed if in a list) + - A single node; the visited node will be replaced by the returned node. + - A list of nodes; the visited nodes will be replaced by all the nodes in the + list. This will only work if the node was already a member of a list; if it + was not, an exception will be raised. (Typically you want to ensure that you + are within a StatListNode or similar before doing this.) + """ + def visitchildren(self, parent, attrs=None, exclude=None): + # generic def entry point for calls from Python subclasses + if exclude is not None: + attrs = self._select_attrs(parent.child_attrs if attrs is None else attrs, exclude) + return self._process_children(parent, attrs) + + @cython.final + def _select_attrs(self, attrs, exclude): + return [name for name in attrs if name not in exclude] + + @cython.final + def _process_children(self, parent, attrs=None): + # fast cdef entry point for calls from Cython subclasses + result = self._visitchildren(parent, attrs) + for attr, newnode in result.items(): + if type(newnode) is list: + newnode = self._flatten_list(newnode) + setattr(parent, attr, newnode) + return result + + @cython.final + def _flatten_list(self, orig_list): + # Flatten the list one level and remove any None + newlist = [] + for x in orig_list: + if x is not None: + if type(x) is list: + newlist.extend(x) + else: + newlist.append(x) + return newlist + + def recurse_to_children(self, node): + self._process_children(node) + return node + + def __call__(self, root): + return self._visit(root) + + +class CythonTransform(VisitorTransform): + """ + Certain common conventions and utilities for Cython transforms. + + - Sets up the context of the pipeline in self.context + - Tracks directives in effect in self.current_directives + """ + def __init__(self, context): + super(CythonTransform, self).__init__() + self.context = context + + def __call__(self, node): + from . import ModuleNode + if isinstance(node, ModuleNode.ModuleNode): + self.current_directives = node.directives + return super(CythonTransform, self).__call__(node) + + def visit_CompilerDirectivesNode(self, node): + old = self.current_directives + self.current_directives = node.directives + self._process_children(node) + self.current_directives = old + return node + + def visit_Node(self, node): + self._process_children(node) + return node + + +class ScopeTrackingTransform(CythonTransform): + # Keeps track of type of scopes + #scope_type: can be either of 'module', 'function', 'cclass', 'pyclass', 'struct' + #scope_node: the node that owns the current scope + + def visit_ModuleNode(self, node): + self.scope_type = 'module' + self.scope_node = node + self._process_children(node) + return node + + def visit_scope(self, node, scope_type): + prev = self.scope_type, self.scope_node + self.scope_type = scope_type + self.scope_node = node + self._process_children(node) + self.scope_type, self.scope_node = prev + return node + + def visit_CClassDefNode(self, node): + return self.visit_scope(node, 'cclass') + + def visit_PyClassDefNode(self, node): + return self.visit_scope(node, 'pyclass') + + def visit_FuncDefNode(self, node): + return self.visit_scope(node, 'function') + + def visit_CStructOrUnionDefNode(self, node): + return self.visit_scope(node, 'struct') + + +class EnvTransform(CythonTransform): + """ + This transformation keeps a stack of the environments. + """ + def __call__(self, root): + self.env_stack = [] + self.enter_scope(root, root.scope) + return super(EnvTransform, self).__call__(root) + + def current_env(self): + return self.env_stack[-1][1] + + def current_scope_node(self): + return self.env_stack[-1][0] + + def global_scope(self): + return self.current_env().global_scope() + + def enter_scope(self, node, scope): + self.env_stack.append((node, scope)) + + def exit_scope(self): + self.env_stack.pop() + + def visit_FuncDefNode(self, node): + self.enter_scope(node, node.local_scope) + self._process_children(node) + self.exit_scope() + return node + + def visit_GeneratorBodyDefNode(self, node): + self._process_children(node) + return node + + def visit_ClassDefNode(self, node): + self.enter_scope(node, node.scope) + self._process_children(node) + self.exit_scope() + return node + + def visit_CStructOrUnionDefNode(self, node): + self.enter_scope(node, node.scope) + self._process_children(node) + self.exit_scope() + return node + + def visit_ScopedExprNode(self, node): + if node.expr_scope: + self.enter_scope(node, node.expr_scope) + self._process_children(node) + self.exit_scope() + else: + self._process_children(node) + return node + + def visit_CArgDeclNode(self, node): + # default arguments are evaluated in the outer scope + if node.default: + attrs = [attr for attr in node.child_attrs if attr != 'default'] + self._process_children(node, attrs) + self.enter_scope(node, self.current_env().outer_scope) + self.visitchildren(node, ('default',)) + self.exit_scope() + else: + self._process_children(node) + return node + + +class NodeRefCleanupMixin(object): + """ + Clean up references to nodes that were replaced. + + NOTE: this implementation assumes that the replacement is + done first, before hitting any further references during + normal tree traversal. This needs to be arranged by calling + "self.visitchildren()" at a proper place in the transform + and by ordering the "child_attrs" of nodes appropriately. + """ + def __init__(self, *args): + super(NodeRefCleanupMixin, self).__init__(*args) + self._replacements = {} + + def visit_CloneNode(self, node): + arg = node.arg + if arg not in self._replacements: + self.visitchildren(arg) + node.arg = self._replacements.get(arg, arg) + return node + + def visit_ResultRefNode(self, node): + expr = node.expression + if expr is None or expr not in self._replacements: + self.visitchildren(node) + expr = node.expression + if expr is not None: + node.expression = self._replacements.get(expr, expr) + return node + + def replace(self, node, replacement): + self._replacements[node] = replacement + return replacement + + +find_special_method_for_binary_operator = { + '<': '__lt__', + '<=': '__le__', + '==': '__eq__', + '!=': '__ne__', + '>=': '__ge__', + '>': '__gt__', + '+': '__add__', + '&': '__and__', + '/': '__div__', + '//': '__floordiv__', + '<<': '__lshift__', + '%': '__mod__', + '*': '__mul__', + '|': '__or__', + '**': '__pow__', + '>>': '__rshift__', + '-': '__sub__', + '^': '__xor__', + 'in': '__contains__', +}.get + + +find_special_method_for_unary_operator = { + 'not': '__not__', + '~': '__inv__', + '-': '__neg__', + '+': '__pos__', +}.get + + +class MethodDispatcherTransform(EnvTransform): + """ + Base class for transformations that want to intercept on specific + builtin functions or methods of builtin types, including special + methods triggered by Python operators. Must run after declaration + analysis when entries were assigned. + + Naming pattern for handler methods is as follows: + + * builtin functions: _handle_(general|simple|any)_function_NAME + + * builtin methods: _handle_(general|simple|any)_method_TYPENAME_METHODNAME + """ + # only visit call nodes and Python operations + def visit_GeneralCallNode(self, node): + self._process_children(node) + function = node.function + if not function.type.is_pyobject: + return node + arg_tuple = node.positional_args + if not isinstance(arg_tuple, ExprNodes.TupleNode): + return node + keyword_args = node.keyword_args + if keyword_args and not isinstance(keyword_args, ExprNodes.DictNode): + # can't handle **kwargs + return node + args = arg_tuple.args + return self._dispatch_to_handler(node, function, args, keyword_args) + + def visit_SimpleCallNode(self, node): + self._process_children(node) + function = node.function + if function.type.is_pyobject: + arg_tuple = node.arg_tuple + if not isinstance(arg_tuple, ExprNodes.TupleNode): + return node + args = arg_tuple.args + else: + args = node.args + return self._dispatch_to_handler(node, function, args, None) + + def visit_PrimaryCmpNode(self, node): + if node.cascade: + # not currently handled below + self._process_children(node) + return node + return self._visit_binop_node(node) + + def visit_BinopNode(self, node): + return self._visit_binop_node(node) + + def _visit_binop_node(self, node): + self._process_children(node) + # FIXME: could special case 'not_in' + special_method_name = find_special_method_for_binary_operator(node.operator) + if special_method_name: + operand1, operand2 = node.operand1, node.operand2 + if special_method_name == '__contains__': + operand1, operand2 = operand2, operand1 + elif special_method_name == '__div__': + if Future.division in self.current_env().global_scope().context.future_directives: + special_method_name = '__truediv__' + obj_type = operand1.type + if obj_type.is_builtin_type: + type_name = obj_type.name + else: + type_name = "object" # safety measure + node = self._dispatch_to_method_handler( + special_method_name, None, False, type_name, + node, None, [operand1, operand2], None) + return node + + def visit_UnopNode(self, node): + self._process_children(node) + special_method_name = find_special_method_for_unary_operator(node.operator) + if special_method_name: + operand = node.operand + obj_type = operand.type + if obj_type.is_builtin_type: + type_name = obj_type.name + else: + type_name = "object" # safety measure + node = self._dispatch_to_method_handler( + special_method_name, None, False, type_name, + node, None, [operand], None) + return node + + ### dispatch to specific handlers + + def _find_handler(self, match_name, has_kwargs): + call_type = has_kwargs and 'general' or 'simple' + handler = getattr(self, '_handle_%s_%s' % (call_type, match_name), None) + if handler is None: + handler = getattr(self, '_handle_any_%s' % match_name, None) + return handler + + def _delegate_to_assigned_value(self, node, function, arg_list, kwargs): + assignment = function.cf_state[0] + value = assignment.rhs + if value.is_name: + if not value.entry or len(value.entry.cf_assignments) > 1: + # the variable might have been reassigned => play safe + return node + elif value.is_attribute and value.obj.is_name: + if not value.obj.entry or len(value.obj.entry.cf_assignments) > 1: + # the underlying variable might have been reassigned => play safe + return node + else: + return node + return self._dispatch_to_handler( + node, value, arg_list, kwargs) + + def _dispatch_to_handler(self, node, function, arg_list, kwargs): + if function.is_name: + # we only consider functions that are either builtin + # Python functions or builtins that were already replaced + # into a C function call (defined in the builtin scope) + if not function.entry: + return node + entry = function.entry + is_builtin = ( + entry.is_builtin or + entry is self.current_env().builtin_scope().lookup_here(function.name)) + if not is_builtin: + if function.cf_state and function.cf_state.is_single: + # we know the value of the variable + # => see if it's usable instead + return self._delegate_to_assigned_value( + node, function, arg_list, kwargs) + if arg_list and entry.is_cmethod and entry.scope and entry.scope.parent_type.is_builtin_type: + if entry.scope.parent_type is arg_list[0].type: + # Optimised (unbound) method of a builtin type => try to "de-optimise". + return self._dispatch_to_method_handler( + entry.name, self_arg=None, is_unbound_method=True, + type_name=entry.scope.parent_type.name, + node=node, function=function, arg_list=arg_list, kwargs=kwargs) + return node + function_handler = self._find_handler( + "function_%s" % function.name, kwargs) + if function_handler is None: + return self._handle_function(node, function.name, function, arg_list, kwargs) + if kwargs: + return function_handler(node, function, arg_list, kwargs) + else: + return function_handler(node, function, arg_list) + elif function.is_attribute: + attr_name = function.attribute + if function.type.is_pyobject: + self_arg = function.obj + elif node.self and function.entry: + entry = function.entry.as_variable + if not entry or not entry.is_builtin: + return node + # C implementation of a Python builtin method - see if we find further matches + self_arg = node.self + arg_list = arg_list[1:] # drop CloneNode of self argument + else: + return node + obj_type = self_arg.type + is_unbound_method = False + if obj_type.is_builtin_type: + if obj_type is Builtin.type_type and self_arg.is_name and arg_list and arg_list[0].type.is_pyobject: + # calling an unbound method like 'list.append(L,x)' + # (ignoring 'type.mro()' here ...) + type_name = self_arg.name + self_arg = None + is_unbound_method = True + else: + type_name = obj_type.name + else: + type_name = "object" # safety measure + return self._dispatch_to_method_handler( + attr_name, self_arg, is_unbound_method, type_name, + node, function, arg_list, kwargs) + else: + return node + + def _dispatch_to_method_handler(self, attr_name, self_arg, + is_unbound_method, type_name, + node, function, arg_list, kwargs): + method_handler = self._find_handler( + "method_%s_%s" % (type_name, attr_name), kwargs) + if method_handler is None: + if (attr_name in TypeSlots.method_name_to_slot + or attr_name == '__new__'): + method_handler = self._find_handler( + "slot%s" % attr_name, kwargs) + if method_handler is None: + return self._handle_method( + node, type_name, attr_name, function, + arg_list, is_unbound_method, kwargs) + if self_arg is not None: + arg_list = [self_arg] + list(arg_list) + if kwargs: + result = method_handler( + node, function, arg_list, is_unbound_method, kwargs) + else: + result = method_handler( + node, function, arg_list, is_unbound_method) + return result + + def _handle_function(self, node, function_name, function, arg_list, kwargs): + """Fallback handler""" + return node + + def _handle_method(self, node, type_name, attr_name, function, + arg_list, is_unbound_method, kwargs): + """Fallback handler""" + return node + + +class RecursiveNodeReplacer(VisitorTransform): + """ + Recursively replace all occurrences of a node in a subtree by + another node. + """ + def __init__(self, orig_node, new_node): + super(RecursiveNodeReplacer, self).__init__() + self.orig_node, self.new_node = orig_node, new_node + + def visit_CloneNode(self, node): + if node is self.orig_node: + return self.new_node + if node.arg is self.orig_node: + node.arg = self.new_node + return node + + def visit_Node(self, node): + self._process_children(node) + if node is self.orig_node: + return self.new_node + else: + return node + +def recursively_replace_node(tree, old_node, new_node): + replace_in = RecursiveNodeReplacer(old_node, new_node) + replace_in(tree) + + +class NodeFinder(TreeVisitor): + """ + Find out if a node appears in a subtree. + """ + def __init__(self, node): + super(NodeFinder, self).__init__() + self.node = node + self.found = False + + def visit_Node(self, node): + if self.found: + pass # short-circuit + elif node is self.node: + self.found = True + else: + self._visitchildren(node, None) + +def tree_contains(tree, node): + finder = NodeFinder(node) + finder.visit(tree) + return finder.found + + +# Utils +def replace_node(ptr, value): + """Replaces a node. ptr is of the form used on the access path stack + (parent, attrname, listidx|None) + """ + parent, attrname, listidx = ptr + if listidx is None: + setattr(parent, attrname, value) + else: + getattr(parent, attrname)[listidx] = value + + +class PrintTree(TreeVisitor): + """Prints a representation of the tree to standard output. + Subclass and override repr_of to provide more information + about nodes. """ + def __init__(self, start=None, end=None): + TreeVisitor.__init__(self) + self._indent = "" + if start is not None or end is not None: + self._line_range = (start or 0, end or 2**30) + else: + self._line_range = None + + def indent(self): + self._indent += " " + + def unindent(self): + self._indent = self._indent[:-2] + + def __call__(self, tree, phase=None): + print("Parse tree dump at phase '%s'" % phase) + self.visit(tree) + return tree + + # Don't do anything about process_list, the defaults gives + # nice-looking name[idx] nodes which will visually appear + # under the parent-node, not displaying the list itself in + # the hierarchy. + def visit_Node(self, node): + self._print_node(node) + self.indent() + self.visitchildren(node) + self.unindent() + return node + + def visit_CloneNode(self, node): + self._print_node(node) + self.indent() + line = node.pos[1] + if self._line_range is None or self._line_range[0] <= line <= self._line_range[1]: + print("%s- %s: %s" % (self._indent, 'arg', self.repr_of(node.arg))) + self.indent() + self.visitchildren(node.arg) + self.unindent() + self.unindent() + return node + + def _print_node(self, node): + line = node.pos[1] + if self._line_range is None or self._line_range[0] <= line <= self._line_range[1]: + if len(self.access_path) == 0: + name = "(root)" + else: + parent, attr, idx = self.access_path[-1] + if idx is not None: + name = "%s[%d]" % (attr, idx) + else: + name = attr + print("%s- %s: %s" % (self._indent, name, self.repr_of(node))) + + def repr_of(self, node): + if node is None: + return "(none)" + else: + result = node.__class__.__name__ + if isinstance(node, ExprNodes.NameNode): + result += "(type=%s, name=\"%s\")" % (repr(node.type), node.name) + elif isinstance(node, Nodes.DefNode): + result += "(name=\"%s\")" % node.name + elif isinstance(node, ExprNodes.ExprNode): + t = node.type + result += "(type=%s)" % repr(t) + elif node.pos: + pos = node.pos + path = pos[0].get_description() + if '/' in path: + path = path.split('/')[-1] + if '\\' in path: + path = path.split('\\')[-1] + result += "(pos=(%s:%s:%s))" % (path, pos[1], pos[2]) + + return result + +if __name__ == "__main__": + import doctest + doctest.testmod() diff --git a/contrib/tools/cython/Cython/Compiler/__init__.py b/contrib/tools/cython/Cython/Compiler/__init__.py new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Compiler/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Coverage.py b/contrib/tools/cython/Cython/Coverage.py new file mode 100644 index 00000000000..c4638d72711 --- /dev/null +++ b/contrib/tools/cython/Cython/Coverage.py @@ -0,0 +1,482 @@ +""" +A Cython plugin for coverage.py + +Requires the coverage package at least in version 4.0 (which added the plugin API). +""" + +from __future__ import absolute_import + +import re +import os.path +import sys +from collections import defaultdict + +from coverage.plugin import CoveragePlugin, FileTracer, FileReporter # requires coverage.py 4.0+ +from coverage.files import canonical_filename + +from .Utils import find_root_package_dir, is_package_dir, open_source_file + + +from . import __version__ + + +C_FILE_EXTENSIONS = ['.c', '.cpp', '.cc', '.cxx'] +MODULE_FILE_EXTENSIONS = set(['.py', '.pyx', '.pxd'] + C_FILE_EXTENSIONS) + + +def _find_c_source(base_path): + file_exists = os.path.exists + for ext in C_FILE_EXTENSIONS: + file_name = base_path + ext + if file_exists(file_name): + return file_name + return None + + +def _find_dep_file_path(main_file, file_path, relative_path_search=False): + abs_path = os.path.abspath(file_path) + if not os.path.exists(abs_path) and (file_path.endswith('.pxi') or + relative_path_search): + # files are looked up relative to the main source file + rel_file_path = os.path.join(os.path.dirname(main_file), file_path) + if os.path.exists(rel_file_path): + abs_path = os.path.abspath(rel_file_path) + # search sys.path for external locations if a valid file hasn't been found + if not os.path.exists(abs_path): + for sys_path in sys.path: + test_path = os.path.realpath(os.path.join(sys_path, file_path)) + if os.path.exists(test_path): + return canonical_filename(test_path) + return canonical_filename(abs_path) + + +class Plugin(CoveragePlugin): + # map from traced file paths to absolute file paths + _file_path_map = None + # map from traced file paths to corresponding C files + _c_files_map = None + # map from parsed C files to their content + _parsed_c_files = None + + def sys_info(self): + return [('Cython version', __version__)] + + def file_tracer(self, filename): + """ + Try to find a C source file for a file path found by the tracer. + """ + # TODO We need to pxd-files to the include map. For more info see pybuild.py + # Currently skip such files, because they are not supported in Arcadia pybuild with coverage. + if os.path.splitext(filename)[-1] not in ('.pyx', '.pxi'): + return None + if filename.startswith('<') or filename.startswith('memory:'): + return None + c_file = py_file = None + filename = canonical_filename(filename) + if self._c_files_map and filename in self._c_files_map: + c_file = self._c_files_map[filename][0] + + if c_file is None: + c_file, py_file = self._find_source_files(filename) + if not c_file: + return None # unknown file + + # parse all source file paths and lines from C file + # to learn about all relevant source files right away (pyx/pxi/pxd) + # FIXME: this might already be too late if the first executed line + # is not from the main .pyx file but a file with a different + # name than the .c file (which prevents us from finding the + # .c file) + _, code = self._read_source_lines(c_file, filename) + if code is None: + return None # no source found + + if self._file_path_map is None: + self._file_path_map = {} + return CythonModuleTracer(filename, py_file, c_file, self._c_files_map, self._file_path_map) + + def file_reporter(self, filename): + # TODO: let coverage.py handle .py files itself + #ext = os.path.splitext(filename)[1].lower() + #if ext == '.py': + # from coverage.python import PythonFileReporter + # return PythonFileReporter(filename) + + filename = canonical_filename(filename) + if self._c_files_map and filename in self._c_files_map: + c_file, rel_file_path, code = self._c_files_map[filename] + else: + c_file, _ = self._find_source_files(filename) + if not c_file: + if standalone(): + raise AssertionError(filename) + return None # unknown file + rel_file_path, code = self._read_source_lines(c_file, filename) + if code is None: + if standalone(): + raise AssertionError(filename) + return None # no source found + + return CythonModuleReporter(c_file, filename, rel_file_path, code) + + def _find_source_files(self, filename): + basename, ext = os.path.splitext(filename) + ext = ext.lower() + if ext in MODULE_FILE_EXTENSIONS: + pass + elif ext == '.pyd': + # Windows extension module + platform_suffix = re.search(r'[.]cp[0-9]+-win[_a-z0-9]*$', basename, re.I) + if platform_suffix: + basename = basename[:platform_suffix.start()] + elif ext == '.so': + # Linux/Unix/Mac extension module + platform_suffix = re.search(r'[.](?:cpython|pypy)-[0-9]+[-_a-z0-9]*$', basename, re.I) + if platform_suffix: + basename = basename[:platform_suffix.start()] + elif ext == '.pxi': + # if we get here, it means that the first traced line of a Cython module was + # not in the main module but in an include file, so try a little harder to + # find the main source file + self._find_c_source_files(os.path.dirname(filename), filename) + if filename in self._c_files_map: + return self._c_files_map[filename][0], None + if standalone(): + raise AssertionError(filename) + else: + # none of our business + return None, None + + c_file = filename if ext in C_FILE_EXTENSIONS else _find_c_source(basename) + if c_file is None: + # a module "pkg/mod.so" can have a source file "pkg/pkg.mod.c" + package_root = find_root_package_dir.uncached(filename) + package_path = os.path.relpath(basename, package_root).split(os.path.sep) + if len(package_path) > 1: + test_basepath = os.path.join(os.path.dirname(filename), '.'.join(package_path)) + c_file = _find_c_source(test_basepath) + + py_source_file = None + if c_file: + py_source_file = os.path.splitext(c_file)[0] + '.py' + if not os.path.exists(py_source_file): + py_source_file = None + + try: + with OpenFile(c_file) as f: + if '/* Generated by Cython ' not in f.read(30): + return None, None # not a Cython file + except (IOError, OSError): + c_file = None + + return c_file, py_source_file + + def _find_c_source_files(self, dir_path, source_file): + """ + Desperately parse all C files in the directory or its package parents + (not re-descending) to find the (included) source file in one of them. + """ + if standalone(): + if os.environ.get('PYTHON_COVERAGE_CYTHON_BUILD_ROOT'): + broot = os.environ['PYTHON_COVERAGE_CYTHON_BUILD_ROOT'] + iter_files = lambda: (os.path.join(root, filename) for root, _, files in os.walk(broot) for filename in files) + else: + import library.python.resource + iter_files = library.python.resource.resfs_files + for c_file in iter_files(): + if os.path.splitext(c_file)[1] in C_FILE_EXTENSIONS: + self._read_source_lines(c_file, source_file) + if source_file in self._c_files_map: + return + raise AssertionError((source_file, os.environ.get('PYTHON_COVERAGE_CYTHON_BUILD_ROOT'))) + + if not os.path.isdir(dir_path): + return + splitext = os.path.splitext + for filename in os.listdir(dir_path): + ext = splitext(filename)[1].lower() + if ext in C_FILE_EXTENSIONS: + self._read_source_lines(os.path.join(dir_path, filename), source_file) + if source_file in self._c_files_map: + return + # not found? then try one package up + if is_package_dir(dir_path): + self._find_c_source_files(os.path.dirname(dir_path), source_file) + + def _read_source_lines(self, c_file, sourcefile): + """ + Parse a Cython generated C/C++ source file and find the executable lines. + Each executable line starts with a comment header that states source file + and line number, as well as the surrounding range of source code lines. + """ + if self._parsed_c_files is None: + self._parsed_c_files = {} + if c_file in self._parsed_c_files: + code_lines = self._parsed_c_files[c_file] + else: + code_lines = self._parse_cfile_lines(c_file) + self._parsed_c_files[c_file] = code_lines + + if self._c_files_map is None: + self._c_files_map = {} + + for filename, code in code_lines.items(): + abs_path = _find_dep_file_path(c_file, filename, + relative_path_search=True) + self._c_files_map[abs_path] = (c_file, filename, code) + + if sourcefile not in self._c_files_map: + return (None,) * 2 # e.g. shared library file + return self._c_files_map[sourcefile][1:] + + def _parse_cfile_lines(self, c_file): + """ + Parse a C file and extract all source file lines that generated executable code. + """ + match_source_path_line = re.compile(r' */[*] +"(.*)":([0-9]+)$').match + match_current_code_line = re.compile(r' *[*] (.*) # <<<<<<+$').match + match_comment_end = re.compile(r' *[*]/$').match + match_trace_line = re.compile(r' *__Pyx_TraceLine\(([0-9]+),').match + not_executable = re.compile( + r'\s*c(?:type)?def\s+' + r'(?:(?:public|external)\s+)?' + r'(?:struct|union|enum|class)' + r'(\s+[^:]+|)\s*:' + ).match + + code_lines = defaultdict(dict) + executable_lines = defaultdict(set) + current_filename = None + + with OpenFile(c_file) as lines: + lines = iter(lines) + for line in lines: + match = match_source_path_line(line) + if not match: + if '__Pyx_TraceLine(' in line and current_filename is not None: + trace_line = match_trace_line(line) + if trace_line: + executable_lines[current_filename].add(int(trace_line.group(1))) + continue + filename, lineno = match.groups() + current_filename = filename + lineno = int(lineno) + for comment_line in lines: + match = match_current_code_line(comment_line) + if match: + code_line = match.group(1).rstrip() + if not_executable(code_line): + break + code_lines[filename][lineno] = code_line + break + elif match_comment_end(comment_line): + # unexpected comment format - false positive? + break + + # Remove lines that generated code but are not traceable. + for filename, lines in code_lines.items(): + dead_lines = set(lines).difference(executable_lines.get(filename, ())) + for lineno in dead_lines: + del lines[lineno] + return code_lines + + +class CythonModuleTracer(FileTracer): + """ + Find the Python/Cython source file for a Cython module. + """ + def __init__(self, module_file, py_file, c_file, c_files_map, file_path_map): + super(CythonModuleTracer, self).__init__() + self.module_file = module_file + self.py_file = py_file + self.c_file = c_file + self._c_files_map = c_files_map + self._file_path_map = file_path_map + + def has_dynamic_source_filename(self): + return True + + def dynamic_source_filename(self, filename, frame): + """ + Determine source file path. Called by the function call tracer. + """ + source_file = frame.f_code.co_filename + try: + return self._file_path_map[source_file] + except KeyError: + pass + if standalone(): + abs_path = self.module_file + else: + abs_path = _find_dep_file_path(filename, source_file) + + if self.py_file and source_file[-3:].lower() == '.py': + # always let coverage.py handle this case itself + self._file_path_map[source_file] = self.py_file + return self.py_file + + assert self._c_files_map is not None + if abs_path not in self._c_files_map: + self._c_files_map[abs_path] = (self.c_file, source_file, None) + self._file_path_map[source_file] = abs_path + return abs_path + + +class CythonModuleReporter(FileReporter): + """ + Provide detailed trace information for one source file to coverage.py. + """ + def __init__(self, c_file, source_file, rel_file_path, code): + super(CythonModuleReporter, self).__init__(source_file) + self.name = rel_file_path + self.c_file = c_file + self._code = code + self._abs_filename = self._find_abs_filename() + + def lines(self): + """ + Return set of line numbers that are possibly executable. + """ + return set(self._code) + + def _iter_source_tokens(self): + current_line = 1 + for line_no, code_line in sorted(self._code.items()): + while line_no > current_line: + yield [] + current_line += 1 + yield [('txt', code_line)] + current_line += 1 + + def source(self): + """ + Return the source code of the file as a string. + """ + if os.path.exists(self._abs_filename): + with open_source_file(self._abs_filename) as f: + return f.read() + else: + return '\n'.join( + (tokens[0][1] if tokens else '') + for tokens in self._iter_source_tokens()) + + def source_token_lines(self): + """ + Iterate over the source code tokens. + """ + if os.path.exists(self._abs_filename): + with open_source_file(self._abs_filename) as f: + for line in f: + yield [('txt', line.rstrip('\n'))] + else: + for line in self._iter_source_tokens(): + yield line + + def _find_abs_filename(self): + for root in [ + os.environ.get('PYTHON_COVERAGE_ARCADIA_SOURCE_ROOT'), + os.environ.get('PYTHON_COVERAGE_CYTHON_BUILD_ROOT'), + ]: + if root: + abs_path = os.path.join(root, self.filename) + if root and os.path.exists(abs_path): + return abs_path + return self.filename + + +def coverage_init(reg, options): + reg.add_file_tracer(Plugin()) + + +# ========================== Arcadia specific ================================= + +def standalone(): + return getattr(sys, 'is_standalone_binary', False) + + +class OpenFile(object): + + def __init__(self, filename, mode='r'): + assert 'r' in mode, ('Read-only', mode) + self.filename = filename + self.mode = mode + self.file = None + self.build_root = os.environ.get('PYTHON_COVERAGE_CYTHON_BUILD_ROOT') + + def __enter__(self): + # See redefined _find_c_source() description for more info + if self.build_root: + self.file = open(os.path.join(self.build_root, self.filename), self.mode) + return self.file + elif standalone(): + import library.python.resource + from six import StringIO + + content = library.python.resource.resfs_read(self.filename, builtin=True) + assert content, (self.filename, os.environ.items()) + return StringIO(content.decode()) + else: + self.file = open(self.filename, self.mode) + return self.file + + def __exit__(self, exc_type, exc_val, exc_tb): + if self.file: + self.file.close() + +# ======================= Redefine some methods =============================== + +if standalone(): + import itertools + import json + + CYTHON_INCLUDE_MAP = {'undef': True} + + + def _find_c_source(base_path): + ''' + There are two different coverage stages when c source file might be required: + * trace - python calls c_tracefunc on every line and CythonModuleTracer needs to match + pyd and pxi files with source files. This is test's runtime and tests' clean environment might + doesn't contain required sources and generated files (c, cpp), that's why we get files from resfs_src. + * report - coverage data contains only covered data and CythonModuleReporter needs to + parse source files to obtain missing lines and branches. This is test_tool's resolve/build_report step. + test_tools doesn't have compiled in sources, however, it can extract required files + from binary and set PYTHON_COVERAGE_CYTHON_BUILD_ROOT to guide coverage. + ''' + if os.environ.get('PYTHON_COVERAGE_CYTHON_BUILD_ROOT'): + # Report stage (resolve) + def exists(filename): + return os.path.exists(os.path.join(os.environ['PYTHON_COVERAGE_CYTHON_BUILD_ROOT'], filename)) + else: + # Trace stage (test's runtime) + def exists(filename): + import library.python.resource + return library.python.resource.resfs_src(filename, resfs_file=True) + + if os.environ.get('PYTHON_COVERAGE_CYTHON_INCLUDE_MAP'): + if CYTHON_INCLUDE_MAP.get('undef'): + with open(os.environ['PYTHON_COVERAGE_CYTHON_INCLUDE_MAP']) as afile: + data = json.load(afile) + data = {os.path.splitext(k)[0]: v for k, v in data.items()} + + CYTHON_INCLUDE_MAP.clear() + CYTHON_INCLUDE_MAP.update(data) + + if base_path in CYTHON_INCLUDE_MAP: + # target file was included and should be sought inside another pyx file + base_path = CYTHON_INCLUDE_MAP[base_path] + + # TODO (', '.py3', '.py2') -> ('.py3', '.py2'), when https://a.yandex-team.ru/review/3511262 is merged + suffixes = [''.join(x) for x in itertools.product(('.pyx',), ('', '.py3', '.py2'), ('.cpp', '.c'))] + suffixes += C_FILE_EXTENSIONS + + for suffix in suffixes: + if exists(base_path + suffix): + return base_path + suffix + + return None + + + def _find_dep_file_path(main_file, file_path, relative_path_search=False): + # file_path is already arcadia root relative + return canonical_filename(file_path) diff --git a/contrib/tools/cython/Cython/Debugger/Cygdb.py b/contrib/tools/cython/Cython/Debugger/Cygdb.py new file mode 100644 index 00000000000..45f31ce6f77 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Cygdb.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python + +""" +The Cython debugger + +The current directory should contain a directory named 'cython_debug', or a +path to the cython project directory should be given (the parent directory of +cython_debug). + +Additional gdb args can be provided only if a path to the project directory is +given. +""" + +import os +import sys +import glob +import tempfile +import textwrap +import subprocess +import optparse +import logging + +logger = logging.getLogger(__name__) + +def make_command_file(path_to_debug_info, prefix_code='', no_import=False): + if not no_import: + pattern = os.path.join(path_to_debug_info, + 'cython_debug', + 'cython_debug_info_*') + debug_files = glob.glob(pattern) + + if not debug_files: + sys.exit('%s.\nNo debug files were found in %s. Aborting.' % ( + usage, os.path.abspath(path_to_debug_info))) + + fd, tempfilename = tempfile.mkstemp() + f = os.fdopen(fd, 'w') + try: + f.write(prefix_code) + f.write(textwrap.dedent('''\ + # This is a gdb command file + # See https://sourceware.org/gdb/onlinedocs/gdb/Command-Files.html + + set breakpoint pending on + set print pretty on + + python + # Activate virtualenv, if we were launched from one + import os + virtualenv = os.getenv('VIRTUAL_ENV') + if virtualenv: + path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py') + print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s" % ( + virtualenv, path_to_activate_this_py)) + with open(path_to_activate_this_py) as f: + exec(f.read(), dict(__file__=path_to_activate_this_py)) + + from Cython.Debugger import libcython, libpython + end + ''')) + + if no_import: + # don't do this, this overrides file command in .gdbinit + # f.write("file %s\n" % sys.executable) + pass + else: + path = os.path.join(path_to_debug_info, "cython_debug", "interpreter") + interpreter_file = open(path) + try: + interpreter = interpreter_file.read() + finally: + interpreter_file.close() + f.write("file %s\n" % interpreter) + f.write('\n'.join('cy import %s\n' % fn for fn in debug_files)) + f.write(textwrap.dedent('''\ + python + import sys + try: + gdb.lookup_type('PyModuleObject') + except RuntimeError: + sys.stderr.write( + 'Python was not compiled with debug symbols (or it was ' + 'stripped). Some functionality may not work (properly).\\n') + end + + source .cygdbinit + ''')) + finally: + f.close() + + return tempfilename + +usage = "Usage: cygdb [options] [PATH [-- GDB_ARGUMENTS]]" + +def main(path_to_debug_info=None, gdb_argv=None, no_import=False): + """ + Start the Cython debugger. This tells gdb to import the Cython and Python + extensions (libcython.py and libpython.py) and it enables gdb's pending + breakpoints. + + path_to_debug_info is the path to the Cython build directory + gdb_argv is the list of options to gdb + no_import tells cygdb whether it should import debug information + """ + parser = optparse.OptionParser(usage=usage) + parser.add_option("--gdb-executable", + dest="gdb", default='gdb', + help="gdb executable to use [default: gdb]") + parser.add_option("--verbose", "-v", + dest="verbosity", action="count", default=0, + help="Verbose mode. Multiple -v options increase the verbosity") + + (options, args) = parser.parse_args() + if path_to_debug_info is None: + if len(args) > 1: + path_to_debug_info = args[0] + else: + path_to_debug_info = os.curdir + + if gdb_argv is None: + gdb_argv = args[1:] + + if path_to_debug_info == '--': + no_import = True + + logging_level = logging.WARN + if options.verbosity == 1: + logging_level = logging.INFO + if options.verbosity >= 2: + logging_level = logging.DEBUG + logging.basicConfig(level=logging_level) + + logger.info("verbosity = %r", options.verbosity) + logger.debug("options = %r; args = %r", options, args) + logger.debug("Done parsing command-line options. path_to_debug_info = %r, gdb_argv = %r", + path_to_debug_info, gdb_argv) + + tempfilename = make_command_file(path_to_debug_info, no_import=no_import) + logger.info("Launching %s with command file: %s and gdb_argv: %s", + options.gdb, tempfilename, gdb_argv) + with open(tempfilename) as tempfile: + logger.debug('Command file (%s) contains: """\n%s"""', tempfilename, tempfile.read()) + logger.info("Spawning %s...", options.gdb) + p = subprocess.Popen([options.gdb, '-command', tempfilename] + gdb_argv) + logger.info("Spawned %s (pid %d)", options.gdb, p.pid) + while True: + try: + logger.debug("Waiting for gdb (pid %d) to exit...", p.pid) + ret = p.wait() + logger.debug("Wait for gdb (pid %d) to exit is done. Returned: %r", p.pid, ret) + except KeyboardInterrupt: + pass + else: + break + logger.debug("Closing temp command file with fd: %s", tempfile.fileno()) + logger.debug("Removing temp command file: %s", tempfilename) + os.remove(tempfilename) + logger.debug("Removed temp command file: %s", tempfilename) diff --git a/contrib/tools/cython/Cython/Debugger/DebugWriter.py b/contrib/tools/cython/Cython/Debugger/DebugWriter.py new file mode 100644 index 00000000000..876a3a2169a --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/DebugWriter.py @@ -0,0 +1,72 @@ +from __future__ import absolute_import + +import os +import sys +import errno + +try: + from lxml import etree + have_lxml = True +except ImportError: + have_lxml = False + try: + from xml.etree import cElementTree as etree + except ImportError: + try: + from xml.etree import ElementTree as etree + except ImportError: + etree = None + +from ..Compiler import Errors + + +class CythonDebugWriter(object): + """ + Class to output debugging information for cygdb + + It writes debug information to cython_debug/cython_debug_info_<modulename> + in the build directory. + """ + + def __init__(self, output_dir): + if etree is None: + raise Errors.NoElementTreeInstalledException() + + self.output_dir = os.path.join(output_dir or os.curdir, 'cython_debug') + self.tb = etree.TreeBuilder() + # set by Cython.Compiler.ParseTreeTransforms.DebugTransform + self.module_name = None + self.start('cython_debug', attrs=dict(version='1.0')) + + def start(self, name, attrs=None): + self.tb.start(name, attrs or {}) + + def end(self, name): + self.tb.end(name) + + def add_entry(self, name, **attrs): + self.tb.start(name, attrs) + self.tb.end(name) + + def serialize(self): + self.tb.end('Module') + self.tb.end('cython_debug') + xml_root_element = self.tb.close() + + try: + os.makedirs(self.output_dir) + except OSError as e: + if e.errno != errno.EEXIST: + raise + + et = etree.ElementTree(xml_root_element) + kw = {} + if have_lxml: + kw['pretty_print'] = True + + fn = "cython_debug_info_" + self.module_name + et.write(os.path.join(self.output_dir, fn), encoding="UTF-8", **kw) + + interpreter_path = os.path.join(self.output_dir, 'interpreter') + with open(interpreter_path, 'w') as f: + f.write(sys.executable) diff --git a/contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py b/contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py new file mode 100644 index 00000000000..13560646ffc --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py @@ -0,0 +1,274 @@ + +import os +import re +import sys +import shutil +import warnings +import textwrap +import unittest +import tempfile +import subprocess +#import distutils.core +#from distutils import sysconfig +from distutils import ccompiler + +import runtests +import Cython.Distutils.extension +import Cython.Distutils.old_build_ext as build_ext +from Cython.Debugger import Cygdb as cygdb + +root = os.path.dirname(os.path.abspath(__file__)) +codefile = os.path.join(root, 'codefile') +cfuncs_file = os.path.join(root, 'cfuncs.c') + +with open(codefile) as f: + source_to_lineno = dict((line.strip(), i + 1) for i, line in enumerate(f)) + + +have_gdb = None +def test_gdb(): + global have_gdb + if have_gdb is not None: + return have_gdb + + have_gdb = False + try: + p = subprocess.Popen(['gdb', '-nx', '--version'], stdout=subprocess.PIPE) + except OSError: + # gdb not found + gdb_version = None + else: + stdout, _ = p.communicate() + # Based on Lib/test/test_gdb.py + regex = r"GNU gdb [^\d]*(\d+)\.(\d+)" + gdb_version = re.match(regex, stdout.decode('ascii', 'ignore')) + + if gdb_version: + gdb_version_number = list(map(int, gdb_version.groups())) + if gdb_version_number >= [7, 2]: + have_gdb = True + with tempfile.NamedTemporaryFile(mode='w+') as python_version_script: + python_version_script.write( + 'python import sys; print("%s %s" % sys.version_info[:2])') + python_version_script.flush() + p = subprocess.Popen(['gdb', '-batch', '-x', python_version_script.name], + stdout=subprocess.PIPE) + stdout, _ = p.communicate() + try: + internal_python_version = list(map(int, stdout.decode('ascii', 'ignore').split())) + if internal_python_version < [2, 6]: + have_gdb = False + except ValueError: + have_gdb = False + + if not have_gdb: + warnings.warn('Skipping gdb tests, need gdb >= 7.2 with Python >= 2.6') + + return have_gdb + + +class DebuggerTestCase(unittest.TestCase): + + def setUp(self): + """ + Run gdb and have cygdb import the debug information from the code + defined in TestParseTreeTransforms's setUp method + """ + if not test_gdb(): + return + + self.tempdir = tempfile.mkdtemp() + self.destfile = os.path.join(self.tempdir, 'codefile.pyx') + self.debug_dest = os.path.join(self.tempdir, + 'cython_debug', + 'cython_debug_info_codefile') + self.cfuncs_destfile = os.path.join(self.tempdir, 'cfuncs') + + self.cwd = os.getcwd() + try: + os.chdir(self.tempdir) + + shutil.copy(codefile, self.destfile) + shutil.copy(cfuncs_file, self.cfuncs_destfile + '.c') + shutil.copy(cfuncs_file.replace('.c', '.h'), + self.cfuncs_destfile + '.h') + + compiler = ccompiler.new_compiler() + compiler.compile(['cfuncs.c'], debug=True, extra_postargs=['-fPIC']) + + opts = dict( + test_directory=self.tempdir, + module='codefile', + ) + + optimization_disabler = build_ext.Optimization() + + cython_compile_testcase = runtests.CythonCompileTestCase( + workdir=self.tempdir, + # we clean up everything (not only compiled files) + cleanup_workdir=False, + tags=runtests.parse_tags(codefile), + **opts + ) + + + new_stderr = open(os.devnull, 'w') + + stderr = sys.stderr + sys.stderr = new_stderr + + optimization_disabler.disable_optimization() + try: + cython_compile_testcase.run_cython( + targetdir=self.tempdir, + incdir=None, + annotate=False, + extra_compile_options={ + 'gdb_debug':True, + 'output_dir':self.tempdir, + }, + **opts + ) + + cython_compile_testcase.run_distutils( + incdir=None, + workdir=self.tempdir, + extra_extension_args={'extra_objects':['cfuncs.o']}, + **opts + ) + finally: + optimization_disabler.restore_state() + sys.stderr = stderr + new_stderr.close() + + # ext = Cython.Distutils.extension.Extension( + # 'codefile', + # ['codefile.pyx'], + # cython_gdb=True, + # extra_objects=['cfuncs.o']) + # + # distutils.core.setup( + # script_args=['build_ext', '--inplace'], + # ext_modules=[ext], + # cmdclass=dict(build_ext=Cython.Distutils.build_ext) + # ) + + except: + os.chdir(self.cwd) + raise + + def tearDown(self): + if not test_gdb(): + return + os.chdir(self.cwd) + shutil.rmtree(self.tempdir) + + +class GdbDebuggerTestCase(DebuggerTestCase): + + def setUp(self): + if not test_gdb(): + return + + super(GdbDebuggerTestCase, self).setUp() + + prefix_code = textwrap.dedent('''\ + python + + import os + import sys + import traceback + + def excepthook(type, value, tb): + traceback.print_exception(type, value, tb) + sys.stderr.flush() + sys.stdout.flush() + os._exit(1) + + sys.excepthook = excepthook + + # Have tracebacks end up on sys.stderr (gdb replaces sys.stderr + # with an object that calls gdb.write()) + sys.stderr = sys.__stderr__ + + end + ''') + + code = textwrap.dedent('''\ + python + + from Cython.Debugger.Tests import test_libcython_in_gdb + test_libcython_in_gdb.main(version=%r) + + end + ''' % (sys.version_info[:2],)) + + self.gdb_command_file = cygdb.make_command_file(self.tempdir, + prefix_code) + + with open(self.gdb_command_file, 'a') as f: + f.write(code) + + args = ['gdb', '-batch', '-x', self.gdb_command_file, '-n', '--args', + sys.executable, '-c', 'import codefile'] + + paths = [] + path = os.environ.get('PYTHONPATH') + if path: + paths.append(path) + paths.append(os.path.dirname(os.path.dirname( + os.path.abspath(Cython.__file__)))) + env = dict(os.environ, PYTHONPATH=os.pathsep.join(paths)) + + self.p = subprocess.Popen( + args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env) + + def tearDown(self): + if not test_gdb(): + return + + try: + super(GdbDebuggerTestCase, self).tearDown() + if self.p: + try: self.p.stdout.close() + except: pass + try: self.p.stderr.close() + except: pass + self.p.wait() + finally: + os.remove(self.gdb_command_file) + + +class TestAll(GdbDebuggerTestCase): + + def test_all(self): + if not test_gdb(): + return + + out, err = self.p.communicate() + out = out.decode('UTF-8') + err = err.decode('UTF-8') + + exit_status = self.p.returncode + + if exit_status == 1: + sys.stderr.write(out) + sys.stderr.write(err) + elif exit_status >= 2: + border = u'*' * 30 + start = u'%s v INSIDE GDB v %s' % (border, border) + stderr = u'%s v STDERR v %s' % (border, border) + end = u'%s ^ INSIDE GDB ^ %s' % (border, border) + errmsg = u'\n%s\n%s%s\n%s%s' % (start, out, stderr, err, end) + + sys.stderr.write(errmsg) + + # FIXME: re-enable this to make the test fail on internal failures + #self.assertEqual(exit_status, 0) + + +if __name__ == '__main__': + unittest.main() diff --git a/contrib/tools/cython/Cython/Debugger/Tests/__init__.py b/contrib/tools/cython/Cython/Debugger/Tests/__init__.py new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Tests/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Debugger/Tests/cfuncs.c b/contrib/tools/cython/Cython/Debugger/Tests/cfuncs.c new file mode 100644 index 00000000000..ccb42050bf7 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Tests/cfuncs.c @@ -0,0 +1,8 @@ +void +some_c_function(void) +{ + int a, b, c; + + a = 1; + b = 2; +} diff --git a/contrib/tools/cython/Cython/Debugger/Tests/cfuncs.h b/contrib/tools/cython/Cython/Debugger/Tests/cfuncs.h new file mode 100644 index 00000000000..3b21bc2d5f9 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Tests/cfuncs.h @@ -0,0 +1 @@ +void some_c_function(void); diff --git a/contrib/tools/cython/Cython/Debugger/Tests/codefile b/contrib/tools/cython/Cython/Debugger/Tests/codefile new file mode 100644 index 00000000000..6b4c6b6addf --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Tests/codefile @@ -0,0 +1,50 @@ +cdef extern from "stdio.h": + int puts(char *s) + +cdef extern from "cfuncs.h": + void some_c_function() + +import os + +cdef int c_var = 12 +python_var = 13 + +def spam(a=0): + cdef: + int b, c + + b = c = d = 0 + + b = 1 + c = 2 + int(10) + puts("spam") + os.path.join("foo", "bar") + some_c_function() + +cpdef eggs(): + pass + +cdef ham(): + pass + +cdef class SomeClass(object): + def spam(self): + pass + +def outer(): + cdef object a = "an object" + def inner(): + b = 2 + # access closed over variables + print a, b + return inner + + +outer()() + +spam() +print "bye!" + +def use_ham(): + ham() diff --git a/contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py b/contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py new file mode 100644 index 00000000000..bd7608d6079 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py @@ -0,0 +1,496 @@ +""" +Tests that run inside GDB. + +Note: debug information is already imported by the file generated by +Cython.Debugger.Cygdb.make_command_file() +""" + +from __future__ import absolute_import + +import os +import re +import sys +import trace +import inspect +import warnings +import unittest +import textwrap +import tempfile +import functools +import traceback +import itertools +#from test import test_support + +import gdb + +from .. import libcython +from .. import libpython +from . import TestLibCython as test_libcython +from ...Utils import add_metaclass + +# for some reason sys.argv is missing in gdb +sys.argv = ['gdb'] + + +def print_on_call_decorator(func): + @functools.wraps(func) + def wrapper(self, *args, **kwargs): + _debug(type(self).__name__, func.__name__) + + try: + return func(self, *args, **kwargs) + except Exception: + _debug("An exception occurred:", traceback.format_exc()) + raise + + return wrapper + +class TraceMethodCallMeta(type): + + def __init__(self, name, bases, dict): + for func_name, func in dict.items(): + if inspect.isfunction(func): + setattr(self, func_name, print_on_call_decorator(func)) + + +@add_metaclass(TraceMethodCallMeta) +class DebugTestCase(unittest.TestCase): + """ + Base class for test cases. On teardown it kills the inferior and unsets + all breakpoints. + """ + + def __init__(self, name): + super(DebugTestCase, self).__init__(name) + self.cy = libcython.cy + self.module = libcython.cy.cython_namespace['codefile'] + self.spam_func, self.spam_meth = libcython.cy.functions_by_name['spam'] + self.ham_func = libcython.cy.functions_by_qualified_name[ + 'codefile.ham'] + self.eggs_func = libcython.cy.functions_by_qualified_name[ + 'codefile.eggs'] + + def read_var(self, varname, cast_to=None): + result = gdb.parse_and_eval('$cy_cvalue("%s")' % varname) + if cast_to: + result = cast_to(result) + + return result + + def local_info(self): + return gdb.execute('info locals', to_string=True) + + def lineno_equals(self, source_line=None, lineno=None): + if source_line is not None: + lineno = test_libcython.source_to_lineno[source_line] + frame = gdb.selected_frame() + self.assertEqual(libcython.cython_info.lineno(frame), lineno) + + def break_and_run(self, source_line): + break_lineno = test_libcython.source_to_lineno[source_line] + gdb.execute('cy break codefile:%d' % break_lineno, to_string=True) + gdb.execute('run', to_string=True) + + def tearDown(self): + gdb.execute('delete breakpoints', to_string=True) + try: + gdb.execute('kill inferior 1', to_string=True) + except RuntimeError: + pass + + gdb.execute('set args -c "import codefile"') + + +class TestDebugInformationClasses(DebugTestCase): + + def test_CythonModule(self): + "test that debug information was parsed properly into data structures" + self.assertEqual(self.module.name, 'codefile') + global_vars = ('c_var', 'python_var', '__name__', + '__builtins__', '__doc__', '__file__') + assert set(global_vars).issubset(self.module.globals) + + def test_CythonVariable(self): + module_globals = self.module.globals + c_var = module_globals['c_var'] + python_var = module_globals['python_var'] + self.assertEqual(c_var.type, libcython.CObject) + self.assertEqual(python_var.type, libcython.PythonObject) + self.assertEqual(c_var.qualified_name, 'codefile.c_var') + + def test_CythonFunction(self): + self.assertEqual(self.spam_func.qualified_name, 'codefile.spam') + self.assertEqual(self.spam_meth.qualified_name, + 'codefile.SomeClass.spam') + self.assertEqual(self.spam_func.module, self.module) + + assert self.eggs_func.pf_cname, (self.eggs_func, self.eggs_func.pf_cname) + assert not self.ham_func.pf_cname + assert not self.spam_func.pf_cname + assert not self.spam_meth.pf_cname + + self.assertEqual(self.spam_func.type, libcython.CObject) + self.assertEqual(self.ham_func.type, libcython.CObject) + + self.assertEqual(self.spam_func.arguments, ['a']) + self.assertEqual(self.spam_func.step_into_functions, + set(['puts', 'some_c_function'])) + + expected_lineno = test_libcython.source_to_lineno['def spam(a=0):'] + self.assertEqual(self.spam_func.lineno, expected_lineno) + self.assertEqual(sorted(self.spam_func.locals), list('abcd')) + + +class TestParameters(unittest.TestCase): + + def test_parameters(self): + gdb.execute('set cy_colorize_code on') + assert libcython.parameters.colorize_code + gdb.execute('set cy_colorize_code off') + assert not libcython.parameters.colorize_code + + +class TestBreak(DebugTestCase): + + def test_break(self): + breakpoint_amount = len(gdb.breakpoints() or ()) + gdb.execute('cy break codefile.spam') + + self.assertEqual(len(gdb.breakpoints()), breakpoint_amount + 1) + bp = gdb.breakpoints()[-1] + self.assertEqual(bp.type, gdb.BP_BREAKPOINT) + assert self.spam_func.cname in bp.location + assert bp.enabled + + def test_python_break(self): + gdb.execute('cy break -p join') + assert 'def join(' in gdb.execute('cy run', to_string=True) + + def test_break_lineno(self): + beginline = 'import os' + nextline = 'cdef int c_var = 12' + + self.break_and_run(beginline) + self.lineno_equals(beginline) + step_result = gdb.execute('cy step', to_string=True) + self.lineno_equals(nextline) + assert step_result.rstrip().endswith(nextline) + + +class TestKilled(DebugTestCase): + + def test_abort(self): + gdb.execute("set args -c 'import os; os.abort()'") + output = gdb.execute('cy run', to_string=True) + assert 'abort' in output.lower() + + +class DebugStepperTestCase(DebugTestCase): + + def step(self, varnames_and_values, source_line=None, lineno=None): + gdb.execute(self.command) + for varname, value in varnames_and_values: + self.assertEqual(self.read_var(varname), value, self.local_info()) + + self.lineno_equals(source_line, lineno) + + +class TestStep(DebugStepperTestCase): + """ + Test stepping. Stepping happens in the code found in + Cython/Debugger/Tests/codefile. + """ + + def test_cython_step(self): + gdb.execute('cy break codefile.spam') + + gdb.execute('run', to_string=True) + self.lineno_equals('def spam(a=0):') + + gdb.execute('cy step', to_string=True) + self.lineno_equals('b = c = d = 0') + + self.command = 'cy step' + self.step([('b', 0)], source_line='b = 1') + self.step([('b', 1), ('c', 0)], source_line='c = 2') + self.step([('c', 2)], source_line='int(10)') + self.step([], source_line='puts("spam")') + + gdb.execute('cont', to_string=True) + self.assertEqual(len(gdb.inferiors()), 1) + self.assertEqual(gdb.inferiors()[0].pid, 0) + + def test_c_step(self): + self.break_and_run('some_c_function()') + gdb.execute('cy step', to_string=True) + self.assertEqual(gdb.selected_frame().name(), 'some_c_function') + + def test_python_step(self): + self.break_and_run('os.path.join("foo", "bar")') + + result = gdb.execute('cy step', to_string=True) + + curframe = gdb.selected_frame() + self.assertEqual(curframe.name(), 'PyEval_EvalFrameEx') + + pyframe = libpython.Frame(curframe).get_pyop() + # With Python 3 inferiors, pyframe.co_name will return a PyUnicodePtr, + # be compatible + frame_name = pyframe.co_name.proxyval(set()) + self.assertEqual(frame_name, 'join') + assert re.match(r'\d+ def join\(', result), result + + +class TestNext(DebugStepperTestCase): + + def test_cython_next(self): + self.break_and_run('c = 2') + + lines = ( + 'int(10)', + 'puts("spam")', + 'os.path.join("foo", "bar")', + 'some_c_function()', + ) + + for line in lines: + gdb.execute('cy next') + self.lineno_equals(line) + + +class TestLocalsGlobals(DebugTestCase): + + def test_locals(self): + self.break_and_run('int(10)') + + result = gdb.execute('cy locals', to_string=True) + assert 'a = 0', repr(result) + assert 'b = (int) 1', result + assert 'c = (int) 2' in result, repr(result) + + def test_globals(self): + self.break_and_run('int(10)') + + result = gdb.execute('cy globals', to_string=True) + assert '__name__ ' in result, repr(result) + assert '__doc__ ' in result, repr(result) + assert 'os ' in result, repr(result) + assert 'c_var ' in result, repr(result) + assert 'python_var ' in result, repr(result) + + +class TestBacktrace(DebugTestCase): + + def test_backtrace(self): + libcython.parameters.colorize_code.value = False + + self.break_and_run('os.path.join("foo", "bar")') + + def match_backtrace_output(result): + assert re.search(r'\#\d+ *0x.* in spam\(\) at .*codefile\.pyx:22', + result), result + assert 'os.path.join("foo", "bar")' in result, result + + result = gdb.execute('cy bt', to_string=True) + match_backtrace_output(result) + + result = gdb.execute('cy bt -a', to_string=True) + match_backtrace_output(result) + + # Apparently not everyone has main() + # assert re.search(r'\#0 *0x.* in main\(\)', result), result + + +class TestFunctions(DebugTestCase): + + def test_functions(self): + self.break_and_run('c = 2') + result = gdb.execute('print $cy_cname("b")', to_string=True) + assert re.search('__pyx_.*b', result), result + + result = gdb.execute('print $cy_lineno()', to_string=True) + supposed_lineno = test_libcython.source_to_lineno['c = 2'] + assert str(supposed_lineno) in result, (supposed_lineno, result) + + result = gdb.execute('print $cy_cvalue("b")', to_string=True) + assert '= 1' in result + + +class TestPrint(DebugTestCase): + + def test_print(self): + self.break_and_run('c = 2') + result = gdb.execute('cy print b', to_string=True) + self.assertEqual('b = (int) 1\n', result) + + +class TestUpDown(DebugTestCase): + + def test_updown(self): + self.break_and_run('os.path.join("foo", "bar")') + gdb.execute('cy step') + self.assertRaises(RuntimeError, gdb.execute, 'cy down') + + result = gdb.execute('cy up', to_string=True) + assert 'spam()' in result + assert 'os.path.join("foo", "bar")' in result + + +class TestExec(DebugTestCase): + + def setUp(self): + super(TestExec, self).setUp() + self.fd, self.tmpfilename = tempfile.mkstemp() + self.tmpfile = os.fdopen(self.fd, 'r+') + + def tearDown(self): + super(TestExec, self).tearDown() + + try: + self.tmpfile.close() + finally: + os.remove(self.tmpfilename) + + def eval_command(self, command): + gdb.execute('cy exec open(%r, "w").write(str(%s))' % + (self.tmpfilename, command)) + return self.tmpfile.read().strip() + + def test_cython_exec(self): + self.break_and_run('os.path.join("foo", "bar")') + + # test normal behaviour + self.assertEqual("[0]", self.eval_command('[a]')) + + # test multiline code + result = gdb.execute(textwrap.dedent('''\ + cy exec + pass + + "nothing" + end + ''')) + result = self.tmpfile.read().rstrip() + self.assertEqual('', result) + + def test_python_exec(self): + self.break_and_run('os.path.join("foo", "bar")') + gdb.execute('cy step') + + gdb.execute('cy exec some_random_var = 14') + self.assertEqual('14', self.eval_command('some_random_var')) + + +class CySet(DebugTestCase): + + def test_cyset(self): + self.break_and_run('os.path.join("foo", "bar")') + + gdb.execute('cy set a = $cy_eval("{None: []}")') + stringvalue = self.read_var("a", cast_to=str) + self.assertEqual(stringvalue, "{None: []}") + + +class TestCyEval(DebugTestCase): + "Test the $cy_eval() gdb function." + + def test_cy_eval(self): + # This function leaks a few objects in the GDB python process. This + # is no biggie + self.break_and_run('os.path.join("foo", "bar")') + + result = gdb.execute('print $cy_eval("None")', to_string=True) + assert re.match(r'\$\d+ = None\n', result), result + + result = gdb.execute('print $cy_eval("[a]")', to_string=True) + assert re.match(r'\$\d+ = \[0\]', result), result + + +class TestClosure(DebugTestCase): + + def break_and_run_func(self, funcname): + gdb.execute('cy break ' + funcname) + gdb.execute('cy run') + + def test_inner(self): + self.break_and_run_func('inner') + self.assertEqual('', gdb.execute('cy locals', to_string=True)) + + # Allow the Cython-generated code to initialize the scope variable + gdb.execute('cy step') + + self.assertEqual(str(self.read_var('a')), "'an object'") + print_result = gdb.execute('cy print a', to_string=True).strip() + self.assertEqual(print_result, "a = 'an object'") + + def test_outer(self): + self.break_and_run_func('outer') + self.assertEqual('', gdb.execute('cy locals', to_string=True)) + + # Initialize scope with 'a' uninitialized + gdb.execute('cy step') + self.assertEqual('', gdb.execute('cy locals', to_string=True)) + + # Initialize 'a' to 1 + gdb.execute('cy step') + print_result = gdb.execute('cy print a', to_string=True).strip() + self.assertEqual(print_result, "a = 'an object'") + + +_do_debug = os.environ.get('GDB_DEBUG') +if _do_debug: + _debug_file = open('/dev/tty', 'w') + +def _debug(*messages): + if _do_debug: + messages = itertools.chain([sys._getframe(1).f_code.co_name, ':'], + messages) + _debug_file.write(' '.join(str(msg) for msg in messages) + '\n') + + +def run_unittest_in_module(modulename): + try: + gdb.lookup_type('PyModuleObject') + except RuntimeError: + msg = ("Unable to run tests, Python was not compiled with " + "debugging information. Either compile python with " + "-g or get a debug build (configure with --with-pydebug).") + warnings.warn(msg) + os._exit(1) + else: + m = __import__(modulename, fromlist=['']) + tests = inspect.getmembers(m, inspect.isclass) + + # test_support.run_unittest(tests) + + test_loader = unittest.TestLoader() + suite = unittest.TestSuite( + [test_loader.loadTestsFromTestCase(cls) for name, cls in tests]) + + result = unittest.TextTestRunner(verbosity=1).run(suite) + return result.wasSuccessful() + +def runtests(): + """ + Run the libcython and libpython tests. Ensure that an appropriate status is + returned to the parent test process. + """ + from Cython.Debugger.Tests import test_libpython_in_gdb + + success_libcython = run_unittest_in_module(__name__) + success_libpython = run_unittest_in_module(test_libpython_in_gdb.__name__) + + if not success_libcython or not success_libpython: + sys.exit(2) + +def main(version, trace_code=False): + global inferior_python_version + + inferior_python_version = version + + if trace_code: + tracer = trace.Trace(count=False, trace=True, outfile=sys.stderr, + ignoredirs=[sys.prefix, sys.exec_prefix]) + tracer.runfunc(runtests) + else: + runtests() diff --git a/contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py b/contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py new file mode 100644 index 00000000000..6f34cee47b3 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py @@ -0,0 +1,115 @@ +# -*- coding: UTF-8 -*- + +""" +Test libpython.py. This is already partly tested by test_libcython_in_gdb and +Lib/test/test_gdb.py in the Python source. These tests are run in gdb and +called from test_libcython_in_gdb.main() +""" + +import os +import sys + +import gdb + +from Cython.Debugger import libcython +from Cython.Debugger import libpython + +from . import test_libcython_in_gdb +from .test_libcython_in_gdb import _debug, inferior_python_version + + +class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase): + """ + Test whether types of Python objects are correctly inferred and that + the right libpython.PySomeTypeObjectPtr classes are instantiated. + + Also test whether values are appropriately formatted (don't be too + laborious as Lib/test/test_gdb.py already covers this extensively). + + Don't take care of decreffing newly allocated objects as a new + interpreter is started for every test anyway. + """ + + def setUp(self): + super(TestPrettyPrinters, self).setUp() + self.break_and_run('b = c = d = 0') + + def get_pyobject(self, code): + value = gdb.parse_and_eval(code) + assert libpython.pointervalue(value) != 0 + return value + + def pyobject_fromcode(self, code, gdbvar=None): + if gdbvar is not None: + d = {'varname':gdbvar, 'code':code} + gdb.execute('set $%(varname)s = %(code)s' % d) + code = '$' + gdbvar + + return libpython.PyObjectPtr.from_pyobject_ptr(self.get_pyobject(code)) + + def get_repr(self, pyobject): + return pyobject.get_truncated_repr(libpython.MAX_OUTPUT_LEN) + + def alloc_bytestring(self, string, gdbvar=None): + if inferior_python_version < (3, 0): + funcname = 'PyString_FromStringAndSize' + else: + funcname = 'PyBytes_FromStringAndSize' + + assert b'"' not in string + + # ensure double quotes + code = '(PyObject *) %s("%s", %d)' % (funcname, string.decode('iso8859-1'), len(string)) + return self.pyobject_fromcode(code, gdbvar=gdbvar) + + def alloc_unicodestring(self, string, gdbvar=None): + postfix = libpython.get_inferior_unicode_postfix() + funcname = 'PyUnicode%s_DecodeUnicodeEscape' % (postfix,) + + data = string.encode("unicode_escape").decode('iso8859-1') + return self.pyobject_fromcode( + '(PyObject *) %s("%s", %d, "strict")' % ( + funcname, data.replace('"', r'\"').replace('\\', r'\\'), len(data)), + gdbvar=gdbvar) + + def test_bytestring(self): + bytestring = self.alloc_bytestring(b"spam") + + if inferior_python_version < (3, 0): + bytestring_class = libpython.PyStringObjectPtr + expected = repr(b"spam") + else: + bytestring_class = libpython.PyBytesObjectPtr + expected = "b'spam'" + + self.assertEqual(type(bytestring), bytestring_class) + self.assertEqual(self.get_repr(bytestring), expected) + + def test_unicode(self): + unicode_string = self.alloc_unicodestring(u"spam ἄλφα") + + expected = u"'spam ἄλφα'" + if inferior_python_version < (3, 0): + expected = 'u' + expected + + self.assertEqual(type(unicode_string), libpython.PyUnicodeObjectPtr) + self.assertEqual(self.get_repr(unicode_string), expected) + + def test_int(self): + if inferior_python_version < (3, 0): + intval = self.pyobject_fromcode('PyInt_FromLong(100)') + self.assertEqual(type(intval), libpython.PyIntObjectPtr) + self.assertEqual(self.get_repr(intval), '100') + + def test_long(self): + longval = self.pyobject_fromcode('PyLong_FromLong(200)', + gdbvar='longval') + assert gdb.parse_and_eval('$longval->ob_type == &PyLong_Type') + + self.assertEqual(type(longval), libpython.PyLongObjectPtr) + self.assertEqual(self.get_repr(longval), '200') + + def test_frame_type(self): + frame = self.pyobject_fromcode('PyEval_GetFrame()') + + self.assertEqual(type(frame), libpython.PyFrameObjectPtr) diff --git a/contrib/tools/cython/Cython/Debugger/__init__.py b/contrib/tools/cython/Cython/Debugger/__init__.py new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Debugger/libcython.py b/contrib/tools/cython/Cython/Debugger/libcython.py new file mode 100644 index 00000000000..23153789b66 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/libcython.py @@ -0,0 +1,1434 @@ +""" +GDB extension that adds Cython support. +""" + +from __future__ import print_function + +try: + input = raw_input +except NameError: + pass + +import sys +import textwrap +import traceback +import functools +import itertools +import collections + +import gdb + +try: # python 2 + UNICODE = unicode + BYTES = str +except NameError: # python 3 + UNICODE = str + BYTES = bytes + +try: + from lxml import etree + have_lxml = True +except ImportError: + have_lxml = False + try: + # Python 2.5 + from xml.etree import cElementTree as etree + except ImportError: + try: + # Python 2.5 + from xml.etree import ElementTree as etree + except ImportError: + try: + # normal cElementTree install + import cElementTree as etree + except ImportError: + # normal ElementTree install + import elementtree.ElementTree as etree + +try: + import pygments.lexers + import pygments.formatters +except ImportError: + pygments = None + sys.stderr.write("Install pygments for colorized source code.\n") + +if hasattr(gdb, 'string_to_argv'): + from gdb import string_to_argv +else: + from shlex import split as string_to_argv + +from Cython.Debugger import libpython + +# C or Python type +CObject = 'CObject' +PythonObject = 'PythonObject' + +_data_types = dict(CObject=CObject, PythonObject=PythonObject) +_filesystemencoding = sys.getfilesystemencoding() or 'UTF-8' + + +# decorators + +def dont_suppress_errors(function): + "*sigh*, readline" + @functools.wraps(function) + def wrapper(*args, **kwargs): + try: + return function(*args, **kwargs) + except Exception: + traceback.print_exc() + raise + + return wrapper + + +def default_selected_gdb_frame(err=True): + def decorator(function): + @functools.wraps(function) + def wrapper(self, frame=None, *args, **kwargs): + try: + frame = frame or gdb.selected_frame() + except RuntimeError: + raise gdb.GdbError("No frame is currently selected.") + + if err and frame.name() is None: + raise NoFunctionNameInFrameError() + + return function(self, frame, *args, **kwargs) + return wrapper + return decorator + + +def require_cython_frame(function): + @functools.wraps(function) + @require_running_program + def wrapper(self, *args, **kwargs): + frame = kwargs.get('frame') or gdb.selected_frame() + if not self.is_cython_function(frame): + raise gdb.GdbError('Selected frame does not correspond with a ' + 'Cython function we know about.') + return function(self, *args, **kwargs) + return wrapper + + +def dispatch_on_frame(c_command, python_command=None): + def decorator(function): + @functools.wraps(function) + def wrapper(self, *args, **kwargs): + is_cy = self.is_cython_function() + is_py = self.is_python_function() + + if is_cy or (is_py and not python_command): + function(self, *args, **kwargs) + elif is_py: + gdb.execute(python_command) + elif self.is_relevant_function(): + gdb.execute(c_command) + else: + raise gdb.GdbError("Not a function cygdb knows about. " + "Use the normal GDB commands instead.") + + return wrapper + return decorator + + +def require_running_program(function): + @functools.wraps(function) + def wrapper(*args, **kwargs): + try: + gdb.selected_frame() + except RuntimeError: + raise gdb.GdbError("No frame is currently selected.") + + return function(*args, **kwargs) + return wrapper + + +def gdb_function_value_to_unicode(function): + @functools.wraps(function) + def wrapper(self, string, *args, **kwargs): + if isinstance(string, gdb.Value): + string = string.string() + + return function(self, string, *args, **kwargs) + return wrapper + + +# Classes that represent the debug information +# Don't rename the parameters of these classes, they come directly from the XML + +class CythonModule(object): + def __init__(self, module_name, filename, c_filename): + self.name = module_name + self.filename = filename + self.c_filename = c_filename + self.globals = {} + # {cython_lineno: min(c_linenos)} + self.lineno_cy2c = {} + # {c_lineno: cython_lineno} + self.lineno_c2cy = {} + self.functions = {} + + +class CythonVariable(object): + + def __init__(self, name, cname, qualified_name, type, lineno): + self.name = name + self.cname = cname + self.qualified_name = qualified_name + self.type = type + self.lineno = int(lineno) + + +class CythonFunction(CythonVariable): + def __init__(self, + module, + name, + cname, + pf_cname, + qualified_name, + lineno, + type=CObject, + is_initmodule_function="False"): + super(CythonFunction, self).__init__(name, + cname, + qualified_name, + type, + lineno) + self.module = module + self.pf_cname = pf_cname + self.is_initmodule_function = is_initmodule_function == "True" + self.locals = {} + self.arguments = [] + self.step_into_functions = set() + + +# General purpose classes + +class CythonBase(object): + + @default_selected_gdb_frame(err=False) + def is_cython_function(self, frame): + return frame.name() in self.cy.functions_by_cname + + @default_selected_gdb_frame(err=False) + def is_python_function(self, frame): + """ + Tells if a frame is associated with a Python function. + If we can't read the Python frame information, don't regard it as such. + """ + if frame.name() == 'PyEval_EvalFrameEx': + pyframe = libpython.Frame(frame).get_pyop() + return pyframe and not pyframe.is_optimized_out() + return False + + @default_selected_gdb_frame() + def get_c_function_name(self, frame): + return frame.name() + + @default_selected_gdb_frame() + def get_c_lineno(self, frame): + return frame.find_sal().line + + @default_selected_gdb_frame() + def get_cython_function(self, frame): + result = self.cy.functions_by_cname.get(frame.name()) + if result is None: + raise NoCythonFunctionInFrameError() + + return result + + @default_selected_gdb_frame() + def get_cython_lineno(self, frame): + """ + Get the current Cython line number. Returns 0 if there is no + correspondence between the C and Cython code. + """ + cyfunc = self.get_cython_function(frame) + return cyfunc.module.lineno_c2cy.get(self.get_c_lineno(frame), 0) + + @default_selected_gdb_frame() + def get_source_desc(self, frame): + filename = lineno = lexer = None + if self.is_cython_function(frame): + filename = self.get_cython_function(frame).module.filename + lineno = self.get_cython_lineno(frame) + if pygments: + lexer = pygments.lexers.CythonLexer(stripall=False) + elif self.is_python_function(frame): + pyframeobject = libpython.Frame(frame).get_pyop() + + if not pyframeobject: + raise gdb.GdbError( + 'Unable to read information on python frame') + + filename = pyframeobject.filename() + lineno = pyframeobject.current_line_num() + + if pygments: + lexer = pygments.lexers.PythonLexer(stripall=False) + else: + symbol_and_line_obj = frame.find_sal() + if not symbol_and_line_obj or not symbol_and_line_obj.symtab: + filename = None + lineno = 0 + else: + filename = symbol_and_line_obj.symtab.fullname() + lineno = symbol_and_line_obj.line + if pygments: + lexer = pygments.lexers.CLexer(stripall=False) + + return SourceFileDescriptor(filename, lexer), lineno + + @default_selected_gdb_frame() + def get_source_line(self, frame): + source_desc, lineno = self.get_source_desc() + return source_desc.get_source(lineno) + + @default_selected_gdb_frame() + def is_relevant_function(self, frame): + """ + returns whether we care about a frame on the user-level when debugging + Cython code + """ + name = frame.name() + older_frame = frame.older() + if self.is_cython_function(frame) or self.is_python_function(frame): + return True + elif older_frame and self.is_cython_function(older_frame): + # check for direct C function call from a Cython function + cython_func = self.get_cython_function(older_frame) + return name in cython_func.step_into_functions + + return False + + @default_selected_gdb_frame(err=False) + def print_stackframe(self, frame, index, is_c=False): + """ + Print a C, Cython or Python stack frame and the line of source code + if available. + """ + # do this to prevent the require_cython_frame decorator from + # raising GdbError when calling self.cy.cy_cvalue.invoke() + selected_frame = gdb.selected_frame() + frame.select() + + try: + source_desc, lineno = self.get_source_desc(frame) + except NoFunctionNameInFrameError: + print('#%-2d Unknown Frame (compile with -g)' % index) + return + + if not is_c and self.is_python_function(frame): + pyframe = libpython.Frame(frame).get_pyop() + if pyframe is None or pyframe.is_optimized_out(): + # print this python function as a C function + return self.print_stackframe(frame, index, is_c=True) + + func_name = pyframe.co_name + func_cname = 'PyEval_EvalFrameEx' + func_args = [] + elif self.is_cython_function(frame): + cyfunc = self.get_cython_function(frame) + f = lambda arg: self.cy.cy_cvalue.invoke(arg, frame=frame) + + func_name = cyfunc.name + func_cname = cyfunc.cname + func_args = [] # [(arg, f(arg)) for arg in cyfunc.arguments] + else: + source_desc, lineno = self.get_source_desc(frame) + func_name = frame.name() + func_cname = func_name + func_args = [] + + try: + gdb_value = gdb.parse_and_eval(func_cname) + except RuntimeError: + func_address = 0 + else: + func_address = gdb_value.address + if not isinstance(func_address, int): + # Seriously? Why is the address not an int? + if not isinstance(func_address, (str, bytes)): + func_address = str(func_address) + func_address = int(func_address.split()[0], 0) + + a = ', '.join('%s=%s' % (name, val) for name, val in func_args) + sys.stdout.write('#%-2d 0x%016x in %s(%s)' % (index, func_address, func_name, a)) + + if source_desc.filename is not None: + sys.stdout.write(' at %s:%s' % (source_desc.filename, lineno)) + + sys.stdout.write('\n') + + try: + sys.stdout.write(' ' + source_desc.get_source(lineno)) + except gdb.GdbError: + pass + + selected_frame.select() + + def get_remote_cython_globals_dict(self): + m = gdb.parse_and_eval('__pyx_m') + + try: + PyModuleObject = gdb.lookup_type('PyModuleObject') + except RuntimeError: + raise gdb.GdbError(textwrap.dedent("""\ + Unable to lookup type PyModuleObject, did you compile python + with debugging support (-g)?""")) + + m = m.cast(PyModuleObject.pointer()) + return m['md_dict'] + + + def get_cython_globals_dict(self): + """ + Get the Cython globals dict where the remote names are turned into + local strings. + """ + remote_dict = self.get_remote_cython_globals_dict() + pyobject_dict = libpython.PyObjectPtr.from_pyobject_ptr(remote_dict) + + result = {} + seen = set() + for k, v in pyobject_dict.items(): + result[k.proxyval(seen)] = v + + return result + + def print_gdb_value(self, name, value, max_name_length=None, prefix=''): + if libpython.pretty_printer_lookup(value): + typename = '' + else: + typename = '(%s) ' % (value.type,) + + if max_name_length is None: + print('%s%s = %s%s' % (prefix, name, typename, value)) + else: + print('%s%-*s = %s%s' % (prefix, max_name_length, name, typename, value)) + + def is_initialized(self, cython_func, local_name): + cyvar = cython_func.locals[local_name] + cur_lineno = self.get_cython_lineno() + + if '->' in cyvar.cname: + # Closed over free variable + if cur_lineno > cython_func.lineno: + if cyvar.type == PythonObject: + return int(gdb.parse_and_eval(cyvar.cname)) + return True + return False + + return cur_lineno > cyvar.lineno + + +class SourceFileDescriptor(object): + def __init__(self, filename, lexer, formatter=None): + self.filename = filename + self.lexer = lexer + self.formatter = formatter + + def valid(self): + return self.filename is not None + + def lex(self, code): + if pygments and self.lexer and parameters.colorize_code: + bg = parameters.terminal_background.value + if self.formatter is None: + formatter = pygments.formatters.TerminalFormatter(bg=bg) + else: + formatter = self.formatter + + return pygments.highlight(code, self.lexer, formatter) + + return code + + def _get_source(self, start, stop, lex_source, mark_line, lex_entire): + with open(self.filename) as f: + # to provide "correct" colouring, the entire code needs to be + # lexed. However, this makes a lot of things terribly slow, so + # we decide not to. Besides, it's unlikely to matter. + + if lex_source and lex_entire: + f = self.lex(f.read()).splitlines() + + slice = itertools.islice(f, start - 1, stop - 1) + + for idx, line in enumerate(slice): + if start + idx == mark_line: + prefix = '>' + else: + prefix = ' ' + + if lex_source and not lex_entire: + line = self.lex(line) + + yield '%s %4d %s' % (prefix, start + idx, line.rstrip()) + + def get_source(self, start, stop=None, lex_source=True, mark_line=0, + lex_entire=False): + exc = gdb.GdbError('Unable to retrieve source code') + + if not self.filename: + raise exc + + start = max(start, 1) + if stop is None: + stop = start + 1 + + try: + return '\n'.join( + self._get_source(start, stop, lex_source, mark_line, lex_entire)) + except IOError: + raise exc + + +# Errors + +class CyGDBError(gdb.GdbError): + """ + Base class for Cython-command related errors + """ + + def __init__(self, *args): + args = args or (self.msg,) + super(CyGDBError, self).__init__(*args) + + +class NoCythonFunctionInFrameError(CyGDBError): + """ + raised when the user requests the current cython function, which is + unavailable + """ + msg = "Current function is a function cygdb doesn't know about" + + +class NoFunctionNameInFrameError(NoCythonFunctionInFrameError): + """ + raised when the name of the C function could not be determined + in the current C stack frame + """ + msg = ('C function name could not be determined in the current C stack ' + 'frame') + + +# Parameters + +class CythonParameter(gdb.Parameter): + """ + Base class for cython parameters + """ + + def __init__(self, name, command_class, parameter_class, default=None): + self.show_doc = self.set_doc = self.__class__.__doc__ + super(CythonParameter, self).__init__(name, command_class, + parameter_class) + if default is not None: + self.value = default + + def __bool__(self): + return bool(self.value) + + __nonzero__ = __bool__ # Python 2 + + + +class CompleteUnqualifiedFunctionNames(CythonParameter): + """ + Have 'cy break' complete unqualified function or method names. + """ + + +class ColorizeSourceCode(CythonParameter): + """ + Tell cygdb whether to colorize source code. + """ + + +class TerminalBackground(CythonParameter): + """ + Tell cygdb about the user's terminal background (light or dark). + """ + + +class CythonParameters(object): + """ + Simple container class that might get more functionality in the distant + future (mostly to remind us that we're dealing with parameters). + """ + + def __init__(self): + self.complete_unqualified = CompleteUnqualifiedFunctionNames( + 'cy_complete_unqualified', + gdb.COMMAND_BREAKPOINTS, + gdb.PARAM_BOOLEAN, + True) + self.colorize_code = ColorizeSourceCode( + 'cy_colorize_code', + gdb.COMMAND_FILES, + gdb.PARAM_BOOLEAN, + True) + self.terminal_background = TerminalBackground( + 'cy_terminal_background_color', + gdb.COMMAND_FILES, + gdb.PARAM_STRING, + "dark") + +parameters = CythonParameters() + + +# Commands + +class CythonCommand(gdb.Command, CythonBase): + """ + Base class for Cython commands + """ + + command_class = gdb.COMMAND_NONE + + @classmethod + def _register(cls, clsname, args, kwargs): + if not hasattr(cls, 'completer_class'): + return cls(clsname, cls.command_class, *args, **kwargs) + else: + return cls(clsname, cls.command_class, cls.completer_class, + *args, **kwargs) + + @classmethod + def register(cls, *args, **kwargs): + alias = getattr(cls, 'alias', None) + if alias: + cls._register(cls.alias, args, kwargs) + + return cls._register(cls.name, args, kwargs) + + +class CyCy(CythonCommand): + """ + Invoke a Cython command. Available commands are: + + cy import + cy break + cy step + cy next + cy run + cy cont + cy finish + cy up + cy down + cy select + cy bt / cy backtrace + cy list + cy print + cy set + cy locals + cy globals + cy exec + """ + + name = 'cy' + command_class = gdb.COMMAND_NONE + completer_class = gdb.COMPLETE_COMMAND + + def __init__(self, name, command_class, completer_class): + # keep the signature 2.5 compatible (i.e. do not use f(*a, k=v) + super(CythonCommand, self).__init__(name, command_class, + completer_class, prefix=True) + + commands = dict( + # GDB commands + import_ = CyImport.register(), + break_ = CyBreak.register(), + step = CyStep.register(), + next = CyNext.register(), + run = CyRun.register(), + cont = CyCont.register(), + finish = CyFinish.register(), + up = CyUp.register(), + down = CyDown.register(), + select = CySelect.register(), + bt = CyBacktrace.register(), + list = CyList.register(), + print_ = CyPrint.register(), + locals = CyLocals.register(), + globals = CyGlobals.register(), + exec_ = libpython.FixGdbCommand('cy exec', '-cy-exec'), + _exec = CyExec.register(), + set = CySet.register(), + + # GDB functions + cy_cname = CyCName('cy_cname'), + cy_cvalue = CyCValue('cy_cvalue'), + cy_lineno = CyLine('cy_lineno'), + cy_eval = CyEval('cy_eval'), + ) + + for command_name, command in commands.items(): + command.cy = self + setattr(self, command_name, command) + + self.cy = self + + # Cython module namespace + self.cython_namespace = {} + + # maps (unique) qualified function names (e.g. + # cythonmodule.ClassName.method_name) to the CythonFunction object + self.functions_by_qualified_name = {} + + # unique cnames of Cython functions + self.functions_by_cname = {} + + # map function names like method_name to a list of all such + # CythonFunction objects + self.functions_by_name = collections.defaultdict(list) + + +class CyImport(CythonCommand): + """ + Import debug information outputted by the Cython compiler + Example: cy import FILE... + """ + + name = 'cy import' + command_class = gdb.COMMAND_STATUS + completer_class = gdb.COMPLETE_FILENAME + + def invoke(self, args, from_tty): + if isinstance(args, BYTES): + args = args.decode(_filesystemencoding) + for arg in string_to_argv(args): + try: + f = open(arg) + except OSError as e: + raise gdb.GdbError('Unable to open file %r: %s' % (args, e.args[1])) + + t = etree.parse(f) + + for module in t.getroot(): + cython_module = CythonModule(**module.attrib) + self.cy.cython_namespace[cython_module.name] = cython_module + + for variable in module.find('Globals'): + d = variable.attrib + cython_module.globals[d['name']] = CythonVariable(**d) + + for function in module.find('Functions'): + cython_function = CythonFunction(module=cython_module, + **function.attrib) + + # update the global function mappings + name = cython_function.name + qname = cython_function.qualified_name + + self.cy.functions_by_name[name].append(cython_function) + self.cy.functions_by_qualified_name[ + cython_function.qualified_name] = cython_function + self.cy.functions_by_cname[ + cython_function.cname] = cython_function + + d = cython_module.functions[qname] = cython_function + + for local in function.find('Locals'): + d = local.attrib + cython_function.locals[d['name']] = CythonVariable(**d) + + for step_into_func in function.find('StepIntoFunctions'): + d = step_into_func.attrib + cython_function.step_into_functions.add(d['name']) + + cython_function.arguments.extend( + funcarg.tag for funcarg in function.find('Arguments')) + + for marker in module.find('LineNumberMapping'): + cython_lineno = int(marker.attrib['cython_lineno']) + c_linenos = list(map(int, marker.attrib['c_linenos'].split())) + cython_module.lineno_cy2c[cython_lineno] = min(c_linenos) + for c_lineno in c_linenos: + cython_module.lineno_c2cy[c_lineno] = cython_lineno + + +class CyBreak(CythonCommand): + """ + Set a breakpoint for Cython code using Cython qualified name notation, e.g.: + + cy break cython_modulename.ClassName.method_name... + + or normal notation: + + cy break function_or_method_name... + + or for a line number: + + cy break cython_module:lineno... + + Set a Python breakpoint: + Break on any function or method named 'func' in module 'modname' + + cy break -p modname.func... + + Break on any function or method named 'func' + + cy break -p func... + """ + + name = 'cy break' + command_class = gdb.COMMAND_BREAKPOINTS + + def _break_pyx(self, name): + modulename, _, lineno = name.partition(':') + lineno = int(lineno) + if modulename: + cython_module = self.cy.cython_namespace[modulename] + else: + cython_module = self.get_cython_function().module + + if lineno in cython_module.lineno_cy2c: + c_lineno = cython_module.lineno_cy2c[lineno] + breakpoint = '%s:%s' % (cython_module.c_filename, c_lineno) + gdb.execute('break ' + breakpoint) + else: + raise gdb.GdbError("Not a valid line number. " + "Does it contain actual code?") + + def _break_funcname(self, funcname): + func = self.cy.functions_by_qualified_name.get(funcname) + + if func and func.is_initmodule_function: + func = None + + break_funcs = [func] + + if not func: + funcs = self.cy.functions_by_name.get(funcname) or [] + funcs = [f for f in funcs if not f.is_initmodule_function] + + if not funcs: + gdb.execute('break ' + funcname) + return + + if len(funcs) > 1: + # multiple functions, let the user pick one + print('There are multiple such functions:') + for idx, func in enumerate(funcs): + print('%3d) %s' % (idx, func.qualified_name)) + + while True: + try: + result = input( + "Select a function, press 'a' for all " + "functions or press 'q' or '^D' to quit: ") + except EOFError: + return + else: + if result.lower() == 'q': + return + elif result.lower() == 'a': + break_funcs = funcs + break + elif (result.isdigit() and + 0 <= int(result) < len(funcs)): + break_funcs = [funcs[int(result)]] + break + else: + print('Not understood...') + else: + break_funcs = [funcs[0]] + + for func in break_funcs: + gdb.execute('break %s' % func.cname) + if func.pf_cname: + gdb.execute('break %s' % func.pf_cname) + + def invoke(self, function_names, from_tty): + if isinstance(function_names, BYTES): + function_names = function_names.decode(_filesystemencoding) + argv = string_to_argv(function_names) + if function_names.startswith('-p'): + argv = argv[1:] + python_breakpoints = True + else: + python_breakpoints = False + + for funcname in argv: + if python_breakpoints: + gdb.execute('py-break %s' % funcname) + elif ':' in funcname: + self._break_pyx(funcname) + else: + self._break_funcname(funcname) + + @dont_suppress_errors + def complete(self, text, word): + # Filter init-module functions (breakpoints can be set using + # modulename:linenumber). + names = [n for n, L in self.cy.functions_by_name.items() + if any(not f.is_initmodule_function for f in L)] + qnames = [n for n, f in self.cy.functions_by_qualified_name.items() + if not f.is_initmodule_function] + + if parameters.complete_unqualified: + all_names = itertools.chain(qnames, names) + else: + all_names = qnames + + words = text.strip().split() + if not words or '.' not in words[-1]: + # complete unqualified + seen = set(text[:-len(word)].split()) + return [n for n in all_names + if n.startswith(word) and n not in seen] + + # complete qualified name + lastword = words[-1] + compl = [n for n in qnames if n.startswith(lastword)] + + if len(lastword) > len(word): + # readline sees something (e.g. a '.') as a word boundary, so don't + # "recomplete" this prefix + strip_prefix_length = len(lastword) - len(word) + compl = [n[strip_prefix_length:] for n in compl] + + return compl + + +class CythonInfo(CythonBase, libpython.PythonInfo): + """ + Implementation of the interface dictated by libpython.LanguageInfo. + """ + + def lineno(self, frame): + # Take care of the Python and Cython levels. We need to care for both + # as we can't simply dispatch to 'py-step', since that would work for + # stepping through Python code, but it would not step back into Cython- + # related code. The C level should be dispatched to the 'step' command. + if self.is_cython_function(frame): + return self.get_cython_lineno(frame) + return super(CythonInfo, self).lineno(frame) + + def get_source_line(self, frame): + try: + line = super(CythonInfo, self).get_source_line(frame) + except gdb.GdbError: + return None + else: + return line.strip() or None + + def exc_info(self, frame): + if self.is_python_function: + return super(CythonInfo, self).exc_info(frame) + + def runtime_break_functions(self): + if self.is_cython_function(): + return self.get_cython_function().step_into_functions + return () + + def static_break_functions(self): + result = ['PyEval_EvalFrameEx'] + result.extend(self.cy.functions_by_cname) + return result + + +class CythonExecutionControlCommand(CythonCommand, + libpython.ExecutionControlCommandBase): + + @classmethod + def register(cls): + return cls(cls.name, cython_info) + + +class CyStep(CythonExecutionControlCommand, libpython.PythonStepperMixin): + "Step through Cython, Python or C code." + + name = 'cy -step' + stepinto = True + + def invoke(self, args, from_tty): + if self.is_python_function(): + self.python_step(self.stepinto) + elif not self.is_cython_function(): + if self.stepinto: + command = 'step' + else: + command = 'next' + + self.finish_executing(gdb.execute(command, to_string=True)) + else: + self.step(stepinto=self.stepinto) + + +class CyNext(CyStep): + "Step-over Cython, Python or C code." + + name = 'cy -next' + stepinto = False + + +class CyRun(CythonExecutionControlCommand): + """ + Run a Cython program. This is like the 'run' command, except that it + displays Cython or Python source lines as well + """ + + name = 'cy run' + + invoke = CythonExecutionControlCommand.run + + +class CyCont(CythonExecutionControlCommand): + """ + Continue a Cython program. This is like the 'run' command, except that it + displays Cython or Python source lines as well. + """ + + name = 'cy cont' + invoke = CythonExecutionControlCommand.cont + + +class CyFinish(CythonExecutionControlCommand): + """ + Execute until the function returns. + """ + name = 'cy finish' + + invoke = CythonExecutionControlCommand.finish + + +class CyUp(CythonCommand): + """ + Go up a Cython, Python or relevant C frame. + """ + name = 'cy up' + _command = 'up' + + def invoke(self, *args): + try: + gdb.execute(self._command, to_string=True) + while not self.is_relevant_function(gdb.selected_frame()): + gdb.execute(self._command, to_string=True) + except RuntimeError as e: + raise gdb.GdbError(*e.args) + + frame = gdb.selected_frame() + index = 0 + while frame: + frame = frame.older() + index += 1 + + self.print_stackframe(index=index - 1) + + +class CyDown(CyUp): + """ + Go down a Cython, Python or relevant C frame. + """ + + name = 'cy down' + _command = 'down' + + +class CySelect(CythonCommand): + """ + Select a frame. Use frame numbers as listed in `cy backtrace`. + This command is useful because `cy backtrace` prints a reversed backtrace. + """ + + name = 'cy select' + + def invoke(self, stackno, from_tty): + try: + stackno = int(stackno) + except ValueError: + raise gdb.GdbError("Not a valid number: %r" % (stackno,)) + + frame = gdb.selected_frame() + while frame.newer(): + frame = frame.newer() + + stackdepth = libpython.stackdepth(frame) + + try: + gdb.execute('select %d' % (stackdepth - stackno - 1,)) + except RuntimeError as e: + raise gdb.GdbError(*e.args) + + +class CyBacktrace(CythonCommand): + 'Print the Cython stack' + + name = 'cy bt' + alias = 'cy backtrace' + command_class = gdb.COMMAND_STACK + completer_class = gdb.COMPLETE_NONE + + @require_running_program + def invoke(self, args, from_tty): + # get the first frame + frame = gdb.selected_frame() + while frame.older(): + frame = frame.older() + + print_all = args == '-a' + + index = 0 + while frame: + try: + is_relevant = self.is_relevant_function(frame) + except CyGDBError: + is_relevant = False + + if print_all or is_relevant: + self.print_stackframe(frame, index) + + index += 1 + frame = frame.newer() + + +class CyList(CythonCommand): + """ + List Cython source code. To disable to customize colouring see the cy_* + parameters. + """ + + name = 'cy list' + command_class = gdb.COMMAND_FILES + completer_class = gdb.COMPLETE_NONE + + # @dispatch_on_frame(c_command='list') + def invoke(self, _, from_tty): + sd, lineno = self.get_source_desc() + source = sd.get_source(lineno - 5, lineno + 5, mark_line=lineno, + lex_entire=True) + print(source) + + +class CyPrint(CythonCommand): + """ + Print a Cython variable using 'cy-print x' or 'cy-print module.function.x' + """ + + name = 'cy print' + command_class = gdb.COMMAND_DATA + + def invoke(self, name, from_tty, max_name_length=None): + if self.is_python_function(): + return gdb.execute('py-print ' + name) + elif self.is_cython_function(): + value = self.cy.cy_cvalue.invoke(name.lstrip('*')) + for c in name: + if c == '*': + value = value.dereference() + else: + break + + self.print_gdb_value(name, value, max_name_length) + else: + gdb.execute('print ' + name) + + def complete(self): + if self.is_cython_function(): + f = self.get_cython_function() + return list(itertools.chain(f.locals, f.globals)) + else: + return [] + + +sortkey = lambda item: item[0].lower() + + +class CyLocals(CythonCommand): + """ + List the locals from the current Cython frame. + """ + + name = 'cy locals' + command_class = gdb.COMMAND_STACK + completer_class = gdb.COMPLETE_NONE + + @dispatch_on_frame(c_command='info locals', python_command='py-locals') + def invoke(self, args, from_tty): + cython_function = self.get_cython_function() + + if cython_function.is_initmodule_function: + self.cy.globals.invoke(args, from_tty) + return + + local_cython_vars = cython_function.locals + max_name_length = len(max(local_cython_vars, key=len)) + for name, cyvar in sorted(local_cython_vars.items(), key=sortkey): + if self.is_initialized(self.get_cython_function(), cyvar.name): + value = gdb.parse_and_eval(cyvar.cname) + if not value.is_optimized_out: + self.print_gdb_value(cyvar.name, value, + max_name_length, '') + + +class CyGlobals(CyLocals): + """ + List the globals from the current Cython module. + """ + + name = 'cy globals' + command_class = gdb.COMMAND_STACK + completer_class = gdb.COMPLETE_NONE + + @dispatch_on_frame(c_command='info variables', python_command='py-globals') + def invoke(self, args, from_tty): + global_python_dict = self.get_cython_globals_dict() + module_globals = self.get_cython_function().module.globals + + max_globals_len = 0 + max_globals_dict_len = 0 + if module_globals: + max_globals_len = len(max(module_globals, key=len)) + if global_python_dict: + max_globals_dict_len = len(max(global_python_dict)) + + max_name_length = max(max_globals_len, max_globals_dict_len) + + seen = set() + print('Python globals:') + for k, v in sorted(global_python_dict.items(), key=sortkey): + v = v.get_truncated_repr(libpython.MAX_OUTPUT_LEN) + seen.add(k) + print(' %-*s = %s' % (max_name_length, k, v)) + + print('C globals:') + for name, cyvar in sorted(module_globals.items(), key=sortkey): + if name not in seen: + try: + value = gdb.parse_and_eval(cyvar.cname) + except RuntimeError: + pass + else: + if not value.is_optimized_out: + self.print_gdb_value(cyvar.name, value, + max_name_length, ' ') + + +class EvaluateOrExecuteCodeMixin(object): + """ + Evaluate or execute Python code in a Cython or Python frame. The 'evalcode' + method evaluations Python code, prints a traceback if an exception went + uncaught, and returns any return value as a gdb.Value (NULL on exception). + """ + + def _fill_locals_dict(self, executor, local_dict_pointer): + "Fill a remotely allocated dict with values from the Cython C stack" + cython_func = self.get_cython_function() + + for name, cyvar in cython_func.locals.items(): + if cyvar.type == PythonObject and self.is_initialized(cython_func, name): + try: + val = gdb.parse_and_eval(cyvar.cname) + except RuntimeError: + continue + else: + if val.is_optimized_out: + continue + + pystringp = executor.alloc_pystring(name) + code = ''' + (PyObject *) PyDict_SetItem( + (PyObject *) %d, + (PyObject *) %d, + (PyObject *) %s) + ''' % (local_dict_pointer, pystringp, cyvar.cname) + + try: + if gdb.parse_and_eval(code) < 0: + gdb.parse_and_eval('PyErr_Print()') + raise gdb.GdbError("Unable to execute Python code.") + finally: + # PyDict_SetItem doesn't steal our reference + executor.xdecref(pystringp) + + def _find_first_cython_or_python_frame(self): + frame = gdb.selected_frame() + while frame: + if (self.is_cython_function(frame) or + self.is_python_function(frame)): + frame.select() + return frame + + frame = frame.older() + + raise gdb.GdbError("There is no Cython or Python frame on the stack.") + + def _evalcode_cython(self, executor, code, input_type): + with libpython.FetchAndRestoreError(): + # get the dict of Cython globals and construct a dict in the + # inferior with Cython locals + global_dict = gdb.parse_and_eval( + '(PyObject *) PyModule_GetDict(__pyx_m)') + local_dict = gdb.parse_and_eval('(PyObject *) PyDict_New()') + + try: + self._fill_locals_dict(executor, + libpython.pointervalue(local_dict)) + result = executor.evalcode(code, input_type, global_dict, + local_dict) + finally: + executor.xdecref(libpython.pointervalue(local_dict)) + + return result + + def evalcode(self, code, input_type): + """ + Evaluate `code` in a Python or Cython stack frame using the given + `input_type`. + """ + frame = self._find_first_cython_or_python_frame() + executor = libpython.PythonCodeExecutor() + if self.is_python_function(frame): + return libpython._evalcode_python(executor, code, input_type) + return self._evalcode_cython(executor, code, input_type) + + +class CyExec(CythonCommand, libpython.PyExec, EvaluateOrExecuteCodeMixin): + """ + Execute Python code in the nearest Python or Cython frame. + """ + + name = '-cy-exec' + command_class = gdb.COMMAND_STACK + completer_class = gdb.COMPLETE_NONE + + def invoke(self, expr, from_tty): + expr, input_type = self.readcode(expr) + executor = libpython.PythonCodeExecutor() + executor.xdecref(self.evalcode(expr, executor.Py_single_input)) + + +class CySet(CythonCommand): + """ + Set a Cython variable to a certain value + + cy set my_cython_c_variable = 10 + cy set my_cython_py_variable = $cy_eval("{'doner': 'kebab'}") + + This is equivalent to + + set $cy_value("my_cython_variable") = 10 + """ + + name = 'cy set' + command_class = gdb.COMMAND_DATA + completer_class = gdb.COMPLETE_NONE + + @require_cython_frame + def invoke(self, expr, from_tty): + name_and_expr = expr.split('=', 1) + if len(name_and_expr) != 2: + raise gdb.GdbError("Invalid expression. Use 'cy set var = expr'.") + + varname, expr = name_and_expr + cname = self.cy.cy_cname.invoke(varname.strip()) + gdb.execute("set %s = %s" % (cname, expr)) + + +# Functions + +class CyCName(gdb.Function, CythonBase): + """ + Get the C name of a Cython variable in the current context. + Examples: + + print $cy_cname("function") + print $cy_cname("Class.method") + print $cy_cname("module.function") + """ + + @require_cython_frame + @gdb_function_value_to_unicode + def invoke(self, cyname, frame=None): + frame = frame or gdb.selected_frame() + cname = None + + if self.is_cython_function(frame): + cython_function = self.get_cython_function(frame) + if cyname in cython_function.locals: + cname = cython_function.locals[cyname].cname + elif cyname in cython_function.module.globals: + cname = cython_function.module.globals[cyname].cname + else: + qname = '%s.%s' % (cython_function.module.name, cyname) + if qname in cython_function.module.functions: + cname = cython_function.module.functions[qname].cname + + if not cname: + cname = self.cy.functions_by_qualified_name.get(cyname) + + if not cname: + raise gdb.GdbError('No such Cython variable: %s' % cyname) + + return cname + + +class CyCValue(CyCName): + """ + Get the value of a Cython variable. + """ + + @require_cython_frame + @gdb_function_value_to_unicode + def invoke(self, cyname, frame=None): + globals_dict = self.get_cython_globals_dict() + cython_function = self.get_cython_function(frame) + + if self.is_initialized(cython_function, cyname): + cname = super(CyCValue, self).invoke(cyname, frame=frame) + return gdb.parse_and_eval(cname) + elif cyname in globals_dict: + return globals_dict[cyname]._gdbval + else: + raise gdb.GdbError("Variable %s is not initialized." % cyname) + + +class CyLine(gdb.Function, CythonBase): + """ + Get the current Cython line. + """ + + @require_cython_frame + def invoke(self): + return self.get_cython_lineno() + + +class CyEval(gdb.Function, CythonBase, EvaluateOrExecuteCodeMixin): + """ + Evaluate Python code in the nearest Python or Cython frame and return + """ + + @gdb_function_value_to_unicode + def invoke(self, python_expression): + input_type = libpython.PythonCodeExecutor.Py_eval_input + return self.evalcode(python_expression, input_type) + + +cython_info = CythonInfo() +cy = CyCy.register() +cython_info.cy = cy + + +def register_defines(): + libpython.source_gdb_script(textwrap.dedent("""\ + define cy step + cy -step + end + + define cy next + cy -next + end + + document cy step + %s + end + + document cy next + %s + end + """) % (CyStep.__doc__, CyNext.__doc__)) + +register_defines() diff --git a/contrib/tools/cython/Cython/Debugger/libpython.py b/contrib/tools/cython/Cython/Debugger/libpython.py new file mode 100644 index 00000000000..fea626dd730 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugger/libpython.py @@ -0,0 +1,2760 @@ +#!/usr/bin/python + +# NOTE: this file is taken from the Python source distribution +# It can be found under Tools/gdb/libpython.py. It is shipped with Cython +# because it's not installed as a python module, and because changes are only +# merged into new python versions (v3.2+). + +''' +From gdb 7 onwards, gdb's build can be configured --with-python, allowing gdb +to be extended with Python code e.g. for library-specific data visualizations, +such as for the C++ STL types. Documentation on this API can be seen at: +http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html + + +This python module deals with the case when the process being debugged (the +"inferior process" in gdb parlance) is itself python, or more specifically, +linked against libpython. In this situation, almost every item of data is a +(PyObject*), and having the debugger merely print their addresses is not very +enlightening. + +This module embeds knowledge about the implementation details of libpython so +that we can emit useful visualizations e.g. a string, a list, a dict, a frame +giving file/line information and the state of local variables + +In particular, given a gdb.Value corresponding to a PyObject* in the inferior +process, we can generate a "proxy value" within the gdb process. For example, +given a PyObject* in the inferior process that is in fact a PyListObject* +holding three PyObject* that turn out to be PyBytesObject* instances, we can +generate a proxy value within the gdb process that is a list of bytes +instances: + [b"foo", b"bar", b"baz"] + +Doing so can be expensive for complicated graphs of objects, and could take +some time, so we also have a "write_repr" method that writes a representation +of the data to a file-like object. This allows us to stop the traversal by +having the file-like object raise an exception if it gets too much data. + +With both "proxyval" and "write_repr" we keep track of the set of all addresses +visited so far in the traversal, to avoid infinite recursion due to cycles in +the graph of object references. + +We try to defer gdb.lookup_type() invocations for python types until as late as +possible: for a dynamically linked python binary, when the process starts in +the debugger, the libpython.so hasn't been dynamically loaded yet, so none of +the type names are known to the debugger + +The module also extends gdb with some python-specific commands. +''' + +# NOTE: some gdbs are linked with Python 3, so this file should be dual-syntax +# compatible (2.6+ and 3.0+). See #19308. + +from __future__ import print_function +import gdb +import os +import locale +import sys + +if sys.version_info[0] >= 3: + unichr = chr + xrange = range + long = int + +# Look up the gdb.Type for some standard types: +# Those need to be refreshed as types (pointer sizes) may change when +# gdb loads different executables + +def _type_char_ptr(): + return gdb.lookup_type('char').pointer() # char* + + +def _type_unsigned_char_ptr(): + return gdb.lookup_type('unsigned char').pointer() # unsigned char* + + +def _type_unsigned_short_ptr(): + return gdb.lookup_type('unsigned short').pointer() + + +def _type_unsigned_int_ptr(): + return gdb.lookup_type('unsigned int').pointer() + + +def _sizeof_void_p(): + return gdb.lookup_type('void').pointer().sizeof + + +# value computed later, see PyUnicodeObjectPtr.proxy() +_is_pep393 = None + +Py_TPFLAGS_HEAPTYPE = (1 << 9) +Py_TPFLAGS_LONG_SUBCLASS = (1 << 24) +Py_TPFLAGS_LIST_SUBCLASS = (1 << 25) +Py_TPFLAGS_TUPLE_SUBCLASS = (1 << 26) +Py_TPFLAGS_BYTES_SUBCLASS = (1 << 27) +Py_TPFLAGS_UNICODE_SUBCLASS = (1 << 28) +Py_TPFLAGS_DICT_SUBCLASS = (1 << 29) +Py_TPFLAGS_BASE_EXC_SUBCLASS = (1 << 30) +Py_TPFLAGS_TYPE_SUBCLASS = (1 << 31) + + +MAX_OUTPUT_LEN=1024 + +hexdigits = "0123456789abcdef" + +ENCODING = locale.getpreferredencoding() + +EVALFRAME = '_PyEval_EvalFrameDefault' + +class NullPyObjectPtr(RuntimeError): + pass + + +def safety_limit(val): + # Given an integer value from the process being debugged, limit it to some + # safety threshold so that arbitrary breakage within said process doesn't + # break the gdb process too much (e.g. sizes of iterations, sizes of lists) + return min(val, 1000) + + +def safe_range(val): + # As per range, but don't trust the value too much: cap it to a safety + # threshold in case the data was corrupted + return xrange(safety_limit(int(val))) + +if sys.version_info[0] >= 3: + def write_unicode(file, text): + file.write(text) +else: + def write_unicode(file, text): + # Write a byte or unicode string to file. Unicode strings are encoded to + # ENCODING encoding with 'backslashreplace' error handler to avoid + # UnicodeEncodeError. + if isinstance(text, unicode): + text = text.encode(ENCODING, 'backslashreplace') + file.write(text) + +try: + os_fsencode = os.fsencode +except AttributeError: + def os_fsencode(filename): + if not isinstance(filename, unicode): + return filename + encoding = sys.getfilesystemencoding() + if encoding == 'mbcs': + # mbcs doesn't support surrogateescape + return filename.encode(encoding) + encoded = [] + for char in filename: + # surrogateescape error handler + if 0xDC80 <= ord(char) <= 0xDCFF: + byte = chr(ord(char) - 0xDC00) + else: + byte = char.encode(encoding) + encoded.append(byte) + return ''.join(encoded) + +class StringTruncated(RuntimeError): + pass + +class TruncatedStringIO(object): + '''Similar to io.StringIO, but can truncate the output by raising a + StringTruncated exception''' + def __init__(self, maxlen=None): + self._val = '' + self.maxlen = maxlen + + def write(self, data): + if self.maxlen: + if len(data) + len(self._val) > self.maxlen: + # Truncation: + self._val += data[0:self.maxlen - len(self._val)] + raise StringTruncated() + + self._val += data + + def getvalue(self): + return self._val + +class PyObjectPtr(object): + """ + Class wrapping a gdb.Value that's either a (PyObject*) within the + inferior process, or some subclass pointer e.g. (PyBytesObject*) + + There will be a subclass for every refined PyObject type that we care + about. + + Note that at every stage the underlying pointer could be NULL, point + to corrupt data, etc; this is the debugger, after all. + """ + _typename = 'PyObject' + + def __init__(self, gdbval, cast_to=None): + if cast_to: + self._gdbval = gdbval.cast(cast_to) + else: + self._gdbval = gdbval + + def field(self, name): + ''' + Get the gdb.Value for the given field within the PyObject, coping with + some python 2 versus python 3 differences. + + Various libpython types are defined using the "PyObject_HEAD" and + "PyObject_VAR_HEAD" macros. + + In Python 2, this these are defined so that "ob_type" and (for a var + object) "ob_size" are fields of the type in question. + + In Python 3, this is defined as an embedded PyVarObject type thus: + PyVarObject ob_base; + so that the "ob_size" field is located insize the "ob_base" field, and + the "ob_type" is most easily accessed by casting back to a (PyObject*). + ''' + if self.is_null(): + raise NullPyObjectPtr(self) + + if name == 'ob_type': + pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type()) + return pyo_ptr.dereference()[name] + + if name == 'ob_size': + pyo_ptr = self._gdbval.cast(PyVarObjectPtr.get_gdb_type()) + return pyo_ptr.dereference()[name] + + # General case: look it up inside the object: + return self._gdbval.dereference()[name] + + def pyop_field(self, name): + ''' + Get a PyObjectPtr for the given PyObject* field within this PyObject, + coping with some python 2 versus python 3 differences. + ''' + return PyObjectPtr.from_pyobject_ptr(self.field(name)) + + def write_field_repr(self, name, out, visited): + ''' + Extract the PyObject* field named "name", and write its representation + to file-like object "out" + ''' + field_obj = self.pyop_field(name) + field_obj.write_repr(out, visited) + + def get_truncated_repr(self, maxlen): + ''' + Get a repr-like string for the data, but truncate it at "maxlen" bytes + (ending the object graph traversal as soon as you do) + ''' + out = TruncatedStringIO(maxlen) + try: + self.write_repr(out, set()) + except StringTruncated: + # Truncation occurred: + return out.getvalue() + '...(truncated)' + + # No truncation occurred: + return out.getvalue() + + def type(self): + return PyTypeObjectPtr(self.field('ob_type')) + + def is_null(self): + return 0 == long(self._gdbval) + + def is_optimized_out(self): + ''' + Is the value of the underlying PyObject* visible to the debugger? + + This can vary with the precise version of the compiler used to build + Python, and the precise version of gdb. + + See e.g. https://bugzilla.redhat.com/show_bug.cgi?id=556975 with + PyEval_EvalFrameEx's "f" + ''' + return self._gdbval.is_optimized_out + + def safe_tp_name(self): + try: + return self.type().field('tp_name').string() + except NullPyObjectPtr: + # NULL tp_name? + return 'unknown' + except RuntimeError: + # Can't even read the object at all? + return 'unknown' + + def proxyval(self, visited): + ''' + Scrape a value from the inferior process, and try to represent it + within the gdb process, whilst (hopefully) avoiding crashes when + the remote data is corrupt. + + Derived classes will override this. + + For example, a PyIntObject* with ob_ival 42 in the inferior process + should result in an int(42) in this process. + + visited: a set of all gdb.Value pyobject pointers already visited + whilst generating this value (to guard against infinite recursion when + visiting object graphs with loops). Analogous to Py_ReprEnter and + Py_ReprLeave + ''' + + class FakeRepr(object): + """ + Class representing a non-descript PyObject* value in the inferior + process for when we don't have a custom scraper, intended to have + a sane repr(). + """ + + def __init__(self, tp_name, address): + self.tp_name = tp_name + self.address = address + + def __repr__(self): + # For the NULL pointer, we have no way of knowing a type, so + # special-case it as per + # http://bugs.python.org/issue8032#msg100882 + if self.address == 0: + return '0x0' + return '<%s at remote 0x%x>' % (self.tp_name, self.address) + + return FakeRepr(self.safe_tp_name(), + long(self._gdbval)) + + def write_repr(self, out, visited): + ''' + Write a string representation of the value scraped from the inferior + process to "out", a file-like object. + ''' + # Default implementation: generate a proxy value and write its repr + # However, this could involve a lot of work for complicated objects, + # so for derived classes we specialize this + return out.write(repr(self.proxyval(visited))) + + @classmethod + def subclass_from_type(cls, t): + ''' + Given a PyTypeObjectPtr instance wrapping a gdb.Value that's a + (PyTypeObject*), determine the corresponding subclass of PyObjectPtr + to use + + Ideally, we would look up the symbols for the global types, but that + isn't working yet: + (gdb) python print gdb.lookup_symbol('PyList_Type')[0].value + Traceback (most recent call last): + File "<string>", line 1, in <module> + NotImplementedError: Symbol type not yet supported in Python scripts. + Error while executing Python code. + + For now, we use tp_flags, after doing some string comparisons on the + tp_name for some special-cases that don't seem to be visible through + flags + ''' + try: + tp_name = t.field('tp_name').string() + tp_flags = int(t.field('tp_flags')) + except RuntimeError: + # Handle any kind of error e.g. NULL ptrs by simply using the base + # class + return cls + + #print('tp_flags = 0x%08x' % tp_flags) + #print('tp_name = %r' % tp_name) + + name_map = {'bool': PyBoolObjectPtr, + 'classobj': PyClassObjectPtr, + 'NoneType': PyNoneStructPtr, + 'frame': PyFrameObjectPtr, + 'set' : PySetObjectPtr, + 'frozenset' : PySetObjectPtr, + 'builtin_function_or_method' : PyCFunctionObjectPtr, + 'method-wrapper': wrapperobject, + } + if tp_name in name_map: + return name_map[tp_name] + + if tp_flags & Py_TPFLAGS_HEAPTYPE: + return HeapTypeObjectPtr + + if tp_flags & Py_TPFLAGS_LONG_SUBCLASS: + return PyLongObjectPtr + if tp_flags & Py_TPFLAGS_LIST_SUBCLASS: + return PyListObjectPtr + if tp_flags & Py_TPFLAGS_TUPLE_SUBCLASS: + return PyTupleObjectPtr + if tp_flags & Py_TPFLAGS_BYTES_SUBCLASS: + return PyBytesObjectPtr + if tp_flags & Py_TPFLAGS_UNICODE_SUBCLASS: + return PyUnicodeObjectPtr + if tp_flags & Py_TPFLAGS_DICT_SUBCLASS: + return PyDictObjectPtr + if tp_flags & Py_TPFLAGS_BASE_EXC_SUBCLASS: + return PyBaseExceptionObjectPtr + #if tp_flags & Py_TPFLAGS_TYPE_SUBCLASS: + # return PyTypeObjectPtr + + # Use the base class: + return cls + + @classmethod + def from_pyobject_ptr(cls, gdbval): + ''' + Try to locate the appropriate derived class dynamically, and cast + the pointer accordingly. + ''' + try: + p = PyObjectPtr(gdbval) + cls = cls.subclass_from_type(p.type()) + return cls(gdbval, cast_to=cls.get_gdb_type()) + except RuntimeError: + # Handle any kind of error e.g. NULL ptrs by simply using the base + # class + pass + return cls(gdbval) + + @classmethod + def get_gdb_type(cls): + return gdb.lookup_type(cls._typename).pointer() + + def as_address(self): + return long(self._gdbval) + +class PyVarObjectPtr(PyObjectPtr): + _typename = 'PyVarObject' + +class ProxyAlreadyVisited(object): + ''' + Placeholder proxy to use when protecting against infinite recursion due to + loops in the object graph. + + Analogous to the values emitted by the users of Py_ReprEnter and Py_ReprLeave + ''' + def __init__(self, rep): + self._rep = rep + + def __repr__(self): + return self._rep + + +def _write_instance_repr(out, visited, name, pyop_attrdict, address): + '''Shared code for use by all classes: + write a representation to file-like object "out"''' + out.write('<') + out.write(name) + + # Write dictionary of instance attributes: + if isinstance(pyop_attrdict, PyDictObjectPtr): + out.write('(') + first = True + for pyop_arg, pyop_val in pyop_attrdict.iteritems(): + if not first: + out.write(', ') + first = False + out.write(pyop_arg.proxyval(visited)) + out.write('=') + pyop_val.write_repr(out, visited) + out.write(')') + out.write(' at remote 0x%x>' % address) + + +class InstanceProxy(object): + + def __init__(self, cl_name, attrdict, address): + self.cl_name = cl_name + self.attrdict = attrdict + self.address = address + + def __repr__(self): + if isinstance(self.attrdict, dict): + kwargs = ', '.join(["%s=%r" % (arg, val) + for arg, val in self.attrdict.iteritems()]) + return '<%s(%s) at remote 0x%x>' % (self.cl_name, + kwargs, self.address) + else: + return '<%s at remote 0x%x>' % (self.cl_name, + self.address) + +def _PyObject_VAR_SIZE(typeobj, nitems): + if _PyObject_VAR_SIZE._type_size_t is None: + _PyObject_VAR_SIZE._type_size_t = gdb.lookup_type('size_t') + + return ( ( typeobj.field('tp_basicsize') + + nitems * typeobj.field('tp_itemsize') + + (_sizeof_void_p() - 1) + ) & ~(_sizeof_void_p() - 1) + ).cast(_PyObject_VAR_SIZE._type_size_t) +_PyObject_VAR_SIZE._type_size_t = None + +class HeapTypeObjectPtr(PyObjectPtr): + _typename = 'PyObject' + + def get_attr_dict(self): + ''' + Get the PyDictObject ptr representing the attribute dictionary + (or None if there's a problem) + ''' + try: + typeobj = self.type() + dictoffset = int_from_int(typeobj.field('tp_dictoffset')) + if dictoffset != 0: + if dictoffset < 0: + type_PyVarObject_ptr = gdb.lookup_type('PyVarObject').pointer() + tsize = int_from_int(self._gdbval.cast(type_PyVarObject_ptr)['ob_size']) + if tsize < 0: + tsize = -tsize + size = _PyObject_VAR_SIZE(typeobj, tsize) + dictoffset += size + assert dictoffset > 0 + assert dictoffset % _sizeof_void_p() == 0 + + dictptr = self._gdbval.cast(_type_char_ptr()) + dictoffset + PyObjectPtrPtr = PyObjectPtr.get_gdb_type().pointer() + dictptr = dictptr.cast(PyObjectPtrPtr) + return PyObjectPtr.from_pyobject_ptr(dictptr.dereference()) + except RuntimeError: + # Corrupt data somewhere; fail safe + pass + + # Not found, or some kind of error: + return None + + def proxyval(self, visited): + ''' + Support for classes. + + Currently we just locate the dictionary using a transliteration to + python of _PyObject_GetDictPtr, ignoring descriptors + ''' + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('<...>') + visited.add(self.as_address()) + + pyop_attr_dict = self.get_attr_dict() + if pyop_attr_dict: + attr_dict = pyop_attr_dict.proxyval(visited) + else: + attr_dict = {} + tp_name = self.safe_tp_name() + + # Class: + return InstanceProxy(tp_name, attr_dict, long(self._gdbval)) + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('<...>') + return + visited.add(self.as_address()) + + pyop_attrdict = self.get_attr_dict() + _write_instance_repr(out, visited, + self.safe_tp_name(), pyop_attrdict, self.as_address()) + +class ProxyException(Exception): + def __init__(self, tp_name, args): + self.tp_name = tp_name + self.args = args + + def __repr__(self): + return '%s%r' % (self.tp_name, self.args) + +class PyBaseExceptionObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyBaseExceptionObject* i.e. an exception + within the process being debugged. + """ + _typename = 'PyBaseExceptionObject' + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('(...)') + visited.add(self.as_address()) + arg_proxy = self.pyop_field('args').proxyval(visited) + return ProxyException(self.safe_tp_name(), + arg_proxy) + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('(...)') + return + visited.add(self.as_address()) + + out.write(self.safe_tp_name()) + self.write_field_repr('args', out, visited) + +class PyClassObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyClassObject* i.e. a <classobj> + instance within the process being debugged. + """ + _typename = 'PyClassObject' + + +class BuiltInFunctionProxy(object): + def __init__(self, ml_name): + self.ml_name = ml_name + + def __repr__(self): + return "<built-in function %s>" % self.ml_name + +class BuiltInMethodProxy(object): + def __init__(self, ml_name, pyop_m_self): + self.ml_name = ml_name + self.pyop_m_self = pyop_m_self + + def __repr__(self): + return ('<built-in method %s of %s object at remote 0x%x>' + % (self.ml_name, + self.pyop_m_self.safe_tp_name(), + self.pyop_m_self.as_address()) + ) + +class PyCFunctionObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyCFunctionObject* + (see Include/methodobject.h and Objects/methodobject.c) + """ + _typename = 'PyCFunctionObject' + + def proxyval(self, visited): + m_ml = self.field('m_ml') # m_ml is a (PyMethodDef*) + ml_name = m_ml['ml_name'].string() + + pyop_m_self = self.pyop_field('m_self') + if pyop_m_self.is_null(): + return BuiltInFunctionProxy(ml_name) + else: + return BuiltInMethodProxy(ml_name, pyop_m_self) + + +class PyCodeObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyCodeObject* i.e. a <code> instance + within the process being debugged. + """ + _typename = 'PyCodeObject' + + def addr2line(self, addrq): + ''' + Get the line number for a given bytecode offset + + Analogous to PyCode_Addr2Line; translated from pseudocode in + Objects/lnotab_notes.txt + ''' + co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) + + # Initialize lineno to co_firstlineno as per PyCode_Addr2Line + # not 0, as lnotab_notes.txt has it: + lineno = int_from_int(self.field('co_firstlineno')) + + addr = 0 + for addr_incr, line_incr in zip(co_lnotab[::2], co_lnotab[1::2]): + addr += ord(addr_incr) + if addr > addrq: + return lineno + lineno += ord(line_incr) + return lineno + + +class PyDictObjectPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyDictObject* i.e. a dict instance + within the process being debugged. + """ + _typename = 'PyDictObject' + + def iteritems(self): + ''' + Yields a sequence of (PyObjectPtr key, PyObjectPtr value) pairs, + analogous to dict.iteritems() + ''' + keys = self.field('ma_keys') + values = self.field('ma_values') + entries, nentries = self._get_entries(keys) + for i in safe_range(nentries): + ep = entries[i] + if long(values): + pyop_value = PyObjectPtr.from_pyobject_ptr(values[i]) + else: + pyop_value = PyObjectPtr.from_pyobject_ptr(ep['me_value']) + if not pyop_value.is_null(): + pyop_key = PyObjectPtr.from_pyobject_ptr(ep['me_key']) + yield (pyop_key, pyop_value) + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('{...}') + visited.add(self.as_address()) + + result = {} + for pyop_key, pyop_value in self.iteritems(): + proxy_key = pyop_key.proxyval(visited) + proxy_value = pyop_value.proxyval(visited) + result[proxy_key] = proxy_value + return result + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('{...}') + return + visited.add(self.as_address()) + + out.write('{') + first = True + for pyop_key, pyop_value in self.iteritems(): + if not first: + out.write(', ') + first = False + pyop_key.write_repr(out, visited) + out.write(': ') + pyop_value.write_repr(out, visited) + out.write('}') + + def _get_entries(self, keys): + dk_nentries = int(keys['dk_nentries']) + dk_size = int(keys['dk_size']) + try: + # <= Python 3.5 + return keys['dk_entries'], dk_size + except RuntimeError: + # >= Python 3.6 + pass + + if dk_size <= 0xFF: + offset = dk_size + elif dk_size <= 0xFFFF: + offset = 2 * dk_size + elif dk_size <= 0xFFFFFFFF: + offset = 4 * dk_size + else: + offset = 8 * dk_size + + ent_addr = keys['dk_indices']['as_1'].address + ent_addr = ent_addr.cast(_type_unsigned_char_ptr()) + offset + ent_ptr_t = gdb.lookup_type('PyDictKeyEntry').pointer() + ent_addr = ent_addr.cast(ent_ptr_t) + + return ent_addr, dk_nentries + + +class PyListObjectPtr(PyObjectPtr): + _typename = 'PyListObject' + + def __getitem__(self, i): + # Get the gdb.Value for the (PyObject*) with the given index: + field_ob_item = self.field('ob_item') + return field_ob_item[i] + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('[...]') + visited.add(self.as_address()) + + result = [PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited) + for i in safe_range(int_from_int(self.field('ob_size')))] + return result + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('[...]') + return + visited.add(self.as_address()) + + out.write('[') + for i in safe_range(int_from_int(self.field('ob_size'))): + if i > 0: + out.write(', ') + element = PyObjectPtr.from_pyobject_ptr(self[i]) + element.write_repr(out, visited) + out.write(']') + +class PyLongObjectPtr(PyObjectPtr): + _typename = 'PyLongObject' + + def proxyval(self, visited): + ''' + Python's Include/longobjrep.h has this declaration: + struct _longobject { + PyObject_VAR_HEAD + digit ob_digit[1]; + }; + + with this description: + The absolute value of a number is equal to + SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) + Negative numbers are represented with ob_size < 0; + zero is represented by ob_size == 0. + + where SHIFT can be either: + #define PyLong_SHIFT 30 + #define PyLong_SHIFT 15 + ''' + ob_size = long(self.field('ob_size')) + if ob_size == 0: + return 0 + + ob_digit = self.field('ob_digit') + + if gdb.lookup_type('digit').sizeof == 2: + SHIFT = 15 + else: + SHIFT = 30 + + digits = [long(ob_digit[i]) * 2**(SHIFT*i) + for i in safe_range(abs(ob_size))] + result = sum(digits) + if ob_size < 0: + result = -result + return result + + def write_repr(self, out, visited): + # Write this out as a Python 3 int literal, i.e. without the "L" suffix + proxy = self.proxyval(visited) + out.write("%s" % proxy) + + +class PyBoolObjectPtr(PyLongObjectPtr): + """ + Class wrapping a gdb.Value that's a PyBoolObject* i.e. one of the two + <bool> instances (Py_True/Py_False) within the process being debugged. + """ + def proxyval(self, visited): + if PyLongObjectPtr.proxyval(self, visited): + return True + else: + return False + +class PyNoneStructPtr(PyObjectPtr): + """ + Class wrapping a gdb.Value that's a PyObject* pointing to the + singleton (we hope) _Py_NoneStruct with ob_type PyNone_Type + """ + _typename = 'PyObject' + + def proxyval(self, visited): + return None + + +class PyFrameObjectPtr(PyObjectPtr): + _typename = 'PyFrameObject' + + def __init__(self, gdbval, cast_to=None): + PyObjectPtr.__init__(self, gdbval, cast_to) + + if not self.is_optimized_out(): + self.co = PyCodeObjectPtr.from_pyobject_ptr(self.field('f_code')) + self.co_name = self.co.pyop_field('co_name') + self.co_filename = self.co.pyop_field('co_filename') + + self.f_lineno = int_from_int(self.field('f_lineno')) + self.f_lasti = int_from_int(self.field('f_lasti')) + self.co_nlocals = int_from_int(self.co.field('co_nlocals')) + self.co_varnames = PyTupleObjectPtr.from_pyobject_ptr(self.co.field('co_varnames')) + + def iter_locals(self): + ''' + Yield a sequence of (name,value) pairs of PyObjectPtr instances, for + the local variables of this frame + ''' + if self.is_optimized_out(): + return + + f_localsplus = self.field('f_localsplus') + for i in safe_range(self.co_nlocals): + pyop_value = PyObjectPtr.from_pyobject_ptr(f_localsplus[i]) + if not pyop_value.is_null(): + pyop_name = PyObjectPtr.from_pyobject_ptr(self.co_varnames[i]) + yield (pyop_name, pyop_value) + + def iter_globals(self): + ''' + Yield a sequence of (name,value) pairs of PyObjectPtr instances, for + the global variables of this frame + ''' + if self.is_optimized_out(): + return () + + pyop_globals = self.pyop_field('f_globals') + return pyop_globals.iteritems() + + def iter_builtins(self): + ''' + Yield a sequence of (name,value) pairs of PyObjectPtr instances, for + the builtin variables + ''' + if self.is_optimized_out(): + return () + + pyop_builtins = self.pyop_field('f_builtins') + return pyop_builtins.iteritems() + + def get_var_by_name(self, name): + ''' + Look for the named local variable, returning a (PyObjectPtr, scope) pair + where scope is a string 'local', 'global', 'builtin' + + If not found, return (None, None) + ''' + for pyop_name, pyop_value in self.iter_locals(): + if name == pyop_name.proxyval(set()): + return pyop_value, 'local' + for pyop_name, pyop_value in self.iter_globals(): + if name == pyop_name.proxyval(set()): + return pyop_value, 'global' + for pyop_name, pyop_value in self.iter_builtins(): + if name == pyop_name.proxyval(set()): + return pyop_value, 'builtin' + return None, None + + def filename(self): + '''Get the path of the current Python source file, as a string''' + if self.is_optimized_out(): + return '(frame information optimized out)' + return self.co_filename.proxyval(set()) + + def current_line_num(self): + '''Get current line number as an integer (1-based) + + Translated from PyFrame_GetLineNumber and PyCode_Addr2Line + + See Objects/lnotab_notes.txt + ''' + if self.is_optimized_out(): + return None + f_trace = self.field('f_trace') + if long(f_trace) != 0: + # we have a non-NULL f_trace: + return self.f_lineno + else: + #try: + return self.co.addr2line(self.f_lasti) + #except ValueError: + # return self.f_lineno + + def current_line(self): + '''Get the text of the current source line as a string, with a trailing + newline character''' + if self.is_optimized_out(): + return '(frame information optimized out)' + filename = self.filename() + try: + f = open(os_fsencode(filename), 'r') + except IOError: + return None + with f: + all_lines = f.readlines() + # Convert from 1-based current_line_num to 0-based list offset: + return all_lines[self.current_line_num()-1] + + def write_repr(self, out, visited): + if self.is_optimized_out(): + out.write('(frame information optimized out)') + return + out.write('Frame 0x%x, for file %s, line %i, in %s (' + % (self.as_address(), + self.co_filename.proxyval(visited), + self.current_line_num(), + self.co_name.proxyval(visited))) + first = True + for pyop_name, pyop_value in self.iter_locals(): + if not first: + out.write(', ') + first = False + + out.write(pyop_name.proxyval(visited)) + out.write('=') + pyop_value.write_repr(out, visited) + + out.write(')') + + def print_traceback(self): + if self.is_optimized_out(): + sys.stdout.write(' (frame information optimized out)\n') + return + visited = set() + sys.stdout.write(' File "%s", line %i, in %s\n' + % (self.co_filename.proxyval(visited), + self.current_line_num(), + self.co_name.proxyval(visited))) + +class PySetObjectPtr(PyObjectPtr): + _typename = 'PySetObject' + + @classmethod + def _dummy_key(self): + return gdb.lookup_global_symbol('_PySet_Dummy').value() + + def __iter__(self): + dummy_ptr = self._dummy_key() + table = self.field('table') + for i in safe_range(self.field('mask') + 1): + setentry = table[i] + key = setentry['key'] + if key != 0 and key != dummy_ptr: + yield PyObjectPtr.from_pyobject_ptr(key) + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('%s(...)' % self.safe_tp_name()) + visited.add(self.as_address()) + + members = (key.proxyval(visited) for key in self) + if self.safe_tp_name() == 'frozenset': + return frozenset(members) + else: + return set(members) + + def write_repr(self, out, visited): + # Emulate Python 3's set_repr + tp_name = self.safe_tp_name() + + # Guard against infinite loops: + if self.as_address() in visited: + out.write('(...)') + return + visited.add(self.as_address()) + + # Python 3's set_repr special-cases the empty set: + if not self.field('used'): + out.write(tp_name) + out.write('()') + return + + # Python 3 uses {} for set literals: + if tp_name != 'set': + out.write(tp_name) + out.write('(') + + out.write('{') + first = True + for key in self: + if not first: + out.write(', ') + first = False + key.write_repr(out, visited) + out.write('}') + + if tp_name != 'set': + out.write(')') + + +class PyBytesObjectPtr(PyObjectPtr): + _typename = 'PyBytesObject' + + def __str__(self): + field_ob_size = self.field('ob_size') + field_ob_sval = self.field('ob_sval') + char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr()) + return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)]) + + def proxyval(self, visited): + return str(self) + + def write_repr(self, out, visited): + # Write this out as a Python 3 bytes literal, i.e. with a "b" prefix + + # Get a PyStringObject* within the Python 2 gdb process: + proxy = self.proxyval(visited) + + # Transliteration of Python 3's Objects/bytesobject.c:PyBytes_Repr + # to Python 2 code: + quote = "'" + if "'" in proxy and not '"' in proxy: + quote = '"' + out.write('b') + out.write(quote) + for byte in proxy: + if byte == quote or byte == '\\': + out.write('\\') + out.write(byte) + elif byte == '\t': + out.write('\\t') + elif byte == '\n': + out.write('\\n') + elif byte == '\r': + out.write('\\r') + elif byte < ' ' or ord(byte) >= 0x7f: + out.write('\\x') + out.write(hexdigits[(ord(byte) & 0xf0) >> 4]) + out.write(hexdigits[ord(byte) & 0xf]) + else: + out.write(byte) + out.write(quote) + + +class PyStringObjectPtr(PyBytesObjectPtr): + _typename = 'PyStringObject' + + +class PyTupleObjectPtr(PyObjectPtr): + _typename = 'PyTupleObject' + + def __getitem__(self, i): + # Get the gdb.Value for the (PyObject*) with the given index: + field_ob_item = self.field('ob_item') + return field_ob_item[i] + + def proxyval(self, visited): + # Guard against infinite loops: + if self.as_address() in visited: + return ProxyAlreadyVisited('(...)') + visited.add(self.as_address()) + + result = tuple(PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited) + for i in safe_range(int_from_int(self.field('ob_size')))) + return result + + def write_repr(self, out, visited): + # Guard against infinite loops: + if self.as_address() in visited: + out.write('(...)') + return + visited.add(self.as_address()) + + out.write('(') + for i in safe_range(int_from_int(self.field('ob_size'))): + if i > 0: + out.write(', ') + element = PyObjectPtr.from_pyobject_ptr(self[i]) + element.write_repr(out, visited) + if self.field('ob_size') == 1: + out.write(',)') + else: + out.write(')') + +class PyTypeObjectPtr(PyObjectPtr): + _typename = 'PyTypeObject' + + +def _unichr_is_printable(char): + # Logic adapted from Python 3's Tools/unicode/makeunicodedata.py + if char == u" ": + return True + import unicodedata + return unicodedata.category(char) not in ("C", "Z") + +if sys.maxunicode >= 0x10000: + _unichr = unichr +else: + # Needed for proper surrogate support if sizeof(Py_UNICODE) is 2 in gdb + def _unichr(x): + if x < 0x10000: + return unichr(x) + x -= 0x10000 + ch1 = 0xD800 | (x >> 10) + ch2 = 0xDC00 | (x & 0x3FF) + return unichr(ch1) + unichr(ch2) + + +class PyUnicodeObjectPtr(PyObjectPtr): + _typename = 'PyUnicodeObject' + + def char_width(self): + _type_Py_UNICODE = gdb.lookup_type('Py_UNICODE') + return _type_Py_UNICODE.sizeof + + def proxyval(self, visited): + global _is_pep393 + if _is_pep393 is None: + fields = gdb.lookup_type('PyUnicodeObject').target().fields() + _is_pep393 = 'data' in [f.name for f in fields] + if _is_pep393: + # Python 3.3 and newer + may_have_surrogates = False + compact = self.field('_base') + ascii = compact['_base'] + state = ascii['state'] + is_compact_ascii = (int(state['ascii']) and int(state['compact'])) + if not int(state['ready']): + # string is not ready + field_length = long(compact['wstr_length']) + may_have_surrogates = True + field_str = ascii['wstr'] + else: + field_length = long(ascii['length']) + if is_compact_ascii: + field_str = ascii.address + 1 + elif int(state['compact']): + field_str = compact.address + 1 + else: + field_str = self.field('data')['any'] + repr_kind = int(state['kind']) + if repr_kind == 1: + field_str = field_str.cast(_type_unsigned_char_ptr()) + elif repr_kind == 2: + field_str = field_str.cast(_type_unsigned_short_ptr()) + elif repr_kind == 4: + field_str = field_str.cast(_type_unsigned_int_ptr()) + else: + # Python 3.2 and earlier + field_length = long(self.field('length')) + field_str = self.field('str') + may_have_surrogates = self.char_width() == 2 + + # Gather a list of ints from the Py_UNICODE array; these are either + # UCS-1, UCS-2 or UCS-4 code points: + if not may_have_surrogates: + Py_UNICODEs = [int(field_str[i]) for i in safe_range(field_length)] + else: + # A more elaborate routine if sizeof(Py_UNICODE) is 2 in the + # inferior process: we must join surrogate pairs. + Py_UNICODEs = [] + i = 0 + limit = safety_limit(field_length) + while i < limit: + ucs = int(field_str[i]) + i += 1 + if ucs < 0xD800 or ucs >= 0xDC00 or i == field_length: + Py_UNICODEs.append(ucs) + continue + # This could be a surrogate pair. + ucs2 = int(field_str[i]) + if ucs2 < 0xDC00 or ucs2 > 0xDFFF: + continue + code = (ucs & 0x03FF) << 10 + code |= ucs2 & 0x03FF + code += 0x00010000 + Py_UNICODEs.append(code) + i += 1 + + # Convert the int code points to unicode characters, and generate a + # local unicode instance. + # This splits surrogate pairs if sizeof(Py_UNICODE) is 2 here (in gdb). + result = u''.join([ + (_unichr(ucs) if ucs <= 0x10ffff else '\ufffd') + for ucs in Py_UNICODEs]) + return result + + def write_repr(self, out, visited): + # Write this out as a Python 3 str literal, i.e. without a "u" prefix + + # Get a PyUnicodeObject* within the Python 2 gdb process: + proxy = self.proxyval(visited) + + # Transliteration of Python 3's Object/unicodeobject.c:unicode_repr + # to Python 2: + if "'" in proxy and '"' not in proxy: + quote = '"' + else: + quote = "'" + out.write(quote) + + i = 0 + while i < len(proxy): + ch = proxy[i] + i += 1 + + # Escape quotes and backslashes + if ch == quote or ch == '\\': + out.write('\\') + out.write(ch) + + # Map special whitespace to '\t', \n', '\r' + elif ch == '\t': + out.write('\\t') + elif ch == '\n': + out.write('\\n') + elif ch == '\r': + out.write('\\r') + + # Map non-printable US ASCII to '\xhh' */ + elif ch < ' ' or ch == 0x7F: + out.write('\\x') + out.write(hexdigits[(ord(ch) >> 4) & 0x000F]) + out.write(hexdigits[ord(ch) & 0x000F]) + + # Copy ASCII characters as-is + elif ord(ch) < 0x7F: + out.write(ch) + + # Non-ASCII characters + else: + ucs = ch + ch2 = None + if sys.maxunicode < 0x10000: + # If sizeof(Py_UNICODE) is 2 here (in gdb), join + # surrogate pairs before calling _unichr_is_printable. + if (i < len(proxy) + and 0xD800 <= ord(ch) < 0xDC00 \ + and 0xDC00 <= ord(proxy[i]) <= 0xDFFF): + ch2 = proxy[i] + ucs = ch + ch2 + i += 1 + + # Unfortuately, Python 2's unicode type doesn't seem + # to expose the "isprintable" method + printable = _unichr_is_printable(ucs) + if printable: + try: + ucs.encode(ENCODING) + except UnicodeEncodeError: + printable = False + + # Map Unicode whitespace and control characters + # (categories Z* and C* except ASCII space) + if not printable: + if ch2 is not None: + # Match Python 3's representation of non-printable + # wide characters. + code = (ord(ch) & 0x03FF) << 10 + code |= ord(ch2) & 0x03FF + code += 0x00010000 + else: + code = ord(ucs) + + # Map 8-bit characters to '\\xhh' + if code <= 0xff: + out.write('\\x') + out.write(hexdigits[(code >> 4) & 0x000F]) + out.write(hexdigits[code & 0x000F]) + # Map 21-bit characters to '\U00xxxxxx' + elif code >= 0x10000: + out.write('\\U') + out.write(hexdigits[(code >> 28) & 0x0000000F]) + out.write(hexdigits[(code >> 24) & 0x0000000F]) + out.write(hexdigits[(code >> 20) & 0x0000000F]) + out.write(hexdigits[(code >> 16) & 0x0000000F]) + out.write(hexdigits[(code >> 12) & 0x0000000F]) + out.write(hexdigits[(code >> 8) & 0x0000000F]) + out.write(hexdigits[(code >> 4) & 0x0000000F]) + out.write(hexdigits[code & 0x0000000F]) + # Map 16-bit characters to '\uxxxx' + else: + out.write('\\u') + out.write(hexdigits[(code >> 12) & 0x000F]) + out.write(hexdigits[(code >> 8) & 0x000F]) + out.write(hexdigits[(code >> 4) & 0x000F]) + out.write(hexdigits[code & 0x000F]) + else: + # Copy characters as-is + out.write(ch) + if ch2 is not None: + out.write(ch2) + + out.write(quote) + + +class wrapperobject(PyObjectPtr): + _typename = 'wrapperobject' + + def safe_name(self): + try: + name = self.field('descr')['d_base']['name'].string() + return repr(name) + except (NullPyObjectPtr, RuntimeError): + return '<unknown name>' + + def safe_tp_name(self): + try: + return self.field('self')['ob_type']['tp_name'].string() + except (NullPyObjectPtr, RuntimeError): + return '<unknown tp_name>' + + def safe_self_addresss(self): + try: + address = long(self.field('self')) + return '%#x' % address + except (NullPyObjectPtr, RuntimeError): + return '<failed to get self address>' + + def proxyval(self, visited): + name = self.safe_name() + tp_name = self.safe_tp_name() + self_address = self.safe_self_addresss() + return ("<method-wrapper %s of %s object at %s>" + % (name, tp_name, self_address)) + + def write_repr(self, out, visited): + proxy = self.proxyval(visited) + out.write(proxy) + + +def int_from_int(gdbval): + return int(str(gdbval)) + + +def stringify(val): + # TODO: repr() puts everything on one line; pformat can be nicer, but + # can lead to v.long results; this function isolates the choice + if True: + return repr(val) + else: + from pprint import pformat + return pformat(val) + + +class PyObjectPtrPrinter: + "Prints a (PyObject*)" + + def __init__ (self, gdbval): + self.gdbval = gdbval + + def to_string (self): + pyop = PyObjectPtr.from_pyobject_ptr(self.gdbval) + if True: + return pyop.get_truncated_repr(MAX_OUTPUT_LEN) + else: + # Generate full proxy value then stringify it. + # Doing so could be expensive + proxyval = pyop.proxyval(set()) + return stringify(proxyval) + +def pretty_printer_lookup(gdbval): + type = gdbval.type.unqualified() + if type.code != gdb.TYPE_CODE_PTR: + return None + + type = type.target().unqualified() + t = str(type) + if t in ("PyObject", "PyFrameObject", "PyUnicodeObject", "wrapperobject"): + return PyObjectPtrPrinter(gdbval) + +""" +During development, I've been manually invoking the code in this way: +(gdb) python + +import sys +sys.path.append('/home/david/coding/python-gdb') +import libpython +end + +then reloading it after each edit like this: +(gdb) python reload(libpython) + +The following code should ensure that the prettyprinter is registered +if the code is autoloaded by gdb when visiting libpython.so, provided +that this python file is installed to the same path as the library (or its +.debug file) plus a "-gdb.py" suffix, e.g: + /usr/lib/libpython2.6.so.1.0-gdb.py + /usr/lib/debug/usr/lib/libpython2.6.so.1.0.debug-gdb.py +""" +def register (obj): + if obj is None: + obj = gdb + + # Wire up the pretty-printer + obj.pretty_printers.append(pretty_printer_lookup) + +register (gdb.current_objfile ()) + + + +# Unfortunately, the exact API exposed by the gdb module varies somewhat +# from build to build +# See http://bugs.python.org/issue8279?#msg102276 + +class Frame(object): + ''' + Wrapper for gdb.Frame, adding various methods + ''' + def __init__(self, gdbframe): + self._gdbframe = gdbframe + + def older(self): + older = self._gdbframe.older() + if older: + return Frame(older) + else: + return None + + def newer(self): + newer = self._gdbframe.newer() + if newer: + return Frame(newer) + else: + return None + + def select(self): + '''If supported, select this frame and return True; return False if unsupported + + Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12 + onwards, but absent on Ubuntu buildbot''' + if not hasattr(self._gdbframe, 'select'): + print ('Unable to select frame: ' + 'this build of gdb does not expose a gdb.Frame.select method') + return False + self._gdbframe.select() + return True + + def get_index(self): + '''Calculate index of frame, starting at 0 for the newest frame within + this thread''' + index = 0 + # Go down until you reach the newest frame: + iter_frame = self + while iter_frame.newer(): + index += 1 + iter_frame = iter_frame.newer() + return index + + # We divide frames into: + # - "python frames": + # - "bytecode frames" i.e. PyEval_EvalFrameEx + # - "other python frames": things that are of interest from a python + # POV, but aren't bytecode (e.g. GC, GIL) + # - everything else + + def is_python_frame(self): + '''Is this a _PyEval_EvalFrameDefault frame, or some other important + frame? (see is_other_python_frame for what "important" means in this + context)''' + if self.is_evalframe(): + return True + if self.is_other_python_frame(): + return True + return False + + def is_evalframe(self): + '''Is this a _PyEval_EvalFrameDefault frame?''' + if self._gdbframe.name() == EVALFRAME: + ''' + I believe we also need to filter on the inline + struct frame_id.inline_depth, only regarding frames with + an inline depth of 0 as actually being this function + + So we reject those with type gdb.INLINE_FRAME + ''' + if self._gdbframe.type() == gdb.NORMAL_FRAME: + # We have a _PyEval_EvalFrameDefault frame: + return True + + return False + + def is_other_python_frame(self): + '''Is this frame worth displaying in python backtraces? + Examples: + - waiting on the GIL + - garbage-collecting + - within a CFunction + If it is, return a descriptive string + For other frames, return False + ''' + if self.is_waiting_for_gil(): + return 'Waiting for the GIL' + + if self.is_gc_collect(): + return 'Garbage-collecting' + + # Detect invocations of PyCFunction instances: + frame = self._gdbframe + caller = frame.name() + if not caller: + return False + + if caller in ('_PyCFunction_FastCallDict', + '_PyCFunction_FastCallKeywords'): + arg_name = 'func' + # Within that frame: + # "func" is the local containing the PyObject* of the + # PyCFunctionObject instance + # "f" is the same value, but cast to (PyCFunctionObject*) + # "self" is the (PyObject*) of the 'self' + try: + # Use the prettyprinter for the func: + func = frame.read_var(arg_name) + return str(func) + except RuntimeError: + return 'PyCFunction invocation (unable to read %s)' % arg_name + + if caller == 'wrapper_call': + try: + func = frame.read_var('wp') + return str(func) + except RuntimeError: + return '<wrapper_call invocation>' + + # This frame isn't worth reporting: + return False + + def is_waiting_for_gil(self): + '''Is this frame waiting on the GIL?''' + # This assumes the _POSIX_THREADS version of Python/ceval_gil.h: + name = self._gdbframe.name() + if name: + return 'pthread_cond_timedwait' in name + + def is_gc_collect(self): + '''Is this frame "collect" within the garbage-collector?''' + return self._gdbframe.name() == 'collect' + + def get_pyop(self): + try: + f = self._gdbframe.read_var('f') + frame = PyFrameObjectPtr.from_pyobject_ptr(f) + if not frame.is_optimized_out(): + return frame + # gdb is unable to get the "f" argument of PyEval_EvalFrameEx() + # because it was "optimized out". Try to get "f" from the frame + # of the caller, PyEval_EvalCodeEx(). + orig_frame = frame + caller = self._gdbframe.older() + if caller: + f = caller.read_var('f') + frame = PyFrameObjectPtr.from_pyobject_ptr(f) + if not frame.is_optimized_out(): + return frame + return orig_frame + except ValueError: + return None + + @classmethod + def get_selected_frame(cls): + _gdbframe = gdb.selected_frame() + if _gdbframe: + return Frame(_gdbframe) + return None + + @classmethod + def get_selected_python_frame(cls): + '''Try to obtain the Frame for the python-related code in the selected + frame, or None''' + try: + frame = cls.get_selected_frame() + except gdb.error: + # No frame: Python didn't start yet + return None + + while frame: + if frame.is_python_frame(): + return frame + frame = frame.older() + + # Not found: + return None + + @classmethod + def get_selected_bytecode_frame(cls): + '''Try to obtain the Frame for the python bytecode interpreter in the + selected GDB frame, or None''' + frame = cls.get_selected_frame() + + while frame: + if frame.is_evalframe(): + return frame + frame = frame.older() + + # Not found: + return None + + def print_summary(self): + if self.is_evalframe(): + pyop = self.get_pyop() + if pyop: + line = pyop.get_truncated_repr(MAX_OUTPUT_LEN) + write_unicode(sys.stdout, '#%i %s\n' % (self.get_index(), line)) + if not pyop.is_optimized_out(): + line = pyop.current_line() + if line is not None: + sys.stdout.write(' %s\n' % line.strip()) + else: + sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index()) + else: + info = self.is_other_python_frame() + if info: + sys.stdout.write('#%i %s\n' % (self.get_index(), info)) + else: + sys.stdout.write('#%i\n' % self.get_index()) + + def print_traceback(self): + if self.is_evalframe(): + pyop = self.get_pyop() + if pyop: + pyop.print_traceback() + if not pyop.is_optimized_out(): + line = pyop.current_line() + if line is not None: + sys.stdout.write(' %s\n' % line.strip()) + else: + sys.stdout.write(' (unable to read python frame information)\n') + else: + info = self.is_other_python_frame() + if info: + sys.stdout.write(' %s\n' % info) + else: + sys.stdout.write(' (not a python frame)\n') + +class PyList(gdb.Command): + '''List the current Python source code, if any + + Use + py-list START + to list at a different line number within the python source. + + Use + py-list START, END + to list a specific range of lines within the python source. + ''' + + def __init__(self): + gdb.Command.__init__ (self, + "py-list", + gdb.COMMAND_FILES, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + import re + + start = None + end = None + + m = re.match(r'\s*(\d+)\s*', args) + if m: + start = int(m.group(0)) + end = start + 10 + + m = re.match(r'\s*(\d+)\s*,\s*(\d+)\s*', args) + if m: + start, end = map(int, m.groups()) + + # py-list requires an actual PyEval_EvalFrameEx frame: + frame = Frame.get_selected_bytecode_frame() + if not frame: + print('Unable to locate gdb frame for python bytecode interpreter') + return + + pyop = frame.get_pyop() + if not pyop or pyop.is_optimized_out(): + print('Unable to read information on python frame') + return + + filename = pyop.filename() + lineno = pyop.current_line_num() + + if start is None: + start = lineno - 5 + end = lineno + 5 + + if start<1: + start = 1 + + try: + f = open(os_fsencode(filename), 'r') + except IOError as err: + sys.stdout.write('Unable to open %s: %s\n' + % (filename, err)) + return + with f: + all_lines = f.readlines() + # start and end are 1-based, all_lines is 0-based; + # so [start-1:end] as a python slice gives us [start, end] as a + # closed interval + for i, line in enumerate(all_lines[start-1:end]): + linestr = str(i+start) + # Highlight current line: + if i + start == lineno: + linestr = '>' + linestr + sys.stdout.write('%4s %s' % (linestr, line)) + + +# ...and register the command: +PyList() + +def move_in_stack(move_up): + '''Move up or down the stack (for the py-up/py-down command)''' + frame = Frame.get_selected_python_frame() + if not frame: + print('Unable to locate python frame') + return + + while frame: + if move_up: + iter_frame = frame.older() + else: + iter_frame = frame.newer() + + if not iter_frame: + break + + if iter_frame.is_python_frame(): + # Result: + if iter_frame.select(): + iter_frame.print_summary() + return + + frame = iter_frame + + if move_up: + print('Unable to find an older python frame') + else: + print('Unable to find a newer python frame') + +class PyUp(gdb.Command): + 'Select and print the python stack frame that called this one (if any)' + def __init__(self): + gdb.Command.__init__ (self, + "py-up", + gdb.COMMAND_STACK, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + move_in_stack(move_up=True) + +class PyDown(gdb.Command): + 'Select and print the python stack frame called by this one (if any)' + def __init__(self): + gdb.Command.__init__ (self, + "py-down", + gdb.COMMAND_STACK, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + move_in_stack(move_up=False) + +# Not all builds of gdb have gdb.Frame.select +if hasattr(gdb.Frame, 'select'): + PyUp() + PyDown() + +class PyBacktraceFull(gdb.Command): + 'Display the current python frame and all the frames within its call stack (if any)' + def __init__(self): + gdb.Command.__init__ (self, + "py-bt-full", + gdb.COMMAND_STACK, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + frame = Frame.get_selected_python_frame() + if not frame: + print('Unable to locate python frame') + return + + while frame: + if frame.is_python_frame(): + frame.print_summary() + frame = frame.older() + +PyBacktraceFull() + +class PyBacktrace(gdb.Command): + 'Display the current python frame and all the frames within its call stack (if any)' + def __init__(self): + gdb.Command.__init__ (self, + "py-bt", + gdb.COMMAND_STACK, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + frame = Frame.get_selected_python_frame() + if not frame: + print('Unable to locate python frame') + return + + sys.stdout.write('Traceback (most recent call first):\n') + while frame: + if frame.is_python_frame(): + frame.print_traceback() + frame = frame.older() + +PyBacktrace() + +class PyPrint(gdb.Command): + 'Look up the given python variable name, and print it' + def __init__(self): + gdb.Command.__init__ (self, + "py-print", + gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + name = str(args) + + frame = Frame.get_selected_python_frame() + if not frame: + print('Unable to locate python frame') + return + + pyop_frame = frame.get_pyop() + if not pyop_frame: + print('Unable to read information on python frame') + return + + pyop_var, scope = pyop_frame.get_var_by_name(name) + + if pyop_var: + print('%s %r = %s' + % (scope, + name, + pyop_var.get_truncated_repr(MAX_OUTPUT_LEN))) + else: + print('%r not found' % name) + +PyPrint() + +class PyLocals(gdb.Command): + 'Look up the given python variable name, and print it' + def __init__(self, command="py-locals"): + gdb.Command.__init__ (self, + command, + gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + + def invoke(self, args, from_tty): + name = str(args) + + frame = Frame.get_selected_python_frame() + if not frame: + print('Unable to locate python frame') + return + + pyop_frame = frame.get_pyop() + if not pyop_frame: + print('Unable to read information on python frame') + return + + namespace = self.get_namespace(pyop_frame) + namespace = [(name.proxyval(set()), val) for name, val in namespace] + + if namespace: + name, val = max(namespace, key=lambda item: len(item[0])) + max_name_length = len(name) + + for name, pyop_value in namespace: + value = pyop_value.get_truncated_repr(MAX_OUTPUT_LEN) + print('%-*s = %s' % (max_name_length, name, value)) + + def get_namespace(self, pyop_frame): + return pyop_frame.iter_locals() + +PyLocals() + + +################################################################## +## added, not in CPython +################################################################## + +import re +import warnings +import tempfile +import textwrap +import itertools + +class PyGlobals(PyLocals): + 'List all the globals in the currently select Python frame' + + def get_namespace(self, pyop_frame): + return pyop_frame.iter_globals() + + +PyGlobals("py-globals") + + +class PyNameEquals(gdb.Function): + + def _get_pycurframe_attr(self, attr): + frame = Frame(gdb.selected_frame()) + if frame.is_evalframeex(): + pyframe = frame.get_pyop() + if pyframe is None: + warnings.warn("Use a Python debug build, Python breakpoints " + "won't work otherwise.") + return None + + return getattr(pyframe, attr).proxyval(set()) + + return None + + def invoke(self, funcname): + attr = self._get_pycurframe_attr('co_name') + return attr is not None and attr == funcname.string() + +PyNameEquals("pyname_equals") + + +class PyModEquals(PyNameEquals): + + def invoke(self, modname): + attr = self._get_pycurframe_attr('co_filename') + if attr is not None: + filename, ext = os.path.splitext(os.path.basename(attr)) + return filename == modname.string() + return False + +PyModEquals("pymod_equals") + + +class PyBreak(gdb.Command): + """ + Set a Python breakpoint. Examples: + + Break on any function or method named 'func' in module 'modname' + + py-break modname.func + + Break on any function or method named 'func' + + py-break func + """ + + def invoke(self, funcname, from_tty): + if '.' in funcname: + modname, dot, funcname = funcname.rpartition('.') + cond = '$pyname_equals("%s") && $pymod_equals("%s")' % (funcname, + modname) + else: + cond = '$pyname_equals("%s")' % funcname + + gdb.execute('break PyEval_EvalFrameEx if ' + cond) + +PyBreak("py-break", gdb.COMMAND_RUNNING, gdb.COMPLETE_NONE) + + +class _LoggingState(object): + """ + State that helps to provide a reentrant gdb.execute() function. + """ + + def __init__(self): + f = tempfile.NamedTemporaryFile('r+') + self.file = f + self.filename = f.name + self.fd = f.fileno() + _execute("set logging file %s" % self.filename) + self.file_position_stack = [] + + def __enter__(self): + if not self.file_position_stack: + _execute("set logging redirect on") + _execute("set logging on") + _execute("set pagination off") + + self.file_position_stack.append(os.fstat(self.fd).st_size) + return self + + def getoutput(self): + gdb.flush() + self.file.seek(self.file_position_stack[-1]) + result = self.file.read() + return result + + def __exit__(self, exc_type, exc_val, tb): + startpos = self.file_position_stack.pop() + self.file.seek(startpos) + self.file.truncate() + if not self.file_position_stack: + _execute("set logging off") + _execute("set logging redirect off") + _execute("set pagination on") + + +def execute(command, from_tty=False, to_string=False): + """ + Replace gdb.execute() with this function and have it accept a 'to_string' + argument (new in 7.2). Have it properly capture stderr also. Ensure + reentrancy. + """ + if to_string: + with _logging_state as state: + _execute(command, from_tty) + return state.getoutput() + else: + _execute(command, from_tty) + + +_execute = gdb.execute +gdb.execute = execute +_logging_state = _LoggingState() + + +def get_selected_inferior(): + """ + Return the selected inferior in gdb. + """ + # Woooh, another bug in gdb! Is there an end in sight? + # http://sourceware.org/bugzilla/show_bug.cgi?id=12212 + return gdb.inferiors()[0] + + selected_thread = gdb.selected_thread() + + for inferior in gdb.inferiors(): + for thread in inferior.threads(): + if thread == selected_thread: + return inferior + + +def source_gdb_script(script_contents, to_string=False): + """ + Source a gdb script with script_contents passed as a string. This is useful + to provide defines for py-step and py-next to make them repeatable (this is + not possible with gdb.execute()). See + http://sourceware.org/bugzilla/show_bug.cgi?id=12216 + """ + fd, filename = tempfile.mkstemp() + f = os.fdopen(fd, 'w') + f.write(script_contents) + f.close() + gdb.execute("source %s" % filename, to_string=to_string) + os.remove(filename) + + +def register_defines(): + source_gdb_script(textwrap.dedent("""\ + define py-step + -py-step + end + + define py-next + -py-next + end + + document py-step + %s + end + + document py-next + %s + end + """) % (PyStep.__doc__, PyNext.__doc__)) + + +def stackdepth(frame): + "Tells the stackdepth of a gdb frame." + depth = 0 + while frame: + frame = frame.older() + depth += 1 + + return depth + + +class ExecutionControlCommandBase(gdb.Command): + """ + Superclass for language specific execution control. Language specific + features should be implemented by lang_info using the LanguageInfo + interface. 'name' is the name of the command. + """ + + def __init__(self, name, lang_info): + super(ExecutionControlCommandBase, self).__init__( + name, gdb.COMMAND_RUNNING, gdb.COMPLETE_NONE) + self.lang_info = lang_info + + def install_breakpoints(self): + all_locations = itertools.chain( + self.lang_info.static_break_functions(), + self.lang_info.runtime_break_functions()) + + for location in all_locations: + result = gdb.execute('break %s' % location, to_string=True) + yield re.search(r'Breakpoint (\d+)', result).group(1) + + def delete_breakpoints(self, breakpoint_list): + for bp in breakpoint_list: + gdb.execute("delete %s" % bp) + + def filter_output(self, result): + reflags = re.MULTILINE + + output_on_halt = [ + (r'^Program received signal .*', reflags|re.DOTALL), + (r'.*[Ww]arning.*', 0), + (r'^Program exited .*', reflags), + ] + + output_always = [ + # output when halting on a watchpoint + (r'^(Old|New) value = .*', reflags), + # output from the 'display' command + (r'^\d+: \w+ = .*', reflags), + ] + + def filter_output(regexes): + output = [] + for regex, flags in regexes: + for match in re.finditer(regex, result, flags): + output.append(match.group(0)) + + return '\n'.join(output) + + # Filter the return value output of the 'finish' command + match_finish = re.search(r'^Value returned is \$\d+ = (.*)', result, + re.MULTILINE) + if match_finish: + finish_output = 'Value returned: %s\n' % match_finish.group(1) + else: + finish_output = '' + + return (filter_output(output_on_halt), + finish_output + filter_output(output_always)) + + def stopped(self): + return get_selected_inferior().pid == 0 + + def finish_executing(self, result): + """ + After doing some kind of code running in the inferior, print the line + of source code or the result of the last executed gdb command (passed + in as the `result` argument). + """ + output_on_halt, output_always = self.filter_output(result) + + if self.stopped(): + print(output_always) + print(output_on_halt) + else: + frame = gdb.selected_frame() + source_line = self.lang_info.get_source_line(frame) + if self.lang_info.is_relevant_function(frame): + raised_exception = self.lang_info.exc_info(frame) + if raised_exception: + print(raised_exception) + + if source_line: + if output_always.rstrip(): + print(output_always.rstrip()) + print(source_line) + else: + print(result) + + def _finish(self): + """ + Execute until the function returns (or until something else makes it + stop) + """ + if gdb.selected_frame().older() is not None: + return gdb.execute('finish', to_string=True) + else: + # outermost frame, continue + return gdb.execute('cont', to_string=True) + + def _finish_frame(self): + """ + Execute until the function returns to a relevant caller. + """ + while True: + result = self._finish() + + try: + frame = gdb.selected_frame() + except RuntimeError: + break + + hitbp = re.search(r'Breakpoint (\d+)', result) + is_relevant = self.lang_info.is_relevant_function(frame) + if hitbp or is_relevant or self.stopped(): + break + + return result + + def finish(self, *args): + "Implements the finish command." + result = self._finish_frame() + self.finish_executing(result) + + def step(self, stepinto, stepover_command='next'): + """ + Do a single step or step-over. Returns the result of the last gdb + command that made execution stop. + + This implementation, for stepping, sets (conditional) breakpoints for + all functions that are deemed relevant. It then does a step over until + either something halts execution, or until the next line is reached. + + If, however, stepover_command is given, it should be a string gdb + command that continues execution in some way. The idea is that the + caller has set a (conditional) breakpoint or watchpoint that can work + more efficiently than the step-over loop. For Python this means setting + a watchpoint for f->f_lasti, which means we can then subsequently + "finish" frames. + We want f->f_lasti instead of f->f_lineno, because the latter only + works properly with local trace functions, see + PyFrameObjectPtr.current_line_num and PyFrameObjectPtr.addr2line. + """ + if stepinto: + breakpoint_list = list(self.install_breakpoints()) + + beginframe = gdb.selected_frame() + + if self.lang_info.is_relevant_function(beginframe): + # If we start in a relevant frame, initialize stuff properly. If + # we don't start in a relevant frame, the loop will halt + # immediately. So don't call self.lang_info.lineno() as it may + # raise for irrelevant frames. + beginline = self.lang_info.lineno(beginframe) + + if not stepinto: + depth = stackdepth(beginframe) + + newframe = beginframe + + while True: + if self.lang_info.is_relevant_function(newframe): + result = gdb.execute(stepover_command, to_string=True) + else: + result = self._finish_frame() + + if self.stopped(): + break + + newframe = gdb.selected_frame() + is_relevant_function = self.lang_info.is_relevant_function(newframe) + try: + framename = newframe.name() + except RuntimeError: + framename = None + + m = re.search(r'Breakpoint (\d+)', result) + if m: + if is_relevant_function and m.group(1) in breakpoint_list: + # although we hit a breakpoint, we still need to check + # that the function, in case hit by a runtime breakpoint, + # is in the right context + break + + if newframe != beginframe: + # new function + + if not stepinto: + # see if we returned to the caller + newdepth = stackdepth(newframe) + is_relevant_function = (newdepth < depth and + is_relevant_function) + + if is_relevant_function: + break + else: + # newframe equals beginframe, check for a difference in the + # line number + lineno = self.lang_info.lineno(newframe) + if lineno and lineno != beginline: + break + + if stepinto: + self.delete_breakpoints(breakpoint_list) + + self.finish_executing(result) + + def run(self, args, from_tty): + self.finish_executing(gdb.execute('run ' + args, to_string=True)) + + def cont(self, *args): + self.finish_executing(gdb.execute('cont', to_string=True)) + + +class LanguageInfo(object): + """ + This class defines the interface that ExecutionControlCommandBase needs to + provide language-specific execution control. + + Classes that implement this interface should implement: + + lineno(frame) + Tells the current line number (only called for a relevant frame). + If lineno is a false value it is not checked for a difference. + + is_relevant_function(frame) + tells whether we care about frame 'frame' + + get_source_line(frame) + get the line of source code for the current line (only called for a + relevant frame). If the source code cannot be retrieved this + function should return None + + exc_info(frame) -- optional + tells whether an exception was raised, if so, it should return a + string representation of the exception value, None otherwise. + + static_break_functions() + returns an iterable of function names that are considered relevant + and should halt step-into execution. This is needed to provide a + performing step-into + + runtime_break_functions() -- optional + list of functions that we should break into depending on the + context + """ + + def exc_info(self, frame): + "See this class' docstring." + + def runtime_break_functions(self): + """ + Implement this if the list of step-into functions depends on the + context. + """ + return () + + +class PythonInfo(LanguageInfo): + + def pyframe(self, frame): + pyframe = Frame(frame).get_pyop() + if pyframe: + return pyframe + else: + raise gdb.RuntimeError( + "Unable to find the Python frame, run your code with a debug " + "build (configure with --with-pydebug or compile with -g).") + + def lineno(self, frame): + return self.pyframe(frame).current_line_num() + + def is_relevant_function(self, frame): + return Frame(frame).is_evalframeex() + + def get_source_line(self, frame): + try: + pyframe = self.pyframe(frame) + return '%4d %s' % (pyframe.current_line_num(), + pyframe.current_line().rstrip()) + except IOError: + return None + + def exc_info(self, frame): + try: + tstate = frame.read_var('tstate').dereference() + if gdb.parse_and_eval('tstate->frame == f'): + # tstate local variable initialized, check for an exception + inf_type = tstate['curexc_type'] + inf_value = tstate['curexc_value'] + + if inf_type: + return 'An exception was raised: %s' % (inf_value,) + except (ValueError, RuntimeError): + # Could not read the variable tstate or it's memory, it's ok + pass + + def static_break_functions(self): + yield 'PyEval_EvalFrameEx' + + +class PythonStepperMixin(object): + """ + Make this a mixin so CyStep can also inherit from this and use a + CythonCodeStepper at the same time. + """ + + def python_step(self, stepinto): + """ + Set a watchpoint on the Python bytecode instruction pointer and try + to finish the frame + """ + output = gdb.execute('watch f->f_lasti', to_string=True) + watchpoint = int(re.search(r'[Ww]atchpoint (\d+):', output).group(1)) + self.step(stepinto=stepinto, stepover_command='finish') + gdb.execute('delete %s' % watchpoint) + + +class PyStep(ExecutionControlCommandBase, PythonStepperMixin): + "Step through Python code." + + stepinto = True + + def invoke(self, args, from_tty): + self.python_step(stepinto=self.stepinto) + + +class PyNext(PyStep): + "Step-over Python code." + + stepinto = False + + +class PyFinish(ExecutionControlCommandBase): + "Execute until function returns to a caller." + + invoke = ExecutionControlCommandBase.finish + + +class PyRun(ExecutionControlCommandBase): + "Run the program." + + invoke = ExecutionControlCommandBase.run + + +class PyCont(ExecutionControlCommandBase): + + invoke = ExecutionControlCommandBase.cont + + +def _pointervalue(gdbval): + """ + Return the value of the pointer as a Python int. + + gdbval.type must be a pointer type + """ + # don't convert with int() as it will raise a RuntimeError + if gdbval.address is not None: + return int(gdbval.address) + else: + # the address attribute is None sometimes, in which case we can + # still convert the pointer to an int + return int(gdbval) + + +def pointervalue(gdbval): + pointer = _pointervalue(gdbval) + try: + if pointer < 0: + raise gdb.GdbError("Negative pointer value, presumably a bug " + "in gdb, aborting.") + except RuntimeError: + # work around yet another bug in gdb where you get random behaviour + # and tracebacks + pass + + return pointer + + +def get_inferior_unicode_postfix(): + try: + gdb.parse_and_eval('PyUnicode_FromEncodedObject') + except RuntimeError: + try: + gdb.parse_and_eval('PyUnicodeUCS2_FromEncodedObject') + except RuntimeError: + return 'UCS4' + else: + return 'UCS2' + else: + return '' + + +class PythonCodeExecutor(object): + + Py_single_input = 256 + Py_file_input = 257 + Py_eval_input = 258 + + def malloc(self, size): + chunk = (gdb.parse_and_eval("(void *) malloc((size_t) %d)" % size)) + + pointer = pointervalue(chunk) + if pointer == 0: + raise gdb.GdbError("No memory could be allocated in the inferior.") + + return pointer + + def alloc_string(self, string): + pointer = self.malloc(len(string)) + get_selected_inferior().write_memory(pointer, string) + + return pointer + + def alloc_pystring(self, string): + stringp = self.alloc_string(string) + PyString_FromStringAndSize = 'PyString_FromStringAndSize' + + try: + gdb.parse_and_eval(PyString_FromStringAndSize) + except RuntimeError: + # Python 3 + PyString_FromStringAndSize = ('PyUnicode%s_FromStringAndSize' % + (get_inferior_unicode_postfix(),)) + + try: + result = gdb.parse_and_eval( + '(PyObject *) %s((char *) %d, (size_t) %d)' % ( + PyString_FromStringAndSize, stringp, len(string))) + finally: + self.free(stringp) + + pointer = pointervalue(result) + if pointer == 0: + raise gdb.GdbError("Unable to allocate Python string in " + "the inferior.") + + return pointer + + def free(self, pointer): + gdb.parse_and_eval("free((void *) %d)" % pointer) + + def incref(self, pointer): + "Increment the reference count of a Python object in the inferior." + gdb.parse_and_eval('Py_IncRef((PyObject *) %d)' % pointer) + + def xdecref(self, pointer): + "Decrement the reference count of a Python object in the inferior." + # Py_DecRef is like Py_XDECREF, but a function. So we don't have + # to check for NULL. This should also decref all our allocated + # Python strings. + gdb.parse_and_eval('Py_DecRef((PyObject *) %d)' % pointer) + + def evalcode(self, code, input_type, global_dict=None, local_dict=None): + """ + Evaluate python code `code` given as a string in the inferior and + return the result as a gdb.Value. Returns a new reference in the + inferior. + + Of course, executing any code in the inferior may be dangerous and may + leave the debuggee in an unsafe state or terminate it altogether. + """ + if '\0' in code: + raise gdb.GdbError("String contains NUL byte.") + + code += '\0' + + pointer = self.alloc_string(code) + + globalsp = pointervalue(global_dict) + localsp = pointervalue(local_dict) + + if globalsp == 0 or localsp == 0: + raise gdb.GdbError("Unable to obtain or create locals or globals.") + + code = """ + PyRun_String( + (char *) %(code)d, + (int) %(start)d, + (PyObject *) %(globals)s, + (PyObject *) %(locals)d) + """ % dict(code=pointer, start=input_type, + globals=globalsp, locals=localsp) + + with FetchAndRestoreError(): + try: + pyobject_return_value = gdb.parse_and_eval(code) + finally: + self.free(pointer) + + return pyobject_return_value + + +class FetchAndRestoreError(PythonCodeExecutor): + """ + Context manager that fetches the error indicator in the inferior and + restores it on exit. + """ + + def __init__(self): + self.sizeof_PyObjectPtr = gdb.lookup_type('PyObject').pointer().sizeof + self.pointer = self.malloc(self.sizeof_PyObjectPtr * 3) + + type = self.pointer + value = self.pointer + self.sizeof_PyObjectPtr + traceback = self.pointer + self.sizeof_PyObjectPtr * 2 + + self.errstate = type, value, traceback + + def __enter__(self): + gdb.parse_and_eval("PyErr_Fetch(%d, %d, %d)" % self.errstate) + + def __exit__(self, *args): + if gdb.parse_and_eval("(int) PyErr_Occurred()"): + gdb.parse_and_eval("PyErr_Print()") + + pyerr_restore = ("PyErr_Restore(" + "(PyObject *) *%d," + "(PyObject *) *%d," + "(PyObject *) *%d)") + + try: + gdb.parse_and_eval(pyerr_restore % self.errstate) + finally: + self.free(self.pointer) + + +class FixGdbCommand(gdb.Command): + + def __init__(self, command, actual_command): + super(FixGdbCommand, self).__init__(command, gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + self.actual_command = actual_command + + def fix_gdb(self): + """ + It seems that invoking either 'cy exec' and 'py-exec' work perfectly + fine, but after this gdb's python API is entirely broken. + Maybe some uncleared exception value is still set? + sys.exc_clear() didn't help. A demonstration: + + (gdb) cy exec 'hello' + 'hello' + (gdb) python gdb.execute('cont') + RuntimeError: Cannot convert value to int. + Error while executing Python code. + (gdb) python gdb.execute('cont') + [15148 refs] + + Program exited normally. + """ + warnings.filterwarnings('ignore', r'.*', RuntimeWarning, + re.escape(__name__)) + try: + int(gdb.parse_and_eval("(void *) 0")) == 0 + except RuntimeError: + pass + # warnings.resetwarnings() + + def invoke(self, args, from_tty): + self.fix_gdb() + try: + gdb.execute('%s %s' % (self.actual_command, args)) + except RuntimeError as e: + raise gdb.GdbError(str(e)) + self.fix_gdb() + + +def _evalcode_python(executor, code, input_type): + """ + Execute Python code in the most recent stack frame. + """ + global_dict = gdb.parse_and_eval('PyEval_GetGlobals()') + local_dict = gdb.parse_and_eval('PyEval_GetLocals()') + + if (pointervalue(global_dict) == 0 or pointervalue(local_dict) == 0): + raise gdb.GdbError("Unable to find the locals or globals of the " + "most recent Python function (relative to the " + "selected frame).") + + return executor.evalcode(code, input_type, global_dict, local_dict) + + +class PyExec(gdb.Command): + + def readcode(self, expr): + if expr: + return expr, PythonCodeExecutor.Py_single_input + else: + lines = [] + while True: + try: + line = input('>') + except EOFError: + break + else: + if line.rstrip() == 'end': + break + + lines.append(line) + + return '\n'.join(lines), PythonCodeExecutor.Py_file_input + + def invoke(self, expr, from_tty): + expr, input_type = self.readcode(expr) + executor = PythonCodeExecutor() + executor.xdecref(_evalcode_python(executor, input_type, global_dict, local_dict)) + + +gdb.execute('set breakpoint pending on') + +if hasattr(gdb, 'GdbError'): + # Wrap py-step and py-next in gdb defines to make them repeatable. + py_step = PyStep('-py-step', PythonInfo()) + py_next = PyNext('-py-next', PythonInfo()) + register_defines() + py_finish = PyFinish('py-finish', PythonInfo()) + py_run = PyRun('py-run', PythonInfo()) + py_cont = PyCont('py-cont', PythonInfo()) + + py_exec = FixGdbCommand('py-exec', '-py-exec') + _py_exec = PyExec("-py-exec", gdb.COMMAND_DATA, gdb.COMPLETE_NONE) +else: + warnings.warn("Use gdb 7.2 or higher to use the py-exec command.") diff --git a/contrib/tools/cython/Cython/Debugging.py b/contrib/tools/cython/Cython/Debugging.py new file mode 100644 index 00000000000..edb3f4e8ca5 --- /dev/null +++ b/contrib/tools/cython/Cython/Debugging.py @@ -0,0 +1,20 @@ +############################################### +# +# Odds and ends for debugging +# +############################################### + +def print_call_chain(*args): + import sys + print(" ".join(map(str, args))) + f = sys._getframe(1) + while f: + name = f.f_code.co_name + s = f.f_locals.get('self', None) + if s: + c = getattr(s, "__class__", None) + if c: + name = "%s.%s" % (c.__name__, name) + print("Called from: %s %s" % (name, f.f_lineno)) + f = f.f_back + print("-" * 70) diff --git a/contrib/tools/cython/Cython/Distutils/__init__.py b/contrib/tools/cython/Cython/Distutils/__init__.py new file mode 100644 index 00000000000..4a24001f15f --- /dev/null +++ b/contrib/tools/cython/Cython/Distutils/__init__.py @@ -0,0 +1,2 @@ +from Cython.Distutils.build_ext import build_ext +from Cython.Distutils.extension import Extension diff --git a/contrib/tools/cython/Cython/Distutils/build_ext.py b/contrib/tools/cython/Cython/Distutils/build_ext.py new file mode 100644 index 00000000000..598bb4a89b1 --- /dev/null +++ b/contrib/tools/cython/Cython/Distutils/build_ext.py @@ -0,0 +1,25 @@ +import sys + +if 'setuptools' in sys.modules: + try: + from setuptools.command.build_ext import build_ext as _build_ext + except ImportError: + # We may be in the process of importing setuptools, which tries + # to import this. + from distutils.command.build_ext import build_ext as _build_ext +else: + from distutils.command.build_ext import build_ext as _build_ext + + +class new_build_ext(_build_ext, object): + def finalize_options(self): + if self.distribution.ext_modules: + nthreads = getattr(self, 'parallel', None) # -j option in Py3.5+ + nthreads = int(nthreads) if nthreads else None + from Cython.Build.Dependencies import cythonize + self.distribution.ext_modules[:] = cythonize( + self.distribution.ext_modules, nthreads=nthreads, force=self.force) + super(new_build_ext, self).finalize_options() + +# This will become new_build_ext in the future. +from .old_build_ext import old_build_ext as build_ext diff --git a/contrib/tools/cython/Cython/Distutils/extension.py b/contrib/tools/cython/Cython/Distutils/extension.py new file mode 100644 index 00000000000..d8bdbf0f5bc --- /dev/null +++ b/contrib/tools/cython/Cython/Distutils/extension.py @@ -0,0 +1,128 @@ +"""Pyrex.Distutils.extension + +Provides a modified Extension class, that understands how to describe +Pyrex extension modules in setup scripts.""" + +__revision__ = "$Id:$" + +import sys +import distutils.extension as _Extension + +try: + import warnings +except ImportError: + warnings = None + + +class Extension(_Extension.Extension): + # When adding arguments to this constructor, be sure to update + # user_options.extend in build_ext.py. + def __init__(self, name, sources, + include_dirs=None, + define_macros=None, + undef_macros=None, + library_dirs=None, + libraries=None, + runtime_library_dirs=None, + extra_objects=None, + extra_compile_args=None, + extra_link_args=None, + export_symbols=None, + #swig_opts=None, + depends=None, + language=None, + cython_include_dirs=None, + cython_directives=None, + cython_create_listing=False, + cython_line_directives=False, + cython_cplus=False, + cython_c_in_temp=False, + cython_gen_pxi=False, + cython_gdb=False, + no_c_in_traceback=False, + cython_compile_time_env=None, + **kw): + + # Translate pyrex_X to cython_X for backwards compatibility. + had_pyrex_options = False + for key in list(kw): + if key.startswith('pyrex_'): + had_pyrex_options = True + kw['cython' + key[5:]] = kw.pop(key) + if had_pyrex_options: + Extension.__init__( + self, name, sources, + include_dirs=include_dirs, + define_macros=define_macros, + undef_macros=undef_macros, + library_dirs=library_dirs, + libraries=libraries, + runtime_library_dirs=runtime_library_dirs, + extra_objects=extra_objects, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + export_symbols=export_symbols, + #swig_opts=swig_opts, + depends=depends, + language=language, + no_c_in_traceback=no_c_in_traceback, + **kw) + return + + _Extension.Extension.__init__( + self, name, sources, + include_dirs=include_dirs, + define_macros=define_macros, + undef_macros=undef_macros, + library_dirs=library_dirs, + libraries=libraries, + runtime_library_dirs=runtime_library_dirs, + extra_objects=extra_objects, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + export_symbols=export_symbols, + #swig_opts=swig_opts, + depends=depends, + language=language, + **kw) + + self.cython_include_dirs = cython_include_dirs or [] + self.cython_directives = cython_directives or {} + self.cython_create_listing = cython_create_listing + self.cython_line_directives = cython_line_directives + self.cython_cplus = cython_cplus + self.cython_c_in_temp = cython_c_in_temp + self.cython_gen_pxi = cython_gen_pxi + self.cython_gdb = cython_gdb + self.no_c_in_traceback = no_c_in_traceback + self.cython_compile_time_env = cython_compile_time_env + +# class Extension + +read_setup_file = _Extension.read_setup_file + + +# reuse and extend original docstring from base class (if we can) +if sys.version_info[0] < 3 and _Extension.Extension.__doc__: + # -OO discards docstrings + Extension.__doc__ = _Extension.Extension.__doc__ + """\ + cython_include_dirs : [string] + list of directories to search for Pyrex header files (.pxd) (in + Unix form for portability) + cython_directives : {string:value} + dict of compiler directives + cython_create_listing_file : boolean + write pyrex error messages to a listing (.lis) file. + cython_line_directives : boolean + emit pyx line numbers for debugging/profiling + cython_cplus : boolean + use the C++ compiler for compiling and linking. + cython_c_in_temp : boolean + put generated C files in temp directory. + cython_gen_pxi : boolean + generate .pxi file for public declarations + cython_gdb : boolean + generate Cython debug information for this extension for cygdb + no_c_in_traceback : boolean + emit the c file and line number from the traceback for exceptions +""" diff --git a/contrib/tools/cython/Cython/Distutils/old_build_ext.py b/contrib/tools/cython/Cython/Distutils/old_build_ext.py new file mode 100644 index 00000000000..aa2a1cf2292 --- /dev/null +++ b/contrib/tools/cython/Cython/Distutils/old_build_ext.py @@ -0,0 +1,355 @@ +"""Cython.Distutils.old_build_ext + +Implements a version of the Distutils 'build_ext' command, for +building Cython extension modules. + +Note that this module is deprecated. Use cythonize() instead. +""" + +__revision__ = "$Id:$" + +import inspect +import sys +import os +from distutils.errors import DistutilsPlatformError +from distutils.dep_util import newer, newer_group +from distutils import log +from distutils.command import build_ext as _build_ext +from distutils import sysconfig +import warnings + + +try: + from __builtin__ import basestring +except ImportError: + basestring = str + + +def _check_stack(path): + try: + for frame in inspect.getouterframes(inspect.currentframe(), 0): + if path in frame[1].replace(os.sep, '/'): + return True + except Exception: + pass + return False + +if (not _check_stack('setuptools/extensions.py') + and not _check_stack('pyximport/pyxbuild.py') + and not _check_stack('Cython/Distutils/build_ext.py')): + warnings.warn( + "Cython.Distutils.old_build_ext does not properly handle dependencies " + "and is deprecated.") + + +extension_name_re = _build_ext.extension_name_re + +show_compilers = _build_ext.show_compilers + +class Optimization(object): + def __init__(self): + self.flags = ( + 'OPT', + 'CFLAGS', + 'CPPFLAGS', + 'EXTRA_CFLAGS', + 'BASECFLAGS', + 'PY_CFLAGS', + ) + self.state = sysconfig.get_config_vars(*self.flags) + self.config_vars = sysconfig.get_config_vars() + + + def disable_optimization(self): + "disable optimization for the C or C++ compiler" + badoptions = ('-O1', '-O2', '-O3') + + for flag, option in zip(self.flags, self.state): + if option is not None: + L = [opt for opt in option.split() if opt not in badoptions] + self.config_vars[flag] = ' '.join(L) + + def restore_state(self): + "restore the original state" + for flag, option in zip(self.flags, self.state): + if option is not None: + self.config_vars[flag] = option + + +optimization = Optimization() + + +class old_build_ext(_build_ext.build_ext): + + description = "build C/C++ and Cython extensions (compile/link to build directory)" + + sep_by = _build_ext.build_ext.sep_by + user_options = _build_ext.build_ext.user_options[:] + boolean_options = _build_ext.build_ext.boolean_options[:] + help_options = _build_ext.build_ext.help_options[:] + + # Add the pyrex specific data. + user_options.extend([ + ('cython-cplus', None, + "generate C++ source files"), + ('cython-create-listing', None, + "write errors to a listing file"), + ('cython-line-directives', None, + "emit source line directives"), + ('cython-include-dirs=', None, + "path to the Cython include files" + sep_by), + ('cython-c-in-temp', None, + "put generated C files in temp directory"), + ('cython-gen-pxi', None, + "generate .pxi file for public declarations"), + ('cython-directives=', None, + "compiler directive overrides"), + ('cython-gdb', None, + "generate debug information for cygdb"), + ('cython-compile-time-env', None, + "cython compile time environment"), + + # For backwards compatibility. + ('pyrex-cplus', None, + "generate C++ source files"), + ('pyrex-create-listing', None, + "write errors to a listing file"), + ('pyrex-line-directives', None, + "emit source line directives"), + ('pyrex-include-dirs=', None, + "path to the Cython include files" + sep_by), + ('pyrex-c-in-temp', None, + "put generated C files in temp directory"), + ('pyrex-gen-pxi', None, + "generate .pxi file for public declarations"), + ('pyrex-directives=', None, + "compiler directive overrides"), + ('pyrex-gdb', None, + "generate debug information for cygdb"), + ]) + + boolean_options.extend([ + 'cython-cplus', 'cython-create-listing', 'cython-line-directives', + 'cython-c-in-temp', 'cython-gdb', + + # For backwards compatibility. + 'pyrex-cplus', 'pyrex-create-listing', 'pyrex-line-directives', + 'pyrex-c-in-temp', 'pyrex-gdb', + ]) + + def initialize_options(self): + _build_ext.build_ext.initialize_options(self) + self.cython_cplus = 0 + self.cython_create_listing = 0 + self.cython_line_directives = 0 + self.cython_include_dirs = None + self.cython_directives = None + self.cython_c_in_temp = 0 + self.cython_gen_pxi = 0 + self.cython_gdb = False + self.no_c_in_traceback = 0 + self.cython_compile_time_env = None + + def __getattr__(self, name): + if name[:6] == 'pyrex_': + return getattr(self, 'cython_' + name[6:]) + else: + return _build_ext.build_ext.__getattr__(self, name) + + def __setattr__(self, name, value): + if name[:6] == 'pyrex_': + return setattr(self, 'cython_' + name[6:], value) + else: + # _build_ext.build_ext.__setattr__(self, name, value) + self.__dict__[name] = value + + def finalize_options (self): + _build_ext.build_ext.finalize_options(self) + if self.cython_include_dirs is None: + self.cython_include_dirs = [] + elif isinstance(self.cython_include_dirs, basestring): + self.cython_include_dirs = \ + self.cython_include_dirs.split(os.pathsep) + if self.cython_directives is None: + self.cython_directives = {} + # finalize_options () + + def run(self): + # We have one shot at this before build_ext initializes the compiler. + # If --pyrex-gdb is in effect as a command line option or as option + # of any Extension module, disable optimization for the C or C++ + # compiler. + if self.cython_gdb or [1 for ext in self.extensions + if getattr(ext, 'cython_gdb', False)]: + optimization.disable_optimization() + + _build_ext.build_ext.run(self) + + def build_extensions(self): + # First, sanity-check the 'extensions' list + self.check_extensions_list(self.extensions) + + for ext in self.extensions: + ext.sources = self.cython_sources(ext.sources, ext) + # Call original build_extensions + _build_ext.build_ext.build_extensions(self) + + def cython_sources(self, sources, extension): + """ + Walk the list of source files in 'sources', looking for Cython + source files (.pyx and .py). Run Cython on all that are + found, and return a modified 'sources' list with Cython source + files replaced by the generated C (or C++) files. + """ + try: + from Cython.Compiler.Main \ + import CompilationOptions, \ + default_options as cython_default_options, \ + compile as cython_compile + from Cython.Compiler.Errors import PyrexError + except ImportError: + e = sys.exc_info()[1] + print("failed to import Cython: %s" % e) + raise DistutilsPlatformError("Cython does not appear to be installed") + + new_sources = [] + cython_sources = [] + cython_targets = {} + + # Setup create_list and cplus from the extension options if + # Cython.Distutils.extension.Extension is used, otherwise just + # use what was parsed from the command-line or the configuration file. + # cplus will also be set to true is extension.language is equal to + # 'C++' or 'c++'. + #try: + # create_listing = self.cython_create_listing or \ + # extension.cython_create_listing + # cplus = self.cython_cplus or \ + # extension.cython_cplus or \ + # (extension.language != None and \ + # extension.language.lower() == 'c++') + #except AttributeError: + # create_listing = self.cython_create_listing + # cplus = self.cython_cplus or \ + # (extension.language != None and \ + # extension.language.lower() == 'c++') + + create_listing = self.cython_create_listing or \ + getattr(extension, 'cython_create_listing', 0) + line_directives = self.cython_line_directives or \ + getattr(extension, 'cython_line_directives', 0) + no_c_in_traceback = self.no_c_in_traceback or \ + getattr(extension, 'no_c_in_traceback', 0) + cplus = self.cython_cplus or getattr(extension, 'cython_cplus', 0) or \ + (extension.language and extension.language.lower() == 'c++') + cython_gen_pxi = self.cython_gen_pxi or getattr(extension, 'cython_gen_pxi', 0) + cython_gdb = self.cython_gdb or getattr(extension, 'cython_gdb', False) + cython_compile_time_env = self.cython_compile_time_env or \ + getattr(extension, 'cython_compile_time_env', None) + + # Set up the include_path for the Cython compiler: + # 1. Start with the command line option. + # 2. Add in any (unique) paths from the extension + # cython_include_dirs (if Cython.Distutils.extension is used). + # 3. Add in any (unique) paths from the extension include_dirs + includes = self.cython_include_dirs + try: + for i in extension.cython_include_dirs: + if not i in includes: + includes.append(i) + except AttributeError: + pass + + # In case extension.include_dirs is a generator, evaluate it and keep + # result + extension.include_dirs = list(extension.include_dirs) + for i in extension.include_dirs: + if not i in includes: + includes.append(i) + + # Set up Cython compiler directives: + # 1. Start with the command line option. + # 2. Add in any (unique) entries from the extension + # cython_directives (if Cython.Distutils.extension is used). + directives = self.cython_directives + if hasattr(extension, "cython_directives"): + directives.update(extension.cython_directives) + + # Set the target_ext to '.c'. Cython will change this to '.cpp' if + # needed. + if cplus: + target_ext = '.cpp' + else: + target_ext = '.c' + + # Decide whether to drop the generated C files into the temp dir + # or the source tree. + + if not self.inplace and (self.cython_c_in_temp + or getattr(extension, 'cython_c_in_temp', 0)): + target_dir = os.path.join(self.build_temp, "pyrex") + for package_name in extension.name.split('.')[:-1]: + target_dir = os.path.join(target_dir, package_name) + else: + target_dir = None + + newest_dependency = None + for source in sources: + (base, ext) = os.path.splitext(os.path.basename(source)) + if ext == ".py": + # FIXME: we might want to special case this some more + ext = '.pyx' + if ext == ".pyx": # Cython source file + output_dir = target_dir or os.path.dirname(source) + new_sources.append(os.path.join(output_dir, base + target_ext)) + cython_sources.append(source) + cython_targets[source] = new_sources[-1] + elif ext == '.pxi' or ext == '.pxd': + if newest_dependency is None \ + or newer(source, newest_dependency): + newest_dependency = source + else: + new_sources.append(source) + + if not cython_sources: + return new_sources + + module_name = extension.name + + for source in cython_sources: + target = cython_targets[source] + depends = [source] + list(extension.depends or ()) + if(source[-4:].lower()==".pyx" and os.path.isfile(source[:-3]+"pxd")): + depends += [source[:-3]+"pxd"] + rebuild = self.force or newer_group(depends, target, 'newer') + if not rebuild and newest_dependency is not None: + rebuild = newer(newest_dependency, target) + if rebuild: + log.info("cythoning %s to %s", source, target) + self.mkpath(os.path.dirname(target)) + if self.inplace: + output_dir = os.curdir + else: + output_dir = self.build_lib + options = CompilationOptions(cython_default_options, + use_listing_file = create_listing, + include_path = includes, + compiler_directives = directives, + output_file = target, + cplus = cplus, + emit_linenums = line_directives, + c_line_in_traceback = not no_c_in_traceback, + generate_pxi = cython_gen_pxi, + output_dir = output_dir, + gdb_debug = cython_gdb, + compile_time_env = cython_compile_time_env) + result = cython_compile(source, options=options, + full_module_name=module_name) + else: + log.info("skipping '%s' Cython extension (up-to-date)", target) + + return new_sources + + # cython_sources () + +# class build_ext diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd new file mode 100644 index 00000000000..56236e925ca --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd new file mode 100644 index 00000000000..9a6d253f45e --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.bool cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd new file mode 100644 index 00000000000..2baeaae00ca --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.buffer cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd new file mode 100644 index 00000000000..87af662de0f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.bytes cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd new file mode 100644 index 00000000000..ed32c6b8781 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.cobject cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd new file mode 100644 index 00000000000..0a780b3b2dd --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.complex cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd new file mode 100644 index 00000000000..05b5f4796a6 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.dict cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd new file mode 100644 index 00000000000..6eb236bccb4 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.exc cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd new file mode 100644 index 00000000000..7e133ef9bb8 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.float cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd new file mode 100644 index 00000000000..1461c4e6353 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.function cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd new file mode 100644 index 00000000000..3852d6a6a15 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.getargs cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd new file mode 100644 index 00000000000..99cb5a9091c --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.instance cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd new file mode 100644 index 00000000000..c1fd5178d64 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.int cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd new file mode 100644 index 00000000000..e09aad27901 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.iterator cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd new file mode 100644 index 00000000000..64febcf9693 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.list cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd new file mode 100644 index 00000000000..1a24380c4cf --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.long cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd new file mode 100644 index 00000000000..cd01bee015f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.mapping cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd new file mode 100644 index 00000000000..d74429ea367 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.mem cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd new file mode 100644 index 00000000000..e7da5154e43 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.method cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd new file mode 100644 index 00000000000..6310c0247dd --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.module cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd new file mode 100644 index 00000000000..ae67da1c38f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.number cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd new file mode 100644 index 00000000000..3981bfa44e1 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.object cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd new file mode 100644 index 00000000000..e03e66a2e23 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.oldbuffer cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd new file mode 100644 index 00000000000..fe9cf8f8d9d --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.pycapsule cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd new file mode 100644 index 00000000000..94474181989 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.ref cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd new file mode 100644 index 00000000000..fdef5b63ebb --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.sequence cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd new file mode 100644 index 00000000000..a2feb937122 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.set cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd new file mode 100644 index 00000000000..24c818338e8 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.string cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd new file mode 100644 index 00000000000..190713b0204 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.tuple cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd new file mode 100644 index 00000000000..3ac47d1b3f2 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.type cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd new file mode 100644 index 00000000000..2b488b2dc89 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.unicode cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd new file mode 100644 index 00000000000..c27ca4df956 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.version cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd new file mode 100644 index 00000000000..1f84f1a1795 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from cpython.weakref cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd new file mode 100644 index 00000000000..41a4aebf1d7 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from libc.stdio cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd new file mode 100644 index 00000000000..499511cde99 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd @@ -0,0 +1,2 @@ +# Present for backwards compatibility +from libc.stdlib cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd new file mode 100644 index 00000000000..22248d2655e --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd @@ -0,0 +1,91 @@ +cdef extern from "<vector>" namespace std: + + cdef cppclass vector[TYPE]: + #constructors + __init__() + __init__(vector&) + __init__(int) + __init__(int, TYPE&) + __init__(iterator, iterator) + #operators + TYPE& __getitem__(int) + TYPE& __setitem__(int, TYPE&) + vector __new__(vector&) + bool __eq__(vector&, vector&) + bool __ne__(vector&, vector&) + bool __lt__(vector&, vector&) + bool __gt__(vector&, vector&) + bool __le__(vector&, vector&) + bool __ge__(vector&, vector&) + #others + void assign(int, TYPE) + #void assign(iterator, iterator) + TYPE& at(int) + TYPE& back() + iterator begin() + int capacity() + void clear() + bool empty() + iterator end() + iterator erase(iterator) + iterator erase(iterator, iterator) + TYPE& front() + iterator insert(iterator, TYPE&) + void insert(iterator, int, TYPE&) + void insert(iterator, iterator) + int max_size() + void pop_back() + void push_back(TYPE&) + iterator rbegin() + iterator rend() + void reserve(int) + void resize(int) + void resize(int, TYPE&) #void resize(size_type num, const TYPE& = TYPE()) + int size() + void swap(container&) + +cdef extern from "<deque>" namespace std: + + cdef cppclass deque[TYPE]: + #constructors + __init__() + __init__(deque&) + __init__(int) + __init__(int, TYPE&) + __init__(iterator, iterator) + #operators + TYPE& operator[]( size_type index ); + const TYPE& operator[]( size_type index ) const; + deque __new__(deque&); + bool __eq__(deque&, deque&); + bool __ne__(deque&, deque&); + bool __lt__(deque&, deque&); + bool __gt__(deque&, deque&); + bool __le__(deque&, deque&); + bool __ge__(deque&, deque&); + #others + void assign(int, TYPE&) + void assign(iterator, iterator) + TYPE& at(int) + TYPE& back() + iterator begin() + void clear() + bool empty() + iterator end() + iterator erase(iterator) + iterator erase(iterator, iterator) + TYPE& front() + iterator insert(iterator, TYPE&) + void insert(iterator, int, TYPE&) + void insert(iterator, iterator, iterator) + int max_size() + void pop_back() + void pop_front() + void push_back(TYPE&) + void push_front(TYPE&) + iterator rbegin() + iterator rend() + void resize(int) + void resize(int, TYPE&) + int size() + void swap(container&) diff --git a/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd b/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd new file mode 100644 index 00000000000..c81f4e66558 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd @@ -0,0 +1,184 @@ +##################################################################### +# +# These are the Cython pxd files for (most of) the Python/C API. +# +# REFERENCE COUNTING: +# +# JUST TO SCARE YOU: +# If you are going to use any of the Python/C API in your Cython +# program, you might be responsible for doing reference counting. +# Read http://docs.python.org/api/refcounts.html which is so +# important I've copied it below. +# +# For all the declaration below, whenever the Py_ function returns +# a *new reference* to a PyObject*, the return type is "object". +# When the function returns a borrowed reference, the return +# type is PyObject*. When Cython sees "object" as a return type +# it doesn't increment the reference count. When it sees PyObject* +# in order to use the result you must explicitly cast to <object>, +# and when you do that Cython increments the reference count whether +# you want it to or not, forcing you to an explicit DECREF (or leak memory). +# To avoid this we make the above convention. Note, you can +# always locally override this convention by putting something like +# +# cdef extern from "Python.h": +# PyObject* PyNumber_Add(PyObject *o1, PyObject *o2) +# +# in your .pyx file or into a cimported .pxd file. You just have to +# use the one from the right (pxd-)namespace then. +# +# Cython automatically takes care of reference counting for anything +# of type object. +# +## More precisely, I think the correct convention for +## using the Python/C API from Cython is as follows. +## +## (1) Declare all input arguments as type "object". This way no explicit +## <PyObject*> casting is needed, and moreover Cython doesn't generate +## any funny reference counting. +## (2) Declare output as object if a new reference is returned. +## (3) Declare output as PyObject* if a borrowed reference is returned. +## +## This way when you call objects, no cast is needed, and if the api +## calls returns a new reference (which is about 95% of them), then +## you can just assign to a variable of type object. With borrowed +## references if you do an explicit typecast to <object>, Cython generates an +## INCREF and DECREF so you have to be careful. However, you got a +## borrowed reference in this case, so there's got to be another reference +## to your object, so you're OK, as long as you relealize this +## and use the result of an explicit cast to <object> as a borrowed +## reference (and you can call Py_INCREF if you want to turn it +## into another reference for some reason). +# +# "The reference count is important because today's computers have +# a finite (and often severely limited) memory size; it counts how +# many different places there are that have a reference to an +# object. Such a place could be another object, or a global (or +# static) C variable, or a local variable in some C function. When +# an object's reference count becomes zero, the object is +# deallocated. If it contains references to other objects, their +# reference count is decremented. Those other objects may be +# deallocated in turn, if this decrement makes their reference +# count become zero, and so on. (There's an obvious problem with +# objects that reference each other here; for now, the solution is +# ``don't do that.'') +# +# Reference counts are always manipulated explicitly. The normal +# way is to use the macro Py_INCREF() to increment an object's +# reference count by one, and Py_DECREF() to decrement it by +# one. The Py_DECREF() macro is considerably more complex than the +# incref one, since it must check whether the reference count +# becomes zero and then cause the object's deallocator to be +# called. The deallocator is a function pointer contained in the +# object's type structure. The type-specific deallocator takes +# care of decrementing the reference counts for other objects +# contained in the object if this is a compound object type, such +# as a list, as well as performing any additional finalization +# that's needed. There's no chance that the reference count can +# overflow; at least as many bits are used to hold the reference +# count as there are distinct memory locations in virtual memory +# (assuming sizeof(long) >= sizeof(char*)). Thus, the reference +# count increment is a simple operation. +# +# It is not necessary to increment an object's reference count for +# every local variable that contains a pointer to an object. In +# theory, the object's reference count goes up by one when the +# variable is made to point to it and it goes down by one when the +# variable goes out of scope. However, these two cancel each other +# out, so at the end the reference count hasn't changed. The only +# real reason to use the reference count is to prevent the object +# from being deallocated as long as our variable is pointing to +# it. If we know that there is at least one other reference to the +# object that lives at least as long as our variable, there is no +# need to increment the reference count temporarily. An important +# situation where this arises is in objects that are passed as +# arguments to C functions in an extension module that are called +# from Python; the call mechanism guarantees to hold a reference +# to every argument for the duration of the call. +# +# However, a common pitfall is to extract an object from a list +# and hold on to it for a while without incrementing its reference +# count. Some other operation might conceivably remove the object +# from the list, decrementing its reference count and possible +# deallocating it. The real danger is that innocent-looking +# operations may invoke arbitrary Python code which could do this; +# there is a code path which allows control to flow back to the +# user from a Py_DECREF(), so almost any operation is potentially +# dangerous. +# +# A safe approach is to always use the generic operations +# (functions whose name begins with "PyObject_", "PyNumber_", +# "PySequence_" or "PyMapping_"). These operations always +# increment the reference count of the object they return. This +# leaves the caller with the responsibility to call Py_DECREF() +# when they are done with the result; this soon becomes second +# nature. +# +# Now you should read http://docs.python.org/api/refcountDetails.html +# just to be sure you understand what is going on. +# +################################################################# + + + +################################################################# +# BIG FAT DEPRECATION WARNING +################################################################# +# Do NOT cimport any names directly from the cpython package, +# despite of the star-imports below. They will be removed at +# some point. +# Instead, use the correct sub-module to draw your cimports from. +# +# A direct cimport from the package will make your code depend on +# all of the existing declarations. This may have side-effects +# and reduces the portability of your code. +################################################################# +# START OF DEPRECATED SECTION +################################################################# + +from cpython.version cimport * +from cpython.ref cimport * +from cpython.exc cimport * +from cpython.module cimport * +from cpython.mem cimport * +from cpython.tuple cimport * +from cpython.list cimport * +from cpython.object cimport * +from cpython.sequence cimport * +from cpython.mapping cimport * +from cpython.iterator cimport * +from cpython.type cimport * +from cpython.number cimport * +from cpython.int cimport * +from cpython.bool cimport * +from cpython.long cimport * +from cpython.float cimport * +from cpython.complex cimport * +from cpython.string cimport * +from cpython.unicode cimport * +from cpython.dict cimport * +from cpython.instance cimport * +from cpython.function cimport * +from cpython.method cimport * +from cpython.weakref cimport * +from cpython.getargs cimport * +from cpython.pythread cimport * +from cpython.pystate cimport * + +# Python <= 2.x +from cpython.cobject cimport * +from cpython.oldbuffer cimport * + +# Python >= 2.4 +from cpython.set cimport * + +# Python >= 2.6 +from cpython.buffer cimport * +from cpython.bytes cimport * + +# Python >= 3.0 +from cpython.pycapsule cimport * + +################################################################# +# END OF DEPRECATED SECTION +################################################################# diff --git a/contrib/tools/cython/Cython/Includes/cpython/array.pxd b/contrib/tools/cython/Cython/Includes/cpython/array.pxd new file mode 100644 index 00000000000..19230a0a827 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/array.pxd @@ -0,0 +1,163 @@ +""" + array.pxd + + Cython interface to Python's array.array module. + + * 1D contiguous data view + * tools for fast array creation, maximum C-speed and handiness + * suitable as allround light weight auto-array within Cython code too + + Usage: + + >>> cimport array + + Usage through Cython buffer interface (Py2.3+): + + >>> def f(arg1, unsigned i, double dx) + ... array.array[double] a = arg1 + ... a[i] += dx + + Fast C-level new_array(_zeros), resize_array, copy_array, Py_SIZE(obj), + zero_array + + cdef array.array[double] k = array.copy(d) + cdef array.array[double] n = array.array(d, Py_SIZE(d) * 2 ) + cdef array.array[double] m = array.zeros_like(FLOAT_TEMPLATE) + array.resize(f, 200000) + + Zero overhead with naked data pointer views by union: + _f, _d, _i, _c, _u, ... + => Original C array speed + Python dynamic memory management + + cdef array.array a = inarray + if + a._d[2] += 0.66 # use as double array without extra casting + + float *subview = vector._f + 10 # starting from 10th element + unsigned char *subview_buffer = vector._B + 4 + + Suitable as lightweight arrays intra Cython without speed penalty. + Replacement for C stack/malloc arrays; no trouble with refcounting, + mem.leaks; seamless Python compatibility, buffer() optional + + + last changes: 2009-05-15 rk + : 2009-12-06 bp + : 2012-05-02 andreasvc + : (see revision control) +""" +from libc.string cimport strcat, strncat, \ + memset, memchr, memcmp, memcpy, memmove + +from cpython.object cimport Py_SIZE +from cpython.ref cimport PyTypeObject, Py_TYPE +from cpython.exc cimport PyErr_BadArgument +from cpython.mem cimport PyObject_Malloc, PyObject_Free + +cdef extern from *: # Hard-coded utility code hack. + ctypedef class array.array [object arrayobject] + ctypedef object GETF(array a, Py_ssize_t ix) + ctypedef object SETF(array a, Py_ssize_t ix, object o) + ctypedef struct arraydescr: # [object arraydescr]: + char typecode + int itemsize + GETF getitem # PyObject * (*getitem)(struct arrayobject *, Py_ssize_t); + SETF setitem # int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *); + + ctypedef union __data_union: + # views of ob_item: + float* as_floats # direct float pointer access to buffer + double* as_doubles # double ... + int* as_ints + unsigned int *as_uints + unsigned char *as_uchars + signed char *as_schars + char *as_chars + unsigned long *as_ulongs + long *as_longs + unsigned long long *as_ulonglongs + long long *as_longlongs + short *as_shorts + unsigned short *as_ushorts + Py_UNICODE *as_pyunicodes + void *as_voidptr + + ctypedef class array.array [object arrayobject]: + cdef __cythonbufferdefaults__ = {'ndim' : 1, 'mode':'c'} + + cdef: + Py_ssize_t ob_size + arraydescr* ob_descr # struct arraydescr *ob_descr; + __data_union data + + def __getbuffer__(self, Py_buffer* info, int flags): + # This implementation of getbuffer is geared towards Cython + # requirements, and does not yet fulfill the PEP. + # In particular strided access is always provided regardless + # of flags + item_count = Py_SIZE(self) + + info.suboffsets = NULL + info.buf = self.data.as_chars + info.readonly = 0 + info.ndim = 1 + info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float) + info.len = info.itemsize * item_count + + info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2) + if not info.shape: + raise MemoryError() + info.shape[0] = item_count # constant regardless of resizing + info.strides = &info.itemsize + + info.format = <char*> (info.shape + 1) + info.format[0] = self.ob_descr.typecode + info.format[1] = 0 + info.obj = self + + def __releasebuffer__(self, Py_buffer* info): + PyObject_Free(info.shape) + + array newarrayobject(PyTypeObject* type, Py_ssize_t size, arraydescr *descr) + + # fast resize/realloc + # not suitable for small increments; reallocation 'to the point' + int resize(array self, Py_ssize_t n) except -1 + # efficient for small increments (not in Py2.3-) + int resize_smart(array self, Py_ssize_t n) except -1 + + +cdef inline array clone(array template, Py_ssize_t length, bint zero): + """ fast creation of a new array, given a template array. + type will be same as template. + if zero is true, new array will be initialized with zeroes.""" + cdef array op = newarrayobject(Py_TYPE(template), length, template.ob_descr) + if zero and op is not None: + memset(op.data.as_chars, 0, length * op.ob_descr.itemsize) + return op + +cdef inline array copy(array self): + """ make a copy of an array. """ + cdef array op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr) + memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize) + return op + +cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1: + """ efficient appending of new stuff of same type + (e.g. of same array type) + n: number of elements (not number of bytes!) """ + cdef Py_ssize_t itemsize = self.ob_descr.itemsize + cdef Py_ssize_t origsize = Py_SIZE(self) + resize_smart(self, origsize + n) + memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize) + return 0 + +cdef inline int extend(array self, array other) except -1: + """ extend array with data from another array; types must match. """ + if self.ob_descr.typecode != other.ob_descr.typecode: + PyErr_BadArgument() + return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) + +cdef inline void zero(array self): + """ set all elements of array to zero. """ + memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize) diff --git a/contrib/tools/cython/Cython/Includes/cpython/bool.pxd b/contrib/tools/cython/Cython/Includes/cpython/bool.pxd new file mode 100644 index 00000000000..c775088ce64 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/bool.pxd @@ -0,0 +1,38 @@ + +cdef extern from "Python.h": + + ############################################################################ + # 7.2.2 Boolean Objects + ############################################################################ + + ctypedef class __builtin__.bool [object PyBoolObject]: + pass + + # Booleans in Python are implemented as a subclass of + # integers. There are only two booleans, Py_False and Py_True. As + # such, the normal creation and deletion functions don't apply to + # booleans. The following macros are available, however. + + bint PyBool_Check(object o) + # Return true if o is of type PyBool_Type. + + #PyObject* Py_False + # The Python False object. This object has no methods. It needs to + # be treated just like any other object with respect to reference + # counts. + + #PyObject* Py_True + # The Python True object. This object has no methods. It needs to + # be treated just like any other object with respect to reference + # counts. + + # Py_RETURN_FALSE + # Return Py_False from a function, properly incrementing its reference count. + + # Py_RETURN_TRUE + # Return Py_True from a function, properly incrementing its reference count. + + object PyBool_FromLong(long v) + # Return value: New reference. + # Return a new reference to Py_True or Py_False depending on the truth value of v. + diff --git a/contrib/tools/cython/Cython/Includes/cpython/buffer.pxd b/contrib/tools/cython/Cython/Includes/cpython/buffer.pxd new file mode 100644 index 00000000000..3f1ada774aa --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/buffer.pxd @@ -0,0 +1,112 @@ +# Please see the Python header files (object.h/abstract.h) for docs + +cdef extern from "Python.h": + + cdef enum: + PyBUF_MAX_NDIM + + cdef enum: + PyBUF_SIMPLE, + PyBUF_WRITABLE, + PyBUF_WRITEABLE, # backwards compatibility + PyBUF_FORMAT, + PyBUF_ND, + PyBUF_STRIDES, + PyBUF_C_CONTIGUOUS, + PyBUF_F_CONTIGUOUS, + PyBUF_ANY_CONTIGUOUS, + PyBUF_INDIRECT, + PyBUF_CONTIG, + PyBUF_CONTIG_RO, + PyBUF_STRIDED, + PyBUF_STRIDED_RO, + PyBUF_RECORDS, + PyBUF_RECORDS_RO, + PyBUF_FULL, + PyBUF_FULL_RO, + PyBUF_READ, + PyBUF_WRITE, + PyBUF_SHADOW + + bint PyObject_CheckBuffer(object obj) + # Return 1 if obj supports the buffer interface otherwise 0. + + int PyObject_GetBuffer(object obj, Py_buffer *view, int flags) except -1 + # Export obj into a Py_buffer, view. These arguments must never be + # NULL. The flags argument is a bit field indicating what kind of + # buffer the caller is prepared to deal with and therefore what + # kind of buffer the exporter is allowed to return. The buffer + # interface allows for complicated memory sharing possibilities, + # but some caller may not be able to handle all the complexity but + # may want to see if the exporter will let them take a simpler + # view to its memory. + + # Some exporters may not be able to share memory in every possible + # way and may need to raise errors to signal to some consumers + # that something is just not possible. These errors should be a + # BufferError unless there is another error that is actually + # causing the problem. The exporter can use flags information to + # simplify how much of the Py_buffer structure is filled in with + # non-default values and/or raise an error if the object can’t + # support a simpler view of its memory. + + # 0 is returned on success and -1 on error. + + void PyBuffer_Release(Py_buffer *view) + # Release the buffer view. This should be called when the buffer + # is no longer being used as it may free memory from it. + + void* PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices) + # ?? + + Py_ssize_t PyBuffer_SizeFromFormat(char *) # actually const char + # Return the implied ~Py_buffer.itemsize from the struct-stype + # ~Py_buffer.format + + int PyBuffer_ToContiguous(void *buf, Py_buffer *view, Py_ssize_t len, char fort) + # ?? + + int PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort) + # ?? + + int PyObject_CopyToObject(object obj, void *buf, Py_ssize_t len, char fortran) except -1 + # Copy len bytes of data pointed to by the contiguous chunk of + # memory pointed to by buf into the buffer exported by obj. The + # buffer must of course be writable. Return 0 on success and + # return -1 and raise an error on failure. If the object does not + # have a writable buffer, then an error is raised. If fortran is + # 'F', then if the object is multi-dimensional, then the data will + # be copied into the array in Fortran-style (first dimension + # varies the fastest). If fortran is 'C', then the data will be + # copied into the array in C-style (last dimension varies the + # fastest). If fortran is 'A', then it does not matter and the + # copy will be made in whatever way is more efficient. + + int PyObject_CopyData(object dest, object src) except -1 + # Copy the data from the src buffer to the buffer of destination + + bint PyBuffer_IsContiguous(Py_buffer *view, char fort) + # Return 1 if the memory defined by the view is C-style (fortran + # is 'C') or Fortran-style (fortran is 'F') contiguous or either + # one (fortran is 'A'). Return 0 otherwise. + + void PyBuffer_FillContiguousStrides(int ndims, + Py_ssize_t *shape, + Py_ssize_t *strides, + Py_ssize_t itemsize, + char fort) + # Fill the strides array with byte-strides of a contiguous + # (Fortran-style if fort is 'F' or C-style otherwise) array of the + # given shape with the given number of bytes per element. + + int PyBuffer_FillInfo(Py_buffer *view, object exporter, void *buf, + Py_ssize_t len, int readonly, int flags) except -1 + # Fill in a buffer-info structure, view, correctly for an exporter + # that can only share a contiguous chunk of memory of “unsigned + # bytes” of the given length. Return 0 on success and -1 (with + # raising an error) on error. + + # DEPRECATED HERE: do not cimport from here, cimport from cpython.object instead + object PyObject_Format(object obj, object format_spec) + # Takes an arbitrary object and returns the result of calling + # obj.__format__(format_spec). diff --git a/contrib/tools/cython/Cython/Includes/cpython/bytearray.pxd b/contrib/tools/cython/Cython/Includes/cpython/bytearray.pxd new file mode 100644 index 00000000000..1af4a6c427b --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/bytearray.pxd @@ -0,0 +1,33 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + bint PyByteArray_Check(object o) + # Return true if the object o is a bytearray object or an instance of a subtype of the bytearray type. + + bint PyByteArray_CheckExact(object o) + # Return true if the object o is a bytearray object, but not an instance of a subtype of the bytearray type. + + bytearray PyByteArray_FromObject(object o) + # Return a new bytearray object from any object, o, that implements the buffer protocol. + + bytearray PyByteArray_FromStringAndSize(char *string, Py_ssize_t len) + # Create a new bytearray object from string and its length, len. On failure, NULL is returned. + + bytearray PyByteArray_Concat(object a, object b) + # Concat bytearrays a and b and return a new bytearray with the result. + + Py_ssize_t PyByteArray_Size(object bytearray) + # Return the size of bytearray after checking for a NULL pointer. + + char* PyByteArray_AsString(object bytearray) + # Return the contents of bytearray as a char array after checking for a NULL pointer. + # The returned array always has an extra null byte appended. + + int PyByteArray_Resize(object bytearray, Py_ssize_t len) + # Resize the internal buffer of bytearray to len. + + char* PyByteArray_AS_STRING(object bytearray) + # Macro version of PyByteArray_AsString(). + + Py_ssize_t PyByteArray_GET_SIZE(object bytearray) + # Macro version of PyByteArray_Size(). diff --git a/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd b/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd new file mode 100644 index 00000000000..ea72c6aae77 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd @@ -0,0 +1,198 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + ctypedef struct va_list + + ############################################################################ + # 7.3.1 String Objects + ############################################################################ + + # These functions raise TypeError when expecting a string + # parameter and are called with a non-string parameter. + # PyStringObject + # This subtype of PyObject represents a Python bytes object. + # PyTypeObject PyBytes_Type + # This instance of PyTypeObject represents the Python bytes type; + # it is the same object as bytes and types.BytesType in the Python + # layer. + + bint PyBytes_Check(object o) + # Return true if the object o is a string object or an instance of + # a subtype of the string type. + + bint PyBytes_CheckExact(object o) + # Return true if the object o is a string object, but not an instance of a subtype of the string type. + + bytes PyBytes_FromString(char *v) + # Return value: New reference. + # Return a new string object with the value v on success, and NULL + # on failure. The parameter v must not be NULL; it will not be + # checked. + + bytes PyBytes_FromStringAndSize(char *v, Py_ssize_t len) + # Return value: New reference. + # Return a new string object with the value v and length len on + # success, and NULL on failure. If v is NULL, the contents of the + # string are uninitialized. + + bytes PyBytes_FromFormat(char *format, ...) + # Return value: New reference. + # Take a C printf()-style format string and a variable number of + # arguments, calculate the size of the resulting Python string and + # return a string with the values formatted into it. The variable + # arguments must be C types and must correspond exactly to the + # format characters in the format string. The following format + # characters are allowed: + # Format Characters Type Comment + # %% n/a The literal % character. + # %c int A single character, represented as an C int. + # %d int Exactly equivalent to printf("%d"). + # %u unsigned int Exactly equivalent to printf("%u"). + # %ld long Exactly equivalent to printf("%ld"). + # %lu unsigned long Exactly equivalent to printf("%lu"). + # %zd Py_ssize_t Exactly equivalent to printf("%zd"). + # %zu size_t Exactly equivalent to printf("%zu"). + # %i int Exactly equivalent to printf("%i"). + # %x int Exactly equivalent to printf("%x"). + # %s char* A null-terminated C character array. + + # %p void* The hex representation of a C pointer. + # Mostly equivalent to printf("%p") except that it is guaranteed to + # start with the literal 0x regardless of what the platform's printf + # yields. + # An unrecognized format character causes all the rest of the + # format string to be copied as-is to the result string, and any + # extra arguments discarded. + + bytes PyBytes_FromFormatV(char *format, va_list vargs) + # Return value: New reference. + # Identical to PyBytes_FromFormat() except that it takes exactly two arguments. + + Py_ssize_t PyBytes_Size(object string) except -1 + # Return the length of the string in string object string. + + Py_ssize_t PyBytes_GET_SIZE(object string) + # Macro form of PyBytes_Size() but without error checking. + + char* PyBytes_AsString(object string) except NULL + # Return a NUL-terminated representation of the contents of + # string. The pointer refers to the internal buffer of string, not + # a copy. The data must not be modified in any way, unless the + # string was just created using PyBytes_FromStringAndSize(NULL, + # size). It must not be deallocated. If string is a Unicode + # object, this function computes the default encoding of string + # and operates on that. If string is not a string object at all, + # PyBytes_AsString() returns NULL and raises TypeError. + + char* PyBytes_AS_STRING(object string) + # Macro form of PyBytes_AsString() but without error + # checking. Only string objects are supported; no Unicode objects + # should be passed. + + int PyBytes_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1 + # Return a NULL-terminated representation of the contents of the + # object obj through the output variables buffer and length. + # + # The function accepts both string and Unicode objects as + # input. For Unicode objects it returns the default encoded + # version of the object. If length is NULL, the resulting buffer + # may not contain NUL characters; if it does, the function returns + # -1 and a TypeError is raised. + + # The buffer refers to an internal string buffer of obj, not a + # copy. The data must not be modified in any way, unless the + # string was just created using PyBytes_FromStringAndSize(NULL, + # size). It must not be deallocated. If string is a Unicode + # object, this function computes the default encoding of string + # and operates on that. If string is not a string object at all, + # PyBytes_AsStringAndSize() returns -1 and raises TypeError. + + void PyBytes_Concat(PyObject **string, object newpart) + # Create a new string object in *string containing the contents of + # newpart appended to string; the caller will own the new + # reference. The reference to the old value of string will be + # stolen. If the new string cannot be created, the old reference + # to string will still be discarded and the value of *string will + # be set to NULL; the appropriate exception will be set. + + void PyBytes_ConcatAndDel(PyObject **string, object newpart) + # Create a new string object in *string containing the contents of + # newpart appended to string. This version decrements the + # reference count of newpart. + + int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1 + # A way to resize a string object even though it is + # ``immutable''. Only use this to build up a brand new string + # object; don't use this if the string may already be known in + # other parts of the code. It is an error to call this function if + # the refcount on the input string object is not one. Pass the + # address of an existing string object as an lvalue (it may be + # written into), and the new size desired. On success, *string + # holds the resized string object and 0 is returned; the address + # in *string may differ from its input value. If the reallocation + # fails, the original string object at *string is deallocated, + # *string is set to NULL, a memory exception is set, and -1 is + # returned. + + bytes PyBytes_Format(object format, object args) + # Return value: New reference. Return a new string object from + # format and args. Analogous to format % args. The args argument + # must be a tuple. + + void PyBytes_InternInPlace(PyObject **string) + # Intern the argument *string in place. The argument must be the + # address of a pointer variable pointing to a Python string + # object. If there is an existing interned string that is the same + # as *string, it sets *string to it (decrementing the reference + # count of the old string object and incrementing the reference + # count of the interned string object), otherwise it leaves + # *string alone and interns it (incrementing its reference + # count). (Clarification: even though there is a lot of talk about + # reference counts, think of this function as + # reference-count-neutral; you own the object after the call if + # and only if you owned it before the call.) + + bytes PyBytes_InternFromString(char *v) + # Return value: New reference. + # A combination of PyBytes_FromString() and + # PyBytes_InternInPlace(), returning either a new string object + # that has been interned, or a new (``owned'') reference to an + # earlier interned string object with the same value. + + object PyBytes_Decode(char *s, Py_ssize_t size, char *encoding, char *errors) + # Return value: New reference. + # Create an object by decoding size bytes of the encoded buffer s + # using the codec registered for encoding. encoding and errors + # have the same meaning as the parameters of the same name in the + # unicode() built-in function. The codec to be used is looked up + # using the Python codec registry. Return NULL if an exception was + # raised by the codec. + + object PyBytes_AsDecodedObject(object str, char *encoding, char *errors) + # Return value: New reference. + # Decode a string object by passing it to the codec registered for + # encoding and return the result as Python object. encoding and + # errors have the same meaning as the parameters of the same name + # in the string encode() method. The codec to be used is looked up + # using the Python codec registry. Return NULL if an exception was + # raised by the codec. + + object PyBytes_Encode(char *s, Py_ssize_t size, char *encoding, char *errors) + # Return value: New reference. + # Encode the char buffer of the given size by passing it to the + # codec registered for encoding and return a Python + # object. encoding and errors have the same meaning as the + # parameters of the same name in the string encode() method. The + # codec to be used is looked up using the Python codec + # registry. Return NULL if an exception was raised by the codec. + + object PyBytes_AsEncodedObject(object str, char *encoding, char *errors) + # Return value: New reference. + # Encode a string object using the codec registered for encoding + # and return the result as Python object. encoding and errors have + # the same meaning as the parameters of the same name in the + # string encode() method. The codec to be used is looked up using + # the Python codec registry. Return NULL if an exception was + # raised by the codec. + + diff --git a/contrib/tools/cython/Cython/Includes/cpython/cellobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/cellobject.pxd new file mode 100644 index 00000000000..5e3dd3d63c4 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/cellobject.pxd @@ -0,0 +1,35 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ############################################################################ + # Cell Objects + ############################################################################ + + bint PyCell_Check(object ob) + # Return true if ob is a cell object; ob must not be NULL. + + object PyCell_New(PyObject* ob) + # Return value: New reference. + # Create and return a new cell object containing the value ob. The + # parameter may be NULL. + + object PyCell_Get(object cell) + # Return value: New reference. + # Return the contents of the cell object cell. + + object PyCell_GET(object cell) + # Return value: Borrowed reference. + # Return the contents of the cell object cell, but without checking that + # cell is non-NULL and is a cell object. + + int PyCell_Set(object cell, PyObject* value) except? -1 + # Set the contents of the cell object cell to value. This releases the + # reference to any current content of the cell. value may be NULL. cell + # must be non-NULL; if it is not a cell object, -1 will be returned. On + # success, 0 will be returned. + + void PyCell_SET(object cell, PyObject* value) + # Sets the value of the cell object cell to value. No reference counts are + # adjusted, and no checks are made for safety; cell must be non-NULL and + # must be a cell object. diff --git a/contrib/tools/cython/Cython/Includes/cpython/ceval.pxd b/contrib/tools/cython/Cython/Includes/cpython/ceval.pxd new file mode 100644 index 00000000000..f22191f9fe9 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/ceval.pxd @@ -0,0 +1,8 @@ + +cdef extern from "Python.h": + + void PyEval_InitThreads() + # Initialize and acquire the global interpreter lock. + + int PyEval_ThreadsInitialized() + # Returns a non-zero value if PyEval_InitThreads() has been called. diff --git a/contrib/tools/cython/Cython/Includes/cpython/cobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/cobject.pxd new file mode 100644 index 00000000000..497d8a92e80 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/cobject.pxd @@ -0,0 +1,36 @@ + +cdef extern from "Python.h": + + ########################################################################### + # Warning: + # + # The CObject API is deprecated as of Python 3.1. Please switch to + # the new Capsules API. + ########################################################################### + + int PyCObject_Check(object p) + # Return true if its argument is a PyCObject. + + object PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *)) + # Return value: New reference. + # + # Create a PyCObject from the void * cobj. The destr function will + # be called when the object is reclaimed, unless it is NULL. + + object PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *)) + # Return value: New reference. + # + # Create a PyCObject from the void * cobj. The destr function will + # be called when the object is reclaimed. The desc argument can be + # used to pass extra callback data for the destructor function. + + void* PyCObject_AsVoidPtr(object self) except? NULL + # Return the object void * that the PyCObject self was created with. + + void* PyCObject_GetDesc(object self) except? NULL + # Return the description void * that the PyCObject self was created with. + + int PyCObject_SetVoidPtr(object self, void* cobj) except 0 + # Set the void pointer inside self to cobj. The PyCObject must not + # have an associated destructor. Return true on success, false on + # failure. diff --git a/contrib/tools/cython/Cython/Includes/cpython/codecs.pxd b/contrib/tools/cython/Cython/Includes/cpython/codecs.pxd new file mode 100644 index 00000000000..f2ca7d2444b --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/codecs.pxd @@ -0,0 +1,121 @@ +cdef extern from "Python.h": + + ########################################################################### + # Codec registry and support functions + ########################################################################### + + int PyCodec_Register(object search_function) + # Register a new codec search function. + + # As side effect, this tries to load the encodings package, if not yet + # done, to make sure that it is always first in the list of search + # functions. + + int PyCodec_KnownEncoding(const char *encoding) + # Return 1 or 0 depending on whether there is a registered codec for the + # given encoding. This function always succeeds. + + object PyCodec_Encode(object o, const char *encoding, const char *errors) + # Return value: New reference. + # Generic codec based encoding API. + + # o is passed through the encoder function found for the given encoding + # using the error handling method defined by errors. errors may be NULL + # to use the default method defined for the codec. Raises a LookupError + # if no encoder can be found. + + object PyCodec_Decode(object o, const char *encoding, const char *errors) + # Return value: New reference. + # Generic codec based decoding API. + + # o is passed through the decoder function found for the given encoding + # using the error handling method defined by errors. errors may be NULL + # to use the default method defined for the codec. Raises a LookupError + # if no encoder can be found. + + + # Codec lookup API + + # In the following functions, the encoding string is looked up converted + # to all lower-case characters, which makes encodings looked up through + # this mechanism effectively case-insensitive. If no codec is found, a + # KeyError is set and NULL returned. + + object PyCodec_Encoder(const char *encoding) + # Return value: New reference. + # Get an encoder function for the given encoding. + + object PyCodec_Decoder(const char *encoding) + # Return value: New reference. + # Get a decoder function for the given encoding. + + object PyCodec_IncrementalEncoder(const char *encoding, const char *errors) + # Return value: New reference. + # Get an IncrementalEncoder object for the given encoding. + + object PyCodec_IncrementalDecoder(const char *encoding, const char *errors) + # Return value: New reference. + # Get an IncrementalDecoder object for the given encoding. + + object PyCodec_StreamReader(const char *encoding, object stream, const char *errors) + # Return value: New reference. + # Get a StreamReader factory function for the given encoding. + + object PyCodec_StreamWriter(const char *encoding, object stream, const char *errors) + # Return value: New reference. + # Get a StreamWriter factory function for the given encoding. + + + # Registry API for Unicode encoding error handlers + + int PyCodec_RegisterError(const char *name, object error) except? -1 + # Register the error handling callback function error under the given + # name. This callback function will be called by a codec when it + # encounters unencodable characters/undecodable bytes and name is + # specified as the error parameter in the call to the encode/decode + # function. + + # The callback gets a single argument, an instance of + # UnicodeEncodeError, UnicodeDecodeError or UnicodeTranslateError that + # holds information about the problematic sequence of characters or bytes + # and their offset in the original string (see Unicode Exception Objects + # for functions to extract this information). The callback must either + # raise the given exception, or return a two-item tuple containing the + # replacement for the problematic sequence, and an integer giving the + # offset in the original string at which encoding/decoding should be + # resumed. + + # Return 0 on success, -1 on error. + + object PyCodec_LookupError(const char *name) + # Return value: New reference. + # Lookup the error handling callback function registered under name. As a + # special case NULL can be passed, in which case the error handling + # callback for "strict" will be returned. + + object PyCodec_StrictErrors(object exc) + # Return value: Always NULL. + # Raise exc as an exception. + + object PyCodec_IgnoreErrors(object exc) + # Return value: New reference. + # Ignore the unicode error, skipping the faulty input. + + object PyCodec_ReplaceErrors(object exc) + # Return value: New reference. + # Replace the unicode encode error with "?" or "U+FFFD". + + object PyCodec_XMLCharRefReplaceErrors(object exc) + # Return value: New reference. + # Replace the unicode encode error with XML character references. + + object PyCodec_BackslashReplaceErrors(object exc) + # Return value: New reference. + # Replace the unicode encode error with backslash escapes ("\x", "\u" + # and "\U"). + + object PyCodec_NameReplaceErrors(object exc) + # Return value: New reference. + # Replace the unicode encode error with "\N{...}" escapes. + + # New in version 3.5. diff --git a/contrib/tools/cython/Cython/Includes/cpython/complex.pxd b/contrib/tools/cython/Cython/Includes/cpython/complex.pxd new file mode 100644 index 00000000000..f5ba339575a --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/complex.pxd @@ -0,0 +1,50 @@ + +cdef extern from "Python.h": + + ctypedef struct Py_complex: + double imag + double real + + ############################################################################ + # 7.2.5.2 Complex Numbers as Python Objects + ############################################################################ + + # PyComplexObject + # This subtype of PyObject represents a Python complex number object. + + ctypedef class __builtin__.complex [object PyComplexObject]: + cdef Py_complex cval + # not making these available to keep them read-only: + #cdef double imag "cval.imag" + #cdef double real "cval.real" + + # PyTypeObject PyComplex_Type + # This instance of PyTypeObject represents the Python complex + # number type. It is the same object as complex and + # types.ComplexType. + + bint PyComplex_Check(object p) + # Return true if its argument is a PyComplexObject or a subtype of + # PyComplexObject. + + bint PyComplex_CheckExact(object p) + # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject. + + object PyComplex_FromCComplex(Py_complex v) + # Return value: New reference. + # Create a new Python complex number object from a C Py_complex value. + + object PyComplex_FromDoubles(double real, double imag) + # Return value: New reference. + # Return a new PyComplexObject object from real and imag. + + double PyComplex_RealAsDouble(object op) except? -1 + # Return the real part of op as a C double. + + double PyComplex_ImagAsDouble(object op) except? -1 + # Return the imaginary part of op as a C double. + + Py_complex PyComplex_AsCComplex(object op) + # Return the Py_complex value of the complex number op. + # + # Returns (-1+0i) in case of an error diff --git a/contrib/tools/cython/Cython/Includes/cpython/conversion.pxd b/contrib/tools/cython/Cython/Includes/cpython/conversion.pxd new file mode 100644 index 00000000000..18e2c3d1a6b --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/conversion.pxd @@ -0,0 +1,36 @@ +# From https://docs.python.org/3/c-api/conversion.html + +from .object cimport PyObject + +cdef extern from "Python.h": + ctypedef struct va_list + + int PyOS_snprintf(char *str, size_t size, const char *format, ...) + # Output not more than size bytes to str according to the format + # string format and the extra arguments. See the Unix man page snprintf(2). + + int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) + # Output not more than size bytes to str according to the format + # string format and the variable argument list va. Unix man page vsnprintf(2). + + double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception) except? -1.0 + # Convert a string s to a double, raising a Python exception on failure. The set of + # accepted strings corresponds to the set of strings accepted by Python’s float() + # constructor, except that s must not have leading or trailing whitespace. + # The conversion is independent of the current locale. + + enum: + Py_DTSF_SIGN + Py_DTSF_ADD_DOT_0 + Py_DTSF_ALT + + char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype) except NULL + # Convert a double val to a string using supplied format_code, precision, and flags. + + int PyOS_stricmp(const char *s1, const char *s2) + # Case insensitive comparison of strings. The function works almost identically + # to strcmp() except that it ignores the case. + + int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size) + # Case insensitive comparison of strings. The function works almost identically + # to strncmp() except that it ignores the case. diff --git a/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd b/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd new file mode 100644 index 00000000000..cd0f90719bd --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd @@ -0,0 +1,212 @@ +from cpython.object cimport PyObject + +cdef extern from "Python.h": + ctypedef struct PyTypeObject: + pass + +cdef extern from "datetime.h": + + ctypedef extern class datetime.date[object PyDateTime_Date]: + pass + + ctypedef extern class datetime.time[object PyDateTime_Time]: + pass + + ctypedef extern class datetime.datetime[object PyDateTime_DateTime]: + pass + + ctypedef extern class datetime.timedelta[object PyDateTime_Delta]: + pass + + ctypedef extern class datetime.tzinfo[object PyDateTime_TZInfo]: + pass + + ctypedef struct PyDateTime_Date: + pass + + ctypedef struct PyDateTime_Time: + char hastzinfo + PyObject *tzinfo + + ctypedef struct PyDateTime_DateTime: + char hastzinfo + PyObject *tzinfo + + ctypedef struct PyDateTime_Delta: + int days + int seconds + int microseconds + + # Define structure for C API. + ctypedef struct PyDateTime_CAPI: + # type objects + PyTypeObject *DateType + PyTypeObject *DateTimeType + PyTypeObject *TimeType + PyTypeObject *DeltaType + PyTypeObject *TZInfoType + + # constructors + object (*Date_FromDate)(int, int, int, PyTypeObject*) + object (*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, object, PyTypeObject*) + object (*Time_FromTime)(int, int, int, int, object, PyTypeObject*) + object (*Delta_FromDelta)(int, int, int, int, PyTypeObject*) + + # constructors for the DB API + object (*DateTime_FromTimestamp)(object, object, object) + object (*Date_FromTimestamp)(object, object) + + # Check type of the object. + bint PyDate_Check(object op) + bint PyDate_CheckExact(object op) + + bint PyDateTime_Check(object op) + bint PyDateTime_CheckExact(object op) + + bint PyTime_Check(object op) + bint PyTime_CheckExact(object op) + + bint PyDelta_Check(object op) + bint PyDelta_CheckExact(object op) + + bint PyTZInfo_Check(object op) + bint PyTZInfo_CheckExact(object op) + + # Getters for date and datetime (C macros). + int PyDateTime_GET_YEAR(object o) + int PyDateTime_GET_MONTH(object o) + int PyDateTime_GET_DAY(object o) + + # Getters for datetime (C macros). + int PyDateTime_DATE_GET_HOUR(object o) + int PyDateTime_DATE_GET_MINUTE(object o) + int PyDateTime_DATE_GET_SECOND(object o) + int PyDateTime_DATE_GET_MICROSECOND(object o) + + # Getters for time (C macros). + int PyDateTime_TIME_GET_HOUR(object o) + int PyDateTime_TIME_GET_MINUTE(object o) + int PyDateTime_TIME_GET_SECOND(object o) + int PyDateTime_TIME_GET_MICROSECOND(object o) + + # Getters for timedelta (C macros). + int PyDateTime_DELTA_GET_DAYS(object o) + int PyDateTime_DELTA_GET_SECONDS(object o) + int PyDateTime_DELTA_GET_MICROSECONDS(object o) + + # PyDateTime CAPI object. + PyDateTime_CAPI *PyDateTimeAPI + + void PyDateTime_IMPORT() + +# Datetime C API initialization function. +# You have to call it before any usage of DateTime CAPI functions. +cdef inline void import_datetime(): + PyDateTime_IMPORT + +# Create date object using DateTime CAPI factory function. +# Note, there are no range checks for any of the arguments. +cdef inline object date_new(int year, int month, int day): + return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType) + +# Create time object using DateTime CAPI factory function +# Note, there are no range checks for any of the arguments. +cdef inline object time_new(int hour, int minute, int second, int microsecond, object tz): + return PyDateTimeAPI.Time_FromTime(hour, minute, second, microsecond, tz, PyDateTimeAPI.TimeType) + +# Create datetime object using DateTime CAPI factory function. +# Note, there are no range checks for any of the arguments. +cdef inline object datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz): + return PyDateTimeAPI.DateTime_FromDateAndTime(year, month, day, hour, minute, second, microsecond, tz, PyDateTimeAPI.DateTimeType) + +# Create timedelta object using DateTime CAPI factory function. +# Note, there are no range checks for any of the arguments. +cdef inline object timedelta_new(int days, int seconds, int useconds): + return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType) + +# More recognizable getters for date/time/datetime/timedelta. +# There are no setters because datetime.h hasn't them. +# This is because of immutable nature of these objects by design. +# If you would change time/date/datetime/timedelta object you need to recreate. + +# Get tzinfo of time +cdef inline object time_tzinfo(object o): + if (<PyDateTime_Time*>o).hastzinfo: + return <object>(<PyDateTime_Time*>o).tzinfo + else: + return None + +# Get tzinfo of datetime +cdef inline object datetime_tzinfo(object o): + if (<PyDateTime_DateTime*>o).hastzinfo: + return <object>(<PyDateTime_DateTime*>o).tzinfo + else: + return None + +# Get year of date +cdef inline int date_year(object o): + return PyDateTime_GET_YEAR(o) + +# Get month of date +cdef inline int date_month(object o): + return PyDateTime_GET_MONTH(o) + +# Get day of date +cdef inline int date_day(object o): + return PyDateTime_GET_DAY(o) + +# Get year of datetime +cdef inline int datetime_year(object o): + return PyDateTime_GET_YEAR(o) + +# Get month of datetime +cdef inline int datetime_month(object o): + return PyDateTime_GET_MONTH(o) + +# Get day of datetime +cdef inline int datetime_day(object o): + return PyDateTime_GET_DAY(o) + +# Get hour of time +cdef inline int time_hour(object o): + return PyDateTime_TIME_GET_HOUR(o) + +# Get minute of time +cdef inline int time_minute(object o): + return PyDateTime_TIME_GET_MINUTE(o) + +# Get second of time +cdef inline int time_second(object o): + return PyDateTime_TIME_GET_SECOND(o) + +# Get microsecond of time +cdef inline int time_microsecond(object o): + return PyDateTime_TIME_GET_MICROSECOND(o) + +# Get hour of datetime +cdef inline int datetime_hour(object o): + return PyDateTime_DATE_GET_HOUR(o) + +# Get minute of datetime +cdef inline int datetime_minute(object o): + return PyDateTime_DATE_GET_MINUTE(o) + +# Get second of datetime +cdef inline int datetime_second(object o): + return PyDateTime_DATE_GET_SECOND(o) + +# Get microsecond of datetime +cdef inline int datetime_microsecond(object o): + return PyDateTime_DATE_GET_MICROSECOND(o) + +# Get days of timedelta +cdef inline int timedelta_days(object o): + return (<PyDateTime_Delta*>o).days + +# Get seconds of timedelta +cdef inline int timedelta_seconds(object o): + return (<PyDateTime_Delta*>o).seconds + +# Get microseconds of timedelta +cdef inline int timedelta_microseconds(object o): + return (<PyDateTime_Delta*>o).microseconds diff --git a/contrib/tools/cython/Cython/Includes/cpython/dict.pxd b/contrib/tools/cython/Cython/Includes/cpython/dict.pxd new file mode 100644 index 00000000000..16dd5e14581 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/dict.pxd @@ -0,0 +1,165 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ############################################################################ + # 7.4.1 Dictionary Objects + ############################################################################ + + # PyDictObject + # + # This subtype of PyObject represents a Python dictionary object + # (i.e. the 'dict' type). + + # PyTypeObject PyDict_Type + # + # This instance of PyTypeObject represents the Python dictionary + # type. This is exposed to Python programs as dict and + # types.DictType. + + bint PyDict_Check(object p) + # Return true if p is a dict object or an instance of a subtype of + # the dict type. + + bint PyDict_CheckExact(object p) + # Return true if p is a dict object, but not an instance of a + # subtype of the dict type. + + dict PyDict_New() + # Return value: New reference. + # Return a new empty dictionary, or NULL on failure. + + object PyDictProxy_New(object dict) + # Return value: New reference. + # Return a proxy object for a mapping which enforces read-only + # behavior. This is normally used to create a proxy to prevent + # modification of the dictionary for non-dynamic class types. + + void PyDict_Clear(object p) + # Empty an existing dictionary of all key-value pairs. + + int PyDict_Contains(object p, object key) except -1 + # Determine if dictionary p contains key. If an item in p is + # matches key, return 1, otherwise return 0. On error, return + # -1. This is equivalent to the Python expression "key in p". + + dict PyDict_Copy(object p) + # Return value: New reference. + # Return a new dictionary that contains the same key-value pairs as p. + + int PyDict_SetItem(object p, object key, object val) except -1 + # Insert value into the dictionary p with a key of key. key must + # be hashable; if it isn't, TypeError will be raised. Return 0 on + # success or -1 on failure. + + int PyDict_SetItemString(object p, const char *key, object val) except -1 + # Insert value into the dictionary p using key as a key. key + # should be a char*. The key object is created using + # PyString_FromString(key). Return 0 on success or -1 on failure. + + int PyDict_DelItem(object p, object key) except -1 + # Remove the entry in dictionary p with key key. key must be + # hashable; if it isn't, TypeError is raised. Return 0 on success + # or -1 on failure. + + int PyDict_DelItemString(object p, const char *key) except -1 + # Remove the entry in dictionary p which has a key specified by + # the string key. Return 0 on success or -1 on failure. + + PyObject* PyDict_GetItem(object p, object key) + # Return value: Borrowed reference. + # Return the object from dictionary p which has a key key. Return + # NULL if the key key is not present, but without setting an + # exception. + + PyObject* PyDict_GetItemString(object p, const char *key) + # Return value: Borrowed reference. + # This is the same as PyDict_GetItem(), but key is specified as a + # char*, rather than a PyObject*. + + list PyDict_Items(object p) + # Return value: New reference. + # Return a PyListObject containing all the items from the + # dictionary, as in the dictionary method items() (see the Python + # Library Reference). + + list PyDict_Keys(object p) + # Return value: New reference. + # Return a PyListObject containing all the keys from the + # dictionary, as in the dictionary method keys() (see the Python + # Library Reference). + + list PyDict_Values(object p) + # Return value: New reference. + # Return a PyListObject containing all the values from the + # dictionary p, as in the dictionary method values() (see the + # Python Library Reference). + + Py_ssize_t PyDict_Size(object p) except -1 + # Return the number of items in the dictionary. This is equivalent + # to "len(p)" on a dictionary. + + int PyDict_Next(object p, Py_ssize_t *ppos, PyObject* *pkey, PyObject* *pvalue) + # Iterate over all key-value pairs in the dictionary p. The int + # referred to by ppos must be initialized to 0 prior to the first + # call to this function to start the iteration; the function + # returns true for each pair in the dictionary, and false once all + # pairs have been reported. The parameters pkey and pvalue should + # either point to PyObject* variables that will be filled in with + # each key and value, respectively, or may be NULL. Any references + # returned through them are borrowed. ppos should not be altered + # during iteration. Its value represents offsets within the + # internal dictionary structure, and since the structure is + # sparse, the offsets are not consecutive. + # For example: + # + #object key, *value; + #int pos = 0; + # + #while (PyDict_Next(self->dict, &pos, &key, &value)) { + # /* do something interesting with the values... */ + # ... + #} + # The dictionary p should not be mutated during iteration. It is + # safe (since Python 2.1) to modify the values of the keys as you + # iterate over the dictionary, but only so long as the set of keys + # does not change. For example: + # object key, *value; + # int pos = 0; + # while (PyDict_Next(self->dict, &pos, &key, &value)) { + # int i = PyInt_AS_LONG(value) + 1; + # object o = PyInt_FromLong(i); + # if (o == NULL) + # return -1; + # if (PyDict_SetItem(self->dict, key, o) < 0) { + # Py_DECREF(o); + # return -1; + # } + # Py_DECREF(o); + # } + + int PyDict_Merge(object a, object b, int override) except -1 + # Iterate over mapping object b adding key-value pairs to + # dictionary a. b may be a dictionary, or any object supporting + # PyMapping_Keys() and PyObject_GetItem(). If override is true, + # existing pairs in a will be replaced if a matching key is found + # in b, otherwise pairs will only be added if there is not a + # matching key in a. Return 0 on success or -1 if an exception was + # raised. + + int PyDict_Update(object a, object b) except -1 + # This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b) + # in Python. Return 0 on success or -1 if an exception was raised. + + int PyDict_MergeFromSeq2(object a, object seq2, int override) except -1 + # Update or merge into dictionary a, from the key-value pairs in + # seq2. seq2 must be an iterable object producing iterable objects + # of length 2, viewed as key-value pairs. In case of duplicate + # keys, the last wins if override is true, else the first + # wins. Return 0 on success or -1 if an exception was + # raised. Equivalent Python (except for the return value): + # + #def PyDict_MergeFromSeq2(a, seq2, override): + # for key, value in seq2: + # if override or key not in a: + # a[key] = value diff --git a/contrib/tools/cython/Cython/Includes/cpython/exc.pxd b/contrib/tools/cython/Cython/Includes/cpython/exc.pxd new file mode 100644 index 00000000000..bc57c0e571b --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/exc.pxd @@ -0,0 +1,257 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ##################################################################### + # 3. Exception Handling + ##################################################################### + + # The functions described in this chapter will let you handle and + # raise Python exceptions. It is important to understand some of + # the basics of Python exception handling. It works somewhat like + # the Unix errno variable: there is a global indicator (per + # thread) of the last error that occurred. Most functions don't + # clear this on success, but will set it to indicate the cause of + # the error on failure. Most functions also return an error + # indicator, usually NULL if they are supposed to return a + # pointer, or -1 if they return an integer (exception: the + # PyArg_*() functions return 1 for success and 0 for failure). + + # When a function must fail because some function it called + # failed, it generally doesn't set the error indicator; the + # function it called already set it. It is responsible for either + # handling the error and clearing the exception or returning after + # cleaning up any resources it holds (such as object references or + # memory allocations); it should not continue normally if it is + # not prepared to handle the error. If returning due to an error, + # it is important to indicate to the caller that an error has been + # set. If the error is not handled or carefully propagated, + # additional calls into the Python/C API may not behave as + # intended and may fail in mysterious ways. + + # The error indicator consists of three Python objects + # corresponding to the Python variables sys.exc_type, + # sys.exc_value and sys.exc_traceback. API functions exist to + # interact with the error indicator in various ways. There is a + # separate error indicator for each thread. + + void PyErr_Print() + # Print a standard traceback to sys.stderr and clear the error + # indicator. Call this function only when the error indicator is + # set. (Otherwise it will cause a fatal error!) + + PyObject* PyErr_Occurred() + # Return value: Borrowed reference. + # Test whether the error indicator is set. If set, return the + # exception type (the first argument to the last call to one of + # the PyErr_Set*() functions or to PyErr_Restore()). If not set, + # return NULL. You do not own a reference to the return value, so + # you do not need to Py_DECREF() it. Note: Do not compare the + # return value to a specific exception; use + # PyErr_ExceptionMatches() instead, shown below. (The comparison + # could easily fail since the exception may be an instance instead + # of a class, in the case of a class exception, or it may be a + # subclass of the expected exception.) + + bint PyErr_ExceptionMatches(object exc) + # Equivalent to "PyErr_GivenExceptionMatches(PyErr_Occurred(), + # exc)". This should only be called when an exception is actually + # set; a memory access violation will occur if no exception has + # been raised. + + bint PyErr_GivenExceptionMatches(object given, object exc) + # Return true if the given exception matches the exception in + # exc. If exc is a class object, this also returns true when given + # is an instance of a subclass. If exc is a tuple, all exceptions + # in the tuple (and recursively in subtuples) are searched for a + # match. If given is NULL, a memory access violation will occur. + + void PyErr_NormalizeException(PyObject** exc, PyObject** val, PyObject** tb) + # Under certain circumstances, the values returned by + # PyErr_Fetch() below can be ``unnormalized'', meaning that *exc + # is a class object but *val is not an instance of the same + # class. This function can be used to instantiate the class in + # that case. If the values are already normalized, nothing + # happens. The delayed normalization is implemented to improve + # performance. + + void PyErr_Clear() + # Clear the error indicator. If the error indicator is not set, there is no effect. + + void PyErr_Fetch(PyObject** ptype, PyObject** pvalue, PyObject** ptraceback) + # Retrieve the error indicator into three variables whose + # addresses are passed. If the error indicator is not set, set all + # three variables to NULL. If it is set, it will be cleared and + # you own a reference to each object retrieved. The value and + # traceback object may be NULL even when the type object is + # not. Note: This function is normally only used by code that + # needs to handle exceptions or by code that needs to save and + # restore the error indicator temporarily. + + void PyErr_Restore(PyObject* type, PyObject* value, PyObject* traceback) + # Set the error indicator from the three objects. If the error + # indicator is already set, it is cleared first. If the objects + # are NULL, the error indicator is cleared. Do not pass a NULL + # type and non-NULL value or traceback. The exception type should + # be a class. Do not pass an invalid exception type or + # value. (Violating these rules will cause subtle problems later.) + # This call takes away a reference to each object: you must own a + # reference to each object before the call and after the call you + # no longer own these references. (If you don't understand this, + # don't use this function. I warned you.) Note: This function is + # normally only used by code that needs to save and restore the + # error indicator temporarily; use PyErr_Fetch() to save the + # current exception state. + + void PyErr_SetString(object type, char *message) + # This is the most common way to set the error indicator. The + # first argument specifies the exception type; it is normally one + # of the standard exceptions, e.g. PyExc_RuntimeError. You need + # not increment its reference count. The second argument is an + # error message; it is converted to a string object. + + void PyErr_SetObject(object type, object value) + # This function is similar to PyErr_SetString() but lets you + # specify an arbitrary Python object for the ``value'' of the + # exception. + + PyObject* PyErr_Format(object exception, char *format, ...) except NULL + # Return value: Always NULL. + # This function sets the error indicator and returns + # NULL. exception should be a Python exception (class, not an + # instance). format should be a string, containing format codes, + # similar to printf(). The width.precision before a format code is + # parsed, but the width part is ignored. + + void PyErr_SetNone(object type) + # This is a shorthand for "PyErr_SetObject(type, Py_None)". + + int PyErr_BadArgument() except 0 + + # This is a shorthand for "PyErr_SetString(PyExc_TypeError, + # message)", where message indicates that a built-in operation was + # invoked with an illegal argument. It is mostly for internal use. + + PyObject* PyErr_NoMemory() except NULL + # Return value: Always NULL. + # This is a shorthand for "PyErr_SetNone(PyExc_MemoryError)"; it + # returns NULL so an object allocation function can write "return + # PyErr_NoMemory();" when it runs out of memory. + + PyObject* PyErr_SetFromErrno(object type) except NULL + # Return value: Always NULL. + # This is a convenience function to raise an exception when a C + # library function has returned an error and set the C variable + # errno. It constructs a tuple object whose first item is the + # integer errno value and whose second item is the corresponding + # error message (gotten from strerror()), and then calls + # "PyErr_SetObject(type, object)". On Unix, when the errno value + # is EINTR, indicating an interrupted system call, this calls + # PyErr_CheckSignals(), and if that set the error indicator, + # leaves it set to that. The function always returns NULL, so a + # wrapper function around a system call can write "return + # PyErr_SetFromErrno(type);" when the system call returns an + # error. + + PyObject* PyErr_SetFromErrnoWithFilenameObject(object type, object filenameObject) except NULL + # Similar to PyErr_SetFromErrno(), with the additional behavior + # that if filenameObject is not NULL, it is passed to the + # constructor of type as a third parameter. + # In the case of OSError exception, this is used to define + # the filename attribute of the exception instance. + + PyObject* PyErr_SetFromErrnoWithFilename(object type, char *filename) except NULL + # Return value: Always NULL. Similar to PyErr_SetFromErrno(), + # with the additional behavior that if filename is not NULL, it is + # passed to the constructor of type as a third parameter. In the + # case of exceptions such as IOError and OSError, this is used to + # define the filename attribute of the exception instance. + + PyObject* PyErr_SetFromWindowsErr(int ierr) except NULL + # Return value: Always NULL. This is a convenience function to + # raise WindowsError. If called with ierr of 0, the error code + # returned by a call to GetLastError() is used instead. It calls + # the Win32 function FormatMessage() to retrieve the Windows + # description of error code given by ierr or GetLastError(), then + # it constructs a tuple object whose first item is the ierr value + # and whose second item is the corresponding error message (gotten + # from FormatMessage()), and then calls + # "PyErr_SetObject(PyExc_WindowsError, object)". This function + # always returns NULL. Availability: Windows. + + PyObject* PyErr_SetExcFromWindowsErr(object type, int ierr) except NULL + # Return value: Always NULL. Similar to + # PyErr_SetFromWindowsErr(), with an additional parameter + # specifying the exception type to be raised. Availability: + # Windows. New in version 2.3. + + PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, char *filename) except NULL + # Return value: Always NULL. Similar to + # PyErr_SetFromWindowsErr(), with the additional behavior that if + # filename is not NULL, it is passed to the constructor of + # WindowsError as a third parameter. Availability: Windows. + + PyObject* PyErr_SetExcFromWindowsErrWithFilename(object type, int ierr, char *filename) except NULL + # Return value: Always NULL. + # Similar to PyErr_SetFromWindowsErrWithFilename(), with an + # additional parameter specifying the exception type to be + # raised. Availability: Windows. + + void PyErr_BadInternalCall() + # This is a shorthand for "PyErr_SetString(PyExc_TypeError, + # message)", where message indicates that an internal operation + # (e.g. a Python/C API function) was invoked with an illegal + # argument. It is mostly for internal use. + + int PyErr_WarnEx(object category, char *message, int stacklevel) except -1 + # Issue a warning message. The category argument is a warning + # category (see below) or NULL; the message argument is a message + # string. stacklevel is a positive number giving a number of stack + # frames; the warning will be issued from the currently executing + # line of code in that stack frame. A stacklevel of 1 is the + # function calling PyErr_WarnEx(), 2 is the function above that, + # and so forth. + + int PyErr_WarnExplicit(object category, char *message, char *filename, int lineno, char *module, object registry) except -1 + # Issue a warning message with explicit control over all warning + # attributes. This is a straightforward wrapper around the Python + # function warnings.warn_explicit(), see there for more + # information. The module and registry arguments may be set to + # NULL to get the default effect described there. + + int PyErr_CheckSignals() except -1 + # This function interacts with Python's signal handling. It checks + # whether a signal has been sent to the processes and if so, + # invokes the corresponding signal handler. If the signal module + # is supported, this can invoke a signal handler written in + # Python. In all cases, the default effect for SIGINT is to raise + # the KeyboardInterrupt exception. If an exception is raised the + # error indicator is set and the function returns 1; otherwise the + # function returns 0. The error indicator may or may not be + # cleared if it was previously set. + + void PyErr_SetInterrupt() nogil + # This function simulates the effect of a SIGINT signal arriving + # -- the next time PyErr_CheckSignals() is called, + # KeyboardInterrupt will be raised. It may be called without + # holding the interpreter lock. + + object PyErr_NewException(char *name, object base, object dict) + # Return value: New reference. + # This utility function creates and returns a new exception + # object. The name argument must be the name of the new exception, + # a C string of the form module.class. The base and dict arguments + # are normally NULL. This creates a class object derived from + # Exception (accessible in C as PyExc_Exception). + + void PyErr_WriteUnraisable(object obj) + # This utility function prints a warning message to sys.stderr + # when an exception has been set but it is impossible for the + # interpreter to actually raise the exception. It is used, for + # example, when an exception occurs in an __del__() method. + # + # The function is called with a single argument obj that + # identifies the context in which the unraisable exception + # occurred. The repr of obj will be printed in the warning + # message. + diff --git a/contrib/tools/cython/Cython/Includes/cpython/float.pxd b/contrib/tools/cython/Cython/Includes/cpython/float.pxd new file mode 100644 index 00000000000..65328f31ea4 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/float.pxd @@ -0,0 +1,39 @@ +cdef extern from "Python.h": + + ############################################################################ + # 7.2.3 + ############################################################################ + # PyFloatObject + # + # This subtype of PyObject represents a Python floating point object. + + # PyTypeObject PyFloat_Type + # + # This instance of PyTypeObject represents the Python floating + # point type. This is the same object as float and + # types.FloatType. + + bint PyFloat_Check(object p) + # Return true if its argument is a PyFloatObject or a subtype of + # PyFloatObject. + + bint PyFloat_CheckExact(object p) + # Return true if its argument is a PyFloatObject, but not a + # subtype of PyFloatObject. + + object PyFloat_FromString(object str, char **pend) + # Return value: New reference. + # Create a PyFloatObject object based on the string value in str, + # or NULL on failure. The pend argument is ignored. It remains + # only for backward compatibility. + + object PyFloat_FromDouble(double v) + # Return value: New reference. + # Create a PyFloatObject object from v, or NULL on failure. + + double PyFloat_AsDouble(object pyfloat) except? -1 + # Return a C double representation of the contents of pyfloat. + + double PyFloat_AS_DOUBLE(object pyfloat) + # Return a C double representation of the contents of pyfloat, but + # without error checking. diff --git a/contrib/tools/cython/Cython/Includes/cpython/function.pxd b/contrib/tools/cython/Cython/Includes/cpython/function.pxd new file mode 100644 index 00000000000..0002a3f6cbc --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/function.pxd @@ -0,0 +1,65 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ############################################################################ + # 7.5.3 Function Objects + ############################################################################ + # There are a few functions specific to Python functions. + + # PyFunctionObject + # + # The C structure used for functions. + + # PyTypeObject PyFunction_Type + # + # This is an instance of PyTypeObject and represents the Python + # function type. It is exposed to Python programmers as + # types.FunctionType. + + bint PyFunction_Check(object o) + # Return true if o is a function object (has type + # PyFunction_Type). The parameter must not be NULL. + + object PyFunction_New(object code, object globals) + # Return value: New reference. + # Return a new function object associated with the code object + # code. globals must be a dictionary with the global variables + # accessible to the function. + # The function's docstring, name and __module__ are retrieved from + # the code object, the argument defaults and closure are set to + # NULL. + + PyObject* PyFunction_GetCode(object op) except? NULL + # Return value: Borrowed reference. + # Return the code object associated with the function object op. + + PyObject* PyFunction_GetGlobals(object op) except? NULL + # Return value: Borrowed reference. + # Return the globals dictionary associated with the function object op. + + PyObject* PyFunction_GetModule(object op) except? NULL + # Return value: Borrowed reference. + # Return the __module__ attribute of the function object op. This + # is normally a string containing the module name, but can be set + # to any other object by Python code. + + PyObject* PyFunction_GetDefaults(object op) except? NULL + # Return value: Borrowed reference. + # Return the argument default values of the function object + # op. This can be a tuple of arguments or NULL. + + int PyFunction_SetDefaults(object op, object defaults) except -1 + # Set the argument default values for the function object + # op. defaults must be Py_None or a tuple. + # Raises SystemError and returns -1 on failure. + + PyObject* PyFunction_GetClosure(object op) except? NULL + # Return value: Borrowed reference. + # Return the closure associated with the function object op. This + # can be NULL or a tuple of cell objects. + + int PyFunction_SetClosure(object op, object closure) except -1 + # Set the closure associated with the function object op. closure + # must be Py_None or a tuple of cell objects. + # Raises SystemError and returns -1 on failure. diff --git a/contrib/tools/cython/Cython/Includes/cpython/genobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/genobject.pxd new file mode 100644 index 00000000000..337b3cc0adc --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/genobject.pxd @@ -0,0 +1,25 @@ +from .pystate cimport PyFrameObject + +cdef extern from "Python.h": + + ########################################################################### + # Generator Objects + ########################################################################### + + bint PyGen_Check(object ob) + # Return true if ob is a generator object; ob must not be NULL. + + bint PyGen_CheckExact(object ob) + # Return true if ob's type is PyGen_Type; ob must not be NULL. + + object PyGen_New(PyFrameObject *frame) + # Return value: New reference. + # Create and return a new generator object based on the frame object. A + # reference to frame is stolen by this function. The argument must not be + # NULL. + + object PyGen_NewWithQualName(PyFrameObject *frame, object name, object qualname) + # Return value: New reference. + # Create and return a new generator object based on the frame object, with + # __name__ and __qualname__ set to name and qualname. A reference to frame + # is stolen by this function. The frame argument must not be NULL. diff --git a/contrib/tools/cython/Cython/Includes/cpython/getargs.pxd b/contrib/tools/cython/Cython/Includes/cpython/getargs.pxd new file mode 100644 index 00000000000..be6df3285a7 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/getargs.pxd @@ -0,0 +1,12 @@ + +cdef extern from "Python.h": + ##################################################################### + # 5.5 Parsing arguments and building values + ##################################################################### + ctypedef struct va_list + int PyArg_ParseTuple(object args, char *format, ...) except 0 + int PyArg_VaParse(object args, char *format, va_list vargs) except 0 + int PyArg_ParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], ...) except 0 + int PyArg_VaParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], va_list vargs) except 0 + int PyArg_Parse(object args, char *format, ...) except 0 + int PyArg_UnpackTuple(object args, char *name, Py_ssize_t min, Py_ssize_t max, ...) except 0 diff --git a/contrib/tools/cython/Cython/Includes/cpython/instance.pxd b/contrib/tools/cython/Cython/Includes/cpython/instance.pxd new file mode 100644 index 00000000000..aecdc0cfd76 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/instance.pxd @@ -0,0 +1,25 @@ +cdef extern from "Python.h": + + ############################################################################ + # 7.5.2 Instance Objects + ############################################################################ + + # PyTypeObject PyInstance_Type + # + # Type object for class instances. + + int PyInstance_Check(object obj) + # Return true if obj is an instance. + + object PyInstance_New(object cls, object arg, object kw) + # Return value: New reference. + # Create a new instance of a specific class. The parameters arg + # and kw are used as the positional and keyword parameters to the + # object's constructor. + + object PyInstance_NewRaw(object cls, object dict) + # Return value: New reference. + # Create a new instance of a specific class without calling its + # constructor. class is the class of new object. The dict + # parameter will be used as the object's __dict__; if NULL, a new + # dictionary will be created for the instance. diff --git a/contrib/tools/cython/Cython/Includes/cpython/int.pxd b/contrib/tools/cython/Cython/Includes/cpython/int.pxd new file mode 100644 index 00000000000..50babff6151 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/int.pxd @@ -0,0 +1,89 @@ +cdef extern from "Python.h": + ctypedef unsigned long long PY_LONG_LONG + + ############################################################################ + # Integer Objects + ############################################################################ + # PyTypeObject PyInt_Type + # This instance of PyTypeObject represents the Python plain + # integer type. This is the same object as int and types.IntType. + + bint PyInt_Check(object o) + # Return true if o is of type PyInt_Type or a subtype of + # PyInt_Type. + + bint PyInt_CheckExact(object o) + # Return true if o is of type PyInt_Type, but not a subtype of + # PyInt_Type. + + object PyInt_FromString(char *str, char **pend, int base) + # Return value: New reference. + # Return a new PyIntObject or PyLongObject based on the string + # value in str, which is interpreted according to the radix in + # base. If pend is non-NULL, *pend will point to the first + # character in str which follows the representation of the + # number. If base is 0, the radix will be determined based on the + # leading characters of str: if str starts with '0x' or '0X', + # radix 16 will be used; if str starts with '0', radix 8 will be + # used; otherwise radix 10 will be used. If base is not 0, it must + # be between 2 and 36, inclusive. Leading spaces are ignored. If + # there are no digits, ValueError will be raised. If the string + # represents a number too large to be contained within the + # machine's long int type and overflow warnings are being + # suppressed, a PyLongObject will be returned. If overflow + # warnings are not being suppressed, NULL will be returned in this + # case. + + object PyInt_FromLong(long ival) + # Return value: New reference. + # Create a new integer object with a value of ival. + # The current implementation keeps an array of integer objects for + # all integers between -5 and 256, when you create an int in that + # range you actually just get back a reference to the existing + # object. So it should be possible to change the value of 1. I + # suspect the behaviour of Python in this case is undefined. :-) + + object PyInt_FromSsize_t(Py_ssize_t ival) + # Return value: New reference. + # Create a new integer object with a value of ival. If the value + # is larger than LONG_MAX or smaller than LONG_MIN, a long integer + # object is returned. + + object PyInt_FromSize_t(size_t ival) + # Return value: New reference. + # Create a new integer object with a value of ival. If the value + # exceeds LONG_MAX, a long integer object is returned. + + long PyInt_AsLong(object io) except? -1 + # Will first attempt to cast the object to a PyIntObject, if it is + # not already one, and then return its value. If there is an + # error, -1 is returned, and the caller should check + # PyErr_Occurred() to find out whether there was an error, or + # whether the value just happened to be -1. + + long PyInt_AS_LONG(object io) + # Return the value of the object io. No error checking is performed. + + unsigned long PyInt_AsUnsignedLongMask(object io) except? -1 + # Will first attempt to cast the object to a PyIntObject or + # PyLongObject, if it is not already one, and then return its + # value as unsigned long. This function does not check for + # overflow. + + PY_LONG_LONG PyInt_AsUnsignedLongLongMask(object io) except? -1 + # Will first attempt to cast the object to a PyIntObject or + # PyLongObject, if it is not already one, and then return its + # value as unsigned long long, without checking for overflow. + + Py_ssize_t PyInt_AsSsize_t(object io) except? -1 + # Will first attempt to cast the object to a PyIntObject or + # PyLongObject, if it is not already one, and then return its + # value as Py_ssize_t. + + long PyInt_GetMax() + # Return the system's idea of the largest integer it can handle + # (LONG_MAX, as defined in the system header files). + + int PyInt_ClearFreeList() + # Clear the integer free list. Return the number of items that could not be freed. + # New in version 2.6. diff --git a/contrib/tools/cython/Cython/Includes/cpython/iterator.pxd b/contrib/tools/cython/Cython/Includes/cpython/iterator.pxd new file mode 100644 index 00000000000..0e10907f7f1 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/iterator.pxd @@ -0,0 +1,36 @@ +cdef extern from "Python.h": + + ############################################################################ + # 6.5 Iterator Protocol + ############################################################################ + bint PyIter_Check(object o) + # Return true if the object o supports the iterator protocol. + + object PyIter_Next(object o) + # Return value: New reference. + # Return the next value from the iteration o. If the object is an + # iterator, this retrieves the next value from the iteration, and + # returns NULL with no exception set if there are no remaining + # items. If the object is not an iterator, TypeError is raised, or + # if there is an error in retrieving the item, returns NULL and + # passes along the exception. + + # To write a loop which iterates over an iterator, the C code should look something like this: + # PyObject *iterator = PyObject_GetIter(obj); + # PyObject *item; + # if (iterator == NULL) { + # /* propagate error */ + # } + # while (item = PyIter_Next(iterator)) { + # /* do something with item */ + # ... + # /* release reference when done */ + # Py_DECREF(item); + # } + # Py_DECREF(iterator); + # if (PyErr_Occurred()) { + # /* propagate error */ + # } + # else { + # /* continue doing useful work */ + # } diff --git a/contrib/tools/cython/Cython/Includes/cpython/iterobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/iterobject.pxd new file mode 100644 index 00000000000..a70aeccb097 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/iterobject.pxd @@ -0,0 +1,24 @@ +cdef extern from "Python.h": + + ########################################################################### + # Iterator Objects + ########################################################################### + + bint PySeqIter_Check(object op) + # Return true if the type of op is PySeqIter_Type. + + object PySeqIter_New(object seq) + # Return value: New reference. + # Return an iterator that works with a general sequence object, seq. The + # iteration ends when the sequence raises IndexError for the subscripting + # operation. + + bint PyCallIter_Check(object op) + # Return true if the type of op is PyCallIter_Type. + + object PyCallIter_New(object callable, object sentinel) + # Return value: New reference. + # Return a new iterator. The first parameter, callable, can be any Python + # callable object that can be called with no parameters; each call to it + # should return the next item in the iteration. When callable returns a + # value equal to sentinel, the iteration will be terminated. diff --git a/contrib/tools/cython/Cython/Includes/cpython/list.pxd b/contrib/tools/cython/Cython/Includes/cpython/list.pxd new file mode 100644 index 00000000000..c6a29535c9a --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/list.pxd @@ -0,0 +1,92 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ############################################################################ + # Lists + ############################################################################ + list PyList_New(Py_ssize_t len) + # Return a new list of length len on success, or NULL on failure. + # + # Note: If length is greater than zero, the returned list object's + # items are set to NULL. Thus you cannot use abstract API + # functions such as PySequence_SetItem() or expose the object to + # Python code before setting all items to a real object with + # PyList_SetItem(). + + bint PyList_Check(object p) + # Return true if p is a list object or an instance of a subtype of + # the list type. + + bint PyList_CheckExact(object p) + # Return true if p is a list object, but not an instance of a + # subtype of the list type. + + Py_ssize_t PyList_Size(object list) except -1 + # Return the length of the list object in list; this is equivalent + # to "len(list)" on a list object. + + Py_ssize_t PyList_GET_SIZE(object list) + # Macro form of PyList_Size() without error checking. + + PyObject* PyList_GetItem(object list, Py_ssize_t index) except NULL + # Return value: Borrowed reference. + # Return the object at position pos in the list pointed to by + # p. The position must be positive, indexing from the end of the + # list is not supported. If pos is out of bounds, return NULL and + # set an IndexError exception. + + PyObject* PyList_GET_ITEM(object list, Py_ssize_t i) + # Return value: Borrowed reference. + # Macro form of PyList_GetItem() without error checking. + + int PyList_SetItem(object list, Py_ssize_t index, object item) except -1 + # Set the item at index index in list to item. Return 0 on success + # or -1 on failure. Note: This function ``steals'' a reference to + # item and discards a reference to an item already in the list at + # the affected position. + + void PyList_SET_ITEM(object list, Py_ssize_t i, object o) + # Macro form of PyList_SetItem() without error checking. This is + # normally only used to fill in new lists where there is no + # previous content. Note: This function ``steals'' a reference to + # item, and, unlike PyList_SetItem(), does not discard a reference + # to any item that it being replaced; any reference in list at + # position i will be *leaked*. + + int PyList_Insert(object list, Py_ssize_t index, object item) except -1 + # Insert the item item into list list in front of index + # index. Return 0 if successful; return -1 and set an exception if + # unsuccessful. Analogous to list.insert(index, item). + + int PyList_Append(object list, object item) except -1 + # Append the object item at the end of list list. Return 0 if + # successful; return -1 and set an exception if + # unsuccessful. Analogous to list.append(item). + + list PyList_GetSlice(object list, Py_ssize_t low, Py_ssize_t high) + # Return value: New reference. + # Return a list of the objects in list containing the objects + # between low and high. Return NULL and set an exception if + # unsuccessful. Analogous to list[low:high]. + + int PyList_SetSlice(object list, Py_ssize_t low, Py_ssize_t high, object itemlist) except -1 + # Set the slice of list between low and high to the contents of + # itemlist. Analogous to list[low:high] = itemlist. The itemlist + # may be NULL, indicating the assignment of an empty list (slice + # deletion). Return 0 on success, -1 on failure. + + int PyList_Sort(object list) except -1 + # Sort the items of list in place. Return 0 on success, -1 on + # failure. This is equivalent to "list.sort()". + + int PyList_Reverse(object list) except -1 + # Reverse the items of list in place. Return 0 on success, -1 on + # failure. This is the equivalent of "list.reverse()". + + tuple PyList_AsTuple(object list) + # Return value: New reference. + # Return a new tuple object containing the contents of list; + # equivalent to "tuple(list)". + + diff --git a/contrib/tools/cython/Cython/Includes/cpython/long.pxd b/contrib/tools/cython/Cython/Includes/cpython/long.pxd new file mode 100644 index 00000000000..eb8140d417a --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/long.pxd @@ -0,0 +1,149 @@ + +cdef extern from "Python.h": + ctypedef long long PY_LONG_LONG + ctypedef unsigned long long uPY_LONG_LONG "unsigned PY_LONG_LONG" + + ############################################################################ + # 7.2.3 Long Integer Objects + ############################################################################ + + # PyLongObject + # + # This subtype of PyObject represents a Python long integer object. + + # PyTypeObject PyLong_Type + # + # This instance of PyTypeObject represents the Python long integer + # type. This is the same object as long and types.LongType. + + bint PyLong_Check(object p) + # Return true if its argument is a PyLongObject or a subtype of PyLongObject. + + bint PyLong_CheckExact(object p) + # Return true if its argument is a PyLongObject, but not a subtype of PyLongObject. + + object PyLong_FromLong(long v) + # Return value: New reference. + # Return a new PyLongObject object from v, or NULL on failure. + + object PyLong_FromUnsignedLong(unsigned long v) + # Return value: New reference. + # Return a new PyLongObject object from a C unsigned long, or NULL on failure. + + object PyLong_FromSsize_t(Py_ssize_t v) + # Return value: New reference. + # Return a new PyLongObject object from a C Py_ssize_t, or NULL on failure.) + + object PyLong_FromSize_t(size_t v) + # Return value: New reference. + # Return a new PyLongObject object from a C size_t, or NULL on failure. + + object PyLong_FromLongLong(PY_LONG_LONG v) + # Return value: New reference. + # Return a new PyLongObject object from a C long long, or NULL on failure. + + object PyLong_FromUnsignedLongLong(uPY_LONG_LONG v) + # Return value: New reference. + # Return a new PyLongObject object from a C unsigned long long, or NULL on failure. + + object PyLong_FromDouble(double v) + # Return value: New reference. + # Return a new PyLongObject object from the integer part of v, or NULL on failure. + + object PyLong_FromString(char *str, char **pend, int base) + # Return value: New reference. + # Return a new PyLongObject based on the string value in str, + # which is interpreted according to the radix in base. If pend is + # non-NULL, *pend will point to the first character in str which + # follows the representation of the number. If base is 0, the + # radix will be determined based on the leading characters of str: + # if str starts with '0x' or '0X', radix 16 will be used; if str + # starts with '0', radix 8 will be used; otherwise radix 10 will + # be used. If base is not 0, it must be between 2 and 36, + # inclusive. Leading spaces are ignored. If there are no digits, + # ValueError will be raised. + + object PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) + # Return value: New reference. + # Convert a sequence of Unicode digits to a Python long integer + # value. The first parameter, u, points to the first character of + # the Unicode string, length gives the number of characters, and + # base is the radix for the conversion. The radix must be in the + # range [2, 36]; if it is out of range, ValueError will be + # raised. + + # object PyLong_FromUnicodeObject(object u, int base) + # Convert a sequence of Unicode digits in the string u to a Python integer + # value. The Unicode string is first encoded to a byte string using + # PyUnicode_EncodeDecimal() and then converted using PyLong_FromString(). + # New in version 3.3. + + object PyLong_FromVoidPtr(void *p) + # Return value: New reference. + # Create a Python integer or long integer from the pointer p. The + # pointer value can be retrieved from the resulting value using + # PyLong_AsVoidPtr(). If the integer is larger than LONG_MAX, a + # positive long integer is returned. + + long PyLong_AsLong(object pylong) except? -1 + # Return a C long representation of the contents of pylong. If + # pylong is greater than LONG_MAX, an OverflowError is raised. + + # long PyLong_AsLongAndOverflow(object pylong, int *overflow) except? -1 + # Return a C long representation of the contents of pylong. If pylong is + # greater than LONG_MAX or less than LONG_MIN, set *overflow to 1 or -1, + # respectively, and return -1; otherwise, set *overflow to 0. If any other + # exception occurs (for example a TypeError or MemoryError), then -1 will + # be returned and *overflow will be 0. + # New in version 2.7. + + # PY_LONG_LONG PyLong_AsLongLongAndOverflow(object pylong, int *overflow) except? -1 + # Return a C long long representation of the contents of pylong. If pylong + # is greater than PY_LLONG_MAX or less than PY_LLONG_MIN, set *overflow to + # 1 or -1, respectively, and return -1; otherwise, set *overflow to 0. If + # any other exception occurs (for example a TypeError or MemoryError), then + # -1 will be returned and *overflow will be 0. + # New in version 2.7. + + Py_ssize_t PyLong_AsSsize_t(object pylong) except? -1 + # Return a C Py_ssize_t representation of the contents of pylong. If pylong + # is greater than PY_SSIZE_T_MAX, an OverflowError is raised and -1 will be + # returned. + + unsigned long PyLong_AsUnsignedLong(object pylong) except? -1 + # Return a C unsigned long representation of the contents of + # pylong. If pylong is greater than ULONG_MAX, an OverflowError is + # raised. + + PY_LONG_LONG PyLong_AsLongLong(object pylong) except? -1 + # Return a C long long from a Python long integer. If pylong + # cannot be represented as a long long, an OverflowError will be + # raised. + + uPY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) except? -1 + #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) + # Return a C unsigned long long from a Python long integer. If + # pylong cannot be represented as an unsigned long long, an + # OverflowError will be raised if the value is positive, or a + # TypeError will be raised if the value is negative. + + unsigned long PyLong_AsUnsignedLongMask(object io) except? -1 + # Return a C unsigned long from a Python long integer, without + # checking for overflow. + + uPY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) except? -1 + #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) + # Return a C unsigned long long from a Python long integer, + # without checking for overflow. + + double PyLong_AsDouble(object pylong) except? -1.0 + # Return a C double representation of the contents of pylong. If + # pylong cannot be approximately represented as a double, an + # OverflowError exception is raised and -1.0 will be returned. + + void* PyLong_AsVoidPtr(object pylong) except? NULL + # Convert a Python integer or long integer pylong to a C void + # pointer. If pylong cannot be converted, an OverflowError will be + # raised. This is only assured to produce a usable void pointer + # for values created with PyLong_FromVoidPtr(). For values outside + # 0..LONG_MAX, both signed and unsigned integers are accepted. diff --git a/contrib/tools/cython/Cython/Includes/cpython/longintrepr.pxd b/contrib/tools/cython/Cython/Includes/cpython/longintrepr.pxd new file mode 100644 index 00000000000..c38c1bff88f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/longintrepr.pxd @@ -0,0 +1,19 @@ +# Internals of the "long" type (Python 2) or "int" type (Python 3). + +cdef extern from "Python.h": + """ + #if PY_MAJOR_VERSION < 3 + #include "longintrepr.h" + #endif + """ + ctypedef unsigned int digit + ctypedef int sdigit # Python >= 2.7 only + + ctypedef class __builtin__.py_long [object PyLongObject]: + cdef digit* ob_digit + + cdef py_long _PyLong_New(Py_ssize_t s) + + cdef long PyLong_SHIFT + cdef digit PyLong_BASE + cdef digit PyLong_MASK diff --git a/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd b/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd new file mode 100644 index 00000000000..3d235b65e20 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd @@ -0,0 +1,64 @@ +cdef extern from "Python.h": + + ############################################################################ + # 6.4 Mapping Protocol + ############################################################################ + + bint PyMapping_Check(object o) + # Return 1 if the object provides mapping protocol, and 0 + # otherwise. This function always succeeds. + + Py_ssize_t PyMapping_Length(object o) except -1 + # Returns the number of keys in object o on success, and -1 on + # failure. For objects that do not provide mapping protocol, this + # is equivalent to the Python expression "len(o)". + + int PyMapping_DelItemString(object o, char *key) except -1 + # Remove the mapping for object key from the object o. Return -1 + # on failure. This is equivalent to the Python statement "del + # o[key]". + + int PyMapping_DelItem(object o, object key) except -1 + # Remove the mapping for object key from the object o. Return -1 + # on failure. This is equivalent to the Python statement "del + # o[key]". + + bint PyMapping_HasKeyString(object o, char *key) + # On success, return 1 if the mapping object has the key key and 0 + # otherwise. This is equivalent to the Python expression + # "o.has_key(key)". This function always succeeds. + + bint PyMapping_HasKey(object o, object key) + # Return 1 if the mapping object has the key key and 0 + # otherwise. This is equivalent to the Python expression + # "o.has_key(key)". This function always succeeds. + + object PyMapping_Keys(object o) + # Return value: New reference. + # On success, return a list of the keys in object o. On failure, + # return NULL. This is equivalent to the Python expression + # "o.keys()". + + object PyMapping_Values(object o) + # Return value: New reference. + # On success, return a list of the values in object o. On failure, + # return NULL. This is equivalent to the Python expression + # "o.values()". + + object PyMapping_Items(object o) + # Return value: New reference. + # On success, return a list of the items in object o, where each + # item is a tuple containing a key-value pair. On failure, return + # NULL. This is equivalent to the Python expression "o.items()". + + object PyMapping_GetItemString(object o, char *key) + # Return value: New reference. + # Return element of o corresponding to the object key or NULL on + # failure. This is the equivalent of the Python expression + # "o[key]". + + int PyMapping_SetItemString(object o, char *key, object v) except -1 + # Map the object key to the value v in object o. Returns -1 on + # failure. This is the equivalent of the Python statement "o[key] + # = v". + diff --git a/contrib/tools/cython/Cython/Includes/cpython/mem.pxd b/contrib/tools/cython/Cython/Includes/cpython/mem.pxd new file mode 100644 index 00000000000..af820f2ee01 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/mem.pxd @@ -0,0 +1,111 @@ +cdef extern from "Python.h": + + ##################################################################### + # 9.2 Memory Interface + ##################################################################### + # You are definitely *supposed* to use these: "In most situations, + # however, it is recommended to allocate memory from the Python + # heap specifically because the latter is under control of the + # Python memory manager. For example, this is required when the + # interpreter is extended with new object types written in + # C. Another reason for using the Python heap is the desire to + # inform the Python memory manager about the memory needs of the + # extension module. Even when the requested memory is used + # exclusively for internal, highly-specific purposes, delegating + # all memory requests to the Python memory manager causes the + # interpreter to have a more accurate image of its memory + # footprint as a whole. Consequently, under certain circumstances, + # the Python memory manager may or may not trigger appropriate + # actions, like garbage collection, memory compaction or other + # preventive procedures. Note that by using the C library + # allocator as shown in the previous example, the allocated memory + # for the I/O buffer escapes completely the Python memory + # manager." + + # The following function sets, modeled after the ANSI C standard, + # but specifying behavior when requesting zero bytes, are + # available for allocating and releasing memory from the Python + # heap: + + void* PyMem_RawMalloc(size_t n) nogil + void* PyMem_Malloc(size_t n) + # Allocates n bytes and returns a pointer of type void* to the + # allocated memory, or NULL if the request fails. Requesting zero + # bytes returns a distinct non-NULL pointer if possible, as if + # PyMem_Malloc(1) had been called instead. The memory will not + # have been initialized in any way. + + void* PyMem_RawRealloc(void *p, size_t n) nogil + void* PyMem_Realloc(void *p, size_t n) + # Resizes the memory block pointed to by p to n bytes. The + # contents will be unchanged to the minimum of the old and the new + # sizes. If p is NULL, the call is equivalent to PyMem_Malloc(n); + # else if n is equal to zero, the memory block is resized but is + # not freed, and the returned pointer is non-NULL. Unless p is + # NULL, it must have been returned by a previous call to + # PyMem_Malloc() or PyMem_Realloc(). + + void PyMem_RawFree(void *p) nogil + void PyMem_Free(void *p) + # Frees the memory block pointed to by p, which must have been + # returned by a previous call to PyMem_Malloc() or + # PyMem_Realloc(). Otherwise, or if PyMem_Free(p) has been called + # before, undefined behavior occurs. If p is NULL, no operation is + # performed. + + # The following type-oriented macros are provided for + # convenience. Note that TYPE refers to any C type. + + # TYPE* PyMem_New(TYPE, size_t n) + # Same as PyMem_Malloc(), but allocates (n * sizeof(TYPE)) bytes + # of memory. Returns a pointer cast to TYPE*. The memory will not + # have been initialized in any way. + + # TYPE* PyMem_Resize(void *p, TYPE, size_t n) + # Same as PyMem_Realloc(), but the memory block is resized to (n * + # sizeof(TYPE)) bytes. Returns a pointer cast to TYPE*. + + void PyMem_Del(void *p) + # Same as PyMem_Free(). + + # In addition, the following macro sets are provided for calling + # the Python memory allocator directly, without involving the C + # API functions listed above. However, note that their use does + # not preserve binary compatibility across Python versions and is + # therefore deprecated in extension modules. + + # PyMem_MALLOC(), PyMem_REALLOC(), PyMem_FREE(). + # PyMem_NEW(), PyMem_RESIZE(), PyMem_DEL(). + + + ##################################################################### + # Raw object memory interface + ##################################################################### + + # Functions to call the same malloc/realloc/free as used by Python's + # object allocator. If WITH_PYMALLOC is enabled, these may differ from + # the platform malloc/realloc/free. The Python object allocator is + # designed for fast, cache-conscious allocation of many "small" objects, + # and with low hidden memory overhead. + # + # PyObject_Malloc(0) returns a unique non-NULL pointer if possible. + # + # PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n). + # PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory + # at p. + # + # Returned pointers must be checked for NULL explicitly; no action is + # performed on failure other than to return NULL (no warning it printed, no + # exception is set, etc). + # + # For allocating objects, use PyObject_{New, NewVar} instead whenever + # possible. The PyObject_{Malloc, Realloc, Free} family is exposed + # so that you can exploit Python's small-block allocator for non-object + # uses. If you must use these routines to allocate object memory, make sure + # the object gets initialized via PyObject_{Init, InitVar} after obtaining + # the raw memory. + + void* PyObject_Malloc(size_t size) + void* PyObject_Calloc(size_t nelem, size_t elsize) + void* PyObject_Realloc(void *ptr, size_t new_size) + void PyObject_Free(void *ptr) diff --git a/contrib/tools/cython/Cython/Includes/cpython/memoryview.pxd b/contrib/tools/cython/Cython/Includes/cpython/memoryview.pxd new file mode 100644 index 00000000000..83a84e6f911 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/memoryview.pxd @@ -0,0 +1,50 @@ +cdef extern from "Python.h": + + ########################################################################### + # MemoryView Objects + ########################################################################### + # A memoryview object exposes the C level buffer interface as a Python + # object which can then be passed around like any other object + + object PyMemoryView_FromObject(object obj) + # Return value: New reference. + # Create a memoryview object from an object that provides the buffer + # interface. If obj supports writable buffer exports, the memoryview object + # will be read/write, otherwise it may be either read-only or read/write at + # the discretion of the exporter. + + object PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags) + # Return value: New reference. + # Create a memoryview object using mem as the underlying buffer. flags can + # be one of PyBUF_READ or PyBUF_WRITE. + # New in version 3.3. + + object PyMemoryView_FromBuffer(Py_buffer *view) + # Return value: New reference. + # Create a memoryview object wrapping the given buffer structure view. For + # simple byte buffers, PyMemoryView_FromMemory() is the preferred function. + + object PyMemoryView_GetContiguous(object obj, + int buffertype, + char order) + # Return value: New reference. + # Create a memoryview object to a contiguous chunk of memory (in either ‘C’ + # or ‘F’ortran order) from an object that defines the buffer interface. If + # memory is contiguous, the memoryview object points to the original + # memory. Otherwise, a copy is made and the memoryview points to a new + # bytes object. + + bint PyMemoryView_Check(object obj) + # Return true if the object obj is a memoryview object. It is not currently + # allowed to create subclasses of memoryview. + + Py_buffer *PyMemoryView_GET_BUFFER(object mview) + # Return a pointer to the memoryview’s private copy of the exporter’s + # buffer. mview must be a memoryview instance; this macro doesn’t check its + # type, you must do it yourself or you will risk crashes. + + Py_buffer *PyMemoryView_GET_BASE(object mview) + # Return either a pointer to the exporting object that the memoryview is + # based on or NULL if the memoryview has been created by one of the + # functions PyMemoryView_FromMemory() or PyMemoryView_FromBuffer(). mview + # must be a memoryview instance. diff --git a/contrib/tools/cython/Cython/Includes/cpython/method.pxd b/contrib/tools/cython/Cython/Includes/cpython/method.pxd new file mode 100644 index 00000000000..f51ebcc7c75 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/method.pxd @@ -0,0 +1,49 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + ############################################################################ + # 7.5.4 Method Objects + ############################################################################ + + # There are some useful functions that are useful for working with method objects. + # PyTypeObject PyMethod_Type + # This instance of PyTypeObject represents the Python method type. This is exposed to Python programs as types.MethodType. + + bint PyMethod_Check(object o) + # Return true if o is a method object (has type + # PyMethod_Type). The parameter must not be NULL. + + object PyMethod_New(object func, object self, object cls) + # Return value: New reference. + # Return a new method object, with func being any callable object; + # this is the function that will be called when the method is + # called. If this method should be bound to an instance, self + # should be the instance and class should be the class of self, + # otherwise self should be NULL and class should be the class + # which provides the unbound method.. + + PyObject* PyMethod_Class(object meth) except NULL + # Return value: Borrowed reference. + # Return the class object from which the method meth was created; + # if this was created from an instance, it will be the class of + # the instance. + + PyObject* PyMethod_GET_CLASS(object meth) + # Return value: Borrowed reference. + # Macro version of PyMethod_Class() which avoids error checking. + + PyObject* PyMethod_Function(object meth) except NULL + # Return value: Borrowed reference. + # Return the function object associated with the method meth. + + PyObject* PyMethod_GET_FUNCTION(object meth) + # Return value: Borrowed reference. + # Macro version of PyMethod_Function() which avoids error checking. + + PyObject* PyMethod_Self(object meth) except? NULL + # Return value: Borrowed reference. + # Return the instance associated with the method meth if it is bound, otherwise return NULL. + + PyObject* PyMethod_GET_SELF(object meth) + # Return value: Borrowed reference. + # Macro version of PyMethod_Self() which avoids error checking. diff --git a/contrib/tools/cython/Cython/Includes/cpython/module.pxd b/contrib/tools/cython/Cython/Includes/cpython/module.pxd new file mode 100644 index 00000000000..8eb323b010b --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/module.pxd @@ -0,0 +1,188 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + ctypedef struct _inittab + + ##################################################################### + # 5.3 Importing Modules + ##################################################################### + object PyImport_ImportModule(const char *name) + # Return value: New reference. + # This is a simplified interface to PyImport_ImportModuleEx() + # below, leaving the globals and locals arguments set to + # NULL. When the name argument contains a dot (when it specifies a + # submodule of a package), the fromlist argument is set to the + # list ['*'] so that the return value is the named module rather + # than the top-level package containing it as would otherwise be + # the case. (Unfortunately, this has an additional side effect + # when name in fact specifies a subpackage instead of a submodule: + # the submodules specified in the package's __all__ variable are + # loaded.) Return a new reference to the imported module, or NULL + # with an exception set on failure. + + object PyImport_ImportModuleEx(const char *name, object globals, object locals, object fromlist) + # Return value: New reference. + + # Import a module. This is best described by referring to the + # built-in Python function __import__(), as the standard + # __import__() function calls this function directly. + + # The return value is a new reference to the imported module or + # top-level package, or NULL with an exception set on failure + # (before Python 2.4, the module may still be created in this + # case). Like for __import__(), the return value when a submodule + # of a package was requested is normally the top-level package, + # unless a non-empty fromlist was given. Changed in version 2.4: + # failing imports remove incomplete module objects. + + object PyImport_ImportModuleLevel(char *name, object globals, object locals, object fromlist, int level) + # Return value: New reference. + + # Import a module. This is best described by referring to the + # built-in Python function __import__(), as the standard + # __import__() function calls this function directly. + + # The return value is a new reference to the imported module or + # top-level package, or NULL with an exception set on failure. Like + # for __import__(), the return value when a submodule of a package + # was requested is normally the top-level package, unless a + # non-empty fromlist was given. + + object PyImport_Import(object name) + # Return value: New reference. + # This is a higher-level interface that calls the current ``import + # hook function''. It invokes the __import__() function from the + # __builtins__ of the current globals. This means that the import + # is done using whatever import hooks are installed in the current + # environment, e.g. by rexec or ihooks. + + object PyImport_ReloadModule(object m) + # Return value: New reference. + # Reload a module. This is best described by referring to the + # built-in Python function reload(), as the standard reload() + # function calls this function directly. Return a new reference to + # the reloaded module, or NULL with an exception set on failure + # (the module still exists in this case). + + PyObject* PyImport_AddModule(const char *name) except NULL + # Return value: Borrowed reference. + # Return the module object corresponding to a module name. The + # name argument may be of the form package.module. First check the + # modules dictionary if there's one there, and if not, create a + # new one and insert it in the modules dictionary. Return NULL + # with an exception set on failure. Note: This function does not + # load or import the module; if the module wasn't already loaded, + # you will get an empty module object. Use PyImport_ImportModule() + # or one of its variants to import a module. Package structures + # implied by a dotted name for name are not created if not already + # present. + + object PyImport_ExecCodeModule(char *name, object co) + # Return value: New reference. + # Given a module name (possibly of the form package.module) and a + # code object read from a Python bytecode file or obtained from + # the built-in function compile(), load the module. Return a new + # reference to the module object, or NULL with an exception set if + # an error occurred. Name is removed from sys.modules in error + # cases, and even if name was already in sys.modules on entry to + # PyImport_ExecCodeModule(). Leaving incompletely initialized + # modules in sys.modules is dangerous, as imports of such modules + # have no way to know that the module object is an unknown (and + # probably damaged with respect to the module author's intents) + # state. + # This function will reload the module if it was already + # imported. See PyImport_ReloadModule() for the intended way to + # reload a module. + # If name points to a dotted name of the form package.module, any + # package structures not already created will still not be + # created. + + + long PyImport_GetMagicNumber() + # Return the magic number for Python bytecode files (a.k.a. .pyc + # and .pyo files). The magic number should be present in the first + # four bytes of the bytecode file, in little-endian byte order. + + PyObject* PyImport_GetModuleDict() except NULL + # Return value: Borrowed reference. + # Return the dictionary used for the module administration + # (a.k.a. sys.modules). Note that this is a per-interpreter + # variable. + + + int PyImport_ImportFrozenModule(char *name) except -1 + # Load a frozen module named name. Return 1 for success, 0 if the + # module is not found, and -1 with an exception set if the + # initialization failed. To access the imported module on a + # successful load, use PyImport_ImportModule(). (Note the misnomer + # -- this function would reload the module if it was already + # imported.) + + + int PyImport_ExtendInittab(_inittab *newtab) except -1 + # Add a collection of modules to the table of built-in + # modules. The newtab array must end with a sentinel entry which + # contains NULL for the name field; failure to provide the + # sentinel value can result in a memory fault. Returns 0 on + # success or -1 if insufficient memory could be allocated to + # extend the internal table. In the event of failure, no modules + # are added to the internal table. This should be called before + # Py_Initialize(). + + ##################################################################### + # 7.5.5 Module Objects + ##################################################################### + + # PyTypeObject PyModule_Type + # + # This instance of PyTypeObject represents the Python module + # type. This is exposed to Python programs as types.ModuleType. + + bint PyModule_Check(object p) + # Return true if p is a module object, or a subtype of a module + # object. + + bint PyModule_CheckExact(object p) + # Return true if p is a module object, but not a subtype of PyModule_Type. + + object PyModule_New(const char *name) + # Return value: New reference. + # Return a new module object with the __name__ attribute set to + # name. Only the module's __doc__ and __name__ attributes are + # filled in; the caller is responsible for providing a __file__ + # attribute. + + PyObject* PyModule_GetDict(object module) except NULL + # Return value: Borrowed reference. + # Return the dictionary object that implements module's namespace; + # this object is the same as the __dict__ attribute of the module + # object. This function never fails. It is recommended extensions + # use other PyModule_*() and PyObject_*() functions rather than + # directly manipulate a module's __dict__. + + char* PyModule_GetName(object module) except NULL + # Return module's __name__ value. If the module does not provide + # one, or if it is not a string, SystemError is raised and NULL is + # returned. + + char* PyModule_GetFilename(object module) except NULL + # Return the name of the file from which module was loaded using + # module's __file__ attribute. If this is not defined, or if it is + # not a string, raise SystemError and return NULL. + + int PyModule_AddObject(object module, const char *name, object value) except -1 + # Add an object to module as name. This is a convenience function + # which can be used from the module's initialization + # function. This steals a reference to value. Return -1 on error, + # 0 on success. + + int PyModule_AddIntConstant(object module, const char *name, long value) except -1 + # Add an integer constant to module as name. This convenience + # function can be used from the module's initialization + # function. Return -1 on error, 0 on success. + + int PyModule_AddStringConstant(object module, const char *name, const char *value) except -1 + # Add a string constant to module as name. This convenience + # function can be used from the module's initialization + # function. The string value must be null-terminated. Return -1 on + # error, 0 on success. diff --git a/contrib/tools/cython/Cython/Includes/cpython/number.pxd b/contrib/tools/cython/Cython/Includes/cpython/number.pxd new file mode 100644 index 00000000000..ded35c292a6 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/number.pxd @@ -0,0 +1,265 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ##################################################################### + # 6.2 Number Protocol + ##################################################################### + + bint PyNumber_Check(object o) + # Returns 1 if the object o provides numeric protocols, and false + # otherwise. This function always succeeds. + + object PyNumber_Add(object o1, object o2) + # Return value: New reference. + # Returns the result of adding o1 and o2, or NULL on failure. This + # is the equivalent of the Python expression "o1 + o2". + + object PyNumber_Subtract(object o1, object o2) + # Return value: New reference. + # Returns the result of subtracting o2 from o1, or NULL on + # failure. This is the equivalent of the Python expression "o1 - + # o2". + + object PyNumber_Multiply(object o1, object o2) + # Return value: New reference. + # Returns the result of multiplying o1 and o2, or NULL on + # failure. This is the equivalent of the Python expression "o1 * + # o2". + + object PyNumber_MatrixMultiply(object o1, object o2) + # Return value: New reference. + # Returns the result of matrix multiplication on o1 and o2, or + # NULL on failure. This is the equivalent of the Python + # expression "o1 @ o2". + # New in version 3.5. + + object PyNumber_Divide(object o1, object o2) + # Return value: New reference. + # Returns the result of dividing o1 by o2, or NULL on + # failure. This is the equivalent of the Python expression "o1 / + # o2". + + object PyNumber_FloorDivide(object o1, object o2) + # Return value: New reference. + # Return the floor of o1 divided by o2, or NULL on failure. This + # is equivalent to the ``classic'' division of integers. + + object PyNumber_TrueDivide(object o1, object o2) + # Return value: New reference. + # Return a reasonable approximation for the mathematical value of + # o1 divided by o2, or NULL on failure. The return value is + # ``approximate'' because binary floating point numbers are + # approximate; it is not possible to represent all real numbers in + # base two. This function can return a floating point value when + # passed two integers. + + object PyNumber_Remainder(object o1, object o2) + # Return value: New reference. + # Returns the remainder of dividing o1 by o2, or NULL on + # failure. This is the equivalent of the Python expression "o1 % + # o2". + + object PyNumber_Divmod(object o1, object o2) + # Return value: New reference. + # See the built-in function divmod(). Returns NULL on + # failure. This is the equivalent of the Python expression + # "divmod(o1, o2)". + + object PyNumber_Power(object o1, object o2, object o3) + # Return value: New reference. + # See the built-in function pow(). Returns NULL on failure. This + # is the equivalent of the Python expression "pow(o1, o2, o3)", + # where o3 is optional. If o3 is to be ignored, pass Py_None in + # its place (passing NULL for o3 would cause an illegal memory + # access). + + object PyNumber_Negative(object o) + # Return value: New reference. + # Returns the negation of o on success, or NULL on failure. This + # is the equivalent of the Python expression "-o". + + object PyNumber_Positive(object o) + # Return value: New reference. + # Returns o on success, or NULL on failure. This is the equivalent + # of the Python expression "+o". + + object PyNumber_Absolute(object o) + # Return value: New reference. + # Returns the absolute value of o, or NULL on failure. This is the + # equivalent of the Python expression "abs(o)". + + object PyNumber_Invert(object o) + # Return value: New reference. + # Returns the bitwise negation of o on success, or NULL on + # failure. This is the equivalent of the Python expression "~o". + + object PyNumber_Lshift(object o1, object o2) + # Return value: New reference. + # Returns the result of left shifting o1 by o2 on success, or NULL + # on failure. This is the equivalent of the Python expression "o1 + # << o2". + + object PyNumber_Rshift(object o1, object o2) + # Return value: New reference. + # Returns the result of right shifting o1 by o2 on success, or + # NULL on failure. This is the equivalent of the Python expression + # "o1 >> o2". + + object PyNumber_And(object o1, object o2) + # Return value: New reference. + # Returns the ``bitwise and'' of o1 and o2 on success and NULL on + # failure. This is the equivalent of the Python expression "o1 & + # o2". + + object PyNumber_Xor(object o1, object o2) + # Return value: New reference. + # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or + # NULL on failure. This is the equivalent of the Python expression + # "o1 ^ o2". + + object PyNumber_Or(object o1, object o2) + # Return value: New reference. + # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on failure. This is the equivalent of the Python expression "o1 | o2". + + object PyNumber_InPlaceAdd(object o1, object o2) + # Return value: New reference. + # Returns the result of adding o1 and o2, or NULL on failure. The + # operation is done in-place when o1 supports it. This is the + # equivalent of the Python statement "o1 += o2". + + object PyNumber_InPlaceSubtract(object o1, object o2) + # Return value: New reference. + # Returns the result of subtracting o2 from o1, or NULL on + # failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 -= o2". + + object PyNumber_InPlaceMultiply(object o1, object o2) + # Return value: New reference. + # Returns the result of multiplying o1 and o2, or NULL on + # failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 *= o2". + + object PyNumber_InPlaceMatrixMultiply(object o1, object o2) + # Return value: New reference. + # Returns the result of matrix multiplication on o1 and o2, or + # NULL on failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 @= o2". + # New in version 3.5. + + object PyNumber_InPlaceDivide(object o1, object o2) + # Return value: New reference. + # Returns the result of dividing o1 by o2, or NULL on failure. The + # operation is done in-place when o1 supports it. This is the + # equivalent of the Python statement "o1 /= o2". + + object PyNumber_InPlaceFloorDivide(object o1, object o2) + # Return value: New reference. + # Returns the mathematical floor of dividing o1 by o2, or NULL on + # failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 //= + # o2". + + object PyNumber_InPlaceTrueDivide(object o1, object o2) + # Return value: New reference. + # Return a reasonable approximation for the mathematical value of + # o1 divided by o2, or NULL on failure. The return value is + # ``approximate'' because binary floating point numbers are + # approximate; it is not possible to represent all real numbers in + # base two. This function can return a floating point value when + # passed two integers. The operation is done in-place when o1 + # supports it. + + object PyNumber_InPlaceRemainder(object o1, object o2) + # Return value: New reference. + # Returns the remainder of dividing o1 by o2, or NULL on + # failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 %= o2". + + object PyNumber_InPlacePower(object o1, object o2, object o3) + # Return value: New reference. + # See the built-in function pow(). Returns NULL on failure. The + # operation is done in-place when o1 supports it. This is the + # equivalent of the Python statement "o1 **= o2" when o3 is + # Py_None, or an in-place variant of "pow(o1, o2, o3)" + # otherwise. If o3 is to be ignored, pass Py_None in its place + # (passing NULL for o3 would cause an illegal memory access). + + object PyNumber_InPlaceLshift(object o1, object o2) + # Return value: New reference. + # Returns the result of left shifting o1 by o2 on success, or NULL + # on failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 <<= o2". + + object PyNumber_InPlaceRshift(object o1, object o2) + # Return value: New reference. + # Returns the result of right shifting o1 by o2 on success, or + # NULL on failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 >>= o2". + + object PyNumber_InPlaceAnd(object o1, object o2) + # Return value: New reference. + # Returns the ``bitwise and'' of o1 and o2 on success and NULL on + # failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 &= o2". + + object PyNumber_InPlaceXor(object o1, object o2) + # Return value: New reference. + # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or + # NULL on failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 ^= o2". + + object PyNumber_InPlaceOr(object o1, object o2) + # Return value: New reference. + # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on + # failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python statement "o1 |= o2". + + int PyNumber_Coerce(PyObject **p1, PyObject **p2) except -1 + # This function takes the addresses of two variables of type + # PyObject*. If the objects pointed to by *p1 and *p2 have the + # same type, increment their reference count and return 0 + # (success). If the objects can be converted to a common numeric + # type, replace *p1 and *p2 by their converted value (with 'new' + # reference counts), and return 0. If no conversion is possible, + # or if some other error occurs, return -1 (failure) and don't + # increment the reference counts. The call PyNumber_Coerce(&o1, + # &o2) is equivalent to the Python statement "o1, o2 = coerce(o1, + # o2)". + + object PyNumber_Int(object o) + # Return value: New reference. + # Returns the o converted to an integer object on success, or NULL + # on failure. If the argument is outside the integer range a long + # object will be returned instead. This is the equivalent of the + # Python expression "int(o)". + + object PyNumber_Long(object o) + # Return value: New reference. + # Returns the o converted to a long integer object on success, or + # NULL on failure. This is the equivalent of the Python expression + # "long(o)". + + object PyNumber_Float(object o) + # Return value: New reference. + # Returns the o converted to a float object on success, or NULL on + # failure. This is the equivalent of the Python expression + # "float(o)". + + object PyNumber_Index(object o) + # Returns the o converted to a Python int or long on success or + # NULL with a TypeError exception raised on failure. + + Py_ssize_t PyNumber_AsSsize_t(object o, object exc) except? -1 + # Returns o converted to a Py_ssize_t value if o can be + # interpreted as an integer. If o can be converted to a Python int + # or long but the attempt to convert to a Py_ssize_t value would + # raise an OverflowError, then the exc argument is the type of + # exception that will be raised (usually IndexError or + # OverflowError). If exc is NULL, then the exception is cleared + # and the value is clipped to PY_SSIZE_T_MIN for a negative + # integer or PY_SSIZE_T_MAX for a positive integer. + + bint PyIndex_Check(object) + # Returns True if o is an index integer (has the nb_index slot of + # the tp_as_number structure filled in). diff --git a/contrib/tools/cython/Cython/Includes/cpython/object.pxd b/contrib/tools/cython/Cython/Includes/cpython/object.pxd new file mode 100644 index 00000000000..5a81166393f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/object.pxd @@ -0,0 +1,399 @@ +from libc.stdio cimport FILE +cimport cpython.type + +cdef extern from "Python.h": + + ctypedef struct PyObject # forward declaration + + ctypedef object (*newfunc)(cpython.type.type, object, object) # (type, args, kwargs) + + ctypedef object (*unaryfunc)(object) + ctypedef object (*binaryfunc)(object, object) + ctypedef object (*ternaryfunc)(object, object, object) + ctypedef int (*inquiry)(object) except -1 + ctypedef Py_ssize_t (*lenfunc)(object) except -1 + ctypedef object (*ssizeargfunc)(object, Py_ssize_t) + ctypedef object (*ssizessizeargfunc)(object, Py_ssize_t, Py_ssize_t) + ctypedef int (*ssizeobjargproc)(object, Py_ssize_t, object) except -1 + ctypedef int (*ssizessizeobjargproc)(object, Py_ssize_t, Py_ssize_t, object) except -1 + ctypedef int (*objobjargproc)(object, object, object) except -1 + ctypedef int (*objobjproc)(object, object) except -1 + + ctypedef Py_hash_t (*hashfunc)(object) except -1 + ctypedef object (*reprfunc)(object) + + ctypedef int (*cmpfunc)(object, object) except -2 + ctypedef object (*richcmpfunc)(object, object, int) + + # The following functions use 'PyObject*' as first argument instead of 'object' to prevent + # accidental reference counting when calling them during a garbage collection run. + ctypedef void (*destructor)(PyObject*) + ctypedef int (*visitproc)(PyObject*, void *) except -1 + ctypedef int (*traverseproc)(PyObject*, visitproc, void*) except -1 + ctypedef void (*freefunc)(void*) + + ctypedef object (*descrgetfunc)(object, object, object) + ctypedef int (*descrsetfunc)(object, object, object) except -1 + + ctypedef struct PyTypeObject: + const char* tp_name + const char* tp_doc + Py_ssize_t tp_basicsize + Py_ssize_t tp_itemsize + Py_ssize_t tp_dictoffset + unsigned long tp_flags + + newfunc tp_new + destructor tp_dealloc + traverseproc tp_traverse + inquiry tp_clear + freefunc tp_free + + ternaryfunc tp_call + hashfunc tp_hash + reprfunc tp_str + reprfunc tp_repr + + cmpfunc tp_compare + richcmpfunc tp_richcompare + + PyTypeObject* tp_base + PyObject* tp_dict + + descrgetfunc tp_descr_get + descrsetfunc tp_descr_set + + ctypedef struct PyObject: + Py_ssize_t ob_refcnt + PyTypeObject *ob_type + + cdef PyTypeObject *Py_TYPE(object) + + void* PyObject_Malloc(size_t) + void* PyObject_Realloc(void *, size_t) + void PyObject_Free(void *) + + ##################################################################### + # 6.1 Object Protocol + ##################################################################### + int PyObject_Print(object o, FILE *fp, int flags) except -1 + # Print an object o, on file fp. Returns -1 on error. The flags + # argument is used to enable certain printing options. The only + # option currently supported is Py_PRINT_RAW; if given, the str() + # of the object is written instead of the repr(). + + bint PyObject_HasAttrString(object o, const char *attr_name) + # Returns 1 if o has the attribute attr_name, and 0 + # otherwise. This is equivalent to the Python expression + # "hasattr(o, attr_name)". This function always succeeds. + + object PyObject_GetAttrString(object o, const char *attr_name) + # Return value: New reference. Retrieve an attribute named + # attr_name from object o. Returns the attribute value on success, + # or NULL on failure. This is the equivalent of the Python + # expression "o.attr_name". + + bint PyObject_HasAttr(object o, object attr_name) + # Returns 1 if o has the attribute attr_name, and 0 + # otherwise. This is equivalent to the Python expression + # "hasattr(o, attr_name)". This function always succeeds. + + object PyObject_GetAttr(object o, object attr_name) + # Return value: New reference. Retrieve an attribute named + # attr_name from object o. Returns the attribute value on success, + # or NULL on failure. This is the equivalent of the Python + # expression "o.attr_name". + + object PyObject_GenericGetAttr(object o, object attr_name) + + int PyObject_SetAttrString(object o, const char *attr_name, object v) except -1 + # Set the value of the attribute named attr_name, for object o, to + # the value v. Returns -1 on failure. This is the equivalent of + # the Python statement "o.attr_name = v". + + int PyObject_SetAttr(object o, object attr_name, object v) except -1 + # Set the value of the attribute named attr_name, for object o, to + # the value v. Returns -1 on failure. This is the equivalent of + # the Python statement "o.attr_name = v". + + int PyObject_GenericSetAttr(object o, object attr_name, object v) except -1 + + int PyObject_DelAttrString(object o, const char *attr_name) except -1 + # Delete attribute named attr_name, for object o. Returns -1 on + # failure. This is the equivalent of the Python statement: "del + # o.attr_name". + + int PyObject_DelAttr(object o, object attr_name) except -1 + # Delete attribute named attr_name, for object o. Returns -1 on + # failure. This is the equivalent of the Python statement "del + # o.attr_name". + + int Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE + + object PyObject_RichCompare(object o1, object o2, int opid) + # Return value: New reference. + # Compare the values of o1 and o2 using the operation specified by + # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or + # Py_GE, corresponding to <, <=, ==, !=, >, or >= + # respectively. This is the equivalent of the Python expression + # "o1 op o2", where op is the operator corresponding to + # opid. Returns the value of the comparison on success, or NULL on + # failure. + + bint PyObject_RichCompareBool(object o1, object o2, int opid) except -1 + # Compare the values of o1 and o2 using the operation specified by + # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or + # Py_GE, corresponding to <, <=, ==, !=, >, or >= + # respectively. Returns -1 on error, 0 if the result is false, 1 + # otherwise. This is the equivalent of the Python expression "o1 + # op o2", where op is the operator corresponding to opid. + + int PyObject_Cmp(object o1, object o2, int *result) except -1 + # Compare the values of o1 and o2 using a routine provided by o1, + # if one exists, otherwise with a routine provided by o2. The + # result of the comparison is returned in result. Returns -1 on + # failure. This is the equivalent of the Python statement "result + # = cmp(o1, o2)". + + int PyObject_Compare(object o1, object o2) except * + # Compare the values of o1 and o2 using a routine provided by o1, + # if one exists, otherwise with a routine provided by o2. Returns + # the result of the comparison on success. On error, the value + # returned is undefined; use PyErr_Occurred() to detect an + # error. This is equivalent to the Python expression "cmp(o1, + # o2)". + + object PyObject_Repr(object o) + # Return value: New reference. + # Compute a string representation of object o. Returns the string + # representation on success, NULL on failure. This is the + # equivalent of the Python expression "repr(o)". Called by the + # repr() built-in function and by reverse quotes. + + object PyObject_Str(object o) + # Return value: New reference. + # Compute a string representation of object o. Returns the string + # representation on success, NULL on failure. This is the + # equivalent of the Python expression "str(o)". Called by the + # str() built-in function and by the print statement. + + object PyObject_Unicode(object o) + # Return value: New reference. + # Compute a Unicode string representation of object o. Returns the + # Unicode string representation on success, NULL on failure. This + # is the equivalent of the Python expression "unicode(o)". Called + # by the unicode() built-in function. + + bint PyObject_IsInstance(object inst, object cls) except -1 + # Returns 1 if inst is an instance of the class cls or a subclass + # of cls, or 0 if not. On error, returns -1 and sets an + # exception. If cls is a type object rather than a class object, + # PyObject_IsInstance() returns 1 if inst is of type cls. If cls + # is a tuple, the check will be done against every entry in + # cls. The result will be 1 when at least one of the checks + # returns 1, otherwise it will be 0. If inst is not a class + # instance and cls is neither a type object, nor a class object, + # nor a tuple, inst must have a __class__ attribute -- the class + # relationship of the value of that attribute with cls will be + # used to determine the result of this function. + + # Subclass determination is done in a fairly straightforward way, + # but includes a wrinkle that implementors of extensions to the + # class system may want to be aware of. If A and B are class + # objects, B is a subclass of A if it inherits from A either + # directly or indirectly. If either is not a class object, a more + # general mechanism is used to determine the class relationship of + # the two objects. When testing if B is a subclass of A, if A is + # B, PyObject_IsSubclass() returns true. If A and B are different + # objects, B's __bases__ attribute is searched in a depth-first + # fashion for A -- the presence of the __bases__ attribute is + # considered sufficient for this determination. + + bint PyObject_IsSubclass(object derived, object cls) except -1 + # Returns 1 if the class derived is identical to or derived from + # the class cls, otherwise returns 0. In case of an error, returns + # -1. If cls is a tuple, the check will be done against every + # entry in cls. The result will be 1 when at least one of the + # checks returns 1, otherwise it will be 0. If either derived or + # cls is not an actual class object (or tuple), this function uses + # the generic algorithm described above. New in version + # 2.1. Changed in version 2.3: Older versions of Python did not + # support a tuple as the second argument. + + bint PyCallable_Check(object o) + # Determine if the object o is callable. Return 1 if the object is + # callable and 0 otherwise. This function always succeeds. + + object PyObject_Call(object callable_object, object args, object kw) + # Return value: New reference. + # Call a callable Python object callable_object, with arguments + # given by the tuple args, and named arguments given by the + # dictionary kw. If no named arguments are needed, kw may be + # NULL. args must not be NULL, use an empty tuple if no arguments + # are needed. Returns the result of the call on success, or NULL + # on failure. This is the equivalent of the Python expression + # "apply(callable_object, args, kw)" or "callable_object(*args, + # **kw)". + + object PyObject_CallObject(object callable_object, object args) + # Return value: New reference. + # Call a callable Python object callable_object, with arguments + # given by the tuple args. If no arguments are needed, then args + # may be NULL. Returns the result of the call on success, or NULL + # on failure. This is the equivalent of the Python expression + # "apply(callable_object, args)" or "callable_object(*args)". + + object PyObject_CallFunction(object callable, char *format, ...) + # Return value: New reference. + # Call a callable Python object callable, with a variable number + # of C arguments. The C arguments are described using a + # Py_BuildValue() style format string. The format may be NULL, + # indicating that no arguments are provided. Returns the result of + # the call on success, or NULL on failure. This is the equivalent + # of the Python expression "apply(callable, args)" or + # "callable(*args)". Note that if you only pass object args, + # PyObject_CallFunctionObjArgs is a faster alternative. + + object PyObject_CallMethod(object o, char *method, char *format, ...) + # Return value: New reference. + # Call the method named method of object o with a variable number + # of C arguments. The C arguments are described by a + # Py_BuildValue() format string that should produce a tuple. The + # format may be NULL, indicating that no arguments are + # provided. Returns the result of the call on success, or NULL on + # failure. This is the equivalent of the Python expression + # "o.method(args)". Note that if you only pass object args, + # PyObject_CallMethodObjArgs is a faster alternative. + + #object PyObject_CallFunctionObjArgs(object callable, ..., NULL) + object PyObject_CallFunctionObjArgs(object callable, ...) + # Return value: New reference. + # Call a callable Python object callable, with a variable number + # of PyObject* arguments. The arguments are provided as a variable + # number of parameters followed by NULL. Returns the result of the + # call on success, or NULL on failure. + + #PyObject* PyObject_CallMethodObjArgs(object o, object name, ..., NULL) + object PyObject_CallMethodObjArgs(object o, object name, ...) + # Return value: New reference. + # Calls a method of the object o, where the name of the method is + # given as a Python string object in name. It is called with a + # variable number of PyObject* arguments. The arguments are + # provided as a variable number of parameters followed by + # NULL. Returns the result of the call on success, or NULL on + # failure. + + long PyObject_Hash(object o) except? -1 + # Compute and return the hash value of an object o. On failure, + # return -1. This is the equivalent of the Python expression + # "hash(o)". + + bint PyObject_IsTrue(object o) except -1 + # Returns 1 if the object o is considered to be true, and 0 + # otherwise. This is equivalent to the Python expression "not not + # o". On failure, return -1. + + bint PyObject_Not(object o) except -1 + # Returns 0 if the object o is considered to be true, and 1 + # otherwise. This is equivalent to the Python expression "not + # o". On failure, return -1. + + object PyObject_Type(object o) + # Return value: New reference. + # When o is non-NULL, returns a type object corresponding to the + # object type of object o. On failure, raises SystemError and + # returns NULL. This is equivalent to the Python expression + # type(o). This function increments the reference count of the + # return value. There's really no reason to use this function + # instead of the common expression o->ob_type, which returns a + # pointer of type PyTypeObject*, except when the incremented + # reference count is needed. + + bint PyObject_TypeCheck(object o, PyTypeObject *type) + # Return true if the object o is of type type or a subtype of + # type. Both parameters must be non-NULL. + + Py_ssize_t PyObject_Length(object o) except -1 + Py_ssize_t PyObject_Size(object o) except -1 + # Return the length of object o. If the object o provides either + # the sequence and mapping protocols, the sequence length is + # returned. On error, -1 is returned. This is the equivalent to + # the Python expression "len(o)". + + object PyObject_GetItem(object o, object key) + # Return value: New reference. + # Return element of o corresponding to the object key or NULL on + # failure. This is the equivalent of the Python expression + # "o[key]". + + int PyObject_SetItem(object o, object key, object v) except -1 + # Map the object key to the value v. Returns -1 on failure. This + # is the equivalent of the Python statement "o[key] = v". + + int PyObject_DelItem(object o, object key) except -1 + # Delete the mapping for key from o. Returns -1 on failure. This + # is the equivalent of the Python statement "del o[key]". + + int PyObject_AsFileDescriptor(object o) except -1 + # Derives a file-descriptor from a Python object. If the object is + # an integer or long integer, its value is returned. If not, the + # object's fileno() method is called if it exists; the method must + # return an integer or long integer, which is returned as the file + # descriptor value. Returns -1 on failure. + + object PyObject_Dir(object o) + # Return value: New reference. + # This is equivalent to the Python expression "dir(o)", returning + # a (possibly empty) list of strings appropriate for the object + # argument, or NULL if there was an error. If the argument is + # NULL, this is like the Python "dir()", returning the names of + # the current locals; in this case, if no execution frame is + # active then NULL is returned but PyErr_Occurred() will return + # false. + + object PyObject_GetIter(object o) + # Return value: New reference. + # This is equivalent to the Python expression "iter(o)". It + # returns a new iterator for the object argument, or the object + # itself if the object is already an iterator. Raises TypeError + # and returns NULL if the object cannot be iterated. + + Py_ssize_t Py_SIZE(object o) + + object PyObject_Format(object obj, object format_spec) + # Takes an arbitrary object and returns the result of calling + # obj.__format__(format_spec). + # Added in Py2.6 + + # Type flags (tp_flags of PyTypeObject) + long Py_TPFLAGS_HAVE_GETCHARBUFFER + long Py_TPFLAGS_HAVE_SEQUENCE_IN + long Py_TPFLAGS_HAVE_INPLACEOPS + long Py_TPFLAGS_CHECKTYPES + long Py_TPFLAGS_HAVE_RICHCOMPARE + long Py_TPFLAGS_HAVE_WEAKREFS + long Py_TPFLAGS_HAVE_ITER + long Py_TPFLAGS_HAVE_CLASS + long Py_TPFLAGS_HEAPTYPE + long Py_TPFLAGS_BASETYPE + long Py_TPFLAGS_READY + long Py_TPFLAGS_READYING + long Py_TPFLAGS_HAVE_GC + long Py_TPFLAGS_HAVE_STACKLESS_EXTENSION + long Py_TPFLAGS_HAVE_INDEX + long Py_TPFLAGS_HAVE_VERSION_TAG + long Py_TPFLAGS_VALID_VERSION_TAG + long Py_TPFLAGS_IS_ABSTRACT + long Py_TPFLAGS_HAVE_NEWBUFFER + long Py_TPFLAGS_INT_SUBCLASS + long Py_TPFLAGS_LONG_SUBCLASS + long Py_TPFLAGS_LIST_SUBCLASS + long Py_TPFLAGS_TUPLE_SUBCLASS + long Py_TPFLAGS_STRING_SUBCLASS + long Py_TPFLAGS_UNICODE_SUBCLASS + long Py_TPFLAGS_DICT_SUBCLASS + long Py_TPFLAGS_BASE_EXC_SUBCLASS + long Py_TPFLAGS_TYPE_SUBCLASS + long Py_TPFLAGS_DEFAULT_EXTERNAL + long Py_TPFLAGS_DEFAULT_CORE + long Py_TPFLAGS_DEFAULT diff --git a/contrib/tools/cython/Cython/Includes/cpython/oldbuffer.pxd b/contrib/tools/cython/Cython/Includes/cpython/oldbuffer.pxd new file mode 100644 index 00000000000..0222428ed48 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/oldbuffer.pxd @@ -0,0 +1,63 @@ +# Legacy Python 2 buffer interface. +# +# These functions are no longer available in Python 3, use the new +# buffer interface instead. + +cdef extern from "Python.h": + cdef enum _: + Py_END_OF_BUFFER + # This constant may be passed as the size parameter to + # PyBuffer_FromObject() or PyBuffer_FromReadWriteObject(). It + # indicates that the new PyBufferObject should refer to base object + # from the specified offset to the end of its exported + # buffer. Using this enables the caller to avoid querying the base + # object for its length. + + bint PyBuffer_Check(object p) + # Return true if the argument has type PyBuffer_Type. + + object PyBuffer_FromObject(object base, Py_ssize_t offset, Py_ssize_t size) + # Return value: New reference. + # + # Return a new read-only buffer object. This raises TypeError if + # base doesn't support the read-only buffer protocol or doesn't + # provide exactly one buffer segment, or it raises ValueError if + # offset is less than zero. The buffer will hold a reference to the + # base object, and the buffer's contents will refer to the base + # object's buffer interface, starting as position offset and + # extending for size bytes. If size is Py_END_OF_BUFFER, then the + # new buffer's contents extend to the length of the base object's + # exported buffer data. + + object PyBuffer_FromReadWriteObject(object base, Py_ssize_t offset, Py_ssize_t size) + # Return value: New reference. + # + # Return a new writable buffer object. Parameters and exceptions + # are similar to those for PyBuffer_FromObject(). If the base + # object does not export the writeable buffer protocol, then + # TypeError is raised. + + object PyBuffer_FromMemory(void *ptr, Py_ssize_t size) + # Return value: New reference. + # + # Return a new read-only buffer object that reads from a specified + # location in memory, with a specified size. The caller is + # responsible for ensuring that the memory buffer, passed in as + # ptr, is not deallocated while the returned buffer object + # exists. Raises ValueError if size is less than zero. Note that + # Py_END_OF_BUFFER may not be passed for the size parameter; + # ValueError will be raised in that case. + + object PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size) + # Return value: New reference. + # + # Similar to PyBuffer_FromMemory(), but the returned buffer is + # writable. + + object PyBuffer_New(Py_ssize_t size) + # Return value: New reference. + # + # Return a new writable buffer object that maintains its own memory + # buffer of size bytes. ValueError is returned if size is not zero + # or positive. Note that the memory buffer (as returned by + # PyObject_AsWriteBuffer()) is not specifically aligned. diff --git a/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd b/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd new file mode 100644 index 00000000000..08062da850f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd @@ -0,0 +1,144 @@ + +# available since Python 3.1! + + +cdef extern from "Python.h": + + ctypedef struct PyCapsule_Type + # This subtype of PyObject represents an opaque value, useful for + # C extension modules who need to pass an opaque value (as a void* + # pointer) through Python code to other C code. It is often used + # to make a C function pointer defined in one module available to + # other modules, so the regular import mechanism can be used to + # access C APIs defined in dynamically loaded modules. + + + ctypedef void (*PyCapsule_Destructor)(object o) noexcept + # The type of a destructor callback for a capsule. + # + # See PyCapsule_New() for the semantics of PyCapsule_Destructor + # callbacks. + + + bint PyCapsule_CheckExact(object o) + # Return true if its argument is a PyCapsule. + + + object PyCapsule_New(void *pointer, const char *name, + PyCapsule_Destructor destructor) + # Return value: New reference. + # + # Create a PyCapsule encapsulating the pointer. The pointer + # argument may not be NULL. + # + # On failure, set an exception and return NULL. + # + # The name string may either be NULL or a pointer to a valid C + # string. If non-NULL, this string must outlive the + # capsule. (Though it is permitted to free it inside the + # destructor.) + # + # If the destructor argument is not NULL, it will be called with + # the capsule as its argument when it is destroyed. + # + # If this capsule will be stored as an attribute of a module, the + # name should be specified as modulename.attributename. This will + # enable other modules to import the capsule using + # PyCapsule_Import(). + + + void* PyCapsule_GetPointer(object capsule, const char *name) except? NULL + # Retrieve the pointer stored in the capsule. On failure, set an + # exception and return NULL. + # + # The name parameter must compare exactly to the name stored in + # the capsule. If the name stored in the capsule is NULL, the name + # passed in must also be NULL. Python uses the C function strcmp() + # to compare capsule names. + + + PyCapsule_Destructor PyCapsule_GetDestructor(object capsule) except? NULL + # Return the current destructor stored in the capsule. On failure, + # set an exception and return NULL. + # + # It is legal for a capsule to have a NULL destructor. This makes + # a NULL return code somewhat ambiguous; use PyCapsule_IsValid() + # or PyErr_Occurred() to disambiguate. + + + const char* PyCapsule_GetName(object capsule) except? NULL + # Return the current name stored in the capsule. On failure, set + # an exception and return NULL. + # + # It is legal for a capsule to have a NULL name. This makes a NULL + # return code somewhat ambiguous; use PyCapsule_IsValid() or + # PyErr_Occurred() to disambiguate. + + + void* PyCapsule_GetContext(object capsule) except? NULL + # Return the current context stored in the capsule. On failure, + # set an exception and return NULL. + # + # It is legal for a capsule to have a NULL context. This makes a + # NULL return code somewhat ambiguous; use PyCapsule_IsValid() or + # PyErr_Occurred() to disambiguate. + + + bint PyCapsule_IsValid(object capsule, const char *name) + # Determines whether or not capsule is a valid capsule. A valid + # capsule is non-NULL, passes PyCapsule_CheckExact(), has a + # non-NULL pointer stored in it, and its internal name matches the + # name parameter. (See PyCapsule_GetPointer() for information on + # how capsule names are compared.) + # + # In other words, if PyCapsule_IsValid() returns a true value, + # calls to any of the accessors (any function starting with + # PyCapsule_Get()) are guaranteed to succeed. + # + # Return a nonzero value if the object is valid and matches the + # name passed in. Return 0 otherwise. This function will not fail. + + + int PyCapsule_SetPointer(object capsule, void *pointer) except -1 + # Set the void pointer inside capsule to pointer. The pointer may + # not be NULL. + # + # Return 0 on success. Return nonzero and set an exception on + # failure. + + + int PyCapsule_SetDestructor(object capsule, PyCapsule_Destructor destructor) except -1 + # Set the destructor inside capsule to destructor. + # + # Return 0 on success. Return nonzero and set an exception on + # failure. + + + int PyCapsule_SetName(object capsule, const char *name) except -1 + # Set the name inside capsule to name. If non-NULL, the name must + # outlive the capsule. If the previous name stored in the capsule + # was not NULL, no attempt is made to free it. + # + # Return 0 on success. Return nonzero and set an exception on + # failure. + + + int PyCapsule_SetContext(object capsule, void *context) except -1 + # Set the context pointer inside capsule to context. Return 0 on + # success. Return nonzero and set an exception on failure. + + + void* PyCapsule_Import(const char *name, int no_block) except? NULL + # Import a pointer to a C object from a capsule attribute in a + # module. The name parameter should specify the full name to the + # attribute, as in module.attribute. The name stored in the + # capsule must match this string exactly. If no_block is true, + # import the module without blocking (using + # PyImport_ImportModuleNoBlock()). If no_block is false, import + # the module conventionally (using PyImport_ImportModule()). + # + # Return the capsule’s internal pointer on success. On failure, + # set an exception and return NULL. However, if PyCapsule_Import() + # failed to import the module, and no_block was true, no exception + # is set. + diff --git a/contrib/tools/cython/Cython/Includes/cpython/pylifecycle.pxd b/contrib/tools/cython/Cython/Includes/cpython/pylifecycle.pxd new file mode 100644 index 00000000000..2c71e371634 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/pylifecycle.pxd @@ -0,0 +1,68 @@ +# Interfaces to configure, query, create & destroy the Python runtime + +from libc.stdio cimport FILE +from .pystate cimport PyThreadState + + +cdef extern from "Python.h": + ctypedef int wchar_t + + void Py_SetProgramName(wchar_t *) + wchar_t *Py_GetProgramName() + + void Py_SetPythonHome(wchar_t *) + wchar_t *Py_GetPythonHome() + + # Only used by applications that embed the interpreter and need to + # override the standard encoding determination mechanism + int Py_SetStandardStreamEncoding(const char *encoding, const char *errors) + + void Py_Initialize() + void Py_InitializeEx(int) + void _Py_InitializeEx_Private(int, int) + void Py_Finalize() + int Py_FinalizeEx() + int Py_IsInitialized() + PyThreadState *Py_NewInterpreter() + void Py_EndInterpreter(PyThreadState *) + + + # _Py_PyAtExit is for the atexit module, Py_AtExit is for low-level + # exit functions. + void _Py_PyAtExit(void (*func)(object), object) + int Py_AtExit(void (*func)()) + + void Py_Exit(int) + + # Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. + void _Py_RestoreSignals() + + int Py_FdIsInteractive(FILE *, const char *) + + # Bootstrap __main__ (defined in Modules/main.c) + int Py_Main(int argc, wchar_t **argv) + + # In getpath.c + wchar_t *Py_GetProgramFullPath() + wchar_t *Py_GetPrefix() + wchar_t *Py_GetExecPrefix() + wchar_t *Py_GetPath() + void Py_SetPath(const wchar_t *) + int _Py_CheckPython3() + + # In their own files + const char *Py_GetVersion() + const char *Py_GetPlatform() + const char *Py_GetCopyright() + const char *Py_GetCompiler() + const char *Py_GetBuildInfo() + const char *_Py_gitidentifier() + const char *_Py_gitversion() + + ctypedef void (*PyOS_sighandler_t)(int) + PyOS_sighandler_t PyOS_getsig(int) + PyOS_sighandler_t PyOS_setsig(int, PyOS_sighandler_t) + + # Random + int _PyOS_URandom(void *buffer, Py_ssize_t size) + int _PyOS_URandomNonblock(void *buffer, Py_ssize_t size) diff --git a/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd b/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd new file mode 100644 index 00000000000..1af63079313 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd @@ -0,0 +1,92 @@ +# Thread and interpreter state structures and their interfaces + +from .object cimport PyObject + +cdef extern from "Python.h": + + # We make these an opaque types. If the user wants specific attributes, + # they can be declared manually. + + ctypedef long PY_INT64_T # FIXME: Py2.7+, not defined here but used here + + ctypedef struct PyInterpreterState: + pass + + ctypedef struct PyThreadState: + pass + + ctypedef struct PyFrameObject: + pass + + # This is not actually a struct, but make sure it can never be coerced to + # an int or used in arithmetic expressions + ctypedef struct PyGILState_STATE: + pass + + # The type of the trace function registered using PyEval_SetProfile() and + # PyEval_SetTrace(). + # Py_tracefunc return -1 when raising an exception, or 0 for success. + ctypedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *) + + # The following values are used for 'what' for tracefunc functions + enum: + PyTrace_CALL + PyTrace_EXCEPTION + PyTrace_LINE + PyTrace_RETURN + PyTrace_C_CALL + PyTrace_C_EXCEPTION + PyTrace_C_RETURN + + + PyInterpreterState * PyInterpreterState_New() + void PyInterpreterState_Clear(PyInterpreterState *) + void PyInterpreterState_Delete(PyInterpreterState *) + PY_INT64_T PyInterpreterState_GetID(PyInterpreterState *) + + PyThreadState * PyThreadState_New(PyInterpreterState *) + void PyThreadState_Clear(PyThreadState *) + void PyThreadState_Delete(PyThreadState *) + + PyThreadState * PyThreadState_Get() + PyThreadState * PyThreadState_Swap(PyThreadState *) # NOTE: DO NOT USE IN CYTHON CODE ! + PyObject * PyThreadState_GetDict() + int PyThreadState_SetAsyncExc(long, PyObject *) + + # Ensure that the current thread is ready to call the Python + # C API, regardless of the current state of Python, or of its + # thread lock. This may be called as many times as desired + # by a thread so long as each call is matched with a call to + # PyGILState_Release(). In general, other thread-state APIs may + # be used between _Ensure() and _Release() calls, so long as the + # thread-state is restored to its previous state before the Release(). + # For example, normal use of the Py_BEGIN_ALLOW_THREADS/ + # Py_END_ALLOW_THREADS macros are acceptable. + + # The return value is an opaque "handle" to the thread state when + # PyGILState_Ensure() was called, and must be passed to + # PyGILState_Release() to ensure Python is left in the same state. Even + # though recursive calls are allowed, these handles can *not* be shared - + # each unique call to PyGILState_Ensure must save the handle for its + # call to PyGILState_Release. + + # When the function returns, the current thread will hold the GIL. + + # Failure is a fatal error. + PyGILState_STATE PyGILState_Ensure() + + # Release any resources previously acquired. After this call, Python's + # state will be the same as it was prior to the corresponding + # PyGILState_Ensure() call (but generally this state will be unknown to + # the caller, hence the use of the GILState API.) + + # Every call to PyGILState_Ensure must be matched by a call to + # PyGILState_Release on the same thread. + void PyGILState_Release(PyGILState_STATE) + + # Routines for advanced debuggers, requested by David Beazley. + # Don't use unless you know what you are doing! + PyInterpreterState * PyInterpreterState_Head() + PyInterpreterState * PyInterpreterState_Next(PyInterpreterState *) + PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *) + PyThreadState * PyThreadState_Next(PyThreadState *) diff --git a/contrib/tools/cython/Cython/Includes/cpython/pythread.pxd b/contrib/tools/cython/Cython/Includes/cpython/pythread.pxd new file mode 100644 index 00000000000..392bef7d64b --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/pythread.pxd @@ -0,0 +1,53 @@ + + +cdef extern from "pythread.h": + + ctypedef void *PyThread_type_lock + ctypedef void *PyThread_type_sema + + void PyThread_init_thread() + long PyThread_start_new_thread(void (*)(void *), void *) # FIXME: legacy + #unsigned long PyThread_start_new_thread(void (*)(void *), void *) # returned 'long' before Py3.7 + void PyThread_exit_thread() + long PyThread_get_thread_ident() # FIXME: legacy + #unsigned long PyThread_get_thread_ident() # returned 'long' before Py3.7 + + PyThread_type_lock PyThread_allocate_lock() + void PyThread_free_lock(PyThread_type_lock) + int PyThread_acquire_lock(PyThread_type_lock, int mode) nogil + void PyThread_release_lock(PyThread_type_lock) nogil + + enum: + # 'mode' in PyThread_acquire_lock() + WAIT_LOCK # 1 + NOWAIT_LOCK # 0 + + ctypedef enum PyLockStatus: + # return values of PyThread_acquire_lock() in CPython 3.2+ + PY_LOCK_FAILURE = 0 + PY_LOCK_ACQUIRED = 1 + PY_LOCK_INTR + + size_t PyThread_get_stacksize() + int PyThread_set_stacksize(size_t) + + # Thread Local Storage (TLS) API deprecated in CPython 3.7+ + int PyThread_create_key() + void PyThread_delete_key(int) + int PyThread_set_key_value(int, void *) + void * PyThread_get_key_value(int) + void PyThread_delete_key_value(int key) + + # Cleanup after a fork + void PyThread_ReInitTLS() + + # Thread Specific Storage (TSS) API in CPython 3.7+ (also backported) + #ctypedef struct Py_tss_t: pass # Cython built-in type + Py_tss_t Py_tss_NEEDS_INIT # Not normally useful: Cython auto-initialises declared "Py_tss_t" variables. + Py_tss_t * PyThread_tss_alloc() + void PyThread_tss_free(Py_tss_t *key) + int PyThread_tss_is_created(Py_tss_t *key) + int PyThread_tss_create(Py_tss_t *key) + void PyThread_tss_delete(Py_tss_t *key) + int PyThread_tss_set(Py_tss_t *key, void *value) + void * PyThread_tss_get(Py_tss_t *key) diff --git a/contrib/tools/cython/Cython/Includes/cpython/ref.pxd b/contrib/tools/cython/Cython/Includes/cpython/ref.pxd new file mode 100644 index 00000000000..4bc9a7d7c88 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/ref.pxd @@ -0,0 +1,51 @@ +from .object cimport PyObject, PyTypeObject, Py_TYPE # legacy imports for re-export + +cdef extern from "Python.h": + ##################################################################### + # 3. Reference Counts + ##################################################################### + # The macros in this section are used for managing reference counts of Python objects. + void Py_INCREF(object o) + # Increment the reference count for object o. The object must not + # be NULL; if you aren't sure that it isn't NULL, use + # Py_XINCREF(). + + void Py_XINCREF(PyObject* o) + # Increment the reference count for object o. The object may be NULL, in which case the macro has no effect. + + void Py_DECREF(object o) + # Decrement the reference count for object o. The object must not + # be NULL; if you aren't sure that it isn't NULL, use + # Py_XDECREF(). If the reference count reaches zero, the object's + # type's deallocation function (which must not be NULL) is + # invoked. + + # Warning: The deallocation function can cause arbitrary Python + # code to be invoked (e.g. when a class instance with a __del__() + # method is deallocated). While exceptions in such code are not + # propagated, the executed code has free access to all Python + # global variables. This means that any object that is reachable + # from a global variable should be in a consistent state before + # Py_DECREF() is invoked. For example, code to delete an object + # from a list should copy a reference to the deleted object in a + # temporary variable, update the list data structure, and then + # call Py_DECREF() for the temporary variable. + + void Py_XDECREF(PyObject* o) + # Decrement the reference count for object o. The object may be + # NULL, in which case the macro has no effect; otherwise the + # effect is the same as for Py_DECREF(), and the same warning + # applies. + + void Py_CLEAR(PyObject* o) + # Decrement the reference count for object o. The object may be + # NULL, in which case the macro has no effect; otherwise the + # effect is the same as for Py_DECREF(), except that the argument + # is also set to NULL. The warning for Py_DECREF() does not apply + # with respect to the object passed because the macro carefully + # uses a temporary variable and sets the argument to NULL before + # decrementing its reference count. + # It is a good idea to use this macro whenever decrementing the + # value of a variable that might be traversed during garbage + # collection. + diff --git a/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd b/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd new file mode 100644 index 00000000000..eb279968d20 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd @@ -0,0 +1,136 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ############################################################################ + # 6.3 Sequence Protocol + ############################################################################ + + bint PySequence_Check(object o) + # Return 1 if the object provides sequence protocol, and 0 + # otherwise. This function always succeeds. + + Py_ssize_t PySequence_Size(object o) except -1 + # Returns the number of objects in sequence o on success, and -1 + # on failure. For objects that do not provide sequence protocol, + # this is equivalent to the Python expression "len(o)". + + Py_ssize_t PySequence_Length(object o) except -1 + # Alternate name for PySequence_Size(). + + object PySequence_Concat(object o1, object o2) + # Return value: New reference. + # Return the concatenation of o1 and o2 on success, and NULL on + # failure. This is the equivalent of the Python expression "o1 + + # o2". + + object PySequence_Repeat(object o, Py_ssize_t count) + # Return value: New reference. + # Return the result of repeating sequence object o count times, or + # NULL on failure. This is the equivalent of the Python expression + # "o * count". + + object PySequence_InPlaceConcat(object o1, object o2) + # Return value: New reference. + # Return the concatenation of o1 and o2 on success, and NULL on + # failure. The operation is done in-place when o1 supports + # it. This is the equivalent of the Python expression "o1 += o2". + + object PySequence_InPlaceRepeat(object o, Py_ssize_t count) + # Return value: New reference. + # Return the result of repeating sequence object o count times, or + # NULL on failure. The operation is done in-place when o supports + # it. This is the equivalent of the Python expression "o *= + # count". + + object PySequence_GetItem(object o, Py_ssize_t i) + # Return value: New reference. + # Return the ith element of o, or NULL on failure. This is the + # equivalent of the Python expression "o[i]". + + object PySequence_GetSlice(object o, Py_ssize_t i1, Py_ssize_t i2) + # Return value: New reference. + # Return the slice of sequence object o between i1 and i2, or NULL + # on failure. This is the equivalent of the Python expression + # "o[i1:i2]". + + int PySequence_SetItem(object o, Py_ssize_t i, object v) except -1 + # Assign object v to the ith element of o. Returns -1 on + # failure. This is the equivalent of the Python statement "o[i] = + # v". This function does not steal a reference to v. + + int PySequence_DelItem(object o, Py_ssize_t i) except -1 + # Delete the ith element of object o. Returns -1 on failure. This + # is the equivalent of the Python statement "del o[i]". + + int PySequence_SetSlice(object o, Py_ssize_t i1, Py_ssize_t i2, object v) except -1 + # Assign the sequence object v to the slice in sequence object o + # from i1 to i2. This is the equivalent of the Python statement + # "o[i1:i2] = v". + + int PySequence_DelSlice(object o, Py_ssize_t i1, Py_ssize_t i2) except -1 + # Delete the slice in sequence object o from i1 to i2. Returns -1 + # on failure. This is the equivalent of the Python statement "del + # o[i1:i2]". + + int PySequence_Count(object o, object value) except -1 + # Return the number of occurrences of value in o, that is, return + # the number of keys for which o[key] == value. On failure, return + # -1. This is equivalent to the Python expression + # "o.count(value)". + + int PySequence_Contains(object o, object value) except -1 + # Determine if o contains value. If an item in o is equal to + # value, return 1, otherwise return 0. On error, return -1. This + # is equivalent to the Python expression "value in o". + + Py_ssize_t PySequence_Index(object o, object value) except -1 + # Return the first index i for which o[i] == value. On error, + # return -1. This is equivalent to the Python expression + # "o.index(value)". + + object PySequence_List(object o) + # Return value: New reference. + # Return a list object with the same contents as the arbitrary + # sequence o. The returned list is guaranteed to be new. + + object PySequence_Tuple(object o) + # Return value: New reference. + # Return a tuple object with the same contents as the arbitrary + # sequence o or NULL on failure. If o is a tuple, a new reference + # will be returned, otherwise a tuple will be constructed with the + # appropriate contents. This is equivalent to the Python + # expression "tuple(o)". + + object PySequence_Fast(object o, char *m) + # Return value: New reference. + # Returns the sequence o as a tuple, unless it is already a tuple + # or list, in which case o is returned. Use + # PySequence_Fast_GET_ITEM() to access the members of the + # result. Returns NULL on failure. If the object is not a + # sequence, raises TypeError with m as the message text. + + PyObject* PySequence_Fast_GET_ITEM(object o, Py_ssize_t i) + # Return value: Borrowed reference. + # Return the ith element of o, assuming that o was returned by + # PySequence_Fast(), o is not NULL, and that i is within bounds. + + PyObject** PySequence_Fast_ITEMS(object o) + # Return the underlying array of PyObject pointers. Assumes that o + # was returned by PySequence_Fast() and o is not NULL. + + object PySequence_ITEM(object o, Py_ssize_t i) + # Return value: New reference. + # Return the ith element of o or NULL on failure. Macro form of + # PySequence_GetItem() but without checking that + # PySequence_Check(o) is true and without adjustment for negative + # indices. + + Py_ssize_t PySequence_Fast_GET_SIZE(object o) + # Returns the length of o, assuming that o was returned by + # PySequence_Fast() and that o is not NULL. The size can also be + # gotten by calling PySequence_Size() on o, but + # PySequence_Fast_GET_SIZE() is faster because it can assume o is + # a list or tuple. + + diff --git a/contrib/tools/cython/Cython/Includes/cpython/set.pxd b/contrib/tools/cython/Cython/Includes/cpython/set.pxd new file mode 100644 index 00000000000..ae31d28ae36 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/set.pxd @@ -0,0 +1,119 @@ +cdef extern from "Python.h": + + ############################################################################ + # 7.5.14 Set Objects + ############################################################################ + + # This section details the public API for set and frozenset + # objects. Any functionality not listed below is best accessed + # using the either the abstract object protocol (including + # PyObject_CallMethod(), PyObject_RichCompareBool(), + # PyObject_Hash(), PyObject_Repr(), PyObject_IsTrue(), + # PyObject_Print(), and PyObject_GetIter()) or the abstract number + # protocol (including PyNumber_Add(), PyNumber_Subtract(), + # PyNumber_Or(), PyNumber_Xor(), PyNumber_InPlaceAdd(), + # PyNumber_InPlaceSubtract(), PyNumber_InPlaceOr(), and + # PyNumber_InPlaceXor()). + + # PySetObject + # This subtype of PyObject is used to hold the internal data for + # both set and frozenset objects. It is like a PyDictObject in + # that it is a fixed size for small sets (much like tuple storage) + # and will point to a separate, variable sized block of memory for + # medium and large sized sets (much like list storage). None of + # the fields of this structure should be considered public and are + # subject to change. All access should be done through the + # documented API rather than by manipulating the values in the + # structure. + + # PyTypeObject PySet_Type + # This is an instance of PyTypeObject representing the Python set type. + + # PyTypeObject PyFrozenSet_Type + # This is an instance of PyTypeObject representing the Python frozenset type. + + # The following type check macros work on pointers to any Python + # object. Likewise, the constructor functions work with any + # iterable Python object. + + bint PyAnySet_Check(object p) + # Return true if p is a set object, a frozenset object, or an + # instance of a subtype. + + bint PyAnySet_CheckExact(object p) + # Return true if p is a set object or a frozenset object but not + # an instance of a subtype. + + bint PyFrozenSet_Check(object p) + # Return true if p is a frozenset object or an instance of a subtype. + + bint PyFrozenSet_CheckExact(object p) + # Return true if p is a frozenset object but not an instance of a subtype. + + bint PySet_Check(object p) + # Return true if p is a set object or an instance of a subtype. + + object PySet_New(object iterable) + # Return value: New reference. + # Return a new set containing objects returned by the + # iterable. The iterable may be NULL to create a new empty + # set. Return the new set on success or NULL on failure. Raise + # TypeError if iterable is not actually iterable. The constructor + # is also useful for copying a set (c=set(s)). + + object PyFrozenSet_New(object iterable) + # Return value: New reference. + # Return a new frozenset containing objects returned by the + # iterable. The iterable may be NULL to create a new empty + # frozenset. Return the new set on success or NULL on + # failure. Raise TypeError if iterable is not actually iterable. + + + # The following functions and macros are available for instances + # of set or frozenset or instances of their subtypes. + + Py_ssize_t PySet_Size(object anyset) except -1 + # Return the length of a set or frozenset object. Equivalent to + # "len(anyset)". Raises a PyExc_SystemError if anyset is not a + # set, frozenset, or an instance of a subtype. + + Py_ssize_t PySet_GET_SIZE(object anyset) + # Macro form of PySet_Size() without error checking. + + bint PySet_Contains(object anyset, object key) except -1 + # Return 1 if found, 0 if not found, and -1 if an error is + # encountered. Unlike the Python __contains__() method, this + # function does not automatically convert unhashable sets into + # temporary frozensets. Raise a TypeError if the key is + # unhashable. Raise PyExc_SystemError if anyset is not a set, + # frozenset, or an instance of a subtype. + + + # The following functions are available for instances of set or + # its subtypes but not for instances of frozenset or its subtypes. + + int PySet_Add(object set, object key) except -1 + # Add key to a set instance. Does not apply to frozenset + # instances. Return 0 on success or -1 on failure. Raise a + # TypeError if the key is unhashable. Raise a MemoryError if there + # is no room to grow. Raise a SystemError if set is an not an + # instance of set or its subtype. + + bint PySet_Discard(object set, object key) except -1 + # Return 1 if found and removed, 0 if not found (no action taken), + # and -1 if an error is encountered. Does not raise KeyError for + # missing keys. Raise a TypeError if the key is unhashable. Unlike + # the Python discard() method, this function does not + # automatically convert unhashable sets into temporary + # frozensets. Raise PyExc_SystemError if set is an not an instance + # of set or its subtype. + + object PySet_Pop(object set) + # Return value: New reference. + # Return a new reference to an arbitrary object in the set, and + # removes the object from the set. Return NULL on failure. Raise + # KeyError if the set is empty. Raise a SystemError if set is an + # not an instance of set or its subtype. + + int PySet_Clear(object set) + # Empty an existing set of all elements. diff --git a/contrib/tools/cython/Cython/Includes/cpython/slice.pxd b/contrib/tools/cython/Cython/Includes/cpython/slice.pxd new file mode 100644 index 00000000000..202dea716c7 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/slice.pxd @@ -0,0 +1,70 @@ +cdef extern from "Python.h": + + # PyTypeObject PySlice_Type + # + # The type object for slice objects. This is the same as slice and types.SliceType + + bint PySlice_Check(object ob) + # + # Return true if ob is a slice object; ob must not be NULL. + + slice PySlice_New(object start, object stop, object step) + # + # Return a new slice object with the given values. The start, stop, and step + # parameters are used as the values of the slice object attributes of the same + # names. Any of the values may be NULL, in which case the None will be used + # for the corresponding attribute. Return NULL if the new object could not be + # allocated. + + int PySlice_GetIndices(object slice, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) except? -1 + # + # Retrieve the start, stop and step indices from the slice object slice, + # assuming a sequence of length length. Treats indices greater than length + # as errors. + # + # Returns 0 on success and -1 on error with no exception set (unless one + # of the indices was not None and failed to be converted to an integer, + # in which case -1 is returned with an exception set). + # + # You probably do not want to use this function. + # + # Changed in version 3.2: The parameter type for the slice parameter was + # PySliceObject* before. + + int PySlice_GetIndicesEx(object slice, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, + Py_ssize_t *slicelength) except -1 + # + # Usable replacement for PySlice_GetIndices(). Retrieve the start, stop, and step + # indices from the slice object slice assuming a sequence of length length, and + # store the length of the slice in slicelength. Out of bounds indices are clipped + # in a manner consistent with the handling of normal slices. + # + # Returns 0 on success and -1 on error with exception set. + # + # Changed in version 3.2: The parameter type for the slice parameter was + # PySliceObject* before. + + int PySlice_Unpack(object slice, Py_ssize_t *start, Py_ssize_t *stop, + Py_ssize_t *step) except -1 + # Extract the start, stop and step data members from a slice object as C + # integers. Silently reduce values larger than PY_SSIZE_T_MAX to + # PY_SSIZE_T_MAX, silently boost the start and stop values less than + # PY_SSIZE_T_MIN to PY_SSIZE_T_MIN, and silently boost the step values + # less than -PY_SSIZE_T_MAX to -PY_SSIZE_T_MAX. + + # Return -1 on error, 0 on success. + + # New in version 3.6.1. + + Py_ssize_t PySlice_AdjustIndices(Py_ssize_t length, Py_ssize_t *start, + Py_ssize_t *stop, Py_ssize_t step) + # Adjust start/end slice indices assuming a sequence of the specified + # length. Out of bounds indices are clipped in a manner consistent with + # the handling of normal slices. + + # Return the length of the slice. Always successful. Doesn’t call Python + # code. + + # New in version 3.6.1. diff --git a/contrib/tools/cython/Cython/Includes/cpython/string.pxd b/contrib/tools/cython/Cython/Includes/cpython/string.pxd new file mode 100644 index 00000000000..8af78f3dde6 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/string.pxd @@ -0,0 +1,198 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + ctypedef struct va_list + + ############################################################################ + # 7.3.1 String Objects + ############################################################################ + + # These functions raise TypeError when expecting a string + # parameter and are called with a non-string parameter. + # PyStringObject + # This subtype of PyObject represents a Python string object. + # PyTypeObject PyString_Type + # This instance of PyTypeObject represents the Python string type; + # it is the same object as str and types.StringType in the Python + # layer. + + bint PyString_Check(object o) + # Return true if the object o is a string object or an instance of + # a subtype of the string type. + + bint PyString_CheckExact(object o) + # Return true if the object o is a string object, but not an instance of a subtype of the string type. + + object PyString_FromString(char *v) + # Return value: New reference. + # Return a new string object with the value v on success, and NULL + # on failure. The parameter v must not be NULL; it will not be + # checked. + + object PyString_FromStringAndSize(char *v, Py_ssize_t len) + # Return value: New reference. + # Return a new string object with the value v and length len on + # success, and NULL on failure. If v is NULL, the contents of the + # string are uninitialized. + + object PyString_FromFormat(char *format, ...) + # Return value: New reference. + # Take a C printf()-style format string and a variable number of + # arguments, calculate the size of the resulting Python string and + # return a string with the values formatted into it. The variable + # arguments must be C types and must correspond exactly to the + # format characters in the format string. The following format + # characters are allowed: + # Format Characters Type Comment + # %% n/a The literal % character. + # %c int A single character, represented as an C int. + # %d int Exactly equivalent to printf("%d"). + # %u unsigned int Exactly equivalent to printf("%u"). + # %ld long Exactly equivalent to printf("%ld"). + # %lu unsigned long Exactly equivalent to printf("%lu"). + # %zd Py_ssize_t Exactly equivalent to printf("%zd"). + # %zu size_t Exactly equivalent to printf("%zu"). + # %i int Exactly equivalent to printf("%i"). + # %x int Exactly equivalent to printf("%x"). + # %s char* A null-terminated C character array. + + # %p void* The hex representation of a C pointer. + # Mostly equivalent to printf("%p") except that it is guaranteed to + # start with the literal 0x regardless of what the platform's printf + # yields. + # An unrecognized format character causes all the rest of the + # format string to be copied as-is to the result string, and any + # extra arguments discarded. + + object PyString_FromFormatV(char *format, va_list vargs) + # Return value: New reference. + # Identical to PyString_FromFormat() except that it takes exactly two arguments. + + Py_ssize_t PyString_Size(object string) except -1 + # Return the length of the string in string object string. + + Py_ssize_t PyString_GET_SIZE(object string) + # Macro form of PyString_Size() but without error checking. + + char* PyString_AsString(object string) except NULL + # Return a NUL-terminated representation of the contents of + # string. The pointer refers to the internal buffer of string, not + # a copy. The data must not be modified in any way, unless the + # string was just created using PyString_FromStringAndSize(NULL, + # size). It must not be deallocated. If string is a Unicode + # object, this function computes the default encoding of string + # and operates on that. If string is not a string object at all, + # PyString_AsString() returns NULL and raises TypeError. + + char* PyString_AS_STRING(object string) + # Macro form of PyString_AsString() but without error + # checking. Only string objects are supported; no Unicode objects + # should be passed. + + int PyString_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1 + # Return a NULL-terminated representation of the contents of the + # object obj through the output variables buffer and length. + # + # The function accepts both string and Unicode objects as + # input. For Unicode objects it returns the default encoded + # version of the object. If length is NULL, the resulting buffer + # may not contain NUL characters; if it does, the function returns + # -1 and a TypeError is raised. + + # The buffer refers to an internal string buffer of obj, not a + # copy. The data must not be modified in any way, unless the + # string was just created using PyString_FromStringAndSize(NULL, + # size). It must not be deallocated. If string is a Unicode + # object, this function computes the default encoding of string + # and operates on that. If string is not a string object at all, + # PyString_AsStringAndSize() returns -1 and raises TypeError. + + void PyString_Concat(PyObject **string, object newpart) + # Create a new string object in *string containing the contents of + # newpart appended to string; the caller will own the new + # reference. The reference to the old value of string will be + # stolen. If the new string cannot be created, the old reference + # to string will still be discarded and the value of *string will + # be set to NULL; the appropriate exception will be set. + + void PyString_ConcatAndDel(PyObject **string, object newpart) + # Create a new string object in *string containing the contents of + # newpart appended to string. This version decrements the + # reference count of newpart. + + int _PyString_Resize(PyObject **string, Py_ssize_t newsize) except -1 + # A way to resize a string object even though it is + # ``immutable''. Only use this to build up a brand new string + # object; don't use this if the string may already be known in + # other parts of the code. It is an error to call this function if + # the refcount on the input string object is not one. Pass the + # address of an existing string object as an lvalue (it may be + # written into), and the new size desired. On success, *string + # holds the resized string object and 0 is returned; the address + # in *string may differ from its input value. If the reallocation + # fails, the original string object at *string is deallocated, + # *string is set to NULL, a memory exception is set, and -1 is + # returned. + + object PyString_Format(object format, object args) + # Return value: New reference. Return a new string object from + # format and args. Analogous to format % args. The args argument + # must be a tuple. + + void PyString_InternInPlace(PyObject **string) + # Intern the argument *string in place. The argument must be the + # address of a pointer variable pointing to a Python string + # object. If there is an existing interned string that is the same + # as *string, it sets *string to it (decrementing the reference + # count of the old string object and incrementing the reference + # count of the interned string object), otherwise it leaves + # *string alone and interns it (incrementing its reference + # count). (Clarification: even though there is a lot of talk about + # reference counts, think of this function as + # reference-count-neutral; you own the object after the call if + # and only if you owned it before the call.) + + object PyString_InternFromString(char *v) + # Return value: New reference. + # A combination of PyString_FromString() and + # PyString_InternInPlace(), returning either a new string object + # that has been interned, or a new (``owned'') reference to an + # earlier interned string object with the same value. + + object PyString_Decode(char *s, Py_ssize_t size, char *encoding, char *errors) + # Return value: New reference. + # Create an object by decoding size bytes of the encoded buffer s + # using the codec registered for encoding. encoding and errors + # have the same meaning as the parameters of the same name in the + # unicode() built-in function. The codec to be used is looked up + # using the Python codec registry. Return NULL if an exception was + # raised by the codec. + + object PyString_AsDecodedObject(object str, char *encoding, char *errors) + # Return value: New reference. + # Decode a string object by passing it to the codec registered for + # encoding and return the result as Python object. encoding and + # errors have the same meaning as the parameters of the same name + # in the string encode() method. The codec to be used is looked up + # using the Python codec registry. Return NULL if an exception was + # raised by the codec. + + object PyString_Encode(char *s, Py_ssize_t size, char *encoding, char *errors) + # Return value: New reference. + # Encode the char buffer of the given size by passing it to the + # codec registered for encoding and return a Python + # object. encoding and errors have the same meaning as the + # parameters of the same name in the string encode() method. The + # codec to be used is looked up using the Python codec + # registry. Return NULL if an exception was raised by the codec. + + object PyString_AsEncodedObject(object str, char *encoding, char *errors) + # Return value: New reference. + # Encode a string object using the codec registered for encoding + # and return the result as Python object. encoding and errors have + # the same meaning as the parameters of the same name in the + # string encode() method. The codec to be used is looked up using + # the Python codec registry. Return NULL if an exception was + # raised by the codec. + + diff --git a/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd b/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd new file mode 100644 index 00000000000..09c46e0b4bc --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd @@ -0,0 +1,71 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + ############################################################################ + # Tuples + ############################################################################ + + bint PyTuple_Check(object p) + # Return true if p is a tuple object or an instance of a subtype + # of the tuple type. + + bint PyTuple_CheckExact(object p) + # Return true if p is a tuple object, but not an instance of a subtype of the tuple type. + + tuple PyTuple_New(Py_ssize_t len) + # Return value: New reference. + # Return a new tuple object of size len, or NULL on failure. + + tuple PyTuple_Pack(Py_ssize_t n, ...) + # Return value: New reference. + # Return a new tuple object of size n, or NULL on failure. The + # tuple values are initialized to the subsequent n C arguments + # pointing to Python objects. "PyTuple_Pack(2, a, b)" is + # equivalent to "Py_BuildValue("(OO)", a, b)". + + Py_ssize_t PyTuple_Size(object p) except -1 + # Take a pointer to a tuple object, and return the size of that tuple. + + Py_ssize_t PyTuple_GET_SIZE(object p) + # Return the size of the tuple p, which must be non-NULL and point + # to a tuple; no error checking is performed. + + PyObject* PyTuple_GetItem(object p, Py_ssize_t pos) except NULL + # Return value: Borrowed reference. + # Return the object at position pos in the tuple pointed to by + # p. If pos is out of bounds, return NULL and sets an IndexError + # exception. + + PyObject* PyTuple_GET_ITEM(object p, Py_ssize_t pos) + # Return value: Borrowed reference. + # Like PyTuple_GetItem(), but does no checking of its arguments. + + tuple PyTuple_GetSlice(object p, Py_ssize_t low, Py_ssize_t high) + # Return value: New reference. + # Take a slice of the tuple pointed to by p from low to high and return it as a new tuple. + + int PyTuple_SetItem(object p, Py_ssize_t pos, object o) except -1 + # Insert a reference to object o at position pos of the tuple + # pointed to by p. Return 0 on success. Note: This function + # ``steals'' a reference to o. + + void PyTuple_SET_ITEM(object p, Py_ssize_t pos, object o) + # Like PyTuple_SetItem(), but does no error checking, and should + # only be used to fill in brand new tuples. Note: This function + # ``steals'' a reference to o. + + int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) except -1 + # Can be used to resize a tuple. newsize will be the new length of + # the tuple. Because tuples are supposed to be immutable, this + # should only be used if there is only one reference to the + # object. Do not use this if the tuple may already be known to + # some other part of the code. The tuple will always grow or + # shrink at the end. Think of this as destroying the old tuple and + # creating a new one, only more efficiently. Returns 0 on + # success. Client code should never assume that the resulting + # value of *p will be the same as before calling this function. If + # the object referenced by *p is replaced, the original *p is + # destroyed. On failure, returns -1 and sets *p to NULL, and + # raises MemoryError or SystemError. + diff --git a/contrib/tools/cython/Cython/Includes/cpython/type.pxd b/contrib/tools/cython/Cython/Includes/cpython/type.pxd new file mode 100644 index 00000000000..a1d094e37c7 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/type.pxd @@ -0,0 +1,48 @@ + +cdef extern from "Python.h": + # The C structure of the objects used to describe built-in types. + + ############################################################################ + # 7.1.1 Type Objects + ############################################################################ + + ctypedef class __builtin__.type [object PyTypeObject]: + pass + + # PyObject* PyType_Type + # This is the type object for type objects; it is the same object + # as type and types.TypeType in the Python layer. + + bint PyType_Check(object o) + # Return true if the object o is a type object, including + # instances of types derived from the standard type object. Return + # false in all other cases. + + bint PyType_CheckExact(object o) + # Return true if the object o is a type object, but not a subtype + # of the standard type object. Return false in all other + # cases. + + bint PyType_HasFeature(object o, int feature) + # Return true if the type object o sets the feature feature. Type + # features are denoted by single bit flags. + + bint PyType_IS_GC(object o) + # Return true if the type object includes support for the cycle + # detector; this tests the type flag Py_TPFLAGS_HAVE_GC. + + bint PyType_IsSubtype(type a, type b) + # Return true if a is a subtype of b. + + object PyType_GenericAlloc(object type, Py_ssize_t nitems) + # Return value: New reference. + + object PyType_GenericNew(type type, object args, object kwds) + # Return value: New reference. + + bint PyType_Ready(type type) except -1 + # Finalize a type object. This should be called on all type + # objects to finish their initialization. This function is + # responsible for adding inherited slots from a type's base + # class. Return 0 on success, or return -1 and sets an exception + # on error. diff --git a/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd b/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd new file mode 100644 index 00000000000..2072c8cb2ae --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd @@ -0,0 +1,572 @@ +cdef extern from *: + # Return true if the object o is a Unicode object or an instance + # of a Unicode subtype. Changed in version 2.2: Allowed subtypes + # to be accepted. + bint PyUnicode_Check(object o) + + # Return true if the object o is a Unicode object, but not an + # instance of a subtype. New in version 2.2. + bint PyUnicode_CheckExact(object o) + + # Return the size of the object. o has to be a PyUnicodeObject + # (not checked). + # + # Deprecated since version 3.3, will be removed in version 3.10: + # Part of the old-style Unicode API, please migrate to using + # PyUnicode_GET_LENGTH(). + Py_ssize_t PyUnicode_GET_SIZE(object o) + + # Return the length of the Unicode string, in code points. o has + # to be a Unicode object in the “canonical” representation (not + # checked). + # + # New in version 3.3. + Py_ssize_t PyUnicode_GET_LENGTH(object o) + + # Return the size of the object's internal buffer in bytes. o has + # to be a PyUnicodeObject (not checked). + Py_ssize_t PyUnicode_GET_DATA_SIZE(object o) + + # Return a pointer to the internal Py_UNICODE buffer of the + # object. o has to be a PyUnicodeObject (not checked). + Py_UNICODE* PyUnicode_AS_UNICODE(object o) + + # Return a pointer to the internal buffer of the object. o has to + # be a PyUnicodeObject (not checked). + char* PyUnicode_AS_DATA(object o) + + # Return 1 or 0 depending on whether ch is a whitespace character. + bint Py_UNICODE_ISSPACE(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is a lowercase character. + bint Py_UNICODE_ISLOWER(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is an uppercase character. + bint Py_UNICODE_ISUPPER(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is a titlecase character. + bint Py_UNICODE_ISTITLE(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is a linebreak character. + bint Py_UNICODE_ISLINEBREAK(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is a decimal character. + bint Py_UNICODE_ISDECIMAL(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is a digit character. + bint Py_UNICODE_ISDIGIT(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is a numeric character. + bint Py_UNICODE_ISNUMERIC(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is an alphabetic character. + bint Py_UNICODE_ISALPHA(Py_UCS4 ch) + + # Return 1 or 0 depending on whether ch is an alphanumeric character. + bint Py_UNICODE_ISALNUM(Py_UCS4 ch) + + # Return the character ch converted to lower case. + # Used to return a Py_UNICODE value before Py3.3. + Py_UCS4 Py_UNICODE_TOLOWER(Py_UCS4 ch) + + # Return the character ch converted to upper case. + # Used to return a Py_UNICODE value before Py3.3. + Py_UCS4 Py_UNICODE_TOUPPER(Py_UCS4 ch) + + # Return the character ch converted to title case. + # Used to return a Py_UNICODE value before Py3.3. + Py_UCS4 Py_UNICODE_TOTITLE(Py_UCS4 ch) + + # Return the character ch converted to a decimal positive + # integer. Return -1 if this is not possible. This macro does not + # raise exceptions. + int Py_UNICODE_TODECIMAL(Py_UCS4 ch) + + # Return the character ch converted to a single digit + # integer. Return -1 if this is not possible. This macro does not + # raise exceptions. + int Py_UNICODE_TODIGIT(Py_UCS4 ch) + + # Return the character ch converted to a double. Return -1.0 if + # this is not possible. This macro does not raise exceptions. + double Py_UNICODE_TONUMERIC(Py_UCS4 ch) + + # To create Unicode objects and access their basic sequence + # properties, use these APIs: + + # Create a Unicode Object from the Py_UNICODE buffer u of the + # given size. u may be NULL which causes the contents to be + # undefined. It is the user's responsibility to fill in the needed + # data. The buffer is copied into the new object. If the buffer is + # not NULL, the return value might be a shared object. Therefore, + # modification of the resulting Unicode object is only allowed + # when u is NULL. + unicode PyUnicode_FromUnicode(Py_UNICODE *u, Py_ssize_t size) + + # Create a Unicode Object from the given Unicode code point ordinal. + # + # The ordinal must be in range(0x10000) on narrow Python builds + # (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError + # is raised in case it is not. + unicode PyUnicode_FromOrdinal(int ordinal) + + # Return a read-only pointer to the Unicode object's internal + # Py_UNICODE buffer, NULL if unicode is not a Unicode object. + Py_UNICODE* PyUnicode_AsUnicode(object o) except NULL + + # Return the length of the Unicode object. + Py_ssize_t PyUnicode_GetSize(object o) except -1 + + # Coerce an encoded object obj to an Unicode object and return a + # reference with incremented refcount. + # String and other char buffer compatible objects are decoded + # according to the given encoding and using the error handling + # defined by errors. Both can be NULL to have the interface use + # the default values (see the next section for details). + # All other objects, including Unicode objects, cause a TypeError + # to be set. + object PyUnicode_FromEncodedObject(object o, char *encoding, char *errors) + + # Shortcut for PyUnicode_FromEncodedObject(obj, NULL, "strict") + # which is used throughout the interpreter whenever coercion to + # Unicode is needed. + object PyUnicode_FromObject(object obj) + + # If the platform supports wchar_t and provides a header file + # wchar.h, Python can interface directly to this type using the + # following functions. Support is optimized if Python's own + # Py_UNICODE type is identical to the system's wchar_t. + + #ctypedef int wchar_t + + # Create a Unicode object from the wchar_t buffer w of the given + # size. Return NULL on failure. + #PyObject* PyUnicode_FromWideChar(wchar_t *w, Py_ssize_t size) + + #Py_ssize_t PyUnicode_AsWideChar(object o, wchar_t *w, Py_ssize_t size) + + +# Unicode Methods + + # Concat two strings giving a new Unicode string. + # Return value: New reference. + unicode PyUnicode_Concat(object left, object right) + + # Split a string giving a list of Unicode strings. If sep is NULL, + # splitting will be done at all whitespace substrings. Otherwise, + # splits occur at the given separator. At most maxsplit splits will + # be done. If negative, no limit is set. Separators are not included + # in the resulting list. + # Return value: New reference. + list PyUnicode_Split(object s, object sep, Py_ssize_t maxsplit) + + # Split a Unicode string at line breaks, returning a list of Unicode + # strings. CRLF is considered to be one line break. If keepend is 0, + # the Line break characters are not included in the resulting strings. + # Return value: New reference. + list PyUnicode_Splitlines(object s, bint keepend) + + # Translate a string by applying a character mapping table to it and + # return the resulting Unicode object. + # + # The mapping table must map Unicode ordinal integers to Unicode ordinal + # integers or None (causing deletion of the character). + # + # Mapping tables need only provide the __getitem__() interface; + # dictionaries and sequences work well. Unmapped character ordinals (ones + # which cause a LookupError) are left untouched and are copied as-is. + # + # errors has the usual meaning for codecs. It may be NULL which indicates + # to use the default error handling. + # Return value: New reference. + unicode PyUnicode_Translate(object str, object table, const char *errors) + + # Join a sequence of strings using the given separator and return the + # resulting Unicode string. + # Return value: New reference. + unicode PyUnicode_Join(object separator, object seq) + + # Return 1 if substr matches str[start:end] at the given tail end + # (direction == -1 means to do a prefix match, direction == 1 a + # suffix match), 0 otherwise. + # Return -1 if an error occurred. + Py_ssize_t PyUnicode_Tailmatch(object str, object substr, + Py_ssize_t start, Py_ssize_t end, int direction) except -1 + + # Return the first position of substr in str[start:end] using the given + # direction (direction == 1 means to do a forward search, direction == -1 + # a backward search). The return value is the index of the first match; + # a value of -1 indicates that no match was found, and -2 indicates that an + # error occurred and an exception has been set. + Py_ssize_t PyUnicode_Find(object str, object substr, Py_ssize_t start, Py_ssize_t end, int direction) except -2 + + # Return the first position of the character ch in str[start:end] using + # the given direction (direction == 1 means to do a forward search, + # direction == -1 a backward search). The return value is the index of + # the first match; a value of -1 indicates that no match was found, and + # -2 indicates that an error occurred and an exception has been set. + # New in version 3.3. + Py_ssize_t PyUnicode_FindChar(object str, Py_UCS4 ch, Py_ssize_t start, Py_ssize_t end, int direction) except -2 + + # Return the number of non-overlapping occurrences of substr in + # str[start:end]. Return -1 if an error occurred. + Py_ssize_t PyUnicode_Count(object str, object substr, Py_ssize_t start, Py_ssize_t end) except -1 + + # Replace at most maxcount occurrences of substr in str with replstr and + # return the resulting Unicode object. maxcount == -1 means replace all + # occurrences. + # Return value: New reference. + unicode PyUnicode_Replace(object str, object substr, object replstr, Py_ssize_t maxcount) + + # Compare two strings and return -1, 0, 1 for less than, + # equal, and greater than, respectively. + int PyUnicode_Compare(object left, object right) except? -1 + + # Compare a unicode object, uni, with string and return -1, 0, 1 for less than, + # equal, and greater than, respectively. It is best to pass only ASCII-encoded + # strings, but the function interprets the input string as ISO-8859-1 if it + # contains non-ASCII characters. + int PyUnicode_CompareWithASCIIString(object uni, const char *string) + + # Rich compare two unicode strings and return one of the following: + # + # NULL in case an exception was raised + # Py_True or Py_False for successful comparisons + # Py_NotImplemented in case the type combination is unknown + # + # Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in case + # the conversion of the arguments to Unicode fails with a UnicodeDecodeError. + # + # Possible values for op are Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, and Py_LE. + object PyUnicode_RichCompare(object left, object right, int op) + + # Return a new string object from format and args; this is analogous to + # format % args. + # Return value: New reference. + unicode PyUnicode_Format(object format, object args) + + # Check whether element is contained in container and return true or false + # accordingly. + # + # element has to coerce to a one element Unicode string. -1 is returned + # if there was an error. + int PyUnicode_Contains(object container, object element) except -1 + + # Intern the argument *string in place. The argument must be the address + # of a pointer variable pointing to a Python unicode string object. If + # there is an existing interned string that is the same as *string, it sets + # *string to it (decrementing the reference count of the old string object + # and incrementing the reference count of the interned string object), + # otherwise it leaves *string alone and interns it (incrementing its reference + # count). (Clarification: even though there is a lot of talk about reference + # counts, think of this function as reference-count-neutral; you own the object + # after the call if and only if you owned it before the call.) + #void PyUnicode_InternInPlace(PyObject **string) + + # A combination of PyUnicode_FromString() and PyUnicode_InternInPlace(), + # returning either a new unicode string object that has been interned, or + # a new ("owned") reference to an earlier interned string object with the + # same value. + unicode PyUnicode_InternFromString(const char *v) + + +# Codecs + + # Create a Unicode object by decoding size bytes of the encoded + # string s. encoding and errors have the same meaning as the + # parameters of the same name in the unicode() builtin + # function. The codec to be used is looked up using the Python + # codec registry. Return NULL if an exception was raised by the + # codec. + object PyUnicode_Decode(char *s, Py_ssize_t size, char *encoding, char *errors) + + # Encode the Py_UNICODE buffer of the given size and return a + # Python string object. encoding and errors have the same meaning + # as the parameters of the same name in the Unicode encode() + # method. The codec to be used is looked up using the Python codec + # registry. Return NULL if an exception was raised by the codec. + object PyUnicode_Encode(Py_UNICODE *s, Py_ssize_t size, + char *encoding, char *errors) + + # Encode a Unicode object and return the result as Python string + # object. encoding and errors have the same meaning as the + # parameters of the same name in the Unicode encode() method. The + # codec to be used is looked up using the Python codec + # registry. Return NULL if an exception was raised by the codec. + object PyUnicode_AsEncodedString(object unicode, char *encoding, char *errors) + +# These are the UTF-8 codec APIs: + + # Create a Unicode object by decoding size bytes of the UTF-8 + # encoded string s. Return NULL if an exception was raised by the + # codec. + unicode PyUnicode_DecodeUTF8(char *s, Py_ssize_t size, char *errors) + + # If consumed is NULL, behave like PyUnicode_DecodeUTF8(). If + # consumed is not NULL, trailing incomplete UTF-8 byte sequences + # will not be treated as an error. Those bytes will not be decoded + # and the number of bytes that have been decoded will be stored in + # consumed. New in version 2.4. + unicode PyUnicode_DecodeUTF8Stateful(char *s, Py_ssize_t size, char *errors, Py_ssize_t *consumed) + + # Encode the Py_UNICODE buffer of the given size using UTF-8 and + # return a Python string object. Return NULL if an exception was + # raised by the codec. + bytes PyUnicode_EncodeUTF8(Py_UNICODE *s, Py_ssize_t size, char *errors) + + # Encode a Unicode objects using UTF-8 and return the result as Python bytes object. Error handling is ``strict''. Return NULL if an exception was raised by the codec. + bytes PyUnicode_AsUTF8String(object unicode) + + + # Return a pointer to the UTF-8 encoding of the Unicode object, + # and store the size of the encoded representation (in bytes) in size. + # The size argument can be NULL; in this case no size will be stored. + # The returned buffer always has an extra null byte appended + # (not included in size), regardless of whether there are any + # other null code points. + + # In the case of an error, NULL is returned with an exception set and + # no size is stored. + + # This caches the UTF-8 representation of the string in the Unicode + # object, and subsequent calls will return a pointer to the same buffer. + # The caller is not responsible for deallocating the buffer + const char* PyUnicode_AsUTF8AndSize(object unicode, Py_ssize_t *size) + +# These are the UTF-16 codec APIs: + + # Decode length bytes from a UTF-16 encoded buffer string and + # return the corresponding Unicode object. errors (if non-NULL) + # defines the error handling. It defaults to ``strict''. + # + # If byteorder is non-NULL, the decoder starts decoding using the + # given byte order: + # + # *byteorder == -1: little endian + # *byteorder == 0: native order + # *byteorder == 1: big endian + # + # and then switches if the first two bytes of the input data are a + # byte order mark (BOM) and the specified byte order is native + # order. This BOM is not copied into the resulting Unicode + # string. After completion, *byteorder is set to the current byte + # order at the. + # + # If byteorder is NULL, the codec starts in native order mode. + unicode PyUnicode_DecodeUTF16(char *s, Py_ssize_t size, char *errors, int *byteorder) + + # If consumed is NULL, behave like PyUnicode_DecodeUTF16(). If + # consumed is not NULL, PyUnicode_DecodeUTF16Stateful() will not + # treat trailing incomplete UTF-16 byte sequences (such as an odd + # number of bytes or a split surrogate pair) as an error. Those + # bytes will not be decoded and the number of bytes that have been + # decoded will be stored in consumed. New in version 2.4. + unicode PyUnicode_DecodeUTF16Stateful(char *s, Py_ssize_t size, char *errors, int *byteorder, Py_ssize_t *consumed) + + # Return a Python string object holding the UTF-16 encoded value + # of the Unicode data in s. If byteorder is not 0, output is + # written according to the following byte order: + # + # byteorder == -1: little endian + # byteorder == 0: native byte order (writes a BOM mark) + # byteorder == 1: big endian + # + # If byteorder is 0, the output string will always start with the + # Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark + # is prepended. + # + # If Py_UNICODE_WIDE is defined, a single Py_UNICODE value may get + # represented as a surrogate pair. If it is not defined, each + # Py_UNICODE values is interpreted as an UCS-2 character. + bytes PyUnicode_EncodeUTF16(Py_UNICODE *s, Py_ssize_t size, char *errors, int byteorder) + + # Return a Python string using the UTF-16 encoding in native byte + # order. The string always starts with a BOM mark. Error handling + # is ``strict''. Return NULL if an exception was raised by the + # codec. + bytes PyUnicode_AsUTF16String(object unicode) + +# These are the ``Unicode Escape'' codec APIs: + + # Create a Unicode object by decoding size bytes of the + # Unicode-Escape encoded string s. Return NULL if an exception was + # raised by the codec. + object PyUnicode_DecodeUnicodeEscape(char *s, Py_ssize_t size, char *errors) + + # Encode the Py_UNICODE buffer of the given size using + # Unicode-Escape and return a Python string object. Return NULL if + # an exception was raised by the codec. + object PyUnicode_EncodeUnicodeEscape(Py_UNICODE *s, Py_ssize_t size) + + # Encode a Unicode objects using Unicode-Escape and return the + # result as Python string object. Error handling is + # ``strict''. Return NULL if an exception was raised by the codec. + object PyUnicode_AsUnicodeEscapeString(object unicode) + +# These are the ``Raw Unicode Escape'' codec APIs: + + # Create a Unicode object by decoding size bytes of the + # Raw-Unicode-Escape encoded string s. Return NULL if an exception + # was raised by the codec. + object PyUnicode_DecodeRawUnicodeEscape(char *s, Py_ssize_t size, char *errors) + + # Encode the Py_UNICODE buffer of the given size using + # Raw-Unicode-Escape and return a Python string object. Return + # NULL if an exception was raised by the codec. + object PyUnicode_EncodeRawUnicodeEscape(Py_UNICODE *s, Py_ssize_t size, char *errors) + + # Encode a Unicode objects using Raw-Unicode-Escape and return the + # result as Python string object. Error handling is + # ``strict''. Return NULL if an exception was raised by the codec. + object PyUnicode_AsRawUnicodeEscapeString(object unicode) + +# These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 Unicode ordinals and only these are accepted by the codecs during encoding. + + # Create a Unicode object by decoding size bytes of the Latin-1 + # encoded string s. Return NULL if an exception was raised by the + # codec. + unicode PyUnicode_DecodeLatin1(char *s, Py_ssize_t size, char *errors) + + # Encode the Py_UNICODE buffer of the given size using Latin-1 and + # return a Python bytes object. Return NULL if an exception was + # raised by the codec. + bytes PyUnicode_EncodeLatin1(Py_UNICODE *s, Py_ssize_t size, char *errors) + + # Encode a Unicode objects using Latin-1 and return the result as + # Python bytes object. Error handling is ``strict''. Return NULL + # if an exception was raised by the codec. + bytes PyUnicode_AsLatin1String(object unicode) + +# These are the ASCII codec APIs. Only 7-bit ASCII data is +# accepted. All other codes generate errors. + + # Create a Unicode object by decoding size bytes of the ASCII + # encoded string s. Return NULL if an exception was raised by the + # codec. + unicode PyUnicode_DecodeASCII(char *s, Py_ssize_t size, char *errors) + + # Encode the Py_UNICODE buffer of the given size using ASCII and + # return a Python bytes object. Return NULL if an exception was + # raised by the codec. + bytes PyUnicode_EncodeASCII(Py_UNICODE *s, Py_ssize_t size, char *errors) + + # Encode a Unicode objects using ASCII and return the result as + # Python bytes object. Error handling is ``strict''. Return NULL + # if an exception was raised by the codec. + bytes PyUnicode_AsASCIIString(object o) + +# These are the mapping codec APIs: +# +# This codec is special in that it can be used to implement many +# different codecs (and this is in fact what was done to obtain most +# of the standard codecs included in the encodings package). The codec +# uses mapping to encode and decode characters. +# +# Decoding mappings must map single string characters to single +# Unicode characters, integers (which are then interpreted as Unicode +# ordinals) or None (meaning "undefined mapping" and causing an +# error). +# +# Encoding mappings must map single Unicode characters to single +# string characters, integers (which are then interpreted as Latin-1 +# ordinals) or None (meaning "undefined mapping" and causing an +# error). +# +# The mapping objects provided must only support the __getitem__ +# mapping interface. +# +# If a character lookup fails with a LookupError, the character is +# copied as-is meaning that its ordinal value will be interpreted as +# Unicode or Latin-1 ordinal resp. Because of this, mappings only need +# to contain those mappings which map characters to different code +# points. + + # Create a Unicode object by decoding size bytes of the encoded + # string s using the given mapping object. Return NULL if an + # exception was raised by the codec. If mapping is NULL latin-1 + # decoding will be done. Else it can be a dictionary mapping byte + # or a unicode string, which is treated as a lookup table. Byte + # values greater that the length of the string and U+FFFE + # "characters" are treated as "undefined mapping". Changed in + # version 2.4: Allowed unicode string as mapping argument. + object PyUnicode_DecodeCharmap(char *s, Py_ssize_t size, object mapping, char *errors) + + # Encode the Py_UNICODE buffer of the given size using the given + # mapping object and return a Python string object. Return NULL if + # an exception was raised by the codec. + # + # Deprecated since version 3.3, will be removed in version 4.0. + object PyUnicode_EncodeCharmap(Py_UNICODE *s, Py_ssize_t size, object mapping, char *errors) + + # Encode a Unicode objects using the given mapping object and + # return the result as Python string object. Error handling is + # ``strict''. Return NULL if an exception was raised by the codec. + object PyUnicode_AsCharmapString(object o, object mapping) + +# The following codec API is special in that maps Unicode to Unicode. + + # Translate a Py_UNICODE buffer of the given length by applying a + # character mapping table to it and return the resulting Unicode + # object. Return NULL when an exception was raised by the codec. + # + # The mapping table must map Unicode ordinal integers to Unicode + # ordinal integers or None (causing deletion of the character). + # + # Mapping tables need only provide the __getitem__() interface; + # dictionaries and sequences work well. Unmapped character + # ordinals (ones which cause a LookupError) are left untouched and + # are copied as-is. + # + # Deprecated since version 3.3, will be removed in version 4.0. + object PyUnicode_TranslateCharmap(Py_UNICODE *s, Py_ssize_t size, + object table, char *errors) + +# These are the MBCS codec APIs. They are currently only available on +# Windows and use the Win32 MBCS converters to implement the +# conversions. Note that MBCS (or DBCS) is a class of encodings, not +# just one. The target encoding is defined by the user settings on the +# machine running the codec. + + # Create a Unicode object by decoding size bytes of the MBCS + # encoded string s. Return NULL if an exception was raised by the + # codec. + unicode PyUnicode_DecodeMBCS(char *s, Py_ssize_t size, char *errors) + + # If consumed is NULL, behave like PyUnicode_DecodeMBCS(). If + # consumed is not NULL, PyUnicode_DecodeMBCSStateful() will not + # decode trailing lead byte and the number of bytes that have been + # decoded will be stored in consumed. New in version 2.5. + # NOTE: Python 2.x uses 'int' values for 'size' and 'consumed' (changed in 3.0) + unicode PyUnicode_DecodeMBCSStateful(char *s, Py_ssize_t size, char *errors, Py_ssize_t *consumed) + + # Encode the Py_UNICODE buffer of the given size using MBCS and + # return a Python string object. Return NULL if an exception was + # raised by the codec. + bytes PyUnicode_EncodeMBCS(Py_UNICODE *s, Py_ssize_t size, char *errors) + + # Encode a Unicode objects using MBCS and return the result as + # Python string object. Error handling is ``strict''. Return NULL + # if an exception was raised by the codec. + bytes PyUnicode_AsMBCSString(object o) + + # Encode the Unicode object using the specified code page and return + # a Python bytes object. Return NULL if an exception was raised by the + # codec. Use CP_ACP code page to get the MBCS encoder. + # + # New in version 3.3. + bytes PyUnicode_EncodeCodePage(int code_page, object unicode, const char *errors) + + +# Py_UCS4 helpers (new in CPython 3.3) + + # These utility functions work on strings of Py_UCS4 characters and + # otherwise behave like the C standard library functions with the same name. + + size_t Py_UCS4_strlen(const Py_UCS4 *u) + Py_UCS4* Py_UCS4_strcpy(Py_UCS4 *s1, const Py_UCS4 *s2) + Py_UCS4* Py_UCS4_strncpy(Py_UCS4 *s1, const Py_UCS4 *s2, size_t n) + Py_UCS4* Py_UCS4_strcat(Py_UCS4 *s1, const Py_UCS4 *s2) + int Py_UCS4_strcmp(const Py_UCS4 *s1, const Py_UCS4 *s2) + int Py_UCS4_strncmp(const Py_UCS4 *s1, const Py_UCS4 *s2, size_t n) + Py_UCS4* Py_UCS4_strchr(const Py_UCS4 *s, Py_UCS4 c) + Py_UCS4* Py_UCS4_strrchr(const Py_UCS4 *s, Py_UCS4 c) diff --git a/contrib/tools/cython/Cython/Includes/cpython/version.pxd b/contrib/tools/cython/Cython/Includes/cpython/version.pxd new file mode 100644 index 00000000000..ce31b249cf0 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/version.pxd @@ -0,0 +1,32 @@ +# Python version constants +# +# It's better to evaluate these at runtime (i.e. C compile time) using +# +# if PY_MAJOR_VERSION >= 3: +# do_stuff_in_Py3_0_and_later() +# if PY_VERSION_HEX >= 0x02070000: +# do_stuff_in_Py2_7_and_later() +# +# than using the IF/DEF statements, which are evaluated at Cython +# compile time. This will keep your C code portable. + + +cdef extern from *: + # the complete version, e.g. 0x010502B2 == 1.5.2b2 + int PY_VERSION_HEX + + # the individual sections as plain numbers + int PY_MAJOR_VERSION + int PY_MINOR_VERSION + int PY_MICRO_VERSION + int PY_RELEASE_LEVEL + int PY_RELEASE_SERIAL + + # Note: PY_RELEASE_LEVEL is one of + # 0xA (alpha) + # 0xB (beta) + # 0xC (release candidate) + # 0xF (final) + + char PY_VERSION[] + char PY_PATCHLEVEL_REVISION[] diff --git a/contrib/tools/cython/Cython/Includes/cpython/weakref.pxd b/contrib/tools/cython/Cython/Includes/cpython/weakref.pxd new file mode 100644 index 00000000000..9c4b50f5644 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/weakref.pxd @@ -0,0 +1,42 @@ +from .object cimport PyObject + +cdef extern from "Python.h": + + bint PyWeakref_Check(object ob) + # Return true if ob is either a reference or proxy object. + + bint PyWeakref_CheckRef(object ob) + # Return true if ob is a reference object. + + bint PyWeakref_CheckProxy(ob) + # Return true if *ob* is a proxy object. + + object PyWeakref_NewRef(object ob, object callback) + # Return a weak reference object for the object ob. This will + # always return a new reference, but is not guaranteed to create a + # new object; an existing reference object may be returned. The + # second parameter, callback, can be a callable object that + # receives notification when ob is garbage collected; it should + # accept a single parameter, which will be the weak reference + # object itself. callback may also be None or NULL. If ob is not + # a weakly-referencable object, or if callback is not callable, + # None, or NULL, this will return NULL and raise TypeError. + + object PyWeakref_NewProxy(object ob, object callback) + # Return a weak reference proxy object for the object ob. This + # will always return a new reference, but is not guaranteed to + # create a new object; an existing proxy object may be returned. + # The second parameter, callback, can be a callable object that + # receives notification when ob is garbage collected; it should + # accept a single parameter, which will be the weak reference + # object itself. callback may also be None or NULL. If ob is not + # a weakly-referencable object, or if callback is not callable, + # None, or NULL, this will return NULL and raise TypeError. + + PyObject* PyWeakref_GetObject(object ref) except NULL + # Return the referenced object from a weak reference, ref. If the + # referent is no longer live, returns None. + + PyObject* PyWeakref_GET_OBJECT(object ref) + # Similar to PyWeakref_GetObject, but implemented as a macro that + # does no error checking. diff --git a/contrib/tools/cython/Cython/Includes/libc/__init__.pxd b/contrib/tools/cython/Cython/Includes/libc/__init__.pxd new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/__init__.pxd @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Includes/libc/errno.pxd b/contrib/tools/cython/Cython/Includes/libc/errno.pxd new file mode 100644 index 00000000000..191d47b3dc1 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/errno.pxd @@ -0,0 +1,128 @@ +# 7.5 Errors <errno.h> + +cdef extern from "<errno.h>" nogil: + enum: + EPERM + ENOENT + ESRCH + EINTR + EIO + ENXIO + E2BIG + ENOEXEC + EBADF + ECHILD + EAGAIN + ENOMEM + EACCES + EFAULT + ENOTBLK + EBUSY + EEXIST + EXDEV + ENODEV + ENOTDIR + EISDIR + EINVAL + ENFILE + EMFILE + ENOTTY + ETXTBSY + EFBIG + ENOSPC + ESPIPE + EROFS + EMLINK + EPIPE + EDOM + ERANGE + EDEADLOCK + ENAMETOOLONG + ENOLCK + ENOSYS + ENOTEMPTY + ELOOP + ENOMSG + EIDRM + ECHRNG + EL2NSYNC + EL3HLT + EL3RST + ELNRNG + EUNATCH + ENOCSI + EL2HLT + EBADE + EBADR + EXFULL + ENOANO + EBADRQC + EBADSLT + EBFONT + ENOSTR + ENODATA + ENOATTR + ETIME + ENOSR + ENONET + ENOPKG + EREMOTE + ENOLINK + EADV + ESRMNT + ECOMM + EPROTO + EMULTIHOP + EDOTDOT + EBADMSG + EOVERFLOW + ENOTUNIQ + EBADFD + EREMCHG + ELIBACC + ELIBBAD + ELIBSCN + ELIBMAX + ELIBEXEC + EILSEQ + ERESTART + ESTRPIPE + EUSERS + ENOTSOCK + EDESTADDRREQ + EMSGSIZE + EPROTOTYPE + ENOPROTOOPT + EPROTONOSUPPORT + ESOCKTNOSUPPORT + EOPNOTSUPP + EPFNOSUPPORT + EAFNOSUPPORT + EADDRINUSE + EADDRNOTAVAIL + ENETDOWN + ENETUNREACH + ENETRESET + ECONNABORTED + ECONNRESET + ENOBUFS + EISCONN + ENOTCONN + ESHUTDOWN + ETOOMANYREFS + ETIMEDOUT + ECONNREFUSED + EHOSTDOWN + EHOSTUNREACH + EALREADY + EINPROGRESS + ESTALE + EUCLEAN + ENOTNAM + ENAVAIL + EISNAM + EREMOTEIO + EDQUOT + + int errno + diff --git a/contrib/tools/cython/Cython/Includes/libc/float.pxd b/contrib/tools/cython/Cython/Includes/libc/float.pxd new file mode 100644 index 00000000000..5e4e12d4f45 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/float.pxd @@ -0,0 +1,43 @@ +# 5.2.4.2.2 Characteristics of floating types <float.h> + +cdef extern from "<float.h>": + + const float FLT_RADIX + + const float FLT_MANT_DIG + const double DBL_MANT_DIG + const long double LDBL_MANT_DIG + + const double DECIMAL_DIG + + const float FLT_DIG + const double DBL_DIG + const long double LDBL_DIG + + const float FLT_MIN_EXP + const double DBL_MIN_EXP + const long double LDBL_MIN_EXP + + const float FLT_MIN_10_EXP + const double DBL_MIN_10_EXP + const long double LDBL_MIN_10_EXP + + const float FLT_MAX_EXP + const double DBL_MAX_EXP + const long double LDBL_MAX_EXP + + const float FLT_MAX_10_EXP + const double DBL_MAX_10_EXP + const long double LDBL_MAX_10_EXP + + const float FLT_MAX + const double DBL_MAX + const long double LDBL_MAX + + const float FLT_EPSILON + const double DBL_EPSILON + const long double LDBL_EPSILON + + const float FLT_MIN + const double DBL_MIN + const long double LDBL_MIN diff --git a/contrib/tools/cython/Cython/Includes/libc/limits.pxd b/contrib/tools/cython/Cython/Includes/libc/limits.pxd new file mode 100644 index 00000000000..39d10a1ff9a --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/limits.pxd @@ -0,0 +1,28 @@ +# 5.2.4.2.1 Sizes of integer types <limits.h> + +cdef extern from "<limits.h>": + const int CHAR_BIT + const int MB_LEN_MAX + + const char CHAR_MIN + const char CHAR_MAX + + const signed char SCHAR_MIN + const signed char SCHAR_MAX + const unsigned char UCHAR_MAX + + const short SHRT_MIN + const short SHRT_MAX + const unsigned short USHRT_MAX + + const int INT_MIN + const int INT_MAX + const unsigned int UINT_MAX + + const long LONG_MIN + const long LONG_MAX + const unsigned long ULONG_MAX + + const long long LLONG_MIN + const long long LLONG_MAX + const unsigned long long ULLONG_MAX diff --git a/contrib/tools/cython/Cython/Includes/libc/locale.pxd b/contrib/tools/cython/Cython/Includes/libc/locale.pxd new file mode 100644 index 00000000000..5cbec953ef5 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/locale.pxd @@ -0,0 +1,46 @@ +# 7.11 Localization <locale.h> + +# deprecated cimport for backwards compatibility: +from libc.string cimport const_char + + +cdef extern from "<locale.h>" nogil: + + struct lconv: + char *decimal_point + char *thousands_sep + char *grouping + char *mon_decimal_point + char *mon_thousands_sep + char *mon_grouping + char *positive_sign + char *negative_sign + char *currency_symbol + char frac_digits + char p_cs_precedes + char n_cs_precedes + char p_sep_by_space + char n_sep_by_space + char p_sign_posn + char n_sign_posn + char *int_curr_symbol + char int_frac_digits + char int_p_cs_precedes + char int_n_cs_precedes + char int_p_sep_by_space + char int_n_sep_by_space + char int_p_sign_posn + char int_n_sign_posn + + enum: LC_ALL + enum: LC_COLLATE + enum: LC_CTYPE + enum: LC_MONETARY + enum: LC_NUMERIC + enum: LC_TIME + + # 7.11.1 Locale control + char *setlocale (int category, const char *locale) + + # 7.11.2 Numeric formatting convention inquiry + lconv *localeconv () diff --git a/contrib/tools/cython/Cython/Includes/libc/math.pxd b/contrib/tools/cython/Cython/Includes/libc/math.pxd new file mode 100644 index 00000000000..b002670b224 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/math.pxd @@ -0,0 +1,112 @@ +cdef extern from "<math.h>" nogil: + const double M_E + const double e "M_E" # as in Python's math module + const double M_LOG2E + const double M_LOG10E + const double M_LN2 + const double M_LN10 + const double M_PI + const double pi "M_PI" # as in Python's math module + const double M_PI_2 + const double M_PI_4 + const double M_1_PI + const double M_2_PI + const double M_2_SQRTPI + const double M_SQRT2 + const double M_SQRT1_2 + + # C99 constants + const float INFINITY + const float NAN + # note: not providing "nan" and "inf" aliases here as nan() is a function in C + const double HUGE_VAL + const float HUGE_VALF + const long double HUGE_VALL + + double acos(double x) + double asin(double x) + double atan(double x) + double atan2(double y, double x) + double cos(double x) + double sin(double x) + double tan(double x) + + double cosh(double x) + double sinh(double x) + double tanh(double x) + double acosh(double x) + double asinh(double x) + double atanh(double x) + + double hypot(double x, double y) + + double exp(double x) + double exp2(double x) + double expm1(double x) + double log(double x) + double logb(double x) + double log2(double x) + double log10(double x) + double log1p(double x) + int ilogb(double x) + + double lgamma(double x) + double tgamma(double x) + + double frexp(double x, int* exponent) + double ldexp(double x, int exponent) + + double modf(double x, double* iptr) + double fmod(double x, double y) + double remainder(double x, double y) + double remquo(double x, double y, int *quot) + double pow(double x, double y) + double sqrt(double x) + double cbrt(double x) + + double fabs(double x) + double ceil(double x) + double floor(double x) + double trunc(double x) + double rint(double x) + double round(double x) + double nearbyint(double x) + double nextafter(double, double) + double nexttoward(double, long double) + + long long llrint(double) + long lrint(double) + long long llround(double) + long lround(double) + + double copysign(double, double) + float copysignf(float, float) + long double copysignl(long double, long double) + + double erf(double) + float erff(float) + long double erfl(long double) + double erfc(double) + float erfcf(float) + long double erfcl(long double) + + double fdim(double x, double y) + double fma(double x, double y, double z) + double fmax(double x, double y) + double fmin(double x, double y) + double scalbln(double x, long n) + double scalbn(double x, int n) + + double nan(const char*) + + int isinf(long double) # -1 / 0 / 1 + bint isfinite(long double) + bint isnan(long double) + bint isnormal(long double) + bint signbit(long double) + int fpclassify(long double) + const int FP_NAN + const int FP_INFINITE + const int FP_ZERO + const int FP_SUBNORMAL + const int FP_NORMAL diff --git a/contrib/tools/cython/Cython/Includes/libc/setjmp.pxd b/contrib/tools/cython/Cython/Includes/libc/setjmp.pxd new file mode 100644 index 00000000000..6c11a534d49 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/setjmp.pxd @@ -0,0 +1,10 @@ +cdef extern from "<setjmp.h>" nogil: + ctypedef struct jmp_buf: + pass + int setjmp(jmp_buf state) + void longjmp(jmp_buf state, int value) + + ctypedef struct sigjmp_buf: + pass + int sigsetjmp(sigjmp_buf state, int savesigs) + void siglongjmp(sigjmp_buf state, int value) diff --git a/contrib/tools/cython/Cython/Includes/libc/signal.pxd b/contrib/tools/cython/Cython/Includes/libc/signal.pxd new file mode 100644 index 00000000000..5d34935543b --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/signal.pxd @@ -0,0 +1,64 @@ +# 7.14 Signal handling <signal.h> + +ctypedef void (*sighandler_t)(int SIGNUM) nogil + +cdef extern from "<signal.h>" nogil: + + ctypedef int sig_atomic_t + + sighandler_t SIG_DFL + sighandler_t SIG_IGN + sighandler_t SIG_ERR + + sighandler_t signal (int signum, sighandler_t action) + int raise_"raise" (int signum) + + # Signals + enum: + # Program Error + SIGFPE + SIGILL + SIGSEGV + SIGBUS + SIGABRT + SIGIOT + SIGTRAP + SIGEMT + SIGSYS + SIGSTKFLT + # Termination + SIGTERM + SIGINT + SIGQUIT + SIGKILL + SIGHUP + # Alarm + SIGALRM + SIGVTALRM + SIGPROF + # Asynchronous I/O + SIGIO + SIGURG + SIGPOLL + # Job Control + SIGCHLD + SIGCLD + SIGCONT + SIGSTOP + SIGTSTP + SIGTTIN + SIGTTOU + # Operation Error + SIGPIPE + SIGLOST + SIGXCPU + SIGXFSZ + SIGPWR + # Miscellaneous + SIGUSR1 + SIGUSR2 + SIGWINCH + SIGINFO + # Real-time signals + SIGRTMIN + SIGRTMAX diff --git a/contrib/tools/cython/Cython/Includes/libc/stddef.pxd b/contrib/tools/cython/Cython/Includes/libc/stddef.pxd new file mode 100644 index 00000000000..9b0f4c5fd2c --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/stddef.pxd @@ -0,0 +1,9 @@ +# 7.17 Common definitions <stddef.h> + +cdef extern from "<stddef.h>": + + ctypedef signed int ptrdiff_t + + ctypedef unsigned int size_t + + ctypedef int wchar_t diff --git a/contrib/tools/cython/Cython/Includes/libc/stdint.pxd b/contrib/tools/cython/Cython/Includes/libc/stdint.pxd new file mode 100644 index 00000000000..ced3d46adda --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/stdint.pxd @@ -0,0 +1,105 @@ +# Longness only used for type promotion. +# Actual compile time size used for conversions. + +# 7.18 Integer types <stdint.h> +cdef extern from "<stdint.h>" nogil: + + # 7.18.1 Integer types + # 7.18.1.1 Exact-width integer types + ctypedef signed char int8_t + ctypedef signed short int16_t + ctypedef signed int int32_t + ctypedef signed long int64_t + ctypedef unsigned char uint8_t + ctypedef unsigned short uint16_t + ctypedef unsigned int uint32_t + ctypedef unsigned long long uint64_t + # 7.18.1.2 Minimum-width integer types + ctypedef signed char int_least8_t + ctypedef signed short int_least16_t + ctypedef signed int int_least32_t + ctypedef signed long int_least64_t + ctypedef unsigned char uint_least8_t + ctypedef unsigned short uint_least16_t + ctypedef unsigned int uint_least32_t + ctypedef unsigned long long uint_least64_t + # 7.18.1.3 Fastest minimum-width integer types + ctypedef signed char int_fast8_t + ctypedef signed short int_fast16_t + ctypedef signed int int_fast32_t + ctypedef signed long int_fast64_t + ctypedef unsigned char uint_fast8_t + ctypedef unsigned short uint_fast16_t + ctypedef unsigned int uint_fast32_t + ctypedef unsigned long long uint_fast64_t + # 7.18.1.4 Integer types capable of holding object pointers + ctypedef ssize_t intptr_t + ctypedef size_t uintptr_t + # 7.18.1.5 Greatest-width integer types + ctypedef signed long long intmax_t + ctypedef unsigned long long uintmax_t + + # 7.18.2 Limits of specified-width integer types + # 7.18.2.1 Limits of exact-width integer types + int8_t INT8_MIN + int16_t INT16_MIN + int32_t INT32_MIN + int64_t INT64_MIN + int8_t INT8_MAX + int16_t INT16_MAX + int32_t INT32_MAX + int64_t INT64_MAX + uint8_t UINT8_MAX + uint16_t UINT16_MAX + uint32_t UINT32_MAX + uint64_t UINT64_MAX + #7.18.2.2 Limits of minimum-width integer types + int_least8_t INT_LEAST8_MIN + int_least16_t INT_LEAST16_MIN + int_least32_t INT_LEAST32_MIN + int_least64_t INT_LEAST64_MIN + int_least8_t INT_LEAST8_MAX + int_least16_t INT_LEAST16_MAX + int_least32_t INT_LEAST32_MAX + int_least64_t INT_LEAST64_MAX + uint_least8_t UINT_LEAST8_MAX + uint_least16_t UINT_LEAST16_MAX + uint_least32_t UINT_LEAST32_MAX + uint_least64_t UINT_LEAST64_MAX + #7.18.2.3 Limits of fastest minimum-width integer types + int_fast8_t INT_FAST8_MIN + int_fast16_t INT_FAST16_MIN + int_fast32_t INT_FAST32_MIN + int_fast64_t INT_FAST64_MIN + int_fast8_t INT_FAST8_MAX + int_fast16_t INT_FAST16_MAX + int_fast32_t INT_FAST32_MAX + int_fast64_t INT_FAST64_MAX + uint_fast8_t UINT_FAST8_MAX + uint_fast16_t UINT_FAST16_MAX + uint_fast32_t UINT_FAST32_MAX + uint_fast64_t UINT_FAST64_MAX + #7.18.2.4 Limits of integer types capable of holding object pointers + enum: INTPTR_MIN + enum: INTPTR_MAX + enum: UINTPTR_MAX + # 7.18.2.5 Limits of greatest-width integer types + enum: INTMAX_MAX + enum: INTMAX_MIN + enum: UINTMAX_MAX + + # 7.18.3 Limits of other integer types + # ptrdiff_t + enum: PTRDIFF_MIN + enum: PTRDIFF_MAX + # sig_atomic_t + enum: SIG_ATOMIC_MIN + enum: SIG_ATOMIC_MAX + # size_t + size_t SIZE_MAX + # wchar_t + enum: WCHAR_MIN + enum: WCHAR_MAX + # wint_t + enum: WINT_MIN + enum: WINT_MAX diff --git a/contrib/tools/cython/Cython/Includes/libc/stdio.pxd b/contrib/tools/cython/Cython/Includes/libc/stdio.pxd new file mode 100644 index 00000000000..1644a5a0ab0 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/stdio.pxd @@ -0,0 +1,80 @@ +# 7.19 Input/output <stdio.h> + + +# deprecated cimports for backwards compatibility: +from libc.string cimport const_char, const_void + + +cdef extern from "<stdio.h>" nogil: + + ctypedef struct FILE + cdef FILE *stdin + cdef FILE *stdout + cdef FILE *stderr + + enum: FOPEN_MAX + enum: FILENAME_MAX + FILE *fopen (const char *filename, const char *opentype) + FILE *freopen (const char *filename, const char *opentype, FILE *stream) + FILE *fdopen (int fdescriptor, const char *opentype) + int fclose (FILE *stream) + int remove (const char *filename) + int rename (const char *oldname, const char *newname) + FILE *tmpfile () + + int remove (const char *pathname) + int rename (const char *oldpath, const char *newpath) + + enum: _IOFBF + enum: _IOLBF + enum: _IONBF + int setvbuf (FILE *stream, char *buf, int mode, size_t size) + enum: BUFSIZ + void setbuf (FILE *stream, char *buf) + + size_t fread (void *data, size_t size, size_t count, FILE *stream) + size_t fwrite (const void *data, size_t size, size_t count, FILE *stream) + int fflush (FILE *stream) + + enum: EOF + void clearerr (FILE *stream) + int feof (FILE *stream) + int ferror (FILE *stream) + + enum: SEEK_SET + enum: SEEK_CUR + enum: SEEK_END + int fseek (FILE *stream, long int offset, int whence) + void rewind (FILE *stream) + long int ftell (FILE *stream) + + ctypedef struct fpos_t + ctypedef const fpos_t const_fpos_t "const fpos_t" + int fgetpos (FILE *stream, fpos_t *position) + int fsetpos (FILE *stream, const fpos_t *position) + + int scanf (const char *template, ...) + int sscanf (const char *s, const char *template, ...) + int fscanf (FILE *stream, const char *template, ...) + + int printf (const char *template, ...) + int sprintf (char *s, const char *template, ...) + int snprintf (char *s, size_t size, const char *template, ...) + int fprintf (FILE *stream, const char *template, ...) + + void perror (const char *message) + + char *gets (char *s) + char *fgets (char *s, int count, FILE *stream) + int getchar () + int fgetc (FILE *stream) + int getc (FILE *stream) + int ungetc (int c, FILE *stream) + + int puts (const char *s) + int fputs (const char *s, FILE *stream) + int putchar (int c) + int fputc (int c, FILE *stream) + int putc (int c, FILE *stream) + + size_t getline(char **lineptr, size_t *n, FILE *stream) diff --git a/contrib/tools/cython/Cython/Includes/libc/stdlib.pxd b/contrib/tools/cython/Cython/Includes/libc/stdlib.pxd new file mode 100644 index 00000000000..e6fac821c78 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/stdlib.pxd @@ -0,0 +1,72 @@ +# 7.20 General utilities <stdlib.h> + +# deprecated cimports for backwards compatibility: +from libc.string cimport const_char, const_void + + +cdef extern from "<stdlib.h>" nogil: + + # 7.20.1 Numeric conversion functions + int atoi (const char *string) + long atol (const char *string) + long long atoll (const char *string) + double atof (const char *string) + long strtol (const char *string, char **tailptr, int base) + unsigned long int strtoul (const char *string, char **tailptr, int base) + long long int strtoll (const char *string, char **tailptr, int base) + unsigned long long int strtoull (const char *string, char **tailptr, int base) + float strtof (const char *string, char **tailptr) + double strtod (const char *string, char **tailptr) + long double strtold (const char *string, char **tailptr) + + # 7.20.2 Pseudo-random sequence generation functions + enum: RAND_MAX + int rand () + void srand (unsigned int seed) + + # 7.20.3 Memory management functions + void *calloc (size_t count, size_t eltsize) + void free (void *ptr) + void *malloc (size_t size) + void *realloc (void *ptr, size_t newsize) + + # 7.20.4 Communication with the environment + enum: EXIT_FAILURE + enum: EXIT_SUCCESS + void exit (int status) + void _exit (int status) + int atexit (void (*function) ()) + void abort () + char *getenv (const char *name) + int system (const char *command) + + #7.20.5 Searching and sorting utilities + void *bsearch (const void *key, const void *array, + size_t count, size_t size, + int (*compare)(const void *, const void *)) + void qsort (void *array, size_t count, size_t size, + int (*compare)(const void *, const void *)) + + # 7.20.6 Integer arithmetic functions + int abs (int number) + long int labs (long int number) + long long int llabs (long long int number) + ctypedef struct div_t: + int quot + int rem + div_t div (int numerator, int denominator) + ctypedef struct ldiv_t: + long int quot + long int rem + ldiv_t ldiv (long int numerator, long int denominator) + ctypedef struct lldiv_t: + long long int quot + long long int rem + lldiv_t lldiv (long long int numerator, long long int denominator) + + + # 7.20.7 Multibyte/wide character conversion functions + # XXX TODO + + # 7.20.8 Multibyte/wide string conversion functions + # XXX TODO diff --git a/contrib/tools/cython/Cython/Includes/libc/string.pxd b/contrib/tools/cython/Cython/Includes/libc/string.pxd new file mode 100644 index 00000000000..e6d96183f20 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/string.pxd @@ -0,0 +1,50 @@ +# 7.21 String handling <string.h> + +cdef extern from *: + # deprecated backwards compatibility declarations + ctypedef const char const_char "const char" + ctypedef const signed char const_schar "const signed char" + ctypedef const unsigned char const_uchar "const unsigned char" + ctypedef const void const_void "const void" + +cdef extern from "<string.h>" nogil: + + void *memcpy (void *pto, const void *pfrom, size_t size) + void *memmove (void *pto, const void *pfrom, size_t size) + void *memset (void *block, int c, size_t size) + int memcmp (const void *a1, const void *a2, size_t size) + void *memchr (const void *block, int c, size_t size) + + void *memchr (const void *block, int c, size_t size) + void *memrchr (const void *block, int c, size_t size) + + size_t strlen (const char *s) + char *strcpy (char *pto, const char *pfrom) + char *strncpy (char *pto, const char *pfrom, size_t size) + char *strdup (const char *s) + char *strndup (const char *s, size_t size) + char *strcat (char *pto, const char *pfrom) + char *strncat (char *pto, const char *pfrom, size_t size) + + int strcmp (const char *s1, const char *s2) + int strcasecmp (const char *s1, const char *s2) + int strncmp (const char *s1, const char *s2, size_t size) + int strncasecmp (const char *s1, const char *s2, size_t n) + + int strcoll (const char *s1, const char *s2) + size_t strxfrm (char *pto, const char *pfrom, size_t size) + + char *strerror (int errnum) + + char *strchr (const char *string, int c) + char *strrchr (const char *string, int c) + + char *strstr (const char *haystack, const char *needle) + char *strcasestr (const char *haystack, const char *needle) + + size_t strcspn (const char *string, const char *stopset) + size_t strspn (const char *string, const char *set) + char * strpbrk (const char *string, const char *stopset) + + char *strtok (char *newstring, const char *delimiters) + char *strsep (char **string_ptr, const char *delimiter) diff --git a/contrib/tools/cython/Cython/Includes/libc/time.pxd b/contrib/tools/cython/Cython/Includes/libc/time.pxd new file mode 100644 index 00000000000..3aa15a2eee3 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/time.pxd @@ -0,0 +1,46 @@ +# http://en.wikipedia.org/wiki/C_date_and_time_functions + +from libc.stddef cimport wchar_t + +cdef extern from "<time.h>" nogil: + ctypedef long clock_t + ctypedef long time_t + + enum: CLOCKS_PER_SEC + clock_t clock() # CPU time + time_t time(time_t *) # wall clock time since Unix epoch + + cdef struct tm: + int tm_sec + int tm_min + int tm_hour + int tm_mday + int tm_mon + int tm_year + int tm_wday + int tm_yday + int tm_isdst + char *tm_zone + long tm_gmtoff + + int daylight # global state + long timezone + char *tzname[2] + void tzset() + + char *asctime(const tm *) + char *asctime_r(const tm *, char *) + char *ctime(const time_t *) + char *ctime_r(const time_t *, char *) + double difftime(time_t, time_t) + tm *getdate(const char *) + tm *gmtime(const time_t *) + tm *gmtime_r(const time_t *, tm *) + tm *localtime(const time_t *) + tm *localtime_r(const time_t *, tm *) + time_t mktime(tm *) + size_t strftime(char *, size_t, const char *, const tm *) + size_t wcsftime(wchar_t *str, size_t cnt, const wchar_t *fmt, tm *time) + + # POSIX not stdC + char *strptime(const char *, const char *, tm *) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/__init__.pxd b/contrib/tools/cython/Cython/Includes/libcpp/__init__.pxd new file mode 100644 index 00000000000..111ea25c2f2 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/__init__.pxd @@ -0,0 +1,4 @@ +cdef extern from *: + ctypedef bint bool + ctypedef void* nullptr_t + nullptr_t nullptr diff --git a/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd b/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd new file mode 100644 index 00000000000..ec7c3835b40 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd @@ -0,0 +1,43 @@ +from libcpp cimport bool + + +cdef extern from "<algorithm>" namespace "std" nogil: + # Sorting and searching + bool binary_search[Iter, T](Iter first, Iter last, const T& value) + bool binary_search[Iter, T, Compare](Iter first, Iter last, const T& value, + Compare comp) + + Iter lower_bound[Iter, T](Iter first, Iter last, const T& value) + Iter lower_bound[Iter, T, Compare](Iter first, Iter last, const T& value, + Compare comp) + + Iter upper_bound[Iter, T](Iter first, Iter last, const T& value) + Iter upper_bound[Iter, T, Compare](Iter first, Iter last, const T& value, + Compare comp) + + void partial_sort[Iter](Iter first, Iter middle, Iter last) + void partial_sort[Iter, Compare](Iter first, Iter middle, Iter last, + Compare comp) + + void sort[Iter](Iter first, Iter last) + void sort[Iter, Compare](Iter first, Iter last, Compare comp) + + # Removing duplicates + Iter unique[Iter](Iter first, Iter last) + Iter unique[Iter, BinaryPredicate](Iter first, Iter last, BinaryPredicate p) + + # Binary heaps (priority queues) + void make_heap[Iter](Iter first, Iter last) + void make_heap[Iter, Compare](Iter first, Iter last, Compare comp) + + void pop_heap[Iter](Iter first, Iter last) + void pop_heap[Iter, Compare](Iter first, Iter last, Compare comp) + + void push_heap[Iter](Iter first, Iter last) + void push_heap[Iter, Compare](Iter first, Iter last, Compare comp) + + void sort_heap[Iter](Iter first, Iter last) + void sort_heap[Iter, Compare](Iter first, Iter last, Compare comp) + + # Copy + OutputIter copy[InputIter,OutputIter](InputIter,InputIter,OutputIter) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/cast.pxd b/contrib/tools/cython/Cython/Includes/libcpp/cast.pxd new file mode 100644 index 00000000000..c3a4d8978f2 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/cast.pxd @@ -0,0 +1,12 @@ +# Defines the standard C++ cast operators. +# +# Due to type restrictions, these are only defined for pointer parameters, +# however that is the only case where they are significantly more interesting +# than the standard C cast operator which can be written "<T>(expression)" in +# Cython. + +cdef extern from * nogil: + cdef T dynamic_cast[T](void *) except + # nullptr may also indicate failure + cdef T static_cast[T](void *) + cdef T reinterpret_cast[T](void *) + cdef T const_cast[T](void *) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd b/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd new file mode 100644 index 00000000000..c875d5e5bd9 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd @@ -0,0 +1,101 @@ +# Note: add integer versions of the functions? + +cdef extern from "<complex>" namespace "std" nogil: + cdef cppclass complex[T]: + complex() except + + complex(T, T) except + + complex(complex[T]&) except + + # How to make the converting constructor, i.e. convert complex[double] + # to complex[float]? + + complex[T] operator+(complex[T]&) + complex[T] operator-(complex[T]&) + complex[T] operator+(complex[T]&, complex[T]&) + complex[T] operator+(complex[T]&, T&) + complex[T] operator+(T&, complex[T]&) + complex[T] operator-(complex[T]&, complex[T]&) + complex[T] operator-(complex[T]&, T&) + complex[T] operator-(T&, complex[T]&) + complex[T] operator*(complex[T]&, complex[T]&) + complex[T] operator*(complex[T]&, T&) + complex[T] operator*(T&, complex[T]&) + complex[T] operator/(complex[T]&, complex[T]&) + complex[T] operator/(complex[T]&, T&) + complex[T] operator/(T&, complex[T]&) + + bint operator==(complex[T]&, complex[T]&) + bint operator==(complex[T]&, T&) + bint operator==(T&, complex[T]&) + bint operator!=(complex[T]&, complex[T]&) + bint operator!=(complex[T]&, T&) + bint operator!=(T&, complex[T]&) + + # Access real part + T real() + void real(T) + + # Access imaginary part + T imag() + void imag(T) + + # Return real part + T real[T](complex[T]&) + long double real(long double) + double real(double) + float real(float) + + # Return imaginary part + T imag[T](complex[T]&) + long double imag(long double) + double imag(double) + float imag(float) + + T abs[T](complex[T]&) + T arg[T](complex[T]&) + long double arg(long double) + double arg(double) + float arg(float) + + T norm[T](complex[T]) + long double norm(long double) + double norm(double) + float norm(float) + + complex[T] conj[T](complex[T]&) + complex[long double] conj(long double) + complex[double] conj(double) + complex[float] conj(float) + + complex[T] proj[T](complex[T]) + complex[long double] proj(long double) + complex[double] proj(double) + complex[float] proj(float) + + complex[T] polar[T](T&, T&) + complex[T] ploar[T](T&) + + complex[T] exp[T](complex[T]&) + complex[T] log[T](complex[T]&) + complex[T] log10[T](complex[T]&) + + complex[T] pow[T](complex[T]&, complex[T]&) + complex[T] pow[T](complex[T]&, T&) + complex[T] pow[T](T&, complex[T]&) + # There are some promotion versions too + + complex[T] sqrt[T](complex[T]&) + + complex[T] sin[T](complex[T]&) + complex[T] cos[T](complex[T]&) + complex[T] tan[T](complex[T]&) + complex[T] asin[T](complex[T]&) + complex[T] acos[T](complex[T]&) + complex[T] atan[T](complex[T]&) + + complex[T] sinh[T](complex[T]&) + complex[T] cosh[T](complex[T]&) + complex[T] tanh[T](complex[T]&) + + complex[T] asinh[T](complex[T]&) + complex[T] acosh[T](complex[T]&) + complex[T] atanh[T](complex[T]&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd b/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd new file mode 100644 index 00000000000..9e2b2291d0c --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd @@ -0,0 +1,86 @@ +cdef extern from "<deque>" namespace "std" nogil: + cdef cppclass deque[T,ALLOCATOR=*]: + ctypedef T value_type + ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass iterator: + T& operator*() + iterator operator++() + iterator operator--() + iterator operator+(size_type) + iterator operator-(size_type) + difference_type operator-(iterator) + bint operator==(iterator) + bint operator!=(iterator) + bint operator<(iterator) + bint operator>(iterator) + bint operator<=(iterator) + bint operator>=(iterator) + cppclass reverse_iterator: + T& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator+(size_type) + reverse_iterator operator-(size_type) + difference_type operator-(reverse_iterator) + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + bint operator<(reverse_iterator) + bint operator>(reverse_iterator) + bint operator<=(reverse_iterator) + bint operator>=(reverse_iterator) + cppclass const_iterator(iterator): + pass + cppclass const_reverse_iterator(reverse_iterator): + pass + deque() except + + deque(deque&) except + + deque(size_t) except + + deque(size_t, T&) except + + #deque[input_iterator](input_iterator, input_iterator) + T& operator[](size_t) + #deque& operator=(deque&) + bint operator==(deque&, deque&) + bint operator!=(deque&, deque&) + bint operator<(deque&, deque&) + bint operator>(deque&, deque&) + bint operator<=(deque&, deque&) + bint operator>=(deque&, deque&) + void assign(size_t, T&) + void assign(input_iterator, input_iterator) + T& at(size_t) + T& back() + iterator begin() + const_iterator const_begin "begin"() + void clear() + bint empty() + iterator end() + const_iterator const_end "end"() + iterator erase(iterator) + iterator erase(iterator, iterator) + T& front() + iterator insert(iterator, T&) + void insert(iterator, size_t, T&) + void insert(iterator, input_iterator, input_iterator) + size_t max_size() + void pop_back() + void pop_front() + void push_back(T&) + void push_front(T&) + reverse_iterator rbegin() + #const_reverse_iterator rbegin() + reverse_iterator rend() + #const_reverse_iterator rend() + void resize(size_t) + void resize(size_t, T&) + size_t size() + void swap(deque&) + + # C++11 methods + void shrink_to_fit() diff --git a/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd b/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd new file mode 100644 index 00000000000..8c3b240d041 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd @@ -0,0 +1,62 @@ +cdef extern from "<forward_list>" namespace "std" nogil: + cdef cppclass forward_list[T,ALLOCATOR=*]: + ctypedef T value_type + ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass iterator: + iterator() + iterator(iterator &) + T& operator*() + iterator operator++() + bint operator==(iterator) + bint operator!=(iterator) + cppclass const_iterator(iterator): + pass + forward_list() except + + forward_list(forward_list&) except + + forward_list(size_t, T&) except + + #forward_list& operator=(forward_list&) + bint operator==(forward_list&, forward_list&) + bint operator!=(forward_list&, forward_list&) + bint operator<(forward_list&, forward_list&) + bint operator>(forward_list&, forward_list&) + bint operator<=(forward_list&, forward_list&) + bint operator>=(forward_list&, forward_list&) + void assign(size_t, T&) + T& front() + iterator before_begin() + const_iterator const_before_begin "before_begin"() + iterator begin() + const_iterator const_begin "begin"() + iterator end() + const_iterator const_end "end"() + bint empty() + size_t max_size() + void clear() + iterator insert_after(iterator, T&) + void insert_after(iterator, size_t, T&) + iterator erase_after(iterator) + iterator erase_after(iterator, iterator) + void push_front(T&) + void pop_front() + void resize(size_t) + void resize(size_t, T&) + void swap(forward_list&) + void merge(forward_list&) + void merge[Compare](forward_list&, Compare) + void splice_after(iterator, forward_list&) + void splice_after(iterator, forward_list&, iterator) + void splice_after(iterator, forward_list&, iterator, iterator) + void remove(const T&) + void remove_if[Predicate](Predicate) + void reverse() + void unique() + void unique[Predicate](Predicate) + void sort() + void sort[Compare](Compare) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd b/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd new file mode 100644 index 00000000000..94cbd9e1dd8 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd @@ -0,0 +1,13 @@ +cdef extern from "<functional>" namespace "std" nogil: + cdef cppclass function[T]: + function() except + + function(T*) except + + function(function&) except + + function(void*) except + + + function operator=(T*) + function operator=(function&) + function operator=(void*) + function operator=[U](U) + + bint operator bool() diff --git a/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd b/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd new file mode 100644 index 00000000000..e0f8bd8d6e4 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd @@ -0,0 +1,32 @@ +#Basic reference: http://www.cplusplus.com/reference/iterator/ +#Most of these classes are in fact empty structs + +cdef extern from "<iterator>" namespace "std" nogil: + cdef cppclass iterator[Category,T,Distance,Pointer,Reference]: + pass + cdef cppclass output_iterator_tag: + pass + cdef cppclass input_iterator_tag: + pass + cdef cppclass forward_iterator_tag(input_iterator_tag): + pass + cdef cppclass bidirectional_iterator_tag(forward_iterator_tag): + pass + cdef cppclass random_access_iterator_tag(bidirectional_iterator_tag): + pass + + cdef cppclass back_insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]): + pass + cdef cppclass front_insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]): + pass + cdef cppclass insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]): + pass + back_insert_iterator[CONTAINER] back_inserter[CONTAINER](CONTAINER &) + front_insert_iterator[CONTAINER] front_inserter[CONTAINER](CONTAINER &) + ##Note: this is the C++98 version of inserter. + ##The C++11 versions's prototype relies on typedef members of classes, which Cython doesn't currently support: + ##template <class Container> + ##insert_iterator<Container> inserter (Container& x, typename Container::iterator it) + insert_iterator[CONTAINER] inserter[CONTAINER,ITERATOR](CONTAINER &, ITERATOR) + + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd b/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd new file mode 100644 index 00000000000..c325263b727 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd @@ -0,0 +1,61 @@ +cdef extern from "<limits>" namespace "std" nogil: + enum float_round_style: + round_indeterminate = -1 + round_toward_zero = 0 + round_to_nearest = 1 + round_toward_infinity = 2 + round_toward_neg_infinity = 3 + + enum float_denorm_style: + denorm_indeterminate = -1 + denorm_absent = 0 + denorm_present = 1 + + #The static methods can be called as, e.g. numeric_limits[int].round_error(), etc. + #The const data members should be declared as static. Cython currently doesn't allow that + #and/or I can't figure it out, so you must instantiate an object to access, e.g. + #cdef numeric_limits[double] lm + #print lm.round_style + cdef cppclass numeric_limits[T]: + const bint is_specialized + @staticmethod + T min() + @staticmethod + T max() + const int digits + const int digits10 + const bint is_signed + const bint is_integer + const bint is_exact + const int radix + @staticmethod + T epsilon() + @staticmethod + T round_error() + + const int min_exponent + const int min_exponent10 + const int max_exponent + const int max_exponent10 + + const bint has_infinity + const bint has_quiet_NaN + const bint has_signaling_NaN + const float_denorm_style has_denorm + const bint has_denorm_loss + @staticmethod + T infinity() + @staticmethod + T quiet_NaN() + @staticmethod + T signaling_NaN() + @staticmethod + T denorm_min() + + const bint is_iec559 + const bint is_bounded + const bint is_modulo + + const bint traps + const bint tinyness_before + const float_round_style round_style diff --git a/contrib/tools/cython/Cython/Includes/libcpp/list.pxd b/contrib/tools/cython/Cython/Includes/libcpp/list.pxd new file mode 100644 index 00000000000..b5b0410ad81 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/list.pxd @@ -0,0 +1,78 @@ +cdef extern from "<list>" namespace "std" nogil: + cdef cppclass list[T,ALLOCATOR=*]: + ctypedef T value_type + ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass iterator: + iterator() + iterator(iterator &) + T& operator*() + iterator operator++() + iterator operator--() + bint operator==(iterator) + bint operator!=(iterator) + cppclass reverse_iterator: + reverse_iterator() + reverse_iterator(iterator &) + T& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + cppclass const_iterator(iterator): + pass + cppclass const_reverse_iterator(reverse_iterator): + pass + list() except + + list(list&) except + + list(size_t, T&) except + + #list operator=(list&) + bint operator==(list&, list&) + bint operator!=(list&, list&) + bint operator<(list&, list&) + bint operator>(list&, list&) + bint operator<=(list&, list&) + bint operator>=(list&, list&) + void assign(size_t, T&) + T& back() + iterator begin() + const_iterator const_begin "begin"() + void clear() + bint empty() + iterator end() + const_iterator const_end "end"() + iterator erase(iterator) + iterator erase(iterator, iterator) + T& front() + iterator insert(iterator, T&) + void insert(iterator, size_t, T&) + size_t max_size() + void merge(list&) + #void merge(list&, BinPred) + void pop_back() + void pop_front() + void push_back(T&) + void push_front(T&) + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + void remove(T&) + #void remove_if(UnPred) + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + void resize(size_t, T&) + void reverse() + size_t size() + void sort() + #void sort(BinPred) + void splice(iterator, list&) + void splice(iterator, list&, iterator) + void splice(iterator, list&, iterator, iterator) + void swap(list&) + void unique() + #void unique(BinPred) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/map.pxd b/contrib/tools/cython/Cython/Includes/libcpp/map.pxd new file mode 100644 index 00000000000..624a7ac026f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/map.pxd @@ -0,0 +1,68 @@ +from .utility cimport pair + +cdef extern from "<map>" namespace "std" nogil: + cdef cppclass map[T, U, COMPARE=*, ALLOCATOR=*]: + ctypedef T key_type + ctypedef U mapped_type + ctypedef pair[const T, U] value_type + ctypedef COMPARE key_compare + ctypedef ALLOCATOR allocator_type + cppclass iterator: + pair[T, U]& operator*() + iterator operator++() + iterator operator--() + bint operator==(iterator) + bint operator!=(iterator) + cppclass reverse_iterator: + pair[T, U]& operator*() + iterator operator++() + iterator operator--() + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + cppclass const_iterator(iterator): + pass + cppclass const_reverse_iterator(reverse_iterator): + pass + map() except + + map(map&) except + + #map(key_compare&) + U& operator[](T&) + #map& operator=(map&) + bint operator==(map&, map&) + bint operator!=(map&, map&) + bint operator<(map&, map&) + bint operator>(map&, map&) + bint operator<=(map&, map&) + bint operator>=(map&, map&) + U& at(const T&) except + + const U& const_at "at"(const T&) except + + iterator begin() + const_iterator const_begin "begin" () + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end" () + pair[iterator, iterator] equal_range(const T&) + #pair[const_iterator, const_iterator] equal_range(key_type&) + void erase(iterator) + void erase(iterator, iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find" (const T&) + pair[iterator, bint] insert(pair[T, U]) except + # XXX pair[T,U]& + iterator insert(iterator, pair[T, U]) except + # XXX pair[T,U]& + #void insert(input_iterator, input_iterator) + #key_compare key_comp() + iterator lower_bound(const T&) + const_iterator const_lower_bound "lower_bound"(const T&) + size_t max_size() + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + size_t size() + void swap(map&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + #value_compare value_comp() diff --git a/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd b/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd new file mode 100644 index 00000000000..2151c1ec7f2 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd @@ -0,0 +1,115 @@ +from libcpp cimport bool, nullptr_t, nullptr + +cdef extern from "<memory>" namespace "std" nogil: + cdef cppclass default_delete[T]: + default_delete() + + cdef cppclass allocator[T]: + allocator() + allocator(const allocator &) + #allocator(const allocator[U] &) #unique_ptr unit tests fail w/this + T * address(T &) + const T * address(const T &) const + T * allocate( size_t n ) # Not to standard. should be a second default argument + void deallocate(T * , size_t) + size_t max_size() const + void construct( T *, const T &) #C++98. The C++11 version is variadic AND perfect-forwarding + void destroy(T *) #C++98 + void destroy[U](U *) #unique_ptr unit tests fail w/this + + + cdef cppclass unique_ptr[T,DELETER=*]: + unique_ptr() + unique_ptr(nullptr_t) + unique_ptr(T*) + unique_ptr(unique_ptr[T]&) + + # Modifiers + T* release() + void reset() + void reset(nullptr_t) + void reset(T*) + void swap(unique_ptr&) + + # Observers + T* get() + T& operator*() + #T* operator->() # Not Supported + bool operator bool() + bool operator!() + + bool operator==(const unique_ptr&) + bool operator!=(const unique_ptr&) + bool operator<(const unique_ptr&) + bool operator>(const unique_ptr&) + bool operator<=(const unique_ptr&) + bool operator>=(const unique_ptr&) + + bool operator==(nullptr_t) + bool operator!=(nullptr_t) + + # Forward Declaration not working ("Compiler crash in AnalyseDeclarationsTransform") + #cdef cppclass weak_ptr[T] + + cdef cppclass shared_ptr[T]: + shared_ptr() + shared_ptr(nullptr_t) + shared_ptr(T*) + shared_ptr(shared_ptr[T]&) + shared_ptr(shared_ptr[T]&, T*) + shared_ptr(unique_ptr[T]&) + #shared_ptr(weak_ptr[T]&) # Not Supported + + # Modifiers + void reset() + void reset(T*) + void swap(shared_ptr&) + + # Observers + T* get() + T& operator*() + #T* operator->() # Not Supported + long use_count() + bool unique() + bool operator bool() + bool operator!() + #bool owner_before[Y](const weak_ptr[Y]&) # Not Supported + bool owner_before[Y](const shared_ptr[Y]&) + + bool operator==(const shared_ptr&) + bool operator!=(const shared_ptr&) + bool operator<(const shared_ptr&) + bool operator>(const shared_ptr&) + bool operator<=(const shared_ptr&) + bool operator>=(const shared_ptr&) + + bool operator==(nullptr_t) + bool operator!=(nullptr_t) + + cdef cppclass weak_ptr[T]: + weak_ptr() + weak_ptr(weak_ptr[T]&) + weak_ptr(shared_ptr[T]&) + + # Modifiers + void reset() + void swap(weak_ptr&) + + # Observers + long use_count() + bool expired() + shared_ptr[T] lock() + bool owner_before[Y](const weak_ptr[Y]&) + bool owner_before[Y](const shared_ptr[Y]&) + + # Smart pointer non-member operations + shared_ptr[T] make_shared[T](...) except + + + # Temporaries used for exception handling break generated code + unique_ptr[T] make_unique[T](...) # except + + + # No checking on the compatibility of T and U. + cdef shared_ptr[T] static_pointer_cast[T, U](const shared_ptr[U]&) + cdef shared_ptr[T] dynamic_pointer_cast[T, U](const shared_ptr[U]&) + cdef shared_ptr[T] const_pointer_cast[T, U](const shared_ptr[U]&) + cdef shared_ptr[T] reinterpret_pointer_cast[T, U](const shared_ptr[U]&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/pair.pxd b/contrib/tools/cython/Cython/Includes/libcpp/pair.pxd new file mode 100644 index 00000000000..869fe6674d2 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/pair.pxd @@ -0,0 +1 @@ +from .utility cimport pair diff --git a/contrib/tools/cython/Cython/Includes/libcpp/queue.pxd b/contrib/tools/cython/Cython/Includes/libcpp/queue.pxd new file mode 100644 index 00000000000..578cbd91599 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/queue.pxd @@ -0,0 +1,25 @@ +cdef extern from "<queue>" namespace "std" nogil: + cdef cppclass queue[T]: + queue() except + + queue(queue&) except + + #queue(Container&) + T& back() + bint empty() + T& front() + void pop() + void push(T&) + size_t size() + # C++11 methods + void swap(queue&) + + cdef cppclass priority_queue[T]: + priority_queue() except + + priority_queue(priority_queue&) except + + #priority_queue(Container&) + bint empty() + void pop() + void push(T&) + size_t size() + T& top() + # C++11 methods + void swap(priority_queue&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/set.pxd b/contrib/tools/cython/Cython/Includes/libcpp/set.pxd new file mode 100644 index 00000000000..1069be7466a --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/set.pxd @@ -0,0 +1,61 @@ +from .utility cimport pair + +cdef extern from "<set>" namespace "std" nogil: + cdef cppclass set[T]: + ctypedef T value_type + cppclass iterator: + T& operator*() + iterator operator++() + iterator operator--() + bint operator==(iterator) + bint operator!=(iterator) + cppclass reverse_iterator: + T& operator*() + iterator operator++() + iterator operator--() + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + cppclass const_iterator(iterator): + pass + cppclass const_reverse_iterator(reverse_iterator): + pass + set() except + + set(set&) except + + #set(key_compare&) + #set& operator=(set&) + bint operator==(set&, set&) + bint operator!=(set&, set&) + bint operator<(set&, set&) + bint operator>(set&, set&) + bint operator<=(set&, set&) + bint operator>=(set&, set&) + iterator begin() + const_iterator const_begin "begin"() + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + pair[iterator, iterator] equal_range(const T&) + #pair[const_iterator, const_iterator] equal_range(T&) + iterator erase(iterator) + iterator erase(iterator, iterator) + size_t erase(T&) + iterator find(T&) + const_iterator const_find "find"(T&) + pair[iterator, bint] insert(const T&) except + + iterator insert(iterator, const T&) except + + void insert(iterator, iterator) except + + #key_compare key_comp() + iterator lower_bound(T&) + const_iterator const_lower_bound "lower_bound"(T&) + size_t max_size() + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + size_t size() + void swap(set&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + #value_compare value_comp() diff --git a/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd b/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd new file mode 100644 index 00000000000..2dc80992b76 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd @@ -0,0 +1,11 @@ +cdef extern from "<stack>" namespace "std" nogil: + cdef cppclass stack[T]: + ctypedef T value_type + stack() except + + stack(stack&) except + + #stack(Container&) + bint empty() + void pop() + void push(T&) + size_t size() + T& top() diff --git a/contrib/tools/cython/Cython/Includes/libcpp/string.pxd b/contrib/tools/cython/Cython/Includes/libcpp/string.pxd new file mode 100644 index 00000000000..a894144f1f6 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/string.pxd @@ -0,0 +1,227 @@ + +# deprecated cimport for backwards compatibility: +from libc.string cimport const_char + +cdef extern from "<string>" namespace "std::string" nogil: + const size_t npos + +cdef extern from "<string>" namespace "std" nogil: + cdef cppclass string: + + cppclass iterator: + iterator() + char& operator*() + iterator(iterator&) + iterator operator++() + iterator operator--() + bint operator==(iterator) + bint operator!=(iterator) + + cppclass reverse_iterator: + char& operator*() + iterator operator++() + iterator operator--() + iterator operator+(size_t) + iterator operator-(size_t) + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + bint operator<(reverse_iterator) + bint operator>(reverse_iterator) + bint operator<=(reverse_iterator) + bint operator>=(reverse_iterator) + + cppclass const_iterator(iterator): + pass + + cppclass const_reverse_iterator(reverse_iterator): + pass + + string() except + + string(const string& s) except + + string(const string& s, size_t pos) except + + string(const string& s, size_t pos, size_t len) except + + string(const char* s) except + + string(const char* s, size_t n) except + + string(size_t n, char c) except + + string(iterator first, iterator last) except + + + iterator begin() + const_iterator const_begin "begin"() + iterator end() + const_iterator const_end "end"() + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + + const char* c_str() + const char* data() + size_t size() + size_t max_size() + size_t length() + void resize(size_t) except + + void resize(size_t, char) except + + void shrink_to_fit() except + + size_t capacity() + void reserve(size_t) except + + void clear() + bint empty() + + iterator erase(iterator first, iterator last) + iterator erase(iterator p) + iterator erase(const_iterator first, const_iterator last) + iterator erase(const_iterator p) + string& erase(size_t pos, size_t len) except + + string& erase(size_t pos) except + + string& erase() except + + + char& at(size_t pos) except + + char& operator[](size_t pos) + char& front() + char& back() + int compare(const string& s) + int compare(size_t pos, size_t len, const string& s) except + + int compare(size_t pos, size_t len, const string& s, size_t subpos, size_t sublen) except + + int compare(const char* s) except + + int compare(size_t pos, size_t len, const char* s) except + + int compare(size_t pos, size_t len, const char* s , size_t n) except + + + string& append(const string& s) except + + string& append(const string& s, size_t subpos, size_t sublen) except + + string& append(const char* s) except + + string& append(const char* s, size_t n) except + + string& append(size_t n, char c) except + + + void push_back(char c) except + + void pop_back() + + string& assign(const string& s) except + + string& assign(const string& s, size_t subpos, size_t sublen) except + + string& assign(const char* s, size_t n) except + + string& assign(const char* s) except + + string& assign(size_t n, char c) except + + + string& insert(size_t pos, const string& s, size_t subpos, size_t sublen) except + + string& insert(size_t pos, const string& s) except + + string& insert(size_t pos, const char* s, size_t n) except + + string& insert(size_t pos, const char* s) except + + string& insert(size_t pos, size_t n, char c) except + + void insert(iterator p, size_t n, char c) except + + iterator insert(iterator p, char c) except + + + size_t copy(char* s, size_t len, size_t pos) except + + size_t copy(char* s, size_t len) except + + + size_t find(const string& s, size_t pos) + size_t find(const string& s) + size_t find(const char* s, size_t pos, size_t n) + size_t find(const char* s, size_t pos) + size_t find(const char* s) + size_t find(char c, size_t pos) + size_t find(char c) + + size_t rfind(const string&, size_t pos) + size_t rfind(const string&) + size_t rfind(const char* s, size_t pos, size_t n) + size_t rfind(const char* s, size_t pos) + size_t rfind(const char* s) + size_t rfind(char c, size_t pos) + size_t rfind(char c) + + size_t find_first_of(const string&, size_t pos) + size_t find_first_of(const string&) + size_t find_first_of(const char* s, size_t pos, size_t n) + size_t find_first_of(const char* s, size_t pos) + size_t find_first_of(const char* s) + size_t find_first_of(char c, size_t pos) + size_t find_first_of(char c) + + size_t find_first_not_of(const string& s, size_t pos) + size_t find_first_not_of(const string& s) + size_t find_first_not_of(const char* s, size_t pos, size_t n) + size_t find_first_not_of(const char* s, size_t pos) + size_t find_first_not_of(const char*) + size_t find_first_not_of(char c, size_t pos) + size_t find_first_not_of(char c) + + size_t find_last_of(const string& s, size_t pos) + size_t find_last_of(const string& s) + size_t find_last_of(const char* s, size_t pos, size_t n) + size_t find_last_of(const char* s, size_t pos) + size_t find_last_of(const char* s) + size_t find_last_of(char c, size_t pos) + size_t find_last_of(char c) + + size_t find_last_not_of(const string& s, size_t pos) + size_t find_last_not_of(const string& s) + size_t find_last_not_of(const char* s, size_t pos, size_t n) + size_t find_last_not_of(const char* s, size_t pos) + size_t find_last_not_of(const char* s) + size_t find_last_not_of(char c, size_t pos) + size_t find_last_not_of(char c) + + string substr(size_t pos, size_t len) except + + string substr(size_t pos) except + + string substr() + + #string& operator= (const string&) + #string& operator= (const char*) + #string& operator= (char) + + string operator+ (const string&) except + + string operator+ (const char*) except + + + bint operator==(const string&) + bint operator==(const char*) + + bint operator!= (const string&) + bint operator!= (const char*) + + bint operator< (const string&) + bint operator< (const char*) + + bint operator> (const string&) + bint operator> (const char*) + + bint operator<= (const string&) + bint operator<= (const char*) + + bint operator>= (const string&) + bint operator>= (const char*) + + + string to_string(int val) except + + string to_string(long val) except + + string to_string(long long val) except + + string to_string(unsigned val) except + + string to_string(size_t val) except + + string to_string(ssize_t val) except + + string to_string(unsigned long val) except + + string to_string(unsigned long long val) except + + string to_string(float val) except + + string to_string(double val) except + + string to_string(long double val) except + + + int stoi(const string& s, size_t* idx, int base) except + + int stoi(const string& s, size_t* idx) except + + int stoi(const string& s) except + + long stol(const string& s, size_t* idx, int base) except + + long stol(const string& s, size_t* idx) except + + long stol(const string& s) except + + long long stoll(const string& s, size_t* idx, int base) except + + long long stoll(const string& s, size_t* idx) except + + long long stoll(const string& s) except + + + unsigned long stoul(const string& s, size_t* idx, int base) except + + unsigned long stoul(const string& s, size_t* idx) except + + unsigned long stoul(const string& s) except + + unsigned long long stoull(const string& s, size_t* idx, int base) except + + unsigned long long stoull(const string& s, size_t* idx) except + + unsigned long long stoull(const string& s) except + + + float stof(const string& s, size_t* idx) except + + float stof(const string& s) except + + double stod(const string& s, size_t* idx) except + + double stod(const string& s) except + + long double stold(const string& s, size_t* idx) except + + long double stold(const string& s) except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/typeindex.pxd b/contrib/tools/cython/Cython/Includes/libcpp/typeindex.pxd new file mode 100644 index 00000000000..d5b7e9149fd --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/typeindex.pxd @@ -0,0 +1,15 @@ +from libcpp cimport bool +from .typeinfo cimport type_info + +# This class is C++11-only +cdef extern from "<typeindex>" namespace "std" nogil: + cdef cppclass type_index: + type_index(const type_info &) + const char* name() + size_t hash_code() + bool operator==(const type_index &) + bool operator!=(const type_index &) + bool operator<(const type_index &) + bool operator<=(const type_index &) + bool operator>(const type_index &) + bool operator>=(const type_index &) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/typeinfo.pxd b/contrib/tools/cython/Cython/Includes/libcpp/typeinfo.pxd new file mode 100644 index 00000000000..9118e006498 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/typeinfo.pxd @@ -0,0 +1,10 @@ +from libcpp cimport bool + +cdef extern from "<typeinfo>" namespace "std" nogil: + cdef cppclass type_info: + const char* name() + int before(const type_info&) + bool operator==(const type_info&) + bool operator!=(const type_info&) + # C++11-only + size_t hash_code() diff --git a/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd b/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd new file mode 100644 index 00000000000..a00fbbed280 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd @@ -0,0 +1,74 @@ +from .utility cimport pair + +cdef extern from "<unordered_map>" namespace "std" nogil: + cdef cppclass unordered_map[T, U, HASH=*, PRED=*, ALLOCATOR=*]: + ctypedef T key_type + ctypedef U mapped_type + ctypedef pair[const T, U] value_type + cppclass iterator: + pair[T, U]& operator*() + iterator operator++() + iterator operator--() + bint operator==(iterator) + bint operator!=(iterator) + cppclass reverse_iterator: + pair[T, U]& operator*() + iterator operator++() + iterator operator--() + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + cppclass const_iterator(iterator): + pass + cppclass const_reverse_iterator(reverse_iterator): + pass + unordered_map() except + + unordered_map(unordered_map&) except + + #unordered_map(key_compare&) + U& operator[](T&) + #unordered_map& operator=(unordered_map&) + bint operator==(unordered_map&, unordered_map&) + bint operator!=(unordered_map&, unordered_map&) + bint operator<(unordered_map&, unordered_map&) + bint operator>(unordered_map&, unordered_map&) + bint operator<=(unordered_map&, unordered_map&) + bint operator>=(unordered_map&, unordered_map&) + U& at(const T&) + const U& const_at "at"(const T&) + iterator begin() + const_iterator const_begin "begin"() + void clear() + size_t count(T&) + bint empty() + iterator end() + const_iterator const_end "end"() + pair[iterator, iterator] equal_range(T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator erase(iterator, iterator) + size_t erase(T&) + iterator find(T&) + const_iterator const_find "find"(T&) + pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& + iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& + iterator insert(iterator, iterator) + #key_compare key_comp() + iterator lower_bound(T&) + const_iterator const_lower_bound "lower_bound"(T&) + size_t max_size() + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + size_t size() + void swap(unordered_map&) + iterator upper_bound(T&) + const_iterator const_upper_bound "upper_bound"(T&) + #value_compare value_comp() + void max_load_factor(float) + float max_load_factor() + void rehash(size_t) + void reserve(size_t) + size_t bucket_count() + size_t max_bucket_count() + size_t bucket_size(size_t) + size_t bucket(const T&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd b/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd new file mode 100644 index 00000000000..5aa24175285 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd @@ -0,0 +1,69 @@ +from .utility cimport pair + +cdef extern from "<unordered_set>" namespace "std" nogil: + cdef cppclass unordered_set[T,HASH=*,PRED=*,ALLOCATOR=*]: + ctypedef T value_type + cppclass iterator: + T& operator*() + iterator operator++() + iterator operator--() + bint operator==(iterator) + bint operator!=(iterator) + cppclass reverse_iterator: + T& operator*() + iterator operator++() + iterator operator--() + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + cppclass const_iterator(iterator): + pass + cppclass const_reverse_iterator(reverse_iterator): + pass + unordered_set() except + + unordered_set(unordered_set&) except + + #unordered_set(key_compare&) + #unordered_set& operator=(unordered_set&) + bint operator==(unordered_set&, unordered_set&) + bint operator!=(unordered_set&, unordered_set&) + bint operator<(unordered_set&, unordered_set&) + bint operator>(unordered_set&, unordered_set&) + bint operator<=(unordered_set&, unordered_set&) + bint operator>=(unordered_set&, unordered_set&) + iterator begin() + const_iterator const_begin "begin"() + void clear() + size_t count(T&) + bint empty() + iterator end() + const_iterator const_end "end"() + pair[iterator, iterator] equal_range(T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(T&) + iterator erase(iterator) + iterator erase(iterator, iterator) + size_t erase(T&) + iterator find(T&) + const_iterator const_find "find"(T&) + pair[iterator, bint] insert(T&) + iterator insert(iterator, T&) + #key_compare key_comp() + iterator insert(iterator, iterator) + iterator lower_bound(T&) + const_iterator const_lower_bound "lower_bound"(T&) + size_t max_size() + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + size_t size() + void swap(unordered_set&) + iterator upper_bound(T&) + const_iterator const_upper_bound "upper_bound"(T&) + #value_compare value_comp() + void max_load_factor(float) + float max_load_factor() + void rehash(size_t) + void reserve(size_t) + size_t bucket_count() + size_t max_bucket_count() + size_t bucket_size(size_t) + size_t bucket(const T&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/utility.pxd b/contrib/tools/cython/Cython/Includes/libcpp/utility.pxd new file mode 100644 index 00000000000..e0df69b1661 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/utility.pxd @@ -0,0 +1,30 @@ +cdef extern from "<utility>" namespace "std" nogil: + cdef cppclass pair[T, U]: + ctypedef T first_type + ctypedef U second_type + T first + U second + pair() except + + pair(pair&) except + + pair(T&, U&) except + + bint operator==(pair&, pair&) + bint operator!=(pair&, pair&) + bint operator<(pair&, pair&) + bint operator>(pair&, pair&) + bint operator<=(pair&, pair&) + bint operator>=(pair&, pair&) + +cdef extern from * namespace "cython_std" nogil: + """ + #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600) + // move should be defined for these versions of MSVC, but __cplusplus isn't set usefully + #include <type_traits> + + namespace cython_std { + template <typename T> typename std::remove_reference<T>::type&& move(T& t) noexcept { return std::move(t); } + template <typename T> typename std::remove_reference<T>::type&& move(T&& t) noexcept { return std::move(t); } + } + + #endif + """ + cdef T move[T](T) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd b/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd new file mode 100644 index 00000000000..9b007dd0c79 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd @@ -0,0 +1,88 @@ +cdef extern from "<vector>" namespace "std" nogil: + cdef cppclass vector[T,ALLOCATOR=*]: + ctypedef T value_type + ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass iterator: + T& operator*() + iterator operator++() + iterator operator--() + iterator operator+(size_type) + iterator operator-(size_type) + difference_type operator-(iterator) + bint operator==(iterator) + bint operator!=(iterator) + bint operator<(iterator) + bint operator>(iterator) + bint operator<=(iterator) + bint operator>=(iterator) + cppclass reverse_iterator: + T& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator+(size_type) + reverse_iterator operator-(size_type) + difference_type operator-(reverse_iterator) + bint operator==(reverse_iterator) + bint operator!=(reverse_iterator) + bint operator<(reverse_iterator) + bint operator>(reverse_iterator) + bint operator<=(reverse_iterator) + bint operator>=(reverse_iterator) + cppclass const_iterator(iterator): + pass + cppclass const_reverse_iterator(reverse_iterator): + pass + vector() except + + vector(vector&) except + + vector(size_type) except + + vector(size_type, T&) except + + #vector[input_iterator](input_iterator, input_iterator) + T& operator[](size_type) + #vector& operator=(vector&) + bint operator==(vector&, vector&) + bint operator!=(vector&, vector&) + bint operator<(vector&, vector&) + bint operator>(vector&, vector&) + bint operator<=(vector&, vector&) + bint operator>=(vector&, vector&) + void assign(size_type, const T&) + void assign[input_iterator](input_iterator, input_iterator) except + + T& at(size_type) except + + T& back() + iterator begin() + const_iterator const_begin "begin"() + size_type capacity() + void clear() + bint empty() + iterator end() + const_iterator const_end "end"() + iterator erase(iterator) + iterator erase(iterator, iterator) + T& front() + iterator insert(iterator, const T&) except + + iterator insert(iterator, size_type, const T&) except + + iterator insert[Iter](iterator, Iter, Iter) except + + size_type max_size() + void pop_back() + void push_back(T&) except + + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "crbegin"() + reverse_iterator rend() + const_reverse_iterator const_rend "crend"() + void reserve(size_type) + void resize(size_type) except + + void resize(size_type, T&) except + + size_type size() + void swap(vector&) + + # C++11 methods + T* data() + const T* const_data "data"() + void shrink_to_fit() diff --git a/contrib/tools/cython/Cython/Includes/numpy.pxd b/contrib/tools/cython/Cython/Includes/numpy.pxd new file mode 100644 index 00000000000..789669dac13 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/numpy.pxd @@ -0,0 +1,1050 @@ +# NumPy static imports for Cython +# +# If any of the PyArray_* functions are called, import_array must be +# called first. +# +# This also defines backwards-compatibility buffer acquisition +# code for use in Python 2.x (or Python <= 2.5 when NumPy starts +# implementing PEP-3118 directly). +# +# Because of laziness, the format string of the buffer is statically +# allocated. Increase the size if this is not enough, or submit a +# patch to do this properly. +# +# Author: Dag Sverre Seljebotn +# + +DEF _buffer_format_string_len = 255 + +cimport cpython.buffer as pybuf +from cpython.ref cimport Py_INCREF +from cpython.mem cimport PyObject_Malloc, PyObject_Free +from cpython.object cimport PyObject, PyTypeObject +from cpython.type cimport type +cimport libc.stdio as stdio + +cdef extern from "Python.h": + ctypedef int Py_intptr_t + +cdef extern from "numpy/arrayobject.h": + ctypedef Py_intptr_t npy_intp + ctypedef size_t npy_uintp + + cdef enum NPY_TYPES: + NPY_BOOL + NPY_BYTE + NPY_UBYTE + NPY_SHORT + NPY_USHORT + NPY_INT + NPY_UINT + NPY_LONG + NPY_ULONG + NPY_LONGLONG + NPY_ULONGLONG + NPY_FLOAT + NPY_DOUBLE + NPY_LONGDOUBLE + NPY_CFLOAT + NPY_CDOUBLE + NPY_CLONGDOUBLE + NPY_OBJECT + NPY_STRING + NPY_UNICODE + NPY_VOID + NPY_DATETIME + NPY_TIMEDELTA + NPY_NTYPES + NPY_NOTYPE + + NPY_INT8 + NPY_INT16 + NPY_INT32 + NPY_INT64 + NPY_INT128 + NPY_INT256 + NPY_UINT8 + NPY_UINT16 + NPY_UINT32 + NPY_UINT64 + NPY_UINT128 + NPY_UINT256 + NPY_FLOAT16 + NPY_FLOAT32 + NPY_FLOAT64 + NPY_FLOAT80 + NPY_FLOAT96 + NPY_FLOAT128 + NPY_FLOAT256 + NPY_COMPLEX32 + NPY_COMPLEX64 + NPY_COMPLEX128 + NPY_COMPLEX160 + NPY_COMPLEX192 + NPY_COMPLEX256 + NPY_COMPLEX512 + + NPY_INTP + + ctypedef enum NPY_ORDER: + NPY_ANYORDER + NPY_CORDER + NPY_FORTRANORDER + NPY_KEEPORDER + + ctypedef enum NPY_CASTING: + NPY_NO_CASTING + NPY_EQUIV_CASTING + NPY_SAFE_CASTING + NPY_SAME_KIND_CASTING + NPY_UNSAFE_CASTING + + ctypedef enum NPY_CLIPMODE: + NPY_CLIP + NPY_WRAP + NPY_RAISE + + ctypedef enum NPY_SCALARKIND: + NPY_NOSCALAR, + NPY_BOOL_SCALAR, + NPY_INTPOS_SCALAR, + NPY_INTNEG_SCALAR, + NPY_FLOAT_SCALAR, + NPY_COMPLEX_SCALAR, + NPY_OBJECT_SCALAR + + ctypedef enum NPY_SORTKIND: + NPY_QUICKSORT + NPY_HEAPSORT + NPY_MERGESORT + + ctypedef enum NPY_SEARCHSIDE: + NPY_SEARCHLEFT + NPY_SEARCHRIGHT + + enum: + # DEPRECATED since NumPy 1.7 ! Do not use in new code! + NPY_C_CONTIGUOUS + NPY_F_CONTIGUOUS + NPY_CONTIGUOUS + NPY_FORTRAN + NPY_OWNDATA + NPY_FORCECAST + NPY_ENSURECOPY + NPY_ENSUREARRAY + NPY_ELEMENTSTRIDES + NPY_ALIGNED + NPY_NOTSWAPPED + NPY_WRITEABLE + NPY_UPDATEIFCOPY + NPY_ARR_HAS_DESCR + + NPY_BEHAVED + NPY_BEHAVED_NS + NPY_CARRAY + NPY_CARRAY_RO + NPY_FARRAY + NPY_FARRAY_RO + NPY_DEFAULT + + NPY_IN_ARRAY + NPY_OUT_ARRAY + NPY_INOUT_ARRAY + NPY_IN_FARRAY + NPY_OUT_FARRAY + NPY_INOUT_FARRAY + + NPY_UPDATE_ALL + + enum: + # Added in NumPy 1.7 to replace the deprecated enums above. + NPY_ARRAY_C_CONTIGUOUS + NPY_ARRAY_F_CONTIGUOUS + NPY_ARRAY_OWNDATA + NPY_ARRAY_FORCECAST + NPY_ARRAY_ENSURECOPY + NPY_ARRAY_ENSUREARRAY + NPY_ARRAY_ELEMENTSTRIDES + NPY_ARRAY_ALIGNED + NPY_ARRAY_NOTSWAPPED + NPY_ARRAY_WRITEABLE + NPY_ARRAY_UPDATEIFCOPY + + NPY_ARRAY_BEHAVED + NPY_ARRAY_BEHAVED_NS + NPY_ARRAY_CARRAY + NPY_ARRAY_CARRAY_RO + NPY_ARRAY_FARRAY + NPY_ARRAY_FARRAY_RO + NPY_ARRAY_DEFAULT + + NPY_ARRAY_IN_ARRAY + NPY_ARRAY_OUT_ARRAY + NPY_ARRAY_INOUT_ARRAY + NPY_ARRAY_IN_FARRAY + NPY_ARRAY_OUT_FARRAY + NPY_ARRAY_INOUT_FARRAY + + NPY_ARRAY_UPDATE_ALL + + cdef enum: + NPY_MAXDIMS + + npy_intp NPY_MAX_ELSIZE + + ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *) + + ctypedef struct PyArray_ArrayDescr: + # shape is a tuple, but Cython doesn't support "tuple shape" + # inside a non-PyObject declaration, so we have to declare it + # as just a PyObject*. + PyObject* shape + + ctypedef struct PyArray_Descr: + pass + + ctypedef class numpy.dtype [object PyArray_Descr, check_size ignore]: + # Use PyDataType_* macros when possible, however there are no macros + # for accessing some of the fields, so some are defined. + cdef PyTypeObject* typeobj + cdef char kind + cdef char type + # Numpy sometimes mutates this without warning (e.g. it'll + # sometimes change "|" to "<" in shared dtype objects on + # little-endian machines). If this matters to you, use + # PyArray_IsNativeByteOrder(dtype.byteorder) instead of + # directly accessing this field. + cdef char byteorder + cdef char flags + cdef int type_num + cdef int itemsize "elsize" + cdef int alignment + cdef dict fields + cdef tuple names + # Use PyDataType_HASSUBARRAY to test whether this field is + # valid (the pointer can be NULL). Most users should access + # this field via the inline helper method PyDataType_SHAPE. + cdef PyArray_ArrayDescr* subarray + + ctypedef extern class numpy.flatiter [object PyArrayIterObject]: + # Use through macros + pass + + ctypedef extern class numpy.broadcast [object PyArrayMultiIterObject]: + # Use through macros + pass + + ctypedef struct PyArrayObject: + # For use in situations where ndarray can't replace PyArrayObject*, + # like PyArrayObject**. + pass + + ctypedef class numpy.ndarray [object PyArrayObject, check_size ignore]: + cdef __cythonbufferdefaults__ = {"mode": "strided"} + + cdef: + # Only taking a few of the most commonly used and stable fields. + # One should use PyArray_* macros instead to access the C fields. + char *data + int ndim "nd" + npy_intp *shape "dimensions" + npy_intp *strides + dtype descr # deprecated since NumPy 1.7 ! + PyObject* base + + # Note: This syntax (function definition in pxd files) is an + # experimental exception made for __getbuffer__ and __releasebuffer__ + # -- the details of this may change. + def __getbuffer__(ndarray self, Py_buffer* info, int flags): + # This implementation of getbuffer is geared towards Cython + # requirements, and does not yet fulfill the PEP. + # In particular strided access is always provided regardless + # of flags + + cdef int i, ndim + cdef int endian_detector = 1 + cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) + + ndim = PyArray_NDIM(self) + + if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): + raise ValueError(u"ndarray is not C contiguous") + + if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): + raise ValueError(u"ndarray is not Fortran contiguous") + + info.buf = PyArray_DATA(self) + info.ndim = ndim + if sizeof(npy_intp) != sizeof(Py_ssize_t): + # Allocate new buffer for strides and shape info. + # This is allocated as one block, strides first. + info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim) + info.shape = info.strides + ndim + for i in range(ndim): + info.strides[i] = PyArray_STRIDES(self)[i] + info.shape[i] = PyArray_DIMS(self)[i] + else: + info.strides = <Py_ssize_t*>PyArray_STRIDES(self) + info.shape = <Py_ssize_t*>PyArray_DIMS(self) + info.suboffsets = NULL + info.itemsize = PyArray_ITEMSIZE(self) + info.readonly = not PyArray_ISWRITEABLE(self) + + cdef int t + cdef char* f = NULL + cdef dtype descr = <dtype>PyArray_DESCR(self) + cdef int offset + + info.obj = self + + if not PyDataType_HASFIELDS(descr): + t = descr.type_num + if ((descr.byteorder == c'>' and little_endian) or + (descr.byteorder == c'<' and not little_endian)): + raise ValueError(u"Non-native byte order not supported") + if t == NPY_BYTE: f = "b" + elif t == NPY_UBYTE: f = "B" + elif t == NPY_SHORT: f = "h" + elif t == NPY_USHORT: f = "H" + elif t == NPY_INT: f = "i" + elif t == NPY_UINT: f = "I" + elif t == NPY_LONG: f = "l" + elif t == NPY_ULONG: f = "L" + elif t == NPY_LONGLONG: f = "q" + elif t == NPY_ULONGLONG: f = "Q" + elif t == NPY_FLOAT: f = "f" + elif t == NPY_DOUBLE: f = "d" + elif t == NPY_LONGDOUBLE: f = "g" + elif t == NPY_CFLOAT: f = "Zf" + elif t == NPY_CDOUBLE: f = "Zd" + elif t == NPY_CLONGDOUBLE: f = "Zg" + elif t == NPY_OBJECT: f = "O" + else: + raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + info.format = f + return + else: + info.format = <char*>PyObject_Malloc(_buffer_format_string_len) + info.format[0] = c'^' # Native data types, manual alignment + offset = 0 + f = _util_dtypestring(descr, info.format + 1, + info.format + _buffer_format_string_len, + &offset) + f[0] = c'\0' # Terminate format string + + def __releasebuffer__(ndarray self, Py_buffer* info): + if PyArray_HASFIELDS(self): + PyObject_Free(info.format) + if sizeof(npy_intp) != sizeof(Py_ssize_t): + PyObject_Free(info.strides) + # info.shape was stored after info.strides in the same block + + + ctypedef unsigned char npy_bool + + ctypedef signed char npy_byte + ctypedef signed short npy_short + ctypedef signed int npy_int + ctypedef signed long npy_long + ctypedef signed long long npy_longlong + + ctypedef unsigned char npy_ubyte + ctypedef unsigned short npy_ushort + ctypedef unsigned int npy_uint + ctypedef unsigned long npy_ulong + ctypedef unsigned long long npy_ulonglong + + ctypedef float npy_float + ctypedef double npy_double + ctypedef long double npy_longdouble + + ctypedef signed char npy_int8 + ctypedef signed short npy_int16 + ctypedef signed int npy_int32 + ctypedef signed long long npy_int64 + ctypedef signed long long npy_int96 + ctypedef signed long long npy_int128 + + ctypedef unsigned char npy_uint8 + ctypedef unsigned short npy_uint16 + ctypedef unsigned int npy_uint32 + ctypedef unsigned long long npy_uint64 + ctypedef unsigned long long npy_uint96 + ctypedef unsigned long long npy_uint128 + + ctypedef float npy_float32 + ctypedef double npy_float64 + ctypedef long double npy_float80 + ctypedef long double npy_float96 + ctypedef long double npy_float128 + + ctypedef struct npy_cfloat: + double real + double imag + + ctypedef struct npy_cdouble: + double real + double imag + + ctypedef struct npy_clongdouble: + long double real + long double imag + + ctypedef struct npy_complex64: + float real + float imag + + ctypedef struct npy_complex128: + double real + double imag + + ctypedef struct npy_complex160: + long double real + long double imag + + ctypedef struct npy_complex192: + long double real + long double imag + + ctypedef struct npy_complex256: + long double real + long double imag + + ctypedef struct PyArray_Dims: + npy_intp *ptr + int len + + int _import_array() except -1 + + # + # Macros from ndarrayobject.h + # + bint PyArray_CHKFLAGS(ndarray m, int flags) + bint PyArray_IS_C_CONTIGUOUS(ndarray arr) + bint PyArray_IS_F_CONTIGUOUS(ndarray arr) + bint PyArray_ISCONTIGUOUS(ndarray m) + bint PyArray_ISWRITEABLE(ndarray m) + bint PyArray_ISALIGNED(ndarray m) + + int PyArray_NDIM(ndarray) + bint PyArray_ISONESEGMENT(ndarray) + bint PyArray_ISFORTRAN(ndarray) + int PyArray_FORTRANIF(ndarray) + + void* PyArray_DATA(ndarray) + char* PyArray_BYTES(ndarray) + npy_intp* PyArray_DIMS(ndarray) + npy_intp* PyArray_STRIDES(ndarray) + npy_intp PyArray_DIM(ndarray, size_t) + npy_intp PyArray_STRIDE(ndarray, size_t) + + PyObject *PyArray_BASE(ndarray) # returns borrowed reference! + PyArray_Descr *PyArray_DESCR(ndarray) # returns borrowed reference to dtype! + int PyArray_FLAGS(ndarray) + npy_intp PyArray_ITEMSIZE(ndarray) + int PyArray_TYPE(ndarray arr) + + object PyArray_GETITEM(ndarray arr, void *itemptr) + int PyArray_SETITEM(ndarray arr, void *itemptr, object obj) + + bint PyTypeNum_ISBOOL(int) + bint PyTypeNum_ISUNSIGNED(int) + bint PyTypeNum_ISSIGNED(int) + bint PyTypeNum_ISINTEGER(int) + bint PyTypeNum_ISFLOAT(int) + bint PyTypeNum_ISNUMBER(int) + bint PyTypeNum_ISSTRING(int) + bint PyTypeNum_ISCOMPLEX(int) + bint PyTypeNum_ISPYTHON(int) + bint PyTypeNum_ISFLEXIBLE(int) + bint PyTypeNum_ISUSERDEF(int) + bint PyTypeNum_ISEXTENDED(int) + bint PyTypeNum_ISOBJECT(int) + + bint PyDataType_ISBOOL(dtype) + bint PyDataType_ISUNSIGNED(dtype) + bint PyDataType_ISSIGNED(dtype) + bint PyDataType_ISINTEGER(dtype) + bint PyDataType_ISFLOAT(dtype) + bint PyDataType_ISNUMBER(dtype) + bint PyDataType_ISSTRING(dtype) + bint PyDataType_ISCOMPLEX(dtype) + bint PyDataType_ISPYTHON(dtype) + bint PyDataType_ISFLEXIBLE(dtype) + bint PyDataType_ISUSERDEF(dtype) + bint PyDataType_ISEXTENDED(dtype) + bint PyDataType_ISOBJECT(dtype) + bint PyDataType_HASFIELDS(dtype) + bint PyDataType_HASSUBARRAY(dtype) + + bint PyArray_ISBOOL(ndarray) + bint PyArray_ISUNSIGNED(ndarray) + bint PyArray_ISSIGNED(ndarray) + bint PyArray_ISINTEGER(ndarray) + bint PyArray_ISFLOAT(ndarray) + bint PyArray_ISNUMBER(ndarray) + bint PyArray_ISSTRING(ndarray) + bint PyArray_ISCOMPLEX(ndarray) + bint PyArray_ISPYTHON(ndarray) + bint PyArray_ISFLEXIBLE(ndarray) + bint PyArray_ISUSERDEF(ndarray) + bint PyArray_ISEXTENDED(ndarray) + bint PyArray_ISOBJECT(ndarray) + bint PyArray_HASFIELDS(ndarray) + + bint PyArray_ISVARIABLE(ndarray) + + bint PyArray_SAFEALIGNEDCOPY(ndarray) + bint PyArray_ISNBO(char) # works on ndarray.byteorder + bint PyArray_IsNativeByteOrder(char) # works on ndarray.byteorder + bint PyArray_ISNOTSWAPPED(ndarray) + bint PyArray_ISBYTESWAPPED(ndarray) + + bint PyArray_FLAGSWAP(ndarray, int) + + bint PyArray_ISCARRAY(ndarray) + bint PyArray_ISCARRAY_RO(ndarray) + bint PyArray_ISFARRAY(ndarray) + bint PyArray_ISFARRAY_RO(ndarray) + bint PyArray_ISBEHAVED(ndarray) + bint PyArray_ISBEHAVED_RO(ndarray) + + + bint PyDataType_ISNOTSWAPPED(dtype) + bint PyDataType_ISBYTESWAPPED(dtype) + + bint PyArray_DescrCheck(object) + + bint PyArray_Check(object) + bint PyArray_CheckExact(object) + + # Cannot be supported due to out arg: + # bint PyArray_HasArrayInterfaceType(object, dtype, object, object&) + # bint PyArray_HasArrayInterface(op, out) + + + bint PyArray_IsZeroDim(object) + # Cannot be supported due to ## ## in macro: + # bint PyArray_IsScalar(object, verbatim work) + bint PyArray_CheckScalar(object) + bint PyArray_IsPythonNumber(object) + bint PyArray_IsPythonScalar(object) + bint PyArray_IsAnyScalar(object) + bint PyArray_CheckAnyScalar(object) + ndarray PyArray_GETCONTIGUOUS(ndarray) + bint PyArray_SAMESHAPE(ndarray, ndarray) + npy_intp PyArray_SIZE(ndarray) + npy_intp PyArray_NBYTES(ndarray) + + object PyArray_FROM_O(object) + object PyArray_FROM_OF(object m, int flags) + object PyArray_FROM_OT(object m, int type) + object PyArray_FROM_OTF(object m, int type, int flags) + object PyArray_FROMANY(object m, int type, int min, int max, int flags) + object PyArray_ZEROS(int nd, npy_intp* dims, int type, int fortran) + object PyArray_EMPTY(int nd, npy_intp* dims, int type, int fortran) + void PyArray_FILLWBYTE(object, int val) + npy_intp PyArray_REFCOUNT(object) + object PyArray_ContiguousFromAny(op, int, int min_depth, int max_depth) + unsigned char PyArray_EquivArrTypes(ndarray a1, ndarray a2) + bint PyArray_EquivByteorders(int b1, int b2) + object PyArray_SimpleNew(int nd, npy_intp* dims, int typenum) + object PyArray_SimpleNewFromData(int nd, npy_intp* dims, int typenum, void* data) + #object PyArray_SimpleNewFromDescr(int nd, npy_intp* dims, dtype descr) + object PyArray_ToScalar(void* data, ndarray arr) + + void* PyArray_GETPTR1(ndarray m, npy_intp i) + void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j) + void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k) + void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l) + + void PyArray_XDECREF_ERR(ndarray) + # Cannot be supported due to out arg + # void PyArray_DESCR_REPLACE(descr) + + + object PyArray_Copy(ndarray) + object PyArray_FromObject(object op, int type, int min_depth, int max_depth) + object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth) + object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth) + + object PyArray_Cast(ndarray mp, int type_num) + object PyArray_Take(ndarray ap, object items, int axis) + object PyArray_Put(ndarray ap, object items, object values) + + void PyArray_ITER_RESET(flatiter it) nogil + void PyArray_ITER_NEXT(flatiter it) nogil + void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil + void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil + void* PyArray_ITER_DATA(flatiter it) nogil + bint PyArray_ITER_NOTDONE(flatiter it) nogil + + void PyArray_MultiIter_RESET(broadcast multi) nogil + void PyArray_MultiIter_NEXT(broadcast multi) nogil + void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil + void PyArray_MultiIter_GOTO1D(broadcast multi, npy_intp ind) nogil + void* PyArray_MultiIter_DATA(broadcast multi, npy_intp i) nogil + void PyArray_MultiIter_NEXTi(broadcast multi, npy_intp i) nogil + bint PyArray_MultiIter_NOTDONE(broadcast multi) nogil + + # Functions from __multiarray_api.h + + # Functions taking dtype and returning object/ndarray are disabled + # for now as they steal dtype references. I'm conservative and disable + # more than is probably needed until it can be checked further. + int PyArray_SetNumericOps (object) + object PyArray_GetNumericOps () + int PyArray_INCREF (ndarray) + int PyArray_XDECREF (ndarray) + void PyArray_SetStringFunction (object, int) + dtype PyArray_DescrFromType (int) + object PyArray_TypeObjectFromType (int) + char * PyArray_Zero (ndarray) + char * PyArray_One (ndarray) + #object PyArray_CastToType (ndarray, dtype, int) + int PyArray_CastTo (ndarray, ndarray) + int PyArray_CastAnyTo (ndarray, ndarray) + int PyArray_CanCastSafely (int, int) + npy_bool PyArray_CanCastTo (dtype, dtype) + int PyArray_ObjectType (object, int) + dtype PyArray_DescrFromObject (object, dtype) + #ndarray* PyArray_ConvertToCommonType (object, int *) + dtype PyArray_DescrFromScalar (object) + dtype PyArray_DescrFromTypeObject (object) + npy_intp PyArray_Size (object) + #object PyArray_Scalar (void *, dtype, object) + #object PyArray_FromScalar (object, dtype) + void PyArray_ScalarAsCtype (object, void *) + #int PyArray_CastScalarToCtype (object, void *, dtype) + #int PyArray_CastScalarDirect (object, dtype, void *, int) + object PyArray_ScalarFromObject (object) + #PyArray_VectorUnaryFunc * PyArray_GetCastFunc (dtype, int) + object PyArray_FromDims (int, int *, int) + #object PyArray_FromDimsAndDataAndDescr (int, int *, dtype, char *) + #object PyArray_FromAny (object, dtype, int, int, int, object) + object PyArray_EnsureArray (object) + object PyArray_EnsureAnyArray (object) + #object PyArray_FromFile (stdio.FILE *, dtype, npy_intp, char *) + #object PyArray_FromString (char *, npy_intp, dtype, npy_intp, char *) + #object PyArray_FromBuffer (object, dtype, npy_intp, npy_intp) + #object PyArray_FromIter (object, dtype, npy_intp) + object PyArray_Return (ndarray) + #object PyArray_GetField (ndarray, dtype, int) + #int PyArray_SetField (ndarray, dtype, int, object) + object PyArray_Byteswap (ndarray, npy_bool) + object PyArray_Resize (ndarray, PyArray_Dims *, int, NPY_ORDER) + int PyArray_MoveInto (ndarray, ndarray) + int PyArray_CopyInto (ndarray, ndarray) + int PyArray_CopyAnyInto (ndarray, ndarray) + int PyArray_CopyObject (ndarray, object) + object PyArray_NewCopy (ndarray, NPY_ORDER) + object PyArray_ToList (ndarray) + object PyArray_ToString (ndarray, NPY_ORDER) + int PyArray_ToFile (ndarray, stdio.FILE *, char *, char *) + int PyArray_Dump (object, object, int) + object PyArray_Dumps (object, int) + int PyArray_ValidType (int) + void PyArray_UpdateFlags (ndarray, int) + object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object) + #object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object) + #dtype PyArray_DescrNew (dtype) + dtype PyArray_DescrNewFromType (int) + double PyArray_GetPriority (object, double) + object PyArray_IterNew (object) + object PyArray_MultiIterNew (int, ...) + + int PyArray_PyIntAsInt (object) + npy_intp PyArray_PyIntAsIntp (object) + int PyArray_Broadcast (broadcast) + void PyArray_FillObjectArray (ndarray, object) + int PyArray_FillWithScalar (ndarray, object) + npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *) + dtype PyArray_DescrNewByteorder (dtype, char) + object PyArray_IterAllButAxis (object, int *) + #object PyArray_CheckFromAny (object, dtype, int, int, int, object) + #object PyArray_FromArray (ndarray, dtype, int) + object PyArray_FromInterface (object) + object PyArray_FromStructInterface (object) + #object PyArray_FromArrayAttr (object, dtype, object) + #NPY_SCALARKIND PyArray_ScalarKind (int, ndarray*) + int PyArray_CanCoerceScalar (int, int, NPY_SCALARKIND) + object PyArray_NewFlagsObject (object) + npy_bool PyArray_CanCastScalar (type, type) + #int PyArray_CompareUCS4 (npy_ucs4 *, npy_ucs4 *, register size_t) + int PyArray_RemoveSmallest (broadcast) + int PyArray_ElementStrides (object) + void PyArray_Item_INCREF (char *, dtype) + void PyArray_Item_XDECREF (char *, dtype) + object PyArray_FieldNames (object) + object PyArray_Transpose (ndarray, PyArray_Dims *) + object PyArray_TakeFrom (ndarray, object, int, ndarray, NPY_CLIPMODE) + object PyArray_PutTo (ndarray, object, object, NPY_CLIPMODE) + object PyArray_PutMask (ndarray, object, object) + object PyArray_Repeat (ndarray, object, int) + object PyArray_Choose (ndarray, object, ndarray, NPY_CLIPMODE) + int PyArray_Sort (ndarray, int, NPY_SORTKIND) + object PyArray_ArgSort (ndarray, int, NPY_SORTKIND) + object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE) + object PyArray_ArgMax (ndarray, int, ndarray) + object PyArray_ArgMin (ndarray, int, ndarray) + object PyArray_Reshape (ndarray, object) + object PyArray_Newshape (ndarray, PyArray_Dims *, NPY_ORDER) + object PyArray_Squeeze (ndarray) + #object PyArray_View (ndarray, dtype, type) + object PyArray_SwapAxes (ndarray, int, int) + object PyArray_Max (ndarray, int, ndarray) + object PyArray_Min (ndarray, int, ndarray) + object PyArray_Ptp (ndarray, int, ndarray) + object PyArray_Mean (ndarray, int, int, ndarray) + object PyArray_Trace (ndarray, int, int, int, int, ndarray) + object PyArray_Diagonal (ndarray, int, int, int) + object PyArray_Clip (ndarray, object, object, ndarray) + object PyArray_Conjugate (ndarray, ndarray) + object PyArray_Nonzero (ndarray) + object PyArray_Std (ndarray, int, int, ndarray, int) + object PyArray_Sum (ndarray, int, int, ndarray) + object PyArray_CumSum (ndarray, int, int, ndarray) + object PyArray_Prod (ndarray, int, int, ndarray) + object PyArray_CumProd (ndarray, int, int, ndarray) + object PyArray_All (ndarray, int, ndarray) + object PyArray_Any (ndarray, int, ndarray) + object PyArray_Compress (ndarray, object, int, ndarray) + object PyArray_Flatten (ndarray, NPY_ORDER) + object PyArray_Ravel (ndarray, NPY_ORDER) + npy_intp PyArray_MultiplyList (npy_intp *, int) + int PyArray_MultiplyIntList (int *, int) + void * PyArray_GetPtr (ndarray, npy_intp*) + int PyArray_CompareLists (npy_intp *, npy_intp *, int) + #int PyArray_AsCArray (object*, void *, npy_intp *, int, dtype) + #int PyArray_As1D (object*, char **, int *, int) + #int PyArray_As2D (object*, char ***, int *, int *, int) + int PyArray_Free (object, void *) + #int PyArray_Converter (object, object*) + int PyArray_IntpFromSequence (object, npy_intp *, int) + object PyArray_Concatenate (object, int) + object PyArray_InnerProduct (object, object) + object PyArray_MatrixProduct (object, object) + object PyArray_CopyAndTranspose (object) + object PyArray_Correlate (object, object, int) + int PyArray_TypestrConvert (int, int) + #int PyArray_DescrConverter (object, dtype*) + #int PyArray_DescrConverter2 (object, dtype*) + int PyArray_IntpConverter (object, PyArray_Dims *) + #int PyArray_BufferConverter (object, chunk) + int PyArray_AxisConverter (object, int *) + int PyArray_BoolConverter (object, npy_bool *) + int PyArray_ByteorderConverter (object, char *) + int PyArray_OrderConverter (object, NPY_ORDER *) + unsigned char PyArray_EquivTypes (dtype, dtype) + #object PyArray_Zeros (int, npy_intp *, dtype, int) + #object PyArray_Empty (int, npy_intp *, dtype, int) + object PyArray_Where (object, object, object) + object PyArray_Arange (double, double, double, int) + #object PyArray_ArangeObj (object, object, object, dtype) + int PyArray_SortkindConverter (object, NPY_SORTKIND *) + object PyArray_LexSort (object, int) + object PyArray_Round (ndarray, int, ndarray) + unsigned char PyArray_EquivTypenums (int, int) + int PyArray_RegisterDataType (dtype) + int PyArray_RegisterCastFunc (dtype, int, PyArray_VectorUnaryFunc *) + int PyArray_RegisterCanCast (dtype, int, NPY_SCALARKIND) + #void PyArray_InitArrFuncs (PyArray_ArrFuncs *) + object PyArray_IntTupleFromIntp (int, npy_intp *) + int PyArray_TypeNumFromName (char *) + int PyArray_ClipmodeConverter (object, NPY_CLIPMODE *) + #int PyArray_OutputConverter (object, ndarray*) + object PyArray_BroadcastToShape (object, npy_intp *, int) + void _PyArray_SigintHandler (int) + void* _PyArray_GetSigintBuf () + #int PyArray_DescrAlignConverter (object, dtype*) + #int PyArray_DescrAlignConverter2 (object, dtype*) + int PyArray_SearchsideConverter (object, void *) + object PyArray_CheckAxis (ndarray, int *, int) + npy_intp PyArray_OverflowMultiplyList (npy_intp *, int) + int PyArray_CompareString (char *, char *, size_t) + int PyArray_SetBaseObject(ndarray, base) # NOTE: steals a reference to base! Use "set_array_base()" instead. + + +# Typedefs that matches the runtime dtype objects in +# the numpy module. + +# The ones that are commented out needs an IFDEF function +# in Cython to enable them only on the right systems. + +ctypedef npy_int8 int8_t +ctypedef npy_int16 int16_t +ctypedef npy_int32 int32_t +ctypedef npy_int64 int64_t +#ctypedef npy_int96 int96_t +#ctypedef npy_int128 int128_t + +ctypedef npy_uint8 uint8_t +ctypedef npy_uint16 uint16_t +ctypedef npy_uint32 uint32_t +ctypedef npy_uint64 uint64_t +#ctypedef npy_uint96 uint96_t +#ctypedef npy_uint128 uint128_t + +ctypedef npy_float32 float32_t +ctypedef npy_float64 float64_t +#ctypedef npy_float80 float80_t +#ctypedef npy_float128 float128_t + +ctypedef float complex complex64_t +ctypedef double complex complex128_t + +# The int types are mapped a bit surprising -- +# numpy.int corresponds to 'l' and numpy.long to 'q' +ctypedef npy_long int_t +ctypedef npy_longlong long_t +ctypedef npy_longlong longlong_t + +ctypedef npy_ulong uint_t +ctypedef npy_ulonglong ulong_t +ctypedef npy_ulonglong ulonglong_t + +ctypedef npy_intp intp_t +ctypedef npy_uintp uintp_t + +ctypedef npy_double float_t +ctypedef npy_double double_t +ctypedef npy_longdouble longdouble_t + +ctypedef npy_cfloat cfloat_t +ctypedef npy_cdouble cdouble_t +ctypedef npy_clongdouble clongdouble_t + +ctypedef npy_cdouble complex_t + +cdef inline object PyArray_MultiIterNew1(a): + return PyArray_MultiIterNew(1, <void*>a) + +cdef inline object PyArray_MultiIterNew2(a, b): + return PyArray_MultiIterNew(2, <void*>a, <void*>b) + +cdef inline object PyArray_MultiIterNew3(a, b, c): + return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) + +cdef inline object PyArray_MultiIterNew4(a, b, c, d): + return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) + +cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) + +cdef inline tuple PyDataType_SHAPE(dtype d): + if PyDataType_HASSUBARRAY(d): + return <tuple>d.subarray.shape + else: + return () + +cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + # Recursive utility function used in __getbuffer__ to get format + # string. The new location in the format string is returned. + + cdef dtype child + cdef int endian_detector = 1 + cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) + cdef tuple fields + + for childname in descr.names: + fields = descr.fields[childname] + child, new_offset = fields + + if (end - f) - <int>(new_offset - offset[0]) < 15: + raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + + if ((child.byteorder == c'>' and little_endian) or + (child.byteorder == c'<' and not little_endian)): + raise ValueError(u"Non-native byte order not supported") + # One could encode it in the format string and have Cython + # complain instead, BUT: < and > in format strings also imply + # standardized sizes for datatypes, and we rely on native in + # order to avoid reencoding data types based on their size. + # + # A proper PEP 3118 exporter for other clients than Cython + # must deal properly with this! + + # Output padding bytes + while offset[0] < new_offset: + f[0] = 120 # "x"; pad byte + f += 1 + offset[0] += 1 + + offset[0] += child.itemsize + + if not PyDataType_HASFIELDS(child): + t = child.type_num + if end - f < 5: + raise RuntimeError(u"Format string allocated too short.") + + # Until ticket #99 is fixed, use integers to avoid warnings + if t == NPY_BYTE: f[0] = 98 #"b" + elif t == NPY_UBYTE: f[0] = 66 #"B" + elif t == NPY_SHORT: f[0] = 104 #"h" + elif t == NPY_USHORT: f[0] = 72 #"H" + elif t == NPY_INT: f[0] = 105 #"i" + elif t == NPY_UINT: f[0] = 73 #"I" + elif t == NPY_LONG: f[0] = 108 #"l" + elif t == NPY_ULONG: f[0] = 76 #"L" + elif t == NPY_LONGLONG: f[0] = 113 #"q" + elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + elif t == NPY_FLOAT: f[0] = 102 #"f" + elif t == NPY_DOUBLE: f[0] = 100 #"d" + elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + elif t == NPY_OBJECT: f[0] = 79 #"O" + else: + raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + f += 1 + else: + # Cython ignores struct boundary information ("T{...}"), + # so don't output it + f = _util_dtypestring(child, f, end, offset) + return f + + +# +# ufunc API +# + +cdef extern from "numpy/ufuncobject.h": + + ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *) + + ctypedef extern class numpy.ufunc [object PyUFuncObject]: + cdef: + int nin, nout, nargs + int identity + PyUFuncGenericFunction *functions + void **data + int ntypes + int check_return + char *name + char *types + char *doc + void *ptr + PyObject *obj + PyObject *userloops + + cdef enum: + PyUFunc_Zero + PyUFunc_One + PyUFunc_None + UFUNC_ERR_IGNORE + UFUNC_ERR_WARN + UFUNC_ERR_RAISE + UFUNC_ERR_CALL + UFUNC_ERR_PRINT + UFUNC_ERR_LOG + UFUNC_MASK_DIVIDEBYZERO + UFUNC_MASK_OVERFLOW + UFUNC_MASK_UNDERFLOW + UFUNC_MASK_INVALID + UFUNC_SHIFT_DIVIDEBYZERO + UFUNC_SHIFT_OVERFLOW + UFUNC_SHIFT_UNDERFLOW + UFUNC_SHIFT_INVALID + UFUNC_FPE_DIVIDEBYZERO + UFUNC_FPE_OVERFLOW + UFUNC_FPE_UNDERFLOW + UFUNC_FPE_INVALID + UFUNC_ERR_DEFAULT + UFUNC_ERR_DEFAULT2 + + object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *, + void **, char *, int, int, int, int, char *, char *, int) + int PyUFunc_RegisterLoopForType(ufunc, int, + PyUFuncGenericFunction, int *, void *) + int PyUFunc_GenericFunction \ + (ufunc, PyObject *, PyObject *, PyArrayObject **) + void PyUFunc_f_f_As_d_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_d_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_f_f \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_g_g \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_F_F_As_D_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_F_F \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_D_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_G_G \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_O_O \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_ff_f_As_dd_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_ff_f \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_dd_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_gg_g \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_FF_F_As_DD_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_DD_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_FF_F \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_GG_G \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_OO_O \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_O_O_method \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_OO_O_method \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_On_Om \ + (char **, npy_intp *, npy_intp *, void *) + int PyUFunc_GetPyValues \ + (char *, int *, int *, PyObject **) + int PyUFunc_checkfperr \ + (int, PyObject *, int *) + void PyUFunc_clearfperr() + int PyUFunc_getfperr() + int PyUFunc_handlefperr \ + (int, PyObject *, int, int *) + int PyUFunc_ReplaceLoopBySignature \ + (ufunc, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *) + object PyUFunc_FromFuncAndDataAndSignature \ + (PyUFuncGenericFunction *, void **, char *, int, int, int, + int, char *, char *, int, char *) + + int _import_umath() except -1 + +cdef inline void set_array_base(ndarray arr, object base): + Py_INCREF(base) # important to do this before stealing the reference below! + PyArray_SetBaseObject(arr, base) + +cdef inline object get_array_base(ndarray arr): + base = PyArray_BASE(arr) + if base is NULL: + return None + return <object>base + +# Versions of the import_* functions which are more suitable for +# Cython code. +cdef inline int import_array() except -1: + try: + _import_array() + except Exception: + raise ImportError("numpy.core.multiarray failed to import") + +cdef inline int import_umath() except -1: + try: + _import_umath() + except Exception: + raise ImportError("numpy.core.umath failed to import") + +cdef inline int import_ufunc() except -1: + try: + _import_umath() + except Exception: + raise ImportError("numpy.core.umath failed to import") diff --git a/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd b/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd new file mode 100644 index 00000000000..15700c05efd --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd @@ -0,0 +1,1049 @@ +# NumPy static imports for Cython +# +# If any of the PyArray_* functions are called, import_array must be +# called first. +# +# This also defines backwards-compatibility buffer acquisition +# code for use in Python 2.x (or Python <= 2.5 when NumPy starts +# implementing PEP-3118 directly). +# +# Because of laziness, the format string of the buffer is statically +# allocated. Increase the size if this is not enough, or submit a +# patch to do this properly. +# +# Author: Dag Sverre Seljebotn +# + +DEF _buffer_format_string_len = 255 + +cimport cpython.buffer as pybuf +from cpython.ref cimport Py_INCREF +from cpython.mem cimport PyObject_Malloc, PyObject_Free +from cpython.object cimport PyObject, PyTypeObject +from cpython.type cimport type +cimport libc.stdio as stdio + +cdef extern from "Python.h": + ctypedef int Py_intptr_t + +cdef extern from "numpy/arrayobject.h": + ctypedef Py_intptr_t npy_intp + ctypedef size_t npy_uintp + + cdef enum NPY_TYPES: + NPY_BOOL + NPY_BYTE + NPY_UBYTE + NPY_SHORT + NPY_USHORT + NPY_INT + NPY_UINT + NPY_LONG + NPY_ULONG + NPY_LONGLONG + NPY_ULONGLONG + NPY_FLOAT + NPY_DOUBLE + NPY_LONGDOUBLE + NPY_CFLOAT + NPY_CDOUBLE + NPY_CLONGDOUBLE + NPY_OBJECT + NPY_STRING + NPY_UNICODE + NPY_VOID + NPY_DATETIME + NPY_TIMEDELTA + NPY_NTYPES + NPY_NOTYPE + + NPY_INT8 + NPY_INT16 + NPY_INT32 + NPY_INT64 + NPY_INT128 + NPY_INT256 + NPY_UINT8 + NPY_UINT16 + NPY_UINT32 + NPY_UINT64 + NPY_UINT128 + NPY_UINT256 + NPY_FLOAT16 + NPY_FLOAT32 + NPY_FLOAT64 + NPY_FLOAT80 + NPY_FLOAT96 + NPY_FLOAT128 + NPY_FLOAT256 + NPY_COMPLEX32 + NPY_COMPLEX64 + NPY_COMPLEX128 + NPY_COMPLEX160 + NPY_COMPLEX192 + NPY_COMPLEX256 + NPY_COMPLEX512 + + NPY_INTP + + ctypedef enum NPY_ORDER: + NPY_ANYORDER + NPY_CORDER + NPY_FORTRANORDER + NPY_KEEPORDER + + ctypedef enum NPY_CASTING: + NPY_NO_CASTING + NPY_EQUIV_CASTING + NPY_SAFE_CASTING + NPY_SAME_KIND_CASTING + NPY_UNSAFE_CASTING + + ctypedef enum NPY_CLIPMODE: + NPY_CLIP + NPY_WRAP + NPY_RAISE + + ctypedef enum NPY_SCALARKIND: + NPY_NOSCALAR, + NPY_BOOL_SCALAR, + NPY_INTPOS_SCALAR, + NPY_INTNEG_SCALAR, + NPY_FLOAT_SCALAR, + NPY_COMPLEX_SCALAR, + NPY_OBJECT_SCALAR + + ctypedef enum NPY_SORTKIND: + NPY_QUICKSORT + NPY_HEAPSORT + NPY_MERGESORT + + ctypedef enum NPY_SEARCHSIDE: + NPY_SEARCHLEFT + NPY_SEARCHRIGHT + + enum: + # DEPRECATED since NumPy 1.7 ! Do not use in new code! + NPY_C_CONTIGUOUS + NPY_F_CONTIGUOUS + NPY_CONTIGUOUS + NPY_FORTRAN + NPY_OWNDATA + NPY_FORCECAST + NPY_ENSURECOPY + NPY_ENSUREARRAY + NPY_ELEMENTSTRIDES + NPY_ALIGNED + NPY_NOTSWAPPED + NPY_WRITEABLE + NPY_UPDATEIFCOPY + NPY_ARR_HAS_DESCR + + NPY_BEHAVED + NPY_BEHAVED_NS + NPY_CARRAY + NPY_CARRAY_RO + NPY_FARRAY + NPY_FARRAY_RO + NPY_DEFAULT + + NPY_IN_ARRAY + NPY_OUT_ARRAY + NPY_INOUT_ARRAY + NPY_IN_FARRAY + NPY_OUT_FARRAY + NPY_INOUT_FARRAY + + NPY_UPDATE_ALL + + enum: + # Added in NumPy 1.7 to replace the deprecated enums above. + NPY_ARRAY_C_CONTIGUOUS + NPY_ARRAY_F_CONTIGUOUS + NPY_ARRAY_OWNDATA + NPY_ARRAY_FORCECAST + NPY_ARRAY_ENSURECOPY + NPY_ARRAY_ENSUREARRAY + NPY_ARRAY_ELEMENTSTRIDES + NPY_ARRAY_ALIGNED + NPY_ARRAY_NOTSWAPPED + NPY_ARRAY_WRITEABLE + NPY_ARRAY_UPDATEIFCOPY + + NPY_ARRAY_BEHAVED + NPY_ARRAY_BEHAVED_NS + NPY_ARRAY_CARRAY + NPY_ARRAY_CARRAY_RO + NPY_ARRAY_FARRAY + NPY_ARRAY_FARRAY_RO + NPY_ARRAY_DEFAULT + + NPY_ARRAY_IN_ARRAY + NPY_ARRAY_OUT_ARRAY + NPY_ARRAY_INOUT_ARRAY + NPY_ARRAY_IN_FARRAY + NPY_ARRAY_OUT_FARRAY + NPY_ARRAY_INOUT_FARRAY + + NPY_ARRAY_UPDATE_ALL + + cdef enum: + NPY_MAXDIMS + + npy_intp NPY_MAX_ELSIZE + + ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *) + + ctypedef struct PyArray_ArrayDescr: + # shape is a tuple, but Cython doesn't support "tuple shape" + # inside a non-PyObject declaration, so we have to declare it + # as just a PyObject*. + PyObject* shape + + ctypedef struct PyArray_Descr: + pass + + ctypedef class numpy.dtype [object PyArray_Descr, check_size ignore]: + # Use PyDataType_* macros when possible, however there are no macros + # for accessing some of the fields, so some are defined. + cdef PyTypeObject* typeobj + cdef char kind + cdef char type + # Numpy sometimes mutates this without warning (e.g. it'll + # sometimes change "|" to "<" in shared dtype objects on + # little-endian machines). If this matters to you, use + # PyArray_IsNativeByteOrder(dtype.byteorder) instead of + # directly accessing this field. + cdef char byteorder + cdef char flags + cdef int type_num + cdef int itemsize "elsize" + cdef int alignment + cdef dict fields + cdef tuple names + # Use PyDataType_HASSUBARRAY to test whether this field is + # valid (the pointer can be NULL). Most users should access + # this field via the inline helper method PyDataType_SHAPE. + cdef PyArray_ArrayDescr* subarray + + ctypedef class numpy.flatiter [object PyArrayIterObject, check_size ignore]: + # Use through macros + pass + + ctypedef class numpy.broadcast [object PyArrayMultiIterObject, check_size ignore]: + # Use through macros + pass + + ctypedef struct PyArrayObject: + # For use in situations where ndarray can't replace PyArrayObject*, + # like PyArrayObject**. + pass + + ctypedef class numpy.ndarray [object PyArrayObject, check_size ignore]: + cdef __cythonbufferdefaults__ = {"mode": "strided"} + + cdef: + # Only taking a few of the most commonly used and stable fields. + # One should use PyArray_* macros instead to access the C fields. + char *data + int ndim "nd" + npy_intp *shape "dimensions" + npy_intp *strides + dtype descr # deprecated since NumPy 1.7 ! + PyObject* base + + # Note: This syntax (function definition in pxd files) is an + # experimental exception made for __getbuffer__ and __releasebuffer__ + # -- the details of this may change. + def __getbuffer__(ndarray self, Py_buffer* info, int flags): + # This implementation of getbuffer is geared towards Cython + # requirements, and does not yet fulfill the PEP. + # In particular strided access is always provided regardless + # of flags + + cdef int i, ndim + cdef int endian_detector = 1 + cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) + + ndim = PyArray_NDIM(self) + + if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): + raise ValueError(u"ndarray is not C contiguous") + + if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): + raise ValueError(u"ndarray is not Fortran contiguous") + + info.buf = PyArray_DATA(self) + info.ndim = ndim + if sizeof(npy_intp) != sizeof(Py_ssize_t): + # Allocate new buffer for strides and shape info. + # This is allocated as one block, strides first. + info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim) + info.shape = info.strides + ndim + for i in range(ndim): + info.strides[i] = PyArray_STRIDES(self)[i] + info.shape[i] = PyArray_DIMS(self)[i] + else: + info.strides = <Py_ssize_t*>PyArray_STRIDES(self) + info.shape = <Py_ssize_t*>PyArray_DIMS(self) + info.suboffsets = NULL + info.itemsize = PyArray_ITEMSIZE(self) + info.readonly = not PyArray_ISWRITEABLE(self) + + cdef int t + cdef char* f = NULL + cdef dtype descr = <dtype>PyArray_DESCR(self) + cdef int offset + + info.obj = self + + if not PyDataType_HASFIELDS(descr): + t = descr.type_num + if ((descr.byteorder == c'>' and little_endian) or + (descr.byteorder == c'<' and not little_endian)): + raise ValueError(u"Non-native byte order not supported") + if t == NPY_BYTE: f = "b" + elif t == NPY_UBYTE: f = "B" + elif t == NPY_SHORT: f = "h" + elif t == NPY_USHORT: f = "H" + elif t == NPY_INT: f = "i" + elif t == NPY_UINT: f = "I" + elif t == NPY_LONG: f = "l" + elif t == NPY_ULONG: f = "L" + elif t == NPY_LONGLONG: f = "q" + elif t == NPY_ULONGLONG: f = "Q" + elif t == NPY_FLOAT: f = "f" + elif t == NPY_DOUBLE: f = "d" + elif t == NPY_LONGDOUBLE: f = "g" + elif t == NPY_CFLOAT: f = "Zf" + elif t == NPY_CDOUBLE: f = "Zd" + elif t == NPY_CLONGDOUBLE: f = "Zg" + elif t == NPY_OBJECT: f = "O" + else: + raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + info.format = f + return + else: + info.format = <char*>PyObject_Malloc(_buffer_format_string_len) + info.format[0] = c'^' # Native data types, manual alignment + offset = 0 + f = _util_dtypestring(descr, info.format + 1, + info.format + _buffer_format_string_len, + &offset) + f[0] = c'\0' # Terminate format string + + def __releasebuffer__(ndarray self, Py_buffer* info): + if PyArray_HASFIELDS(self): + PyObject_Free(info.format) + if sizeof(npy_intp) != sizeof(Py_ssize_t): + PyObject_Free(info.strides) + # info.shape was stored after info.strides in the same block + + ctypedef unsigned char npy_bool + + ctypedef signed char npy_byte + ctypedef signed short npy_short + ctypedef signed int npy_int + ctypedef signed long npy_long + ctypedef signed long long npy_longlong + + ctypedef unsigned char npy_ubyte + ctypedef unsigned short npy_ushort + ctypedef unsigned int npy_uint + ctypedef unsigned long npy_ulong + ctypedef unsigned long long npy_ulonglong + + ctypedef float npy_float + ctypedef double npy_double + ctypedef long double npy_longdouble + + ctypedef signed char npy_int8 + ctypedef signed short npy_int16 + ctypedef signed int npy_int32 + ctypedef signed long long npy_int64 + ctypedef signed long long npy_int96 + ctypedef signed long long npy_int128 + + ctypedef unsigned char npy_uint8 + ctypedef unsigned short npy_uint16 + ctypedef unsigned int npy_uint32 + ctypedef unsigned long long npy_uint64 + ctypedef unsigned long long npy_uint96 + ctypedef unsigned long long npy_uint128 + + ctypedef float npy_float32 + ctypedef double npy_float64 + ctypedef long double npy_float80 + ctypedef long double npy_float96 + ctypedef long double npy_float128 + + ctypedef struct npy_cfloat: + double real + double imag + + ctypedef struct npy_cdouble: + double real + double imag + + ctypedef struct npy_clongdouble: + long double real + long double imag + + ctypedef struct npy_complex64: + float real + float imag + + ctypedef struct npy_complex128: + double real + double imag + + ctypedef struct npy_complex160: + long double real + long double imag + + ctypedef struct npy_complex192: + long double real + long double imag + + ctypedef struct npy_complex256: + long double real + long double imag + + ctypedef struct PyArray_Dims: + npy_intp *ptr + int len + + int _import_array() except -1 + + # + # Macros from ndarrayobject.h + # + bint PyArray_CHKFLAGS(ndarray m, int flags) + bint PyArray_IS_C_CONTIGUOUS(ndarray arr) + bint PyArray_IS_F_CONTIGUOUS(ndarray arr) + bint PyArray_ISCONTIGUOUS(ndarray m) + bint PyArray_ISWRITEABLE(ndarray m) + bint PyArray_ISALIGNED(ndarray m) + + int PyArray_NDIM(ndarray) + bint PyArray_ISONESEGMENT(ndarray) + bint PyArray_ISFORTRAN(ndarray) + int PyArray_FORTRANIF(ndarray) + + void* PyArray_DATA(ndarray) + char* PyArray_BYTES(ndarray) + npy_intp* PyArray_DIMS(ndarray) + npy_intp* PyArray_STRIDES(ndarray) + npy_intp PyArray_DIM(ndarray, size_t) + npy_intp PyArray_STRIDE(ndarray, size_t) + + PyObject *PyArray_BASE(ndarray) # returns borrowed reference! + PyArray_Descr *PyArray_DESCR(ndarray) # returns borrowed reference to dtype! + int PyArray_FLAGS(ndarray) + npy_intp PyArray_ITEMSIZE(ndarray) + int PyArray_TYPE(ndarray arr) + + object PyArray_GETITEM(ndarray arr, void *itemptr) + int PyArray_SETITEM(ndarray arr, void *itemptr, object obj) + + bint PyTypeNum_ISBOOL(int) + bint PyTypeNum_ISUNSIGNED(int) + bint PyTypeNum_ISSIGNED(int) + bint PyTypeNum_ISINTEGER(int) + bint PyTypeNum_ISFLOAT(int) + bint PyTypeNum_ISNUMBER(int) + bint PyTypeNum_ISSTRING(int) + bint PyTypeNum_ISCOMPLEX(int) + bint PyTypeNum_ISPYTHON(int) + bint PyTypeNum_ISFLEXIBLE(int) + bint PyTypeNum_ISUSERDEF(int) + bint PyTypeNum_ISEXTENDED(int) + bint PyTypeNum_ISOBJECT(int) + + bint PyDataType_ISBOOL(dtype) + bint PyDataType_ISUNSIGNED(dtype) + bint PyDataType_ISSIGNED(dtype) + bint PyDataType_ISINTEGER(dtype) + bint PyDataType_ISFLOAT(dtype) + bint PyDataType_ISNUMBER(dtype) + bint PyDataType_ISSTRING(dtype) + bint PyDataType_ISCOMPLEX(dtype) + bint PyDataType_ISPYTHON(dtype) + bint PyDataType_ISFLEXIBLE(dtype) + bint PyDataType_ISUSERDEF(dtype) + bint PyDataType_ISEXTENDED(dtype) + bint PyDataType_ISOBJECT(dtype) + bint PyDataType_HASFIELDS(dtype) + bint PyDataType_HASSUBARRAY(dtype) + + bint PyArray_ISBOOL(ndarray) + bint PyArray_ISUNSIGNED(ndarray) + bint PyArray_ISSIGNED(ndarray) + bint PyArray_ISINTEGER(ndarray) + bint PyArray_ISFLOAT(ndarray) + bint PyArray_ISNUMBER(ndarray) + bint PyArray_ISSTRING(ndarray) + bint PyArray_ISCOMPLEX(ndarray) + bint PyArray_ISPYTHON(ndarray) + bint PyArray_ISFLEXIBLE(ndarray) + bint PyArray_ISUSERDEF(ndarray) + bint PyArray_ISEXTENDED(ndarray) + bint PyArray_ISOBJECT(ndarray) + bint PyArray_HASFIELDS(ndarray) + + bint PyArray_ISVARIABLE(ndarray) + + bint PyArray_SAFEALIGNEDCOPY(ndarray) + bint PyArray_ISNBO(char) # works on ndarray.byteorder + bint PyArray_IsNativeByteOrder(char) # works on ndarray.byteorder + bint PyArray_ISNOTSWAPPED(ndarray) + bint PyArray_ISBYTESWAPPED(ndarray) + + bint PyArray_FLAGSWAP(ndarray, int) + + bint PyArray_ISCARRAY(ndarray) + bint PyArray_ISCARRAY_RO(ndarray) + bint PyArray_ISFARRAY(ndarray) + bint PyArray_ISFARRAY_RO(ndarray) + bint PyArray_ISBEHAVED(ndarray) + bint PyArray_ISBEHAVED_RO(ndarray) + + + bint PyDataType_ISNOTSWAPPED(dtype) + bint PyDataType_ISBYTESWAPPED(dtype) + + bint PyArray_DescrCheck(object) + + bint PyArray_Check(object) + bint PyArray_CheckExact(object) + + # Cannot be supported due to out arg: + # bint PyArray_HasArrayInterfaceType(object, dtype, object, object&) + # bint PyArray_HasArrayInterface(op, out) + + + bint PyArray_IsZeroDim(object) + # Cannot be supported due to ## ## in macro: + # bint PyArray_IsScalar(object, verbatim work) + bint PyArray_CheckScalar(object) + bint PyArray_IsPythonNumber(object) + bint PyArray_IsPythonScalar(object) + bint PyArray_IsAnyScalar(object) + bint PyArray_CheckAnyScalar(object) + ndarray PyArray_GETCONTIGUOUS(ndarray) + bint PyArray_SAMESHAPE(ndarray, ndarray) + npy_intp PyArray_SIZE(ndarray) + npy_intp PyArray_NBYTES(ndarray) + + object PyArray_FROM_O(object) + object PyArray_FROM_OF(object m, int flags) + object PyArray_FROM_OT(object m, int type) + object PyArray_FROM_OTF(object m, int type, int flags) + object PyArray_FROMANY(object m, int type, int min, int max, int flags) + object PyArray_ZEROS(int nd, npy_intp* dims, int type, int fortran) + object PyArray_EMPTY(int nd, npy_intp* dims, int type, int fortran) + void PyArray_FILLWBYTE(object, int val) + npy_intp PyArray_REFCOUNT(object) + object PyArray_ContiguousFromAny(op, int, int min_depth, int max_depth) + unsigned char PyArray_EquivArrTypes(ndarray a1, ndarray a2) + bint PyArray_EquivByteorders(int b1, int b2) + object PyArray_SimpleNew(int nd, npy_intp* dims, int typenum) + object PyArray_SimpleNewFromData(int nd, npy_intp* dims, int typenum, void* data) + #object PyArray_SimpleNewFromDescr(int nd, npy_intp* dims, dtype descr) + object PyArray_ToScalar(void* data, ndarray arr) + + void* PyArray_GETPTR1(ndarray m, npy_intp i) + void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j) + void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k) + void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l) + + void PyArray_XDECREF_ERR(ndarray) + # Cannot be supported due to out arg + # void PyArray_DESCR_REPLACE(descr) + + + object PyArray_Copy(ndarray) + object PyArray_FromObject(object op, int type, int min_depth, int max_depth) + object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth) + object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth) + + object PyArray_Cast(ndarray mp, int type_num) + object PyArray_Take(ndarray ap, object items, int axis) + object PyArray_Put(ndarray ap, object items, object values) + + void PyArray_ITER_RESET(flatiter it) nogil + void PyArray_ITER_NEXT(flatiter it) nogil + void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil + void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil + void* PyArray_ITER_DATA(flatiter it) nogil + bint PyArray_ITER_NOTDONE(flatiter it) nogil + + void PyArray_MultiIter_RESET(broadcast multi) nogil + void PyArray_MultiIter_NEXT(broadcast multi) nogil + void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil + void PyArray_MultiIter_GOTO1D(broadcast multi, npy_intp ind) nogil + void* PyArray_MultiIter_DATA(broadcast multi, npy_intp i) nogil + void PyArray_MultiIter_NEXTi(broadcast multi, npy_intp i) nogil + bint PyArray_MultiIter_NOTDONE(broadcast multi) nogil + + # Functions from __multiarray_api.h + + # Functions taking dtype and returning object/ndarray are disabled + # for now as they steal dtype references. I'm conservative and disable + # more than is probably needed until it can be checked further. + int PyArray_SetNumericOps (object) + object PyArray_GetNumericOps () + int PyArray_INCREF (ndarray) + int PyArray_XDECREF (ndarray) + void PyArray_SetStringFunction (object, int) + dtype PyArray_DescrFromType (int) + object PyArray_TypeObjectFromType (int) + char * PyArray_Zero (ndarray) + char * PyArray_One (ndarray) + #object PyArray_CastToType (ndarray, dtype, int) + int PyArray_CastTo (ndarray, ndarray) + int PyArray_CastAnyTo (ndarray, ndarray) + int PyArray_CanCastSafely (int, int) + npy_bool PyArray_CanCastTo (dtype, dtype) + int PyArray_ObjectType (object, int) + dtype PyArray_DescrFromObject (object, dtype) + #ndarray* PyArray_ConvertToCommonType (object, int *) + dtype PyArray_DescrFromScalar (object) + dtype PyArray_DescrFromTypeObject (object) + npy_intp PyArray_Size (object) + #object PyArray_Scalar (void *, dtype, object) + #object PyArray_FromScalar (object, dtype) + void PyArray_ScalarAsCtype (object, void *) + #int PyArray_CastScalarToCtype (object, void *, dtype) + #int PyArray_CastScalarDirect (object, dtype, void *, int) + object PyArray_ScalarFromObject (object) + #PyArray_VectorUnaryFunc * PyArray_GetCastFunc (dtype, int) + object PyArray_FromDims (int, int *, int) + #object PyArray_FromDimsAndDataAndDescr (int, int *, dtype, char *) + #object PyArray_FromAny (object, dtype, int, int, int, object) + object PyArray_EnsureArray (object) + object PyArray_EnsureAnyArray (object) + #object PyArray_FromFile (stdio.FILE *, dtype, npy_intp, char *) + #object PyArray_FromString (char *, npy_intp, dtype, npy_intp, char *) + #object PyArray_FromBuffer (object, dtype, npy_intp, npy_intp) + #object PyArray_FromIter (object, dtype, npy_intp) + object PyArray_Return (ndarray) + #object PyArray_GetField (ndarray, dtype, int) + #int PyArray_SetField (ndarray, dtype, int, object) + object PyArray_Byteswap (ndarray, npy_bool) + object PyArray_Resize (ndarray, PyArray_Dims *, int, NPY_ORDER) + int PyArray_MoveInto (ndarray, ndarray) + int PyArray_CopyInto (ndarray, ndarray) + int PyArray_CopyAnyInto (ndarray, ndarray) + int PyArray_CopyObject (ndarray, object) + object PyArray_NewCopy (ndarray, NPY_ORDER) + object PyArray_ToList (ndarray) + object PyArray_ToString (ndarray, NPY_ORDER) + int PyArray_ToFile (ndarray, stdio.FILE *, char *, char *) + int PyArray_Dump (object, object, int) + object PyArray_Dumps (object, int) + int PyArray_ValidType (int) + void PyArray_UpdateFlags (ndarray, int) + object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object) + #object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object) + #dtype PyArray_DescrNew (dtype) + dtype PyArray_DescrNewFromType (int) + double PyArray_GetPriority (object, double) + object PyArray_IterNew (object) + object PyArray_MultiIterNew (int, ...) + + int PyArray_PyIntAsInt (object) + npy_intp PyArray_PyIntAsIntp (object) + int PyArray_Broadcast (broadcast) + void PyArray_FillObjectArray (ndarray, object) + int PyArray_FillWithScalar (ndarray, object) + npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *) + dtype PyArray_DescrNewByteorder (dtype, char) + object PyArray_IterAllButAxis (object, int *) + #object PyArray_CheckFromAny (object, dtype, int, int, int, object) + #object PyArray_FromArray (ndarray, dtype, int) + object PyArray_FromInterface (object) + object PyArray_FromStructInterface (object) + #object PyArray_FromArrayAttr (object, dtype, object) + #NPY_SCALARKIND PyArray_ScalarKind (int, ndarray*) + int PyArray_CanCoerceScalar (int, int, NPY_SCALARKIND) + object PyArray_NewFlagsObject (object) + npy_bool PyArray_CanCastScalar (type, type) + #int PyArray_CompareUCS4 (npy_ucs4 *, npy_ucs4 *, register size_t) + int PyArray_RemoveSmallest (broadcast) + int PyArray_ElementStrides (object) + void PyArray_Item_INCREF (char *, dtype) + void PyArray_Item_XDECREF (char *, dtype) + object PyArray_FieldNames (object) + object PyArray_Transpose (ndarray, PyArray_Dims *) + object PyArray_TakeFrom (ndarray, object, int, ndarray, NPY_CLIPMODE) + object PyArray_PutTo (ndarray, object, object, NPY_CLIPMODE) + object PyArray_PutMask (ndarray, object, object) + object PyArray_Repeat (ndarray, object, int) + object PyArray_Choose (ndarray, object, ndarray, NPY_CLIPMODE) + int PyArray_Sort (ndarray, int, NPY_SORTKIND) + object PyArray_ArgSort (ndarray, int, NPY_SORTKIND) + object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE, PyObject*) + object PyArray_ArgMax (ndarray, int, ndarray) + object PyArray_ArgMin (ndarray, int, ndarray) + object PyArray_Reshape (ndarray, object) + object PyArray_Newshape (ndarray, PyArray_Dims *, NPY_ORDER) + object PyArray_Squeeze (ndarray) + #object PyArray_View (ndarray, dtype, type) + object PyArray_SwapAxes (ndarray, int, int) + object PyArray_Max (ndarray, int, ndarray) + object PyArray_Min (ndarray, int, ndarray) + object PyArray_Ptp (ndarray, int, ndarray) + object PyArray_Mean (ndarray, int, int, ndarray) + object PyArray_Trace (ndarray, int, int, int, int, ndarray) + object PyArray_Diagonal (ndarray, int, int, int) + object PyArray_Clip (ndarray, object, object, ndarray) + object PyArray_Conjugate (ndarray, ndarray) + object PyArray_Nonzero (ndarray) + object PyArray_Std (ndarray, int, int, ndarray, int) + object PyArray_Sum (ndarray, int, int, ndarray) + object PyArray_CumSum (ndarray, int, int, ndarray) + object PyArray_Prod (ndarray, int, int, ndarray) + object PyArray_CumProd (ndarray, int, int, ndarray) + object PyArray_All (ndarray, int, ndarray) + object PyArray_Any (ndarray, int, ndarray) + object PyArray_Compress (ndarray, object, int, ndarray) + object PyArray_Flatten (ndarray, NPY_ORDER) + object PyArray_Ravel (ndarray, NPY_ORDER) + npy_intp PyArray_MultiplyList (npy_intp *, int) + int PyArray_MultiplyIntList (int *, int) + void * PyArray_GetPtr (ndarray, npy_intp*) + int PyArray_CompareLists (npy_intp *, npy_intp *, int) + #int PyArray_AsCArray (object*, void *, npy_intp *, int, dtype) + #int PyArray_As1D (object*, char **, int *, int) + #int PyArray_As2D (object*, char ***, int *, int *, int) + int PyArray_Free (object, void *) + #int PyArray_Converter (object, object*) + int PyArray_IntpFromSequence (object, npy_intp *, int) + object PyArray_Concatenate (object, int) + object PyArray_InnerProduct (object, object) + object PyArray_MatrixProduct (object, object) + object PyArray_CopyAndTranspose (object) + object PyArray_Correlate (object, object, int) + int PyArray_TypestrConvert (int, int) + #int PyArray_DescrConverter (object, dtype*) + #int PyArray_DescrConverter2 (object, dtype*) + int PyArray_IntpConverter (object, PyArray_Dims *) + #int PyArray_BufferConverter (object, chunk) + int PyArray_AxisConverter (object, int *) + int PyArray_BoolConverter (object, npy_bool *) + int PyArray_ByteorderConverter (object, char *) + int PyArray_OrderConverter (object, NPY_ORDER *) + unsigned char PyArray_EquivTypes (dtype, dtype) + #object PyArray_Zeros (int, npy_intp *, dtype, int) + #object PyArray_Empty (int, npy_intp *, dtype, int) + object PyArray_Where (object, object, object) + object PyArray_Arange (double, double, double, int) + #object PyArray_ArangeObj (object, object, object, dtype) + int PyArray_SortkindConverter (object, NPY_SORTKIND *) + object PyArray_LexSort (object, int) + object PyArray_Round (ndarray, int, ndarray) + unsigned char PyArray_EquivTypenums (int, int) + int PyArray_RegisterDataType (dtype) + int PyArray_RegisterCastFunc (dtype, int, PyArray_VectorUnaryFunc *) + int PyArray_RegisterCanCast (dtype, int, NPY_SCALARKIND) + #void PyArray_InitArrFuncs (PyArray_ArrFuncs *) + object PyArray_IntTupleFromIntp (int, npy_intp *) + int PyArray_TypeNumFromName (char *) + int PyArray_ClipmodeConverter (object, NPY_CLIPMODE *) + #int PyArray_OutputConverter (object, ndarray*) + object PyArray_BroadcastToShape (object, npy_intp *, int) + void _PyArray_SigintHandler (int) + void* _PyArray_GetSigintBuf () + #int PyArray_DescrAlignConverter (object, dtype*) + #int PyArray_DescrAlignConverter2 (object, dtype*) + int PyArray_SearchsideConverter (object, void *) + object PyArray_CheckAxis (ndarray, int *, int) + npy_intp PyArray_OverflowMultiplyList (npy_intp *, int) + int PyArray_CompareString (char *, char *, size_t) + int PyArray_SetBaseObject(ndarray, base) # NOTE: steals a reference to base! Use "set_array_base()" instead. + + +# Typedefs that matches the runtime dtype objects in +# the numpy module. + +# The ones that are commented out needs an IFDEF function +# in Cython to enable them only on the right systems. + +ctypedef npy_int8 int8_t +ctypedef npy_int16 int16_t +ctypedef npy_int32 int32_t +ctypedef npy_int64 int64_t +#ctypedef npy_int96 int96_t +#ctypedef npy_int128 int128_t + +ctypedef npy_uint8 uint8_t +ctypedef npy_uint16 uint16_t +ctypedef npy_uint32 uint32_t +ctypedef npy_uint64 uint64_t +#ctypedef npy_uint96 uint96_t +#ctypedef npy_uint128 uint128_t + +ctypedef npy_float32 float32_t +ctypedef npy_float64 float64_t +#ctypedef npy_float80 float80_t +#ctypedef npy_float128 float128_t + +ctypedef float complex complex64_t +ctypedef double complex complex128_t + +# The int types are mapped a bit surprising -- +# numpy.int corresponds to 'l' and numpy.long to 'q' +ctypedef npy_long int_t +ctypedef npy_longlong long_t +ctypedef npy_longlong longlong_t + +ctypedef npy_ulong uint_t +ctypedef npy_ulonglong ulong_t +ctypedef npy_ulonglong ulonglong_t + +ctypedef npy_intp intp_t +ctypedef npy_uintp uintp_t + +ctypedef npy_double float_t +ctypedef npy_double double_t +ctypedef npy_longdouble longdouble_t + +ctypedef npy_cfloat cfloat_t +ctypedef npy_cdouble cdouble_t +ctypedef npy_clongdouble clongdouble_t + +ctypedef npy_cdouble complex_t + +cdef inline object PyArray_MultiIterNew1(a): + return PyArray_MultiIterNew(1, <void*>a) + +cdef inline object PyArray_MultiIterNew2(a, b): + return PyArray_MultiIterNew(2, <void*>a, <void*>b) + +cdef inline object PyArray_MultiIterNew3(a, b, c): + return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) + +cdef inline object PyArray_MultiIterNew4(a, b, c, d): + return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) + +cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) + +cdef inline tuple PyDataType_SHAPE(dtype d): + if PyDataType_HASSUBARRAY(d): + return <tuple>d.subarray.shape + else: + return () + +cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + # Recursive utility function used in __getbuffer__ to get format + # string. The new location in the format string is returned. + + cdef dtype child + cdef int endian_detector = 1 + cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) + cdef tuple fields + + for childname in descr.names: + fields = descr.fields[childname] + child, new_offset = fields + + if (end - f) - <int>(new_offset - offset[0]) < 15: + raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + + if ((child.byteorder == c'>' and little_endian) or + (child.byteorder == c'<' and not little_endian)): + raise ValueError(u"Non-native byte order not supported") + # One could encode it in the format string and have Cython + # complain instead, BUT: < and > in format strings also imply + # standardized sizes for datatypes, and we rely on native in + # order to avoid reencoding data types based on their size. + # + # A proper PEP 3118 exporter for other clients than Cython + # must deal properly with this! + + # Output padding bytes + while offset[0] < new_offset: + f[0] = 120 # "x"; pad byte + f += 1 + offset[0] += 1 + + offset[0] += child.itemsize + + if not PyDataType_HASFIELDS(child): + t = child.type_num + if end - f < 5: + raise RuntimeError(u"Format string allocated too short.") + + # Until ticket #99 is fixed, use integers to avoid warnings + if t == NPY_BYTE: f[0] = 98 #"b" + elif t == NPY_UBYTE: f[0] = 66 #"B" + elif t == NPY_SHORT: f[0] = 104 #"h" + elif t == NPY_USHORT: f[0] = 72 #"H" + elif t == NPY_INT: f[0] = 105 #"i" + elif t == NPY_UINT: f[0] = 73 #"I" + elif t == NPY_LONG: f[0] = 108 #"l" + elif t == NPY_ULONG: f[0] = 76 #"L" + elif t == NPY_LONGLONG: f[0] = 113 #"q" + elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + elif t == NPY_FLOAT: f[0] = 102 #"f" + elif t == NPY_DOUBLE: f[0] = 100 #"d" + elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + elif t == NPY_OBJECT: f[0] = 79 #"O" + else: + raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + f += 1 + else: + # Cython ignores struct boundary information ("T{...}"), + # so don't output it + f = _util_dtypestring(child, f, end, offset) + return f + + +# +# ufunc API +# + +cdef extern from "numpy/ufuncobject.h": + + ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *) + + ctypedef class numpy.ufunc [object PyUFuncObject, check_size ignore]: + cdef: + int nin, nout, nargs + int identity + PyUFuncGenericFunction *functions + void **data + int ntypes + int check_return + char *name + char *types + char *doc + void *ptr + PyObject *obj + PyObject *userloops + + cdef enum: + PyUFunc_Zero + PyUFunc_One + PyUFunc_None + UFUNC_ERR_IGNORE + UFUNC_ERR_WARN + UFUNC_ERR_RAISE + UFUNC_ERR_CALL + UFUNC_ERR_PRINT + UFUNC_ERR_LOG + UFUNC_MASK_DIVIDEBYZERO + UFUNC_MASK_OVERFLOW + UFUNC_MASK_UNDERFLOW + UFUNC_MASK_INVALID + UFUNC_SHIFT_DIVIDEBYZERO + UFUNC_SHIFT_OVERFLOW + UFUNC_SHIFT_UNDERFLOW + UFUNC_SHIFT_INVALID + UFUNC_FPE_DIVIDEBYZERO + UFUNC_FPE_OVERFLOW + UFUNC_FPE_UNDERFLOW + UFUNC_FPE_INVALID + UFUNC_ERR_DEFAULT + UFUNC_ERR_DEFAULT2 + + object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *, + void **, char *, int, int, int, int, char *, char *, int) + int PyUFunc_RegisterLoopForType(ufunc, int, + PyUFuncGenericFunction, int *, void *) + int PyUFunc_GenericFunction \ + (ufunc, PyObject *, PyObject *, PyArrayObject **) + void PyUFunc_f_f_As_d_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_d_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_f_f \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_g_g \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_F_F_As_D_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_F_F \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_D_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_G_G \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_O_O \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_ff_f_As_dd_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_ff_f \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_dd_d \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_gg_g \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_FF_F_As_DD_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_DD_D \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_FF_F \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_GG_G \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_OO_O \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_O_O_method \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_OO_O_method \ + (char **, npy_intp *, npy_intp *, void *) + void PyUFunc_On_Om \ + (char **, npy_intp *, npy_intp *, void *) + int PyUFunc_GetPyValues \ + (char *, int *, int *, PyObject **) + int PyUFunc_checkfperr \ + (int, PyObject *, int *) + void PyUFunc_clearfperr() + int PyUFunc_getfperr() + int PyUFunc_handlefperr \ + (int, PyObject *, int, int *) + int PyUFunc_ReplaceLoopBySignature \ + (ufunc, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *) + object PyUFunc_FromFuncAndDataAndSignature \ + (PyUFuncGenericFunction *, void **, char *, int, int, int, + int, char *, char *, int, char *) + + int _import_umath() except -1 + +cdef inline void set_array_base(ndarray arr, object base): + Py_INCREF(base) # important to do this before stealing the reference below! + PyArray_SetBaseObject(arr, base) + +cdef inline object get_array_base(ndarray arr): + base = PyArray_BASE(arr) + if base is NULL: + return None + return <object>base + +# Versions of the import_* functions which are more suitable for +# Cython code. +cdef inline int import_array() except -1: + try: + _import_array() + except Exception: + raise ImportError("numpy.core.multiarray failed to import") + +cdef inline int import_umath() except -1: + try: + _import_umath() + except Exception: + raise ImportError("numpy.core.umath failed to import") + +cdef inline int import_ufunc() except -1: + try: + _import_umath() + except Exception: + raise ImportError("numpy.core.umath failed to import") diff --git a/contrib/tools/cython/Cython/Includes/numpy/math.pxd b/contrib/tools/cython/Cython/Includes/numpy/math.pxd new file mode 100644 index 00000000000..c16df1c51a5 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/numpy/math.pxd @@ -0,0 +1,133 @@ +# NumPy math library +# +# This exports the functionality of the NumPy core math library, aka npymath, +# which provides implementations of C99 math functions and macros for system +# with a C89 library (such as MSVC). npymath is available with NumPy >=1.3, +# although some functions will require later versions. The spacing function is +# not in C99, but comes from Fortran. +# +# On the Cython side, the npymath functions are available without the "npy_" +# prefix that they have in C, to make this is a drop-in replacement for +# libc.math. The same is true for the constants, where possible. +# +# See the NumPy documentation for linking instructions. +# +# Complex number support and NumPy 2.0 half-precision functions are currently +# not exported. +# +# Author: Lars Buitinck + +cdef extern from "numpy/npy_math.h" nogil: + # Floating-point classification + long double NAN "NPY_NAN" + long double INFINITY "NPY_INFINITY" + long double PZERO "NPY_PZERO" # positive zero + long double NZERO "NPY_NZERO" # negative zero + + # These four are actually macros and work on any floating-point type. + int isinf "npy_isinf"(long double) # -1 / 0 / 1 + bint isfinite "npy_isfinite"(long double) + bint isnan "npy_isnan"(long double) + bint signbit "npy_signbit"(long double) + + # Math constants + long double E "NPY_E" + long double LOG2E "NPY_LOG2E" # ln(e) / ln(2) + long double LOG10E "NPY_LOG10E" # ln(e) / ln(10) + long double LOGE2 "NPY_LOGE2" # ln(2) + long double LOGE10 "NPY_LOGE10" # ln(10) + long double PI "NPY_PI" + long double PI_2 "NPY_PI_2" # pi / 2 + long double PI_4 "NPY_PI_4" # pi / 4 + long double NPY_1_PI # 1 / pi; NPY_ because of ident syntax + long double NPY_2_PI # 2 / pi + long double EULER "NPY_EULER" # Euler constant (gamma, 0.57721) + + # Low-level floating point manipulation (NumPy >=1.4) + float copysignf "npy_copysignf"(float, float) + float nextafterf "npy_nextafterf"(float x, float y) + float spacingf "npy_spacingf"(float x) + double copysign "npy_copysign"(double, double) + double nextafter "npy_nextafter"(double x, double y) + double spacing "npy_spacing"(double x) + long double copysignl "npy_copysignl"(long double, long double) + long double nextafterl "npy_nextafterl"(long double x, long double y) + long double spacingl "npy_spacingl"(long double x) + + # Float C99 functions + float sinf "npy_sinf"(float x) + float cosf "npy_cosf"(float x) + float tanf "npy_tanf"(float x) + float sinhf "npy_sinhf"(float x) + float coshf "npy_coshf"(float x) + float tanhf "npy_tanhf"(float x) + float fabsf "npy_fabsf"(float x) + float floorf "npy_floorf"(float x) + float ceilf "npy_ceilf"(float x) + float rintf "npy_rintf"(float x) + float sqrtf "npy_sqrtf"(float x) + float log10f "npy_log10f"(float x) + float logf "npy_logf"(float x) + float expf "npy_expf"(float x) + float expm1f "npy_expm1f"(float x) + float asinf "npy_asinf"(float x) + float acosf "npy_acosf"(float x) + float atanf "npy_atanf"(float x) + float asinhf "npy_asinhf"(float x) + float acoshf "npy_acoshf"(float x) + float atanhf "npy_atanhf"(float x) + float log1pf "npy_log1pf"(float x) + float exp2f "npy_exp2f"(float x) + float log2f "npy_log2f"(float x) + float atan2f "npy_atan2f"(float x, float y) + float hypotf "npy_hypotf"(float x, float y) + float powf "npy_powf"(float x, float y) + float fmodf "npy_fmodf"(float x, float y) + float modff "npy_modff"(float x, float* y) + + # Long double C99 functions + long double sinl "npy_sinl"(long double x) + long double cosl "npy_cosl"(long double x) + long double tanl "npy_tanl"(long double x) + long double sinhl "npy_sinhl"(long double x) + long double coshl "npy_coshl"(long double x) + long double tanhl "npy_tanhl"(long double x) + long double fabsl "npy_fabsl"(long double x) + long double floorl "npy_floorl"(long double x) + long double ceill "npy_ceill"(long double x) + long double rintl "npy_rintl"(long double x) + long double sqrtl "npy_sqrtl"(long double x) + long double log10l "npy_log10l"(long double x) + long double logl "npy_logl"(long double x) + long double expl "npy_expl"(long double x) + long double expm1l "npy_expm1l"(long double x) + long double asinl "npy_asinl"(long double x) + long double acosl "npy_acosl"(long double x) + long double atanl "npy_atanl"(long double x) + long double asinhl "npy_asinhl"(long double x) + long double acoshl "npy_acoshl"(long double x) + long double atanhl "npy_atanhl"(long double x) + long double log1pl "npy_log1pl"(long double x) + long double exp2l "npy_exp2l"(long double x) + long double log2l "npy_log2l"(long double x) + long double atan2l "npy_atan2l"(long double x, long double y) + long double hypotl "npy_hypotl"(long double x, long double y) + long double powl "npy_powl"(long double x, long double y) + long double fmodl "npy_fmodl"(long double x, long double y) + long double modfl "npy_modfl"(long double x, long double* y) + + # NumPy extensions + float deg2radf "npy_deg2radf"(float x) + float rad2degf "npy_rad2degf"(float x) + float logaddexpf "npy_logaddexpf"(float x, float y) + float logaddexp2f "npy_logaddexp2f"(float x, float y) + + double deg2rad "npy_deg2rad"(double x) + double rad2deg "npy_rad2deg"(double x) + double logaddexp "npy_logaddexp"(double x, double y) + double logaddexp2 "npy_logaddexp2"(double x, double y) + + long double deg2radl "npy_deg2radl"(long double x) + long double rad2degl "npy_rad2degl"(long double x) + long double logaddexpl "npy_logaddexpl"(long double x, long double y) + long double logaddexp2l "npy_logaddexp2l"(long double x, long double y) diff --git a/contrib/tools/cython/Cython/Includes/openmp.pxd b/contrib/tools/cython/Cython/Includes/openmp.pxd new file mode 100644 index 00000000000..30873a588bb --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/openmp.pxd @@ -0,0 +1,51 @@ +cdef extern from "<omp.h>": + ctypedef struct omp_lock_t: + pass + ctypedef struct omp_nest_lock_t: + pass + + ctypedef enum omp_sched_t: + omp_sched_static = 1, + omp_sched_dynamic = 2, + omp_sched_guided = 3, + omp_sched_auto = 4 + + extern void omp_set_num_threads(int) nogil + extern int omp_get_num_threads() nogil + extern int omp_get_max_threads() nogil + extern int omp_get_thread_num() nogil + extern int omp_get_num_procs() nogil + + extern int omp_in_parallel() nogil + + extern void omp_set_dynamic(int) nogil + extern int omp_get_dynamic() nogil + + extern void omp_set_nested(int) nogil + extern int omp_get_nested() nogil + + extern void omp_init_lock(omp_lock_t *) nogil + extern void omp_destroy_lock(omp_lock_t *) nogil + extern void omp_set_lock(omp_lock_t *) nogil + extern void omp_unset_lock(omp_lock_t *) nogil + extern int omp_test_lock(omp_lock_t *) nogil + + extern void omp_init_nest_lock(omp_nest_lock_t *) nogil + extern void omp_destroy_nest_lock(omp_nest_lock_t *) nogil + extern void omp_set_nest_lock(omp_nest_lock_t *) nogil + extern void omp_unset_nest_lock(omp_nest_lock_t *) nogil + extern int omp_test_nest_lock(omp_nest_lock_t *) nogil + + extern double omp_get_wtime() nogil + extern double omp_get_wtick() nogil + + void omp_set_schedule(omp_sched_t, int) nogil + void omp_get_schedule(omp_sched_t *, int *) nogil + int omp_get_thread_limit() nogil + void omp_set_max_active_levels(int) nogil + int omp_get_max_active_levels() nogil + int omp_get_level() nogil + int omp_get_ancestor_thread_num(int) nogil + int omp_get_team_size(int) nogil + int omp_get_active_level() nogil + diff --git a/contrib/tools/cython/Cython/Includes/posix/__init__.pxd b/contrib/tools/cython/Cython/Includes/posix/__init__.pxd new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/__init__.pxd @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd b/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd new file mode 100644 index 00000000000..cff5bea15a9 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd @@ -0,0 +1,14 @@ +# POSIX dynamic linking/loading interface. +# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dlfcn.h.html + +cdef extern from "<dlfcn.h>" nogil: + void *dlopen(const char *, int) + char *dlerror() + void *dlsym(void *, const char *) + int dlclose(void *) + + enum: + RTLD_LAZY + RTLD_NOW + RTLD_GLOBAL + RTLD_LOCAL diff --git a/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd b/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd new file mode 100644 index 00000000000..9afc33a3688 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd @@ -0,0 +1,68 @@ +# http://www.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html + +cdef extern from "<fcntl.h>" nogil: + + enum: F_DUPFD + enum: F_GETFD + enum: F_SETFD + enum: F_GETFL + enum: F_SETFL + enum: F_GETLK + enum: F_SETLK + enum: F_SETLKW + enum: F_GETOWN + enum: F_SETOWN + + enum: FD_CLOEXEC + + enum: F_RDLCK + enum: F_UNLCK + enum: F_WRLCK + + enum: SEEK_SET + enum: SEEK_CUR + enum: SEEK_END + + enum: O_CREAT + enum: O_DIRECT + enum: O_EXCL + enum: O_NOCTTY + enum: O_TRUNC + + enum: O_APPEND + enum: O_DSYNC + enum: O_NONBLOCK + enum: O_RSYNC + enum: O_SYNC + + enum: O_ACCMODE # O_RDONLY|O_WRONLY|O_RDWR + + enum: O_RDONLY + enum: O_WRONLY + enum: O_RDWR + + enum: S_IFMT + enum: S_IFBLK + enum: S_IFCHR + enum: S_IFIFO + enum: S_IFREG + enum: S_IFDIR + enum: S_IFLNK + enum: S_IFSOCK + + ctypedef int mode_t + ctypedef signed pid_t + ctypedef signed off_t + + struct flock: + short l_type + short l_whence + off_t l_start + off_t l_len + pid_t l_pid + + int creat(char *, mode_t) + int fcntl(int, int, ...) + int open(char *, int, ...) + #int open (char *, int, mode_t) + diff --git a/contrib/tools/cython/Cython/Includes/posix/ioctl.pxd b/contrib/tools/cython/Cython/Includes/posix/ioctl.pxd new file mode 100644 index 00000000000..dacbc307f3f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/ioctl.pxd @@ -0,0 +1,4 @@ +cdef extern from "<sys/ioctl.h>" nogil: + enum: FIONBIO + + int ioctl(int fd, int request, ...) diff --git a/contrib/tools/cython/Cython/Includes/posix/mman.pxd b/contrib/tools/cython/Cython/Includes/posix/mman.pxd new file mode 100644 index 00000000000..c810f431b3d --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/mman.pxd @@ -0,0 +1,99 @@ +# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/mman.h.html + +from posix.types cimport off_t, mode_t + +cdef extern from "<sys/mman.h>" nogil: + enum: PROT_EXEC # protection bits for mmap/mprotect + enum: PROT_READ + enum: PROT_WRITE + enum: PROT_NONE + + enum: MAP_PRIVATE # flag bits for mmap + enum: MAP_SHARED + enum: MAP_FIXED + enum: MAP_ANON # These three are not in POSIX, but are + enum: MAP_ANONYMOUS # fairly common in spelling/semantics + enum: MAP_STACK + + enum: MAP_LOCKED # Typically available only on Linux + enum: MAP_HUGETLB + enum: MAP_POPULATE + enum: MAP_NORESERVE + enum: MAP_GROWSDOWN + + enum: MAP_NOCORE # Typically available only on BSD + enum: MAP_NOSYNC + + void *MAP_FAILED + + void *mmap(void *addr, size_t Len, int prot, int flags, int fd, off_t off) + int munmap(void *addr, size_t Len) + int mprotect(void *addr, size_t Len, int prot) + + enum: MS_ASYNC + enum: MS_SYNC + enum: MS_INVALIDATE + int msync(void *addr, size_t Len, int flags) + + enum: POSIX_MADV_NORMAL # POSIX advice flags + enum: POSIX_MADV_SEQUENTIAL + enum: POSIX_MADV_RANDOM + enum: POSIX_MADV_WILLNEED + enum: POSIX_MADV_DONTNEED + int posix_madvise(void *addr, size_t Len, int advice) + + enum: MCL_CURRENT + enum: MCL_FUTURE + int mlock(const void *addr, size_t Len) + int munlock(const void *addr, size_t Len) + int mlockall(int flags) + int munlockall() + # Linux-specific + enum: MLOCK_ONFAULT + enum: MCL_ONFAULT + int mlock2(const void *addr, size_t len, int flags) + + int shm_open(const char *name, int oflag, mode_t mode) + int shm_unlink(const char *name) + + # often available + enum: MADV_NORMAL # pre-POSIX advice flags; should translate 1-1 to POSIX_* + enum: MADV_RANDOM # but in practice it is not always the same. + enum: MADV_SEQUENTIAL + enum: MADV_WILLNEED + enum: MADV_DONTNEED + enum: MADV_REMOVE # other pre-POSIX advice flags; often available + enum: MADV_DONTFORK + enum: MADV_DOFORK + enum: MADV_HWPOISON + enum: MADV_MERGEABLE, + enum: MADV_UNMERGEABLE + enum: MADV_SOFT_OFFLINE + enum: MADV_HUGEPAGE + enum: MADV_NOHUGEPAGE + enum: MADV_DONTDUMP + enum: MADV_DODUMP + enum: MADV_FREE + enum: MADV_WIPEONFORK + enum: MADV_KEEPONFORK + int madvise(void *addr, size_t Len, int advice) + + # sometimes available + int mincore(void *addr, size_t Len, unsigned char *vec) + + # These two are Linux specific but sometimes very efficient + void *mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...) + int remap_file_pages(void *addr, size_t Len, int prot, + size_t pgoff, int flags) + + # The rare but standardized typed memory option + enum: POSIX_TYPED_MEM_ALLOCATE + enum: POSIX_TYPED_MEM_ALLOCATE_CONTIG + enum: POSIX_TYPED_MEM_MAP_ALLOCATABLE + int posix_typed_mem_open(const char *name, int oflag, int tflag) + int posix_mem_offset(const void *addr, size_t Len, off_t *off, + size_t *contig_len, int *fildes) + + cdef struct posix_typed_mem_info: + size_t posix_tmi_length + int posix_typed_mem_get_info(int fildes, posix_typed_mem_info *info) diff --git a/contrib/tools/cython/Cython/Includes/posix/resource.pxd b/contrib/tools/cython/Cython/Includes/posix/resource.pxd new file mode 100644 index 00000000000..9f55c6ab4ee --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/resource.pxd @@ -0,0 +1,55 @@ +# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html + +from posix.time cimport timeval +from posix.types cimport id_t + +cdef extern from "<sys/resource.h>" nogil: + + enum: PRIO_PROCESS + enum: PRIO_PGRP + enum: PRIO_USER + + enum: RLIM_INFINITY + enum: RLIM_SAVED_MAX + enum: RLIM_SAVED_CUR + + enum: RUSAGE_SELF + enum: RUSAGE_CHILDREN + + enum: RLIMIT_CORE + enum: RLIMIT_CPU + enum: RLIMIT_DATA + enum: RLIMIT_FSIZE + enum: RLIMIT_NOFILE + enum: RLIMIT_STACK + enum: RLIMIT_AS + + ctypedef unsigned long rlim_t + + cdef struct rlimit: + rlim_t rlim_cur + rlim_t rlim_max + + cdef struct rusage: + timeval ru_utime + timeval ru_stime + long ru_maxrss + long ru_ixrss + long ru_idrss + long ru_isrss + long ru_minflt + long ru_majflt + long ru_nswap + long ru_inblock + long ru_oublock + long ru_msgsnd + long ru_msgrcv + long ru_nsignals + long ru_nvcsw + long ru_nivcsw + + int getpriority(int, id_t) + int getrlimit(int, rlimit *) + int getrusage(int, rusage *) + int setpriority(int, id_t, int) + int setrlimit(int, const rlimit *) diff --git a/contrib/tools/cython/Cython/Includes/posix/select.pxd b/contrib/tools/cython/Cython/Includes/posix/select.pxd new file mode 100644 index 00000000000..46703df1043 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/select.pxd @@ -0,0 +1,19 @@ +from .types cimport sigset_t +from .time cimport timeval, timespec + +cdef extern from "<sys/select.h>" nogil: + ctypedef struct fd_set: + pass + + int FD_SETSIZE + void FD_SET(int, fd_set*) + void FD_CLR(int, fd_set*) + bint FD_ISSET(int, fd_set*) + void FD_ZERO(fd_set*) + + int select(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const timeval *timeout) + + int pselect(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const timespec *timeout, + const sigset_t *sigmask) diff --git a/contrib/tools/cython/Cython/Includes/posix/signal.pxd b/contrib/tools/cython/Cython/Includes/posix/signal.pxd new file mode 100644 index 00000000000..9fe7d9c36c7 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/signal.pxd @@ -0,0 +1,73 @@ +# 7.14 Signal handling <signal.h> + +from posix.types cimport pid_t, sigset_t, uid_t + +cdef extern from "<signal.h>" nogil: + + cdef union sigval: + int sival_int + void *sival_ptr + + cdef struct sigevent: + int sigev_notify + int sigev_signo + sigval sigev_value + void sigev_notify_function(sigval) + + ctypedef struct siginfo_t: + int si_signo + int si_code + int si_errno + pid_t si_pid + uid_t si_uid + void *si_addr + int si_status + long si_band + sigval si_value + + cdef struct sigaction_t "sigaction": + void sa_handler(int) + void sa_sigaction(int, siginfo_t *, void *) + sigset_t sa_mask + int sa_flags + + ctypedef struct stack_t: + void *ss_sp + int ss_flags + size_t ss_size + + enum: SA_NOCLDSTOP + enum: SIG_BLOCK + enum: SIG_UNBLOCK + enum: SIG_SETMASK + enum: SA_ONSTACK + enum: SA_RESETHAND + enum: SA_RESTART + enum: SA_SIGINFO + enum: SA_NOCLDWAIT + enum: SA_NODEFER + enum: SS_ONSTACK + enum: SS_DISABLE + enum: MINSIGSTKSZ + enum: SIGSTKSZ + + enum: SIGEV_NONE + enum: SIGEV_SIGNAL + enum: SIGEV_THREAD + enum: SIGEV_THREAD_ID + + + int kill (pid_t, int) + int killpg (pid_t, int) + int sigaction (int, const sigaction_t *, sigaction_t *) + int sigpending (sigset_t *) + int sigprocmask (int, const sigset_t *, sigset_t *) + int sigsuspend (const sigset_t *) + + int sigaddset (sigset_t *, int) + int sigdelset (sigset_t *, int) + int sigemptyset (sigset_t *) + int sigfillset (sigset_t *) + int sigismember (const sigset_t *, int) + + int sigaltstack(const stack_t *, stack_t *) diff --git a/contrib/tools/cython/Cython/Includes/posix/stat.pxd b/contrib/tools/cython/Cython/Includes/posix/stat.pxd new file mode 100644 index 00000000000..69c2eca1667 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/stat.pxd @@ -0,0 +1,71 @@ +from posix.types cimport (blkcnt_t, blksize_t, dev_t, gid_t, ino_t, mode_t, + nlink_t, off_t, time_t, uid_t) + + +cdef extern from "<sys/stat.h>" nogil: + cdef struct struct_stat "stat": + dev_t st_dev + ino_t st_ino + mode_t st_mode + nlink_t st_nlink + uid_t st_uid + gid_t st_gid + dev_t st_rdev + off_t st_size + blksize_t st_blksize + blkcnt_t st_blocks + time_t st_atime + time_t st_mtime + time_t st_ctime + + # st_birthtime exists on *BSD and OS X. + # Under Linux, defining it here does not hurt. Compilation under Linux + # will only (and rightfully) fail when attempting to use the field. + time_t st_birthtime + +# POSIX prescribes including both <sys/stat.h> and <unistd.h> for these +cdef extern from "<unistd.h>" nogil: + int fchmod(int, mode_t) + int chmod(const char *, mode_t) + + int fstat(int, struct_stat *) + int lstat(const char *, struct_stat *) + int stat(const char *, struct_stat *) + + # Macros for st_mode + mode_t S_ISREG(mode_t) + mode_t S_ISDIR(mode_t) + mode_t S_ISCHR(mode_t) + mode_t S_ISBLK(mode_t) + mode_t S_ISFIFO(mode_t) + mode_t S_ISLNK(mode_t) + mode_t S_ISSOCK(mode_t) + + mode_t S_IFMT + mode_t S_IFREG + mode_t S_IFDIR + mode_t S_IFCHR + mode_t S_IFBLK + mode_t S_IFIFO + mode_t S_IFLNK + mode_t S_IFSOCK + + # Permissions + mode_t S_ISUID + mode_t S_ISGID + mode_t S_ISVTX + + mode_t S_IRWXU + mode_t S_IRUSR + mode_t S_IWUSR + mode_t S_IXUSR + + mode_t S_IRWXG + mode_t S_IRGRP + mode_t S_IWGRP + mode_t S_IXGRP + + mode_t S_IRWXO + mode_t S_IROTH + mode_t S_IWOTH + mode_t S_IXOTH diff --git a/contrib/tools/cython/Cython/Includes/posix/stdio.pxd b/contrib/tools/cython/Cython/Includes/posix/stdio.pxd new file mode 100644 index 00000000000..53913fdf457 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/stdio.pxd @@ -0,0 +1,37 @@ +# POSIX additions to <stdio.h>. +# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html + +from libc.stdio cimport FILE +from libc.stddef cimport wchar_t +from posix.types cimport off_t + +cdef extern from "<stdio.h>" nogil: + # File descriptors + FILE *fdopen(int, const char *) + int fileno(FILE *) + + # Pipes + FILE *popen(const char *, const char *) + int pclose(FILE *) + + # Memory streams (POSIX.2008) + FILE *fmemopen(void *, size_t, const char *) + FILE *open_memstream(char **, size_t *) + FILE *open_wmemstream(wchar_t **, size_t *) + + # Seek and tell with off_t + int fseeko(FILE *, off_t, int) + off_t ftello(FILE *) + + # Locking (for multithreading) + void flockfile(FILE *) + int ftrylockfile(FILE *) + void funlockfile(FILE *) + int getc_unlocked(FILE *) + int getchar_unlocked() + int putc_unlocked(int, FILE *) + int putchar_unlocked(int) + + # Reading lines and records (POSIX.2008) + ssize_t getline(char **, size_t *, FILE *) + ssize_t getdelim(char **, size_t *, int, FILE *) diff --git a/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd b/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd new file mode 100644 index 00000000000..513de938a88 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd @@ -0,0 +1,29 @@ +# POSIX additions to <stdlib.h> +# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html + +cdef extern from "<stdlib.h>" nogil: + void _Exit(int) + double drand48() + double erand48(unsigned short *) + int getsubopt(char **, char *const *, char **) + void lcong48(unsigned short *) + long lrand() + char *mkdtemp(char *) + int mkstemp(char *) + long mrand() + long nrand48(unsigned short *) + int posix_memalign(void **, size_t, size_t) + int posix_openpt(int) + char *ptsname(int) + int putenv(char *) + int rand_r(unsigned *) + long random() + char *realpath(const char *, char *) + unsigned short *seed48(unsigned short *) + int setenv(const char *, const char *, int) + void setkey(const char *) + char *setstate(char *) + void srand48(long) + void srandom(unsigned) + int unlockpt(int) + int unsetenv(const char *) diff --git a/contrib/tools/cython/Cython/Includes/posix/strings.pxd b/contrib/tools/cython/Cython/Includes/posix/strings.pxd new file mode 100644 index 00000000000..6ee48491eb8 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/strings.pxd @@ -0,0 +1,9 @@ +cdef extern from "<strings.h>" nogil: + int bcmp(const void *, const void *, size_t) + void bcopy(const void *, void *, size_t) + void bzero(void *, size_t) + int ffs(int) + char *index(const char *, int) + char *rindex(const char *, int) + int strcasecmp(const char *, const char *) + int strncasecmp(const char *, const char *, size_t) diff --git a/contrib/tools/cython/Cython/Includes/posix/time.pxd b/contrib/tools/cython/Cython/Includes/posix/time.pxd new file mode 100644 index 00000000000..6bc81bfea01 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/time.pxd @@ -0,0 +1,71 @@ +# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html + +from posix.types cimport suseconds_t, time_t, clockid_t, timer_t +from posix.signal cimport sigevent + +cdef extern from "<sys/time.h>" nogil: + enum: CLOCK_REALTIME + enum: TIMER_ABSTIME + enum: CLOCK_MONOTONIC + + # FreeBSD-specific clocks + enum: CLOCK_UPTIME + enum: CLOCK_UPTIME_PRECISE + enum: CLOCK_UPTIME_FAST + enum: CLOCK_REALTIME_PRECISE + enum: CLOCK_REALTIME_FAST + enum: CLOCK_MONOTONIC_PRECISE + enum: CLOCK_MONOTONIC_FAST + enum: CLOCK_SECOND + + # Linux-specific clocks + enum: CLOCK_PROCESS_CPUTIME_ID + enum: CLOCK_THREAD_CPUTIME_ID + enum: CLOCK_MONOTONIC_RAW + enum: CLOCK_REALTIME_COARSE + enum: CLOCK_MONOTONIC_COARSE + enum: CLOCK_BOOTTIME + enum: CLOCK_REALTIME_ALARM + enum: CLOCK_BOOTTIME_ALARM + + enum: ITIMER_REAL + enum: ITIMER_VIRTUAL + enum: ITIMER_PROF + + cdef struct timezone: + int tz_minuteswest + int dsttime + + cdef struct timeval: + time_t tv_sec + suseconds_t tv_usec + + cdef struct timespec: + time_t tv_sec + long tv_nsec + + cdef struct itimerval: + timeval it_interval + timeval it_value + + cdef struct itimerspec: + timespec it_interval + timespec it_value + + int nanosleep(const timespec *, timespec *) + + int getitimer(int, itimerval *) + int gettimeofday(timeval *tp, timezone *tzp) + int setitimer(int, const itimerval *, itimerval *) + + int clock_getcpuclockid(pid_t, clockid_t *) + int clock_getres(clockid_t, timespec *) + int clock_gettime(clockid_t, timespec *) + int clock_nanosleep(clockid_t, int, const timespec *, timespec *) + int clock_settime(clockid_t, const timespec *) + + int timer_create(clockid_t, sigevent *, timer_t *) + int timer_delete(timer_t) + int timer_gettime(timer_t, itimerspec *) + int timer_getoverrun(timer_t) + int timer_settime(timer_t, int, const itimerspec *, itimerspec *) diff --git a/contrib/tools/cython/Cython/Includes/posix/types.pxd b/contrib/tools/cython/Cython/Includes/posix/types.pxd new file mode 100644 index 00000000000..308f2954ee2 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/types.pxd @@ -0,0 +1,30 @@ +# Note that the actual size of these types is system-dependent, and +# can't be detected at C compile time. However, the generated C code +# will correctly use the actual size of these types *except* for +# determining promotion in binary arithmetic expressions involving +# mixed types. In this case, operands are promoted to the declared +# larger type, with a bias towards typedef types. Thus, with the +# declarations below, long + time_t will result in a time_t whereas +# long long + time_t will result in a long long which should be +# acceptable for either 32-bit or 64-bit signed time_t (though admittedly +# the POSIX standard doesn't even specify that time_t must be an integral +# type). + +cdef extern from "<sys/types.h>": + ctypedef long blkcnt_t + ctypedef long blksize_t + ctypedef long clockid_t + ctypedef long dev_t + ctypedef long gid_t + ctypedef long id_t + ctypedef unsigned long ino_t + ctypedef long mode_t + ctypedef long nlink_t + ctypedef long off_t + ctypedef long pid_t + ctypedef struct sigset_t: + pass + ctypedef long suseconds_t + ctypedef long time_t + ctypedef long timer_t + ctypedef long uid_t diff --git a/contrib/tools/cython/Cython/Includes/posix/unistd.pxd b/contrib/tools/cython/Cython/Includes/posix/unistd.pxd new file mode 100644 index 00000000000..1afeca38545 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/unistd.pxd @@ -0,0 +1,271 @@ +# http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html + +from posix.types cimport gid_t, pid_t, off_t, uid_t + +cdef extern from "<unistd.h>" nogil: + + #:NULL + + enum: R_OK + enum: W_OK + enum: X_OK + enum: F_OK + + enum: _CS_PATH + enum: _CS_POSIX_V6_ILP32_OFF32_CFLAGS + enum: _CS_POSIX_V6_ILP32_OFF32_LDFLAGS + enum: _CS_POSIX_V6_ILP32_OFF32_LIBS + enum: _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS + enum: _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS + enum: _CS_POSIX_V6_ILP32_OFFBIG_LIBS + enum: _CS_POSIX_V6_LP64_OFF64_CFLAGS + enum: _CS_POSIX_V6_LP64_OFF64_LDFLAGS + enum: _CS_POSIX_V6_LP64_OFF64_LIBS + enum: _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS + enum: _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS + enum: _CS_POSIX_V6_LPBIG_OFFBIG_LIBS + enum: _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS + + enum: SEEK_SET + enum: SEEK_CUR + enum: SEEK_END + + enum: F_LOCK + enum: F_TEST + enum: F_TLOCK + enum: F_ULOCK + + enum: _PC_2_SYMLINKS + enum: _PC_ALLOC_SIZE_MIN + enum: _PC_ASYNC_IO + enum: _PC_CHOWN_RESTRICTED + enum: _PC_FILESIZEBITS + enum: _PC_LINK_MAX + enum: _PC_MAX_CANON + enum: _PC_MAX_INPUT + enum: _PC_NAME_MAX + enum: _PC_NO_TRUNC + enum: _PC_PATH_MAX + enum: _PC_PIPE_BUF + enum: _PC_PRIO_IO + enum: _PC_REC_INCR_XFER_SIZE + enum: _PC_REC_MIN_XFER_SIZE + enum: _PC_REC_XFER_ALIGN + enum: _PC_SYMLINK_MAX + enum: _PC_SYNC_IO + enum: _PC_VDISABLE + + enum: _SC_2_C_BIND + enum: _SC_2_C_DEV + enum: _SC_2_CHAR_TERM + enum: _SC_2_FORT_DEV + enum: _SC_2_FORT_RUN + enum: _SC_2_LOCALEDEF + enum: _SC_2_PBS + enum: _SC_2_PBS_ACCOUNTING + enum: _SC_2_PBS_CHECKPOINT + enum: _SC_2_PBS_LOCATE + enum: _SC_2_PBS_MESSAGE + enum: _SC_2_PBS_TRACK + enum: _SC_2_SW_DEV + enum: _SC_2_UPE + enum: _SC_2_VERSION + enum: _SC_ADVISORY_INFO + enum: _SC_AIO_LISTIO_MAX + enum: _SC_AIO_MAX + enum: _SC_AIO_PRIO_DELTA_MAX + enum: _SC_ARG_MAX + enum: _SC_ASYNCHRONOUS_IO + enum: _SC_ATEXIT_MAX + enum: _SC_BARRIERS + enum: _SC_BC_BASE_MAX + enum: _SC_BC_DIM_MAX + enum: _SC_BC_SCALE_MAX + enum: _SC_BC_STRING_MAX + enum: _SC_CHILD_MAX + enum: _SC_CLK_TCK + enum: _SC_CLOCK_SELECTION + enum: _SC_COLL_WEIGHTS_MAX + enum: _SC_CPUTIME + enum: _SC_DELAYTIMER_MAX + enum: _SC_EXPR_NEST_MAX + enum: _SC_FSYNC + enum: _SC_GETGR_R_SIZE_MAX + enum: _SC_GETPW_R_SIZE_MAX + enum: _SC_HOST_NAME_MAX + enum: _SC_IOV_MAX + enum: _SC_IPV6 + enum: _SC_JOB_CONTROL + enum: _SC_LINE_MAX + enum: _SC_LOGIN_NAME_MAX + enum: _SC_MAPPED_FILES + enum: _SC_MEMLOCK + enum: _SC_MEMLOCK_RANGE + enum: _SC_MEMORY_PROTECTION + enum: _SC_MESSAGE_PASSING + enum: _SC_MONOTONIC_CLOCK + enum: _SC_MQ_OPEN_MAX + enum: _SC_MQ_PRIO_MAX + enum: _SC_NGROUPS_MAX + enum: _SC_OPEN_MAX + enum: _SC_PAGE_SIZE + enum: _SC_PAGESIZE + enum: _SC_PRIORITIZED_IO + enum: _SC_PRIORITY_SCHEDULING + enum: _SC_RAW_SOCKETS + enum: _SC_RE_DUP_MAX + enum: _SC_READER_WRITER_LOCKS + enum: _SC_REALTIME_SIGNALS + enum: _SC_REGEXP + enum: _SC_RTSIG_MAX + enum: _SC_SAVED_IDS + enum: _SC_SEM_NSEMS_MAX + enum: _SC_SEM_VALUE_MAX + enum: _SC_SEMAPHORES + enum: _SC_SHARED_MEMORY_OBJECTS + enum: _SC_SHELL + enum: _SC_SIGQUEUE_MAX + enum: _SC_SPAWN + enum: _SC_SPIN_LOCKS + enum: _SC_SPORADIC_SERVER + enum: _SC_SS_REPL_MAX + enum: _SC_STREAM_MAX + enum: _SC_SYMLOOP_MAX + enum: _SC_SYNCHRONIZED_IO + enum: _SC_THREAD_ATTR_STACKADDR + enum: _SC_THREAD_ATTR_STACKSIZE + enum: _SC_THREAD_CPUTIME + enum: _SC_THREAD_DESTRUCTOR_ITERATIONS + enum: _SC_THREAD_KEYS_MAX + enum: _SC_THREAD_PRIO_INHERIT + enum: _SC_THREAD_PRIO_PROTECT + enum: _SC_THREAD_PRIORITY_SCHEDULING + enum: _SC_THREAD_PROCESS_SHARED + enum: _SC_THREAD_SAFE_FUNCTIONS + enum: _SC_THREAD_SPORADIC_SERVER + enum: _SC_THREAD_STACK_MIN + enum: _SC_THREAD_THREADS_MAX + enum: _SC_THREADS + enum: _SC_TIMEOUTS + enum: _SC_TIMER_MAX + enum: _SC_TIMERS + enum: _SC_TRACE + enum: _SC_TRACE_EVENT_FILTER + enum: _SC_TRACE_EVENT_NAME_MAX + enum: _SC_TRACE_INHERIT + enum: _SC_TRACE_LOG + enum: _SC_TRACE_NAME_MAX + enum: _SC_TRACE_SYS_MAX + enum: _SC_TRACE_USER_EVENT_MAX + enum: _SC_TTY_NAME_MAX + enum: _SC_TYPED_MEMORY_OBJECTS + enum: _SC_TZNAME_MAX + enum: _SC_V6_ILP32_OFF32 + enum: _SC_V6_ILP32_OFFBIG + enum: _SC_V6_LP64_OFF64 + enum: _SC_V6_LPBIG_OFFBIG + enum: _SC_VERSION + enum: _SC_XBS5_ILP32_OFF32 + enum: _SC_XBS5_ILP32_OFFBIG + enum: _SC_XBS5_LP64_OFF64 + enum: _SC_XBS5_LPBIG_OFFBIG + enum: _SC_XOPEN_CRYPT + enum: _SC_XOPEN_ENH_I18N + enum: _SC_XOPEN_LEGACY + enum: _SC_XOPEN_REALTIME + enum: _SC_XOPEN_REALTIME_THREADS + enum: _SC_XOPEN_SHM + enum: _SC_XOPEN_STREAMS + enum: _SC_XOPEN_UNIX + enum: _SC_XOPEN_VERSION + + enum: STDIN_FILENO #0 + enum: STDOUT_FILENO #1 + enum: STDERR_FILENO #2 + + ctypedef unsigned useconds_t + + int access(const char *, int) + unsigned alarm(unsigned) + int chdir(const char *) + int chown(const char *, uid_t, gid_t) + int close(int) + size_t confstr(int, char *, size_t) + char *crypt(const char *, const char *) + char *ctermid(char *) + int dup(int) + int dup2(int, int) + void encrypt(char[64], int) + int execl(const char *, const char *, ...) + int execle(const char *, const char *, ...) + int execlp(const char *, const char *, ...) + int execv(const char *, char *[]) + int execve(const char *, char *[], char *[]) + int execvp(const char *, char *[]) + void _exit(int) + int fchown(int, uid_t, gid_t) + int fchdir(int) + int fdatasync(int) + pid_t fork() + long fpathconf(int, int) + int fsync(int) + int ftruncate(int, off_t) + char *getcwd(char *, size_t) + gid_t getegid() + uid_t geteuid() + gid_t getgid() + int getgroups(int, gid_t []) + long gethostid() + int gethostname(char *, size_t) + char *getlogin() + int getlogin_r(char *, size_t) + int getopt(int, char * [], const char *) + pid_t getpgid(pid_t) + pid_t getpgrp() + pid_t getpid() + pid_t getppid() + pid_t getsid(pid_t) + uid_t getuid() + char *getwd(char *) + int isatty(int) + int lchown(const char *, uid_t, gid_t) + int link(const char *, const char *) + int lockf(int, int, off_t) + off_t lseek(int, off_t, int) + int nice(int) + long pathconf(char *, int) + int pause() + int pipe(int [2]) + ssize_t pread(int, void *, size_t, off_t) + ssize_t pwrite(int, const void *, size_t, off_t) + ssize_t read(int, void *, size_t) + ssize_t readlink(const char *, char *, size_t) + int rmdir(const char *) + int setegid(gid_t) + int seteuid(uid_t) + int setgid(gid_t) + int setpgid(pid_t, pid_t) + pid_t setpgrp() + int setregid(gid_t, gid_t) + int setreuid(uid_t, uid_t) + pid_t setsid() + int setuid(uid_t) + unsigned sleep(unsigned) + void swab(const void *, void *, ssize_t) + int symlink(const char *, const char *) + void sync() + long sysconf(int) + pid_t tcgetpgrp(int) + int tcsetpgrp(int, pid_t) + int truncate(const char *, off_t) + char *ttyname(int) + int ttyname_r(int, char *, size_t) + useconds_t ualarm(useconds_t, useconds_t) + int unlink(const char *) + int usleep(useconds_t) + pid_t vfork() + ssize_t write(int, const void *, size_t) + char *optarg + int optind + int opterr + int optopt diff --git a/contrib/tools/cython/Cython/Includes/posix/wait.pxd b/contrib/tools/cython/Cython/Includes/posix/wait.pxd new file mode 100644 index 00000000000..d18cff9cf84 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/wait.pxd @@ -0,0 +1,38 @@ +# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/wait.h.html + +from posix.types cimport pid_t, id_t +from posix.signal cimport siginfo_t +from posix.resource cimport rusage + +cdef extern from "<sys/wait.h>" nogil: + enum: WNOHANG + enum: WUNTRACED + enum: WCONTINUED + enum: WEXITED + enum: WSTOPPED + enum: WNOWAIT + + int WEXITSTATUS(int status) + int WIFCONTINUED(int status) + int WIFEXITED(int status) + int WIFSIGNALED(int status) + int WIFSTOPPED(int status) + int WSTOPSIG(int status) + int WTERMSIG(int status) + + ctypedef int idtype_t + enum: P_ALL # idtype_t values + enum: P_PID + enum: P_PGID + + pid_t wait(int *stat_loc) + pid_t waitpid(pid_t pid, int *status, int options) + int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) + +# wait3 was in POSIX until 2008 while wait4 was never standardized. +# Even so, these calls are in almost every Unix, always in sys/wait.h. +# Hence, posix.wait is the least surprising place to declare them for Cython. +# libc may require _XXX_SOURCE to be defined at C-compile time to provide them. + + pid_t wait3(int *status, int options, rusage *rusage) + pid_t wait4(pid_t pid, int *status, int options, rusage *rusage) diff --git a/contrib/tools/cython/Cython/Parser/ConcreteSyntaxTree.pyx b/contrib/tools/cython/Cython/Parser/ConcreteSyntaxTree.pyx new file mode 100644 index 00000000000..f9888c561c4 --- /dev/null +++ b/contrib/tools/cython/Cython/Parser/ConcreteSyntaxTree.pyx @@ -0,0 +1,88 @@ +cdef extern from "graminit.c": + ctypedef struct grammar: + pass + cdef grammar _PyParser_Grammar + cdef int Py_file_input + +cdef extern from "node.h": + ctypedef struct node + void PyNode_Free(node* n) + int NCH(node* n) + node* CHILD(node* n, int ix) + node* RCHILD(node* n, int ix) + short TYPE(node* n) + char* STR(node* n) + +cdef extern from "parsetok.h": + ctypedef struct perrdetail: + pass + cdef void PyParser_SetError(perrdetail *err) except * + cdef node * PyParser_ParseStringFlagsFilenameEx( + const char * s, + const char * filename, + grammar * g, + int start, + perrdetail * err_ret, + int * flags) + +import distutils.sysconfig +import os +import re + +def extract_names(path): + # All parse tree types are #defined in these files as ints. + type_names = {} + for line in open(path): + if line.startswith('#define'): + try: + _, name, value = line.strip().split() + type_names[int(value)] = name + except: + pass + return type_names + +cdef dict type_names = {} + +cdef print_tree(node* n, indent=""): + if not type_names: + type_names.update(extract_names( + os.path.join(distutils.sysconfig.get_python_inc(), 'token.h'))) + type_names.update(extract_names( + os.path.join(os.path.dirname(__file__), 'graminit.h'))) + + print indent, type_names.get(TYPE(n), 'unknown'), <object>STR(n) if NCH(n) == 0 else NCH(n) + indent += " " + for i in range(NCH(n)): + print_tree(CHILD(n, i), indent) + +def handle_includes(source, path): + # TODO: Use include directory. + def include_here(include_line): + included = os.path.join(os.path.dirname(path), include_line.group(1)[1:-1]) + if not os.path.exists(included): + return include_line.group(0) + ' # no such path: ' + included + return handle_includes(open(included).read(), path) + # TODO: Proper string tokenizing. + return re.sub(r'^include\s+([^\n]+[\'"])\s*(#.*)?$', include_here, source, flags=re.M) + +def p_module(path): + cdef perrdetail err + cdef int flags + cdef node* n + source = open(path).read() + if '\ninclude ' in source: + # TODO: Tokanizer needs to understand includes. + source = handle_includes(source, path) + path = "preparse(%s)" % path + n = PyParser_ParseStringFlagsFilenameEx( + source, + path, + &_PyParser_Grammar, + Py_file_input, + &err, + &flags) + if n: +# print_tree(n) + PyNode_Free(n) + else: + PyParser_SetError(&err) diff --git a/contrib/tools/cython/Cython/Parser/Grammar b/contrib/tools/cython/Cython/Parser/Grammar new file mode 100644 index 00000000000..214e36d5a3f --- /dev/null +++ b/contrib/tools/cython/Cython/Parser/Grammar @@ -0,0 +1,214 @@ +# Grammar for Cython, based on the Grammar for Python 3 + +# Note: This grammar is not yet used by the Cython parser and is subject to change. + +# Start symbols for the grammar: +# single_input is a single interactive statement; +# file_input is a module or sequence of commands read from an input file; +# eval_input is the input for the eval() functions. +# NB: compound_stmt in single_input is followed by extra NEWLINE! +single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE +file_input: (NEWLINE | stmt)* ENDMARKER +eval_input: testlist NEWLINE* ENDMARKER + +decorator: '@' dotted_PY_NAME [ '(' [arglist] ')' ] NEWLINE +decorators: decorator+ +decorated: decorators (classdef | funcdef | async_funcdef | cdef_stmt) +async_funcdef: 'async' funcdef +funcdef: 'def' PY_NAME parameters ['->' test] ':' suite +parameters: '(' [typedargslist] ')' +typedargslist: (tfpdef ['=' (test | '*')] (',' tfpdef ['=' (test | '*')])* [',' + ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]] + | '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef) [',' ellipsis] +tfpdef: maybe_typed_name [('not' | 'or') 'None'] [':' test] +varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' + ['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]] + | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef) +vfpdef: maybe_typed_name ['not' 'None'] + +stmt: simple_stmt | compound_stmt | cdef_stmt | ctypedef_stmt | DEF_stmt | IF_stmt +simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE +small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | + import_stmt | global_stmt | nonlocal_stmt | assert_stmt | print_stmt) +expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | + ('=' (yield_expr|testlist_star_expr))*) +testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [','] +augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | + '<<=' | '>>=' | '**=' | '//=') +print_stmt: 'print' ( [ test (',' test)* [','] ] | + '>>' test [ (',' test)+ [','] ] ) +# For normal assignments, additional restrictions enforced by the interpreter +del_stmt: 'del' exprlist +pass_stmt: 'pass' +flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt +break_stmt: 'break' +continue_stmt: 'continue' +return_stmt: 'return' [testlist] +yield_stmt: yield_expr +raise_stmt: 'raise' [test ['from' test]] +# raise_stmt: 'raise' [test [',' test [',' test]]] +import_stmt: import_PY_NAME | import_from +import_PY_NAME: ('import' | 'cimport') dotted_as_PY_NAMEs +# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS +import_from: ('from' (('.' | '...')* dotted_PY_NAME | ('.' | '...')+) + ('import' | 'cimport') ('*' | '(' import_as_PY_NAMEs ')' | import_as_PY_NAMEs)) +import_as_PY_NAME: PY_NAME ['as' PY_NAME] +dotted_as_PY_NAME: dotted_PY_NAME ['as' PY_NAME] +import_as_PY_NAMEs: import_as_PY_NAME (',' import_as_PY_NAME)* [','] +dotted_as_PY_NAMEs: dotted_as_PY_NAME (',' dotted_as_PY_NAME)* +dotted_PY_NAME: PY_NAME ('.' PY_NAME)* +global_stmt: 'global' PY_NAME (',' PY_NAME)* +nonlocal_stmt: 'nonlocal' PY_NAME (',' PY_NAME)* +exec_stmt: 'exec' expr ['in' test [',' test]] +assert_stmt: 'assert' test [',' test] + +compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated +if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] +while_stmt: 'while' test ':' suite ['else' ':' suite] +for_stmt: 'for' exprlist ('in' testlist | for_from_clause)':' suite ['else' ':' suite] +for_from_clause: 'from' expr comp_op PY_NAME comp_op expr ['by' expr] +try_stmt: ('try' ':' suite + ((except_clause ':' suite)+ + ['else' ':' suite] + ['finally' ':' suite] | + 'finally' ':' suite)) +with_stmt: 'with' with_item (',' with_item)* ':' suite +with_item: test ['as' expr] +# NB compile.c makes sure that the default except clause is last +except_clause: 'except' [test [('as' | ',') test]] +suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT + +test: or_test ['if' or_test 'else' test] | lambdef +test_nocond: or_test | lambdef_nocond +lambdef: 'lambda' [varargslist] ':' test +lambdef_nocond: 'lambda' [varargslist] ':' test_nocond +or_test: and_test ('or' and_test)* +and_test: not_test ('and' not_test)* +not_test: 'not' not_test | comparison +comparison: expr (comp_op expr)* +# <> isn't actually a valid comparison operator in Python. It's here for the +# sake of a __future__ import described in PEP 401 +comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' +star_expr: '*' expr +expr: xor_expr ('|' xor_expr)* +xor_expr: and_expr ('^' and_expr)* +and_expr: shift_expr ('&' shift_expr)* +shift_expr: arith_expr (('<<'|'>>') arith_expr)* +arith_expr: term (('+'|'-') term)* +term: factor (('*'|'/'|'%'|'//') factor)* +factor: ('+'|'-'|'~') factor | power | address | size_of | cast +power: atom_expr ['**' factor] +atom_expr: ['await'] atom trailer* +atom: ('(' [yield_expr|testlist_comp] ')' | + '[' [testlist_comp] ']' | + '{' [dictorsetmaker] '}' | + new_expr | + PY_NAME | NUMBER | STRING+ | ellipsis | 'None' | 'True' | 'False') +testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) +trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' (PY_NAME | 'sizeof') +subscriptlist: subscript (',' subscript)* [','] +subscript: test | [test] ':' [test] [sliceop] +sliceop: ':' [test] +exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] +testlist: test (',' test)* [','] +dictorsetmaker: ( ((test ':' test | '**' expr) + (comp_for | (',' (test ':' test | '**' expr))* [','])) | + ((test | star_expr) + (comp_for | (',' (test | star_expr))* [','])) ) + +classdef: 'class' PY_NAME ['(' [arglist] ')'] ':' suite + +arglist: argument (',' argument)* [','] + +# The reason that keywords are test nodes instead of NAME is that using NAME +# results in an ambiguity. ast.c makes sure it's a NAME. +# "test '=' test" is really "keyword '=' test", but we have no such token. +# These need to be in a single rule to avoid grammar that is ambiguous +# to our LL(1) parser. Even though 'test' includes '*expr' in star_expr, +# we explicitly match '*' here, too, to give it proper precedence. +# Illegal combinations and orderings are blocked in ast.c: +# multiple (test comp_for) arguments are blocked; keyword unpackings +# that precede iterable unpackings are blocked; etc. +argument: ( test [comp_for] | + test '=' test | + '**' expr | + star_expr ) + +comp_iter: comp_for | comp_if +comp_for: 'for' exprlist ('in' or_test | for_from_clause) [comp_iter] +comp_if: 'if' test_nocond [comp_iter] + +# not used in grammar, but may appear in "node" passed from Parser to Compiler +encoding_decl: NAME + +yield_expr: 'yield' [yield_arg] +yield_arg: 'from' test | testlist + + +# Cython extensions + +# Accommodate to Py2 tokenizer. +ellipsis: '...' | '.' '.' '.' + +signedness: 'unsigned' | 'signed' +longness: 'char' | 'short' | 'long' | 'long' 'long' +# TODO: [unsigned] double doesn't make sens, but we need long double +int_type: signedness [longness] | longness | [signedness] [longness] ('int' | 'double') | 'complex' + +type: ['const'] (NAME ('.' PY_NAME)* | int_type | '(' type ')') ['complex'] [type_qualifiers] +maybe_typed_name: ['const'] (NAME [('.' PY_NAME)* ['complex'] [type_qualifiers] NAME] | (int_type | '(' type ')') ['complex'] [type_qualifiers] NAME) +teplate_params: '[' NAME (',' NAME)* ']' +type_qualifiers: type_qualifier+ +type_qualifier: '*' | '**' | '&' | type_index ('.' NAME [type_index])* +# TODO: old buffer syntax +type_index: '[' [(NUMBER | type (',' type)* | (memory_view_index (',' memory_view_index)*))] ']' +memory_view_index: ':' [':'] [NUMBER] + +address: '&' factor +cast: '<' type ['?'] '>' factor +size_of: 'sizeof' '(' (type) ')' +type_id: 'typeid' '(' (type) ')' +new_expr: 'new' type '(' [arglist] ')' + +# TODO: Restrict cdef_stmt to "top-level" statements. +cdef_stmt: ('cdef' | 'cpdef') (cvar_def | cdef_type_decl | extern_block) +cdef_type_decl: ctype_decl | fused | cclass +ctype_decl: struct | enum | cppclass +# TODO: Does the cdef/ctypedef distinction even make sense for fused? +ctypedef_stmt: 'ctypedef' (cvar_decl | struct | enum | fused) + +# Note: these two are similar but can't be used in an or clause +# as it would cause ambiguity in the LL(1) parser. +# Requires a type +cvar_decl: [visibility] type cname (NEWLINE | cfunc) +# Allows an assignment +cvar_def: [visibility] maybe_typed_name (['=' test] (',' PY_NAME ['=' test])* NEWLINE | cfunc) + +visibility: 'public' | 'api' | 'readonly' +# TODO: Standardize gil_spec first or last. +cfunc: [teplate_params] parameters [gil_spec] [exception_value] [gil_spec] (':' suite | NEWLINE) +exception_value: 'except' (['?'] expr | '*' | '+' [PY_NAME]) +gil_spec: 'with' ('gil' | 'nogil') | 'nogil' + +cname: NAME [STRING] +cclass: classdef +fused: 'fused' PY_NAME ':' NEWLINE INDENT ( type NEWLINE)+ DEDENT +enum: 'enum' [cname] (NEWLINE | ':' enum_suite) +enum_suite: NEWLINE INDENT (cname ['=' NUMBER] NEWLINE | pass_stmt NEWLINE)+ DEDENT +struct: ('struct' | 'union') cname (NEWLINE | (':' struct_suite)) +struct_suite: NEWLINE INDENT (cvar_decl | pass_stmt NEWLINE)+ DEDENT +cppclass: 'cppclass' cname [teplate_params] [cppclass_bases] (NEWLINE | ':' cppclass_suite) +cppclass_bases: '(' dotted_PY_NAME (',' dotted_PY_NAME [teplate_params])*')' +cppclass_suite: NEWLINE INDENT (cvar_decl | ctype_decl | pass_stmt NEWLINE)+ DEDENT +# TODO: C++ constructors, operators + +extern_block: 'extern' (cvar_decl | 'from' ('*' | STRING) ['namespace' STRING] [gil_spec] ':' (pass_stmt | extern_suite)) +extern_suite: NEWLINE INDENT (['cdef' | 'cpdef'] (cvar_decl | cdef_type_decl) | ctypedef_stmt)+ DEDENT + +cy_type_kwd: 'struct' | 'union' | 'fused' | 'cppclass' | 'int' | 'double' | 'complex' +cy_kwd: cy_type_kwd | signedness | longness | visibility | 'gil' | 'nogil' | 'namespace' | 'const' | 'by' | 'extern' +PY_NAME: NAME | cy_kwd + +# TODO: Do we really want these? Don't play well with include... +DEF_stmt: 'DEF' NAME '=' testlist +IF_stmt: 'IF' test ':' suite ('ELIF' test ':' suite)* ['ELSE' ':' suite] diff --git a/contrib/tools/cython/Cython/Parser/__init__.py b/contrib/tools/cython/Cython/Parser/__init__.py new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/contrib/tools/cython/Cython/Parser/__init__.py diff --git a/contrib/tools/cython/Cython/Plex/Actions.pxd b/contrib/tools/cython/Cython/Plex/Actions.pxd new file mode 100644 index 00000000000..34660a2d9b1 --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Actions.pxd @@ -0,0 +1,25 @@ + +cdef class Action: + cdef perform(self, token_stream, text) + cpdef same_as(self, other) + +cdef class Return(Action): + cdef object value + cdef perform(self, token_stream, text) + cpdef same_as(self, other) + +cdef class Call(Action): + cdef object function + cdef perform(self, token_stream, text) + cpdef same_as(self, other) + +cdef class Begin(Action): + cdef object state_name + cdef perform(self, token_stream, text) + cpdef same_as(self, other) + +cdef class Ignore(Action): + cdef perform(self, token_stream, text) + +cdef class Text(Action): + cdef perform(self, token_stream, text) diff --git a/contrib/tools/cython/Cython/Plex/Actions.py b/contrib/tools/cython/Cython/Plex/Actions.py new file mode 100644 index 00000000000..c88176e7161 --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Actions.py @@ -0,0 +1,110 @@ +# cython: auto_pickle=False +#======================================================================= +# +# Python Lexical Analyser +# +# Actions for use in token specifications +# +#======================================================================= + +class Action(object): + def perform(self, token_stream, text): + pass # abstract + + def same_as(self, other): + return self is other + + +class Return(Action): + """ + Internal Plex action which causes |value| to + be returned as the value of the associated token + """ + + def __init__(self, value): + self.value = value + + def perform(self, token_stream, text): + return self.value + + def same_as(self, other): + return isinstance(other, Return) and self.value == other.value + + def __repr__(self): + return "Return(%s)" % repr(self.value) + + +class Call(Action): + """ + Internal Plex action which causes a function to be called. + """ + + def __init__(self, function): + self.function = function + + def perform(self, token_stream, text): + return self.function(token_stream, text) + + def __repr__(self): + return "Call(%s)" % self.function.__name__ + + def same_as(self, other): + return isinstance(other, Call) and self.function is other.function + + +class Begin(Action): + """ + Begin(state_name) is a Plex action which causes the Scanner to + enter the state |state_name|. See the docstring of Plex.Lexicon + for more information. + """ + + def __init__(self, state_name): + self.state_name = state_name + + def perform(self, token_stream, text): + token_stream.begin(self.state_name) + + def __repr__(self): + return "Begin(%s)" % self.state_name + + def same_as(self, other): + return isinstance(other, Begin) and self.state_name == other.state_name + + +class Ignore(Action): + """ + IGNORE is a Plex action which causes its associated token + to be ignored. See the docstring of Plex.Lexicon for more + information. + """ + + def perform(self, token_stream, text): + return None + + def __repr__(self): + return "IGNORE" + + +IGNORE = Ignore() +#IGNORE.__doc__ = Ignore.__doc__ + + +class Text(Action): + """ + TEXT is a Plex action which causes the text of a token to + be returned as the value of the token. See the docstring of + Plex.Lexicon for more information. + """ + + def perform(self, token_stream, text): + return text + + def __repr__(self): + return "TEXT" + + +TEXT = Text() +#TEXT.__doc__ = Text.__doc__ + + diff --git a/contrib/tools/cython/Cython/Plex/DFA.py b/contrib/tools/cython/Cython/Plex/DFA.py new file mode 100644 index 00000000000..76324621fca --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/DFA.py @@ -0,0 +1,164 @@ +#======================================================================= +# +# Python Lexical Analyser +# +# Converting NFA to DFA +# +#======================================================================= + +from __future__ import absolute_import + +from . import Machines +from .Machines import LOWEST_PRIORITY +from .Transitions import TransitionMap + + +def nfa_to_dfa(old_machine, debug=None): + """ + Given a nondeterministic Machine, return a new equivalent + Machine which is deterministic. + """ + # We build a new machine whose states correspond to sets of states + # in the old machine. Initially we add a new state corresponding to + # the epsilon-closure of each initial old state. Then we give transitions + # to each new state which are the union of all transitions out of any + # of the corresponding old states. The new state reached on a given + # character is the one corresponding to the set of states reachable + # on that character from any of the old states. As new combinations of + # old states are created, new states are added as needed until closure + # is reached. + new_machine = Machines.FastMachine() + state_map = StateMap(new_machine) + # Seed the process using the initial states of the old machine. + # Make the corresponding new states into initial states of the new + # machine with the same names. + for (key, old_state) in old_machine.initial_states.items(): + new_state = state_map.old_to_new(epsilon_closure(old_state)) + new_machine.make_initial_state(key, new_state) + # Tricky bit here: we add things to the end of this list while we're + # iterating over it. The iteration stops when closure is achieved. + for new_state in new_machine.states: + transitions = TransitionMap() + for old_state in state_map.new_to_old(new_state): + for event, old_target_states in old_state.transitions.items(): + if event and old_target_states: + transitions.add_set(event, set_epsilon_closure(old_target_states)) + for event, old_states in transitions.items(): + new_machine.add_transitions(new_state, event, state_map.old_to_new(old_states)) + if debug: + debug.write("\n===== State Mapping =====\n") + state_map.dump(debug) + return new_machine + + +def set_epsilon_closure(state_set): + """ + Given a set of states, return the union of the epsilon + closures of its member states. + """ + result = {} + for state1 in state_set: + for state2 in epsilon_closure(state1): + result[state2] = 1 + return result + + +def epsilon_closure(state): + """ + Return the set of states reachable from the given state + by epsilon moves. + """ + # Cache the result + result = state.epsilon_closure + if result is None: + result = {} + state.epsilon_closure = result + add_to_epsilon_closure(result, state) + return result + + +def add_to_epsilon_closure(state_set, state): + """ + Recursively add to |state_set| states reachable from the given state + by epsilon moves. + """ + if not state_set.get(state, 0): + state_set[state] = 1 + state_set_2 = state.transitions.get_epsilon() + if state_set_2: + for state2 in state_set_2: + add_to_epsilon_closure(state_set, state2) + + +class StateMap(object): + """ + Helper class used by nfa_to_dfa() to map back and forth between + sets of states from the old machine and states of the new machine. + """ + new_machine = None # Machine + old_to_new_dict = None # {(old_state,...) : new_state} + new_to_old_dict = None # {id(new_state) : old_state_set} + + def __init__(self, new_machine): + self.new_machine = new_machine + self.old_to_new_dict = {} + self.new_to_old_dict = {} + + def old_to_new(self, old_state_set): + """ + Return the state of the new machine corresponding to the + set of old machine states represented by |state_set|. A new + state will be created if necessary. If any of the old states + are accepting states, the new state will be an accepting state + with the highest priority action from the old states. + """ + key = self.make_key(old_state_set) + new_state = self.old_to_new_dict.get(key, None) + if not new_state: + action = self.highest_priority_action(old_state_set) + new_state = self.new_machine.new_state(action) + self.old_to_new_dict[key] = new_state + self.new_to_old_dict[id(new_state)] = old_state_set + #for old_state in old_state_set.keys(): + #new_state.merge_actions(old_state) + return new_state + + def highest_priority_action(self, state_set): + best_action = None + best_priority = LOWEST_PRIORITY + for state in state_set: + priority = state.action_priority + if priority > best_priority: + best_action = state.action + best_priority = priority + return best_action + + # def old_to_new_set(self, old_state_set): + # """ + # Return the new state corresponding to a set of old states as + # a singleton set. + # """ + # return {self.old_to_new(old_state_set):1} + + def new_to_old(self, new_state): + """Given a new state, return a set of corresponding old states.""" + return self.new_to_old_dict[id(new_state)] + + def make_key(self, state_set): + """ + Convert a set of states into a uniquified + sorted tuple suitable for use as a dictionary key. + """ + lst = list(state_set) + lst.sort() + return tuple(lst) + + def dump(self, file): + from .Transitions import state_set_str + + for new_state in self.new_machine.states: + old_state_set = self.new_to_old_dict[id(new_state)] + file.write(" State %s <-- %s\n" % ( + new_state['number'], state_set_str(old_state_set))) + + diff --git a/contrib/tools/cython/Cython/Plex/Errors.py b/contrib/tools/cython/Cython/Plex/Errors.py new file mode 100644 index 00000000000..f460100d77e --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Errors.py @@ -0,0 +1,54 @@ +#======================================================================= +# +# Python Lexical Analyser +# +# Exception classes +# +#======================================================================= + + +class PlexError(Exception): + message = "" + + +class PlexTypeError(PlexError, TypeError): + pass + + +class PlexValueError(PlexError, ValueError): + pass + + +class InvalidRegex(PlexError): + pass + + +class InvalidToken(PlexError): + def __init__(self, token_number, message): + PlexError.__init__(self, "Token number %d: %s" % (token_number, message)) + + +class InvalidScanner(PlexError): + pass + + +class AmbiguousAction(PlexError): + message = "Two tokens with different actions can match the same string" + + def __init__(self): + pass + + +class UnrecognizedInput(PlexError): + scanner = None + position = None + state_name = None + + def __init__(self, scanner, state_name): + self.scanner = scanner + self.position = scanner.get_position() + self.state_name = state_name + + def __str__(self): + return ("'%s', line %d, char %d: Token not recognised in state %r" % ( + self.position + (self.state_name,))) diff --git a/contrib/tools/cython/Cython/Plex/Lexicons.py b/contrib/tools/cython/Cython/Plex/Lexicons.py new file mode 100644 index 00000000000..787f5854b8e --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Lexicons.py @@ -0,0 +1,200 @@ +#======================================================================= +# +# Python Lexical Analyser +# +# Lexical Analyser Specification +# +#======================================================================= + +from __future__ import absolute_import + +import types + +from . import Actions +from . import DFA +from . import Errors +from . import Machines +from . import Regexps + +# debug_flags for Lexicon constructor +DUMP_NFA = 1 +DUMP_DFA = 2 + + +class State(object): + """ + This class is used as part of a Plex.Lexicon specification to + introduce a user-defined state. + + Constructor: + + State(name, token_specifications) + """ + + name = None + tokens = None + + def __init__(self, name, tokens): + self.name = name + self.tokens = tokens + + +class Lexicon(object): + """ + Lexicon(specification) builds a lexical analyser from the given + |specification|. The specification consists of a list of + specification items. Each specification item may be either: + + 1) A token definition, which is a tuple: + + (pattern, action) + + The |pattern| is a regular axpression built using the + constructors defined in the Plex module. + + The |action| is the action to be performed when this pattern + is recognised (see below). + + 2) A state definition: + + State(name, tokens) + + where |name| is a character string naming the state, + and |tokens| is a list of token definitions as + above. The meaning and usage of states is described + below. + + Actions + ------- + + The |action| in a token specication may be one of three things: + + 1) A function, which is called as follows: + + function(scanner, text) + + where |scanner| is the relevant Scanner instance, and |text| + is the matched text. If the function returns anything + other than None, that value is returned as the value of the + token. If it returns None, scanning continues as if the IGNORE + action were specified (see below). + + 2) One of the following special actions: + + IGNORE means that the recognised characters will be treated as + white space and ignored. Scanning will continue until + the next non-ignored token is recognised before returning. + + TEXT causes the scanned text itself to be returned as the + value of the token. + + 3) Any other value, which is returned as the value of the token. + + States + ------ + + At any given time, the scanner is in one of a number of states. + Associated with each state is a set of possible tokens. When scanning, + only tokens associated with the current state are recognised. + + There is a default state, whose name is the empty string. Token + definitions which are not inside any State definition belong to + the default state. + + The initial state of the scanner is the default state. The state can + be changed in one of two ways: + + 1) Using Begin(state_name) as the action of a token. + + 2) Calling the begin(state_name) method of the Scanner. + + To change back to the default state, use '' as the state name. + """ + + machine = None # Machine + tables = None # StateTableMachine + + def __init__(self, specifications, debug=None, debug_flags=7, timings=None): + if not isinstance(specifications, list): + raise Errors.InvalidScanner("Scanner definition is not a list") + if timings: + from .Timing import time + + total_time = 0.0 + time1 = time() + nfa = Machines.Machine() + default_initial_state = nfa.new_initial_state('') + token_number = 1 + for spec in specifications: + if isinstance(spec, State): + user_initial_state = nfa.new_initial_state(spec.name) + for token in spec.tokens: + self.add_token_to_machine( + nfa, user_initial_state, token, token_number) + token_number += 1 + elif isinstance(spec, tuple): + self.add_token_to_machine( + nfa, default_initial_state, spec, token_number) + token_number += 1 + else: + raise Errors.InvalidToken( + token_number, + "Expected a token definition (tuple) or State instance") + if timings: + time2 = time() + total_time = total_time + (time2 - time1) + time3 = time() + if debug and (debug_flags & 1): + debug.write("\n============= NFA ===========\n") + nfa.dump(debug) + dfa = DFA.nfa_to_dfa(nfa, debug=(debug_flags & 3) == 3 and debug) + if timings: + time4 = time() + total_time = total_time + (time4 - time3) + if debug and (debug_flags & 2): + debug.write("\n============= DFA ===========\n") + dfa.dump(debug) + if timings: + timings.write("Constructing NFA : %5.2f\n" % (time2 - time1)) + timings.write("Converting to DFA: %5.2f\n" % (time4 - time3)) + timings.write("TOTAL : %5.2f\n" % total_time) + self.machine = dfa + + def add_token_to_machine(self, machine, initial_state, token_spec, token_number): + try: + (re, action_spec) = self.parse_token_definition(token_spec) + # Disabled this -- matching empty strings can be useful + #if re.nullable: + # raise Errors.InvalidToken( + # token_number, "Pattern can match 0 input symbols") + if isinstance(action_spec, Actions.Action): + action = action_spec + else: + try: + action_spec.__call__ + except AttributeError: + action = Actions.Return(action_spec) + else: + action = Actions.Call(action_spec) + final_state = machine.new_state() + re.build_machine(machine, initial_state, final_state, + match_bol=1, nocase=0) + final_state.set_action(action, priority=-token_number) + except Errors.PlexError as e: + raise e.__class__("Token number %d: %s" % (token_number, e)) + + def parse_token_definition(self, token_spec): + if not isinstance(token_spec, tuple): + raise Errors.InvalidToken("Token definition is not a tuple") + if len(token_spec) != 2: + raise Errors.InvalidToken("Wrong number of items in token definition") + pattern, action = token_spec + if not isinstance(pattern, Regexps.RE): + raise Errors.InvalidToken("Pattern is not an RE instance") + return (pattern, action) + + def get_initial_state(self, name): + return self.machine.get_initial_state(name) + + + diff --git a/contrib/tools/cython/Cython/Plex/Machines.py b/contrib/tools/cython/Cython/Plex/Machines.py new file mode 100644 index 00000000000..398850976bb --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Machines.py @@ -0,0 +1,255 @@ +#======================================================================= +# +# Python Lexical Analyser +# +# Classes for building NFAs and DFAs +# +#======================================================================= + +from __future__ import absolute_import + +import sys + +from .Transitions import TransitionMap + +try: + from sys import maxsize as maxint +except ImportError: + from sys import maxint + +try: + unichr +except NameError: + unichr = chr + +LOWEST_PRIORITY = -maxint + + +class Machine(object): + """A collection of Nodes representing an NFA or DFA.""" + states = None # [Node] + next_state_number = 1 + initial_states = None # {(name, bol): Node} + + def __init__(self): + self.states = [] + self.initial_states = {} + + def __del__(self): + #print "Destroying", self ### + for state in self.states: + state.destroy() + + def new_state(self): + """Add a new state to the machine and return it.""" + s = Node() + n = self.next_state_number + self.next_state_number = n + 1 + s.number = n + self.states.append(s) + return s + + def new_initial_state(self, name): + state = self.new_state() + self.make_initial_state(name, state) + return state + + def make_initial_state(self, name, state): + self.initial_states[name] = state + + def get_initial_state(self, name): + return self.initial_states[name] + + def dump(self, file): + file.write("Plex.Machine:\n") + if self.initial_states is not None: + file.write(" Initial states:\n") + for (name, state) in sorted(self.initial_states.items()): + file.write(" '%s': %d\n" % (name, state.number)) + for s in self.states: + s.dump(file) + + +class Node(object): + """A state of an NFA or DFA.""" + transitions = None # TransitionMap + action = None # Action + action_priority = None # integer + number = 0 # for debug output + epsilon_closure = None # used by nfa_to_dfa() + + def __init__(self): + # Preinitialise the list of empty transitions, because + # the nfa-to-dfa algorithm needs it + #self.transitions = {'':[]} + self.transitions = TransitionMap() + self.action_priority = LOWEST_PRIORITY + + def destroy(self): + #print "Destroying", self ### + self.transitions = None + self.action = None + self.epsilon_closure = None + + def add_transition(self, event, new_state): + self.transitions.add(event, new_state) + + def link_to(self, state): + """Add an epsilon-move from this state to another state.""" + self.add_transition('', state) + + def set_action(self, action, priority): + """Make this an accepting state with the given action. If + there is already an action, choose the action with highest + priority.""" + if priority > self.action_priority: + self.action = action + self.action_priority = priority + + def get_action(self): + return self.action + + def get_action_priority(self): + return self.action_priority + + def is_accepting(self): + return self.action is not None + + def __str__(self): + return "State %d" % self.number + + def dump(self, file): + # Header + file.write(" State %d:\n" % self.number) + # Transitions + # self.dump_transitions(file) + self.transitions.dump(file) + # Action + action = self.action + priority = self.action_priority + if action is not None: + file.write(" %s [priority %d]\n" % (action, priority)) + + def __lt__(self, other): + return self.number < other.number + + +class FastMachine(object): + """ + FastMachine is a deterministic machine represented in a way that + allows fast scanning. + """ + initial_states = None # {state_name:state} + states = None # [state] where state = {event:state, 'else':state, 'action':Action} + next_number = 1 # for debugging + + new_state_template = { + '': None, 'bol': None, 'eol': None, 'eof': None, 'else': None + } + + def __init__(self): + self.initial_states = {} + self.states = [] + + def __del__(self): + for state in self.states: + state.clear() + + def new_state(self, action=None): + number = self.next_number + self.next_number = number + 1 + result = self.new_state_template.copy() + result['number'] = number + result['action'] = action + self.states.append(result) + return result + + def make_initial_state(self, name, state): + self.initial_states[name] = state + + def add_transitions(self, state, event, new_state, maxint=maxint): + if type(event) is tuple: + code0, code1 = event + if code0 == -maxint: + state['else'] = new_state + elif code1 != maxint: + while code0 < code1: + state[unichr(code0)] = new_state + code0 += 1 + else: + state[event] = new_state + + def get_initial_state(self, name): + return self.initial_states[name] + + def dump(self, file): + file.write("Plex.FastMachine:\n") + file.write(" Initial states:\n") + for name, state in sorted(self.initial_states.items()): + file.write(" %s: %s\n" % (repr(name), state['number'])) + for state in self.states: + self.dump_state(state, file) + + def dump_state(self, state, file): + # Header + file.write(" State %d:\n" % state['number']) + # Transitions + self.dump_transitions(state, file) + # Action + action = state['action'] + if action is not None: + file.write(" %s\n" % action) + + def dump_transitions(self, state, file): + chars_leading_to_state = {} + special_to_state = {} + for (c, s) in state.items(): + if len(c) == 1: + chars = chars_leading_to_state.get(id(s), None) + if chars is None: + chars = [] + chars_leading_to_state[id(s)] = chars + chars.append(c) + elif len(c) <= 4: + special_to_state[c] = s + ranges_to_state = {} + for state in self.states: + char_list = chars_leading_to_state.get(id(state), None) + if char_list: + ranges = self.chars_to_ranges(char_list) + ranges_to_state[ranges] = state + ranges_list = ranges_to_state.keys() + ranges_list.sort() + for ranges in ranges_list: + key = self.ranges_to_string(ranges) + state = ranges_to_state[ranges] + file.write(" %s --> State %d\n" % (key, state['number'])) + for key in ('bol', 'eol', 'eof', 'else'): + state = special_to_state.get(key, None) + if state: + file.write(" %s --> State %d\n" % (key, state['number'])) + + def chars_to_ranges(self, char_list): + char_list.sort() + i = 0 + n = len(char_list) + result = [] + while i < n: + c1 = ord(char_list[i]) + c2 = c1 + i += 1 + while i < n and ord(char_list[i]) == c2 + 1: + i += 1 + c2 += 1 + result.append((chr(c1), chr(c2))) + return tuple(result) + + def ranges_to_string(self, range_list): + return ','.join(map(self.range_to_string, range_list)) + + def range_to_string(self, range_tuple): + (c1, c2) = range_tuple + if c1 == c2: + return repr(c1) + else: + return "%s..%s" % (repr(c1), repr(c2)) diff --git a/contrib/tools/cython/Cython/Plex/Regexps.py b/contrib/tools/cython/Cython/Plex/Regexps.py new file mode 100644 index 00000000000..41816c939ac --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Regexps.py @@ -0,0 +1,576 @@ +#======================================================================= +# +# Python Lexical Analyser +# +# Regular Expressions +# +#======================================================================= + +from __future__ import absolute_import + +import types +try: + from sys import maxsize as maxint +except ImportError: + from sys import maxint + +from . import Errors + +# +# Constants +# + +BOL = 'bol' +EOL = 'eol' +EOF = 'eof' + +nl_code = ord('\n') + + +# +# Helper functions +# + +def chars_to_ranges(s): + """ + Return a list of character codes consisting of pairs + [code1a, code1b, code2a, code2b,...] which cover all + the characters in |s|. + """ + char_list = list(s) + char_list.sort() + i = 0 + n = len(char_list) + result = [] + while i < n: + code1 = ord(char_list[i]) + code2 = code1 + 1 + i += 1 + while i < n and code2 >= ord(char_list[i]): + code2 += 1 + i += 1 + result.append(code1) + result.append(code2) + return result + + +def uppercase_range(code1, code2): + """ + If the range of characters from code1 to code2-1 includes any + lower case letters, return the corresponding upper case range. + """ + code3 = max(code1, ord('a')) + code4 = min(code2, ord('z') + 1) + if code3 < code4: + d = ord('A') - ord('a') + return (code3 + d, code4 + d) + else: + return None + + +def lowercase_range(code1, code2): + """ + If the range of characters from code1 to code2-1 includes any + upper case letters, return the corresponding lower case range. + """ + code3 = max(code1, ord('A')) + code4 = min(code2, ord('Z') + 1) + if code3 < code4: + d = ord('a') - ord('A') + return (code3 + d, code4 + d) + else: + return None + + +def CodeRanges(code_list): + """ + Given a list of codes as returned by chars_to_ranges, return + an RE which will match a character in any of the ranges. + """ + re_list = [CodeRange(code_list[i], code_list[i + 1]) for i in range(0, len(code_list), 2)] + return Alt(*re_list) + + +def CodeRange(code1, code2): + """ + CodeRange(code1, code2) is an RE which matches any character + with a code |c| in the range |code1| <= |c| < |code2|. + """ + if code1 <= nl_code < code2: + return Alt(RawCodeRange(code1, nl_code), + RawNewline, + RawCodeRange(nl_code + 1, code2)) + else: + return RawCodeRange(code1, code2) + + +# +# Abstract classes +# + +class RE(object): + """RE is the base class for regular expression constructors. + The following operators are defined on REs: + + re1 + re2 is an RE which matches |re1| followed by |re2| + re1 | re2 is an RE which matches either |re1| or |re2| + """ + + nullable = 1 # True if this RE can match 0 input symbols + match_nl = 1 # True if this RE can match a string ending with '\n' + str = None # Set to a string to override the class's __str__ result + + def build_machine(self, machine, initial_state, final_state, + match_bol, nocase): + """ + This method should add states to |machine| to implement this + RE, starting at |initial_state| and ending at |final_state|. + If |match_bol| is true, the RE must be able to match at the + beginning of a line. If nocase is true, upper and lower case + letters should be treated as equivalent. + """ + raise NotImplementedError("%s.build_machine not implemented" % + self.__class__.__name__) + + def build_opt(self, m, initial_state, c): + """ + Given a state |s| of machine |m|, return a new state + reachable from |s| on character |c| or epsilon. + """ + s = m.new_state() + initial_state.link_to(s) + initial_state.add_transition(c, s) + return s + + def __add__(self, other): + return Seq(self, other) + + def __or__(self, other): + return Alt(self, other) + + def __str__(self): + if self.str: + return self.str + else: + return self.calc_str() + + def check_re(self, num, value): + if not isinstance(value, RE): + self.wrong_type(num, value, "Plex.RE instance") + + def check_string(self, num, value): + if type(value) != type(''): + self.wrong_type(num, value, "string") + + def check_char(self, num, value): + self.check_string(num, value) + if len(value) != 1: + raise Errors.PlexValueError("Invalid value for argument %d of Plex.%s." + "Expected a string of length 1, got: %s" % ( + num, self.__class__.__name__, repr(value))) + + def wrong_type(self, num, value, expected): + if type(value) == types.InstanceType: + got = "%s.%s instance" % ( + value.__class__.__module__, value.__class__.__name__) + else: + got = type(value).__name__ + raise Errors.PlexTypeError("Invalid type for argument %d of Plex.%s " + "(expected %s, got %s" % ( + num, self.__class__.__name__, expected, got)) + +# +# Primitive RE constructors +# ------------------------- +# +# These are the basic REs from which all others are built. +# + +## class Char(RE): +## """ +## Char(c) is an RE which matches the character |c|. +## """ + +## nullable = 0 + +## def __init__(self, char): +## self.char = char +## self.match_nl = char == '\n' + +## def build_machine(self, m, initial_state, final_state, match_bol, nocase): +## c = self.char +## if match_bol and c != BOL: +## s1 = self.build_opt(m, initial_state, BOL) +## else: +## s1 = initial_state +## if c == '\n' or c == EOF: +## s1 = self.build_opt(m, s1, EOL) +## if len(c) == 1: +## code = ord(self.char) +## s1.add_transition((code, code+1), final_state) +## if nocase and is_letter_code(code): +## code2 = other_case_code(code) +## s1.add_transition((code2, code2+1), final_state) +## else: +## s1.add_transition(c, final_state) + +## def calc_str(self): +## return "Char(%s)" % repr(self.char) + + +def Char(c): + """ + Char(c) is an RE which matches the character |c|. + """ + if len(c) == 1: + result = CodeRange(ord(c), ord(c) + 1) + else: + result = SpecialSymbol(c) + result.str = "Char(%s)" % repr(c) + return result + + +class RawCodeRange(RE): + """ + RawCodeRange(code1, code2) is a low-level RE which matches any character + with a code |c| in the range |code1| <= |c| < |code2|, where the range + does not include newline. For internal use only. + """ + nullable = 0 + match_nl = 0 + range = None # (code, code) + uppercase_range = None # (code, code) or None + lowercase_range = None # (code, code) or None + + def __init__(self, code1, code2): + self.range = (code1, code2) + self.uppercase_range = uppercase_range(code1, code2) + self.lowercase_range = lowercase_range(code1, code2) + + def build_machine(self, m, initial_state, final_state, match_bol, nocase): + if match_bol: + initial_state = self.build_opt(m, initial_state, BOL) + initial_state.add_transition(self.range, final_state) + if nocase: + if self.uppercase_range: + initial_state.add_transition(self.uppercase_range, final_state) + if self.lowercase_range: + initial_state.add_transition(self.lowercase_range, final_state) + + def calc_str(self): + return "CodeRange(%d,%d)" % (self.code1, self.code2) + + +class _RawNewline(RE): + """ + RawNewline is a low-level RE which matches a newline character. + For internal use only. + """ + nullable = 0 + match_nl = 1 + + def build_machine(self, m, initial_state, final_state, match_bol, nocase): + if match_bol: + initial_state = self.build_opt(m, initial_state, BOL) + s = self.build_opt(m, initial_state, EOL) + s.add_transition((nl_code, nl_code + 1), final_state) + + +RawNewline = _RawNewline() + + +class SpecialSymbol(RE): + """ + SpecialSymbol(sym) is an RE which matches the special input + symbol |sym|, which is one of BOL, EOL or EOF. + """ + nullable = 0 + match_nl = 0 + sym = None + + def __init__(self, sym): + self.sym = sym + + def build_machine(self, m, initial_state, final_state, match_bol, nocase): + # Sequences 'bol bol' and 'bol eof' are impossible, so only need + # to allow for bol if sym is eol + if match_bol and self.sym == EOL: + initial_state = self.build_opt(m, initial_state, BOL) + initial_state.add_transition(self.sym, final_state) + + +class Seq(RE): + """Seq(re1, re2, re3...) is an RE which matches |re1| followed by + |re2| followed by |re3|...""" + + def __init__(self, *re_list): + nullable = 1 + for i, re in enumerate(re_list): + self.check_re(i, re) + nullable = nullable and re.nullable + self.re_list = re_list + self.nullable = nullable + i = len(re_list) + match_nl = 0 + while i: + i -= 1 + re = re_list[i] + if re.match_nl: + match_nl = 1 + break + if not re.nullable: + break + self.match_nl = match_nl + + def build_machine(self, m, initial_state, final_state, match_bol, nocase): + re_list = self.re_list + if len(re_list) == 0: + initial_state.link_to(final_state) + else: + s1 = initial_state + n = len(re_list) + for i, re in enumerate(re_list): + if i < n - 1: + s2 = m.new_state() + else: + s2 = final_state + re.build_machine(m, s1, s2, match_bol, nocase) + s1 = s2 + match_bol = re.match_nl or (match_bol and re.nullable) + + def calc_str(self): + return "Seq(%s)" % ','.join(map(str, self.re_list)) + + +class Alt(RE): + """Alt(re1, re2, re3...) is an RE which matches either |re1| or + |re2| or |re3|...""" + + def __init__(self, *re_list): + self.re_list = re_list + nullable = 0 + match_nl = 0 + nullable_res = [] + non_nullable_res = [] + i = 1 + for re in re_list: + self.check_re(i, re) + if re.nullable: + nullable_res.append(re) + nullable = 1 + else: + non_nullable_res.append(re) + if re.match_nl: + match_nl = 1 + i += 1 + self.nullable_res = nullable_res + self.non_nullable_res = non_nullable_res + self.nullable = nullable + self.match_nl = match_nl + + def build_machine(self, m, initial_state, final_state, match_bol, nocase): + for re in self.nullable_res: + re.build_machine(m, initial_state, final_state, match_bol, nocase) + if self.non_nullable_res: + if match_bol: + initial_state = self.build_opt(m, initial_state, BOL) + for re in self.non_nullable_res: + re.build_machine(m, initial_state, final_state, 0, nocase) + + def calc_str(self): + return "Alt(%s)" % ','.join(map(str, self.re_list)) + + +class Rep1(RE): + """Rep1(re) is an RE which matches one or more repetitions of |re|.""" + + def __init__(self, re): + self.check_re(1, re) + self.re = re + self.nullable = re.nullable + self.match_nl = re.match_nl + + def build_machine(self, m, initial_state, final_state, match_bol, nocase): + s1 = m.new_state() + s2 = m.new_state() + initial_state.link_to(s1) + self.re.build_machine(m, s1, s2, match_bol or self.re.match_nl, nocase) + s2.link_to(s1) + s2.link_to(final_state) + + def calc_str(self): + return "Rep1(%s)" % self.re + + +class SwitchCase(RE): + """ + SwitchCase(re, nocase) is an RE which matches the same strings as RE, + but treating upper and lower case letters according to |nocase|. If + |nocase| is true, case is ignored, otherwise it is not. + """ + re = None + nocase = None + + def __init__(self, re, nocase): + self.re = re + self.nocase = nocase + self.nullable = re.nullable + self.match_nl = re.match_nl + + def build_machine(self, m, initial_state, final_state, match_bol, nocase): + self.re.build_machine(m, initial_state, final_state, match_bol, + self.nocase) + + def calc_str(self): + if self.nocase: + name = "NoCase" + else: + name = "Case" + return "%s(%s)" % (name, self.re) + +# +# Composite RE constructors +# ------------------------- +# +# These REs are defined in terms of the primitive REs. +# + +Empty = Seq() +Empty.__doc__ = \ + """ + Empty is an RE which matches the empty string. + """ +Empty.str = "Empty" + + +def Str1(s): + """ + Str1(s) is an RE which matches the literal string |s|. + """ + result = Seq(*tuple(map(Char, s))) + result.str = "Str(%s)" % repr(s) + return result + + +def Str(*strs): + """ + Str(s) is an RE which matches the literal string |s|. + Str(s1, s2, s3, ...) is an RE which matches any of |s1| or |s2| or |s3|... + """ + if len(strs) == 1: + return Str1(strs[0]) + else: + result = Alt(*tuple(map(Str1, strs))) + result.str = "Str(%s)" % ','.join(map(repr, strs)) + return result + + +def Any(s): + """ + Any(s) is an RE which matches any character in the string |s|. + """ + #result = apply(Alt, tuple(map(Char, s))) + result = CodeRanges(chars_to_ranges(s)) + result.str = "Any(%s)" % repr(s) + return result + + +def AnyBut(s): + """ + AnyBut(s) is an RE which matches any character (including + newline) which is not in the string |s|. + """ + ranges = chars_to_ranges(s) + ranges.insert(0, -maxint) + ranges.append(maxint) + result = CodeRanges(ranges) + result.str = "AnyBut(%s)" % repr(s) + return result + + +AnyChar = AnyBut("") +AnyChar.__doc__ = \ + """ + AnyChar is an RE which matches any single character (including a newline). + """ +AnyChar.str = "AnyChar" + + +def Range(s1, s2=None): + """ + Range(c1, c2) is an RE which matches any single character in the range + |c1| to |c2| inclusive. + Range(s) where |s| is a string of even length is an RE which matches + any single character in the ranges |s[0]| to |s[1]|, |s[2]| to |s[3]|,... + """ + if s2: + result = CodeRange(ord(s1), ord(s2) + 1) + result.str = "Range(%s,%s)" % (s1, s2) + else: + ranges = [] + for i in range(0, len(s1), 2): + ranges.append(CodeRange(ord(s1[i]), ord(s1[i + 1]) + 1)) + result = Alt(*ranges) + result.str = "Range(%s)" % repr(s1) + return result + + +def Opt(re): + """ + Opt(re) is an RE which matches either |re| or the empty string. + """ + result = Alt(re, Empty) + result.str = "Opt(%s)" % re + return result + + +def Rep(re): + """ + Rep(re) is an RE which matches zero or more repetitions of |re|. + """ + result = Opt(Rep1(re)) + result.str = "Rep(%s)" % re + return result + + +def NoCase(re): + """ + NoCase(re) is an RE which matches the same strings as RE, but treating + upper and lower case letters as equivalent. + """ + return SwitchCase(re, nocase=1) + + +def Case(re): + """ + Case(re) is an RE which matches the same strings as RE, but treating + upper and lower case letters as distinct, i.e. it cancels the effect + of any enclosing NoCase(). + """ + return SwitchCase(re, nocase=0) + +# +# RE Constants +# + +Bol = Char(BOL) +Bol.__doc__ = \ + """ + Bol is an RE which matches the beginning of a line. + """ +Bol.str = "Bol" + +Eol = Char(EOL) +Eol.__doc__ = \ + """ + Eol is an RE which matches the end of a line. + """ +Eol.str = "Eol" + +Eof = Char(EOF) +Eof.__doc__ = \ + """ + Eof is an RE which matches the end of the file. + """ +Eof.str = "Eof" + diff --git a/contrib/tools/cython/Cython/Plex/Scanners.pxd b/contrib/tools/cython/Cython/Plex/Scanners.pxd new file mode 100644 index 00000000000..6e75f55e619 --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Scanners.pxd @@ -0,0 +1,50 @@ +from __future__ import absolute_import + +import cython + +from Cython.Plex.Actions cimport Action + +cdef class Scanner: + + cdef public lexicon + cdef public stream + cdef public name + cdef public unicode buffer + cdef public Py_ssize_t buf_start_pos + cdef public Py_ssize_t next_pos + cdef public Py_ssize_t cur_pos + cdef public Py_ssize_t cur_line + cdef public Py_ssize_t cur_line_start + cdef public Py_ssize_t start_pos + cdef public Py_ssize_t start_line + cdef public Py_ssize_t start_col + cdef public text + cdef public initial_state # int? + cdef public state_name + cdef public list queue + cdef public bint trace + cdef public cur_char + cdef public long input_state + + cdef public level + + @cython.final + @cython.locals(input_state=long) + cdef next_char(self) + @cython.locals(action=Action) + cpdef tuple read(self) + @cython.final + cdef tuple scan_a_token(self) + ##cdef tuple position(self) # used frequently by Parsing.py + + @cython.final + @cython.locals(cur_pos=Py_ssize_t, cur_line=Py_ssize_t, cur_line_start=Py_ssize_t, + input_state=long, next_pos=Py_ssize_t, state=dict, + buf_start_pos=Py_ssize_t, buf_len=Py_ssize_t, buf_index=Py_ssize_t, + trace=bint, discard=Py_ssize_t, data=unicode, buffer=unicode) + cdef run_machine_inlined(self) + + @cython.final + cdef begin(self, state) + @cython.final + cdef produce(self, value, text = *) diff --git a/contrib/tools/cython/Cython/Plex/Scanners.py b/contrib/tools/cython/Cython/Plex/Scanners.py new file mode 100644 index 00000000000..88f7e2da3ba --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Scanners.py @@ -0,0 +1,338 @@ +# cython: auto_pickle=False +#======================================================================= +# +# Python Lexical Analyser +# +# +# Scanning an input stream +# +#======================================================================= + +from __future__ import absolute_import + +import cython + +cython.declare(BOL=object, EOL=object, EOF=object, NOT_FOUND=object) + +from . import Errors +from .Regexps import BOL, EOL, EOF + +NOT_FOUND = object() + + +class Scanner(object): + """ + A Scanner is used to read tokens from a stream of characters + using the token set specified by a Plex.Lexicon. + + Constructor: + + Scanner(lexicon, stream, name = '') + + See the docstring of the __init__ method for details. + + Methods: + + See the docstrings of the individual methods for more + information. + + read() --> (value, text) + Reads the next lexical token from the stream. + + position() --> (name, line, col) + Returns the position of the last token read using the + read() method. + + begin(state_name) + Causes scanner to change state. + + produce(value [, text]) + Causes return of a token value to the caller of the + Scanner. + + """ + + # lexicon = None # Lexicon + # stream = None # file-like object + # name = '' + # buffer = '' + # buf_start_pos = 0 # position in input of start of buffer + # next_pos = 0 # position in input of next char to read + # cur_pos = 0 # position in input of current char + # cur_line = 1 # line number of current char + # cur_line_start = 0 # position in input of start of current line + # start_pos = 0 # position in input of start of token + # start_line = 0 # line number of start of token + # start_col = 0 # position in line of start of token + # text = None # text of last token read + # initial_state = None # Node + # state_name = '' # Name of initial state + # queue = None # list of tokens to be returned + # trace = 0 + + def __init__(self, lexicon, stream, name='', initial_pos=None): + """ + Scanner(lexicon, stream, name = '') + + |lexicon| is a Plex.Lexicon instance specifying the lexical tokens + to be recognised. + + |stream| can be a file object or anything which implements a + compatible read() method. + + |name| is optional, and may be the name of the file being + scanned or any other identifying string. + """ + self.trace = 0 + + self.buffer = u'' + self.buf_start_pos = 0 + self.next_pos = 0 + self.cur_pos = 0 + self.cur_line = 1 + self.start_pos = 0 + self.start_line = 0 + self.start_col = 0 + self.text = None + self.state_name = None + + self.lexicon = lexicon + self.stream = stream + self.name = name + self.queue = [] + self.initial_state = None + self.begin('') + self.next_pos = 0 + self.cur_pos = 0 + self.cur_line_start = 0 + self.cur_char = BOL + self.input_state = 1 + if initial_pos is not None: + self.cur_line, self.cur_line_start = initial_pos[1], -initial_pos[2] + + def read(self): + """ + Read the next lexical token from the stream and return a + tuple (value, text), where |value| is the value associated with + the token as specified by the Lexicon, and |text| is the actual + string read from the stream. Returns (None, '') on end of file. + """ + queue = self.queue + while not queue: + self.text, action = self.scan_a_token() + if action is None: + self.produce(None) + self.eof() + else: + value = action.perform(self, self.text) + if value is not None: + self.produce(value) + result = queue[0] + del queue[0] + return result + + def scan_a_token(self): + """ + Read the next input sequence recognised by the machine + and return (text, action). Returns ('', None) on end of + file. + """ + self.start_pos = self.cur_pos + self.start_line = self.cur_line + self.start_col = self.cur_pos - self.cur_line_start + action = self.run_machine_inlined() + if action is not None: + if self.trace: + print("Scanner: read: Performing %s %d:%d" % ( + action, self.start_pos, self.cur_pos)) + text = self.buffer[ + self.start_pos - self.buf_start_pos: + self.cur_pos - self.buf_start_pos] + return (text, action) + else: + if self.cur_pos == self.start_pos: + if self.cur_char is EOL: + self.next_char() + if self.cur_char is None or self.cur_char is EOF: + return (u'', None) + raise Errors.UnrecognizedInput(self, self.state_name) + + def run_machine_inlined(self): + """ + Inlined version of run_machine for speed. + """ + state = self.initial_state + cur_pos = self.cur_pos + cur_line = self.cur_line + cur_line_start = self.cur_line_start + cur_char = self.cur_char + input_state = self.input_state + next_pos = self.next_pos + buffer = self.buffer + buf_start_pos = self.buf_start_pos + buf_len = len(buffer) + b_action, b_cur_pos, b_cur_line, b_cur_line_start, b_cur_char, b_input_state, b_next_pos = \ + None, 0, 0, 0, u'', 0, 0 + trace = self.trace + while 1: + if trace: #TRACE# + print("State %d, %d/%d:%s -->" % ( #TRACE# + state['number'], input_state, cur_pos, repr(cur_char))) #TRACE# + # Begin inlined self.save_for_backup() + #action = state.action #@slow + action = state['action'] #@fast + if action is not None: + b_action, b_cur_pos, b_cur_line, b_cur_line_start, b_cur_char, b_input_state, b_next_pos = \ + action, cur_pos, cur_line, cur_line_start, cur_char, input_state, next_pos + # End inlined self.save_for_backup() + c = cur_char + #new_state = state.new_state(c) #@slow + new_state = state.get(c, NOT_FOUND) #@fast + if new_state is NOT_FOUND: #@fast + new_state = c and state.get('else') #@fast + if new_state: + if trace: #TRACE# + print("State %d" % new_state['number']) #TRACE# + state = new_state + # Begin inlined: self.next_char() + if input_state == 1: + cur_pos = next_pos + # Begin inlined: c = self.read_char() + buf_index = next_pos - buf_start_pos + if buf_index < buf_len: + c = buffer[buf_index] + next_pos += 1 + else: + discard = self.start_pos - buf_start_pos + data = self.stream.read(0x1000) + buffer = self.buffer[discard:] + data + self.buffer = buffer + buf_start_pos += discard + self.buf_start_pos = buf_start_pos + buf_len = len(buffer) + buf_index -= discard + if data: + c = buffer[buf_index] + next_pos += 1 + else: + c = u'' + # End inlined: c = self.read_char() + if c == u'\n': + cur_char = EOL + input_state = 2 + elif not c: + cur_char = EOL + input_state = 4 + else: + cur_char = c + elif input_state == 2: + cur_char = u'\n' + input_state = 3 + elif input_state == 3: + cur_line += 1 + cur_line_start = cur_pos = next_pos + cur_char = BOL + input_state = 1 + elif input_state == 4: + cur_char = EOF + input_state = 5 + else: # input_state = 5 + cur_char = u'' + # End inlined self.next_char() + else: # not new_state + if trace: #TRACE# + print("blocked") #TRACE# + # Begin inlined: action = self.back_up() + if b_action is not None: + (action, cur_pos, cur_line, cur_line_start, + cur_char, input_state, next_pos) = \ + (b_action, b_cur_pos, b_cur_line, b_cur_line_start, + b_cur_char, b_input_state, b_next_pos) + else: + action = None + break # while 1 + # End inlined: action = self.back_up() + self.cur_pos = cur_pos + self.cur_line = cur_line + self.cur_line_start = cur_line_start + self.cur_char = cur_char + self.input_state = input_state + self.next_pos = next_pos + if trace: #TRACE# + if action is not None: #TRACE# + print("Doing %s" % action) #TRACE# + return action + + def next_char(self): + input_state = self.input_state + if self.trace: + print("Scanner: next: %s [%d] %d" % (" " * 20, input_state, self.cur_pos)) + if input_state == 1: + self.cur_pos = self.next_pos + c = self.read_char() + if c == u'\n': + self.cur_char = EOL + self.input_state = 2 + elif not c: + self.cur_char = EOL + self.input_state = 4 + else: + self.cur_char = c + elif input_state == 2: + self.cur_char = u'\n' + self.input_state = 3 + elif input_state == 3: + self.cur_line += 1 + self.cur_line_start = self.cur_pos = self.next_pos + self.cur_char = BOL + self.input_state = 1 + elif input_state == 4: + self.cur_char = EOF + self.input_state = 5 + else: # input_state = 5 + self.cur_char = u'' + if self.trace: + print("--> [%d] %d %r" % (input_state, self.cur_pos, self.cur_char)) + + def position(self): + """ + Return a tuple (name, line, col) representing the location of + the last token read using the read() method. |name| is the + name that was provided to the Scanner constructor; |line| + is the line number in the stream (1-based); |col| is the + position within the line of the first character of the token + (0-based). + """ + return (self.name, self.start_line, self.start_col) + + def get_position(self): + """Python accessible wrapper around position(), only for error reporting. + """ + return self.position() + + def begin(self, state_name): + """Set the current state of the scanner to the named state.""" + self.initial_state = ( + self.lexicon.get_initial_state(state_name)) + self.state_name = state_name + + def produce(self, value, text=None): + """ + Called from an action procedure, causes |value| to be returned + as the token value from read(). If |text| is supplied, it is + returned in place of the scanned text. + + produce() can be called more than once during a single call to an action + procedure, in which case the tokens are queued up and returned one + at a time by subsequent calls to read(), until the queue is empty, + whereupon scanning resumes. + """ + if text is None: + text = self.text + self.queue.append((value, text)) + + def eof(self): + """ + Override this method if you want something to be done at + end of file. + """ diff --git a/contrib/tools/cython/Cython/Plex/Timing.py b/contrib/tools/cython/Cython/Plex/Timing.py new file mode 100644 index 00000000000..5c3692693bb --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Timing.py @@ -0,0 +1,23 @@ +# +# Get time in platform-dependent way +# + +from __future__ import absolute_import + +import os +from sys import platform, exit, stderr + +if platform == 'mac': + import MacOS + def time(): + return MacOS.GetTicks() / 60.0 + timekind = "real" +elif hasattr(os, 'times'): + def time(): + t = os.times() + return t[0] + t[1] + timekind = "cpu" +else: + stderr.write( + "Don't know how to get time on platform %s\n" % repr(platform)) + exit(1) diff --git a/contrib/tools/cython/Cython/Plex/Traditional.py b/contrib/tools/cython/Cython/Plex/Traditional.py new file mode 100644 index 00000000000..ec7252daed9 --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Traditional.py @@ -0,0 +1,158 @@ +#======================================================================= +# +# Python Lexical Analyser +# +# Traditional Regular Expression Syntax +# +#======================================================================= + +from __future__ import absolute_import + +from .Regexps import Alt, Seq, Rep, Rep1, Opt, Any, AnyBut, Bol, Eol, Char +from .Errors import PlexError + + +class RegexpSyntaxError(PlexError): + pass + + +def re(s): + """ + Convert traditional string representation of regular expression |s| + into Plex representation. + """ + return REParser(s).parse_re() + + +class REParser(object): + def __init__(self, s): + self.s = s + self.i = -1 + self.end = 0 + self.next() + + def parse_re(self): + re = self.parse_alt() + if not self.end: + self.error("Unexpected %s" % repr(self.c)) + return re + + def parse_alt(self): + """Parse a set of alternative regexps.""" + re = self.parse_seq() + if self.c == '|': + re_list = [re] + while self.c == '|': + self.next() + re_list.append(self.parse_seq()) + re = Alt(*re_list) + return re + + def parse_seq(self): + """Parse a sequence of regexps.""" + re_list = [] + while not self.end and not self.c in "|)": + re_list.append(self.parse_mod()) + return Seq(*re_list) + + def parse_mod(self): + """Parse a primitive regexp followed by *, +, ? modifiers.""" + re = self.parse_prim() + while not self.end and self.c in "*+?": + if self.c == '*': + re = Rep(re) + elif self.c == '+': + re = Rep1(re) + else: # self.c == '?' + re = Opt(re) + self.next() + return re + + def parse_prim(self): + """Parse a primitive regexp.""" + c = self.get() + if c == '.': + re = AnyBut("\n") + elif c == '^': + re = Bol + elif c == '$': + re = Eol + elif c == '(': + re = self.parse_alt() + self.expect(')') + elif c == '[': + re = self.parse_charset() + self.expect(']') + else: + if c == '\\': + c = self.get() + re = Char(c) + return re + + def parse_charset(self): + """Parse a charset. Does not include the surrounding [].""" + char_list = [] + invert = 0 + if self.c == '^': + invert = 1 + self.next() + if self.c == ']': + char_list.append(']') + self.next() + while not self.end and self.c != ']': + c1 = self.get() + if self.c == '-' and self.lookahead(1) != ']': + self.next() + c2 = self.get() + for a in range(ord(c1), ord(c2) + 1): + char_list.append(chr(a)) + else: + char_list.append(c1) + chars = ''.join(char_list) + if invert: + return AnyBut(chars) + else: + return Any(chars) + + def next(self): + """Advance to the next char.""" + s = self.s + i = self.i = self.i + 1 + if i < len(s): + self.c = s[i] + else: + self.c = '' + self.end = 1 + + def get(self): + if self.end: + self.error("Premature end of string") + c = self.c + self.next() + return c + + def lookahead(self, n): + """Look ahead n chars.""" + j = self.i + n + if j < len(self.s): + return self.s[j] + else: + return '' + + def expect(self, c): + """ + Expect to find character |c| at current position. + Raises an exception otherwise. + """ + if self.c == c: + self.next() + else: + self.error("Missing %s" % repr(c)) + + def error(self, mess): + """Raise exception to signal syntax error in regexp.""" + raise RegexpSyntaxError("Syntax error in regexp %s at position %d: %s" % ( + repr(self.s), self.i, mess)) + + + diff --git a/contrib/tools/cython/Cython/Plex/Transitions.py b/contrib/tools/cython/Cython/Plex/Transitions.py new file mode 100644 index 00000000000..3833817946c --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Transitions.py @@ -0,0 +1,251 @@ +# +# Plex - Transition Maps +# +# This version represents state sets directly as dicts for speed. +# + +from __future__ import absolute_import + +try: + from sys import maxsize as maxint +except ImportError: + from sys import maxint + + +class TransitionMap(object): + """ + A TransitionMap maps an input event to a set of states. + An input event is one of: a range of character codes, + the empty string (representing an epsilon move), or one + of the special symbols BOL, EOL, EOF. + + For characters, this implementation compactly represents + the map by means of a list: + + [code_0, states_0, code_1, states_1, code_2, states_2, + ..., code_n-1, states_n-1, code_n] + + where |code_i| is a character code, and |states_i| is a + set of states corresponding to characters with codes |c| + in the range |code_i| <= |c| <= |code_i+1|. + + The following invariants hold: + n >= 1 + code_0 == -maxint + code_n == maxint + code_i < code_i+1 for i in 0..n-1 + states_0 == states_n-1 + + Mappings for the special events '', BOL, EOL, EOF are + kept separately in a dictionary. + """ + + map = None # The list of codes and states + special = None # Mapping for special events + + def __init__(self, map=None, special=None): + if not map: + map = [-maxint, {}, maxint] + if not special: + special = {} + self.map = map + self.special = special + #self.check() ### + + def add(self, event, new_state, + TupleType=tuple): + """ + Add transition to |new_state| on |event|. + """ + if type(event) is TupleType: + code0, code1 = event + i = self.split(code0) + j = self.split(code1) + map = self.map + while i < j: + map[i + 1][new_state] = 1 + i += 2 + else: + self.get_special(event)[new_state] = 1 + + def add_set(self, event, new_set, + TupleType=tuple): + """ + Add transitions to the states in |new_set| on |event|. + """ + if type(event) is TupleType: + code0, code1 = event + i = self.split(code0) + j = self.split(code1) + map = self.map + while i < j: + map[i + 1].update(new_set) + i += 2 + else: + self.get_special(event).update(new_set) + + def get_epsilon(self, + none=None): + """ + Return the mapping for epsilon, or None. + """ + return self.special.get('', none) + + def iteritems(self, + len=len): + """ + Return the mapping as an iterable of ((code1, code2), state_set) and + (special_event, state_set) pairs. + """ + result = [] + map = self.map + else_set = map[1] + i = 0 + n = len(map) - 1 + code0 = map[0] + while i < n: + set = map[i + 1] + code1 = map[i + 2] + if set or else_set: + result.append(((code0, code1), set)) + code0 = code1 + i += 2 + for event, set in self.special.items(): + if set: + result.append((event, set)) + return iter(result) + + items = iteritems + + # ------------------- Private methods -------------------- + + def split(self, code, + len=len, maxint=maxint): + """ + Search the list for the position of the split point for |code|, + inserting a new split point if necessary. Returns index |i| such + that |code| == |map[i]|. + """ + # We use a funky variation on binary search. + map = self.map + hi = len(map) - 1 + # Special case: code == map[-1] + if code == maxint: + return hi + # General case + lo = 0 + # loop invariant: map[lo] <= code < map[hi] and hi - lo >= 2 + while hi - lo >= 4: + # Find midpoint truncated to even index + mid = ((lo + hi) // 2) & ~1 + if code < map[mid]: + hi = mid + else: + lo = mid + # map[lo] <= code < map[hi] and hi - lo == 2 + if map[lo] == code: + return lo + else: + map[hi:hi] = [code, map[hi - 1].copy()] + #self.check() ### + return hi + + def get_special(self, event): + """ + Get state set for special event, adding a new entry if necessary. + """ + special = self.special + set = special.get(event, None) + if not set: + set = {} + special[event] = set + return set + + # --------------------- Conversion methods ----------------------- + + def __str__(self): + map_strs = [] + map = self.map + n = len(map) + i = 0 + while i < n: + code = map[i] + if code == -maxint: + code_str = "-inf" + elif code == maxint: + code_str = "inf" + else: + code_str = str(code) + map_strs.append(code_str) + i += 1 + if i < n: + map_strs.append(state_set_str(map[i])) + i += 1 + special_strs = {} + for event, set in self.special.items(): + special_strs[event] = state_set_str(set) + return "[%s]+%s" % ( + ','.join(map_strs), + special_strs + ) + + # --------------------- Debugging methods ----------------------- + + def check(self): + """Check data structure integrity.""" + if not self.map[-3] < self.map[-1]: + print(self) + assert 0 + + def dump(self, file): + map = self.map + i = 0 + n = len(map) - 1 + while i < n: + self.dump_range(map[i], map[i + 2], map[i + 1], file) + i += 2 + for event, set in self.special.items(): + if set: + if not event: + event = 'empty' + self.dump_trans(event, set, file) + + def dump_range(self, code0, code1, set, file): + if set: + if code0 == -maxint: + if code1 == maxint: + k = "any" + else: + k = "< %s" % self.dump_char(code1) + elif code1 == maxint: + k = "> %s" % self.dump_char(code0 - 1) + elif code0 == code1 - 1: + k = self.dump_char(code0) + else: + k = "%s..%s" % (self.dump_char(code0), + self.dump_char(code1 - 1)) + self.dump_trans(k, set, file) + + def dump_char(self, code): + if 0 <= code <= 255: + return repr(chr(code)) + else: + return "chr(%d)" % code + + def dump_trans(self, key, set, file): + file.write(" %s --> %s\n" % (key, self.dump_set(set))) + + def dump_set(self, set): + return state_set_str(set) + + +# +# State set manipulation functions +# + +#def merge_state_sets(set1, set2): +# for state in set2.keys(): +# set1[state] = 1 + +def state_set_str(set): + return "[%s]" % ','.join(["S%d" % state.number for state in set]) diff --git a/contrib/tools/cython/Cython/Plex/__init__.py b/contrib/tools/cython/Cython/Plex/__init__.py new file mode 100644 index 00000000000..81a066f782c --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/__init__.py @@ -0,0 +1,39 @@ +#======================================================================= +# +# Python Lexical Analyser +# +#======================================================================= + +""" +The Plex module provides lexical analysers with similar capabilities +to GNU Flex. The following classes and functions are exported; +see the attached docstrings for more information. + + Scanner For scanning a character stream under the + direction of a Lexicon. + + Lexicon For constructing a lexical definition + to be used by a Scanner. + + Str, Any, AnyBut, AnyChar, Seq, Alt, Opt, Rep, Rep1, + Bol, Eol, Eof, Empty + + Regular expression constructors, for building pattern + definitions for a Lexicon. + + State For defining scanner states when creating a + Lexicon. + + TEXT, IGNORE, Begin + + Actions for associating with patterns when + creating a Lexicon. +""" + +from __future__ import absolute_import + +from .Actions import TEXT, IGNORE, Begin +from .Lexicons import Lexicon, State +from .Regexps import RE, Seq, Alt, Rep1, Empty, Str, Any, AnyBut, AnyChar, Range +from .Regexps import Opt, Rep, Bol, Eol, Eof, Case, NoCase +from .Scanners import Scanner diff --git a/contrib/tools/cython/Cython/Runtime/__init__.py b/contrib/tools/cython/Cython/Runtime/__init__.py new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Runtime/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Runtime/refnanny.pyx b/contrib/tools/cython/Cython/Runtime/refnanny.pyx new file mode 100644 index 00000000000..d4b873fe97a --- /dev/null +++ b/contrib/tools/cython/Cython/Runtime/refnanny.pyx @@ -0,0 +1,194 @@ +# cython: language_level=3, auto_pickle=False + +from cpython.ref cimport PyObject, Py_INCREF, Py_DECREF, Py_XDECREF, Py_XINCREF +from cpython.exc cimport PyErr_Fetch, PyErr_Restore +from cpython.pystate cimport PyThreadState_Get + +cimport cython + +loglevel = 0 +reflog = [] + +cdef log(level, action, obj, lineno): + if loglevel >= level: + reflog.append((lineno, action, id(obj))) + +LOG_NONE, LOG_ALL = range(2) + +@cython.final +cdef class Context(object): + cdef readonly object name, filename + cdef readonly dict refs + cdef readonly list errors + cdef readonly Py_ssize_t start + + def __cinit__(self, name, line=0, filename=None): + self.name = name + self.start = line + self.filename = filename + self.refs = {} # id -> (count, [lineno]) + self.errors = [] + + cdef regref(self, obj, lineno, bint is_null): + log(LOG_ALL, u'regref', u"<NULL>" if is_null else obj, lineno) + if is_null: + self.errors.append(f"NULL argument on line {lineno}") + return + id_ = id(obj) + count, linenumbers = self.refs.get(id_, (0, [])) + self.refs[id_] = (count + 1, linenumbers) + linenumbers.append(lineno) + + cdef bint delref(self, obj, lineno, bint is_null) except -1: + # returns whether it is ok to do the decref operation + log(LOG_ALL, u'delref', u"<NULL>" if is_null else obj, lineno) + if is_null: + self.errors.append(f"NULL argument on line {lineno}") + return False + id_ = id(obj) + count, linenumbers = self.refs.get(id_, (0, [])) + if count == 0: + self.errors.append(f"Too many decrefs on line {lineno}, reference acquired on lines {linenumbers!r}") + return False + elif count == 1: + del self.refs[id_] + return True + else: + self.refs[id_] = (count - 1, linenumbers) + return True + + cdef end(self): + if self.refs: + msg = u"References leaked:" + for count, linenos in self.refs.itervalues(): + msg += f"\n ({count}) acquired on lines: {u', '.join([f'{x}' for x in linenos])}" + self.errors.append(msg) + if self.errors: + return u"\n".join([u'REFNANNY: '+error for error in self.errors]) + else: + return None + +cdef void report_unraisable(object e=None): + try: + if e is None: + import sys + e = sys.exc_info()[1] + print(f"refnanny raised an exception: {e}") + except: + pass # We absolutely cannot exit with an exception + +# All Python operations must happen after any existing +# exception has been fetched, in case we are called from +# exception-handling code. + +cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except NULL: + if Context is None: + # Context may be None during finalize phase. + # In that case, we don't want to be doing anything fancy + # like caching and resetting exceptions. + return NULL + cdef (PyObject*) type = NULL, value = NULL, tb = NULL, result = NULL + PyThreadState_Get() + PyErr_Fetch(&type, &value, &tb) + try: + ctx = Context(funcname, lineno, filename) + Py_INCREF(ctx) + result = <PyObject*>ctx + except Exception, e: + report_unraisable(e) + PyErr_Restore(type, value, tb) + return result + +cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): + if ctx == NULL: return + cdef (PyObject*) type = NULL, value = NULL, tb = NULL + PyErr_Fetch(&type, &value, &tb) + try: + try: + if p_obj is NULL: + (<Context>ctx).regref(None, lineno, True) + else: + (<Context>ctx).regref(<object>p_obj, lineno, False) + except: + report_unraisable() + except: + # __Pyx_GetException may itself raise errors + pass + PyErr_Restore(type, value, tb) + +cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): + if ctx == NULL: return 1 + cdef (PyObject*) type = NULL, value = NULL, tb = NULL + cdef bint decref_ok = False + PyErr_Fetch(&type, &value, &tb) + try: + try: + if p_obj is NULL: + decref_ok = (<Context>ctx).delref(None, lineno, True) + else: + decref_ok = (<Context>ctx).delref(<object>p_obj, lineno, False) + except: + report_unraisable() + except: + # __Pyx_GetException may itself raise errors + pass + PyErr_Restore(type, value, tb) + return decref_ok + +cdef void GIVEREF(PyObject* ctx, PyObject* p_obj, int lineno): + GIVEREF_and_report(ctx, p_obj, lineno) + +cdef void INCREF(PyObject* ctx, PyObject* obj, int lineno): + Py_XINCREF(obj) + PyThreadState_Get() + GOTREF(ctx, obj, lineno) + +cdef void DECREF(PyObject* ctx, PyObject* obj, int lineno): + if GIVEREF_and_report(ctx, obj, lineno): + Py_XDECREF(obj) + PyThreadState_Get() + +cdef void FinishContext(PyObject** ctx): + if ctx == NULL or ctx[0] == NULL: return + cdef (PyObject*) type = NULL, value = NULL, tb = NULL + cdef object errors = None + cdef Context context + PyThreadState_Get() + PyErr_Fetch(&type, &value, &tb) + try: + try: + context = <Context>ctx[0] + errors = context.end() + if errors: + print(f"{context.filename.decode('latin1')}: {context.name.decode('latin1')}()") + print(errors) + context = None + except: + report_unraisable() + except: + # __Pyx_GetException may itself raise errors + pass + Py_XDECREF(ctx[0]) + ctx[0] = NULL + PyErr_Restore(type, value, tb) + +ctypedef struct RefNannyAPIStruct: + void (*INCREF)(PyObject*, PyObject*, int) + void (*DECREF)(PyObject*, PyObject*, int) + void (*GOTREF)(PyObject*, PyObject*, int) + void (*GIVEREF)(PyObject*, PyObject*, int) + PyObject* (*SetupContext)(char*, int, char*) except NULL + void (*FinishContext)(PyObject**) + +cdef RefNannyAPIStruct api +api.INCREF = INCREF +api.DECREF = DECREF +api.GOTREF = GOTREF +api.GIVEREF = GIVEREF +api.SetupContext = SetupContext +api.FinishContext = FinishContext + +cdef extern from "Python.h": + object PyLong_FromVoidPtr(void*) + +RefNannyAPI = PyLong_FromVoidPtr(<void*>&api) diff --git a/contrib/tools/cython/Cython/Shadow.py b/contrib/tools/cython/Cython/Shadow.py new file mode 100644 index 00000000000..96296070e5f --- /dev/null +++ b/contrib/tools/cython/Cython/Shadow.py @@ -0,0 +1,474 @@ +# cython.* namespace for pure mode. +from __future__ import absolute_import + +__version__ = "0.29.34" + +try: + from __builtin__ import basestring +except ImportError: + basestring = str + + +# BEGIN shameless copy from Cython/minivect/minitypes.py + +class _ArrayType(object): + + is_array = True + subtypes = ['dtype'] + + def __init__(self, dtype, ndim, is_c_contig=False, is_f_contig=False, + inner_contig=False, broadcasting=None): + self.dtype = dtype + self.ndim = ndim + self.is_c_contig = is_c_contig + self.is_f_contig = is_f_contig + self.inner_contig = inner_contig or is_c_contig or is_f_contig + self.broadcasting = broadcasting + + def __repr__(self): + axes = [":"] * self.ndim + if self.is_c_contig: + axes[-1] = "::1" + elif self.is_f_contig: + axes[0] = "::1" + + return "%s[%s]" % (self.dtype, ", ".join(axes)) + + +def index_type(base_type, item): + """ + Support array type creation by slicing, e.g. double[:, :] specifies + a 2D strided array of doubles. The syntax is the same as for + Cython memoryviews. + """ + class InvalidTypeSpecification(Exception): + pass + + def verify_slice(s): + if s.start or s.stop or s.step not in (None, 1): + raise InvalidTypeSpecification( + "Only a step of 1 may be provided to indicate C or " + "Fortran contiguity") + + if isinstance(item, tuple): + step_idx = None + for idx, s in enumerate(item): + verify_slice(s) + if s.step and (step_idx or idx not in (0, len(item) - 1)): + raise InvalidTypeSpecification( + "Step may only be provided once, and only in the " + "first or last dimension.") + + if s.step == 1: + step_idx = idx + + return _ArrayType(base_type, len(item), + is_c_contig=step_idx == len(item) - 1, + is_f_contig=step_idx == 0) + elif isinstance(item, slice): + verify_slice(item) + return _ArrayType(base_type, 1, is_c_contig=bool(item.step)) + else: + # int[8] etc. + assert int(item) == item # array size must be a plain integer + array(base_type, item) + +# END shameless copy + + +compiled = False + +_Unspecified = object() + +# Function decorators + +def _empty_decorator(x): + return x + +def locals(**arg_types): + return _empty_decorator + +def test_assert_path_exists(*paths): + return _empty_decorator + +def test_fail_if_path_exists(*paths): + return _empty_decorator + +class _EmptyDecoratorAndManager(object): + def __call__(self, x): + return x + def __enter__(self): + pass + def __exit__(self, exc_type, exc_value, traceback): + pass + +class _Optimization(object): + pass + +cclass = ccall = cfunc = _EmptyDecoratorAndManager() + +returns = wraparound = boundscheck = initializedcheck = nonecheck = \ + embedsignature = cdivision = cdivision_warnings = \ + always_allows_keywords = profile = linetrace = infer_types = \ + unraisable_tracebacks = freelist = \ + lambda _: _EmptyDecoratorAndManager() + +exceptval = lambda _=None, check=True: _EmptyDecoratorAndManager() + +overflowcheck = lambda _: _EmptyDecoratorAndManager() +optimization = _Optimization() + +overflowcheck.fold = optimization.use_switch = \ + optimization.unpack_method_calls = lambda arg: _EmptyDecoratorAndManager() + +final = internal = type_version_tag = no_gc_clear = no_gc = _empty_decorator + +binding = lambda _: _empty_decorator + + +_cython_inline = None +def inline(f, *args, **kwds): + if isinstance(f, basestring): + global _cython_inline + if _cython_inline is None: + from Cython.Build.Inline import cython_inline as _cython_inline + return _cython_inline(f, *args, **kwds) + else: + assert len(args) == len(kwds) == 0 + return f + + +def compile(f): + from Cython.Build.Inline import RuntimeCompiledFunction + return RuntimeCompiledFunction(f) + + +# Special functions + +def cdiv(a, b): + q = a / b + if q < 0: + q += 1 + return q + +def cmod(a, b): + r = a % b + if (a*b) < 0: + r -= b + return r + + +# Emulated language constructs + +def cast(type, *args, **kwargs): + kwargs.pop('typecheck', None) + assert not kwargs + if hasattr(type, '__call__'): + return type(*args) + else: + return args[0] + +def sizeof(arg): + return 1 + +def typeof(arg): + return arg.__class__.__name__ + # return type(arg) + +def address(arg): + return pointer(type(arg))([arg]) + +def declare(type=None, value=_Unspecified, **kwds): + if type not in (None, object) and hasattr(type, '__call__'): + if value is not _Unspecified: + return type(value) + else: + return type() + else: + return value + +class _nogil(object): + """Support for 'with nogil' statement and @nogil decorator. + """ + def __call__(self, x): + if callable(x): + # Used as function decorator => return the function unchanged. + return x + # Used as conditional context manager or to create an "@nogil(True/False)" decorator => keep going. + return self + + def __enter__(self): + pass + def __exit__(self, exc_class, exc, tb): + return exc_class is None + +nogil = _nogil() +gil = _nogil() +del _nogil + + +# Emulated types + +class CythonMetaType(type): + + def __getitem__(type, ix): + return array(type, ix) + +CythonTypeObject = CythonMetaType('CythonTypeObject', (object,), {}) + +class CythonType(CythonTypeObject): + + def _pointer(self, n=1): + for i in range(n): + self = pointer(self) + return self + +class PointerType(CythonType): + + def __init__(self, value=None): + if isinstance(value, (ArrayType, PointerType)): + self._items = [cast(self._basetype, a) for a in value._items] + elif isinstance(value, list): + self._items = [cast(self._basetype, a) for a in value] + elif value is None or value == 0: + self._items = [] + else: + raise ValueError + + def __getitem__(self, ix): + if ix < 0: + raise IndexError("negative indexing not allowed in C") + return self._items[ix] + + def __setitem__(self, ix, value): + if ix < 0: + raise IndexError("negative indexing not allowed in C") + self._items[ix] = cast(self._basetype, value) + + def __eq__(self, value): + if value is None and not self._items: + return True + elif type(self) != type(value): + return False + else: + return not self._items and not value._items + + def __repr__(self): + return "%s *" % (self._basetype,) + +class ArrayType(PointerType): + + def __init__(self): + self._items = [None] * self._n + + +class StructType(CythonType): + + def __init__(self, cast_from=_Unspecified, **data): + if cast_from is not _Unspecified: + # do cast + if len(data) > 0: + raise ValueError('Cannot accept keyword arguments when casting.') + if type(cast_from) is not type(self): + raise ValueError('Cannot cast from %s'%cast_from) + for key, value in cast_from.__dict__.items(): + setattr(self, key, value) + else: + for key, value in data.items(): + setattr(self, key, value) + + def __setattr__(self, key, value): + if key in self._members: + self.__dict__[key] = cast(self._members[key], value) + else: + raise AttributeError("Struct has no member '%s'" % key) + + +class UnionType(CythonType): + + def __init__(self, cast_from=_Unspecified, **data): + if cast_from is not _Unspecified: + # do type cast + if len(data) > 0: + raise ValueError('Cannot accept keyword arguments when casting.') + if isinstance(cast_from, dict): + datadict = cast_from + elif type(cast_from) is type(self): + datadict = cast_from.__dict__ + else: + raise ValueError('Cannot cast from %s'%cast_from) + else: + datadict = data + if len(datadict) > 1: + raise AttributeError("Union can only store one field at a time.") + for key, value in datadict.items(): + setattr(self, key, value) + + def __setattr__(self, key, value): + if key == '__dict__': + CythonType.__setattr__(self, key, value) + elif key in self._members: + self.__dict__ = {key: cast(self._members[key], value)} + else: + raise AttributeError("Union has no member '%s'" % key) + +def pointer(basetype): + class PointerInstance(PointerType): + _basetype = basetype + return PointerInstance + +def array(basetype, n): + class ArrayInstance(ArrayType): + _basetype = basetype + _n = n + return ArrayInstance + +def struct(**members): + class StructInstance(StructType): + _members = members + for key in members: + setattr(StructInstance, key, None) + return StructInstance + +def union(**members): + class UnionInstance(UnionType): + _members = members + for key in members: + setattr(UnionInstance, key, None) + return UnionInstance + +class typedef(CythonType): + + def __init__(self, type, name=None): + self._basetype = type + self.name = name + + def __call__(self, *arg): + value = cast(self._basetype, *arg) + return value + + def __repr__(self): + return self.name or str(self._basetype) + + __getitem__ = index_type + +class _FusedType(CythonType): + __getitem__ = index_type + + +def fused_type(*args): + if not args: + raise TypeError("Expected at least one type as argument") + + # Find the numeric type with biggest rank if all types are numeric + rank = -1 + for type in args: + if type not in (py_int, py_long, py_float, py_complex): + break + + if type_ordering.index(type) > rank: + result_type = type + else: + return result_type + + # Not a simple numeric type, return a fused type instance. The result + # isn't really meant to be used, as we can't keep track of the context in + # pure-mode. Casting won't do anything in this case. + return _FusedType() + + +def _specialized_from_args(signatures, args, kwargs): + "Perhaps this should be implemented in a TreeFragment in Cython code" + raise Exception("yet to be implemented") + + +py_int = typedef(int, "int") +try: + py_long = typedef(long, "long") +except NameError: # Py3 + py_long = typedef(int, "long") +py_float = typedef(float, "float") +py_complex = typedef(complex, "double complex") + + +# Predefined types + +int_types = ['char', 'short', 'Py_UNICODE', 'int', 'Py_UCS4', 'long', 'longlong', 'Py_ssize_t', 'size_t'] +float_types = ['longdouble', 'double', 'float'] +complex_types = ['longdoublecomplex', 'doublecomplex', 'floatcomplex', 'complex'] +other_types = ['bint', 'void', 'Py_tss_t'] + +to_repr = { + 'longlong': 'long long', + 'longdouble': 'long double', + 'longdoublecomplex': 'long double complex', + 'doublecomplex': 'double complex', + 'floatcomplex': 'float complex', +}.get + +gs = globals() + +# note: cannot simply name the unicode type here as 2to3 gets in the way and replaces it by str +try: + import __builtin__ as builtins +except ImportError: # Py3 + import builtins + +gs['unicode'] = typedef(getattr(builtins, 'unicode', str), 'unicode') +del builtins + +for name in int_types: + reprname = to_repr(name, name) + gs[name] = typedef(py_int, reprname) + if name not in ('Py_UNICODE', 'Py_UCS4') and not name.endswith('size_t'): + gs['u'+name] = typedef(py_int, "unsigned " + reprname) + gs['s'+name] = typedef(py_int, "signed " + reprname) + +for name in float_types: + gs[name] = typedef(py_float, to_repr(name, name)) + +for name in complex_types: + gs[name] = typedef(py_complex, to_repr(name, name)) + +bint = typedef(bool, "bint") +void = typedef(None, "void") +Py_tss_t = typedef(None, "Py_tss_t") + +for t in int_types + float_types + complex_types + other_types: + for i in range(1, 4): + gs["%s_%s" % ('p'*i, t)] = gs[t]._pointer(i) + +NULL = gs['p_void'](0) + +# looks like 'gs' has some users out there by now... +#del gs + +integral = floating = numeric = _FusedType() + +type_ordering = [py_int, py_long, py_float, py_complex] + +class CythonDotParallel(object): + """ + The cython.parallel module. + """ + + __all__ = ['parallel', 'prange', 'threadid'] + + def parallel(self, num_threads=None): + return nogil + + def prange(self, start=0, stop=None, step=1, nogil=False, schedule=None, chunksize=None, num_threads=None): + if stop is None: + stop = start + start = 0 + return range(start, stop, step) + + def threadid(self): + return 0 + + # def threadsavailable(self): + # return 1 + +import sys +sys.modules['cython.parallel'] = CythonDotParallel() +del sys diff --git a/contrib/tools/cython/Cython/StringIOTree.pxd b/contrib/tools/cython/Cython/StringIOTree.pxd new file mode 100644 index 00000000000..20455c9dfbe --- /dev/null +++ b/contrib/tools/cython/Cython/StringIOTree.pxd @@ -0,0 +1,17 @@ +cimport cython + +cdef class StringIOTree: + cdef public list prepended_children + cdef public object stream + cdef public object write + cdef public list markers + + @cython.locals(x=StringIOTree) + cpdef getvalue(self) + @cython.locals(child=StringIOTree) + cpdef copyto(self, target) + cpdef commit(self) + #def insert(self, iotree) + #def insertion_point(self) + @cython.locals(c=StringIOTree) + cpdef allmarkers(self) diff --git a/contrib/tools/cython/Cython/StringIOTree.py b/contrib/tools/cython/Cython/StringIOTree.py new file mode 100644 index 00000000000..d8239efeda9 --- /dev/null +++ b/contrib/tools/cython/Cython/StringIOTree.py @@ -0,0 +1,108 @@ +# cython: auto_pickle=False + +r""" +Implements a buffer with insertion points. When you know you need to +"get back" to a place and write more later, simply call insertion_point() +at that spot and get a new StringIOTree object that is "left behind". + +EXAMPLE: + +>>> a = StringIOTree() +>>> _= a.write('first\n') +>>> b = a.insertion_point() +>>> _= a.write('third\n') +>>> _= b.write('second\n') +>>> a.getvalue().split() +['first', 'second', 'third'] + +>>> c = b.insertion_point() +>>> d = c.insertion_point() +>>> _= d.write('alpha\n') +>>> _= b.write('gamma\n') +>>> _= c.write('beta\n') +>>> b.getvalue().split() +['second', 'alpha', 'beta', 'gamma'] + +>>> i = StringIOTree() +>>> d.insert(i) +>>> _= i.write('inserted\n') +>>> out = StringIO() +>>> a.copyto(out) +>>> out.getvalue().split() +['first', 'second', 'alpha', 'inserted', 'beta', 'gamma', 'third'] +""" + +from __future__ import absolute_import #, unicode_literals + +try: + # Prefer cStringIO since io.StringIO() does not support writing 'str' in Py2. + from cStringIO import StringIO +except ImportError: + from io import StringIO + + +class StringIOTree(object): + """ + See module docs. + """ + + def __init__(self, stream=None): + self.prepended_children = [] + if stream is None: + stream = StringIO() + self.stream = stream + self.write = stream.write + self.markers = [] + + def getvalue(self): + content = [x.getvalue() for x in self.prepended_children] + content.append(self.stream.getvalue()) + return "".join(content) + + def copyto(self, target): + """Potentially cheaper than getvalue as no string concatenation + needs to happen.""" + for child in self.prepended_children: + child.copyto(target) + stream_content = self.stream.getvalue() + if stream_content: + target.write(stream_content) + + def commit(self): + # Save what we have written until now so that the buffer + # itself is empty -- this makes it ready for insertion + if self.stream.tell(): + self.prepended_children.append(StringIOTree(self.stream)) + self.prepended_children[-1].markers = self.markers + self.markers = [] + self.stream = StringIO() + self.write = self.stream.write + + def insert(self, iotree): + """ + Insert a StringIOTree (and all of its contents) at this location. + Further writing to self appears after what is inserted. + """ + self.commit() + self.prepended_children.append(iotree) + + def insertion_point(self): + """ + Returns a new StringIOTree, which is left behind at the current position + (it what is written to the result will appear right before whatever is + next written to self). + + Calling getvalue() or copyto() on the result will only return the + contents written to it. + """ + # Save what we have written until now + # This is so that getvalue on the result doesn't include it. + self.commit() + # Construct the new forked object to return + other = StringIOTree() + self.prepended_children.append(other) + return other + + def allmarkers(self): + children = self.prepended_children + return [m for c in children for m in c.allmarkers()] + self.markers diff --git a/contrib/tools/cython/Cython/Tempita/__init__.py b/contrib/tools/cython/Cython/Tempita/__init__.py new file mode 100644 index 00000000000..41a0ce3d0ef --- /dev/null +++ b/contrib/tools/cython/Cython/Tempita/__init__.py @@ -0,0 +1,4 @@ +# The original Tempita implements all of its templating code here. +# Moved it to _tempita.py to make the compilation portable. + +from ._tempita import * diff --git a/contrib/tools/cython/Cython/Tempita/_looper.py b/contrib/tools/cython/Cython/Tempita/_looper.py new file mode 100644 index 00000000000..4010988300f --- /dev/null +++ b/contrib/tools/cython/Cython/Tempita/_looper.py @@ -0,0 +1,163 @@ +""" +Helper for looping over sequences, particular in templates. + +Often in a loop in a template it's handy to know what's next up, +previously up, if this is the first or last item in the sequence, etc. +These can be awkward to manage in a normal Python loop, but using the +looper you can get a better sense of the context. Use like:: + + >>> for loop, item in looper(['a', 'b', 'c']): + ... print loop.number, item + ... if not loop.last: + ... print '---' + 1 a + --- + 2 b + --- + 3 c + +""" + +import sys +from Cython.Tempita.compat3 import basestring_ + +__all__ = ['looper'] + + +class looper(object): + """ + Helper for looping (particularly in templates) + + Use this like:: + + for loop, item in looper(seq): + if loop.first: + ... + """ + + def __init__(self, seq): + self.seq = seq + + def __iter__(self): + return looper_iter(self.seq) + + def __repr__(self): + return '<%s for %r>' % ( + self.__class__.__name__, self.seq) + + +class looper_iter(object): + + def __init__(self, seq): + self.seq = list(seq) + self.pos = 0 + + def __iter__(self): + return self + + def __next__(self): + if self.pos >= len(self.seq): + raise StopIteration + result = loop_pos(self.seq, self.pos), self.seq[self.pos] + self.pos += 1 + return result + + if sys.version < "3": + next = __next__ + + +class loop_pos(object): + + def __init__(self, seq, pos): + self.seq = seq + self.pos = pos + + def __repr__(self): + return '<loop pos=%r at %r>' % ( + self.seq[self.pos], self.pos) + + def index(self): + return self.pos + index = property(index) + + def number(self): + return self.pos + 1 + number = property(number) + + def item(self): + return self.seq[self.pos] + item = property(item) + + def __next__(self): + try: + return self.seq[self.pos + 1] + except IndexError: + return None + __next__ = property(__next__) + + if sys.version < "3": + next = __next__ + + def previous(self): + if self.pos == 0: + return None + return self.seq[self.pos - 1] + previous = property(previous) + + def odd(self): + return not self.pos % 2 + odd = property(odd) + + def even(self): + return self.pos % 2 + even = property(even) + + def first(self): + return self.pos == 0 + first = property(first) + + def last(self): + return self.pos == len(self.seq) - 1 + last = property(last) + + def length(self): + return len(self.seq) + length = property(length) + + def first_group(self, getter=None): + """ + Returns true if this item is the start of a new group, + where groups mean that some attribute has changed. The getter + can be None (the item itself changes), an attribute name like + ``'.attr'``, a function, or a dict key or list index. + """ + if self.first: + return True + return self._compare_group(self.item, self.previous, getter) + + def last_group(self, getter=None): + """ + Returns true if this item is the end of a new group, + where groups mean that some attribute has changed. The getter + can be None (the item itself changes), an attribute name like + ``'.attr'``, a function, or a dict key or list index. + """ + if self.last: + return True + return self._compare_group(self.item, self.__next__, getter) + + def _compare_group(self, item, other, getter): + if getter is None: + return item != other + elif (isinstance(getter, basestring_) + and getter.startswith('.')): + getter = getter[1:] + if getter.endswith('()'): + getter = getter[:-2] + return getattr(item, getter)() != getattr(other, getter)() + else: + return getattr(item, getter) != getattr(other, getter) + elif hasattr(getter, '__call__'): + return getter(item) != getter(other) + else: + return item[getter] != other[getter] diff --git a/contrib/tools/cython/Cython/Tempita/_tempita.py b/contrib/tools/cython/Cython/Tempita/_tempita.py new file mode 100644 index 00000000000..587f6e4841f --- /dev/null +++ b/contrib/tools/cython/Cython/Tempita/_tempita.py @@ -0,0 +1,1188 @@ +""" +A small templating language + +This implements a small templating language. This language implements +if/elif/else, for/continue/break, expressions, and blocks of Python +code. The syntax is:: + + {{any expression (function calls etc)}} + {{any expression | filter}} + {{for x in y}}...{{endfor}} + {{if x}}x{{elif y}}y{{else}}z{{endif}} + {{py:x=1}} + {{py: + def foo(bar): + return 'baz' + }} + {{default var = default_value}} + {{# comment}} + +You use this with the ``Template`` class or the ``sub`` shortcut. +The ``Template`` class takes the template string and the name of +the template (for errors) and a default namespace. Then (like +``string.Template``) you can call the ``tmpl.substitute(**kw)`` +method to make a substitution (or ``tmpl.substitute(a_dict)``). + +``sub(content, **kw)`` substitutes the template immediately. You +can use ``__name='tmpl.html'`` to set the name of the template. + +If there are syntax errors ``TemplateError`` will be raised. +""" + +from __future__ import absolute_import + +import re +import sys +try: + import cgi +except ImportError: + pass +try: + from urllib import quote as url_quote +except ImportError: # Py3 + try: + from urllib.parse import quote as url_quote + except ImportError: + pass +import os +import tokenize +from io import StringIO + +from ._looper import looper +from .compat3 import bytes, unicode_, basestring_, next, is_unicode, coerce_text + +__all__ = ['TemplateError', 'Template', 'sub', 'HTMLTemplate', + 'sub_html', 'html', 'bunch'] + +in_re = re.compile(r'\s+in\s+') +var_re = re.compile(r'^[a-z_][a-z0-9_]*$', re.I) + + +class TemplateError(Exception): + """Exception raised while parsing a template + """ + + def __init__(self, message, position, name=None): + Exception.__init__(self, message) + self.position = position + self.name = name + + def __str__(self): + msg = ' '.join(self.args) + if self.position: + msg = '%s at line %s column %s' % ( + msg, self.position[0], self.position[1]) + if self.name: + msg += ' in %s' % self.name + return msg + + +class _TemplateContinue(Exception): + pass + + +class _TemplateBreak(Exception): + pass + + +def get_file_template(name, from_template): + path = os.path.join(os.path.dirname(from_template.name), name) + return from_template.__class__.from_filename( + path, namespace=from_template.namespace, + get_template=from_template.get_template) + + +class Template(object): + + default_namespace = { + 'start_braces': '{{', + 'end_braces': '}}', + 'looper': looper, + } + + default_encoding = 'utf8' + default_inherit = None + + def __init__(self, content, name=None, namespace=None, stacklevel=None, + get_template=None, default_inherit=None, line_offset=0, + delimeters=None): + self.content = content + + # set delimeters + if delimeters is None: + delimeters = (self.default_namespace['start_braces'], + self.default_namespace['end_braces']) + else: + #assert len(delimeters) == 2 and all([isinstance(delimeter, basestring) + # for delimeter in delimeters]) + self.default_namespace = self.__class__.default_namespace.copy() + self.default_namespace['start_braces'] = delimeters[0] + self.default_namespace['end_braces'] = delimeters[1] + self.delimeters = delimeters + + self._unicode = is_unicode(content) + if name is None and stacklevel is not None: + try: + caller = sys._getframe(stacklevel) + except ValueError: + pass + else: + globals = caller.f_globals + lineno = caller.f_lineno + if '__file__' in globals: + name = globals['__file__'] + if name.endswith('.pyc') or name.endswith('.pyo'): + name = name[:-1] + elif '__name__' in globals: + name = globals['__name__'] + else: + name = '<string>' + if lineno: + name += ':%s' % lineno + self.name = name + self._parsed = parse(content, name=name, line_offset=line_offset, delimeters=self.delimeters) + if namespace is None: + namespace = {} + self.namespace = namespace + self.get_template = get_template + if default_inherit is not None: + self.default_inherit = default_inherit + + def from_filename(cls, filename, namespace=None, encoding=None, + default_inherit=None, get_template=get_file_template): + f = open(filename, 'rb') + c = f.read() + f.close() + if encoding: + c = c.decode(encoding) + return cls(content=c, name=filename, namespace=namespace, + default_inherit=default_inherit, get_template=get_template) + + from_filename = classmethod(from_filename) + + def __repr__(self): + return '<%s %s name=%r>' % ( + self.__class__.__name__, + hex(id(self))[2:], self.name) + + def substitute(self, *args, **kw): + if args: + if kw: + raise TypeError( + "You can only give positional *or* keyword arguments") + if len(args) > 1: + raise TypeError( + "You can only give one positional argument") + if not hasattr(args[0], 'items'): + raise TypeError( + "If you pass in a single argument, you must pass in a dictionary-like object (with a .items() method); you gave %r" + % (args[0],)) + kw = args[0] + ns = kw + ns['__template_name__'] = self.name + if self.namespace: + ns.update(self.namespace) + result, defs, inherit = self._interpret(ns) + if not inherit: + inherit = self.default_inherit + if inherit: + result = self._interpret_inherit(result, defs, inherit, ns) + return result + + def _interpret(self, ns): + __traceback_hide__ = True + parts = [] + defs = {} + self._interpret_codes(self._parsed, ns, out=parts, defs=defs) + if '__inherit__' in defs: + inherit = defs.pop('__inherit__') + else: + inherit = None + return ''.join(parts), defs, inherit + + def _interpret_inherit(self, body, defs, inherit_template, ns): + __traceback_hide__ = True + if not self.get_template: + raise TemplateError( + 'You cannot use inheritance without passing in get_template', + position=None, name=self.name) + templ = self.get_template(inherit_template, self) + self_ = TemplateObject(self.name) + for name, value in defs.items(): + setattr(self_, name, value) + self_.body = body + ns = ns.copy() + ns['self'] = self_ + return templ.substitute(ns) + + def _interpret_codes(self, codes, ns, out, defs): + __traceback_hide__ = True + for item in codes: + if isinstance(item, basestring_): + out.append(item) + else: + self._interpret_code(item, ns, out, defs) + + def _interpret_code(self, code, ns, out, defs): + __traceback_hide__ = True + name, pos = code[0], code[1] + if name == 'py': + self._exec(code[2], ns, pos) + elif name == 'continue': + raise _TemplateContinue() + elif name == 'break': + raise _TemplateBreak() + elif name == 'for': + vars, expr, content = code[2], code[3], code[4] + expr = self._eval(expr, ns, pos) + self._interpret_for(vars, expr, content, ns, out, defs) + elif name == 'cond': + parts = code[2:] + self._interpret_if(parts, ns, out, defs) + elif name == 'expr': + parts = code[2].split('|') + base = self._eval(parts[0], ns, pos) + for part in parts[1:]: + func = self._eval(part, ns, pos) + base = func(base) + out.append(self._repr(base, pos)) + elif name == 'default': + var, expr = code[2], code[3] + if var not in ns: + result = self._eval(expr, ns, pos) + ns[var] = result + elif name == 'inherit': + expr = code[2] + value = self._eval(expr, ns, pos) + defs['__inherit__'] = value + elif name == 'def': + name = code[2] + signature = code[3] + parts = code[4] + ns[name] = defs[name] = TemplateDef(self, name, signature, body=parts, ns=ns, + pos=pos) + elif name == 'comment': + return + else: + assert 0, "Unknown code: %r" % name + + def _interpret_for(self, vars, expr, content, ns, out, defs): + __traceback_hide__ = True + for item in expr: + if len(vars) == 1: + ns[vars[0]] = item + else: + if len(vars) != len(item): + raise ValueError( + 'Need %i items to unpack (got %i items)' + % (len(vars), len(item))) + for name, value in zip(vars, item): + ns[name] = value + try: + self._interpret_codes(content, ns, out, defs) + except _TemplateContinue: + continue + except _TemplateBreak: + break + + def _interpret_if(self, parts, ns, out, defs): + __traceback_hide__ = True + # @@: if/else/else gets through + for part in parts: + assert not isinstance(part, basestring_) + name, pos = part[0], part[1] + if name == 'else': + result = True + else: + result = self._eval(part[2], ns, pos) + if result: + self._interpret_codes(part[3], ns, out, defs) + break + + def _eval(self, code, ns, pos): + __traceback_hide__ = True + try: + try: + value = eval(code, self.default_namespace, ns) + except SyntaxError as e: + raise SyntaxError( + 'invalid syntax in expression: %s' % code) + return value + except Exception as e: + if getattr(e, 'args', None): + arg0 = e.args[0] + else: + arg0 = coerce_text(e) + e.args = (self._add_line_info(arg0, pos),) + raise + + def _exec(self, code, ns, pos): + __traceback_hide__ = True + try: + exec(code, self.default_namespace, ns) + except Exception as e: + if e.args: + e.args = (self._add_line_info(e.args[0], pos),) + else: + e.args = (self._add_line_info(None, pos),) + raise + + def _repr(self, value, pos): + __traceback_hide__ = True + try: + if value is None: + return '' + if self._unicode: + try: + value = unicode_(value) + except UnicodeDecodeError: + value = bytes(value) + else: + if not isinstance(value, basestring_): + value = coerce_text(value) + if (is_unicode(value) + and self.default_encoding): + value = value.encode(self.default_encoding) + except Exception as e: + e.args = (self._add_line_info(e.args[0], pos),) + raise + else: + if self._unicode and isinstance(value, bytes): + if not self.default_encoding: + raise UnicodeDecodeError( + 'Cannot decode bytes value %r into unicode ' + '(no default_encoding provided)' % value) + try: + value = value.decode(self.default_encoding) + except UnicodeDecodeError as e: + raise UnicodeDecodeError( + e.encoding, + e.object, + e.start, + e.end, + e.reason + ' in string %r' % value) + elif not self._unicode and is_unicode(value): + if not self.default_encoding: + raise UnicodeEncodeError( + 'Cannot encode unicode value %r into bytes ' + '(no default_encoding provided)' % value) + value = value.encode(self.default_encoding) + return value + + def _add_line_info(self, msg, pos): + msg = "%s at line %s column %s" % ( + msg, pos[0], pos[1]) + if self.name: + msg += " in file %s" % self.name + return msg + + +def sub(content, delimeters=None, **kw): + name = kw.get('__name') + tmpl = Template(content, name=name, delimeters=delimeters) + return tmpl.substitute(kw) + + +def paste_script_template_renderer(content, vars, filename=None): + tmpl = Template(content, name=filename) + return tmpl.substitute(vars) + + +class bunch(dict): + + def __init__(self, **kw): + for name, value in kw.items(): + setattr(self, name, value) + + def __setattr__(self, name, value): + self[name] = value + + def __getattr__(self, name): + try: + return self[name] + except KeyError: + raise AttributeError(name) + + def __getitem__(self, key): + if 'default' in self: + try: + return dict.__getitem__(self, key) + except KeyError: + return dict.__getitem__(self, 'default') + else: + return dict.__getitem__(self, key) + + def __repr__(self): + return '<%s %s>' % ( + self.__class__.__name__, + ' '.join(['%s=%r' % (k, v) for k, v in sorted(self.items())])) + +############################################################ +## HTML Templating +############################################################ + + +class html(object): + + def __init__(self, value): + self.value = value + + def __str__(self): + return self.value + + def __html__(self): + return self.value + + def __repr__(self): + return '<%s %r>' % ( + self.__class__.__name__, self.value) + + +def html_quote(value, force=True): + if not force and hasattr(value, '__html__'): + return value.__html__() + if value is None: + return '' + if not isinstance(value, basestring_): + value = coerce_text(value) + if sys.version >= "3" and isinstance(value, bytes): + value = cgi.escape(value.decode('latin1'), 1) + value = value.encode('latin1') + else: + value = cgi.escape(value, 1) + if sys.version < "3": + if is_unicode(value): + value = value.encode('ascii', 'xmlcharrefreplace') + return value + + +def url(v): + v = coerce_text(v) + if is_unicode(v): + v = v.encode('utf8') + return url_quote(v) + + +def attr(**kw): + parts = [] + for name, value in sorted(kw.items()): + if value is None: + continue + if name.endswith('_'): + name = name[:-1] + parts.append('%s="%s"' % (html_quote(name), html_quote(value))) + return html(' '.join(parts)) + + +class HTMLTemplate(Template): + + default_namespace = Template.default_namespace.copy() + default_namespace.update(dict( + html=html, + attr=attr, + url=url, + html_quote=html_quote, + )) + + def _repr(self, value, pos): + if hasattr(value, '__html__'): + value = value.__html__() + quote = False + else: + quote = True + plain = Template._repr(self, value, pos) + if quote: + return html_quote(plain) + else: + return plain + + +def sub_html(content, **kw): + name = kw.get('__name') + tmpl = HTMLTemplate(content, name=name) + return tmpl.substitute(kw) + + +class TemplateDef(object): + def __init__(self, template, func_name, func_signature, + body, ns, pos, bound_self=None): + self._template = template + self._func_name = func_name + self._func_signature = func_signature + self._body = body + self._ns = ns + self._pos = pos + self._bound_self = bound_self + + def __repr__(self): + return '<tempita function %s(%s) at %s:%s>' % ( + self._func_name, self._func_signature, + self._template.name, self._pos) + + def __str__(self): + return self() + + def __call__(self, *args, **kw): + values = self._parse_signature(args, kw) + ns = self._ns.copy() + ns.update(values) + if self._bound_self is not None: + ns['self'] = self._bound_self + out = [] + subdefs = {} + self._template._interpret_codes(self._body, ns, out, subdefs) + return ''.join(out) + + def __get__(self, obj, type=None): + if obj is None: + return self + return self.__class__( + self._template, self._func_name, self._func_signature, + self._body, self._ns, self._pos, bound_self=obj) + + def _parse_signature(self, args, kw): + values = {} + sig_args, var_args, var_kw, defaults = self._func_signature + extra_kw = {} + for name, value in kw.items(): + if not var_kw and name not in sig_args: + raise TypeError( + 'Unexpected argument %s' % name) + if name in sig_args: + values[sig_args] = value + else: + extra_kw[name] = value + args = list(args) + sig_args = list(sig_args) + while args: + while sig_args and sig_args[0] in values: + sig_args.pop(0) + if sig_args: + name = sig_args.pop(0) + values[name] = args.pop(0) + elif var_args: + values[var_args] = tuple(args) + break + else: + raise TypeError( + 'Extra position arguments: %s' + % ', '.join([repr(v) for v in args])) + for name, value_expr in defaults.items(): + if name not in values: + values[name] = self._template._eval( + value_expr, self._ns, self._pos) + for name in sig_args: + if name not in values: + raise TypeError( + 'Missing argument: %s' % name) + if var_kw: + values[var_kw] = extra_kw + return values + + +class TemplateObject(object): + + def __init__(self, name): + self.__name = name + self.get = TemplateObjectGetter(self) + + def __repr__(self): + return '<%s %s>' % (self.__class__.__name__, self.__name) + + +class TemplateObjectGetter(object): + + def __init__(self, template_obj): + self.__template_obj = template_obj + + def __getattr__(self, attr): + return getattr(self.__template_obj, attr, Empty) + + def __repr__(self): + return '<%s around %r>' % (self.__class__.__name__, self.__template_obj) + + +class _Empty(object): + def __call__(self, *args, **kw): + return self + + def __str__(self): + return '' + + def __repr__(self): + return 'Empty' + + def __unicode__(self): + return u'' + + def __iter__(self): + return iter(()) + + def __bool__(self): + return False + + if sys.version < "3": + __nonzero__ = __bool__ + +Empty = _Empty() +del _Empty + +############################################################ +## Lexing and Parsing +############################################################ + + +def lex(s, name=None, trim_whitespace=True, line_offset=0, delimeters=None): + """ + Lex a string into chunks: + + >>> lex('hey') + ['hey'] + >>> lex('hey {{you}}') + ['hey ', ('you', (1, 7))] + >>> lex('hey {{') + Traceback (most recent call last): + ... + TemplateError: No }} to finish last expression at line 1 column 7 + >>> lex('hey }}') + Traceback (most recent call last): + ... + TemplateError: }} outside expression at line 1 column 7 + >>> lex('hey {{ {{') + Traceback (most recent call last): + ... + TemplateError: {{ inside expression at line 1 column 10 + + """ + if delimeters is None: + delimeters = ( Template.default_namespace['start_braces'], + Template.default_namespace['end_braces'] ) + in_expr = False + chunks = [] + last = 0 + last_pos = (line_offset + 1, 1) + + token_re = re.compile(r'%s|%s' % (re.escape(delimeters[0]), + re.escape(delimeters[1]))) + for match in token_re.finditer(s): + expr = match.group(0) + pos = find_position(s, match.end(), last, last_pos) + if expr == delimeters[0] and in_expr: + raise TemplateError('%s inside expression' % delimeters[0], + position=pos, + name=name) + elif expr == delimeters[1] and not in_expr: + raise TemplateError('%s outside expression' % delimeters[1], + position=pos, + name=name) + if expr == delimeters[0]: + part = s[last:match.start()] + if part: + chunks.append(part) + in_expr = True + else: + chunks.append((s[last:match.start()], last_pos)) + in_expr = False + last = match.end() + last_pos = pos + if in_expr: + raise TemplateError('No %s to finish last expression' % delimeters[1], + name=name, position=last_pos) + part = s[last:] + if part: + chunks.append(part) + if trim_whitespace: + chunks = trim_lex(chunks) + return chunks + +statement_re = re.compile(r'^(?:if |elif |for |def |inherit |default |py:)') +single_statements = ['else', 'endif', 'endfor', 'enddef', 'continue', 'break'] +trail_whitespace_re = re.compile(r'\n\r?[\t ]*$') +lead_whitespace_re = re.compile(r'^[\t ]*\n') + + +def trim_lex(tokens): + r""" + Takes a lexed set of tokens, and removes whitespace when there is + a directive on a line by itself: + + >>> tokens = lex('{{if x}}\nx\n{{endif}}\ny', trim_whitespace=False) + >>> tokens + [('if x', (1, 3)), '\nx\n', ('endif', (3, 3)), '\ny'] + >>> trim_lex(tokens) + [('if x', (1, 3)), 'x\n', ('endif', (3, 3)), 'y'] + """ + last_trim = None + for i, current in enumerate(tokens): + if isinstance(current, basestring_): + # we don't trim this + continue + item = current[0] + if not statement_re.search(item) and item not in single_statements: + continue + if not i: + prev = '' + else: + prev = tokens[i - 1] + if i + 1 >= len(tokens): + next_chunk = '' + else: + next_chunk = tokens[i + 1] + if (not isinstance(next_chunk, basestring_) + or not isinstance(prev, basestring_)): + continue + prev_ok = not prev or trail_whitespace_re.search(prev) + if i == 1 and not prev.strip(): + prev_ok = True + if last_trim is not None and last_trim + 2 == i and not prev.strip(): + prev_ok = 'last' + if (prev_ok + and (not next_chunk or lead_whitespace_re.search(next_chunk) + or (i == len(tokens) - 2 and not next_chunk.strip()))): + if prev: + if ((i == 1 and not prev.strip()) + or prev_ok == 'last'): + tokens[i - 1] = '' + else: + m = trail_whitespace_re.search(prev) + # +1 to leave the leading \n on: + prev = prev[:m.start() + 1] + tokens[i - 1] = prev + if next_chunk: + last_trim = i + if i == len(tokens) - 2 and not next_chunk.strip(): + tokens[i + 1] = '' + else: + m = lead_whitespace_re.search(next_chunk) + next_chunk = next_chunk[m.end():] + tokens[i + 1] = next_chunk + return tokens + + +def find_position(string, index, last_index, last_pos): + """Given a string and index, return (line, column)""" + lines = string.count('\n', last_index, index) + if lines > 0: + column = index - string.rfind('\n', last_index, index) + else: + column = last_pos[1] + (index - last_index) + return (last_pos[0] + lines, column) + + +def parse(s, name=None, line_offset=0, delimeters=None): + r""" + Parses a string into a kind of AST + + >>> parse('{{x}}') + [('expr', (1, 3), 'x')] + >>> parse('foo') + ['foo'] + >>> parse('{{if x}}test{{endif}}') + [('cond', (1, 3), ('if', (1, 3), 'x', ['test']))] + >>> parse('series->{{for x in y}}x={{x}}{{endfor}}') + ['series->', ('for', (1, 11), ('x',), 'y', ['x=', ('expr', (1, 27), 'x')])] + >>> parse('{{for x, y in z:}}{{continue}}{{endfor}}') + [('for', (1, 3), ('x', 'y'), 'z', [('continue', (1, 21))])] + >>> parse('{{py:x=1}}') + [('py', (1, 3), 'x=1')] + >>> parse('{{if x}}a{{elif y}}b{{else}}c{{endif}}') + [('cond', (1, 3), ('if', (1, 3), 'x', ['a']), ('elif', (1, 12), 'y', ['b']), ('else', (1, 23), None, ['c']))] + + Some exceptions:: + + >>> parse('{{continue}}') + Traceback (most recent call last): + ... + TemplateError: continue outside of for loop at line 1 column 3 + >>> parse('{{if x}}foo') + Traceback (most recent call last): + ... + TemplateError: No {{endif}} at line 1 column 3 + >>> parse('{{else}}') + Traceback (most recent call last): + ... + TemplateError: else outside of an if block at line 1 column 3 + >>> parse('{{if x}}{{for x in y}}{{endif}}{{endfor}}') + Traceback (most recent call last): + ... + TemplateError: Unexpected endif at line 1 column 25 + >>> parse('{{if}}{{endif}}') + Traceback (most recent call last): + ... + TemplateError: if with no expression at line 1 column 3 + >>> parse('{{for x y}}{{endfor}}') + Traceback (most recent call last): + ... + TemplateError: Bad for (no "in") in 'x y' at line 1 column 3 + >>> parse('{{py:x=1\ny=2}}') + Traceback (most recent call last): + ... + TemplateError: Multi-line py blocks must start with a newline at line 1 column 3 + """ + if delimeters is None: + delimeters = ( Template.default_namespace['start_braces'], + Template.default_namespace['end_braces'] ) + tokens = lex(s, name=name, line_offset=line_offset, delimeters=delimeters) + result = [] + while tokens: + next_chunk, tokens = parse_expr(tokens, name) + result.append(next_chunk) + return result + + +def parse_expr(tokens, name, context=()): + if isinstance(tokens[0], basestring_): + return tokens[0], tokens[1:] + expr, pos = tokens[0] + expr = expr.strip() + if expr.startswith('py:'): + expr = expr[3:].lstrip(' \t') + if expr.startswith('\n') or expr.startswith('\r'): + expr = expr.lstrip('\r\n') + if '\r' in expr: + expr = expr.replace('\r\n', '\n') + expr = expr.replace('\r', '') + expr += '\n' + else: + if '\n' in expr: + raise TemplateError( + 'Multi-line py blocks must start with a newline', + position=pos, name=name) + return ('py', pos, expr), tokens[1:] + elif expr in ('continue', 'break'): + if 'for' not in context: + raise TemplateError( + 'continue outside of for loop', + position=pos, name=name) + return (expr, pos), tokens[1:] + elif expr.startswith('if '): + return parse_cond(tokens, name, context) + elif (expr.startswith('elif ') + or expr == 'else'): + raise TemplateError( + '%s outside of an if block' % expr.split()[0], + position=pos, name=name) + elif expr in ('if', 'elif', 'for'): + raise TemplateError( + '%s with no expression' % expr, + position=pos, name=name) + elif expr in ('endif', 'endfor', 'enddef'): + raise TemplateError( + 'Unexpected %s' % expr, + position=pos, name=name) + elif expr.startswith('for '): + return parse_for(tokens, name, context) + elif expr.startswith('default '): + return parse_default(tokens, name, context) + elif expr.startswith('inherit '): + return parse_inherit(tokens, name, context) + elif expr.startswith('def '): + return parse_def(tokens, name, context) + elif expr.startswith('#'): + return ('comment', pos, tokens[0][0]), tokens[1:] + return ('expr', pos, tokens[0][0]), tokens[1:] + + +def parse_cond(tokens, name, context): + start = tokens[0][1] + pieces = [] + context = context + ('if',) + while 1: + if not tokens: + raise TemplateError( + 'Missing {{endif}}', + position=start, name=name) + if (isinstance(tokens[0], tuple) + and tokens[0][0] == 'endif'): + return ('cond', start) + tuple(pieces), tokens[1:] + next_chunk, tokens = parse_one_cond(tokens, name, context) + pieces.append(next_chunk) + + +def parse_one_cond(tokens, name, context): + (first, pos), tokens = tokens[0], tokens[1:] + content = [] + if first.endswith(':'): + first = first[:-1] + if first.startswith('if '): + part = ('if', pos, first[3:].lstrip(), content) + elif first.startswith('elif '): + part = ('elif', pos, first[5:].lstrip(), content) + elif first == 'else': + part = ('else', pos, None, content) + else: + assert 0, "Unexpected token %r at %s" % (first, pos) + while 1: + if not tokens: + raise TemplateError( + 'No {{endif}}', + position=pos, name=name) + if (isinstance(tokens[0], tuple) + and (tokens[0][0] == 'endif' + or tokens[0][0].startswith('elif ') + or tokens[0][0] == 'else')): + return part, tokens + next_chunk, tokens = parse_expr(tokens, name, context) + content.append(next_chunk) + + +def parse_for(tokens, name, context): + first, pos = tokens[0] + tokens = tokens[1:] + context = ('for',) + context + content = [] + assert first.startswith('for ') + if first.endswith(':'): + first = first[:-1] + first = first[3:].strip() + match = in_re.search(first) + if not match: + raise TemplateError( + 'Bad for (no "in") in %r' % first, + position=pos, name=name) + vars = first[:match.start()] + if '(' in vars: + raise TemplateError( + 'You cannot have () in the variable section of a for loop (%r)' + % vars, position=pos, name=name) + vars = tuple([ + v.strip() for v in first[:match.start()].split(',') + if v.strip()]) + expr = first[match.end():] + while 1: + if not tokens: + raise TemplateError( + 'No {{endfor}}', + position=pos, name=name) + if (isinstance(tokens[0], tuple) + and tokens[0][0] == 'endfor'): + return ('for', pos, vars, expr, content), tokens[1:] + next_chunk, tokens = parse_expr(tokens, name, context) + content.append(next_chunk) + + +def parse_default(tokens, name, context): + first, pos = tokens[0] + assert first.startswith('default ') + first = first.split(None, 1)[1] + parts = first.split('=', 1) + if len(parts) == 1: + raise TemplateError( + "Expression must be {{default var=value}}; no = found in %r" % first, + position=pos, name=name) + var = parts[0].strip() + if ',' in var: + raise TemplateError( + "{{default x, y = ...}} is not supported", + position=pos, name=name) + if not var_re.search(var): + raise TemplateError( + "Not a valid variable name for {{default}}: %r" + % var, position=pos, name=name) + expr = parts[1].strip() + return ('default', pos, var, expr), tokens[1:] + + +def parse_inherit(tokens, name, context): + first, pos = tokens[0] + assert first.startswith('inherit ') + expr = first.split(None, 1)[1] + return ('inherit', pos, expr), tokens[1:] + + +def parse_def(tokens, name, context): + first, start = tokens[0] + tokens = tokens[1:] + assert first.startswith('def ') + first = first.split(None, 1)[1] + if first.endswith(':'): + first = first[:-1] + if '(' not in first: + func_name = first + sig = ((), None, None, {}) + elif not first.endswith(')'): + raise TemplateError("Function definition doesn't end with ): %s" % first, + position=start, name=name) + else: + first = first[:-1] + func_name, sig_text = first.split('(', 1) + sig = parse_signature(sig_text, name, start) + context = context + ('def',) + content = [] + while 1: + if not tokens: + raise TemplateError( + 'Missing {{enddef}}', + position=start, name=name) + if (isinstance(tokens[0], tuple) + and tokens[0][0] == 'enddef'): + return ('def', start, func_name, sig, content), tokens[1:] + next_chunk, tokens = parse_expr(tokens, name, context) + content.append(next_chunk) + + +def parse_signature(sig_text, name, pos): + tokens = tokenize.generate_tokens(StringIO(sig_text).readline) + sig_args = [] + var_arg = None + var_kw = None + defaults = {} + + def get_token(pos=False): + try: + tok_type, tok_string, (srow, scol), (erow, ecol), line = next(tokens) + except StopIteration: + return tokenize.ENDMARKER, '' + if pos: + return tok_type, tok_string, (srow, scol), (erow, ecol) + else: + return tok_type, tok_string + while 1: + var_arg_type = None + tok_type, tok_string = get_token() + if tok_type == tokenize.ENDMARKER: + break + if tok_type == tokenize.OP and (tok_string == '*' or tok_string == '**'): + var_arg_type = tok_string + tok_type, tok_string = get_token() + if tok_type != tokenize.NAME: + raise TemplateError('Invalid signature: (%s)' % sig_text, + position=pos, name=name) + var_name = tok_string + tok_type, tok_string = get_token() + if tok_type == tokenize.ENDMARKER or (tok_type == tokenize.OP and tok_string == ','): + if var_arg_type == '*': + var_arg = var_name + elif var_arg_type == '**': + var_kw = var_name + else: + sig_args.append(var_name) + if tok_type == tokenize.ENDMARKER: + break + continue + if var_arg_type is not None: + raise TemplateError('Invalid signature: (%s)' % sig_text, + position=pos, name=name) + if tok_type == tokenize.OP and tok_string == '=': + nest_type = None + unnest_type = None + nest_count = 0 + start_pos = end_pos = None + parts = [] + while 1: + tok_type, tok_string, s, e = get_token(True) + if start_pos is None: + start_pos = s + end_pos = e + if tok_type == tokenize.ENDMARKER and nest_count: + raise TemplateError('Invalid signature: (%s)' % sig_text, + position=pos, name=name) + if (not nest_count and + (tok_type == tokenize.ENDMARKER or (tok_type == tokenize.OP and tok_string == ','))): + default_expr = isolate_expression(sig_text, start_pos, end_pos) + defaults[var_name] = default_expr + sig_args.append(var_name) + break + parts.append((tok_type, tok_string)) + if nest_count and tok_type == tokenize.OP and tok_string == nest_type: + nest_count += 1 + elif nest_count and tok_type == tokenize.OP and tok_string == unnest_type: + nest_count -= 1 + if not nest_count: + nest_type = unnest_type = None + elif not nest_count and tok_type == tokenize.OP and tok_string in ('(', '[', '{'): + nest_type = tok_string + nest_count = 1 + unnest_type = {'(': ')', '[': ']', '{': '}'}[nest_type] + return sig_args, var_arg, var_kw, defaults + + +def isolate_expression(string, start_pos, end_pos): + srow, scol = start_pos + srow -= 1 + erow, ecol = end_pos + erow -= 1 + lines = string.splitlines(True) + if srow == erow: + return lines[srow][scol:ecol] + parts = [lines[srow][scol:]] + parts.extend(lines[srow+1:erow]) + if erow < len(lines): + # It'll sometimes give (end_row_past_finish, 0) + parts.append(lines[erow][:ecol]) + return ''.join(parts) + +_fill_command_usage = """\ +%prog [OPTIONS] TEMPLATE arg=value + +Use py:arg=value to set a Python value; otherwise all values are +strings. +""" + + +def fill_command(args=None): + import sys + import optparse + import pkg_resources + import os + if args is None: + args = sys.argv[1:] + dist = pkg_resources.get_distribution('Paste') + parser = optparse.OptionParser( + version=coerce_text(dist), + usage=_fill_command_usage) + parser.add_option( + '-o', '--output', + dest='output', + metavar="FILENAME", + help="File to write output to (default stdout)") + parser.add_option( + '--html', + dest='use_html', + action='store_true', + help="Use HTML style filling (including automatic HTML quoting)") + parser.add_option( + '--env', + dest='use_env', + action='store_true', + help="Put the environment in as top-level variables") + options, args = parser.parse_args(args) + if len(args) < 1: + print('You must give a template filename') + sys.exit(2) + template_name = args[0] + args = args[1:] + vars = {} + if options.use_env: + vars.update(os.environ) + for value in args: + if '=' not in value: + print('Bad argument: %r' % value) + sys.exit(2) + name, value = value.split('=', 1) + if name.startswith('py:'): + name = name[:3] + value = eval(value) + vars[name] = value + if template_name == '-': + template_content = sys.stdin.read() + template_name = '<stdin>' + else: + f = open(template_name, 'rb') + template_content = f.read() + f.close() + if options.use_html: + TemplateClass = HTMLTemplate + else: + TemplateClass = Template + template = TemplateClass(template_content, name=template_name) + result = template.substitute(vars) + if options.output: + f = open(options.output, 'wb') + f.write(result) + f.close() + else: + sys.stdout.write(result) + +if __name__ == '__main__': + fill_command() diff --git a/contrib/tools/cython/Cython/Tempita/compat3.py b/contrib/tools/cython/Cython/Tempita/compat3.py new file mode 100644 index 00000000000..9905530757a --- /dev/null +++ b/contrib/tools/cython/Cython/Tempita/compat3.py @@ -0,0 +1,47 @@ +import sys + +__all__ = ['b', 'basestring_', 'bytes', 'unicode_', 'next', 'is_unicode'] + +if sys.version < "3": + b = bytes = str + basestring_ = basestring + unicode_ = unicode +else: + + def b(s): + if isinstance(s, str): + return s.encode('latin1') + return bytes(s) + basestring_ = (bytes, str) + bytes = bytes + unicode_ = str +text = str + +if sys.version < "3": + + def next(obj): + return obj.next() +else: + next = next + +if sys.version < "3": + + def is_unicode(obj): + return isinstance(obj, unicode) +else: + + def is_unicode(obj): + return isinstance(obj, str) + + +def coerce_text(v): + if not isinstance(v, basestring_): + if sys.version < "3": + attr = '__unicode__' + else: + attr = '__str__' + if hasattr(v, attr): + return unicode(v) + else: + return bytes(v) + return v diff --git a/contrib/tools/cython/Cython/TestUtils.py b/contrib/tools/cython/Cython/TestUtils.py new file mode 100644 index 00000000000..9d6eb67fc3d --- /dev/null +++ b/contrib/tools/cython/Cython/TestUtils.py @@ -0,0 +1,217 @@ +from __future__ import absolute_import + +import os +import unittest +import tempfile + +from .Compiler import Errors +from .CodeWriter import CodeWriter +from .Compiler.TreeFragment import TreeFragment, strip_common_indent +from .Compiler.Visitor import TreeVisitor, VisitorTransform +from .Compiler import TreePath + + +class NodeTypeWriter(TreeVisitor): + def __init__(self): + super(NodeTypeWriter, self).__init__() + self._indents = 0 + self.result = [] + + def visit_Node(self, node): + if not self.access_path: + name = u"(root)" + else: + tip = self.access_path[-1] + if tip[2] is not None: + name = u"%s[%d]" % tip[1:3] + else: + name = tip[1] + + self.result.append(u" " * self._indents + + u"%s: %s" % (name, node.__class__.__name__)) + self._indents += 1 + self.visitchildren(node) + self._indents -= 1 + + +def treetypes(root): + """Returns a string representing the tree by class names. + There's a leading and trailing whitespace so that it can be + compared by simple string comparison while still making test + cases look ok.""" + w = NodeTypeWriter() + w.visit(root) + return u"\n".join([u""] + w.result + [u""]) + + +class CythonTest(unittest.TestCase): + + def setUp(self): + self.listing_file = Errors.listing_file + self.echo_file = Errors.echo_file + Errors.listing_file = Errors.echo_file = None + + def tearDown(self): + Errors.listing_file = self.listing_file + Errors.echo_file = self.echo_file + + def assertLines(self, expected, result): + "Checks that the given strings or lists of strings are equal line by line" + if not isinstance(expected, list): + expected = expected.split(u"\n") + if not isinstance(result, list): + result = result.split(u"\n") + for idx, (expected_line, result_line) in enumerate(zip(expected, result)): + self.assertEqual(expected_line, result_line, + "Line %d:\nExp: %s\nGot: %s" % (idx, expected_line, result_line)) + self.assertEqual(len(expected), len(result), + "Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(expected), u"\n".join(result))) + + def codeToLines(self, tree): + writer = CodeWriter() + writer.write(tree) + return writer.result.lines + + def codeToString(self, tree): + return "\n".join(self.codeToLines(tree)) + + def assertCode(self, expected, result_tree): + result_lines = self.codeToLines(result_tree) + + expected_lines = strip_common_indent(expected.split("\n")) + + for idx, (line, expected_line) in enumerate(zip(result_lines, expected_lines)): + self.assertEqual(expected_line, line, + "Line %d:\nGot: %s\nExp: %s" % (idx, line, expected_line)) + self.assertEqual(len(result_lines), len(expected_lines), + "Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(result_lines), expected)) + + def assertNodeExists(self, path, result_tree): + self.assertNotEqual(TreePath.find_first(result_tree, path), None, + "Path '%s' not found in result tree" % path) + + def fragment(self, code, pxds=None, pipeline=None): + "Simply create a tree fragment using the name of the test-case in parse errors." + if pxds is None: + pxds = {} + if pipeline is None: + pipeline = [] + name = self.id() + if name.startswith("__main__."): + name = name[len("__main__."):] + name = name.replace(".", "_") + return TreeFragment(code, name, pxds, pipeline=pipeline) + + def treetypes(self, root): + return treetypes(root) + + def should_fail(self, func, exc_type=Exception): + """Calls "func" and fails if it doesn't raise the right exception + (any exception by default). Also returns the exception in question. + """ + try: + func() + self.fail("Expected an exception of type %r" % exc_type) + except exc_type as e: + self.assertTrue(isinstance(e, exc_type)) + return e + + def should_not_fail(self, func): + """Calls func and succeeds if and only if no exception is raised + (i.e. converts exception raising into a failed testcase). Returns + the return value of func.""" + try: + return func() + except Exception as exc: + self.fail(str(exc)) + + +class TransformTest(CythonTest): + """ + Utility base class for transform unit tests. It is based around constructing + test trees (either explicitly or by parsing a Cython code string); running + the transform, serialize it using a customized Cython serializer (with + special markup for nodes that cannot be represented in Cython), + and do a string-comparison line-by-line of the result. + + To create a test case: + - Call run_pipeline. The pipeline should at least contain the transform you + are testing; pyx should be either a string (passed to the parser to + create a post-parse tree) or a node representing input to pipeline. + The result will be a transformed result. + + - Check that the tree is correct. If wanted, assertCode can be used, which + takes a code string as expected, and a ModuleNode in result_tree + (it serializes the ModuleNode to a string and compares line-by-line). + + All code strings are first stripped for whitespace lines and then common + indentation. + + Plans: One could have a pxd dictionary parameter to run_pipeline. + """ + + def run_pipeline(self, pipeline, pyx, pxds=None): + if pxds is None: + pxds = {} + tree = self.fragment(pyx, pxds).root + # Run pipeline + for T in pipeline: + tree = T(tree) + return tree + + +class TreeAssertVisitor(VisitorTransform): + # actually, a TreeVisitor would be enough, but this needs to run + # as part of the compiler pipeline + + def visit_CompilerDirectivesNode(self, node): + directives = node.directives + if 'test_assert_path_exists' in directives: + for path in directives['test_assert_path_exists']: + if TreePath.find_first(node, path) is None: + Errors.error( + node.pos, + "Expected path '%s' not found in result tree" % path) + if 'test_fail_if_path_exists' in directives: + for path in directives['test_fail_if_path_exists']: + if TreePath.find_first(node, path) is not None: + Errors.error( + node.pos, + "Unexpected path '%s' found in result tree" % path) + self.visitchildren(node) + return node + + visit_Node = VisitorTransform.recurse_to_children + + +def unpack_source_tree(tree_file, dir=None): + if dir is None: + dir = tempfile.mkdtemp() + header = [] + cur_file = None + f = open(tree_file) + try: + lines = f.readlines() + finally: + f.close() + del f + try: + for line in lines: + if line[:5] == '#####': + filename = line.strip().strip('#').strip().replace('/', os.path.sep) + path = os.path.join(dir, filename) + if not os.path.exists(os.path.dirname(path)): + os.makedirs(os.path.dirname(path)) + if cur_file is not None: + f, cur_file = cur_file, None + f.close() + cur_file = open(path, 'w') + elif cur_file is not None: + cur_file.write(line) + elif line.strip() and not line.lstrip().startswith('#'): + if line.strip() not in ('"""', "'''"): + header.append(line) + finally: + if cur_file is not None: + cur_file.close() + return dir, ''.join(header) diff --git a/contrib/tools/cython/Cython/Tests/TestCodeWriter.py b/contrib/tools/cython/Cython/Tests/TestCodeWriter.py new file mode 100644 index 00000000000..42e457da20e --- /dev/null +++ b/contrib/tools/cython/Cython/Tests/TestCodeWriter.py @@ -0,0 +1,82 @@ +from Cython.TestUtils import CythonTest + +class TestCodeWriter(CythonTest): + # CythonTest uses the CodeWriter heavily, so do some checking by + # roundtripping Cython code through the test framework. + + # Note that this test is dependent upon the normal Cython parser + # to generate the input trees to the CodeWriter. This save *a lot* + # of time; better to spend that time writing other tests than perfecting + # this one... + + # Whitespace is very significant in this process: + # - always newline on new block (!) + # - indent 4 spaces + # - 1 space around every operator + + def t(self, codestr): + self.assertCode(codestr, self.fragment(codestr).root) + + def test_print(self): + self.t(u""" + print x, y + print x + y ** 2 + print x, y, z, + """) + + def test_if(self): + self.t(u"if x:\n pass") + + def test_ifelifelse(self): + self.t(u""" + if x: + pass + elif y: + pass + elif z + 34 ** 34 - 2: + pass + else: + pass + """) + + def test_def(self): + self.t(u""" + def f(x, y, z): + pass + def f(x = 34, y = 54, z): + pass + """) + + def test_longness_and_signedness(self): + self.t(u"def f(unsigned long long long long long int y):\n pass") + + def test_signed_short(self): + self.t(u"def f(signed short int y):\n pass") + + def test_typed_args(self): + self.t(u"def f(int x, unsigned long int y):\n pass") + + def test_cdef_var(self): + self.t(u""" + cdef int hello + cdef int hello = 4, x = 3, y, z + """) + + def test_for_loop(self): + self.t(u""" + for x, y, z in f(g(h(34) * 2) + 23): + print x, y, z + else: + print 43 + """) + + def test_inplace_assignment(self): + self.t(u"x += 43") + + def test_attribute(self): + self.t(u"a.x") + +if __name__ == "__main__": + import unittest + unittest.main() + diff --git a/contrib/tools/cython/Cython/Tests/TestCythonUtils.py b/contrib/tools/cython/Cython/Tests/TestCythonUtils.py new file mode 100644 index 00000000000..2641900c012 --- /dev/null +++ b/contrib/tools/cython/Cython/Tests/TestCythonUtils.py @@ -0,0 +1,11 @@ +import unittest + +from ..Utils import build_hex_version + +class TestCythonUtils(unittest.TestCase): + def test_build_hex_version(self): + self.assertEqual('0x001D00A1', build_hex_version('0.29a1')) + self.assertEqual('0x001D00A1', build_hex_version('0.29a1')) + self.assertEqual('0x001D03C4', build_hex_version('0.29.3rc4')) + self.assertEqual('0x001D00F0', build_hex_version('0.29')) + self.assertEqual('0x040000F0', build_hex_version('4.0')) diff --git a/contrib/tools/cython/Cython/Tests/TestJediTyper.py b/contrib/tools/cython/Cython/Tests/TestJediTyper.py new file mode 100644 index 00000000000..253adef1715 --- /dev/null +++ b/contrib/tools/cython/Cython/Tests/TestJediTyper.py @@ -0,0 +1,225 @@ +# -*- coding: utf-8 -*- +# tag: jedi + +from __future__ import absolute_import + +import sys +import os.path + +from textwrap import dedent +from contextlib import contextmanager +from tempfile import NamedTemporaryFile + +from Cython.Compiler.ParseTreeTransforms import NormalizeTree, InterpretCompilerDirectives +from Cython.Compiler import Main, Symtab, Visitor +from Cython.TestUtils import TransformTest + +TOOLS_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'Tools')) + + +@contextmanager +def _tempfile(code): + code = dedent(code) + if not isinstance(code, bytes): + code = code.encode('utf8') + + with NamedTemporaryFile(suffix='.py') as f: + f.write(code) + f.seek(0) + yield f + + +def _test_typing(code, inject=False): + sys.path.insert(0, TOOLS_DIR) + try: + import jedityper + finally: + sys.path.remove(TOOLS_DIR) + lines = [] + with _tempfile(code) as f: + types = jedityper.analyse(f.name) + if inject: + lines = jedityper.inject_types(f.name, types) + return types, lines + + +class DeclarationsFinder(Visitor.VisitorTransform): + directives = None + + visit_Node = Visitor.VisitorTransform.recurse_to_children + + def visit_CompilerDirectivesNode(self, node): + if not self.directives: + self.directives = [] + self.directives.append(node) + self.visitchildren(node) + return node + + +class TestJediTyper(TransformTest): + def _test(self, code): + return _test_typing(code)[0] + + def test_typing_global_int_loop(self): + code = '''\ + for i in range(10): + a = i + 1 + ''' + types = self._test(code) + self.assertIn((None, (1, 0)), types) + variables = types.pop((None, (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['int']), 'i': set(['int'])}, variables) + + def test_typing_function_int_loop(self): + code = '''\ + def func(x): + for i in range(x): + a = i + 1 + return a + ''' + types = self._test(code) + self.assertIn(('func', (1, 0)), types) + variables = types.pop(('func', (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['int']), 'i': set(['int'])}, variables) + + def test_conflicting_types_in_function(self): + code = '''\ + def func(a, b): + print(a) + a = 1 + b += a + a = 'abc' + return a, str(b) + + print(func(1.5, 2)) + ''' + types = self._test(code) + self.assertIn(('func', (1, 0)), types) + variables = types.pop(('func', (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['float', 'int', 'str']), 'b': set(['int'])}, variables) + + def _test_typing_function_char_loop(self): + code = '''\ + def func(x): + l = [] + for c in x: + l.append(c) + return l + + print(func('abcdefg')) + ''' + types = self._test(code) + self.assertIn(('func', (1, 0)), types) + variables = types.pop(('func', (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['int']), 'i': set(['int'])}, variables) + + def test_typing_global_list(self): + code = '''\ + a = [x for x in range(10)] + b = list(range(10)) + c = a + b + d = [0]*10 + ''' + types = self._test(code) + self.assertIn((None, (1, 0)), types) + variables = types.pop((None, (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['list']), 'b': set(['list']), 'c': set(['list']), 'd': set(['list'])}, variables) + + def test_typing_function_list(self): + code = '''\ + def func(x): + a = [[], []] + b = [0]* 10 + a + c = a[0] + + print(func([0]*100)) + ''' + types = self._test(code) + self.assertIn(('func', (1, 0)), types) + variables = types.pop(('func', (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['list']), 'b': set(['list']), 'c': set(['list']), 'x': set(['list'])}, variables) + + def test_typing_global_dict(self): + code = '''\ + a = dict() + b = {i: i**2 for i in range(10)} + c = a + ''' + types = self._test(code) + self.assertIn((None, (1, 0)), types) + variables = types.pop((None, (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['dict']), 'b': set(['dict']), 'c': set(['dict'])}, variables) + + def test_typing_function_dict(self): + code = '''\ + def func(x): + a = dict() + b = {i: i**2 for i in range(10)} + c = x + + print(func({1:2, 'x':7})) + ''' + types = self._test(code) + self.assertIn(('func', (1, 0)), types) + variables = types.pop(('func', (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['dict']), 'b': set(['dict']), 'c': set(['dict']), 'x': set(['dict'])}, variables) + + + def test_typing_global_set(self): + code = '''\ + a = set() + # b = {i for i in range(10)} # jedi does not support set comprehension yet + c = a + d = {1,2,3} + e = a | b + ''' + types = self._test(code) + self.assertIn((None, (1, 0)), types) + variables = types.pop((None, (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['set']), 'c': set(['set']), 'd': set(['set']), 'e': set(['set'])}, variables) + + def test_typing_function_set(self): + code = '''\ + def func(x): + a = set() + # b = {i for i in range(10)} # jedi does not support set comprehension yet + c = a + d = a | b + + print(func({1,2,3})) + ''' + types = self._test(code) + self.assertIn(('func', (1, 0)), types) + variables = types.pop(('func', (1, 0))) + self.assertFalse(types) + self.assertEqual({'a': set(['set']), 'c': set(['set']), 'd': set(['set']), 'x': set(['set'])}, variables) + + +class TestTypeInjection(TestJediTyper): + """ + Subtype of TestJediTyper that additionally tests type injection and compilation. + """ + def setUp(self): + super(TestTypeInjection, self).setUp() + compilation_options = Main.CompilationOptions(Main.default_options) + ctx = compilation_options.create_context() + transform = InterpretCompilerDirectives(ctx, ctx.compiler_directives) + transform.module_scope = Symtab.ModuleScope('__main__', None, ctx) + self.declarations_finder = DeclarationsFinder() + self.pipeline = [NormalizeTree(None), transform, self.declarations_finder] + + def _test(self, code): + types, lines = _test_typing(code, inject=True) + tree = self.run_pipeline(self.pipeline, ''.join(lines)) + directives = self.declarations_finder.directives + # TODO: validate directives + return types diff --git a/contrib/tools/cython/Cython/Tests/TestStringIOTree.py b/contrib/tools/cython/Cython/Tests/TestStringIOTree.py new file mode 100644 index 00000000000..a15f2cd88d7 --- /dev/null +++ b/contrib/tools/cython/Cython/Tests/TestStringIOTree.py @@ -0,0 +1,67 @@ +import unittest + +from Cython import StringIOTree as stringtree + +code = """ +cdef int spam # line 1 + +cdef ham(): + a = 1 + b = 2 + c = 3 + d = 4 + +def eggs(): + pass + +cpdef bacon(): + print spam + print 'scotch' + print 'tea?' + print 'or coffee?' # line 16 +""" + +linemap = dict(enumerate(code.splitlines())) + +class TestStringIOTree(unittest.TestCase): + + def setUp(self): + self.tree = stringtree.StringIOTree() + + def test_markers(self): + assert not self.tree.allmarkers() + + def test_insertion(self): + self.write_lines((1, 2, 3)) + line_4_to_6_insertion_point = self.tree.insertion_point() + self.write_lines((7, 8)) + line_9_to_13_insertion_point = self.tree.insertion_point() + self.write_lines((14, 15, 16)) + + line_4_insertion_point = line_4_to_6_insertion_point.insertion_point() + self.write_lines((5, 6), tree=line_4_to_6_insertion_point) + + line_9_to_12_insertion_point = ( + line_9_to_13_insertion_point.insertion_point()) + self.write_line(13, tree=line_9_to_13_insertion_point) + + self.write_line(4, tree=line_4_insertion_point) + self.write_line(9, tree=line_9_to_12_insertion_point) + line_10_insertion_point = line_9_to_12_insertion_point.insertion_point() + self.write_line(11, tree=line_9_to_12_insertion_point) + self.write_line(10, tree=line_10_insertion_point) + self.write_line(12, tree=line_9_to_12_insertion_point) + + self.assertEqual(self.tree.allmarkers(), list(range(1, 17))) + self.assertEqual(code.strip(), self.tree.getvalue().strip()) + + + def write_lines(self, linenos, tree=None): + for lineno in linenos: + self.write_line(lineno, tree=tree) + + def write_line(self, lineno, tree=None): + if tree is None: + tree = self.tree + tree.markers.append(lineno) + tree.write(linemap[lineno] + '\n') diff --git a/contrib/tools/cython/Cython/Tests/__init__.py b/contrib/tools/cython/Cython/Tests/__init__.py new file mode 100644 index 00000000000..fa81adaff68 --- /dev/null +++ b/contrib/tools/cython/Cython/Tests/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/contrib/tools/cython/Cython/Tests/xmlrunner.py b/contrib/tools/cython/Cython/Tests/xmlrunner.py new file mode 100644 index 00000000000..d6838aa22ec --- /dev/null +++ b/contrib/tools/cython/Cython/Tests/xmlrunner.py @@ -0,0 +1,397 @@ +# -*- coding: utf-8 -*- + +"""unittest-xml-reporting is a PyUnit-based TestRunner that can export test +results to XML files that can be consumed by a wide range of tools, such as +build systems, IDEs and Continuous Integration servers. + +This module provides the XMLTestRunner class, which is heavily based on the +default TextTestRunner. This makes the XMLTestRunner very simple to use. + +The script below, adapted from the unittest documentation, shows how to use +XMLTestRunner in a very simple way. In fact, the only difference between this +script and the original one is the last line: + +import random +import unittest +import xmlrunner + +class TestSequenceFunctions(unittest.TestCase): + def setUp(self): + self.seq = range(10) + + def test_shuffle(self): + # make sure the shuffled sequence does not lose any elements + random.shuffle(self.seq) + self.seq.sort() + self.assertEqual(self.seq, range(10)) + + def test_choice(self): + element = random.choice(self.seq) + self.assertTrue(element in self.seq) + + def test_sample(self): + self.assertRaises(ValueError, random.sample, self.seq, 20) + for element in random.sample(self.seq, 5): + self.assertTrue(element in self.seq) + +if __name__ == '__main__': + unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports')) +""" + +from __future__ import absolute_import + +import os +import sys +import time +from unittest import TestResult, TextTestResult, TextTestRunner +import xml.dom.minidom +try: + from StringIO import StringIO +except ImportError: + from io import StringIO # doesn't accept 'str' in Py2 + + +class XMLDocument(xml.dom.minidom.Document): + def createCDATAOrText(self, data): + if ']]>' in data: + return self.createTextNode(data) + return self.createCDATASection(data) + + +class _TestInfo(object): + """This class is used to keep useful information about the execution of a + test method. + """ + + # Possible test outcomes + (SUCCESS, FAILURE, ERROR) = range(3) + + def __init__(self, test_result, test_method, outcome=SUCCESS, err=None): + "Create a new instance of _TestInfo." + self.test_result = test_result + self.test_method = test_method + self.outcome = outcome + self.err = err + self.stdout = test_result.stdout and test_result.stdout.getvalue().strip() or '' + self.stderr = test_result.stdout and test_result.stderr.getvalue().strip() or '' + + def get_elapsed_time(self): + """Return the time that shows how long the test method took to + execute. + """ + return self.test_result.stop_time - self.test_result.start_time + + def get_description(self): + "Return a text representation of the test method." + return self.test_result.getDescription(self.test_method) + + def get_error_info(self): + """Return a text representation of an exception thrown by a test + method. + """ + if not self.err: + return '' + return self.test_result._exc_info_to_string( + self.err, self.test_method) + + +class _XMLTestResult(TextTestResult): + """A test result class that can express test results in a XML report. + + Used by XMLTestRunner. + """ + def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1, + elapsed_times=True): + "Create a new instance of _XMLTestResult." + TextTestResult.__init__(self, stream, descriptions, verbosity) + self.successes = [] + self.callback = None + self.elapsed_times = elapsed_times + self.output_patched = False + + def _prepare_callback(self, test_info, target_list, verbose_str, + short_str): + """Append a _TestInfo to the given target list and sets a callback + method to be called by stopTest method. + """ + target_list.append(test_info) + def callback(): + """This callback prints the test method outcome to the stream, + as well as the elapsed time. + """ + + # Ignore the elapsed times for a more reliable unit testing + if not self.elapsed_times: + self.start_time = self.stop_time = 0 + + if self.showAll: + self.stream.writeln('(%.3fs) %s' % \ + (test_info.get_elapsed_time(), verbose_str)) + elif self.dots: + self.stream.write(short_str) + self.callback = callback + + def _patch_standard_output(self): + """Replace the stdout and stderr streams with string-based streams + in order to capture the tests' output. + """ + if not self.output_patched: + (self.old_stdout, self.old_stderr) = (sys.stdout, sys.stderr) + self.output_patched = True + (sys.stdout, sys.stderr) = (self.stdout, self.stderr) = \ + (StringIO(), StringIO()) + + def _restore_standard_output(self): + "Restore the stdout and stderr streams." + (sys.stdout, sys.stderr) = (self.old_stdout, self.old_stderr) + self.output_patched = False + + def startTest(self, test): + "Called before execute each test method." + self._patch_standard_output() + self.start_time = time.time() + TestResult.startTest(self, test) + + if self.showAll: + self.stream.write(' ' + self.getDescription(test)) + self.stream.write(" ... ") + + def stopTest(self, test): + "Called after execute each test method." + self._restore_standard_output() + TextTestResult.stopTest(self, test) + self.stop_time = time.time() + + if self.callback and callable(self.callback): + self.callback() + self.callback = None + + def addSuccess(self, test): + "Called when a test executes successfully." + self._prepare_callback(_TestInfo(self, test), + self.successes, 'OK', '.') + + def addFailure(self, test, err): + "Called when a test method fails." + self._prepare_callback(_TestInfo(self, test, _TestInfo.FAILURE, err), + self.failures, 'FAIL', 'F') + + def addError(self, test, err): + "Called when a test method raises an error." + self._prepare_callback(_TestInfo(self, test, _TestInfo.ERROR, err), + self.errors, 'ERROR', 'E') + + def printErrorList(self, flavour, errors): + "Write some information about the FAIL or ERROR to the stream." + for test_info in errors: + if isinstance(test_info, tuple): + test_info, exc_info = test_info + + try: + t = test_info.get_elapsed_time() + except AttributeError: + t = 0 + try: + descr = test_info.get_description() + except AttributeError: + try: + descr = test_info.getDescription() + except AttributeError: + descr = str(test_info) + try: + err_info = test_info.get_error_info() + except AttributeError: + err_info = str(test_info) + + self.stream.writeln(self.separator1) + self.stream.writeln('%s [%.3fs]: %s' % (flavour, t, descr)) + self.stream.writeln(self.separator2) + self.stream.writeln('%s' % err_info) + + def _get_info_by_testcase(self): + """This method organizes test results by TestCase module. This + information is used during the report generation, where a XML report + will be generated for each TestCase. + """ + tests_by_testcase = {} + + for tests in (self.successes, self.failures, self.errors): + for test_info in tests: + if not isinstance(test_info, _TestInfo): + print("Unexpected test result type: %r" % (test_info,)) + continue + testcase = type(test_info.test_method) + + # Ignore module name if it is '__main__' + module = testcase.__module__ + '.' + if module == '__main__.': + module = '' + testcase_name = module + testcase.__name__ + + if testcase_name not in tests_by_testcase: + tests_by_testcase[testcase_name] = [] + tests_by_testcase[testcase_name].append(test_info) + + return tests_by_testcase + + def _report_testsuite(suite_name, tests, xml_document): + "Appends the testsuite section to the XML document." + testsuite = xml_document.createElement('testsuite') + xml_document.appendChild(testsuite) + + testsuite.setAttribute('name', str(suite_name)) + testsuite.setAttribute('tests', str(len(tests))) + + testsuite.setAttribute('time', '%.3f' % + sum([e.get_elapsed_time() for e in tests])) + + failures = len([1 for e in tests if e.outcome == _TestInfo.FAILURE]) + testsuite.setAttribute('failures', str(failures)) + + errors = len([1 for e in tests if e.outcome == _TestInfo.ERROR]) + testsuite.setAttribute('errors', str(errors)) + + return testsuite + + _report_testsuite = staticmethod(_report_testsuite) + + def _report_testcase(suite_name, test_result, xml_testsuite, xml_document): + "Appends a testcase section to the XML document." + testcase = xml_document.createElement('testcase') + xml_testsuite.appendChild(testcase) + + testcase.setAttribute('classname', str(suite_name)) + testcase.setAttribute('name', test_result.test_method.shortDescription() + or getattr(test_result.test_method, '_testMethodName', + str(test_result.test_method))) + testcase.setAttribute('time', '%.3f' % test_result.get_elapsed_time()) + + if (test_result.outcome != _TestInfo.SUCCESS): + elem_name = ('failure', 'error')[test_result.outcome-1] + failure = xml_document.createElement(elem_name) + testcase.appendChild(failure) + + failure.setAttribute('type', str(test_result.err[0].__name__)) + failure.setAttribute('message', str(test_result.err[1])) + + error_info = test_result.get_error_info() + failureText = xml_document.createCDATAOrText(error_info) + failure.appendChild(failureText) + + _report_testcase = staticmethod(_report_testcase) + + def _report_output(test_runner, xml_testsuite, xml_document, stdout, stderr): + "Appends the system-out and system-err sections to the XML document." + systemout = xml_document.createElement('system-out') + xml_testsuite.appendChild(systemout) + + systemout_text = xml_document.createCDATAOrText(stdout) + systemout.appendChild(systemout_text) + + systemerr = xml_document.createElement('system-err') + xml_testsuite.appendChild(systemerr) + + systemerr_text = xml_document.createCDATAOrText(stderr) + systemerr.appendChild(systemerr_text) + + _report_output = staticmethod(_report_output) + + def generate_reports(self, test_runner): + "Generates the XML reports to a given XMLTestRunner object." + all_results = self._get_info_by_testcase() + + if type(test_runner.output) == str and not \ + os.path.exists(test_runner.output): + os.makedirs(test_runner.output) + + for suite, tests in all_results.items(): + doc = XMLDocument() + + # Build the XML file + testsuite = _XMLTestResult._report_testsuite(suite, tests, doc) + stdout, stderr = [], [] + for test in tests: + _XMLTestResult._report_testcase(suite, test, testsuite, doc) + if test.stdout: + stdout.extend(['*****************', test.get_description(), test.stdout]) + if test.stderr: + stderr.extend(['*****************', test.get_description(), test.stderr]) + _XMLTestResult._report_output(test_runner, testsuite, doc, + '\n'.join(stdout), '\n'.join(stderr)) + xml_content = doc.toprettyxml(indent='\t') + + if type(test_runner.output) is str: + report_file = open('%s%sTEST-%s.xml' % \ + (test_runner.output, os.sep, suite), 'w') + try: + report_file.write(xml_content) + finally: + report_file.close() + else: + # Assume that test_runner.output is a stream + test_runner.output.write(xml_content) + + +class XMLTestRunner(TextTestRunner): + """A test runner class that outputs the results in JUnit like XML files. + """ + def __init__(self, output='.', stream=None, descriptions=True, verbose=False, elapsed_times=True): + "Create a new instance of XMLTestRunner." + if stream is None: + stream = sys.stderr + verbosity = (1, 2)[verbose] + TextTestRunner.__init__(self, stream, descriptions, verbosity) + self.output = output + self.elapsed_times = elapsed_times + + def _make_result(self): + """Create the TestResult object which will be used to store + information about the executed tests. + """ + return _XMLTestResult(self.stream, self.descriptions, \ + self.verbosity, self.elapsed_times) + + def run(self, test): + "Run the given test case or test suite." + # Prepare the test execution + result = self._make_result() + + # Print a nice header + self.stream.writeln() + self.stream.writeln('Running tests...') + self.stream.writeln(result.separator2) + + # Execute tests + start_time = time.time() + test(result) + stop_time = time.time() + time_taken = stop_time - start_time + + # Generate reports + self.stream.writeln() + self.stream.writeln('Generating XML reports...') + result.generate_reports(self) + + # Print results + result.printErrors() + self.stream.writeln(result.separator2) + run = result.testsRun + self.stream.writeln("Ran %d test%s in %.3fs" % + (run, run != 1 and "s" or "", time_taken)) + self.stream.writeln() + + # Error traces + if not result.wasSuccessful(): + self.stream.write("FAILED (") + failed, errored = (len(result.failures), len(result.errors)) + if failed: + self.stream.write("failures=%d" % failed) + if errored: + if failed: + self.stream.write(", ") + self.stream.write("errors=%d" % errored) + self.stream.writeln(")") + else: + self.stream.writeln("OK") + + return result diff --git a/contrib/tools/cython/Cython/Utility/AsyncGen.c b/contrib/tools/cython/Cython/Utility/AsyncGen.c new file mode 100644 index 00000000000..9a11d6a129c --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/AsyncGen.c @@ -0,0 +1,1133 @@ +// This is copied from genobject.c in CPython 3.6. +// Try to keep it in sync by doing this from time to time: +// sed -e 's|__pyx_||ig' Cython/Utility/AsyncGen.c | diff -udw - cpython/Objects/genobject.c | less + +//////////////////// AsyncGenerator.proto //////////////////// +//@requires: Coroutine.c::Coroutine + +#define __Pyx_AsyncGen_USED +typedef struct { + __pyx_CoroutineObject coro; + PyObject *ag_finalizer; + int ag_hooks_inited; + int ag_closed; +} __pyx_PyAsyncGenObject; + +static PyTypeObject *__pyx__PyAsyncGenWrappedValueType = 0; +static PyTypeObject *__pyx__PyAsyncGenASendType = 0; +static PyTypeObject *__pyx__PyAsyncGenAThrowType = 0; +static PyTypeObject *__pyx_AsyncGenType = 0; + +#define __Pyx_AsyncGen_CheckExact(obj) (Py_TYPE(obj) == __pyx_AsyncGenType) +#define __pyx_PyAsyncGenASend_CheckExact(o) \ + (Py_TYPE(o) == __pyx__PyAsyncGenASendType) +#define __pyx_PyAsyncGenAThrow_CheckExact(o) \ + (Py_TYPE(o) == __pyx__PyAsyncGenAThrowType) + +static PyObject *__Pyx_async_gen_anext(PyObject *o); +static CYTHON_INLINE PyObject *__Pyx_async_gen_asend_iternext(PyObject *o); +static PyObject *__Pyx_async_gen_asend_send(PyObject *o, PyObject *arg); +static PyObject *__Pyx_async_gen_asend_close(PyObject *o, PyObject *args); +static PyObject *__Pyx_async_gen_athrow_close(PyObject *o, PyObject *args); + +static PyObject *__Pyx__PyAsyncGenValueWrapperNew(PyObject *val); + + +static __pyx_CoroutineObject *__Pyx_AsyncGen_New( + __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + __pyx_PyAsyncGenObject *gen = PyObject_GC_New(__pyx_PyAsyncGenObject, __pyx_AsyncGenType); + if (unlikely(!gen)) + return NULL; + gen->ag_finalizer = NULL; + gen->ag_closed = 0; + gen->ag_hooks_inited = 0; + return __Pyx__Coroutine_NewInit((__pyx_CoroutineObject*)gen, body, code, closure, name, qualname, module_name); +} + +static int __pyx_AsyncGen_init(void); +static void __Pyx_PyAsyncGen_Fini(void); + +//////////////////// AsyncGenerator.cleanup //////////////////// + +__Pyx_PyAsyncGen_Fini(); + +//////////////////// AsyncGeneratorInitFinalizer //////////////////// + +// this is separated out because it needs more adaptation + +#if PY_VERSION_HEX < 0x030600B0 +static int __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o) { +#if 0 + // TODO: implement finalizer support in older Python versions + PyThreadState *tstate; + PyObject *finalizer; + PyObject *firstiter; +#endif + + if (likely(o->ag_hooks_inited)) { + return 0; + } + + o->ag_hooks_inited = 1; + +#if 0 + tstate = __Pyx_PyThreadState_Current; + + finalizer = tstate->async_gen_finalizer; + if (finalizer) { + Py_INCREF(finalizer); + o->ag_finalizer = finalizer; + } + + firstiter = tstate->async_gen_firstiter; + if (firstiter) { + PyObject *res; + + Py_INCREF(firstiter); + res = __Pyx_PyObject_CallOneArg(firstiter, (PyObject*)o); + Py_DECREF(firstiter); + if (res == NULL) { + return 1; + } + Py_DECREF(res); + } +#endif + + return 0; +} +#endif + + +//////////////////// AsyncGenerator //////////////////// +//@requires: AsyncGeneratorInitFinalizer +//@requires: Coroutine.c::Coroutine +//@requires: Coroutine.c::ReturnWithStopIteration +//@requires: ObjectHandling.c::PyObjectCall2Args +//@requires: ObjectHandling.c::PyObject_GenericGetAttrNoDict + +PyDoc_STRVAR(__Pyx_async_gen_send_doc, +"send(arg) -> send 'arg' into generator,\n\ +return next yielded value or raise StopIteration."); + +PyDoc_STRVAR(__Pyx_async_gen_close_doc, +"close() -> raise GeneratorExit inside generator."); + +PyDoc_STRVAR(__Pyx_async_gen_throw_doc, +"throw(typ[,val[,tb]]) -> raise exception in generator,\n\ +return next yielded value or raise StopIteration."); + +PyDoc_STRVAR(__Pyx_async_gen_await_doc, +"__await__() -> return a representation that can be passed into the 'await' expression."); + +// COPY STARTS HERE: + +static PyObject *__Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *, PyObject *); +static PyObject *__Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *, PyObject *); + +static const char *__Pyx_NON_INIT_CORO_MSG = "can't send non-None value to a just-started coroutine"; +static const char *__Pyx_ASYNC_GEN_IGNORED_EXIT_MSG = "async generator ignored GeneratorExit"; + +typedef enum { + __PYX_AWAITABLE_STATE_INIT, /* new awaitable, has not yet been iterated */ + __PYX_AWAITABLE_STATE_ITER, /* being iterated */ + __PYX_AWAITABLE_STATE_CLOSED, /* closed */ +} __pyx_AwaitableState; + +typedef struct { + PyObject_HEAD + __pyx_PyAsyncGenObject *ags_gen; + + /* Can be NULL, when in the __anext__() mode (equivalent of "asend(None)") */ + PyObject *ags_sendval; + + __pyx_AwaitableState ags_state; +} __pyx_PyAsyncGenASend; + + +typedef struct { + PyObject_HEAD + __pyx_PyAsyncGenObject *agt_gen; + + /* Can be NULL, when in the "aclose()" mode (equivalent of "athrow(GeneratorExit)") */ + PyObject *agt_args; + + __pyx_AwaitableState agt_state; +} __pyx_PyAsyncGenAThrow; + + +typedef struct { + PyObject_HEAD + PyObject *agw_val; +} __pyx__PyAsyncGenWrappedValue; + + +#ifndef _PyAsyncGen_MAXFREELIST +#define _PyAsyncGen_MAXFREELIST 80 +#endif + +// Freelists boost performance 6-10%; they also reduce memory +// fragmentation, as _PyAsyncGenWrappedValue and PyAsyncGenASend +// are short-living objects that are instantiated for every +// __anext__ call. + +static __pyx__PyAsyncGenWrappedValue *__Pyx_ag_value_freelist[_PyAsyncGen_MAXFREELIST]; +static int __Pyx_ag_value_freelist_free = 0; + +static __pyx_PyAsyncGenASend *__Pyx_ag_asend_freelist[_PyAsyncGen_MAXFREELIST]; +static int __Pyx_ag_asend_freelist_free = 0; + +#define __pyx__PyAsyncGenWrappedValue_CheckExact(o) \ + (Py_TYPE(o) == __pyx__PyAsyncGenWrappedValueType) + + +static int +__Pyx_async_gen_traverse(__pyx_PyAsyncGenObject *gen, visitproc visit, void *arg) +{ + Py_VISIT(gen->ag_finalizer); + return __Pyx_Coroutine_traverse((__pyx_CoroutineObject*)gen, visit, arg); +} + + +static PyObject * +__Pyx_async_gen_repr(__pyx_CoroutineObject *o) +{ + // avoid NULL pointer dereference for qualname during garbage collection + return PyUnicode_FromFormat("<async_generator object %S at %p>", + o->gi_qualname ? o->gi_qualname : Py_None, o); +} + + +#if PY_VERSION_HEX >= 0x030600B0 +static int +__Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o) +{ + PyThreadState *tstate; + PyObject *finalizer; + PyObject *firstiter; + + if (o->ag_hooks_inited) { + return 0; + } + + o->ag_hooks_inited = 1; + + tstate = __Pyx_PyThreadState_Current; + + finalizer = tstate->async_gen_finalizer; + if (finalizer) { + Py_INCREF(finalizer); + o->ag_finalizer = finalizer; + } + + firstiter = tstate->async_gen_firstiter; + if (firstiter) { + PyObject *res; +#if CYTHON_UNPACK_METHODS + PyObject *self; +#endif + + Py_INCREF(firstiter); + // at least asyncio stores methods here => optimise the call +#if CYTHON_UNPACK_METHODS + if (likely(PyMethod_Check(firstiter)) && likely((self = PyMethod_GET_SELF(firstiter)) != NULL)) { + PyObject *function = PyMethod_GET_FUNCTION(firstiter); + res = __Pyx_PyObject_Call2Args(function, self, (PyObject*)o); + } else +#endif + res = __Pyx_PyObject_CallOneArg(firstiter, (PyObject*)o); + + Py_DECREF(firstiter); + if (unlikely(res == NULL)) { + return 1; + } + Py_DECREF(res); + } + + return 0; +} +#endif + + +static PyObject * +__Pyx_async_gen_anext(PyObject *g) +{ + __pyx_PyAsyncGenObject *o = (__pyx_PyAsyncGenObject*) g; + if (__Pyx_async_gen_init_hooks(o)) { + return NULL; + } + return __Pyx_async_gen_asend_new(o, NULL); +} + +static PyObject * +__Pyx_async_gen_anext_method(PyObject *g, CYTHON_UNUSED PyObject *arg) { + return __Pyx_async_gen_anext(g); +} + + +static PyObject * +__Pyx_async_gen_asend(__pyx_PyAsyncGenObject *o, PyObject *arg) +{ + if (__Pyx_async_gen_init_hooks(o)) { + return NULL; + } + return __Pyx_async_gen_asend_new(o, arg); +} + + +static PyObject * +__Pyx_async_gen_aclose(__pyx_PyAsyncGenObject *o, CYTHON_UNUSED PyObject *arg) +{ + if (__Pyx_async_gen_init_hooks(o)) { + return NULL; + } + return __Pyx_async_gen_athrow_new(o, NULL); +} + + +static PyObject * +__Pyx_async_gen_athrow(__pyx_PyAsyncGenObject *o, PyObject *args) +{ + if (__Pyx_async_gen_init_hooks(o)) { + return NULL; + } + return __Pyx_async_gen_athrow_new(o, args); +} + + +static PyObject * +__Pyx_async_gen_self_method(PyObject *g, CYTHON_UNUSED PyObject *arg) { + return __Pyx_NewRef(g); +} + + +static PyGetSetDef __Pyx_async_gen_getsetlist[] = { + {(char*) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, + (char*) PyDoc_STR("name of the async generator"), 0}, + {(char*) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, + (char*) PyDoc_STR("qualified name of the async generator"), 0}, + //REMOVED: {(char*) "ag_await", (getter)coro_get_cr_await, NULL, + //REMOVED: (char*) PyDoc_STR("object being awaited on, or None")}, + {0, 0, 0, 0, 0} /* Sentinel */ +}; + +static PyMemberDef __Pyx_async_gen_memberlist[] = { + //REMOVED: {(char*) "ag_frame", T_OBJECT, offsetof(__pyx_PyAsyncGenObject, ag_frame), READONLY}, + {(char*) "ag_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, + //REMOVED: {(char*) "ag_code", T_OBJECT, offsetof(__pyx_PyAsyncGenObject, ag_code), READONLY}, + //ADDED: "ag_await" + {(char*) "ag_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, + (char*) PyDoc_STR("object being awaited on, or None")}, + {0, 0, 0, 0, 0} /* Sentinel */ +}; + +PyDoc_STRVAR(__Pyx_async_aclose_doc, +"aclose() -> raise GeneratorExit inside generator."); + +PyDoc_STRVAR(__Pyx_async_asend_doc, +"asend(v) -> send 'v' in generator."); + +PyDoc_STRVAR(__Pyx_async_athrow_doc, +"athrow(typ[,val[,tb]]) -> raise exception in generator."); + +PyDoc_STRVAR(__Pyx_async_aiter_doc, +"__aiter__(v) -> return an asynchronous iterator."); + +PyDoc_STRVAR(__Pyx_async_anext_doc, +"__anext__(v) -> continue asynchronous iteration and return the next element."); + +static PyMethodDef __Pyx_async_gen_methods[] = { + {"asend", (PyCFunction)__Pyx_async_gen_asend, METH_O, __Pyx_async_asend_doc}, + {"athrow",(PyCFunction)__Pyx_async_gen_athrow, METH_VARARGS, __Pyx_async_athrow_doc}, + {"aclose", (PyCFunction)__Pyx_async_gen_aclose, METH_NOARGS, __Pyx_async_aclose_doc}, + {"__aiter__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_aiter_doc}, + {"__anext__", (PyCFunction)__Pyx_async_gen_anext_method, METH_NOARGS, __Pyx_async_anext_doc}, + {0, 0, 0, 0} /* Sentinel */ +}; + + +#if CYTHON_USE_ASYNC_SLOTS +static __Pyx_PyAsyncMethodsStruct __Pyx_async_gen_as_async = { + 0, /* am_await */ + PyObject_SelfIter, /* am_aiter */ + (unaryfunc)__Pyx_async_gen_anext, /* am_anext */ +#if PY_VERSION_HEX >= 0x030A00A3 + 0, /*am_send*/ +#endif +}; +#endif + +static PyTypeObject __pyx_AsyncGenType_type = { + PyVarObject_HEAD_INIT(0, 0) + "async_generator", /* tp_name */ + sizeof(__pyx_PyAsyncGenObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)__Pyx_Coroutine_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ +#if CYTHON_USE_ASYNC_SLOTS + &__Pyx_async_gen_as_async, /* tp_as_async */ +#else + 0, /*tp_reserved*/ +#endif + (reprfunc)__Pyx_async_gen_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_HAVE_FINALIZE, /* tp_flags */ + 0, /* tp_doc */ + (traverseproc)__Pyx_async_gen_traverse, /* tp_traverse */ + 0, /* tp_clear */ +#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1 + // in order to (mis-)use tp_reserved above, we must also implement tp_richcompare + __Pyx_Coroutine_compare, /*tp_richcompare*/ +#else + 0, /*tp_richcompare*/ +#endif + offsetof(__pyx_CoroutineObject, gi_weakreflist), /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + __Pyx_async_gen_methods, /* tp_methods */ + __Pyx_async_gen_memberlist, /* tp_members */ + __Pyx_async_gen_getsetlist, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#if CYTHON_USE_TP_FINALIZE + 0, /*tp_del*/ +#else + __Pyx_Coroutine_del, /*tp_del*/ +#endif + 0, /* tp_version_tag */ +#if CYTHON_USE_TP_FINALIZE + __Pyx_Coroutine_del, /* tp_finalize */ +#elif PY_VERSION_HEX >= 0x030400a1 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + + +static int +__Pyx_PyAsyncGen_ClearFreeLists(void) +{ + int ret = __Pyx_ag_value_freelist_free + __Pyx_ag_asend_freelist_free; + + while (__Pyx_ag_value_freelist_free) { + __pyx__PyAsyncGenWrappedValue *o; + o = __Pyx_ag_value_freelist[--__Pyx_ag_value_freelist_free]; + assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o)); + PyObject_GC_Del(o); + } + + while (__Pyx_ag_asend_freelist_free) { + __pyx_PyAsyncGenASend *o; + o = __Pyx_ag_asend_freelist[--__Pyx_ag_asend_freelist_free]; + assert(Py_TYPE(o) == __pyx__PyAsyncGenASendType); + PyObject_GC_Del(o); + } + + return ret; +} + +static void +__Pyx_PyAsyncGen_Fini(void) +{ + __Pyx_PyAsyncGen_ClearFreeLists(); +} + + +static PyObject * +__Pyx_async_gen_unwrap_value(__pyx_PyAsyncGenObject *gen, PyObject *result) +{ + if (result == NULL) { + PyObject *exc_type = PyErr_Occurred(); + if (!exc_type) { + PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); + gen->ag_closed = 1; + } else if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, __Pyx_PyExc_StopAsyncIteration, PyExc_GeneratorExit)) { + gen->ag_closed = 1; + } + + return NULL; + } + + if (__pyx__PyAsyncGenWrappedValue_CheckExact(result)) { + /* async yield */ + __Pyx_ReturnWithStopIteration(((__pyx__PyAsyncGenWrappedValue*)result)->agw_val); + Py_DECREF(result); + return NULL; + } + + return result; +} + + +/* ---------- Async Generator ASend Awaitable ------------ */ + + +static void +__Pyx_async_gen_asend_dealloc(__pyx_PyAsyncGenASend *o) +{ + PyObject_GC_UnTrack((PyObject *)o); + Py_CLEAR(o->ags_gen); + Py_CLEAR(o->ags_sendval); + if (__Pyx_ag_asend_freelist_free < _PyAsyncGen_MAXFREELIST) { + assert(__pyx_PyAsyncGenASend_CheckExact(o)); + __Pyx_ag_asend_freelist[__Pyx_ag_asend_freelist_free++] = o; + } else { + PyObject_GC_Del(o); + } +} + +static int +__Pyx_async_gen_asend_traverse(__pyx_PyAsyncGenASend *o, visitproc visit, void *arg) +{ + Py_VISIT(o->ags_gen); + Py_VISIT(o->ags_sendval); + return 0; +} + + +static PyObject * +__Pyx_async_gen_asend_send(PyObject *g, PyObject *arg) +{ + __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g; + PyObject *result; + + if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + if (o->ags_state == __PYX_AWAITABLE_STATE_INIT) { + if (arg == NULL || arg == Py_None) { + arg = o->ags_sendval ? o->ags_sendval : Py_None; + } + o->ags_state = __PYX_AWAITABLE_STATE_ITER; + } + + result = __Pyx_Coroutine_Send((PyObject*)o->ags_gen, arg); + result = __Pyx_async_gen_unwrap_value(o->ags_gen, result); + + if (result == NULL) { + o->ags_state = __PYX_AWAITABLE_STATE_CLOSED; + } + + return result; +} + + +static CYTHON_INLINE PyObject * +__Pyx_async_gen_asend_iternext(PyObject *o) +{ + return __Pyx_async_gen_asend_send(o, Py_None); +} + + +static PyObject * +__Pyx_async_gen_asend_throw(__pyx_PyAsyncGenASend *o, PyObject *args) +{ + PyObject *result; + + if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + result = __Pyx_Coroutine_Throw((PyObject*)o->ags_gen, args); + result = __Pyx_async_gen_unwrap_value(o->ags_gen, result); + + if (result == NULL) { + o->ags_state = __PYX_AWAITABLE_STATE_CLOSED; + } + + return result; +} + + +static PyObject * +__Pyx_async_gen_asend_close(PyObject *g, CYTHON_UNUSED PyObject *args) +{ + __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g; + o->ags_state = __PYX_AWAITABLE_STATE_CLOSED; + Py_RETURN_NONE; +} + + +static PyMethodDef __Pyx_async_gen_asend_methods[] = { + {"send", (PyCFunction)__Pyx_async_gen_asend_send, METH_O, __Pyx_async_gen_send_doc}, + {"throw", (PyCFunction)__Pyx_async_gen_asend_throw, METH_VARARGS, __Pyx_async_gen_throw_doc}, + {"close", (PyCFunction)__Pyx_async_gen_asend_close, METH_NOARGS, __Pyx_async_gen_close_doc}, + {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc}, + {0, 0, 0, 0} /* Sentinel */ +}; + + +#if CYTHON_USE_ASYNC_SLOTS +static __Pyx_PyAsyncMethodsStruct __Pyx_async_gen_asend_as_async = { + PyObject_SelfIter, /* am_await */ + 0, /* am_aiter */ + 0, /* am_anext */ +#if PY_VERSION_HEX >= 0x030A00A3 + 0, /*am_send*/ +#endif +}; +#endif + + +static PyTypeObject __pyx__PyAsyncGenASendType_type = { + PyVarObject_HEAD_INIT(0, 0) + "async_generator_asend", /* tp_name */ + sizeof(__pyx_PyAsyncGenASend), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)__Pyx_async_gen_asend_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ +#if CYTHON_USE_ASYNC_SLOTS + &__Pyx_async_gen_asend_as_async, /* tp_as_async */ +#else + 0, /*tp_reserved*/ +#endif + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + 0, /* tp_doc */ + (traverseproc)__Pyx_async_gen_asend_traverse, /* tp_traverse */ + 0, /* tp_clear */ +#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1 + // in order to (mis-)use tp_reserved above, we must also implement tp_richcompare + __Pyx_Coroutine_compare, /*tp_richcompare*/ +#else + 0, /*tp_richcompare*/ +#endif + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)__Pyx_async_gen_asend_iternext, /* tp_iternext */ + __Pyx_async_gen_asend_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + + +static PyObject * +__Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *gen, PyObject *sendval) +{ + __pyx_PyAsyncGenASend *o; + if (__Pyx_ag_asend_freelist_free) { + __Pyx_ag_asend_freelist_free--; + o = __Pyx_ag_asend_freelist[__Pyx_ag_asend_freelist_free]; + _Py_NewReference((PyObject *)o); + } else { + o = PyObject_GC_New(__pyx_PyAsyncGenASend, __pyx__PyAsyncGenASendType); + if (o == NULL) { + return NULL; + } + } + + Py_INCREF(gen); + o->ags_gen = gen; + + Py_XINCREF(sendval); + o->ags_sendval = sendval; + + o->ags_state = __PYX_AWAITABLE_STATE_INIT; + + PyObject_GC_Track((PyObject*)o); + return (PyObject*)o; +} + + +/* ---------- Async Generator Value Wrapper ------------ */ + + +static void +__Pyx_async_gen_wrapped_val_dealloc(__pyx__PyAsyncGenWrappedValue *o) +{ + PyObject_GC_UnTrack((PyObject *)o); + Py_CLEAR(o->agw_val); + if (__Pyx_ag_value_freelist_free < _PyAsyncGen_MAXFREELIST) { + assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o)); + __Pyx_ag_value_freelist[__Pyx_ag_value_freelist_free++] = o; + } else { + PyObject_GC_Del(o); + } +} + + +static int +__Pyx_async_gen_wrapped_val_traverse(__pyx__PyAsyncGenWrappedValue *o, + visitproc visit, void *arg) +{ + Py_VISIT(o->agw_val); + return 0; +} + + +static PyTypeObject __pyx__PyAsyncGenWrappedValueType_type = { + PyVarObject_HEAD_INIT(0, 0) + "async_generator_wrapped_value", /* tp_name */ + sizeof(__pyx__PyAsyncGenWrappedValue), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)__Pyx_async_gen_wrapped_val_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_as_async */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + 0, /* tp_doc */ + (traverseproc)__Pyx_async_gen_wrapped_val_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + + +static PyObject * +__Pyx__PyAsyncGenValueWrapperNew(PyObject *val) +{ + // NOTE: steals a reference to val ! + __pyx__PyAsyncGenWrappedValue *o; + assert(val); + + if (__Pyx_ag_value_freelist_free) { + __Pyx_ag_value_freelist_free--; + o = __Pyx_ag_value_freelist[__Pyx_ag_value_freelist_free]; + assert(__pyx__PyAsyncGenWrappedValue_CheckExact(o)); + _Py_NewReference((PyObject*)o); + } else { + o = PyObject_GC_New(__pyx__PyAsyncGenWrappedValue, __pyx__PyAsyncGenWrappedValueType); + if (unlikely(!o)) { + Py_DECREF(val); + return NULL; + } + } + o->agw_val = val; + // no Py_INCREF(val) - steals reference! + PyObject_GC_Track((PyObject*)o); + return (PyObject*)o; +} + + +/* ---------- Async Generator AThrow awaitable ------------ */ + + +static void +__Pyx_async_gen_athrow_dealloc(__pyx_PyAsyncGenAThrow *o) +{ + PyObject_GC_UnTrack((PyObject *)o); + Py_CLEAR(o->agt_gen); + Py_CLEAR(o->agt_args); + PyObject_GC_Del(o); +} + + +static int +__Pyx_async_gen_athrow_traverse(__pyx_PyAsyncGenAThrow *o, visitproc visit, void *arg) +{ + Py_VISIT(o->agt_gen); + Py_VISIT(o->agt_args); + return 0; +} + + +static PyObject * +__Pyx_async_gen_athrow_send(__pyx_PyAsyncGenAThrow *o, PyObject *arg) +{ + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*)o->agt_gen; + PyObject *retval; + + if (o->agt_state == __PYX_AWAITABLE_STATE_CLOSED) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + if (o->agt_state == __PYX_AWAITABLE_STATE_INIT) { + if (o->agt_gen->ag_closed) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + if (arg != Py_None) { + PyErr_SetString(PyExc_RuntimeError, __Pyx_NON_INIT_CORO_MSG); + return NULL; + } + + o->agt_state = __PYX_AWAITABLE_STATE_ITER; + + if (o->agt_args == NULL) { + /* aclose() mode */ + o->agt_gen->ag_closed = 1; + + retval = __Pyx__Coroutine_Throw((PyObject*)gen, + /* Do not close generator when + PyExc_GeneratorExit is passed */ + PyExc_GeneratorExit, NULL, NULL, NULL, 0); + + if (retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval)) { + Py_DECREF(retval); + goto yield_close; + } + } else { + PyObject *typ; + PyObject *tb = NULL; + PyObject *val = NULL; + + if (!PyArg_UnpackTuple(o->agt_args, "athrow", 1, 3, + &typ, &val, &tb)) { + return NULL; + } + + retval = __Pyx__Coroutine_Throw((PyObject*)gen, + /* Do not close generator when PyExc_GeneratorExit is passed */ + typ, val, tb, o->agt_args, 0); + retval = __Pyx_async_gen_unwrap_value(o->agt_gen, retval); + } + if (retval == NULL) { + goto check_error; + } + return retval; + } + + assert (o->agt_state == __PYX_AWAITABLE_STATE_ITER); + + retval = __Pyx_Coroutine_Send((PyObject *)gen, arg); + if (o->agt_args) { + return __Pyx_async_gen_unwrap_value(o->agt_gen, retval); + } else { + /* aclose() mode */ + if (retval) { + if (__pyx__PyAsyncGenWrappedValue_CheckExact(retval)) { + Py_DECREF(retval); + goto yield_close; + } + else { + return retval; + } + } + else { + goto check_error; + } + } + +yield_close: + PyErr_SetString( + PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG); + return NULL; + +check_error: + if (PyErr_ExceptionMatches(__Pyx_PyExc_StopAsyncIteration)) { + o->agt_state = __PYX_AWAITABLE_STATE_CLOSED; + if (o->agt_args == NULL) { + // when aclose() is called we don't want to propagate + // StopAsyncIteration; just raise StopIteration, signalling + // that 'aclose()' is done. + PyErr_Clear(); + PyErr_SetNone(PyExc_StopIteration); + } + } + else if (PyErr_ExceptionMatches(PyExc_GeneratorExit)) { + o->agt_state = __PYX_AWAITABLE_STATE_CLOSED; + PyErr_Clear(); /* ignore these errors */ + PyErr_SetNone(PyExc_StopIteration); + } + return NULL; +} + + +static PyObject * +__Pyx_async_gen_athrow_throw(__pyx_PyAsyncGenAThrow *o, PyObject *args) +{ + PyObject *retval; + + if (o->agt_state == __PYX_AWAITABLE_STATE_INIT) { + PyErr_SetString(PyExc_RuntimeError, __Pyx_NON_INIT_CORO_MSG); + return NULL; + } + + if (o->agt_state == __PYX_AWAITABLE_STATE_CLOSED) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + retval = __Pyx_Coroutine_Throw((PyObject*)o->agt_gen, args); + if (o->agt_args) { + return __Pyx_async_gen_unwrap_value(o->agt_gen, retval); + } else { + /* aclose() mode */ + if (retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval)) { + Py_DECREF(retval); + PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG); + return NULL; + } + return retval; + } +} + + +static PyObject * +__Pyx_async_gen_athrow_iternext(__pyx_PyAsyncGenAThrow *o) +{ + return __Pyx_async_gen_athrow_send(o, Py_None); +} + + +static PyObject * +__Pyx_async_gen_athrow_close(PyObject *g, CYTHON_UNUSED PyObject *args) +{ + __pyx_PyAsyncGenAThrow *o = (__pyx_PyAsyncGenAThrow*) g; + o->agt_state = __PYX_AWAITABLE_STATE_CLOSED; + Py_RETURN_NONE; +} + + +static PyMethodDef __Pyx_async_gen_athrow_methods[] = { + {"send", (PyCFunction)__Pyx_async_gen_athrow_send, METH_O, __Pyx_async_gen_send_doc}, + {"throw", (PyCFunction)__Pyx_async_gen_athrow_throw, METH_VARARGS, __Pyx_async_gen_throw_doc}, + {"close", (PyCFunction)__Pyx_async_gen_athrow_close, METH_NOARGS, __Pyx_async_gen_close_doc}, + {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc}, + {0, 0, 0, 0} /* Sentinel */ +}; + + +#if CYTHON_USE_ASYNC_SLOTS +static __Pyx_PyAsyncMethodsStruct __Pyx_async_gen_athrow_as_async = { + PyObject_SelfIter, /* am_await */ + 0, /* am_aiter */ + 0, /* am_anext */ +#if PY_VERSION_HEX >= 0x030A00A3 + 0, /*am_send*/ +#endif +}; +#endif + + +static PyTypeObject __pyx__PyAsyncGenAThrowType_type = { + PyVarObject_HEAD_INIT(0, 0) + "async_generator_athrow", /* tp_name */ + sizeof(__pyx_PyAsyncGenAThrow), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)__Pyx_async_gen_athrow_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ +#if CYTHON_USE_ASYNC_SLOTS + &__Pyx_async_gen_athrow_as_async, /* tp_as_async */ +#else + 0, /*tp_reserved*/ +#endif + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + 0, /* tp_doc */ + (traverseproc)__Pyx_async_gen_athrow_traverse, /* tp_traverse */ + 0, /* tp_clear */ +#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1 + // in order to (mis-)use tp_reserved above, we must also implement tp_richcompare + __Pyx_Coroutine_compare, /*tp_richcompare*/ +#else + 0, /*tp_richcompare*/ +#endif + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)__Pyx_async_gen_athrow_iternext, /* tp_iternext */ + __Pyx_async_gen_athrow_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + + +static PyObject * +__Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *gen, PyObject *args) +{ + __pyx_PyAsyncGenAThrow *o; + o = PyObject_GC_New(__pyx_PyAsyncGenAThrow, __pyx__PyAsyncGenAThrowType); + if (o == NULL) { + return NULL; + } + o->agt_gen = gen; + o->agt_args = args; + o->agt_state = __PYX_AWAITABLE_STATE_INIT; + Py_INCREF(gen); + Py_XINCREF(args); + PyObject_GC_Track((PyObject*)o); + return (PyObject*)o; +} + + +/* ---------- global type sharing ------------ */ + +static int __pyx_AsyncGen_init(void) { + // on Windows, C-API functions can't be used in slots statically + __pyx_AsyncGenType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx__PyAsyncGenWrappedValueType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx__PyAsyncGenAThrowType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx__PyAsyncGenASendType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + + __pyx_AsyncGenType = __Pyx_FetchCommonType(&__pyx_AsyncGenType_type); + if (unlikely(!__pyx_AsyncGenType)) + return -1; + + __pyx__PyAsyncGenAThrowType = __Pyx_FetchCommonType(&__pyx__PyAsyncGenAThrowType_type); + if (unlikely(!__pyx__PyAsyncGenAThrowType)) + return -1; + + __pyx__PyAsyncGenWrappedValueType = __Pyx_FetchCommonType(&__pyx__PyAsyncGenWrappedValueType_type); + if (unlikely(!__pyx__PyAsyncGenWrappedValueType)) + return -1; + + __pyx__PyAsyncGenASendType = __Pyx_FetchCommonType(&__pyx__PyAsyncGenASendType_type); + if (unlikely(!__pyx__PyAsyncGenASendType)) + return -1; + + return 0; +} diff --git a/contrib/tools/cython/Cython/Utility/Buffer.c b/contrib/tools/cython/Cython/Utility/Buffer.c new file mode 100644 index 00000000000..3c7105fa356 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Buffer.c @@ -0,0 +1,921 @@ +/////////////// BufferStructDeclare.proto /////////////// + +/* structs for buffer access */ + +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; + +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; + +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[{{max_dims}}]; +} __Pyx_LocalBuf_ND; + +/////////////// BufferIndexError.proto /////////////// +static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/ + +/////////////// BufferIndexError /////////////// +static void __Pyx_RaiseBufferIndexError(int axis) { + PyErr_Format(PyExc_IndexError, + "Out of bounds on buffer access (axis %d)", axis); +} + +/////////////// BufferIndexErrorNogil.proto /////////////// +//@requires: BufferIndexError + +static void __Pyx_RaiseBufferIndexErrorNogil(int axis); /*proto*/ + +/////////////// BufferIndexErrorNogil /////////////// +static void __Pyx_RaiseBufferIndexErrorNogil(int axis) { + #ifdef WITH_THREAD + PyGILState_STATE gilstate = PyGILState_Ensure(); + #endif + __Pyx_RaiseBufferIndexError(axis); + #ifdef WITH_THREAD + PyGILState_Release(gilstate); + #endif +} + +/////////////// BufferFallbackError.proto /////////////// +static void __Pyx_RaiseBufferFallbackError(void); /*proto*/ + +/////////////// BufferFallbackError /////////////// +static void __Pyx_RaiseBufferFallbackError(void) { + PyErr_SetString(PyExc_ValueError, + "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); +} + +/////////////// BufferFormatStructs.proto /////////////// +//@proto_block: utility_code_proto_before_types + +#define IS_UNSIGNED(type) (((type) -1) > 0) + +/* Run-time type information about structs used with buffers */ +struct __Pyx_StructField_; + +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) + +typedef struct { + const char* name; /* for error messages only */ + struct __Pyx_StructField_* fields; + size_t size; /* sizeof(type) */ + size_t arraysize[8]; /* length of array in each dimension */ + int ndim; + char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */ + char is_unsigned; + int flags; +} __Pyx_TypeInfo; + +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; + +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; + +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/////////////// GetAndReleaseBuffer.proto /////////////// + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + +/////////////// GetAndReleaseBuffer /////////////// + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + + {{for type_ptr, getbuffer, releasebuffer in types}} + {{if getbuffer}} + if (__Pyx_TypeCheck(obj, {{type_ptr}})) return {{getbuffer}}(obj, view, flags); + {{endif}} + {{endfor}} + + PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); + return -1; +} + +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + + if ((0)) {} + {{for type_ptr, getbuffer, releasebuffer in types}} + {{if releasebuffer}} + else if (__Pyx_TypeCheck(obj, {{type_ptr}})) {{releasebuffer}}(obj, view); + {{endif}} + {{endfor}} + + view->obj = NULL; + Py_DECREF(obj); +} + +#endif /* PY_MAJOR_VERSION < 3 */ + + +/////////////// BufferGetAndValidate.proto /////////////// + +#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack) \ + ((obj == Py_None || obj == NULL) ? \ + (__Pyx_ZeroBuffer(buf), 0) : \ + __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) + +static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static void __Pyx_ZeroBuffer(Py_buffer* buf); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);/*proto*/ + +static Py_ssize_t __Pyx_minusones[] = { {{ ", ".join(["-1"] * max_dims) }} }; +static Py_ssize_t __Pyx_zeros[] = { {{ ", ".join(["0"] * max_dims) }} }; + + +/////////////// BufferGetAndValidate /////////////// +//@requires: BufferFormatCheck + +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (unlikely(info->buf == NULL)) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +static void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} + +static int __Pyx__GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + buf->buf = NULL; + if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { + __Pyx_ZeroBuffer(buf); + return -1; + } + // From this point on, we have acquired the buffer and must release it on errors. + if (unlikely(buf->ndim != nd)) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if (unlikely((size_t)buf->itemsize != dtype->size)) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_SafeReleaseBuffer(buf); + return -1; +} + + +/////////////// BufferFormatCheck.proto /////////////// + +// Buffer format string checking +// +// Buffer type checking. Utility code for checking that acquired +// buffers match our assumptions. We only need to check ndim and +// the format string; the access mode/flags is checked by the +// exporter. See: +// +// http://docs.python.org/3/library/struct.html +// http://legacy.python.org/dev/peps/pep-3118/#additions-to-the-struct-string-syntax +// +// The alignment code is copied from _struct.c in Python. + +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type); /*proto*/ + +/////////////// BufferFormatCheck /////////////// +//@requires: ModuleSetupCode.c::IsLittleEndian +//@requires: BufferFormatStructs + +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} + +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t <= '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} + +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) /* First char was not a digit */ + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} + + +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} + +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case '?': return "'bool'"; + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} + +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} + +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} + +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif + +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} + +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif + +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} + +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case '?': case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} + + +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} + +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + + /* printf("processing... %s\n", ctx->head->field->type->name); */ + + if (ctx->enc_type == 0) return 0; + + /* Validate array size */ + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + + /* handle strings ('s' and 'p') */ + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + /* special case -- treat as struct rather than complex number */ + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + /* special case -- chars don't care about sign */ + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + + --ctx->enc_count; /* Consume from buffer string */ + + /* Done checking, move to next field, pushing or popping struct stack if needed */ + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; /* breaks both loops as ctx->enc_count == 0 */ + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; /* empty struct */ + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} + +/* Parse an array in the format string (e.g. (1,2,3)) */ +static PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number, ndim; + + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + + /* Process the previous element */ + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + + // store ndim now, as field advanced by __Pyx_BufFmt_ProcessTypeChunk call + ndim = ctx->head->field->type->ndim; + + /* Parse all numbers in the format string */ + while (*ts && *ts != ')') { + // ignore space characters (not using isspace() due to C/C++ problem on MacOS-X) + switch (*ts) { + case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; + default: break; /* not a 'break' in the loop */ + } + + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + + if (*ts == ',') ts++; + i++; + } + + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} + +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + + while (1) { + /* puts(ts); */ + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case '\r': + case '\n': + ++ts; + break; + case '<': + if (!__Pyx_Is_Little_Endian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_Is_Little_Endian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': /* substruct */ + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': /* end of substruct; either repeat or move on */ + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + if (alignment && ctx->fmt_offset % alignment) { + /* Pad struct on size of the first member */ + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } + CYTHON_FALLTHROUGH; + case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 'p': + if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) && + (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) { + /* Continue pooling same type */ + ctx->enc_count += ctx->new_count; + ctx->new_count = 1; + got_Z = 0; + ++ts; + break; + } + CYTHON_FALLTHROUGH; + case 's': + /* 's' or new type (cannot be added to current pool) */ + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} + +/////////////// TypeInfoCompare.proto /////////////// +static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b); + +/////////////// TypeInfoCompare /////////////// +//@requires: BufferFormatStructs + +// See if two dtypes are equal +static int +__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b) +{ + int i; + + if (!a || !b) + return 0; + + if (a == b) + return 1; + + if (a->size != b->size || a->typegroup != b->typegroup || + a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) { + if (a->typegroup == 'H' || b->typegroup == 'H') { + /* Special case for chars */ + return a->size == b->size; + } else { + return 0; + } + } + + if (a->ndim) { + /* Verify multidimensional C arrays */ + for (i = 0; i < a->ndim; i++) + if (a->arraysize[i] != b->arraysize[i]) + return 0; + } + + if (a->typegroup == 'S') { + /* Check for packed struct */ + if (a->flags != b->flags) + return 0; + + /* compare all struct fields */ + if (a->fields || b->fields) { + /* Check if both have fields */ + if (!(a->fields && b->fields)) + return 0; + + /* compare */ + for (i = 0; a->fields[i].type && b->fields[i].type; i++) { + __Pyx_StructField *field_a = a->fields + i; + __Pyx_StructField *field_b = b->fields + i; + + if (field_a->offset != field_b->offset || + !__pyx_typeinfo_cmp(field_a->type, field_b->type)) + return 0; + } + + /* If all fields are processed, we have a match */ + return !a->fields[i].type && !b->fields[i].type; + } + } + + return 1; +} + + +/////////////// TypeInfoToFormat.proto /////////////// +struct __pyx_typeinfo_string { + char string[3]; +}; +static struct __pyx_typeinfo_string __Pyx_TypeInfoToFormat(__Pyx_TypeInfo *type); + +/////////////// TypeInfoToFormat /////////////// +//@requires: BufferFormatStructs + +// See also MemoryView.pyx:BufferFormatFromTypeInfo + +static struct __pyx_typeinfo_string __Pyx_TypeInfoToFormat(__Pyx_TypeInfo *type) { + struct __pyx_typeinfo_string result = { {0} }; + char *buf = (char *) result.string; + size_t size = type->size; + + switch (type->typegroup) { + case 'H': + *buf = 'c'; + break; + case 'I': + case 'U': + if (size == 1) + *buf = (type->is_unsigned) ? 'B' : 'b'; + else if (size == 2) + *buf = (type->is_unsigned) ? 'H' : 'h'; + else if (size == 4) + *buf = (type->is_unsigned) ? 'I' : 'i'; + else if (size == 8) + *buf = (type->is_unsigned) ? 'Q' : 'q'; + break; + case 'P': + *buf = 'P'; + break; + case 'C': + { + __Pyx_TypeInfo complex_type = *type; + complex_type.typegroup = 'R'; + complex_type.size /= 2; + + *buf++ = 'Z'; + *buf = __Pyx_TypeInfoToFormat(&complex_type).string[0]; + break; + } + case 'R': + if (size == 4) + *buf = 'f'; + else if (size == 8) + *buf = 'd'; + else + *buf = 'g'; + break; + } + + return result; +} diff --git a/contrib/tools/cython/Cython/Utility/Builtins.c b/contrib/tools/cython/Cython/Utility/Builtins.c new file mode 100644 index 00000000000..32aeff8f265 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Builtins.c @@ -0,0 +1,542 @@ +/* + * Special implementations of built-in functions and methods. + * + * Optional optimisations for builtins are in Optimize.c. + * + * General object operations and protocols are in ObjectHandling.c. + */ + +//////////////////// Globals.proto //////////////////// + +static PyObject* __Pyx_Globals(void); /*proto*/ + +//////////////////// Globals //////////////////// +//@substitute: naming +//@requires: ObjectHandling.c::GetAttr + +// This is a stub implementation until we have something more complete. +// Currently, we only handle the most common case of a read-only dict +// of Python names. Supporting cdef names in the module and write +// access requires a rewrite as a dedicated class. + +static PyObject* __Pyx_Globals(void) { + Py_ssize_t i; + PyObject *names; + PyObject *globals = $moddict_cname; + Py_INCREF(globals); + names = PyObject_Dir($module_cname); + if (!names) + goto bad; + for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) { +#if CYTHON_COMPILING_IN_PYPY + PyObject* name = PySequence_ITEM(names, i); + if (!name) + goto bad; +#else + PyObject* name = PyList_GET_ITEM(names, i); +#endif + if (!PyDict_Contains(globals, name)) { + PyObject* value = __Pyx_GetAttr($module_cname, name); + if (!value) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif + goto bad; + } + if (PyDict_SetItem(globals, name, value) < 0) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif + Py_DECREF(value); + goto bad; + } + } +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif + } + Py_DECREF(names); + return globals; +bad: + Py_XDECREF(names); + Py_XDECREF(globals); + return NULL; +} + +//////////////////// PyExecGlobals.proto //////////////////// + +static PyObject* __Pyx_PyExecGlobals(PyObject*); + +//////////////////// PyExecGlobals //////////////////// +//@requires: Globals +//@requires: PyExec + +static PyObject* __Pyx_PyExecGlobals(PyObject* code) { + PyObject* result; + PyObject* globals = __Pyx_Globals(); + if (unlikely(!globals)) + return NULL; + result = __Pyx_PyExec2(code, globals); + Py_DECREF(globals); + return result; +} + +//////////////////// PyExec.proto //////////////////// + +static PyObject* __Pyx_PyExec3(PyObject*, PyObject*, PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject*, PyObject*); + +//////////////////// PyExec //////////////////// +//@substitute: naming + +static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject* o, PyObject* globals) { + return __Pyx_PyExec3(o, globals, NULL); +} + +static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals) { + PyObject* result; + PyObject* s = 0; + char *code = 0; + + if (!globals || globals == Py_None) { + globals = $moddict_cname; + } else if (!PyDict_Check(globals)) { + PyErr_Format(PyExc_TypeError, "exec() arg 2 must be a dict, not %.200s", + Py_TYPE(globals)->tp_name); + goto bad; + } + if (!locals || locals == Py_None) { + locals = globals; + } + + if (__Pyx_PyDict_GetItemStr(globals, PYIDENT("__builtins__")) == NULL) { + if (PyDict_SetItem(globals, PYIDENT("__builtins__"), PyEval_GetBuiltins()) < 0) + goto bad; + } + + if (PyCode_Check(o)) { + if (__Pyx_PyCode_HasFreeVars((PyCodeObject *)o)) { + PyErr_SetString(PyExc_TypeError, + "code object passed to exec() may not contain free variables"); + goto bad; + } + #if PY_VERSION_HEX < 0x030200B1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) + result = PyEval_EvalCode((PyCodeObject *)o, globals, locals); + #else + result = PyEval_EvalCode(o, globals, locals); + #endif + } else { + PyCompilerFlags cf; + cf.cf_flags = 0; +#if PY_VERSION_HEX >= 0x030800A3 + cf.cf_feature_version = PY_MINOR_VERSION; +#endif + if (PyUnicode_Check(o)) { + cf.cf_flags = PyCF_SOURCE_IS_UTF8; + s = PyUnicode_AsUTF8String(o); + if (!s) goto bad; + o = s; + #if PY_MAJOR_VERSION >= 3 + } else if (!PyBytes_Check(o)) { + #else + } else if (!PyString_Check(o)) { + #endif + PyErr_Format(PyExc_TypeError, + "exec: arg 1 must be string, bytes or code object, got %.200s", + Py_TYPE(o)->tp_name); + goto bad; + } + #if PY_MAJOR_VERSION >= 3 + code = PyBytes_AS_STRING(o); + #else + code = PyString_AS_STRING(o); + #endif + if (PyEval_MergeCompilerFlags(&cf)) { + result = PyRun_StringFlags(code, Py_file_input, globals, locals, &cf); + } else { + result = PyRun_String(code, Py_file_input, globals, locals); + } + Py_XDECREF(s); + } + + return result; +bad: + Py_XDECREF(s); + return 0; +} + +//////////////////// GetAttr3.proto //////////////////// + +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/ + +//////////////////// GetAttr3 //////////////////// +//@requires: ObjectHandling.c::GetAttr +//@requires: Exceptions.c::PyThreadStateGet +//@requires: Exceptions.c::PyErrFetchRestore +//@requires: Exceptions.c::PyErrExceptionMatches + +static PyObject *__Pyx_GetAttr3Default(PyObject *d) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + return NULL; + __Pyx_PyErr_Clear(); + Py_INCREF(d); + return d; +} + +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { + PyObject *r = __Pyx_GetAttr(o, n); + return (likely(r)) ? r : __Pyx_GetAttr3Default(d); +} + +//////////////////// HasAttr.proto //////////////////// + +static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); /*proto*/ + +//////////////////// HasAttr //////////////////// +//@requires: ObjectHandling.c::GetAttr + +static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { + PyObject *r; + if (unlikely(!__Pyx_PyBaseString_Check(n))) { + PyErr_SetString(PyExc_TypeError, + "hasattr(): attribute name must be string"); + return -1; + } + r = __Pyx_GetAttr(o, n); + if (unlikely(!r)) { + PyErr_Clear(); + return 0; + } else { + Py_DECREF(r); + return 1; + } +} + +//////////////////// Intern.proto //////////////////// + +static PyObject* __Pyx_Intern(PyObject* s); /* proto */ + +//////////////////// Intern //////////////////// + +static PyObject* __Pyx_Intern(PyObject* s) { + if (!(likely(PyString_CheckExact(s)))) { + PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(s)->tp_name); + return 0; + } + Py_INCREF(s); + #if PY_MAJOR_VERSION >= 3 + PyUnicode_InternInPlace(&s); + #else + PyString_InternInPlace(&s); + #endif + return s; +} + +//////////////////// abs_longlong.proto //////////////////// + +static CYTHON_INLINE PY_LONG_LONG __Pyx_abs_longlong(PY_LONG_LONG x) { +#if defined (__cplusplus) && __cplusplus >= 201103L + return std::abs(x); +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + return llabs(x); +#elif defined (_MSC_VER) + // abs() is defined for long, but 64-bits type on MSVC is long long. + // Use MS-specific _abs64() instead, which returns the original (negative) value for abs(-MAX-1) + return _abs64(x); +#elif defined (__GNUC__) + // gcc or clang on 64 bit windows. + return __builtin_llabs(x); +#else + if (sizeof(PY_LONG_LONG) <= sizeof(Py_ssize_t)) + return __Pyx_sst_abs(x); + return (x<0) ? -x : x; +#endif +} + + +//////////////////// py_abs.proto //////////////////// + +#if CYTHON_USE_PYLONG_INTERNALS +static PyObject *__Pyx_PyLong_AbsNeg(PyObject *num);/*proto*/ + +#define __Pyx_PyNumber_Absolute(x) \ + ((likely(PyLong_CheckExact(x))) ? \ + (likely(Py_SIZE(x) >= 0) ? (Py_INCREF(x), (x)) : __Pyx_PyLong_AbsNeg(x)) : \ + PyNumber_Absolute(x)) + +#else +#define __Pyx_PyNumber_Absolute(x) PyNumber_Absolute(x) +#endif + +//////////////////// py_abs //////////////////// + +#if CYTHON_USE_PYLONG_INTERNALS +static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) { + if (likely(Py_SIZE(n) == -1)) { + // digits are unsigned + return PyLong_FromLong(((PyLongObject*)n)->ob_digit[0]); + } +#if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *copy = _PyLong_Copy((PyLongObject*)n); + if (likely(copy)) { + // negate the size to swap the sign + __Pyx_SET_SIZE(copy, -Py_SIZE(copy)); + } + return copy; + } +#else + return PyNumber_Negative(n); +#endif +} +#endif + + +//////////////////// pow2.proto //////////////////// + +#define __Pyx_PyNumber_Power2(a, b) PyNumber_Power(a, b, Py_None) + + +//////////////////// object_ord.proto //////////////////// +//@requires: TypeConversion.c::UnicodeAsUCS4 + +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyObject_Ord(c) \ + (likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c)) +#else +#define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c) +#endif +static long __Pyx__PyObject_Ord(PyObject* c); /*proto*/ + +//////////////////// object_ord //////////////////// + +static long __Pyx__PyObject_Ord(PyObject* c) { + Py_ssize_t size; + if (PyBytes_Check(c)) { + size = PyBytes_GET_SIZE(c); + if (likely(size == 1)) { + return (unsigned char) PyBytes_AS_STRING(c)[0]; + } +#if PY_MAJOR_VERSION < 3 + } else if (PyUnicode_Check(c)) { + return (long)__Pyx_PyUnicode_AsPy_UCS4(c); +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + } else if (PyByteArray_Check(c)) { + size = PyByteArray_GET_SIZE(c); + if (likely(size == 1)) { + return (unsigned char) PyByteArray_AS_STRING(c)[0]; + } +#endif + } else { + // FIXME: support character buffers - but CPython doesn't support them either + PyErr_Format(PyExc_TypeError, + "ord() expected string of length 1, but %.200s found", Py_TYPE(c)->tp_name); + return (long)(Py_UCS4)-1; + } + PyErr_Format(PyExc_TypeError, + "ord() expected a character, but string of length %zd found", size); + return (long)(Py_UCS4)-1; +} + + +//////////////////// py_dict_keys.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d); /*proto*/ + +//////////////////// py_dict_keys //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "keys", d); + else + return PyDict_Keys(d); +} + +//////////////////// py_dict_values.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /*proto*/ + +//////////////////// py_dict_values //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "values", d); + else + return PyDict_Values(d); +} + +//////////////////// py_dict_items.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /*proto*/ + +//////////////////// py_dict_items //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "items", d); + else + return PyDict_Items(d); +} + +//////////////////// py_dict_iterkeys.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterKeys(PyObject* d); /*proto*/ + +//////////////////// py_dict_iterkeys //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterKeys(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "keys", d); + else + return CALL_UNBOUND_METHOD(PyDict_Type, "iterkeys", d); +} + +//////////////////// py_dict_itervalues.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterValues(PyObject* d); /*proto*/ + +//////////////////// py_dict_itervalues //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterValues(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "values", d); + else + return CALL_UNBOUND_METHOD(PyDict_Type, "itervalues", d); +} + +//////////////////// py_dict_iteritems.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterItems(PyObject* d); /*proto*/ + +//////////////////// py_dict_iteritems //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterItems(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "items", d); + else + return CALL_UNBOUND_METHOD(PyDict_Type, "iteritems", d); +} + +//////////////////// py_dict_viewkeys.proto //////////////////// + +#if PY_VERSION_HEX < 0x02070000 +#error This module uses dict views, which require Python 2.7 or later +#endif +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewKeys(PyObject* d); /*proto*/ + +//////////////////// py_dict_viewkeys //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewKeys(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "keys", d); + else + return CALL_UNBOUND_METHOD(PyDict_Type, "viewkeys", d); +} + +//////////////////// py_dict_viewvalues.proto //////////////////// + +#if PY_VERSION_HEX < 0x02070000 +#error This module uses dict views, which require Python 2.7 or later +#endif +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewValues(PyObject* d); /*proto*/ + +//////////////////// py_dict_viewvalues //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewValues(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "values", d); + else + return CALL_UNBOUND_METHOD(PyDict_Type, "viewvalues", d); +} + +//////////////////// py_dict_viewitems.proto //////////////////// + +#if PY_VERSION_HEX < 0x02070000 +#error This module uses dict views, which require Python 2.7 or later +#endif +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewItems(PyObject* d); /*proto*/ + +//////////////////// py_dict_viewitems //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewItems(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return CALL_UNBOUND_METHOD(PyDict_Type, "items", d); + else + return CALL_UNBOUND_METHOD(PyDict_Type, "viewitems", d); +} + + +//////////////////// pyfrozenset_new.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it); + +//////////////////// pyfrozenset_new //////////////////// +//@substitute: naming + +static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) { + if (it) { + PyObject* result; +#if CYTHON_COMPILING_IN_PYPY + // PyPy currently lacks PyFrozenSet_CheckExact() and PyFrozenSet_New() + PyObject* args; + args = PyTuple_Pack(1, it); + if (unlikely(!args)) + return NULL; + result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL); + Py_DECREF(args); + return result; +#else + if (PyFrozenSet_CheckExact(it)) { + Py_INCREF(it); + return it; + } + result = PyFrozenSet_New(it); + if (unlikely(!result)) + return NULL; + if ((PY_VERSION_HEX >= 0x031000A1) || likely(PySet_GET_SIZE(result))) + return result; + // empty frozenset is a singleton (on Python <3.10) + // seems wasteful, but CPython does the same + Py_DECREF(result); +#endif + } +#if CYTHON_USE_TYPE_SLOTS + return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, $empty_tuple, NULL); +#else + return PyObject_Call((PyObject*)&PyFrozenSet_Type, $empty_tuple, NULL); +#endif +} + + +//////////////////// PySet_Update.proto //////////////////// + +static CYTHON_INLINE int __Pyx_PySet_Update(PyObject* set, PyObject* it); /*proto*/ + +//////////////////// PySet_Update //////////////////// + +static CYTHON_INLINE int __Pyx_PySet_Update(PyObject* set, PyObject* it) { + PyObject *retval; + #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY + if (PyAnySet_Check(it)) { + if (PySet_GET_SIZE(it) == 0) + return 0; + // fast and safe case: CPython will update our result set and return it + retval = PySet_Type.tp_as_number->nb_inplace_or(set, it); + if (likely(retval == set)) { + Py_DECREF(retval); + return 0; + } + if (unlikely(!retval)) + return -1; + // unusual result, fall through to set.update() call below + Py_DECREF(retval); + } + #endif + retval = CALL_UNBOUND_METHOD(PySet_Type, "update", set, it); + if (unlikely(!retval)) return -1; + Py_DECREF(retval); + return 0; +} diff --git a/contrib/tools/cython/Cython/Utility/CConvert.pyx b/contrib/tools/cython/Cython/Utility/CConvert.pyx new file mode 100644 index 00000000000..5969f6a5826 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CConvert.pyx @@ -0,0 +1,132 @@ +#################### FromPyStructUtility #################### + +cdef extern from *: + ctypedef struct PyTypeObject: + char* tp_name + PyTypeObject *Py_TYPE(obj) + bint PyMapping_Check(obj) + object PyErr_Format(exc, const char *format, ...) + +@cname("{{funcname}}") +cdef {{struct_type}} {{funcname}}(obj) except *: + cdef {{struct_type}} result + if not PyMapping_Check(obj): + PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) + + {{for member in var_entries:}} + try: + value = obj['{{member.name}}'] + except KeyError: + raise ValueError("No value specified for struct attribute '{{member.name}}'") + result.{{member.cname}} = value + {{endfor}} + return result + + +#################### FromPyUnionUtility #################### + +cdef extern from *: + ctypedef struct PyTypeObject: + char* tp_name + PyTypeObject *Py_TYPE(obj) + bint PyMapping_Check(obj) + object PyErr_Format(exc, const char *format, ...) + +@cname("{{funcname}}") +cdef {{struct_type}} {{funcname}}(obj) except *: + cdef {{struct_type}} result + cdef Py_ssize_t length + if not PyMapping_Check(obj): + PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) + + last_found = None + length = len(obj) + if length: + {{for member in var_entries:}} + if '{{member.name}}' in obj: + if last_found is not None: + raise ValueError("More than one union attribute passed: '%s' and '%s'" % (last_found, '{{member.name}}')) + last_found = '{{member.name}}' + result.{{member.cname}} = obj['{{member.name}}'] + length -= 1 + if not length: + return result + {{endfor}} + if last_found is None: + raise ValueError("No value specified for any of the union attributes (%s)" % + '{{", ".join(member.name for member in var_entries)}}') + return result + + +#################### cfunc.to_py #################### + +@cname("{{cname}}") +cdef object {{cname}}({{return_type.ctype}} (*f)({{ ', '.join(arg.type_cname for arg in args) }}) {{except_clause}}): + def wrap({{ ', '.join('{arg.ctype} {arg.name}'.format(arg=arg) for arg in args) }}): + """wrap({{', '.join(('{arg.name}: {arg.type_displayname}'.format(arg=arg) if arg.type_displayname else arg.name) for arg in args)}}){{if return_type.type_displayname}} -> {{return_type.type_displayname}}{{endif}}""" + {{'' if return_type.type.is_void else 'return '}}f({{ ', '.join(arg.name for arg in args) }}) + return wrap + + +#################### carray.from_py #################### + +cdef extern from *: + object PyErr_Format(exc, const char *format, ...) + +@cname("{{cname}}") +cdef int {{cname}}(object o, {{base_type}} *v, Py_ssize_t length) except -1: + cdef Py_ssize_t i = length + try: + i = len(o) + except (TypeError, OverflowError): + pass + if i == length: + for i, item in enumerate(o): + if i >= length: + break + v[i] = item + else: + i += 1 # convert index to length + if i == length: + return 0 + + PyErr_Format( + IndexError, + ("too many values found during array assignment, expected %zd" + if i >= length else + "not enough values found during array assignment, expected %zd, got %zd"), + length, i) + + +#################### carray.to_py #################### + +cdef extern from *: + void Py_INCREF(object o) + tuple PyTuple_New(Py_ssize_t size) + list PyList_New(Py_ssize_t size) + void PyTuple_SET_ITEM(object p, Py_ssize_t pos, object o) + void PyList_SET_ITEM(object p, Py_ssize_t pos, object o) + + +@cname("{{cname}}") +cdef inline list {{cname}}({{base_type}} *v, Py_ssize_t length): + cdef size_t i + cdef object value + l = PyList_New(length) + for i in range(<size_t>length): + value = v[i] + Py_INCREF(value) + PyList_SET_ITEM(l, i, value) + return l + + +@cname("{{to_tuple_cname}}") +cdef inline tuple {{to_tuple_cname}}({{base_type}} *v, Py_ssize_t length): + cdef size_t i + cdef object value + t = PyTuple_New(length) + for i in range(<size_t>length): + value = v[i] + Py_INCREF(value) + PyTuple_SET_ITEM(t, i, value) + return t diff --git a/contrib/tools/cython/Cython/Utility/CMath.c b/contrib/tools/cython/Cython/Utility/CMath.c new file mode 100644 index 00000000000..2cd22231384 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CMath.c @@ -0,0 +1,95 @@ + +/////////////// CDivisionWarning.proto /////////////// + +static int __Pyx_cdivision_warning(const char *, int); /* proto */ + +/////////////// CDivisionWarning /////////////// + +static int __Pyx_cdivision_warning(const char *filename, int lineno) { +#if CYTHON_COMPILING_IN_PYPY + // avoid compiler warnings + filename++; lineno++; + return PyErr_Warn(PyExc_RuntimeWarning, + "division with oppositely signed operands, C and Python semantics differ"); +#else + return PyErr_WarnExplicit(PyExc_RuntimeWarning, + "division with oppositely signed operands, C and Python semantics differ", + filename, + lineno, + __Pyx_MODULE_NAME, + NULL); +#endif +} + + +/////////////// DivInt.proto /////////////// + +static CYTHON_INLINE %(type)s __Pyx_div_%(type_name)s(%(type)s, %(type)s); /* proto */ + +/////////////// DivInt /////////////// + +static CYTHON_INLINE %(type)s __Pyx_div_%(type_name)s(%(type)s a, %(type)s b) { + %(type)s q = a / b; + %(type)s r = a - q*b; + q -= ((r != 0) & ((r ^ b) < 0)); + return q; +} + + +/////////////// ModInt.proto /////////////// + +static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s, %(type)s); /* proto */ + +/////////////// ModInt /////////////// + +static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s a, %(type)s b) { + %(type)s r = a %% b; + r += ((r != 0) & ((r ^ b) < 0)) * b; + return r; +} + + +/////////////// ModFloat.proto /////////////// + +static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s, %(type)s); /* proto */ + +/////////////// ModFloat /////////////// + +static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s a, %(type)s b) { + %(type)s r = fmod%(math_h_modifier)s(a, b); + r += ((r != 0) & ((r < 0) ^ (b < 0))) * b; + return r; +} + + +/////////////// IntPow.proto /////////////// + +static CYTHON_INLINE %(type)s %(func_name)s(%(type)s, %(type)s); /* proto */ + +/////////////// IntPow /////////////// + +static CYTHON_INLINE %(type)s %(func_name)s(%(type)s b, %(type)s e) { + %(type)s t = b; + switch (e) { + case 3: + t *= b; + CYTHON_FALLTHROUGH; + case 2: + t *= b; + CYTHON_FALLTHROUGH; + case 1: + return t; + case 0: + return 1; + } + #if %(signed)s + if (unlikely(e<0)) return 0; + #endif + t = 1; + while (likely(e)) { + t *= (b * (e&1)) | ((~e)&1); /* 1 or b */ + b *= b; + e >>= 1; + } + return t; +} diff --git a/contrib/tools/cython/Cython/Utility/Capsule.c b/contrib/tools/cython/Cython/Utility/Capsule.c new file mode 100644 index 00000000000..cc4fe0d8871 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Capsule.c @@ -0,0 +1,20 @@ +//////////////// Capsule.proto //////////////// + +/* Todo: wrap the rest of the functionality in similar functions */ +static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig); + +//////////////// Capsule //////////////// + +static CYTHON_INLINE PyObject * +__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) +{ + PyObject *cobj; + +#if PY_VERSION_HEX >= 0x02070000 + cobj = PyCapsule_New(p, sig, NULL); +#else + cobj = PyCObject_FromVoidPtr(p, NULL); +#endif + + return cobj; +} diff --git a/contrib/tools/cython/Cython/Utility/CommonStructures.c b/contrib/tools/cython/Cython/Utility/CommonStructures.c new file mode 100644 index 00000000000..c7945feb49c --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CommonStructures.c @@ -0,0 +1,86 @@ +/////////////// FetchCommonType.proto /////////////// + +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); + +/////////////// FetchCommonType /////////////// + +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* fake_module; + PyTypeObject* cached_type = NULL; + + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); + if (cached_type) { + if (!PyType_Check((PyObject*)cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", + type->tp_name); + goto bad; + } + if (cached_type->tp_basicsize != type->tp_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + type->tp_name); + goto bad; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; + } + +done: + Py_DECREF(fake_module); + // NOTE: always returns owned reference, or NULL on error + return cached_type; + +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} + + +/////////////// FetchCommonPointer.proto /////////////// + +static void* __Pyx_FetchCommonPointer(void* pointer, const char* name); + +/////////////// FetchCommonPointer /////////////// + + +static void* __Pyx_FetchCommonPointer(void* pointer, const char* name) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject* fake_module = NULL; + PyObject* capsule = NULL; + void* value = NULL; + + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + + capsule = PyObject_GetAttrString(fake_module, name); + if (!capsule) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + capsule = PyCapsule_New(pointer, name, NULL); + if (!capsule) goto bad; + if (PyObject_SetAttrString(fake_module, name, capsule) < 0) + goto bad; + } + value = PyCapsule_GetPointer(capsule, name); + +bad: + Py_XDECREF(capsule); + Py_DECREF(fake_module); + return value; +#else + return pointer; +#endif +} diff --git a/contrib/tools/cython/Cython/Utility/CommonTypes.c b/contrib/tools/cython/Cython/Utility/CommonTypes.c new file mode 100644 index 00000000000..c2403cbf98a --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CommonTypes.c @@ -0,0 +1,48 @@ +/////////////// FetchCommonType.proto /////////////// + +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); + +/////////////// FetchCommonType /////////////// + +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* fake_module; + PyTypeObject* cached_type = NULL; + + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); + if (cached_type) { + if (!PyType_Check((PyObject*)cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", + type->tp_name); + goto bad; + } + if (cached_type->tp_basicsize != type->tp_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + type->tp_name); + goto bad; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; + } + +done: + Py_DECREF(fake_module); + // NOTE: always returns owned reference, or NULL on error + return cached_type; + +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} diff --git a/contrib/tools/cython/Cython/Utility/Complex.c b/contrib/tools/cython/Cython/Utility/Complex.c new file mode 100644 index 00000000000..15d5f544dd7 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Complex.c @@ -0,0 +1,291 @@ +/////////////// Header.proto /////////////// +//@proto_block: h_code + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include <complex> + #else + #include <complex.h> + #endif +#endif + +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +/////////////// RealImag.proto /////////////// + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif + +#if defined(__cplusplus) && CYTHON_CCOMPLEX \ + && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + + +/////////////// Declarations.proto /////////////// +//@proto_block: complex_type_declarations + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< {{real_type}} > {{type_name}}; + #else + typedef {{real_type}} _Complex {{type_name}}; + #endif +#else + typedef struct { {{real_type}} real, imag; } {{type_name}}; +#endif + +static CYTHON_INLINE {{type}} {{type_name}}_from_parts({{real_type}}, {{real_type}}); + +/////////////// Declarations /////////////// + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE {{type}} {{type_name}}_from_parts({{real_type}} x, {{real_type}} y) { + return ::std::complex< {{real_type}} >(x, y); + } + #else + static CYTHON_INLINE {{type}} {{type_name}}_from_parts({{real_type}} x, {{real_type}} y) { + return x + y*({{type}})_Complex_I; + } + #endif +#else + static CYTHON_INLINE {{type}} {{type_name}}_from_parts({{real_type}} x, {{real_type}} y) { + {{type}} z; + z.real = x; + z.imag = y; + return z; + } +#endif + + +/////////////// ToPy.proto /////////////// + +#define __pyx_PyComplex_FromComplex(z) \ + PyComplex_FromDoubles((double)__Pyx_CREAL(z), \ + (double)__Pyx_CIMAG(z)) + + +/////////////// FromPy.proto /////////////// + +static {{type}} __Pyx_PyComplex_As_{{type_name}}(PyObject*); + +/////////////// FromPy /////////////// + +static {{type}} __Pyx_PyComplex_As_{{type_name}}(PyObject* o) { + Py_complex cval; +#if !CYTHON_COMPILING_IN_PYPY + if (PyComplex_CheckExact(o)) + cval = ((PyComplexObject *)o)->cval; + else +#endif + cval = PyComplex_AsCComplex(o); + return {{type_name}}_from_parts( + ({{real_type}})cval.real, + ({{real_type}})cval.imag); +} + + +/////////////// Arithmetic.proto /////////////// + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq{{func_suffix}}(a, b) ((a)==(b)) + #define __Pyx_c_sum{{func_suffix}}(a, b) ((a)+(b)) + #define __Pyx_c_diff{{func_suffix}}(a, b) ((a)-(b)) + #define __Pyx_c_prod{{func_suffix}}(a, b) ((a)*(b)) + #define __Pyx_c_quot{{func_suffix}}(a, b) ((a)/(b)) + #define __Pyx_c_neg{{func_suffix}}(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero{{func_suffix}}(z) ((z)==({{real_type}})0) + #define __Pyx_c_conj{{func_suffix}}(z) (::std::conj(z)) + #if {{is_float}} + #define __Pyx_c_abs{{func_suffix}}(z) (::std::abs(z)) + #define __Pyx_c_pow{{func_suffix}}(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero{{func_suffix}}(z) ((z)==0) + #define __Pyx_c_conj{{func_suffix}}(z) (conj{{m}}(z)) + #if {{is_float}} + #define __Pyx_c_abs{{func_suffix}}(z) (cabs{{m}}(z)) + #define __Pyx_c_pow{{func_suffix}}(a, b) (cpow{{m}}(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq{{func_suffix}}({{type}}, {{type}}); + static CYTHON_INLINE {{type}} __Pyx_c_sum{{func_suffix}}({{type}}, {{type}}); + static CYTHON_INLINE {{type}} __Pyx_c_diff{{func_suffix}}({{type}}, {{type}}); + static CYTHON_INLINE {{type}} __Pyx_c_prod{{func_suffix}}({{type}}, {{type}}); + static CYTHON_INLINE {{type}} __Pyx_c_quot{{func_suffix}}({{type}}, {{type}}); + static CYTHON_INLINE {{type}} __Pyx_c_neg{{func_suffix}}({{type}}); + static CYTHON_INLINE int __Pyx_c_is_zero{{func_suffix}}({{type}}); + static CYTHON_INLINE {{type}} __Pyx_c_conj{{func_suffix}}({{type}}); + #if {{is_float}} + static CYTHON_INLINE {{real_type}} __Pyx_c_abs{{func_suffix}}({{type}}); + static CYTHON_INLINE {{type}} __Pyx_c_pow{{func_suffix}}({{type}}, {{type}}); + #endif +#endif + +/////////////// Arithmetic /////////////// + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq{{func_suffix}}({{type}} a, {{type}} b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE {{type}} __Pyx_c_sum{{func_suffix}}({{type}} a, {{type}} b) { + {{type}} z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE {{type}} __Pyx_c_diff{{func_suffix}}({{type}} a, {{type}} b) { + {{type}} z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE {{type}} __Pyx_c_prod{{func_suffix}}({{type}} a, {{type}} b) { + {{type}} z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + + #if {{is_float}} + static CYTHON_INLINE {{type}} __Pyx_c_quot{{func_suffix}}({{type}} a, {{type}} b) { + if (b.imag == 0) { + return {{type_name}}_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabs{{m}}(b.real) >= fabs{{m}}(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return {{type_name}}_from_parts(a.real / b.real, a.imag / b.imag); + } else { + {{real_type}} r = b.imag / b.real; + {{real_type}} s = ({{real_type}})(1.0) / (b.real + b.imag * r); + return {{type_name}}_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + {{real_type}} r = b.real / b.imag; + {{real_type}} s = ({{real_type}})(1.0) / (b.imag + b.real * r); + return {{type_name}}_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE {{type}} __Pyx_c_quot{{func_suffix}}({{type}} a, {{type}} b) { + if (b.imag == 0) { + return {{type_name}}_from_parts(a.real / b.real, a.imag / b.real); + } else { + {{real_type}} denom = b.real * b.real + b.imag * b.imag; + return {{type_name}}_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + + static CYTHON_INLINE {{type}} __Pyx_c_neg{{func_suffix}}({{type}} a) { + {{type}} z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero{{func_suffix}}({{type}} a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE {{type}} __Pyx_c_conj{{func_suffix}}({{type}} a) { + {{type}} z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if {{is_float}} + static CYTHON_INLINE {{real_type}} __Pyx_c_abs{{func_suffix}}({{type}} z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt{{m}}(z.real*z.real + z.imag*z.imag); + #else + return hypot{{m}}(z.real, z.imag); + #endif + } + static CYTHON_INLINE {{type}} __Pyx_c_pow{{func_suffix}}({{type}} a, {{type}} b) { + {{type}} z; + {{real_type}} r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + {{real_type}} denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + return __Pyx_c_prod{{func_suffix}}(a, a); + case 3: + z = __Pyx_c_prod{{func_suffix}}(a, a); + return __Pyx_c_prod{{func_suffix}}(z, a); + case 4: + z = __Pyx_c_prod{{func_suffix}}(a, a); + return __Pyx_c_prod{{func_suffix}}(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if ((b.imag == 0) && (a.real >= 0)) { + z.real = pow{{m}}(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2{{m}}(0.0, -1.0); + } + } else { + r = __Pyx_c_abs{{func_suffix}}(a); + theta = atan2{{m}}(a.imag, a.real); + } + lnr = log{{m}}(r); + z_r = exp{{m}}(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos{{m}}(z_theta); + z.imag = z_r * sin{{m}}(z_theta); + return z; + } + #endif +#endif diff --git a/contrib/tools/cython/Cython/Utility/Coroutine.c b/contrib/tools/cython/Cython/Utility/Coroutine.c new file mode 100644 index 00000000000..a02578acd0d --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Coroutine.c @@ -0,0 +1,2395 @@ +//////////////////// GeneratorYieldFrom.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_Generator_Yield_From(__pyx_CoroutineObject *gen, PyObject *source); + +//////////////////// GeneratorYieldFrom //////////////////// +//@requires: Generator + +static void __PyxPyIter_CheckErrorAndDecref(PyObject *source) { + PyErr_Format(PyExc_TypeError, + "iter() returned non-iterator of type '%.100s'", + Py_TYPE(source)->tp_name); + Py_DECREF(source); +} + +static CYTHON_INLINE PyObject* __Pyx_Generator_Yield_From(__pyx_CoroutineObject *gen, PyObject *source) { + PyObject *source_gen, *retval; +#ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(source)) { + // TODO: this should only happen for types.coroutine()ed generators, but we can't determine that here + Py_INCREF(source); + source_gen = source; + retval = __Pyx_Generator_Next(source); + } else +#endif + { +#if CYTHON_USE_TYPE_SLOTS + if (likely(Py_TYPE(source)->tp_iter)) { + source_gen = Py_TYPE(source)->tp_iter(source); + if (unlikely(!source_gen)) + return NULL; + if (unlikely(!PyIter_Check(source_gen))) { + __PyxPyIter_CheckErrorAndDecref(source_gen); + return NULL; + } + } else + // CPython also allows non-iterable sequences to be iterated over +#endif + { + source_gen = PyObject_GetIter(source); + if (unlikely(!source_gen)) + return NULL; + } + // source_gen is now the iterator, make the first next() call +#if CYTHON_USE_TYPE_SLOTS + retval = Py_TYPE(source_gen)->tp_iternext(source_gen); +#else + retval = PyIter_Next(source_gen); +#endif + } + if (likely(retval)) { + gen->yieldfrom = source_gen; + return retval; + } + Py_DECREF(source_gen); + return NULL; +} + + +//////////////////// CoroutineYieldFrom.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source); + +//////////////////// CoroutineYieldFrom //////////////////// +//@requires: Coroutine +//@requires: GetAwaitIter + +static PyObject* __Pyx__Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen, PyObject *source) { + PyObject *retval; + PyObject *source_gen = __Pyx__Coroutine_GetAwaitableIter(source); + if (unlikely(!source_gen)) { + return NULL; + } + // source_gen is now the iterator, make the first next() call + if (__Pyx_Coroutine_Check(source_gen)) { + retval = __Pyx_Generator_Next(source_gen); + } else { +#if CYTHON_USE_TYPE_SLOTS + retval = Py_TYPE(source_gen)->tp_iternext(source_gen); +#else + retval = PyIter_Next(source_gen); +#endif + } + if (retval) { + gen->yieldfrom = source_gen; + return retval; + } + Py_DECREF(source_gen); + return NULL; +} + +static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source) { + PyObject *retval; + if (__Pyx_Coroutine_Check(source)) { + if (unlikely(((__pyx_CoroutineObject*)source)->yieldfrom)) { + PyErr_SetString( + PyExc_RuntimeError, + "coroutine is being awaited already"); + return NULL; + } + retval = __Pyx_Generator_Next(source); +#ifdef __Pyx_AsyncGen_USED + // inlined "__pyx_PyAsyncGenASend" handling to avoid the series of generic calls + } else if (__pyx_PyAsyncGenASend_CheckExact(source)) { + retval = __Pyx_async_gen_asend_iternext(source); +#endif + } else { + return __Pyx__Coroutine_Yield_From_Generic(gen, source); + } + if (retval) { + Py_INCREF(source); + gen->yieldfrom = source; + } + return retval; +} + + +//////////////////// GetAwaitIter.proto //////////////////// + +static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o); /*proto*/ +static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o); /*proto*/ + +//////////////////// GetAwaitIter //////////////////// +//@requires: ObjectHandling.c::PyObjectGetMethod +//@requires: ObjectHandling.c::PyObjectCallNoArg +//@requires: ObjectHandling.c::PyObjectCallOneArg + +static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) { +#ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(o)) { + return __Pyx_NewRef(o); + } +#endif + return __Pyx__Coroutine_GetAwaitableIter(o); +} + + +static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) { +#if PY_VERSION_HEX >= 0x030600B3 || defined(_PyErr_FormatFromCause) + _PyErr_FormatFromCause( + PyExc_TypeError, + "'async for' received an invalid object " + "from __anext__: %.100s", + Py_TYPE(source)->tp_name); +#elif PY_MAJOR_VERSION >= 3 + PyObject *exc, *val, *val2, *tb; + assert(PyErr_Occurred()); + PyErr_Fetch(&exc, &val, &tb); + PyErr_NormalizeException(&exc, &val, &tb); + if (tb != NULL) { + PyException_SetTraceback(val, tb); + Py_DECREF(tb); + } + Py_DECREF(exc); + assert(!PyErr_Occurred()); + PyErr_Format( + PyExc_TypeError, + "'async for' received an invalid object " + "from __anext__: %.100s", + Py_TYPE(source)->tp_name); + + PyErr_Fetch(&exc, &val2, &tb); + PyErr_NormalizeException(&exc, &val2, &tb); + Py_INCREF(val); + PyException_SetCause(val2, val); + PyException_SetContext(val2, val); + PyErr_Restore(exc, val2, tb); +#else + // since Py2 does not have exception chaining, it's better to avoid shadowing exceptions there + source++; +#endif +} + +// adapted from genobject.c in Py3.5 +static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) { + PyObject *res; +#if CYTHON_USE_ASYNC_SLOTS + __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj); + if (likely(am && am->am_await)) { + res = (*am->am_await)(obj); + } else +#endif +#if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact) + if (PyCoro_CheckExact(obj)) { + return __Pyx_NewRef(obj); + } else +#endif +#if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE) +#if PY_VERSION_HEX >= 0x030C00A6 + if (PyGen_CheckExact(obj) && (PyGen_GetCode(obj)->co_flags & CO_ITERABLE_COROUTINE)) { +#else + if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) { +#endif + // Python generator marked with "@types.coroutine" decorator + return __Pyx_NewRef(obj); + } else +#endif + { + PyObject *method = NULL; + int is_method = __Pyx_PyObject_GetMethod(obj, PYIDENT("__await__"), &method); + if (likely(is_method)) { + res = __Pyx_PyObject_CallOneArg(method, obj); + } else if (likely(method)) { + res = __Pyx_PyObject_CallNoArg(method); + } else + goto slot_error; + Py_DECREF(method); + } + if (unlikely(!res)) { + // surprisingly, CPython replaces the exception here... + __Pyx_Coroutine_AwaitableIterError(obj); + goto bad; + } + if (unlikely(!PyIter_Check(res))) { + PyErr_Format(PyExc_TypeError, + "__await__() returned non-iterator of type '%.100s'", + Py_TYPE(res)->tp_name); + Py_CLEAR(res); + } else { + int is_coroutine = 0; + #ifdef __Pyx_Coroutine_USED + is_coroutine |= __Pyx_Coroutine_Check(res); + #endif + #if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact) + is_coroutine |= PyCoro_CheckExact(res); + #endif + if (unlikely(is_coroutine)) { + /* __await__ must return an *iterator*, not + a coroutine or another awaitable (see PEP 492) */ + PyErr_SetString(PyExc_TypeError, + "__await__() returned a coroutine"); + Py_CLEAR(res); + } + } + return res; +slot_error: + PyErr_Format(PyExc_TypeError, + "object %.100s can't be used in 'await' expression", + Py_TYPE(obj)->tp_name); +bad: + return NULL; +} + + +//////////////////// AsyncIter.proto //////////////////// + +static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *o); /*proto*/ +static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*proto*/ + +//////////////////// AsyncIter //////////////////// +//@requires: GetAwaitIter +//@requires: ObjectHandling.c::PyObjectCallMethod0 + +static PyObject *__Pyx_Coroutine_GetAsyncIter_Generic(PyObject *obj) { +#if PY_VERSION_HEX < 0x030500B1 + { + PyObject *iter = __Pyx_PyObject_CallMethod0(obj, PYIDENT("__aiter__")); + if (likely(iter)) + return iter; + // FIXME: for the sake of a nicely conforming exception message, assume any AttributeError meant '__aiter__' + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; + } +#else + // avoid C warning about 'unused function' + if ((0)) (void) __Pyx_PyObject_CallMethod0(obj, PYIDENT("__aiter__")); +#endif + + PyErr_Format(PyExc_TypeError, "'async for' requires an object with __aiter__ method, got %.100s", + Py_TYPE(obj)->tp_name); + return NULL; +} + + +static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) { +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(obj)) { + return __Pyx_NewRef(obj); + } +#endif +#if CYTHON_USE_ASYNC_SLOTS + { + __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj); + if (likely(am && am->am_aiter)) { + return (*am->am_aiter)(obj); + } + } +#endif + return __Pyx_Coroutine_GetAsyncIter_Generic(obj); +} + + +static PyObject *__Pyx__Coroutine_AsyncIterNext(PyObject *obj) { +#if PY_VERSION_HEX < 0x030500B1 + { + PyObject *value = __Pyx_PyObject_CallMethod0(obj, PYIDENT("__anext__")); + if (likely(value)) + return value; + } + // FIXME: for the sake of a nicely conforming exception message, assume any AttributeError meant '__anext__' + if (PyErr_ExceptionMatches(PyExc_AttributeError)) +#endif + PyErr_Format(PyExc_TypeError, "'async for' requires an object with __anext__ method, got %.100s", + Py_TYPE(obj)->tp_name); + return NULL; +} + + +static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) { +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(obj)) { + return __Pyx_async_gen_anext(obj); + } +#endif +#if CYTHON_USE_ASYNC_SLOTS + { + __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj); + if (likely(am && am->am_anext)) { + return (*am->am_anext)(obj); + } + } +#endif + return __Pyx__Coroutine_AsyncIterNext(obj); +} + + +//////////////////// pep479.proto //////////////////// + +static void __Pyx_Generator_Replace_StopIteration(int in_async_gen); /*proto*/ + +//////////////////// pep479 //////////////////// +//@requires: Exceptions.c::GetException + +static void __Pyx_Generator_Replace_StopIteration(CYTHON_UNUSED int in_async_gen) { + PyObject *exc, *val, *tb, *cur_exc; + __Pyx_PyThreadState_declare + #ifdef __Pyx_StopAsyncIteration_USED + int is_async_stopiteration = 0; + #endif + + cur_exc = PyErr_Occurred(); + if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) { + #ifdef __Pyx_StopAsyncIteration_USED + if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, __Pyx_PyExc_StopAsyncIteration))) { + is_async_stopiteration = 1; + } else + #endif + return; + } + + __Pyx_PyThreadState_assign + // Chain exceptions by moving Stop(Async)Iteration to exc_info before creating the RuntimeError. + // In Py2.x, no chaining happens, but the exception still stays visible in exc_info. + __Pyx_GetException(&exc, &val, &tb); + Py_XDECREF(exc); + Py_XDECREF(val); + Py_XDECREF(tb); + PyErr_SetString(PyExc_RuntimeError, + #ifdef __Pyx_StopAsyncIteration_USED + is_async_stopiteration ? "async generator raised StopAsyncIteration" : + in_async_gen ? "async generator raised StopIteration" : + #endif + "generator raised StopIteration"); +} + + +//////////////////// CoroutineBase.proto //////////////////// +//@substitute: naming + +typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *); + +#if CYTHON_USE_EXC_INFO_STACK +// See https://bugs.python.org/issue25612 +#define __Pyx_ExcInfoStruct _PyErr_StackItem +#else +// Minimal replacement struct for Py<3.7, without the Py3.7 exception state stack. +typedef struct { + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; +} __Pyx_ExcInfoStruct; +#endif + +typedef struct { + PyObject_HEAD + __pyx_coroutine_body_t body; + PyObject *closure; + __Pyx_ExcInfoStruct gi_exc_state; + PyObject *gi_weakreflist; + PyObject *classobj; + PyObject *yieldfrom; + PyObject *gi_name; + PyObject *gi_qualname; + PyObject *gi_modulename; + PyObject *gi_code; + PyObject *gi_frame; + int resume_label; + // using T_BOOL for property below requires char value + char is_running; +} __pyx_CoroutineObject; + +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); /*proto*/ + +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); /*proto*/ + +static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self); +static int __Pyx_Coroutine_clear(PyObject *self); /*proto*/ +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); /*proto*/ +static PyObject *__Pyx_Coroutine_Close(PyObject *self); /*proto*/ +static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); /*proto*/ + +// macros for exception state swapping instead of inline functions to make use of the local thread state context +#if CYTHON_USE_EXC_INFO_STACK +#define __Pyx_Coroutine_SwapException(self) +#define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state) +#else +#define __Pyx_Coroutine_SwapException(self) { \ + __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback); \ + __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state); \ + } +#define __Pyx_Coroutine_ResetAndClearException(self) { \ + __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback); \ + (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL; \ + } +#endif + +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyGen_FetchStopIterationValue(pvalue) \ + __Pyx_PyGen__FetchStopIterationValue($local_tstate_cname, pvalue) +#else +#define __Pyx_PyGen_FetchStopIterationValue(pvalue) \ + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue) +#endif +static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); /*proto*/ +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state); /*proto*/ + + +//////////////////// Coroutine.proto //////////////////// + +#define __Pyx_Coroutine_USED +static PyTypeObject *__pyx_CoroutineType = 0; +static PyTypeObject *__pyx_CoroutineAwaitType = 0; +#define __Pyx_Coroutine_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineType) +// __Pyx_Coroutine_Check(obj): see override for IterableCoroutine below +#define __Pyx_Coroutine_Check(obj) __Pyx_Coroutine_CheckExact(obj) +#define __Pyx_CoroutineAwait_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineAwaitType) + +#define __Pyx_Coroutine_New(body, code, closure, name, qualname, module_name) \ + __Pyx__Coroutine_New(__pyx_CoroutineType, body, code, closure, name, qualname, module_name) + +static int __pyx_Coroutine_init(void); /*proto*/ +static PyObject *__Pyx__Coroutine_await(PyObject *coroutine); /*proto*/ + +typedef struct { + PyObject_HEAD + PyObject *coroutine; +} __pyx_CoroutineAwaitObject; + +static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self, PyObject *arg); /*proto*/ +static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args); /*proto*/ + + +//////////////////// Generator.proto //////////////////// + +#define __Pyx_Generator_USED +static PyTypeObject *__pyx_GeneratorType = 0; +#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType) + +#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name) \ + __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name) + +static PyObject *__Pyx_Generator_Next(PyObject *self); +static int __pyx_Generator_init(void); /*proto*/ + + +//////////////////// AsyncGen //////////////////// +//@requires: AsyncGen.c::AsyncGenerator +// -> empty, only delegates to separate file + + +//////////////////// CoroutineBase //////////////////// +//@substitute: naming +//@requires: Exceptions.c::PyErrFetchRestore +//@requires: Exceptions.c::PyThreadStateGet +//@requires: Exceptions.c::SwapException +//@requires: Exceptions.c::RaiseException +//@requires: Exceptions.c::SaveResetException +//@requires: ObjectHandling.c::PyObjectCallMethod1 +//@requires: ObjectHandling.c::PyObjectGetAttrStr +//@requires: CommonStructures.c::FetchCommonType + +#include <structmember.h> +#include <frameobject.h> +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif + +#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) + +// If StopIteration exception is set, fetches its 'value' +// attribute if any, otherwise sets pvalue to None. +// +// Returns 0 if no exception or StopIteration is set. +// If any other exception is set, returns -1 and leaves +// pvalue unchanged. +static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *$local_tstate_cname, PyObject **pvalue) { + PyObject *et, *ev, *tb; + PyObject *value = NULL; + + __Pyx_ErrFetch(&et, &ev, &tb); + + if (!et) { + Py_XDECREF(tb); + Py_XDECREF(ev); + Py_INCREF(Py_None); + *pvalue = Py_None; + return 0; + } + + // most common case: plain StopIteration without or with separate argument + if (likely(et == PyExc_StopIteration)) { + if (!ev) { + Py_INCREF(Py_None); + value = Py_None; + } +#if PY_VERSION_HEX >= 0x030300A0 + else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) { + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); + } +#endif + // PyErr_SetObject() and friends put the value directly into ev + else if (unlikely(PyTuple_Check(ev))) { + // if it's a tuple, it is interpreted as separate constructor arguments (surprise!) + if (PyTuple_GET_SIZE(ev) >= 1) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + value = PyTuple_GET_ITEM(ev, 0); + Py_INCREF(value); +#else + value = PySequence_ITEM(ev, 0); +#endif + } else { + Py_INCREF(Py_None); + value = Py_None; + } + Py_DECREF(ev); + } + else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { + // 'steal' reference to ev + value = ev; + } + if (likely(value)) { + Py_XDECREF(tb); + Py_DECREF(et); + *pvalue = value; + return 0; + } + } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + + // otherwise: normalise and check what that gives us + PyErr_NormalizeException(&et, &ev, &tb); + if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { + // looks like normalisation failed - raise the new exception + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + Py_XDECREF(tb); + Py_DECREF(et); +#if PY_VERSION_HEX >= 0x030300A0 + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); +#else + { + PyObject* args = __Pyx_PyObject_GetAttrStr(ev, PYIDENT("args")); + Py_DECREF(ev); + if (likely(args)) { + value = PySequence_GetItem(args, 0); + Py_DECREF(args); + } + if (unlikely(!value)) { + __Pyx_ErrRestore(NULL, NULL, NULL); + Py_INCREF(Py_None); + value = Py_None; + } + } +#endif + *pvalue = value; + return 0; +} + +static CYTHON_INLINE +void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) { + PyObject *t, *v, *tb; + t = exc_state->exc_type; + v = exc_state->exc_value; + tb = exc_state->exc_traceback; + + exc_state->exc_type = NULL; + exc_state->exc_value = NULL; + exc_state->exc_traceback = NULL; + + Py_XDECREF(t); + Py_XDECREF(v); + Py_XDECREF(tb); +} + +#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) { + const char *msg; + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check((PyObject*)gen)) { + msg = "coroutine already executing"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) { + msg = "async generator already executing"; + #endif + } else { + msg = "generator already executing"; + } + PyErr_SetString(PyExc_ValueError, msg); +} + +#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) { + const char *msg; + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check(gen)) { + msg = "can't send non-None value to a just-started coroutine"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(gen)) { + msg = "can't send non-None value to a just-started async generator"; + #endif + } else { + msg = "can't send non-None value to a just-started generator"; + } + PyErr_SetString(PyExc_TypeError, msg); +} + +#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) { + #ifdef __Pyx_Coroutine_USED + if (!closing && __Pyx_Coroutine_Check(gen)) { + // `self` is an exhausted coroutine: raise an error, + // except when called from gen_close(), which should + // always be a silent method. + PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine"); + } else + #endif + if (value) { + // `gen` is an exhausted generator: + // only set exception if called from send(). + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); + else + #endif + PyErr_SetNone(PyExc_StopIteration); + } +} + +static +PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) { + __Pyx_PyThreadState_declare + PyThreadState *tstate; + __Pyx_ExcInfoStruct *exc_state; + PyObject *retval; + + assert(!self->is_running); + + if (unlikely(self->resume_label == 0)) { + if (unlikely(value && value != Py_None)) { + return __Pyx_Coroutine_NotStartedError((PyObject*)self); + } + } + + if (unlikely(self->resume_label == -1)) { + return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing); + } + +#if CYTHON_FAST_THREAD_STATE + __Pyx_PyThreadState_assign + tstate = $local_tstate_cname; +#else + tstate = __Pyx_PyThreadState_Current; +#endif + + // Traceback/Frame rules pre-Py3.7: + // - on entry, save external exception state in self->gi_exc_state, restore it on exit + // - on exit, keep internally generated exceptions in self->gi_exc_state, clear everything else + // - on entry, set "f_back" pointer of internal exception traceback to (current) outer call frame + // - on exit, clear "f_back" of internal exception traceback + // - do not touch external frames and tracebacks + + // Traceback/Frame rules for Py3.7+ (CYTHON_USE_EXC_INFO_STACK): + // - on entry, push internal exception state in self->gi_exc_state on the exception stack + // - on exit, keep internally generated exceptions in self->gi_exc_state, clear everything else + // - on entry, set "f_back" pointer of internal exception traceback to (current) outer call frame + // - on exit, clear "f_back" of internal exception traceback + // - do not touch external frames and tracebacks + + exc_state = &self->gi_exc_state; + if (exc_state->exc_type) { + #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON + // FIXME: what to do in PyPy? + #else + // Generators always return to their most recent caller, not + // necessarily their creator. + if (exc_state->exc_traceback) { + PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback; + PyFrameObject *f = tb->tb_frame; + + assert(f->f_back == NULL); + #if PY_VERSION_HEX >= 0x030B00A1 + // PyThreadState_GetFrame returns NULL if there isn't a current frame + // which is a valid state so no need to check + f->f_back = PyThreadState_GetFrame(tstate); + #else + Py_XINCREF(tstate->frame); + f->f_back = tstate->frame; + #endif + } + #endif + } + +#if CYTHON_USE_EXC_INFO_STACK + // See https://bugs.python.org/issue25612 + exc_state->previous_item = tstate->exc_info; + tstate->exc_info = exc_state; +#else + if (exc_state->exc_type) { + // We were in an except handler when we left, + // restore the exception state which was put aside. + __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); + // self->exc_* now holds the exception state of the caller + } else { + // save away the exception state of the caller + __Pyx_Coroutine_ExceptionClear(exc_state); + __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); + } +#endif + + self->is_running = 1; + retval = self->body((PyObject *) self, tstate, value); + self->is_running = 0; + +#if CYTHON_USE_EXC_INFO_STACK + // See https://bugs.python.org/issue25612 + exc_state = &self->gi_exc_state; + tstate->exc_info = exc_state->previous_item; + exc_state->previous_item = NULL; + // Cut off the exception frame chain so that we can reconnect it on re-entry above. + __Pyx_Coroutine_ResetFrameBackpointer(exc_state); +#endif + + return retval; +} + +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) { + // Don't keep the reference to f_back any longer than necessary. It + // may keep a chain of frames alive or it could create a reference + // cycle. + PyObject *exc_tb = exc_state->exc_traceback; + + if (likely(exc_tb)) { +#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON + // FIXME: what to do in PyPy? +#else + PyTracebackObject *tb = (PyTracebackObject *) exc_tb; + PyFrameObject *f = tb->tb_frame; + Py_CLEAR(f->f_back); +#endif + } +} + +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) { + if (unlikely(!retval)) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (!__Pyx_PyErr_Occurred()) { + // method call must not terminate with NULL without setting an exception + PyObject *exc = PyExc_StopIteration; + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + exc = __Pyx_PyExc_StopAsyncIteration; + #endif + __Pyx_PyErr_SetNone(exc); + } + } + return retval; +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) +static CYTHON_INLINE +PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) { +#if PY_VERSION_HEX <= 0x030A00A1 + return _PyGen_Send(gen, arg); +#else + PyObject *result; + // PyIter_Send() asserts non-NULL arg + if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) { + if (PyAsyncGen_CheckExact(gen)) { + assert(result == Py_None); + PyErr_SetNone(PyExc_StopAsyncIteration); + } + else if (result == Py_None) { + PyErr_SetNone(PyExc_StopIteration); + } + else { + _PyGen_SetStopIterationValue(result); + } + Py_CLEAR(result); + } + return result; +#endif +} +#endif + +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { + PyObject *ret; + PyObject *val = NULL; + __Pyx_Coroutine_Undelegate(gen); + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val); + // val == NULL on failure => pass on exception + ret = __Pyx_Coroutine_SendEx(gen, val, 0); + Py_XDECREF(val); + return ret; +} + +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { + PyObject *retval; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + // FIXME: does this really need an INCREF() ? + //Py_INCREF(yf); + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + ret = __Pyx_async_gen_asend_send(yf, value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + // _PyGen_Send() is not exported before Py3.6 + if (PyGen_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + // _PyGen_Send() is not exported before Py3.6 + if (PyCoro_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif + { + if (value == Py_None) + ret = Py_TYPE(yf)->tp_iternext(yf); + else + ret = __Pyx_PyObject_CallMethod1(yf, PYIDENT("send"), value); + } + gen->is_running = 0; + //Py_DECREF(yf); + if (likely(ret)) { + return ret; + } + retval = __Pyx_Coroutine_FinishDelegation(gen); + } else { + retval = __Pyx_Coroutine_SendEx(gen, value, 0); + } + return __Pyx_Coroutine_MethodReturn(self, retval); +} + +// This helper function is used by gen_close and gen_throw to +// close a subiterator being delegated to by yield-from. +static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { + PyObject *retval = NULL; + int err = 0; + + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + if (__Pyx_CoroutineAwait_CheckExact(yf)) { + retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + retval = __Pyx_async_gen_asend_close(yf, NULL); + // cannot fail + } else + if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { + retval = __Pyx_async_gen_athrow_close(yf, NULL); + // cannot fail + } else + #endif + { + PyObject *meth; + gen->is_running = 1; + meth = __Pyx_PyObject_GetAttrStr(yf, PYIDENT("close")); + if (unlikely(!meth)) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_WriteUnraisable(yf); + } + PyErr_Clear(); + } else { + retval = PyObject_CallFunction(meth, NULL); + Py_DECREF(meth); + if (!retval) + err = -1; + } + gen->is_running = 0; + } + Py_XDECREF(retval); + return err; +} + +static PyObject *__Pyx_Generator_Next(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + // FIXME: does this really need an INCREF() ? + //Py_INCREF(yf); + // YieldFrom code ensures that yf is an iterator + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Generator_Next(yf); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + // _PyGen_Send() is not exported before Py3.6 + if (PyGen_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + ret = __Pyx_Coroutine_Send(yf, Py_None); + } else + #endif + ret = Py_TYPE(yf)->tp_iternext(yf); + gen->is_running = 0; + //Py_DECREF(yf); + if (likely(ret)) { + return ret; + } + return __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_SendEx(gen, Py_None, 0); +} + +static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) { + return __Pyx_Coroutine_Close(self); +} + +static PyObject *__Pyx_Coroutine_Close(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *retval, *raised_exception; + PyObject *yf = gen->yieldfrom; + int err = 0; + + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + + if (yf) { + Py_INCREF(yf); + err = __Pyx_Coroutine_CloseIter(gen, yf); + __Pyx_Coroutine_Undelegate(gen); + Py_DECREF(yf); + } + if (err == 0) + PyErr_SetNone(PyExc_GeneratorExit); + retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); + if (unlikely(retval)) { + const char *msg; + Py_DECREF(retval); + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check(self)) { + msg = "coroutine ignored GeneratorExit"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(self)) { +#if PY_VERSION_HEX < 0x03060000 + msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)"; +#else + msg = "async generator ignored GeneratorExit"; +#endif + #endif + } else { + msg = "generator ignored GeneratorExit"; + } + PyErr_SetString(PyExc_RuntimeError, msg); + return NULL; + } + raised_exception = PyErr_Occurred(); + if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { + // ignore these errors + if (raised_exception) PyErr_Clear(); + Py_INCREF(Py_None); + return Py_None; + } + return NULL; +} + +static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb, + PyObject *args, int close_on_genexit) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *yf = gen->yieldfrom; + + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + + if (yf) { + PyObject *ret; + Py_INCREF(yf); + if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) { + // Asynchronous generators *should not* be closed right away. + // We have to allow some awaits to work it through, hence the + // `close_on_genexit` parameter here. + int err = __Pyx_Coroutine_CloseIter(gen, yf); + Py_DECREF(yf); + __Pyx_Coroutine_Undelegate(gen); + if (err < 0) + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); + goto throw_here; + } + gen->is_running = 1; + if (0 + #ifdef __Pyx_Generator_USED + || __Pyx_Generator_CheckExact(yf) + #endif + #ifdef __Pyx_Coroutine_USED + || __Pyx_Coroutine_Check(yf) + #endif + ) { + ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { + ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); + #endif + } else { + PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, PYIDENT("throw")); + if (unlikely(!meth)) { + Py_DECREF(yf); + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + gen->is_running = 0; + return NULL; + } + PyErr_Clear(); + __Pyx_Coroutine_Undelegate(gen); + gen->is_running = 0; + goto throw_here; + } + if (likely(args)) { + ret = PyObject_CallObject(meth, args); + } else { + // "tb" or even "val" might be NULL, but that also correctly terminates the argument list + ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL); + } + Py_DECREF(meth); + } + gen->is_running = 0; + Py_DECREF(yf); + if (!ret) { + ret = __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_MethodReturn(self, ret); + } +throw_here: + __Pyx_Raise(typ, val, tb, NULL); + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); +} + +static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { + PyObject *typ; + PyObject *val = NULL; + PyObject *tb = NULL; + + if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) + return NULL; + + return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1); +} + +static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) { + Py_VISIT(exc_state->exc_type); + Py_VISIT(exc_state->exc_value); + Py_VISIT(exc_state->exc_traceback); + return 0; +} + +static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) { + Py_VISIT(gen->closure); + Py_VISIT(gen->classobj); + Py_VISIT(gen->yieldfrom); + return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg); +} + +static int __Pyx_Coroutine_clear(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + + Py_CLEAR(gen->closure); + Py_CLEAR(gen->classobj); + Py_CLEAR(gen->yieldfrom); + __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state); +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer); + } +#endif + Py_CLEAR(gen->gi_code); + Py_CLEAR(gen->gi_frame); + Py_CLEAR(gen->gi_name); + Py_CLEAR(gen->gi_qualname); + Py_CLEAR(gen->gi_modulename); + return 0; +} + +static void __Pyx_Coroutine_dealloc(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + + PyObject_GC_UnTrack(gen); + if (gen->gi_weakreflist != NULL) + PyObject_ClearWeakRefs(self); + + if (gen->resume_label >= 0) { + // Generator is paused or unstarted, so we need to close + PyObject_GC_Track(self); +#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE + if (PyObject_CallFinalizerFromDealloc(self)) +#else + Py_TYPE(gen)->tp_del(self); + if (Py_REFCNT(self) > 0) +#endif + { + // resurrected. :( + return; + } + PyObject_GC_UnTrack(self); + } + +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + /* We have to handle this case for asynchronous generators + right here, because this code has to be between UNTRACK + and GC_Del. */ + Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer); + } +#endif + __Pyx_Coroutine_clear(self); + PyObject_GC_Del(gen); +} + +static void __Pyx_Coroutine_del(PyObject *self) { + PyObject *error_type, *error_value, *error_traceback; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + __Pyx_PyThreadState_declare + + if (gen->resume_label < 0) { + // already terminated => nothing to clean up + return; + } + +#if !CYTHON_USE_TP_FINALIZE + // Temporarily resurrect the object. + assert(self->ob_refcnt == 0); + __Pyx_SET_REFCNT(self, 1); +#endif + + __Pyx_PyThreadState_assign + + // Save the current exception, if any. + __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); + +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self; + PyObject *finalizer = agen->ag_finalizer; + if (finalizer && !agen->ag_closed) { + PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self); + if (unlikely(!res)) { + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + // Restore the saved exception. + __Pyx_ErrRestore(error_type, error_value, error_traceback); + return; + } + } +#endif + + if (unlikely(gen->resume_label == 0 && !error_value)) { +#ifdef __Pyx_Coroutine_USED +#ifdef __Pyx_Generator_USED + // only warn about (async) coroutines + if (!__Pyx_Generator_CheckExact(self)) +#endif + { + // untrack dead object as we are executing Python code (which might trigger GC) + PyObject_GC_UnTrack(self); +#if PY_MAJOR_VERSION >= 3 /* PY_VERSION_HEX >= 0x03030000*/ || defined(PyErr_WarnFormat) + if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0)) + PyErr_WriteUnraisable(self); +#else + {PyObject *msg; + char *cmsg; + #if CYTHON_COMPILING_IN_PYPY + msg = NULL; + cmsg = (char*) "coroutine was never awaited"; + #else + char *cname; + PyObject *qualname; + qualname = gen->gi_qualname; + cname = PyString_AS_STRING(qualname); + msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname); + + if (unlikely(!msg)) { + PyErr_Clear(); + cmsg = (char*) "coroutine was never awaited"; + } else { + cmsg = PyString_AS_STRING(msg); + } + #endif + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) + PyErr_WriteUnraisable(self); + Py_XDECREF(msg);} +#endif + PyObject_GC_Track(self); + } +#endif /*__Pyx_Coroutine_USED*/ + } else { + PyObject *res = __Pyx_Coroutine_Close(self); + if (unlikely(!res)) { + if (PyErr_Occurred()) + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + } + + // Restore the saved exception. + __Pyx_ErrRestore(error_type, error_value, error_traceback); + +#if !CYTHON_USE_TP_FINALIZE + // Undo the temporary resurrection; can't use DECREF here, it would + // cause a recursive call. + assert(Py_REFCNT(self) > 0); + if (--self->ob_refcnt == 0) { + // this is the normal path out + return; + } + + // close() resurrected it! Make it look like the original Py_DECREF + // never happened. + { + Py_ssize_t refcnt = Py_REFCNT(self); + _Py_NewReference(self); + __Pyx_SET_REFCNT(self, refcnt); + } +#if CYTHON_COMPILING_IN_CPYTHON + assert(PyType_IS_GC(Py_TYPE(self)) && + _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); + + // If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so + // we need to undo that. + _Py_DEC_REFTOTAL; +#endif + // If Py_TRACE_REFS, _Py_NewReference re-added self to the object + // chain, so no more to do there. + // If COUNT_ALLOCS, the original decref bumped tp_frees, and + // _Py_NewReference bumped tp_allocs: both of those need to be + // undone. +#ifdef COUNT_ALLOCS + --Py_TYPE(self)->tp_frees; + --Py_TYPE(self)->tp_allocs; +#endif +#endif +} + +static PyObject * +__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) +{ + PyObject *name = self->gi_name; + // avoid NULL pointer dereference during garbage collection + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} + +static int +__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; + +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + tmp = self->gi_name; + Py_INCREF(value); + self->gi_name = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) +{ + PyObject *name = self->gi_qualname; + // avoid NULL pointer dereference during garbage collection + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} + +static int +__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; + +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + tmp = self->gi_qualname; + Py_INCREF(value); + self->gi_qualname = value; + Py_XDECREF(tmp); + return 0; +} + + +static PyObject * +__Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) +{ + PyObject *frame = self->gi_frame; + if (!frame) { + if (unlikely(!self->gi_code)) { + // Avoid doing something stupid, e.g. during garbage collection. + Py_RETURN_NONE; + } + frame = (PyObject *) PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/ + $moddict_cname, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (unlikely(!frame)) + return NULL; + // keep the frame cached once it's created + self->gi_frame = frame; + } + Py_INCREF(frame); + return frame; +} + +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); + if (unlikely(!gen)) + return NULL; + return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name); +} + +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + gen->body = body; + gen->closure = closure; + Py_XINCREF(closure); + gen->is_running = 0; + gen->resume_label = 0; + gen->classobj = NULL; + gen->yieldfrom = NULL; + gen->gi_exc_state.exc_type = NULL; + gen->gi_exc_state.exc_value = NULL; + gen->gi_exc_state.exc_traceback = NULL; +#if CYTHON_USE_EXC_INFO_STACK + gen->gi_exc_state.previous_item = NULL; +#endif + gen->gi_weakreflist = NULL; + Py_XINCREF(qualname); + gen->gi_qualname = qualname; + Py_XINCREF(name); + gen->gi_name = name; + Py_XINCREF(module_name); + gen->gi_modulename = module_name; + Py_XINCREF(code); + gen->gi_code = code; + gen->gi_frame = NULL; + + PyObject_GC_Track(gen); + return gen; +} + + +//////////////////// Coroutine //////////////////// +//@requires: CoroutineBase +//@requires: PatchGeneratorABC +//@requires: ObjectHandling.c::PyObject_GenericGetAttrNoDict + +static void __Pyx_CoroutineAwait_dealloc(PyObject *self) { + PyObject_GC_UnTrack(self); + Py_CLEAR(((__pyx_CoroutineAwaitObject*)self)->coroutine); + PyObject_GC_Del(self); +} + +static int __Pyx_CoroutineAwait_traverse(__pyx_CoroutineAwaitObject *self, visitproc visit, void *arg) { + Py_VISIT(self->coroutine); + return 0; +} + +static int __Pyx_CoroutineAwait_clear(__pyx_CoroutineAwaitObject *self) { + Py_CLEAR(self->coroutine); + return 0; +} + +static PyObject *__Pyx_CoroutineAwait_Next(__pyx_CoroutineAwaitObject *self) { + return __Pyx_Generator_Next(self->coroutine); +} + +static PyObject *__Pyx_CoroutineAwait_Send(__pyx_CoroutineAwaitObject *self, PyObject *value) { + return __Pyx_Coroutine_Send(self->coroutine, value); +} + +static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args) { + return __Pyx_Coroutine_Throw(self->coroutine, args); +} + +static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self, CYTHON_UNUSED PyObject *arg) { + return __Pyx_Coroutine_Close(self->coroutine); +} + +static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) { + Py_INCREF(self); + return self; +} + +#if !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_CoroutineAwait_no_new(CYTHON_UNUSED PyTypeObject *type, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwargs) { + PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead"); + return NULL; +} +#endif + +static PyMethodDef __pyx_CoroutineAwait_methods[] = { + {"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O, + (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next yielded value or raise StopIteration.")}, + {"throw", (PyCFunction) __Pyx_CoroutineAwait_Throw, METH_VARARGS, + (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next yielded value or raise StopIteration.")}, + {"close", (PyCFunction) __Pyx_CoroutineAwait_Close, METH_NOARGS, + (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_CoroutineAwaitType_type = { + PyVarObject_HEAD_INIT(0, 0) + "coroutine_wrapper", /*tp_name*/ + sizeof(__pyx_CoroutineAwaitObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __Pyx_CoroutineAwait_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_as_async resp. tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + PyDoc_STR("A wrapper object implementing __await__ for coroutines."), /*tp_doc*/ + (traverseproc) __Pyx_CoroutineAwait_traverse, /*tp_traverse*/ + (inquiry) __Pyx_CoroutineAwait_clear, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __Pyx_CoroutineAwait_self, /*tp_iter*/ + (iternextfunc) __Pyx_CoroutineAwait_Next, /*tp_iternext*/ + __pyx_CoroutineAwait_methods, /*tp_methods*/ + 0 , /*tp_members*/ + 0 , /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ +#if !CYTHON_COMPILING_IN_PYPY + __Pyx_CoroutineAwait_no_new, /*tp_new*/ +#else + 0, /*tp_new*/ +#endif + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + +#if PY_VERSION_HEX < 0x030500B1 || defined(__Pyx_IterableCoroutine_USED) || CYTHON_USE_ASYNC_SLOTS +static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) { + __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_CoroutineAwaitType); + if (unlikely(!await)) return NULL; + Py_INCREF(coroutine); + await->coroutine = coroutine; + PyObject_GC_Track(await); + return (PyObject*)await; +} +#endif + +#if PY_VERSION_HEX < 0x030500B1 +static PyObject *__Pyx_Coroutine_await_method(PyObject *coroutine, CYTHON_UNUSED PyObject *arg) { + return __Pyx__Coroutine_await(coroutine); +} +#endif + +#if defined(__Pyx_IterableCoroutine_USED) || CYTHON_USE_ASYNC_SLOTS +static PyObject *__Pyx_Coroutine_await(PyObject *coroutine) { + if (unlikely(!coroutine || !__Pyx_Coroutine_Check(coroutine))) { + PyErr_SetString(PyExc_TypeError, "invalid input, expected coroutine"); + return NULL; + } + return __Pyx__Coroutine_await(coroutine); +} +#endif + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1 +static PyObject *__Pyx_Coroutine_compare(PyObject *obj, PyObject *other, int op) { + PyObject* result; + switch (op) { + case Py_EQ: result = (other == obj) ? Py_True : Py_False; break; + case Py_NE: result = (other != obj) ? Py_True : Py_False; break; + default: + result = Py_NotImplemented; + } + Py_INCREF(result); + return result; +} +#endif + +static PyMethodDef __pyx_Coroutine_methods[] = { + {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, + (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next iterated value or raise StopIteration.")}, + {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, + (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next iterated value or raise StopIteration.")}, + {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, + (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")}, +#if PY_VERSION_HEX < 0x030500B1 + {"__await__", (PyCFunction) __Pyx_Coroutine_await_method, METH_NOARGS, + (char*) PyDoc_STR("__await__() -> return an iterator to be used in await expression.")}, +#endif + {0, 0, 0, 0} +}; + +static PyMemberDef __pyx_Coroutine_memberlist[] = { + {(char *) "cr_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, + {(char*) "cr_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, + (char*) PyDoc_STR("object being awaited, or None")}, + {(char*) "cr_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL}, + {(char *) "__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), PY_WRITE_RESTRICTED, 0}, + {0, 0, 0, 0, 0} +}; + +static PyGetSetDef __pyx_Coroutine_getsets[] = { + {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, + (char*) PyDoc_STR("name of the coroutine"), 0}, + {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, + (char*) PyDoc_STR("qualified name of the coroutine"), 0}, + {(char *) "cr_frame", (getter)__Pyx_Coroutine_get_frame, NULL, + (char*) PyDoc_STR("Frame of the coroutine"), 0}, + {0, 0, 0, 0, 0} +}; + +#if CYTHON_USE_ASYNC_SLOTS +static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async = { + __Pyx_Coroutine_await, /*am_await*/ + 0, /*am_aiter*/ + 0, /*am_anext*/ +#if PY_VERSION_HEX >= 0x030A00A3 + 0, /*am_send*/ +#endif +}; +#endif + +static PyTypeObject __pyx_CoroutineType_type = { + PyVarObject_HEAD_INIT(0, 0) + "coroutine", /*tp_name*/ + sizeof(__pyx_CoroutineObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __Pyx_Coroutine_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ +#if CYTHON_USE_ASYNC_SLOTS + &__pyx_Coroutine_as_async, /*tp_as_async (tp_reserved) - Py3 only! */ +#else + 0, /*tp_reserved*/ +#endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/ + 0, /*tp_doc*/ + (traverseproc) __Pyx_Coroutine_traverse, /*tp_traverse*/ + 0, /*tp_clear*/ +#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1 + // in order to (mis-)use tp_reserved above, we must also implement tp_richcompare + __Pyx_Coroutine_compare, /*tp_richcompare*/ +#else + 0, /*tp_richcompare*/ +#endif + offsetof(__pyx_CoroutineObject, gi_weakreflist), /*tp_weaklistoffset*/ + // no tp_iter() as iterator is only available through __await__() + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_Coroutine_methods, /*tp_methods*/ + __pyx_Coroutine_memberlist, /*tp_members*/ + __pyx_Coroutine_getsets, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +#if CYTHON_USE_TP_FINALIZE + 0, /*tp_del*/ +#else + __Pyx_Coroutine_del, /*tp_del*/ +#endif + 0, /*tp_version_tag*/ +#if CYTHON_USE_TP_FINALIZE + __Pyx_Coroutine_del, /*tp_finalize*/ +#elif PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + +static int __pyx_Coroutine_init(void) { + // on Windows, C-API functions can't be used in slots statically + __pyx_CoroutineType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx_CoroutineType = __Pyx_FetchCommonType(&__pyx_CoroutineType_type); + if (unlikely(!__pyx_CoroutineType)) + return -1; + +#ifdef __Pyx_IterableCoroutine_USED + if (unlikely(__pyx_IterableCoroutine_init() == -1)) + return -1; +#endif + + __pyx_CoroutineAwaitType = __Pyx_FetchCommonType(&__pyx_CoroutineAwaitType_type); + if (unlikely(!__pyx_CoroutineAwaitType)) + return -1; + return 0; +} + + +//////////////////// IterableCoroutine.proto //////////////////// + +#define __Pyx_IterableCoroutine_USED + +static PyTypeObject *__pyx_IterableCoroutineType = 0; + +#undef __Pyx_Coroutine_Check +#define __Pyx_Coroutine_Check(obj) (__Pyx_Coroutine_CheckExact(obj) || (Py_TYPE(obj) == __pyx_IterableCoroutineType)) + +#define __Pyx_IterableCoroutine_New(body, code, closure, name, qualname, module_name) \ + __Pyx__Coroutine_New(__pyx_IterableCoroutineType, body, code, closure, name, qualname, module_name) + +static int __pyx_IterableCoroutine_init(void);/*proto*/ + + +//////////////////// IterableCoroutine //////////////////// +//@requires: Coroutine +//@requires: CommonStructures.c::FetchCommonType + +static PyTypeObject __pyx_IterableCoroutineType_type = { + PyVarObject_HEAD_INIT(0, 0) + "iterable_coroutine", /*tp_name*/ + sizeof(__pyx_CoroutineObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __Pyx_Coroutine_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ +#if CYTHON_USE_ASYNC_SLOTS + &__pyx_Coroutine_as_async, /*tp_as_async (tp_reserved) - Py3 only! */ +#else + 0, /*tp_reserved*/ +#endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/ + 0, /*tp_doc*/ + (traverseproc) __Pyx_Coroutine_traverse, /*tp_traverse*/ + 0, /*tp_clear*/ +#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1 + // in order to (mis-)use tp_reserved above, we must also implement tp_richcompare + __Pyx_Coroutine_compare, /*tp_richcompare*/ +#else + 0, /*tp_richcompare*/ +#endif + offsetof(__pyx_CoroutineObject, gi_weakreflist), /*tp_weaklistoffset*/ + // enable iteration for legacy support of asyncio yield-from protocol + __Pyx_Coroutine_await, /*tp_iter*/ + (iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/ + __pyx_Coroutine_methods, /*tp_methods*/ + __pyx_Coroutine_memberlist, /*tp_members*/ + __pyx_Coroutine_getsets, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_del*/ +#else + __Pyx_Coroutine_del, /*tp_del*/ +#endif + 0, /*tp_version_tag*/ +#if PY_VERSION_HEX >= 0x030400a1 + __Pyx_Coroutine_del, /*tp_finalize*/ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + + +static int __pyx_IterableCoroutine_init(void) { + __pyx_IterableCoroutineType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx_IterableCoroutineType = __Pyx_FetchCommonType(&__pyx_IterableCoroutineType_type); + if (unlikely(!__pyx_IterableCoroutineType)) + return -1; + return 0; +} + + +//////////////////// Generator //////////////////// +//@requires: CoroutineBase +//@requires: PatchGeneratorABC +//@requires: ObjectHandling.c::PyObject_GenericGetAttrNoDict + +static PyMethodDef __pyx_Generator_methods[] = { + {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, + (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, + {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, + (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, + {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, + (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, + {0, 0, 0, 0} +}; + +static PyMemberDef __pyx_Generator_memberlist[] = { + {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, + {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, + (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, + {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL}, + {0, 0, 0, 0, 0} +}; + +static PyGetSetDef __pyx_Generator_getsets[] = { + {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, + (char*) PyDoc_STR("name of the generator"), 0}, + {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, + (char*) PyDoc_STR("qualified name of the generator"), 0}, + {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL, + (char*) PyDoc_STR("Frame of the generator"), 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_GeneratorType_type = { + PyVarObject_HEAD_INIT(0, 0) + "generator", /*tp_name*/ + sizeof(__pyx_CoroutineObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __Pyx_Coroutine_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare / tp_as_async*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/ + 0, /*tp_doc*/ + (traverseproc) __Pyx_Coroutine_traverse, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + offsetof(__pyx_CoroutineObject, gi_weakreflist), /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + (iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/ + __pyx_Generator_methods, /*tp_methods*/ + __pyx_Generator_memberlist, /*tp_members*/ + __pyx_Generator_getsets, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +#if CYTHON_USE_TP_FINALIZE + 0, /*tp_del*/ +#else + __Pyx_Coroutine_del, /*tp_del*/ +#endif + 0, /*tp_version_tag*/ +#if CYTHON_USE_TP_FINALIZE + __Pyx_Coroutine_del, /*tp_finalize*/ +#elif PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + +static int __pyx_Generator_init(void) { + // on Windows, C-API functions can't be used in slots statically + __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; + + __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); + if (unlikely(!__pyx_GeneratorType)) { + return -1; + } + return 0; +} + + +/////////////// ReturnWithStopIteration.proto /////////////// + +#define __Pyx_ReturnWithStopIteration(value) \ + if (value == Py_None) PyErr_SetNone(PyExc_StopIteration); else __Pyx__ReturnWithStopIteration(value) +static void __Pyx__ReturnWithStopIteration(PyObject* value); /*proto*/ + +/////////////// ReturnWithStopIteration /////////////// +//@requires: Exceptions.c::PyErrFetchRestore +//@requires: Exceptions.c::PyThreadStateGet +//@substitute: naming + +// 1) Instantiating an exception just to pass back a value is costly. +// 2) CPython 3.3 <= x < 3.5b1 crash in yield-from when the StopIteration is not instantiated. +// 3) Passing a tuple as value into PyErr_SetObject() passes its items on as arguments. +// 4) Passing an exception as value will interpret it as an exception on unpacking and raise it (or unpack its value). +// 5) If there is currently an exception being handled, we need to chain it. + +static void __Pyx__ReturnWithStopIteration(PyObject* value) { + PyObject *exc, *args; +#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_PYSTON + __Pyx_PyThreadState_declare + if ((PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030500B1) + || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) { + args = PyTuple_New(1); + if (unlikely(!args)) return; + Py_INCREF(value); + PyTuple_SET_ITEM(args, 0, value); + exc = PyType_Type.tp_call(PyExc_StopIteration, args, NULL); + Py_DECREF(args); + if (!exc) return; + } else { + // it's safe to avoid instantiating the exception + Py_INCREF(value); + exc = value; + } + #if CYTHON_FAST_THREAD_STATE + __Pyx_PyThreadState_assign + #if CYTHON_USE_EXC_INFO_STACK + if (!$local_tstate_cname->exc_info->exc_type) + #else + if (!$local_tstate_cname->exc_type) + #endif + { + // no chaining needed => avoid the overhead in PyErr_SetObject() + Py_INCREF(PyExc_StopIteration); + __Pyx_ErrRestore(PyExc_StopIteration, exc, NULL); + return; + } + #endif +#else + args = PyTuple_Pack(1, value); + if (unlikely(!args)) return; + exc = PyObject_Call(PyExc_StopIteration, args, NULL); + Py_DECREF(args); + if (unlikely(!exc)) return; +#endif + PyErr_SetObject(PyExc_StopIteration, exc); + Py_DECREF(exc); +} + + +//////////////////// PatchModuleWithCoroutine.proto //////////////////// + +static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); /*proto*/ + +//////////////////// PatchModuleWithCoroutine //////////////////// +//@substitute: naming + +static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + int result; + PyObject *globals, *result_obj; + globals = PyDict_New(); if (unlikely(!globals)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_coroutine_type", + #ifdef __Pyx_Coroutine_USED + (PyObject*)__pyx_CoroutineType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_generator_type", + #ifdef __Pyx_Generator_USED + (PyObject*)__pyx_GeneratorType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "__builtins__", $builtins_cname) < 0)) goto ignore; + result_obj = PyRun_String(py_code, Py_file_input, globals, globals); + if (unlikely(!result_obj)) goto ignore; + Py_DECREF(result_obj); + Py_DECREF(globals); + return module; + +ignore: + Py_XDECREF(globals); + PyErr_WriteUnraisable(module); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { + Py_DECREF(module); + module = NULL; + } +#else + // avoid "unused" warning + py_code++; +#endif + return module; +} + + +//////////////////// PatchGeneratorABC.proto //////////////////// + +// register with Generator/Coroutine ABCs in 'collections.abc' +// see https://bugs.python.org/issue24018 +static int __Pyx_patch_abc(void); /*proto*/ + +//////////////////// PatchGeneratorABC //////////////////// +//@requires: PatchModuleWithCoroutine + +#ifndef CYTHON_REGISTER_ABCS +#define CYTHON_REGISTER_ABCS 1 +#endif + +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) +static PyObject* __Pyx_patch_abc_module(PyObject *module); /*proto*/ +static PyObject* __Pyx_patch_abc_module(PyObject *module) { + module = __Pyx_Coroutine_patch_module( + module, CSTRING("""\ +if _cython_generator_type is not None: + try: Generator = _module.Generator + except AttributeError: pass + else: Generator.register(_cython_generator_type) +if _cython_coroutine_type is not None: + try: Coroutine = _module.Coroutine + except AttributeError: pass + else: Coroutine.register(_cython_coroutine_type) +""") + ); + return module; +} +#endif + +static int __Pyx_patch_abc(void) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + static int abc_patched = 0; + if (CYTHON_REGISTER_ABCS && !abc_patched) { + PyObject *module; + module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections"); + if (!module) { + PyErr_WriteUnraisable(NULL); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, + ((PY_MAJOR_VERSION >= 3) ? + "Cython module failed to register with collections.abc module" : + "Cython module failed to register with collections module"), 1) < 0)) { + return -1; + } + } else { + module = __Pyx_patch_abc_module(module); + abc_patched = 1; + if (unlikely(!module)) + return -1; + Py_DECREF(module); + } + // also register with "backports_abc" module if available, just in case + module = PyImport_ImportModule("backports_abc"); + if (module) { + module = __Pyx_patch_abc_module(module); + Py_XDECREF(module); + } + if (!module) { + PyErr_Clear(); + } + } +#else + // avoid "unused" warning for __Pyx_Coroutine_patch_module() + if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL); +#endif + return 0; +} + + +//////////////////// PatchAsyncIO.proto //////////////////// + +// run after importing "asyncio" to patch Cython generator support into it +static PyObject* __Pyx_patch_asyncio(PyObject* module); /*proto*/ + +//////////////////// PatchAsyncIO //////////////////// +//@requires: ImportExport.c::Import +//@requires: PatchModuleWithCoroutine +//@requires: PatchInspect + +static PyObject* __Pyx_patch_asyncio(PyObject* module) { +#if PY_VERSION_HEX < 0x030500B2 && \ + (defined(__Pyx_Coroutine_USED) || defined(__Pyx_Generator_USED)) && \ + (!defined(CYTHON_PATCH_ASYNCIO) || CYTHON_PATCH_ASYNCIO) + PyObject *patch_module = NULL; + static int asyncio_patched = 0; + if (unlikely((!asyncio_patched) && module)) { + PyObject *package; + package = __Pyx_Import(PYIDENT("asyncio.coroutines"), NULL, 0); + if (package) { + patch_module = __Pyx_Coroutine_patch_module( + PyObject_GetAttrString(package, "coroutines"), CSTRING("""\ +try: + coro_types = _module._COROUTINE_TYPES +except AttributeError: pass +else: + if _cython_coroutine_type is not None and _cython_coroutine_type not in coro_types: + coro_types = tuple(coro_types) + (_cython_coroutine_type,) + if _cython_generator_type is not None and _cython_generator_type not in coro_types: + coro_types = tuple(coro_types) + (_cython_generator_type,) +_module._COROUTINE_TYPES = coro_types +""") + ); + } else { + PyErr_Clear(); +// Always enable fallback: even if we compile against 3.4.2, we might be running on 3.4.1 at some point. +//#if PY_VERSION_HEX < 0x03040200 + // Py3.4.1 used to have asyncio.tasks instead of asyncio.coroutines + package = __Pyx_Import(PYIDENT("asyncio.tasks"), NULL, 0); + if (unlikely(!package)) goto asyncio_done; + patch_module = __Pyx_Coroutine_patch_module( + PyObject_GetAttrString(package, "tasks"), CSTRING("""\ +if hasattr(_module, 'iscoroutine'): + old_types = getattr(_module.iscoroutine, '_cython_coroutine_types', None) + if old_types is None or not isinstance(old_types, set): + old_types = set() + def cy_wrap(orig_func, type=type, cython_coroutine_types=old_types): + def cy_iscoroutine(obj): return type(obj) in cython_coroutine_types or orig_func(obj) + cy_iscoroutine._cython_coroutine_types = cython_coroutine_types + return cy_iscoroutine + _module.iscoroutine = cy_wrap(_module.iscoroutine) + if _cython_coroutine_type is not None: + old_types.add(_cython_coroutine_type) + if _cython_generator_type is not None: + old_types.add(_cython_generator_type) +""") + ); +//#endif +// Py < 0x03040200 + } + Py_DECREF(package); + if (unlikely(!patch_module)) goto ignore; +//#if PY_VERSION_HEX < 0x03040200 +asyncio_done: + PyErr_Clear(); +//#endif + asyncio_patched = 1; +#ifdef __Pyx_Generator_USED + // now patch inspect.isgenerator() by looking up the imported module in the patched asyncio module + { + PyObject *inspect_module; + if (patch_module) { + inspect_module = PyObject_GetAttr(patch_module, PYIDENT("inspect")); + Py_DECREF(patch_module); + } else { + inspect_module = __Pyx_Import(PYIDENT("inspect"), NULL, 0); + } + if (unlikely(!inspect_module)) goto ignore; + inspect_module = __Pyx_patch_inspect(inspect_module); + if (unlikely(!inspect_module)) { + Py_DECREF(module); + module = NULL; + } + Py_XDECREF(inspect_module); + } +#else + // avoid "unused" warning for __Pyx_patch_inspect() + if ((0)) return __Pyx_patch_inspect(module); +#endif + } + return module; +ignore: + PyErr_WriteUnraisable(module); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch asyncio package with custom generator type", 1) < 0)) { + Py_DECREF(module); + module = NULL; + } +#else + // avoid "unused" warning for __Pyx_Coroutine_patch_module() + if ((0)) return __Pyx_patch_inspect(__Pyx_Coroutine_patch_module(module, NULL)); +#endif + return module; +} + + +//////////////////// PatchInspect.proto //////////////////// + +// run after importing "inspect" to patch Cython generator support into it +static PyObject* __Pyx_patch_inspect(PyObject* module); /*proto*/ + +//////////////////// PatchInspect //////////////////// +//@requires: PatchModuleWithCoroutine + +static PyObject* __Pyx_patch_inspect(PyObject* module) { +#if defined(__Pyx_Generator_USED) && (!defined(CYTHON_PATCH_INSPECT) || CYTHON_PATCH_INSPECT) + static int inspect_patched = 0; + if (unlikely((!inspect_patched) && module)) { + module = __Pyx_Coroutine_patch_module( + module, CSTRING("""\ +old_types = getattr(_module.isgenerator, '_cython_generator_types', None) +if old_types is None or not isinstance(old_types, set): + old_types = set() + def cy_wrap(orig_func, type=type, cython_generator_types=old_types): + def cy_isgenerator(obj): return type(obj) in cython_generator_types or orig_func(obj) + cy_isgenerator._cython_generator_types = cython_generator_types + return cy_isgenerator + _module.isgenerator = cy_wrap(_module.isgenerator) +old_types.add(_cython_generator_type) +""") + ); + inspect_patched = 1; + } +#else + // avoid "unused" warning for __Pyx_Coroutine_patch_module() + if ((0)) return __Pyx_Coroutine_patch_module(module, NULL); +#endif + return module; +} + + +//////////////////// StopAsyncIteration.proto //////////////////// + +#define __Pyx_StopAsyncIteration_USED +static PyObject *__Pyx_PyExc_StopAsyncIteration; +static int __pyx_StopAsyncIteration_init(void); /*proto*/ + +//////////////////// StopAsyncIteration //////////////////// + +#if PY_VERSION_HEX < 0x030500B1 +static PyTypeObject __Pyx__PyExc_StopAsyncIteration_type = { + PyVarObject_HEAD_INIT(0, 0) + "StopAsyncIteration", /*tp_name*/ + sizeof(PyBaseExceptionObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + 0, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare / reserved*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + PyDoc_STR("Signal the end from iterator.__anext__()."), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM+0 >= 0x06000000 + 0, /*tp_pypy_flags*/ +#endif +}; +#endif + +static int __pyx_StopAsyncIteration_init(void) { +#if PY_VERSION_HEX >= 0x030500B1 + __Pyx_PyExc_StopAsyncIteration = PyExc_StopAsyncIteration; +#else + PyObject *builtins = PyEval_GetBuiltins(); + if (likely(builtins)) { + PyObject *exc = PyMapping_GetItemString(builtins, (char*) "StopAsyncIteration"); + if (exc) { + __Pyx_PyExc_StopAsyncIteration = exc; + return 0; + } + } + PyErr_Clear(); + + __Pyx__PyExc_StopAsyncIteration_type.tp_traverse = ((PyTypeObject*)PyExc_BaseException)->tp_traverse; + __Pyx__PyExc_StopAsyncIteration_type.tp_clear = ((PyTypeObject*)PyExc_BaseException)->tp_clear; + __Pyx__PyExc_StopAsyncIteration_type.tp_dictoffset = ((PyTypeObject*)PyExc_BaseException)->tp_dictoffset; + __Pyx__PyExc_StopAsyncIteration_type.tp_base = (PyTypeObject*)PyExc_Exception; + + __Pyx_PyExc_StopAsyncIteration = (PyObject*) __Pyx_FetchCommonType(&__Pyx__PyExc_StopAsyncIteration_type); + if (unlikely(!__Pyx_PyExc_StopAsyncIteration)) + return -1; + if (builtins && unlikely(PyMapping_SetItemString(builtins, (char*) "StopAsyncIteration", __Pyx_PyExc_StopAsyncIteration) < 0)) + return -1; +#endif + return 0; +} diff --git a/contrib/tools/cython/Cython/Utility/CpdefEnums.pyx b/contrib/tools/cython/Cython/Utility/CpdefEnums.pyx new file mode 100644 index 00000000000..148d776c29c --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CpdefEnums.pyx @@ -0,0 +1,66 @@ +#################### EnumBase #################### + +cimport cython + +cdef extern from *: + int PY_VERSION_HEX + +cdef object __Pyx_OrderedDict +if PY_VERSION_HEX >= 0x02070000: + from collections import OrderedDict as __Pyx_OrderedDict +else: + __Pyx_OrderedDict = dict + +@cython.internal +cdef class __Pyx_EnumMeta(type): + def __init__(cls, name, parents, dct): + type.__init__(cls, name, parents, dct) + cls.__members__ = __Pyx_OrderedDict() + def __iter__(cls): + return iter(cls.__members__.values()) + def __getitem__(cls, name): + return cls.__members__[name] + +# @cython.internal +cdef object __Pyx_EnumBase +class __Pyx_EnumBase(int): + __metaclass__ = __Pyx_EnumMeta + def __new__(cls, value, name=None): + for v in cls: + if v == value: + return v + if name is None: + raise ValueError("Unknown enum value: '%s'" % value) + res = int.__new__(cls, value) + res.name = name + setattr(cls, name, res) + cls.__members__[name] = res + return res + def __repr__(self): + return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self) + def __str__(self): + return "%s.%s" % (self.__class__.__name__, self.name) + +if PY_VERSION_HEX >= 0x03040000: + from enum import IntEnum as __Pyx_EnumBase + +#################### EnumType #################### +#@requires: EnumBase + +cdef dict __Pyx_globals = globals() +if PY_VERSION_HEX >= 0x03040000: + # create new IntEnum() + {{name}} = __Pyx_EnumBase('{{name}}', __Pyx_OrderedDict([ + {{for item in items}} + ('{{item}}', {{item}}), + {{endfor}} + ])) + {{for item in items}} + __Pyx_globals['{{item}}'] = {{name}}.{{item}} + {{endfor}} +else: + class {{name}}(__Pyx_EnumBase): + pass + {{for item in items}} + __Pyx_globals['{{item}}'] = {{name}}({{item}}, '{{item}}') + {{endfor}} diff --git a/contrib/tools/cython/Cython/Utility/CppConvert.pyx b/contrib/tools/cython/Cython/Utility/CppConvert.pyx new file mode 100644 index 00000000000..5f7859dd0ef --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CppConvert.pyx @@ -0,0 +1,384 @@ +# TODO: Figure out how many of the pass-by-value copies the compiler can eliminate. + + +#################### string.from_py #################### + +cdef extern from *: + cdef cppclass string "{{type}}": + string() + string(char* c_str, size_t size) + cdef const char* __Pyx_PyObject_AsStringAndSize(object, Py_ssize_t*) except NULL + +@cname("{{cname}}") +cdef string {{cname}}(object o) except *: + cdef Py_ssize_t length = 0 + cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + return string(data, length) + + +#################### string.to_py #################### + +#cimport cython +#from libcpp.string cimport string +cdef extern from *: + cdef cppclass string "{{type}}": + char* data() + size_t size() + +{{for py_type in ['PyObject', 'PyUnicode', 'PyStr', 'PyBytes', 'PyByteArray']}} +cdef extern from *: + cdef object __Pyx_{{py_type}}_FromStringAndSize(const char*, size_t) + +@cname("{{cname.replace("PyObject", py_type, 1)}}") +cdef inline object {{cname.replace("PyObject", py_type, 1)}}(const string& s): + return __Pyx_{{py_type}}_FromStringAndSize(s.data(), s.size()) +{{endfor}} + + +#################### vector.from_py #################### + +cdef extern from *: + cdef cppclass vector "std::vector" [T]: + void push_back(T&) + +@cname("{{cname}}") +cdef vector[X] {{cname}}(object o) except *: + cdef vector[X] v + for item in o: + v.push_back(<X>item) + return v + + +#################### vector.to_py #################### + +cdef extern from *: + cdef cppclass vector "const std::vector" [T]: + size_t size() + T& operator[](size_t) + +@cname("{{cname}}") +cdef object {{cname}}(vector[X]& v): + return [v[i] for i in range(v.size())] + + +#################### list.from_py #################### + +cdef extern from *: + cdef cppclass cpp_list "std::list" [T]: + void push_back(T&) + +@cname("{{cname}}") +cdef cpp_list[X] {{cname}}(object o) except *: + cdef cpp_list[X] l + for item in o: + l.push_back(<X>item) + return l + + +#################### list.to_py #################### + +cimport cython + +cdef extern from *: + cdef cppclass cpp_list "std::list" [T]: + cppclass const_iterator: + T& operator*() + const_iterator operator++() + bint operator!=(const_iterator) + const_iterator begin() + const_iterator end() + +@cname("{{cname}}") +cdef object {{cname}}(const cpp_list[X]& v): + o = [] + cdef cpp_list[X].const_iterator iter = v.begin() + while iter != v.end(): + o.append(cython.operator.dereference(iter)) + cython.operator.preincrement(iter) + return o + + +#################### set.from_py #################### + +cdef extern from *: + cdef cppclass set "std::{{maybe_unordered}}set" [T]: + void insert(T&) + +@cname("{{cname}}") +cdef set[X] {{cname}}(object o) except *: + cdef set[X] s + for item in o: + s.insert(<X>item) + return s + + +#################### set.to_py #################### + +cimport cython + +cdef extern from *: + cdef cppclass cpp_set "std::{{maybe_unordered}}set" [T]: + cppclass const_iterator: + T& operator*() + const_iterator operator++() + bint operator!=(const_iterator) + const_iterator begin() + const_iterator end() + +@cname("{{cname}}") +cdef object {{cname}}(const cpp_set[X]& s): + o = set() + cdef cpp_set[X].const_iterator iter = s.begin() + while iter != s.end(): + o.add(cython.operator.dereference(iter)) + cython.operator.preincrement(iter) + return o + +#################### pair.from_py #################### + +cdef extern from *: + cdef cppclass pair "std::pair" [T, U]: + pair() + pair(T&, U&) + +@cname("{{cname}}") +cdef pair[X,Y] {{cname}}(object o) except *: + x, y = o + return pair[X,Y](<X>x, <Y>y) + + +#################### pair.to_py #################### + +cdef extern from *: + cdef cppclass pair "std::pair" [T, U]: + T first + U second + +@cname("{{cname}}") +cdef object {{cname}}(const pair[X,Y]& p): + return p.first, p.second + + +#################### map.from_py #################### + +cdef extern from *: + cdef cppclass pair "std::pair" [T, U]: + pair(T&, U&) + cdef cppclass map "std::{{maybe_unordered}}map" [T, U]: + void insert(pair[T, U]&) + cdef cppclass vector "std::vector" [T]: + pass + + +@cname("{{cname}}") +cdef map[X,Y] {{cname}}(object o) except *: + cdef dict d = o + cdef map[X,Y] m + for key, value in d.iteritems(): + m.insert(pair[X,Y](<X>key, <Y>value)) + return m + + +#################### map.to_py #################### +# TODO: Work out const so that this can take a const +# reference rather than pass by value. + +cimport cython + +cdef extern from *: + cdef cppclass map "std::{{maybe_unordered}}map" [T, U]: + cppclass value_type: + T first + U second + cppclass const_iterator: + value_type& operator*() + const_iterator operator++() + bint operator!=(const_iterator) + const_iterator begin() + const_iterator end() + +@cname("{{cname}}") +cdef object {{cname}}(const map[X,Y]& s): + o = {} + cdef const map[X,Y].value_type *key_value + cdef map[X,Y].const_iterator iter = s.begin() + while iter != s.end(): + key_value = &cython.operator.dereference(iter) + o[key_value.first] = key_value.second + cython.operator.preincrement(iter) + return o + + +#################### complex.from_py #################### + +cdef extern from *: + cdef cppclass std_complex "std::complex" [T]: + std_complex() + std_complex(T, T) except + + +@cname("{{cname}}") +cdef std_complex[X] {{cname}}(object o) except *: + cdef double complex z = o + return std_complex[X](<X>z.real, <X>z.imag) + + +#################### complex.to_py #################### + +cdef extern from *: + cdef cppclass std_complex "std::complex" [T]: + X real() + X imag() + +@cname("{{cname}}") +cdef object {{cname}}(const std_complex[X]& z): + cdef double complex tmp + tmp.real = <double>z.real() + tmp.imag = <double>z.imag() + return tmp + + +#################### arcadia_TMaybe.from_py #################### + +cdef extern from *: + cdef cppclass TMaybe [T]: + TMaybe() + TMaybe(T&) + TMaybe& operator =(T&) + +@cname("{{cname}}") +cdef TMaybe[X] {{cname}}(object o) except *: + cdef TMaybe[X] result + if o is not None: + result = <X>o + return result + +#################### arcadia_TMaybe.to_py #################### + +cdef extern from *: + cdef cppclass TMaybe [T]: + bint Defined() + T& GetRef() + +@cname("{{cname}}") +cdef object {{cname}}(const TMaybe[X]& s): + if s.Defined(): + return s.GetRef() + return None + + +#################### arcadia_TVector.from_py #################### + +cdef extern from *: + cdef cppclass TVector [T]: + void push_back(T&) + +@cname("{{cname}}") +cdef TVector[X] {{cname}}(object o) except *: + cdef TVector[X] v + for item in o: + v.push_back(<X>item) + return v + + +#################### arcadia_TVector.to_py #################### + +cdef extern from *: + cdef cppclass TVector [T]: + size_t size() + T& operator[](size_t) + +@cname("{{cname}}") +cdef object {{cname}}(const TVector[X]& v): + return [v[i] for i in range(v.size())] + + +#################### arcadia_THashMap.from_py #################### + +cdef extern from *: + cdef cppclass pair "std::pair" [T, U]: + pair(T&, U&) + cdef cppclass THashMap [T, U]: + void insert(pair[T, U]&) + + +@cname("{{cname}}") +cdef THashMap[X,Y] {{cname}}(object o) except *: + cdef dict d = o + cdef THashMap[X,Y] m + for key, value in d.iteritems(): + m.insert(pair[X,Y](<X>key, <Y>value)) + return m + + +#################### arcadia_THashMap.to_py #################### + +cimport cython + +cdef extern from *: + cdef cppclass THashMap [T, U]: + cppclass value_type: + T first + U second + cppclass const_iterator: + value_type& operator*() + const_iterator operator++() + bint operator!=(const_iterator) + const_iterator begin() + const_iterator end() + +@cname("{{cname}}") +cdef dict {{cname}}(const THashMap[X,Y]& s): + cdef dict result = {} + cdef const THashMap[X,Y].value_type *key_value + cdef THashMap[X,Y].const_iterator iter = s.begin() + while iter != s.end(): + key_value = &cython.operator.dereference(iter) + result[key_value.first] = key_value.second + cython.operator.preincrement(iter) + return result + + +#################### arcadia_TMap.from_py #################### + +cdef extern from *: + cdef cppclass pair "std::pair" [T, U]: + pair(T&, U&) + cdef cppclass TMap [T, U]: + void insert(pair[T, U]&) + + +@cname("{{cname}}") +cdef TMap[X,Y] {{cname}}(object o) except *: + cdef dict d = o + cdef TMap[X,Y] m + for key, value in d.iteritems(): + m.insert(pair[X,Y](<X>key, <Y>value)) + return m + + +#################### arcadia_TMap.to_py #################### + +cimport cython + +cdef extern from *: + cdef cppclass TMap [T, U]: + cppclass value_type: + T first + U second + cppclass const_iterator: + value_type& operator*() + const_iterator operator++() + bint operator!=(const_iterator) + const_iterator begin() + const_iterator end() + +@cname("{{cname}}") +cdef dict {{cname}}(const TMap[X,Y]& s): + cdef dict result = {} + cdef const TMap[X,Y].value_type *key_value + cdef TMap[X,Y].const_iterator iter = s.begin() + while iter != s.end(): + key_value = &cython.operator.dereference(iter) + result[key_value.first] = key_value.second + cython.operator.preincrement(iter) + return result diff --git a/contrib/tools/cython/Cython/Utility/CppSupport.cpp b/contrib/tools/cython/Cython/Utility/CppSupport.cpp new file mode 100644 index 00000000000..b8fcff06436 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CppSupport.cpp @@ -0,0 +1,58 @@ +/////////////// CppExceptionConversion.proto /////////////// + +#ifndef __Pyx_CppExn2PyErr +#include <new> +#include <typeinfo> +#include <stdexcept> +#include <ios> + +static void __Pyx_CppExn2PyErr() { + // Catch a handful of different errors here and turn them into the + // equivalent Python errors. + try { + if (PyErr_Occurred()) + ; // let the latest Python exn pass through and ignore the current one + else + throw; + } catch (const std::bad_alloc& exn) { + PyErr_SetString(PyExc_MemoryError, exn.what()); + } catch (const std::bad_cast& exn) { + PyErr_SetString(PyExc_TypeError, exn.what()); + } catch (const std::bad_typeid& exn) { + PyErr_SetString(PyExc_TypeError, exn.what()); + } catch (const std::domain_error& exn) { + PyErr_SetString(PyExc_ValueError, exn.what()); + } catch (const std::invalid_argument& exn) { + PyErr_SetString(PyExc_ValueError, exn.what()); + } catch (const std::ios_base::failure& exn) { + // Unfortunately, in standard C++ we have no way of distinguishing EOF + // from other errors here; be careful with the exception mask + PyErr_SetString(PyExc_IOError, exn.what()); + } catch (const std::out_of_range& exn) { + // Change out_of_range to IndexError + PyErr_SetString(PyExc_IndexError, exn.what()); + } catch (const std::overflow_error& exn) { + PyErr_SetString(PyExc_OverflowError, exn.what()); + } catch (const std::range_error& exn) { + PyErr_SetString(PyExc_ArithmeticError, exn.what()); + } catch (const std::underflow_error& exn) { + PyErr_SetString(PyExc_ArithmeticError, exn.what()); + } catch (const std::exception& exn) { + PyErr_SetString(PyExc_RuntimeError, exn.what()); + } + catch (...) + { + PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); + } +} +#endif + +/////////////// PythranConversion.proto /////////////// + +template <class T> +auto __Pyx_pythran_to_python(T &&value) -> decltype(to_python( + typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type{std::forward<T>(value)})) +{ + using returnable_type = typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type; + return to_python(returnable_type{std::forward<T>(value)}); +} diff --git a/contrib/tools/cython/Cython/Utility/CythonFunction.c b/contrib/tools/cython/Cython/Utility/CythonFunction.c new file mode 100644 index 00000000000..dbe9a0a9db3 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/CythonFunction.c @@ -0,0 +1,1347 @@ + +//////////////////// CythonFunctionShared.proto //////////////////// + +#define __Pyx_CyFunction_USED 1 + +#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 +#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 +#define __Pyx_CYFUNCTION_CCLASS 0x04 + +#define __Pyx_CyFunction_GetClosure(f) \ + (((__pyx_CyFunctionObject *) (f))->func_closure) +#define __Pyx_CyFunction_GetClassObj(f) \ + (((__pyx_CyFunctionObject *) (f))->func_classobj) + +#define __Pyx_CyFunction_Defaults(type, f) \ + ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) +#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \ + ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) + + +typedef struct { + PyCFunctionObject func; +#if PY_VERSION_HEX < 0x030500A0 + PyObject *func_weakreflist; +#endif + PyObject *func_dict; + PyObject *func_name; + PyObject *func_qualname; + PyObject *func_doc; + PyObject *func_globals; + PyObject *func_code; + PyObject *func_closure; + // No-args super() class cell + PyObject *func_classobj; + + // Dynamic default args and annotations + void *defaults; + int defaults_pyobjects; + size_t defaults_size; // used by FusedFunction for copying defaults + int flags; + + // Defaults info + PyObject *defaults_tuple; /* Const defaults tuple */ + PyObject *defaults_kwdict; /* Const kwonly defaults dict */ + PyObject *(*defaults_getter)(PyObject *); + PyObject *func_annotations; /* function annotations dict */ +} __pyx_CyFunctionObject; + +static PyTypeObject *__pyx_CyFunctionType = 0; + +#define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType)) + +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *self, + PyObject *module, PyObject *globals, + PyObject* code); + +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, + size_t size, + int pyobjects); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, + PyObject *tuple); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, + PyObject *dict); +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, + PyObject *dict); + + +static int __pyx_CyFunction_init(void); + + +//////////////////// CythonFunctionShared //////////////////// +//@substitute: naming +//@requires: CommonStructures.c::FetchCommonType +////@requires: ObjectHandling.c::PyObjectGetAttrStr + +#include <structmember.h> + +static PyObject * +__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) +{ + if (unlikely(op->func_doc == NULL)) { + if (op->func.m_ml->ml_doc) { +#if PY_MAJOR_VERSION >= 3 + op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); +#else + op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); +#endif + if (unlikely(op->func_doc == NULL)) + return NULL; + } else { + Py_INCREF(Py_None); + return Py_None; + } + } + Py_INCREF(op->func_doc); + return op->func_doc; +} + +static int +__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp = op->func_doc; + if (value == NULL) { + // Mark as deleted + value = Py_None; + } + Py_INCREF(value); + op->func_doc = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + if (unlikely(op->func_name == NULL)) { +#if PY_MAJOR_VERSION >= 3 + op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); +#else + op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); +#endif + if (unlikely(op->func_name == NULL)) + return NULL; + } + Py_INCREF(op->func_name); + return op->func_name; +} + +static int +__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; + +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + tmp = op->func_name; + Py_INCREF(value); + op->func_name = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + Py_INCREF(op->func_qualname); + return op->func_qualname; +} + +static int +__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; + +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + tmp = op->func_qualname; + Py_INCREF(value); + op->func_qualname = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) +{ + PyObject *self; + + self = m->func_closure; + if (self == NULL) + self = Py_None; + Py_INCREF(self); + return self; +} + +static PyObject * +__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + if (unlikely(op->func_dict == NULL)) { + op->func_dict = PyDict_New(); + if (unlikely(op->func_dict == NULL)) + return NULL; + } + Py_INCREF(op->func_dict); + return op->func_dict; +} + +static int +__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; + + if (unlikely(value == NULL)) { + PyErr_SetString(PyExc_TypeError, + "function's dictionary may not be deleted"); + return -1; + } + if (unlikely(!PyDict_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "setting function's dictionary to a non-dict"); + return -1; + } + tmp = op->func_dict; + Py_INCREF(value); + op->func_dict = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + Py_INCREF(op->func_globals); + return op->func_globals; +} + +static PyObject * +__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + PyObject* result = (op->func_code) ? op->func_code : Py_None; + Py_INCREF(result); + return result; +} + +static int +__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { + int result = 0; + PyObject *res = op->defaults_getter((PyObject *) op); + if (unlikely(!res)) + return -1; + + // Cache result + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + op->defaults_tuple = PyTuple_GET_ITEM(res, 0); + Py_INCREF(op->defaults_tuple); + op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); + Py_INCREF(op->defaults_kwdict); + #else + op->defaults_tuple = PySequence_ITEM(res, 0); + if (unlikely(!op->defaults_tuple)) result = -1; + else { + op->defaults_kwdict = PySequence_ITEM(res, 1); + if (unlikely(!op->defaults_kwdict)) result = -1; + } + #endif + Py_DECREF(res); + return result; +} + +static int +__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { + PyObject* tmp; + if (!value) { + // del => explicit None to prevent rebuilding + value = Py_None; + } else if (value != Py_None && !PyTuple_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__defaults__ must be set to a tuple object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_tuple; + op->defaults_tuple = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { + PyObject* result = op->defaults_tuple; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_tuple; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} + +static int +__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { + PyObject* tmp; + if (!value) { + // del => explicit None to prevent rebuilding + value = Py_None; + } else if (value != Py_None && !PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__kwdefaults__ must be set to a dict object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_kwdict; + op->defaults_kwdict = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { + PyObject* result = op->defaults_kwdict; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_kwdict; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} + +static int +__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { + PyObject* tmp; + if (!value || value == Py_None) { + value = NULL; + } else if (!PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__annotations__ must be set to a dict object"); + return -1; + } + Py_XINCREF(value); + tmp = op->func_annotations; + op->func_annotations = value; + Py_XDECREF(tmp); + return 0; +} + +static PyObject * +__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { + PyObject* result = op->func_annotations; + if (unlikely(!result)) { + result = PyDict_New(); + if (unlikely(!result)) return NULL; + op->func_annotations = result; + } + Py_INCREF(result); + return result; +} + +//#if PY_VERSION_HEX >= 0x030400C1 +//static PyObject * +//__Pyx_CyFunction_get_signature(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { +// PyObject *inspect_module, *signature_class, *signature; +// // from inspect import Signature +// inspect_module = PyImport_ImportModuleLevelObject(PYIDENT("inspect"), NULL, NULL, NULL, 0); +// if (unlikely(!inspect_module)) +// goto bad; +// signature_class = __Pyx_PyObject_GetAttrStr(inspect_module, PYIDENT("Signature")); +// Py_DECREF(inspect_module); +// if (unlikely(!signature_class)) +// goto bad; +// // return Signature.from_function(op) +// signature = PyObject_CallMethodObjArgs(signature_class, PYIDENT("from_function"), op, NULL); +// Py_DECREF(signature_class); +// if (likely(signature)) +// return signature; +//bad: +// // make sure we raise an AttributeError from this property on any errors +// if (!PyErr_ExceptionMatches(PyExc_AttributeError)) +// PyErr_SetString(PyExc_AttributeError, "failed to calculate __signature__"); +// return NULL; +//} +//#endif + +static PyGetSetDef __pyx_CyFunction_getsets[] = { + {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, + {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, + {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, + {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, +//#if PY_VERSION_HEX >= 0x030400C1 +// {(char *) "__signature__", (getter)__Pyx_CyFunction_get_signature, 0, 0, 0}, +//#endif + {0, 0, 0, 0, 0} +}; + +static PyMemberDef __pyx_CyFunction_members[] = { + {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, + {0, 0, 0, 0, 0} +}; + +static PyObject * +__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) +{ +#if PY_MAJOR_VERSION >= 3 + Py_INCREF(m->func_qualname); + return m->func_qualname; +#else + return PyString_FromString(m->func.m_ml->ml_name); +#endif +} + +static PyMethodDef __pyx_CyFunction_methods[] = { + {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, + {0, 0, 0, 0} +}; + + +#if PY_VERSION_HEX < 0x030500A0 +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) +#else +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) +#endif + +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + if (unlikely(op == NULL)) + return NULL; + op->flags = flags; + __Pyx_CyFunction_weakreflist(op) = NULL; + op->func.m_ml = ml; + op->func.m_self = (PyObject *) op; + Py_XINCREF(closure); + op->func_closure = closure; + Py_XINCREF(module); + op->func.m_module = module; + op->func_dict = NULL; + op->func_name = NULL; + Py_INCREF(qualname); + op->func_qualname = qualname; + op->func_doc = NULL; + op->func_classobj = NULL; + op->func_globals = globals; + Py_INCREF(op->func_globals); + Py_XINCREF(code); + op->func_code = code; + // Dynamic Default args + op->defaults_pyobjects = 0; + op->defaults_size = 0; + op->defaults = NULL; + op->defaults_tuple = NULL; + op->defaults_kwdict = NULL; + op->defaults_getter = NULL; + op->func_annotations = NULL; + return (PyObject *) op; +} + +static int +__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) +{ + Py_CLEAR(m->func_closure); + Py_CLEAR(m->func.m_module); + Py_CLEAR(m->func_dict); + Py_CLEAR(m->func_name); + Py_CLEAR(m->func_qualname); + Py_CLEAR(m->func_doc); + Py_CLEAR(m->func_globals); + Py_CLEAR(m->func_code); + Py_CLEAR(m->func_classobj); + Py_CLEAR(m->defaults_tuple); + Py_CLEAR(m->defaults_kwdict); + Py_CLEAR(m->func_annotations); + + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + + for (i = 0; i < m->defaults_pyobjects; i++) + Py_XDECREF(pydefaults[i]); + + PyObject_Free(m->defaults); + m->defaults = NULL; + } + + return 0; +} + +static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + if (__Pyx_CyFunction_weakreflist(m) != NULL) + PyObject_ClearWeakRefs((PyObject *) m); + __Pyx_CyFunction_clear(m); + PyObject_GC_Del(m); +} + +static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + PyObject_GC_UnTrack(m); + __Pyx__CyFunction_dealloc(m); +} + +static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) +{ + Py_VISIT(m->func_closure); + Py_VISIT(m->func.m_module); + Py_VISIT(m->func_dict); + Py_VISIT(m->func_name); + Py_VISIT(m->func_qualname); + Py_VISIT(m->func_doc); + Py_VISIT(m->func_globals); + Py_VISIT(m->func_code); + Py_VISIT(m->func_classobj); + Py_VISIT(m->defaults_tuple); + Py_VISIT(m->defaults_kwdict); + + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + + for (i = 0; i < m->defaults_pyobjects; i++) + Py_VISIT(pydefaults[i]); + } + + return 0; +} + +static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) +{ +#if PY_MAJOR_VERSION < 3 + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + + if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { + Py_INCREF(func); + return func; + } + + if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { + if (type == NULL) + type = (PyObject *)(Py_TYPE(obj)); + return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); + } + + if (obj == Py_None) + obj = NULL; +#endif + return __Pyx_PyMethod_New(func, obj, type); +} + +static PyObject* +__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) +{ +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromFormat("<cyfunction %U at %p>", + op->func_qualname, (void *)op); +#else + return PyString_FromFormat("<cyfunction %s at %p>", + PyString_AsString(op->func_qualname), (void *)op); +#endif +} + +static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { + // originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c + PyCFunctionObject* f = (PyCFunctionObject*)func; + PyCFunction meth = f->m_ml->ml_meth; + Py_ssize_t size; + + switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { + case METH_VARARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) + return (*meth)(self, arg); + break; + case METH_VARARGS | METH_KEYWORDS: + return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); + case METH_NOARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 0)) + return (*meth)(self, NULL); + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + case METH_O: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 1)) { + PyObject *result, *arg0; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + arg0 = PyTuple_GET_ITEM(arg, 0); + #else + arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; + #endif + result = (*meth)(self, arg0); + #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_DECREF(arg0); + #endif + return result; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + default: + PyErr_SetString(PyExc_SystemError, "Bad call flags in " + "__Pyx_CyFunction_Call. METH_OLDARGS is no " + "longer supported!"); + + return NULL; + } + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + f->m_ml->ml_name); + return NULL; +} + +static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); +} + +static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { + PyObject *result; + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + Py_ssize_t argc; + PyObject *new_args; + PyObject *self; + + argc = PyTuple_GET_SIZE(args); + new_args = PyTuple_GetSlice(args, 1, argc); + + if (unlikely(!new_args)) + return NULL; + + self = PyTuple_GetItem(args, 0); + if (unlikely(!self)) { + Py_DECREF(new_args); +#if PY_MAJOR_VERSION > 2 + PyErr_Format(PyExc_TypeError, + "unbound method %.200S() needs an argument", + cyfunc->func_qualname); +#else + // %S doesn't work in PyErr_Format on Py2 and replicating + // the formatting seems more trouble than it's worth + // (so produce a less useful error message). + PyErr_SetString(PyExc_TypeError, + "unbound method needs an argument"); +#endif + return NULL; + } + + result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); + Py_DECREF(new_args); + } else { + result = __Pyx_CyFunction_Call(func, args, kw); + } + return result; +} + +static PyTypeObject __pyx_CyFunctionType_type = { + PyVarObject_HEAD_INIT(0, 0) + "cython_function_or_method", /*tp_name*/ + sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ +#if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ +#else + 0, /*reserved*/ +#endif + (reprfunc) __Pyx_CyFunction_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + __Pyx_CyFunction_CallAsMethod, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + (traverseproc) __Pyx_CyFunction_traverse, /*tp_traverse*/ + (inquiry) __Pyx_CyFunction_clear, /*tp_clear*/ + 0, /*tp_richcompare*/ +#if PY_VERSION_HEX < 0x030500A0 + offsetof(__pyx_CyFunctionObject, func_weakreflist), /*tp_weaklistoffset*/ +#else + offsetof(PyCFunctionObject, m_weakreflist), /*tp_weaklistoffset*/ +#endif + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_CyFunction_methods, /*tp_methods*/ + __pyx_CyFunction_members, /*tp_members*/ + __pyx_CyFunction_getsets, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + __Pyx_CyFunction_descr_get, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + + +static int __pyx_CyFunction_init(void) { + __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); + if (unlikely(__pyx_CyFunctionType == NULL)) { + return -1; + } + return 0; +} + +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + + m->defaults = PyObject_Malloc(size); + if (unlikely(!m->defaults)) + return PyErr_NoMemory(); + memset(m->defaults, 0, size); + m->defaults_pyobjects = pyobjects; + m->defaults_size = size; + return m->defaults; +} + +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_tuple = tuple; + Py_INCREF(tuple); +} + +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_kwdict = dict; + Py_INCREF(dict); +} + +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->func_annotations = dict; + Py_INCREF(dict); +} + + +//////////////////// CythonFunction.proto //////////////////// + +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *closure, + PyObject *module, PyObject *globals, + PyObject* code); + +//////////////////// CythonFunction //////////////////// +//@requires: CythonFunctionShared + +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + PyObject *op = __Pyx_CyFunction_Init( + PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), + ml, flags, qualname, closure, module, globals, code + ); + if (likely(op)) { + PyObject_GC_Track(op); + } + return op; +} + + +//////////////////// CyFunctionClassCell.proto //////////////////// +static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);/*proto*/ + +//////////////////// CyFunctionClassCell //////////////////// +//@requires: CythonFunctionShared + +static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) { + Py_ssize_t i, count = PyList_GET_SIZE(cyfunctions); + + for (i = 0; i < count; i++) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + PyList_GET_ITEM(cyfunctions, i); +#else + PySequence_ITEM(cyfunctions, i); + if (unlikely(!m)) + return -1; +#endif + Py_INCREF(classobj); + m->func_classobj = classobj; +#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_DECREF((PyObject*)m); +#endif + } + return 0; +} + + +//////////////////// FusedFunction.proto //////////////////// + +typedef struct { + __pyx_CyFunctionObject func; + PyObject *__signatures__; + PyObject *type; + PyObject *self; +} __pyx_FusedFunctionObject; + +static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags, + PyObject *qualname, PyObject *closure, + PyObject *module, PyObject *globals, + PyObject *code); + +static int __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self); +static PyTypeObject *__pyx_FusedFunctionType = NULL; +static int __pyx_FusedFunction_init(void); + +#define __Pyx_FusedFunction_USED + +//////////////////// FusedFunction //////////////////// +//@requires: CythonFunctionShared + +static PyObject * +__pyx_FusedFunction_New(PyMethodDef *ml, int flags, + PyObject *qualname, PyObject *closure, + PyObject *module, PyObject *globals, + PyObject *code) +{ + PyObject *op = __Pyx_CyFunction_Init( + // __pyx_CyFunctionObject is correct below since that's the cast that we want. + PyObject_GC_New(__pyx_CyFunctionObject, __pyx_FusedFunctionType), + ml, flags, qualname, closure, module, globals, code + ); + if (likely(op)) { + __pyx_FusedFunctionObject *fusedfunc = (__pyx_FusedFunctionObject *) op; + fusedfunc->__signatures__ = NULL; + fusedfunc->type = NULL; + fusedfunc->self = NULL; + PyObject_GC_Track(op); + } + return op; +} + +static void +__pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self) +{ + PyObject_GC_UnTrack(self); + Py_CLEAR(self->self); + Py_CLEAR(self->type); + Py_CLEAR(self->__signatures__); + __Pyx__CyFunction_dealloc((__pyx_CyFunctionObject *) self); +} + +static int +__pyx_FusedFunction_traverse(__pyx_FusedFunctionObject *self, + visitproc visit, + void *arg) +{ + Py_VISIT(self->self); + Py_VISIT(self->type); + Py_VISIT(self->__signatures__); + return __Pyx_CyFunction_traverse((__pyx_CyFunctionObject *) self, visit, arg); +} + +static int +__pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self) +{ + Py_CLEAR(self->self); + Py_CLEAR(self->type); + Py_CLEAR(self->__signatures__); + return __Pyx_CyFunction_clear((__pyx_CyFunctionObject *) self); +} + + +static PyObject * +__pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type) +{ + __pyx_FusedFunctionObject *func, *meth; + + func = (__pyx_FusedFunctionObject *) self; + + if (func->self || func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD) { + // Do not allow rebinding and don't do anything for static methods + Py_INCREF(self); + return self; + } + + if (obj == Py_None) + obj = NULL; + + meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_New( + ((PyCFunctionObject *) func)->m_ml, + ((__pyx_CyFunctionObject *) func)->flags, + ((__pyx_CyFunctionObject *) func)->func_qualname, + ((__pyx_CyFunctionObject *) func)->func_closure, + ((PyCFunctionObject *) func)->m_module, + ((__pyx_CyFunctionObject *) func)->func_globals, + ((__pyx_CyFunctionObject *) func)->func_code); + if (!meth) + return NULL; + + // defaults needs copying fully rather than just copying the pointer + // since otherwise it will be freed on destruction of meth despite + // belonging to func rather than meth + if (func->func.defaults) { + PyObject **pydefaults; + int i; + + if (!__Pyx_CyFunction_InitDefaults((PyObject*)meth, + func->func.defaults_size, + func->func.defaults_pyobjects)) { + Py_XDECREF((PyObject*)meth); + return NULL; + } + memcpy(meth->func.defaults, func->func.defaults, func->func.defaults_size); + + pydefaults = __Pyx_CyFunction_Defaults(PyObject *, meth); + for (i = 0; i < meth->func.defaults_pyobjects; i++) + Py_XINCREF(pydefaults[i]); + } + + Py_XINCREF(func->func.func_classobj); + meth->func.func_classobj = func->func.func_classobj; + + Py_XINCREF(func->__signatures__); + meth->__signatures__ = func->__signatures__; + + Py_XINCREF(type); + meth->type = type; + + Py_XINCREF(func->func.defaults_tuple); + meth->func.defaults_tuple = func->func.defaults_tuple; + + if (func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD) + obj = type; + + Py_XINCREF(obj); + meth->self = obj; + + return (PyObject *) meth; +} + +static PyObject * +_obj_to_str(PyObject *obj) +{ + if (PyType_Check(obj)) + return PyObject_GetAttr(obj, PYIDENT("__name__")); + else + return PyObject_Str(obj); +} + +static PyObject * +__pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx) +{ + PyObject *signature = NULL; + PyObject *unbound_result_func; + PyObject *result_func = NULL; + + if (self->__signatures__ == NULL) { + PyErr_SetString(PyExc_TypeError, "Function is not fused"); + return NULL; + } + + if (PyTuple_Check(idx)) { + PyObject *list = PyList_New(0); + Py_ssize_t n = PyTuple_GET_SIZE(idx); + PyObject *sep = NULL; + int i; + + if (unlikely(!list)) + return NULL; + + for (i = 0; i < n; i++) { + int ret; + PyObject *string; +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + PyObject *item = PyTuple_GET_ITEM(idx, i); +#else + PyObject *item = PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err; +#endif + string = _obj_to_str(item); +#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_DECREF(item); +#endif + if (unlikely(!string)) goto __pyx_err; + ret = PyList_Append(list, string); + Py_DECREF(string); + if (unlikely(ret < 0)) goto __pyx_err; + } + + sep = PyUnicode_FromString("|"); + if (likely(sep)) + signature = PyUnicode_Join(sep, list); +__pyx_err: +; + Py_DECREF(list); + Py_XDECREF(sep); + } else { + signature = _obj_to_str(idx); + } + + if (!signature) + return NULL; + + unbound_result_func = PyObject_GetItem(self->__signatures__, signature); + + if (unbound_result_func) { + if (self->self || self->type) { + __pyx_FusedFunctionObject *unbound = (__pyx_FusedFunctionObject *) unbound_result_func; + + // TODO: move this to InitClassCell + Py_CLEAR(unbound->func.func_classobj); + Py_XINCREF(self->func.func_classobj); + unbound->func.func_classobj = self->func.func_classobj; + + result_func = __pyx_FusedFunction_descr_get(unbound_result_func, + self->self, self->type); + } else { + result_func = unbound_result_func; + Py_INCREF(result_func); + } + } + + Py_DECREF(signature); + Py_XDECREF(unbound_result_func); + + return result_func; +} + +static PyObject * +__pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw) +{ + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; + int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD && + !((__pyx_FusedFunctionObject *) func)->__signatures__); + + if (cyfunc->flags & __Pyx_CYFUNCTION_CCLASS && !static_specialized) { + return __Pyx_CyFunction_CallAsMethod(func, args, kw); + } else { + return __Pyx_CyFunction_Call(func, args, kw); + } +} + +// Note: the 'self' from method binding is passed in in the args tuple, +// whereas PyCFunctionObject's m_self is passed in as the first +// argument to the C function. For extension methods we need +// to pass 'self' as 'm_self' and not as the first element of the +// args tuple. + +static PyObject * +__pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw) +{ + __pyx_FusedFunctionObject *binding_func = (__pyx_FusedFunctionObject *) func; + Py_ssize_t argc = PyTuple_GET_SIZE(args); + PyObject *new_args = NULL; + __pyx_FusedFunctionObject *new_func = NULL; + PyObject *result = NULL; + PyObject *self = NULL; + int is_staticmethod = binding_func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD; + int is_classmethod = binding_func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD; + + if (binding_func->self) { + // Bound method call, put 'self' in the args tuple + Py_ssize_t i; + new_args = PyTuple_New(argc + 1); + if (!new_args) + return NULL; + + self = binding_func->self; +#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_INCREF(self); +#endif + Py_INCREF(self); + PyTuple_SET_ITEM(new_args, 0, self); + + for (i = 0; i < argc; i++) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + PyObject *item = PyTuple_GET_ITEM(args, i); + Py_INCREF(item); +#else + PyObject *item = PySequence_ITEM(args, i); if (unlikely(!item)) goto bad; +#endif + PyTuple_SET_ITEM(new_args, i + 1, item); + } + + args = new_args; + } else if (binding_func->type) { + // Unbound method call + if (argc < 1) { + PyErr_SetString(PyExc_TypeError, "Need at least one argument, 0 given."); + return NULL; + } +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + self = PyTuple_GET_ITEM(args, 0); +#else + self = PySequence_ITEM(args, 0); if (unlikely(!self)) return NULL; +#endif + } + + if (self && !is_classmethod && !is_staticmethod) { + int is_instance = PyObject_IsInstance(self, binding_func->type); + if (unlikely(!is_instance)) { + PyErr_Format(PyExc_TypeError, + "First argument should be of type %.200s, got %.200s.", + ((PyTypeObject *) binding_func->type)->tp_name, + Py_TYPE(self)->tp_name); + goto bad; + } else if (unlikely(is_instance == -1)) { + goto bad; + } + } +#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_XDECREF(self); + self = NULL; +#endif + + if (binding_func->__signatures__) { + PyObject *tup; + if (is_staticmethod && binding_func->func.flags & __Pyx_CYFUNCTION_CCLASS) { + // FIXME: this seems wrong, but we must currently pass the signatures dict as 'self' argument + tup = PyTuple_Pack(3, args, + kw == NULL ? Py_None : kw, + binding_func->func.defaults_tuple); + if (unlikely(!tup)) goto bad; + new_func = (__pyx_FusedFunctionObject *) __Pyx_CyFunction_CallMethod( + func, binding_func->__signatures__, tup, NULL); + } else { + tup = PyTuple_Pack(4, binding_func->__signatures__, args, + kw == NULL ? Py_None : kw, + binding_func->func.defaults_tuple); + if (unlikely(!tup)) goto bad; + new_func = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_callfunction(func, tup, NULL); + } + Py_DECREF(tup); + + if (unlikely(!new_func)) + goto bad; + + Py_XINCREF(binding_func->func.func_classobj); + Py_CLEAR(new_func->func.func_classobj); + new_func->func.func_classobj = binding_func->func.func_classobj; + + func = (PyObject *) new_func; + } + + result = __pyx_FusedFunction_callfunction(func, args, kw); +bad: +#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_XDECREF(self); +#endif + Py_XDECREF(new_args); + Py_XDECREF((PyObject *) new_func); + return result; +} + +static PyMemberDef __pyx_FusedFunction_members[] = { + {(char *) "__signatures__", + T_OBJECT, + offsetof(__pyx_FusedFunctionObject, __signatures__), + READONLY, + 0}, + {0, 0, 0, 0, 0}, +}; + +static PyMappingMethods __pyx_FusedFunction_mapping_methods = { + 0, + (binaryfunc) __pyx_FusedFunction_getitem, + 0, +}; + +static PyTypeObject __pyx_FusedFunctionType_type = { + PyVarObject_HEAD_INIT(0, 0) + "fused_cython_function", /*tp_name*/ + sizeof(__pyx_FusedFunctionObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __pyx_FusedFunction_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ +#if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ +#else + 0, /*reserved*/ +#endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + &__pyx_FusedFunction_mapping_methods, /*tp_as_mapping*/ + 0, /*tp_hash*/ + (ternaryfunc) __pyx_FusedFunction_call, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + (traverseproc) __pyx_FusedFunction_traverse, /*tp_traverse*/ + (inquiry) __pyx_FusedFunction_clear,/*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + __pyx_FusedFunction_members, /*tp_members*/ + // __doc__ is None for the fused function type, but we need it to be + // a descriptor for the instance's __doc__, so rebuild descriptors in our subclass + __pyx_CyFunction_getsets, /*tp_getset*/ + // NOTE: tp_base may be changed later during module initialisation when importing CyFunction across modules. + &__pyx_CyFunctionType_type, /*tp_base*/ + 0, /*tp_dict*/ + __pyx_FusedFunction_descr_get, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ +#endif +}; + +static int __pyx_FusedFunction_init(void) { + // Set base from __Pyx_FetchCommonTypeFromSpec, in case it's different from the local static value. + __pyx_FusedFunctionType_type.tp_base = __pyx_CyFunctionType; + __pyx_FusedFunctionType = __Pyx_FetchCommonType(&__pyx_FusedFunctionType_type); + if (__pyx_FusedFunctionType == NULL) { + return -1; + } + return 0; +} + +//////////////////// ClassMethod.proto //////////////////// + +#include "descrobject.h" +static CYTHON_UNUSED PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/ + +//////////////////// ClassMethod //////////////////// + +static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { +#if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000 + if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) { + // cdef classes + return PyClassMethod_New(method); + } +#else +#if CYTHON_COMPILING_IN_PYSTON || CYTHON_COMPILING_IN_PYPY + // special C-API function only in Pyston and PyPy >= 5.9 + if (PyMethodDescr_Check(method)) +#else + #if PY_MAJOR_VERSION == 2 + // PyMethodDescr_Type is not exposed in the CPython C-API in Py2. + static PyTypeObject *methoddescr_type = NULL; + if (methoddescr_type == NULL) { + PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append"); + if (!meth) return NULL; + methoddescr_type = Py_TYPE(meth); + Py_DECREF(meth); + } + #else + PyTypeObject *methoddescr_type = &PyMethodDescr_Type; + #endif + if (__Pyx_TypeCheck(method, methoddescr_type)) +#endif + { + // cdef classes + PyMethodDescrObject *descr = (PyMethodDescrObject *)method; + #if PY_VERSION_HEX < 0x03020000 + PyTypeObject *d_type = descr->d_type; + #else + PyTypeObject *d_type = descr->d_common.d_type; + #endif + return PyDescr_NewClassMethod(d_type, descr->d_method); + } +#endif + else if (PyMethod_Check(method)) { + // python classes + return PyClassMethod_New(PyMethod_GET_FUNCTION(method)); + } + else { + return PyClassMethod_New(method); + } +} diff --git a/contrib/tools/cython/Cython/Utility/Embed.c b/contrib/tools/cython/Cython/Utility/Embed.c new file mode 100644 index 00000000000..b7ec1d73258 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Embed.c @@ -0,0 +1,261 @@ +//////////////////// MainFunction //////////////////// + +#ifdef __FreeBSD__ +#include <floatingpoint.h> +#endif + +#if PY_MAJOR_VERSION < 3 +void Py_InitArgcArgv(int argc, char **argv); + +int %(main_method)s(int argc, char** argv) { +#elif defined(WIN32) || defined(MS_WINDOWS) +int %(wmain_method)s(int argc, wchar_t **argv) { +#else +static int __Pyx_main(int argc, wchar_t **argv) { +#endif + /* 754 requires that FP exceptions run in "no stop" mode by default, + * and until C vendors implement C99's ways to control FP exceptions, + * Python requires non-stop mode. Alas, some platforms enable FP + * exceptions by default. Here we disable them. + */ +#ifdef __FreeBSD__ + fp_except_t m; + + m = fpgetmask(); + fpsetmask(m & ~FP_X_OFL); +#endif +#if PY_VERSION_HEX < 0x03080000 + if (argc && argv) { + Py_InitArgcArgv(argc, argv); + Py_SetProgramName(argv[0]); + } + Py_Initialize(); + if (argc && argv) + PySys_SetArgv(argc, argv); +#else + { + PyStatus status; + + PyConfig config; + PyConfig_InitPythonConfig(&config); + // Disable parsing command line arguments + config.parse_argv = 0; + + if (argc && argv) { + status = PyConfig_SetString(&config, &config.program_name, argv[0]); + if (PyStatus_Exception(status)) { + PyConfig_Clear(&config); + return 1; + } + + status = PyConfig_SetArgv(&config, argc, argv); + if (PyStatus_Exception(status)) { + PyConfig_Clear(&config); + return 1; + } + } + + status = Py_InitializeFromConfig(&config); + if (PyStatus_Exception(status)) { + PyConfig_Clear(&config); + return 1; + } + + PyConfig_Clear(&config); + } +#endif + { /* init module '%(module_name)s' as '__main__' */ + PyObject* m = NULL; + %(module_is_main)s = 1; + #if PY_MAJOR_VERSION < 3 + init%(module_name)s(); + #elif CYTHON_PEP489_MULTI_PHASE_INIT + m = PyInit_%(module_name)s(); + if (!PyModule_Check(m)) { + PyModuleDef *mdef = (PyModuleDef *) m; + PyObject *modname = PyUnicode_FromString("__main__"); + m = NULL; + if (modname) { + // FIXME: not currently calling PyModule_FromDefAndSpec() here because we do not have a module spec! + // FIXME: not currently setting __file__, __path__, __spec__, ... + m = PyModule_NewObject(modname); + Py_DECREF(modname); + if (m) PyModule_ExecDef(m, mdef); + } + } + #else + m = PyInit_%(module_name)s(); + #endif + if (PyErr_Occurred()) { + PyErr_Print(); /* This exits with the right code if SystemExit. */ + #if PY_MAJOR_VERSION < 3 + if (Py_FlushLine()) PyErr_Clear(); + #endif + return 1; + } + Py_XDECREF(m); + } +#if PY_VERSION_HEX < 0x03060000 + Py_Finalize(); +#else + if (Py_FinalizeEx() < 0) + return 2; +#endif + return 0; +} + + +#if PY_MAJOR_VERSION >= 3 && !defined(WIN32) && !defined(MS_WINDOWS) +#include <locale.h> + +static wchar_t* +__Pyx_char2wchar(char* arg) +{ + wchar_t *res; +#ifdef HAVE_BROKEN_MBSTOWCS + /* Some platforms have a broken implementation of + * mbstowcs which does not count the characters that + * would result from conversion. Use an upper bound. + */ + size_t argsize = strlen(arg); +#else + size_t argsize = mbstowcs(NULL, arg, 0); +#endif + size_t count; + unsigned char *in; + wchar_t *out; +#ifdef HAVE_MBRTOWC + mbstate_t mbs; +#endif + if (argsize != (size_t)-1) { + res = (wchar_t *)malloc((argsize+1)*sizeof(wchar_t)); + if (!res) + goto oom; + count = mbstowcs(res, arg, argsize+1); + if (count != (size_t)-1) { + wchar_t *tmp; + /* Only use the result if it contains no + surrogate characters. */ + for (tmp = res; *tmp != 0 && + (*tmp < 0xd800 || *tmp > 0xdfff); tmp++) + ; + if (*tmp == 0) + return res; + } + free(res); + } + /* Conversion failed. Fall back to escaping with surrogateescape. */ +#ifdef HAVE_MBRTOWC + /* Try conversion with mbrtwoc (C99), and escape non-decodable bytes. */ + + /* Overallocate; as multi-byte characters are in the argument, the + actual output could use less memory. */ + argsize = strlen(arg) + 1; + res = (wchar_t *)malloc(argsize*sizeof(wchar_t)); + if (!res) goto oom; + in = (unsigned char*)arg; + out = res; + memset(&mbs, 0, sizeof mbs); + while (argsize) { + size_t converted = mbrtowc(out, (char*)in, argsize, &mbs); + if (converted == 0) + /* Reached end of string; null char stored. */ + break; + if (converted == (size_t)-2) { + /* Incomplete character. This should never happen, + since we provide everything that we have - + unless there is a bug in the C library, or I + misunderstood how mbrtowc works. */ + fprintf(stderr, "unexpected mbrtowc result -2\\n"); + free(res); + return NULL; + } + if (converted == (size_t)-1) { + /* Conversion error. Escape as UTF-8b, and start over + in the initial shift state. */ + *out++ = 0xdc00 + *in++; + argsize--; + memset(&mbs, 0, sizeof mbs); + continue; + } + if (*out >= 0xd800 && *out <= 0xdfff) { + /* Surrogate character. Escape the original + byte sequence with surrogateescape. */ + argsize -= converted; + while (converted--) + *out++ = 0xdc00 + *in++; + continue; + } + /* successfully converted some bytes */ + in += converted; + argsize -= converted; + out++; + } +#else + /* Cannot use C locale for escaping; manually escape as if charset + is ASCII (i.e. escape all bytes > 128. This will still roundtrip + correctly in the locale's charset, which must be an ASCII superset. */ + res = (wchar_t *)malloc((strlen(arg)+1)*sizeof(wchar_t)); + if (!res) goto oom; + in = (unsigned char*)arg; + out = res; + while(*in) + if(*in < 128) + *out++ = *in++; + else + *out++ = 0xdc00 + *in++; + *out = 0; +#endif + return res; +oom: + fprintf(stderr, "out of memory\\n"); + return NULL; +} + +int +%(main_method)s(int argc, char **argv) +{ + if (!argc) { + return __Pyx_main(0, NULL); + } + else { + int i, res; + wchar_t **argv_copy = (wchar_t **)malloc(sizeof(wchar_t*)*argc); + /* We need a second copy, as Python might modify the first one. */ + wchar_t **argv_copy2 = (wchar_t **)malloc(sizeof(wchar_t*)*argc); + char *oldloc = strdup(setlocale(LC_ALL, NULL)); + if (!argv_copy || !argv_copy2 || !oldloc) { + fprintf(stderr, "out of memory\\n"); + free(argv_copy); + free(argv_copy2); + free(oldloc); + return 1; + } + res = 0; + setlocale(LC_ALL, ""); + for (i = 0; i < argc; i++) { + argv_copy2[i] = argv_copy[i] = +#if PY_VERSION_HEX < 0x03050000 + __Pyx_char2wchar(argv[i]); +#else + Py_DecodeLocale(argv[i], NULL); +#endif + if (!argv_copy[i]) res = 1; /* failure, but continue to simplify cleanup */ + } + setlocale(LC_ALL, oldloc); + free(oldloc); + if (res == 0) + res = __Pyx_main(argc, argv_copy); + for (i = 0; i < argc; i++) { +#if PY_VERSION_HEX < 0x03050000 + free(argv_copy2[i]); +#else + PyMem_RawFree(argv_copy2[i]); +#endif + } + free(argv_copy); + free(argv_copy2); + return res; + } +} +#endif diff --git a/contrib/tools/cython/Cython/Utility/Exceptions.c b/contrib/tools/cython/Cython/Utility/Exceptions.c new file mode 100644 index 00000000000..87d3a5cddb7 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Exceptions.c @@ -0,0 +1,814 @@ +// Exception raising code +// +// Exceptions are raised by __Pyx_Raise() and stored as plain +// type/value/tb in PyThreadState->curexc_*. When being caught by an +// 'except' statement, curexc_* is moved over to exc_* by +// __Pyx_GetException() + + +/////////////// PyThreadStateGet.proto /////////////// +//@substitute: naming + +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *$local_tstate_cname; +#define __Pyx_PyThreadState_assign $local_tstate_cname = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() $local_tstate_cname->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + + +/////////////// PyErrExceptionMatches.proto /////////////// +//@substitute: naming + +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState($local_tstate_cname, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/////////////// PyErrExceptionMatches /////////////// + +#if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + // the tighter subtype checking in Py3 allows faster out-of-order comparison + for (i=0; i<n; i++) { + if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; + } +#endif + for (i=0; i<n; i++) { + if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1; + } + return 0; +} + +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { + PyObject *exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/////////////// PyErrFetchRestore.proto /////////////// +//@substitute: naming +//@requires: PyThreadStateGet + +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState($local_tstate_cname, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState($local_tstate_cname, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif + +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/////////////// PyErrFetchRestore /////////////// + +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} + +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/////////////// RaiseException.proto /////////////// + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ + +/////////////// RaiseException /////////////// +//@requires: PyErrFetchRestore +//@requires: PyThreadStateGet + +// The following function is based on do_raise() from ceval.c. There +// are separate versions for Python2 and Python3 as exception handling +// has changed quite a lot between the two versions. + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + /* 'cause' is only used in Py3 */ + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + + if (PyType_Check(type)) { + /* instantiate the type now (we don't know when and how it will be caught) */ +#if CYTHON_COMPILING_IN_PYPY + /* PyPy can't handle value == NULL */ + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + + } else { + /* Raising an instance. The value should be a dummy. */ + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + /* Normalize to raise <class>, <instance> */ + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} + +#else /* Python 3+ */ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + // make sure value is an exception instance of type + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + // error on subclass test + goto bad; + } else { + // believe the instance + type = instance_class; + } + } + } + if (!instance_class) { + // instantiate the type now (we don't know when and how it will be caught) + // assuming that 'value' is an argument to the type's constructor + // not using PyErr_NormalizeException() to avoid ref-counting problems + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + // raise ... from None + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + + PyErr_SetObject(type, value); + + if (tb) { +#if CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#else + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#endif + } + +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + + +/////////////// GetTopmostException.proto /////////////// + +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); +#endif + +/////////////// GetTopmostException /////////////// + +#if CYTHON_USE_EXC_INFO_STACK +// Copied from errors.c in CPython. +static _PyErr_StackItem * +__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) +{ + _PyErr_StackItem *exc_info = tstate->exc_info; + while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && + exc_info->previous_item != NULL) + { + exc_info = exc_info->previous_item; + } + return exc_info; +} +#endif + + +/////////////// GetException.proto /////////////// +//@substitute: naming +//@requires: PyThreadStateGet + +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException($local_tstate_cname, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +#endif + +/////////////// GetException /////////////// + +#if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) +#endif +{ + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + // traceback may be NULL for freshly raised exceptions + Py_XINCREF(local_tb); + // exception state may be temporarily empty in parallel loops (race condition) + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + #if CYTHON_USE_EXC_INFO_STACK + { + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = local_type; + exc_info->exc_value = local_value; + exc_info->exc_traceback = local_tb; + } + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + #endif + // Make sure tstate is in a consistent state when we XDECREF + // these objects (DECREF may run arbitrary code). + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/////////////// ReRaiseException.proto /////////////// + +static CYTHON_INLINE void __Pyx_ReraiseException(void); /*proto*/ + +/////////////// ReRaiseException /////////////// +//@requires: GetTopmostException + +static CYTHON_INLINE void __Pyx_ReraiseException(void) { + PyObject *type = NULL, *value = NULL, *tb = NULL; +#if CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = PyThreadState_GET(); + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + type = exc_info->exc_type; + value = exc_info->exc_value; + tb = exc_info->exc_traceback; + #else + type = tstate->exc_type; + value = tstate->exc_value; + tb = tstate->exc_traceback; + #endif +#else + PyErr_GetExcInfo(&type, &value, &tb); +#endif + if (!type || type == Py_None) { +#if !CYTHON_FAST_THREAD_STATE + Py_XDECREF(type); + Py_XDECREF(value); + Py_XDECREF(tb); +#endif + // message copied from Py3 + PyErr_SetString(PyExc_RuntimeError, + "No active exception to reraise"); + } else { +#if CYTHON_FAST_THREAD_STATE + Py_INCREF(type); + Py_XINCREF(value); + Py_XINCREF(tb); + +#endif + PyErr_Restore(type, value, tb); + } +} + +/////////////// SaveResetException.proto /////////////// +//@substitute: naming +//@requires: PyThreadStateGet + +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave($local_tstate_cname, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset($local_tstate_cname, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +#else + +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/////////////// SaveResetException /////////////// +//@requires: GetTopmostException + +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + *type = exc_info->exc_type; + *value = exc_info->exc_value; + *tb = exc_info->exc_traceback; + #else + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + #endif + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} + +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = type; + exc_info->exc_value = value; + exc_info->exc_traceback = tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/////////////// SwapException.proto /////////////// +//@substitute: naming +//@requires: PyThreadStateGet + +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap($local_tstate_cname, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +#endif + +/////////////// SwapException /////////////// + +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + + exc_info->exc_type = *type; + exc_info->exc_value = *value; + exc_info->exc_traceback = *tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + #endif + + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} + +#else + +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +/////////////// WriteUnraisableException.proto /////////////// + +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); /*proto*/ + +/////////////// WriteUnraisableException /////////////// +//@requires: PyErrFetchRestore +//@requires: PyThreadStateGet + +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); + /* initalize to suppress warning */ + else state = (PyGILState_STATE)0; +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + +/////////////// CLineInTraceback.proto /////////////// + +#ifdef CYTHON_CLINE_IN_TRACEBACK /* 0 or 1 to disable/enable C line display in tracebacks at C compile time */ +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);/*proto*/ +#endif + +/////////////// CLineInTraceback /////////////// +//@requires: ObjectHandling.c::PyObjectGetAttrStr +//@requires: ObjectHandling.c::PyDictVersioning +//@requires: PyErrFetchRestore +//@substitute: naming + +#ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + + if (unlikely(!${cython_runtime_cname})) { + // Very early error where the runtime module is not set up yet. + return c_line; + } + + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); + +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(${cython_runtime_cname}); + if (likely(cython_runtime_dict)) { + __PYX_PY_DICT_LOOKUP_IF_MODIFIED( + use_cline, *cython_runtime_dict, + __Pyx_PyDict_GetItemStr(*cython_runtime_dict, PYIDENT("cline_in_traceback"))) + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(${cython_runtime_cname}, PYIDENT("cline_in_traceback")); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + // No need to handle errors here when we reset the exception state just afterwards. + (void) PyObject_SetAttr(${cython_runtime_cname}, PYIDENT("cline_in_traceback"), Py_False); + } + else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + +/////////////// AddTraceback.proto /////////////// + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); /*proto*/ + +/////////////// AddTraceback /////////////// +//@requires: ModuleSetupCode.c::CodeObjectCache +//@requires: CLineInTraceback +//@substitute: naming + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif + +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = NULL; + PyObject *py_funcname = NULL; + #if PY_MAJOR_VERSION < 3 + PyObject *py_srcfile = NULL; + + py_srcfile = PyString_FromString(filename); + if (!py_srcfile) goto bad; + #endif + + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line); + if (!py_funcname) goto bad; + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, $cfilenm_cname, c_line); + if (!py_funcname) goto bad; + funcname = PyUnicode_AsUTF8(py_funcname); + if (!funcname) goto bad; + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + #endif + } + #if PY_MAJOR_VERSION < 3 + py_code = __Pyx_PyCode_New( + 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + $empty_bytes, /*PyObject *code,*/ + $empty_tuple, /*PyObject *consts,*/ + $empty_tuple, /*PyObject *names,*/ + $empty_tuple, /*PyObject *varnames,*/ + $empty_tuple, /*PyObject *freevars,*/ + $empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, /*int firstlineno,*/ + $empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + #else + py_code = PyCode_NewEmpty(filename, funcname, py_line); + #endif + Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline + return py_code; +bad: + Py_XDECREF(py_funcname); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_srcfile); + #endif + return NULL; +} + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject *ptype, *pvalue, *ptraceback; + + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + + // Negate to avoid collisions between py and c lines. + py_code = $global_code_object_cache_find(c_line ? -c_line : py_line); + if (!py_code) { + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) { + /* If the code object creation fails, then we should clear the + fetched exception references and propagate the new exception */ + Py_XDECREF(ptype); + Py_XDECREF(pvalue); + Py_XDECREF(ptraceback); + goto bad; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + $global_code_object_cache_insert(c_line ? -c_line : py_line, py_code); + } + py_frame = PyFrame_New( + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + $moddict_cname, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} diff --git a/contrib/tools/cython/Cython/Utility/ExtensionTypes.c b/contrib/tools/cython/Cython/Utility/ExtensionTypes.c new file mode 100644 index 00000000000..dc187ab49e8 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/ExtensionTypes.c @@ -0,0 +1,301 @@ +/////////////// PyType_Ready.proto /////////////// + +static int __Pyx_PyType_Ready(PyTypeObject *t); + +/////////////// PyType_Ready /////////////// + +// Wrapper around PyType_Ready() with some runtime checks and fixes +// to deal with multiple inheritance. +static int __Pyx_PyType_Ready(PyTypeObject *t) { + // Loop over all bases (except the first) and check that those + // really are heap types. Otherwise, it would not be safe to + // subclass them. + // + // We also check tp_dictoffset: it is unsafe to inherit + // tp_dictoffset from a base class because the object structures + // would not be compatible. So, if our extension type doesn't set + // tp_dictoffset (i.e. there is no __dict__ attribute in the object + // structure), we need to check that none of the base classes sets + // it either. + int r; + PyObject *bases = t->tp_bases; + if (bases) + { + Py_ssize_t i, n = PyTuple_GET_SIZE(bases); + for (i = 1; i < n; i++) /* Skip first base */ + { + PyObject *b0 = PyTuple_GET_ITEM(bases, i); + PyTypeObject *b; +#if PY_MAJOR_VERSION < 3 + /* Disallow old-style classes */ + if (PyClass_Check(b0)) + { + PyErr_Format(PyExc_TypeError, "base class '%.200s' is an old-style class", + PyString_AS_STRING(((PyClassObject*)b0)->cl_name)); + return -1; + } +#endif + b = (PyTypeObject*)b0; + if (!PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE)) + { + PyErr_Format(PyExc_TypeError, "base class '%.200s' is not a heap type", + b->tp_name); + return -1; + } + if (t->tp_dictoffset == 0 && b->tp_dictoffset) + { + PyErr_Format(PyExc_TypeError, + "extension type '%.200s' has no __dict__ slot, but base type '%.200s' has: " + "either add 'cdef dict __dict__' to the extension type " + "or add '__slots__ = [...]' to the base type", + t->tp_name, b->tp_name); + return -1; + } + } + } + +#if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) + { + // Make sure GC does not pick up our non-heap type as heap type with this hack! + // For details, see https://github.com/cython/cython/issues/3603 + PyObject *ret, *py_status; + int gc_was_enabled; + PyObject *gc = PyImport_Import(PYUNICODE("gc")); + if (unlikely(!gc)) return -1; + py_status = PyObject_CallMethodObjArgs(gc, PYUNICODE("isenabled"), NULL); + if (unlikely(!py_status)) { + Py_DECREF(gc); + return -1; + } + gc_was_enabled = __Pyx_PyObject_IsTrue(py_status); + Py_DECREF(py_status); + if (gc_was_enabled > 0) { + ret = PyObject_CallMethodObjArgs(gc, PYUNICODE("disable"), NULL); + if (unlikely(!ret)) { + Py_DECREF(gc); + return -1; + } + Py_DECREF(ret); + } else if (unlikely(gc_was_enabled == -1)) { + Py_DECREF(gc); + return -1; + } + + // As of https://bugs.python.org/issue22079 + // PyType_Ready enforces that all bases of a non-heap type are + // non-heap. We know that this is the case for the solid base but + // other bases are heap allocated and are kept alive through the + // tp_bases reference. + // Other than this check, the Py_TPFLAGS_HEAPTYPE flag is unused + // in PyType_Ready(). + t->tp_flags |= Py_TPFLAGS_HEAPTYPE; +#endif + + r = PyType_Ready(t); + +#if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) + t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE; + + if (gc_was_enabled) { + PyObject *t, *v, *tb; + PyErr_Fetch(&t, &v, &tb); + ret = PyObject_CallMethodObjArgs(gc, PYUNICODE("enable"), NULL); + if (likely(ret || r == -1)) { + Py_XDECREF(ret); + // do not overwrite exceptions raised by PyType_Ready() above + PyErr_Restore(t, v, tb); + } else { + // PyType_Ready() succeeded, but gc.enable() failed. + Py_XDECREF(t); + Py_XDECREF(v); + Py_XDECREF(tb); + r = -1; + } + } + Py_DECREF(gc); + } +#endif + + return r; +} + +/////////////// CallNextTpDealloc.proto /////////////// + +static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc); + +/////////////// CallNextTpDealloc /////////////// + +static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) { + PyTypeObject* type = Py_TYPE(obj); + /* try to find the first parent type that has a different tp_dealloc() function */ + while (type && type->tp_dealloc != current_tp_dealloc) + type = type->tp_base; + while (type && type->tp_dealloc == current_tp_dealloc) + type = type->tp_base; + if (type) + type->tp_dealloc(obj); +} + +/////////////// CallNextTpTraverse.proto /////////////// + +static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse); + +/////////////// CallNextTpTraverse /////////////// + +static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) { + PyTypeObject* type = Py_TYPE(obj); + /* try to find the first parent type that has a different tp_traverse() function */ + while (type && type->tp_traverse != current_tp_traverse) + type = type->tp_base; + while (type && type->tp_traverse == current_tp_traverse) + type = type->tp_base; + if (type && type->tp_traverse) + return type->tp_traverse(obj, v, a); + // FIXME: really ignore? + return 0; +} + +/////////////// CallNextTpClear.proto /////////////// + +static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc); + +/////////////// CallNextTpClear /////////////// + +static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { + PyTypeObject* type = Py_TYPE(obj); + /* try to find the first parent type that has a different tp_clear() function */ + while (type && type->tp_clear != current_tp_clear) + type = type->tp_base; + while (type && type->tp_clear == current_tp_clear) + type = type->tp_base; + if (type && type->tp_clear) + type->tp_clear(obj); +} + +/////////////// SetupReduce.proto /////////////// + +static int __Pyx_setup_reduce(PyObject* type_obj); + +/////////////// SetupReduce /////////////// +//@requires: ObjectHandling.c::PyObjectGetAttrStrNoError +//@requires: ObjectHandling.c::PyObjectGetAttrStr +//@substitute: naming + +static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + int ret; + PyObject *name_attr; + + name_attr = __Pyx_PyObject_GetAttrStr(meth, PYIDENT("__name__")); + if (likely(name_attr)) { + ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); + } else { + ret = -1; + } + + if (unlikely(ret < 0)) { + PyErr_Clear(); + ret = 0; + } + + Py_XDECREF(name_attr); + return ret; +} + +static int __Pyx_setup_reduce(PyObject* type_obj) { + int ret = 0; + PyObject *object_reduce = NULL; + PyObject *object_getstate = NULL; + PyObject *object_reduce_ex = NULL; + PyObject *reduce = NULL; + PyObject *reduce_ex = NULL; + PyObject *reduce_cython = NULL; + PyObject *setstate = NULL; + PyObject *setstate_cython = NULL; + PyObject *getstate = NULL; + +#if CYTHON_USE_PYTYPE_LOOKUP + getstate = _PyType_Lookup((PyTypeObject*)type_obj, PYIDENT("__getstate__")); +#else + getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__getstate__")); + if (!getstate && PyErr_Occurred()) { + goto __PYX_BAD; + } +#endif + if (getstate) { + // Python 3.11 introduces object.__getstate__. Because it's version-specific failure to find it should not be an error +#if CYTHON_USE_PYTYPE_LOOKUP + object_getstate = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__getstate__")); +#else + object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, PYIDENT("__getstate__")); + if (!object_getstate && PyErr_Occurred()) { + goto __PYX_BAD; + } +#endif + if (object_getstate != getstate) { + goto __PYX_GOOD; + } + } + +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__reduce_ex__")); if (!object_reduce_ex) goto __PYX_BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, PYIDENT("__reduce_ex__")); if (!object_reduce_ex) goto __PYX_BAD; +#endif + + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce_ex__")); if (unlikely(!reduce_ex)) goto __PYX_BAD; + if (reduce_ex == object_reduce_ex) { + +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__reduce__")); if (!object_reduce) goto __PYX_BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, PYIDENT("__reduce__")); if (!object_reduce) goto __PYX_BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce__")); if (unlikely(!reduce)) goto __PYX_BAD; + + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, PYIDENT("__reduce_cython__"))) { + reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__reduce_cython__")); + if (likely(reduce_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__reduce__"), reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__reduce_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (reduce == object_reduce || PyErr_Occurred()) { + // Ignore if we're done, i.e. if 'reduce' already has the right name and the original is gone. + // Otherwise: error. + goto __PYX_BAD; + } + + setstate = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__setstate__")); + if (!setstate) PyErr_Clear(); + if (!setstate || __Pyx_setup_reduce_is_named(setstate, PYIDENT("__setstate_cython__"))) { + setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__setstate_cython__")); + if (likely(setstate_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__setstate__"), setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__setstate_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (!setstate || PyErr_Occurred()) { + // Ignore if we're done, i.e. if 'setstate' already has the right name and the original is gone. + // Otherwise: error. + goto __PYX_BAD; + } + } + PyType_Modified((PyTypeObject*)type_obj); + } + } + goto __PYX_GOOD; + +__PYX_BAD: + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + ret = -1; +__PYX_GOOD: +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); + Py_XDECREF(object_getstate); + Py_XDECREF(getstate); +#endif + Py_XDECREF(reduce); + Py_XDECREF(reduce_ex); + Py_XDECREF(reduce_cython); + Py_XDECREF(setstate); + Py_XDECREF(setstate_cython); + return ret; +} diff --git a/contrib/tools/cython/Cython/Utility/FunctionArguments.c b/contrib/tools/cython/Cython/Utility/FunctionArguments.c new file mode 100644 index 00000000000..8333d936664 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/FunctionArguments.c @@ -0,0 +1,352 @@ +//////////////////// ArgTypeTest.proto //////////////////// + + +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact) \ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 : \ + __Pyx__ArgTypeTest(obj, type, name, exact)) + +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /*proto*/ + +//////////////////// ArgTypeTest //////////////////// + +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + else if (exact) { + #if PY_MAJOR_VERSION == 2 + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(__Pyx_TypeCheck(obj, type))) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +//////////////////// RaiseArgTupleInvalid.proto //////////////////// + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + +//////////////////// RaiseArgTupleInvalid //////////////////// + +// __Pyx_RaiseArgtupleInvalid raises the correct exception when too +// many or too few positional arguments were found. This handles +// Py_ssize_t formatting correctly. + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + + +//////////////////// RaiseKeywordRequired.proto //////////////////// + +static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name); /*proto*/ + +//////////////////// RaiseKeywordRequired //////////////////// + +static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name) { + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() needs keyword-only argument %U", func_name, kw_name); + #else + "%s() needs keyword-only argument %s", func_name, + PyString_AS_STRING(kw_name)); + #endif +} + + +//////////////////// RaiseDoubleKeywords.proto //////////////////// + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ + +//////////////////// RaiseDoubleKeywords //////////////////// + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + + +//////////////////// RaiseMappingExpected.proto //////////////////// + +static void __Pyx_RaiseMappingExpectedError(PyObject* arg); /*proto*/ + +//////////////////// RaiseMappingExpected //////////////////// + +static void __Pyx_RaiseMappingExpectedError(PyObject* arg) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not a mapping", Py_TYPE(arg)->tp_name); +} + + +//////////////////// KeywordStringCheck.proto //////////////////// + +static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ + +//////////////////// KeywordStringCheck //////////////////// + +// __Pyx_CheckKeywordStrings raises an error if non-string keywords +// were passed to a function, or if any keywords were passed to a +// function that does not accept them. + +static int __Pyx_CheckKeywordStrings( + PyObject *kwdict, + const char* function_name, + int kw_allowed) +{ + PyObject* key = 0; + Py_ssize_t pos = 0; +#if CYTHON_COMPILING_IN_PYPY + /* PyPy appears to check keywords at call time, not at unpacking time => not much to do here */ + if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) + goto invalid_keyword; + return 1; +#else + while (PyDict_Next(kwdict, &pos, &key, 0)) { + #if PY_MAJOR_VERSION < 3 + if (unlikely(!PyString_Check(key))) + #endif + if (unlikely(!PyUnicode_Check(key))) + goto invalid_keyword_type; + } + if ((!kw_allowed) && unlikely(key)) + goto invalid_keyword; + return 1; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + return 0; +#endif +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif + return 0; +} + + +//////////////////// ParseKeywords.proto //////////////////// + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ + +//////////////////// ParseKeywords //////////////////// +//@requires: RaiseDoubleKeywords + +// __Pyx_ParseOptionalKeywords copies the optional/unknown keyword +// arguments from the kwds dict into kwds2. If kwds2 is NULL, unknown +// keywords will raise an invalid keyword error. +// +// Three kinds of errors are checked: 1) non-string keywords, 2) +// unexpected keywords and 3) overlap with positional arguments. +// +// If num_posargs is greater 0, it denotes the number of positional +// arguments that were passed and that must therefore not appear +// amongst the keywords as well. +// +// This method does not check for required keyword arguments. + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + // not found after positional args, check for duplicate + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + // In Py2, we may need to convert the argument name from str to unicode for comparison. + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + // not found after positional args, check for duplicate + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + // need to convert argument name from bytes to unicode for comparison + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + + +//////////////////// MergeKeywords.proto //////////////////// + +static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping); /*proto*/ + +//////////////////// MergeKeywords //////////////////// +//@requires: RaiseDoubleKeywords +//@requires: Optimize.c::dict_iter + +static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) { + PyObject *iter, *key = NULL, *value = NULL; + int source_is_dict, result; + Py_ssize_t orig_length, ppos = 0; + + iter = __Pyx_dict_iterator(source_mapping, 0, PYIDENT("items"), &orig_length, &source_is_dict); + if (unlikely(!iter)) { + // slow fallback: try converting to dict, then iterate + PyObject *args; + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + args = PyTuple_Pack(1, source_mapping); + if (likely(args)) { + PyObject *fallback = PyObject_Call((PyObject*)&PyDict_Type, args, NULL); + Py_DECREF(args); + if (likely(fallback)) { + iter = __Pyx_dict_iterator(fallback, 1, PYIDENT("items"), &orig_length, &source_is_dict); + Py_DECREF(fallback); + } + } + if (unlikely(!iter)) goto bad; + } + + while (1) { + result = __Pyx_dict_iter_next(iter, orig_length, &ppos, &key, &value, NULL, source_is_dict); + if (unlikely(result < 0)) goto bad; + if (!result) break; + + if (unlikely(PyDict_Contains(kwdict, key))) { + __Pyx_RaiseDoubleKeywordsError("function", key); + result = -1; + } else { + result = PyDict_SetItem(kwdict, key, value); + } + Py_DECREF(key); + Py_DECREF(value); + if (unlikely(result < 0)) goto bad; + } + Py_XDECREF(iter); + return 0; + +bad: + Py_XDECREF(iter); + return -1; +} diff --git a/contrib/tools/cython/Cython/Utility/ImportExport.c b/contrib/tools/cython/Cython/Utility/ImportExport.c new file mode 100644 index 00000000000..e1458fc8ff6 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/ImportExport.c @@ -0,0 +1,761 @@ +/////////////// PyIdentifierFromString.proto /////////////// + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + + +/////////////// Import.proto /////////////// + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ + +/////////////// Import /////////////// +//@requires: ObjectHandling.c::PyObjectGetAttrStr +//@substitute: naming + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_MAJOR_VERSION < 3 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr($builtins_cname, PYIDENT("__import__")); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict($module_cname); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + // Avoid C compiler warning if strchr() evaluates to false at compile time. + if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { + /* try package relative import first */ + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; /* try absolute import on failure */ + } + #endif + if (!module) { + #if PY_MAJOR_VERSION < 3 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + + +/////////////// ImportFrom.proto /////////////// + +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/ + +/////////////// ImportFrom /////////////// +//@requires: ObjectHandling.c::PyObjectGetAttrStr + +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + + +/////////////// ImportStar /////////////// +//@substitute: naming + +/* import_all_from is an unexposed function from ceval.c */ + +static int +__Pyx_import_all_from(PyObject *locals, PyObject *v) +{ + PyObject *all = PyObject_GetAttrString(v, "__all__"); + PyObject *dict, *name, *value; + int skip_leading_underscores = 0; + int pos, err; + + if (all == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; /* Unexpected error */ + PyErr_Clear(); + dict = PyObject_GetAttrString(v, "__dict__"); + if (dict == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; + PyErr_SetString(PyExc_ImportError, + "from-import-* object has no __dict__ and no __all__"); + return -1; + } +#if PY_MAJOR_VERSION < 3 + all = PyObject_CallMethod(dict, (char *)"keys", NULL); +#else + all = PyMapping_Keys(dict); +#endif + Py_DECREF(dict); + if (all == NULL) + return -1; + skip_leading_underscores = 1; + } + + for (pos = 0, err = 0; ; pos++) { + name = PySequence_GetItem(all, pos); + if (name == NULL) { + if (!PyErr_ExceptionMatches(PyExc_IndexError)) + err = -1; + else + PyErr_Clear(); + break; + } + if (skip_leading_underscores && +#if PY_MAJOR_VERSION < 3 + likely(PyString_Check(name)) && + PyString_AS_STRING(name)[0] == '_') +#else + likely(PyUnicode_Check(name)) && + likely(__Pyx_PyUnicode_GET_LENGTH(name)) && + __Pyx_PyUnicode_READ_CHAR(name, 0) == '_') +#endif + { + Py_DECREF(name); + continue; + } + value = PyObject_GetAttr(v, name); + if (value == NULL) + err = -1; + else if (PyDict_CheckExact(locals)) + err = PyDict_SetItem(locals, name, value); + else + err = PyObject_SetItem(locals, name, value); + Py_DECREF(name); + Py_XDECREF(value); + if (err != 0) + break; + } + Py_DECREF(all); + return err; +} + + +static int ${import_star}(PyObject* m) { + + int i; + int ret = -1; + char* s; + PyObject *locals = 0; + PyObject *list = 0; +#if PY_MAJOR_VERSION >= 3 + PyObject *utf8_name = 0; +#endif + PyObject *name; + PyObject *item; + + locals = PyDict_New(); if (!locals) goto bad; + if (__Pyx_import_all_from(locals, m) < 0) goto bad; + list = PyDict_Items(locals); if (!list) goto bad; + + for(i=0; i<PyList_GET_SIZE(list); i++) { + name = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 0); + item = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 1); +#if PY_MAJOR_VERSION >= 3 + utf8_name = PyUnicode_AsUTF8String(name); + if (!utf8_name) goto bad; + s = PyBytes_AS_STRING(utf8_name); + if (${import_star_set}(item, name, s) < 0) goto bad; + Py_DECREF(utf8_name); utf8_name = 0; +#else + s = PyString_AsString(name); + if (!s) goto bad; + if (${import_star_set}(item, name, s) < 0) goto bad; +#endif + } + ret = 0; + +bad: + Py_XDECREF(locals); + Py_XDECREF(list); +#if PY_MAJOR_VERSION >= 3 + Py_XDECREF(utf8_name); +#endif + return ret; +} + + +/////////////// SetPackagePathFromImportLib.proto /////////////// + +// PY_VERSION_HEX >= 0x03030000 +#if PY_MAJOR_VERSION >= 3 && !CYTHON_PEP489_MULTI_PHASE_INIT +static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name); +#else +#define __Pyx_SetPackagePathFromImportLib(a) 0 +#endif + +/////////////// SetPackagePathFromImportLib /////////////// +//@requires: ObjectHandling.c::PyObjectGetAttrStr +//@substitute: naming + +// PY_VERSION_HEX >= 0x03030000 +#if PY_MAJOR_VERSION >= 3 && !CYTHON_PEP489_MULTI_PHASE_INIT +static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name) { + PyObject *importlib, *osmod, *ossep, *parts, *package_path; + PyObject *file_path = NULL; + int result; + PyObject *spec; + // package_path = [importlib.util.find_spec(module_name).origin.rsplit(os.sep, 1)[0]] + importlib = PyImport_ImportModule("importlib.util"); + if (unlikely(!importlib)) + goto bad; + spec = PyObject_CallMethod(importlib, "find_spec", "(O)", module_name); + Py_DECREF(importlib); + if (unlikely(!spec)) + goto bad; + file_path = PyObject_GetAttrString(spec, "origin"); + Py_DECREF(spec); + if (unlikely(!file_path)) + goto bad; + + if (unlikely(PyObject_SetAttrString($module_cname, "__file__", file_path) < 0)) + goto bad; + + osmod = PyImport_ImportModule("os"); + if (unlikely(!osmod)) + goto bad; + ossep = PyObject_GetAttrString(osmod, "sep"); + Py_DECREF(osmod); + if (unlikely(!ossep)) + goto bad; + parts = PyObject_CallMethod(file_path, "rsplit", "(Oi)", ossep, 1); + Py_DECREF(file_path); file_path = NULL; + Py_DECREF(ossep); + if (unlikely(!parts)) + goto bad; + package_path = Py_BuildValue("[O]", PyList_GET_ITEM(parts, 0)); + Py_DECREF(parts); + if (unlikely(!package_path)) + goto bad; + goto set_path; + +bad: + PyErr_WriteUnraisable(module_name); + Py_XDECREF(file_path); + + // set an empty path list on failure + PyErr_Clear(); + package_path = PyList_New(0); + if (unlikely(!package_path)) + return -1; + +set_path: + result = PyObject_SetAttrString($module_cname, "__path__", package_path); + Py_DECREF(package_path); + return result; +} +#endif + + +/////////////// TypeImport.proto /////////////// + +#ifndef __PYX_HAVE_RT_ImportType_proto +#define __PYX_HAVE_RT_ImportType_proto + +#if __STDC_VERSION__ >= 201112L +#include <stdalign.h> +#endif + +#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L +#define __PYX_GET_STRUCT_ALIGNMENT(s) alignof(s) +#else +// best guess at what the alignment could be since we can't measure it +#define __PYX_GET_STRUCT_ALIGNMENT(s) sizeof(void*) +#endif + +enum __Pyx_ImportType_CheckSize { + __Pyx_ImportType_CheckSize_Error = 0, + __Pyx_ImportType_CheckSize_Warn = 1, + __Pyx_ImportType_CheckSize_Ignore = 2 +}; + +static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize check_size); /*proto*/ + +#endif + +/////////////// TypeImport /////////////// + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, + size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize check_size) +{ + PyObject *result = 0; + char warning[200]; + Py_ssize_t basicsize; + Py_ssize_t itemsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; + PyObject *py_itemsize; +#endif + + result = PyObject_GetAttrString(module, class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; + itemsize = ((PyTypeObject *)result)->tp_itemsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; + py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); + if (!py_itemsize) + goto bad; + itemsize = PyLong_AsSsize_t(py_itemsize); + Py_DECREF(py_itemsize); + py_itemsize = 0; + if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (itemsize) { + // If itemsize is smaller than the alignment the struct can end up with some extra + // padding at the end. In this case we need to work out the maximum size that + // the padding could be when calculating the range of valid struct sizes. + if (size % alignment) { + // if this is true we've probably calculated the alignment wrongly + // (most likely because alignof isn't available) + alignment = size % alignment; + } + if (itemsize < (Py_ssize_t)alignment) + itemsize = (Py_ssize_t)alignment; + } + if ((size_t)(basicsize + itemsize) < size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + /* check_size == __Pyx_ImportType_CheckSize_Ignore does not warn nor error */ + return (PyTypeObject *)result; +bad: + Py_XDECREF(result); + return NULL; +} +#endif + +/////////////// FunctionImport.proto /////////////// + +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/ + +/////////////// FunctionImport /////////////// +//@substitute: naming + +#ifndef __PYX_HAVE_RT_ImportFunction +#define __PYX_HAVE_RT_ImportFunction +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + + d = PyObject_GetAttrString(module, (char *)"$api_name"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, funcname); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%.200s does not export expected C function %.200s", + PyModule_GetName(module), funcname); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", + PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); + goto bad; + } + tmp.p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", + PyModule_GetName(module), funcname, sig, desc); + goto bad; + } + tmp.p = PyCObject_AsVoidPtr(cobj);} +#endif + *f = tmp.fp; + if (!(*f)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + +/////////////// FunctionExport.proto /////////////// + +static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /*proto*/ + +/////////////// FunctionExport /////////////// +//@substitute: naming + +static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + + d = PyObject_GetAttrString($module_cname, (char *)"$api_name"); + if (!d) { + PyErr_Clear(); + d = PyDict_New(); + if (!d) + goto bad; + Py_INCREF(d); + if (PyModule_AddObject($module_cname, (char *)"$api_name", d) < 0) + goto bad; + } + tmp.fp = f; +#if PY_VERSION_HEX >= 0x02070000 + cobj = PyCapsule_New(tmp.p, sig, 0); +#else + cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0); +#endif + if (!cobj) + goto bad; + if (PyDict_SetItemString(d, name, cobj) < 0) + goto bad; + Py_DECREF(cobj); + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(cobj); + Py_XDECREF(d); + return -1; +} + +/////////////// VoidPtrImport.proto /////////////// + +static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig); /*proto*/ + +/////////////// VoidPtrImport /////////////// +//@substitute: naming + +#ifndef __PYX_HAVE_RT_ImportVoidPtr +#define __PYX_HAVE_RT_ImportVoidPtr +static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + + d = PyObject_GetAttrString(module, (char *)"$api_name"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, name); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%.200s does not export expected C variable %.200s", + PyModule_GetName(module), name); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", + PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj)); + goto bad; + } + *p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", + PyModule_GetName(module), name, sig, desc); + goto bad; + } + *p = PyCObject_AsVoidPtr(cobj);} +#endif + if (!(*p)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + +/////////////// VoidPtrExport.proto /////////////// + +static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig); /*proto*/ + +/////////////// VoidPtrExport /////////////// +//@substitute: naming +//@requires: ObjectHandling.c::PyObjectSetAttrStr + +static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) { + PyObject *d; + PyObject *cobj = 0; + + d = PyDict_GetItem($moddict_cname, PYIDENT("$api_name")); + Py_XINCREF(d); + if (!d) { + d = PyDict_New(); + if (!d) + goto bad; + if (__Pyx_PyObject_SetAttrStr($module_cname, PYIDENT("$api_name"), d) < 0) + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 + cobj = PyCapsule_New(p, sig, 0); +#else + cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0); +#endif + if (!cobj) + goto bad; + if (PyDict_SetItem(d, name, cobj) < 0) + goto bad; + Py_DECREF(cobj); + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(cobj); + Py_XDECREF(d); + return -1; +} + + +/////////////// SetVTable.proto /////////////// + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +/////////////// SetVTable /////////////// + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, PYIDENT("__pyx_vtable__"), ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + + +/////////////// GetVTable.proto /////////////// + +static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ + +/////////////// GetVTable /////////////// + +static void* __Pyx_GetVtable(PyObject *dict) { + void* ptr; + PyObject *ob = PyObject_GetItem(dict, PYIDENT("__pyx_vtable__")); + if (!ob) + goto bad; +#if PY_VERSION_HEX >= 0x02070000 + ptr = PyCapsule_GetPointer(ob, 0); +#else + ptr = PyCObject_AsVoidPtr(ob); +#endif + if (!ptr && !PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); + Py_DECREF(ob); + return ptr; +bad: + Py_XDECREF(ob); + return NULL; +} + + +/////////////// MergeVTables.proto /////////////// +//@requires: GetVTable + +static int __Pyx_MergeVtables(PyTypeObject *type); /*proto*/ + +/////////////// MergeVTables /////////////// + +static int __Pyx_MergeVtables(PyTypeObject *type) { + int i; + void** base_vtables; + void* unknown = (void*)-1; + PyObject* bases = type->tp_bases; + int base_depth = 0; + { + PyTypeObject* base = type->tp_base; + while (base) { + base_depth += 1; + base = base->tp_base; + } + } + base_vtables = (void**) malloc(sizeof(void*) * (size_t)(base_depth + 1)); + base_vtables[0] = unknown; + // Could do MRO resolution of individual methods in the future, assuming + // compatible vtables, but for now simply require a common vtable base. + // Note that if the vtables of various bases are extended separately, + // resolution isn't possible and we must reject it just as when the + // instance struct is so extended. (It would be good to also do this + // check when a multiple-base class is created in pure Python as well.) + for (i = 1; i < PyTuple_GET_SIZE(bases); i++) { + void* base_vtable = __Pyx_GetVtable(((PyTypeObject*)PyTuple_GET_ITEM(bases, i))->tp_dict); + if (base_vtable != NULL) { + int j; + PyTypeObject* base = type->tp_base; + for (j = 0; j < base_depth; j++) { + if (base_vtables[j] == unknown) { + base_vtables[j] = __Pyx_GetVtable(base->tp_dict); + base_vtables[j + 1] = unknown; + } + if (base_vtables[j] == base_vtable) { + break; + } else if (base_vtables[j] == NULL) { + // No more potential matching bases (with vtables). + goto bad; + } + base = base->tp_base; + } + } + } + PyErr_Clear(); + free(base_vtables); + return 0; +bad: + PyErr_Format( + PyExc_TypeError, + "multiple bases have vtable conflict: '%s' and '%s'", + type->tp_base->tp_name, ((PyTypeObject*)PyTuple_GET_ITEM(bases, i))->tp_name); + free(base_vtables); + return -1; +} + + +/////////////// ImportNumPyArray.proto /////////////// + +static PyObject *__pyx_numpy_ndarray = NULL; + +static PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void); /*proto*/ + +/////////////// ImportNumPyArray.cleanup /////////////// +Py_CLEAR(__pyx_numpy_ndarray); + +/////////////// ImportNumPyArray /////////////// +//@requires: ImportExport.c::Import + +static PyObject* __Pyx__ImportNumPyArray(void) { + PyObject *numpy_module, *ndarray_object = NULL; + numpy_module = __Pyx_Import(PYIDENT("numpy"), NULL, 0); + if (likely(numpy_module)) { + ndarray_object = PyObject_GetAttrString(numpy_module, "ndarray"); + Py_DECREF(numpy_module); + } + if (unlikely(!ndarray_object)) { + // ImportError, AttributeError, ... + PyErr_Clear(); + } + if (unlikely(!ndarray_object || !PyObject_TypeCheck(ndarray_object, &PyType_Type))) { + Py_XDECREF(ndarray_object); + Py_INCREF(Py_None); + ndarray_object = Py_None; + } + return ndarray_object; +} + +static CYTHON_INLINE PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void) { + if (unlikely(!__pyx_numpy_ndarray)) { + __pyx_numpy_ndarray = __Pyx__ImportNumPyArray(); + } + Py_INCREF(__pyx_numpy_ndarray); + return __pyx_numpy_ndarray; +} diff --git a/contrib/tools/cython/Cython/Utility/MemoryView.pyx b/contrib/tools/cython/Cython/Utility/MemoryView.pyx new file mode 100644 index 00000000000..277c0bd87a3 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/MemoryView.pyx @@ -0,0 +1,1496 @@ +#################### View.MemoryView #################### + +# This utility provides cython.array and cython.view.memoryview + +from __future__ import absolute_import + +cimport cython + +# from cpython cimport ... +cdef extern from "Python.h": + int PyIndex_Check(object) + object PyLong_FromVoidPtr(void *) + +cdef extern from "pythread.h": + ctypedef void *PyThread_type_lock + + PyThread_type_lock PyThread_allocate_lock() + void PyThread_free_lock(PyThread_type_lock) + int PyThread_acquire_lock(PyThread_type_lock, int mode) nogil + void PyThread_release_lock(PyThread_type_lock) nogil + +cdef extern from "<string.h>": + void *memset(void *b, int c, size_t len) + +cdef extern from *: + bint __PYX_CYTHON_ATOMICS_ENABLED() noexcept + int __Pyx_GetBuffer(object, Py_buffer *, int) except -1 + void __Pyx_ReleaseBuffer(Py_buffer *) + + ctypedef struct PyObject + ctypedef Py_ssize_t Py_intptr_t + void Py_INCREF(PyObject *) + void Py_DECREF(PyObject *) + + void* PyMem_Malloc(size_t n) + void PyMem_Free(void *p) + void* PyObject_Malloc(size_t n) + void PyObject_Free(void *p) + + cdef struct __pyx_memoryview "__pyx_memoryview_obj": + Py_buffer view + PyObject *obj + __Pyx_TypeInfo *typeinfo + + ctypedef struct {{memviewslice_name}}: + __pyx_memoryview *memview + char *data + Py_ssize_t shape[{{max_dims}}] + Py_ssize_t strides[{{max_dims}}] + Py_ssize_t suboffsets[{{max_dims}}] + + void __PYX_INC_MEMVIEW({{memviewslice_name}} *memslice, int have_gil) + void __PYX_XDEC_MEMVIEW({{memviewslice_name}} *memslice, int have_gil) + + ctypedef struct __pyx_buffer "Py_buffer": + PyObject *obj + + PyObject *Py_None + + cdef enum: + PyBUF_C_CONTIGUOUS, + PyBUF_F_CONTIGUOUS, + PyBUF_ANY_CONTIGUOUS + PyBUF_FORMAT + PyBUF_WRITABLE + PyBUF_STRIDES + PyBUF_INDIRECT + PyBUF_ND + PyBUF_RECORDS + PyBUF_RECORDS_RO + + ctypedef struct __Pyx_TypeInfo: + pass + + cdef object capsule "__pyx_capsule_create" (void *p, char *sig) + cdef int __pyx_array_getbuffer(PyObject *obj, Py_buffer view, int flags) + cdef int __pyx_memoryview_getbuffer(PyObject *obj, Py_buffer view, int flags) + +cdef extern from *: + ctypedef int __pyx_atomic_int + {{memviewslice_name}} slice_copy_contig "__pyx_memoryview_copy_new_contig"( + __Pyx_memviewslice *from_mvs, + char *mode, int ndim, + size_t sizeof_dtype, int contig_flag, + bint dtype_is_object) nogil except * + bint slice_is_contig "__pyx_memviewslice_is_contig" ( + {{memviewslice_name}} mvs, char order, int ndim) nogil + bint slices_overlap "__pyx_slices_overlap" ({{memviewslice_name}} *slice1, + {{memviewslice_name}} *slice2, + int ndim, size_t itemsize) nogil + + +cdef extern from "<stdlib.h>": + void *malloc(size_t) nogil + void free(void *) nogil + void *memcpy(void *dest, void *src, size_t n) nogil + + + + +# +### cython.array class +# + +@cname("__pyx_array") +cdef class array: + + cdef: + char *data + Py_ssize_t len + char *format + int ndim + Py_ssize_t *_shape + Py_ssize_t *_strides + Py_ssize_t itemsize + unicode mode # FIXME: this should have been a simple 'char' + bytes _format + void (*callback_free_data)(void *data) + # cdef object _memview + cdef bint free_data + cdef bint dtype_is_object + + def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, + mode="c", bint allocate_buffer=True): + + cdef int idx + cdef Py_ssize_t i, dim + cdef PyObject **p + + self.ndim = <int> len(shape) + self.itemsize = itemsize + + if not self.ndim: + raise ValueError("Empty shape tuple for cython.array") + + if itemsize <= 0: + raise ValueError("itemsize <= 0 for cython.array") + + if not isinstance(format, bytes): + format = format.encode('ASCII') + self._format = format # keep a reference to the byte string + self.format = self._format + + # use single malloc() for both shape and strides + self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) + self._strides = self._shape + self.ndim + + if not self._shape: + raise MemoryError("unable to allocate shape and strides.") + + # cdef Py_ssize_t dim, stride + for idx, dim in enumerate(shape): + if dim <= 0: + raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + self._shape[idx] = dim + + cdef char order + if mode == 'fortran': + order = b'F' + self.mode = u'fortran' + elif mode == 'c': + order = b'C' + self.mode = u'c' + else: + raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) + + self.len = fill_contig_strides_array(self._shape, self._strides, + itemsize, self.ndim, order) + + self.free_data = allocate_buffer + self.dtype_is_object = format == b'O' + if allocate_buffer: + # use malloc() for backwards compatibility + # in case external code wants to change the data pointer + self.data = <char *>malloc(self.len) + if not self.data: + raise MemoryError("unable to allocate array data.") + + if self.dtype_is_object: + p = <PyObject **> self.data + for i in range(self.len / itemsize): + p[i] = Py_None + Py_INCREF(Py_None) + + @cname('getbuffer') + def __getbuffer__(self, Py_buffer *info, int flags): + cdef int bufmode = -1 + if self.mode == u"c": + bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + elif self.mode == u"fortran": + bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + if not (flags & bufmode): + raise ValueError("Can only create a buffer that is contiguous in memory.") + info.buf = self.data + info.len = self.len + info.ndim = self.ndim + info.shape = self._shape + info.strides = self._strides + info.suboffsets = NULL + info.itemsize = self.itemsize + info.readonly = 0 + + if flags & PyBUF_FORMAT: + info.format = self.format + else: + info.format = NULL + + info.obj = self + + __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + + def __dealloc__(array self): + if self.callback_free_data != NULL: + self.callback_free_data(self.data) + elif self.free_data: + if self.dtype_is_object: + refcount_objects_in_slice(self.data, self._shape, + self._strides, self.ndim, False) + free(self.data) + PyObject_Free(self._shape) + + @property + def memview(self): + return self.get_memview() + + @cname('get_memview') + cdef get_memview(self): + flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + return memoryview(self, flags, self.dtype_is_object) + + def __len__(self): + return self._shape[0] + + def __getattr__(self, attr): + return getattr(self.memview, attr) + + def __getitem__(self, item): + return self.memview[item] + + def __setitem__(self, item, value): + self.memview[item] = value + + +@cname("__pyx_array_new") +cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, + char *mode, char *buf): + cdef array result + + if buf == NULL: + result = array(shape, itemsize, format, mode.decode('ASCII')) + else: + result = array(shape, itemsize, format, mode.decode('ASCII'), + allocate_buffer=False) + result.data = buf + + return result + + +# +### Memoryview constants and cython.view.memoryview class +# + +# Disable generic_contiguous, as it makes trouble verifying contiguity: +# - 'contiguous' or '::1' means the dimension is contiguous with dtype +# - 'indirect_contiguous' means a contiguous list of pointers +# - dtype contiguous must be contiguous in the first or last dimension +# from the start, or from the dimension following the last indirect dimension +# +# e.g. +# int[::indirect_contiguous, ::contiguous, :] +# +# is valid (list of pointers to 2d fortran-contiguous array), but +# +# int[::generic_contiguous, ::contiguous, :] +# +# would mean you'd have assert dimension 0 to be indirect (and pointer contiguous) at runtime. +# So it doesn't bring any performance benefit, and it's only confusing. + +@cname('__pyx_MemviewEnum') +cdef class Enum(object): + cdef object name + def __init__(self, name): + self.name = name + def __repr__(self): + return self.name + +cdef generic = Enum("<strided and direct or indirect>") +cdef strided = Enum("<strided and direct>") # default +cdef indirect = Enum("<strided and indirect>") +# Disable generic_contiguous, as it is a troublemaker +#cdef generic_contiguous = Enum("<contiguous and direct or indirect>") +cdef contiguous = Enum("<contiguous and direct>") +cdef indirect_contiguous = Enum("<contiguous and indirect>") + +# 'follow' is implied when the first or last axis is ::1 + + +@cname('__pyx_align_pointer') +cdef void *align_pointer(void *memory, size_t alignment) nogil: + "Align pointer memory on a given boundary" + cdef Py_intptr_t aligned_p = <Py_intptr_t> memory + cdef size_t offset + + with cython.cdivision(True): + offset = aligned_p % alignment + + if offset > 0: + aligned_p += alignment - offset + + return <void *> aligned_p + + +# pre-allocate thread locks for reuse +## note that this could be implemented in a more beautiful way in "normal" Cython, +## but this code gets merged into the user module and not everything works there. +DEF THREAD_LOCKS_PREALLOCATED = 8 +cdef int __pyx_memoryview_thread_locks_used = 0 +cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ + PyThread_allocate_lock(), + PyThread_allocate_lock(), + PyThread_allocate_lock(), + PyThread_allocate_lock(), + PyThread_allocate_lock(), + PyThread_allocate_lock(), + PyThread_allocate_lock(), + PyThread_allocate_lock(), +] + + +@cname('__pyx_memoryview') +cdef class memoryview(object): + + cdef object obj + cdef object _size + cdef object _array_interface + cdef PyThread_type_lock lock + # the following array will contain a single __pyx_atomic int with + # suitable alignment + cdef __pyx_atomic_int acquisition_count[2] + cdef __pyx_atomic_int *acquisition_count_aligned_p + cdef Py_buffer view + cdef int flags + cdef bint dtype_is_object + cdef __Pyx_TypeInfo *typeinfo + + def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): + self.obj = obj + self.flags = flags + if type(self) is memoryview or obj is not None: + __Pyx_GetBuffer(obj, &self.view, flags) + if <PyObject *> self.view.obj == NULL: + (<__pyx_buffer *> &self.view).obj = Py_None + Py_INCREF(Py_None) + + if not __PYX_CYTHON_ATOMICS_ENABLED(): + global __pyx_memoryview_thread_locks_used + if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: + self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + __pyx_memoryview_thread_locks_used += 1 + if self.lock is NULL: + self.lock = PyThread_allocate_lock() + if self.lock is NULL: + raise MemoryError + + if flags & PyBUF_FORMAT: + self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + else: + self.dtype_is_object = dtype_is_object + + self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( + <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int)) + self.typeinfo = NULL + + def __dealloc__(memoryview self): + if self.obj is not None: + __Pyx_ReleaseBuffer(&self.view) + elif (<__pyx_buffer *> &self.view).obj == Py_None: + # Undo the incref in __cinit__() above. + (<__pyx_buffer *> &self.view).obj = NULL + Py_DECREF(Py_None) + + cdef int i + global __pyx_memoryview_thread_locks_used + if self.lock != NULL: + for i in range(__pyx_memoryview_thread_locks_used): + if __pyx_memoryview_thread_locks[i] is self.lock: + __pyx_memoryview_thread_locks_used -= 1 + if i != __pyx_memoryview_thread_locks_used: + __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + break + else: + PyThread_free_lock(self.lock) + + cdef char *get_item_pointer(memoryview self, object index) except NULL: + cdef Py_ssize_t dim + cdef char *itemp = <char *> self.view.buf + + for dim, idx in enumerate(index): + itemp = pybuffer_index(&self.view, itemp, idx, dim) + + return itemp + + #@cname('__pyx_memoryview_getitem') + def __getitem__(memoryview self, object index): + if index is Ellipsis: + return self + + have_slices, indices = _unellipsify(index, self.view.ndim) + + cdef char *itemp + if have_slices: + return memview_slice(self, indices) + else: + itemp = self.get_item_pointer(indices) + return self.convert_item_to_object(itemp) + + def __setitem__(memoryview self, object index, object value): + if self.view.readonly: + raise TypeError("Cannot assign to read-only memoryview") + + have_slices, index = _unellipsify(index, self.view.ndim) + + if have_slices: + obj = self.is_slice(value) + if obj: + self.setitem_slice_assignment(self[index], obj) + else: + self.setitem_slice_assign_scalar(self[index], value) + else: + self.setitem_indexed(index, value) + + cdef is_slice(self, obj): + if not isinstance(obj, memoryview): + try: + obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + self.dtype_is_object) + except TypeError: + return None + + return obj + + cdef setitem_slice_assignment(self, dst, src): + cdef {{memviewslice_name}} dst_slice + cdef {{memviewslice_name}} src_slice + + memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], + get_slice_from_memview(dst, &dst_slice)[0], + src.ndim, dst.ndim, self.dtype_is_object) + + cdef setitem_slice_assign_scalar(self, memoryview dst, value): + cdef int array[128] + cdef void *tmp = NULL + cdef void *item + + cdef {{memviewslice_name}} *dst_slice + cdef {{memviewslice_name}} tmp_slice + dst_slice = get_slice_from_memview(dst, &tmp_slice) + + if <size_t>self.view.itemsize > sizeof(array): + tmp = PyMem_Malloc(self.view.itemsize) + if tmp == NULL: + raise MemoryError + item = tmp + else: + item = <void *> array + + try: + if self.dtype_is_object: + (<PyObject **> item)[0] = <PyObject *> value + else: + self.assign_item_from_object(<char *> item, value) + + # It would be easy to support indirect dimensions, but it's easier + # to disallow :) + if self.view.suboffsets != NULL: + assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + item, self.dtype_is_object) + finally: + PyMem_Free(tmp) + + cdef setitem_indexed(self, index, value): + cdef char *itemp = self.get_item_pointer(index) + self.assign_item_from_object(itemp, value) + + cdef convert_item_to_object(self, char *itemp): + """Only used if instantiated manually by the user, or if Cython doesn't + know how to convert the type""" + import struct + cdef bytes bytesitem + # Do a manual and complete check here instead of this easy hack + bytesitem = itemp[:self.view.itemsize] + try: + result = struct.unpack(self.view.format, bytesitem) + except struct.error: + raise ValueError("Unable to convert item to object") + else: + if len(self.view.format) == 1: + return result[0] + return result + + cdef assign_item_from_object(self, char *itemp, object value): + """Only used if instantiated manually by the user, or if Cython doesn't + know how to convert the type""" + import struct + cdef char c + cdef bytes bytesvalue + cdef Py_ssize_t i + + if isinstance(value, tuple): + bytesvalue = struct.pack(self.view.format, *value) + else: + bytesvalue = struct.pack(self.view.format, value) + + for i, c in enumerate(bytesvalue): + itemp[i] = c + + @cname('getbuffer') + def __getbuffer__(self, Py_buffer *info, int flags): + if flags & PyBUF_WRITABLE and self.view.readonly: + raise ValueError("Cannot create writable memory view from read-only memoryview") + + if flags & PyBUF_ND: + info.shape = self.view.shape + else: + info.shape = NULL + + if flags & PyBUF_STRIDES: + info.strides = self.view.strides + else: + info.strides = NULL + + if flags & PyBUF_INDIRECT: + info.suboffsets = self.view.suboffsets + else: + info.suboffsets = NULL + + if flags & PyBUF_FORMAT: + info.format = self.view.format + else: + info.format = NULL + + info.buf = self.view.buf + info.ndim = self.view.ndim + info.itemsize = self.view.itemsize + info.len = self.view.len + info.readonly = self.view.readonly + info.obj = self + + __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") + + # Some properties that have the same semantics as in NumPy + @property + def T(self): + cdef _memoryviewslice result = memoryview_copy(self) + transpose_memslice(&result.from_slice) + return result + + @property + def base(self): + return self.obj + + @property + def shape(self): + return tuple([length for length in self.view.shape[:self.view.ndim]]) + + @property + def strides(self): + if self.view.strides == NULL: + # Note: we always ask for strides, so if this is not set it's a bug + raise ValueError("Buffer view does not expose strides") + + return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + + @property + def suboffsets(self): + if self.view.suboffsets == NULL: + return (-1,) * self.view.ndim + + return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + + @property + def ndim(self): + return self.view.ndim + + @property + def itemsize(self): + return self.view.itemsize + + @property + def nbytes(self): + return self.size * self.view.itemsize + + @property + def size(self): + if self._size is None: + result = 1 + + for length in self.view.shape[:self.view.ndim]: + result *= length + + self._size = result + + return self._size + + def __len__(self): + if self.view.ndim >= 1: + return self.view.shape[0] + + return 0 + + def __repr__(self): + return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__, + id(self)) + + def __str__(self): + return "<MemoryView of %r object>" % (self.base.__class__.__name__,) + + # Support the same attributes as memoryview slices + def is_c_contig(self): + cdef {{memviewslice_name}} *mslice + cdef {{memviewslice_name}} tmp + mslice = get_slice_from_memview(self, &tmp) + return slice_is_contig(mslice[0], 'C', self.view.ndim) + + def is_f_contig(self): + cdef {{memviewslice_name}} *mslice + cdef {{memviewslice_name}} tmp + mslice = get_slice_from_memview(self, &tmp) + return slice_is_contig(mslice[0], 'F', self.view.ndim) + + def copy(self): + cdef {{memviewslice_name}} mslice + cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + + slice_copy(self, &mslice) + mslice = slice_copy_contig(&mslice, "c", self.view.ndim, + self.view.itemsize, + flags|PyBUF_C_CONTIGUOUS, + self.dtype_is_object) + + return memoryview_copy_from_slice(self, &mslice) + + def copy_fortran(self): + cdef {{memviewslice_name}} src, dst + cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + + slice_copy(self, &src) + dst = slice_copy_contig(&src, "fortran", self.view.ndim, + self.view.itemsize, + flags|PyBUF_F_CONTIGUOUS, + self.dtype_is_object) + + return memoryview_copy_from_slice(self, &dst) + + +@cname('__pyx_memoryview_new') +cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): + cdef memoryview result = memoryview(o, flags, dtype_is_object) + result.typeinfo = typeinfo + return result + +@cname('__pyx_memoryview_check') +cdef inline bint memoryview_check(object o): + return isinstance(o, memoryview) + +cdef tuple _unellipsify(object index, int ndim): + """ + Replace all ellipses with full slices and fill incomplete indices with + full slices. + """ + if not isinstance(index, tuple): + tup = (index,) + else: + tup = index + + result = [] + have_slices = False + seen_ellipsis = False + for idx, item in enumerate(tup): + if item is Ellipsis: + if not seen_ellipsis: + result.extend([slice(None)] * (ndim - len(tup) + 1)) + seen_ellipsis = True + else: + result.append(slice(None)) + have_slices = True + else: + if not isinstance(item, slice) and not PyIndex_Check(item): + raise TypeError("Cannot index with type '%s'" % type(item)) + + have_slices = have_slices or isinstance(item, slice) + result.append(item) + + nslices = ndim - len(result) + if nslices: + result.extend([slice(None)] * nslices) + + return have_slices or nslices, tuple(result) + +cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + for suboffset in suboffsets[:ndim]: + if suboffset >= 0: + raise ValueError("Indirect dimensions not supported") + +# +### Slicing a memoryview +# + +@cname('__pyx_memview_slice') +cdef memoryview memview_slice(memoryview memview, object indices): + cdef int new_ndim = 0, suboffset_dim = -1, dim + cdef bint negative_step + cdef {{memviewslice_name}} src, dst + cdef {{memviewslice_name}} *p_src + + # dst is copied by value in memoryview_fromslice -- initialize it + # src is never copied + memset(&dst, 0, sizeof(dst)) + + cdef _memoryviewslice memviewsliceobj + + assert memview.view.ndim > 0 + + if isinstance(memview, _memoryviewslice): + memviewsliceobj = memview + p_src = &memviewsliceobj.from_slice + else: + slice_copy(memview, &src) + p_src = &src + + # Note: don't use variable src at this point + # SubNote: we should be able to declare variables in blocks... + + # memoryview_fromslice() will inc our dst slice + dst.memview = p_src.memview + dst.data = p_src.data + + # Put everything in temps to avoid this bloody warning: + # "Argument evaluation order in C function call is undefined and + # may not be as expected" + cdef {{memviewslice_name}} *p_dst = &dst + cdef int *p_suboffset_dim = &suboffset_dim + cdef Py_ssize_t start, stop, step + cdef bint have_start, have_stop, have_step + + for dim, index in enumerate(indices): + if PyIndex_Check(index): + slice_memviewslice( + p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + dim, new_ndim, p_suboffset_dim, + index, 0, 0, # start, stop, step + 0, 0, 0, # have_{start,stop,step} + False) + elif index is None: + p_dst.shape[new_ndim] = 1 + p_dst.strides[new_ndim] = 0 + p_dst.suboffsets[new_ndim] = -1 + new_ndim += 1 + else: + start = index.start or 0 + stop = index.stop or 0 + step = index.step or 0 + + have_start = index.start is not None + have_stop = index.stop is not None + have_step = index.step is not None + + slice_memviewslice( + p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + dim, new_ndim, p_suboffset_dim, + start, stop, step, + have_start, have_stop, have_step, + True) + new_ndim += 1 + + if isinstance(memview, _memoryviewslice): + return memoryview_fromslice(dst, new_ndim, + memviewsliceobj.to_object_func, + memviewsliceobj.to_dtype_func, + memview.dtype_is_object) + else: + return memoryview_fromslice(dst, new_ndim, NULL, NULL, + memview.dtype_is_object) + + +# +### Slicing in a single dimension of a memoryviewslice +# + +cdef extern from "<stdlib.h>": + void abort() nogil + void printf(char *s, ...) nogil + +cdef extern from "<stdio.h>": + ctypedef struct FILE + FILE *stderr + int fputs(char *s, FILE *stream) + +cdef extern from "pystate.h": + void PyThreadState_Get() nogil + + # These are not actually nogil, but we check for the GIL before calling them + void PyErr_SetString(PyObject *type, char *msg) nogil + PyObject *PyErr_Format(PyObject *exc, char *msg, ...) nogil + +@cname('__pyx_memoryview_slice_memviewslice') +cdef int slice_memviewslice( + {{memviewslice_name}} *dst, + Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, + int dim, int new_ndim, int *suboffset_dim, + Py_ssize_t start, Py_ssize_t stop, Py_ssize_t step, + int have_start, int have_stop, int have_step, + bint is_slice) nogil except -1: + """ + Create a new slice dst given slice src. + + dim - the current src dimension (indexing will make dimensions + disappear) + new_dim - the new dst dimension + suboffset_dim - pointer to a single int initialized to -1 to keep track of + where slicing offsets should be added + """ + + cdef Py_ssize_t new_shape + cdef bint negative_step + + if not is_slice: + # index is a normal integer-like index + if start < 0: + start += shape + if not 0 <= start < shape: + _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + else: + # index is a slice + negative_step = have_step != 0 and step < 0 + + if have_step and step == 0: + _err_dim(ValueError, "Step may not be zero (axis %d)", dim) + + # check our bounds and set defaults + if have_start: + if start < 0: + start += shape + if start < 0: + start = 0 + elif start >= shape: + if negative_step: + start = shape - 1 + else: + start = shape + else: + if negative_step: + start = shape - 1 + else: + start = 0 + + if have_stop: + if stop < 0: + stop += shape + if stop < 0: + stop = 0 + elif stop > shape: + stop = shape + else: + if negative_step: + stop = -1 + else: + stop = shape + + if not have_step: + step = 1 + + # len = ceil( (stop - start) / step ) + with cython.cdivision(True): + new_shape = (stop - start) // step + + if (stop - start) - step * new_shape: + new_shape += 1 + + if new_shape < 0: + new_shape = 0 + + # shape/strides/suboffsets + dst.strides[new_ndim] = stride * step + dst.shape[new_ndim] = new_shape + dst.suboffsets[new_ndim] = suboffset + + # Add the slicing or idexing offsets to the right suboffset or base data * + if suboffset_dim[0] < 0: + dst.data += start * stride + else: + dst.suboffsets[suboffset_dim[0]] += start * stride + + if suboffset >= 0: + if not is_slice: + if new_ndim == 0: + dst.data = (<char **> dst.data)[0] + suboffset + else: + _err_dim(IndexError, "All dimensions preceding dimension %d " + "must be indexed and not sliced", dim) + else: + suboffset_dim[0] = new_ndim + + return 0 + +# +### Index a memoryview +# +@cname('__pyx_pybuffer_index') +cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, + Py_ssize_t dim) except NULL: + cdef Py_ssize_t shape, stride, suboffset = -1 + cdef Py_ssize_t itemsize = view.itemsize + cdef char *resultp + + if view.ndim == 0: + shape = view.len / itemsize + stride = itemsize + else: + shape = view.shape[dim] + stride = view.strides[dim] + if view.suboffsets != NULL: + suboffset = view.suboffsets[dim] + + if index < 0: + index += view.shape[dim] + if index < 0: + raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + + if index >= shape: + raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + + resultp = bufp + index * stride + if suboffset >= 0: + resultp = (<char **> resultp)[0] + suboffset + + return resultp + +# +### Transposing a memoryviewslice +# +@cname('__pyx_memslice_transpose') +cdef int transpose_memslice({{memviewslice_name}} *memslice) nogil except 0: + cdef int ndim = memslice.memview.view.ndim + + cdef Py_ssize_t *shape = memslice.shape + cdef Py_ssize_t *strides = memslice.strides + + # reverse strides and shape + cdef int i, j + for i in range(ndim / 2): + j = ndim - 1 - i + strides[i], strides[j] = strides[j], strides[i] + shape[i], shape[j] = shape[j], shape[i] + + if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: + _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + + return 1 + +# +### Creating new memoryview objects from slices and memoryviews +# +@cname('__pyx_memoryviewslice') +cdef class _memoryviewslice(memoryview): + "Internal class for passing memoryview slices to Python" + + # We need this to keep our shape/strides/suboffset pointers valid + cdef {{memviewslice_name}} from_slice + # We need this only to print it's class' name + cdef object from_object + + cdef object (*to_object_func)(char *) + cdef int (*to_dtype_func)(char *, object) except 0 + + def __dealloc__(self): + __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + + cdef convert_item_to_object(self, char *itemp): + if self.to_object_func != NULL: + return self.to_object_func(itemp) + else: + return memoryview.convert_item_to_object(self, itemp) + + cdef assign_item_from_object(self, char *itemp, object value): + if self.to_dtype_func != NULL: + self.to_dtype_func(itemp, value) + else: + memoryview.assign_item_from_object(self, itemp, value) + + @property + def base(self): + return self.from_object + + __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") + + +@cname('__pyx_memoryview_fromslice') +cdef memoryview_fromslice({{memviewslice_name}} memviewslice, + int ndim, + object (*to_object_func)(char *), + int (*to_dtype_func)(char *, object) except 0, + bint dtype_is_object): + + cdef _memoryviewslice result + + if <PyObject *> memviewslice.memview == Py_None: + return None + + # assert 0 < ndim <= memviewslice.memview.view.ndim, ( + # ndim, memviewslice.memview.view.ndim) + + result = _memoryviewslice(None, 0, dtype_is_object) + + result.from_slice = memviewslice + __PYX_INC_MEMVIEW(&memviewslice, 1) + + result.from_object = (<memoryview> memviewslice.memview).base + result.typeinfo = memviewslice.memview.typeinfo + + result.view = memviewslice.memview.view + result.view.buf = <void *> memviewslice.data + result.view.ndim = ndim + (<__pyx_buffer *> &result.view).obj = Py_None + Py_INCREF(Py_None) + + if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE: + result.flags = PyBUF_RECORDS + else: + result.flags = PyBUF_RECORDS_RO + + result.view.shape = <Py_ssize_t *> result.from_slice.shape + result.view.strides = <Py_ssize_t *> result.from_slice.strides + + # only set suboffsets if actually used, otherwise set to NULL to improve compatibility + result.view.suboffsets = NULL + for suboffset in result.from_slice.suboffsets[:ndim]: + if suboffset >= 0: + result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets + break + + result.view.len = result.view.itemsize + for length in result.view.shape[:ndim]: + result.view.len *= length + + result.to_object_func = to_object_func + result.to_dtype_func = to_dtype_func + + return result + +@cname('__pyx_memoryview_get_slice_from_memoryview') +cdef {{memviewslice_name}} *get_slice_from_memview(memoryview memview, + {{memviewslice_name}} *mslice) except NULL: + cdef _memoryviewslice obj + if isinstance(memview, _memoryviewslice): + obj = memview + return &obj.from_slice + else: + slice_copy(memview, mslice) + return mslice + +@cname('__pyx_memoryview_slice_copy') +cdef void slice_copy(memoryview memview, {{memviewslice_name}} *dst): + cdef int dim + cdef (Py_ssize_t*) shape, strides, suboffsets + + shape = memview.view.shape + strides = memview.view.strides + suboffsets = memview.view.suboffsets + + dst.memview = <__pyx_memoryview *> memview + dst.data = <char *> memview.view.buf + + for dim in range(memview.view.ndim): + dst.shape[dim] = shape[dim] + dst.strides[dim] = strides[dim] + dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 + +@cname('__pyx_memoryview_copy_object') +cdef memoryview_copy(memoryview memview): + "Create a new memoryview object" + cdef {{memviewslice_name}} memviewslice + slice_copy(memview, &memviewslice) + return memoryview_copy_from_slice(memview, &memviewslice) + +@cname('__pyx_memoryview_copy_object_from_slice') +cdef memoryview_copy_from_slice(memoryview memview, {{memviewslice_name}} *memviewslice): + """ + Create a new memoryview object from a given memoryview object and slice. + """ + cdef object (*to_object_func)(char *) + cdef int (*to_dtype_func)(char *, object) except 0 + + if isinstance(memview, _memoryviewslice): + to_object_func = (<_memoryviewslice> memview).to_object_func + to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + else: + to_object_func = NULL + to_dtype_func = NULL + + return memoryview_fromslice(memviewslice[0], memview.view.ndim, + to_object_func, to_dtype_func, + memview.dtype_is_object) + + +# +### Copy the contents of a memoryview slices +# +cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + if arg < 0: + return -arg + else: + return arg + +@cname('__pyx_get_best_slice_order') +cdef char get_best_order({{memviewslice_name}} *mslice, int ndim) nogil: + """ + Figure out the best memory access order for a given slice. + """ + cdef int i + cdef Py_ssize_t c_stride = 0 + cdef Py_ssize_t f_stride = 0 + + for i in range(ndim - 1, -1, -1): + if mslice.shape[i] > 1: + c_stride = mslice.strides[i] + break + + for i in range(ndim): + if mslice.shape[i] > 1: + f_stride = mslice.strides[i] + break + + if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): + return 'C' + else: + return 'F' + +@cython.cdivision(True) +cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, + char *dst_data, Py_ssize_t *dst_strides, + Py_ssize_t *src_shape, Py_ssize_t *dst_shape, + int ndim, size_t itemsize) nogil: + # Note: src_extent is 1 if we're broadcasting + # dst_extent always >= src_extent as we don't do reductions + cdef Py_ssize_t i + cdef Py_ssize_t src_extent = src_shape[0] + cdef Py_ssize_t dst_extent = dst_shape[0] + cdef Py_ssize_t src_stride = src_strides[0] + cdef Py_ssize_t dst_stride = dst_strides[0] + + if ndim == 1: + if (src_stride > 0 and dst_stride > 0 and + <size_t> src_stride == itemsize == <size_t> dst_stride): + memcpy(dst_data, src_data, itemsize * dst_extent) + else: + for i in range(dst_extent): + memcpy(dst_data, src_data, itemsize) + src_data += src_stride + dst_data += dst_stride + else: + for i in range(dst_extent): + _copy_strided_to_strided(src_data, src_strides + 1, + dst_data, dst_strides + 1, + src_shape + 1, dst_shape + 1, + ndim - 1, itemsize) + src_data += src_stride + dst_data += dst_stride + +cdef void copy_strided_to_strided({{memviewslice_name}} *src, + {{memviewslice_name}} *dst, + int ndim, size_t itemsize) nogil: + _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, + src.shape, dst.shape, ndim, itemsize) + +@cname('__pyx_memoryview_slice_get_size') +cdef Py_ssize_t slice_get_size({{memviewslice_name}} *src, int ndim) nogil: + "Return the size of the memory occupied by the slice in number of bytes" + cdef Py_ssize_t shape, size = src.memview.view.itemsize + + for shape in src.shape[:ndim]: + size *= shape + + return size + +@cname('__pyx_fill_contig_strides_array') +cdef Py_ssize_t fill_contig_strides_array( + Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, + int ndim, char order) nogil: + """ + Fill the strides array for a slice with C or F contiguous strides. + This is like PyBuffer_FillContiguousStrides, but compatible with py < 2.6 + """ + cdef int idx + + if order == 'F': + for idx in range(ndim): + strides[idx] = stride + stride *= shape[idx] + else: + for idx in range(ndim - 1, -1, -1): + strides[idx] = stride + stride *= shape[idx] + + return stride + +@cname('__pyx_memoryview_copy_data_to_temp') +cdef void *copy_data_to_temp({{memviewslice_name}} *src, + {{memviewslice_name}} *tmpslice, + char order, + int ndim) nogil except NULL: + """ + Copy a direct slice to temporary contiguous memory. The caller should free + the result when done. + """ + cdef int i + cdef void *result + + cdef size_t itemsize = src.memview.view.itemsize + cdef size_t size = slice_get_size(src, ndim) + + result = malloc(size) + if not result: + _err(MemoryError, NULL) + + # tmpslice[0] = src + tmpslice.data = <char *> result + tmpslice.memview = src.memview + for i in range(ndim): + tmpslice.shape[i] = src.shape[i] + tmpslice.suboffsets[i] = -1 + + fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, + ndim, order) + + # We need to broadcast strides again + for i in range(ndim): + if tmpslice.shape[i] == 1: + tmpslice.strides[i] = 0 + + if slice_is_contig(src[0], order, ndim): + memcpy(result, src.data, size) + else: + copy_strided_to_strided(src, tmpslice, ndim, itemsize) + + return result + +# Use 'with gil' functions and avoid 'with gil' blocks, as the code within the blocks +# has temporaries that need the GIL to clean up +@cname('__pyx_memoryview_err_extents') +cdef int _err_extents(int i, Py_ssize_t extent1, + Py_ssize_t extent2) except -1 with gil: + raise ValueError("got differing extents in dimension %d (got %d and %d)" % + (i, extent1, extent2)) + +@cname('__pyx_memoryview_err_dim') +cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: + raise error(msg.decode('ascii') % dim) + +@cname('__pyx_memoryview_err') +cdef int _err(object error, char *msg) except -1 with gil: + if msg != NULL: + raise error(msg.decode('ascii')) + else: + raise error + +@cname('__pyx_memoryview_copy_contents') +cdef int memoryview_copy_contents({{memviewslice_name}} src, + {{memviewslice_name}} dst, + int src_ndim, int dst_ndim, + bint dtype_is_object) nogil except -1: + """ + Copy memory from slice src to slice dst. + Check for overlapping memory and verify the shapes. + """ + cdef void *tmpdata = NULL + cdef size_t itemsize = src.memview.view.itemsize + cdef int i + cdef char order = get_best_order(&src, src_ndim) + cdef bint broadcasting = False + cdef bint direct_copy = False + cdef {{memviewslice_name}} tmp + + if src_ndim < dst_ndim: + broadcast_leading(&src, src_ndim, dst_ndim) + elif dst_ndim < src_ndim: + broadcast_leading(&dst, dst_ndim, src_ndim) + + cdef int ndim = max(src_ndim, dst_ndim) + + for i in range(ndim): + if src.shape[i] != dst.shape[i]: + if src.shape[i] == 1: + broadcasting = True + src.strides[i] = 0 + else: + _err_extents(i, dst.shape[i], src.shape[i]) + + if src.suboffsets[i] >= 0: + _err_dim(ValueError, "Dimension %d is not direct", i) + + if slices_overlap(&src, &dst, ndim, itemsize): + # slices overlap, copy to temp, copy temp to dst + if not slice_is_contig(src, order, ndim): + order = get_best_order(&dst, ndim) + + tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) + src = tmp + + if not broadcasting: + # See if both slices have equal contiguity, in that case perform a + # direct copy. This only works when we are not broadcasting. + if slice_is_contig(src, 'C', ndim): + direct_copy = slice_is_contig(dst, 'C', ndim) + elif slice_is_contig(src, 'F', ndim): + direct_copy = slice_is_contig(dst, 'F', ndim) + + if direct_copy: + # Contiguous slices with same order + refcount_copying(&dst, dtype_is_object, ndim, False) + memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + refcount_copying(&dst, dtype_is_object, ndim, True) + free(tmpdata) + return 0 + + if order == 'F' == get_best_order(&dst, ndim): + # see if both slices have Fortran order, transpose them to match our + # C-style indexing order + transpose_memslice(&src) + transpose_memslice(&dst) + + refcount_copying(&dst, dtype_is_object, ndim, False) + copy_strided_to_strided(&src, &dst, ndim, itemsize) + refcount_copying(&dst, dtype_is_object, ndim, True) + + free(tmpdata) + return 0 + +@cname('__pyx_memoryview_broadcast_leading') +cdef void broadcast_leading({{memviewslice_name}} *mslice, + int ndim, + int ndim_other) nogil: + cdef int i + cdef int offset = ndim_other - ndim + + for i in range(ndim - 1, -1, -1): + mslice.shape[i + offset] = mslice.shape[i] + mslice.strides[i + offset] = mslice.strides[i] + mslice.suboffsets[i + offset] = mslice.suboffsets[i] + + for i in range(offset): + mslice.shape[i] = 1 + mslice.strides[i] = mslice.strides[0] + mslice.suboffsets[i] = -1 + +# +### Take care of refcounting the objects in slices. Do this separately from any copying, +### to minimize acquiring the GIL +# + +@cname('__pyx_memoryview_refcount_copying') +cdef void refcount_copying({{memviewslice_name}} *dst, bint dtype_is_object, + int ndim, bint inc) nogil: + # incref or decref the objects in the destination slice if the dtype is + # object + if dtype_is_object: + refcount_objects_in_slice_with_gil(dst.data, dst.shape, + dst.strides, ndim, inc) + +@cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') +cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, + Py_ssize_t *strides, int ndim, + bint inc) with gil: + refcount_objects_in_slice(data, shape, strides, ndim, inc) + +@cname('__pyx_memoryview_refcount_objects_in_slice') +cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, + Py_ssize_t *strides, int ndim, bint inc): + cdef Py_ssize_t i + + for i in range(shape[0]): + if ndim == 1: + if inc: + Py_INCREF((<PyObject **> data)[0]) + else: + Py_DECREF((<PyObject **> data)[0]) + else: + refcount_objects_in_slice(data, shape + 1, strides + 1, + ndim - 1, inc) + + data += strides[0] + +# +### Scalar to slice assignment +# +@cname('__pyx_memoryview_slice_assign_scalar') +cdef void slice_assign_scalar({{memviewslice_name}} *dst, int ndim, + size_t itemsize, void *item, + bint dtype_is_object) nogil: + refcount_copying(dst, dtype_is_object, ndim, False) + _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, + itemsize, item) + refcount_copying(dst, dtype_is_object, ndim, True) + + +@cname('__pyx_memoryview__slice_assign_scalar') +cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, + Py_ssize_t *strides, int ndim, + size_t itemsize, void *item) nogil: + cdef Py_ssize_t i + cdef Py_ssize_t stride = strides[0] + cdef Py_ssize_t extent = shape[0] + + if ndim == 1: + for i in range(extent): + memcpy(data, item, itemsize) + data += stride + else: + for i in range(extent): + _slice_assign_scalar(data, shape + 1, strides + 1, + ndim - 1, itemsize, item) + data += stride + + +############### BufferFormatFromTypeInfo ############### +cdef extern from *: + ctypedef struct __Pyx_StructField + + cdef enum: + __PYX_BUF_FLAGS_PACKED_STRUCT + __PYX_BUF_FLAGS_INTEGER_COMPLEX + + ctypedef struct __Pyx_TypeInfo: + char* name + __Pyx_StructField* fields + size_t size + size_t arraysize[8] + int ndim + char typegroup + char is_unsigned + int flags + + ctypedef struct __Pyx_StructField: + __Pyx_TypeInfo* type + char* name + size_t offset + + ctypedef struct __Pyx_BufFmt_StackElem: + __Pyx_StructField* field + size_t parent_offset + + #ctypedef struct __Pyx_BufFmt_Context: + # __Pyx_StructField root + __Pyx_BufFmt_StackElem* head + + struct __pyx_typeinfo_string: + char string[3] + + __pyx_typeinfo_string __Pyx_TypeInfoToFormat(__Pyx_TypeInfo *) + + +@cname('__pyx_format_from_typeinfo') +cdef bytes format_from_typeinfo(__Pyx_TypeInfo *type): + cdef __Pyx_StructField *field + cdef __pyx_typeinfo_string fmt + cdef bytes part, result + + if type.typegroup == 'S': + assert type.fields != NULL + assert type.fields.type != NULL + + if type.flags & __PYX_BUF_FLAGS_PACKED_STRUCT: + alignment = b'^' + else: + alignment = b'' + + parts = [b"T{"] + field = type.fields + + while field.type: + part = format_from_typeinfo(field.type) + parts.append(part + b':' + field.name + b':') + field += 1 + + result = alignment.join(parts) + b'}' + else: + fmt = __Pyx_TypeInfoToFormat(type) + if type.arraysize[0]: + extents = [unicode(type.arraysize[i]) for i in range(type.ndim)] + result = (u"(%s)" % u','.join(extents)).encode('ascii') + fmt.string + else: + result = fmt.string + + return result diff --git a/contrib/tools/cython/Cython/Utility/MemoryView_C.c b/contrib/tools/cython/Cython/Utility/MemoryView_C.c new file mode 100644 index 00000000000..1b78b2a4e3a --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/MemoryView_C.c @@ -0,0 +1,941 @@ +////////// MemviewSliceStruct.proto ////////// +//@proto_block: utility_code_proto_before_types + +/* memoryview slice struct */ +struct {{memview_struct_name}}; + +typedef struct { + struct {{memview_struct_name}} *memview; + char *data; + Py_ssize_t shape[{{max_dims}}]; + Py_ssize_t strides[{{max_dims}}]; + Py_ssize_t suboffsets[{{max_dims}}]; +} {{memviewslice_name}}; + +// used for "len(memviewslice)" +#define __Pyx_MemoryView_Len(m) (m.shape[0]) + + +/////////// Atomics.proto ///////////// +//@proto_block: utility_code_proto_before_types + +#include <pythread.h> + +#ifndef CYTHON_ATOMICS + #define CYTHON_ATOMICS 1 +#endif +// using CYTHON_ATOMICS as a cdef extern bint in the Cython memoryview code +// interacts badly with "import *". Therefore, define a helper function-like macro +#define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS + +#define __pyx_atomic_int_type int + +#if CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 && \ + (__GNUC_MINOR__ > 1 || \ + (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2)))) + /* gcc >= 4.1.2 */ + #define __pyx_atomic_incr_aligned(value) __sync_fetch_and_add(value, 1) + #define __pyx_atomic_decr_aligned(value) __sync_fetch_and_sub(value, 1) + + #ifdef __PYX_DEBUG_ATOMICS + #warning "Using GNU atomics" + #endif +#elif CYTHON_ATOMICS && defined(_MSC_VER) && CYTHON_COMPILING_IN_NOGIL + /* msvc */ + #include <intrin.h> + #undef __pyx_atomic_int_type + #define __pyx_atomic_int_type long + #pragma intrinsic (_InterlockedExchangeAdd) + #define __pyx_atomic_incr_aligned(value) _InterlockedExchangeAdd(value, 1) + #define __pyx_atomic_decr_aligned(value) _InterlockedExchangeAdd(value, -1) + + #ifdef __PYX_DEBUG_ATOMICS + #pragma message ("Using MSVC atomics") + #endif +#else + #undef CYTHON_ATOMICS + #define CYTHON_ATOMICS 0 + + #ifdef __PYX_DEBUG_ATOMICS + #warning "Not using atomics" + #endif +#endif + +typedef volatile __pyx_atomic_int_type __pyx_atomic_int; + +#if CYTHON_ATOMICS + #define __pyx_add_acquisition_count(memview) \ + __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview)) + #define __pyx_sub_acquisition_count(memview) \ + __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview)) +#else + #define __pyx_add_acquisition_count(memview) \ + __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) + #define __pyx_sub_acquisition_count(memview) \ + __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) +#endif + + +/////////////// ObjectToMemviewSlice.proto /////////////// + +static CYTHON_INLINE {{memviewslice_name}} {{funcname}}(PyObject *, int writable_flag); + + +////////// MemviewSliceInit.proto ////////// + +#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d + +#define __Pyx_MEMVIEW_DIRECT 1 +#define __Pyx_MEMVIEW_PTR 2 +#define __Pyx_MEMVIEW_FULL 4 +#define __Pyx_MEMVIEW_CONTIG 8 +#define __Pyx_MEMVIEW_STRIDED 16 +#define __Pyx_MEMVIEW_FOLLOW 32 + +#define __Pyx_IS_C_CONTIG 1 +#define __Pyx_IS_F_CONTIG 2 + +static int __Pyx_init_memviewslice( + struct __pyx_memoryview_obj *memview, + int ndim, + __Pyx_memviewslice *memviewslice, + int memview_is_new_reference); + +static CYTHON_INLINE int __pyx_add_acquisition_count_locked( + __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); +static CYTHON_INLINE int __pyx_sub_acquisition_count_locked( + __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); + +#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p) +#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview)) +#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__) +#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__) +static CYTHON_INLINE void __Pyx_INC_MEMVIEW({{memviewslice_name}} *, int, int); +static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW({{memviewslice_name}} *, int, int); + + +/////////////// MemviewSliceIndex.proto /////////////// + +static CYTHON_INLINE char *__pyx_memviewslice_index_full( + const char *bufp, Py_ssize_t idx, Py_ssize_t stride, Py_ssize_t suboffset); + + +/////////////// ObjectToMemviewSlice /////////////// +//@requires: MemviewSliceValidateAndInit + +static CYTHON_INLINE {{memviewslice_name}} {{funcname}}(PyObject *obj, int writable_flag) { + {{memviewslice_name}} result = {{memslice_init}}; + __Pyx_BufFmt_StackElem stack[{{struct_nesting_depth}}]; + int axes_specs[] = { {{axes_specs}} }; + int retcode; + + if (obj == Py_None) { + /* We don't bother to refcount None */ + result.memview = (struct __pyx_memoryview_obj *) Py_None; + return result; + } + + retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, {{c_or_f_flag}}, + {{buf_flag}} | writable_flag, {{ndim}}, + &{{dtype_typeinfo}}, stack, + &result, obj); + + if (unlikely(retcode == -1)) + goto __pyx_fail; + + return result; +__pyx_fail: + result.memview = NULL; + result.data = NULL; + return result; +} + + +/////////////// MemviewSliceValidateAndInit.proto /////////////// + +static int __Pyx_ValidateAndInit_memviewslice( + int *axes_specs, + int c_or_f_flag, + int buf_flags, + int ndim, + __Pyx_TypeInfo *dtype, + __Pyx_BufFmt_StackElem stack[], + __Pyx_memviewslice *memviewslice, + PyObject *original_obj); + +/////////////// MemviewSliceValidateAndInit /////////////// +//@requires: Buffer.c::TypeInfoCompare +//@requires: Buffer.c::BufferFormatStructs +//@requires: Buffer.c::BufferFormatCheck + +static int +__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec) +{ + if (buf->shape[dim] <= 1) + return 1; + + if (buf->strides) { + if (spec & __Pyx_MEMVIEW_CONTIG) { + if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) { + if (unlikely(buf->strides[dim] != sizeof(void *))) { + PyErr_Format(PyExc_ValueError, + "Buffer is not indirectly contiguous " + "in dimension %d.", dim); + goto fail; + } + } else if (unlikely(buf->strides[dim] != buf->itemsize)) { + PyErr_SetString(PyExc_ValueError, + "Buffer and memoryview are not contiguous " + "in the same dimension."); + goto fail; + } + } + + if (spec & __Pyx_MEMVIEW_FOLLOW) { + Py_ssize_t stride = buf->strides[dim]; + if (stride < 0) + stride = -stride; + if (unlikely(stride < buf->itemsize)) { + PyErr_SetString(PyExc_ValueError, + "Buffer and memoryview are not contiguous " + "in the same dimension."); + goto fail; + } + } + } else { + if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) { + PyErr_Format(PyExc_ValueError, + "C-contiguous buffer is not contiguous in " + "dimension %d", dim); + goto fail; + } else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) { + PyErr_Format(PyExc_ValueError, + "C-contiguous buffer is not indirect in " + "dimension %d", dim); + goto fail; + } else if (unlikely(buf->suboffsets)) { + PyErr_SetString(PyExc_ValueError, + "Buffer exposes suboffsets but no strides"); + goto fail; + } + } + + return 1; +fail: + return 0; +} + +static int +__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec) +{ + // Todo: without PyBUF_INDIRECT we may not have suboffset information, i.e., the + // ptr may not be set to NULL but may be uninitialized? + if (spec & __Pyx_MEMVIEW_DIRECT) { + if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) { + PyErr_Format(PyExc_ValueError, + "Buffer not compatible with direct access " + "in dimension %d.", dim); + goto fail; + } + } + + if (spec & __Pyx_MEMVIEW_PTR) { + if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) { + PyErr_Format(PyExc_ValueError, + "Buffer is not indirectly accessible " + "in dimension %d.", dim); + goto fail; + } + } + + return 1; +fail: + return 0; +} + +static int +__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag) +{ + int i; + + if (c_or_f_flag & __Pyx_IS_F_CONTIG) { + Py_ssize_t stride = 1; + for (i = 0; i < ndim; i++) { + if (unlikely(stride * buf->itemsize != buf->strides[i] && buf->shape[i] > 1)) { + PyErr_SetString(PyExc_ValueError, + "Buffer not fortran contiguous."); + goto fail; + } + stride = stride * buf->shape[i]; + } + } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) { + Py_ssize_t stride = 1; + for (i = ndim - 1; i >- 1; i--) { + if (unlikely(stride * buf->itemsize != buf->strides[i] && buf->shape[i] > 1)) { + PyErr_SetString(PyExc_ValueError, + "Buffer not C contiguous."); + goto fail; + } + stride = stride * buf->shape[i]; + } + } + + return 1; +fail: + return 0; +} + +static int __Pyx_ValidateAndInit_memviewslice( + int *axes_specs, + int c_or_f_flag, + int buf_flags, + int ndim, + __Pyx_TypeInfo *dtype, + __Pyx_BufFmt_StackElem stack[], + __Pyx_memviewslice *memviewslice, + PyObject *original_obj) +{ + struct __pyx_memoryview_obj *memview, *new_memview; + __Pyx_RefNannyDeclarations + Py_buffer *buf; + int i, spec = 0, retval = -1; + __Pyx_BufFmt_Context ctx; + int from_memoryview = __pyx_memoryview_check(original_obj); + + __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0); + + if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *) + original_obj)->typeinfo)) { + /* We have a matching dtype, skip format parsing */ + memview = (struct __pyx_memoryview_obj *) original_obj; + new_memview = NULL; + } else { + memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( + original_obj, buf_flags, 0, dtype); + new_memview = memview; + if (unlikely(!memview)) + goto fail; + } + + buf = &memview->view; + if (unlikely(buf->ndim != ndim)) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + ndim, buf->ndim); + goto fail; + } + + if (new_memview) { + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail; + } + + if (unlikely((unsigned) buf->itemsize != dtype->size)) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) " + "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)", + buf->itemsize, + (buf->itemsize > 1) ? "s" : "", + dtype->name, + dtype->size, + (dtype->size > 1) ? "s" : ""); + goto fail; + } + + /* Check axes */ + if (buf->len > 0) { + // 0-sized arrays do not undergo these checks since their strides are + // irrelevant and they are always both C- and F-contiguous. + for (i = 0; i < ndim; i++) { + spec = axes_specs[i]; + if (unlikely(!__pyx_check_strides(buf, i, ndim, spec))) + goto fail; + if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec))) + goto fail; + } + + /* Check contiguity */ + if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag))) + goto fail; + } + + /* Initialize */ + if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice, + new_memview != NULL) == -1)) { + goto fail; + } + + retval = 0; + goto no_fail; + +fail: + Py_XDECREF(new_memview); + retval = -1; + +no_fail: + __Pyx_RefNannyFinishContext(); + return retval; +} + + +////////// MemviewSliceInit ////////// + +static int +__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview, + int ndim, + {{memviewslice_name}} *memviewslice, + int memview_is_new_reference) +{ + __Pyx_RefNannyDeclarations + int i, retval=-1; + Py_buffer *buf = &memview->view; + __Pyx_RefNannySetupContext("init_memviewslice", 0); + + if (unlikely(memviewslice->memview || memviewslice->data)) { + PyErr_SetString(PyExc_ValueError, + "memviewslice is already initialized!"); + goto fail; + } + + if (buf->strides) { + for (i = 0; i < ndim; i++) { + memviewslice->strides[i] = buf->strides[i]; + } + } else { + Py_ssize_t stride = buf->itemsize; + for (i = ndim - 1; i >= 0; i--) { + memviewslice->strides[i] = stride; + stride *= buf->shape[i]; + } + } + + for (i = 0; i < ndim; i++) { + memviewslice->shape[i] = buf->shape[i]; + if (buf->suboffsets) { + memviewslice->suboffsets[i] = buf->suboffsets[i]; + } else { + memviewslice->suboffsets[i] = -1; + } + } + + memviewslice->memview = memview; + memviewslice->data = (char *)buf->buf; + if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) { + Py_INCREF(memview); + } + retval = 0; + goto no_fail; + +fail: + /* Don't decref, the memoryview may be borrowed. Let the caller do the cleanup */ + /* __Pyx_XDECREF(memviewslice->memview); */ + memviewslice->memview = 0; + memviewslice->data = 0; + retval = -1; +no_fail: + __Pyx_RefNannyFinishContext(); + return retval; +} + +#ifndef Py_NO_RETURN +// available since Py3.3 +#define Py_NO_RETURN +#endif + +static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN { + va_list vargs; + char msg[200]; + +#if PY_VERSION_HEX >= 0x030A0000 || defined(HAVE_STDARG_PROTOTYPES) + va_start(vargs, fmt); +#else + va_start(vargs); +#endif + vsnprintf(msg, 200, fmt, vargs); + va_end(vargs); + + Py_FatalError(msg); +} + +static CYTHON_INLINE int +__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) +{ + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)++; + PyThread_release_lock(lock); + return result; +} + +static CYTHON_INLINE int +__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) +{ + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)--; + PyThread_release_lock(lock); + return result; +} + + +static CYTHON_INLINE void +__Pyx_INC_MEMVIEW({{memviewslice_name}} *memslice, int have_gil, int lineno) +{ + int first_time; + struct {{memview_struct_name}} *memview = memslice->memview; + if (unlikely(!memview || (PyObject *) memview == Py_None)) + return; /* allow uninitialized memoryview assignment */ + + if (unlikely(__pyx_get_slice_count(memview) < 0)) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + + first_time = __pyx_add_acquisition_count(memview) == 0; + + if (unlikely(first_time)) { + if (have_gil) { + Py_INCREF((PyObject *) memview); + } else { + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_INCREF((PyObject *) memview); + PyGILState_Release(_gilstate); + } + } +} + +static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW({{memviewslice_name}} *memslice, + int have_gil, int lineno) { + int last_time; + struct {{memview_struct_name}} *memview = memslice->memview; + + if (unlikely(!memview || (PyObject *) memview == Py_None)) { + // we do not ref-count None + memslice->memview = NULL; + return; + } + + if (unlikely(__pyx_get_slice_count(memview) <= 0)) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + + last_time = __pyx_sub_acquisition_count(memview) == 1; + memslice->data = NULL; + + if (unlikely(last_time)) { + if (have_gil) { + Py_CLEAR(memslice->memview); + } else { + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_CLEAR(memslice->memview); + PyGILState_Release(_gilstate); + } + } else { + memslice->memview = NULL; + } +} + + +////////// MemviewSliceCopyTemplate.proto ////////// + +static {{memviewslice_name}} +__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, + const char *mode, int ndim, + size_t sizeof_dtype, int contig_flag, + int dtype_is_object); + + +////////// MemviewSliceCopyTemplate ////////// + +static {{memviewslice_name}} +__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, + const char *mode, int ndim, + size_t sizeof_dtype, int contig_flag, + int dtype_is_object) +{ + __Pyx_RefNannyDeclarations + int i; + __Pyx_memviewslice new_mvs = {{memslice_init}}; + struct __pyx_memoryview_obj *from_memview = from_mvs->memview; + Py_buffer *buf = &from_memview->view; + PyObject *shape_tuple = NULL; + PyObject *temp_int = NULL; + struct __pyx_array_obj *array_obj = NULL; + struct __pyx_memoryview_obj *memview_obj = NULL; + + __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0); + + for (i = 0; i < ndim; i++) { + if (unlikely(from_mvs->suboffsets[i] >= 0)) { + PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with " + "indirect dimensions (axis %d)", i); + goto fail; + } + } + + shape_tuple = PyTuple_New(ndim); + if (unlikely(!shape_tuple)) { + goto fail; + } + __Pyx_GOTREF(shape_tuple); + + + for(i = 0; i < ndim; i++) { + temp_int = PyInt_FromSsize_t(from_mvs->shape[i]); + if(unlikely(!temp_int)) { + goto fail; + } else { + PyTuple_SET_ITEM(shape_tuple, i, temp_int); + temp_int = NULL; + } + } + + array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL); + if (unlikely(!array_obj)) { + goto fail; + } + __Pyx_GOTREF(array_obj); + + memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( + (PyObject *) array_obj, contig_flag, + dtype_is_object, + from_mvs->memview->typeinfo); + if (unlikely(!memview_obj)) + goto fail; + + /* initialize new_mvs */ + if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0)) + goto fail; + + if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim, + dtype_is_object) < 0)) + goto fail; + + goto no_fail; + +fail: + __Pyx_XDECREF(new_mvs.memview); + new_mvs.memview = NULL; + new_mvs.data = NULL; +no_fail: + __Pyx_XDECREF(shape_tuple); + __Pyx_XDECREF(temp_int); + __Pyx_XDECREF(array_obj); + __Pyx_RefNannyFinishContext(); + return new_mvs; +} + + +////////// CopyContentsUtility.proto ///////// + +#define {{func_cname}}(slice) \ + __pyx_memoryview_copy_new_contig(&slice, "{{mode}}", {{ndim}}, \ + sizeof({{dtype_decl}}), {{contig_flag}}, \ + {{dtype_is_object}}) + + +////////// OverlappingSlices.proto ////////// + +static int __pyx_slices_overlap({{memviewslice_name}} *slice1, + {{memviewslice_name}} *slice2, + int ndim, size_t itemsize); + + +////////// OverlappingSlices ////////// + +/* Based on numpy's core/src/multiarray/array_assign.c */ + +/* Gets a half-open range [start, end) which contains the array data */ +static void +__pyx_get_array_memory_extents({{memviewslice_name}} *slice, + void **out_start, void **out_end, + int ndim, size_t itemsize) +{ + char *start, *end; + int i; + + start = end = slice->data; + + for (i = 0; i < ndim; i++) { + Py_ssize_t stride = slice->strides[i]; + Py_ssize_t extent = slice->shape[i]; + + if (extent == 0) { + *out_start = *out_end = start; + return; + } else { + if (stride > 0) + end += stride * (extent - 1); + else + start += stride * (extent - 1); + } + } + + /* Return a half-open range */ + *out_start = start; + *out_end = end + itemsize; +} + +/* Returns 1 if the arrays have overlapping data, 0 otherwise */ +static int +__pyx_slices_overlap({{memviewslice_name}} *slice1, + {{memviewslice_name}} *slice2, + int ndim, size_t itemsize) +{ + void *start1, *end1, *start2, *end2; + + __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize); + __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize); + + return (start1 < end2) && (start2 < end1); +} + + +////////// MemviewSliceCheckContig.proto ////////// + +#define __pyx_memviewslice_is_contig_{{contig_type}}{{ndim}}(slice) \ + __pyx_memviewslice_is_contig(slice, '{{contig_type}}', {{ndim}}) + + +////////// MemviewSliceIsContig.proto ////////// + +static int __pyx_memviewslice_is_contig(const {{memviewslice_name}} mvs, char order, int ndim);/*proto*/ + + +////////// MemviewSliceIsContig ////////// + +static int +__pyx_memviewslice_is_contig(const {{memviewslice_name}} mvs, char order, int ndim) +{ + int i, index, step, start; + Py_ssize_t itemsize = mvs.memview->view.itemsize; + + if (order == 'F') { + step = 1; + start = 0; + } else { + step = -1; + start = ndim - 1; + } + + for (i = 0; i < ndim; i++) { + index = start + step * i; + if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize) + return 0; + + itemsize *= mvs.shape[index]; + } + + return 1; +} + + +/////////////// MemviewSliceIndex /////////////// + +static CYTHON_INLINE char * +__pyx_memviewslice_index_full(const char *bufp, Py_ssize_t idx, + Py_ssize_t stride, Py_ssize_t suboffset) +{ + bufp = bufp + idx * stride; + if (suboffset >= 0) { + bufp = *((char **) bufp) + suboffset; + } + return (char *) bufp; +} + + +/////////////// MemviewDtypeToObject.proto /////////////// + +{{if to_py_function}} +static CYTHON_INLINE PyObject *{{get_function}}(const char *itemp); /* proto */ +{{endif}} + +{{if from_py_function}} +static CYTHON_INLINE int {{set_function}}(const char *itemp, PyObject *obj); /* proto */ +{{endif}} + +/////////////// MemviewDtypeToObject /////////////// + +{{#__pyx_memview_<dtype_name>_to_object}} + +/* Convert a dtype to or from a Python object */ + +{{if to_py_function}} +static CYTHON_INLINE PyObject *{{get_function}}(const char *itemp) { + return (PyObject *) {{to_py_function}}(*({{dtype}} *) itemp); +} +{{endif}} + +{{if from_py_function}} +static CYTHON_INLINE int {{set_function}}(const char *itemp, PyObject *obj) { + {{dtype}} value = {{from_py_function}}(obj); + if ({{error_condition}}) + return 0; + *({{dtype}} *) itemp = value; + return 1; +} +{{endif}} + + +/////////////// MemviewObjectToObject.proto /////////////// + +/* Function callbacks (for memoryview object) for dtype object */ +static PyObject *{{get_function}}(const char *itemp); /* proto */ +static int {{set_function}}(const char *itemp, PyObject *obj); /* proto */ + + +/////////////// MemviewObjectToObject /////////////// + +static PyObject *{{get_function}}(const char *itemp) { + PyObject *result = *(PyObject **) itemp; + Py_INCREF(result); + return result; +} + +static int {{set_function}}(const char *itemp, PyObject *obj) { + Py_INCREF(obj); + Py_DECREF(*(PyObject **) itemp); + *(PyObject **) itemp = obj; + return 1; +} + +/////////// ToughSlice ////////// + +/* Dimension is indexed with 'start:stop:step' */ + +if (unlikely(__pyx_memoryview_slice_memviewslice( + &{{dst}}, + {{src}}.shape[{{dim}}], {{src}}.strides[{{dim}}], {{src}}.suboffsets[{{dim}}], + {{dim}}, + {{new_ndim}}, + &{{get_suboffset_dim()}}, + {{start}}, + {{stop}}, + {{step}}, + {{int(have_start)}}, + {{int(have_stop)}}, + {{int(have_step)}}, + 1) < 0)) +{ + {{error_goto}} +} + + +////////// SimpleSlice ////////// + +/* Dimension is indexed with ':' only */ + +{{dst}}.shape[{{new_ndim}}] = {{src}}.shape[{{dim}}]; +{{dst}}.strides[{{new_ndim}}] = {{src}}.strides[{{dim}}]; + +{{if access == 'direct'}} + {{dst}}.suboffsets[{{new_ndim}}] = -1; +{{else}} + {{dst}}.suboffsets[{{new_ndim}}] = {{src}}.suboffsets[{{dim}}]; + if ({{src}}.suboffsets[{{dim}}] >= 0) + {{get_suboffset_dim()}} = {{new_ndim}}; +{{endif}} + + +////////// SliceIndex ////////// + +// Dimension is indexed with an integer, we could use the ToughSlice +// approach, but this is faster + +{ + Py_ssize_t __pyx_tmp_idx = {{idx}}; + + {{if wraparound or boundscheck}} + Py_ssize_t __pyx_tmp_shape = {{src}}.shape[{{dim}}]; + {{endif}} + + Py_ssize_t __pyx_tmp_stride = {{src}}.strides[{{dim}}]; + {{if wraparound}} + if (__pyx_tmp_idx < 0) + __pyx_tmp_idx += __pyx_tmp_shape; + {{endif}} + + {{if boundscheck}} + if (unlikely(!__Pyx_is_valid_index(__pyx_tmp_idx, __pyx_tmp_shape))) { + {{if not have_gil}} + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + {{endif}} + + PyErr_SetString(PyExc_IndexError, + "Index out of bounds (axis {{dim}})"); + + {{if not have_gil}} + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + {{endif}} + + {{error_goto}} + } + {{endif}} + + {{if all_dimensions_direct}} + {{dst}}.data += __pyx_tmp_idx * __pyx_tmp_stride; + {{else}} + if ({{get_suboffset_dim()}} < 0) { + {{dst}}.data += __pyx_tmp_idx * __pyx_tmp_stride; + + /* This dimension is the first dimension, or is preceded by */ + /* direct or indirect dimensions that are indexed away. */ + /* Hence suboffset_dim must be less than zero, and we can have */ + /* our data pointer refer to another block by dereferencing. */ + /* slice.data -> B -> C becomes slice.data -> C */ + + {{if indirect}} + { + Py_ssize_t __pyx_tmp_suboffset = {{src}}.suboffsets[{{dim}}]; + + {{if generic}} + if (__pyx_tmp_suboffset >= 0) + {{endif}} + + {{dst}}.data = *((char **) {{dst}}.data) + __pyx_tmp_suboffset; + } + {{endif}} + + } else { + {{dst}}.suboffsets[{{get_suboffset_dim()}}] += __pyx_tmp_idx * __pyx_tmp_stride; + + /* Note: dimension can not be indirect, the compiler will have */ + /* issued an error */ + } + + {{endif}} +} + + +////////// FillStrided1DScalar.proto ////////// + +static void +__pyx_fill_slice_{{dtype_name}}({{type_decl}} *p, Py_ssize_t extent, Py_ssize_t stride, + size_t itemsize, void *itemp); + +////////// FillStrided1DScalar ////////// + +/* Fill a slice with a scalar value. The dimension is direct and strided or contiguous */ +/* This can be used as a callback for the memoryview object to efficienty assign a scalar */ +/* Currently unused */ +static void +__pyx_fill_slice_{{dtype_name}}({{type_decl}} *p, Py_ssize_t extent, Py_ssize_t stride, + size_t itemsize, void *itemp) +{ + Py_ssize_t i; + {{type_decl}} item = *(({{type_decl}} *) itemp); + {{type_decl}} *endp; + + stride /= sizeof({{type_decl}}); + endp = p + stride * extent; + + while (p < endp) { + *p = item; + p += stride; + } +} diff --git a/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c b/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c new file mode 100644 index 00000000000..ec0a7f9bdc1 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c @@ -0,0 +1,1702 @@ +/////////////// CModulePreamble /////////////// + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wunused-function" +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 +// Ignore tp_print initializer. Need for ya make -DUSE_SYSTEM_PYTHON=3.8 +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif +#endif + +#include <stddef.h> /* For offsetof */ +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif + +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif + +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif + +// For use in DL_IMPORT/DL_EXPORT macros. +#define __PYX_COMMA , + +#ifndef HAVE_LONG_LONG + // CPython has required PY_LONG_LONG support for years, even if HAVE_LONG_LONG is not defined for us + #if PY_VERSION_HEX >= 0x02070000 + #define HAVE_LONG_LONG + #endif +#endif + +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif + +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif + +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_NOGIL 0 + + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif + +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_NOGIL 0 + + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif + +#elif defined(PY_NOGIL) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_NOGIL 1 + + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #ifndef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 1 + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 1 + #endif + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #define CYTHON_COMPILING_IN_NOGIL 0 + + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + // looks like calling _PyType_Lookup() isn't safe in Py<=2.6/3.1 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + // PyLong internals changed in Py3.12. + #define CYTHON_USE_PYLONG_INTERNALS (PY_VERSION_HEX < 0x030C00A5) + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 + // Python 3.11a2 hid _PyLong_FormatAdvancedWriter and _PyFloat_FormatAdvancedWriter + // therefore disable unicode writer until a better alternative appears + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #elif !defined(CYTHON_FAST_THREAD_STATE) + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + // Python 3.11 deleted localplus argument from frame object, which is used in our + // fast_pycall code + // On Python 3.10 it causes issues when used while profiling/debugging + #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000) + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif + #ifndef CYTHON_USE_DICT_VERSIONS + // The dict version field is now deprecated in Py3.12. + #define CYTHON_USE_DICT_VERSIONS ((PY_VERSION_HEX >= 0x030600B1) && (PY_VERSION_HEX < 0x030C00A5)) + #endif + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #elif !defined(CYTHON_USE_EXC_INFO_STACK) + #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) + #endif + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 + #endif +#endif + +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif + +#if CYTHON_USE_PYLONG_INTERNALS + #if PY_MAJOR_VERSION < 3 + #include "longintrepr.h" + #endif + /* These short defines can easily conflict with other code */ + #undef SHIFT + #undef BASE + #undef MASK + /* Compile-time sanity check that these are indeed equal. Github issue #2670. */ + #ifdef SIZEOF_VOID_P + enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; + #endif +#endif + +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif + +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif + +// restrict +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif + +// unused attribute +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif + +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif + +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif + +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) + +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include <stdint.h> +#endif + + +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 /* Xcode < 7.0 */ + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +/////////////// CInitCode /////////////// + +// inline attribute +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif + + +/////////////// CppInitCode /////////////// + +#ifndef __cplusplus + #error "Cython files generated with the C++ option must be compiled with a C++ compiler." +#endif + +// inline attribute +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #else + #define CYTHON_INLINE inline + #endif +#endif + +// Work around clang bug http://stackoverflow.com/questions/21847816/c-invoke-nested-template-class-destructor +template<typename T> +void __Pyx_call_destructor(T& x) { + x.~T(); +} + +// Used for temporary variables of "reference" type. +template<typename T> +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + // __Pyx_FakeReference(T& ref) : ptr(&ref) { } + // Const version needed as Cython doesn't know about const overloads (e.g. for stl containers). + __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { } + T *operator->() { return ptr; } + T *operator&() { return ptr; } + operator T&() { return *ptr; } + // TODO(robertwb): Delegate all operators (or auto-generate unwrapping code where needed). + template<typename U> bool operator ==(U other) { return *ptr == other; } + template<typename U> bool operator !=(U other) { return *ptr != other; } + private: + T *ptr; +}; + + +/////////////// PythonCompatibility /////////////// + +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif + +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" + +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_DefaultClassType PyType_Type +#if PY_VERSION_HEX >= 0x030B00A1 + static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f, + PyObject *code, PyObject *c, PyObject* n, PyObject *v, + PyObject *fv, PyObject *cell, PyObject* fn, + PyObject *name, int fline, PyObject *lnos) { + // TODO - currently written to be simple and work in limited API etc. + // A more optimized version would be good + PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; + PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL; + const char *fn_cstr=NULL; + const char *name_cstr=NULL; + PyCodeObject* co=NULL; + PyObject *type, *value, *traceback; + + // we must be able to call this while an exception is happening - thus clear then restore the state + PyErr_Fetch(&type, &value, &traceback); + + if (!(kwds=PyDict_New())) goto end; + if (!(argcount=PyLong_FromLong(a))) goto end; + if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; + if (!(posonlyargcount=PyLong_FromLong(0))) goto end; + if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; + if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; + if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; + if (!(nlocals=PyLong_FromLong(l))) goto end; + if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; + if (!(stacksize=PyLong_FromLong(s))) goto end; + if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; + if (!(flags=PyLong_FromLong(f))) goto end; + if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; + + if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; + if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; + if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; + + if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too; + if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here + if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too; + + Py_XDECREF((PyObject*)co); + co = (PyCodeObject*)call_result; + call_result = NULL; + + if (0) { + cleanup_code_too: + Py_XDECREF((PyObject*)co); + co = NULL; + } + end: + Py_XDECREF(kwds); + Py_XDECREF(argcount); + Py_XDECREF(posonlyargcount); + Py_XDECREF(kwonlyargcount); + Py_XDECREF(nlocals); + Py_XDECREF(stacksize); + Py_XDECREF(replace); + Py_XDECREF(call_result); + Py_XDECREF(empty); + if (type) { + PyErr_Restore(type, value, traceback); + } + return co; + } +#else + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif + #define __Pyx_DefaultClassType PyType_Type +#endif + +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif + +#ifndef METH_STACKLESS + // already defined for Stackless Python (all versions) and C-Python >= 3.7 + // value if defined: Stackless Python < 3.6: 0x80 else 0x100 + #define METH_STACKLESS 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) + // new in CPython 3.6, but changed in 3.7 - see + // positional-only parameters: + // https://bugs.python.org/issue29464 + // const args: + // https://bugs.python.org/issue32240 + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + // new in CPython 3.7, used to be old signature of _PyCFunctionFast() in 3.6 + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func) \ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif + +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif + +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 + #define PyMem_RawMalloc(n) PyMem_Malloc(n) + #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) + #define PyMem_RawFree(p) PyMem_Free(p) +#endif + +#if CYTHON_COMPILING_IN_PYSTON + // special C-API functions only in Pyston + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif + +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + //#elif PY_VERSION_HEX >= 0x03050200 + // Actually added in 3.5.2, but compiling against that does not guarantee that we get imported there. + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif + +// TSS (Thread Specific Storage) API +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; /* PyThread_create_key reports success always */ +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +// PyThread_delete_key_value(key) is equalivalent to PyThread_set_key_value(key, NULL) +// PyThread_ReInitTLS() is a no-op +#endif /* TSS (Thread Specific Storage) API */ + +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif + +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif + +/* new Py3.3 unicode type (PEP 393) */ +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + + #if PY_VERSION_HEX >= 0x030C0000 + // Py3.12 / PEP-623 removed wstr type unicode strings and all of the PyUnicode_READY() machinery. + #define __Pyx_PyUnicode_READY(op) (0) + #else + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #endif + + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #if PY_VERSION_HEX >= 0x030C0000 + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) + #else + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 + // Avoid calling deprecated C-API functions in Py3.9+ that PEP-623 schedules for removal in Py3.12. + // https://www.python.org/dev/peps/pep-0623/ + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) + #else + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) + #endif + #endif +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + /* (void)(k) => avoid unused variable warning due to macro: */ + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif + +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif + +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif + +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif + +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif + +// ("..." % x) must call PyNumber_Remainder() if x is a string subclass that implements "__rmod__()". +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif + +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif + +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact + // PyPy3 used to define "PyObject_Unicode" +#ifndef PyObject_Unicode + #define PyObject_Unicode PyObject_Str +#endif +#endif + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif + +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif + + +#if PY_VERSION_HEX >= 0x030900A4 + #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) +#else + #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) +#endif + +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + // NOTE: might fail with exception => check for -1 + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif + +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif + +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif + +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif + +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t +#endif + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif + +// backport of PyAsyncMethods from Py3.5 to older Py3.x versions +// (mis-)using the "tp_reserved" type slot which is re-activated as "tp_as_async" in Py3.5 +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; +#endif + + +/////////////// SmallCodeConfig.proto /////////////// + +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define CYTHON_SMALL_CODE __attribute__((cold)) +#else + #define CYTHON_SMALL_CODE +#endif +#endif + + +/////////////// PyModInitFuncType.proto /////////////// + +#ifndef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC + +#elif PY_MAJOR_VERSION < 3 +// Py2: define this to void manually because PyMODINIT_FUNC adds __declspec(dllexport) to it's definition. +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" void +#else +#define __Pyx_PyMODINIT_FUNC void +#endif + +#else +// Py3+: define this to PyObject * manually because PyMODINIT_FUNC adds __declspec(dllexport) to it's definition. +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyObject * +#endif +#endif + + +/////////////// FastTypeChecks.proto /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);/*proto*/ +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);/*proto*/ +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);/*proto*/ +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) + +/////////////// FastTypeChecks /////////////// +//@requires: Exceptions.c::PyThreadStateGet +//@requires: Exceptions.c::PyErrFetchRestore + +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} + +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + // should only get here for incompletely initialised types, i.e. never under normal usage patterns + return __Pyx_InBases(a, b); +} + + +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + // PyObject_IsSubclass() can recurse and therefore is not safe + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + // This function must not fail, so print the error here (which also clears it) + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + // This function must not fail, so print the error here (which also clears it) + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif + +// so far, we only call PyErr_GivenExceptionMatches() with an exception type (not instance) as first argument +// => optimise for that case + +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + // the tighter subtype checking in Py3 allows faster out-of-order comparison + for (i=0; i<n; i++) { + if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; + } +#endif + for (i=0; i<n; i++) { + PyObject *t = PyTuple_GET_ITEM(tuple, i); + #if PY_MAJOR_VERSION < 3 + if (likely(exc_type == t)) return 1; + #endif + if (likely(PyExceptionClass_Check(t))) { + if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; + } else { + // FIXME: Py3: PyErr_SetString(PyExc_TypeError, "catching classes that do not inherit from BaseException is not allowed"); + } + } + return 0; +} + +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + if (likely(PyExceptionClass_Check(exc_type))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } else if (likely(PyTuple_Check(exc_type))) { + return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); + } else { + // FIXME: Py3: PyErr_SetString(PyExc_TypeError, "catching classes that do not inherit from BaseException is not allowed"); + } + } + return PyErr_GivenExceptionMatches(err, exc_type); +} + +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + // Only used internally with known exception types => pure safety check assertions. + assert(PyExceptionClass_Check(exc_type1)); + assert(PyExceptionClass_Check(exc_type2)); + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} + +#endif + + +/////////////// MathInitCode /////////////// + +#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) + #if !defined(_USE_MATH_DEFINES) + #define _USE_MATH_DEFINES + #endif +#endif +#include <math.h> + +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + // Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + // a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + // a quiet NaN. + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif + +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +/////////////// UtilityFunctionPredeclarations.proto /////////////// + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ + +/////////////// ForceInitThreads.proto /////////////// +//@proto_block: utility_code_proto_before_types + +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + +/////////////// InitThreads.init /////////////// + +#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 +PyEval_InitThreads(); +#endif + + +/////////////// ModuleCreationPEP489 /////////////// +//@substitute: naming + +//#if CYTHON_PEP489_MULTI_PHASE_INIT +static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { + #if PY_VERSION_HEX >= 0x030700A1 + static PY_INT64_T main_interpreter_id = -1; + PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); + if (main_interpreter_id == -1) { + main_interpreter_id = current_id; + return (unlikely(current_id == -1)) ? -1 : 0; + } else if (unlikely(main_interpreter_id != current_id)) + + #else + static PyInterpreterState *main_interpreter = NULL; + PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; + if (!main_interpreter) { + main_interpreter = current_interpreter; + } else if (unlikely(main_interpreter != current_interpreter)) + #endif + + { + PyErr_SetString( + PyExc_ImportError, + "Interpreter change detected - this module can only be loaded into one interpreter per process."); + return -1; + } + return 0; +} + +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + if (allow_none || value != Py_None) { + result = PyDict_SetItemString(moddict, to_name, value); + } + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} + +static CYTHON_SMALL_CODE PyObject* ${pymodule_create_func_cname}(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + + // For now, we only have exactly one module instance. + if (__Pyx_check_single_interpreter()) + return NULL; + if (${module_cname}) + return __Pyx_NewRef(${module_cname}); + + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + // moddict is a borrowed reference + + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; + + return module; +bad: + Py_XDECREF(module); + return NULL; +} +//#endif + + +/////////////// CodeObjectCache.proto /////////////// + +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; + +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; + +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/////////////// CodeObjectCache /////////////// +// Note that errors are simply ignored in the code below. +// This is just a cache, if a lookup or insertion fails - so what? + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} + +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} + +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/////////////// CodeObjectCache.cleanup /////////////// + + if (__pyx_code_cache.entries) { + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + int i, count = __pyx_code_cache.count; + __pyx_code_cache.count = 0; + __pyx_code_cache.max_count = 0; + __pyx_code_cache.entries = NULL; + for (i=0; i<count; i++) { + Py_DECREF(entries[i].code_object); + } + PyMem_Free(entries); + } + +/////////////// CheckBinaryVersion.proto /////////////// + +static int __Pyx_check_binary_version(void); + +/////////////// CheckBinaryVersion /////////////// + +static int __Pyx_check_binary_version(void) { + char ctversion[5]; + int same=1, i, found_dot; + const char* rt_from_call = Py_GetVersion(); + PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + // slightly convoluted, but now that we're into double digit version numbers we can no longer just rely on the length. + found_dot = 0; + for (i = 0; i < 4; i++) { + if (!ctversion[i]) { + // if they are the same, just check that the runtime version doesn't continue with further numbers + same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); + break; + } + if (rt_from_call[i] != ctversion[i]) { + same = 0; + break; + } + } + + if (!same) { + char rtversion[5] = {'\0'}; + // copy the runtime-version for the error message + char message[200]; + for (i=0; i<4; ++i) { + if (rt_from_call[i] == '.') { + if (found_dot) break; + found_dot = 1; + } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { + break; + } + rtversion[i] = rt_from_call[i]; + } + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/////////////// IsLittleEndian.proto /////////////// + +static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); + +/////////////// IsLittleEndian /////////////// + +static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) +{ + union { + uint32_t u32; + uint8_t u8[4]; + } S; + S.u32 = 0x01020304; + return S.u8[0] == 4; +} + +/////////////// Refnanny.proto /////////////// + +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif + +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif /* CYTHON_REFNANNY */ + +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) + +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/////////////// Refnanny /////////////// + +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule(modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, "RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + + +/////////////// ImportRefnannyAPI /////////////// + +#if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + + +/////////////// RegisterModuleCleanup.proto /////////////// +//@substitute: naming + +static void ${cleanup_cname}(PyObject *self); /*proto*/ + +#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY +static int __Pyx_RegisterCleanup(void); /*proto*/ +#else +#define __Pyx_RegisterCleanup() (0) +#endif + +/////////////// RegisterModuleCleanup /////////////// +//@substitute: naming + +#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY +static PyObject* ${cleanup_cname}_atexit(PyObject *module, CYTHON_UNUSED PyObject *unused) { + ${cleanup_cname}(module); + Py_INCREF(Py_None); return Py_None; +} + +static int __Pyx_RegisterCleanup(void) { + // Don't use Py_AtExit because that has a 32-call limit and is called + // after python finalization. + // Also, we try to prepend the cleanup function to "atexit._exithandlers" + // in Py2 because CPython runs them last-to-first. Being run last allows + // user exit code to run before us that may depend on the globals + // and cached objects that we are about to clean up. + + static PyMethodDef cleanup_def = { + "__cleanup", (PyCFunction)${cleanup_cname}_atexit, METH_NOARGS, 0}; + + PyObject *cleanup_func = 0; + PyObject *atexit = 0; + PyObject *reg = 0; + PyObject *args = 0; + PyObject *res = 0; + int ret = -1; + + cleanup_func = PyCFunction_New(&cleanup_def, 0); + if (!cleanup_func) + goto bad; + + atexit = PyImport_ImportModule("atexit"); + if (!atexit) + goto bad; + reg = PyObject_GetAttrString(atexit, "_exithandlers"); + if (reg && PyList_Check(reg)) { + PyObject *a, *kw; + a = PyTuple_New(0); + kw = PyDict_New(); + if (!a || !kw) { + Py_XDECREF(a); + Py_XDECREF(kw); + goto bad; + } + args = PyTuple_Pack(3, cleanup_func, a, kw); + Py_DECREF(a); + Py_DECREF(kw); + if (!args) + goto bad; + ret = PyList_Insert(reg, 0, args); + } else { + if (!reg) + PyErr_Clear(); + Py_XDECREF(reg); + reg = PyObject_GetAttrString(atexit, "register"); + if (!reg) + goto bad; + args = PyTuple_Pack(1, cleanup_func); + if (!args) + goto bad; + res = PyObject_CallObject(reg, args); + if (!res) + goto bad; + ret = 0; + } +bad: + Py_XDECREF(cleanup_func); + Py_XDECREF(atexit); + Py_XDECREF(reg); + Py_XDECREF(args); + Py_XDECREF(res); + return ret; +} +#endif + +/////////////// FastGil.init /////////////// +#ifdef WITH_THREAD +__Pyx_FastGilFuncInit(); +#endif + +/////////////// NoFastGil.proto /////////////// +//@proto_block: utility_code_proto_before_types + +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/////////////// FastGil.proto /////////////// +//@proto_block: utility_code_proto_before_types + +struct __Pyx_FastGilVtab { + PyGILState_STATE (*Fast_PyGILState_Ensure)(void); + void (*Fast_PyGILState_Release)(PyGILState_STATE oldstate); + void (*FastGIL_Remember)(void); + void (*FastGIL_Forget)(void); +}; + +static void __Pyx_FastGIL_Noop(void) {} +static struct __Pyx_FastGilVtab __Pyx_FastGilFuncs = { + PyGILState_Ensure, + PyGILState_Release, + __Pyx_FastGIL_Noop, + __Pyx_FastGIL_Noop +}; + +static void __Pyx_FastGilFuncInit(void); + +#define __Pyx_PyGILState_Ensure __Pyx_FastGilFuncs.Fast_PyGILState_Ensure +#define __Pyx_PyGILState_Release __Pyx_FastGilFuncs.Fast_PyGILState_Release +#define __Pyx_FastGIL_Remember __Pyx_FastGilFuncs.FastGIL_Remember +#define __Pyx_FastGIL_Forget __Pyx_FastGilFuncs.FastGIL_Forget + +#ifdef WITH_THREAD + #ifndef CYTHON_THREAD_LOCAL + #if __STDC_VERSION__ >= 201112 + #define CYTHON_THREAD_LOCAL _Thread_local + #elif defined(__GNUC__) + #define CYTHON_THREAD_LOCAL __thread + #elif defined(_MSC_VER) + #define CYTHON_THREAD_LOCAL __declspec(thread) + #endif + #endif +#endif + +/////////////// FastGil /////////////// +//@requires: CommonStructures.c::FetchCommonPointer +// The implementations of PyGILState_Ensure/Release calls PyThread_get_key_value +// several times which is turns out to be quite slow (slower in fact than +// acquiring the GIL itself). Simply storing it in a thread local for the +// common case is much faster. +// To make optimal use of this thread local, we attempt to share it between +// modules. + +#define __Pyx_FastGIL_ABI_module "_cython_" CYTHON_ABI +#define __Pyx_FastGIL_PyCapsuleName "FastGilFuncs" +#define __Pyx_FastGIL_PyCapsule \ + __Pyx_FastGIL_ABI_module "." __Pyx_FastGIL_PyCapsuleName + +#if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_THREAD_LOCAL +#endif + +#ifdef CYTHON_THREAD_LOCAL + +#include "pythread.h" +#include "pystate.h" + +static CYTHON_THREAD_LOCAL PyThreadState *__Pyx_FastGil_tcur = NULL; +static CYTHON_THREAD_LOCAL int __Pyx_FastGil_tcur_depth = 0; +static int __Pyx_FastGil_autoTLSkey = -1; + +static CYTHON_INLINE void __Pyx_FastGIL_Remember0(void) { + ++__Pyx_FastGil_tcur_depth; +} + +static CYTHON_INLINE void __Pyx_FastGIL_Forget0(void) { + if (--__Pyx_FastGil_tcur_depth == 0) { + __Pyx_FastGil_tcur = NULL; + } +} + +static CYTHON_INLINE PyThreadState *__Pyx_FastGil_get_tcur(void) { + PyThreadState *tcur = __Pyx_FastGil_tcur; + if (tcur == NULL) { + tcur = __Pyx_FastGil_tcur = (PyThreadState*)PyThread_get_key_value(__Pyx_FastGil_autoTLSkey); + } + return tcur; +} + +static PyGILState_STATE __Pyx_FastGil_PyGILState_Ensure(void) { + int current; + PyThreadState *tcur; + __Pyx_FastGIL_Remember0(); + tcur = __Pyx_FastGil_get_tcur(); + if (tcur == NULL) { + // Uninitialized, need to initialize now. + return PyGILState_Ensure(); + } + current = tcur == __Pyx_PyThreadState_Current; + if (current == 0) { + PyEval_RestoreThread(tcur); + } + ++tcur->gilstate_counter; + return current ? PyGILState_LOCKED : PyGILState_UNLOCKED; +} + +static void __Pyx_FastGil_PyGILState_Release(PyGILState_STATE oldstate) { + PyThreadState *tcur = __Pyx_FastGil_get_tcur(); + __Pyx_FastGIL_Forget0(); + if (tcur->gilstate_counter == 1) { + // This is the last lock, do all the cleanup as well. + PyGILState_Release(oldstate); + } else { + --tcur->gilstate_counter; + if (oldstate == PyGILState_UNLOCKED) { + PyEval_SaveThread(); + } + } +} + +static void __Pyx_FastGilFuncInit0(void) { + /* Try to detect autoTLSkey. */ + int key; + void* this_thread_state = (void*) PyGILState_GetThisThreadState(); + for (key = 0; key < 100; key++) { + if (PyThread_get_key_value(key) == this_thread_state) { + __Pyx_FastGil_autoTLSkey = key; + break; + } + } + if (__Pyx_FastGil_autoTLSkey != -1) { + PyObject* capsule = NULL; + PyObject* abi_module = NULL; + __Pyx_PyGILState_Ensure = __Pyx_FastGil_PyGILState_Ensure; + __Pyx_PyGILState_Release = __Pyx_FastGil_PyGILState_Release; + __Pyx_FastGIL_Remember = __Pyx_FastGIL_Remember0; + __Pyx_FastGIL_Forget = __Pyx_FastGIL_Forget0; + capsule = PyCapsule_New(&__Pyx_FastGilFuncs, __Pyx_FastGIL_PyCapsule, NULL); + abi_module = PyImport_AddModule(__Pyx_FastGIL_ABI_module); + if (capsule && abi_module) { + PyObject_SetAttrString(abi_module, __Pyx_FastGIL_PyCapsuleName, capsule); + } + Py_XDECREF(capsule); + } +} + +#else + +static void __Pyx_FastGilFuncInit0(void) { + CYTHON_UNUSED void* force_use = (void*)&__Pyx_FetchCommonPointer; +} + +#endif + +static void __Pyx_FastGilFuncInit(void) { +#if PY_VERSION_HEX >= 0x02070000 + struct __Pyx_FastGilVtab* shared = (struct __Pyx_FastGilVtab*)PyCapsule_Import(__Pyx_FastGIL_PyCapsule, 1); +#else + struct __Pyx_FastGilVtab* shared = NULL; +#endif + if (shared) { + __Pyx_FastGilFuncs = *shared; + } else { + PyErr_Clear(); + __Pyx_FastGilFuncInit0(); + } +} diff --git a/contrib/tools/cython/Cython/Utility/ObjectHandling.c b/contrib/tools/cython/Cython/Utility/ObjectHandling.c new file mode 100644 index 00000000000..02574e46ecf --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/ObjectHandling.c @@ -0,0 +1,2506 @@ +/* + * General object operations and protocol implementations, + * including their specialisations for certain builtins. + * + * Optional optimisations for builtins are in Optimize.c. + * + * Required replacements of builtins are in Builtins.c. + */ + +/////////////// RaiseNoneIterError.proto /////////////// + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/////////////// RaiseNoneIterError /////////////// + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/////////////// RaiseTooManyValuesToUnpack.proto /////////////// + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/////////////// RaiseTooManyValuesToUnpack /////////////// + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/////////////// RaiseNeedMoreValuesToUnpack.proto /////////////// + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/////////////// RaiseNeedMoreValuesToUnpack /////////////// + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/////////////// UnpackTupleError.proto /////////////// + +static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/ + +/////////////// UnpackTupleError /////////////// +//@requires: RaiseNoneIterError +//@requires: RaiseNeedMoreValuesToUnpack +//@requires: RaiseTooManyValuesToUnpack + +static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { + if (t == Py_None) { + __Pyx_RaiseNoneNotIterableError(); + } else if (PyTuple_GET_SIZE(t) < index) { + __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); + } else { + __Pyx_RaiseTooManyValuesError(index); + } +} + +/////////////// UnpackItemEndCheck.proto /////////////// + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +/////////////// UnpackItemEndCheck /////////////// +//@requires: RaiseTooManyValuesToUnpack +//@requires: IterFinish + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } + + return __Pyx_IterFinish(); +} + +/////////////// UnpackTuple2.proto /////////////// + +#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple) \ + (likely(is_tuple || PyTuple_Check(tuple)) ? \ + (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ? \ + __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) : \ + (__Pyx_UnpackTupleError(tuple, 2), -1)) : \ + __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple)) + +static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( + PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple); +static int __Pyx_unpack_tuple2_generic( + PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple); + +/////////////// UnpackTuple2 /////////////// +//@requires: UnpackItemEndCheck +//@requires: UnpackTupleError +//@requires: RaiseNeedMoreValuesToUnpack + +static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( + PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) { + PyObject *value1 = NULL, *value2 = NULL; +#if CYTHON_COMPILING_IN_PYPY + value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad; + value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad; +#else + value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1); + value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2); +#endif + if (decref_tuple) { + Py_DECREF(tuple); + } + + *pvalue1 = value1; + *pvalue2 = value2; + return 0; +#if CYTHON_COMPILING_IN_PYPY +bad: + Py_XDECREF(value1); + Py_XDECREF(value2); + if (decref_tuple) { Py_XDECREF(tuple); } + return -1; +#endif +} + +static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, + int has_known_size, int decref_tuple) { + Py_ssize_t index; + PyObject *value1 = NULL, *value2 = NULL, *iter = NULL; + iternextfunc iternext; + + iter = PyObject_GetIter(tuple); + if (unlikely(!iter)) goto bad; + if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; } + + iternext = Py_TYPE(iter)->tp_iternext; + value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; } + value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; } + if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad; + + Py_DECREF(iter); + *pvalue1 = value1; + *pvalue2 = value2; + return 0; + +unpacking_failed: + if (!has_known_size && __Pyx_IterFinish() == 0) + __Pyx_RaiseNeedMoreValuesError(index); +bad: + Py_XDECREF(iter); + Py_XDECREF(value1); + Py_XDECREF(value2); + if (decref_tuple) { Py_XDECREF(tuple); } + return -1; +} + + +/////////////// IterNext.proto /////////////// + +#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL) +static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*proto*/ + +/////////////// IterNext /////////////// +//@requires: Exceptions.c::PyThreadStateGet +//@requires: Exceptions.c::PyErrFetchRestore + +static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) { + PyObject* exc_type; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + exc_type = __Pyx_PyErr_Occurred(); + if (unlikely(exc_type)) { + if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) + return NULL; + __Pyx_PyErr_Clear(); + Py_INCREF(defval); + return defval; + } + if (defval) { + Py_INCREF(defval); + return defval; + } + __Pyx_PyErr_SetNone(PyExc_StopIteration); + return NULL; +} + +static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) { + PyErr_Format(PyExc_TypeError, + "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name); +} + +// originally copied from Py3's builtin_next() +static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) { + PyObject* next; + // We always do a quick slot check because calling PyIter_Check() is so wasteful. + iternextfunc iternext = Py_TYPE(iterator)->tp_iternext; + if (likely(iternext)) { +#if CYTHON_USE_TYPE_SLOTS + next = iternext(iterator); + if (likely(next)) + return next; + #if PY_VERSION_HEX >= 0x02070000 + if (unlikely(iternext == &_PyObject_NextNotImplemented)) + return NULL; + #endif +#else + // Since the slot was set, assume that PyIter_Next() will likely succeed, and properly fail otherwise. + // Note: PyIter_Next() crashes in CPython if "tp_iternext" is NULL. + next = PyIter_Next(iterator); + if (likely(next)) + return next; +#endif + } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) { + // If CYTHON_USE_TYPE_SLOTS, then the slot was not set and we don't have an iterable. + // Otherwise, don't trust "tp_iternext" and rely on PyIter_Check(). + __Pyx_PyIter_Next_ErrorNoIterator(iterator); + return NULL; + } +#if !CYTHON_USE_TYPE_SLOTS + else { + // We have an iterator with an empty "tp_iternext", but didn't call next() on it yet. + next = PyIter_Next(iterator); + if (likely(next)) + return next; + } +#endif + return __Pyx_PyIter_Next2Default(defval); +} + +/////////////// IterFinish.proto /////////////// + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +/////////////// IterFinish /////////////// + +// When PyIter_Next(iter) has returned NULL in order to signal termination, +// this function does the right cleanup and returns 0 on success. If it +// detects an error that occurred in the iterator, it returns -1. + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + + +/////////////// ObjectGetItem.proto /////////////// + +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);/*proto*/ +#else +#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) +#endif + +/////////////// ObjectGetItem /////////////// +// //@requires: GetItemInt - added in IndexNode as it uses templating. + +#if CYTHON_USE_TYPE_SLOTS +static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { + PyObject *runerr = NULL; + Py_ssize_t key_value; + PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; + if (unlikely(!(m && m->sq_item))) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); + return NULL; + } + + key_value = __Pyx_PyIndex_AsSsize_t(index); + if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { + return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); + } + + // Error handling code -- only manage OverflowError differently. + if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { + PyErr_Clear(); + PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); + } + return NULL; +} + +static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { + PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; + if (likely(m && m->mp_subscript)) { + return m->mp_subscript(obj, key); + } + return __Pyx_PyObject_GetIndex(obj, key); +} +#endif + + +/////////////// DictGetItem.proto /////////////// + +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);/*proto*/ + +#define __Pyx_PyObject_Dict_GetItem(obj, name) \ + (likely(PyDict_CheckExact(obj)) ? \ + __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) + +#else +#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) +#endif + +/////////////// DictGetItem /////////////// + +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + if (unlikely(PyTuple_Check(key))) { + // CPython interprets tuples as separate arguments => must wrap them in another tuple. + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) { + PyErr_SetObject(PyExc_KeyError, args); + Py_DECREF(args); + } + } else { + // Avoid tuple packing if possible. + PyErr_SetObject(PyExc_KeyError, key); + } + } + return NULL; + } + Py_INCREF(value); + return value; +} +#endif + +/////////////// GetItemInt.proto /////////////// + +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) + +{{for type in ['List', 'Tuple']}} +#define __Pyx_GetItemInt_{{type}}(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_{{type}}_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "{{ type.lower() }} index out of range"), (PyObject*)NULL)) + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +{{endfor}} + +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/////////////// GetItemInt /////////////// + +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} + +{{for type in ['List', 'Tuple']}} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += Py{{type}}_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, Py{{type}}_GET_SIZE(o)))) { + PyObject *r = Py{{type}}_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +{{endfor}} + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + // inlined PySequence_GetItem() + special cased length overflow + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + // if length > max(Py_ssize_t), maybe the object can wrap around itself? + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/////////////// SetItemInt.proto /////////////// + +#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) : \ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) + +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck); + +/////////////// SetItemInt /////////////// + +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + int r; + if (!j) return -1; + r = PyObject_SetItem(o, j, v); + Py_DECREF(j); + return r; +} + +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, + CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { + PyObject* old = PyList_GET_ITEM(o, n); + Py_INCREF(v); + PyList_SET_ITEM(o, n, v); + Py_DECREF(old); + return 1; + } + } else { + // inlined PySequence_SetItem() + special cased length overflow + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_ass_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + // if length > max(Py_ssize_t), maybe the object can wrap around itself? + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return -1; + PyErr_Clear(); + } + } + return m->sq_ass_item(o, i, v); + } + } +#else +#if CYTHON_COMPILING_IN_PYPY + if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) +#else + if (is_list || PySequence_Check(o)) +#endif + { + return PySequence_SetItem(o, i, v); + } +#endif + return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); +} + + +/////////////// DelItemInt.proto /////////////// + +#define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound) : \ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \ + __Pyx_DelItem_Generic(o, to_py_func(i)))) + +static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j); +static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound); + +/////////////// DelItemInt /////////////// + +static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) { + int r; + if (!j) return -1; + r = PyObject_DelItem(o, j); + Py_DECREF(j); + return r; +} + +static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i, + CYTHON_UNUSED int is_list, CYTHON_NCP_UNUSED int wraparound) { +#if !CYTHON_USE_TYPE_SLOTS + if (is_list || PySequence_Check(o)) { + return PySequence_DelItem(o, i); + } +#else + // inlined PySequence_DelItem() + special cased length overflow + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_ass_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + // if length > max(Py_ssize_t), maybe the object can wrap around itself? + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return -1; + PyErr_Clear(); + } + } + return m->sq_ass_item(o, i, (PyObject *)NULL); + } +#endif + return __Pyx_DelItem_Generic(o, PyInt_FromSsize_t(i)); +} + + +/////////////// SliceObject.proto /////////////// + +// we pass pointer addresses to show the C compiler what is NULL and what isn't +{{if access == 'Get'}} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( + PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** py_start, PyObject** py_stop, PyObject** py_slice, + int has_cstart, int has_cstop, int wraparound); +{{else}} +#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) \ + __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) + +// we pass pointer addresses to show the C compiler what is NULL and what isn't +static CYTHON_INLINE int __Pyx_PyObject_SetSlice( + PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** py_start, PyObject** py_stop, PyObject** py_slice, + int has_cstart, int has_cstop, int wraparound); +{{endif}} + +/////////////// SliceObject /////////////// + +{{if access == 'Get'}} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, +{{else}} +static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value, +{{endif}} + Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, + int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { +#if CYTHON_USE_TYPE_SLOTS + PyMappingMethods* mp; +#if PY_MAJOR_VERSION < 3 + PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; + if (likely(ms && ms->sq_{{if access == 'Set'}}ass_{{endif}}slice)) { + if (!has_cstart) { + if (_py_start && (*_py_start != Py_None)) { + cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); + if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstart = 0; + } + if (!has_cstop) { + if (_py_stop && (*_py_stop != Py_None)) { + cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); + if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstop = PY_SSIZE_T_MAX; + } + if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { + Py_ssize_t l = ms->sq_length(obj); + if (likely(l >= 0)) { + if (cstop < 0) { + cstop += l; + if (cstop < 0) cstop = 0; + } + if (cstart < 0) { + cstart += l; + if (cstart < 0) cstart = 0; + } + } else { + // if length > max(Py_ssize_t), maybe the object can wrap around itself? + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + goto bad; + PyErr_Clear(); + } + } +{{if access == 'Get'}} + return ms->sq_slice(obj, cstart, cstop); +{{else}} + return ms->sq_ass_slice(obj, cstart, cstop, value); +{{endif}} + } +#endif + + mp = Py_TYPE(obj)->tp_as_mapping; +{{if access == 'Get'}} + if (likely(mp && mp->mp_subscript)) +{{else}} + if (likely(mp && mp->mp_ass_subscript)) +{{endif}} +#endif + { + {{if access == 'Get'}}PyObject*{{else}}int{{endif}} result; + PyObject *py_slice, *py_start, *py_stop; + if (_py_slice) { + py_slice = *_py_slice; + } else { + PyObject* owned_start = NULL; + PyObject* owned_stop = NULL; + if (_py_start) { + py_start = *_py_start; + } else { + if (has_cstart) { + owned_start = py_start = PyInt_FromSsize_t(cstart); + if (unlikely(!py_start)) goto bad; + } else + py_start = Py_None; + } + if (_py_stop) { + py_stop = *_py_stop; + } else { + if (has_cstop) { + owned_stop = py_stop = PyInt_FromSsize_t(cstop); + if (unlikely(!py_stop)) { + Py_XDECREF(owned_start); + goto bad; + } + } else + py_stop = Py_None; + } + py_slice = PySlice_New(py_start, py_stop, Py_None); + Py_XDECREF(owned_start); + Py_XDECREF(owned_stop); + if (unlikely(!py_slice)) goto bad; + } +#if CYTHON_USE_TYPE_SLOTS +{{if access == 'Get'}} + result = mp->mp_subscript(obj, py_slice); +#else + result = PyObject_GetItem(obj, py_slice); +{{else}} + result = mp->mp_ass_subscript(obj, py_slice, value); +#else + result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice); +{{endif}} +#endif + if (!_py_slice) { + Py_DECREF(py_slice); + } + return result; + } + PyErr_Format(PyExc_TypeError, +{{if access == 'Get'}} + "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); +{{else}} + "'%.200s' object does not support slice %.10s", + Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion"); +{{endif}} + +bad: + return {{if access == 'Get'}}NULL{{else}}-1{{endif}}; +} + + +/////////////// SliceTupleAndList.proto /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop); +static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop); +#else +#define __Pyx_PyList_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop) +#define __Pyx_PyTuple_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop) +#endif + +/////////////// SliceTupleAndList /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) { + Py_ssize_t start = *_start, stop = *_stop, length = *_length; + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + + if (stop < 0) + stop += length; + else if (stop > length) + stop = length; + + *_length = stop - start; + *_start = start; + *_stop = stop; +} + +static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { + PyObject *v; + Py_ssize_t i; + for (i = 0; i < length; i++) { + v = dest[i] = src[i]; + Py_INCREF(v); + } +} + +{{for type in ['List', 'Tuple']}} +static CYTHON_INLINE PyObject* __Pyx_Py{{type}}_GetSlice( + PyObject* src, Py_ssize_t start, Py_ssize_t stop) { + PyObject* dest; + Py_ssize_t length = Py{{type}}_GET_SIZE(src); + __Pyx_crop_slice(&start, &stop, &length); + if (unlikely(length <= 0)) + return Py{{type}}_New(0); + + dest = Py{{type}}_New(length); + if (unlikely(!dest)) + return NULL; + __Pyx_copy_object_array( + ((Py{{type}}Object*)src)->ob_item + start, + ((Py{{type}}Object*)dest)->ob_item, + length); + return dest; +} +{{endfor}} +#endif + + +/////////////// CalculateMetaclass.proto /////////////// + +static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); + +/////////////// CalculateMetaclass /////////////// + +static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { + Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); + for (i=0; i < nbases; i++) { + PyTypeObject *tmptype; + PyObject *tmp = PyTuple_GET_ITEM(bases, i); + tmptype = Py_TYPE(tmp); +#if PY_MAJOR_VERSION < 3 + if (tmptype == &PyClass_Type) + continue; +#endif + if (!metaclass) { + metaclass = tmptype; + continue; + } + if (PyType_IsSubtype(metaclass, tmptype)) + continue; + if (PyType_IsSubtype(tmptype, metaclass)) { + metaclass = tmptype; + continue; + } + // else: + PyErr_SetString(PyExc_TypeError, + "metaclass conflict: " + "the metaclass of a derived class " + "must be a (non-strict) subclass " + "of the metaclasses of all its bases"); + return NULL; + } + if (!metaclass) { +#if PY_MAJOR_VERSION < 3 + metaclass = &PyClass_Type; +#else + metaclass = &PyType_Type; +#endif + } + // make owned reference + Py_INCREF((PyObject*) metaclass); + return (PyObject*) metaclass; +} + + +/////////////// FindInheritedMetaclass.proto /////////////// + +static PyObject *__Pyx_FindInheritedMetaclass(PyObject *bases); /*proto*/ + +/////////////// FindInheritedMetaclass /////////////// +//@requires: PyObjectGetAttrStr +//@requires: CalculateMetaclass + +static PyObject *__Pyx_FindInheritedMetaclass(PyObject *bases) { + PyObject *metaclass; + if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) { + PyTypeObject *metatype; +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + PyObject *base = PyTuple_GET_ITEM(bases, 0); +#else + PyObject *base = PySequence_ITEM(bases, 0); +#endif +#if PY_MAJOR_VERSION < 3 + PyObject* basetype = __Pyx_PyObject_GetAttrStr(base, PYIDENT("__class__")); + if (basetype) { + metatype = (PyType_Check(basetype)) ? ((PyTypeObject*) basetype) : NULL; + } else { + PyErr_Clear(); + metatype = Py_TYPE(base); + basetype = (PyObject*) metatype; + Py_INCREF(basetype); + } +#else + metatype = Py_TYPE(base); +#endif + metaclass = __Pyx_CalculateMetaclass(metatype, bases); +#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_DECREF(base); +#endif +#if PY_MAJOR_VERSION < 3 + Py_DECREF(basetype); +#endif + } else { + // no bases => use default metaclass +#if PY_MAJOR_VERSION < 3 + metaclass = (PyObject *) &PyClass_Type; +#else + metaclass = (PyObject *) &PyType_Type; +#endif + Py_INCREF(metaclass); + } + return metaclass; +} + +/////////////// Py3MetaclassGet.proto /////////////// + +static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw); /*proto*/ + +/////////////// Py3MetaclassGet /////////////// +//@requires: FindInheritedMetaclass +//@requires: CalculateMetaclass + +static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw) { + PyObject *metaclass = mkw ? __Pyx_PyDict_GetItemStr(mkw, PYIDENT("metaclass")) : NULL; + if (metaclass) { + Py_INCREF(metaclass); + if (PyDict_DelItem(mkw, PYIDENT("metaclass")) < 0) { + Py_DECREF(metaclass); + return NULL; + } + if (PyType_Check(metaclass)) { + PyObject* orig = metaclass; + metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); + Py_DECREF(orig); + } + return metaclass; + } + return __Pyx_FindInheritedMetaclass(bases); +} + +/////////////// CreateClass.proto /////////////// + +static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, + PyObject *qualname, PyObject *modname); /*proto*/ + +/////////////// CreateClass /////////////// +//@requires: FindInheritedMetaclass +//@requires: CalculateMetaclass + +static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, + PyObject *qualname, PyObject *modname) { + PyObject *result; + PyObject *metaclass; + + if (PyDict_SetItem(dict, PYIDENT("__module__"), modname) < 0) + return NULL; + if (PyDict_SetItem(dict, PYIDENT("__qualname__"), qualname) < 0) + return NULL; + + /* Python2 __metaclass__ */ + metaclass = __Pyx_PyDict_GetItemStr(dict, PYIDENT("__metaclass__")); + if (metaclass) { + Py_INCREF(metaclass); + if (PyType_Check(metaclass)) { + PyObject* orig = metaclass; + metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); + Py_DECREF(orig); + } + } else { + metaclass = __Pyx_FindInheritedMetaclass(bases); + } + if (unlikely(!metaclass)) + return NULL; + result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL); + Py_DECREF(metaclass); + return result; +} + +/////////////// Py3ClassCreate.proto /////////////// + +static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, + PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/ +static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, + PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /*proto*/ + +/////////////// Py3ClassCreate /////////////// +//@requires: PyObjectGetAttrStr +//@requires: CalculateMetaclass + +static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, + PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { + PyObject *ns; + if (metaclass) { + PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, PYIDENT("__prepare__")); + if (prep) { + PyObject *pargs = PyTuple_Pack(2, name, bases); + if (unlikely(!pargs)) { + Py_DECREF(prep); + return NULL; + } + ns = PyObject_Call(prep, pargs, mkw); + Py_DECREF(prep); + Py_DECREF(pargs); + } else { + if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) + return NULL; + PyErr_Clear(); + ns = PyDict_New(); + } + } else { + ns = PyDict_New(); + } + + if (unlikely(!ns)) + return NULL; + + /* Required here to emulate assignment order */ + if (unlikely(PyObject_SetItem(ns, PYIDENT("__module__"), modname) < 0)) goto bad; + if (unlikely(PyObject_SetItem(ns, PYIDENT("__qualname__"), qualname) < 0)) goto bad; + if (unlikely(doc && PyObject_SetItem(ns, PYIDENT("__doc__"), doc) < 0)) goto bad; + return ns; +bad: + Py_DECREF(ns); + return NULL; +} + +static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, + PyObject *dict, PyObject *mkw, + int calculate_metaclass, int allow_py2_metaclass) { + PyObject *result, *margs; + PyObject *owned_metaclass = NULL; + if (allow_py2_metaclass) { + /* honour Python2 __metaclass__ for backward compatibility */ + owned_metaclass = PyObject_GetItem(dict, PYIDENT("__metaclass__")); + if (owned_metaclass) { + metaclass = owned_metaclass; + } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { + PyErr_Clear(); + } else { + return NULL; + } + } + if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { + metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); + Py_XDECREF(owned_metaclass); + if (unlikely(!metaclass)) + return NULL; + owned_metaclass = metaclass; + } + margs = PyTuple_Pack(3, name, bases, dict); + if (unlikely(!margs)) { + result = NULL; + } else { + result = PyObject_Call(metaclass, margs, mkw); + Py_DECREF(margs); + } + Py_XDECREF(owned_metaclass); + return result; +} + +/////////////// ExtTypeTest.proto /////////////// + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +/////////////// ExtTypeTest /////////////// + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(__Pyx_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/////////////// CallableCheck.proto /////////////// + +#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyCallable_Check(obj) (Py_TYPE(obj)->tp_call != NULL) +#else +#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj) +#endif + +/////////////// PyDictContains.proto /////////////// + +static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +/////////////// PySetContains.proto /////////////// + +static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq); /* proto */ + +/////////////// PySetContains /////////////// +//@requires: Builtins.c::pyfrozenset_new + +static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) { + int result = -1; + if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) { + /* Convert key to frozenset */ + PyObject *tmpkey; + PyErr_Clear(); + tmpkey = __Pyx_PyFrozenSet_New(key); + if (tmpkey != NULL) { + result = PySet_Contains(set, tmpkey); + Py_DECREF(tmpkey); + } + } + return result; +} + +static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) { + int result = PySet_Contains(set, key); + + if (unlikely(result < 0)) { + result = __Pyx_PySet_ContainsUnhashable(set, key); + } + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +/////////////// PySequenceContains.proto /////////////// + +static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { + int result = PySequence_Contains(seq, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +/////////////// PyBoolOrNullFromLong.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) { + return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b); +} + +/////////////// GetBuiltinName.proto /////////////// + +static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ + +/////////////// GetBuiltinName /////////////// +//@requires: PyObjectGetAttrStr +//@substitute: naming + +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr($builtins_cname, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/////////////// GetNameInClass.proto /////////////// + +#define __Pyx_GetNameInClass(var, nmspace, name) (var) = __Pyx__GetNameInClass(nmspace, name) +static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/ + +/////////////// GetNameInClass /////////////// +//@requires: PyObjectGetAttrStr +//@requires: GetModuleGlobalName +//@requires: Exceptions.c::PyThreadStateGet +//@requires: Exceptions.c::PyErrFetchRestore +//@requires: Exceptions.c::PyErrExceptionMatches + +static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) { + PyObject *result; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + return NULL; + __Pyx_PyErr_Clear(); + __Pyx_GetModuleGlobalNameUncached(result, name); + return result; +} + +static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) { + PyObject *result; + result = __Pyx_PyObject_GetAttrStr(nmspace, name); + if (!result) { + result = __Pyx_GetGlobalNameAfterAttributeLookup(name); + } + return result; +} + + +/////////////// SetNameInClass.proto /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 +// Identifier names are always interned and have a pre-calculated hash value. +#define __Pyx_SetNameInClass(ns, name, value) \ + (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value)) +#elif CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_SetNameInClass(ns, name, value) \ + (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value)) +#else +#define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value) +#endif + + +/////////////// GetModuleGlobalName.proto /////////////// +//@requires: PyDictVersioning +//@substitute: naming + +#if CYTHON_USE_DICT_VERSIONS +#define __Pyx_GetModuleGlobalName(var, name) do { \ + static PY_UINT64_T __pyx_dict_version = 0; \ + static PyObject *__pyx_dict_cached_value = NULL; \ + (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION($moddict_cname))) ? \ + (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) : \ + __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \ +} while(0) +#define __Pyx_GetModuleGlobalNameUncached(var, name) do { \ + PY_UINT64_T __pyx_dict_version; \ + PyObject *__pyx_dict_cached_value; \ + (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \ +} while(0) +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); /*proto*/ +#else +#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) +#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); /*proto*/ +#endif + + +/////////////// GetModuleGlobalName /////////////// +//@requires: GetBuiltinName +//@substitute: naming + +#if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + // Identifier names are always interned and have a pre-calculated hash value. + result = _PyDict_GetItem_KnownHash($moddict_cname, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE($moddict_cname, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } else if (unlikely(PyErr_Occurred())) { + return NULL; + } +#else + result = PyDict_GetItem($moddict_cname, name); + __PYX_UPDATE_DICT_CACHE($moddict_cname, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } +#endif +#else + result = PyObject_GetItem($moddict_cname, name); + __PYX_UPDATE_DICT_CACHE($moddict_cname, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } + PyErr_Clear(); +#endif + return __Pyx_GetBuiltinName(name); +} + +//////////////////// GetAttr.proto //////////////////// + +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /*proto*/ + +//////////////////// GetAttr //////////////////// +//@requires: PyObjectGetAttrStr + +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { +#if CYTHON_USE_TYPE_SLOTS +#if PY_MAJOR_VERSION >= 3 + if (likely(PyUnicode_Check(n))) +#else + if (likely(PyString_Check(n))) +#endif + return __Pyx_PyObject_GetAttrStr(o, n); +#endif + return PyObject_GetAttr(o, n); +} + +/////////////// PyObjectLookupSpecial.proto /////////////// +//@requires: PyObjectGetAttrStr + +#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) { + PyObject *res; + PyTypeObject *tp = Py_TYPE(obj); +#if PY_MAJOR_VERSION < 3 + if (unlikely(PyInstance_Check(obj))) + return __Pyx_PyObject_GetAttrStr(obj, attr_name); +#endif + // adapted from CPython's special_lookup() in ceval.c + res = _PyType_Lookup(tp, attr_name); + if (likely(res)) { + descrgetfunc f = Py_TYPE(res)->tp_descr_get; + if (!f) { + Py_INCREF(res); + } else { + res = f(res, obj, (PyObject *)tp); + } + } else { + PyErr_SetObject(PyExc_AttributeError, attr_name); + } + return res; +} +#else +#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n) +#endif + + +/////////////// PyObject_GenericGetAttrNoDict.proto /////////////// + +// Setting "tp_getattro" to anything but "PyObject_GenericGetAttr" disables fast method calls in Py3.7. +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); +#else +// No-args macro to allow function pointer assignment. +#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr +#endif + +/////////////// PyObject_GenericGetAttrNoDict /////////////// + +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 + +static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, attr_name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(attr_name)); +#endif + return NULL; +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { + // Copied and adapted from _PyObject_GenericGetAttrWithDict() in CPython 2.6/3.7. + // To be used in the "tp_getattro" slot of extension types that have no instance dict and cannot be subclassed. + PyObject *descr; + PyTypeObject *tp = Py_TYPE(obj); + + if (unlikely(!PyString_Check(attr_name))) { + return PyObject_GenericGetAttr(obj, attr_name); + } + + assert(!tp->tp_dictoffset); + descr = _PyType_Lookup(tp, attr_name); + if (unlikely(!descr)) { + return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); + } + + Py_INCREF(descr); + + #if PY_MAJOR_VERSION < 3 + if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) + #endif + { + descrgetfunc f = Py_TYPE(descr)->tp_descr_get; + // Optimise for the non-descriptor case because it is faster. + if (unlikely(f)) { + PyObject *res = f(descr, obj, (PyObject *)tp); + Py_DECREF(descr); + return res; + } + } + return descr; +} +#endif + + +/////////////// PyObject_GenericGetAttr.proto /////////////// + +// Setting "tp_getattro" to anything but "PyObject_GenericGetAttr" disables fast method calls in Py3.7. +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); +#else +// No-args macro to allow function pointer assignment. +#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr +#endif + +/////////////// PyObject_GenericGetAttr /////////////// +//@requires: PyObject_GenericGetAttrNoDict + +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { + if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { + return PyObject_GenericGetAttr(obj, attr_name); + } + return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); +} +#endif + + +/////////////// PyObjectGetAttrStrNoError.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);/*proto*/ + +/////////////// PyObjectGetAttrStrNoError /////////////// +//@requires: PyObjectGetAttrStr +//@requires: Exceptions.c::PyThreadStateGet +//@requires: Exceptions.c::PyErrFetchRestore +//@requires: Exceptions.c::PyErrExceptionMatches + +static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + __Pyx_PyErr_Clear(); +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 + // _PyObject_GenericGetAttrWithDict() in CPython 3.7+ can avoid raising the AttributeError. + // See https://bugs.python.org/issue32544 + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { + return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); + } +#endif + result = __Pyx_PyObject_GetAttrStr(obj, attr_name); + if (unlikely(!result)) { + __Pyx_PyObject_GetAttrStr_ClearAttributeError(); + } + return result; +} + + +/////////////// PyObjectGetAttrStr.proto /////////////// + +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);/*proto*/ +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/////////////// PyObjectGetAttrStr /////////////// + +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + + +/////////////// PyObjectSetAttrStr.proto /////////////// + +#if CYTHON_USE_TYPE_SLOTS +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);/*proto*/ +#else +#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) +#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) +#endif + +/////////////// PyObjectSetAttrStr /////////////// + +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_setattr)) + return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); +#endif + return PyObject_SetAttr(obj, attr_name, value); +} +#endif + + +/////////////// PyObjectGetMethod.proto /////////////// + +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);/*proto*/ + +/////////////// PyObjectGetMethod /////////////// +//@requires: PyObjectGetAttrStr + +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { + PyObject *attr; +#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP + // Copied from _PyObject_GetMethod() in CPython 3.7 + PyTypeObject *tp = Py_TYPE(obj); + PyObject *descr; + descrgetfunc f = NULL; + PyObject **dictptr, *dict; + int meth_found = 0; + + assert (*method == NULL); + + if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; + } + if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { + return 0; + } + + descr = _PyType_Lookup(tp, name); + if (likely(descr != NULL)) { + Py_INCREF(descr); + // Repeating the condition below accommodates for MSVC's inability to test macros inside of macro expansions. +#if PY_MAJOR_VERSION >= 3 + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type))) + #endif +#else + // "PyMethodDescr_Type" is not part of the C-API in Py2. + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr))) + #endif +#endif + { + meth_found = 1; + } else { + f = Py_TYPE(descr)->tp_descr_get; + if (f != NULL && PyDescr_IsData(descr)) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + } + } + + dictptr = _PyObject_GetDictPtr(obj); + if (dictptr != NULL && (dict = *dictptr) != NULL) { + Py_INCREF(dict); + attr = __Pyx_PyDict_GetItemStr(dict, name); + if (attr != NULL) { + Py_INCREF(attr); + Py_DECREF(dict); + Py_XDECREF(descr); + goto try_unpack; + } + Py_DECREF(dict); + } + + if (meth_found) { + *method = descr; + return 1; + } + + if (f != NULL) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + + if (descr != NULL) { + *method = descr; + return 0; + } + + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(name)); +#endif + return 0; + +// Generic fallback implementation using normal attribute lookup. +#else + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; +#endif + +try_unpack: +#if CYTHON_UNPACK_METHODS + // Even if we failed to avoid creating a bound method object, it's still worth unpacking it now, if possible. + if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { + PyObject *function = PyMethod_GET_FUNCTION(attr); + Py_INCREF(function); + Py_DECREF(attr); + *method = function; + return 1; + } +#endif + *method = attr; + return 0; +} + + +/////////////// UnpackUnboundCMethod.proto /////////////// + +typedef struct { + PyObject *type; + PyObject **method_name; + // "func" is set on first access (direct C function pointer) + PyCFunction func; + // "method" is set on first access (fallback) + PyObject *method; + int flag; +} __Pyx_CachedCFunction; + +/////////////// UnpackUnboundCMethod /////////////// +//@requires: PyObjectGetAttrStr + +static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { + PyObject *method; + method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); + if (unlikely(!method)) + return -1; + target->method = method; +#if CYTHON_COMPILING_IN_CPYTHON + #if PY_MAJOR_VERSION >= 3 + // method dscriptor type isn't exported in Py2.x, cannot easily check the type there + if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) + #endif + { + PyMethodDescrObject *descr = (PyMethodDescrObject*) method; + target->func = descr->d_method->ml_meth; + target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); + } +#endif + return 0; +} + + +/////////////// CallUnboundCMethod0.proto /////////////// +//@substitute: naming + +static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); /*proto*/ +#if CYTHON_COMPILING_IN_CPYTHON +// FASTCALL methods receive "&empty_tuple" as simple "PyObject[0]*" +#define __Pyx_CallUnboundCMethod0(cfunc, self) \ + (likely((cfunc)->func) ? \ + (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) : \ + (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ? \ + (PY_VERSION_HEX >= 0x030700A0 ? \ + (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &$empty_tuple, 0) : \ + (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &$empty_tuple, 0, NULL)) : \ + (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ? \ + (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &$empty_tuple, 0, NULL) : \ + (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, $empty_tuple, NULL)) : \ + ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, $empty_tuple) : \ + __Pyx__CallUnboundCMethod0(cfunc, self)))))) : \ + __Pyx__CallUnboundCMethod0(cfunc, self)) +#else +#define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) +#endif + +/////////////// CallUnboundCMethod0 /////////////// +//@requires: UnpackUnboundCMethod +//@requires: PyObjectCall + +static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { + PyObject *args, *result = NULL; + if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; +#if CYTHON_ASSUME_SAFE_MACROS + args = PyTuple_New(1); + if (unlikely(!args)) goto bad; + Py_INCREF(self); + PyTuple_SET_ITEM(args, 0, self); +#else + args = PyTuple_Pack(1, self); + if (unlikely(!args)) goto bad; +#endif + result = __Pyx_PyObject_Call(cfunc->method, args, NULL); + Py_DECREF(args); +bad: + return result; +} + + +/////////////// CallUnboundCMethod1.proto /////////////// + +static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);/*proto*/ + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);/*proto*/ +#else +#define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg) +#endif + +/////////////// CallUnboundCMethod1 /////////////// +//@requires: UnpackUnboundCMethod +//@requires: PyObjectCall + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) { + if (likely(cfunc->func)) { + int flag = cfunc->flag; + // Not using #ifdefs for PY_VERSION_HEX to avoid C compiler warnings about unused functions. + if (flag == METH_O) { + return (*(cfunc->func))(self, arg); + } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) { + #if PY_VERSION_HEX >= 0x030700A0 + return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1); + #else + return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); + #endif + } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) { + return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); + } + } + return __Pyx__CallUnboundCMethod1(cfunc, self, arg); +} +#endif + +static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){ + PyObject *args, *result = NULL; + if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; +#if CYTHON_COMPILING_IN_CPYTHON + if (cfunc->func && (cfunc->flag & METH_VARARGS)) { + args = PyTuple_New(1); + if (unlikely(!args)) goto bad; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + if (cfunc->flag & METH_KEYWORDS) + result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); + else + result = (*cfunc->func)(self, args); + } else { + args = PyTuple_New(2); + if (unlikely(!args)) goto bad; + Py_INCREF(self); + PyTuple_SET_ITEM(args, 0, self); + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 1, arg); + result = __Pyx_PyObject_Call(cfunc->method, args, NULL); + } +#else + args = PyTuple_Pack(2, self, arg); + if (unlikely(!args)) goto bad; + result = __Pyx_PyObject_Call(cfunc->method, args, NULL); +#endif +bad: + Py_XDECREF(args); + return result; +} + + +/////////////// CallUnboundCMethod2.proto /////////////// + +static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); /*proto*/ + +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 +static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); /*proto*/ +#else +#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) +#endif + +/////////////// CallUnboundCMethod2 /////////////// +//@requires: UnpackUnboundCMethod +//@requires: PyObjectCall + +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 +static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { + if (likely(cfunc->func)) { + PyObject *args[2] = {arg1, arg2}; + if (cfunc->flag == METH_FASTCALL) { + #if PY_VERSION_HEX >= 0x030700A0 + return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2); + #else + return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); + #endif + } + #if PY_VERSION_HEX >= 0x030700A0 + if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) + return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); + #endif + } + return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); +} +#endif + +static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ + PyObject *args, *result = NULL; + if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; +#if CYTHON_COMPILING_IN_CPYTHON + if (cfunc->func && (cfunc->flag & METH_VARARGS)) { + args = PyTuple_New(2); + if (unlikely(!args)) goto bad; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + if (cfunc->flag & METH_KEYWORDS) + result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); + else + result = (*cfunc->func)(self, args); + } else { + args = PyTuple_New(3); + if (unlikely(!args)) goto bad; + Py_INCREF(self); + PyTuple_SET_ITEM(args, 0, self); + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 1, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 2, arg2); + result = __Pyx_PyObject_Call(cfunc->method, args, NULL); + } +#else + args = PyTuple_Pack(3, self, arg1, arg2); + if (unlikely(!args)) goto bad; + result = __Pyx_PyObject_Call(cfunc->method, args, NULL); +#endif +bad: + Py_XDECREF(args); + return result; +} + + +/////////////// PyObjectCallMethod0.proto /////////////// + +static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /*proto*/ + +/////////////// PyObjectCallMethod0 /////////////// +//@requires: PyObjectGetMethod +//@requires: PyObjectCallOneArg +//@requires: PyObjectCallNoArg + +static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { + PyObject *method = NULL, *result = NULL; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_CallOneArg(method, obj); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) goto bad; + result = __Pyx_PyObject_CallNoArg(method); + Py_DECREF(method); +bad: + return result; +} + + +/////////////// PyObjectCallMethod1.proto /////////////// + +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /*proto*/ + +/////////////// PyObjectCallMethod1 /////////////// +//@requires: PyObjectGetMethod +//@requires: PyObjectCallOneArg +//@requires: PyObjectCall2Args + +static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { + // Separate function to avoid excessive inlining. + PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); + Py_DECREF(method); + return result; +} + +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { + PyObject *method = NULL, *result; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_Call2Args(method, obj, arg); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) return NULL; + return __Pyx__PyObject_CallMethod1(method, arg); +} + + +/////////////// PyObjectCallMethod2.proto /////////////// + +static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name, PyObject* arg1, PyObject* arg2); /*proto*/ + +/////////////// PyObjectCallMethod2 /////////////// +//@requires: PyObjectCall +//@requires: PyFunctionFastCall +//@requires: PyCFunctionFastCall +//@requires: PyObjectCall2Args + +static PyObject* __Pyx_PyObject_Call3Args(PyObject* function, PyObject* arg1, PyObject* arg2, PyObject* arg3) { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[3] = {arg1, arg2, arg3}; + return __Pyx_PyFunction_FastCall(function, args, 3); + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[3] = {arg1, arg2, arg3}; + return __Pyx_PyFunction_FastCall(function, args, 3); + } + #endif + + args = PyTuple_New(3); + if (unlikely(!args)) goto done; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + Py_INCREF(arg3); + PyTuple_SET_ITEM(args, 2, arg3); + + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + return result; +} + +static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name, PyObject* arg1, PyObject* arg2) { + PyObject *args, *method = NULL, *result = NULL; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_Call3Args(method, obj, arg1, arg2); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) return NULL; + result = __Pyx_PyObject_Call2Args(method, arg1, arg2); + Py_DECREF(method); + return result; +} + + +/////////////// tp_new.proto /////////////// + +#define __Pyx_tp_new(type_obj, args) __Pyx_tp_new_kwargs(type_obj, args, NULL) +static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) { + return (PyObject*) (((PyTypeObject*)type_obj)->tp_new((PyTypeObject*)type_obj, args, kwargs)); +} + + +/////////////// PyObjectCall.proto /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/ +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/////////////// PyObjectCall /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = Py_TYPE(func)->tp_call; + + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + + +/////////////// PyObjectCallMethO.proto /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); /*proto*/ +#endif + +/////////////// PyObjectCallMethO /////////////// + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + + +/////////////// PyFunctionFastCall.proto /////////////// + +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs) \ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) + +// let's assume that the non-public C-API function might still change during the 3.6 beta phase +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif + +// Backport from Python 3 +// Assert a build-time dependency, as an expression. +// Your compile will fail if the condition isn't true, or can't be evaluated +// by the compiler. This can be used in an expression: its value is 0. +// Example: +// #define foo_to_char(foo) \ +// ((char *)(foo) \ +// + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0)) +// +// Written by Rusty Russell, public domain, http://ccodearchive.net/ +#define __Pyx_BUILD_ASSERT_EXPR(cond) \ + (sizeof(char [1 - 2*!(cond)]) - 1) + +#ifndef Py_MEMBER_SIZE +// Get the size of a structure member in bytes +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) +#endif + +#if CYTHON_FAST_PYCALL + // Initialised by module init code. + static size_t __pyx_pyframe_localsplus_offset = 0; + + #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif + + // This is the long runtime version of + // #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus) + // offsetof(PyFrameObject, f_localsplus) differs between regular C-Python and Stackless Python. + // Therefore the offset is computed at run time from PyFrame_type.tp_basicsize. That is feasible, + // because f_localsplus is the last field of PyFrameObject (checked by Py_BUILD_ASSERT_EXPR below). + #define __Pxy_PyFrame_Initialize_Offsets() \ + ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)), \ + (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) + #define __Pyx_PyFrame_GetLocalsplus(frame) \ + (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) +#endif // CYTHON_FAST_PYCALL +#endif + + +/////////////// PyFunctionFastCall /////////////// +// copied from CPython 3.6 ceval.c + +#if CYTHON_FAST_PYCALL + +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + + fastlocals = __Pyx_PyFrame_GetLocalsplus(f); + + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + + return result; +} + + +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; + //#if PY_VERSION_HEX >= 0x03050000 + //PyObject *name, *qualname; + //#endif +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + /* Fast paths */ + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); + //#if PY_VERSION_HEX >= 0x03050000 + //name = ((PyFunctionObject *)func) -> func_name; + //qualname = ((PyFunctionObject *)func) -> func_qualname; + //#endif +#endif + + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } + + //#if PY_VERSION_HEX >= 0x03050000 + //return _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL, + // args, nargs, + // NULL, 0, + // d, nd, kwdefs, + // closure, name, qualname); + //#elif PY_MAJOR_VERSION >= 3 +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); + +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif /* CPython < 3.6 */ +#endif /* CYTHON_FAST_PYCALL */ + + +/////////////// PyCFunctionFastCall.proto /////////////// + +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/////////////// PyCFunctionFastCall /////////////// + +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); + } +} +#endif /* CYTHON_FAST_PYCCALL */ + + +/////////////// PyObjectCall2Args.proto /////////////// + +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /*proto*/ + +/////////////// PyObjectCall2Args /////////////// +//@requires: PyObjectCall +//@requires: PyFunctionFastCall +//@requires: PyCFunctionFastCall + +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { + PyObject *args, *result = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyFunction_FastCall(function, args, 2); + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyCFunction_FastCall(function, args, 2); + } + #endif + + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + + Py_INCREF(function); + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); +done: + return result; +} + + +/////////////// PyObjectCallOneArg.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /*proto*/ + +/////////////// PyObjectCallOneArg /////////////// +//@requires: PyObjectCallMethO +//@requires: PyObjectCall +//@requires: PyFunctionFastCall +//@requires: PyCFunctionFastCall + +#if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif + if (likely(PyCFunction_Check(func))) { + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + // fast and simple case that we are optimising for + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (__Pyx_PyFastCFunction_Check(func)) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + + +/////////////// PyObjectCallNoArg.proto /////////////// +//@requires: PyObjectCall +//@substitute: naming + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /*proto*/ +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, $empty_tuple, NULL) +#endif + +/////////////// PyObjectCallNoArg /////////////// +//@requires: PyObjectCallMethO +//@requires: PyObjectCall +//@requires: PyFunctionFastCall +//@substitute: naming + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#if defined(__Pyx_CyFunction_USED) && defined(NDEBUG) + // TODO PyCFunction_GET_FLAGS has a type-check assert that breaks with a CyFunction + // in debug mode. There is likely to be a better way of avoiding tripping this + // check that doesn't involve disabling the optimized path. + if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) +#else + if (likely(PyCFunction_Check(func))) +#endif + { + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + // fast and simple case that we are optimising for + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, $empty_tuple, NULL); +} +#endif + + +/////////////// MatrixMultiply.proto /////////////// + +#if PY_VERSION_HEX >= 0x03050000 + #define __Pyx_PyNumber_MatrixMultiply(x,y) PyNumber_MatrixMultiply(x,y) + #define __Pyx_PyNumber_InPlaceMatrixMultiply(x,y) PyNumber_InPlaceMatrixMultiply(x,y) +#else +#define __Pyx_PyNumber_MatrixMultiply(x,y) __Pyx__PyNumber_MatrixMultiply(x, y, "@") +static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const char* op_name); +static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y); +#endif + +/////////////// MatrixMultiply /////////////// +//@requires: PyObjectGetAttrStr +//@requires: PyObjectCallOneArg +//@requires: PyFunctionFastCall +//@requires: PyCFunctionFastCall + +#if PY_VERSION_HEX < 0x03050000 +static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg) { + // NOTE: eats the method reference + PyObject *result = NULL; +#if CYTHON_UNPACK_METHODS + if (likely(PyMethod_Check(method))) { + PyObject *self = PyMethod_GET_SELF(method); + if (likely(self)) { + PyObject *args; + PyObject *function = PyMethod_GET_FUNCTION(method); + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {self, arg}; + result = __Pyx_PyFunction_FastCall(function, args, 2); + goto done; + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {self, arg}; + result = __Pyx_PyCFunction_FastCall(function, args, 2); + goto done; + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(self); + PyTuple_SET_ITEM(args, 0, self); + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 1, arg); + Py_INCREF(function); + Py_DECREF(method); method = NULL; + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); + return result; + } + } +#endif + result = __Pyx_PyObject_CallOneArg(method, arg); +done: + Py_DECREF(method); + return result; +} + +#define __Pyx_TryMatrixMethod(x, y, py_method_name) { \ + PyObject *func = __Pyx_PyObject_GetAttrStr(x, py_method_name); \ + if (func) { \ + PyObject *result = __Pyx_PyObject_CallMatrixMethod(func, y); \ + if (result != Py_NotImplemented) \ + return result; \ + Py_DECREF(result); \ + } else { \ + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) \ + return NULL; \ + PyErr_Clear(); \ + } \ +} + +static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const char* op_name) { + int right_is_subtype = PyObject_IsSubclass((PyObject*)Py_TYPE(y), (PyObject*)Py_TYPE(x)); + if (unlikely(right_is_subtype == -1)) + return NULL; + if (right_is_subtype) { + // to allow subtypes to override parent behaviour, try reversed operation first + // see note at https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types + __Pyx_TryMatrixMethod(y, x, PYIDENT("__rmatmul__")) + } + __Pyx_TryMatrixMethod(x, y, PYIDENT("__matmul__")) + if (!right_is_subtype) { + __Pyx_TryMatrixMethod(y, x, PYIDENT("__rmatmul__")) + } + PyErr_Format(PyExc_TypeError, + "unsupported operand type(s) for %.2s: '%.100s' and '%.100s'", + op_name, + Py_TYPE(x)->tp_name, + Py_TYPE(y)->tp_name); + return NULL; +} + +static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y) { + __Pyx_TryMatrixMethod(x, y, PYIDENT("__imatmul__")) + return __Pyx__PyNumber_MatrixMultiply(x, y, "@="); +} + +#undef __Pyx_TryMatrixMethod +#endif + + +/////////////// PyDictVersioning.proto /////////////// + +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) +#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) \ + (version_var) = __PYX_GET_DICT_VERSION(dict); \ + (cache_var) = (value); + +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) { \ + static PY_UINT64_T __pyx_dict_version = 0; \ + static PyObject *__pyx_dict_cached_value = NULL; \ + if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) { \ + (VAR) = __pyx_dict_cached_value; \ + } else { \ + (VAR) = __pyx_dict_cached_value = (LOOKUP); \ + __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT); \ + } \ +} + +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); /*proto*/ +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); /*proto*/ +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); /*proto*/ + +#else +#define __PYX_GET_DICT_VERSION(dict) (0) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); +#endif + +/////////////// PyDictVersioning /////////////// + +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; +} + +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { + PyObject **dictptr = NULL; + Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; + if (offset) { +#if CYTHON_COMPILING_IN_CPYTHON + dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); +#else + dictptr = _PyObject_GetDictPtr(obj); +#endif + } + return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; +} + +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) + return 0; + return obj_dict_version == __Pyx_get_object_dict_version(obj); +} +#endif diff --git a/contrib/tools/cython/Cython/Utility/Optimize.c b/contrib/tools/cython/Cython/Utility/Optimize.c new file mode 100644 index 00000000000..d18c9b78ec6 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Optimize.c @@ -0,0 +1,1195 @@ +/* + * Optional optimisations of built-in functions and methods. + * + * Required replacements of builtins are in Builtins.c. + * + * General object operations and protocols are in ObjectHandling.c. + */ + +/////////////// append.proto /////////////// + +static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); /*proto*/ + +/////////////// append /////////////// +//@requires: ListAppend +//@requires: ObjectHandling.c::PyObjectCallMethod1 + +static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { + if (likely(PyList_CheckExact(L))) { + if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; + } else { + PyObject* retval = __Pyx_PyObject_CallMethod1(L, PYIDENT("append"), x); + if (unlikely(!retval)) + return -1; + Py_DECREF(retval); + } + return 0; +} + +/////////////// ListAppend.proto /////////////// + +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/////////////// ListCompAppend.proto /////////////// + +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +//////////////////// ListExtend.proto //////////////////// + +static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject* none = _PyList_Extend((PyListObject*)L, v); + if (unlikely(!none)) + return -1; + Py_DECREF(none); + return 0; +#else + return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v); +#endif +} + +/////////////// pop.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L); /*proto*/ + +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L); /*proto*/ +#define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ? \ + __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L)) + +#else +#define __Pyx_PyList_Pop(L) __Pyx__PyObject_Pop(L) +#define __Pyx_PyObject_Pop(L) __Pyx__PyObject_Pop(L) +#endif + +/////////////// pop /////////////// +//@requires: ObjectHandling.c::PyObjectCallMethod0 + +static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) { + if (Py_TYPE(L) == &PySet_Type) { + return PySet_Pop(L); + } + return __Pyx_PyObject_CallMethod0(L, PYIDENT("pop")); +} + +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) { + /* Check that both the size is positive and no reallocation shrinking needs to be done. */ + if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) { + __Pyx_SET_SIZE(L, Py_SIZE(L) - 1); + return PyList_GET_ITEM(L, PyList_GET_SIZE(L)); + } + return CALL_UNBOUND_METHOD(PyList_Type, "pop", L); +} +#endif + + +/////////////// pop_index.proto /////////////// + +static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix); /*proto*/ +static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix); /*proto*/ + +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix); /*proto*/ + +#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) ( \ + (likely(PyList_CheckExact(L) && __Pyx_fits_Py_ssize_t(ix, type, is_signed))) ? \ + __Pyx__PyList_PopIndex(L, py_ix, ix) : ( \ + (unlikely((py_ix) == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) : \ + __Pyx__PyObject_PopIndex(L, py_ix))) + +#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) ( \ + __Pyx_fits_Py_ssize_t(ix, type, is_signed) ? \ + __Pyx__PyList_PopIndex(L, py_ix, ix) : ( \ + (unlikely((py_ix) == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) : \ + __Pyx__PyObject_PopIndex(L, py_ix))) + +#else + +#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) \ + __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) + +#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) ( \ + (unlikely((py_ix) == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) : \ + __Pyx__PyObject_PopIndex(L, py_ix)) +#endif + +/////////////// pop_index /////////////// +//@requires: ObjectHandling.c::PyObjectCallMethod1 + +static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix) { + PyObject *r; + if (unlikely(!py_ix)) return NULL; + r = __Pyx__PyObject_PopIndex(L, py_ix); + Py_DECREF(py_ix); + return r; +} + +static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix) { + return __Pyx_PyObject_CallMethod1(L, PYIDENT("pop"), py_ix); +} + +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix) { + Py_ssize_t size = PyList_GET_SIZE(L); + if (likely(size > (((PyListObject*)L)->allocated >> 1))) { + Py_ssize_t cix = ix; + if (cix < 0) { + cix += size; + } + if (likely(__Pyx_is_valid_index(cix, size))) { + PyObject* v = PyList_GET_ITEM(L, cix); + __Pyx_SET_SIZE(L, Py_SIZE(L) - 1); + size -= 1; + memmove(&PyList_GET_ITEM(L, cix), &PyList_GET_ITEM(L, cix+1), (size_t)(size-cix)*sizeof(PyObject*)); + return v; + } + } + if (py_ix == Py_None) { + return __Pyx__PyObject_PopNewIndex(L, PyInt_FromSsize_t(ix)); + } else { + return __Pyx__PyObject_PopIndex(L, py_ix); + } +} +#endif + + +/////////////// dict_getitem_default.proto /////////////// + +static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); /*proto*/ + +/////////////// dict_getitem_default /////////////// + +static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { + PyObject* value; +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (unlikely(PyErr_Occurred())) + return NULL; + value = default_value; + } + Py_INCREF(value); + // avoid C compiler warning about unused utility functions + if ((1)); +#else + if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { + /* these presumably have safe hash functions */ + value = PyDict_GetItem(d, key); + if (unlikely(!value)) { + value = default_value; + } + Py_INCREF(value); + } +#endif + else { + if (default_value == Py_None) + value = CALL_UNBOUND_METHOD(PyDict_Type, "get", d, key); + else + value = CALL_UNBOUND_METHOD(PyDict_Type, "get", d, key, default_value); + } + return value; +} + + +/////////////// dict_setdefault.proto /////////////// + +static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value, int is_safe_type); /*proto*/ + +/////////////// dict_setdefault /////////////// + +static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value, + CYTHON_UNUSED int is_safe_type) { + PyObject* value; +#if PY_VERSION_HEX >= 0x030400A0 + // we keep the method call at the end to avoid "unused" C compiler warnings + if ((1)) { + value = PyDict_SetDefault(d, key, default_value); + if (unlikely(!value)) return NULL; + Py_INCREF(value); +#else + if (is_safe_type == 1 || (is_safe_type == -1 && + /* the following builtins presumably have repeatably safe and fast hash functions */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY + (PyUnicode_CheckExact(key) || PyString_CheckExact(key) || PyLong_CheckExact(key)))) { + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (unlikely(PyErr_Occurred())) + return NULL; + if (unlikely(PyDict_SetItem(d, key, default_value) == -1)) + return NULL; + value = default_value; + } + Py_INCREF(value); +#else + (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key) || PyLong_CheckExact(key)))) { + value = PyDict_GetItem(d, key); + if (unlikely(!value)) { + if (unlikely(PyDict_SetItem(d, key, default_value) == -1)) + return NULL; + value = default_value; + } + Py_INCREF(value); +#endif +#endif + } else { + value = CALL_UNBOUND_METHOD(PyDict_Type, "setdefault", d, key, default_value); + } + return value; +} + + +/////////////// py_dict_clear.proto /////////////// + +#define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0) + + +/////////////// py_dict_pop.proto /////////////// + +static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value); /*proto*/ + +/////////////// py_dict_pop /////////////// + +static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3 + if ((1)) { + return _PyDict_Pop(d, key, default_value); + } else + // avoid "function unused" warnings +#endif + if (default_value) { + return CALL_UNBOUND_METHOD(PyDict_Type, "pop", d, key, default_value); + } else { + return CALL_UNBOUND_METHOD(PyDict_Type, "pop", d, key); + } +} + + +/////////////// dict_iter.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name, + Py_ssize_t* p_orig_length, int* p_is_dict); +static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos, + PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict); + +/////////////// dict_iter /////////////// +//@requires: ObjectHandling.c::UnpackTuple2 +//@requires: ObjectHandling.c::IterFinish +//@requires: ObjectHandling.c::PyObjectCallMethod0 + +static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name, + Py_ssize_t* p_orig_length, int* p_source_is_dict) { + is_dict = is_dict || likely(PyDict_CheckExact(iterable)); + *p_source_is_dict = is_dict; + if (is_dict) { +#if !CYTHON_COMPILING_IN_PYPY + *p_orig_length = PyDict_Size(iterable); + Py_INCREF(iterable); + return iterable; +#elif PY_MAJOR_VERSION >= 3 + // On PyPy3, we need to translate manually a few method names. + // This logic is not needed on CPython thanks to the fast case above. + static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; + PyObject **pp = NULL; + if (method_name) { + const char *name = PyUnicode_AsUTF8(method_name); + if (strcmp(name, "iteritems") == 0) pp = &py_items; + else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; + else if (strcmp(name, "itervalues") == 0) pp = &py_values; + if (pp) { + if (!*pp) { + *pp = PyUnicode_FromString(name + 4); + if (!*pp) + return NULL; + } + method_name = *pp; + } + } +#endif + } + *p_orig_length = 0; + if (method_name) { + PyObject* iter; + iterable = __Pyx_PyObject_CallMethod0(iterable, method_name); + if (!iterable) + return NULL; +#if !CYTHON_COMPILING_IN_PYPY + if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable)) + return iterable; +#endif + iter = PyObject_GetIter(iterable); + Py_DECREF(iterable); + return iter; + } + return PyObject_GetIter(iterable); +} + +static CYTHON_INLINE int __Pyx_dict_iter_next( + PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos, + PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) { + PyObject* next_item; +#if !CYTHON_COMPILING_IN_PYPY + if (source_is_dict) { + PyObject *key, *value; + if (unlikely(orig_length != PyDict_Size(iter_obj))) { + PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); + return -1; + } + if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) { + return 0; + } + if (pitem) { + PyObject* tuple = PyTuple_New(2); + if (unlikely(!tuple)) { + return -1; + } + Py_INCREF(key); + Py_INCREF(value); + PyTuple_SET_ITEM(tuple, 0, key); + PyTuple_SET_ITEM(tuple, 1, value); + *pitem = tuple; + } else { + if (pkey) { + Py_INCREF(key); + *pkey = key; + } + if (pvalue) { + Py_INCREF(value); + *pvalue = value; + } + } + return 1; + } else if (PyTuple_CheckExact(iter_obj)) { + Py_ssize_t pos = *ppos; + if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0; + *ppos = pos + 1; + next_item = PyTuple_GET_ITEM(iter_obj, pos); + Py_INCREF(next_item); + } else if (PyList_CheckExact(iter_obj)) { + Py_ssize_t pos = *ppos; + if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0; + *ppos = pos + 1; + next_item = PyList_GET_ITEM(iter_obj, pos); + Py_INCREF(next_item); + } else +#endif + { + next_item = PyIter_Next(iter_obj); + if (unlikely(!next_item)) { + return __Pyx_IterFinish(); + } + } + if (pitem) { + *pitem = next_item; + } else if (pkey && pvalue) { + if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) + return -1; + } else if (pkey) { + *pkey = next_item; + } else { + *pvalue = next_item; + } + return 1; +} + + +/////////////// set_iter.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_set_iterator(PyObject* iterable, int is_set, + Py_ssize_t* p_orig_length, int* p_source_is_set); /*proto*/ +static CYTHON_INLINE int __Pyx_set_iter_next( + PyObject* iter_obj, Py_ssize_t orig_length, + Py_ssize_t* ppos, PyObject **value, + int source_is_set); /*proto*/ + +/////////////// set_iter /////////////// +//@requires: ObjectHandling.c::IterFinish + +static CYTHON_INLINE PyObject* __Pyx_set_iterator(PyObject* iterable, int is_set, + Py_ssize_t* p_orig_length, int* p_source_is_set) { +#if CYTHON_COMPILING_IN_CPYTHON + is_set = is_set || likely(PySet_CheckExact(iterable) || PyFrozenSet_CheckExact(iterable)); + *p_source_is_set = is_set; + if (likely(is_set)) { + *p_orig_length = PySet_Size(iterable); + Py_INCREF(iterable); + return iterable; + } +#else + (void)is_set; + *p_source_is_set = 0; +#endif + *p_orig_length = 0; + return PyObject_GetIter(iterable); +} + +static CYTHON_INLINE int __Pyx_set_iter_next( + PyObject* iter_obj, Py_ssize_t orig_length, + Py_ssize_t* ppos, PyObject **value, + int source_is_set) { + if (!CYTHON_COMPILING_IN_CPYTHON || unlikely(!source_is_set)) { + *value = PyIter_Next(iter_obj); + if (unlikely(!*value)) { + return __Pyx_IterFinish(); + } + (void)orig_length; + (void)ppos; + return 1; + } +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(PySet_GET_SIZE(iter_obj) != orig_length)) { + PyErr_SetString( + PyExc_RuntimeError, + "set changed size during iteration"); + return -1; + } + { + Py_hash_t hash; + int ret = _PySet_NextEntry(iter_obj, ppos, value, &hash); + // CPython does not raise errors here, only if !isinstance(iter_obj, set/frozenset) + assert (ret != -1); + if (likely(ret)) { + Py_INCREF(*value); + return 1; + } + } +#endif + return 0; +} + +/////////////// py_set_discard_unhashable /////////////// +//@requires: Builtins.c::pyfrozenset_new + +static int __Pyx_PySet_DiscardUnhashable(PyObject *set, PyObject *key) { + PyObject *tmpkey; + int rv; + + if (likely(!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))) + return -1; + PyErr_Clear(); + tmpkey = __Pyx_PyFrozenSet_New(key); + if (tmpkey == NULL) + return -1; + rv = PySet_Discard(set, tmpkey); + Py_DECREF(tmpkey); + return rv; +} + + +/////////////// py_set_discard.proto /////////////// + +static CYTHON_INLINE int __Pyx_PySet_Discard(PyObject *set, PyObject *key); /*proto*/ + +/////////////// py_set_discard /////////////// +//@requires: py_set_discard_unhashable + +static CYTHON_INLINE int __Pyx_PySet_Discard(PyObject *set, PyObject *key) { + int found = PySet_Discard(set, key); + // Convert *key* to frozenset if necessary + if (unlikely(found < 0)) { + found = __Pyx_PySet_DiscardUnhashable(set, key); + } + // note: returns -1 on error, 0 (not found) or 1 (found) otherwise => error check for -1 or < 0 works + return found; +} + + +/////////////// py_set_remove.proto /////////////// + +static CYTHON_INLINE int __Pyx_PySet_Remove(PyObject *set, PyObject *key); /*proto*/ + +/////////////// py_set_remove /////////////// +//@requires: py_set_discard_unhashable + +static int __Pyx_PySet_RemoveNotFound(PyObject *set, PyObject *key, int found) { + // Convert *key* to frozenset if necessary + if (unlikely(found < 0)) { + found = __Pyx_PySet_DiscardUnhashable(set, key); + } + if (likely(found == 0)) { + // Not found + PyObject *tup; + tup = PyTuple_Pack(1, key); + if (!tup) + return -1; + PyErr_SetObject(PyExc_KeyError, tup); + Py_DECREF(tup); + return -1; + } + // note: returns -1 on error, 0 (not found) or 1 (found) otherwise => error check for -1 or < 0 works + return found; +} + +static CYTHON_INLINE int __Pyx_PySet_Remove(PyObject *set, PyObject *key) { + int found = PySet_Discard(set, key); + if (unlikely(found != 1)) { + // note: returns -1 on error, 0 (not found) or 1 (found) otherwise => error check for -1 or < 0 works + return __Pyx_PySet_RemoveNotFound(set, key, found); + } + return 0; +} + + +/////////////// unicode_iter.proto /////////////// + +static CYTHON_INLINE int __Pyx_init_unicode_iteration( + PyObject* ustring, Py_ssize_t *length, void** data, int *kind); /* proto */ + +/////////////// unicode_iter /////////////// + +static CYTHON_INLINE int __Pyx_init_unicode_iteration( + PyObject* ustring, Py_ssize_t *length, void** data, int *kind) { +#if CYTHON_PEP393_ENABLED + if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return -1; + *kind = PyUnicode_KIND(ustring); + *length = PyUnicode_GET_LENGTH(ustring); + *data = PyUnicode_DATA(ustring); +#else + *kind = 0; + *length = PyUnicode_GET_SIZE(ustring); + *data = (void*)PyUnicode_AS_UNICODE(ustring); +#endif + return 0; +} + +/////////////// pyobject_as_double.proto /////////////// + +static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */ + +#if CYTHON_COMPILING_IN_PYPY +#define __Pyx_PyObject_AsDouble(obj) \ +(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) : \ + likely(PyInt_CheckExact(obj)) ? \ + PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj)) +#else +#define __Pyx_PyObject_AsDouble(obj) \ +((likely(PyFloat_CheckExact(obj))) ? \ + PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj)) +#endif + +/////////////// pyobject_as_double /////////////// + +static double __Pyx__PyObject_AsDouble(PyObject* obj) { + PyObject* float_value; +#if !CYTHON_USE_TYPE_SLOTS + float_value = PyNumber_Float(obj); if ((0)) goto bad; +#else + PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number; + if (likely(nb) && likely(nb->nb_float)) { + float_value = nb->nb_float(obj); + if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { + PyErr_Format(PyExc_TypeError, + "__float__ returned non-float (type %.200s)", + Py_TYPE(float_value)->tp_name); + Py_DECREF(float_value); + goto bad; + } + } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { +#if PY_MAJOR_VERSION >= 3 + float_value = PyFloat_FromString(obj); +#else + float_value = PyFloat_FromString(obj, 0); +#endif + } else { + PyObject* args = PyTuple_New(1); + if (unlikely(!args)) goto bad; + PyTuple_SET_ITEM(args, 0, obj); + float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0); + PyTuple_SET_ITEM(args, 0, 0); + Py_DECREF(args); + } +#endif + if (likely(float_value)) { + double value = PyFloat_AS_DOUBLE(float_value); + Py_DECREF(float_value); + return value; + } +bad: + return (double)-1; +} + + +/////////////// PyNumberPow2.proto /////////////// + +#define __Pyx_PyNumber_InPlacePowerOf2(a, b, c) __Pyx__PyNumber_PowerOf2(a, b, c, 1) +#define __Pyx_PyNumber_PowerOf2(a, b, c) __Pyx__PyNumber_PowerOf2(a, b, c, 0) + +static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject *none, int inplace); /*proto*/ + +/////////////// PyNumberPow2 /////////////// + +static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject *none, int inplace) { +// in CPython, 1<<N is substantially faster than 2**N +// see http://bugs.python.org/issue21420 +#if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t shiftby; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(exp))) { + shiftby = PyInt_AS_LONG(exp); + } else +#endif + if (likely(PyLong_CheckExact(exp))) { + #if CYTHON_USE_PYLONG_INTERNALS + const Py_ssize_t size = Py_SIZE(exp); + // tuned to optimise branch prediction + if (likely(size == 1)) { + shiftby = ((PyLongObject*)exp)->ob_digit[0]; + } else if (size == 0) { + return PyInt_FromLong(1L); + } else if (unlikely(size < 0)) { + goto fallback; + } else { + shiftby = PyLong_AsSsize_t(exp); + } + #else + shiftby = PyLong_AsSsize_t(exp); + #endif + } else { + goto fallback; + } + if (likely(shiftby >= 0)) { + if ((size_t)shiftby <= sizeof(long) * 8 - 2) { + long value = 1L << shiftby; + return PyInt_FromLong(value); +#ifdef HAVE_LONG_LONG + } else if ((size_t)shiftby <= sizeof(unsigned PY_LONG_LONG) * 8 - 1) { + unsigned PY_LONG_LONG value = ((unsigned PY_LONG_LONG)1) << shiftby; + return PyLong_FromUnsignedLongLong(value); +#endif + } else { + PyObject *result, *one = PyInt_FromLong(1L); + if (unlikely(!one)) return NULL; + result = PyNumber_Lshift(one, exp); + Py_DECREF(one); + return result; + } + } else if (shiftby == -1 && PyErr_Occurred()) { + PyErr_Clear(); + } +fallback: +#endif + return (inplace ? PyNumber_InPlacePower : PyNumber_Power)(two, exp, none); +} + + +/////////////// PyIntCompare.proto /////////////// + +{{py: c_ret_type = 'PyObject*' if ret_type.is_pyobject else 'int'}} +static CYTHON_INLINE {{c_ret_type}} __Pyx_PyInt_{{'' if ret_type.is_pyobject else 'Bool'}}{{op}}{{order}}(PyObject *op1, PyObject *op2, long intval, long inplace); /*proto*/ + +/////////////// PyIntCompare /////////////// + +{{py: pyval, ival = ('op2', 'b') if order == 'CObj' else ('op1', 'a') }} +{{py: c_ret_type = 'PyObject*' if ret_type.is_pyobject else 'int'}} +{{py: return_true = 'Py_RETURN_TRUE' if ret_type.is_pyobject else 'return 1'}} +{{py: return_false = 'Py_RETURN_FALSE' if ret_type.is_pyobject else 'return 0'}} +{{py: slot_name = op.lower() }} +{{py: c_op = {'Eq': '==', 'Ne': '!='}[op] }} +{{py: +return_compare = ( + (lambda a,b,c_op, return_true=return_true, return_false=return_false: "if ({a} {c_op} {b}) {return_true}; else {return_false};".format( + a=a, b=b, c_op=c_op, return_true=return_true, return_false=return_false)) + if ret_type.is_pyobject else + (lambda a,b,c_op: "return ({a} {c_op} {b});".format(a=a, b=b, c_op=c_op)) + ) +}} + +static CYTHON_INLINE {{c_ret_type}} __Pyx_PyInt_{{'' if ret_type.is_pyobject else 'Bool'}}{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) { + if (op1 == op2) { + {{return_true if op == 'Eq' else return_false}}; + } + + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact({{pyval}}))) { + const long {{'a' if order == 'CObj' else 'b'}} = intval; + long {{ival}} = PyInt_AS_LONG({{pyval}}); + {{return_compare('a', 'b', c_op)}} + } + #endif + + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact({{pyval}}))) { + int unequal; + unsigned long uintval; + Py_ssize_t size = Py_SIZE({{pyval}}); + const digit* digits = ((PyLongObject*){{pyval}})->ob_digit; + if (intval == 0) { + // == 0 => Py_SIZE(pyval) == 0 + {{return_compare('size', '0', c_op)}} + } else if (intval < 0) { + // < 0 => Py_SIZE(pyval) < 0 + if (size >= 0) + {{return_false if op == 'Eq' else return_true}}; + // both are negative => can use absolute values now. + intval = -intval; + size = -size; + } else { + // > 0 => Py_SIZE(pyval) > 0 + if (size <= 0) + {{return_false if op == 'Eq' else return_true}}; + } + // After checking that the sign is the same (and excluding 0), now compare the absolute values. + // When inlining, the C compiler should select exactly one line from this unrolled loop. + uintval = (unsigned long) intval; + {{for _size in range(4, 0, -1)}} +#if PyLong_SHIFT * {{_size}} < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * {{_size}})) { + // The C integer value is between (PyLong_BASE ** _size) and MIN(PyLong_BASE ** _size, LONG_MAX). + unequal = (size != {{_size+1}}) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + {{for _i in range(1, _size+1)}} | (digits[{{_i}}] != ((uintval >> ({{_i}} * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)){{endfor}}; + } else +#endif + {{endfor}} + unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); + + {{return_compare('unequal', '0', c_op)}} + } + #endif + + if (PyFloat_CheckExact({{pyval}})) { + const long {{'a' if order == 'CObj' else 'b'}} = intval; + double {{ival}} = PyFloat_AS_DOUBLE({{pyval}}); + {{return_compare('(double)a', '(double)b', c_op)}} + } + + return {{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}( + PyObject_RichCompare(op1, op2, Py_{{op.upper()}})); +} + + +/////////////// PyIntBinop.proto /////////////// + +{{py: c_ret_type = 'PyObject*' if ret_type.is_pyobject else 'int'}} +#if !CYTHON_COMPILING_IN_PYPY +static {{c_ret_type}} __Pyx_PyInt_{{'' if ret_type.is_pyobject else 'Bool'}}{{op}}{{order}}(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); /*proto*/ +#else +#define __Pyx_PyInt_{{'' if ret_type.is_pyobject else 'Bool'}}{{op}}{{order}}(op1, op2, intval, inplace, zerodivision_check) \ + {{if op in ('Eq', 'Ne')}}{{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}(PyObject_RichCompare(op1, op2, Py_{{op.upper()}})) + {{else}}(inplace ? PyNumber_InPlace{{op}}(op1, op2) : PyNumber_{{op}}(op1, op2)) + {{endif}} +#endif + +/////////////// PyIntBinop /////////////// + +#if !CYTHON_COMPILING_IN_PYPY +{{py: from Cython.Utility import pylong_join }} +{{py: pyval, ival = ('op2', 'b') if order == 'CObj' else ('op1', 'a') }} +{{py: c_ret_type = 'PyObject*' if ret_type.is_pyobject else 'int'}} +{{py: return_true = 'Py_RETURN_TRUE' if ret_type.is_pyobject else 'return 1'}} +{{py: return_false = 'Py_RETURN_FALSE' if ret_type.is_pyobject else 'return 0'}} +{{py: slot_name = {'TrueDivide': 'true_divide', 'FloorDivide': 'floor_divide'}.get(op, op.lower()) }} +{{py: cfunc_name = '__Pyx_PyInt_%s%s%s' % ('' if ret_type.is_pyobject else 'Bool', op, order)}} +{{py: zerodiv_check = lambda operand, _cfunc_name=cfunc_name: '%s_ZeroDivisionError(%s)' % (_cfunc_name, operand)}} +{{py: +c_op = { + 'Add': '+', 'Subtract': '-', 'Remainder': '%', 'TrueDivide': '/', 'FloorDivide': '/', + 'Or': '|', 'Xor': '^', 'And': '&', 'Rshift': '>>', 'Lshift': '<<', + 'Eq': '==', 'Ne': '!=', + }[op] +}} + +{{if op in ('TrueDivide', 'FloorDivide', 'Remainder')}} +#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS +#define {{zerodiv_check('operand')}} \ + if (unlikely(zerodivision_check && ((operand) == 0))) { \ + PyErr_SetString(PyExc_ZeroDivisionError, "integer division{{if op == 'Remainder'}} or modulo{{endif}} by zero"); \ + return NULL; \ + } +#endif +{{endif}} + +static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { + // Prevent "unused" warnings. + (void)inplace; + (void)zerodivision_check; + + {{if op in ('Eq', 'Ne')}} + if (op1 == op2) { + {{return_true if op == 'Eq' else return_false}}; + } + {{endif}} + + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact({{pyval}}))) { + const long {{'a' if order == 'CObj' else 'b'}} = intval; + {{if c_op in '+-%' or op == 'FloorDivide'}} + long x; + {{endif}} + long {{ival}} = PyInt_AS_LONG({{pyval}}); + + {{if op in ('Eq', 'Ne')}} + if (a {{c_op}} b) { + {{return_true}}; + } else { + {{return_false}}; + } + {{elif c_op in '+-'}} + // adapted from intobject.c in Py2.7: + // casts in the line below avoid undefined behaviour on overflow + x = (long)((unsigned long)a {{c_op}} b); + if (likely((x^a) >= 0 || (x^{{ '~' if op == 'Subtract' else '' }}b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_{{slot_name}}(op1, op2); + {{elif c_op == '%'}} + {{zerodiv_check('b')}} + // see ExprNodes.py :: mod_int_utility_code + x = a % b; + x += ((x != 0) & ((x ^ b) < 0)) * b; + return PyInt_FromLong(x); + {{elif op == 'TrueDivide'}} + {{zerodiv_check('b')}} + if (8 * sizeof(long) <= 53 || likely(labs({{ival}}) <= ((PY_LONG_LONG)1 << 53))) { + return PyFloat_FromDouble((double)a / (double)b); + } + // let Python do the rounding + return PyInt_Type.tp_as_number->nb_{{slot_name}}(op1, op2); + {{elif op == 'FloorDivide'}} + // INT_MIN / -1 is the only case that overflows, b == 0 is an error case + {{zerodiv_check('b')}} + if (unlikely(b == -1 && ((unsigned long)a) == 0-(unsigned long)a)) + return PyInt_Type.tp_as_number->nb_{{slot_name}}(op1, op2); + else { + long q, r; + // see ExprNodes.py :: div_int_utility_code + q = a / b; + r = a - q*b; + q -= ((r != 0) & ((r ^ b) < 0)); + x = q; + } + return PyInt_FromLong(x); + {{elif op == 'Lshift'}} + if (likely(b < (int)(sizeof(long)*8) && a == (a << b) >> b) || !a) { + return PyInt_FromLong(a {{c_op}} b); + } + {{else}} + // other operations are safe, no overflow + return PyInt_FromLong(a {{c_op}} b); + {{endif}} + } + #endif + + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact({{pyval}}))) { + const long {{'a' if order == 'CObj' else 'b'}} = intval; + long {{ival}}{{if op not in ('Eq', 'Ne')}}, x{{endif}}; + {{if op not in ('Eq', 'Ne', 'TrueDivide')}} +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG ll{{'a' if order == 'CObj' else 'b'}} = intval; + PY_LONG_LONG ll{{ival}}, llx; +#endif + {{endif}} + const digit* digits = ((PyLongObject*){{pyval}})->ob_digit; + const Py_ssize_t size = Py_SIZE({{pyval}}); + // handle most common case first to avoid indirect branch and optimise branch prediction + if (likely(__Pyx_sst_abs(size) <= 1)) { + {{ival}} = likely(size) ? digits[0] : 0; + if (size == -1) {{ival}} = -{{ival}}; + } else { + switch (size) { + {{for _size in range(2, 5)}} + {{for _case in (-_size, _size)}} + case {{_case}}: + if (8 * sizeof(long) - 1 > {{_size}} * PyLong_SHIFT{{if op == 'TrueDivide'}} && {{_size-1}} * PyLong_SHIFT < 53{{endif}}) { + {{ival}} = {{'-' if _case < 0 else ''}}(long) {{pylong_join(_size, 'digits')}}; + break; + {{if op not in ('Eq', 'Ne', 'TrueDivide')}} +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > {{_size}} * PyLong_SHIFT) { + ll{{ival}} = {{'-' if _case < 0 else ''}}(PY_LONG_LONG) {{pylong_join(_size, 'digits', 'unsigned PY_LONG_LONG')}}; + goto long_long; +#endif + {{endif}} + } + // if size doesn't fit into a long or PY_LONG_LONG anymore, fall through to default + CYTHON_FALLTHROUGH; + {{endfor}} + {{endfor}} + + {{if op in ('Eq', 'Ne')}} + #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15 + // unusual setup - your fault + default: return {{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}( + PyLong_Type.tp_richcompare({{'op1, op2' if order == 'ObjC' else 'op2, op1'}}, Py_{{op.upper()}})); + #else + // too large for the long values we allow => definitely not equal + default: {{return_false if op == 'Eq' else return_true}}; + #endif + {{else}} + default: return PyLong_Type.tp_as_number->nb_{{slot_name}}(op1, op2); + {{endif}} + } + } + {{if op in ('Eq', 'Ne')}} + if (a {{c_op}} b) { + {{return_true}}; + } else { + {{return_false}}; + } + {{else}} + {{if c_op == '%'}} + {{zerodiv_check('b')}} + // see ExprNodes.py :: mod_int_utility_code + x = a % b; + x += ((x != 0) & ((x ^ b) < 0)) * b; + {{elif op == 'TrueDivide'}} + {{zerodiv_check('b')}} + if ((8 * sizeof(long) <= 53 || likely(labs({{ival}}) <= ((PY_LONG_LONG)1 << 53))) + || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) { + return PyFloat_FromDouble((double)a / (double)b); + } + return PyLong_Type.tp_as_number->nb_{{slot_name}}(op1, op2); + {{elif op == 'FloorDivide'}} + {{zerodiv_check('b')}} + { + long q, r; + // see ExprNodes.py :: div_int_utility_code + q = a / b; + r = a - q*b; + q -= ((r != 0) & ((r ^ b) < 0)); + x = q; + } + {{else}} + x = a {{c_op}} b; + {{if op == 'Lshift'}} +#ifdef HAVE_LONG_LONG + if (unlikely(!(b < (int)(sizeof(long)*8) && a == x >> b)) && a) { + ll{{ival}} = {{ival}}; + goto long_long; + } +#else + if (likely(b < (int)(sizeof(long)*8) && a == x >> b) || !a) /* execute return statement below */ +#endif + {{endif}} + {{endif}} + return PyLong_FromLong(x); + + {{if op != 'TrueDivide'}} +#ifdef HAVE_LONG_LONG + long_long: + {{if c_op == '%'}} + // see ExprNodes.py :: mod_int_utility_code + llx = lla % llb; + llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb; + {{elif op == 'FloorDivide'}} + { + PY_LONG_LONG q, r; + // see ExprNodes.py :: div_int_utility_code + q = lla / llb; + r = lla - q*llb; + q -= ((r != 0) & ((r ^ llb) < 0)); + llx = q; + } + {{else}} + llx = lla {{c_op}} llb; + {{if op == 'Lshift'}} + if (likely(lla == llx >> llb)) /* then execute 'return' below */ + {{endif}} + {{endif}} + return PyLong_FromLongLong(llx); +#endif + {{endif}}{{# if op != 'TrueDivide' #}} + {{endif}}{{# if op in ('Eq', 'Ne') #}} + } + #endif + + {{if c_op in '+-' or op in ('TrueDivide', 'Eq', 'Ne')}} + if (PyFloat_CheckExact({{pyval}})) { + const long {{'a' if order == 'CObj' else 'b'}} = intval; + double {{ival}} = PyFloat_AS_DOUBLE({{pyval}}); + {{if op in ('Eq', 'Ne')}} + if ((double)a {{c_op}} (double)b) { + {{return_true}}; + } else { + {{return_false}}; + } + {{else}} + double result; + {{if op == 'TrueDivide'}} + if (unlikely(zerodivision_check && b == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero"); + return NULL; + } + {{endif}} + // copied from floatobject.c in Py3.5: +// PyFPE_START_PROTECT("{{op.lower() if not op.endswith('Divide') else 'divide'}}", return NULL) + result = ((double)a) {{c_op}} (double)b; +// PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + {{endif}} + } + {{endif}} + + {{if op in ('Eq', 'Ne')}} + return {{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}( + PyObject_RichCompare(op1, op2, Py_{{op.upper()}})); + {{else}} + return (inplace ? PyNumber_InPlace{{op}} : PyNumber_{{op}})(op1, op2); + {{endif}} +} +#endif + +/////////////// PyFloatBinop.proto /////////////// + +{{py: c_ret_type = 'PyObject*' if ret_type.is_pyobject else 'int'}} +#if !CYTHON_COMPILING_IN_PYPY +static {{c_ret_type}} __Pyx_PyFloat_{{'' if ret_type.is_pyobject else 'Bool'}}{{op}}{{order}}(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check); /*proto*/ +#else +#define __Pyx_PyFloat_{{'' if ret_type.is_pyobject else 'Bool'}}{{op}}{{order}}(op1, op2, floatval, inplace, zerodivision_check) \ + {{if op in ('Eq', 'Ne')}}{{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}(PyObject_RichCompare(op1, op2, Py_{{op.upper()}})) + {{elif op == 'Divide'}}((inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2))) + {{else}}(inplace ? PyNumber_InPlace{{op}}(op1, op2) : PyNumber_{{op}}(op1, op2)) + {{endif}} +#endif + +/////////////// PyFloatBinop /////////////// + +#if !CYTHON_COMPILING_IN_PYPY +{{py: from Cython.Utility import pylong_join }} +{{py: c_ret_type = 'PyObject*' if ret_type.is_pyobject else 'int'}} +{{py: return_true = 'Py_RETURN_TRUE' if ret_type.is_pyobject else 'return 1'}} +{{py: return_false = 'Py_RETURN_FALSE' if ret_type.is_pyobject else 'return 0'}} +{{py: pyval, fval = ('op2', 'b') if order == 'CObj' else ('op1', 'a') }} +{{py: cfunc_name = '__Pyx_PyFloat_%s%s%s' % ('' if ret_type.is_pyobject else 'Bool', op, order) }} +{{py: zerodiv_check = lambda operand, _cfunc_name=cfunc_name: '%s_ZeroDivisionError(%s)' % (_cfunc_name, operand)}} +{{py: +c_op = { + 'Add': '+', 'Subtract': '-', 'TrueDivide': '/', 'Divide': '/', 'Remainder': '%', + 'Eq': '==', 'Ne': '!=', + }[op] +}} + +{{if order == 'CObj' and c_op in '%/'}} +#define {{zerodiv_check('operand')}} if (unlikely(zerodivision_check && ((operand) == 0))) { \ + PyErr_SetString(PyExc_ZeroDivisionError, "float division{{if op == 'Remainder'}} or modulo{{endif}} by zero"); \ + return NULL; \ +} +{{endif}} + +static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) { + const double {{'a' if order == 'CObj' else 'b'}} = floatval; + double {{fval}}{{if op not in ('Eq', 'Ne')}}, result{{endif}}; + // Prevent "unused" warnings. + (void)inplace; + (void)zerodivision_check; + + {{if op in ('Eq', 'Ne')}} + if (op1 == op2) { + {{return_true if op == 'Eq' else return_false}}; + } + {{endif}} + + if (likely(PyFloat_CheckExact({{pyval}}))) { + {{fval}} = PyFloat_AS_DOUBLE({{pyval}}); + {{if order == 'CObj' and c_op in '%/'}}{{zerodiv_check(fval)}}{{endif}} + } else + + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact({{pyval}}))) { + {{fval}} = (double) PyInt_AS_LONG({{pyval}}); + {{if order == 'CObj' and c_op in '%/'}}{{zerodiv_check(fval)}}{{endif}} + } else + #endif + + if (likely(PyLong_CheckExact({{pyval}}))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*){{pyval}})->ob_digit; + const Py_ssize_t size = Py_SIZE({{pyval}}); + switch (size) { + case 0: {{if order == 'CObj' and c_op in '%/'}}{{zerodiv_check('0')}}{{else}}{{fval}} = 0.0;{{endif}} break; + case -1: {{fval}} = -(double) digits[0]; break; + case 1: {{fval}} = (double) digits[0]; break; + {{for _size in (2, 3, 4)}} + case -{{_size}}: + case {{_size}}: + if (8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || ({{_size-1}} * PyLong_SHIFT < 53))) { + {{fval}} = (double) {{pylong_join(_size, 'digits')}}; + // let CPython do its own float rounding from 2**53 on (max. consecutive integer in double float) + if ((8 * sizeof(unsigned long) < 53) || ({{_size}} * PyLong_SHIFT < 53) || ({{fval}} < (double) ((PY_LONG_LONG)1 << 53))) { + if (size == {{-_size}}) + {{fval}} = -{{fval}}; + break; + } + } + // Fall through if size doesn't fit safely into a double anymore. + // It may not be obvious that this is a safe fall-through given the "fval < 2**53" + // check above. However, the number of digits that CPython uses for a given PyLong + // value is minimal, and together with the "(size-1) * SHIFT < 53" check above, + // this should make it safe. + CYTHON_FALLTHROUGH; + {{endfor}} + default: + #else + { + #endif + {{if op in ('Eq', 'Ne')}} + return {{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}( + PyFloat_Type.tp_richcompare({{'op1, op2' if order == 'CObj' else 'op2, op1'}}, Py_{{op.upper()}})); + {{else}} + {{fval}} = PyLong_AsDouble({{pyval}}); + if (unlikely({{fval}} == -1.0 && PyErr_Occurred())) return NULL; + {{if order == 'CObj' and c_op in '%/'}}{{zerodiv_check(fval)}}{{endif}} + {{endif}} + } + } else { + {{if op in ('Eq', 'Ne')}} + return {{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}( + PyObject_RichCompare(op1, op2, Py_{{op.upper()}})); + {{elif op == 'Divide'}} + return (inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2)); + {{else}} + return (inplace ? PyNumber_InPlace{{op}} : PyNumber_{{op}})(op1, op2); + {{endif}} + } + + {{if op in ('Eq', 'Ne')}} + if (a {{c_op}} b) { + {{return_true}}; + } else { + {{return_false}}; + } + {{else}} + // copied from floatobject.c in Py3.5: + {{if order == 'CObj' and c_op in '%/'}}{{zerodiv_check('b')}}{{endif}} +// PyFPE_START_PROTECT("{{op.lower() if not op.endswith('Divide') else 'divide'}}", return NULL) + {{if c_op == '%'}} + result = fmod(a, b); + if (result) + result += ((result < 0) ^ (b < 0)) * b; + else + result = copysign(0.0, b); + {{else}} + result = a {{c_op}} b; + {{endif}} +// PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + {{endif}} +} +#endif diff --git a/contrib/tools/cython/Cython/Utility/Overflow.c b/contrib/tools/cython/Cython/Utility/Overflow.c new file mode 100644 index 00000000000..0259c58f010 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Overflow.c @@ -0,0 +1,311 @@ +/* +These functions provide integer arithmetic with integer checking. They do not +actually raise an exception when an overflow is detected, but rather set a bit +in the overflow parameter. (This parameter may be re-used across several +arithmetic operations, so should be or-ed rather than assigned to.) + +The implementation is divided into two parts, the signed and unsigned basecases, +which is where the magic happens, and a generic template matching a specific +type to an implementation based on its (c-compile-time) size and signedness. + +When possible, branching is avoided, and preference is given to speed over +accuracy (a low rate of falsely "detected" overflows are acceptable, +undetected overflows are not). + + +TODO: Hook up checking. +TODO: Conditionally support 128-bit with intmax_t? +*/ + +/////////////// Common.proto /////////////// + +static int __Pyx_check_twos_complement(void) { + if ((-1 != ~0)) { + PyErr_SetString(PyExc_RuntimeError, "Two's complement required for overflow checks."); + return 1; + } else if ((sizeof(short) == sizeof(int))) { + PyErr_SetString(PyExc_RuntimeError, "sizeof(short) < sizeof(int) required for overflow checks."); + return 1; + } else { + return 0; + } +} + +#define __PYX_IS_UNSIGNED(type) ((((type) -1) > 0)) +#define __PYX_SIGN_BIT(type) ((((unsigned type) 1) << (sizeof(type) * 8 - 1))) +#define __PYX_HALF_MAX(type) ((((type) 1) << (sizeof(type) * 8 - 2))) +#define __PYX_MIN(type) ((__PYX_IS_UNSIGNED(type) ? (type) 0 : 0 - __PYX_HALF_MAX(type) - __PYX_HALF_MAX(type))) +#define __PYX_MAX(type) ((~__PYX_MIN(type))) + +#define __Pyx_add_no_overflow(a, b, overflow) ((a) + (b)) +#define __Pyx_add_const_no_overflow(a, b, overflow) ((a) + (b)) +#define __Pyx_sub_no_overflow(a, b, overflow) ((a) - (b)) +#define __Pyx_sub_const_no_overflow(a, b, overflow) ((a) - (b)) +#define __Pyx_mul_no_overflow(a, b, overflow) ((a) * (b)) +#define __Pyx_mul_const_no_overflow(a, b, overflow) ((a) * (b)) +#define __Pyx_div_no_overflow(a, b, overflow) ((a) / (b)) +#define __Pyx_div_const_no_overflow(a, b, overflow) ((a) / (b)) + +/////////////// Common.init /////////////// +//@substitute: naming + +// FIXME: Propagate the error here instead of just printing it. +if (unlikely(__Pyx_check_twos_complement())) { + PyErr_WriteUnraisable($module_cname); +} + +/////////////// BaseCaseUnsigned.proto /////////////// + +static CYTHON_INLINE {{UINT}} __Pyx_add_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow); +static CYTHON_INLINE {{UINT}} __Pyx_sub_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow); +static CYTHON_INLINE {{UINT}} __Pyx_mul_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow); +static CYTHON_INLINE {{UINT}} __Pyx_div_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow); + +// Use these when b is known at compile time. +#define __Pyx_add_const_{{NAME}}_checking_overflow __Pyx_add_{{NAME}}_checking_overflow +#define __Pyx_sub_const_{{NAME}}_checking_overflow __Pyx_sub_{{NAME}}_checking_overflow +static CYTHON_INLINE {{UINT}} __Pyx_mul_const_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} constant, int *overflow); +#define __Pyx_div_const_{{NAME}}_checking_overflow __Pyx_div_{{NAME}}_checking_overflow + +/////////////// BaseCaseUnsigned /////////////// + +static CYTHON_INLINE {{UINT}} __Pyx_add_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow) { + {{UINT}} r = a + b; + *overflow |= r < a; + return r; +} + +static CYTHON_INLINE {{UINT}} __Pyx_sub_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow) { + {{UINT}} r = a - b; + *overflow |= r > a; + return r; +} + +static CYTHON_INLINE {{UINT}} __Pyx_mul_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow) { + if ((sizeof({{UINT}}) < sizeof(unsigned long))) { + unsigned long big_r = ((unsigned long) a) * ((unsigned long) b); + {{UINT}} r = ({{UINT}}) big_r; + *overflow |= big_r != r; + return r; +#ifdef HAVE_LONG_LONG + } else if ((sizeof({{UINT}}) < sizeof(unsigned PY_LONG_LONG))) { + unsigned PY_LONG_LONG big_r = ((unsigned PY_LONG_LONG) a) * ((unsigned PY_LONG_LONG) b); + {{UINT}} r = ({{UINT}}) big_r; + *overflow |= big_r != r; + return r; +#endif + } else { + {{UINT}} prod = a * b; + double dprod = ((double) a) * ((double) b); + // Overflow results in an error of at least 2^sizeof(UINT), + // whereas rounding represents an error on the order of 2^(sizeof(UINT)-53). + *overflow |= fabs(dprod - prod) > (__PYX_MAX({{UINT}}) / 2); + return prod; + } +} + +static CYTHON_INLINE {{UINT}} __Pyx_mul_const_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow) { + if (b > 1) { + *overflow |= a > __PYX_MAX({{UINT}}) / b; + } + return a * b; +} + + +static CYTHON_INLINE {{UINT}} __Pyx_div_{{NAME}}_checking_overflow({{UINT}} a, {{UINT}} b, int *overflow) { + if (b == 0) { + *overflow |= 1; + return 0; + } + return a / b; +} + + +/////////////// BaseCaseSigned.proto /////////////// + +static CYTHON_INLINE {{INT}} __Pyx_add_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow); +static CYTHON_INLINE {{INT}} __Pyx_sub_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow); +static CYTHON_INLINE {{INT}} __Pyx_mul_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow); +static CYTHON_INLINE {{INT}} __Pyx_div_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow); + + +// Use when b is known at compile time. +static CYTHON_INLINE {{INT}} __Pyx_add_const_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow); +static CYTHON_INLINE {{INT}} __Pyx_sub_const_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow); +static CYTHON_INLINE {{INT}} __Pyx_mul_const_{{NAME}}_checking_overflow({{INT}} a, {{INT}} constant, int *overflow); +#define __Pyx_div_const_{{NAME}}_checking_overflow __Pyx_div_{{NAME}}_checking_overflow + +/////////////// BaseCaseSigned /////////////// + +static CYTHON_INLINE {{INT}} __Pyx_add_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow) { + if ((sizeof({{INT}}) < sizeof(long))) { + long big_r = ((long) a) + ((long) b); + {{INT}} r = ({{INT}}) big_r; + *overflow |= big_r != r; + return r; +#ifdef HAVE_LONG_LONG + } else if ((sizeof({{INT}}) < sizeof(PY_LONG_LONG))) { + PY_LONG_LONG big_r = ((PY_LONG_LONG) a) + ((PY_LONG_LONG) b); + {{INT}} r = ({{INT}}) big_r; + *overflow |= big_r != r; + return r; +#endif + } else { + // Signed overflow undefined, but unsigned overflow is well defined. + {{INT}} r = ({{INT}}) ((unsigned {{INT}}) a + (unsigned {{INT}}) b); + // Overflow happened if the operands have the same sign, but the result + // has opposite sign. + // sign(a) == sign(b) != sign(r) + {{INT}} sign_a = __PYX_SIGN_BIT({{INT}}) & a; + {{INT}} sign_b = __PYX_SIGN_BIT({{INT}}) & b; + {{INT}} sign_r = __PYX_SIGN_BIT({{INT}}) & r; + *overflow |= (sign_a == sign_b) & (sign_a != sign_r); + return r; + } +} + +static CYTHON_INLINE {{INT}} __Pyx_add_const_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow) { + if (b > 0) { + *overflow |= a > __PYX_MAX({{INT}}) - b; + } else if (b < 0) { + *overflow |= a < __PYX_MIN({{INT}}) - b; + } + return a + b; +} + +static CYTHON_INLINE {{INT}} __Pyx_sub_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow) { + *overflow |= b == __PYX_MIN({{INT}}); + return __Pyx_add_{{NAME}}_checking_overflow(a, -b, overflow); +} + +static CYTHON_INLINE {{INT}} __Pyx_sub_const_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow) { + *overflow |= b == __PYX_MIN({{INT}}); + return __Pyx_add_const_{{NAME}}_checking_overflow(a, -b, overflow); +} + +static CYTHON_INLINE {{INT}} __Pyx_mul_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow) { + if ((sizeof({{INT}}) < sizeof(long))) { + long big_r = ((long) a) * ((long) b); + {{INT}} r = ({{INT}}) big_r; + *overflow |= big_r != r; + return ({{INT}}) r; +#ifdef HAVE_LONG_LONG + } else if ((sizeof({{INT}}) < sizeof(PY_LONG_LONG))) { + PY_LONG_LONG big_r = ((PY_LONG_LONG) a) * ((PY_LONG_LONG) b); + {{INT}} r = ({{INT}}) big_r; + *overflow |= big_r != r; + return ({{INT}}) r; +#endif + } else { + {{INT}} prod = a * b; + double dprod = ((double) a) * ((double) b); + // Overflow results in an error of at least 2^sizeof(INT), + // whereas rounding represents an error on the order of 2^(sizeof(INT)-53). + *overflow |= fabs(dprod - prod) > (__PYX_MAX({{INT}}) / 2); + return prod; + } +} + +static CYTHON_INLINE {{INT}} __Pyx_mul_const_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow) { + if (b > 1) { + *overflow |= a > __PYX_MAX({{INT}}) / b; + *overflow |= a < __PYX_MIN({{INT}}) / b; + } else if (b == -1) { + *overflow |= a == __PYX_MIN({{INT}}); + } else if (b < -1) { + *overflow |= a > __PYX_MIN({{INT}}) / b; + *overflow |= a < __PYX_MAX({{INT}}) / b; + } + return a * b; +} + +static CYTHON_INLINE {{INT}} __Pyx_div_{{NAME}}_checking_overflow({{INT}} a, {{INT}} b, int *overflow) { + if (b == 0) { + *overflow |= 1; + return 0; + } + *overflow |= (a == __PYX_MIN({{INT}})) & (b == -1); + return a / b; +} + + +/////////////// SizeCheck.init /////////////// +//@substitute: naming + +// FIXME: Propagate the error here instead of just printing it. +if (unlikely(__Pyx_check_sane_{{NAME}}())) { + PyErr_WriteUnraisable($module_cname); +} + +/////////////// SizeCheck.proto /////////////// + +static int __Pyx_check_sane_{{NAME}}(void) { + if (((sizeof({{TYPE}}) <= sizeof(int)) || +#ifdef HAVE_LONG_LONG + (sizeof({{TYPE}}) == sizeof(PY_LONG_LONG)) || +#endif + (sizeof({{TYPE}}) == sizeof(long)))) { + return 0; + } else { + PyErr_Format(PyExc_RuntimeError, \ + "Bad size for int type %.{{max(60, len(TYPE))}}s: %d", "{{TYPE}}", (int) sizeof({{TYPE}})); + return 1; + } +} + + +/////////////// Binop.proto /////////////// + +static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}} a, {{TYPE}} b, int *overflow); + +/////////////// Binop /////////////// + +static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}} a, {{TYPE}} b, int *overflow) { + if ((sizeof({{TYPE}}) < sizeof(int))) { + return __Pyx_{{BINOP}}_no_overflow(a, b, overflow); + } else if (__PYX_IS_UNSIGNED({{TYPE}})) { + if ((sizeof({{TYPE}}) == sizeof(unsigned int))) { + return ({{TYPE}}) __Pyx_{{BINOP}}_unsigned_int_checking_overflow(a, b, overflow); + } else if ((sizeof({{TYPE}}) == sizeof(unsigned long))) { + return ({{TYPE}}) __Pyx_{{BINOP}}_unsigned_long_checking_overflow(a, b, overflow); +#ifdef HAVE_LONG_LONG + } else if ((sizeof({{TYPE}}) == sizeof(unsigned PY_LONG_LONG))) { + return ({{TYPE}}) __Pyx_{{BINOP}}_unsigned_long_long_checking_overflow(a, b, overflow); +#endif + } else { + abort(); return 0; /* handled elsewhere */ + } + } else { + if ((sizeof({{TYPE}}) == sizeof(int))) { + return ({{TYPE}}) __Pyx_{{BINOP}}_int_checking_overflow(a, b, overflow); + } else if ((sizeof({{TYPE}}) == sizeof(long))) { + return ({{TYPE}}) __Pyx_{{BINOP}}_long_checking_overflow(a, b, overflow); +#ifdef HAVE_LONG_LONG + } else if ((sizeof({{TYPE}}) == sizeof(PY_LONG_LONG))) { + return ({{TYPE}}) __Pyx_{{BINOP}}_long_long_checking_overflow(a, b, overflow); +#endif + } else { + abort(); return 0; /* handled elsewhere */ + } + } +} + +/////////////// LeftShift.proto /////////////// + +static CYTHON_INLINE {{TYPE}} __Pyx_lshift_{{NAME}}_checking_overflow({{TYPE}} a, {{TYPE}} b, int *overflow) { + *overflow |= +#if {{SIGNED}} + (b < 0) | +#endif + (b > ({{TYPE}}) (8 * sizeof({{TYPE}}))) | (a > (__PYX_MAX({{TYPE}}) >> b)); + return a << b; +} +#define __Pyx_lshift_const_{{NAME}}_checking_overflow __Pyx_lshift_{{NAME}}_checking_overflow + + +/////////////// UnaryNegOverflows.proto /////////////// + +//FIXME: shouldn't the macro name be prefixed by "__Pyx_" ? Too late now, I guess... +// from intobject.c +#define UNARY_NEG_WOULD_OVERFLOW(x) \ + (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x))) diff --git a/contrib/tools/cython/Cython/Utility/Printing.c b/contrib/tools/cython/Cython/Utility/Printing.c new file mode 100644 index 00000000000..71aa7eafe95 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Printing.c @@ -0,0 +1,176 @@ +////////////////////// Print.proto ////////////////////// +//@substitute: naming + +static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/ +#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 +static PyObject* $print_function = 0; +static PyObject* $print_function_kwargs = 0; +#endif + +////////////////////// Print.cleanup ////////////////////// +//@substitute: naming + +#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 +Py_CLEAR($print_function); +Py_CLEAR($print_function_kwargs); +#endif + +////////////////////// Print ////////////////////// +//@substitute: naming + +#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject((char *)"stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} + +static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { + int i; + + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + Py_INCREF(f); + for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { + PyObject* v; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + goto error; + } + v = PyTuple_GET_ITEM(arg_tuple, i); + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + goto error; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + Py_ssize_t len = PyString_Size(v); + if (len > 0) { + // append soft-space if necessary (not using isspace() due to C/C++ problem on MacOS-X) + switch (s[len-1]) { + case ' ': break; + case '\f': case '\r': case '\n': case '\t': case '\v': + PyFile_SoftSpace(f, 0); + break; + default: break; + } + } + } + } + if (newline) { + if (PyFile_WriteString("\n", f) < 0) + goto error; + PyFile_SoftSpace(f, 0); + } + Py_DECREF(f); + return 0; +error: + Py_DECREF(f); + return -1; +} + +#else /* Python 3 has a print function */ + +static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { + PyObject* kwargs = 0; + PyObject* result = 0; + PyObject* end_string; + if (unlikely(!$print_function)) { + $print_function = PyObject_GetAttr($builtins_cname, PYIDENT("print")); + if (!$print_function) + return -1; + } + if (stream) { + kwargs = PyDict_New(); + if (unlikely(!kwargs)) + return -1; + if (unlikely(PyDict_SetItem(kwargs, PYIDENT("file"), stream) < 0)) + goto bad; + if (!newline) { + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + goto bad; + if (PyDict_SetItem(kwargs, PYIDENT("end"), end_string) < 0) { + Py_DECREF(end_string); + goto bad; + } + Py_DECREF(end_string); + } + } else if (!newline) { + if (unlikely(!$print_function_kwargs)) { + $print_function_kwargs = PyDict_New(); + if (unlikely(!$print_function_kwargs)) + return -1; + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + return -1; + if (PyDict_SetItem($print_function_kwargs, PYIDENT("end"), end_string) < 0) { + Py_DECREF(end_string); + return -1; + } + Py_DECREF(end_string); + } + kwargs = $print_function_kwargs; + } + result = PyObject_Call($print_function, arg_tuple, kwargs); + if (unlikely(kwargs) && (kwargs != $print_function_kwargs)) + Py_DECREF(kwargs); + if (!result) + return -1; + Py_DECREF(result); + return 0; +bad: + if (kwargs != $print_function_kwargs) + Py_XDECREF(kwargs); + return -1; +} +#endif + +////////////////////// PrintOne.proto ////////////////////// +//@requires: Print + +static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/ + +////////////////////// PrintOne ////////////////////// + +#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 + +static int __Pyx_PrintOne(PyObject* f, PyObject *o) { + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + Py_INCREF(f); + if (PyFile_SoftSpace(f, 0)) { + if (PyFile_WriteString(" ", f) < 0) + goto error; + } + if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) + goto error; + if (PyFile_WriteString("\n", f) < 0) + goto error; + Py_DECREF(f); + return 0; +error: + Py_DECREF(f); + return -1; + /* the line below is just to avoid C compiler + * warnings about unused functions */ + return __Pyx_Print(f, NULL, 0); +} + +#else /* Python 3 has a print function */ + +static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { + int res; + PyObject* arg_tuple = PyTuple_Pack(1, o); + if (unlikely(!arg_tuple)) + return -1; + res = __Pyx_Print(stream, arg_tuple, 1); + Py_DECREF(arg_tuple); + return res; +} + +#endif diff --git a/contrib/tools/cython/Cython/Utility/Profile.c b/contrib/tools/cython/Cython/Utility/Profile.c new file mode 100644 index 00000000000..662f9680400 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/Profile.c @@ -0,0 +1,384 @@ +/////////////// Profile.proto /////////////// +//@requires: Exceptions.c::PyErrFetchRestore +//@substitute: naming + +// Note that cPython ignores PyTrace_EXCEPTION, +// but maybe some other profilers don't. + +#ifndef CYTHON_PROFILE +#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON + #define CYTHON_PROFILE 0 +#else + #define CYTHON_PROFILE 1 +#endif +#endif + +#ifndef CYTHON_TRACE_NOGIL + #define CYTHON_TRACE_NOGIL 0 +#else + #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE) + #define CYTHON_TRACE 1 + #endif +#endif + +#ifndef CYTHON_TRACE + #define CYTHON_TRACE 0 +#endif + +#if CYTHON_TRACE + #undef CYTHON_PROFILE_REUSE_FRAME +#endif + +#ifndef CYTHON_PROFILE_REUSE_FRAME + #define CYTHON_PROFILE_REUSE_FRAME 0 +#endif + +#if CYTHON_PROFILE || CYTHON_TRACE + + #include "compile.h" + #include "frameobject.h" + #include "traceback.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif + + #if CYTHON_PROFILE_REUSE_FRAME + #define CYTHON_FRAME_MODIFIER static + #define CYTHON_FRAME_DEL(frame) + #else + #define CYTHON_FRAME_MODIFIER + #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame) + #endif + + #define __Pyx_TraceDeclarations \ + static PyCodeObject *$frame_code_cname = NULL; \ + CYTHON_FRAME_MODIFIER PyFrameObject *$frame_cname = NULL; \ + int __Pyx_use_tracing = 0; + + #define __Pyx_TraceFrameInit(codeobj) \ + if (codeobj) $frame_code_cname = (PyCodeObject*) codeobj; + +#if PY_VERSION_HEX >= 0x030b00a2 + #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ + (unlikely((tstate)->cframe->use_tracing) && \ + (!(check_tracing) || !(tstate)->tracing) && \ + (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc))) + + #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate) + + #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate) + +#elif PY_VERSION_HEX >= 0x030a00b1 + #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ + (unlikely((tstate)->cframe->use_tracing) && \ + (!(check_tracing) || !(tstate)->tracing) && \ + (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc))) + + #define __Pyx_EnterTracing(tstate) \ + do { tstate->tracing++; tstate->cframe->use_tracing = 0; } while (0) + + #define __Pyx_LeaveTracing(tstate) \ + do { \ + tstate->tracing--; \ + tstate->cframe->use_tracing = ((CYTHON_TRACE && tstate->c_tracefunc != NULL) \ + || tstate->c_profilefunc != NULL); \ + } while (0) + +#else + #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ + (unlikely((tstate)->use_tracing) && \ + (!(check_tracing) || !(tstate)->tracing) && \ + (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc))) + + #define __Pyx_EnterTracing(tstate) \ + do { tstate->tracing++; tstate->use_tracing = 0; } while (0) + + #define __Pyx_LeaveTracing(tstate) \ + do { \ + tstate->tracing--; \ + tstate->use_tracing = ((CYTHON_TRACE && tstate->c_tracefunc != NULL) \ + || tstate->c_profilefunc != NULL); \ + } while (0) + +#endif + + #ifdef WITH_THREAD + #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error) \ + if (nogil) { \ + if (CYTHON_TRACE_NOGIL) { \ + PyThreadState *tstate; \ + PyGILState_STATE state = PyGILState_Ensure(); \ + tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 1, 1)) { \ + __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&$frame_code_cname, &$frame_cname, tstate, funcname, srcfile, firstlineno); \ + } \ + PyGILState_Release(state); \ + if (unlikely(__Pyx_use_tracing < 0)) goto_error; \ + } \ + } else { \ + PyThreadState* tstate = PyThreadState_GET(); \ + if (__Pyx_IsTracing(tstate, 1, 1)) { \ + __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&$frame_code_cname, &$frame_cname, tstate, funcname, srcfile, firstlineno); \ + if (unlikely(__Pyx_use_tracing < 0)) goto_error; \ + } \ + } + #else + #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error) \ + { PyThreadState* tstate = PyThreadState_GET(); \ + if (__Pyx_IsTracing(tstate, 1, 1)) { \ + __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&$frame_code_cname, &$frame_cname, tstate, funcname, srcfile, firstlineno); \ + if (unlikely(__Pyx_use_tracing < 0)) goto_error; \ + } \ + } + #endif + + #define __Pyx_TraceException() \ + if (likely(!__Pyx_use_tracing)); else { \ + PyThreadState* tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 0, 1)) { \ + __Pyx_EnterTracing(tstate); \ + PyObject *exc_info = __Pyx_GetExceptionTuple(tstate); \ + if (exc_info) { \ + if (CYTHON_TRACE && tstate->c_tracefunc) \ + tstate->c_tracefunc( \ + tstate->c_traceobj, $frame_cname, PyTrace_EXCEPTION, exc_info); \ + tstate->c_profilefunc( \ + tstate->c_profileobj, $frame_cname, PyTrace_EXCEPTION, exc_info); \ + Py_DECREF(exc_info); \ + } \ + __Pyx_LeaveTracing(tstate); \ + } \ + } + + static void __Pyx_call_return_trace_func(PyThreadState *tstate, PyFrameObject *frame, PyObject *result) { + PyObject *type, *value, *traceback; + __Pyx_ErrFetchInState(tstate, &type, &value, &traceback); + __Pyx_EnterTracing(tstate); + if (CYTHON_TRACE && tstate->c_tracefunc) + tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_RETURN, result); + if (tstate->c_profilefunc) + tstate->c_profilefunc(tstate->c_profileobj, frame, PyTrace_RETURN, result); + CYTHON_FRAME_DEL(frame); + __Pyx_LeaveTracing(tstate); + __Pyx_ErrRestoreInState(tstate, type, value, traceback); + } + + #ifdef WITH_THREAD + #define __Pyx_TraceReturn(result, nogil) \ + if (likely(!__Pyx_use_tracing)); else { \ + if (nogil) { \ + if (CYTHON_TRACE_NOGIL) { \ + PyThreadState *tstate; \ + PyGILState_STATE state = PyGILState_Ensure(); \ + tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 0, 0)) { \ + __Pyx_call_return_trace_func(tstate, $frame_cname, (PyObject*)result); \ + } \ + PyGILState_Release(state); \ + } \ + } else { \ + PyThreadState* tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 0, 0)) { \ + __Pyx_call_return_trace_func(tstate, $frame_cname, (PyObject*)result); \ + } \ + } \ + } + #else + #define __Pyx_TraceReturn(result, nogil) \ + if (likely(!__Pyx_use_tracing)); else { \ + PyThreadState* tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 0, 0)) { \ + __Pyx_call_return_trace_func(tstate, $frame_cname, (PyObject*)result); \ + } \ + } + #endif + + static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno); /*proto*/ + static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, PyThreadState* tstate, const char *funcname, const char *srcfile, int firstlineno); /*proto*/ + +#else + + #define __Pyx_TraceDeclarations + #define __Pyx_TraceFrameInit(codeobj) + // mark error label as used to avoid compiler warnings + #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error) if ((1)); else goto_error; + #define __Pyx_TraceException() + #define __Pyx_TraceReturn(result, nogil) + +#endif /* CYTHON_PROFILE */ + +#if CYTHON_TRACE + // see call_trace_protected() in CPython's ceval.c + static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) { + int ret; + PyObject *type, *value, *traceback; + __Pyx_ErrFetchInState(tstate, &type, &value, &traceback); + __Pyx_PyFrame_SetLineNumber(frame, lineno); + __Pyx_EnterTracing(tstate); + + ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL); + + __Pyx_LeaveTracing(tstate); + if (likely(!ret)) { + __Pyx_ErrRestoreInState(tstate, type, value, traceback); + } else { + Py_XDECREF(type); + Py_XDECREF(value); + Py_XDECREF(traceback); + } + return ret; + } + + #ifdef WITH_THREAD + #define __Pyx_TraceLine(lineno, nogil, goto_error) \ + if (likely(!__Pyx_use_tracing)); else { \ + // mark error label as used to avoid compiler warnings \ + if ((1)); else goto_error; \ + if (nogil) { \ + if (CYTHON_TRACE_NOGIL) { \ + int ret = 0; \ + PyThreadState *tstate; \ + PyGILState_STATE state = PyGILState_Ensure(); \ + tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 0, 0) && tstate->c_tracefunc && $frame_cname->f_trace) { \ + ret = __Pyx_call_line_trace_func(tstate, $frame_cname, lineno); \ + } \ + PyGILState_Release(state); \ + // XXX https://github.com/cython/cython/issues/2274 \ + if (unlikely(ret)) { fprintf(stderr, "cython: line_trace_func returned %d\n", ret); } \ + } \ + } else { \ + PyThreadState* tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 0, 0) && tstate->c_tracefunc && $frame_cname->f_trace) { \ + int ret = __Pyx_call_line_trace_func(tstate, $frame_cname, lineno); \ + // XXX https://github.com/cython/cython/issues/2274 \ + if (unlikely(ret)) { fprintf(stderr, "cython: line_trace_func returned %d\n", ret); } \ + } \ + } \ + } + #else + #define __Pyx_TraceLine(lineno, nogil, goto_error) \ + if (likely(!__Pyx_use_tracing)); else { \ + // mark error label as used to avoid compiler warnings \ + if ((1)); else goto_error; \ + PyThreadState* tstate = __Pyx_PyThreadState_Current; \ + if (__Pyx_IsTracing(tstate, 0, 0) && tstate->c_tracefunc && $frame_cname->f_trace) { \ + int ret = __Pyx_call_line_trace_func(tstate, $frame_cname, lineno); \ + // XXX https://github.com/cython/cython/issues/2274 \ + if (unlikely(ret)) { fprintf(stderr, "cython: line_trace_func returned %d\n", ret); } \ + } \ + } + #endif +#else + // mark error label as used to avoid compiler warnings + #define __Pyx_TraceLine(lineno, nogil, goto_error) if ((1)); else goto_error; +#endif + +/////////////// Profile /////////////// +//@substitute: naming + +#if CYTHON_PROFILE + +static int __Pyx_TraceSetupAndCall(PyCodeObject** code, + PyFrameObject** frame, + PyThreadState* tstate, + const char *funcname, + const char *srcfile, + int firstlineno) { + PyObject *type, *value, *traceback; + int retval; + if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) { + if (*code == NULL) { + *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno); + if (*code == NULL) return 0; + } + *frame = PyFrame_New( + tstate, /*PyThreadState *tstate*/ + *code, /*PyCodeObject *code*/ + $moddict_cname, /*PyObject *globals*/ + 0 /*PyObject *locals*/ + ); + if (*frame == NULL) return 0; + if (CYTHON_TRACE && (*frame)->f_trace == NULL) { + // this enables "f_lineno" lookup, at least in CPython ... + Py_INCREF(Py_None); + (*frame)->f_trace = Py_None; + } +#if PY_VERSION_HEX < 0x030400B1 + } else { + (*frame)->f_tstate = tstate; +#endif + } + __Pyx_PyFrame_SetLineNumber(*frame, firstlineno); + + retval = 1; + __Pyx_EnterTracing(tstate); + __Pyx_ErrFetchInState(tstate, &type, &value, &traceback); + + #if CYTHON_TRACE + if (tstate->c_tracefunc) + retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0; + if (retval && tstate->c_profilefunc) + #endif + retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0; + + __Pyx_LeaveTracing(tstate); + if (retval) { + __Pyx_ErrRestoreInState(tstate, type, value, traceback); + return __Pyx_IsTracing(tstate, 0, 0) && retval; + } else { + Py_XDECREF(type); + Py_XDECREF(value); + Py_XDECREF(traceback); + return -1; + } +} + +static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) { + PyCodeObject *py_code = 0; + +#if PY_MAJOR_VERSION >= 3 + py_code = PyCode_NewEmpty(srcfile, funcname, firstlineno); + // make CPython use a fresh dict for "f_locals" at need (see GH #1836) + if (likely(py_code)) { + py_code->co_flags |= CO_OPTIMIZED | CO_NEWLOCALS; + } +#else + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + + py_funcname = PyString_FromString(funcname); + if (unlikely(!py_funcname)) goto bad; + py_srcfile = PyString_FromString(srcfile); + if (unlikely(!py_srcfile)) goto bad; + + py_code = PyCode_New( + 0, /*int argcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + // make CPython use a fresh dict for "f_locals" at need (see GH #1836) + CO_OPTIMIZED | CO_NEWLOCALS, /*int flags,*/ + $empty_bytes, /*PyObject *code,*/ + $empty_tuple, /*PyObject *consts,*/ + $empty_tuple, /*PyObject *names,*/ + $empty_tuple, /*PyObject *varnames,*/ + $empty_tuple, /*PyObject *freevars,*/ + $empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + firstlineno, /*int firstlineno,*/ + $empty_bytes /*PyObject *lnotab*/ + ); + +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); +#endif + + return py_code; +} + +#endif /* CYTHON_PROFILE */ diff --git a/contrib/tools/cython/Cython/Utility/StringTools.c b/contrib/tools/cython/Cython/Utility/StringTools.c new file mode 100644 index 00000000000..6810d31a6bb --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/StringTools.c @@ -0,0 +1,1195 @@ + +//////////////////// IncludeStringH.proto //////////////////// + +#include <string.h> + +//////////////////// IncludeCppStringH.proto //////////////////// + +#include <string> + +//////////////////// InitStrings.proto //////////////////// + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + +//////////////////// InitStrings //////////////////// + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else /* Python 3+ has unicode identifiers */ + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + // initialise cached hash value + if (PyObject_Hash(*t->p) == -1) + return -1; + ++t; + } + return 0; +} + +//////////////////// BytesContains.proto //////////////////// + +static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character); /*proto*/ + +//////////////////// BytesContains //////////////////// +//@requires: IncludeStringH + +static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) { + const Py_ssize_t length = PyBytes_GET_SIZE(bytes); + char* char_start = PyBytes_AS_STRING(bytes); + return memchr(char_start, (unsigned char)character, (size_t)length) != NULL; +} + + +//////////////////// PyUCS4InUnicode.proto //////////////////// + +static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character); /*proto*/ + +//////////////////// PyUCS4InUnicode //////////////////// + +#if PY_VERSION_HEX < 0x03090000 || (defined(PyUnicode_WCHAR_KIND) && defined(PyUnicode_AS_UNICODE)) + +#if PY_VERSION_HEX < 0x03090000 +#define __Pyx_PyUnicode_AS_UNICODE(op) PyUnicode_AS_UNICODE(op) +#define __Pyx_PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(op) +#else +// Avoid calling deprecated C-API functions in Py3.9+ that PEP-623 schedules for removal in Py3.12. +// https://www.python.org/dev/peps/pep-0623/ +#define __Pyx_PyUnicode_AS_UNICODE(op) (((PyASCIIObject *)(op))->wstr) +#define __Pyx_PyUnicode_GET_SIZE(op) ((PyCompactUnicodeObject *)(op))->wstr_length +#endif + +#if !defined(Py_UNICODE_SIZE) || Py_UNICODE_SIZE == 2 +static int __Pyx_PyUnicodeBufferContainsUCS4_SP(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) { + /* handle surrogate pairs for Py_UNICODE buffers in 16bit Unicode builds */ + Py_UNICODE high_val, low_val; + Py_UNICODE* pos; + high_val = (Py_UNICODE) (0xD800 | (((character - 0x10000) >> 10) & ((1<<10)-1))); + low_val = (Py_UNICODE) (0xDC00 | ( (character - 0x10000) & ((1<<10)-1))); + for (pos=buffer; pos < buffer+length-1; pos++) { + if (unlikely((high_val == pos[0]) & (low_val == pos[1]))) return 1; + } + return 0; +} +#endif + +static int __Pyx_PyUnicodeBufferContainsUCS4_BMP(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) { + Py_UNICODE uchar; + Py_UNICODE* pos; + uchar = (Py_UNICODE) character; + for (pos=buffer; pos < buffer+length; pos++) { + if (unlikely(uchar == pos[0])) return 1; + } + return 0; +} +#endif + +static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) { +#if CYTHON_PEP393_ENABLED + const int kind = PyUnicode_KIND(unicode); + #ifdef PyUnicode_WCHAR_KIND + if (likely(kind != PyUnicode_WCHAR_KIND)) + #endif + { + Py_ssize_t i; + const void* udata = PyUnicode_DATA(unicode); + const Py_ssize_t length = PyUnicode_GET_LENGTH(unicode); + for (i=0; i < length; i++) { + if (unlikely(character == PyUnicode_READ(kind, udata, i))) return 1; + } + return 0; + } +#elif PY_VERSION_HEX >= 0x03090000 + #error Cannot use "UChar in Unicode" in Python 3.9 without PEP-393 unicode strings. +#elif !defined(PyUnicode_AS_UNICODE) + #error Cannot use "UChar in Unicode" in Python < 3.9 without Py_UNICODE support. +#endif + +#if PY_VERSION_HEX < 0x03090000 || (defined(PyUnicode_WCHAR_KIND) && defined(PyUnicode_AS_UNICODE)) +#if !defined(Py_UNICODE_SIZE) || Py_UNICODE_SIZE == 2 + if ((sizeof(Py_UNICODE) == 2) && unlikely(character > 65535)) { + return __Pyx_PyUnicodeBufferContainsUCS4_SP( + __Pyx_PyUnicode_AS_UNICODE(unicode), + __Pyx_PyUnicode_GET_SIZE(unicode), + character); + } else +#endif + { + return __Pyx_PyUnicodeBufferContainsUCS4_BMP( + __Pyx_PyUnicode_AS_UNICODE(unicode), + __Pyx_PyUnicode_GET_SIZE(unicode), + character); + + } +#endif +} + + +//////////////////// PyUnicodeContains.proto //////////////////// + +static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) { + int result = PyUnicode_Contains(text, substring); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + + +//////////////////// CStringEquals.proto //////////////////// + +static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/ + +//////////////////// CStringEquals //////////////////// + +static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) { + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + return *s1 == *s2; +} + + +//////////////////// StrEquals.proto //////////////////// +//@requires: BytesEquals +//@requires: UnicodeEquals + +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals +#else +#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals +#endif + + +//////////////////// UnicodeEquals.proto //////////////////// + +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ + +//////////////////// UnicodeEquals //////////////////// +//@requires: BytesEquals + +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY + return PyObject_RichCompareBool(s1, s2, equals); +#else +#if PY_MAJOR_VERSION < 3 + PyObject* owned_ref = NULL; +#endif + int s1_is_unicode, s2_is_unicode; + if (s1 == s2) { + /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */ + goto return_eq; + } + s1_is_unicode = PyUnicode_CheckExact(s1); + s2_is_unicode = PyUnicode_CheckExact(s2); +#if PY_MAJOR_VERSION < 3 + if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { + owned_ref = PyUnicode_FromObject(s2); + if (unlikely(!owned_ref)) + return -1; + s2 = owned_ref; + s2_is_unicode = 1; + } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { + owned_ref = PyUnicode_FromObject(s1); + if (unlikely(!owned_ref)) + return -1; + s1 = owned_ref; + s1_is_unicode = 1; + } else if (((!s2_is_unicode) & (!s1_is_unicode))) { + return __Pyx_PyBytes_Equals(s1, s2, equals); + } +#endif + if (s1_is_unicode & s2_is_unicode) { + Py_ssize_t length; + int kind; + void *data1, *data2; + if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) + return -1; + length = __Pyx_PyUnicode_GET_LENGTH(s1); + if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { + goto return_ne; + } +#if CYTHON_USE_UNICODE_INTERNALS + { + Py_hash_t hash1, hash2; + #if CYTHON_PEP393_ENABLED + hash1 = ((PyASCIIObject*)s1)->hash; + hash2 = ((PyASCIIObject*)s2)->hash; + #else + hash1 = ((PyUnicodeObject*)s1)->hash; + hash2 = ((PyUnicodeObject*)s2)->hash; + #endif + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + goto return_ne; + } + } +#endif + // len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2") + kind = __Pyx_PyUnicode_KIND(s1); + if (kind != __Pyx_PyUnicode_KIND(s2)) { + goto return_ne; + } + data1 = __Pyx_PyUnicode_DATA(s1); + data2 = __Pyx_PyUnicode_DATA(s2); + if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { + goto return_ne; + } else if (length == 1) { + goto return_eq; + } else { + int result = memcmp(data1, data2, (size_t)(length * kind)); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & s2_is_unicode) { + goto return_ne; + } else if ((s2 == Py_None) & s1_is_unicode) { + goto return_ne; + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +return_eq: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ); +return_ne: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_NE); +#endif +} + + +//////////////////// BytesEquals.proto //////////////////// + +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ + +//////////////////// BytesEquals //////////////////// +//@requires: IncludeStringH + +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY + return PyObject_RichCompareBool(s1, s2, equals); +#else + if (s1 == s2) { + /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */ + return (equals == Py_EQ); + } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { + const char *ps1, *ps2; + Py_ssize_t length = PyBytes_GET_SIZE(s1); + if (length != PyBytes_GET_SIZE(s2)) + return (equals == Py_NE); + // len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2") + ps1 = PyBytes_AS_STRING(s1); + ps2 = PyBytes_AS_STRING(s2); + if (ps1[0] != ps2[0]) { + return (equals == Py_NE); + } else if (length == 1) { + return (equals == Py_EQ); + } else { + int result; +#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) + Py_hash_t hash1, hash2; + hash1 = ((PyBytesObject*)s1)->ob_shash; + hash2 = ((PyBytesObject*)s2)->ob_shash; + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + return (equals == Py_NE); + } +#endif + result = memcmp(ps1, ps2, (size_t)length); + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { + return (equals == Py_NE); + } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { + return (equals == Py_NE); + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +#endif +} + +//////////////////// GetItemIntByteArray.proto //////////////////// + +#define __Pyx_GetItemInt_ByteArray(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "bytearray index out of range"), -1)) + +static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, + int wraparound, int boundscheck); + +//////////////////// GetItemIntByteArray //////////////////// + +static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, + int wraparound, int boundscheck) { + Py_ssize_t length; + if (wraparound | boundscheck) { + length = PyByteArray_GET_SIZE(string); + if (wraparound & unlikely(i < 0)) i += length; + if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) { + return (unsigned char) (PyByteArray_AS_STRING(string)[i]); + } else { + PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); + return -1; + } + } else { + return (unsigned char) (PyByteArray_AS_STRING(string)[i]); + } +} + + +//////////////////// SetItemIntByteArray.proto //////////////////// + +#define __Pyx_SetItemInt_ByteArray(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_SetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, v, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "bytearray index out of range"), -1)) + +static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, unsigned char v, + int wraparound, int boundscheck); + +//////////////////// SetItemIntByteArray //////////////////// + +static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, unsigned char v, + int wraparound, int boundscheck) { + Py_ssize_t length; + if (wraparound | boundscheck) { + length = PyByteArray_GET_SIZE(string); + if (wraparound & unlikely(i < 0)) i += length; + if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) { + PyByteArray_AS_STRING(string)[i] = (char) v; + return 0; + } else { + PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); + return -1; + } + } else { + PyByteArray_AS_STRING(string)[i] = (char) v; + return 0; + } +} + + +//////////////////// GetItemIntUnicode.proto //////////////////// + +#define __Pyx_GetItemInt_Unicode(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_Unicode_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "string index out of range"), (Py_UCS4)-1)) + +static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i, + int wraparound, int boundscheck); + +//////////////////// GetItemIntUnicode //////////////////// + +static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i, + int wraparound, int boundscheck) { + Py_ssize_t length; + if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return (Py_UCS4)-1; + if (wraparound | boundscheck) { + length = __Pyx_PyUnicode_GET_LENGTH(ustring); + if (wraparound & unlikely(i < 0)) i += length; + if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) { + return __Pyx_PyUnicode_READ_CHAR(ustring, i); + } else { + PyErr_SetString(PyExc_IndexError, "string index out of range"); + return (Py_UCS4)-1; + } + } else { + return __Pyx_PyUnicode_READ_CHAR(ustring, i); + } +} + + +/////////////// decode_c_string_utf16.proto /////////////// + +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 0; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = -1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} + +/////////////// decode_cpp_string.proto /////////////// +//@requires: IncludeCppStringH +//@requires: decode_c_bytes + +static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string( + std::string_view cppstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + return __Pyx_decode_c_bytes( + cppstring.data(), cppstring.size(), start, stop, encoding, errors, decode_func); +} + +/////////////// decode_c_string.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + const char* cstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); + +/////////////// decode_c_string /////////////// +//@requires: IncludeStringH +//@requires: decode_c_string_utf16 +//@substitute: naming + +/* duplicate code to avoid calling strlen() if start >= 0 and stop >= 0 */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + const char* cstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + Py_ssize_t length; + if (unlikely((start < 0) | (stop < 0))) { + size_t slen = strlen(cstring); + if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) { + PyErr_SetString(PyExc_OverflowError, + "c-string too long to convert to Python"); + return NULL; + } + length = (Py_ssize_t) slen; + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + if (unlikely(stop <= start)) + return __Pyx_NewRef($empty_unicode); + length = stop - start; + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/////////////// decode_c_bytes.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); + +/////////////// decode_c_bytes /////////////// +//@requires: decode_c_string_utf16 +//@substitute: naming + +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + if (unlikely((start < 0) | (stop < 0))) { + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + if (stop > length) + stop = length; + if (unlikely(stop <= start)) + return __Pyx_NewRef($empty_unicode); + length = stop - start; + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/////////////// decode_bytes.proto /////////////// +//@requires: decode_c_bytes + +static CYTHON_INLINE PyObject* __Pyx_decode_bytes( + PyObject* string, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + return __Pyx_decode_c_bytes( + PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string), + start, stop, encoding, errors, decode_func); +} + +/////////////// decode_bytearray.proto /////////////// +//@requires: decode_c_bytes + +static CYTHON_INLINE PyObject* __Pyx_decode_bytearray( + PyObject* string, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + return __Pyx_decode_c_bytes( + PyByteArray_AS_STRING(string), PyByteArray_GET_SIZE(string), + start, stop, encoding, errors, decode_func); +} + +/////////////// PyUnicode_Substring.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring( + PyObject* text, Py_ssize_t start, Py_ssize_t stop); + +/////////////// PyUnicode_Substring /////////////// +//@substitute: naming + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring( + PyObject* text, Py_ssize_t start, Py_ssize_t stop) { + Py_ssize_t length; + if (unlikely(__Pyx_PyUnicode_READY(text) == -1)) return NULL; + length = __Pyx_PyUnicode_GET_LENGTH(text); + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + else if (stop > length) + stop = length; + if (stop <= start) + return __Pyx_NewRef($empty_unicode); +#if CYTHON_PEP393_ENABLED + return PyUnicode_FromKindAndData(PyUnicode_KIND(text), + PyUnicode_1BYTE_DATA(text) + start*PyUnicode_KIND(text), stop-start); +#else + return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(text)+start, stop-start); +#endif +} + + +/////////////// py_unicode_istitle.proto /////////////// + +// Py_UNICODE_ISTITLE() doesn't match unicode.istitle() as the latter +// additionally allows character that comply with Py_UNICODE_ISUPPER() + +#if PY_VERSION_HEX < 0x030200A2 +static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UNICODE uchar) +#else +static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar) +#endif +{ + return Py_UNICODE_ISTITLE(uchar) || Py_UNICODE_ISUPPER(uchar); +} + + +/////////////// unicode_tailmatch.proto /////////////// + +static int __Pyx_PyUnicode_Tailmatch( + PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/ + +/////////////// unicode_tailmatch /////////////// + +// Python's unicode.startswith() and unicode.endswith() support a +// tuple of prefixes/suffixes, whereas it's much more common to +// test for a single unicode string. + +static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings, + Py_ssize_t start, Py_ssize_t end, int direction) { + Py_ssize_t i, count = PyTuple_GET_SIZE(substrings); + for (i = 0; i < count; i++) { + Py_ssize_t result; +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i), + start, end, direction); +#else + PyObject* sub = PySequence_ITEM(substrings, i); + if (unlikely(!sub)) return -1; + result = PyUnicode_Tailmatch(s, sub, start, end, direction); + Py_DECREF(sub); +#endif + if (result) { + return (int) result; + } + } + return 0; +} + +static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr, + Py_ssize_t start, Py_ssize_t end, int direction) { + if (unlikely(PyTuple_Check(substr))) { + return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction); + } + return (int) PyUnicode_Tailmatch(s, substr, start, end, direction); +} + + +/////////////// bytes_tailmatch.proto /////////////// + +static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg, + Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/ +static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, + Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/ + +/////////////// bytes_tailmatch /////////////// + +static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg, + Py_ssize_t start, Py_ssize_t end, int direction) { + const char* self_ptr = PyBytes_AS_STRING(self); + Py_ssize_t self_len = PyBytes_GET_SIZE(self); + const char* sub_ptr; + Py_ssize_t sub_len; + int retval; + + Py_buffer view; + view.obj = NULL; + + if ( PyBytes_Check(arg) ) { + sub_ptr = PyBytes_AS_STRING(arg); + sub_len = PyBytes_GET_SIZE(arg); + } +#if PY_MAJOR_VERSION < 3 + // Python 2.x allows mixing unicode and str + else if ( PyUnicode_Check(arg) ) { + return (int) PyUnicode_Tailmatch(self, arg, start, end, direction); + } +#endif + else { + if (unlikely(PyObject_GetBuffer(self, &view, PyBUF_SIMPLE) == -1)) + return -1; + sub_ptr = (const char*) view.buf; + sub_len = view.len; + } + + if (end > self_len) + end = self_len; + else if (end < 0) + end += self_len; + if (end < 0) + end = 0; + if (start < 0) + start += self_len; + if (start < 0) + start = 0; + + if (direction > 0) { + /* endswith */ + if (end-sub_len > start) + start = end - sub_len; + } + + if (start + sub_len <= end) + retval = !memcmp(self_ptr+start, sub_ptr, (size_t)sub_len); + else + retval = 0; + + if (view.obj) + PyBuffer_Release(&view); + + return retval; +} + +static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings, + Py_ssize_t start, Py_ssize_t end, int direction) { + Py_ssize_t i, count = PyTuple_GET_SIZE(substrings); + for (i = 0; i < count; i++) { + int result; +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i), + start, end, direction); +#else + PyObject* sub = PySequence_ITEM(substrings, i); + if (unlikely(!sub)) return -1; + result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction); + Py_DECREF(sub); +#endif + if (result) { + return result; + } + } + return 0; +} + +static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, + Py_ssize_t start, Py_ssize_t end, int direction) { + if (unlikely(PyTuple_Check(substr))) { + return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction); + } + + return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction); +} + + +/////////////// str_tailmatch.proto /////////////// + +static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start, + Py_ssize_t end, int direction); /*proto*/ + +/////////////// str_tailmatch /////////////// +//@requires: bytes_tailmatch +//@requires: unicode_tailmatch + +static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start, + Py_ssize_t end, int direction) +{ + // We do not use a C compiler macro here to avoid "unused function" + // warnings for the *_Tailmatch() function that is not being used in + // the specific CPython version. The C compiler will generate the same + // code anyway, and will usually just remove the unused function. + if (PY_MAJOR_VERSION < 3) + return __Pyx_PyBytes_Tailmatch(self, arg, start, end, direction); + else + return __Pyx_PyUnicode_Tailmatch(self, arg, start, end, direction); +} + + +/////////////// bytes_index.proto /////////////// + +static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t index, int check_bounds); /*proto*/ + +/////////////// bytes_index /////////////// + +static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t index, int check_bounds) { + if (index < 0) + index += PyBytes_GET_SIZE(bytes); + if (check_bounds) { + Py_ssize_t size = PyBytes_GET_SIZE(bytes); + if (unlikely(!__Pyx_is_valid_index(index, size))) { + PyErr_SetString(PyExc_IndexError, "string index out of range"); + return (char) -1; + } + } + return PyBytes_AS_STRING(bytes)[index]; +} + + +//////////////////// StringJoin.proto //////////////////// + +#if PY_MAJOR_VERSION < 3 +#define __Pyx_PyString_Join __Pyx_PyBytes_Join +#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v)) +#else +#define __Pyx_PyString_Join PyUnicode_Join +#define __Pyx_PyBaseString_Join PyUnicode_Join +#endif + +#if CYTHON_COMPILING_IN_CPYTHON + #if PY_MAJOR_VERSION < 3 + #define __Pyx_PyBytes_Join _PyString_Join + #else + #define __Pyx_PyBytes_Join _PyBytes_Join + #endif +#else +static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); /*proto*/ +#endif + + +//////////////////// StringJoin //////////////////// + +#if !CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) { + return PyObject_CallMethodObjArgs(sep, PYIDENT("join"), values, NULL); +} +#endif + + +/////////////// JoinPyUnicode.proto /////////////// + +static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength, + Py_UCS4 max_char); + +/////////////// JoinPyUnicode /////////////// +//@requires: IncludeStringH +//@substitute: naming + +static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength, + CYTHON_UNUSED Py_UCS4 max_char) { +#if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + PyObject *result_uval; + int result_ukind; + Py_ssize_t i, char_pos; + void *result_udata; +#if CYTHON_PEP393_ENABLED + // Py 3.3+ (post PEP-393) + result_uval = PyUnicode_New(result_ulength, max_char); + if (unlikely(!result_uval)) return NULL; + result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND; + result_udata = PyUnicode_DATA(result_uval); +#else + // Py 2.x/3.2 (pre PEP-393) + result_uval = PyUnicode_FromUnicode(NULL, result_ulength); + if (unlikely(!result_uval)) return NULL; + result_ukind = sizeof(Py_UNICODE); + result_udata = PyUnicode_AS_UNICODE(result_uval); +#endif + + char_pos = 0; + for (i=0; i < value_count; i++) { + int ukind; + Py_ssize_t ulength; + void *udata; + PyObject *uval = PyTuple_GET_ITEM(value_tuple, i); + if (unlikely(__Pyx_PyUnicode_READY(uval))) + goto bad; + ulength = __Pyx_PyUnicode_GET_LENGTH(uval); + if (unlikely(!ulength)) + continue; + if (unlikely(char_pos + ulength < 0)) + goto overflow; + ukind = __Pyx_PyUnicode_KIND(uval); + udata = __Pyx_PyUnicode_DATA(uval); + if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) { + memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind)); + } else { + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters) + _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength); + #else + Py_ssize_t j; + for (j=0; j < ulength; j++) { + Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j); + __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar); + } + #endif + } + char_pos += ulength; + } + return result_uval; +overflow: + PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string"); +bad: + Py_DECREF(result_uval); + return NULL; +#else + // non-CPython fallback + result_ulength++; + value_count++; + return PyUnicode_Join($empty_unicode, value_tuple); +#endif +} + + +/////////////// BuildPyUnicode.proto /////////////// + +static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength, + int prepend_sign, char padding_char); + +/////////////// BuildPyUnicode /////////////// + +// Create a PyUnicode object from an ASCII char*, e.g. a formatted number. + +static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength, + int prepend_sign, char padding_char) { + PyObject *uval; + Py_ssize_t uoffset = ulength - clength; +#if CYTHON_USE_UNICODE_INTERNALS + Py_ssize_t i; +#if CYTHON_PEP393_ENABLED + // Py 3.3+ (post PEP-393) + void *udata; + uval = PyUnicode_New(ulength, 127); + if (unlikely(!uval)) return NULL; + udata = PyUnicode_DATA(uval); +#else + // Py 2.x/3.2 (pre PEP-393) + Py_UNICODE *udata; + uval = PyUnicode_FromUnicode(NULL, ulength); + if (unlikely(!uval)) return NULL; + udata = PyUnicode_AS_UNICODE(uval); +#endif + if (uoffset > 0) { + i = 0; + if (prepend_sign) { + __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-'); + i++; + } + for (; i < uoffset; i++) { + __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char); + } + } + for (i=0; i < clength; i++) { + __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]); + } + +#else + // non-CPython + { + PyObject *sign = NULL, *padding = NULL; + uval = NULL; + if (uoffset > 0) { + prepend_sign = !!prepend_sign; + if (uoffset > prepend_sign) { + padding = PyUnicode_FromOrdinal(padding_char); + if (likely(padding) && uoffset > prepend_sign + 1) { + PyObject *tmp; + PyObject *repeat = PyInt_FromSsize_t(uoffset - prepend_sign); + if (unlikely(!repeat)) goto done_or_error; + tmp = PyNumber_Multiply(padding, repeat); + Py_DECREF(repeat); + Py_DECREF(padding); + padding = tmp; + } + if (unlikely(!padding)) goto done_or_error; + } + if (prepend_sign) { + sign = PyUnicode_FromOrdinal('-'); + if (unlikely(!sign)) goto done_or_error; + } + } + + uval = PyUnicode_DecodeASCII(chars, clength, NULL); + if (likely(uval) && padding) { + PyObject *tmp = PyNumber_Add(padding, uval); + Py_DECREF(uval); + uval = tmp; + } + if (likely(uval) && sign) { + PyObject *tmp = PyNumber_Add(sign, uval); + Py_DECREF(uval); + uval = tmp; + } +done_or_error: + Py_XDECREF(padding); + Py_XDECREF(sign); + } +#endif + + return uval; +} + + +//////////////////// ByteArrayAppendObject.proto //////////////////// + +static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value); + +//////////////////// ByteArrayAppendObject //////////////////// +//@requires: ByteArrayAppend + +static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value) { + Py_ssize_t ival; +#if PY_MAJOR_VERSION < 3 + if (unlikely(PyString_Check(value))) { + if (unlikely(PyString_GET_SIZE(value) != 1)) { + PyErr_SetString(PyExc_ValueError, "string must be of size 1"); + return -1; + } + ival = (unsigned char) (PyString_AS_STRING(value)[0]); + } else +#endif +#if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(value)) && likely(Py_SIZE(value) == 1 || Py_SIZE(value) == 0)) { + if (Py_SIZE(value) == 0) { + ival = 0; + } else { + ival = ((PyLongObject*)value)->ob_digit[0]; + if (unlikely(ival > 255)) goto bad_range; + } + } else +#endif + { + // CPython calls PyNumber_Index() internally + ival = __Pyx_PyIndex_AsSsize_t(value); + if (unlikely(!__Pyx_is_valid_index(ival, 256))) { + if (ival == -1 && PyErr_Occurred()) + return -1; + goto bad_range; + } + } + return __Pyx_PyByteArray_Append(bytearray, ival); +bad_range: + PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); + return -1; +} + +//////////////////// ByteArrayAppend.proto //////////////////// + +static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value); + +//////////////////// ByteArrayAppend //////////////////// +//@requires: ObjectHandling.c::PyObjectCallMethod1 + +static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value) { + PyObject *pyval, *retval; +#if CYTHON_COMPILING_IN_CPYTHON + if (likely(__Pyx_is_valid_index(value, 256))) { + Py_ssize_t n = Py_SIZE(bytearray); + if (likely(n != PY_SSIZE_T_MAX)) { + if (unlikely(PyByteArray_Resize(bytearray, n + 1) < 0)) + return -1; + PyByteArray_AS_STRING(bytearray)[n] = value; + return 0; + } + } else { + PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); + return -1; + } +#endif + pyval = PyInt_FromLong(value); + if (unlikely(!pyval)) + return -1; + retval = __Pyx_PyObject_CallMethod1(bytearray, PYIDENT("append"), pyval); + Py_DECREF(pyval); + if (unlikely(!retval)) + return -1; + Py_DECREF(retval); + return 0; +} + + +//////////////////// PyObjectFormat.proto //////////////////// + +#if CYTHON_USE_UNICODE_WRITER +static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f); +#else +#define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f) +#endif + +//////////////////// PyObjectFormat //////////////////// + +#if CYTHON_USE_UNICODE_WRITER +static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) { + int ret; + _PyUnicodeWriter writer; + + if (likely(PyFloat_CheckExact(obj))) { + // copied from CPython 3.5 "float__format__()" in floatobject.c +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000 + _PyUnicodeWriter_Init(&writer, 0); +#else + _PyUnicodeWriter_Init(&writer); +#endif + ret = _PyFloat_FormatAdvancedWriter( + &writer, + obj, + format_spec, 0, PyUnicode_GET_LENGTH(format_spec)); + } else if (likely(PyLong_CheckExact(obj))) { + // copied from CPython 3.5 "long__format__()" in longobject.c +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000 + _PyUnicodeWriter_Init(&writer, 0); +#else + _PyUnicodeWriter_Init(&writer); +#endif + ret = _PyLong_FormatAdvancedWriter( + &writer, + obj, + format_spec, 0, PyUnicode_GET_LENGTH(format_spec)); + } else { + return PyObject_Format(obj, format_spec); + } + + if (unlikely(ret == -1)) { + _PyUnicodeWriter_Dealloc(&writer); + return NULL; + } + return _PyUnicodeWriter_Finish(&writer); +} +#endif + + +//////////////////// PyObjectFormatSimple.proto //////////////////// + +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyObject_FormatSimple(s, f) ( \ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \ + PyObject_Format(s, f)) +#elif PY_MAJOR_VERSION < 3 + // str is common in Py2, but formatting must return a Unicode string + #define __Pyx_PyObject_FormatSimple(s, f) ( \ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \ + likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") : \ + PyObject_Format(s, f)) +#elif CYTHON_USE_TYPE_SLOTS + // Py3 nicely returns unicode strings from str() which makes this quite efficient for builtin types + #define __Pyx_PyObject_FormatSimple(s, f) ( \ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \ + likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) : \ + likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) : \ + PyObject_Format(s, f)) +#else + #define __Pyx_PyObject_FormatSimple(s, f) ( \ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \ + PyObject_Format(s, f)) +#endif + + +//////////////////// PyObjectFormatAndDecref.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f); +static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f); + +//////////////////// PyObjectFormatAndDecref //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) { + if (unlikely(!s)) return NULL; + if (likely(PyUnicode_CheckExact(s))) return s; + #if PY_MAJOR_VERSION < 3 + // str is common in Py2, but formatting must return a Unicode string + if (likely(PyString_CheckExact(s))) { + PyObject *result = PyUnicode_FromEncodedObject(s, NULL, "strict"); + Py_DECREF(s); + return result; + } + #endif + return __Pyx_PyObject_FormatAndDecref(s, f); +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) { + PyObject *result = PyObject_Format(s, f); + Py_DECREF(s); + return result; +} + + +//////////////////// PyUnicode_Unicode.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);/*proto*/ + +//////////////////// PyUnicode_Unicode //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) { + if (unlikely(obj == Py_None)) + obj = PYUNICODE("None"); + return __Pyx_NewRef(obj); +} + + +//////////////////// PyObject_Unicode.proto //////////////////// + +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyObject_Unicode(obj) \ + (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj)) +#else +#define __Pyx_PyObject_Unicode(obj) \ + (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj)) +#endif diff --git a/contrib/tools/cython/Cython/Utility/TestCyUtilityLoader.pyx b/contrib/tools/cython/Cython/Utility/TestCyUtilityLoader.pyx new file mode 100644 index 00000000000..00e7a7681b8 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/TestCyUtilityLoader.pyx @@ -0,0 +1,8 @@ +########## TestCyUtilityLoader ########## +#@requires: OtherUtility + +test {{cy_loader}} impl + + +########## OtherUtility ########## +req {{cy_loader}} impl diff --git a/contrib/tools/cython/Cython/Utility/TestCythonScope.pyx b/contrib/tools/cython/Cython/Utility/TestCythonScope.pyx new file mode 100644 index 00000000000..f585be29832 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/TestCythonScope.pyx @@ -0,0 +1,64 @@ +########## TestClass ########## +# These utilities are for testing purposes + +cdef extern from *: + cdef object __pyx_test_dep(object) + +@cname('__pyx_TestClass') +cdef class TestClass(object): + cdef public int value + + def __init__(self, int value): + self.value = value + + def __str__(self): + return 'TestClass(%d)' % self.value + + cdef cdef_method(self, int value): + print 'Hello from cdef_method', value + + cpdef cpdef_method(self, int value): + print 'Hello from cpdef_method', value + + def def_method(self, int value): + print 'Hello from def_method', value + + @cname('cdef_cname') + cdef cdef_cname_method(self, int value): + print "Hello from cdef_cname_method", value + + @cname('cpdef_cname') + cpdef cpdef_cname_method(self, int value): + print "Hello from cpdef_cname_method", value + + @cname('def_cname') + def def_cname_method(self, int value): + print "Hello from def_cname_method", value + +@cname('__pyx_test_call_other_cy_util') +cdef test_call(obj): + print 'test_call' + __pyx_test_dep(obj) + +@cname('__pyx_TestClass_New') +cdef _testclass_new(int value): + return TestClass(value) + +########### TestDep ########## + +@cname('__pyx_test_dep') +cdef test_dep(obj): + print 'test_dep', obj + +########## TestScope ########## + +@cname('__pyx_testscope') +cdef object _testscope(int value): + return "hello from cython scope, value=%d" % value + +########## View.TestScope ########## + +@cname('__pyx_view_testscope') +cdef object _testscope(int value): + return "hello from cython.view scope, value=%d" % value + diff --git a/contrib/tools/cython/Cython/Utility/TestUtilityLoader.c b/contrib/tools/cython/Cython/Utility/TestUtilityLoader.c new file mode 100644 index 00000000000..595305f211b --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/TestUtilityLoader.c @@ -0,0 +1,12 @@ +////////// TestUtilityLoader.proto ////////// +test {{loader}} prototype + +////////// TestUtilityLoader ////////// +//@requires: OtherUtility +test {{loader}} impl + +////////// OtherUtility.proto ////////// +req {{loader}} proto + +////////// OtherUtility ////////// +req {{loader}} impl diff --git a/contrib/tools/cython/Cython/Utility/TypeConversion.c b/contrib/tools/cython/Cython/Utility/TypeConversion.c new file mode 100644 index 00000000000..7a7bf0f7999 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/TypeConversion.c @@ -0,0 +1,1017 @@ +/////////////// TypeConversions.proto /////////////// + +/* Type Conversion Predeclarations */ + +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) + +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ + (sizeof(type) < sizeof(Py_ssize_t)) || \ + (sizeof(type) > sizeof(Py_ssize_t) && \ + likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX) && \ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ + v == (type)PY_SSIZE_T_MIN))) || \ + (sizeof(type) == sizeof(Py_ssize_t) && \ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX))) ) + +static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { + // Optimisation from Section 14.2 "Bounds Checking" in + // https://www.agner.org/optimize/optimizing_cpp.pdf + // See https://bugs.python.org/issue28397 + // The cast to unsigned effectively tests for "0 <= i < limit". + return (size_t) i < (size_t) limit; +} + +// fast and unsafe abs(Py_ssize_t) that ignores the overflow for (-PY_SSIZE_T_MAX-1) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include <cstdlib> + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) + // abs() is defined for long, but 64-bits type on MSVC is long long. + // Use MS-specific _abs64 instead. + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + // gcc or clang on 64 bit windows. + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif + +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); + +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); + +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif + +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) + +// There used to be a Py_UNICODE_strlen() in CPython 3.x, but it is deprecated since Py3.3. +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} + +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode + +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); + +#define __Pyx_PySequence_Tuple(obj) \ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) + +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); + +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) + +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) + +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif + +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) + +// __PYX_DEFAULT_STRING_ENCODING is either a user provided string constant +// or we need to look it up here +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; + +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + +/////////////// TypeConversions /////////////// + +/* Type Conversion Functions */ + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} + +// Py3.7 returns a "const char*" for unicode strings +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} + +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + // borrowed reference, cached internally in 'o' by CPython + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + // raise the error + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} + +#else /* CYTHON_PEP393_ENABLED: */ + +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (likely(PyUnicode_IS_ASCII(o))) { + // cached for the lifetime of the object + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + // raise the error + PyUnicode_AsASCIIString(o); + return NULL; + } +#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ + return PyUnicode_AsUTF8AndSize(o, length); +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ +} +#endif /* CYTHON_PEP393_ENABLED */ +#endif + +// Py3.7 returns a "const char*" for unicode strings +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); + } else +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ + +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} + +/* Note: __Pyx_PyObject_IsTrue is written to minimize branching. */ +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} + +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { + int retval; + if (unlikely(!x)) return -1; + retval = __Pyx_PyObject_IsTrue(x); + Py_DECREF(x); + return retval; +} + +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + // CPython issue #17576: warn if 'result' not of exact type int. + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} + +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x) || PyLong_Check(x))) +#else + if (likely(PyLong_Check(x))) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = m->nb_int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = m->nb_long(x); + } + #else + if (likely(m && m->nb_int)) { + name = "int"; + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } +#endif + if (likely(res)) { +#if PY_MAJOR_VERSION < 3 + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { +#else + if (unlikely(!PyLong_CheckExact(res))) { +#endif + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} + +{{py: from Cython.Utility import pylong_join }} + +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(b); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + // handle most common case first to avoid indirect branch and optimise branch prediction + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + {{for _size in (2, 3, 4)}} + {{for _case in (_size, -_size)}} + case {{_case}}: + if (8 * sizeof(Py_ssize_t) > {{_size}} * PyLong_SHIFT) { + return {{'-' if _case < 0 else ''}}(Py_ssize_t) {{pylong_join(_size, 'digits', 'size_t')}}; + } + break; + {{endfor}} + {{endfor}} + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} + + +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { + if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { + return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); +#if PY_MAJOR_VERSION < 3 + } else if (likely(PyInt_CheckExact(o))) { + return PyInt_AS_LONG(o); +#endif + } else { + Py_ssize_t ival; + PyObject *x; + x = PyNumber_Index(o); + if (!x) return -1; + ival = PyInt_AsLong(x); + Py_DECREF(x); + return ival; + } +} + + +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} + + +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +/////////////// GCCDiagnostics.proto /////////////// + +// GCC diagnostic pragmas were introduced in GCC 4.6 +// Used to silence conversion warnings that are ok but cannot be avoided. +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define __Pyx_HAS_GCC_DIAGNOSTIC +#endif + + +/////////////// ToPyCTupleUtility.proto /////////////// +static PyObject* {{funcname}}({{struct_type_decl}}); + +/////////////// ToPyCTupleUtility /////////////// +static PyObject* {{funcname}}({{struct_type_decl}} value) { + PyObject* item = NULL; + PyObject* result = PyTuple_New({{size}}); + if (!result) goto bad; + + {{for ix, component in enumerate(components):}} + {{py:attr = "value.f%s" % ix}} + item = {{component.to_py_function}}({{attr}}); + if (!item) goto bad; + PyTuple_SET_ITEM(result, {{ix}}, item); + {{endfor}} + + return result; +bad: + Py_XDECREF(item); + Py_XDECREF(result); + return NULL; +} + + +/////////////// FromPyCTupleUtility.proto /////////////// +static {{struct_type_decl}} {{funcname}}(PyObject *); + +/////////////// FromPyCTupleUtility /////////////// +static {{struct_type_decl}} {{funcname}}(PyObject * o) { + {{struct_type_decl}} result; + + if (!PyTuple_Check(o) || PyTuple_GET_SIZE(o) != {{size}}) { + PyErr_Format(PyExc_TypeError, "Expected %.16s of size %d, got %.200s", "a tuple", {{size}}, Py_TYPE(o)->tp_name); + goto bad; + } + +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + {{for ix, component in enumerate(components):}} + {{py:attr = "result.f%s" % ix}} + {{attr}} = {{component.from_py_function}}(PyTuple_GET_ITEM(o, {{ix}})); + if ({{component.error_condition(attr)}}) goto bad; + {{endfor}} +#else + { + PyObject *item; + {{for ix, component in enumerate(components):}} + {{py:attr = "result.f%s" % ix}} + item = PySequence_ITEM(o, {{ix}}); if (unlikely(!item)) goto bad; + {{attr}} = {{component.from_py_function}}(item); + Py_DECREF(item); + if ({{component.error_condition(attr)}}) goto bad; + {{endfor}} + } +#endif + + return result; +bad: + return result; +} + + +/////////////// UnicodeAsUCS4.proto /////////////// + +static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*); + +/////////////// UnicodeAsUCS4 /////////////// + +static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) { + Py_ssize_t length; + #if CYTHON_PEP393_ENABLED + length = PyUnicode_GET_LENGTH(x); + if (likely(length == 1)) { + return PyUnicode_READ_CHAR(x, 0); + } + #else + length = PyUnicode_GET_SIZE(x); + if (likely(length == 1)) { + return PyUnicode_AS_UNICODE(x)[0]; + } + #if Py_UNICODE_SIZE == 2 + else if (PyUnicode_GET_SIZE(x) == 2) { + Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0]; + if (high_val >= 0xD800 && high_val <= 0xDBFF) { + Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1]; + if (low_val >= 0xDC00 && low_val <= 0xDFFF) { + return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1))); + } + } + } + #endif + #endif + PyErr_Format(PyExc_ValueError, + "only single character unicode strings can be converted to Py_UCS4, " + "got length %" CYTHON_FORMAT_SSIZE_T "d", length); + return (Py_UCS4)-1; +} + + +/////////////// ObjectAsUCS4.proto /////////////// +//@requires: UnicodeAsUCS4 + +#define __Pyx_PyObject_AsPy_UCS4(x) \ + (likely(PyUnicode_Check(x)) ? __Pyx_PyUnicode_AsPy_UCS4(x) : __Pyx__PyObject_AsPy_UCS4(x)) +static Py_UCS4 __Pyx__PyObject_AsPy_UCS4(PyObject*); + +/////////////// ObjectAsUCS4 /////////////// + +static Py_UCS4 __Pyx__PyObject_AsPy_UCS4_raise_error(long ival) { + if (ival < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "cannot convert negative value to Py_UCS4"); + } else { + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to Py_UCS4"); + } + return (Py_UCS4)-1; +} + +static Py_UCS4 __Pyx__PyObject_AsPy_UCS4(PyObject* x) { + long ival; + ival = __Pyx_PyInt_As_long(x); + if (unlikely(!__Pyx_is_valid_index(ival, 1114111 + 1))) { + return __Pyx__PyObject_AsPy_UCS4_raise_error(ival); + } + return (Py_UCS4)ival; +} + + +/////////////// ObjectAsPyUnicode.proto /////////////// + +static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject*); + +/////////////// ObjectAsPyUnicode /////////////// + +static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) { + long ival; + #if CYTHON_PEP393_ENABLED + #if Py_UNICODE_SIZE > 2 + const long maxval = 1114111; + #else + const long maxval = 65535; + #endif + #else + static long maxval = 0; + #endif + if (PyUnicode_Check(x)) { + if (unlikely(__Pyx_PyUnicode_GET_LENGTH(x) != 1)) { + PyErr_Format(PyExc_ValueError, + "only single character unicode strings can be converted to Py_UNICODE, " + "got length %" CYTHON_FORMAT_SSIZE_T "d", __Pyx_PyUnicode_GET_LENGTH(x)); + return (Py_UNICODE)-1; + } + #if CYTHON_PEP393_ENABLED + ival = PyUnicode_READ_CHAR(x, 0); + #else + return PyUnicode_AS_UNICODE(x)[0]; + #endif + } else { + #if !CYTHON_PEP393_ENABLED + if (unlikely(!maxval)) + maxval = (long)PyUnicode_GetMax(); + #endif + ival = __Pyx_PyInt_As_long(x); + } + if (unlikely(!__Pyx_is_valid_index(ival, maxval + 1))) { + if (ival < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "cannot convert negative value to Py_UNICODE"); + return (Py_UNICODE)-1; + } else { + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to Py_UNICODE"); + } + return (Py_UNICODE)-1; + } + return (Py_UNICODE)ival; +} + + +/////////////// CIntToPy.proto /////////////// + +static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value); + +/////////////// CIntToPy /////////////// +//@requires: GCCDiagnostics + +static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const {{TYPE}} neg_one = ({{TYPE}}) -1, const_zero = ({{TYPE}}) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof({{TYPE}}) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof({{TYPE}}) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof({{TYPE}}) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof({{TYPE}}) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof({{TYPE}}) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof({{TYPE}}), + little, !is_unsigned); + } +} + + +/////////////// CIntToDigits /////////////// + +static const char DIGIT_PAIRS_10[2*10*10+1] = { + "00010203040506070809" + "10111213141516171819" + "20212223242526272829" + "30313233343536373839" + "40414243444546474849" + "50515253545556575859" + "60616263646566676869" + "70717273747576777879" + "80818283848586878889" + "90919293949596979899" +}; + +static const char DIGIT_PAIRS_8[2*8*8+1] = { + "0001020304050607" + "1011121314151617" + "2021222324252627" + "3031323334353637" + "4041424344454647" + "5051525354555657" + "6061626364656667" + "7071727374757677" +}; + +static const char DIGITS_HEX[2*16+1] = { + "0123456789abcdef" + "0123456789ABCDEF" +}; + + +/////////////// CIntToPyUnicode.proto /////////////// + +static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t width, char padding_char, char format_char); + +/////////////// CIntToPyUnicode /////////////// +//@requires: StringTools.c::IncludeStringH +//@requires: StringTools.c::BuildPyUnicode +//@requires: CIntToDigits +//@requires: GCCDiagnostics + +// NOTE: inlining because most arguments are constant, which collapses lots of code below + +static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t width, char padding_char, char format_char) { + // simple and conservative C string allocation on the stack: each byte gives at most 3 digits, plus sign + char digits[sizeof({{TYPE}})*3+2]; + // 'dpos' points to end of digits array + 1 initially to allow for pre-decrement looping + char *dpos, *end = digits + sizeof({{TYPE}})*3+2; + const char *hex_digits = DIGITS_HEX; + Py_ssize_t length, ulength; + int prepend_sign, last_one_off; + {{TYPE}} remaining; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const {{TYPE}} neg_one = ({{TYPE}}) -1, const_zero = ({{TYPE}}) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + + if (format_char == 'X') { + hex_digits += 16; + format_char = 'x'; + } + + // surprise: even trivial sprintf() calls don't get optimised in gcc (4.8) + remaining = value; /* not using abs(value) to avoid overflow problems */ + last_one_off = 0; + dpos = end; + do { + int digit_pos; + switch (format_char) { + case 'o': + digit_pos = abs((int)(remaining % (8*8))); + remaining = ({{TYPE}}) (remaining / (8*8)); + dpos -= 2; + memcpy(dpos, DIGIT_PAIRS_8 + digit_pos * 2, 2); /* copy 2 digits at a time, unaligned */ + last_one_off = (digit_pos < 8); + break; + case 'd': + digit_pos = abs((int)(remaining % (10*10))); + remaining = ({{TYPE}}) (remaining / (10*10)); + dpos -= 2; + memcpy(dpos, DIGIT_PAIRS_10 + digit_pos * 2, 2); /* copy 2 digits at a time, unaligned */ + last_one_off = (digit_pos < 10); + break; + case 'x': + *(--dpos) = hex_digits[abs((int)(remaining % 16))]; + remaining = ({{TYPE}}) (remaining / 16); + break; + default: + assert(0); + break; + } + } while (unlikely(remaining != 0)); + + if (last_one_off) { + assert(*dpos == '0'); + dpos++; + } + length = end - dpos; + ulength = length; + prepend_sign = 0; + if (!is_unsigned && value <= neg_one) { + if (padding_char == ' ' || width <= length + 1) { + *(--dpos) = '-'; + ++length; + } else { + prepend_sign = 1; + } + ++ulength; + } + if (width > ulength) { + ulength = width; + } + // single character unicode strings are cached in CPython => use PyUnicode_FromOrdinal() for them + if (ulength == 1) { + return PyUnicode_FromOrdinal(*dpos); + } + return __Pyx_PyUnicode_BuildFromAscii(ulength, dpos, (int) length, prepend_sign, padding_char); +} + + +/////////////// CBIntToPyUnicode.proto /////////////// + +#define {{TO_PY_FUNCTION}}(value) \ + ((value) ? __Pyx_NewRef({{TRUE_CONST}}) : __Pyx_NewRef({{FALSE_CONST}})) + + +/////////////// PyIntFromDouble.proto /////////////// + +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value); +#else +#define __Pyx_PyInt_FromDouble(value) PyLong_FromDouble(value) +#endif + +/////////////// PyIntFromDouble /////////////// + +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value) { + if (value >= (double)LONG_MIN && value <= (double)LONG_MAX) { + return PyInt_FromLong((long)value); + } + return PyLong_FromDouble(value); +} +#endif + + +/////////////// CIntFromPyVerify /////////////// + +// see CIntFromPy +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value) \ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) + +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value) \ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) + +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc) \ + { \ + func_type value = func_value; \ + if (sizeof(target_type) < sizeof(func_type)) { \ + if (unlikely(value != (func_type) (target_type) value)) { \ + func_type zero = 0; \ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred())) \ + return (target_type) -1; \ + if (is_unsigned && unlikely(value < zero)) \ + goto raise_neg_overflow; \ + else \ + goto raise_overflow; \ + } \ + } \ + return (target_type) value; \ + } + + +/////////////// CIntFromPy.proto /////////////// + +static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *); + +/////////////// CIntFromPy /////////////// +//@requires: CIntFromPyVerify +//@requires: GCCDiagnostics + +{{py: from Cython.Utility import pylong_join }} + +static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const {{TYPE}} neg_one = ({{TYPE}}) -1, const_zero = ({{TYPE}}) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof({{TYPE}}) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT({{TYPE}}, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return ({{TYPE}}) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return ({{TYPE}}) 0; + case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, digits[0]) + {{for _size in (2, 3, 4)}} + case {{_size}}: + if (8 * sizeof({{TYPE}}) > {{_size-1}} * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long, {{pylong_join(_size, 'digits')}}) + } else if (8 * sizeof({{TYPE}}) >= {{_size}} * PyLong_SHIFT) { + return ({{TYPE}}) {{pylong_join(_size, 'digits', TYPE)}}; + } + } + break; + {{endfor}} + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + // misuse Py_False as a quick way to compare to a '0' int object in PyPy + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return ({{TYPE}}) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof({{TYPE}}) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC({{TYPE}}, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof({{TYPE}}) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC({{TYPE}}, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { + // signed +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return ({{TYPE}}) 0; + case -1: __PYX_VERIFY_RETURN_INT({{TYPE}}, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, +digits[0]) + {{for _size in (2, 3, 4)}} + {{for _case in (-_size, _size)}} + case {{_case}}: + if (8 * sizeof({{TYPE}}){{' - 1' if _case < 0 else ''}} > {{_size-1}} * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT({{TYPE}}, {{'long' if _case < 0 else 'unsigned long'}}, {{'-(long) ' if _case < 0 else ''}}{{pylong_join(_size, 'digits')}}) + } else if (8 * sizeof({{TYPE}}) - 1 > {{_size}} * PyLong_SHIFT) { + return ({{TYPE}}) ({{'((%s)-1)*' % TYPE if _case < 0 else ''}}{{pylong_join(_size, 'digits', TYPE)}}); + } + } + break; + {{endfor}} + {{endfor}} + } +#endif + if (sizeof({{TYPE}}) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC({{TYPE}}, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof({{TYPE}}) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC({{TYPE}}, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + {{TYPE}} val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return ({{TYPE}}) -1; + } + } else { + {{TYPE}} val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return ({{TYPE}}) -1; + val = {{FROM_PY_FUNCTION}}(tmp); + Py_DECREF(tmp); + return val; + } + +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to {{TYPE}}"); + return ({{TYPE}}) -1; + +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to {{TYPE}}"); + return ({{TYPE}}) -1; +} diff --git a/contrib/tools/cython/Cython/Utility/__init__.py b/contrib/tools/cython/Cython/Utility/__init__.py new file mode 100644 index 00000000000..73ccc1e2cba --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/__init__.py @@ -0,0 +1,29 @@ + +def pylong_join(count, digits_ptr='digits', join_type='unsigned long'): + """ + Generate an unrolled shift-then-or loop over the first 'count' digits. + Assumes that they fit into 'join_type'. + + (((d[2] << n) | d[1]) << n) | d[0] + """ + return ('(' * (count * 2) + ' | '.join( + "(%s)%s[%d])%s)" % (join_type, digits_ptr, _i, " << PyLong_SHIFT" if _i else '') + for _i in range(count-1, -1, -1))) + + +# although it could potentially make use of data independence, +# this implementation is a bit slower than the simpler one above +def _pylong_join(count, digits_ptr='digits', join_type='unsigned long'): + """ + Generate an or-ed series of shifts for the first 'count' digits. + Assumes that they fit into 'join_type'. + + (d[2] << 2*n) | (d[1] << 1*n) | d[0] + """ + def shift(n): + # avoid compiler warnings for overly large shifts that will be discarded anyway + return " << (%d * PyLong_SHIFT < 8 * sizeof(%s) ? %d * PyLong_SHIFT : 0)" % (n, join_type, n) if n else '' + + return '(%s)' % ' | '.join( + "(((%s)%s[%d])%s)" % (join_type, digits_ptr, i, shift(i)) + for i in range(count-1, -1, -1)) diff --git a/contrib/tools/cython/Cython/Utility/arrayarray.h b/contrib/tools/cython/Cython/Utility/arrayarray.h new file mode 100644 index 00000000000..a9e49237856 --- /dev/null +++ b/contrib/tools/cython/Cython/Utility/arrayarray.h @@ -0,0 +1,149 @@ +/////////////// ArrayAPI.proto /////////////// + +// arrayarray.h +// +// Artificial C-API for Python's <array.array> type, +// used by array.pxd +// +// last changes: 2009-05-15 rk +// 2012-05-02 andreasvc +// (see revision control) +// + +#ifndef _ARRAYARRAY_H +#define _ARRAYARRAY_H + +// These two forward declarations are explicitly handled in the type +// declaration code, as including them here is too late for cython-defined +// types to use them. +// struct arrayobject; +// typedef struct arrayobject arrayobject; + +// All possible arraydescr values are defined in the vector "descriptors" +// below. That's defined later because the appropriate get and set +// functions aren't visible yet. +typedef struct arraydescr { + int typecode; + int itemsize; + PyObject * (*getitem)(struct arrayobject *, Py_ssize_t); + int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *); +#if PY_MAJOR_VERSION >= 3 + char *formats; +#endif +} arraydescr; + + +struct arrayobject { + PyObject_HEAD + Py_ssize_t ob_size; + union { + char *ob_item; + float *as_floats; + double *as_doubles; + int *as_ints; + unsigned int *as_uints; + unsigned char *as_uchars; + signed char *as_schars; + char *as_chars; + unsigned long *as_ulongs; + long *as_longs; +#if PY_MAJOR_VERSION >= 3 + unsigned long long *as_ulonglongs; + long long *as_longlongs; +#endif + short *as_shorts; + unsigned short *as_ushorts; + Py_UNICODE *as_pyunicodes; + void *as_voidptr; + } data; + Py_ssize_t allocated; + struct arraydescr *ob_descr; + PyObject *weakreflist; /* List of weak references */ +#if PY_MAJOR_VERSION >= 3 + int ob_exports; /* Number of exported buffers */ +#endif +}; + +#ifndef NO_NEWARRAY_INLINE +// fast creation of a new array +static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ssize_t size, + struct arraydescr *descr) { + arrayobject *op; + size_t nbytes; + + if (size < 0) { + PyErr_BadInternalCall(); + return NULL; + } + + nbytes = size * descr->itemsize; + // Check for overflow + if (nbytes / descr->itemsize != (size_t)size) { + return PyErr_NoMemory(); + } + op = (arrayobject *) type->tp_alloc(type, 0); + if (op == NULL) { + return NULL; + } + op->ob_descr = descr; + op->allocated = size; + op->weakreflist = NULL; + __Pyx_SET_SIZE(op, size); + if (size <= 0) { + op->data.ob_item = NULL; + } + else { + op->data.ob_item = PyMem_NEW(char, nbytes); + if (op->data.ob_item == NULL) { + Py_DECREF(op); + return PyErr_NoMemory(); + } + } + return (PyObject *) op; +} +#else +PyObject* newarrayobject(PyTypeObject *type, Py_ssize_t size, + struct arraydescr *descr); +#endif /* ifndef NO_NEWARRAY_INLINE */ + +// fast resize (reallocation to the point) +// not designed for filing small increments (but for fast opaque array apps) +static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) { + void *items = (void*) self->data.ob_item; + PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize)); + if (items == NULL) { + PyErr_NoMemory(); + return -1; + } + self->data.ob_item = (char*) items; + __Pyx_SET_SIZE(self, n); + self->allocated = n; + return 0; +} + +// suitable for small increments; over allocation 50% ; +static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) { + void *items = (void*) self->data.ob_item; + Py_ssize_t newsize; + if (n < self->allocated && n*4 > self->allocated) { + __Pyx_SET_SIZE(self, n); + return 0; + } + newsize = n + (n / 2) + 1; + if (newsize <= n) { /* overflow */ + PyErr_NoMemory(); + return -1; + } + PyMem_Resize(items, char, (size_t)(newsize * self->ob_descr->itemsize)); + if (items == NULL) { + PyErr_NoMemory(); + return -1; + } + self->data.ob_item = (char*) items; + __Pyx_SET_SIZE(self, n); + self->allocated = newsize; + return 0; +} + +#endif +/* _ARRAYARRAY_H */ diff --git a/contrib/tools/cython/Cython/Utils.py b/contrib/tools/cython/Cython/Utils.py new file mode 100644 index 00000000000..13f83fb755b --- /dev/null +++ b/contrib/tools/cython/Cython/Utils.py @@ -0,0 +1,475 @@ +# +# Cython -- Things that don't belong +# anywhere else in particular +# + +from __future__ import absolute_import + +try: + from __builtin__ import basestring +except ImportError: + basestring = str + +try: + FileNotFoundError +except NameError: + FileNotFoundError = OSError + +import os +import sys +import re +import io +import codecs +import shutil +import tempfile +from contextlib import contextmanager + +modification_time = os.path.getmtime + +_function_caches = [] +def clear_function_caches(): + for cache in _function_caches: + cache.clear() + +def cached_function(f): + cache = {} + _function_caches.append(cache) + uncomputed = object() + def wrapper(*args): + res = cache.get(args, uncomputed) + if res is uncomputed: + res = cache[args] = f(*args) + return res + wrapper.uncached = f + return wrapper + +def cached_method(f): + cache_name = '__%s_cache' % f.__name__ + def wrapper(self, *args): + cache = getattr(self, cache_name, None) + if cache is None: + cache = {} + setattr(self, cache_name, cache) + if args in cache: + return cache[args] + res = cache[args] = f(self, *args) + return res + return wrapper + +def replace_suffix(path, newsuf): + base, _ = os.path.splitext(path) + return base + newsuf + + +def open_new_file(path): + if os.path.exists(path): + # Make sure to create a new file here so we can + # safely hard link the output files. + os.unlink(path) + + # we use the ISO-8859-1 encoding here because we only write pure + # ASCII strings or (e.g. for file names) byte encoded strings as + # Unicode, so we need a direct mapping from the first 256 Unicode + # characters to a byte sequence, which ISO-8859-1 provides + + # note: can't use io.open() in Py2 as we may be writing str objects + return codecs.open(path, "w", encoding="ISO-8859-1") + + +def castrate_file(path, st): + # Remove junk contents from an output file after a + # failed compilation. + # Also sets access and modification times back to + # those specified by st (a stat struct). + try: + f = open_new_file(path) + except EnvironmentError: + pass + else: + f.write( + "#error Do not use this file, it is the result of a failed Cython compilation.\n") + f.close() + if st: + os.utime(path, (st.st_atime, st.st_mtime-1)) + +def file_newer_than(path, time): + ftime = modification_time(path) + return ftime > time + + +def safe_makedirs(path): + try: + os.makedirs(path) + except OSError: + if not os.path.isdir(path): + raise + + +def copy_file_to_dir_if_newer(sourcefile, destdir): + """ + Copy file sourcefile to directory destdir (creating it if needed), + preserving metadata. If the destination file exists and is not + older than the source file, the copying is skipped. + """ + destfile = os.path.join(destdir, os.path.basename(sourcefile)) + try: + desttime = modification_time(destfile) + except OSError: + # New file does not exist, destdir may or may not exist + safe_makedirs(destdir) + else: + # New file already exists + if not file_newer_than(sourcefile, desttime): + return + shutil.copy2(sourcefile, destfile) + + +@cached_function +def find_root_package_dir(file_path): + dir = os.path.dirname(file_path) + if file_path == dir: + return dir + elif is_package_dir(dir): + return find_root_package_dir(dir) + else: + return dir + +@cached_function +def check_package_dir(dir, package_names): + for dirname in package_names: + dir = os.path.join(dir, dirname) + if not is_package_dir(dir): + return None + return dir + +@cached_function +def is_package_dir(dir_path): + for filename in ("__init__.py", + "__init__.pyc", + "__init__.pyx", + "__init__.pxd"): + path = os.path.join(dir_path, filename) + if path_exists(path): + return 1 + +@cached_function +def path_exists(path): + # try on the filesystem first + if os.path.exists(path): + return True + # figure out if a PEP 302 loader is around + try: + loader = __loader__ + # XXX the code below assumes a 'zipimport.zipimporter' instance + # XXX should be easy to generalize, but too lazy right now to write it + archive_path = getattr(loader, 'archive', None) + if archive_path: + normpath = os.path.normpath(path) + if normpath.startswith(archive_path): + arcname = normpath[len(archive_path)+1:] + try: + loader.get_data(arcname) + return True + except IOError: + return False + except NameError: + pass + return False + +# file name encodings + +def decode_filename(filename): + if isinstance(filename, bytes): + try: + filename_encoding = sys.getfilesystemencoding() + if filename_encoding is None: + filename_encoding = sys.getdefaultencoding() + filename = filename.decode(filename_encoding) + except UnicodeDecodeError: + pass + return filename + +# support for source file encoding detection + +_match_file_encoding = re.compile(br"(\w*coding)[:=]\s*([-\w.]+)").search + + +def detect_opened_file_encoding(f): + # PEPs 263 and 3120 + # Most of the time the first two lines fall in the first couple of hundred chars, + # and this bulk read/split is much faster. + lines = () + start = b'' + while len(lines) < 3: + data = f.read(500) + start += data + lines = start.split(b"\n") + if not data: + break + m = _match_file_encoding(lines[0]) + if m and m.group(1) != b'c_string_encoding': + return m.group(2).decode('iso8859-1') + elif len(lines) > 1: + m = _match_file_encoding(lines[1]) + if m: + return m.group(2).decode('iso8859-1') + return "UTF-8" + + +def skip_bom(f): + """ + Read past a BOM at the beginning of a source file. + This could be added to the scanner, but it's *substantially* easier + to keep it at this level. + """ + if f.read(1) != u'\uFEFF': + f.seek(0) + + +def open_source_file(source_filename, encoding=None, error_handling=None): + stream = None + try: + if encoding is None: + # Most of the time the encoding is not specified, so try hard to open the file only once. + f = io.open(source_filename, 'rb') + encoding = detect_opened_file_encoding(f) + f.seek(0) + stream = io.TextIOWrapper(f, encoding=encoding, errors=error_handling) + else: + stream = io.open(source_filename, encoding=encoding, errors=error_handling) + + except OSError: + if os.path.exists(source_filename): + raise # File is there, but something went wrong reading from it. + # Allow source files to be in zip files etc. + try: + loader = __loader__ + if source_filename.startswith(loader.archive): + stream = open_source_from_loader( + loader, source_filename, + encoding, error_handling) + except (NameError, AttributeError): + pass + + if stream is None: + raise FileNotFoundError(source_filename) + skip_bom(stream) + return stream + + +def open_source_from_loader(loader, + source_filename, + encoding=None, error_handling=None): + nrmpath = os.path.normpath(source_filename) + arcname = nrmpath[len(loader.archive)+1:] + data = loader.get_data(arcname) + return io.TextIOWrapper(io.BytesIO(data), + encoding=encoding, + errors=error_handling) + + +def str_to_number(value): + # note: this expects a string as input that was accepted by the + # parser already, with an optional "-" sign in front + is_neg = False + if value[:1] == '-': + is_neg = True + value = value[1:] + if len(value) < 2: + value = int(value, 0) + elif value[0] == '0': + literal_type = value[1] # 0'o' - 0'b' - 0'x' + if literal_type in 'xX': + # hex notation ('0x1AF') + value = int(value[2:], 16) + elif literal_type in 'oO': + # Py3 octal notation ('0o136') + value = int(value[2:], 8) + elif literal_type in 'bB': + # Py3 binary notation ('0b101') + value = int(value[2:], 2) + else: + # Py2 octal notation ('0136') + value = int(value, 8) + else: + value = int(value, 0) + return -value if is_neg else value + + +def long_literal(value): + if isinstance(value, basestring): + value = str_to_number(value) + return not -2**31 <= value < 2**31 + + +@cached_function +def get_cython_cache_dir(): + r""" + Return the base directory containing Cython's caches. + + Priority: + + 1. CYTHON_CACHE_DIR + 2. (OS X): ~/Library/Caches/Cython + (posix not OS X): XDG_CACHE_HOME/cython if XDG_CACHE_HOME defined + 3. ~/.cython + + """ + if 'CYTHON_CACHE_DIR' in os.environ: + return os.environ['CYTHON_CACHE_DIR'] + + parent = None + if os.name == 'posix': + if sys.platform == 'darwin': + parent = os.path.expanduser('~/Library/Caches') + else: + # this could fallback on ~/.cache + parent = os.environ.get('XDG_CACHE_HOME') + + if parent and os.path.isdir(parent): + return os.path.join(parent, 'cython') + + # last fallback: ~/.cython + return os.path.expanduser(os.path.join('~', '.cython')) + + +@contextmanager +def captured_fd(stream=2, encoding=None): + orig_stream = os.dup(stream) # keep copy of original stream + try: + with tempfile.TemporaryFile(mode="a+b") as temp_file: + def read_output(_output=[b'']): + if not temp_file.closed: + temp_file.seek(0) + _output[0] = temp_file.read() + return _output[0] + + os.dup2(temp_file.fileno(), stream) # replace stream by copy of pipe + try: + def get_output(): + result = read_output() + return result.decode(encoding) if encoding else result + + yield get_output + finally: + os.dup2(orig_stream, stream) # restore original stream + read_output() # keep the output in case it's used after closing the context manager + finally: + os.close(orig_stream) + + +def print_bytes(s, header_text=None, end=b'\n', file=sys.stdout, flush=True): + if header_text: + file.write(header_text) # note: text! => file.write() instead of out.write() + file.flush() + try: + out = file.buffer # Py3 + except AttributeError: + out = file # Py2 + out.write(s) + if end: + out.write(end) + if flush: + out.flush() + +class LazyStr: + def __init__(self, callback): + self.callback = callback + def __str__(self): + return self.callback() + def __repr__(self): + return self.callback() + def __add__(self, right): + return self.callback() + right + def __radd__(self, left): + return left + self.callback() + + +class OrderedSet(object): + def __init__(self, elements=()): + self._list = [] + self._set = set() + self.update(elements) + def __iter__(self): + return iter(self._list) + def update(self, elements): + for e in elements: + self.add(e) + def add(self, e): + if e not in self._set: + self._list.append(e) + self._set.add(e) + + +# Class decorator that adds a metaclass and recreates the class with it. +# Copied from 'six'. +def add_metaclass(metaclass): + """Class decorator for creating a class with a metaclass.""" + def wrapper(cls): + orig_vars = cls.__dict__.copy() + slots = orig_vars.get('__slots__') + if slots is not None: + if isinstance(slots, str): + slots = [slots] + for slots_var in slots: + orig_vars.pop(slots_var) + orig_vars.pop('__dict__', None) + orig_vars.pop('__weakref__', None) + return metaclass(cls.__name__, cls.__bases__, orig_vars) + return wrapper + + +def raise_error_if_module_name_forbidden(full_module_name): + #it is bad idea to call the pyx-file cython.pyx, so fail early + if full_module_name == 'cython' or full_module_name.startswith('cython.'): + raise ValueError('cython is a special module, cannot be used as a module name') + + +def build_hex_version(version_string): + """ + Parse and translate '4.3a1' into the readable hex representation '0x040300A1' (like PY_VERSION_HEX). + """ + # First, parse '4.12a1' into [4, 12, 0, 0xA01]. + digits = [] + release_status = 0xF0 + for digit in re.split('([.abrc]+)', version_string): + if digit in ('a', 'b', 'rc'): + release_status = {'a': 0xA0, 'b': 0xB0, 'rc': 0xC0}[digit] + digits = (digits + [0, 0])[:3] # 1.2a1 -> 1.2.0a1 + elif digit != '.': + digits.append(int(digit)) + digits = (digits + [0] * 3)[:4] + digits[3] += release_status + + # Then, build a single hex value, two hex digits per version part. + hexversion = 0 + for digit in digits: + hexversion = (hexversion << 8) + digit + + return '0x%08X' % hexversion + + +def write_depfile(target, source, dependencies): + src_base_dir = os.path.dirname(source) + cwd = os.getcwd() + if not src_base_dir.endswith(os.sep): + src_base_dir += os.sep + # paths below the base_dir are relative, otherwise absolute + paths = [] + for fname in dependencies: + fname = os.path.abspath(fname) + if fname.startswith(src_base_dir): + try: + newpath = os.path.relpath(fname, cwd) + except ValueError: + # if they are on different Windows drives, absolute is fine + newpath = fname + else: + newpath = fname + paths.append(newpath) + + depline = os.path.relpath(target, cwd) + ": \\\n " + depline += " \\\n ".join(paths) + "\n" + + with open(target+'.dep', 'w') as outfile: + outfile.write(depline) diff --git a/contrib/tools/cython/Cython/__init__.py b/contrib/tools/cython/Cython/__init__.py new file mode 100644 index 00000000000..549246b8a37 --- /dev/null +++ b/contrib/tools/cython/Cython/__init__.py @@ -0,0 +1,12 @@ +from __future__ import absolute_import + +from .Shadow import __version__ + +# Void cython.* directives (for case insensitive operating systems). +from .Shadow import * + + +def load_ipython_extension(ip): + """Load the extension in IPython.""" + from .Build.IpythonMagic import CythonMagics # pylint: disable=cyclic-import + ip.register_magics(CythonMagics) diff --git a/contrib/tools/cython/Cython/ya.make b/contrib/tools/cython/Cython/ya.make new file mode 100644 index 00000000000..084b2bf9452 --- /dev/null +++ b/contrib/tools/cython/Cython/ya.make @@ -0,0 +1,26 @@ +PY23_LIBRARY() + +LICENSE(Public-Domain) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +WITHOUT_LICENSE_TEXTS() + +OWNER(g:yatool) + +NO_LINT() + +# Minimal set of the files required to support coverage (DEVTOOLS-4095) +PY_SRCS( + __init__.py + Coverage.py + Shadow.py + Utils.py +) + +PEERDIR( + contrib/python/six + library/python/resource +) + +END() diff --git a/contrib/tools/cython/INSTALL.txt b/contrib/tools/cython/INSTALL.txt new file mode 100644 index 00000000000..a54a2eee3ed --- /dev/null +++ b/contrib/tools/cython/INSTALL.txt @@ -0,0 +1,22 @@ +Cython - Installation Instructions +================================== + +You have two installation options: + +(1) Run the setup.py script in this directory + as follows: + + python setup.py install + + This will install the Cython package + into your Python system. + +OR + +(2) If you prefer not to modify your Python + installation, arrange for the directory + containing this file (INSTALL.txt) to be in + your PYTHONPATH. On unix, also put the bin + directory on your PATH. + +See README.txt for pointers to other documentation. diff --git a/contrib/tools/cython/LICENSE.txt b/contrib/tools/cython/LICENSE.txt new file mode 100644 index 00000000000..d9a10c0d8e8 --- /dev/null +++ b/contrib/tools/cython/LICENSE.txt @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/contrib/tools/cython/README.rst b/contrib/tools/cython/README.rst new file mode 100644 index 00000000000..fe4b5958a18 --- /dev/null +++ b/contrib/tools/cython/README.rst @@ -0,0 +1,86 @@ +Welcome to Cython! +================== + +Cython is a language that makes writing C extensions for +Python as easy as Python itself. Cython is based on +Pyrex, but supports more cutting edge functionality and +optimizations. + +The Cython language is very close to the Python language, but Cython +additionally supports calling C functions and declaring C types on variables +and class attributes. This allows the compiler to generate very efficient C +code from Cython code. + +This makes Cython the ideal language for wrapping external C libraries, and +for fast C modules that speed up the execution of Python code. + +* Official website: http://cython.org/ +* Documentation: http://docs.cython.org/en/latest/ +* Github repository: https://github.com/cython/cython +* Wiki: https://github.com/cython/cython/wiki + + +Installation: +------------- + +If you already have a C compiler, just do:: + + pip install Cython + +otherwise, see `the installation page <http://docs.cython.org/en/latest/src/quickstart/install.html>`_. + + +License: +-------- + +The original Pyrex program was licensed "free of restrictions" (see below). +Cython itself is licensed under the permissive **Apache License**. + +See `LICENSE.txt <https://github.com/cython/cython/blob/master/LICENSE.txt>`_. + + +Contributing: +------------- + +Want to contribute to the Cython project? +Here is some `help to get you started <https://github.com/cython/cython/blob/master/docs/CONTRIBUTING.rst>`_. + + +Get the full source history: +---------------------------- + +Note that Cython used to ship the full version control repository in its source +distribution, but no longer does so due to space constraints. To get the +full source history from a downloaded source archive, make sure you have git +installed, then step into the base directory of the Cython source distribution +and type:: + + make repo + + +The following is from Pyrex: +------------------------------------------------------ +This is a development version of Pyrex, a language +for writing Python extension modules. + +For more info, see: + +* Doc/About.html for a description of the language +* INSTALL.txt for installation instructions +* USAGE.txt for usage instructions +* Demos for usage examples + +Comments, suggestions, bug reports, etc. are +welcome! + +Copyright stuff: Pyrex is free of restrictions. You +may use, redistribute, modify and distribute modified +versions. + +The latest version of Pyrex can be found `here <http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/>`_. + +| Greg Ewing, Computer Science Dept +| University of Canterbury +| Christchurch, New Zealand + + A citizen of NewZealandCorp, a wholly-owned subsidiary of USA Inc. diff --git a/contrib/tools/cython/USAGE.txt b/contrib/tools/cython/USAGE.txt new file mode 100644 index 00000000000..13d07ad7e1c --- /dev/null +++ b/contrib/tools/cython/USAGE.txt @@ -0,0 +1,75 @@ +Cython - Usage Instructions +========================== + +Building Cython extensions using distutils +----------------------------------------- + +Cython comes with an experimental distutils extension for compiling +Cython modules, contributed by Graham Fawcett of the University of +Windsor (fawcett@uwindsor.ca). + +The Demos directory contains a setup.py file demonstrating its use. To +compile the demos: + +(1) cd Demos + +(2) python setup.py build_ext --inplace + + or + + python setup.py build --build-lib=. + +(You may get a screed of warnings from the C compiler, but you can +ignore these -- as long as there are no actual errors, things are +probably okay.) + +Try out the extensions with: + + python run_primes.py + python run_spam.py + python run_numeric_demo.py + + +Building Cython extensions by hand +--------------------------------- + +You can also invoke the Cython compiler on its own to translate a .pyx +file to a .c file. On Unix, + + cython filename.pyx + +On other platforms, + + python cython.py filename.pyx + +It's then up to you to compile and link the .c file using whatever +procedure is appropriate for your platform. The file +Makefile.nodistutils in the Demos directory shows how to do this for +one particular Unix system. + + +Command line options +-------------------- + +The cython command supports the following options: + + Short Long Argument Description + ----------------------------------------------------------------------------- + -v --version Display version number of cython compiler + -l --create-listing Write error messages to a .lis file + -I --include-dir <directory> Search for include files in named + directory (may be repeated) + -o --output-file <filename> Specify name of generated C file (only + one source file allowed if this is used) + -p, --embed-positions If specified, the positions in Cython files of each + function definition is embedded in its docstring. + -z, --pre-import <module> If specified, assume undeclared names in this + module. Emulates the behavior of putting + "from <module> import *" at the top of the file. + + +Anything else is taken as the name of a Cython source file and compiled +to a C source file. Multiple Cython source files can be specified +(unless -o is used), in which case each source file is treated as the +source of a distinct extension module and compiled separately to +produce its own C file. diff --git a/contrib/tools/cython/cygdb.py b/contrib/tools/cython/cygdb.py new file mode 100755 index 00000000000..7f2d57f5d60 --- /dev/null +++ b/contrib/tools/cython/cygdb.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +import sys + +from Cython.Debugger import Cygdb as cygdb + +if __name__ == '__main__': + cygdb.main() diff --git a/contrib/tools/cython/cython.py b/contrib/tools/cython/cython.py new file mode 100755 index 00000000000..4b91fb9451d --- /dev/null +++ b/contrib/tools/cython/cython.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +# Change content of this file to change uids for cython programs - cython 0.29.34 r0 + +# +# Cython -- Main Program, generic +# + +if __name__ == '__main__': + + import os + import sys + sys.dont_write_bytecode = True + + # Make sure we import the right Cython + cythonpath, _ = os.path.split(os.path.realpath(__file__)) + sys.path.insert(0, cythonpath) + + from Cython.Compiler.Main import main + main(command_line = 1) + +else: + # Void cython.* directives. + from Cython.Shadow import * + ## and bring in the __version__ + from Cython import __version__ + from Cython import load_ipython_extension diff --git a/contrib/tools/cython/generated_c_headers.h b/contrib/tools/cython/generated_c_headers.h new file mode 100644 index 00000000000..7b9637ef9c2 --- /dev/null +++ b/contrib/tools/cython/generated_c_headers.h @@ -0,0 +1 @@ +#pragma once
\ No newline at end of file diff --git a/contrib/tools/cython/generated_cpp_headers.h b/contrib/tools/cython/generated_cpp_headers.h new file mode 100644 index 00000000000..645dbac0dea --- /dev/null +++ b/contrib/tools/cython/generated_cpp_headers.h @@ -0,0 +1,8 @@ +#pragma once + +// Content must be in sync with https://a.yandex-team.ru/arc/trunk/arcadia/contrib/tools/cython/Cython/Compiler/Nodes.py?rev=r8428765#L717-720 +// or other placess of cython compiler adding C++ specific headers implicitelly. +#include "ios" +#include "new" +#include "stdexcept" +#include "typeinfo" diff --git a/contrib/tools/cython/ya.make b/contrib/tools/cython/ya.make new file mode 100644 index 00000000000..b035d9104a4 --- /dev/null +++ b/contrib/tools/cython/ya.make @@ -0,0 +1,20 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +PY3_LIBRARY() + +LICENSE( + Apache-2.0 AND + LicenseRef-scancode-unknown-license-reference +) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +OWNER(g:python-contrib) + +VERSION(0.29.34) + +ORIGINAL_SOURCE(mirror://pypi/C/Cython/Cython-0.29.34.tar.gz) + +NO_LINT() + +END() diff --git a/contrib/tools/flex-old/ya.make b/contrib/tools/flex-old/ya.make new file mode 100644 index 00000000000..c6cc30128e3 --- /dev/null +++ b/contrib/tools/flex-old/ya.make @@ -0,0 +1,29 @@ +PROGRAM(flex) + +VERSION(2.5.4) + +NO_RUNTIME() +NO_OPTIMIZE() +NO_COMPILER_WARNINGS() + +SRCS( + ccl.c + dfa.c + ecs.c + gen.c + main.c + misc.c + nfa.c + skel.c + sym.c + tblcmp.c + yylex.c + scan.c + parse.c +) + +INDUCED_DEPS(h+cpp + ${ARCADIA_ROOT}/contrib/tools/flex-old/FlexLexer.h +) + +END() diff --git a/contrib/tools/protoc/bin/ya.make b/contrib/tools/protoc/bin/ya.make new file mode 100644 index 00000000000..2b9c2039388 --- /dev/null +++ b/contrib/tools/protoc/bin/ya.make @@ -0,0 +1,20 @@ +PROGRAM(protoc) + +LICENSE(BSD-3-Clause) + +NO_COMPILER_WARNINGS() + +PEERDIR( + contrib/libs/protoc +) +SRCDIR( + contrib/libs/protoc +) + +SRCS( + src/google/protobuf/compiler/main.cc +) + +INCLUDE(${ARCADIA_ROOT}/contrib/tools/protoc/ya.make.induced_deps) + +END() diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/bin/ya.make b/contrib/tools/protoc/plugins/cpp_styleguide/bin/ya.make new file mode 100644 index 00000000000..c6e59ea46d5 --- /dev/null +++ b/contrib/tools/protoc/plugins/cpp_styleguide/bin/ya.make @@ -0,0 +1,19 @@ +PROGRAM(cpp_styleguide) + +NO_COMPILER_WARNINGS() + +PEERDIR( + contrib/libs/protoc +) + +SRCS( + cpp_styleguide.cpp +) + +SRCDIR( + contrib/tools/protoc/plugins/cpp_styleguide +) + +INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/protoc/plugins/cpp_styleguide/ya.make.induced_deps) + +END() diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/ya.make b/contrib/tools/protoc/plugins/cpp_styleguide/ya.make new file mode 100644 index 00000000000..ea749e8ca71 --- /dev/null +++ b/contrib/tools/protoc/plugins/cpp_styleguide/ya.make @@ -0,0 +1,11 @@ +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/protoc/plugins/cpp_styleguide/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/contrib/tools/protoc/plugins/cpp_styleguide/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/contrib/tools/protoc/plugins/grpc_cpp/bin/ya.make b/contrib/tools/protoc/plugins/grpc_cpp/bin/ya.make new file mode 100644 index 00000000000..81672852db6 --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_cpp/bin/ya.make @@ -0,0 +1,28 @@ +PROGRAM(grpc_cpp) + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc/src/compiler/grpc_plugin_support +) + +ADDINCL( + contrib/libs/grpc + contrib/libs/grpc/include +) + +NO_COMPILER_WARNINGS() + +CFLAGS( + -DGRPC_USE_ABSL=0 +) + +SRCDIR(contrib/libs/grpc/src/compiler) + +SRCS( + cpp_plugin.cc +) + +INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/protoc/plugins/grpc_cpp/ya.make.induced_deps) + +END() diff --git a/contrib/tools/protoc/plugins/grpc_cpp/ya.make b/contrib/tools/protoc/plugins/grpc_cpp/ya.make new file mode 100644 index 00000000000..0d73a27c957 --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_cpp/ya.make @@ -0,0 +1,14 @@ +# Copy of contrib/libs/grpc/src/compiler/grpc_cpp_plugin +# Generated by devtools/yamaker. + +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/protoc/plugins/grpc_cpp/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/contrib/tools/protoc/plugins/grpc_cpp/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/contrib/tools/protoc/plugins/grpc_java/bin/parsever/ya.make b/contrib/tools/protoc/plugins/grpc_java/bin/parsever/ya.make new file mode 100644 index 00000000000..2237d039c8c --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_java/bin/parsever/ya.make @@ -0,0 +1,11 @@ +PY3_PROGRAM() + +PEERDIR(library/python/resource) + +RESOURCE( + ${ARCADIA_ROOT}/contrib/libs/grpc-java/core/src/main/java/io/grpc/internal/GrpcUtil.java /GrpcUtil.java +) + +PY_SRCS(__main__.py) + +END() diff --git a/contrib/tools/protoc/plugins/grpc_java/bin/test/ya.make b/contrib/tools/protoc/plugins/grpc_java/bin/test/ya.make new file mode 100644 index 00000000000..d196ed450b2 --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_java/bin/test/ya.make @@ -0,0 +1,7 @@ +EXECTEST() + +DEPENDS(contrib/tools/protoc/plugins/grpc_java/bin/parsever) +INCLUDE(${ARCADIA_ROOT}/contrib/tools/protoc/plugins/grpc_java/bin/ya.version) +RUN(parsever ${GRPC_JAVA_VERSION}) + +END() diff --git a/contrib/tools/protoc/plugins/grpc_java/bin/ya.make b/contrib/tools/protoc/plugins/grpc_java/bin/ya.make new file mode 100644 index 00000000000..34373aefea1 --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_java/bin/ya.make @@ -0,0 +1,20 @@ +PROGRAM(grpc_java) + +INCLUDE(ya.version) + +VERSION(${GRPC_JAVA_VERSION}) + +NO_COMPILER_WARNINGS() + +PEERDIR( + contrib/libs/protoc +) + +SRCDIR(contrib/libs/grpc-java/compiler/src/java_plugin/cpp) + +SRCS( + java_plugin.cpp + java_generator.cpp +) + +END() diff --git a/contrib/tools/protoc/plugins/grpc_java/bin/ya.version b/contrib/tools/protoc/plugins/grpc_java/bin/ya.version new file mode 100644 index 00000000000..2990e20e5ba --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_java/bin/ya.version @@ -0,0 +1 @@ +SET(GRPC_JAVA_VERSION 1.43.2) diff --git a/contrib/tools/protoc/plugins/grpc_java/ya.make b/contrib/tools/protoc/plugins/grpc_java/ya.make new file mode 100644 index 00000000000..23d63e89ba7 --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_java/ya.make @@ -0,0 +1,13 @@ +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/protoc/plugins/grpc_java/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/contrib/tools/protoc/plugins/grpc_java/bin/ya.make) +ENDIF() + +RECURSE( + bin + bin/parsever + bin/test +) diff --git a/contrib/tools/protoc/plugins/grpc_python/bin/ya.make b/contrib/tools/protoc/plugins/grpc_python/bin/ya.make new file mode 100644 index 00000000000..ab21ab6c50d --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_python/bin/ya.make @@ -0,0 +1,26 @@ +PROGRAM(grpc_python) + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc/src/compiler/grpc_plugin_support +) + +ADDINCL( + contrib/libs/grpc + contrib/libs/grpc/include +) + +NO_COMPILER_WARNINGS() + +CFLAGS( + -DGRPC_USE_ABSL=0 +) + +SRCDIR(contrib/libs/grpc/src/compiler) + +SRCS( + python_plugin.cc +) + +END() diff --git a/contrib/tools/protoc/plugins/grpc_python/ya.make b/contrib/tools/protoc/plugins/grpc_python/ya.make new file mode 100644 index 00000000000..3cd9647f0b0 --- /dev/null +++ b/contrib/tools/protoc/plugins/grpc_python/ya.make @@ -0,0 +1,14 @@ +# Copy of contrib/libs/grpc/src/compiler/grpc_python_plugin +# Generated by devtools/yamaker. + +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/protoc/plugins/grpc_python/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/contrib/tools/protoc/plugins/grpc_python/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/contrib/tools/protoc/plugins/ya.make b/contrib/tools/protoc/plugins/ya.make new file mode 100644 index 00000000000..44254ae1112 --- /dev/null +++ b/contrib/tools/protoc/plugins/ya.make @@ -0,0 +1,6 @@ +RECURSE( + cpp_styleguide + grpc_cpp + grpc_java + grpc_python +) diff --git a/contrib/tools/protoc/ya.make b/contrib/tools/protoc/ya.make new file mode 100644 index 00000000000..59b96b2a63e --- /dev/null +++ b/contrib/tools/protoc/ya.make @@ -0,0 +1,16 @@ +# WARN: +# The Piglet sync service (abc:cc-piglet) relies on prebuiltness of protoc. +# DO NOT REMOVE ya.make.prebuilt. + +IF (USE_PREBUILT_TOOLS) + INCLUDE(ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(bin/ya.make) +ENDIF() + +RECURSE( + bin + plugins +) diff --git a/contrib/tools/protoc/ya.make.induced_deps b/contrib/tools/protoc/ya.make.induced_deps new file mode 100644 index 00000000000..55ede44772a --- /dev/null +++ b/contrib/tools/protoc/ya.make.induced_deps @@ -0,0 +1,30 @@ +INDUCED_DEPS(cpp + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/descriptor.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/stubs/common.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/stubs/once.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/stubs/port.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/wire_format.h +) +INDUCED_DEPS(h+cpp + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/arena.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/arenastring.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/extension_set.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_table_driven.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/map.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/map_entry.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/map_field_inl.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/message.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/port_def.inc + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/port_undef.inc + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/repeated_field.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/stubs/common.h + ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h +) diff --git a/contrib/tools/ragel5/aapl/ya.make b/contrib/tools/ragel5/aapl/ya.make new file mode 100644 index 00000000000..6962c52ce9f --- /dev/null +++ b/contrib/tools/ragel5/aapl/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +LICENSE(LGPL-2.1-or-later) + + +NO_UTIL() + +ADDINCL( + GLOBAL contrib/tools/ragel5/aapl +) + +END() diff --git a/contrib/tools/ragel6/bin/ya.make b/contrib/tools/ragel6/bin/ya.make new file mode 100644 index 00000000000..f84c703b649 --- /dev/null +++ b/contrib/tools/ragel6/bin/ya.make @@ -0,0 +1,118 @@ +PROGRAM(ragel6) + +VERSION(6.10) + +LICENSE(GPL-2.0) + +IF (OS_LINUX) + ALLOCATOR(MIM) +ENDIF() + +PEERDIR( + contrib/tools/ragel5/aapl +) + +ADDINCL( + contrib/tools/ragel6 +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +CFLAGS( + -DHAVE_CONFIG_H +) + +SRCDIR(contrib/tools/ragel6) + +SRCS( + rlparse.cpp + rlscan.cpp +) + +JOIN_SRCS( + all_cd.cpp + cdcodegen.cpp + cdfflat.cpp + cdfgoto.cpp + cdflat.cpp + cdftable.cpp + cdgoto.cpp + cdipgoto.cpp + cdsplit.cpp + cdtable.cpp +) + +JOIN_SRCS( + all_cs.cpp + cscodegen.cpp + csfflat.cpp + csfgoto.cpp + csflat.cpp + csftable.cpp + csgoto.cpp + csipgoto.cpp + cssplit.cpp + cstable.cpp +) + +JOIN_SRCS( + all_fs.cpp + fsmap.cpp + fsmattach.cpp + fsmbase.cpp + fsmgraph.cpp + fsmmin.cpp + fsmstate.cpp +) + +JOIN_SRCS( + all_go.cpp + gocodegen.cpp + gofflat.cpp + gofgoto.cpp + goflat.cpp + goftable.cpp + gogoto.cpp + goipgoto.cpp + gotable.cpp + gotablish.cpp +) + +JOIN_SRCS( + all_ml.cpp + mlcodegen.cpp + mlfflat.cpp + mlfgoto.cpp + mlflat.cpp + mlftable.cpp + mlgoto.cpp + mltable.cpp +) + +JOIN_SRCS( + all_r.cpp + rbxgoto.cpp + redfsm.cpp + rubycodegen.cpp + rubyfflat.cpp + rubyflat.cpp + rubyftable.cpp + rubytable.cpp +) + +JOIN_SRCS( + all_other.cpp + common.cpp + dotcodegen.cpp + gendata.cpp + inputdata.cpp + javacodegen.cpp + main.cpp + parsedata.cpp + parsetree.cpp + xmlcodegen.cpp +) + +END() diff --git a/contrib/tools/ragel6/ya.make b/contrib/tools/ragel6/ya.make new file mode 100644 index 00000000000..c572d443e86 --- /dev/null +++ b/contrib/tools/ragel6/ya.make @@ -0,0 +1,13 @@ +# Generated by devtools/yamaker from nixpkgs 980c4c3c2f664ccc5002f7fd6e08059cf1f00e75. + +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/ragel6/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/contrib/tools/ragel6/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/contrib/tools/yasm/bin/ya.make b/contrib/tools/yasm/bin/ya.make new file mode 100644 index 00000000000..df47e126489 --- /dev/null +++ b/contrib/tools/yasm/bin/ya.make @@ -0,0 +1,114 @@ +PROGRAM(yasm) + +IF (MUSL) + PEERDIR(contrib/libs/musl_extra) + PEERDIR(contrib/libs/jemalloc) + DISABLE(USE_ASMLIB) + NO_RUNTIME() + ENABLE(MUSL_LITE) +ELSE() + NO_PLATFORM() +ENDIF() + +NO_CLANG_COVERAGE() +NO_COMPILER_WARNINGS() +NO_UTIL() + +ALLOCATOR(FAKE) + +ADDINCL( + contrib/tools/yasm + contrib/tools/yasm/frontends/yasm + contrib/tools/yasm/modules +) + +CFLAGS( + -DHAVE_CONFIG_H + -DYASM_LIB_SOURCE +) + +SRCDIR(contrib/tools/yasm) + +SRCS( + frontends/yasm/yasm-options.c + frontends/yasm/yasm.c + libyasm/assocdat.c + libyasm/bc-align.c + libyasm/bc-data.c + libyasm/bc-incbin.c + libyasm/bc-org.c + libyasm/bc-reserve.c + libyasm/bitvect.c + libyasm/bytecode.c + libyasm/cmake-module.c + libyasm/errwarn.c + libyasm/expr.c + libyasm/file.c + libyasm/floatnum.c + libyasm/hamt.c + libyasm/insn.c + libyasm/intnum.c + libyasm/inttree.c + libyasm/linemap.c + libyasm/md5.c + libyasm/mergesort.c + libyasm/phash.c + libyasm/replace_path.c + libyasm/section.c + libyasm/strcasecmp.c + libyasm/strsep.c + libyasm/symrec.c + libyasm/valparam.c + libyasm/value.c + libyasm/xmalloc.c + libyasm/xstrdup.c + modules/arch/lc3b/lc3barch.c + modules/arch/lc3b/lc3bbc.c + modules/arch/x86/x86arch.c + modules/arch/x86/x86bc.c + modules/arch/x86/x86expr.c + modules/arch/x86/x86id.c + modules/dbgfmts/codeview/cv-dbgfmt.c + modules/dbgfmts/codeview/cv-symline.c + modules/dbgfmts/codeview/cv-type.c + modules/dbgfmts/dwarf2/dwarf2-aranges.c + modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c + modules/dbgfmts/dwarf2/dwarf2-info.c + modules/dbgfmts/dwarf2/dwarf2-line.c + modules/dbgfmts/null/null-dbgfmt.c + modules/dbgfmts/stabs/stabs-dbgfmt.c + modules/gas-token.c + modules/init_plugin.c + modules/lc3bid.c + modules/listfmts/nasm/nasm-listfmt.c + modules/nasm-token.c + modules/objfmts/bin/bin-objfmt.c + modules/objfmts/coff/coff-objfmt.c + modules/objfmts/coff/win64-except.c + modules/objfmts/dbg/dbg-objfmt.c + modules/objfmts/elf/elf-objfmt.c + modules/objfmts/elf/elf-x86-amd64.c + modules/objfmts/elf/elf-x86-x32.c + modules/objfmts/elf/elf-x86-x86.c + modules/objfmts/elf/elf.c + modules/objfmts/macho/macho-objfmt.c + modules/objfmts/rdf/rdf-objfmt.c + modules/objfmts/xdf/xdf-objfmt.c + modules/parsers/gas/gas-parse-intel.c + modules/parsers/gas/gas-parse.c + modules/parsers/gas/gas-parser.c + modules/parsers/nasm/nasm-parse.c + modules/parsers/nasm/nasm-parser.c + modules/preprocs/cpp/cpp-preproc.c + modules/preprocs/gas/gas-eval.c + modules/preprocs/gas/gas-preproc.c + modules/preprocs/nasm/nasm-eval.c + modules/preprocs/nasm/nasm-pp.c + modules/preprocs/nasm/nasm-preproc.c + modules/preprocs/nasm/nasmlib.c + modules/preprocs/raw/raw-preproc.c + modules/x86cpu.c + modules/x86regtmod.c +) + +END() diff --git a/contrib/tools/yasm/ya.make b/contrib/tools/yasm/ya.make new file mode 100644 index 00000000000..79da84c6da6 --- /dev/null +++ b/contrib/tools/yasm/ya.make @@ -0,0 +1,18 @@ +# Autogenerated for platforms: +# darwin-x86_64 +# linux-x86_64 +# windows-x86_64 + +VERSION(1.3.0) + +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/yasm/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/contrib/tools/yasm/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/library/cpp/accurate_accumulate/benchmark/metrics/ya.make b/library/cpp/accurate_accumulate/benchmark/metrics/ya.make new file mode 100644 index 00000000000..5c7ccf91974 --- /dev/null +++ b/library/cpp/accurate_accumulate/benchmark/metrics/ya.make @@ -0,0 +1,15 @@ +PY2TEST() + +SIZE(LARGE) + +TAG( + ya:force_sandbox + sb:intel_e5_2660v1 + ya:fat +) + +TEST_SRCS(main.py) + +DEPENDS(library/cpp/accurate_accumulate/benchmark) + +END() diff --git a/library/cpp/accurate_accumulate/benchmark/ya.make b/library/cpp/accurate_accumulate/benchmark/ya.make new file mode 100644 index 00000000000..5eb3aac4468 --- /dev/null +++ b/library/cpp/accurate_accumulate/benchmark/ya.make @@ -0,0 +1,15 @@ +Y_BENCHMARK() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/accurate_accumulate +) + +END() + +RECURSE( + metrics +) diff --git a/library/cpp/accurate_accumulate/ya.make b/library/cpp/accurate_accumulate/ya.make new file mode 100644 index 00000000000..b4bca269583 --- /dev/null +++ b/library/cpp/accurate_accumulate/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + accurate_accumulate.h + accurate_accumulate.cpp +) + +END() + +RECURSE( + benchmark +) diff --git a/library/cpp/actors/core/ut/ya.make b/library/cpp/actors/core/ut/ya.make new file mode 100644 index 00000000000..44803e76196 --- /dev/null +++ b/library/cpp/actors/core/ut/ya.make @@ -0,0 +1,43 @@ +UNITTEST_FOR(library/cpp/actors/core) + +FORK_SUBTESTS() +IF (SANITIZER_TYPE) + SIZE(LARGE) + TIMEOUT(1200) + TAG(ya:fat) + SPLIT_FACTOR(20) + REQUIREMENTS( + ram:32 + ) +ELSE() + SIZE(MEDIUM) + TIMEOUT(600) + REQUIREMENTS( + ram:16 + ) +ENDIF() + + +PEERDIR( + library/cpp/actors/interconnect + library/cpp/actors/testlib +) + +SRCS( + actor_coroutine_ut.cpp + benchmark_ut.cpp + actor_ut.cpp + actorsystem_ut.cpp + performance_ut.cpp + ask_ut.cpp + balancer_ut.cpp + event_pb_payload_ut.cpp + event_pb_ut.cpp + executor_pool_basic_ut.cpp + executor_pool_united_ut.cpp + log_ut.cpp + mon_ut.cpp + scheduler_actor_ut.cpp +) + +END() diff --git a/library/cpp/actors/core/ya.make b/library/cpp/actors/core/ya.make new file mode 100644 index 00000000000..d5a67c03a52 --- /dev/null +++ b/library/cpp/actors/core/ya.make @@ -0,0 +1,131 @@ +LIBRARY() + +NO_WSHADOW() + +IF (PROFILE_MEMORY_ALLOCATIONS) + CFLAGS(-DPROFILE_MEMORY_ALLOCATIONS) +ENDIF() + +IF (ALLOCATOR == "B" OR ALLOCATOR == "BS" OR ALLOCATOR == "C") + CXXFLAGS(-DBALLOC) + PEERDIR( + library/cpp/balloc/optional + ) +ENDIF() + +SRCS( + actor_bootstrapped.cpp + actor_coroutine.cpp + actor_coroutine.h + actor.cpp + actor.h + actor_virtual.cpp + actorid.cpp + actorid.h + actorsystem.cpp + actorsystem.h + ask.cpp + ask.h + av_bootstrapped.cpp + balancer.h + balancer.cpp + buffer.cpp + buffer.h + callstack.cpp + callstack.h + config.h + cpu_manager.cpp + cpu_manager.h + cpu_state.h + defs.h + event.cpp + event.h + event_load.h + event_local.h + event_pb.cpp + event_pb.h + events.h + events_undelivered.cpp + executelater.h + executor_pool_base.cpp + executor_pool_base.h + executor_pool_basic.cpp + executor_pool_basic.h + executor_pool_io.cpp + executor_pool_io.h + executor_pool_united.cpp + executor_pool_united.h + executor_thread.cpp + executor_thread.h + harmonizer.cpp + harmonizer.h + hfunc.h + interconnect.cpp + interconnect.h + invoke.h + io_dispatcher.cpp + io_dispatcher.h + lease.h + log.cpp + log.h + log_settings.cpp + log_settings.h + log_buffer.cpp + log_buffer.h + log_metrics.h + mailbox.cpp + mailbox.h + mailbox_queue_revolving.h + mailbox_queue_simple.h + mon.h + mon_stats.h + monotonic.cpp + monotonic.h + monotonic_provider.cpp + monotonic_provider.h + worker_context.cpp + worker_context.h + probes.cpp + probes.h + process_stats.cpp + process_stats.h + scheduler_actor.cpp + scheduler_actor.h + scheduler_basic.cpp + scheduler_basic.h + scheduler_cookie.cpp + scheduler_cookie.h + scheduler_queue.h + servicemap.h +) + +GENERATE_ENUM_SERIALIZATION(defs.h) +GENERATE_ENUM_SERIALIZATION(actor.h) +GENERATE_ENUM_SERIALIZATION(log_iface.h) + +PEERDIR( + library/cpp/actors/memory_log + library/cpp/actors/prof + library/cpp/actors/protos + library/cpp/actors/util + library/cpp/execprofile + library/cpp/json/writer + library/cpp/logger + library/cpp/lwtrace + library/cpp/monlib/dynamic_counters + library/cpp/svnversion + library/cpp/time_provider + library/cpp/threading/future +) + +IF (SANITIZER_TYPE == "thread") + SUPPRESSIONS( + tsan.supp + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/actors/dnscachelib/ya.make b/library/cpp/actors/dnscachelib/ya.make new file mode 100644 index 00000000000..62eaafc8f51 --- /dev/null +++ b/library/cpp/actors/dnscachelib/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + dnscache.cpp + dnscache.h + probes.cpp + probes.h + timekeeper.h +) + +PEERDIR( + contrib/libs/c-ares + library/cpp/lwtrace + library/cpp/deprecated/atomic +) + +IF (NOT EXPORT_CMAKE) + ADDINCL( + contrib/libs/c-ares/include + ) +ENDIF() + +END() diff --git a/library/cpp/actors/dnsresolver/ut/ya.make b/library/cpp/actors/dnsresolver/ut/ya.make new file mode 100644 index 00000000000..ec4b117bf7c --- /dev/null +++ b/library/cpp/actors/dnsresolver/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(library/cpp/actors/dnsresolver) + +PEERDIR( + library/cpp/actors/testlib +) + +SRCS( + dnsresolver_caching_ut.cpp + dnsresolver_ondemand_ut.cpp + dnsresolver_ut.cpp +) + +ADDINCL(contrib/libs/c-ares/include) + +TAG(ya:external) +REQUIREMENTS(network:full) + +END() diff --git a/library/cpp/actors/dnsresolver/ya.make b/library/cpp/actors/dnsresolver/ya.make new file mode 100644 index 00000000000..a66125d65c9 --- /dev/null +++ b/library/cpp/actors/dnsresolver/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + dnsresolver.cpp + dnsresolver_caching.cpp + dnsresolver_ondemand.cpp +) + +PEERDIR( + library/cpp/actors/core + contrib/libs/c-ares +) + +ADDINCL(contrib/libs/c-ares/include) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/actors/examples/01_ping_pong/ya.make b/library/cpp/actors/examples/01_ping_pong/ya.make new file mode 100644 index 00000000000..d33cfd3456c --- /dev/null +++ b/library/cpp/actors/examples/01_ping_pong/ya.make @@ -0,0 +1,13 @@ +PROGRAM(example_01_ping_pong) + +ALLOCATOR(LF) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/actors/core +) + +END() diff --git a/library/cpp/actors/examples/02_discovery/ya.make b/library/cpp/actors/examples/02_discovery/ya.make new file mode 100644 index 00000000000..953c13259cb --- /dev/null +++ b/library/cpp/actors/examples/02_discovery/ya.make @@ -0,0 +1,25 @@ +PROGRAM(example_02_discovery) + +ALLOCATOR(LF) + +SRCS( + endpoint.cpp + lookup.cpp + main.cpp + publish.cpp + replica.cpp + services.h +) + +SRCS( + protocol.proto +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/dnsresolver + library/cpp/actors/interconnect + library/cpp/actors/http +) + +END() diff --git a/library/cpp/actors/examples/ya.make b/library/cpp/actors/examples/ya.make new file mode 100644 index 00000000000..0a98074b478 --- /dev/null +++ b/library/cpp/actors/examples/ya.make @@ -0,0 +1,4 @@ +RECURSE( + 01_ping_pong + 02_discovery +) diff --git a/library/cpp/actors/helpers/ut/ya.make b/library/cpp/actors/helpers/ut/ya.make new file mode 100644 index 00000000000..10b298bb729 --- /dev/null +++ b/library/cpp/actors/helpers/ut/ya.make @@ -0,0 +1,31 @@ +UNITTEST_FOR(library/cpp/actors/helpers) + +FORK_SUBTESTS() +IF (SANITIZER_TYPE) + SIZE(LARGE) + TIMEOUT(1200) + TAG(ya:fat) + SPLIT_FACTOR(20) + REQUIREMENTS( + ram:32 + ) +ELSE() + SIZE(MEDIUM) + TIMEOUT(600) + REQUIREMENTS( + ram:16 + ) +ENDIF() + + +PEERDIR( + library/cpp/actors/interconnect + library/cpp/actors/testlib + library/cpp/actors/core +) + +SRCS( + selfping_actor_ut.cpp +) + +END() diff --git a/library/cpp/actors/helpers/ya.make b/library/cpp/actors/helpers/ya.make new file mode 100644 index 00000000000..94acdca7261 --- /dev/null +++ b/library/cpp/actors/helpers/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + activeactors.cpp + activeactors.h + flow_controlled_queue.cpp + flow_controlled_queue.h + future_callback.h + mon_histogram_helper.h + selfping_actor.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/dynamic_counters +) + +END() + +RECURSE_FOR_TESTS( + ut +) + diff --git a/library/cpp/actors/http/ut/ya.make b/library/cpp/actors/http/ut/ya.make new file mode 100644 index 00000000000..84043080534 --- /dev/null +++ b/library/cpp/actors/http/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(library/cpp/actors/http) + +SIZE(SMALL) + +PEERDIR( + library/cpp/actors/testlib +) + +IF (NOT OS_WINDOWS) +SRCS( + http_ut.cpp +) +ELSE() +ENDIF() + +END() diff --git a/library/cpp/actors/http/ya.make b/library/cpp/actors/http/ya.make new file mode 100644 index 00000000000..9b66988ea9a --- /dev/null +++ b/library/cpp/actors/http/ya.make @@ -0,0 +1,36 @@ +LIBRARY() + +SRCS( + http_cache.cpp + http_cache.h + http_compress.cpp + http_config.h + http_proxy_acceptor.cpp + http_proxy_incoming.cpp + http_proxy_outgoing.cpp + http_proxy_sock_impl.h + http_proxy_sock64.h + http_proxy_ssl.h + http_proxy.cpp + http_proxy.h + http_static.cpp + http_static.h + http.cpp + http.h +) + +PEERDIR( + contrib/libs/openssl + contrib/libs/zlib + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/dns + library/cpp/monlib/metrics + library/cpp/string_utils/quote +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/actors/interconnect/mock/ya.make b/library/cpp/actors/interconnect/mock/ya.make new file mode 100644 index 00000000000..d097e3f0945 --- /dev/null +++ b/library/cpp/actors/interconnect/mock/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + ic_mock.cpp + ic_mock.h +) + +SUPPRESSIONS(tsan.supp) + +PEERDIR( + library/cpp/actors/interconnect +) + +END() diff --git a/library/cpp/actors/interconnect/ut/lib/ya.make b/library/cpp/actors/interconnect/ut/lib/ya.make new file mode 100644 index 00000000000..615c6a0e544 --- /dev/null +++ b/library/cpp/actors/interconnect/ut/lib/ya.make @@ -0,0 +1,10 @@ +LIBRARY() + +SRCS( + node.h + test_events.h + test_actors.h + ic_test_cluster.h +) + +END() diff --git a/library/cpp/actors/interconnect/ut/protos/ya.make b/library/cpp/actors/interconnect/ut/protos/ya.make new file mode 100644 index 00000000000..a7ffcd6bd03 --- /dev/null +++ b/library/cpp/actors/interconnect/ut/protos/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + interconnect_test.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/library/cpp/actors/interconnect/ut/ya.make b/library/cpp/actors/interconnect/ut/ya.make new file mode 100644 index 00000000000..d524fc69f05 --- /dev/null +++ b/library/cpp/actors/interconnect/ut/ya.make @@ -0,0 +1,32 @@ +UNITTEST() + +IF (SANITIZER_TYPE == "thread") + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + channel_scheduler_ut.cpp + event_holder_pool_ut.cpp + interconnect_ut.cpp + large.cpp + outgoing_stream_ut.cpp + poller_actor_ut.cpp + dynamic_proxy_ut.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/actors/interconnect/ut/lib + library/cpp/actors/interconnect/ut/protos + library/cpp/actors/testlib + library/cpp/digest/md5 + library/cpp/testing/unittest +) + +END() diff --git a/library/cpp/actors/interconnect/ut_fat/ya.make b/library/cpp/actors/interconnect/ut_fat/ya.make new file mode 100644 index 00000000000..8361c5d9f7e --- /dev/null +++ b/library/cpp/actors/interconnect/ut_fat/ya.make @@ -0,0 +1,21 @@ +UNITTEST() + +SIZE(LARGE) + +TAG(ya:fat) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/actors/interconnect/mock + library/cpp/actors/interconnect/ut/lib + library/cpp/actors/interconnect/ut/protos + library/cpp/testing/unittest + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/actors/interconnect/ut_huge_cluster/ya.make b/library/cpp/actors/interconnect/ut_huge_cluster/ya.make new file mode 100644 index 00000000000..828783323d9 --- /dev/null +++ b/library/cpp/actors/interconnect/ut_huge_cluster/ya.make @@ -0,0 +1,34 @@ +UNITTEST() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +IF (BUILD_TYPE == "RELEASE" OR BUILD_TYPE == "RELWITHDEBINFO") + SRCS( + huge_cluster.cpp + ) +ELSE () + MESSAGE(WARNING "It takes too much time to run test in DEBUG mode, some tests are skipped") +ENDIF () + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/actors/interconnect/ut/lib + library/cpp/actors/interconnect/ut/protos + library/cpp/testing/unittest + library/cpp/actors/testlib +) + +REQUIREMENTS( + cpu:4 + ram:32 +) + +END() diff --git a/library/cpp/actors/interconnect/ya.make b/library/cpp/actors/interconnect/ya.make new file mode 100644 index 00000000000..11355c710c1 --- /dev/null +++ b/library/cpp/actors/interconnect/ya.make @@ -0,0 +1,96 @@ +LIBRARY() + +NO_WSHADOW() + +IF (PROFILE_MEMORY_ALLOCATIONS) + CFLAGS(-DPROFILE_MEMORY_ALLOCATIONS) +ENDIF() + +SRCS( + channel_scheduler.h + event_filter.h + event_holder_pool.h + events_local.h + interconnect_address.cpp + interconnect_address.h + interconnect_channel.cpp + interconnect_channel.h + interconnect_common.h + interconnect_counters.cpp + interconnect.h + interconnect_handshake.cpp + interconnect_handshake.h + interconnect_impl.h + interconnect_mon.cpp + interconnect_mon.h + interconnect_nameserver_dynamic.cpp + interconnect_nameserver_table.cpp + interconnect_proxy_wrapper.cpp + interconnect_proxy_wrapper.h + interconnect_resolve.cpp + interconnect_stream.cpp + interconnect_stream.h + interconnect_tcp_input_session.cpp + interconnect_tcp_proxy.cpp + interconnect_tcp_proxy.h + interconnect_tcp_server.cpp + interconnect_tcp_server.h + interconnect_tcp_session.cpp + interconnect_tcp_session.h + load.cpp + load.h + logging.h + packet.cpp + packet.h + poller_actor.cpp + poller_actor.h + poller.h + poller_tcp.cpp + poller_tcp.h + poller_tcp_unit.cpp + poller_tcp_unit.h + poller_tcp_unit_select.cpp + poller_tcp_unit_select.h + profiler.h + slowpoke_actor.h + types.cpp + types.h + watchdog_timer.h +) + +IF (OS_LINUX) + SRCS( + poller_tcp_unit_epoll.cpp + poller_tcp_unit_epoll.h + ) +ENDIF() + +PEERDIR( + contrib/libs/libc_compat + contrib/libs/openssl + contrib/libs/xxhash + library/cpp/actors/core + library/cpp/actors/dnscachelib + library/cpp/actors/dnsresolver + library/cpp/actors/helpers + library/cpp/actors/prof + library/cpp/actors/protos + library/cpp/actors/util + library/cpp/actors/wilson + library/cpp/digest/crc32c + library/cpp/json + library/cpp/lwtrace + library/cpp/monlib/dynamic_counters + library/cpp/monlib/metrics + library/cpp/monlib/service/pages/tablesorter + library/cpp/openssl/init + library/cpp/packedtypes +) + +END() + +RECURSE_FOR_TESTS( + ut + ut_fat + ut_huge_cluster +) diff --git a/library/cpp/actors/log_backend/ya.make b/library/cpp/actors/log_backend/ya.make new file mode 100644 index 00000000000..ce9f049e9a5 --- /dev/null +++ b/library/cpp/actors/log_backend/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/logger +) + +SRCS( + actor_log_backend.cpp +) + +END() diff --git a/library/cpp/actors/memory_log/ya.make b/library/cpp/actors/memory_log/ya.make new file mode 100644 index 00000000000..ae766a5464b --- /dev/null +++ b/library/cpp/actors/memory_log/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + memlog.cpp + memlog.h + mmap.cpp +) + +PEERDIR( + library/cpp/threading/queue + contrib/libs/linuxvdso + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/actors/prof/ut/ya.make b/library/cpp/actors/prof/ut/ya.make new file mode 100644 index 00000000000..e439856698a --- /dev/null +++ b/library/cpp/actors/prof/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/actors/prof) + +SRCS( + tag_ut.cpp +) + +END() diff --git a/library/cpp/actors/prof/ya.make b/library/cpp/actors/prof/ya.make new file mode 100644 index 00000000000..ca29f6cf390 --- /dev/null +++ b/library/cpp/actors/prof/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + tag.cpp + tcmalloc.cpp +) + +PEERDIR( + contrib/libs/tcmalloc/malloc_extension + library/cpp/charset + library/cpp/containers/atomizer +) + +IF (PROFILE_MEMORY_ALLOCATIONS) + CFLAGS(-DPROFILE_MEMORY_ALLOCATIONS) + PEERDIR( + library/cpp/malloc/api + library/cpp/lfalloc/dbg_info + library/cpp/ytalloc/api + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/actors/protos/ya.make b/library/cpp/actors/protos/ya.make new file mode 100644 index 00000000000..c9139191ec0 --- /dev/null +++ b/library/cpp/actors/protos/ya.make @@ -0,0 +1,12 @@ +PROTO_LIBRARY() + +SRCS( + actors.proto + interconnect.proto + services_common.proto + unittests.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/library/cpp/actors/testlib/ut/ya.make b/library/cpp/actors/testlib/ut/ya.make new file mode 100644 index 00000000000..ea6aef37a61 --- /dev/null +++ b/library/cpp/actors/testlib/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(library/cpp/actors/testlib) + +FORK_SUBTESTS() +SIZE(SMALL) + + +PEERDIR( + library/cpp/actors/core +) + +SRCS( + decorator_ut.cpp +) + +END() diff --git a/library/cpp/actors/testlib/ya.make b/library/cpp/actors/testlib/ya.make new file mode 100644 index 00000000000..0bd44ddd576 --- /dev/null +++ b/library/cpp/actors/testlib/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + test_runtime.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect/mock + library/cpp/actors/protos + library/cpp/random_provider + library/cpp/time_provider +) + +IF (GCC) + CFLAGS(-fno-devirtualize-speculatively) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/actors/util/ut/ya.make b/library/cpp/actors/util/ut/ya.make new file mode 100644 index 00000000000..9ac85047517 --- /dev/null +++ b/library/cpp/actors/util/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(library/cpp/actors/util) + +IF (WITH_VALGRIND) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + cpu_load_log_ut.cpp + memory_tracker_ut.cpp + thread_load_log_ut.cpp + rope_ut.cpp + rc_buf_ut.cpp + shared_data_ut.cpp + shared_data_rope_backend_ut.cpp + shared_data_native_rope_backend_ut.cpp + unordered_cache_ut.cpp +) + +END() diff --git a/library/cpp/actors/util/ya.make b/library/cpp/actors/util/ya.make new file mode 100644 index 00000000000..6dfc0e97a80 --- /dev/null +++ b/library/cpp/actors/util/ya.make @@ -0,0 +1,47 @@ +LIBRARY() + +SRCS( + affinity.cpp + affinity.h + cpu_load_log.h + cpumask.h + datetime.h + defs.h + funnel_queue.h + futex.h + intrinsics.h + local_process_key.h + named_tuple.h + queue_chunk.h + queue_oneone_inplace.h + memory_track.cpp + memory_track.h + memory_tracker.cpp + memory_tracker.h + recentwnd.h + rope.h + rc_buf.h + shared_data.h + shared_data.cpp + shared_data_rope_backend.h + should_continue.cpp + should_continue.h + thread.h + threadparkpad.cpp + threadparkpad.h + thread_load_log.h + ticket_lock.h + timerfd.h + unordered_cache.h +) + +PEERDIR( + library/cpp/deprecated/atomic + library/cpp/pop_count +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/actors/wilson/protos/ya.make b/library/cpp/actors/wilson/protos/ya.make new file mode 100644 index 00000000000..9a756e8da0f --- /dev/null +++ b/library/cpp/actors/wilson/protos/ya.make @@ -0,0 +1,17 @@ +PROTO_LIBRARY() + + GRPC() + + SRCS( + common.proto + resource.proto + service.proto + trace.proto + ) + + EXCLUDE_TAGS( + GO_PROTO + JAVA_PROTO + ) + +END() diff --git a/library/cpp/actors/wilson/ya.make b/library/cpp/actors/wilson/ya.make new file mode 100644 index 00000000000..0dc8ba79add --- /dev/null +++ b/library/cpp/actors/wilson/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + wilson_event.cpp + wilson_span.cpp + wilson_profile_span.cpp + wilson_trace.cpp + wilson_uploader.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/protos + library/cpp/actors/wilson/protos +) + +END() + +RECURSE( + protos +) diff --git a/library/cpp/actors/ya.make b/library/cpp/actors/ya.make new file mode 100644 index 00000000000..2612c414cd4 --- /dev/null +++ b/library/cpp/actors/ya.make @@ -0,0 +1,15 @@ +RECURSE( + log_backend + core + dnsresolver + examples + interconnect + memory_log + helpers + prof + protos + util + wilson + testlib + http +) diff --git a/library/cpp/archive/ut/ya.make b/library/cpp/archive/ut/ya.make new file mode 100644 index 00000000000..d8022cd70c8 --- /dev/null +++ b/library/cpp/archive/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/archive +) + +SRCDIR(library/cpp/archive) + +SRCS( + yarchive_ut.cpp + directory_models_archive_reader_ut.cpp +) + +END() diff --git a/library/cpp/archive/ya.make b/library/cpp/archive/ya.make new file mode 100644 index 00000000000..ff20c9ffbd8 --- /dev/null +++ b/library/cpp/archive/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + yarchive.cpp + yarchive.h + directory_models_archive_reader.cpp + directory_models_archive_reader.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/balloc/lib/ya.make b/library/cpp/balloc/lib/ya.make new file mode 100644 index 00000000000..a2c5f800087 --- /dev/null +++ b/library/cpp/balloc/lib/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +NO_UTIL() +NO_COMPILER_WARNINGS() + +SRCS( + alloc_stats.cpp + alloc_stats.h +) + +IF (OS_LINUX) + PEERDIR( + contrib/libs/linuxvdso + ) +ENDIF() + +PEERDIR( + library/cpp/balloc/setup + library/cpp/malloc/api +) + +SET(IDE_FOLDER "util") + +END() + +NEED_CHECK() diff --git a/library/cpp/balloc/setup/ya.make b/library/cpp/balloc/setup/ya.make new file mode 100644 index 00000000000..90bb97ea288 --- /dev/null +++ b/library/cpp/balloc/setup/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +NO_UTIL() + +IF ("${YMAKE}" MATCHES "devtools") + CFLAGS(-DYMAKE=1) +ENDIF() + +SRCS( + alloc.cpp + enable.cpp +) + +END() + +NEED_CHECK() diff --git a/library/cpp/balloc/ya.make b/library/cpp/balloc/ya.make new file mode 100644 index 00000000000..a8480fb4579 --- /dev/null +++ b/library/cpp/balloc/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +NO_UTIL() +ALLOCATOR_IMPL() +NO_COMPILER_WARNINGS() + +IF (OS_WINDOWS) + PEERDIR( + library/cpp/lfalloc + ) +ELSE() + SRCS( + balloc.cpp + malloc-info.cpp + ) + + PEERDIR( + library/cpp/balloc/lib + ) +ENDIF() + +END() + +NEED_CHECK() diff --git a/library/cpp/binsaver/ut/ya.make b/library/cpp/binsaver/ut/ya.make new file mode 100644 index 00000000000..de198b31a45 --- /dev/null +++ b/library/cpp/binsaver/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(library/cpp/binsaver) + +SRCS( + binsaver_ut.cpp +) + +PEERDIR(library/cpp/binsaver/ut_util) + +END() diff --git a/library/cpp/binsaver/ut_util/ya.make b/library/cpp/binsaver/ut_util/ya.make new file mode 100644 index 00000000000..39b6c955b23 --- /dev/null +++ b/library/cpp/binsaver/ut_util/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + ut_util.cpp +) + +PEERDIR( + library/cpp/binsaver + library/cpp/testing/unittest +) + +END() diff --git a/library/cpp/binsaver/ya.make b/library/cpp/binsaver/ya.make new file mode 100644 index 00000000000..ae26fa93c16 --- /dev/null +++ b/library/cpp/binsaver/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + class_factory.h + bin_saver.cpp + blob_io.cpp + buffered_io.cpp + mem_io.cpp + util_stream_io.cpp +) + +PEERDIR( + library/cpp/containers/2d_array +) + +END() + +RECURSE_FOR_TESTS( + ut + ut_util +) diff --git a/library/cpp/bit_io/ut/ya.make b/library/cpp/bit_io/ut/ya.make new file mode 100644 index 00000000000..a206a477e10 --- /dev/null +++ b/library/cpp/bit_io/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/bit_io) + +SRCS( + bitinout_ut.cpp +) + +END() diff --git a/library/cpp/bit_io/ya.make b/library/cpp/bit_io/ya.make new file mode 100644 index 00000000000..cb046bcf7e7 --- /dev/null +++ b/library/cpp/bit_io/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + library/cpp/deprecated/accessors +) + +SRCS( + bitinput.cpp + bitinput_impl.cpp + bitoutput.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/blockcodecs/codecs/brotli/ya.make b/library/cpp/blockcodecs/codecs/brotli/ya.make new file mode 100644 index 00000000000..f1983cef159 --- /dev/null +++ b/library/cpp/blockcodecs/codecs/brotli/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + contrib/libs/brotli/enc + contrib/libs/brotli/dec + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL brotli.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/bzip/ya.make b/library/cpp/blockcodecs/codecs/bzip/ya.make new file mode 100644 index 00000000000..7c835803418 --- /dev/null +++ b/library/cpp/blockcodecs/codecs/bzip/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/libbz2 + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL bzip.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/fastlz/ya.make b/library/cpp/blockcodecs/codecs/fastlz/ya.make new file mode 100644 index 00000000000..24306c308c5 --- /dev/null +++ b/library/cpp/blockcodecs/codecs/fastlz/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/fastlz + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL fastlz.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/legacy_zstd06/ya.make b/library/cpp/blockcodecs/codecs/legacy_zstd06/ya.make new file mode 100644 index 00000000000..d4735651b9f --- /dev/null +++ b/library/cpp/blockcodecs/codecs/legacy_zstd06/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/zstd06 + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL legacy_zstd06.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/lz4/ya.make b/library/cpp/blockcodecs/codecs/lz4/ya.make new file mode 100644 index 00000000000..c66b8fc634a --- /dev/null +++ b/library/cpp/blockcodecs/codecs/lz4/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/lz4 + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL lz4.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/lzma/ya.make b/library/cpp/blockcodecs/codecs/lzma/ya.make new file mode 100644 index 00000000000..20db16c83d2 --- /dev/null +++ b/library/cpp/blockcodecs/codecs/lzma/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/lzmasdk + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL lzma.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/snappy/ya.make b/library/cpp/blockcodecs/codecs/snappy/ya.make new file mode 100644 index 00000000000..122cd721cc0 --- /dev/null +++ b/library/cpp/blockcodecs/codecs/snappy/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/snappy + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL snappy.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/zlib/ya.make b/library/cpp/blockcodecs/codecs/zlib/ya.make new file mode 100644 index 00000000000..206ce30e102 --- /dev/null +++ b/library/cpp/blockcodecs/codecs/zlib/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/zlib + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL zlib.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/zstd/ya.make b/library/cpp/blockcodecs/codecs/zstd/ya.make new file mode 100644 index 00000000000..3e65f7ca2fa --- /dev/null +++ b/library/cpp/blockcodecs/codecs/zstd/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/zstd + library/cpp/blockcodecs/core +) + +SRCS( + GLOBAL zstd.cpp +) + +END() diff --git a/library/cpp/blockcodecs/core/ya.make b/library/cpp/blockcodecs/core/ya.make new file mode 100644 index 00000000000..ac9789ab7f3 --- /dev/null +++ b/library/cpp/blockcodecs/core/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +SRCS( + codecs.cpp + stream.cpp +) + +END() diff --git a/library/cpp/blockcodecs/fuzz/proto/ya.make b/library/cpp/blockcodecs/fuzz/proto/ya.make new file mode 100644 index 00000000000..93252bce8da --- /dev/null +++ b/library/cpp/blockcodecs/fuzz/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + case.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/library/cpp/blockcodecs/fuzz/ya.make b/library/cpp/blockcodecs/fuzz/ya.make new file mode 100644 index 00000000000..c917e89aac0 --- /dev/null +++ b/library/cpp/blockcodecs/fuzz/ya.make @@ -0,0 +1,18 @@ +IF (NOT MSVC) + FUZZ() + + SIZE(MEDIUM) + + SRCS( + main.cpp + ) + + PEERDIR( + contrib/libs/protobuf + contrib/libs/protobuf-mutator + library/cpp/blockcodecs + library/cpp/blockcodecs/fuzz/proto + ) + + END() +ENDIF() diff --git a/library/cpp/blockcodecs/ut/ya.make b/library/cpp/blockcodecs/ut/ya.make new file mode 100644 index 00000000000..d39e21f3710 --- /dev/null +++ b/library/cpp/blockcodecs/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(library/cpp/blockcodecs) + +FORK_TESTS() + +FORK_SUBTESTS() + +SPLIT_FACTOR(40) + +TIMEOUT(300) + +SIZE(MEDIUM) + +SRCS( + codecs_ut.cpp +) + +END() diff --git a/library/cpp/blockcodecs/ya.make b/library/cpp/blockcodecs/ya.make new file mode 100644 index 00000000000..add534d2d69 --- /dev/null +++ b/library/cpp/blockcodecs/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +PEERDIR( + library/cpp/blockcodecs/core + library/cpp/blockcodecs/codecs/brotli + library/cpp/blockcodecs/codecs/bzip + library/cpp/blockcodecs/codecs/fastlz + library/cpp/blockcodecs/codecs/legacy_zstd06 + library/cpp/blockcodecs/codecs/lz4 + library/cpp/blockcodecs/codecs/lzma + library/cpp/blockcodecs/codecs/snappy + library/cpp/blockcodecs/codecs/zlib + library/cpp/blockcodecs/codecs/zstd +) + +SRCS( + codecs.cpp + stream.cpp +) + +END() + +RECURSE_FOR_TESTS( + fuzz + ut +) diff --git a/library/cpp/bucket_quoter/ut/ya.make b/library/cpp/bucket_quoter/ut/ya.make new file mode 100644 index 00000000000..d7bc7a30edf --- /dev/null +++ b/library/cpp/bucket_quoter/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +FORK_SUBTESTS() +SRCS( + main.cpp + test_namespace.cpp +) +PEERDIR( + library/cpp/bucket_quoter + library/cpp/getopt +) + +END() diff --git a/library/cpp/bucket_quoter/ya.make b/library/cpp/bucket_quoter/ya.make new file mode 100644 index 00000000000..d74141e39d2 --- /dev/null +++ b/library/cpp/bucket_quoter/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + bucket_quoter.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/build_info/ya.make b/library/cpp/build_info/ya.make new file mode 100644 index 00000000000..8e5d7b6c83e --- /dev/null +++ b/library/cpp/build_info/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +DEFAULT(SANDBOX_TASK_ID 0) +DEFAULT(KOSHER_SVN_VERSION "") + +CREATE_BUILDINFO_FOR(buildinfo_data.h) + +PEERDIR( + library/cpp/string_utils/base64 +) + +SRCS( + sandbox.cpp.in + build_info.cpp.in + build_info_static.cpp +) + +END() diff --git a/library/cpp/cache/ut/ya.make b/library/cpp/cache/ut/ya.make new file mode 100644 index 00000000000..32fb8fd1531 --- /dev/null +++ b/library/cpp/cache/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/cache +) + +SRCS( + cache_ut.cpp +) + +END() diff --git a/library/cpp/cache/ya.make b/library/cpp/cache/ya.make new file mode 100644 index 00000000000..27f94e52a60 --- /dev/null +++ b/library/cpp/cache/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + cache.cpp + thread_safe_cache.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/case_insensitive_string/ut/ya.make b/library/cpp/case_insensitive_string/ut/ya.make new file mode 100644 index 00000000000..85db6ec4681 --- /dev/null +++ b/library/cpp/case_insensitive_string/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/case_insensitive_string) + +SRCS( + case_insensitive_string_ut.cpp +) + +END() diff --git a/library/cpp/case_insensitive_string/ya.make b/library/cpp/case_insensitive_string/ya.make new file mode 100644 index 00000000000..1057ab7adaf --- /dev/null +++ b/library/cpp/case_insensitive_string/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + case_insensitive_char_traits.cpp + case_insensitive_string.cpp +) + +PEERDIR( + contrib/libs/libc_compat + library/cpp/digest/murmur +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/cgiparam/fuzz/ya.make b/library/cpp/cgiparam/fuzz/ya.make new file mode 100644 index 00000000000..dd4cda38f5e --- /dev/null +++ b/library/cpp/cgiparam/fuzz/ya.make @@ -0,0 +1,11 @@ +FUZZ() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/cgiparam +) + +END() diff --git a/library/cpp/cgiparam/ut/ya.make b/library/cpp/cgiparam/ut/ya.make new file mode 100644 index 00000000000..0edb867245b --- /dev/null +++ b/library/cpp/cgiparam/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/cgiparam) + +SRCS( + cgiparam_ut.cpp +) + +END() diff --git a/library/cpp/cgiparam/ya.make b/library/cpp/cgiparam/ya.make new file mode 100644 index 00000000000..3db2e22adc4 --- /dev/null +++ b/library/cpp/cgiparam/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + cgiparam.cpp + cgiparam.h +) + +PEERDIR( + library/cpp/iterator + library/cpp/string_utils/quote + library/cpp/string_utils/scan +) + +END() + +RECURSE_FOR_TESTS( + fuzz + ut +) diff --git a/library/cpp/charset/ut/ya.make b/library/cpp/charset/ut/ya.make new file mode 100644 index 00000000000..42f7ca54e20 --- /dev/null +++ b/library/cpp/charset/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(library/cpp/charset) + +SRCS( + ci_string_ut.cpp + codepage_ut.cpp + iconv_ut.cpp + wide_ut.cpp +) + +END() diff --git a/library/cpp/charset/ya.make b/library/cpp/charset/ya.make new file mode 100644 index 00000000000..f9fbbf9d09a --- /dev/null +++ b/library/cpp/charset/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +IF (NOT OPENSOURCE) + CXXFLAGS(-DUSE_ICONV_EXTENSIONS) +ENDIF() + +SRCS( + generated/cp_data.cpp + generated/encrec_data.cpp + codepage.cpp + cp_encrec.cpp + doccodes.cpp + iconv.cpp + recyr.hh + recyr_int.hh + ci_string.cpp + wide.cpp +) + +PEERDIR( + contrib/libs/libiconv +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/codecs/float_huffman_bench/ya.make b/library/cpp/codecs/float_huffman_bench/ya.make new file mode 100644 index 00000000000..cc1bf1c7795 --- /dev/null +++ b/library/cpp/codecs/float_huffman_bench/ya.make @@ -0,0 +1,11 @@ +G_BENCHMARK() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/codecs +) + +END() diff --git a/library/cpp/codecs/greedy_dict/ut/ya.make b/library/cpp/codecs/greedy_dict/ut/ya.make new file mode 100644 index 00000000000..acb110d061d --- /dev/null +++ b/library/cpp/codecs/greedy_dict/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/codecs/greedy_dict) + +SRCS( + greedy_dict_ut.cpp +) + +END() diff --git a/library/cpp/codecs/greedy_dict/ya.make b/library/cpp/codecs/greedy_dict/ya.make new file mode 100644 index 00000000000..f4b2714f419 --- /dev/null +++ b/library/cpp/codecs/greedy_dict/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + gd_builder.cpp + gd_entry.cpp +) + +PEERDIR( + library/cpp/containers/comptrie + library/cpp/string_utils/relaxed_escaper +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/codecs/ut/ya.make b/library/cpp/codecs/ut/ya.make new file mode 100644 index 00000000000..b5197692832 --- /dev/null +++ b/library/cpp/codecs/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST() + +PEERDIR( + library/cpp/string_utils/base64 + library/cpp/codecs + library/cpp/string_utils/relaxed_escaper +) + +SRCS( + tls_cache_ut.cpp + codecs_ut.cpp + float_huffman_ut.cpp +) + +END() diff --git a/library/cpp/codecs/ya.make b/library/cpp/codecs/ya.make new file mode 100644 index 00000000000..f3a39c1e51f --- /dev/null +++ b/library/cpp/codecs/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +SRCS( + tls_cache.cpp + codecs.cpp + codecs_registry.cpp + comptable_codec.cpp + delta_codec.cpp + float_huffman.cpp + huffman_codec.cpp + pfor_codec.cpp + solar_codec.cpp + zstd_dict_codec.cpp +) + +PEERDIR( + contrib/libs/zstd + library/cpp/bit_io + library/cpp/blockcodecs + library/cpp/codecs/greedy_dict + library/cpp/comptable + library/cpp/containers/comptrie + library/cpp/deprecated/accessors + library/cpp/packers + library/cpp/string_utils/relaxed_escaper +) + +END() + +RECURSE( + greedy_dict + float_huffman_bench + ut +) diff --git a/library/cpp/colorizer/ut/ya.make b/library/cpp/colorizer/ut/ya.make new file mode 100644 index 00000000000..493514e1768 --- /dev/null +++ b/library/cpp/colorizer/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/colorizer) + +SRCS( + colorizer_ut.cpp +) + +END() diff --git a/library/cpp/colorizer/ya.make b/library/cpp/colorizer/ya.make new file mode 100644 index 00000000000..eb1c01850b2 --- /dev/null +++ b/library/cpp/colorizer/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + colors.cpp + output.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/compproto/ut/ya.make b/library/cpp/compproto/ut/ya.make new file mode 100644 index 00000000000..2686f5b4804 --- /dev/null +++ b/library/cpp/compproto/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/compproto +) + +SRCDIR(library/cpp/compproto) + +SRCS( + compproto_ut.cpp +) + +END() diff --git a/library/cpp/compproto/ya.make b/library/cpp/compproto/ya.make new file mode 100644 index 00000000000..dc9ad86f035 --- /dev/null +++ b/library/cpp/compproto/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + bit.h + compressor.h + huff.h + metainfo.h + lib.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/comptable/usage/ya.make b/library/cpp/comptable/usage/ya.make new file mode 100644 index 00000000000..e622cc106e5 --- /dev/null +++ b/library/cpp/comptable/usage/ya.make @@ -0,0 +1,11 @@ +PROGRAM() + +SRCS( + usage.cpp +) + +PEERDIR( + library/cpp/comptable +) + +END() diff --git a/library/cpp/comptable/ut/ya.make b/library/cpp/comptable/ut/ya.make new file mode 100644 index 00000000000..d98ecad7b68 --- /dev/null +++ b/library/cpp/comptable/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/comptable) + +SRCS( + comptable_ut.cpp +) + +END() diff --git a/library/cpp/comptable/ya.make b/library/cpp/comptable/ya.make new file mode 100644 index 00000000000..a4e6e286d2f --- /dev/null +++ b/library/cpp/comptable/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + comptable.cpp +) + +PEERDIR( + library/cpp/compproto +) + +END() + +RECURSE( + usage + ut +) diff --git a/library/cpp/config/ya.make b/library/cpp/config/ya.make new file mode 100644 index 00000000000..14646644adf --- /dev/null +++ b/library/cpp/config/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +PEERDIR( + library/cpp/archive + library/cpp/json + library/cpp/lua + library/cpp/string_utils/relaxed_escaper +) + +ARCHIVE( + NAME code.inc + support/pp.lua +) + +SRCS( + config.cpp + sax.cpp + value.cpp + markup.cpp + markupfsm.h.rl6 + ini.cpp + domscheme.cpp +) + +END() diff --git a/library/cpp/containers/2d_array/ya.make b/library/cpp/containers/2d_array/ya.make new file mode 100644 index 00000000000..50aa2a5f8b8 --- /dev/null +++ b/library/cpp/containers/2d_array/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + 2d_array.cpp +) + +END() diff --git a/library/cpp/containers/absl_flat_hash/ya.make b/library/cpp/containers/absl_flat_hash/ya.make new file mode 100644 index 00000000000..8a7731d8047 --- /dev/null +++ b/library/cpp/containers/absl_flat_hash/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + contrib/restricted/abseil-cpp/absl/container +) + +# WARN thegeorg@: removing this ADDINCL will break svn selective checkout. Just don't. +ADDINCL( + contrib/restricted/abseil-cpp +) + +SRCS( + flat_hash_map.cpp + flat_hash_set.cpp +) + +END() diff --git a/library/cpp/containers/atomizer/ya.make b/library/cpp/containers/atomizer/ya.make new file mode 100644 index 00000000000..ee755e4186c --- /dev/null +++ b/library/cpp/containers/atomizer/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + library/cpp/containers/str_map +) + +SRCS( + atomizer.cpp +) + +END() diff --git a/library/cpp/containers/bitseq/ut/ya.make b/library/cpp/containers/bitseq/ut/ya.make new file mode 100644 index 00000000000..1b835458c95 --- /dev/null +++ b/library/cpp/containers/bitseq/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/containers/bitseq) + +SRCS( + bititerator_ut.cpp + bitvector_ut.cpp +) + +END() diff --git a/library/cpp/containers/bitseq/ya.make b/library/cpp/containers/bitseq/ya.make new file mode 100644 index 00000000000..a59c3e765ef --- /dev/null +++ b/library/cpp/containers/bitseq/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + util/draft + library/cpp/pop_count +) + +SRCS( + bitvector.cpp + readonly_bitvector.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/containers/compact_vector/ut/ya.make b/library/cpp/containers/compact_vector/ut/ya.make new file mode 100644 index 00000000000..1a84894570a --- /dev/null +++ b/library/cpp/containers/compact_vector/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST() + +SRCDIR(library/cpp/containers/compact_vector) + +SRCS( + compact_vector_ut.cpp +) + +END() diff --git a/library/cpp/containers/compact_vector/ya.make b/library/cpp/containers/compact_vector/ya.make new file mode 100644 index 00000000000..b7d97b13536 --- /dev/null +++ b/library/cpp/containers/compact_vector/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + compact_vector.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/containers/comptrie/benchmark/ya.make b/library/cpp/containers/comptrie/benchmark/ya.make new file mode 100644 index 00000000000..d0d42fb7d7b --- /dev/null +++ b/library/cpp/containers/comptrie/benchmark/ya.make @@ -0,0 +1,12 @@ +Y_BENCHMARK() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/containers/comptrie + util +) + +END() diff --git a/library/cpp/containers/comptrie/ut/ya.make b/library/cpp/containers/comptrie/ut/ya.make new file mode 100644 index 00000000000..3a9bdefcbd1 --- /dev/null +++ b/library/cpp/containers/comptrie/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/containers/comptrie) + +SRCS( + comptrie_ut.cpp +) + +END() diff --git a/library/cpp/containers/comptrie/ya.make b/library/cpp/containers/comptrie/ya.make new file mode 100644 index 00000000000..8931bfb3835 --- /dev/null +++ b/library/cpp/containers/comptrie/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +SRCS( + array_with_size.h + chunked_helpers_trie.h + comptrie.h + comptrie_packer.h + comptrie_trie.h + first_symbol_iterator.h + key_selector.h + leaf_skipper.h + set.h + comptrie.cpp + comptrie_builder.cpp + comptrie_impl.cpp + make_fast_layout.cpp + minimize.cpp + node.cpp + opaque_trie_iterator.cpp + prefix_iterator.cpp + search_iterator.cpp + write_trie_backwards.cpp + writeable_node.cpp +) + +PEERDIR( + library/cpp/packers + library/cpp/containers/compact_vector + library/cpp/on_disk/chunks + util/draft +) + +END() + +RECURSE( + benchmark + ut +) diff --git a/library/cpp/containers/disjoint_interval_tree/ut/ya.make b/library/cpp/containers/disjoint_interval_tree/ut/ya.make new file mode 100644 index 00000000000..b4ccc419176 --- /dev/null +++ b/library/cpp/containers/disjoint_interval_tree/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/containers/disjoint_interval_tree) + +SRCS( + disjoint_interval_tree_ut.cpp +) + +END() diff --git a/library/cpp/containers/disjoint_interval_tree/ya.make b/library/cpp/containers/disjoint_interval_tree/ya.make new file mode 100644 index 00000000000..688a415c0fb --- /dev/null +++ b/library/cpp/containers/disjoint_interval_tree/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +SRCS(disjoint_interval_tree.cpp) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/containers/intrusive_avl_tree/ut/ya.make b/library/cpp/containers/intrusive_avl_tree/ut/ya.make new file mode 100644 index 00000000000..f17a1aee31a --- /dev/null +++ b/library/cpp/containers/intrusive_avl_tree/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/containers/intrusive_avl_tree) + +SRCS( + avltree_ut.cpp +) + +END() diff --git a/library/cpp/containers/intrusive_avl_tree/ya.make b/library/cpp/containers/intrusive_avl_tree/ya.make new file mode 100644 index 00000000000..ef546dcd58d --- /dev/null +++ b/library/cpp/containers/intrusive_avl_tree/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + avltree.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/containers/intrusive_rb_tree/fuzz/ya.make b/library/cpp/containers/intrusive_rb_tree/fuzz/ya.make new file mode 100644 index 00000000000..9043c78472f --- /dev/null +++ b/library/cpp/containers/intrusive_rb_tree/fuzz/ya.make @@ -0,0 +1,15 @@ +FUZZ() + +SIZE(LARGE) + +TAG(ya:fat) + +PEERDIR( + library/cpp/containers/intrusive_rb_tree +) + +SRCS( + rb_tree_fuzzing.cpp +) + +END() diff --git a/library/cpp/containers/intrusive_rb_tree/ut/ya.make b/library/cpp/containers/intrusive_rb_tree/ut/ya.make new file mode 100644 index 00000000000..db8d6f0a723 --- /dev/null +++ b/library/cpp/containers/intrusive_rb_tree/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/containers/intrusive_rb_tree) + +SRCS( + rb_tree_ut.cpp +) + +END() diff --git a/library/cpp/containers/intrusive_rb_tree/ya.make b/library/cpp/containers/intrusive_rb_tree/ya.make new file mode 100644 index 00000000000..492f83e6707 --- /dev/null +++ b/library/cpp/containers/intrusive_rb_tree/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + rb_tree.cpp +) + +END() + +RECURSE( + fuzz + ut +) diff --git a/library/cpp/containers/paged_vector/ut/ya.make b/library/cpp/containers/paged_vector/ut/ya.make new file mode 100644 index 00000000000..d0ffac4d79b --- /dev/null +++ b/library/cpp/containers/paged_vector/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/containers/paged_vector +) + +SRCS( + paged_vector_ut.cpp +) + +END() diff --git a/library/cpp/containers/paged_vector/ya.make b/library/cpp/containers/paged_vector/ya.make new file mode 100644 index 00000000000..b03a0a2deda --- /dev/null +++ b/library/cpp/containers/paged_vector/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + paged_vector.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/containers/ring_buffer/ya.make b/library/cpp/containers/ring_buffer/ya.make new file mode 100644 index 00000000000..c9220b578ab --- /dev/null +++ b/library/cpp/containers/ring_buffer/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + ring_buffer.cpp +) + +END() diff --git a/library/cpp/containers/sorted_vector/ut/ya.make b/library/cpp/containers/sorted_vector/ut/ya.make new file mode 100644 index 00000000000..3c67b30c190 --- /dev/null +++ b/library/cpp/containers/sorted_vector/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/containers/sorted_vector) + + +SRCS( + sorted_vector_ut.cpp +) + +END() diff --git a/library/cpp/containers/sorted_vector/ya.make b/library/cpp/containers/sorted_vector/ya.make new file mode 100644 index 00000000000..9f32d973595 --- /dev/null +++ b/library/cpp/containers/sorted_vector/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +SRCS( + sorted_vector.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/containers/stack_array/ut/ya.make b/library/cpp/containers/stack_array/ut/ya.make new file mode 100644 index 00000000000..fdd5b8cdbac --- /dev/null +++ b/library/cpp/containers/stack_array/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/containers/stack_array) + +SRCS( + tests_ut.cpp +) + +END() diff --git a/library/cpp/containers/stack_array/ya.make b/library/cpp/containers/stack_array/ya.make new file mode 100644 index 00000000000..8bce0023e32 --- /dev/null +++ b/library/cpp/containers/stack_array/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + range_ops.cpp + stack_array.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/containers/stack_vector/ut/ya.make b/library/cpp/containers/stack_vector/ut/ya.make new file mode 100644 index 00000000000..1c07585ff7f --- /dev/null +++ b/library/cpp/containers/stack_vector/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST() + +SRCDIR(library/cpp/containers/stack_vector) + +SRCS( + stack_vec_ut.cpp +) + +END() diff --git a/library/cpp/containers/stack_vector/ya.make b/library/cpp/containers/stack_vector/ya.make new file mode 100644 index 00000000000..c36f19d82dc --- /dev/null +++ b/library/cpp/containers/stack_vector/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +SRCS( + stack_vec.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/containers/str_map/ya.make b/library/cpp/containers/str_map/ya.make new file mode 100644 index 00000000000..893e6beedd1 --- /dev/null +++ b/library/cpp/containers/str_map/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + str_map.cpp +) + +END() diff --git a/library/cpp/containers/top_keeper/ut/ya.make b/library/cpp/containers/top_keeper/ut/ya.make new file mode 100644 index 00000000000..b15057918b3 --- /dev/null +++ b/library/cpp/containers/top_keeper/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/containers/top_keeper) + +SRCS( + top_keeper_ut.cpp +) + +END() diff --git a/library/cpp/containers/top_keeper/ya.make b/library/cpp/containers/top_keeper/ya.make new file mode 100644 index 00000000000..e90d7b7e942 --- /dev/null +++ b/library/cpp/containers/top_keeper/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + top_keeper.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) + + diff --git a/library/cpp/coroutine/engine/stack/benchmark/ya.make b/library/cpp/coroutine/engine/stack/benchmark/ya.make new file mode 100644 index 00000000000..f2fca4aeb5a --- /dev/null +++ b/library/cpp/coroutine/engine/stack/benchmark/ya.make @@ -0,0 +1,11 @@ +G_BENCHMARK() + +SRCS( + alloc_bm.cpp +) + +PEERDIR( + library/cpp/coroutine/engine +) + +END()
\ No newline at end of file diff --git a/library/cpp/coroutine/engine/stack/ut/ya.make b/library/cpp/coroutine/engine/stack/ut/ya.make new file mode 100644 index 00000000000..e3f33ecf6c8 --- /dev/null +++ b/library/cpp/coroutine/engine/stack/ut/ya.make @@ -0,0 +1,15 @@ +GTEST() + +SRCS( + stack_allocator_ut.cpp + stack_guards_ut.cpp + stack_pool_ut.cpp + stack_ut.cpp + stack_utils_ut.cpp +) + +PEERDIR( + library/cpp/coroutine/engine +) + +END()
\ No newline at end of file diff --git a/library/cpp/coroutine/engine/ut/ya.make b/library/cpp/coroutine/engine/ut/ya.make new file mode 100644 index 00000000000..450c3bdd7c9 --- /dev/null +++ b/library/cpp/coroutine/engine/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/coroutine/engine) + +SRCS( + coroutine_ut.cpp +) + +END() diff --git a/library/cpp/coroutine/engine/ya.make b/library/cpp/coroutine/engine/ya.make new file mode 100644 index 00000000000..fcd9b877417 --- /dev/null +++ b/library/cpp/coroutine/engine/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(poller.h) + +GENERATE_ENUM_SERIALIZATION(stack/stack_common.h) + +PEERDIR( + contrib/libs/libc_compat + library/cpp/containers/intrusive_rb_tree + library/cpp/deprecated/atomic +) + +SRCS( + cont_poller.cpp + helper.cpp + impl.cpp + iostatus.cpp + network.cpp + poller.cpp + sockpool.cpp + stack/stack.cpp + stack/stack_allocator.cpp + stack/stack_guards.cpp + stack/stack_storage.cpp + stack/stack_utils.cpp + trampoline.cpp +) + +END() + +RECURSE( + stack/benchmark + stack/ut + ut +) diff --git a/library/cpp/coroutine/listener/ya.make b/library/cpp/coroutine/listener/ya.make new file mode 100644 index 00000000000..a99e3ebef53 --- /dev/null +++ b/library/cpp/coroutine/listener/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + library/cpp/coroutine/engine +) + +SRCS( + listen.cpp +) + +END() diff --git a/library/cpp/cppparser/ya.make b/library/cpp/cppparser/ya.make new file mode 100644 index 00000000000..8e999a1ae0b --- /dev/null +++ b/library/cpp/cppparser/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + parser.cpp +) + +END() diff --git a/library/cpp/cpuid_check/ya.make b/library/cpp/cpuid_check/ya.make new file mode 100644 index 00000000000..3fb1e157e57 --- /dev/null +++ b/library/cpp/cpuid_check/ya.make @@ -0,0 +1,5 @@ +LIBRARY() + +SRCS(GLOBAL cpu_id_check.cpp) + +END() diff --git a/library/cpp/dbg_output/ut/ya.make b/library/cpp/dbg_output/ut/ya.make new file mode 100644 index 00000000000..2a1e2fb45c0 --- /dev/null +++ b/library/cpp/dbg_output/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/dbg_output) + +SRCS( + dbg_output_ut.cpp +) + +END() diff --git a/library/cpp/dbg_output/ya.make b/library/cpp/dbg_output/ya.make new file mode 100644 index 00000000000..ad4dba231cf --- /dev/null +++ b/library/cpp/dbg_output/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + library/cpp/colorizer +) + +SRCS( + dump.cpp + dumpers.cpp + engine.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/deprecated/accessors/ut/ya.make b/library/cpp/deprecated/accessors/ut/ya.make new file mode 100644 index 00000000000..5e79af5efd9 --- /dev/null +++ b/library/cpp/deprecated/accessors/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/deprecated/accessors) + +SRCS( + accessors_ut.cpp +) + +END() diff --git a/library/cpp/deprecated/accessors/ya.make b/library/cpp/deprecated/accessors/ya.make new file mode 100644 index 00000000000..0aa8fcfa9bd --- /dev/null +++ b/library/cpp/deprecated/accessors/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + accessors.cpp + accessors_impl.cpp + memory_traits.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/deprecated/atomic/ut/ya.make b/library/cpp/deprecated/atomic/ut/ya.make new file mode 100644 index 00000000000..e21fd089904 --- /dev/null +++ b/library/cpp/deprecated/atomic/ut/ya.make @@ -0,0 +1,5 @@ +UNITTEST_FOR(library/cpp/deprecated/atomic) + +SRCS(atomic_ut.cpp) + +END() diff --git a/library/cpp/deprecated/atomic/ya.make b/library/cpp/deprecated/atomic/ya.make new file mode 100644 index 00000000000..af1c3c5ac0d --- /dev/null +++ b/library/cpp/deprecated/atomic/ya.make @@ -0,0 +1,5 @@ +LIBRARY() + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/deprecated/enum_codegen/ut/ya.make b/library/cpp/deprecated/enum_codegen/ut/ya.make new file mode 100644 index 00000000000..2cdca47ad08 --- /dev/null +++ b/library/cpp/deprecated/enum_codegen/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +SRCDIR(library/cpp/deprecated/enum_codegen) + +PEERDIR( + library/cpp/deprecated/enum_codegen +) + +SRCS( + enum_codegen_ut.cpp +) + +END() diff --git a/library/cpp/deprecated/enum_codegen/ya.make b/library/cpp/deprecated/enum_codegen/ya.make new file mode 100644 index 00000000000..9ff9997c84d --- /dev/null +++ b/library/cpp/deprecated/enum_codegen/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + enum_codegen.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/deprecated/kmp/ut/ya.make b/library/cpp/deprecated/kmp/ut/ya.make new file mode 100644 index 00000000000..bb240b042ea --- /dev/null +++ b/library/cpp/deprecated/kmp/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/deprecated/kmp) + +SRCS( + kmp_ut.cpp +) + +END() diff --git a/library/cpp/deprecated/kmp/ya.make b/library/cpp/deprecated/kmp/ya.make new file mode 100644 index 00000000000..9814333db05 --- /dev/null +++ b/library/cpp/deprecated/kmp/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + kmp.cpp + kmp.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/deprecated/split/ut/ya.make b/library/cpp/deprecated/split/ut/ya.make new file mode 100644 index 00000000000..8b3da078c20 --- /dev/null +++ b/library/cpp/deprecated/split/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/deprecated/split) + +SRCS( + delim_string_iter_ut.cpp + split_iterator_ut.cpp +) + +END() diff --git a/library/cpp/deprecated/split/ya.make b/library/cpp/deprecated/split/ya.make new file mode 100644 index 00000000000..8b6897fa28f --- /dev/null +++ b/library/cpp/deprecated/split/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + delim_string_iter.cpp + split_iterator.cpp +) + +PEERDIR( + library/cpp/deprecated/kmp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/deprecated/threadable/ya.make b/library/cpp/deprecated/threadable/ya.make new file mode 100644 index 00000000000..58ffc0046f1 --- /dev/null +++ b/library/cpp/deprecated/threadable/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + threadable.cpp +) + +END() diff --git a/library/cpp/diff/ut/ya.make b/library/cpp/diff/ut/ya.make new file mode 100644 index 00000000000..c0a091aa867 --- /dev/null +++ b/library/cpp/diff/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +SRCDIR(library/cpp/diff) + +PEERDIR( + library/cpp/diff +) + +SRCS( + diff_ut.cpp +) + +END() diff --git a/library/cpp/diff/ya.make b/library/cpp/diff/ya.make new file mode 100644 index 00000000000..c975ced7aa1 --- /dev/null +++ b/library/cpp/diff/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + library/cpp/lcs + library/cpp/containers/stack_array +) + +SRCS( + diff.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/digest/argonish/benchmark/ya.make b/library/cpp/digest/argonish/benchmark/ya.make new file mode 100644 index 00000000000..8d7d2a51fd1 --- /dev/null +++ b/library/cpp/digest/argonish/benchmark/ya.make @@ -0,0 +1,11 @@ +Y_BENCHMARK() + +PEERDIR( + library/cpp/digest/argonish +) + +SRCS( + mbench.cpp +) + +END() diff --git a/library/cpp/digest/argonish/internal/argon2/ya.make b/library/cpp/digest/argonish/internal/argon2/ya.make new file mode 100644 index 00000000000..f5220c3f614 --- /dev/null +++ b/library/cpp/digest/argonish/internal/argon2/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +PEERDIR( + library/cpp/digest/argonish/internal/blamka + library/cpp/digest/argonish/internal/blake2b + library/cpp/threading/poor_man_openmp +) + +END() diff --git a/library/cpp/digest/argonish/internal/blake2b/ya.make b/library/cpp/digest/argonish/internal/blake2b/ya.make new file mode 100644 index 00000000000..a0b99aa4b26 --- /dev/null +++ b/library/cpp/digest/argonish/internal/blake2b/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +PEERDIR( + library/cpp/digest/argonish/internal/rotations +) + +END() diff --git a/library/cpp/digest/argonish/internal/blamka/ya.make b/library/cpp/digest/argonish/internal/blamka/ya.make new file mode 100644 index 00000000000..a0b99aa4b26 --- /dev/null +++ b/library/cpp/digest/argonish/internal/blamka/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +PEERDIR( + library/cpp/digest/argonish/internal/rotations +) + +END() diff --git a/library/cpp/digest/argonish/internal/proxies/avx2/ya.make b/library/cpp/digest/argonish/internal/proxies/avx2/ya.make new file mode 100644 index 00000000000..efeed5ad4da --- /dev/null +++ b/library/cpp/digest/argonish/internal/proxies/avx2/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +NO_UTIL() + +IF (ARCH_X86_64 OR ARCH_I386) + PEERDIR( + library/cpp/digest/argonish/internal/proxies/macro + library/cpp/digest/argonish/internal/argon2 + library/cpp/digest/argonish/internal/blake2b + ) + SRC_C_AVX2( + proxy_avx2.cpp + ) +ENDIF() + +END() diff --git a/library/cpp/digest/argonish/internal/proxies/macro/ya.make b/library/cpp/digest/argonish/internal/proxies/macro/ya.make new file mode 100644 index 00000000000..9865d255c8f --- /dev/null +++ b/library/cpp/digest/argonish/internal/proxies/macro/ya.make @@ -0,0 +1,3 @@ +LIBRARY() + +END() diff --git a/library/cpp/digest/argonish/internal/proxies/ref/ya.make b/library/cpp/digest/argonish/internal/proxies/ref/ya.make new file mode 100644 index 00000000000..e48de6d9ebf --- /dev/null +++ b/library/cpp/digest/argonish/internal/proxies/ref/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +NO_UTIL() + +PEERDIR( + library/cpp/digest/argonish/internal/proxies/macro + library/cpp/digest/argonish/internal/argon2 + library/cpp/digest/argonish/internal/blake2b +) + +SRCS( + proxy_ref.cpp +) + +END() diff --git a/library/cpp/digest/argonish/internal/proxies/sse2/ya.make b/library/cpp/digest/argonish/internal/proxies/sse2/ya.make new file mode 100644 index 00000000000..0598fb9c9ab --- /dev/null +++ b/library/cpp/digest/argonish/internal/proxies/sse2/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +NO_UTIL() + +IF (ARCH_X86_64 OR ARCH_I386) + PEERDIR( + library/cpp/digest/argonish/internal/proxies/macro + library/cpp/digest/argonish/internal/argon2 + library/cpp/digest/argonish/internal/blake2b + ) + SRC_C_SSE2( + proxy_sse2.cpp + ) +ENDIF() + +END() diff --git a/library/cpp/digest/argonish/internal/proxies/sse41/ya.make b/library/cpp/digest/argonish/internal/proxies/sse41/ya.make new file mode 100644 index 00000000000..f0839adcb0a --- /dev/null +++ b/library/cpp/digest/argonish/internal/proxies/sse41/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +NO_UTIL() + +IF (ARCH_X86_64 OR ARCH_I386) + PEERDIR( + library/cpp/digest/argonish/internal/proxies/macro + library/cpp/digest/argonish/internal/argon2 + library/cpp/digest/argonish/internal/blake2b + ) + SRC_C_SSE41( + proxy_sse41.cpp + ) +ENDIF() + +END() diff --git a/library/cpp/digest/argonish/internal/proxies/ssse3/ya.make b/library/cpp/digest/argonish/internal/proxies/ssse3/ya.make new file mode 100644 index 00000000000..95e32e5ee09 --- /dev/null +++ b/library/cpp/digest/argonish/internal/proxies/ssse3/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +NO_UTIL() + +IF (ARCH_X86_64 OR ARCH_I386) + PEERDIR( + library/cpp/digest/argonish/internal/proxies/macro + library/cpp/digest/argonish/internal/argon2 + library/cpp/digest/argonish/internal/blake2b + ) + + SRC_C_SSSE3( + proxy_ssse3.cpp + ) +ENDIF() + +END() diff --git a/library/cpp/digest/argonish/internal/rotations/ya.make b/library/cpp/digest/argonish/internal/rotations/ya.make new file mode 100644 index 00000000000..9865d255c8f --- /dev/null +++ b/library/cpp/digest/argonish/internal/rotations/ya.make @@ -0,0 +1,3 @@ +LIBRARY() + +END() diff --git a/library/cpp/digest/argonish/ut/ya.make b/library/cpp/digest/argonish/ut/ya.make new file mode 100644 index 00000000000..38d41702d21 --- /dev/null +++ b/library/cpp/digest/argonish/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(library/cpp/digest/argonish) + +PEERDIR( + library/cpp/digest/argonish +) + +SRCS( + ut.cpp +) + +END() diff --git a/library/cpp/digest/argonish/ut_fat/ya.make b/library/cpp/digest/argonish/ut_fat/ya.make new file mode 100644 index 00000000000..6f0a77611d4 --- /dev/null +++ b/library/cpp/digest/argonish/ut_fat/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(library/cpp/digest/argonish) + +PEERDIR( + library/cpp/digest/argonish +) + +SRCS( + ut.cpp +) + +TAG( + sb:intel_e5_2660v4 + ya:fat + ya:force_sandbox +) + +SIZE(LARGE) + +END() diff --git a/library/cpp/digest/argonish/ya.make b/library/cpp/digest/argonish/ya.make new file mode 100644 index 00000000000..771307059e3 --- /dev/null +++ b/library/cpp/digest/argonish/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +IF (ARCH_X86_64 OR ARCH_I386) + PEERDIR( + library/cpp/threading/poor_man_openmp + library/cpp/digest/argonish/internal/proxies/avx2 + library/cpp/digest/argonish/internal/proxies/ref + library/cpp/digest/argonish/internal/proxies/sse2 + library/cpp/digest/argonish/internal/proxies/sse41 + library/cpp/digest/argonish/internal/proxies/ssse3 + ) +ELSE() + PEERDIR( + library/cpp/threading/poor_man_openmp + library/cpp/digest/argonish/internal/proxies/ref + ) +ENDIF() + +SRCS( + factory/factory.cpp +) + +END() + +RECURSE( + benchmark + ut + ut_fat +) diff --git a/library/cpp/digest/crc32c/ut/ya.make b/library/cpp/digest/crc32c/ut/ya.make new file mode 100644 index 00000000000..8a4e5cb8613 --- /dev/null +++ b/library/cpp/digest/crc32c/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/digest/crc32c) + +SRCS( + crc32c_ut.cpp +) + +END() diff --git a/library/cpp/digest/crc32c/ya.make b/library/cpp/digest/crc32c/ya.make new file mode 100644 index 00000000000..a2f8e87da18 --- /dev/null +++ b/library/cpp/digest/crc32c/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +#!!! +PEERDIR( + contrib/libs/crcutil +) + +SRCS( + crc32c.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/digest/lower_case/ut/ya.make b/library/cpp/digest/lower_case/ut/ya.make new file mode 100644 index 00000000000..159d49aa2a8 --- /dev/null +++ b/library/cpp/digest/lower_case/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/digest/lower_case) + +SRCS( + lchash_ut.cpp + hash_ops_ut.cpp +) + +END() diff --git a/library/cpp/digest/lower_case/ya.make b/library/cpp/digest/lower_case/ya.make new file mode 100644 index 00000000000..6d6d804a5bf --- /dev/null +++ b/library/cpp/digest/lower_case/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + lciter.cpp + lchash.cpp + hash_ops.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/digest/md5/bench/ya.make b/library/cpp/digest/md5/bench/ya.make new file mode 100644 index 00000000000..eb3c7ea5f63 --- /dev/null +++ b/library/cpp/digest/md5/bench/ya.make @@ -0,0 +1,11 @@ +G_BENCHMARK() + +PEERDIR( + library/cpp/digest/md5 +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/digest/md5/medium_ut/ya.make b/library/cpp/digest/md5/medium_ut/ya.make new file mode 100644 index 00000000000..5ccfc9a6eee --- /dev/null +++ b/library/cpp/digest/md5/medium_ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(library/cpp/digest/md5) + +SIZE(MEDIUM) + +TIMEOUT(120) + +SRCS( + md5_medium_ut.cpp +) + +REQUIREMENTS(ram:10) + +END() diff --git a/library/cpp/digest/md5/ut/ya.make b/library/cpp/digest/md5/ut/ya.make new file mode 100644 index 00000000000..76b61b4b196 --- /dev/null +++ b/library/cpp/digest/md5/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/digest/md5) + +SRCS( + md5_ut.cpp +) + +END() diff --git a/library/cpp/digest/md5/ya.make b/library/cpp/digest/md5/ya.make new file mode 100644 index 00000000000..1e6ffd9642f --- /dev/null +++ b/library/cpp/digest/md5/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + md5.cpp +) + +PEERDIR( + contrib/libs/nayuki_md5 + library/cpp/string_utils/base64 +) + +END() + +RECURSE( + bench + medium_ut + ut +) diff --git a/library/cpp/digest/murmur/ut/ya.make b/library/cpp/digest/murmur/ut/ya.make new file mode 100644 index 00000000000..de14ca6fb6b --- /dev/null +++ b/library/cpp/digest/murmur/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/digest/murmur +) + +SRCDIR(library/cpp/digest/murmur) + +SRCS( + murmur_ut.cpp +) + +END() diff --git a/library/cpp/digest/murmur/ya.make b/library/cpp/digest/murmur/ya.make new file mode 100644 index 00000000000..9c4bb887b74 --- /dev/null +++ b/library/cpp/digest/murmur/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + murmur.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/digest/old_crc/gencrc/ya.make b/library/cpp/digest/old_crc/gencrc/ya.make new file mode 100644 index 00000000000..4d89e966698 --- /dev/null +++ b/library/cpp/digest/old_crc/gencrc/ya.make @@ -0,0 +1,7 @@ +PROGRAM() + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/digest/old_crc/ut/ya.make b/library/cpp/digest/old_crc/ut/ya.make new file mode 100644 index 00000000000..8b3f7b3fd3b --- /dev/null +++ b/library/cpp/digest/old_crc/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/digest/old_crc) + +SRCS( + crc_ut.cpp +) + +END() diff --git a/library/cpp/digest/old_crc/ya.make b/library/cpp/digest/old_crc/ya.make new file mode 100644 index 00000000000..6bd8b7a1f8d --- /dev/null +++ b/library/cpp/digest/old_crc/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + crc.cpp +) + +RUN_PROGRAM( + library/cpp/digest/old_crc/gencrc + STDOUT crc.inc +) + +END() + +RECURSE( + gencrc + ut +) diff --git a/library/cpp/digest/sfh/ut/ya.make b/library/cpp/digest/sfh/ut/ya.make new file mode 100644 index 00000000000..4308c181e14 --- /dev/null +++ b/library/cpp/digest/sfh/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/digest/sfh) + +SRCS( + sfh_ut.cpp +) + +END() diff --git a/library/cpp/digest/sfh/ya.make b/library/cpp/digest/sfh/ya.make new file mode 100644 index 00000000000..630a2d16bcc --- /dev/null +++ b/library/cpp/digest/sfh/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + sfh.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/dns/ut/ya.make b/library/cpp/dns/ut/ya.make new file mode 100644 index 00000000000..1382bbe431d --- /dev/null +++ b/library/cpp/dns/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/dns +) + +SRCS( + dns_ut.cpp +) + +END() diff --git a/library/cpp/dns/ya.make b/library/cpp/dns/ya.make new file mode 100644 index 00000000000..eea4122e5d6 --- /dev/null +++ b/library/cpp/dns/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + cache.cpp + thread.cpp + magic.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/enumbitset/ut/ya.make b/library/cpp/enumbitset/ut/ya.make new file mode 100644 index 00000000000..0cea204a39f --- /dev/null +++ b/library/cpp/enumbitset/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/enumbitset) + +SRCS( + enumbitset_ut.cpp +) + +END() diff --git a/library/cpp/enumbitset/ya.make b/library/cpp/enumbitset/ya.make new file mode 100644 index 00000000000..9f5ed3b4357 --- /dev/null +++ b/library/cpp/enumbitset/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + enumbitset.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/execprofile/ya.make b/library/cpp/execprofile/ya.make new file mode 100644 index 00000000000..5d0b3c7eeb5 --- /dev/null +++ b/library/cpp/execprofile/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + profile.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/getopt/last_getopt_demo/ya.make b/library/cpp/getopt/last_getopt_demo/ya.make new file mode 100644 index 00000000000..bbc01016d63 --- /dev/null +++ b/library/cpp/getopt/last_getopt_demo/ya.make @@ -0,0 +1,11 @@ +PROGRAM(last_getopt_demo) + +PEERDIR( + library/cpp/getopt +) + +SRCS( + demo.cpp +) + +END() diff --git a/library/cpp/getopt/small/ya.make b/library/cpp/getopt/small/ya.make new file mode 100644 index 00000000000..b4a8981bacf --- /dev/null +++ b/library/cpp/getopt/small/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +PEERDIR( + library/cpp/colorizer +) + +SRCS( + completer.cpp + completer_command.cpp + completion_generator.cpp + formatted_output.cpp + last_getopt.cpp + last_getopt_easy_setup.cpp + last_getopt_opt.cpp + last_getopt_opts.cpp + last_getopt_parser.cpp + last_getopt_parse_result.cpp + modchooser.cpp + opt.cpp + opt2.cpp + posix_getopt.cpp + wrap.cpp + ygetopt.cpp +) + +END() diff --git a/library/cpp/getopt/ut/ya.make b/library/cpp/getopt/ut/ya.make new file mode 100644 index 00000000000..fde0eab8bcd --- /dev/null +++ b/library/cpp/getopt/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(library/cpp/getopt) + +SRCS( + last_getopt_ut.cpp + modchooser_ut.cpp + opt2_ut.cpp + opt_ut.cpp + posix_getopt_ut.cpp + wrap.cpp + ygetopt_ut.cpp +) + +END() diff --git a/library/cpp/getopt/ya.make b/library/cpp/getopt/ya.make new file mode 100644 index 00000000000..035be9a668d --- /dev/null +++ b/library/cpp/getopt/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PEERDIR( + library/cpp/getopt/small + library/cpp/svnversion + library/cpp/build_info +) + +SRCS( + GLOBAL print.cpp +) + +END() + +RECURSE( + last_getopt_demo + small + ut +) diff --git a/library/cpp/grpc/client/ut/ya.make b/library/cpp/grpc/client/ut/ya.make new file mode 100644 index 00000000000..45a88622f47 --- /dev/null +++ b/library/cpp/grpc/client/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/grpc/client) + +SRCS( + grpc_client_low_ut.cpp +) + +END() diff --git a/library/cpp/grpc/client/ya.make b/library/cpp/grpc/client/ya.make new file mode 100644 index 00000000000..a963a42abef --- /dev/null +++ b/library/cpp/grpc/client/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + grpc_client_low.cpp +) + +PEERDIR( + contrib/libs/grpc + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/grpc/server/actors/ya.make b/library/cpp/grpc/server/actors/ya.make new file mode 100644 index 00000000000..a8d4b403738 --- /dev/null +++ b/library/cpp/grpc/server/actors/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + logger.cpp +) + +PEERDIR( + library/cpp/actors/core +) + +END() diff --git a/library/cpp/grpc/server/ut/ya.make b/library/cpp/grpc/server/ut/ya.make new file mode 100644 index 00000000000..94408dc8ce8 --- /dev/null +++ b/library/cpp/grpc/server/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(library/cpp/grpc/server) + +TIMEOUT(600) +SIZE(MEDIUM) + +PEERDIR( + library/cpp/grpc/server +) + +SRCS( + grpc_response_ut.cpp + stream_adaptor_ut.cpp +) + +END() + diff --git a/library/cpp/grpc/server/ya.make b/library/cpp/grpc/server/ya.make new file mode 100644 index 00000000000..9ed8f30ef2e --- /dev/null +++ b/library/cpp/grpc/server/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + event_callback.cpp + grpc_request.cpp + grpc_server.cpp + grpc_counters.cpp +) + +GENERATE_ENUM_SERIALIZATION(grpc_request_base.h) + +PEERDIR( + contrib/libs/grpc + library/cpp/monlib/dynamic_counters/percentile +) + +END() + +RECURSE_FOR_TESTS(ut) + diff --git a/library/cpp/histogram/adaptive/protos/ya.make b/library/cpp/histogram/adaptive/protos/ya.make new file mode 100644 index 00000000000..03b42254807 --- /dev/null +++ b/library/cpp/histogram/adaptive/protos/ya.make @@ -0,0 +1,11 @@ +PROTO_LIBRARY() + +SRCS( + histo.proto +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() diff --git a/library/cpp/histogram/adaptive/ya.make b/library/cpp/histogram/adaptive/ya.make new file mode 100644 index 00000000000..43d0525b4e5 --- /dev/null +++ b/library/cpp/histogram/adaptive/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + common.cpp + adaptive_histogram.cpp + block_histogram.cpp + fixed_bin_histogram.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/histogram/adaptive/protos +) + +END() diff --git a/library/cpp/histogram/hdr/ut/ya.make b/library/cpp/histogram/hdr/ut/ya.make new file mode 100644 index 00000000000..3d954aaffc8 --- /dev/null +++ b/library/cpp/histogram/hdr/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/histogram/hdr) + +SRCS( + histogram_ut.cpp + histogram_iter_ut.cpp +) + +END() diff --git a/library/cpp/histogram/hdr/ya.make b/library/cpp/histogram/hdr/ya.make new file mode 100644 index 00000000000..48f80c3c2f1 --- /dev/null +++ b/library/cpp/histogram/hdr/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + histogram.cpp + histogram_iter.cpp +) + +PEERDIR( + contrib/libs/hdr_histogram +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/histogram/simple/ya.make b/library/cpp/histogram/simple/ya.make new file mode 100644 index 00000000000..00544e802c1 --- /dev/null +++ b/library/cpp/histogram/simple/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + library/cpp/json + library/cpp/threading/future +) + +SRCS( + histogram.cpp +) + +END() diff --git a/library/cpp/html/entity/ya.make b/library/cpp/html/entity/ya.make new file mode 100644 index 00000000000..827e9c6b6dd --- /dev/null +++ b/library/cpp/html/entity/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + htmlentity.cpp + decoder.rl6 +) + +SET( + RAGEL6_FLAGS + -C + -e + -F1 +) + +PEERDIR( + library/cpp/charset +) + +END() diff --git a/library/cpp/html/escape/ut/ya.make b/library/cpp/html/escape/ut/ya.make new file mode 100644 index 00000000000..605e99d2fd3 --- /dev/null +++ b/library/cpp/html/escape/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +SRCS( + escape_ut.cpp +) + +PEERDIR( + library/cpp/html/escape +) + +END() diff --git a/library/cpp/html/escape/ya.make b/library/cpp/html/escape/ya.make new file mode 100644 index 00000000000..b5de3c9a77d --- /dev/null +++ b/library/cpp/html/escape/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + escape.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/html/pcdata/ut/ya.make b/library/cpp/html/pcdata/ut/ya.make new file mode 100644 index 00000000000..6d7f95627c0 --- /dev/null +++ b/library/cpp/html/pcdata/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/html/pcdata) + +SRCS( + pcdata_ut.cpp +) + +END() diff --git a/library/cpp/html/pcdata/ya.make b/library/cpp/html/pcdata/ya.make new file mode 100644 index 00000000000..2710d6728be --- /dev/null +++ b/library/cpp/html/pcdata/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + pcdata.cpp + pcdata.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/http/fetch/ut/ya.make b/library/cpp/http/fetch/ut/ya.make new file mode 100644 index 00000000000..df14c2a09f0 --- /dev/null +++ b/library/cpp/http/fetch/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/http/fetch) + +SRCS( + httpfsm_ut.cpp + httpparser_ut.cpp +) + +END() diff --git a/library/cpp/http/fetch/ya.make b/library/cpp/http/fetch/ya.make new file mode 100644 index 00000000000..78125f42cf3 --- /dev/null +++ b/library/cpp/http/fetch/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +PEERDIR( + contrib/libs/zlib + library/cpp/charset + library/cpp/digest/md5 + library/cpp/http/misc + library/cpp/logger + library/cpp/mime/types + library/cpp/uri +) + +SRCS( + http_digest.cpp + http_socket.cpp + httpheader.cpp + httpload.cpp + exthttpcodes.cpp + httpfsm.rl6 + httpagent.h + httpfetcher.h + httpheader.h + httpparser.h + httpzreader.h + sockhandler.h +) + +GENERATE_ENUM_SERIALIZATION(httpheader.h) + +SET(RAGEL6_FLAGS -CG1) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/http/io/fuzz/ya.make b/library/cpp/http/io/fuzz/ya.make new file mode 100644 index 00000000000..8cb1fe288d6 --- /dev/null +++ b/library/cpp/http/io/fuzz/ya.make @@ -0,0 +1,13 @@ +FUZZ() + +PEERDIR( + library/cpp/http/io +) + +SIZE(MEDIUM) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/http/io/list_codings/ya.make b/library/cpp/http/io/list_codings/ya.make new file mode 100644 index 00000000000..afc5c454442 --- /dev/null +++ b/library/cpp/http/io/list_codings/ya.make @@ -0,0 +1,11 @@ +PROGRAM() + +PEERDIR( + library/cpp/http/io +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/http/io/ut/ya.make b/library/cpp/http/io/ut/ya.make new file mode 100644 index 00000000000..75beaaafb96 --- /dev/null +++ b/library/cpp/http/io/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(library/cpp/http/io) + +PEERDIR( + library/cpp/http/server +) + +SRCS( + chunk_ut.cpp + compression_ut.cpp + headers_ut.cpp + stream_ut.cpp + stream_ut_medium.cpp +) + +END() diff --git a/library/cpp/http/io/ya.make b/library/cpp/http/io/ya.make new file mode 100644 index 00000000000..0390aecf55b --- /dev/null +++ b/library/cpp/http/io/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +PEERDIR( + library/cpp/blockcodecs + library/cpp/streams/brotli + library/cpp/streams/bzip2 + library/cpp/streams/lzma +) + +SRCS( + chunk.cpp + compression.cpp + headers.cpp + stream.cpp +) + +END() + +RECURSE( + fuzz + list_codings + ut +) diff --git a/library/cpp/http/misc/ut/ya.make b/library/cpp/http/misc/ut/ya.make new file mode 100644 index 00000000000..604f1c4e749 --- /dev/null +++ b/library/cpp/http/misc/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(library/cpp/http/misc) + +SRCS( + httpdate_ut.cpp + httpreqdata_ut.cpp + parsed_request_ut.cpp +) + +END() diff --git a/library/cpp/http/misc/ya.make b/library/cpp/http/misc/ya.make new file mode 100644 index 00000000000..935e1f0fcc5 --- /dev/null +++ b/library/cpp/http/misc/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(httpcodes.h) + +SRCS( + httpcodes.cpp + httpdate.cpp + httpreqdata.cpp + parsed_request.cpp +) + +PEERDIR( + library/cpp/case_insensitive_string + library/cpp/cgiparam + library/cpp/digest/lower_case +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/http/push_parser/ya.make b/library/cpp/http/push_parser/ya.make new file mode 100644 index 00000000000..bf8b852c6e3 --- /dev/null +++ b/library/cpp/http/push_parser/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + http_parser.cpp +) + +PEERDIR( + library/cpp/http/io + library/cpp/blockcodecs + library/cpp/streams/brotli +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/http/server/ut/ya.make b/library/cpp/http/server/ut/ya.make new file mode 100644 index 00000000000..78911fc4f1a --- /dev/null +++ b/library/cpp/http/server/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(library/cpp/http/server) + +SIZE(MEDIUM) + +SRCS( + http_ut.cpp + response_ut.cpp +) + +END() diff --git a/library/cpp/http/server/ya.make b/library/cpp/http/server/ya.make new file mode 100644 index 00000000000..a37783e7ed2 --- /dev/null +++ b/library/cpp/http/server/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + conn.cpp + http.cpp + http_ex.cpp + options.cpp + response.cpp +) + +PEERDIR( + library/cpp/http/misc + library/cpp/http/io + library/cpp/threading/equeue + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/http/simple/ut/https_server/ya.make b/library/cpp/http/simple/ut/https_server/ya.make new file mode 100644 index 00000000000..6a0765382d9 --- /dev/null +++ b/library/cpp/http/simple/ut/https_server/ya.make @@ -0,0 +1,5 @@ +GO_PROGRAM() + +SRCS(main.go) + +END() diff --git a/library/cpp/http/simple/ut/ya.make b/library/cpp/http/simple/ut/ya.make new file mode 100644 index 00000000000..3f77967ea67 --- /dev/null +++ b/library/cpp/http/simple/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(library/cpp/http/simple) + +PEERDIR( + library/cpp/http/misc + library/cpp/testing/mock_server +) + +SRCS( + http_ut.cpp + https_ut.cpp +) + +DEPENDS(library/cpp/http/simple/ut/https_server) + +DATA(arcadia/library/cpp/http/simple/ut/https_server) + +END() + +RECURSE( + https_server +) diff --git a/library/cpp/http/simple/ya.make b/library/cpp/http/simple/ya.make new file mode 100644 index 00000000000..3ef55c852cf --- /dev/null +++ b/library/cpp/http/simple/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +PEERDIR( + library/cpp/http/io + library/cpp/openssl/io + library/cpp/string_utils/url + library/cpp/uri +) + +SRCS( + http_client.cpp +) + +END() + +IF (NOT OS_WINDOWS) + RECURSE_FOR_TESTS( + ut + ) +ENDIF() diff --git a/library/cpp/hyperloglog/ut/ya.make b/library/cpp/hyperloglog/ut/ya.make new file mode 100644 index 00000000000..a910146b678 --- /dev/null +++ b/library/cpp/hyperloglog/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/hyperloglog) + +SRCS( + hyperloglog_ut.cpp +) + +END() diff --git a/library/cpp/hyperloglog/ya.make b/library/cpp/hyperloglog/ya.make new file mode 100644 index 00000000000..8268acc561a --- /dev/null +++ b/library/cpp/hyperloglog/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + hyperloglog.h + hyperloglog.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/int128/bench/ya.make b/library/cpp/int128/bench/ya.make new file mode 100644 index 00000000000..0dbc45e21ff --- /dev/null +++ b/library/cpp/int128/bench/ya.make @@ -0,0 +1,11 @@ +Y_BENCHMARK() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/int128 +) + +END() diff --git a/library/cpp/int128/ut/ya.make b/library/cpp/int128/ut/ya.make new file mode 100644 index 00000000000..22ef97d5662 --- /dev/null +++ b/library/cpp/int128/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(library/cpp/int128) + +SRCS( + int128_ut_helpers.cpp + int128_ut_helpers.h + int128_ut.cpp + int128_typetraits_ut.cpp + int128_old_ut.cpp + int128_via_intrinsic_ut.cpp + i128_ut.cpp + i128_and_intrinsic_identity_ut.cpp + i128_comparison_ut.cpp + i128_division_ut.cpp + i128_type_traits_ut.cpp + ui128_division_ut.cpp +) + +END() diff --git a/library/cpp/int128/ya.make b/library/cpp/int128/ya.make new file mode 100644 index 00000000000..095d7e3cb69 --- /dev/null +++ b/library/cpp/int128/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + int128.cpp + int128.h +) + +END() + +RECURSE( + bench + ut +) diff --git a/library/cpp/ipmath/ut/ya.make b/library/cpp/ipmath/ut/ya.make new file mode 100644 index 00000000000..b974ba7b031 --- /dev/null +++ b/library/cpp/ipmath/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(library/cpp/ipmath) + +SRCS( + ipmath_ut.cpp +) + +PEERDIR( + library/cpp/testing/gmock_in_unittest +) + +END() diff --git a/library/cpp/ipmath/ya.make b/library/cpp/ipmath/ya.make new file mode 100644 index 00000000000..04cd721f5b6 --- /dev/null +++ b/library/cpp/ipmath/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + ipmath.cpp + range_set.cpp +) + +PEERDIR(library/cpp/ipv6_address) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/ipv6_address/ut/ya.make b/library/cpp/ipv6_address/ut/ya.make new file mode 100644 index 00000000000..1bb25059bfa --- /dev/null +++ b/library/cpp/ipv6_address/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/ipv6_address) + +SRCS( + ipv6_address_ut.cpp +) + +END() diff --git a/library/cpp/ipv6_address/ya.make b/library/cpp/ipv6_address/ya.make new file mode 100644 index 00000000000..6ee52114313 --- /dev/null +++ b/library/cpp/ipv6_address/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + ipv6_address.cpp + ipv6_address.h + ipv6_address_p.h +) + +PEERDIR( + library/cpp/int128 +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/iterator/ut/ya.make b/library/cpp/iterator/ut/ya.make new file mode 100644 index 00000000000..4a5fb14c586 --- /dev/null +++ b/library/cpp/iterator/ut/ya.make @@ -0,0 +1,16 @@ +GTEST() + +PEERDIR( + library/cpp/iterator +) + +SRCS( + filtering_ut.cpp + functools_ut.cpp + iterate_keys_ut.cpp + iterate_values_ut.cpp + mapped_ut.cpp + zip_ut.cpp +) + +END() diff --git a/library/cpp/iterator/ya.make b/library/cpp/iterator/ya.make new file mode 100644 index 00000000000..1fd418e64ac --- /dev/null +++ b/library/cpp/iterator/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + cartesian_product.cpp + concatenate.cpp + enumerate.cpp + iterate_keys.cpp + iterate_values.cpp + filtering.cpp + functools.cpp + mapped.cpp + zip.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/json/common/ya.make b/library/cpp/json/common/ya.make new file mode 100644 index 00000000000..ae064167e6b --- /dev/null +++ b/library/cpp/json/common/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + defs.cpp +) + +END() diff --git a/library/cpp/json/converter/ut/ya.make b/library/cpp/json/converter/ut/ya.make new file mode 100644 index 00000000000..15c555d3d42 --- /dev/null +++ b/library/cpp/json/converter/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(library/cpp/json/converter) + +SIZE(SMALL) + +SRCS( + test_conversion.cpp +) + +PEERDIR( + library/cpp/json + library/cpp/json/writer +) + +END() diff --git a/library/cpp/json/converter/ya.make b/library/cpp/json/converter/ya.make new file mode 100644 index 00000000000..0458d1cefa3 --- /dev/null +++ b/library/cpp/json/converter/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + converter.cpp +) + +PEERDIR( + library/cpp/json/writer +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/json/easy_parse/ya.make b/library/cpp/json/easy_parse/ya.make new file mode 100644 index 00000000000..89a2d5bd849 --- /dev/null +++ b/library/cpp/json/easy_parse/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + json_easy_parser.cpp +) + +PEERDIR( + library/cpp/json +) + +END() diff --git a/library/cpp/json/fast_sax/ya.make b/library/cpp/json/fast_sax/ya.make new file mode 100644 index 00000000000..2b6aaab19ce --- /dev/null +++ b/library/cpp/json/fast_sax/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + library/cpp/json/common +) + +SRCS( + parser.rl6 + unescape.cpp +) + +END() diff --git a/library/cpp/json/fuzzy_test/ya.make b/library/cpp/json/fuzzy_test/ya.make new file mode 100644 index 00000000000..224f3ab6f23 --- /dev/null +++ b/library/cpp/json/fuzzy_test/ya.make @@ -0,0 +1,11 @@ +FUZZ() + +PEERDIR( + library/cpp/json +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/json/ut/ya.make b/library/cpp/json/ut/ya.make new file mode 100644 index 00000000000..1f14dd8f6f0 --- /dev/null +++ b/library/cpp/json/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(library/cpp/json) + +PEERDIR( + library/cpp/string_utils/relaxed_escaper +) + +SRCS( + json_reader_fast_ut.cpp + json_reader_ut.cpp + json_prettifier_ut.cpp + json_writer_ut.cpp + json_saveload_ut.cpp +) + +END() diff --git a/library/cpp/json/writer/ut/ya.make b/library/cpp/json/writer/ut/ya.make new file mode 100644 index 00000000000..256b950a6e3 --- /dev/null +++ b/library/cpp/json/writer/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/json/writer +) + +SRCDIR(library/cpp/json/writer) + +SRCS( + json_ut.cpp + json_value_ut.cpp +) + +END() diff --git a/library/cpp/json/writer/ya.make b/library/cpp/json/writer/ya.make new file mode 100644 index 00000000000..15340ed6dc7 --- /dev/null +++ b/library/cpp/json/writer/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + library/cpp/json/common +) + +SRCS( + json_value.cpp + json.cpp +) + +GENERATE_ENUM_SERIALIZATION(json_value.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/json/ya.make b/library/cpp/json/ya.make new file mode 100644 index 00000000000..bdcf9a12c78 --- /dev/null +++ b/library/cpp/json/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + json_writer.cpp + json_reader.cpp + json_prettifier.cpp + rapidjson_helpers.cpp +) + +PEERDIR( + contrib/libs/rapidjson + library/cpp/json/common + library/cpp/json/fast_sax + library/cpp/json/writer + library/cpp/string_utils/relaxed_escaper +) + +END() + +RECURSE( + converter + fuzzy_test + ut + writer + yson +) diff --git a/library/cpp/json/yson/ut/ya.make b/library/cpp/json/yson/ut/ya.make new file mode 100644 index 00000000000..8fce6dbe2fa --- /dev/null +++ b/library/cpp/json/yson/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(library/cpp/json/yson) + +ALLOCATOR(LF) + +DATA(sbr://363537653) + +PEERDIR( + library/cpp/blockcodecs + library/cpp/histogram/simple + library/cpp/testing/unittest +) + +SIZE(LARGE) + +TAG(ya:fat) + +TIMEOUT(600) + +SRCS( + json2yson_ut.cpp +) + +END() diff --git a/library/cpp/json/yson/ya.make b/library/cpp/json/yson/ya.make new file mode 100644 index 00000000000..258a78efcc5 --- /dev/null +++ b/library/cpp/json/yson/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + library/cpp/json + library/cpp/yson + library/cpp/yson/json +) + +SRCS( + json2yson.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/lcs/ut/ya.make b/library/cpp/lcs/ut/ya.make new file mode 100644 index 00000000000..e893bc95278 --- /dev/null +++ b/library/cpp/lcs/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/lcs +) + +SRCDIR(library/cpp/lcs) + +SRCS( + lcs_via_lis_ut.cpp +) + +END() diff --git a/library/cpp/lcs/ya.make b/library/cpp/lcs/ya.make new file mode 100644 index 00000000000..8c63b44e795 --- /dev/null +++ b/library/cpp/lcs/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + library/cpp/containers/paged_vector +) + +SRCS( + lcs_via_lis.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/lfalloc/alloc_profiler/ut/ya.make b/library/cpp/lfalloc/alloc_profiler/ut/ya.make new file mode 100644 index 00000000000..a93b86e365d --- /dev/null +++ b/library/cpp/lfalloc/alloc_profiler/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(library/cpp/lfalloc/alloc_profiler) + +PEERDIR( + library/cpp/testing/unittest +) + +IF (ARCH_AARCH64) + PEERDIR( + contrib/libs/jemalloc + ) +ELSE() + ALLOCATOR(LF_DBG) +ENDIF() + +SRCS( + profiler_ut.cpp + align_ut.cpp +) + +END() diff --git a/library/cpp/lfalloc/alloc_profiler/ya.make b/library/cpp/lfalloc/alloc_profiler/ya.make new file mode 100644 index 00000000000..73542891c75 --- /dev/null +++ b/library/cpp/lfalloc/alloc_profiler/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + profiler.cpp + stackcollect.cpp +) + +PEERDIR( + library/cpp/lfalloc/dbg_info + library/cpp/cache + library/cpp/deprecated/atomic +) + +END() + +RECURSE( + ut +) diff --git a/library/cpp/lfalloc/dbg/ya.make b/library/cpp/lfalloc/dbg/ya.make new file mode 100644 index 00000000000..39f3fb94563 --- /dev/null +++ b/library/cpp/lfalloc/dbg/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +ALLOCATOR_IMPL() +NO_UTIL() + +NO_COMPILER_WARNINGS() + +IF (ARCH_AARCH64) + PEERDIR( + contrib/libs/jemalloc + ) +ELSE() + IF ("${YMAKE}" MATCHES "devtools") + CFLAGS(-DYMAKE=1) + ENDIF() + CXXFLAGS( + -DLFALLOC_DBG + -DLFALLOC_YT + ) + SRCS( + ../lf_allocX64.cpp + ) +ENDIF() + +PEERDIR( + library/cpp/malloc/api +) + +SET(IDE_FOLDER "util") + +END() diff --git a/library/cpp/lfalloc/dbg_info/ya.make b/library/cpp/lfalloc/dbg_info/ya.make new file mode 100644 index 00000000000..47b7a59f958 --- /dev/null +++ b/library/cpp/lfalloc/dbg_info/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/malloc/api +) + +SRCS( + dbg_info.cpp +) + +SET(IDE_FOLDER "util") + +END() diff --git a/library/cpp/lfalloc/ya.make b/library/cpp/lfalloc/ya.make new file mode 100644 index 00000000000..43cc8516da1 --- /dev/null +++ b/library/cpp/lfalloc/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +BUILD_ONLY_IF(FATAL_ERROR ARCH_TYPE_64) + +ALLOCATOR_IMPL() +NO_UTIL() + +NO_COMPILER_WARNINGS() + +SRCS( + lf_allocX64.cpp +) + +PEERDIR( + library/cpp/malloc/api +) + +SET(IDE_FOLDER "util") + +END() diff --git a/library/cpp/lfalloc/yt/ya.make b/library/cpp/lfalloc/yt/ya.make new file mode 100644 index 00000000000..36068c090d8 --- /dev/null +++ b/library/cpp/lfalloc/yt/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +NO_UTIL() +ALLOCATOR_IMPL() + +NO_COMPILER_WARNINGS() + +IF (ARCH_AARCH64) + PEERDIR( + contrib/libs/jemalloc + ) +ELSE() + IF ("${YMAKE}" MATCHES "devtools") + CFLAGS(-DYMAKE=1) + ENDIF() + CXXFLAGS(-DLFALLOC_YT) + SRCS( + ../lf_allocX64.cpp + ) +ENDIF() + +PEERDIR( + library/cpp/malloc/api +) + +SET(IDE_FOLDER "util") + +END() diff --git a/library/cpp/linear_regression/benchmark/ya.make b/library/cpp/linear_regression/benchmark/ya.make new file mode 100644 index 00000000000..5a2f1ebb5d9 --- /dev/null +++ b/library/cpp/linear_regression/benchmark/ya.make @@ -0,0 +1,13 @@ +PROGRAM(linear_regression_benchmark) + +SRCS( + pool.h + pool.cpp + main.cpp +) + +PEERDIR( + library/cpp/linear_regression +) + +END() diff --git a/library/cpp/linear_regression/ut/ya.make b/library/cpp/linear_regression/ut/ya.make new file mode 100644 index 00000000000..18e8e5eff0e --- /dev/null +++ b/library/cpp/linear_regression/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/linear_regression +) + +SRCDIR(library/cpp/linear_regression) + +SRCS( + linear_regression_ut.cpp +) + +END() diff --git a/library/cpp/linear_regression/ya.make b/library/cpp/linear_regression/ya.make new file mode 100644 index 00000000000..504de7ee6eb --- /dev/null +++ b/library/cpp/linear_regression/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + linear_regression.cpp + unimodal.cpp + welford.cpp +) + +PEERDIR( + library/cpp/accurate_accumulate +) + +END() + +RECURSE( + benchmark + ut +) diff --git a/library/cpp/logger/global/ut/ya.make b/library/cpp/logger/global/ut/ya.make new file mode 100644 index 00000000000..df11609b6cf --- /dev/null +++ b/library/cpp/logger/global/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + library/cpp/logger/global +) + +SRCDIR(library/cpp/logger/global) + +SRCS( + rty_formater_ut.cpp +) + +END() diff --git a/library/cpp/logger/global/ya.make b/library/cpp/logger/global/ya.make new file mode 100644 index 00000000000..40f2c49a077 --- /dev/null +++ b/library/cpp/logger/global/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + library/cpp/logger +) + +SRCS( + common.cpp + global.cpp + rty_formater.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/logger/init_context/ya.make b/library/cpp/logger/init_context/ya.make new file mode 100644 index 00000000000..282999948f8 --- /dev/null +++ b/library/cpp/logger/init_context/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/logger + library/cpp/config + library/cpp/yconf +) +SRCS( + config.cpp + yconf.cpp +) + +END() diff --git a/library/cpp/logger/ut/ya.make b/library/cpp/logger/ut/ya.make new file mode 100644 index 00000000000..c6fe244bd73 --- /dev/null +++ b/library/cpp/logger/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/logger + library/cpp/logger/init_context + library/cpp/yconf/patcher +) + +SRCDIR(library/cpp/logger) + +SRCS( + log_ut.cpp + element_ut.cpp + rotating_file_ut.cpp + composite_ut.cpp + reopen_ut.cpp +) + +END() diff --git a/library/cpp/logger/ya.make b/library/cpp/logger/ya.make new file mode 100644 index 00000000000..5e426eb32ee --- /dev/null +++ b/library/cpp/logger/ya.make @@ -0,0 +1,45 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(priority.h) + +PEERDIR( + library/cpp/json + library/cpp/deprecated/atomic +) + +SRCS( + all.h + backend.cpp + backend_creator.cpp + composite.cpp + GLOBAL composite_creator.cpp + element.cpp + file.cpp + GLOBAL file_creator.cpp + filter.cpp + filter_creator.cpp + log.cpp + null.cpp + GLOBAL null_creator.cpp + priority.h + record.h + rotating_file.cpp + GLOBAL rotating_file_creator.cpp + stream.cpp + GLOBAL stream_creator.cpp + sync_page_cache_file.cpp + GLOBAL sync_page_cache_file_creator.cpp + system.cpp + GLOBAL system_creator.cpp + thread.cpp + thread_creator.cpp + GLOBAL uninitialized_creator.cpp + reopen.h +) + +END() + +RECURSE( + global + ut +) diff --git a/library/cpp/lua/ya.make b/library/cpp/lua/ya.make new file mode 100644 index 00000000000..b9cc204d9e6 --- /dev/null +++ b/library/cpp/lua/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + library/cpp/json + contrib/libs/lua + library/cpp/string_utils/ztstrbuf +) + +SRCS( + eval.cpp + json.cpp + wrapper.cpp +) + +END() diff --git a/library/cpp/lwtrace/example1/ya.make b/library/cpp/lwtrace/example1/ya.make new file mode 100644 index 00000000000..b447f7ddcc6 --- /dev/null +++ b/library/cpp/lwtrace/example1/ya.make @@ -0,0 +1,11 @@ +PROGRAM(lwtrace-example1) + +SRCS( + lwtrace_example1.cpp +) + +PEERDIR( + library/cpp/lwtrace +) + +END() diff --git a/library/cpp/lwtrace/example2/ya.make b/library/cpp/lwtrace/example2/ya.make new file mode 100644 index 00000000000..9b10bf4e038 --- /dev/null +++ b/library/cpp/lwtrace/example2/ya.make @@ -0,0 +1,12 @@ +PROGRAM(lwtrace-example2) + +SRCS( + lwtrace_example2.cpp +) + +PEERDIR( + library/cpp/lwtrace + library/cpp/getopt +) + +END() diff --git a/library/cpp/lwtrace/example3/ya.make b/library/cpp/lwtrace/example3/ya.make new file mode 100644 index 00000000000..970037228ef --- /dev/null +++ b/library/cpp/lwtrace/example3/ya.make @@ -0,0 +1,11 @@ +PROGRAM(lwtrace-example3) + +SRCS( + lwtrace_example3.cpp +) + +PEERDIR( + library/cpp/lwtrace +) + +END() diff --git a/library/cpp/lwtrace/example4/ya.make b/library/cpp/lwtrace/example4/ya.make new file mode 100644 index 00000000000..fb20185c558 --- /dev/null +++ b/library/cpp/lwtrace/example4/ya.make @@ -0,0 +1,11 @@ +PROGRAM(lwtrace-example4) + +SRCS( + lwtrace_example4.cpp +) + +PEERDIR( + library/cpp/lwtrace +) + +END() diff --git a/library/cpp/lwtrace/example5/ya.make b/library/cpp/lwtrace/example5/ya.make new file mode 100644 index 00000000000..235d457c05f --- /dev/null +++ b/library/cpp/lwtrace/example5/ya.make @@ -0,0 +1,11 @@ +PROGRAM(lwtrace-example5) + +SRCS( + lwtrace_example5.cpp +) + +PEERDIR( + library/cpp/lwtrace +) + +END() diff --git a/library/cpp/lwtrace/mon/analytics/ya.make b/library/cpp/lwtrace/mon/analytics/ya.make new file mode 100644 index 00000000000..f4f70117dae --- /dev/null +++ b/library/cpp/lwtrace/mon/analytics/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + analytics.cpp +) + +END() diff --git a/library/cpp/lwtrace/mon/ya.make b/library/cpp/lwtrace/mon/ya.make new file mode 100644 index 00000000000..f6d60f8e7d5 --- /dev/null +++ b/library/cpp/lwtrace/mon/ya.make @@ -0,0 +1,53 @@ +LIBRARY() + +RESOURCE( + static/common.css lwtrace/mon/static/common.css + static/common.js lwtrace/mon/static/common.js + static/css/bootstrap.min.css lwtrace/mon/static/css/bootstrap.min.css + static/css/d3-gantt.css lwtrace/mon/static/css/d3-gantt.css + static/css/jquery.treegrid.css lwtrace/mon/static/css/jquery.treegrid.css + static/analytics.css lwtrace/mon/static/analytics.css + static/analytics.flot.html lwtrace/mon/static/analytics.flot.html + static/analytics.gantt.html lwtrace/mon/static/analytics.gantt.html + static/analytics.header.html lwtrace/mon/static/analytics.header.html + static/analytics.js lwtrace/mon/static/analytics.js + static/fonts/glyphicons-halflings-regular.eot lwtrace/mon/static/fonts/glyphicons-halflings-regular.eot + static/fonts/glyphicons-halflings-regular.svg lwtrace/mon/static/fonts/glyphicons-halflings-regular.svg + static/fonts/glyphicons-halflings-regular.ttf lwtrace/mon/static/fonts/glyphicons-halflings-regular.ttf + static/fonts/glyphicons-halflings-regular.woff2 lwtrace/mon/static/fonts/glyphicons-halflings-regular.woff2 + static/fonts/glyphicons-halflings-regular.woff lwtrace/mon/static/fonts/glyphicons-halflings-regular.woff + static/footer.html lwtrace/mon/static/footer.html + static/header.html lwtrace/mon/static/header.html + static/img/collapse.png lwtrace/mon/static/img/collapse.png + static/img/expand.png lwtrace/mon/static/img/expand.png + static/img/file.png lwtrace/mon/static/img/file.png + static/img/folder.png lwtrace/mon/static/img/folder.png + static/js/bootstrap.min.js lwtrace/mon/static/js/bootstrap.min.js + static/js/d3.v4.min.js lwtrace/mon/static/js/d3.v4.min.js + static/js/d3-gantt.js lwtrace/mon/static/js/d3-gantt.js + static/js/d3-tip-0.8.0-alpha.1.js lwtrace/mon/static/js/d3-tip-0.8.0-alpha.1.js + static/js/filesaver.min.js lwtrace/mon/static/js/filesaver.min.js + static/js/jquery.flot.extents.js lwtrace/mon/static/js/jquery.flot.extents.js + static/js/jquery.flot.min.js lwtrace/mon/static/js/jquery.flot.min.js + static/js/jquery.flot.navigate.min.js lwtrace/mon/static/js/jquery.flot.navigate.min.js + static/js/jquery.flot.selection.min.js lwtrace/mon/static/js/jquery.flot.selection.min.js + static/js/jquery.min.js lwtrace/mon/static/js/jquery.min.js + static/js/jquery.treegrid.bootstrap3.js lwtrace/mon/static/js/jquery.treegrid.bootstrap3.js + static/js/jquery.treegrid.min.js lwtrace/mon/static/js/jquery.treegrid.min.js + static/js/jquery.url.min.js lwtrace/mon/static/js/jquery.url.min.js +) + +SRCS( + mon_lwtrace.cpp +) + +PEERDIR( + library/cpp/html/pcdata + library/cpp/lwtrace + library/cpp/lwtrace/mon/analytics + library/cpp/monlib/dynamic_counters + library/cpp/resource + library/cpp/string_utils/base64 +) + +END() diff --git a/library/cpp/lwtrace/protos/ya.make b/library/cpp/lwtrace/protos/ya.make new file mode 100644 index 00000000000..4ddd5476bbb --- /dev/null +++ b/library/cpp/lwtrace/protos/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +INCLUDE_TAGS(GO_PROTO) + +SRCS( + lwtrace.proto +) + +END() diff --git a/library/cpp/lwtrace/tests/ya.make b/library/cpp/lwtrace/tests/ya.make new file mode 100644 index 00000000000..908fdf2330d --- /dev/null +++ b/library/cpp/lwtrace/tests/ya.make @@ -0,0 +1,13 @@ +PROGRAM() + +SRCS( + trace_tests.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/getopt + library/cpp/lwtrace +) + +END() diff --git a/library/cpp/lwtrace/ut/ya.make b/library/cpp/lwtrace/ut/ya.make new file mode 100644 index 00000000000..8b7c885786b --- /dev/null +++ b/library/cpp/lwtrace/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(library/cpp/lwtrace) + +FORK_SUBTESTS() + +SRCS( + log_ut.cpp + trace_ut.cpp +) + +END() diff --git a/library/cpp/lwtrace/ya.make b/library/cpp/lwtrace/ya.make new file mode 100644 index 00000000000..e3a92bec1f6 --- /dev/null +++ b/library/cpp/lwtrace/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +PEERDIR( + library/cpp/lwtrace/protos + library/cpp/deprecated/atomic +) + +SRCS( + check.cpp + control.cpp + custom_action.cpp + kill_action.cpp + log_shuttle.cpp + perf.cpp + probes.cpp + shuttle.cpp + sleep_action.cpp + start.cpp + stderr_writer.cpp + symbol.cpp + trace.cpp +) + +END() + +RECURSE( + example1 + example2 + example3 + example4 + example5 + mon + tests + ut +) diff --git a/library/cpp/malloc/api/helpers/ya.make b/library/cpp/malloc/api/helpers/ya.make new file mode 100644 index 00000000000..b09146f2fee --- /dev/null +++ b/library/cpp/malloc/api/helpers/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + library/cpp/malloc/api +) + +SRCS( + io.cpp +) + +END() diff --git a/library/cpp/malloc/api/ut/ya.make b/library/cpp/malloc/api/ut/ya.make new file mode 100644 index 00000000000..5580da99d73 --- /dev/null +++ b/library/cpp/malloc/api/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/malloc/api/helpers +) + +SRCS( + ut.cpp +) + +END() diff --git a/library/cpp/malloc/api/ya.make b/library/cpp/malloc/api/ya.make new file mode 100644 index 00000000000..499792ba197 --- /dev/null +++ b/library/cpp/malloc/api/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +NO_UTIL() + +SRCS( + malloc.cpp +) + +END() + +RECURSE( + helpers + ut +) diff --git a/library/cpp/malloc/jemalloc/ya.make b/library/cpp/malloc/jemalloc/ya.make new file mode 100644 index 00000000000..035133b0f5d --- /dev/null +++ b/library/cpp/malloc/jemalloc/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +NO_UTIL() +ALLOCATOR_IMPL() + +IF (OS_ANDROID) + PEERDIR( + library/cpp/malloc/system + ) +ELSE() + PEERDIR( + library/cpp/malloc/api + contrib/libs/jemalloc + ) + SRCS( + malloc-info.cpp + ) +ENDIF() + +END() diff --git a/library/cpp/malloc/mimalloc/link_test/ya.make b/library/cpp/malloc/mimalloc/link_test/ya.make new file mode 100644 index 00000000000..1488b55072f --- /dev/null +++ b/library/cpp/malloc/mimalloc/link_test/ya.make @@ -0,0 +1,9 @@ +PROGRAM() + +ALLOCATOR(MIM) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/malloc/mimalloc/ya.make b/library/cpp/malloc/mimalloc/ya.make new file mode 100644 index 00000000000..fe0f2fd0b52 --- /dev/null +++ b/library/cpp/malloc/mimalloc/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +NO_UTIL() +ALLOCATOR_IMPL() + +PEERDIR( + library/cpp/malloc/api + contrib/libs/mimalloc +) + +SRCS( + info.cpp +) + +END() + +RECURSE( + link_test +) diff --git a/library/cpp/malloc/system/ya.make b/library/cpp/malloc/system/ya.make new file mode 100644 index 00000000000..e8454480c3b --- /dev/null +++ b/library/cpp/malloc/system/ya.make @@ -0,0 +1,17 @@ +# External build system generator for opensource export relies on the name system_allocator. +# Change it carefully. +LIBRARY(system_allocator) + +ALLOCATOR_IMPL() + +NO_UTIL() + +PEERDIR( + library/cpp/malloc/api +) + +SRCS( + malloc-info.cpp +) + +END() diff --git a/library/cpp/malloc/tcmalloc/ya.make b/library/cpp/malloc/tcmalloc/ya.make new file mode 100644 index 00000000000..a558a514f47 --- /dev/null +++ b/library/cpp/malloc/tcmalloc/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +NO_UTIL() +ALLOCATOR_IMPL() + +PEERDIR( + library/cpp/malloc/api + contrib/libs/tcmalloc/malloc_extension +) +SRCS( + malloc-info.cpp +) + +END() diff --git a/library/cpp/messagebus/actor/ut/ya.make b/library/cpp/messagebus/actor/ut/ya.make new file mode 100644 index 00000000000..c2078d41b50 --- /dev/null +++ b/library/cpp/messagebus/actor/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST() + +PEERDIR( + library/cpp/messagebus/actor +) + +SRCS( + ../actor_ut.cpp + ../ring_buffer_ut.cpp + ../tasks_ut.cpp + ../what_thread_does_guard_ut.cpp +) + +END() diff --git a/library/cpp/messagebus/actor/ya.make b/library/cpp/messagebus/actor/ya.make new file mode 100644 index 00000000000..bd871502b60 --- /dev/null +++ b/library/cpp/messagebus/actor/ya.make @@ -0,0 +1,17 @@ +LIBRARY(messagebus_actor) + +SRCS( + executor.cpp + thread_extra.cpp + what_thread_does.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/messagebus/config/ya.make b/library/cpp/messagebus/config/ya.make new file mode 100644 index 00000000000..81ffbef0c6b --- /dev/null +++ b/library/cpp/messagebus/config/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/getopt + library/cpp/deprecated/enum_codegen +) + +SRCS( + netaddr.cpp + session_config.cpp +) + +END() diff --git a/library/cpp/messagebus/debug_receiver/ya.make b/library/cpp/messagebus/debug_receiver/ya.make new file mode 100644 index 00000000000..fe6904bdd7c --- /dev/null +++ b/library/cpp/messagebus/debug_receiver/ya.make @@ -0,0 +1,15 @@ +PROGRAM(messagebus_debug_receiver) + +SRCS( + debug_receiver.cpp + debug_receiver_proto.cpp + debug_receiver_handler.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/lwtrace + library/cpp/messagebus +) + +END() diff --git a/library/cpp/messagebus/monitoring/ya.make b/library/cpp/messagebus/monitoring/ya.make new file mode 100644 index 00000000000..7176d83951c --- /dev/null +++ b/library/cpp/messagebus/monitoring/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +PEERDIR( + library/cpp/monlib/encode/legacy_protobuf/protos +) + +SRCS( + mon_proto.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/library/cpp/messagebus/oldmodule/ya.make b/library/cpp/messagebus/oldmodule/ya.make new file mode 100644 index 00000000000..b9ada634676 --- /dev/null +++ b/library/cpp/messagebus/oldmodule/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/messagebus + library/cpp/messagebus/actor +) + +SRCS( + module.cpp + startsession.cpp +) + +END() diff --git a/library/cpp/messagebus/protobuf/ya.make b/library/cpp/messagebus/protobuf/ya.make new file mode 100644 index 00000000000..cbe79df6750 --- /dev/null +++ b/library/cpp/messagebus/protobuf/ya.make @@ -0,0 +1,13 @@ +LIBRARY(messagebus_protobuf) + +SRCS( + ybusbuf.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/messagebus + library/cpp/messagebus/actor +) + +END() diff --git a/library/cpp/messagebus/rain_check/core/ya.make b/library/cpp/messagebus/rain_check/core/ya.make new file mode 100644 index 00000000000..dfbbb1446b1 --- /dev/null +++ b/library/cpp/messagebus/rain_check/core/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +PEERDIR( + library/cpp/coroutine/engine + library/cpp/deprecated/enum_codegen + library/cpp/messagebus + library/cpp/messagebus/actor + library/cpp/messagebus/scheduler +) + +SRCS( + coro.cpp + coro_stack.cpp + env.cpp + rain_check.cpp + simple.cpp + sleep.cpp + spawn.cpp + task.cpp + track.cpp +) + +END() diff --git a/library/cpp/messagebus/rain_check/http/ya.make b/library/cpp/messagebus/rain_check/http/ya.make new file mode 100644 index 00000000000..f9aaf08fbf0 --- /dev/null +++ b/library/cpp/messagebus/rain_check/http/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + client.cpp + http_code_extractor.cpp +) + +PEERDIR( + library/cpp/messagebus/rain_check/core + library/cpp/neh + library/cpp/http/misc + library/cpp/http/io +) + +END() diff --git a/library/cpp/messagebus/rain_check/messagebus/ya.make b/library/cpp/messagebus/rain_check/messagebus/ya.make new file mode 100644 index 00000000000..a2f9c2825a6 --- /dev/null +++ b/library/cpp/messagebus/rain_check/messagebus/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/messagebus + library/cpp/messagebus/rain_check/core +) + +SRCS( + messagebus_client.cpp + messagebus_server.cpp +) + +END() diff --git a/library/cpp/messagebus/rain_check/test/helper/ya.make b/library/cpp/messagebus/rain_check/test/helper/ya.make new file mode 100644 index 00000000000..4cbdeeb4418 --- /dev/null +++ b/library/cpp/messagebus/rain_check/test/helper/ya.make @@ -0,0 +1,11 @@ +LIBRARY(messagebus-rain_check-test-helper) + +PEERDIR( + library/cpp/messagebus/rain_check/core +) + +SRCS( + misc.cpp +) + +END() diff --git a/library/cpp/messagebus/rain_check/test/perftest/ya.make b/library/cpp/messagebus/rain_check/test/perftest/ya.make new file mode 100644 index 00000000000..79d2884835e --- /dev/null +++ b/library/cpp/messagebus/rain_check/test/perftest/ya.make @@ -0,0 +1,12 @@ +PROGRAM(messagebus_rain_check_perftest) + +PEERDIR( + library/cpp/messagebus/rain_check/core + library/cpp/messagebus/rain_check/test/helper +) + +SRCS( + perftest.cpp +) + +END() diff --git a/library/cpp/messagebus/rain_check/test/ut/ya.make b/library/cpp/messagebus/rain_check/test/ut/ya.make new file mode 100644 index 00000000000..ba6fa9fc8ed --- /dev/null +++ b/library/cpp/messagebus/rain_check/test/ut/ya.make @@ -0,0 +1,22 @@ +PROGRAM(library-messagebus-rain_check-test-ut) + +PEERDIR( + library/cpp/testing/unittest_main + library/cpp/messagebus/rain_check/core + library/cpp/messagebus/rain_check/http + library/cpp/messagebus/rain_check/messagebus + library/cpp/messagebus/test/helper +) + +SRCS( + ../../core/coro_ut.cpp + ../../core/simple_ut.cpp + ../../core/sleep_ut.cpp + ../../core/spawn_ut.cpp + ../../core/track_ut.cpp + ../../http/client_ut.cpp + ../../messagebus/messagebus_client_ut.cpp + ../../messagebus/messagebus_server_ut.cpp +) + +END() diff --git a/library/cpp/messagebus/rain_check/test/ya.make b/library/cpp/messagebus/rain_check/test/ya.make new file mode 100644 index 00000000000..347086cbc30 --- /dev/null +++ b/library/cpp/messagebus/rain_check/test/ya.make @@ -0,0 +1,4 @@ +RECURSE( + perftest + ut +) diff --git a/library/cpp/messagebus/rain_check/ya.make b/library/cpp/messagebus/rain_check/ya.make new file mode 100644 index 00000000000..c8714647440 --- /dev/null +++ b/library/cpp/messagebus/rain_check/ya.make @@ -0,0 +1,6 @@ +RECURSE( + core + http + messagebus + test +) diff --git a/library/cpp/messagebus/scheduler/ut/ya.make b/library/cpp/messagebus/scheduler/ut/ya.make new file mode 100644 index 00000000000..b43dc6f2d51 --- /dev/null +++ b/library/cpp/messagebus/scheduler/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/messagebus/scheduler +) + +SRCS( + ../scheduler_ut.cpp +) + +END() diff --git a/library/cpp/messagebus/scheduler/ya.make b/library/cpp/messagebus/scheduler/ya.make new file mode 100644 index 00000000000..9ad77875def --- /dev/null +++ b/library/cpp/messagebus/scheduler/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + library/cpp/threading/future + library/cpp/deprecated/atomic +) + +SRCS( + scheduler.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/messagebus/test/example/client/ya.make b/library/cpp/messagebus/test/example/client/ya.make new file mode 100644 index 00000000000..41dace996ab --- /dev/null +++ b/library/cpp/messagebus/test/example/client/ya.make @@ -0,0 +1,11 @@ +PROGRAM(messagebus_example_client) + +PEERDIR( + library/cpp/messagebus/test/example/common +) + +SRCS( + client.cpp +) + +END() diff --git a/library/cpp/messagebus/test/example/common/ya.make b/library/cpp/messagebus/test/example/common/ya.make new file mode 100644 index 00000000000..1281f6b16a2 --- /dev/null +++ b/library/cpp/messagebus/test/example/common/ya.make @@ -0,0 +1,13 @@ +LIBRARY(messagebus_test_example_common) + +PEERDIR( + library/cpp/messagebus + library/cpp/messagebus/protobuf +) + +SRCS( + proto.cpp + messages.proto +) + +END() diff --git a/library/cpp/messagebus/test/example/server/ya.make b/library/cpp/messagebus/test/example/server/ya.make new file mode 100644 index 00000000000..70101f175ce --- /dev/null +++ b/library/cpp/messagebus/test/example/server/ya.make @@ -0,0 +1,11 @@ +PROGRAM(messagebus_example_server) + +PEERDIR( + library/cpp/messagebus/test/example/common +) + +SRCS( + server.cpp +) + +END() diff --git a/library/cpp/messagebus/test/example/ya.make b/library/cpp/messagebus/test/example/ya.make new file mode 100644 index 00000000000..36351241159 --- /dev/null +++ b/library/cpp/messagebus/test/example/ya.make @@ -0,0 +1,5 @@ +RECURSE( + client + common + server +) diff --git a/library/cpp/messagebus/test/helper/ya.make b/library/cpp/messagebus/test/helper/ya.make new file mode 100644 index 00000000000..bf65ab4ea0c --- /dev/null +++ b/library/cpp/messagebus/test/helper/ya.make @@ -0,0 +1,16 @@ +LIBRARY(messagebus_test_helper) + +SRCS( + example.cpp + example_module.cpp + fixed_port.cpp + message_handler_error.cpp + hanging_server.cpp +) + +PEERDIR( + library/cpp/messagebus/oldmodule + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/messagebus/test/perftest/ya.make b/library/cpp/messagebus/test/perftest/ya.make new file mode 100644 index 00000000000..4e71ae64cb5 --- /dev/null +++ b/library/cpp/messagebus/test/perftest/ya.make @@ -0,0 +1,22 @@ +PROGRAM(messagebus_perftest) + +PEERDIR( + library/cpp/deprecated/threadable + library/cpp/execprofile + library/cpp/getopt + library/cpp/lwtrace + library/cpp/messagebus + library/cpp/messagebus/oldmodule + library/cpp/messagebus/protobuf + library/cpp/messagebus/www + library/cpp/sighandler + library/cpp/threading/future +) + +SRCS( + messages.proto + perftest.cpp + simple_proto.cpp +) + +END() diff --git a/library/cpp/messagebus/test/ut/ya.make b/library/cpp/messagebus/test/ut/ya.make new file mode 100644 index 00000000000..561c6743a1c --- /dev/null +++ b/library/cpp/messagebus/test/ut/ya.make @@ -0,0 +1,51 @@ +UNITTEST_FOR(library/cpp/messagebus) + +TIMEOUT(1200) + +SIZE(LARGE) + +TAG( + ya:not_autocheck + ya:fat +) + +FORK_SUBTESTS() + +PEERDIR( + library/cpp/messagebus + library/cpp/messagebus/test/helper + library/cpp/messagebus/www + library/cpp/resource + library/cpp/deprecated/atomic +) + +SRCS( + messagebus_ut.cpp + module_client_ut.cpp + module_client_one_way_ut.cpp + module_server_ut.cpp + one_way_ut.cpp + starter_ut.cpp + sync_client_ut.cpp + locator_uniq_ut.cpp + www_ut.cpp + ../../async_result_ut.cpp + ../../cc_semaphore_ut.cpp + ../../coreconn_ut.cpp + ../../duration_histogram_ut.cpp + ../../message_status_counter_ut.cpp + ../../misc/weak_ptr_ut.cpp + ../../latch_ut.cpp + ../../lfqueue_batch_ut.cpp + ../../local_flags_ut.cpp + ../../memory_ut.cpp + ../../moved_ut.cpp + ../../netaddr_ut.cpp + ../../network_ut.cpp + ../../nondestroying_holder_ut.cpp + ../../scheduler_actor_ut.cpp + ../../socket_addr_ut.cpp + ../../vector_swaps_ut.cpp +) + +END() diff --git a/library/cpp/messagebus/test/ya.make b/library/cpp/messagebus/test/ya.make new file mode 100644 index 00000000000..ec6d54b0938 --- /dev/null +++ b/library/cpp/messagebus/test/ya.make @@ -0,0 +1,5 @@ +RECURSE( + example + perftest + ut +) diff --git a/library/cpp/messagebus/www/ya.make b/library/cpp/messagebus/www/ya.make new file mode 100644 index 00000000000..18329845baf --- /dev/null +++ b/library/cpp/messagebus/www/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + html_output.cpp + www.cpp +) + +RESOURCE( + messagebus.js /messagebus.js + bus-ico.png /bus-ico.png +) + +PEERDIR( + library/cpp/resource + library/cpp/cgiparam + library/cpp/html/pcdata + library/cpp/http/fetch + library/cpp/http/server + library/cpp/json/writer + library/cpp/messagebus + library/cpp/messagebus/oldmodule + library/cpp/monlib/deprecated/json + library/cpp/uri +) + +END() diff --git a/library/cpp/messagebus/ya.make b/library/cpp/messagebus/ya.make new file mode 100644 index 00000000000..c6ee800bb8a --- /dev/null +++ b/library/cpp/messagebus/ya.make @@ -0,0 +1,79 @@ +LIBRARY() + +IF (SANITIZER_TYPE == "undefined") + NO_SANITIZE() +ENDIF() + +SRCS( + acceptor.cpp + acceptor_status.cpp + connection.cpp + coreconn.cpp + duration_histogram.cpp + event_loop.cpp + futex_like.cpp + handler.cpp + key_value_printer.cpp + local_flags.cpp + locator.cpp + mb_lwtrace.cpp + message.cpp + message_counter.cpp + message_status.cpp + message_status_counter.cpp + messqueue.cpp + misc/atomic_box.h + misc/granup.h + misc/test_sync.h + misc/tokenquota.h + misc/weak_ptr.h + network.cpp + queue_config.cpp + remote_client_connection.cpp + remote_client_session.cpp + remote_client_session_semaphore.cpp + remote_connection.cpp + remote_connection_status.cpp + remote_server_connection.cpp + remote_server_session.cpp + remote_server_session_semaphore.cpp + session.cpp + session_impl.cpp + session_job_count.cpp + shutdown_state.cpp + socket_addr.cpp + storage.cpp + synchandler.cpp + use_after_free_checker.cpp + use_count_checker.cpp + ybus.h +) + +PEERDIR( + contrib/libs/sparsehash + library/cpp/codecs + library/cpp/deprecated/enum_codegen + library/cpp/getopt/small + library/cpp/lwtrace + library/cpp/messagebus/actor + library/cpp/messagebus/config + library/cpp/messagebus/monitoring + library/cpp/messagebus/scheduler + library/cpp/string_utils/indent_text + library/cpp/threading/future + library/cpp/deprecated/atomic +) + +END() + +RECURSE( + actor + config + debug_receiver + monitoring + oldmodule + rain_check + scheduler + test + www +) diff --git a/library/cpp/mime/types/ya.make b/library/cpp/mime/types/ya.make new file mode 100644 index 00000000000..6c6489003ba --- /dev/null +++ b/library/cpp/mime/types/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +SRCS( + mime.cpp +) + +GENERATE_ENUM_SERIALIZATION(mime.h) + +END() diff --git a/library/cpp/monlib/consumers/ya.make b/library/cpp/monlib/consumers/ya.make new file mode 100644 index 00000000000..8ac0bd54e75 --- /dev/null +++ b/library/cpp/monlib/consumers/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + collecting_consumer.cpp +) + +PEERDIR( + library/cpp/monlib/metrics +) + +END() diff --git a/library/cpp/monlib/deprecated/json/ut/ya.make b/library/cpp/monlib/deprecated/json/ut/ya.make new file mode 100644 index 00000000000..77930f1bf3a --- /dev/null +++ b/library/cpp/monlib/deprecated/json/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/monlib/deprecated/json) + +SRCS( + writer_ut.cpp +) + +END() diff --git a/library/cpp/monlib/deprecated/json/ya.make b/library/cpp/monlib/deprecated/json/ya.make new file mode 100644 index 00000000000..87f63a5c90e --- /dev/null +++ b/library/cpp/monlib/deprecated/json/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +# Deprecated writer of Solomon JSON format +# https://wiki.yandex-team.ru/solomon/api/dataformat/json +# +# This writer will be deleted soon, so please consider to use +# high level library library/cpp/monlib/encode which is decoupled from the +# particular format. + +SRCS( + writer.h + writer.cpp +) + +PEERDIR( + library/cpp/json +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/monlib/dynamic_counters/percentile/ut/ya.make b/library/cpp/monlib/dynamic_counters/percentile/ut/ya.make new file mode 100644 index 00000000000..f97dcbd92ea --- /dev/null +++ b/library/cpp/monlib/dynamic_counters/percentile/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/monlib/dynamic_counters/percentile) + + SRCS( + percentile_ut.cpp + ) + +END() diff --git a/library/cpp/monlib/dynamic_counters/percentile/ya.make b/library/cpp/monlib/dynamic_counters/percentile/ya.make new file mode 100644 index 00000000000..d6ab61f66f1 --- /dev/null +++ b/library/cpp/monlib/dynamic_counters/percentile/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + + SRCS( + percentile.h + percentile_lg.h + ) + + PEERDIR( + library/cpp/containers/stack_vector + library/cpp/monlib/dynamic_counters + ) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/monlib/dynamic_counters/ut/ya.make b/library/cpp/monlib/dynamic_counters/ut/ya.make new file mode 100644 index 00000000000..9c272eaea10 --- /dev/null +++ b/library/cpp/monlib/dynamic_counters/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(library/cpp/monlib/dynamic_counters) + +SRCS( + contention_ut.cpp + counters_ut.cpp + encode_ut.cpp +) + +PEERDIR( + library/cpp/monlib/encode/protobuf + library/cpp/monlib/encode/json +) + +END() diff --git a/library/cpp/monlib/dynamic_counters/ya.make b/library/cpp/monlib/dynamic_counters/ya.make new file mode 100644 index 00000000000..67ad8e19483 --- /dev/null +++ b/library/cpp/monlib/dynamic_counters/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +NO_WSHADOW() + +SRCS( + counters.cpp + encode.cpp + golovan_page.cpp + page.cpp +) + +PEERDIR( + library/cpp/containers/stack_vector + library/cpp/monlib/encode/json + library/cpp/monlib/encode/spack + library/cpp/monlib/encode/prometheus + library/cpp/monlib/service/pages + library/cpp/string_utils/quote + library/cpp/threading/light_rw_lock +) + +END() + +RECURSE( + percentile + ut +) diff --git a/library/cpp/monlib/encode/buffered/ut/ya.make b/library/cpp/monlib/encode/buffered/ut/ya.make new file mode 100644 index 00000000000..365b6e47405 --- /dev/null +++ b/library/cpp/monlib/encode/buffered/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/monlib/encode/buffered) + +SRCS( + string_pool_ut.cpp +) + +END() diff --git a/library/cpp/monlib/encode/buffered/ya.make b/library/cpp/monlib/encode/buffered/ya.make new file mode 100644 index 00000000000..e3d77932b14 --- /dev/null +++ b/library/cpp/monlib/encode/buffered/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + buffered_encoder_base.cpp + string_pool.cpp +) + +PEERDIR( + library/cpp/monlib/encode + library/cpp/monlib/metrics +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/monlib/encode/fake/ya.make b/library/cpp/monlib/encode/fake/ya.make new file mode 100644 index 00000000000..e5849dd8e93 --- /dev/null +++ b/library/cpp/monlib/encode/fake/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + fake.cpp +) + +END() diff --git a/library/cpp/monlib/encode/fuzz/ya.make b/library/cpp/monlib/encode/fuzz/ya.make new file mode 100644 index 00000000000..d9ca172bae4 --- /dev/null +++ b/library/cpp/monlib/encode/fuzz/ya.make @@ -0,0 +1,5 @@ +RECURSE_ROOT_RELATIVE( + library/cpp/monlib/encode/json/fuzz + library/cpp/monlib/encode/prometheus/fuzz + library/cpp/monlib/encode/spack/fuzz +) diff --git a/library/cpp/monlib/encode/json/fuzz/ya.make b/library/cpp/monlib/encode/json/fuzz/ya.make new file mode 100644 index 00000000000..545900c5c1f --- /dev/null +++ b/library/cpp/monlib/encode/json/fuzz/ya.make @@ -0,0 +1,14 @@ +FUZZ() + +PEERDIR( + library/cpp/monlib/encode/json + library/cpp/monlib/encode/fake +) + +SIZE(MEDIUM) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/monlib/encode/json/ut/ya.make b/library/cpp/monlib/encode/json/ut/ya.make new file mode 100644 index 00000000000..9be38d2fd47 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/ya.make @@ -0,0 +1,41 @@ +UNITTEST_FOR(library/cpp/monlib/encode/json) + +SRCS( + json_decoder_ut.cpp + json_ut.cpp +) + +RESOURCE( + buffered_test.json /buffered_test.json + buffered_ts_merge.json /buffered_ts_merge.json + empty_series.json /empty_series.json + expected.json /expected.json + expected_buffered.json /expected_buffered.json + expected_cloud.json /expected_cloud.json + expected_cloud_buffered.json /expected_cloud_buffered.json + merged.json /merged.json + histogram_timeseries.json /histogram_timeseries.json + histogram_value.json /histogram_value.json + histogram_value_inf_before_bounds.json /histogram_value_inf_before_bounds.json + int_gauge.json /int_gauge.json + sensors.json /sensors.json + metrics.json /metrics.json + named_metrics.json /named_metrics.json + test_decode_to_encode.json /test_decode_to_encode.json + crash.json /crash.json + hist_crash.json /hist_crash.json + summary_value.json /summary_value.json + summary_inf.json /summary_inf.json + summary_timeseries.json /summary_timeseries.json + log_histogram_value.json /log_histogram_value.json + log_histogram_timeseries.json /log_histogram_timeseries.json +) + +PEERDIR( + library/cpp/json + library/cpp/monlib/consumers + library/cpp/monlib/encode/protobuf + library/cpp/resource +) + +END() diff --git a/library/cpp/monlib/encode/json/ya.make b/library/cpp/monlib/encode/json/ya.make new file mode 100644 index 00000000000..45997b5037c --- /dev/null +++ b/library/cpp/monlib/encode/json/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + json_decoder.cpp + json_encoder.cpp +) + +PEERDIR( + library/cpp/monlib/encode + library/cpp/monlib/encode/buffered + library/cpp/monlib/exception + library/cpp/json + library/cpp/json/writer +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/monlib/encode/legacy_protobuf/protos/ya.make b/library/cpp/monlib/encode/legacy_protobuf/protos/ya.make new file mode 100644 index 00000000000..3623e094b53 --- /dev/null +++ b/library/cpp/monlib/encode/legacy_protobuf/protos/ya.make @@ -0,0 +1,11 @@ +PROTO_LIBRARY() + +SRCS( + metric_meta.proto +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() diff --git a/library/cpp/monlib/encode/prometheus/fuzz/ya.make b/library/cpp/monlib/encode/prometheus/fuzz/ya.make new file mode 100644 index 00000000000..22c3ca57834 --- /dev/null +++ b/library/cpp/monlib/encode/prometheus/fuzz/ya.make @@ -0,0 +1,14 @@ +FUZZ() + +PEERDIR( + library/cpp/monlib/encode/prometheus + library/cpp/monlib/encode/fake +) + +SIZE(MEDIUM) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/monlib/encode/prometheus/ut/ya.make b/library/cpp/monlib/encode/prometheus/ut/ya.make new file mode 100644 index 00000000000..735e48d05fb --- /dev/null +++ b/library/cpp/monlib/encode/prometheus/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(library/cpp/monlib/encode/prometheus) + +SRCS( + prometheus_encoder_ut.cpp + prometheus_decoder_ut.cpp +) + +PEERDIR( + library/cpp/monlib/encode/protobuf +) + +END() diff --git a/library/cpp/monlib/encode/prometheus/ya.make b/library/cpp/monlib/encode/prometheus/ya.make new file mode 100644 index 00000000000..c43e4c5e882 --- /dev/null +++ b/library/cpp/monlib/encode/prometheus/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + prometheus_decoder.cpp + prometheus_encoder.cpp +) + +PEERDIR( + library/cpp/monlib/encode + library/cpp/monlib/encode/buffered +) + +END() + +RECURSE( + fuzz + ut +) diff --git a/library/cpp/monlib/encode/protobuf/protos/ya.make b/library/cpp/monlib/encode/protobuf/protos/ya.make new file mode 100644 index 00000000000..a1c3ea1d588 --- /dev/null +++ b/library/cpp/monlib/encode/protobuf/protos/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + samples.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/library/cpp/monlib/encode/protobuf/ya.make b/library/cpp/monlib/encode/protobuf/ya.make new file mode 100644 index 00000000000..2c11e9b7933 --- /dev/null +++ b/library/cpp/monlib/encode/protobuf/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + protobuf_encoder.cpp +) + +PEERDIR( + library/cpp/monlib/encode + library/cpp/monlib/encode/protobuf/protos +) + +END() diff --git a/library/cpp/monlib/encode/spack/fuzz/ya.make b/library/cpp/monlib/encode/spack/fuzz/ya.make new file mode 100644 index 00000000000..bacb1f50a6d --- /dev/null +++ b/library/cpp/monlib/encode/spack/fuzz/ya.make @@ -0,0 +1,16 @@ +FUZZ() + +FUZZ_OPTS(-rss_limit_mb=1024) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/monlib/encode/spack + library/cpp/monlib/encode/fake +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/monlib/encode/spack/ut/ya.make b/library/cpp/monlib/encode/spack/ut/ya.make new file mode 100644 index 00000000000..ff42d19b70c --- /dev/null +++ b/library/cpp/monlib/encode/spack/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(library/cpp/monlib/encode/spack) + +SRCS( + spack_v1_ut.cpp +) + +PEERDIR( + library/cpp/monlib/encode/protobuf +) + +END() diff --git a/library/cpp/monlib/encode/spack/ya.make b/library/cpp/monlib/encode/spack/ya.make new file mode 100644 index 00000000000..22ccf0d786c --- /dev/null +++ b/library/cpp/monlib/encode/spack/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + spack_v1_decoder.cpp + spack_v1_encoder.cpp + varint.cpp + compression.cpp +) + +PEERDIR( + library/cpp/monlib/encode/buffered + library/cpp/monlib/exception + + contrib/libs/lz4 + contrib/libs/xxhash + contrib/libs/zlib + contrib/libs/zstd +) + +END() + +RECURSE( + fuzz + ut +) diff --git a/library/cpp/monlib/encode/text/ut/ya.make b/library/cpp/monlib/encode/text/ut/ya.make new file mode 100644 index 00000000000..beb40819598 --- /dev/null +++ b/library/cpp/monlib/encode/text/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/monlib/encode/text) + +SRCS( + text_encoder_ut.cpp +) + +END() diff --git a/library/cpp/monlib/encode/text/ya.make b/library/cpp/monlib/encode/text/ya.make new file mode 100644 index 00000000000..d328c1784e1 --- /dev/null +++ b/library/cpp/monlib/encode/text/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + text_encoder.cpp +) + +PEERDIR( + library/cpp/monlib/encode +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/monlib/encode/ut/ya.make b/library/cpp/monlib/encode/ut/ya.make new file mode 100644 index 00000000000..96e75d067c3 --- /dev/null +++ b/library/cpp/monlib/encode/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/monlib/encode) + +SRCS( + format_ut.cpp +) + +END() diff --git a/library/cpp/monlib/encode/ya.make b/library/cpp/monlib/encode/ya.make new file mode 100644 index 00000000000..9052c739112 --- /dev/null +++ b/library/cpp/monlib/encode/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + encoder.cpp + encoder_state.cpp + format.cpp +) + +PEERDIR( + library/cpp/monlib/metrics +) + +GENERATE_ENUM_SERIALIZATION_WITH_HEADER(encoder_state_enum.h) + +END() + +RECURSE( + fuzz + ut +) diff --git a/library/cpp/monlib/exception/ya.make b/library/cpp/monlib/exception/ya.make new file mode 100644 index 00000000000..b70228efd81 --- /dev/null +++ b/library/cpp/monlib/exception/ya.make @@ -0,0 +1,10 @@ +LIBRARY() + +SRCS( + exception.cpp +) + +PEERDIR( +) + +END() diff --git a/library/cpp/monlib/messagebus/ya.make b/library/cpp/monlib/messagebus/ya.make new file mode 100644 index 00000000000..117ba8e992b --- /dev/null +++ b/library/cpp/monlib/messagebus/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + mon_messagebus.cpp + mon_service_messagebus.cpp +) + +PEERDIR( + library/cpp/messagebus + library/cpp/messagebus/www + library/cpp/monlib/dynamic_counters +) + +END() diff --git a/library/cpp/monlib/metrics/ut/ya.make b/library/cpp/monlib/metrics/ut/ya.make new file mode 100644 index 00000000000..b0f3440750b --- /dev/null +++ b/library/cpp/monlib/metrics/ut/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(library/cpp/monlib/metrics) + +SRCS( + ewma_ut.cpp + fake_ut.cpp + histogram_collector_ut.cpp + labels_ut.cpp + log_histogram_collector_ut.cpp + metric_registry_ut.cpp + metric_sub_registry_ut.cpp + metric_value_ut.cpp + summary_collector_ut.cpp + timer_ut.cpp +) + +RESOURCE( + histograms.json /histograms.json +) + +PEERDIR( + library/cpp/resource + library/cpp/monlib/encode/protobuf + library/cpp/monlib/encode/json + library/cpp/threading/future +) + +END() diff --git a/library/cpp/monlib/metrics/ya.make b/library/cpp/monlib/metrics/ya.make new file mode 100644 index 00000000000..6e6997030fb --- /dev/null +++ b/library/cpp/monlib/metrics/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION_WITH_HEADER(metric_value_type.h) + +SRCS( + ewma.cpp + fake.cpp + histogram_collector_explicit.cpp + histogram_collector_exponential.cpp + histogram_collector_linear.cpp + histogram_snapshot.cpp + log_histogram_snapshot.cpp + labels.cpp + metric_registry.cpp + metric_consumer.cpp + metric_type.cpp + metric_value.cpp + summary_collector.cpp + summary_snapshot.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/monlib/service/pages/tablesorter/ya.make b/library/cpp/monlib/service/pages/tablesorter/ya.make new file mode 100644 index 00000000000..7906d696aeb --- /dev/null +++ b/library/cpp/monlib/service/pages/tablesorter/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +RESOURCE( + resources/jquery.tablesorter.css jquery.tablesorter.css + resources/jquery.tablesorter.js jquery.tablesorter.js +) + +PEERDIR( + library/cpp/monlib/dynamic_counters +) + +END() diff --git a/library/cpp/monlib/service/pages/ya.make b/library/cpp/monlib/service/pages/ya.make new file mode 100644 index 00000000000..956530ed555 --- /dev/null +++ b/library/cpp/monlib/service/pages/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +NO_WSHADOW() + +SRCS( + diag_mon_page.cpp + html_mon_page.cpp + index_mon_page.cpp + mon_page.cpp + pre_mon_page.cpp + resource_mon_page.cpp + templates.cpp + version_mon_page.cpp + registry_mon_page.cpp +) + +PEERDIR( + library/cpp/build_info + library/cpp/malloc/api + library/cpp/svnversion + library/cpp/resource + library/cpp/monlib/service + library/cpp/monlib/encode/json + library/cpp/monlib/encode/text + library/cpp/monlib/encode/spack + library/cpp/monlib/encode/prometheus +) + +END() diff --git a/library/cpp/monlib/service/ya.make b/library/cpp/monlib/service/ya.make new file mode 100644 index 00000000000..b07b3c9d12f --- /dev/null +++ b/library/cpp/monlib/service/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + monservice.cpp + mon_service_http_request.cpp + service.cpp + format.cpp + auth.cpp +) + +PEERDIR( + library/cpp/string_utils/base64 + contrib/libs/protobuf + library/cpp/coroutine/engine + library/cpp/coroutine/listener + library/cpp/http/fetch + library/cpp/http/server + library/cpp/http/io + library/cpp/logger + library/cpp/malloc/api + library/cpp/svnversion + library/cpp/uri + library/cpp/cgiparam +) + +END() diff --git a/library/cpp/neh/asio/ya.make b/library/cpp/neh/asio/ya.make new file mode 100644 index 00000000000..8e26bb7930e --- /dev/null +++ b/library/cpp/neh/asio/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +PEERDIR( + contrib/libs/libc_compat + library/cpp/coroutine/engine + library/cpp/dns + library/cpp/deprecated/atomic +) + +SRCS( + asio.cpp + deadline_timer_impl.cpp + executor.cpp + io_service_impl.cpp + poll_interrupter.cpp + tcp_acceptor_impl.cpp + tcp_socket_impl.cpp +) + +END() diff --git a/library/cpp/neh/ya.make b/library/cpp/neh/ya.make new file mode 100644 index 00000000000..f24f9fac600 --- /dev/null +++ b/library/cpp/neh/ya.make @@ -0,0 +1,53 @@ +LIBRARY() + +PEERDIR( + contrib/libs/openssl + library/cpp/containers/intrusive_rb_tree + library/cpp/coroutine/engine + library/cpp/coroutine/listener + library/cpp/dns + library/cpp/http/io + library/cpp/http/misc + library/cpp/http/push_parser + library/cpp/neh/asio + library/cpp/netliba/v6 + library/cpp/openssl/init + library/cpp/openssl/method + library/cpp/threading/atomic + library/cpp/threading/thread_local + library/cpp/deprecated/atomic +) + +SRCS( + conn_cache.cpp + factory.cpp + https.cpp + http_common.cpp + http_headers.cpp + http2.cpp + inproc.cpp + jobqueue.cpp + location.cpp + multi.cpp + multiclient.cpp + netliba.cpp + netliba_udp_http.cpp + neh.cpp + pipequeue.cpp + rpc.cpp + rq.cpp + smart_ptr.cpp + stat.cpp + tcp.cpp + tcp2.cpp + udp.cpp + utils.cpp +) + +GENERATE_ENUM_SERIALIZATION(http_common.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/netliba/socket/ya.make b/library/cpp/netliba/socket/ya.make new file mode 100644 index 00000000000..01ed1b57669 --- /dev/null +++ b/library/cpp/netliba/socket/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +IF (MUSL) + # TODO + NO_COMPILER_WARNINGS() +ENDIF() + +PEERDIR( + contrib/libs/libc_compat + library/cpp/threading/chunk_queue + library/cpp/deprecated/atomic +) + +SRCS( + creators.cpp + socket.cpp + stdafx.cpp +) + +END() diff --git a/library/cpp/netliba/v6/ya.make b/library/cpp/netliba/v6/ya.make new file mode 100644 index 00000000000..bb9982356cd --- /dev/null +++ b/library/cpp/netliba/v6/ya.make @@ -0,0 +1,44 @@ +LIBRARY() + +SRCS( + stdafx.cpp + udp_address.cpp + udp_client_server.cpp + udp_http.cpp + net_acks.cpp + udp_test.cpp + block_chain.cpp + net_test.cpp + udp_debug.cpp + udp_socket.cpp + net_queue_stat.h + ib_low.cpp + ib_buffers.cpp + ib_mem.cpp + ib_cs.cpp + ib_test.cpp + cpu_affinity.cpp + net_request.cpp + ib_collective.cpp + ib_memstream.cpp +) + +IF (OS_LINUX AND NOT CATBOOST_OPENSOURCE) + PEERDIR( + contrib/libs/ibdrv + ) +ENDIF() + +IF (CATBOOST_OPENSOURCE) + CFLAGS(-DCATBOOST_OPENSOURCE=yes) +ENDIF() + +PEERDIR( + library/cpp/binsaver + library/cpp/netliba/socket + library/cpp/string_utils/url + library/cpp/threading/atomic + library/cpp/threading/mux_event +) + +END() diff --git a/library/cpp/on_disk/chunks/ut/ya.make b/library/cpp/on_disk/chunks/ut/ya.make new file mode 100644 index 00000000000..3289aa50749 --- /dev/null +++ b/library/cpp/on_disk/chunks/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/on_disk/chunks) + +SRCS( + chunks_ut.cpp +) + +END() diff --git a/library/cpp/on_disk/chunks/ya.make b/library/cpp/on_disk/chunks/ya.make new file mode 100644 index 00000000000..b67e7ec32c4 --- /dev/null +++ b/library/cpp/on_disk/chunks/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + chunked_helpers.cpp + reader.cpp + writer.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/openssl/holders/ut/ya.make b/library/cpp/openssl/holders/ut/ya.make new file mode 100644 index 00000000000..cae373a4a99 --- /dev/null +++ b/library/cpp/openssl/holders/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/openssl/holders) + +SRCS( + evp_ut.cpp + hmac_ut.cpp +) + +END() diff --git a/library/cpp/openssl/holders/ya.make b/library/cpp/openssl/holders/ya.make new file mode 100644 index 00000000000..07e12af1ba6 --- /dev/null +++ b/library/cpp/openssl/holders/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + contrib/libs/openssl +) + +SRCS( + bio.cpp + x509_vfy.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/openssl/init/ya.make b/library/cpp/openssl/init/ya.make new file mode 100644 index 00000000000..1c39d273801 --- /dev/null +++ b/library/cpp/openssl/init/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + contrib/libs/openssl +) + +SRCS( + init.cpp +) + +END() diff --git a/library/cpp/openssl/io/ut/ya.make b/library/cpp/openssl/io/ut/ya.make new file mode 100644 index 00000000000..54a88ddad3c --- /dev/null +++ b/library/cpp/openssl/io/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/openssl/io) + +SRCS( + builtin_ut.cpp +) + +END() diff --git a/library/cpp/openssl/io/ya.make b/library/cpp/openssl/io/ya.make new file mode 100644 index 00000000000..3fbb74fb9f5 --- /dev/null +++ b/library/cpp/openssl/io/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + certs + contrib/libs/openssl + library/cpp/openssl/init + library/cpp/openssl/method +) + +SRCS( + stream.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/openssl/method/ut/ya.make b/library/cpp/openssl/method/ut/ya.make new file mode 100644 index 00000000000..493e582a68b --- /dev/null +++ b/library/cpp/openssl/method/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/openssl/method) + +SRCS( + io_ut.cpp +) + +END() diff --git a/library/cpp/openssl/method/ya.make b/library/cpp/openssl/method/ya.make new file mode 100644 index 00000000000..21e5007a854 --- /dev/null +++ b/library/cpp/openssl/method/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + contrib/libs/openssl + library/cpp/openssl/holders +) + +SRCS( + io.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/packedtypes/ut/ya.make b/library/cpp/packedtypes/ut/ya.make new file mode 100644 index 00000000000..3254037ad8b --- /dev/null +++ b/library/cpp/packedtypes/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(library/cpp/packedtypes) + +PEERDIR( + library/cpp/digest/old_crc +) + +SRCS( + longs_ut.cpp + packed_ut.cpp + packedfloat_ut.cpp + zigzag_ut.cpp +) + +END() diff --git a/library/cpp/packedtypes/ya.make b/library/cpp/packedtypes/ya.make new file mode 100644 index 00000000000..0b7e6d78fce --- /dev/null +++ b/library/cpp/packedtypes/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +PEERDIR( + library/cpp/streams/zc_memory_input +) + +SRCS( + fixed_point.h + longs.cpp + packed.h + packedfloat.cpp + packedfloat.h + zigzag.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/packers/ut/ya.make b/library/cpp/packers/ut/ya.make new file mode 100644 index 00000000000..0aae24a72f3 --- /dev/null +++ b/library/cpp/packers/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(library/cpp/packers) + +SRCS( + packers_ut.cpp + proto_packer_ut.cpp + region_packer_ut.cpp + test.proto +) + +END() diff --git a/library/cpp/packers/ya.make b/library/cpp/packers/ya.make new file mode 100644 index 00000000000..87a90c822c5 --- /dev/null +++ b/library/cpp/packers/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + packers.cpp + proto_packer.cpp + region_packer.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/pop_count/benchmark/ya.make b/library/cpp/pop_count/benchmark/ya.make new file mode 100644 index 00000000000..e7ea9418db5 --- /dev/null +++ b/library/cpp/pop_count/benchmark/ya.make @@ -0,0 +1,12 @@ +Y_BENCHMARK() + +PEERDIR( + util/draft + library/cpp/pop_count +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/pop_count/ut/ya.make b/library/cpp/pop_count/ut/ya.make new file mode 100644 index 00000000000..179d47f064d --- /dev/null +++ b/library/cpp/pop_count/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/pop_count) + +SRCS( + popcount_ut.cpp +) + +END() diff --git a/library/cpp/pop_count/ya.make b/library/cpp/pop_count/ya.make new file mode 100644 index 00000000000..d858f3e87ec --- /dev/null +++ b/library/cpp/pop_count/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + popcount.cpp +) + +END() + +RECURSE( + benchmark + ut +) diff --git a/library/cpp/presort/ya.make b/library/cpp/presort/ya.make new file mode 100644 index 00000000000..21204b9ef1a --- /dev/null +++ b/library/cpp/presort/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + presort.cpp +) + +END() diff --git a/library/cpp/protobuf/interop/ut/ya.make b/library/cpp/protobuf/interop/ut/ya.make new file mode 100644 index 00000000000..07813fe5dfa --- /dev/null +++ b/library/cpp/protobuf/interop/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(library/cpp/protobuf/interop) + +SRCS( + cast_ut.cpp +) + +PEERDIR( + library/cpp/protobuf/interop +) + +END() diff --git a/library/cpp/protobuf/interop/ya.make b/library/cpp/protobuf/interop/ya.make new file mode 100644 index 00000000000..ed6fcd65cd9 --- /dev/null +++ b/library/cpp/protobuf/interop/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + cast.cpp +) + +PEERDIR( + contrib/libs/protobuf +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/protobuf/json/ut/ya.make b/library/cpp/protobuf/json/ut/ya.make new file mode 100644 index 00000000000..2a5391e375d --- /dev/null +++ b/library/cpp/protobuf/json/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(library/cpp/protobuf/json) + +SRCS( + filter_ut.cpp + json2proto_ut.cpp + proto2json_ut.cpp + inline_ut.proto + inline_ut.cpp + string_transform_ut.cpp + filter_ut.proto + test.proto + util_ut.cpp +) + +GENERATE_ENUM_SERIALIZATION(test.pb.h) + +PEERDIR( + library/cpp/protobuf/interop + library/cpp/protobuf/json +) + +END() diff --git a/library/cpp/protobuf/json/ya.make b/library/cpp/protobuf/json/ya.make new file mode 100644 index 00000000000..7dbd055a3a2 --- /dev/null +++ b/library/cpp/protobuf/json/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + json2proto.cpp + json_output_create.cpp + json_value_output.cpp + json_writer_output.cpp + name_generator.cpp + proto2json.cpp + proto2json_printer.cpp + string_transform.cpp + util.h + util.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/json + library/cpp/protobuf/util + library/cpp/string_utils/relaxed_escaper +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/protobuf/util/proto/ya.make b/library/cpp/protobuf/util/proto/ya.make new file mode 100644 index 00000000000..f3fedf54cd7 --- /dev/null +++ b/library/cpp/protobuf/util/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + merge.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/library/cpp/protobuf/util/ut/ya.make b/library/cpp/protobuf/util/ut/ya.make new file mode 100644 index 00000000000..1f321085b1a --- /dev/null +++ b/library/cpp/protobuf/util/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(library/cpp/protobuf/util) + +SRCS( + extensions.proto + sample_for_is_equal.proto + sample_for_simple_reflection.proto + common_ut.proto + pb_io_ut.cpp + is_equal_ut.cpp + iterators_ut.cpp + simple_reflection_ut.cpp + repeated_field_utils_ut.cpp + walk_ut.cpp + merge_ut.cpp +) + +END() diff --git a/library/cpp/protobuf/util/ya.make b/library/cpp/protobuf/util/ya.make new file mode 100644 index 00000000000..98c6a0306d4 --- /dev/null +++ b/library/cpp/protobuf/util/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +PEERDIR( + contrib/libs/protobuf + library/cpp/binsaver + library/cpp/protobuf/util/proto + library/cpp/string_utils/base64 +) + +SRCS( + is_equal.cpp + iterators.h + merge.cpp + path.cpp + pb_io.cpp + pb_utils.h + repeated_field_utils.h + simple_reflection.cpp + walk.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/random_provider/ya.make b/library/cpp/random_provider/ya.make new file mode 100644 index 00000000000..f4cf8ed7dfb --- /dev/null +++ b/library/cpp/random_provider/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +SRCS( + random_provider.cpp + random_provider.h +) + +END() diff --git a/library/cpp/regex/hyperscan/ut/ya.make b/library/cpp/regex/hyperscan/ut/ya.make new file mode 100644 index 00000000000..ea5fa1b21bc --- /dev/null +++ b/library/cpp/regex/hyperscan/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/regex/hyperscan +) + +SRCS( + hyperscan_ut.cpp +) + +END() diff --git a/library/cpp/regex/hyperscan/ya.make b/library/cpp/regex/hyperscan/ya.make new file mode 100644 index 00000000000..72abbef9a26 --- /dev/null +++ b/library/cpp/regex/hyperscan/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + contrib/libs/hyperscan + contrib/libs/hyperscan/runtime_core2 + contrib/libs/hyperscan/runtime_corei7 + contrib/libs/hyperscan/runtime_avx2 + contrib/libs/hyperscan/runtime_avx512 +) + +SRCS( + hyperscan.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/regex/pcre/benchmark/ya.make b/library/cpp/regex/pcre/benchmark/ya.make new file mode 100644 index 00000000000..7f138f70123 --- /dev/null +++ b/library/cpp/regex/pcre/benchmark/ya.make @@ -0,0 +1,12 @@ +G_BENCHMARK() + +PEERDIR( + library/cpp/regex/pcre +) + +SRCS( + main.cpp +) + +END() + diff --git a/library/cpp/regex/pcre/ut/ya.make b/library/cpp/regex/pcre/ut/ya.make new file mode 100644 index 00000000000..f3742e02b89 --- /dev/null +++ b/library/cpp/regex/pcre/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/regex/pcre) + +SRCS( + pcre_ut.cpp + regexp_ut.cpp +) + +END() diff --git a/library/cpp/regex/pcre/ya.make b/library/cpp/regex/pcre/ya.make new file mode 100644 index 00000000000..a1f5f3d4d6a --- /dev/null +++ b/library/cpp/regex/pcre/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +PEERDIR( + contrib/libs/pcre + contrib/libs/pcre/pcre16 + contrib/libs/pcre/pcre32 + library/cpp/containers/stack_array +) + +SRCS( + pcre.cpp + regexp.cpp +) + +END() + +RECURSE_FOR_TESTS( + benchmark + ut +) + diff --git a/library/cpp/regex/pire/inline/ya.make b/library/cpp/regex/pire/inline/ya.make new file mode 100644 index 00000000000..fb6aab0839c --- /dev/null +++ b/library/cpp/regex/pire/inline/ya.make @@ -0,0 +1,17 @@ +PROGRAM(pire_inline) + +CFLAGS(-DPIRE_NO_CONFIG) + +PEERDIR( + ADDINCL library/cpp/regex/pire +) + +SRCDIR( + contrib/libs/pire/pire +) + +SRCS( + inline.l +) + +END() diff --git a/library/cpp/regex/pire/ut/ya.make b/library/cpp/regex/pire/ut/ya.make new file mode 100644 index 00000000000..0e106cf6b33 --- /dev/null +++ b/library/cpp/regex/pire/ut/ya.make @@ -0,0 +1,39 @@ +# this test in not linked into build tree with ReCURSE and is built by unittest/library + +UNITTEST() + +SET(PIRETESTSDIR contrib/libs/pire/ut) + +CFLAGS(-DPIRE_NO_CONFIG) + +PEERDIR( + library/cpp/regex/pire +) + +SRCDIR( + ${PIRETESTSDIR} +) + +ADDINCL( + contrib/libs/pire/pire + contrib/libs/pire/ut +) + +SRCS( + pire_ut.cpp + capture_ut.cpp + count_ut.cpp + glyph_ut.cpp + easy_ut.cpp + read_unicode_ut.cpp + regexp_ut.cpp + approx_matching_ut.cpp +) + +SIZE(MEDIUM) + +TIMEOUT(600) + +PIRE_INLINE(inline_ut.cpp) + +END() diff --git a/library/cpp/regex/pire/ya.make b/library/cpp/regex/pire/ya.make new file mode 100644 index 00000000000..b2579a73dff --- /dev/null +++ b/library/cpp/regex/pire/ya.make @@ -0,0 +1,33 @@ +LIBRARY() + +CFLAGS(-DPIRE_NO_CONFIG) + +SRCDIR(contrib/libs/pire/pire) + +SRCS( + pcre2pire.cpp + classes.cpp + encoding.cpp + fsm.cpp + scanner_io.cpp + easy.cpp + scanners/null.cpp + extra/capture.cpp + extra/count.cpp + extra/glyphs.cpp + re_lexer.cpp + re_parser.y + read_unicode.cpp + extraencodings.cpp + approx_matching.cpp + half_final_fsm.cpp + minimize.h +) + +PEERDIR( + library/cpp/charset +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/resource/ut/lib/ya.make b/library/cpp/resource/ut/lib/ya.make new file mode 100644 index 00000000000..a6524b06b8e --- /dev/null +++ b/library/cpp/resource/ut/lib/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +RESOURCE( + data /x +) + +END() diff --git a/library/cpp/resource/ut/ya.make b/library/cpp/resource/ut/ya.make new file mode 100644 index 00000000000..a07e24f4d82 --- /dev/null +++ b/library/cpp/resource/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/resource/ut/lib) + +SRCS( + resource_ut.cpp +) + +END() diff --git a/library/cpp/resource/ya.make b/library/cpp/resource/ya.make new file mode 100644 index 00000000000..e6961d2bb20 --- /dev/null +++ b/library/cpp/resource/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + library/cpp/blockcodecs/core + library/cpp/blockcodecs/codecs/zstd +) + +SRCS( + registry.cpp + resource.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/retry/protos/ya.make b/library/cpp/retry/protos/ya.make new file mode 100644 index 00000000000..5530fbfb0d1 --- /dev/null +++ b/library/cpp/retry/protos/ya.make @@ -0,0 +1,12 @@ +PROTO_LIBRARY() + +SRCS( + retry_options.proto +) + +PEERDIR() + +EXCLUDE_TAGS(GO_PROTO) + +END() + diff --git a/library/cpp/retry/ut/ya.make b/library/cpp/retry/ut/ya.make new file mode 100644 index 00000000000..10825edd324 --- /dev/null +++ b/library/cpp/retry/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/retry) + +SRCS( + retry_policy_ut.cpp + retry_ut.cpp +) + +END() diff --git a/library/cpp/retry/ya.make b/library/cpp/retry/ya.make new file mode 100644 index 00000000000..8f901085b0a --- /dev/null +++ b/library/cpp/retry/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + retry.cpp + utils.cpp +) + +PEERDIR( + library/cpp/retry/protos +) + +END() + +RECURSE( + protos + ut +) diff --git a/library/cpp/scheme/tests/fuzz_json/lib/ya.make b/library/cpp/scheme/tests/fuzz_json/lib/ya.make new file mode 100644 index 00000000000..471f9624d77 --- /dev/null +++ b/library/cpp/scheme/tests/fuzz_json/lib/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + fuzz_json.cpp +) + +PEERDIR( + library/cpp/scheme +) + +END() diff --git a/library/cpp/scheme/tests/fuzz_json/ya.make b/library/cpp/scheme/tests/fuzz_json/ya.make new file mode 100644 index 00000000000..1a00d69d570 --- /dev/null +++ b/library/cpp/scheme/tests/fuzz_json/ya.make @@ -0,0 +1,13 @@ +FUZZ() + +SIZE(MEDIUM) + +SRCS( + fuzz_json.cpp +) + +PEERDIR( + library/cpp/scheme/tests/fuzz_json/lib +) + +END() diff --git a/library/cpp/scheme/tests/fuzz_ops/lib/ya.make b/library/cpp/scheme/tests/fuzz_ops/lib/ya.make new file mode 100644 index 00000000000..642e76862c6 --- /dev/null +++ b/library/cpp/scheme/tests/fuzz_ops/lib/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(vm_defs.h) + +SRCS( + fuzz_ops.cpp + vm_apply.cpp + vm_defs.cpp + vm_parse.cpp +) + +PEERDIR( + library/cpp/scheme +) + +END() diff --git a/library/cpp/scheme/tests/fuzz_ops/ut/ya.make b/library/cpp/scheme/tests/fuzz_ops/ut/ya.make new file mode 100644 index 00000000000..042a1038679 --- /dev/null +++ b/library/cpp/scheme/tests/fuzz_ops/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + library/cpp/testing/unittest + library/cpp/scheme + library/cpp/scheme/tests/fuzz_ops/lib +) + +SRCS( + vm_parse_ut.cpp +) + +END() diff --git a/library/cpp/scheme/tests/fuzz_ops/ya.make b/library/cpp/scheme/tests/fuzz_ops/ya.make new file mode 100644 index 00000000000..7f11242f2d4 --- /dev/null +++ b/library/cpp/scheme/tests/fuzz_ops/ya.make @@ -0,0 +1,11 @@ +FUZZ() + +SRCS( + fuzz_ops.cpp +) + +PEERDIR( + library/cpp/scheme/tests/fuzz_ops/lib +) + +END() diff --git a/library/cpp/scheme/tests/ut/ya.make b/library/cpp/scheme/tests/ut/ya.make new file mode 100644 index 00000000000..ceea46500fc --- /dev/null +++ b/library/cpp/scheme/tests/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST() + +PEERDIR( + library/cpp/protobuf/util + library/cpp/scheme/tests/fuzz_ops/lib + library/cpp/scheme/ut_utils + library/cpp/string_utils/quote + library/cpp/testing/unittest +) + +SRCS( + fuzz_ops_found_bugs_ut.cpp + scheme_cast_ut.cpp + scheme_json_ut.cpp + scheme_merge_ut.cpp + scheme_path_ut.cpp + scheme_proto_ut.cpp + scheme_ut.cpp + scheme_ut.proto +) + +END() diff --git a/library/cpp/scheme/tests/ya.make b/library/cpp/scheme/tests/ya.make new file mode 100644 index 00000000000..4e3d5791272 --- /dev/null +++ b/library/cpp/scheme/tests/ya.make @@ -0,0 +1,6 @@ +RECURSE( + fuzz_json + fuzz_ops + fuzz_ops/ut + ut +) diff --git a/library/cpp/scheme/ut_utils/ya.make b/library/cpp/scheme/ut_utils/ya.make new file mode 100644 index 00000000000..15200afca3e --- /dev/null +++ b/library/cpp/scheme/ut_utils/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + scheme_ut_utils.cpp +) + +PEERDIR( + library/cpp/colorizer + library/cpp/json + library/cpp/scheme + library/cpp/testing/unittest +) + +END() diff --git a/library/cpp/scheme/util/ya.make b/library/cpp/scheme/util/ya.make new file mode 100644 index 00000000000..274c481a992 --- /dev/null +++ b/library/cpp/scheme/util/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + scheme_holder.cpp + utils.cpp +) + +PEERDIR( + library/cpp/string_utils/base64 +) + +END() diff --git a/library/cpp/scheme/ya.make b/library/cpp/scheme/ya.make new file mode 100644 index 00000000000..2b6c79a2e0e --- /dev/null +++ b/library/cpp/scheme/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +SRCS( + scheme.cpp + scheme_cast.h + scimpl.h + scimpl_defs.h + scimpl_private.cpp + scimpl_protobuf.cpp + scimpl_select.rl6 + scimpl_json_read.cpp + scimpl_json_write.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/json + library/cpp/string_utils/relaxed_escaper +) + +GENERATE_ENUM_SERIALIZATION(scheme.h) + +END() + +RECURSE( + tests + ut_utils + util +) diff --git a/library/cpp/sighandler/ya.make b/library/cpp/sighandler/ya.make new file mode 100644 index 00000000000..d303178df45 --- /dev/null +++ b/library/cpp/sighandler/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + async_signals_handler.cpp + async_signals_handler.h +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/sliding_window/ut/ya.make b/library/cpp/sliding_window/ut/ya.make new file mode 100644 index 00000000000..f38df817a95 --- /dev/null +++ b/library/cpp/sliding_window/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/sliding_window) + +SRCS( + sliding_window_ut.cpp +) + +END() diff --git a/library/cpp/sliding_window/ya.make b/library/cpp/sliding_window/ya.make new file mode 100644 index 00000000000..3a81e864940 --- /dev/null +++ b/library/cpp/sliding_window/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + sliding_window.cpp + sliding_window.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/sse/ut/ya.make b/library/cpp/sse/ut/ya.make new file mode 100644 index 00000000000..bdcbac1d69c --- /dev/null +++ b/library/cpp/sse/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(library/cpp/sse) + +SRCS( + test.cpp +) + +IF (ARCH_X86_64) + CFLAGS(-msse4.1 -msse4.2) +ENDIF() + +END() diff --git a/library/cpp/sse/ya.make b/library/cpp/sse/ya.make new file mode 100644 index 00000000000..15c7cde0c17 --- /dev/null +++ b/library/cpp/sse/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + sse.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/streams/brotli/ut/ya.make b/library/cpp/streams/brotli/ut/ya.make new file mode 100644 index 00000000000..ffa9c0748ab --- /dev/null +++ b/library/cpp/streams/brotli/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/streams/brotli) + +SRCS( + brotli_ut.cpp +) + +END() diff --git a/library/cpp/streams/brotli/ya.make b/library/cpp/streams/brotli/ya.make new file mode 100644 index 00000000000..abc1006372c --- /dev/null +++ b/library/cpp/streams/brotli/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + contrib/libs/brotli/enc + contrib/libs/brotli/dec +) + +SRCS( + brotli.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/streams/bzip2/ut/ya.make b/library/cpp/streams/bzip2/ut/ya.make new file mode 100644 index 00000000000..86e36216a41 --- /dev/null +++ b/library/cpp/streams/bzip2/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/streams/bzip2) + +SRCS( + bzip2_ut.cpp +) + +END() diff --git a/library/cpp/streams/bzip2/ya.make b/library/cpp/streams/bzip2/ya.make new file mode 100644 index 00000000000..bdbc706a860 --- /dev/null +++ b/library/cpp/streams/bzip2/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + contrib/libs/libbz2 +) + +SRCS( + bzip2.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/streams/lzma/ut/ya.make b/library/cpp/streams/lzma/ut/ya.make new file mode 100644 index 00000000000..99b7e5e401a --- /dev/null +++ b/library/cpp/streams/lzma/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/streams/lzma) + +SRCS( + lzma_ut.cpp +) + +END() diff --git a/library/cpp/streams/lzma/ya.make b/library/cpp/streams/lzma/ya.make new file mode 100644 index 00000000000..2b2e352ebda --- /dev/null +++ b/library/cpp/streams/lzma/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + contrib/libs/lzmasdk +) + +SRCS( + lzma.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/streams/zc_memory_input/ya.make b/library/cpp/streams/zc_memory_input/ya.make new file mode 100644 index 00000000000..3909706ffa8 --- /dev/null +++ b/library/cpp/streams/zc_memory_input/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + zc_memory_input.cpp +) + +END() diff --git a/library/cpp/streams/zstd/ut/ya.make b/library/cpp/streams/zstd/ut/ya.make new file mode 100644 index 00000000000..3e490b9bc13 --- /dev/null +++ b/library/cpp/streams/zstd/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/streams/zstd) + +SRCS( + zstd_ut.cpp +) + +END() diff --git a/library/cpp/streams/zstd/ya.make b/library/cpp/streams/zstd/ya.make new file mode 100644 index 00000000000..e920a0fab47 --- /dev/null +++ b/library/cpp/streams/zstd/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + contrib/libs/zstd +) + +SRCS( + zstd.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/string_utils/base64/bench/metrics/ya.make b/library/cpp/string_utils/base64/bench/metrics/ya.make new file mode 100644 index 00000000000..d941438e1a1 --- /dev/null +++ b/library/cpp/string_utils/base64/bench/metrics/ya.make @@ -0,0 +1,15 @@ +PY2TEST() + +SIZE(LARGE) + +TAG( + ya:force_sandbox + sb:intel_e5_2660v1 + ya:fat +) + +TEST_SRCS(main.py) + +DEPENDS(library/cpp/string_utils/base64/bench) + +END() diff --git a/library/cpp/string_utils/base64/bench/ya.make b/library/cpp/string_utils/base64/bench/ya.make new file mode 100644 index 00000000000..6e47492f27c --- /dev/null +++ b/library/cpp/string_utils/base64/bench/ya.make @@ -0,0 +1,15 @@ +Y_BENCHMARK() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/string_utils/base64 +) + +END() + +RECURSE( + metrics +) diff --git a/library/cpp/string_utils/base64/fuzz/generic/ya.make b/library/cpp/string_utils/base64/fuzz/generic/ya.make new file mode 100644 index 00000000000..42200698ea3 --- /dev/null +++ b/library/cpp/string_utils/base64/fuzz/generic/ya.make @@ -0,0 +1,7 @@ +FUZZ() + +PEERDIR( + library/cpp/string_utils/base64/fuzz/lib +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/lib/ya.make b/library/cpp/string_utils/base64/fuzz/lib/ya.make new file mode 100644 index 00000000000..9ce31c32999 --- /dev/null +++ b/library/cpp/string_utils/base64/fuzz/lib/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/string_utils/base64 +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/uneven/ya.make b/library/cpp/string_utils/base64/fuzz/uneven/ya.make new file mode 100644 index 00000000000..b43737fccf9 --- /dev/null +++ b/library/cpp/string_utils/base64/fuzz/uneven/ya.make @@ -0,0 +1,11 @@ +FUZZ() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/string_utils/base64 +) + +END() diff --git a/library/cpp/string_utils/base64/fuzz/ya.make b/library/cpp/string_utils/base64/fuzz/ya.make new file mode 100644 index 00000000000..87a10e7ac46 --- /dev/null +++ b/library/cpp/string_utils/base64/fuzz/ya.make @@ -0,0 +1,5 @@ +RECURSE( + generic + lib + uneven +) diff --git a/library/cpp/string_utils/base64/ut/ya.make b/library/cpp/string_utils/base64/ut/ya.make new file mode 100644 index 00000000000..bfab185e891 --- /dev/null +++ b/library/cpp/string_utils/base64/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(library/cpp/string_utils/base64) + +SRCS( + base64_ut.cpp + base64_decode_uneven_ut.cpp +) + +PEERDIR( + contrib/libs/base64/avx2 + contrib/libs/base64/ssse3 + contrib/libs/base64/neon32 + contrib/libs/base64/neon64 + contrib/libs/base64/plain32 + contrib/libs/base64/plain64 +) + +END() diff --git a/library/cpp/string_utils/base64/ya.make b/library/cpp/string_utils/base64/ya.make new file mode 100644 index 00000000000..695da9a14b7 --- /dev/null +++ b/library/cpp/string_utils/base64/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + base64.cpp +) + +PEERDIR( + contrib/libs/base64/avx2 + contrib/libs/base64/ssse3 + contrib/libs/base64/neon32 + contrib/libs/base64/neon64 + contrib/libs/base64/plain32 + contrib/libs/base64/plain64 +) + +END() + +RECURSE( + bench + fuzz + ut +) diff --git a/library/cpp/string_utils/csv/ya.make b/library/cpp/string_utils/csv/ya.make new file mode 100644 index 00000000000..16682d40e56 --- /dev/null +++ b/library/cpp/string_utils/csv/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + csv.cpp +) + +END() diff --git a/library/cpp/string_utils/indent_text/ya.make b/library/cpp/string_utils/indent_text/ya.make new file mode 100644 index 00000000000..28a5e77cfe5 --- /dev/null +++ b/library/cpp/string_utils/indent_text/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + indent_text.cpp +) + +END() diff --git a/library/cpp/string_utils/levenshtein_diff/ut/ya.make b/library/cpp/string_utils/levenshtein_diff/ut/ya.make new file mode 100644 index 00000000000..30ff29f97b7 --- /dev/null +++ b/library/cpp/string_utils/levenshtein_diff/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/string_utils/levenshtein_diff) + +SRCS( + levenshtein_diff_ut.cpp +) + +END() diff --git a/library/cpp/string_utils/levenshtein_diff/ya.make b/library/cpp/string_utils/levenshtein_diff/ya.make new file mode 100644 index 00000000000..3baf79d7ad7 --- /dev/null +++ b/library/cpp/string_utils/levenshtein_diff/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + levenshtein_diff.cpp +) + +PEERDIR( + util/draft +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/string_utils/parse_size/ut/ya.make b/library/cpp/string_utils/parse_size/ut/ya.make new file mode 100644 index 00000000000..f570c5cfbac --- /dev/null +++ b/library/cpp/string_utils/parse_size/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/string_utils/parse_size) + +SRCS( + parse_size_ut.cpp +) + +END() diff --git a/library/cpp/string_utils/parse_size/ya.make b/library/cpp/string_utils/parse_size/ya.make new file mode 100644 index 00000000000..d960d156bb0 --- /dev/null +++ b/library/cpp/string_utils/parse_size/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + parse_size.cpp + parse_size.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/string_utils/quote/ut/ya.make b/library/cpp/string_utils/quote/ut/ya.make new file mode 100644 index 00000000000..ad951b1ed1c --- /dev/null +++ b/library/cpp/string_utils/quote/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/string_utils/quote) + +SRCS( + quote_ut.cpp +) + +END() diff --git a/library/cpp/string_utils/quote/ya.make b/library/cpp/string_utils/quote/ya.make new file mode 100644 index 00000000000..109592c235e --- /dev/null +++ b/library/cpp/string_utils/quote/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + quote.cpp + quote.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/string_utils/relaxed_escaper/ut/ya.make b/library/cpp/string_utils/relaxed_escaper/ut/ya.make new file mode 100644 index 00000000000..d437907e5b4 --- /dev/null +++ b/library/cpp/string_utils/relaxed_escaper/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/string_utils/relaxed_escaper) + +SRCS( + relaxed_escaper_ut.cpp +) + +END() diff --git a/library/cpp/string_utils/relaxed_escaper/ya.make b/library/cpp/string_utils/relaxed_escaper/ya.make new file mode 100644 index 00000000000..2f9e92a5785 --- /dev/null +++ b/library/cpp/string_utils/relaxed_escaper/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + relaxed_escaper.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/string_utils/scan/ya.make b/library/cpp/string_utils/scan/ya.make new file mode 100644 index 00000000000..e90dbf31543 --- /dev/null +++ b/library/cpp/string_utils/scan/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + scan.cpp +) + +END() diff --git a/library/cpp/string_utils/url/ut/ya.make b/library/cpp/string_utils/url/ut/ya.make new file mode 100644 index 00000000000..c876bb28889 --- /dev/null +++ b/library/cpp/string_utils/url/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/string_utils/url) + +SRCS( + url_ut.cpp +) + +END() diff --git a/library/cpp/string_utils/url/ya.make b/library/cpp/string_utils/url/ya.make new file mode 100644 index 00000000000..bccc1c332b5 --- /dev/null +++ b/library/cpp/string_utils/url/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + url.cpp + url.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/string_utils/ztstrbuf/ya.make b/library/cpp/string_utils/ztstrbuf/ya.make new file mode 100644 index 00000000000..019d9e890bb --- /dev/null +++ b/library/cpp/string_utils/ztstrbuf/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + ztstrbuf.cpp +) + +END() diff --git a/library/cpp/svnversion/test/ya.make b/library/cpp/svnversion/test/ya.make new file mode 100644 index 00000000000..e5037452616 --- /dev/null +++ b/library/cpp/svnversion/test/ya.make @@ -0,0 +1,4 @@ +PROGRAM() +PEERDIR(library/cpp/svnversion) +SRCS(main.cpp) +END() diff --git a/library/cpp/svnversion/ya.make b/library/cpp/svnversion/ya.make new file mode 100644 index 00000000000..3789c4b38a9 --- /dev/null +++ b/library/cpp/svnversion/ya.make @@ -0,0 +1,10 @@ +LIBRARY() + +SRCS( + svnversion.cpp + svn_interface.c +) +END() +RECURSE( + test +) diff --git a/library/cpp/tdigest/ya.make b/library/cpp/tdigest/ya.make new file mode 100644 index 00000000000..2546443726e --- /dev/null +++ b/library/cpp/tdigest/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + tdigest.cpp + tdigest.proto +) + +PEERDIR( + contrib/libs/protobuf +) + +END() diff --git a/library/cpp/terminate_handler/sample/exception/ya.make b/library/cpp/terminate_handler/sample/exception/ya.make new file mode 100644 index 00000000000..c43de8348e0 --- /dev/null +++ b/library/cpp/terminate_handler/sample/exception/ya.make @@ -0,0 +1,11 @@ +PROGRAM(exception_sample) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/pure-virtual/ya.make b/library/cpp/terminate_handler/sample/pure-virtual/ya.make new file mode 100644 index 00000000000..ae4a907f402 --- /dev/null +++ b/library/cpp/terminate_handler/sample/pure-virtual/ya.make @@ -0,0 +1,11 @@ +PROGRAM() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/rethrow/ya.make b/library/cpp/terminate_handler/sample/rethrow/ya.make new file mode 100644 index 00000000000..ae4a907f402 --- /dev/null +++ b/library/cpp/terminate_handler/sample/rethrow/ya.make @@ -0,0 +1,11 @@ +PROGRAM() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/segv/ya.make b/library/cpp/terminate_handler/sample/segv/ya.make new file mode 100644 index 00000000000..ae4a907f402 --- /dev/null +++ b/library/cpp/terminate_handler/sample/segv/ya.make @@ -0,0 +1,11 @@ +PROGRAM() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/ya.make b/library/cpp/terminate_handler/sample/ya.make new file mode 100644 index 00000000000..af089abc65b --- /dev/null +++ b/library/cpp/terminate_handler/sample/ya.make @@ -0,0 +1,6 @@ +RECURSE( + exception + pure-virtual + rethrow + segv +) diff --git a/library/cpp/terminate_handler/ya.make b/library/cpp/terminate_handler/ya.make new file mode 100644 index 00000000000..79ce28968d5 --- /dev/null +++ b/library/cpp/terminate_handler/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + GLOBAL terminate_handler.cpp + segv_handler.cpp +) + +END() + +RECURSE( + sample +) diff --git a/library/cpp/testing/benchmark/examples/metrics/ya.make b/library/cpp/testing/benchmark/examples/metrics/ya.make new file mode 100644 index 00000000000..56eb58fc7f0 --- /dev/null +++ b/library/cpp/testing/benchmark/examples/metrics/ya.make @@ -0,0 +1,15 @@ +PY2TEST() + +SIZE(LARGE) + +TAG( + ya:force_sandbox + sb:intel_e5_2660v1 + ya:fat +) + +TEST_SRCS(main.py) + +DEPENDS(library/cpp/testing/benchmark/examples) + +END() diff --git a/library/cpp/testing/benchmark/examples/ya.make b/library/cpp/testing/benchmark/examples/ya.make new file mode 100644 index 00000000000..857c43519ce --- /dev/null +++ b/library/cpp/testing/benchmark/examples/ya.make @@ -0,0 +1,11 @@ +Y_BENCHMARK() + +SRCS( + main.cpp +) + +END() + +RECURSE( + metrics +) diff --git a/library/cpp/testing/benchmark/main/ya.make b/library/cpp/testing/benchmark/main/ya.make new file mode 100644 index 00000000000..684435b94f8 --- /dev/null +++ b/library/cpp/testing/benchmark/main/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + GLOBAL main.cpp +) + +PEERDIR( + library/cpp/testing/benchmark +) + +END() diff --git a/library/cpp/testing/benchmark/ya.make b/library/cpp/testing/benchmark/ya.make new file mode 100644 index 00000000000..8ded7f4ec29 --- /dev/null +++ b/library/cpp/testing/benchmark/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + bench.cpp + dummy.cpp +) + +PEERDIR( + contrib/libs/re2 + library/cpp/colorizer + library/cpp/getopt/small + library/cpp/json + library/cpp/linear_regression + library/cpp/threading/poor_man_openmp +) + +END() + +RECURSE( + examples + main +) diff --git a/library/cpp/testing/common/ut/ya.make b/library/cpp/testing/common/ut/ya.make new file mode 100644 index 00000000000..100c42f835a --- /dev/null +++ b/library/cpp/testing/common/ut/ya.make @@ -0,0 +1,12 @@ +GTEST() +SRCS( + env_ut.cpp + network_ut.cpp + scope_ut.cpp +) + +PEERDIR( + library/cpp/testing/common +) + +END() diff --git a/library/cpp/testing/common/ya.make b/library/cpp/testing/common/ya.make new file mode 100644 index 00000000000..c0ec98af53a --- /dev/null +++ b/library/cpp/testing/common/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + env.cpp + network.cpp + probe.cpp + scope.cpp +) + +PEERDIR( + library/cpp/json +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/testing/gbenchmark/ya.make b/library/cpp/testing/gbenchmark/ya.make new file mode 100644 index 00000000000..b352898aae3 --- /dev/null +++ b/library/cpp/testing/gbenchmark/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + main.cpp +) + +PEERDIR( + contrib/restricted/google/benchmark + library/cpp/testing/hook +) + +END() diff --git a/library/cpp/testing/gmock_in_unittest/example_ut/ya.make b/library/cpp/testing/gmock_in_unittest/example_ut/ya.make new file mode 100644 index 00000000000..38d3aae8117 --- /dev/null +++ b/library/cpp/testing/gmock_in_unittest/example_ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/testing/gmock_in_unittest +) + +SRCS( + example_ut.cpp +) + +END() diff --git a/library/cpp/testing/gmock_in_unittest/ya.make b/library/cpp/testing/gmock_in_unittest/ya.make new file mode 100644 index 00000000000..cd2fa65b48d --- /dev/null +++ b/library/cpp/testing/gmock_in_unittest/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PEERDIR( + contrib/restricted/googletest/googlemock + contrib/restricted/googletest/googletest + library/cpp/testing/gtest_extensions + library/cpp/testing/unittest +) + +SRCS( + events.cpp + GLOBAL registration.cpp +) + +END() + +RECURSE_FOR_TESTS( + example_ut +) diff --git a/library/cpp/testing/gtest/ut/ya.make b/library/cpp/testing/gtest/ut/ya.make new file mode 100644 index 00000000000..d06bbefd492 --- /dev/null +++ b/library/cpp/testing/gtest/ut/ya.make @@ -0,0 +1,15 @@ +GTEST() +SRCS( + matchers_ut.cpp + ut.cpp +) + +DATA( + arcadia/library/cpp/testing/gtest/ut/golden +) + +PEERDIR( + library/cpp/testing/hook +) + +END() diff --git a/library/cpp/testing/gtest/ya.make b/library/cpp/testing/gtest/ya.make new file mode 100644 index 00000000000..74beb1a0512 --- /dev/null +++ b/library/cpp/testing/gtest/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +PROVIDES(test_framework) + +SRCS( + gtest.cpp + main.cpp + matchers.cpp +) + +PEERDIR( + contrib/restricted/googletest/googlemock + contrib/restricted/googletest/googletest + library/cpp/string_utils/relaxed_escaper + library/cpp/testing/common + library/cpp/testing/gtest_extensions + library/cpp/testing/hook +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/testing/gtest_extensions/ut/ya.make b/library/cpp/testing/gtest_extensions/ut/ya.make new file mode 100644 index 00000000000..61c20583b40 --- /dev/null +++ b/library/cpp/testing/gtest_extensions/ut/ya.make @@ -0,0 +1,11 @@ +GTEST() +SRCS( + gtest_extensions_ut.cpp + probe_ut.cpp +) + +PEERDIR( + library/cpp/testing/gtest_extensions +) + +END() diff --git a/library/cpp/testing/gtest_extensions/ya.make b/library/cpp/testing/gtest_extensions/ya.make new file mode 100644 index 00000000000..e954914d789 --- /dev/null +++ b/library/cpp/testing/gtest_extensions/ya.make @@ -0,0 +1,17 @@ +LIBRARY() +PEERDIR( + contrib/restricted/googletest/googlemock + contrib/restricted/googletest/googletest +) + +SRCS( + assertions.cpp + gtest_extensions.cpp + matchers.cpp + pretty_printers.cpp + probe.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/testing/gtest_main/ya.make b/library/cpp/testing/gtest_main/ya.make new file mode 100644 index 00000000000..e005ab92375 --- /dev/null +++ b/library/cpp/testing/gtest_main/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/testing/gtest +) + +END() diff --git a/library/cpp/testing/hook/ya.make b/library/cpp/testing/hook/ya.make new file mode 100644 index 00000000000..a5935ceb878 --- /dev/null +++ b/library/cpp/testing/hook/ya.make @@ -0,0 +1,6 @@ +LIBRARY() +SRCS( + hook.cpp +) + +END() diff --git a/library/cpp/testing/mock_server/ya.make b/library/cpp/testing/mock_server/ya.make new file mode 100644 index 00000000000..4b9fc8371d5 --- /dev/null +++ b/library/cpp/testing/mock_server/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +PEERDIR( + library/cpp/http/misc + library/cpp/http/server +) + +SRCS( + server.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/testing/unittest/fat/ya.make b/library/cpp/testing/unittest/fat/ya.make new file mode 100644 index 00000000000..464f26818f6 --- /dev/null +++ b/library/cpp/testing/unittest/fat/ya.make @@ -0,0 +1,17 @@ +UNITTEST() + +SRCS( + test_port_manager.cpp +) + +SIZE(LARGE) + +# We need to run tests at the same time on the single machine +FORK_SUBTESTS() + +TAG( + ya:fat + ya:force_sandbox +) + +END() diff --git a/library/cpp/testing/unittest/pytests/test_subject/ya.make b/library/cpp/testing/unittest/pytests/test_subject/ya.make new file mode 100644 index 00000000000..c9990b674fb --- /dev/null +++ b/library/cpp/testing/unittest/pytests/test_subject/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +TAG(ya:manual) + +SRCS( + tests.cpp +) + +PEERDIR( + library/cpp/testing/unittest +) + +END() diff --git a/library/cpp/testing/unittest/pytests/ya.make b/library/cpp/testing/unittest/pytests/ya.make new file mode 100644 index 00000000000..bbc1c9dec33 --- /dev/null +++ b/library/cpp/testing/unittest/pytests/ya.make @@ -0,0 +1,21 @@ +PY3TEST() + +SIZE(MEDIUM) + +TEST_SRCS( + test_tear_down.py +) + +PEERDIR( + library/python/testing/yatest_common +) + +DEPENDS( + library/cpp/testing/unittest/pytests/test_subject +) + +END() + +RECURSE( + test_subject +) diff --git a/library/cpp/testing/unittest/ut/ya.make b/library/cpp/testing/unittest/ut/ya.make new file mode 100644 index 00000000000..86efa0d788f --- /dev/null +++ b/library/cpp/testing/unittest/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(library/cpp/testing/unittest) + +SRCS( + main.cpp + registar_ut.cpp +) + +END() diff --git a/library/cpp/testing/unittest/ya.make b/library/cpp/testing/unittest/ya.make new file mode 100644 index 00000000000..f9fa7a09b3d --- /dev/null +++ b/library/cpp/testing/unittest/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +PROVIDES(test_framework) + +PEERDIR( + contrib/libs/libxml + library/cpp/colorizer + library/cpp/dbg_output + library/cpp/diff + library/cpp/json/writer + library/cpp/testing/common + library/cpp/testing/hook +) + +SRCS( + gtest.cpp + checks.cpp + junit.cpp + plugin.cpp + registar.cpp + tests_data.cpp + utmain.cpp +) + +END() + +RECURSE_FOR_TESTS( + fat + pytests + ut +) diff --git a/library/cpp/testing/unittest_main/ya.make b/library/cpp/testing/unittest_main/ya.make new file mode 100644 index 00000000000..85022961433 --- /dev/null +++ b/library/cpp/testing/unittest_main/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + library/cpp/testing/unittest + library/cpp/terminate_handler +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/threading/atomic/ut/ya.make b/library/cpp/threading/atomic/ut/ya.make new file mode 100644 index 00000000000..fe2a5ac8f9a --- /dev/null +++ b/library/cpp/threading/atomic/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/threading/atomic) + +SRCS( + bool_ut.cpp +) + +END() diff --git a/library/cpp/threading/atomic/ya.make b/library/cpp/threading/atomic/ya.make new file mode 100644 index 00000000000..e4dd81d9d3d --- /dev/null +++ b/library/cpp/threading/atomic/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + bool.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/threading/chunk_queue/ut/ya.make b/library/cpp/threading/chunk_queue/ut/ya.make new file mode 100644 index 00000000000..a58422ce02a --- /dev/null +++ b/library/cpp/threading/chunk_queue/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/threading/chunk_queue) + +SRCS( + queue_ut.cpp +) + +END() diff --git a/library/cpp/threading/chunk_queue/ya.make b/library/cpp/threading/chunk_queue/ya.make new file mode 100644 index 00000000000..a0d7c556ef9 --- /dev/null +++ b/library/cpp/threading/chunk_queue/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + queue.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/threading/equeue/ut/ya.make b/library/cpp/threading/equeue/ut/ya.make new file mode 100644 index 00000000000..60bc0aa604b --- /dev/null +++ b/library/cpp/threading/equeue/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/threading/equeue +) + +SRCDIR(library/cpp/threading/equeue) + +SRCS( + equeue_ut.cpp +) + +END() diff --git a/library/cpp/threading/equeue/ya.make b/library/cpp/threading/equeue/ya.make new file mode 100644 index 00000000000..445797aa121 --- /dev/null +++ b/library/cpp/threading/equeue/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + equeue.h + equeue.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/threading/future/mt_ut/ya.make b/library/cpp/threading/future/mt_ut/ya.make new file mode 100644 index 00000000000..fee088813ad --- /dev/null +++ b/library/cpp/threading/future/mt_ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(library/cpp/threading/future) + +SRCS( + future_mt_ut.cpp +) + +IF(SANITIZER_TYPE) + SIZE(MEDIUM) +ENDIF() + + +END() diff --git a/library/cpp/threading/future/perf/ya.make b/library/cpp/threading/future/perf/ya.make new file mode 100644 index 00000000000..06774201073 --- /dev/null +++ b/library/cpp/threading/future/perf/ya.make @@ -0,0 +1,11 @@ +Y_BENCHMARK(library-threading-future-perf) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/threading/future +) + +END() diff --git a/library/cpp/threading/future/ut/ya.make b/library/cpp/threading/future/ut/ya.make new file mode 100644 index 00000000000..7b182741691 --- /dev/null +++ b/library/cpp/threading/future/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(library/cpp/threading/future) + +SRCS( + async_semaphore_ut.cpp + async_ut.cpp + future_ut.cpp + legacy_future_ut.cpp +) + +END() diff --git a/library/cpp/threading/future/ya.make b/library/cpp/threading/future/ya.make new file mode 100644 index 00000000000..32b54ff5180 --- /dev/null +++ b/library/cpp/threading/future/ya.make @@ -0,0 +1,25 @@ +SUBSCRIBER( + swarmer +) + +LIBRARY() + +SRCS( + async_semaphore.cpp + async.cpp + core/future.cpp + core/fwd.cpp + fwd.cpp + wait/fwd.cpp + wait/wait.cpp + wait/wait_group.cpp + wait/wait_policy.cpp +) + +END() + +RECURSE( + mt_ut + perf + ut +) diff --git a/library/cpp/threading/hot_swap/ya.make b/library/cpp/threading/hot_swap/ya.make new file mode 100644 index 00000000000..82eb6490a4a --- /dev/null +++ b/library/cpp/threading/hot_swap/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + hot_swap.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/threading/light_rw_lock/bench/ya.make b/library/cpp/threading/light_rw_lock/bench/ya.make new file mode 100644 index 00000000000..297cfe1d0ab --- /dev/null +++ b/library/cpp/threading/light_rw_lock/bench/ya.make @@ -0,0 +1,11 @@ +PROGRAM(lightrwlock_test) + +SRCS( + lightrwlock_test.cpp +) + +PEERDIR( + library/cpp/threading/light_rw_lock +) + +END() diff --git a/library/cpp/threading/light_rw_lock/ut/ya.make b/library/cpp/threading/light_rw_lock/ut/ya.make new file mode 100644 index 00000000000..780dd65803c --- /dev/null +++ b/library/cpp/threading/light_rw_lock/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(library/cpp/threading/light_rw_lock) + +SRCS( + rwlock_ut.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/threading/light_rw_lock/ya.make b/library/cpp/threading/light_rw_lock/ya.make new file mode 100644 index 00000000000..a2452336c38 --- /dev/null +++ b/library/cpp/threading/light_rw_lock/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + lightrwlock.cpp + lightrwlock.h +) + +END() + +RECURSE( + bench + ut +) diff --git a/library/cpp/threading/local_executor/ut/ya.make b/library/cpp/threading/local_executor/ut/ya.make new file mode 100644 index 00000000000..c571115f60e --- /dev/null +++ b/library/cpp/threading/local_executor/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/threading/local_executor) + +SRCS( + local_executor_ut.cpp +) + +END() diff --git a/library/cpp/threading/local_executor/ya.make b/library/cpp/threading/local_executor/ya.make new file mode 100644 index 00000000000..2ccaa3031a8 --- /dev/null +++ b/library/cpp/threading/local_executor/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + local_executor.cpp + tbb_local_executor.cpp +) + +PEERDIR( + contrib/libs/tbb + library/cpp/threading/future + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/threading/mux_event/ya.make b/library/cpp/threading/mux_event/ya.make new file mode 100644 index 00000000000..0e112b5ef9c --- /dev/null +++ b/library/cpp/threading/mux_event/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + mux_event.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() diff --git a/library/cpp/threading/poor_man_openmp/ut/ya.make b/library/cpp/threading/poor_man_openmp/ut/ya.make new file mode 100644 index 00000000000..570b8788f06 --- /dev/null +++ b/library/cpp/threading/poor_man_openmp/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/threading/poor_man_openmp) + +SRCS( + thread_helper_ut.cpp +) + +END() diff --git a/library/cpp/threading/poor_man_openmp/ya.make b/library/cpp/threading/poor_man_openmp/ya.make new file mode 100644 index 00000000000..976b2b6b3c3 --- /dev/null +++ b/library/cpp/threading/poor_man_openmp/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + thread_helper.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/threading/queue/ut/ya.make b/library/cpp/threading/queue/ut/ya.make new file mode 100644 index 00000000000..28246305df7 --- /dev/null +++ b/library/cpp/threading/queue/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(library/cpp/threading/queue) + +ALLOCATOR(B) + +SRCS( + basic_ut.cpp + queue_ut.cpp + tune_ut.cpp + unordered_ut.cpp + ut_helpers.cpp + ut_helpers.h +) + +END() diff --git a/library/cpp/threading/queue/ya.make b/library/cpp/threading/queue/ya.make new file mode 100644 index 00000000000..507c80b0721 --- /dev/null +++ b/library/cpp/threading/queue/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + mpmc_unordered_ring.cpp + mpmc_unordered_ring.h + mpsc_htswap.cpp + mpsc_htswap.h + mpsc_intrusive_unordered.cpp + mpsc_intrusive_unordered.h + mpsc_read_as_filled.cpp + mpsc_read_as_filled.h + mpsc_vinfarr_obstructive.cpp + mpsc_vinfarr_obstructive.h +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/threading/skip_list/perf/ya.make b/library/cpp/threading/skip_list/perf/ya.make new file mode 100644 index 00000000000..476d2eaff43 --- /dev/null +++ b/library/cpp/threading/skip_list/perf/ya.make @@ -0,0 +1,13 @@ +PROGRAM(skiplist-perf) + +PEERDIR( + library/cpp/charset + library/cpp/getopt/small + library/cpp/threading/skip_list +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/threading/skip_list/ut/ya.make b/library/cpp/threading/skip_list/ut/ya.make new file mode 100644 index 00000000000..6748e4e43ab --- /dev/null +++ b/library/cpp/threading/skip_list/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/threading/skip_list) + +SRCS( + skiplist_ut.cpp +) + +END() diff --git a/library/cpp/threading/skip_list/ya.make b/library/cpp/threading/skip_list/ya.make new file mode 100644 index 00000000000..0c3f91046ea --- /dev/null +++ b/library/cpp/threading/skip_list/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + skiplist.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE( + perf + ut +) diff --git a/library/cpp/threading/task_scheduler/ut/ya.make b/library/cpp/threading/task_scheduler/ut/ya.make new file mode 100644 index 00000000000..93e77b8e9aa --- /dev/null +++ b/library/cpp/threading/task_scheduler/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/threading/task_scheduler) + +SRCS( + task_scheduler_ut.cpp +) + +END() diff --git a/library/cpp/threading/task_scheduler/ya.make b/library/cpp/threading/task_scheduler/ya.make new file mode 100644 index 00000000000..33cb6bba2f3 --- /dev/null +++ b/library/cpp/threading/task_scheduler/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + task_scheduler.cpp +) + +PEERDIR( + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/threading/thread_local/ya.make b/library/cpp/threading/thread_local/ya.make new file mode 100644 index 00000000000..676381ab0f4 --- /dev/null +++ b/library/cpp/threading/thread_local/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + library/cpp/threading/hot_swap + library/cpp/threading/skip_list +) + +GENERATE_ENUM_SERIALIZATION(thread_local.h) + +SRCS(thread_local.cpp) + +END() diff --git a/library/cpp/time_provider/ya.make b/library/cpp/time_provider/ya.make new file mode 100644 index 00000000000..3f7f4b36019 --- /dev/null +++ b/library/cpp/time_provider/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +SRCS( + monotonic.cpp + time_provider.cpp + monotonic_provider.cpp +) + +END() diff --git a/library/cpp/timezone_conversion/ut/ya.make b/library/cpp/timezone_conversion/ut/ya.make new file mode 100644 index 00000000000..1c797135bf0 --- /dev/null +++ b/library/cpp/timezone_conversion/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + library/cpp/testing/unittest + library/cpp/timezone_conversion +) + +SRCS( + convert_ut.cpp + civil_ut.cpp +) + +END() diff --git a/library/cpp/timezone_conversion/ya.make b/library/cpp/timezone_conversion/ya.make new file mode 100644 index 00000000000..8ccc87db1c6 --- /dev/null +++ b/library/cpp/timezone_conversion/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + contrib/libs/cctz/tzdata + util/draft +) + +SRCS( + convert.cpp + civil.cpp +) + +GENERATE_ENUM_SERIALIZATION(civil.h) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/tld/ut/ya.make b/library/cpp/tld/ut/ya.make new file mode 100644 index 00000000000..9b2516e2593 --- /dev/null +++ b/library/cpp/tld/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST() + +PEERDIR( + ADDINCL library/cpp/tld +) + +SRCDIR(library/cpp/tld) + +SRCS( + tld_ut.cpp +) + +END() diff --git a/library/cpp/tld/ya.make b/library/cpp/tld/ya.make new file mode 100644 index 00000000000..64815a2a0c2 --- /dev/null +++ b/library/cpp/tld/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +RUN_PYTHON3( + gen_tld.py tlds-alpha-by-domain.txt + IN tlds-alpha-by-domain.txt + STDOUT tld.inc +) + +SRCS( + tld.cpp +) + +PEERDIR( + library/cpp/digest/lower_case +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/unicode/normalization/ut/ya.make b/library/cpp/unicode/normalization/ut/ya.make new file mode 100644 index 00000000000..3cd271e620b --- /dev/null +++ b/library/cpp/unicode/normalization/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + library/cpp/unicode/normalization +) + +SRCS( + normalization_ut.cpp +) + +END() diff --git a/library/cpp/unicode/normalization/ya.make b/library/cpp/unicode/normalization/ya.make new file mode 100644 index 00000000000..0646cfb8b0d --- /dev/null +++ b/library/cpp/unicode/normalization/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +NO_UTIL() + +SRCS( + generated/composition.cpp + generated/decomposition.cpp + decomposition_table.h + normalization.cpp +) + +IF(NOT OPENSOURCE) + SRCS( + custom_encoder.cpp + ) + PEERDIR( + library/cpp/charset + ) + GENERATE_ENUM_SERIALIZATION(normalization.h) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/unicode/punycode/ut/ya.make b/library/cpp/unicode/punycode/ut/ya.make new file mode 100644 index 00000000000..b242ab48ccd --- /dev/null +++ b/library/cpp/unicode/punycode/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/unicode/punycode) + +SRCS( + punycode_ut.cpp +) + +END() diff --git a/library/cpp/unicode/punycode/ya.make b/library/cpp/unicode/punycode/ya.make new file mode 100644 index 00000000000..4c5effa07b4 --- /dev/null +++ b/library/cpp/unicode/punycode/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + contrib/libs/libidn +) + +SRCS( + punycode.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/unicode/set/ya.make b/library/cpp/unicode/set/ya.make new file mode 100644 index 00000000000..b06845f9237 --- /dev/null +++ b/library/cpp/unicode/set/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + set.cpp + quoted_pair.cpp + unicode_set.cpp + unicode_set_parser.cpp + unicode_set_token.cpp + generated/category_ranges.cpp + unicode_set_lexer.rl6 +) + +GENERATE_ENUM_SERIALIZATION(unicode_set_token.h) + +END() diff --git a/library/cpp/unified_agent_client/examples/ua_grpc_client/ya.make b/library/cpp/unified_agent_client/examples/ua_grpc_client/ya.make new file mode 100644 index 00000000000..7700d7b49a9 --- /dev/null +++ b/library/cpp/unified_agent_client/examples/ua_grpc_client/ya.make @@ -0,0 +1,12 @@ +PROGRAM(ua_grpc_client) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/unified_agent_client + library/cpp/getopt +) + +END() diff --git a/library/cpp/unified_agent_client/examples/ya.make b/library/cpp/unified_agent_client/examples/ya.make new file mode 100644 index 00000000000..6162b86b841 --- /dev/null +++ b/library/cpp/unified_agent_client/examples/ya.make @@ -0,0 +1,3 @@ +RECURSE( + ua_grpc_client +) diff --git a/library/cpp/unified_agent_client/proto/ya.make b/library/cpp/unified_agent_client/proto/ya.make new file mode 100644 index 00000000000..fe017da6d5e --- /dev/null +++ b/library/cpp/unified_agent_client/proto/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +INCLUDE_TAGS(GO_PROTO) + +GRPC() + +SRCS( + unified_agent.proto +) + +GENERATE_ENUM_SERIALIZATION(unified_agent.pb.h) + +END() diff --git a/library/cpp/unified_agent_client/ya.make b/library/cpp/unified_agent_client/ya.make new file mode 100644 index 00000000000..6771471974f --- /dev/null +++ b/library/cpp/unified_agent_client/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +ADDINCL( + contrib/libs/grpc + contrib/libs/grpc/include +) + +SRCS( + backend.cpp + backend_creator.cpp + client_impl.cpp + counters.cpp + helpers.cpp + grpc_io.cpp + grpc_status_code.cpp + clock.cpp + duration_counter.cpp + logger.cpp + throttling.cpp + proto_weighing.cpp + GLOBAL registrar.cpp +) + +PEERDIR( + contrib/libs/grpc + library/cpp/logger/global + library/cpp/threading/future + library/cpp/monlib/dynamic_counters + library/cpp/unified_agent_client/proto +) + +GENERATE_ENUM_SERIALIZATION(grpc_io.h) + +END() + +RECURSE( + examples +) diff --git a/library/cpp/uri/benchmark/ya.make b/library/cpp/uri/benchmark/ya.make new file mode 100644 index 00000000000..6822537c459 --- /dev/null +++ b/library/cpp/uri/benchmark/ya.make @@ -0,0 +1,12 @@ +Y_BENCHMARK() + +PEERDIR( + library/cpp/testing/benchmark + library/cpp/uri +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/uri/ut/ya.make b/library/cpp/uri/ut/ya.make new file mode 100644 index 00000000000..e9907497210 --- /dev/null +++ b/library/cpp/uri/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(library/cpp/uri) + +NO_OPTIMIZE() + +NO_WSHADOW() + +PEERDIR( + library/cpp/html/entity +) + +SRCS( + location_ut.cpp + uri-ru_ut.cpp + uri_ut.cpp +) + +END() diff --git a/library/cpp/uri/ya.make b/library/cpp/uri/ya.make new file mode 100644 index 00000000000..4b751615552 --- /dev/null +++ b/library/cpp/uri/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + assign.cpp + common.cpp + encode.cpp + http_url.h + location.cpp + other.cpp + parse.cpp + qargs.cpp + uri.cpp + encodefsm.rl6 + parsefsm.rl6 +) + +PEERDIR( + contrib/libs/libidn + library/cpp/charset +) + +END() + +RECURSE( + benchmark + ut +) diff --git a/library/cpp/xml/document/ut/ya.make b/library/cpp/xml/document/ut/ya.make new file mode 100644 index 00000000000..0ddf387bcba --- /dev/null +++ b/library/cpp/xml/document/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(library/cpp/xml/document) + +SRCS( + xml-document_ut.cpp + xml-textreader_ut.cpp + xml-options_ut.cpp +) + +END() diff --git a/library/cpp/xml/document/ya.make b/library/cpp/xml/document/ya.make new file mode 100644 index 00000000000..f95e0bbf070 --- /dev/null +++ b/library/cpp/xml/document/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + xml-document.cpp + xml-textreader.cpp + xml-options.cpp +) + +PEERDIR( + library/cpp/xml/init + contrib/libs/libxml + library/cpp/string_utils/ztstrbuf +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/xml/init/ya.make b/library/cpp/xml/init/ya.make new file mode 100644 index 00000000000..1df06392e38 --- /dev/null +++ b/library/cpp/xml/init/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + contrib/libs/libxml + library/cpp/charset +) + +SRCS( + ptr.cpp + init.cpp +) + +END() diff --git a/library/cpp/yaml/as/ut/ya.make b/library/cpp/yaml/as/ut/ya.make new file mode 100644 index 00000000000..e254b4c0767 --- /dev/null +++ b/library/cpp/yaml/as/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST() + +SRCS( + tstring_test.cpp +) + +PEERDIR( + contrib/libs/yaml-cpp + library/cpp/yaml/as +) + +END() diff --git a/library/cpp/yaml/as/ya.make b/library/cpp/yaml/as/ya.make new file mode 100644 index 00000000000..3cc3bf754f1 --- /dev/null +++ b/library/cpp/yaml/as/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + contrib/libs/yaml-cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/yaml/fyamlcpp/ut/ya.make b/library/cpp/yaml/fyamlcpp/ut/ya.make new file mode 100644 index 00000000000..1ac2b254388 --- /dev/null +++ b/library/cpp/yaml/fyamlcpp/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(library/cpp/yaml/fyamlcpp) + +SRCS( + fyamlcpp_ut.cpp + libfyaml_ut.cpp +) + +END() + diff --git a/library/cpp/yaml/fyamlcpp/ya.make b/library/cpp/yaml/fyamlcpp/ya.make new file mode 100644 index 00000000000..06ce8066ee8 --- /dev/null +++ b/library/cpp/yaml/fyamlcpp/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + fyamlcpp.cpp + fyamlcpp.h +) + +PEERDIR( + contrib/libs/libfyaml +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/yconf/patcher/ya.make b/library/cpp/yconf/patcher/ya.make new file mode 100644 index 00000000000..a3888c4f3b0 --- /dev/null +++ b/library/cpp/yconf/patcher/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/json + library/cpp/yconf +) + +SRCS( + config_patcher.cpp + unstrict_config.cpp +) + +END() diff --git a/library/cpp/yconf/ya.make b/library/cpp/yconf/ya.make new file mode 100644 index 00000000000..a444e5e057c --- /dev/null +++ b/library/cpp/yconf/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + conf.cpp +) + +PEERDIR( + library/cpp/charset + library/cpp/logger +) + +END() diff --git a/library/cpp/yson/json/ya.make b/library/cpp/yson/json/ya.make new file mode 100644 index 00000000000..cdf7bd2b103 --- /dev/null +++ b/library/cpp/yson/json/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + json_writer.cpp + yson2json_adapter.cpp +) + +PEERDIR( + library/cpp/json +) + +END() diff --git a/library/cpp/yson/node/benchmark/ya.make b/library/cpp/yson/node/benchmark/ya.make new file mode 100644 index 00000000000..dd2035b1fa7 --- /dev/null +++ b/library/cpp/yson/node/benchmark/ya.make @@ -0,0 +1,13 @@ +G_BENCHMARK() + +SRCS( + reserve.cpp +) + +PEERDIR( + library/cpp/yson/node +) + +SIZE(SMALL) + +END() diff --git a/library/cpp/yson/node/ut/ya.make b/library/cpp/yson/node/ut/ya.make new file mode 100644 index 00000000000..a3f79f74035 --- /dev/null +++ b/library/cpp/yson/node/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(library/cpp/yson/node) + +SRCS( + node_ut.cpp +) + +END() diff --git a/library/cpp/yson/node/ya.make b/library/cpp/yson/node/ya.make new file mode 100644 index 00000000000..18fcd101686 --- /dev/null +++ b/library/cpp/yson/node/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(node.h) + +PEERDIR( + library/cpp/yson + library/cpp/yson/json +) + +SRCS( + node.cpp + node_io.cpp + node_builder.cpp + node_visitor.cpp + serialize.cpp +) + +END() + +RECURSE( + benchmark + ut +) diff --git a/library/cpp/yson/ut/ya.make b/library/cpp/yson/ut/ya.make new file mode 100644 index 00000000000..489735f772e --- /dev/null +++ b/library/cpp/yson/ut/ya.make @@ -0,0 +1,11 @@ +GTEST() + +SRCS( + yson_ut.cpp +) + +PEERDIR( + library/cpp/yson +) + +END() diff --git a/library/cpp/yson/ya.make b/library/cpp/yson/ya.make new file mode 100644 index 00000000000..cc973356bd1 --- /dev/null +++ b/library/cpp/yson/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +PEERDIR( + library/cpp/yt/misc + library/cpp/yt/yson +) + +SRCS( + consumer.cpp + lexer.cpp + parser.cpp + token.cpp + tokenizer.cpp + varint.cpp + writer.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/yson_pull/ut/ya.make b/library/cpp/yson_pull/ut/ya.make new file mode 100644 index 00000000000..04b6a7e713e --- /dev/null +++ b/library/cpp/yson_pull/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(library/cpp/yson_pull) + +SRCS( + cescape_ut.cpp + reader_ut.cpp + writer_ut.cpp + loop_ut.cpp +) + +END() diff --git a/library/cpp/yson_pull/ya.make b/library/cpp/yson_pull/ya.make new file mode 100644 index 00000000000..bbe2f23d038 --- /dev/null +++ b/library/cpp/yson_pull/ya.make @@ -0,0 +1,23 @@ +LIBRARY(yson_pull) + +SRCS( + consumer.cpp + event.cpp + exceptions.cpp + input.cpp + output.cpp + read_ops.cpp + reader.cpp + scalar.cpp + writer.cpp +) + +GENERATE_ENUM_SERIALIZATION(event.h) + +GENERATE_ENUM_SERIALIZATION(scalar.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/yt/assert/ya.make b/library/cpp/yt/assert/ya.make new file mode 100644 index 00000000000..a9833ab70e9 --- /dev/null +++ b/library/cpp/yt/assert/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + assert.cpp +) + +END() diff --git a/library/cpp/yt/coding/unittests/ya.make b/library/cpp/yt/coding/unittests/ya.make new file mode 100644 index 00000000000..ab94ee8796a --- /dev/null +++ b/library/cpp/yt/coding/unittests/ya.make @@ -0,0 +1,15 @@ +GTEST() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + zig_zag_ut.cpp + varint_ut.cpp +) + +PEERDIR( + library/cpp/yt/coding + library/cpp/testing/gtest +) + +END() diff --git a/library/cpp/yt/coding/ya.make b/library/cpp/yt/coding/ya.make new file mode 100644 index 00000000000..639d94e755c --- /dev/null +++ b/library/cpp/yt/coding/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( +) + +PEERDIR( + library/cpp/yt/exception +) + +END() + +RECURSE_FOR_TESTS( + unittests +) + +IF (NOT OPENSOURCE) + RECURSE( + benchmark + ) +ENDIF() diff --git a/library/cpp/yt/containers/ya.make b/library/cpp/yt/containers/ya.make new file mode 100644 index 00000000000..fbc70dbd7c8 --- /dev/null +++ b/library/cpp/yt/containers/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( +) + +PEERDIR( + library/cpp/yt/assert +) + +END() + +RECURSE_FOR_TESTS( + unittests +) diff --git a/library/cpp/yt/cpu_clock/ya.make b/library/cpp/yt/cpu_clock/ya.make new file mode 100644 index 00000000000..60ea0e940e8 --- /dev/null +++ b/library/cpp/yt/cpu_clock/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + clock.cpp +) + +PEERDIR( + library/cpp/yt/assert +) + +END() + +RECURSE( + benchmark +) + +RECURSE_FOR_TESTS( + unittests +) diff --git a/library/cpp/yt/exception/ya.make b/library/cpp/yt/exception/ya.make new file mode 100644 index 00000000000..ff0014adcf9 --- /dev/null +++ b/library/cpp/yt/exception/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + exception.cpp +) + +END() diff --git a/library/cpp/yt/malloc/ya.make b/library/cpp/yt/malloc/ya.make new file mode 100644 index 00000000000..252f7f7b3d0 --- /dev/null +++ b/library/cpp/yt/malloc/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + malloc.cpp +) + +END() diff --git a/library/cpp/yt/memory/unittests/ya.make b/library/cpp/yt/memory/unittests/ya.make new file mode 100644 index 00000000000..54f8f4f1a5e --- /dev/null +++ b/library/cpp/yt/memory/unittests/ya.make @@ -0,0 +1,29 @@ +GTEST(unittester-library-memory) + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +IF (NOT OS_WINDOWS) + ALLOCATOR(YT) +ENDIF() + +SRCS( + atomic_intrusive_ptr_ut.cpp + chunked_memory_pool_ut.cpp + chunked_memory_pool_output_ut.cpp + free_list_ut.cpp + intrusive_ptr_ut.cpp + weak_ptr_ut.cpp +) + +IF (NOT OS_WINDOWS) + SRCS( + safe_memory_reader_ut.cpp + ) +ENDIF() + +PEERDIR( + library/cpp/testing/gtest + library/cpp/yt/memory +) + +END() diff --git a/library/cpp/yt/memory/ya.make b/library/cpp/yt/memory/ya.make new file mode 100644 index 00000000000..171bfd5cbfa --- /dev/null +++ b/library/cpp/yt/memory/ya.make @@ -0,0 +1,40 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + blob.cpp + chunked_input_stream.cpp + chunked_memory_allocator.cpp + chunked_memory_pool.cpp + chunked_memory_pool_output.cpp + chunked_output_stream.cpp + memory_tag.cpp + ref.cpp + ref_tracked.cpp + safe_memory_reader.cpp + shared_range.cpp +) + +PEERDIR( + library/cpp/yt/assert + library/cpp/yt/misc + library/cpp/yt/malloc +) + +CHECK_DEPENDENT_DIRS( + ALLOW_ONLY ALL + build + contrib + library + util + library/cpp/yt/assert + library/cpp/yt/misc + library/cpp/yt/malloc +) + +END() + +RECURSE_FOR_TESTS( + unittests +) diff --git a/library/cpp/yt/misc/unittests/ya.make b/library/cpp/yt/misc/unittests/ya.make new file mode 100644 index 00000000000..bc985812eda --- /dev/null +++ b/library/cpp/yt/misc/unittests/ya.make @@ -0,0 +1,15 @@ +GTEST(unittester-library-misc) + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + enum_ut.cpp + guid_ut.cpp + preprocessor_ut.cpp +) + +PEERDIR( + library/cpp/yt/misc +) + +END() diff --git a/library/cpp/yt/misc/ya.make b/library/cpp/yt/misc/ya.make new file mode 100644 index 00000000000..586d14f6eeb --- /dev/null +++ b/library/cpp/yt/misc/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + guid.cpp + source_location.cpp + thread_name.cpp + variant.cpp +) + +PEERDIR( + library/cpp/yt/exception +) + +CHECK_DEPENDENT_DIRS( + ALLOW_ONLY ALL + build + contrib + library + util + yt/yt/library/small_containers +) + +END() + +RECURSE_FOR_TESTS( + unittests +) diff --git a/library/cpp/yt/small_containers/unittests/ya.make b/library/cpp/yt/small_containers/unittests/ya.make new file mode 100644 index 00000000000..bf3deade90e --- /dev/null +++ b/library/cpp/yt/small_containers/unittests/ya.make @@ -0,0 +1,17 @@ +GTEST(unittester-small-containers) + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + compact_flat_map_ut.cpp + compact_heap_ut.cpp + compact_set_ut.cpp + compact_vector_ut.cpp +) + +PEERDIR( + library/cpp/yt/small_containers + library/cpp/testing/gtest +) + +END() diff --git a/library/cpp/yt/small_containers/ya.make b/library/cpp/yt/small_containers/ya.make new file mode 100644 index 00000000000..e52beb943c1 --- /dev/null +++ b/library/cpp/yt/small_containers/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +PEERDIR( + library/cpp/yt/assert + library/cpp/yt/malloc + library/cpp/yt/misc +) + +CHECK_DEPENDENT_DIRS( + ALLOW_ONLY ALL + build + contrib + library + util +) + +END() + +RECURSE_FOR_TESTS( + unittests +) diff --git a/library/cpp/yt/string/unittests/ya.make b/library/cpp/yt/string/unittests/ya.make new file mode 100644 index 00000000000..8fd64d36627 --- /dev/null +++ b/library/cpp/yt/string/unittests/ya.make @@ -0,0 +1,17 @@ +GTEST(unittester-library-string) + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + enum_ut.cpp + format_ut.cpp + guid_ut.cpp + string_ut.cpp +) + +PEERDIR( + library/cpp/yt/string + library/cpp/testing/gtest +) + +END() diff --git a/library/cpp/yt/string/ya.make b/library/cpp/yt/string/ya.make new file mode 100644 index 00000000000..95b07ee0d1f --- /dev/null +++ b/library/cpp/yt/string/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + enum.cpp + guid.cpp + string.cpp + format.cpp +) + +PEERDIR( + library/cpp/yt/assert + library/cpp/yt/exception + library/cpp/yt/misc + library/cpp/yt/small_containers +) + +CHECK_DEPENDENT_DIRS( + ALLOW_ONLY ALL + build + contrib + library + util + library/cpp/yt/assert + library/cpp/yt/misc + library/cpp/yt/small_containers +) + +END() + +RECURSE_FOR_TESTS( + unittests +) diff --git a/library/cpp/yt/system/ya.make b/library/cpp/yt/system/ya.make new file mode 100644 index 00000000000..22aab5151e7 --- /dev/null +++ b/library/cpp/yt/system/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + thread_id.cpp +) + +END() diff --git a/library/cpp/yt/threading/ya.make b/library/cpp/yt/threading/ya.make new file mode 100644 index 00000000000..4f1d7fbdde6 --- /dev/null +++ b/library/cpp/yt/threading/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + at_fork.cpp + count_down_latch.cpp + event_count.cpp + fork_aware_spin_lock.cpp + fork_aware_rw_spin_lock.cpp + futex.cpp + notification_handle.cpp + public.cpp + recursive_spin_lock.cpp + rw_spin_lock.cpp + spin_lock_base.cpp + spin_lock.cpp + spin_wait.cpp + spin_wait_hook.cpp +) + +PEERDIR( + library/cpp/yt/assert + library/cpp/yt/cpu_clock + library/cpp/yt/system + library/cpp/yt/memory +) + +END() + +RECURSE_FOR_TESTS(unittests) diff --git a/library/cpp/yt/ya_cpp.make.inc b/library/cpp/yt/ya_cpp.make.inc new file mode 100644 index 00000000000..cfd07909ebe --- /dev/null +++ b/library/cpp/yt/ya_cpp.make.inc @@ -0,0 +1,7 @@ +# This file should be included in all YT projects (including YT ORM installations). + +IF (NOT MSVC) + CXXFLAGS( + -Wdeprecated-this-capture + ) +ENDIF() diff --git a/library/cpp/yt/yson/ya.make b/library/cpp/yt/yson/ya.make new file mode 100644 index 00000000000..f8bd9fc15d7 --- /dev/null +++ b/library/cpp/yt/yson/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + consumer.cpp +) + +PEERDIR( + library/cpp/yt/yson_string +) + +END() diff --git a/library/cpp/yt/yson_string/unittests/ya.make b/library/cpp/yt/yson_string/unittests/ya.make new file mode 100644 index 00000000000..f301e5b438f --- /dev/null +++ b/library/cpp/yt/yson_string/unittests/ya.make @@ -0,0 +1,15 @@ +GTEST() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + convert_ut.cpp +) + +PEERDIR( + library/cpp/yt/yson_string + library/cpp/testing/gtest + library/cpp/testing/gtest_extensions +) + +END() diff --git a/library/cpp/yt/yson_string/ya.make b/library/cpp/yt/yson_string/ya.make new file mode 100644 index 00000000000..ba693760f10 --- /dev/null +++ b/library/cpp/yt/yson_string/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) + +SRCS( + convert.cpp + string.cpp +) + +PEERDIR( + library/cpp/yt/assert + library/cpp/yt/coding + library/cpp/yt/exception + library/cpp/yt/string + library/cpp/yt/memory + library/cpp/yt/misc +) + +END() + +RECURSE_FOR_TESTS( + unittests +) diff --git a/library/cpp/ytalloc/api/ya.make b/library/cpp/ytalloc/api/ya.make new file mode 100644 index 00000000000..7e7852df14e --- /dev/null +++ b/library/cpp/ytalloc/api/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + fallback.cpp +) + +PEERDIR( + library/cpp/yt/misc +) + +END() diff --git a/library/cpp/ytalloc/impl/ya.make b/library/cpp/ytalloc/impl/ya.make new file mode 100644 index 00000000000..23b6d5874ed --- /dev/null +++ b/library/cpp/ytalloc/impl/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +ALLOCATOR_IMPL() +SRCS( + bridge.cpp +) + +PEERDIR( + library/cpp/malloc/api + library/cpp/yt/containers + library/cpp/yt/memory + library/cpp/yt/threading +) + +END() diff --git a/library/go/core/buildinfo/ya.make b/library/go/core/buildinfo/ya.make new file mode 100644 index 00000000000..5b0ae3c638e --- /dev/null +++ b/library/go/core/buildinfo/ya.make @@ -0,0 +1,7 @@ +GO_LIBRARY() + +SRCS(buildinfo.go) + +END() + +RECURSE(test) diff --git a/library/python/certifi/ya.make b/library/python/certifi/ya.make new file mode 100644 index 00000000000..ba8f150ea0a --- /dev/null +++ b/library/python/certifi/ya.make @@ -0,0 +1,16 @@ +PY23_LIBRARY() + +RESOURCE_FILES( + PREFIX library/python/certifi/ + .dist-info/METADATA + .dist-info/top_level.txt +) + +PY_SRCS( + TOP_LEVEL + certifi/__init__.py + certifi/binary.py + certifi/source.py +) + +END() diff --git a/library/python/cores/ya.make b/library/python/cores/ya.make new file mode 100644 index 00000000000..0a828cb58b1 --- /dev/null +++ b/library/python/cores/ya.make @@ -0,0 +1,10 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +PEERDIR( + contrib/python/six + library/python/reservoir_sampling +) + +END() diff --git a/library/python/filelock/ya.make b/library/python/filelock/ya.make new file mode 100644 index 00000000000..00302eb3d80 --- /dev/null +++ b/library/python/filelock/ya.make @@ -0,0 +1,9 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +PEERDIR( + library/python/windows +) + +END() diff --git a/library/python/find_root/ya.make b/library/python/find_root/ya.make new file mode 100644 index 00000000000..35821361805 --- /dev/null +++ b/library/python/find_root/ya.make @@ -0,0 +1,5 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +END() diff --git a/library/python/fs/test/ya.make b/library/python/fs/test/ya.make new file mode 100644 index 00000000000..e5e1b738b64 --- /dev/null +++ b/library/python/fs/test/ya.make @@ -0,0 +1,12 @@ +PY23_TEST() + +TEST_SRCS( + test_fs.py +) + +PEERDIR( + library/python/fs + library/python/tmp +) + +END() diff --git a/library/python/fs/ya.make b/library/python/fs/ya.make new file mode 100644 index 00000000000..836f49b6d83 --- /dev/null +++ b/library/python/fs/ya.make @@ -0,0 +1,21 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py +) + +IF (OS_DARWIN) + PY_SRCS( + clonefile.pyx + ) +ENDIF() + +PEERDIR( + library/python/func + library/python/strings + library/python/windows +) + +END() + +RECURSE_FOR_TESTS(test) diff --git a/library/python/func/ut/ya.make b/library/python/func/ut/ya.make new file mode 100644 index 00000000000..4e8f326de7a --- /dev/null +++ b/library/python/func/ut/ya.make @@ -0,0 +1,9 @@ +PY23_TEST() + +TEST_SRCS(test_func.py) + +PEERDIR( + library/python/func +) + +END() diff --git a/library/python/func/ya.make b/library/python/func/ya.make new file mode 100644 index 00000000000..47ab634913c --- /dev/null +++ b/library/python/func/ya.make @@ -0,0 +1,9 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/python/import_test/ya.make b/library/python/import_test/ya.make new file mode 100644 index 00000000000..11e098cfe6f --- /dev/null +++ b/library/python/import_test/ya.make @@ -0,0 +1,9 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +PEERDIR( + library/python/testing/import_test +) + +END() diff --git a/library/python/pytest/plugins/ya.make b/library/python/pytest/plugins/ya.make new file mode 100644 index 00000000000..41e20f6e2f0 --- /dev/null +++ b/library/python/pytest/plugins/ya.make @@ -0,0 +1,32 @@ +PY23_LIBRARY() + +PY_SRCS( + ya.py + collection.py + conftests.py + fixtures.py + metrics.py +) + +PEERDIR( + library/python/filelock + library/python/find_root + library/python/testing/filter + library/python/testing/yatest_common +) + +IF (PYTHON2) + PY_SRCS( + fakeid_py2.py + ) + + PEERDIR( + contrib/deprecated/python/faulthandler + ) +ELSE() + PY_SRCS( + fakeid_py3.py + ) +ENDIF() + +END() diff --git a/library/python/pytest/ut/ya.make b/library/python/pytest/ut/ya.make new file mode 100644 index 00000000000..bb94c24c70b --- /dev/null +++ b/library/python/pytest/ut/ya.make @@ -0,0 +1,14 @@ +PY23_TEST() + +TEST_SRCS( + test_tools.py +) + +PEERDIR( + contrib/python/pytest-mock + library/python/pytest +) + +STYLE_PYTHON() + +END() diff --git a/library/python/pytest/ya.make b/library/python/pytest/ya.make new file mode 100644 index 00000000000..b04788cc472 --- /dev/null +++ b/library/python/pytest/ya.make @@ -0,0 +1,36 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py + config.py + context.py + main.py + rewrite.py + yatest_tools.py +) + +PEERDIR( + contrib/python/python-dateutil + contrib/python/ipdb + contrib/python/py + contrib/python/pytest + contrib/python/requests + library/python/pytest/plugins + library/python/testing/yatest_common + library/python/testing/yatest_lib +) + +IF (NOT OPENSOURCE) + PEERDIR(contrib/tools/gprof2dot) +ENDIF() + +RESOURCE_FILES( + PREFIX library/python/pytest/ + pytest.yatest.ini +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/python/reservoir_sampling/ya.make b/library/python/reservoir_sampling/ya.make new file mode 100644 index 00000000000..35821361805 --- /dev/null +++ b/library/python/reservoir_sampling/ya.make @@ -0,0 +1,5 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +END() diff --git a/library/python/resource/ut/lib/ya.make b/library/python/resource/ut/lib/ya.make new file mode 100644 index 00000000000..f5e28cad29f --- /dev/null +++ b/library/python/resource/ut/lib/ya.make @@ -0,0 +1,15 @@ +PY23_LIBRARY() + +TEST_SRCS(test_simple.py) + +PEERDIR( + library/python/resource +) + +RESOURCE( + qw.txt /qw.txt + qw.txt /prefix/1.txt + qw.txt /prefix/2.txt +) + +END() diff --git a/library/python/resource/ut/py2/ya.make b/library/python/resource/ut/py2/ya.make new file mode 100644 index 00000000000..073e4a68ac6 --- /dev/null +++ b/library/python/resource/ut/py2/ya.make @@ -0,0 +1,7 @@ +PY2TEST() + +PEERDIR( + library/python/resource/ut/lib +) + +END() diff --git a/library/python/resource/ut/py3/ya.make b/library/python/resource/ut/py3/ya.make new file mode 100644 index 00000000000..65256285923 --- /dev/null +++ b/library/python/resource/ut/py3/ya.make @@ -0,0 +1,7 @@ +PY3TEST() + +PEERDIR( + library/python/resource/ut/lib +) + +END() diff --git a/library/python/resource/ut/ya.make b/library/python/resource/ut/ya.make new file mode 100644 index 00000000000..4cedc9fb3e4 --- /dev/null +++ b/library/python/resource/ut/ya.make @@ -0,0 +1,4 @@ +RECURSE( + py2 + py3 +) diff --git a/library/python/resource/ya.make b/library/python/resource/ya.make new file mode 100644 index 00000000000..2642f0b42b6 --- /dev/null +++ b/library/python/resource/ya.make @@ -0,0 +1,11 @@ +PY23_LIBRARY() + +PEERDIR( + contrib/python/six +) + +PY_SRCS(__init__.py) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/python/strings/ut/ya.make b/library/python/strings/ut/ya.make new file mode 100644 index 00000000000..df95e366fa9 --- /dev/null +++ b/library/python/strings/ut/ya.make @@ -0,0 +1,11 @@ +PY23_TEST() + +TEST_SRCS(test_strings.py) + +PEERDIR( + library/python/strings +) + +STYLE_PYTHON() + +END() diff --git a/library/python/strings/ya.make b/library/python/strings/ya.make new file mode 100644 index 00000000000..1cd6137b7ea --- /dev/null +++ b/library/python/strings/ya.make @@ -0,0 +1,20 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py + CYTHONIZE_PY + strings.py +) + +PEERDIR( + library/python/func + contrib/python/six +) + +STYLE_PYTHON() + +END() + +RECURSE( + ut +) diff --git a/library/python/svn_version/ya.make b/library/python/svn_version/ya.make new file mode 100644 index 00000000000..f168ea4a94b --- /dev/null +++ b/library/python/svn_version/ya.make @@ -0,0 +1,13 @@ +PY23_LIBRARY() + +PEERDIR( + library/cpp/svnversion + contrib/python/future +) + +PY_SRCS( + __init__.py + __svn_version.pyx +) + +END() diff --git a/library/python/symbols/libc/ya.make b/library/python/symbols/libc/ya.make new file mode 100644 index 00000000000..1aa4d90ac83 --- /dev/null +++ b/library/python/symbols/libc/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + library/python/symbols/registry +) + +IF (GCC OR CLANG) + CFLAGS( + -Wno-deprecated-declarations # For sem_getvalue. + ) +ENDIF() + +SRCS( + GLOBAL syms.cpp +) + +END() diff --git a/library/python/symbols/module/ya.make b/library/python/symbols/module/ya.make new file mode 100644 index 00000000000..87bcd72b4a3 --- /dev/null +++ b/library/python/symbols/module/ya.make @@ -0,0 +1,21 @@ +PY23_LIBRARY() + +NO_PYTHON_INCLUDES() + +PEERDIR( + contrib/libs/python/Include +) + +SRCS( + module.cpp +) + +PY_REGISTER( + library.python.symbols.module.syms +) + +PY_SRCS( + __init__.py +) + +END() diff --git a/library/python/symbols/python/ut/py2/ya.make b/library/python/symbols/python/ut/py2/ya.make new file mode 100644 index 00000000000..991cbedf65d --- /dev/null +++ b/library/python/symbols/python/ut/py2/ya.make @@ -0,0 +1,7 @@ +PY2TEST() + +PEERDIR( + library/python/symbols/python/ut +) + +END() diff --git a/library/python/symbols/python/ut/py3/ya.make b/library/python/symbols/python/ut/py3/ya.make new file mode 100644 index 00000000000..e5542a6c4e3 --- /dev/null +++ b/library/python/symbols/python/ut/py3/ya.make @@ -0,0 +1,7 @@ +PY3TEST() + +PEERDIR( + library/python/symbols/python/ut +) + +END() diff --git a/library/python/symbols/python/ut/ya.make b/library/python/symbols/python/ut/ya.make new file mode 100644 index 00000000000..933c81781f3 --- /dev/null +++ b/library/python/symbols/python/ut/ya.make @@ -0,0 +1,14 @@ +PY23_LIBRARY() + +TEST_SRCS(test_ctypes.py) + +PEERDIR( + library/python/symbols/python +) + +END() + +RECURSE_FOR_TESTS( + py2 + py3 +) diff --git a/library/python/symbols/python/ya.make b/library/python/symbols/python/ya.make new file mode 100644 index 00000000000..e19c591608b --- /dev/null +++ b/library/python/symbols/python/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/python/symbols/registry +) + +SRCS( + GLOBAL syms.cpp +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/library/python/symbols/registry/ya.make b/library/python/symbols/registry/ya.make new file mode 100644 index 00000000000..16cf2603723 --- /dev/null +++ b/library/python/symbols/registry/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + syms.cpp +) + +END() diff --git a/library/python/symbols/win_unicode_console/ya.make b/library/python/symbols/win_unicode_console/ya.make new file mode 100644 index 00000000000..f1fe4ad2ced --- /dev/null +++ b/library/python/symbols/win_unicode_console/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + library/python/symbols/registry +) + +SRCS( + GLOBAL syms.cpp +) + +END() diff --git a/library/python/testing/filter/ya.make b/library/python/testing/filter/ya.make new file mode 100644 index 00000000000..8703f5dcd27 --- /dev/null +++ b/library/python/testing/filter/ya.make @@ -0,0 +1,4 @@ +PY23_LIBRARY() +PY_SRCS(filter.py) + +END() diff --git a/library/python/testing/import_test/ya.make b/library/python/testing/import_test/ya.make new file mode 100644 index 00000000000..3f95288f4d3 --- /dev/null +++ b/library/python/testing/import_test/ya.make @@ -0,0 +1,5 @@ +PY23_LIBRARY() + +PY_SRCS(import_test.py) + +END() diff --git a/library/python/testing/recipe/ya.make b/library/python/testing/recipe/ya.make new file mode 100644 index 00000000000..6e05a5a1ea4 --- /dev/null +++ b/library/python/testing/recipe/ya.make @@ -0,0 +1,14 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py + ports.py +) + +PEERDIR( + contrib/python/ipdb + library/python/testing/yatest_common + library/python/testing/yatest_lib +) + +END() diff --git a/library/python/testing/yatest_common/ya.make b/library/python/testing/yatest_common/ya.make new file mode 100644 index 00000000000..2f5aa3bf390 --- /dev/null +++ b/library/python/testing/yatest_common/ya.make @@ -0,0 +1,38 @@ +PY23_LIBRARY() + +NO_EXTENDED_SOURCE_SEARCH() + +PY_SRCS( + TOP_LEVEL + yatest/__init__.py + yatest/common/__init__.py + yatest/common/benchmark.py + yatest/common/canonical.py + yatest/common/environment.py + yatest/common/errors.py + yatest/common/misc.py + yatest/common/network.py + yatest/common/path.py + yatest/common/process.py + yatest/common/runtime.py + yatest/common/runtime_java.py +) + +STYLE_PYTHON() + +PEERDIR( + contrib/python/packaging + contrib/python/six + library/python/cores + library/python/filelock + library/python/fs + library/python/testing/yatest_lib +) + +IF (NOT CATBOOST_OPENSOURCE) + PEERDIR( + library/python/coredump_filter + ) +ENDIF() + +END() diff --git a/library/python/testing/yatest_common_standalone/ya.make b/library/python/testing/yatest_common_standalone/ya.make new file mode 100644 index 00000000000..8f2d5f52c3f --- /dev/null +++ b/library/python/testing/yatest_common_standalone/ya.make @@ -0,0 +1,15 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py +) + +STYLE_PYTHON() + +PEERDIR( + library/python/testing/yatest_common +) + +PY_CONSTRUCTOR(library.python.testing.yatest_common_standalone) + +END() diff --git a/library/python/testing/yatest_lib/tests/ya.make b/library/python/testing/yatest_lib/tests/ya.make new file mode 100644 index 00000000000..fe7b1c7837f --- /dev/null +++ b/library/python/testing/yatest_lib/tests/ya.make @@ -0,0 +1,12 @@ +PY23_TEST() + +PEERDIR( + library/python/testing/yatest_lib +) + +TEST_SRCS( + test_external.py + test_testsplitter.py +) + +END() diff --git a/library/python/testing/yatest_lib/ya.make b/library/python/testing/yatest_lib/ya.make new file mode 100644 index 00000000000..79442b8faf1 --- /dev/null +++ b/library/python/testing/yatest_lib/ya.make @@ -0,0 +1,24 @@ +PY23_LIBRARY() + +PY_SRCS( + NAMESPACE + yatest_lib + external.py + test_splitter.py + tools.py + ya.py +) + +PEERDIR( + contrib/python/six +) + +IF(PYTHON2) + PEERDIR( + contrib/deprecated/python/enum34 + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS(tests) diff --git a/library/python/tmp/ya.make b/library/python/tmp/ya.make new file mode 100644 index 00000000000..478db75256f --- /dev/null +++ b/library/python/tmp/ya.make @@ -0,0 +1,12 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +PEERDIR( + library/python/fs + library/python/unique_id +) + +END() + +RECURSE_FOR_TESTS(test) diff --git a/library/python/unique_id/ya.make b/library/python/unique_id/ya.make new file mode 100644 index 00000000000..35821361805 --- /dev/null +++ b/library/python/unique_id/ya.make @@ -0,0 +1,5 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +END() diff --git a/library/python/windows/ya.make b/library/python/windows/ya.make new file mode 100644 index 00000000000..97c6f48f23a --- /dev/null +++ b/library/python/windows/ya.make @@ -0,0 +1,11 @@ +PY23_LIBRARY() + +PY_SRCS(__init__.py) + +PEERDIR( + library/python/func + library/python/strings + contrib/python/six +) + +END() diff --git a/library/recipes/common/ya.make b/library/recipes/common/ya.make new file mode 100644 index 00000000000..bb8569f57d4 --- /dev/null +++ b/library/recipes/common/ya.make @@ -0,0 +1,11 @@ +PY23_LIBRARY() + +PEERDIR( + contrib/python/psutil +) + +PY_SRCS( + __init__.py +) + +END() diff --git a/tools/archiver/ya.make b/tools/archiver/ya.make new file mode 100644 index 00000000000..028324e02a2 --- /dev/null +++ b/tools/archiver/ya.make @@ -0,0 +1,15 @@ +PROGRAM() + +PEERDIR( + library/cpp/archive + library/cpp/digest/md5 + library/cpp/getopt/small +) + +SRCS( + main.cpp +) + +SET(IDE_FOLDER "_Builders") + +END() diff --git a/tools/enum_parser/enum_parser/ya.make b/tools/enum_parser/enum_parser/ya.make new file mode 100644 index 00000000000..1bd2356ff15 --- /dev/null +++ b/tools/enum_parser/enum_parser/ya.make @@ -0,0 +1,28 @@ +PROGRAM(enum_parser) + +SRCS( + main.cpp +) + +INDUCED_DEPS(h+cpp + ${ARCADIA_ROOT}/util/generic/typetraits.h + ${ARCADIA_ROOT}/util/generic/singleton.h + ${ARCADIA_ROOT}/util/generic/string.h + ${ARCADIA_ROOT}/util/generic/vector.h + ${ARCADIA_ROOT}/util/generic/map.h + ${ARCADIA_ROOT}/util/string/cast.h + ${ARCADIA_ROOT}/util/stream/output.h + ${ARCADIA_ROOT}/tools/enum_parser/enum_serialization_runtime/enum_runtime.h + ${ARCADIA_ROOT}/tools/enum_parser/enum_parser/stdlib_deps.h +) + +INDUCED_DEPS(h + ${ARCADIA_ROOT}/util/generic/serialized_enum.h +) + +PEERDIR( + library/cpp/getopt/small + tools/enum_parser/parse_enum +) + +END() diff --git a/tools/enum_parser/enum_serialization_runtime/ya.make b/tools/enum_parser/enum_serialization_runtime/ya.make new file mode 100644 index 00000000000..357eb61466a --- /dev/null +++ b/tools/enum_parser/enum_serialization_runtime/ya.make @@ -0,0 +1,10 @@ +LIBRARY() + +SRCS( + dispatch_methods.cpp + enum_runtime.cpp + ordered_pairs.cpp +) + + +END() diff --git a/tools/enum_parser/parse_enum/benchmark/ya.make b/tools/enum_parser/parse_enum/benchmark/ya.make new file mode 100644 index 00000000000..746389067df --- /dev/null +++ b/tools/enum_parser/parse_enum/benchmark/ya.make @@ -0,0 +1,9 @@ +Y_BENCHMARK() + +SRCS( + main.cpp +) + +GENERATE_ENUM_SERIALIZATION_WITH_HEADER(enum.h) + +END() diff --git a/tools/enum_parser/parse_enum/benchmark_build/lib/ya.make b/tools/enum_parser/parse_enum/benchmark_build/lib/ya.make new file mode 100644 index 00000000000..3e5d7a626b6 --- /dev/null +++ b/tools/enum_parser/parse_enum/benchmark_build/lib/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS() + +RUN_PYTHON3( + ${ARCADIA_ROOT}/tools/enum_parser/parse_enum/benchmark_build/lib/gen.py + --range 1000 + --namespace NHuge + --enum EHuge 1000 + STDOUT enum_huge.h +) + +RUN_PYTHON3( + ${ARCADIA_ROOT}/tools/enum_parser/parse_enum/benchmark_build/lib/gen.py + --enum EEnormous 9000 + STDOUT enum_enormous.h +) + +GENERATE_ENUM_SERIALIZATION_WITH_HEADER(enum_huge.h) +GENERATE_ENUM_SERIALIZATION_WITH_HEADER(enum_enormous.h) + +END() diff --git a/tools/enum_parser/parse_enum/benchmark_build/ut/ya.make b/tools/enum_parser/parse_enum/benchmark_build/ut/ya.make new file mode 100644 index 00000000000..802a84325f5 --- /dev/null +++ b/tools/enum_parser/parse_enum/benchmark_build/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + tools/enum_parser/parse_enum/benchmark_build/lib +) + +SRCS( + huge_enums_fallback_ut.cpp +) + +END() diff --git a/tools/enum_parser/parse_enum/benchmark_build/ya.make b/tools/enum_parser/parse_enum/benchmark_build/ya.make new file mode 100644 index 00000000000..ec7e3420274 --- /dev/null +++ b/tools/enum_parser/parse_enum/benchmark_build/ya.make @@ -0,0 +1,4 @@ +RECURSE_FOR_TESTS( + lib + ut +) diff --git a/tools/enum_parser/parse_enum/ut/ya.make b/tools/enum_parser/parse_enum/ut/ya.make new file mode 100644 index 00000000000..eee686134a5 --- /dev/null +++ b/tools/enum_parser/parse_enum/ut/ya.make @@ -0,0 +1,28 @@ +UNITTEST() + +PEERDIR( + ADDINCL tools/enum_parser/parse_enum + library/cpp/resource +) + +SRCDIR(tools/enum_parser/parse_enum) + +RESOURCE( + enums.h /enums + badcode.h /badcode + unbalanced.h /unbalanced + alias_before_name.h /alias_before_name +) + +# self-test +GENERATE_ENUM_SERIALIZATION(enums.h) + +# test GENERATE_ENUM_SERIALIZATION_WITH_HEADER macro +GENERATE_ENUM_SERIALIZATION_WITH_HEADER(enums_with_header.h) + +SRCS( + parse_enum_ut.cpp + enums.cpp +) + +END() diff --git a/tools/enum_parser/parse_enum/ya.make b/tools/enum_parser/parse_enum/ya.make new file mode 100644 index 00000000000..c9c2ecb0811 --- /dev/null +++ b/tools/enum_parser/parse_enum/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + parse_enum.cpp +) + +PEERDIR( + library/cpp/cppparser +) + +END() + +RECURSE( + benchmark + ut +) + +RECURSE_FOR_TESTS( + benchmark_build +) diff --git a/tools/fix_elf/bin/ya.make b/tools/fix_elf/bin/ya.make new file mode 100644 index 00000000000..b18928922ac --- /dev/null +++ b/tools/fix_elf/bin/ya.make @@ -0,0 +1,15 @@ +PROGRAM(fix_elf) + +SRCDIR( + tools/fix_elf +) + +SRCS( + patch.cpp +) + +PEERDIR( + library/cpp/getopt/small +) + +END() diff --git a/tools/fix_elf/ya.make b/tools/fix_elf/ya.make new file mode 100644 index 00000000000..95155de3c86 --- /dev/null +++ b/tools/fix_elf/ya.make @@ -0,0 +1,11 @@ +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/tools/fix_elf/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/tools/fix_elf/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/tools/rescompiler/bin/ya.make b/tools/rescompiler/bin/ya.make new file mode 100644 index 00000000000..741fcc33ff4 --- /dev/null +++ b/tools/rescompiler/bin/ya.make @@ -0,0 +1,17 @@ +PROGRAM(rescompiler) + +PEERDIR( + library/cpp/resource +) + +SRCDIR( + tools/rescompiler +) + +SRCS( + main.cpp +) + +INCLUDE(${ARCADIA_ROOT}/build/prebuilt/tools/rescompiler/ya.make.induced_deps) + +END() diff --git a/tools/rescompiler/ya.make b/tools/rescompiler/ya.make new file mode 100644 index 00000000000..f9a4ecab169 --- /dev/null +++ b/tools/rescompiler/ya.make @@ -0,0 +1,11 @@ +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/tools/rescompiler/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/tools/rescompiler/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/tools/rescompressor/bin/ya.make b/tools/rescompressor/bin/ya.make new file mode 100644 index 00000000000..c5ec5cd469e --- /dev/null +++ b/tools/rescompressor/bin/ya.make @@ -0,0 +1,15 @@ +PROGRAM(rescompressor) + +PEERDIR( + library/cpp/resource +) + +SRCDIR( + tools/rescompressor +) + +SRCS( + main.cpp +) + +END() diff --git a/tools/rescompressor/ya.make b/tools/rescompressor/ya.make new file mode 100644 index 00000000000..40bd714900c --- /dev/null +++ b/tools/rescompressor/ya.make @@ -0,0 +1,11 @@ +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/tools/rescompressor/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/tools/rescompressor/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/tools/rorescompiler/bin/ya.make b/tools/rorescompiler/bin/ya.make new file mode 100644 index 00000000000..3913b270978 --- /dev/null +++ b/tools/rorescompiler/bin/ya.make @@ -0,0 +1,17 @@ +PROGRAM(rorescompiler) + +PEERDIR( + library/cpp/resource +) + +SRCDIR( + tools/rorescompiler +) + +SRCS( + main.cpp +) + +INCLUDE(${ARCADIA_ROOT}/build/prebuilt/tools/rorescompiler/ya.make.induced_deps) + +END() diff --git a/tools/rorescompiler/ya.make b/tools/rorescompiler/ya.make new file mode 100644 index 00000000000..3e131bbdf6e --- /dev/null +++ b/tools/rorescompiler/ya.make @@ -0,0 +1,11 @@ +IF (USE_PREBUILT_TOOLS) + INCLUDE(${ARCADIA_ROOT}/build/prebuilt/tools/rorescompiler/ya.make.prebuilt) +ENDIF() + +IF (NOT PREBUILT) + INCLUDE(${ARCADIA_ROOT}/tools/rorescompiler/bin/ya.make) +ENDIF() + +RECURSE( + bin +) diff --git a/util/charset/ut/ya.make b/util/charset/ut/ya.make new file mode 100644 index 00000000000..e9a3e2ffa67 --- /dev/null +++ b/util/charset/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(util/charset) + +SUBSCRIBER(g:util-subscribers) + +DATA(arcadia/util/charset/ut/utf8) + +SRCS( + utf8_ut.cpp + wide_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +REQUIREMENTS(ram:17) + +END() diff --git a/util/charset/ya.make b/util/charset/ya.make new file mode 100644 index 00000000000..e1a29cec256 --- /dev/null +++ b/util/charset/ya.make @@ -0,0 +1,36 @@ +LIBRARY() + +SUBSCRIBER(g:util-subscribers) + +NO_UTIL() + +NO_SANITIZE_HEADERS() + +IF (TSTRING_IS_STD_STRING) + CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) +ENDIF() + +JOIN_SRCS( + all_charset.cpp + generated/unidata.cpp + recode_result.cpp + unicode_table.cpp + unidata.cpp + utf8.cpp + wide.cpp +) + +IF (ARCH_X86_64 AND NOT DISABLE_INSTRUCTION_SETS) + SRC_C_SSE41(wide_sse41.cpp) +ELSE() + SRC( + wide_sse41.cpp + -DSSE41_STUB + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/util/datetime/benchmark/gmtime_r/ya.make b/util/datetime/benchmark/gmtime_r/ya.make new file mode 100644 index 00000000000..32acd7c1c05 --- /dev/null +++ b/util/datetime/benchmark/gmtime_r/ya.make @@ -0,0 +1,13 @@ +SUBSCRIBER(g:util-subscribers) + +Y_BENCHMARK() + +PEERDIR( + util/draft +) + +SRCS( + main.cpp +) + +END() diff --git a/util/datetime/benchmark/ya.make b/util/datetime/benchmark/ya.make new file mode 100644 index 00000000000..6c9ed6cfd4f --- /dev/null +++ b/util/datetime/benchmark/ya.make @@ -0,0 +1,5 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE( + gmtime_r +) diff --git a/util/datetime/ut/ya.make b/util/datetime/ut/ya.make new file mode 100644 index 00000000000..70f63305d57 --- /dev/null +++ b/util/datetime/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + datetime/base_ut.cpp + datetime/cputimer_ut.cpp + datetime/parser_deprecated_ut.cpp + datetime/parser_ut.cpp + datetime/uptime_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/datetime/ya.make b/util/datetime/ya.make new file mode 100644 index 00000000000..f4a66598a00 --- /dev/null +++ b/util/datetime/ya.make @@ -0,0 +1,9 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE( + benchmark +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/util/digest/benchmark/murmur/ya.make b/util/digest/benchmark/murmur/ya.make new file mode 100644 index 00000000000..39559996abc --- /dev/null +++ b/util/digest/benchmark/murmur/ya.make @@ -0,0 +1,7 @@ +G_BENCHMARK() + +SRCS( + main.cpp +) + +END() diff --git a/util/digest/benchmark/ya.make b/util/digest/benchmark/ya.make new file mode 100644 index 00000000000..bfc0faff9ec --- /dev/null +++ b/util/digest/benchmark/ya.make @@ -0,0 +1,3 @@ +RECURSE( + murmur +) diff --git a/util/digest/ut/ya.make b/util/digest/ut/ya.make new file mode 100644 index 00000000000..b6e56efeec4 --- /dev/null +++ b/util/digest/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + digest/city_ut.cpp + digest/fnv_ut.cpp + digest/multi_ut.cpp + digest/murmur_ut.cpp + digest/sequence_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/digest/ut_cython/ya.make b/util/digest/ut_cython/ya.make new file mode 100644 index 00000000000..7a17a589cfa --- /dev/null +++ b/util/digest/ut_cython/ya.make @@ -0,0 +1,16 @@ +PY23_TEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/digest) + +PY_SRCS( + NAMESPACE util.digest + multi_ut.pyx +) + +TEST_SRCS( + test_digest.py +) + +END() diff --git a/util/digest/ya.make b/util/digest/ya.make new file mode 100644 index 00000000000..d1c47dc23be --- /dev/null +++ b/util/digest/ya.make @@ -0,0 +1,12 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE( + benchmark + ut +) + +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) + RECURSE( + ut_cython + ) +ENDIF() diff --git a/util/draft/ut/ya.make b/util/draft/ut/ya.make new file mode 100644 index 00000000000..bd637f8cdad --- /dev/null +++ b/util/draft/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/draft) + +PEERDIR( + util/draft +) + +SRCS( + date_ut.cpp + datetime_ut.cpp + holder_vector_ut.cpp + memory_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/draft/ya.make b/util/draft/ya.make new file mode 100644 index 00000000000..6bb0cae5530 --- /dev/null +++ b/util/draft/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SUBSCRIBER(g:util-subscribers) + +NO_UTIL() + +IF (TSTRING_IS_STD_STRING) + CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) +ENDIF() + +SRCS( + date.cpp + datetime.cpp + enum.cpp + holder_vector.cpp + ip.cpp + matrix.cpp + memory.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/util/folder/ut/ya.make b/util/folder/ut/ya.make new file mode 100644 index 00000000000..2ffaa8a2ec2 --- /dev/null +++ b/util/folder/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + folder/dirut_ut.cpp + folder/filelist_ut.cpp + folder/fts_ut.cpp + folder/iterator_ut.cpp + folder/path_ut.cpp + folder/pathsplit_ut.cpp +) + +PEERDIR( + library/cpp/threading/future +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/folder/ut_cython/ya.make b/util/folder/ut_cython/ya.make new file mode 100644 index 00000000000..5cc8534a585 --- /dev/null +++ b/util/folder/ut_cython/ya.make @@ -0,0 +1,16 @@ +PY23_TEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/folder) + +PY_SRCS( + NAMESPACE util.folder + path_ut.pyx +) + +TEST_SRCS( + test_folder.py +) + +END() diff --git a/util/folder/ya.make b/util/folder/ya.make new file mode 100644 index 00000000000..c995d26bde1 --- /dev/null +++ b/util/folder/ya.make @@ -0,0 +1,11 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) + +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) + RECURSE( + ut_cython + ) +ENDIF() diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make new file mode 100644 index 00000000000..98dda8111e4 --- /dev/null +++ b/util/generic/ut/ya.make @@ -0,0 +1,73 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +FORK_TESTS() + +SRCS( + generic/adaptor_ut.cpp + generic/algorithm_ut.cpp + generic/array_ref_ut.cpp + generic/array_size_ut.cpp + generic/bitmap_ut.cpp + generic/bitops_ut.cpp + generic/buffer_ut.cpp + generic/cast_ut.cpp + generic/deque_ut.cpp + generic/explicit_type_ut.cpp + generic/flags_ut.cpp + generic/function_ref_ut.cpp + generic/function_ut.cpp + generic/guid_ut.cpp + generic/hash_primes_ut.cpp + generic/hash_ut.cpp + generic/intrlist_ut.cpp + generic/is_in_ut.cpp + generic/iterator_range_ut.cpp + generic/iterator_ut.cpp + generic/lazy_value_ut.cpp + generic/list_ut.cpp + generic/map_ut.cpp + generic/mapfindptr_ut.cpp + generic/maybe_ut.cpp + generic/mem_copy_ut.cpp + generic/objects_counter_ut.cpp + generic/overloaded_ut.cpp + generic/ptr_ut.cpp + generic/queue_ut.cpp + generic/scope_ut.cpp + generic/serialized_enum_ut.cpp + generic/set_ut.cpp + generic/singleton_ut.cpp + generic/size_literals_ut.cpp + generic/stack_ut.cpp + generic/store_policy_ut.cpp + generic/strbuf_ut.cpp + generic/string_ut.cpp + generic/typelist_ut.cpp + generic/typetraits_ut.cpp + generic/utility_ut.cpp + generic/va_args_ut.cpp + generic/vector_ut.cpp + generic/xrange_ut.cpp + generic/yexception_ut.c + generic/yexception_ut.cpp + generic/ylimits_ut.cpp + generic/ymath_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +IF (NOT OS_IOS AND NOT ARCH_PPC64LE) + # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC + # (somewhere in unscaledcycleclock.cc). + PEERDIR( + library/cpp/containers/absl_flat_hash + ) + + SRCS( + generic/string_transparent_hash_ut.cpp + ) +ENDIF() + +END() diff --git a/util/generic/ut_cython/ya.make b/util/generic/ut_cython/ya.make new file mode 100644 index 00000000000..ea923ff4133 --- /dev/null +++ b/util/generic/ut_cython/ya.make @@ -0,0 +1,25 @@ +PY23_TEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/generic) + +PY_SRCS( + NAMESPACE util.generic + array_ref_ut.pyx + deque_ut.pyx + hash_set_ut.pyx + hash_ut.pyx + list_ut.pyx + map_ut.pyx + maybe_ut.pyx + ptr_ut.pyx + string_ut.pyx + vector_ut.pyx +) + +TEST_SRCS( + test_generic.py +) + +END() diff --git a/util/generic/ya.make b/util/generic/ya.make new file mode 100644 index 00000000000..c995d26bde1 --- /dev/null +++ b/util/generic/ya.make @@ -0,0 +1,11 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) + +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) + RECURSE( + ut_cython + ) +ENDIF() diff --git a/util/memory/ut/ya.make b/util/memory/ut/ya.make new file mode 100644 index 00000000000..fbddc4ca4e4 --- /dev/null +++ b/util/memory/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + memory/addstorage_ut.cpp + memory/blob_ut.cpp + memory/pool_ut.cpp + memory/smallobj_ut.cpp + memory/tempbuf_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/memory/ut_cython/ya.make b/util/memory/ut_cython/ya.make new file mode 100644 index 00000000000..d8a06845b16 --- /dev/null +++ b/util/memory/ut_cython/ya.make @@ -0,0 +1,16 @@ +PY23_TEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/memory) + +PY_SRCS( + NAMESPACE util.memory + blob_ut.pyx +) + +TEST_SRCS( + test_memory.py +) + +END() diff --git a/util/memory/ya.make b/util/memory/ya.make new file mode 100644 index 00000000000..c995d26bde1 --- /dev/null +++ b/util/memory/ya.make @@ -0,0 +1,11 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) + +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) + RECURSE( + ut_cython + ) +ENDIF() diff --git a/util/network/ut/ya.make b/util/network/ut/ya.make new file mode 100644 index 00000000000..f62c9198529 --- /dev/null +++ b/util/network/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(util) + +REQUIREMENTS(network:full) + +SUBSCRIBER(g:util-subscribers) + +PEERDIR( + library/cpp/threading/future +) + +SRCS( + network/address_ut.cpp + network/endpoint_ut.cpp + network/ip_ut.cpp + network/poller_ut.cpp + network/sock_ut.cpp + network/socket_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/network/ya.make b/util/network/ya.make new file mode 100644 index 00000000000..08f8a28a880 --- /dev/null +++ b/util/network/ya.make @@ -0,0 +1,5 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) diff --git a/util/random/ut/ya.make b/util/random/ut/ya.make new file mode 100644 index 00000000000..66c9078fbdc --- /dev/null +++ b/util/random/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + random/common_ops_ut.cpp + random/easy_ut.cpp + random/entropy_ut.cpp + random/fast_ut.cpp + random/normal_ut.cpp + random/mersenne_ut.cpp + random/random_ut.cpp + random/shuffle_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/random/ya.make b/util/random/ya.make new file mode 100644 index 00000000000..08f8a28a880 --- /dev/null +++ b/util/random/ya.make @@ -0,0 +1,5 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) diff --git a/util/stream/ut/ya.make b/util/stream/ut/ya.make new file mode 100644 index 00000000000..c2e268cb024 --- /dev/null +++ b/util/stream/ut/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + stream/aligned_ut.cpp + stream/buffer_ut.cpp + stream/buffered_ut.cpp + stream/direct_io_ut.cpp + stream/file_ut.cpp + stream/format_ut.cpp + stream/format_std_ut.cpp + stream/hex_ut.cpp + stream/input_ut.cpp + stream/ios_ut.cpp + stream/labeled_ut.cpp + stream/length_ut.cpp + stream/mem_ut.cpp + stream/multi_ut.cpp + stream/printf_ut.cpp + stream/str_ut.cpp + stream/tokenizer_ut.cpp + stream/walk_ut.cpp + stream/zerocopy_output_ut.cpp + stream/zlib_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/stream/ut_cython/ya.make b/util/stream/ut_cython/ya.make new file mode 100644 index 00000000000..841a8fb0bae --- /dev/null +++ b/util/stream/ut_cython/ya.make @@ -0,0 +1,16 @@ +PY23_TEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/stream) + +PY_SRCS( + NAMESPACE util.stream + str_ut.pyx +) + +TEST_SRCS( + test_stream.py +) + +END() diff --git a/util/stream/ya.make b/util/stream/ya.make new file mode 100644 index 00000000000..c995d26bde1 --- /dev/null +++ b/util/stream/ya.make @@ -0,0 +1,11 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) + +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) + RECURSE( + ut_cython + ) +ENDIF() diff --git a/util/string/ut/ya.make b/util/string/ut/ya.make new file mode 100644 index 00000000000..7243176bfe5 --- /dev/null +++ b/util/string/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + string/builder_ut.cpp + string/cast_ut.cpp + string/escape_ut.cpp + string/join_ut.cpp + string/hex_ut.cpp + string/printf_ut.cpp + string/split_ut.cpp + string/strip_ut.cpp + string/subst_ut.cpp + string/type_ut.cpp + string/util_ut.cpp + string/vector_ut.cpp + string/ascii_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) + +END() diff --git a/util/string/ut_cython/ya.make b/util/string/ut_cython/ya.make new file mode 100644 index 00000000000..99a29c96cec --- /dev/null +++ b/util/string/ut_cython/ya.make @@ -0,0 +1,16 @@ +PY23_TEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/string) + +PY_SRCS( + NAMESPACE util.string + cast_ut.pyx +) + +TEST_SRCS( + test_string.py +) + +END() diff --git a/util/string/ya.make b/util/string/ya.make new file mode 100644 index 00000000000..c995d26bde1 --- /dev/null +++ b/util/string/ya.make @@ -0,0 +1,11 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) + +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) + RECURSE( + ut_cython + ) +ENDIF() diff --git a/util/system/ut/stdin_osfhandle/ya.make b/util/system/ut/stdin_osfhandle/ya.make new file mode 100644 index 00000000000..224bf2e5fa5 --- /dev/null +++ b/util/system/ut/stdin_osfhandle/ya.make @@ -0,0 +1,13 @@ +PROGRAM() + +SUBSCRIBER(g:util-subscribers) + +SRCS( + main.cpp +) + +NO_UTIL() + +BUILD_ONLY_IF(OS_WINDOWS) + +END() diff --git a/util/system/ut/ya.make b/util/system/ut/ya.make new file mode 100644 index 00000000000..f69ca701e50 --- /dev/null +++ b/util/system/ut/ya.make @@ -0,0 +1,91 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +FORK_TESTS() + +FORK_SUBTESTS() + +SPLIT_FACTOR(40) + +TIMEOUT(300) + +SIZE(MEDIUM) + +EXPLICIT_DATA() + +IF (OS_DARWIN) + SIZE(LARGE) + TAG(ya:fat ya:force_sandbox ya:exotic_platform) + TIMEOUT(3600) +ENDIF() + +PEERDIR( + library/cpp/testing/benchmark +) + +SRCS( + system/align_ut.cpp + system/atexit_ut.cpp + system/backtrace_ut.cpp + system/byteorder_ut.cpp + system/compat_ut.cpp + system/compiler_ut.cpp + system/context_ut.cpp + system/condvar_ut.cpp + system/cpu_id_ut.cpp + system/datetime_ut.cpp + system/daemon_ut.cpp + system/direct_io_ut.cpp + system/env_ut.cpp + system/error_ut.cpp + system/event_ut.cpp + system/execpath_ut.cpp + system/file_ut.cpp + system/filemap_ut.cpp + system/flock_ut.cpp + system/fs_ut.cpp + system/fstat_ut.cpp + system/getpid_ut.cpp + system/guard_ut.cpp + system/hi_lo_ut.cpp + system/hostname_ut.cpp + system/info_ut.cpp + system/interrupt_signals_ut.cpp + system/mem_info_ut.cpp + system/mincore_ut.cpp + system/mutex_ut.cpp + system/nice_ut.cpp + system/pipe_ut.cpp + system/platform_ut.cpp + system/progname_ut.cpp + system/rusage_ut.cpp + system/rwlock_ut.cpp + system/sanitizers_ut.cpp + system/shellcommand_ut.cpp + system/spinlock_ut.cpp + system/src_root_ut.cpp + system/src_location_ut.cpp + system/shmat_ut.cpp + system/tempfile_ut.cpp + system/thread_ut.cpp + system/tls_ut.cpp + system/types_ut.cpp + system/type_name_ut.cpp + system/user_ut.cpp + system/unaligned_mem_ut.cpp + system/yassert_ut.cpp +) + +IF (OS_WINDOWS) + SRCS( + system/fs_win_ut.cpp + ) + DEPENDS( + util/system/ut/stdin_osfhandle + ) +ENDIF() + +REQUIREMENTS(ram:12) + +END() diff --git a/util/system/ut_cython/ya.make b/util/system/ut_cython/ya.make new file mode 100644 index 00000000000..62128e231da --- /dev/null +++ b/util/system/ut_cython/ya.make @@ -0,0 +1,16 @@ +PY23_TEST() + +SUBSCRIBER(g:util-subscribers) + +SRCDIR(util/system) + +PY_SRCS( + NAMESPACE util.system + types_ut.pyx +) + +TEST_SRCS( + test_system.py +) + +END() diff --git a/util/system/ya.make b/util/system/ya.make new file mode 100644 index 00000000000..c995d26bde1 --- /dev/null +++ b/util/system/ya.make @@ -0,0 +1,11 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) + +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) + RECURSE( + ut_cython + ) +ENDIF() diff --git a/util/tests/ya_util_tests.inc b/util/tests/ya_util_tests.inc new file mode 100644 index 00000000000..57855aee6bd --- /dev/null +++ b/util/tests/ya_util_tests.inc @@ -0,0 +1,4 @@ +IF (OS_DARWIN) + SIZE(LARGE) + TAG(ya:fat ya:force_sandbox ya:exotic_platform) +ENDIF() diff --git a/util/thread/ut/ya.make b/util/thread/ut/ya.make new file mode 100644 index 00000000000..ade94fb4059 --- /dev/null +++ b/util/thread/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + thread/factory_ut.cpp + thread/lfqueue_ut.cpp + thread/lfstack_ut.cpp + thread/pool_ut.cpp + thread/singleton_ut.cpp +) + +PEERDIR( + library/cpp/threading/future +) + +END() diff --git a/util/thread/ya.make b/util/thread/ya.make new file mode 100644 index 00000000000..08f8a28a880 --- /dev/null +++ b/util/thread/ya.make @@ -0,0 +1,5 @@ +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) diff --git a/util/ut/ya.make b/util/ut/ya.make new file mode 100644 index 00000000000..dc07708117c --- /dev/null +++ b/util/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(util) + +SUBSCRIBER(g:util-subscribers) + +SRCS( + ysaveload_ut.cpp +) + +END() diff --git a/util/ya.make b/util/ya.make new file mode 100644 index 00000000000..4f5737c7f27 --- /dev/null +++ b/util/ya.make @@ -0,0 +1,404 @@ +LIBRARY(yutil) + +SUBSCRIBER(g:util-subscribers) + +NEED_CHECK() + +NO_SANITIZE_HEADERS() + +NO_UTIL() + +# stream +# string +PEERDIR( + util/charset + contrib/libs/zlib + contrib/libs/double-conversion +) + +PEERDIR( + contrib/libs/libc_compat +) + +# datetime +JOIN_SRCS( + all_datetime.cpp + datetime/base.cpp + datetime/constants.cpp + datetime/cputimer.cpp + datetime/systime.cpp + datetime/uptime.cpp +) + +SRCS( + datetime/parser.rl6 + digest/city.cpp + random/random.cpp + string/cast.cpp +) + +IF (OS_WINDOWS) + SRCS( + datetime/strptime.cpp + ) +ENDIF() + +# digest +JOIN_SRCS( + all_digest.cpp + digest/fnv.cpp + digest/multi.cpp + digest/murmur.cpp + digest/numeric.cpp + digest/sequence.cpp +) + +JOIN_SRCS( + all_util.cpp + ysafeptr.cpp + ysaveload.cpp + str_stl.cpp +) + +# folder +JOIN_SRCS( + all_folder.cpp + folder/dirut.cpp + folder/filelist.cpp + folder/fts.cpp + folder/fwd.cpp + folder/iterator.cpp + folder/path.cpp + folder/pathsplit.cpp + folder/tempdir.cpp +) + +IF (OS_WINDOWS) + SRCS( + folder/lstat_win.c + folder/dirent_win.c + ) +ENDIF() + +# generic +JOIN_SRCS( + all_generic.cpp + generic/adaptor.cpp + generic/algorithm.cpp + generic/array_ref.cpp + generic/array_size.cpp + generic/bitmap.cpp + generic/bitops.cpp + generic/bt_exception.cpp + generic/buffer.cpp + generic/cast.cpp + generic/deque.cpp + generic/explicit_type.cpp + generic/fastqueue.cpp + generic/flags.cpp + generic/function.cpp + generic/function_ref.cpp + generic/fwd.cpp + generic/guid.cpp + generic/hash.cpp + generic/hash_multi_map.cpp + generic/hash_table.cpp + generic/hash_primes.cpp + generic/hash_set.cpp + generic/hide_ptr.cpp + generic/intrlist.cpp + generic/is_in.cpp + generic/iterator.cpp + generic/iterator_range.cpp + generic/lazy_value.cpp + generic/list.cpp + generic/map.cpp + generic/mapfindptr.cpp + generic/maybe.cpp + generic/mem_copy.cpp + generic/noncopyable.cpp + generic/object_counter.cpp + generic/overloaded.cpp + generic/ptr.cpp + generic/queue.cpp + generic/refcount.cpp + generic/scope.cpp + generic/serialized_enum.cpp + generic/set.cpp + generic/singleton.cpp + generic/size_literals.cpp + generic/stack.cpp + generic/store_policy.cpp + generic/strbuf.cpp + generic/strfcpy.cpp + generic/string.cpp + generic/typelist.cpp + generic/typetraits.cpp + generic/utility.cpp + generic/va_args.cpp + generic/variant.cpp + generic/vector.cpp + generic/xrange.cpp + generic/yexception.cpp + generic/ylimits.cpp + generic/ymath.cpp +) + +# memory +JOIN_SRCS( + all_memory.cpp + memory/addstorage.cpp + memory/alloc.cpp + memory/blob.cpp + memory/mmapalloc.cpp + memory/pool.cpp + memory/segmented_string_pool.cpp + memory/segpool_alloc.cpp + memory/smallobj.cpp + memory/tempbuf.cpp +) + +# network +JOIN_SRCS( + all_network.cpp + network/address.cpp + network/endpoint.cpp + network/hostip.cpp + network/init.cpp + network/interface.cpp + network/iovec.cpp + network/ip.cpp + network/nonblock.cpp + network/pair.cpp + network/poller.cpp + network/pollerimpl.cpp + network/sock.cpp + network/socket.cpp +) + +# random +JOIN_SRCS( + all_random.cpp + random/common_ops.cpp + random/easy.cpp + random/entropy.cpp + random/fast.cpp + random/lcg_engine.cpp + random/mersenne32.cpp + random/mersenne64.cpp + random/mersenne.cpp + random/normal.cpp + random/shuffle.cpp + random/init_atfork.cpp +) + +JOIN_SRCS( + all_stream.cpp + stream/aligned.cpp + stream/buffer.cpp + stream/buffered.cpp + stream/debug.cpp + stream/direct_io.cpp + stream/file.cpp + stream/format.cpp + stream/fwd.cpp + stream/hex.cpp + stream/holder.cpp + stream/input.cpp + stream/labeled.cpp + stream/length.cpp + stream/mem.cpp + stream/multi.cpp + stream/null.cpp + stream/output.cpp + stream/pipe.cpp + stream/printf.cpp + stream/str.cpp + stream/tee.cpp + stream/tempbuf.cpp + stream/tokenizer.cpp + stream/trace.cpp + stream/walk.cpp + stream/zerocopy.cpp + stream/zerocopy_output.cpp + stream/zlib.cpp +) + +JOIN_SRCS( + all_string.cpp + string/ascii.cpp + string/builder.cpp + string/cstriter.cpp + string/escape.cpp + string/hex.cpp + string/join.cpp + string/printf.cpp + string/reverse.cpp + string/split.cpp + string/strip.cpp + string/strspn.cpp + string/subst.cpp + string/type.cpp + string/util.cpp + string/vector.cpp +) + +IF (GCC OR CLANG OR CLANG_CL) + CFLAGS(-Wnarrowing) +ENDIF() + +IF (TSTRING_IS_STD_STRING) + CFLAGS(GLOBAL -DTSTRING_IS_STD_STRING) +ENDIF() + +JOIN_SRCS( + all_system_1.cpp + system/atexit.cpp + system/backtrace.cpp + system/compat.cpp + system/condvar.cpp + system/context.cpp + system/daemon.cpp + system/datetime.cpp + system/defaults.c + system/direct_io.cpp + system/dynlib.cpp + system/env.cpp + system/error.cpp + system/event.cpp + system/execpath.cpp + system/fasttime.cpp + system/file.cpp + system/file_lock.cpp + system/filemap.cpp + system/flock.cpp + system/fs.cpp + system/fstat.cpp + system/getpid.cpp + system/hi_lo.cpp + system/hostname.cpp + system/hp_timer.cpp + system/info.cpp +) + +IF (OS_WINDOWS) + SRCS(system/err.cpp) +ENDIF() + +JOIN_SRCS( + all_system_2.cpp + system/align.cpp + system/byteorder.cpp + system/cpu_id.cpp + system/fhandle.cpp + system/guard.cpp + system/interrupt_signals.cpp + system/madvise.cpp + system/maxlen.cpp + system/mem_info.cpp + system/mincore.cpp + system/mktemp.cpp + system/mlock.cpp + system/mutex.cpp + system/nice.cpp + system/pipe.cpp + system/platform.cpp + system/progname.cpp + system/protect.cpp + system/rusage.cpp + system/rwlock.cpp + system/sanitizers.cpp + system/sem.cpp + system/shellcommand.cpp + system/shmat.cpp + system/sigset.cpp + system/spinlock.cpp + system/spin_wait.cpp + system/src_location.cpp + system/sys_alloc.cpp + system/sysstat.cpp + system/tempfile.cpp + system/thread.cpp + system/tls.cpp + system/types.cpp + system/type_name.cpp + system/unaligned_mem.cpp + system/user.cpp + system/utime.cpp + system/yassert.cpp + system/yield.cpp +) + +SRC_C_NO_LTO(system/compiler.cpp) + +IF (OS_WINDOWS) + SRCS( + system/fs_win.cpp + system/winint.cpp + ) +ELSEIF (OS_CYGWIN OR OS_IOS) + # no asm context switching on cygwin or iOS +ELSE() + IF (ARCH_X86_64 OR ARCH_I386) + SRCS( + system/context_x86.asm + ) + ENDIF() + IF (ARCH_AARCH64 OR ARCH_ARM64) + SRCS( + system/context_aarch64.S + ) + ENDIF() +ENDIF() + +IF (OS_LINUX) + SRCS( + system/valgrind.cpp + ) + EXTRALIBS( + -lrt + -ldl + ) +ENDIF() + +IF (MUSL) + PEERDIR( + contrib/libs/linuxvdso + ) +ELSE() + IF (OS_LINUX OR SUN OR CYGWIN OR OS_WINDOWS) + SRCS( + system/mktemp_system.cpp + ) + ENDIF() +ENDIF() + +# thread +JOIN_SRCS( + all_thread.cpp + thread/factory.cpp + thread/fwd.cpp + thread/lfqueue.cpp + thread/lfstack.cpp + thread/pool.cpp + thread/singleton.cpp +) + +END() + +RECURSE( + charset + datetime + digest + draft + folder + generic + memory + network + random + stream + string + system + thread + ut +) @@ -0,0 +1,440 @@ +#!/usr/bin/env sh + +# Shell commands follow +# Next line is bilingual: it starts a comment in Python, but do nothing in shell +""":" + +# Find a suitable python interpreter +for cmd in python3 python; do + command -v > /dev/null $cmd && exec `command -v $cmd` $0 "$@" +done + +echo "Python interpreter is not found in this system, please, install python or contact DEVTOOLSSUPPORT" >2 + +exit 2 + +":""" +# Previous line is bilingual: it ends a comment in Python, but do nothing in shell +# Shell commands end here +# Python script follows + +import os +import sys +import platform +import json + +URLS = ['https://proxy.sandbox.yandex-team.ru/4539258385', 'https://storage.yandex-team.ru/get-devtools/1809005/430f2caabd581ca83b5b43d74d759b75/by_platform.json'] +MD5 = '430f2caabd581ca83b5b43d74d759b75' + +URLS3 = ['https://proxy.sandbox.yandex-team.ru/4539260099', 'https://storage.yandex-team.ru/get-devtools/1937027/3d52d181a8c51064b385b0d7a1cc6ce7/by_platform.json'] +MD53 = '3d52d181a8c51064b385b0d7a1cc6ce7' + +DEFAULT_PY_VER = 2 + +RETRIES = 5 +HASH_PREFIX = 10 + +PY3_HANDLERS = [ + "ya3bin0", "ya3bin3", # handers for tests + "krevedko", + "curl", "nvim", "gdb", "emacs", "grep", "jstyle", "nile", "sed", "vim", + "py23_utils", +] +PY2_HANDLERS = ["ya2bin0", "ya2bin2"] + +EXPERIMENTAL_PY3_HANDLERS = [ + 'upload', 'download', 'paste', 'whoami', +] + + +def create_dirs(path): + try: + os.makedirs(path) + except OSError as e: + import errno + + if e.errno != errno.EEXIST: + raise + + return path + + +def home_dir(): + # Do not trust $HOME, as it is unreliable in certain environments + # Temporarily delete os.environ["HOME"] to force reading current home directory from /etc/passwd + home_from_env = os.environ.pop("HOME", None) + try: + home_from_passwd = os.path.expanduser("~") + if os.path.isabs(home_from_passwd): + # This home dir is valid, prefer it over $HOME + return home_from_passwd + else: + # When python is built with musl (this is quire weird though), + # only users from /etc/passwd will be properly resolved, + # as musl does not have nss module for LDAP integration. + return home_from_env + + finally: + if home_from_env is not None: + os.environ["HOME"] = home_from_env + + +def misc_root(): + return create_dirs(os.getenv('YA_CACHE_DIR') or os.path.join(home_dir(), '.ya')) + + +def tool_root(): + return create_dirs(os.getenv('YA_CACHE_DIR_TOOLS') or os.path.join(misc_root(), 'tools')) + + +def ya_token(): + def get_token_from_file(): + try: + with open(os.environ.get('YA_TOKEN_PATH', os.path.join(home_dir(), '.ya_token')), 'r') as f: + return f.read().strip() + except: + pass + return os.getenv('YA_TOKEN') or get_token_from_file() + + +TOOLS_DIR = tool_root() + + +def uniq(size=6): + import string + import random + + return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(size)) + + +_ssl_is_tuned = False + + +def _tune_ssl(): + global _ssl_is_tuned + if _ssl_is_tuned: + return + try: + import ssl + ssl._create_default_https_context = ssl._create_unverified_context + except AttributeError: + pass + + try: + import urllib3 + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + except (AttributeError, ImportError): + pass + _ssl_is_tuned = True + + +def _fetch(url, into): + import hashlib + _tune_ssl() + + try: + from urllib2 import urlopen + from urllib2 import Request + from urlparse import urlparse + except ImportError: + from urllib.request import urlopen + from urllib.request import Request + from urllib.parse import urlparse + + request = Request(str(url)) + request.add_header('User-Agent', 'ya-bootstrap') + if urlparse(url).netloc == 'proxy.sandbox.yandex-team.ru': + token = ya_token() + if token: + request.add_header('Authorization', 'OAuth {}'.format(token)) + + md5 = hashlib.md5() + sys.stderr.write('Downloading %s ' % url) + sys.stderr.flush() + conn = urlopen(request, timeout=10) + sys.stderr.write('[') + sys.stderr.flush() + try: + with open(into, 'wb') as f: + while True: + block = conn.read(1024 * 1024) + sys.stderr.write('.') + sys.stderr.flush() + if block: + md5.update(block) + f.write(block) + else: + break + return md5.hexdigest() + + finally: + sys.stderr.write('] ') + sys.stderr.flush() + + +def _atomic_fetch(url, into, md5): + tmp_dest = into + '.' + uniq() + try: + real_md5 = _fetch(url, tmp_dest) + if real_md5 != md5: + raise Exception('MD5 mismatched: %s differs from %s' % (real_md5, md5)) + os.rename(tmp_dest, into) + sys.stderr.write('OK\n') + except Exception as e: + sys.stderr.write('ERROR: ' + str(e) + '\n') + raise + finally: + try: + os.remove(tmp_dest) + except OSError: + pass + + +def _extract(path, into): + import tarfile + + tar = tarfile.open(path, errorlevel=2) + + # tar.extractall() will try to set file ownership according to the attributes stored in the archive + # by calling TarFile.chown() method. + # As this information is hardly relevant to the point of deployment / extraction, + # it will just fail (python2) if ya is executed with root euid, or silently set non-existent numeric owner (python3) + # to the files being extracted. + # mock it with noop to retain current user ownership. + tar.chown = lambda *args, **kwargs: None + + tar.extractall(path=into) + tar.close() + + +def _get(urls, md5): + dest_path = os.path.join(TOOLS_DIR, md5[:HASH_PREFIX]) + + if not os.path.exists(dest_path): + for iter in range(RETRIES): + try: + _atomic_fetch(urls[iter % len(urls)], dest_path, md5) + break + except Exception: + if iter + 1 == RETRIES: + raise + else: + import time + time.sleep(iter) + + return dest_path + + +def _get_dir(urls, md5, ya_name): + dest_dir = os.path.join(TOOLS_DIR, md5[:HASH_PREFIX] + '_d') + + if os.path.isfile(os.path.join(dest_dir, ya_name)): + return dest_dir + + try: + packed_path = _get(urls, md5) + except Exception: + if os.path.isfile(os.path.join(dest_dir, ya_name)): + return dest_dir + raise + + tmp_dir = dest_dir + '.' + uniq() + try: + try: + _extract(packed_path, tmp_dir) + except Exception: + if os.path.isfile(os.path.join(dest_dir, ya_name)): + return dest_dir + raise + + try: + os.rename(tmp_dir, dest_dir) + except OSError as e: + import errno + if e.errno != errno.ENOTEMPTY: + raise + + return dest_dir + finally: + import shutil + shutil.rmtree(tmp_dir, ignore_errors=True) + try: + os.remove(packed_path) + except Exception: + pass + + +def _mine_arc_root(): + return os.path.dirname(os.path.realpath(__file__)) + + +def _parse_arguments(): + use_python = None + use_python_set_force = False + print_sandbox_id = False + result_args = list(sys.argv[1:]) + handler = None + + if len(sys.argv) > 1: + for index, arg in enumerate(sys.argv[1:]): + if arg == "-3" or arg == "-2": + if arg == "-3": + new_value = 3 + elif arg == "-2": + new_value = 2 + else: + raise NotImplementedError("Unknown argument: {}".format(arg)) + + if use_python is not None and use_python != new_value: + sys.stderr.write("You can use only python2 (-2) OR python3 (-3) -based ya-bin, not both\n") + exit(2) + + use_python = new_value + use_python_set_force = True + elif arg.startswith("--print-sandbox-id="): + if print_sandbox_id: + sys.stderr.write("You can print only one sandbox id at a time") + exit(2) + + print_sandbox_id = arg.split('=')[1] + else: + # Do not try to parse remaining part of command + result_args = result_args[index:] + break + + # All ya script specific arguments found, search for handler + + skippable_flags = ('--error-file',) + skip_next = False + for arg in result_args: + if not arg.startswith("-") and not skip_next: + handler = arg + break + + skip_next = arg in skippable_flags + + ENV_TRUE = ('yes', '1') + + py3_handlers_disabled = os.environ.get('YA_DISABLE_PY3_HANDLERS') in ENV_TRUE + + if py3_handlers_disabled: + use_python = 2 + use_python_set_force = True # Prevent ya-bin respawn + elif use_python == 3: + if not print_sandbox_id: + sys.stderr.write("!! python3-based ya-bin will be used, " + "be prepared for some strange effects, " + "don't be ashamed to write in DEVTOOLSSUPPORT about it\n") + pass + elif use_python == 2: + pass + elif handler in PY2_HANDLERS: + use_python = 2 + elif handler in PY3_HANDLERS: + use_python = 3 + else: + use_python = 23 # ya-bin/3 makes a decision + + if not py3_handlers_disabled and use_python != 3: + ya_experimental = os.environ.get("YA_EXPERIMENTAL") in ENV_TRUE + if ya_experimental and handler in EXPERIMENTAL_PY3_HANDLERS: + sys.stderr.write("!! python3-based ya-bin will be used because of:\n" + " * You enable `YA_EXPERIMENTAL` environment variable\n" + " * Handler `{}` in the list of experimental python3-compatible handlers" + "\n".format(handler)) + use_python = 3 + + if use_python == 2: + urls, md5 = URLS, MD5 + elif use_python == 3: + urls, md5 = URLS3, MD53 + elif use_python == 23: + if DEFAULT_PY_VER == 2: + urls, md5 = URLS, MD5 + elif DEFAULT_PY_VER == 3: + urls, md5 = URLS3, MD53 + else: + raise NotImplementedError("Unknown default python version: {}".format(DEFAULT_PY_VER)) + else: + raise NotImplementedError("Unknown python version: {}".format(use_python)) + return md5, print_sandbox_id, result_args, urls, use_python, use_python_set_force + + +def main(): + if not os.path.exists(TOOLS_DIR): + os.makedirs(TOOLS_DIR) + + md5, print_sandbox_id, result_args, urls, use_python, use_python_set_force = _parse_arguments() + + with open(_get(urls, md5), 'r') as fp: + meta = json.load(fp)['data'] + my_platform = platform.system().lower() + my_machine = platform.machine().lower() + if my_platform == 'linux': + if 'ppc64le' in platform.platform(): + my_platform = 'linux-ppc64le' + elif 'aarch64' in platform.platform(): + my_platform = 'linux-aarch64' + else: + my_platform = 'linux_musl' + if my_platform == 'darwin' and my_machine == 'arm64': + my_platform = 'darwin-arm64' + + def _platform_key(target_platform): + """ match by max prefix length, prefer shortest """ + def _key_for_platform(platform): + return len(os.path.commonprefix([target_platform, platform])), -len(platform) + + return _key_for_platform + + best_key = max(meta.keys(), key=_platform_key(my_platform)) + value = meta[best_key] + + if print_sandbox_id: + target = print_sandbox_id + best_target = max(meta.keys(), key=_platform_key(target)) + sys.stdout.write(str(meta[best_target]['resource_id']) + '\n') + exit(0) + + ya_name = {'win32': 'ya-bin.exe', 'win32-clang-cl': 'ya-bin.exe'}.get(best_key, 'ya-bin') # XXX + ya_dir = _get_dir(value['urls'], value['md5'], ya_name) + + # Popen `args` must have `str` type + ya_path = str(os.path.join(ya_dir, ya_name)) + + env = os.environ.copy() + if 'YA_SOURCE_ROOT' not in env: + src_root = _mine_arc_root() + if src_root is not None: + env['YA_SOURCE_ROOT'] = src_root + + # For more info see YT-14105 + for env_name in [ + 'LD_PRELOAD', + 'Y_PYTHON_SOURCE_ROOT', + ]: + if env_name in os.environ: + sys.stderr.write("Warn: {}='{}' is specified and may affect the correct operation of the ya\n".format(env_name, env[env_name])) + + env['YA_PYVER_REQUIRE'] = str(use_python) + if use_python_set_force: + env['YA_PYVER_SET_FORCED'] = 'yes' + + if os.name == 'nt': + import subprocess + + p = subprocess.Popen([ya_path] + result_args, env=env) + p.wait() + sys.exit(p.returncode) + else: + os.execve(ya_path, [ya_path] + result_args, env) + + +if __name__ == '__main__': + try: + main() + except Exception as e: + sys.stderr.write('ERROR: ' + str(e) + '\n') + from traceback import format_exc + sys.stderr.write(format_exc() + "\n") + sys.exit(1) diff --git a/ydb/apps/dstool/lib/ya.make b/ydb/apps/dstool/lib/ya.make new file mode 100644 index 00000000000..9016b190c27 --- /dev/null +++ b/ydb/apps/dstool/lib/ya.make @@ -0,0 +1,54 @@ +PY3_LIBRARY(dstool_lib) + +PY_SRCS( + arg_parser.py + bs_layout.py + commands.py + common.py + grouptool.py + table.py + + # commands + dstool_cmd_device_list.py + + dstool_cmd_pdisk_add_by_serial.py + dstool_cmd_pdisk_list.py + dstool_cmd_pdisk_remove_by_serial.py + dstool_cmd_pdisk_set.py + + dstool_cmd_vdisk_evict.py + dstool_cmd_vdisk_list.py + dstool_cmd_vdisk_remove_donor.py + dstool_cmd_vdisk_wipe.py + + dstool_cmd_group_add.py + dstool_cmd_group_check.py + dstool_cmd_group_decommit.py + dstool_cmd_group_list.py + dstool_cmd_group_show_blob_info.py + dstool_cmd_group_show_storage_efficiency.py + dstool_cmd_group_show_usage_by_tablets.py + dstool_cmd_group_state.py + dstool_cmd_group_take_snapshot.py + dstool_cmd_group_virtual_create.py + dstool_cmd_group_virtual_cancel.py + + dstool_cmd_pool_create_virtual.py + dstool_cmd_pool_list.py + + dstool_cmd_box_list.py + + dstool_cmd_node_list.py + + dstool_cmd_cluster_balance.py + dstool_cmd_cluster_get.py + dstool_cmd_cluster_set.py + dstool_cmd_cluster_workload_run.py + dstool_cmd_cluster_list.py +) + +PEERDIR( + ydb/core/protos +) + +END() diff --git a/ydb/apps/dstool/ya.make b/ydb/apps/dstool/ya.make new file mode 100644 index 00000000000..65e95e3cf4b --- /dev/null +++ b/ydb/apps/dstool/ya.make @@ -0,0 +1,38 @@ +PY3_PROGRAM(ydb-dstool) + +STRIP() + +# +# DON'T ALLOW NEW DEPENDENCIES WITHOUT EXPLICIT APPROVE FROM kikimr-dev@ or fomichev@ +# +IF (OPENSOURCE) + CHECK_DEPENDENT_DIRS( + ALLOW_ONLY + PEERDIRS + arc/api/public + build/external_resources/antlr3 + build/platform + certs + contrib + library + tools/archiver + tools/enum_parser/enum_parser + tools/enum_parser/enum_serialization_runtime + tools/rescompressor + tools/rorescompiler + util + ydb + ) +ENDIF() + +PY_MAIN(ydb.apps.dstool.main) + +PY_SRCS( + main.py +) + +PEERDIR( + ydb/apps/dstool/lib +) + +END() diff --git a/ydb/apps/pgwire/ya.make b/ydb/apps/pgwire/ya.make new file mode 100644 index 00000000000..8d0229c1d8b --- /dev/null +++ b/ydb/apps/pgwire/ya.make @@ -0,0 +1,25 @@ +PROGRAM() + +SRCS( + appdata.h + log_impl.h + main.cpp + pg_ydb_connection.cpp + pg_ydb_connection.h + pg_ydb_proxy.cpp + pg_ydb_proxy.h + pgwire.cpp + pgwire.h + signals.h +) + +PEERDIR( + ydb/core/base + ydb/core/pgproxy + ydb/core/protos + ydb/public/api/grpc + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/draft +) + +END() diff --git a/ydb/apps/ya.make b/ydb/apps/ya.make new file mode 100644 index 00000000000..b12d0d9c417 --- /dev/null +++ b/ydb/apps/ya.make @@ -0,0 +1,6 @@ +RECURSE( + ydbd + ydb + dstool + pgwire +) diff --git a/ydb/apps/ydb/commands/ya.make b/ydb/apps/ydb/commands/ya.make new file mode 100644 index 00000000000..04196051b60 --- /dev/null +++ b/ydb/apps/ydb/commands/ya.make @@ -0,0 +1,14 @@ +LIBRARY(commands) + +SRCS( + ydb_cloud_root.cpp + ydb_update.cpp + ydb_version.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/iam + ydb/public/lib/ydb_cli/commands +) + +END() diff --git a/ydb/apps/ydb/ya.make b/ydb/apps/ydb/ya.make new file mode 100644 index 00000000000..152d9446af1 --- /dev/null +++ b/ydb/apps/ydb/ya.make @@ -0,0 +1,45 @@ +PROGRAM(ydb) + +STRIP() + +SRCS( + main.cpp +) + +DISABLE(USE_ASMLIB) + +PEERDIR( + contrib/libs/asmlib + ydb/apps/ydb/commands +) + +RESOURCE( + ydb/apps/ydb/version.txt version.txt +) + +# +# DON'T ALLOW NEW DEPENDENCIES WITHOUT EXPLICIT APPROVE FROM kikimr-dev@ or fomichev@ +# +CHECK_DEPENDENT_DIRS( + ALLOW_ONLY + PEERDIRS + build/platform + certs + contrib + library + tools/enum_parser/enum_parser + tools/enum_parser/enum_serialization_runtime + tools/rescompressor + tools/rorescompiler + util + ydb/apps/ydb + ydb/core/fq/libs/protos + ydb/core/grpc_services/validation + ydb/library + ydb/public + ydb/library/yql/public/decimal + ydb/library/yql/public/issue + ydb/library/yql/public/issue/protos +) + +END() diff --git a/ydb/apps/ydbd/ya.make b/ydb/apps/ydbd/ya.make new file mode 100644 index 00000000000..4e0b51ffe9a --- /dev/null +++ b/ydb/apps/ydbd/ya.make @@ -0,0 +1,100 @@ +PROGRAM(ydbd) + +IF (OS_LINUX) + ALLOCATOR(TCMALLOC_256K) +ELSE() + IF (PROFILE_MEMORY_ALLOCATIONS) + ALLOCATOR(LF_DBG) + ELSE() + ALLOCATOR(LF_YT) + ENDIF() +ENDIF() + +IF (OS_WINDOWS) + CFLAGS( + -DKIKIMR_DISABLE_S3_OPS + ) +ENDIF() + +SRCS( + export.cpp + export.h + sqs.cpp + sqs.h + main.cpp +) + +IF (ARCH_X86_64) + PEERDIR( + ydb/library/yql/udfs/common/hyperscan + ) +ENDIF() + +PEERDIR( + ydb/core/driver_lib/run + ydb/core/protos + ydb/core/security + ydb/library/folder_service/mock + ydb/library/keys + ydb/library/pdisk_io + ydb/library/security + ydb/library/yql/parser/pg_wrapper + ydb/library/yql/sql/pg + ydb/library/yql/udfs/common/clickhouse/client + ydb/library/yql/udfs/common/datetime + ydb/library/yql/udfs/common/datetime2 + ydb/library/yql/udfs/common/digest + ydb/library/yql/udfs/common/histogram + ydb/library/yql/udfs/common/hyperloglog + ydb/library/yql/udfs/common/ip_base + ydb/library/yql/udfs/common/json + ydb/library/yql/udfs/common/json2 + ydb/library/yql/udfs/common/math + ydb/library/yql/udfs/common/pire + ydb/library/yql/udfs/common/re2 + ydb/library/yql/udfs/common/set + ydb/library/yql/udfs/common/stat + ydb/library/yql/udfs/common/string + ydb/library/yql/udfs/common/top + ydb/library/yql/udfs/common/topfreq + ydb/library/yql/udfs/common/unicode_base + ydb/library/yql/udfs/common/url_base + ydb/library/yql/udfs/common/yson2 + ydb/library/yql/udfs/logs/dsv + ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs +) + +# +# DON'T ALLOW NEW DEPENDENCIES WITHOUT EXPLICIT APPROVE FROM kikimr-dev@ or fomichev@ +# +CHECK_DEPENDENT_DIRS( + ALLOW_ONLY + PEERDIRS + arc/api/public + build/external_resources/antlr3 + build/platform + certs + contrib + library + tools/archiver + tools/enum_parser/enum_parser + tools/enum_parser/enum_serialization_runtime + tools/rescompressor + tools/rorescompiler + util + ydb +) + +YQL_LAST_ABI_VERSION() + +IF (OPENSOURCE) + RESTRICT_LICENSES( + DENY REQUIRE_DISCLOSURE FORBIDDEN PROTESTWARE + EXCEPT contrib/libs/linux-headers # DTCC-553 + EXCEPT contrib/libs/fmt # + EXCEPT contrib/libs/t1ha # KIKIMR-16412 + ) +ENDIF() + +END() + diff --git a/ydb/core/actorlib_impl/ut/ya.make b/ydb/core/actorlib_impl/ut/ya.make new file mode 100644 index 00000000000..7606043803d --- /dev/null +++ b/ydb/core/actorlib_impl/ut/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/actorlib_impl) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE == "thread") + TIMEOUT(2400) + SPLIT_FACTOR(20) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/getopt + library/cpp/svnversion + ydb/core/testlib/actors + ydb/core/testlib/basics/default +) + +SRCS( + actor_activity_ut.cpp + actor_bootstrapped_ut.cpp + actor_tracker_ut.cpp + test_interconnect_ut.cpp + test_protocols_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/actorlib_impl/ya.make b/ydb/core/actorlib_impl/ya.make new file mode 100644 index 00000000000..9d44148ea9d --- /dev/null +++ b/ydb/core/actorlib_impl/ya.make @@ -0,0 +1,61 @@ +LIBRARY() + +SRCS( + actor_tracker.cpp + actor_tracker.h + async_destroyer.h + connect_socket_protocol.cpp + connect_socket_protocol.h + defs.h + destruct_actor.h + http_request_protocol.h + load_network.cpp + load_network.h + long_timer.cpp + long_timer.h + mad_squirrel.cpp + mad_squirrel.h + melancholic_gopher.cpp + name_service_client_protocol.cpp + name_service_client_protocol.h + node_identifier.cpp + node_identifier.h + proto_ready_actor.h + read_data_protocol.cpp + read_data_protocol.h + read_http_reply_protocol.cpp + read_http_reply_protocol.h + router_rr.h + send_data_protocol.cpp + send_data_protocol.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/dnscachelib + library/cpp/actors/protos + library/cpp/containers/stack_vector + library/cpp/digest/crc32c + library/cpp/html/pcdata + library/cpp/lwtrace + library/cpp/lwtrace/mon + library/cpp/messagebus/monitoring + library/cpp/monlib/dynamic_counters + library/cpp/monlib/service/pages/tablesorter + library/cpp/packedtypes + library/cpp/sliding_window + ydb/core/base + ydb/core/driver_lib/version + ydb/core/mon + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/util +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/audit/ya.make b/ydb/core/audit/ya.make new file mode 100644 index 00000000000..8e09a0ccfbd --- /dev/null +++ b/ydb/core/audit/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + audit_log_impl.cpp + audit_log_impl.h + audit_log.cpp + audit_log.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/json + library/cpp/logger + ydb/core/base +) + +RESOURCE( + ydb/core/kqp/kqp_default_settings.txt kqp_default_settings.txt +) + +END() diff --git a/ydb/core/base/services/ya.make b/ydb/core/base/services/ya.make new file mode 100644 index 00000000000..88338c50352 --- /dev/null +++ b/ydb/core/base/services/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + blobstorage_service_id.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/protos + library/cpp/actors/interconnect + library/cpp/actors/helpers +) + +END() diff --git a/ydb/core/base/ut/ya.make b/ydb/core/base/ut/ya.make new file mode 100644 index 00000000000..11ca289e944 --- /dev/null +++ b/ydb/core/base/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/base) + +FORK_SUBTESTS() +TIMEOUT(600) +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion +) + +SRCS( + path_ut.cpp + blobstorage_grouptype_ut.cpp + localdb_ut.cpp + logoblob_ut.cpp + statestorage_ut.cpp + statestorage_guardian_impl_ut.cpp +) + +END() diff --git a/ydb/core/base/ut_board_subscriber/ya.make b/ydb/core/base/ut_board_subscriber/ya.make new file mode 100644 index 00000000000..fb94c54d017 --- /dev/null +++ b/ydb/core/base/ut_board_subscriber/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/base) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/actors/interconnect + library/cpp/actors/core + library/cpp/testing/unittest + ydb/core/testlib/basics + ydb/core/base + ydb/core/testlib/basics/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + board_subscriber_ut.cpp +) + +END() diff --git a/ydb/core/base/ya.make b/ydb/core/base/ya.make new file mode 100644 index 00000000000..cc1114a8495 --- /dev/null +++ b/ydb/core/base/ya.make @@ -0,0 +1,122 @@ +LIBRARY() + +IF (KIKIMR_DEFAULT_SHARDED_COMPACTION) + # Makes it easier to test sharded compaction + CFLAGS( + -DKIKIMR_DEFAULT_SHARDED_COMPACTION=1 + ) +ENDIF() + +SRCS( + actor_activity_names.cpp + appdata.h + appdata.cpp + board_lookup.cpp + board_publish.cpp + board_replica.cpp + blobstorage.h + blobstorage.cpp + channel_profiles.h + counters.cpp + counters.h + defs.h + domain.h + event_filter.cpp + event_filter.h + events.h + group_stat.cpp + group_stat.h + hive.h + interconnect_channels.h + kikimr_issue.cpp + kikimr_issue.h + localdb.cpp + localdb.h + location.h + logoblob.cpp + logoblob.h + nameservice.h + path.cpp + pathid.cpp + pool_stats_collector.cpp + pool_stats_collector.h + quoter.cpp + quoter.h + resource_profile.h + row_version.cpp + row_version.h + services_assert.cpp + shared_quota.h + statestorage.cpp + statestorage.h + statestorage_event_filter.cpp + statestorage_guardian.cpp + statestorage_guardian_impl.h + statestorage_impl.h + statestorage_monitoring.cpp + statestorage_proxy.cpp + statestorage_replica.cpp + statestorage_replica_probe.cpp + statestorage_warden.cpp + storage_pools.cpp + storage_pools.h + subdomain.h + subdomain.cpp + table_index.cpp + tablet.cpp + tablet.h + tablet_killer.cpp + tablet_pipe.h + tablet_pipecache.h + tablet_resolver.h + tablet_status_checker.cpp + tabletid.h + tablet_types.h + traceid.cpp + traceid.h + tracing.h + tx_processing.h + tx_processing.cpp + user_registry.h + blobstorage_grouptype.cpp + wilson.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/helpers + library/cpp/actors/interconnect + library/cpp/actors/protos + library/cpp/actors/wilson + library/cpp/deprecated/enum_codegen + library/cpp/logger + library/cpp/lwtrace + library/cpp/lwtrace/mon + library/cpp/random_provider + library/cpp/time_provider + ydb/core/base/services + ydb/core/debug + ydb/core/erasure + ydb/core/protos + ydb/core/protos/out + ydb/library/aclib + ydb/library/login + ydb/library/pdisk_io + ydb/library/pretty_types_print/protobuf + ydb/public/api/protos/out + ydb/library/yql/minikql + library/cpp/deprecated/atomic +) + +RESOURCE( + ydb/core/base/kikimr_issue.txt kikimr_issue.txt +) + +GENERATE_ENUM_SERIALIZATION(quoter.h) + +END() + +RECURSE_FOR_TESTS( + ut + ut_board_subscriber +) diff --git a/ydb/core/blob_depot/agent/ya.make b/ydb/core/blob_depot/agent/ya.make new file mode 100644 index 00000000000..e09528669db --- /dev/null +++ b/ydb/core/blob_depot/agent/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + + SRCS( + agent.cpp + agent.h + agent_impl.h + blob_mapping_cache.cpp + blob_mapping_cache.h + blocks.cpp + blocks.h + channel_kind.cpp + comm.cpp + defs.h + garbage.cpp + metrics.cpp + proxy.cpp + query.cpp + read.cpp + request.cpp + resolved_value.cpp + resolved_value.h + status.cpp + + # DS Proxy queries + storage_put.cpp + storage_get.cpp + storage_block.cpp + storage_discover.cpp + storage_range.cpp + storage_collect_garbage.cpp + storage_status.cpp + storage_patch.cpp + ) + + PEERDIR( + ydb/core/blobstorage/vdisk/common + ydb/core/blob_depot + ydb/core/protos + ) + +END() diff --git a/ydb/core/blob_depot/ut/ya.make b/ydb/core/blob_depot/ut/ya.make new file mode 100644 index 00000000000..4328ac87f32 --- /dev/null +++ b/ydb/core/blob_depot/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(ydb/core/blob_depot) + + SIZE(MEDIUM) + + SRCS( + closed_interval_set_ut.cpp + given_id_range_ut.cpp + ) + +END() diff --git a/ydb/core/blob_depot/ya.make b/ydb/core/blob_depot/ya.make new file mode 100644 index 00000000000..9d3d3d9f699 --- /dev/null +++ b/ydb/core/blob_depot/ya.make @@ -0,0 +1,62 @@ +LIBRARY() + + SRCS( + blob_depot.cpp + blob_depot.h + defs.h + types.h + events.h + schema.h + + agent.cpp + assimilator.cpp + assimilator.h + blob_depot_tablet.h + blocks.cpp + blocks.h + coro_tx.cpp + coro_tx.h + data.cpp + data.h + data_decommit.cpp + data_gc.cpp + data_load.cpp + data_mon.cpp + data_resolve.cpp + data_resolve.h + data_trash.cpp + data_uncertain.cpp + data_uncertain.h + garbage_collection.cpp + garbage_collection.h + given_id_range.cpp + group_metrics_exchange.cpp + mon_main.cpp + mon_main.h + space_monitor.cpp + space_monitor.h + testing.cpp + testing.h + + # operations + op_apply_config.cpp + op_init_schema.cpp + op_load.cpp + op_commit_blob_seq.cpp + ) + + PEERDIR( + ydb/core/blobstorage/vdisk/common + ydb/core/tablet_flat + ydb/core/protos + ) + +END() + +RECURSE( + agent +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/backpressure/ut/ya.make b/ydb/core/blobstorage/backpressure/ut/ya.make new file mode 100644 index 00000000000..782b980cc59 --- /dev/null +++ b/ydb/core/blobstorage/backpressure/ut/ya.make @@ -0,0 +1,26 @@ +UNITTEST_FOR(ydb/core/blobstorage/backpressure) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/dsproxy/mock +) + +SRCS( + queue_backpressure_client_ut.cpp + queue_backpressure_server_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/backpressure/ut_client/ya.make b/ydb/core/blobstorage/backpressure/ut_client/ya.make new file mode 100644 index 00000000000..58ecbaaf3bb --- /dev/null +++ b/ydb/core/blobstorage/backpressure/ut_client/ya.make @@ -0,0 +1,24 @@ +UNITTEST() + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/actors/interconnect/mock + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/base + ydb/core/blobstorage/vdisk + ydb/core/blobstorage/vdisk/common + ydb/core/tx/scheme_board + ydb/library/yql/public/udf/service/stub +) + +YQL_LAST_ABI_VERSION() + +SRCS( + backpressure_ut.cpp + defs.h + loader.h + skeleton_front_mock.h +) + +END() diff --git a/ydb/core/blobstorage/backpressure/ya.make b/ydb/core/blobstorage/backpressure/ya.make new file mode 100644 index 00000000000..5c6ad0bab14 --- /dev/null +++ b/ydb/core/blobstorage/backpressure/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +PEERDIR( + contrib/libs/protobuf + library/cpp/actors/core + library/cpp/containers/intrusive_rb_tree + ydb/core/base + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/lwtrace_probes + ydb/core/blobstorage/vdisk/common + ydb/core/protos +) + +SRCS( + common.h + defs.h + event.cpp + event.h + queue.cpp + queue.h + queue_backpressure_client.cpp + queue_backpressure_client.h + queue_backpressure_common.h + queue_backpressure_server.h + unisched.cpp + unisched.h +) + +END() + +RECURSE_FOR_TESTS( + ut + ut_client +) diff --git a/ydb/core/blobstorage/base/ut/ya.make b/ydb/core/blobstorage/base/ut/ya.make new file mode 100644 index 00000000000..3a104bb6547 --- /dev/null +++ b/ydb/core/blobstorage/base/ut/ya.make @@ -0,0 +1,19 @@ +GTEST() + +SIZE(SMALL) + +PEERDIR( + ydb/core/blobstorage/base + library/cpp/getopt + library/cpp/svnversion + ydb/core/erasure + ydb/core/protos +) + +SRCS( + ydb/core/blobstorage/base/batched_vec_ut.cpp + ydb/core/blobstorage/base/bufferwithgaps_ut.cpp + ydb/core/blobstorage/base/ptr_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/base/ya.make b/ydb/core/blobstorage/base/ya.make new file mode 100644 index 00000000000..3e0de81dd5e --- /dev/null +++ b/ydb/core/blobstorage/base/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/wilson + library/cpp/deprecated/atomic + library/cpp/lwtrace + ydb/core/protos +) + +SRCS( + batched_vec.h + blobstorage_events.h + blobstorage_oos_defs.h + blobstorage_vdiskid.cpp + blobstorage_vdiskid.h + blobstorage_syncstate.cpp + blobstorage_syncstate.h + defs.h + html.cpp + html.h + ptr.h + vdisk_lsn.h + vdisk_sync_common.h + vdisk_priorities.h + utility.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/crypto/ut/ya.make b/ydb/core/blobstorage/crypto/ut/ya.make new file mode 100644 index 00000000000..38578d1d897 --- /dev/null +++ b/ydb/core/blobstorage/crypto/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/blobstorage/crypto) + +IF (NOT OS_WINDOWS AND NOT ARCH_ARM64) + SRCS( + chacha_ut.cpp + chacha_vec_ut.cpp + crypto_rope_ut.cpp + crypto_ut.cpp + poly1305_ut.cpp + poly1305_vec_ut.cpp + ) +ELSE() + SRCS( + chacha_ut.cpp + crypto_ut.cpp + poly1305_ut.cpp + ) +ENDIF() + +END() diff --git a/ydb/core/blobstorage/crypto/ya.make b/ydb/core/blobstorage/crypto/ya.make new file mode 100644 index 00000000000..bf82855ccaf --- /dev/null +++ b/ydb/core/blobstorage/crypto/ya.make @@ -0,0 +1,33 @@ +LIBRARY() + +IF (NOT OS_WINDOWS AND NOT ARCH_ARM64) + SRCS( + chacha.cpp + crypto.cpp + crypto.h + poly1305.cpp + chacha_vec.cpp + poly1305_vec.cpp + secured_block.cpp + ) +ELSE() + SRCS( + chacha.cpp + crypto.cpp + crypto.h + poly1305.cpp + secured_block.cpp + ) +ENDIF() + +PEERDIR( + contrib/libs/t1ha + library/cpp/sse + library/cpp/actors/util +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/dsproxy/mock/ya.make b/ydb/core/blobstorage/dsproxy/mock/ya.make new file mode 100644 index 00000000000..6468a535106 --- /dev/null +++ b/ydb/core/blobstorage/dsproxy/mock/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/vdisk/common +) + +SRCS( + defs.h + dsproxy_mock.cpp + dsproxy_mock.h +) + +END() diff --git a/ydb/core/blobstorage/dsproxy/ut/ya.make b/ydb/core/blobstorage/dsproxy/ut/ya.make new file mode 100644 index 00000000000..e41b956275d --- /dev/null +++ b/ydb/core/blobstorage/dsproxy/ut/ya.make @@ -0,0 +1,52 @@ +UNITTEST() + +FORK_SUBTESTS(MODULO) + +SPLIT_FACTOR(20) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/actors/core + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/dsproxy + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/ut_vdisk/lib + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/query + ydb/core/testlib/default + ydb/core/testlib/actors + ydb/core/testlib/basics +) + +YQL_LAST_ABI_VERSION() + +SRCS( + dsproxy_put_ut.cpp + dsproxy_quorum_tracker_ut.cpp + dsproxy_sequence_ut.cpp + dsproxy_patch_ut.cpp + dsproxy_counters_ut.cpp +) + + +IF (BUILD_TYPE == "RELEASE") + SRCS( + dsproxy_fault_tolerance_ut.cpp + dsproxy_get_ut.cpp + ) +ELSE () + MESSAGE(WARNING "It takes too much time to run test in DEBUG mode, some tests are skipped") +ENDIF () + +END() diff --git a/ydb/core/blobstorage/dsproxy/ut_fat/ya.make b/ydb/core/blobstorage/dsproxy/ut_fat/ya.make new file mode 100644 index 00000000000..bf379b8fc28 --- /dev/null +++ b/ydb/core/blobstorage/dsproxy/ut_fat/ya.make @@ -0,0 +1,37 @@ +UNITTEST() + +FORK_SUBTESTS() + +SPLIT_FACTOR(30) + +IF (WITH_VALGRIND) + SIZE(LARGE) + TAG(ya:fat) + TIMEOUT(1800) +ELSE() + SIZE(MEDIUM) + TIMEOUT(600) +ENDIF() + +PEERDIR( + library/cpp/actors/protos + library/cpp/actors/util + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/dsproxy + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/vdisk + ydb/core/blobstorage/vdisk/common + ydb/core/testlib/default +) + +SRCS( + dsproxy_ut.cpp +) + +REQUIREMENTS(ram:10) + +END() diff --git a/ydb/core/blobstorage/dsproxy/ya.make b/ydb/core/blobstorage/dsproxy/ya.make new file mode 100644 index 00000000000..a8dd854358e --- /dev/null +++ b/ydb/core/blobstorage/dsproxy/ya.make @@ -0,0 +1,82 @@ +LIBRARY() + +SRCS( + dsproxy.h + dsproxy_impl.cpp + dsproxy_impl.h + dsproxy_encrypt.cpp + dsproxy_request.cpp + dsproxy_stat.cpp + dsproxy_state.cpp + dsproxy_blackboard.h + dsproxy_blackboard.cpp + dsproxy_assimilate.cpp + dsproxy_block.cpp + dsproxy_collect.cpp + dsproxy_discover.cpp + dsproxy_discover_m3dc.cpp + dsproxy_discover_m3of4.cpp + dsproxy_get.cpp + dsproxy_get_impl.cpp + dsproxy_get_impl.h + dsproxy_indexrestoreget.cpp + dsproxy_mon.cpp + dsproxy_mon.h + dsproxy_monactor.cpp + dsproxy_monactor.h + dsproxy_multicollect.cpp + dsproxy_multiget.cpp + dsproxy_nodemon.cpp + dsproxy_nodemon.h + dsproxy_nodemonactor.cpp + dsproxy_nodemonactor.h + dsproxy_patch.cpp + dsproxy_put.cpp + dsproxy_put_impl.cpp + dsproxy_put_impl.h + dsproxy_quorum_tracker.h + dsproxy_range.cpp + dsproxy_responsiveness.h + dsproxy_status.cpp + dsproxy_strategy_accelerate_put.h + dsproxy_strategy_accelerate_put_m3dc.h + dsproxy_strategy_base.cpp + dsproxy_strategy_base.h + dsproxy_strategy_get_bold.h + dsproxy_strategy_get_m3dc_basic.h + dsproxy_strategy_get_m3dc_restore.h + dsproxy_strategy_get_m3of4.h + dsproxy_strategy_get_min_iops_block.h + dsproxy_strategy_get_min_iops_mirror.h + dsproxy_strategy_m3of4_base.h + dsproxy_strategy_put_m3dc.h + dsproxy_strategy_put_m3of4.h + dsproxy_strategy_restore.h + group_sessions.cpp + group_sessions.h + log_acc.h + blobstorage_backoff.cpp +) + +PEERDIR( + library/cpp/monlib/dynamic_counters/percentile + ydb/core/base + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/storagepoolmon + ydb/core/blobstorage/vdisk/ingress + ydb/core/control + ydb/core/util +) + +END() + +RECURSE( + mock +) + +RECURSE_FOR_TESTS( + ut + ut_fat +) diff --git a/ydb/core/blobstorage/groupinfo/ut/ya.make b/ydb/core/blobstorage/groupinfo/ut/ya.make new file mode 100644 index 00000000000..2be8b98663d --- /dev/null +++ b/ydb/core/blobstorage/groupinfo/ut/ya.make @@ -0,0 +1,37 @@ +UNITTEST_FOR(ydb/core/blobstorage/groupinfo) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/erasure +) + +SRCS( + blobstorage_groupinfo_iter_ut.cpp + blobstorage_groupinfo_ut.cpp +) + +IF (BUILD_TYPE == "RELEASE") + SRCS( + blobstorage_groupinfo_blobmap_ut.cpp + blobstorage_groupinfo_partlayout_ut.cpp + ) +ELSE () + MESSAGE(WARNING "It takes too much time to run test in DEBUG mode, some tests are skipped") +ENDIF () + +END() diff --git a/ydb/core/blobstorage/groupinfo/ya.make b/ydb/core/blobstorage/groupinfo/ya.make new file mode 100644 index 00000000000..fb227634529 --- /dev/null +++ b/ydb/core/blobstorage/groupinfo/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/digest/crc32c + library/cpp/pop_count + ydb/core/base + ydb/core/base/services + ydb/core/blobstorage/crypto + ydb/core/blobstorage/vdisk/ingress + ydb/core/protos +) + +SRCS( + blobstorage_groupinfo_blobmap.cpp + blobstorage_groupinfo_blobmap.h + blobstorage_groupinfo.cpp + blobstorage_groupinfo.h + blobstorage_groupinfo_iter.h + blobstorage_groupinfo_partlayout.cpp + blobstorage_groupinfo_partlayout.h + blobstorage_groupinfo_sets.h + defs.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/incrhuge/ut/ya.make b/ydb/core/blobstorage/incrhuge/ut/ya.make new file mode 100644 index 00000000000..0b4dee640a2 --- /dev/null +++ b/ydb/core/blobstorage/incrhuge/ut/ya.make @@ -0,0 +1,29 @@ +UNITTEST() + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/actors/protos + ydb/core/blobstorage + ydb/core/blobstorage/incrhuge + ydb/core/blobstorage/pdisk +) + +SRCS( + incrhuge_basic_ut.cpp + incrhuge_id_dict_ut.cpp + incrhuge_log_merger_ut.cpp +) + +REQUIREMENTS(ram:9) + +END() diff --git a/ydb/core/blobstorage/incrhuge/ya.make b/ydb/core/blobstorage/incrhuge/ya.make new file mode 100644 index 00000000000..fe1a5666ef9 --- /dev/null +++ b/ydb/core/blobstorage/incrhuge/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/protos +) + +SRCS( + defs.h + incrhuge.h + incrhuge_data.h + incrhuge_id_dict.h + incrhuge_keeper.cpp + incrhuge_keeper.h + incrhuge_keeper_alloc.cpp + incrhuge_keeper_alloc.h + incrhuge_keeper_common.cpp + incrhuge_keeper_common.h + incrhuge_keeper_defrag.cpp + incrhuge_keeper_defrag.h + incrhuge_keeper_delete.cpp + incrhuge_keeper_delete.h + incrhuge_keeper_log.cpp + incrhuge_keeper_log.h + incrhuge_keeper_read.cpp + incrhuge_keeper_read.h + incrhuge_keeper_recovery.cpp + incrhuge_keeper_recovery.h + incrhuge_keeper_recovery_read_log.cpp + incrhuge_keeper_recovery_read_log.h + incrhuge_keeper_recovery_scan.cpp + incrhuge_keeper_recovery_scan.h + incrhuge_keeper_write.cpp + incrhuge_keeper_write.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/lwtrace_probes/ya.make b/ydb/core/blobstorage/lwtrace_probes/ya.make new file mode 100644 index 00000000000..a2a97b5ba95 --- /dev/null +++ b/ydb/core/blobstorage/lwtrace_probes/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + blobstorage_probes.cpp +) + +PEERDIR( + contrib/libs/grpc + library/cpp/lwtrace/protos + ydb/core/base + ydb/core/protos +) + +END() diff --git a/ydb/core/blobstorage/nodewarden/ut/ya.make b/ydb/core/blobstorage/nodewarden/ut/ya.make new file mode 100644 index 00000000000..7e76208b6b0 --- /dev/null +++ b/ydb/core/blobstorage/nodewarden/ut/ya.make @@ -0,0 +1,26 @@ +UNITTEST_FOR(ydb/core/blobstorage/nodewarden) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/testlib/default +) + +SRCS( + blobstorage_node_warden_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:14) + +END() diff --git a/ydb/core/blobstorage/nodewarden/ut_sequence/ya.make b/ydb/core/blobstorage/nodewarden/ut_sequence/ya.make new file mode 100644 index 00000000000..fc87356d992 --- /dev/null +++ b/ydb/core/blobstorage/nodewarden/ut_sequence/ya.make @@ -0,0 +1,21 @@ +UNITTEST() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + ydb/core/blobstorage/base + ydb/core/blobstorage/crypto + ydb/core/blobstorage/nodewarden + ydb/core/blobstorage/pdisk + ydb/core/testlib/default +) + +SRCS( + dsproxy_config_retrieval.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/blobstorage/nodewarden/ya.make b/ydb/core/blobstorage/nodewarden/ya.make new file mode 100644 index 00000000000..75365f818df --- /dev/null +++ b/ydb/core/blobstorage/nodewarden/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +SRCS( + group_stat_aggregator.cpp + node_warden_cache.cpp + node_warden_group.cpp + node_warden_group_resolver.cpp + node_warden_impl.cpp + node_warden_mon.cpp + node_warden_pdisk.cpp + node_warden_pipe.cpp + node_warden_proxy.cpp + node_warden_resource.cpp + node_warden_scrub.cpp + node_warden_stat_aggr.cpp + node_warden_vdisk.cpp +) + +PEERDIR( + library/cpp/json + ydb/core/base + ydb/core/blob_depot/agent + ydb/core/blobstorage/crypto + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/pdisk + ydb/core/control + ydb/library/pdisk_io +) + +END() + +RECURSE_FOR_TESTS( + ut + ut_sequence +) diff --git a/ydb/core/blobstorage/other/ya.make b/ydb/core/blobstorage/other/ya.make new file mode 100644 index 00000000000..26f33fc372b --- /dev/null +++ b/ydb/core/blobstorage/other/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +PEERDIR( + library/cpp/json/writer + library/cpp/monlib/service/pages + library/cpp/threading/future + ydb/core/base + ydb/core/blobstorage/base +) + +SRCS( + defs.h + mon_blob_range_page.cpp + mon_blob_range_page.h + mon_get_blob_page.cpp + mon_get_blob_page.h + mon_vdisk_stream.cpp + mon_vdisk_stream.h +) + +END() diff --git a/ydb/core/blobstorage/pdisk/mock/ya.make b/ydb/core/blobstorage/pdisk/mock/ya.make new file mode 100644 index 00000000000..eb4c5eb7bb6 --- /dev/null +++ b/ydb/core/blobstorage/pdisk/mock/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + pdisk_mock.cpp + pdisk_mock.h +) + +PEERDIR( + library/cpp/actors/core + ydb/core/blobstorage/pdisk +) + +END() diff --git a/ydb/core/blobstorage/pdisk/ut/ya.make b/ydb/core/blobstorage/pdisk/ut/ya.make new file mode 100644 index 00000000000..f6d01054c4d --- /dev/null +++ b/ydb/core/blobstorage/pdisk/ut/ya.make @@ -0,0 +1,50 @@ +UNITTEST_FOR(ydb/core/blobstorage/pdisk) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + ENV(VALGRIND_OPTS=--max-stackframe=16000000) +ENDIF() + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(2400) + SPLIT_FACTOR(20) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/blobstorage/lwtrace_probes + ydb/core/testlib/actors +) + +SRCS( + blobstorage_pdisk_blockdevice_ut.cpp + blobstorage_pdisk_crypto_ut.cpp + blobstorage_pdisk_log_cache_ut.cpp + blobstorage_pdisk_util_ut.cpp + blobstorage_pdisk_ut_env.cpp + blobstorage_pdisk_ut_races.cpp + blobstorage_pdisk_ut.cpp + blobstorage_pdisk_ut_actions.cpp + blobstorage_pdisk_ut_helpers.cpp + blobstorage_pdisk_ut_run.cpp + blobstorage_pdisk_ut_sectormap.cpp + blobstorage_pdisk_restore_ut.cpp + mock/pdisk_mock.cpp +) + +IF (BUILD_TYPE == "RELEASE") + SRCS( + blobstorage_pdisk_ut_yard.cpp + ) +ELSE () + MESSAGE(WARNING "It takes too much time to run test in DEBUG mode, some tests are skipped") +ENDIF () + +END() diff --git a/ydb/core/blobstorage/pdisk/ya.make b/ydb/core/blobstorage/pdisk/ya.make new file mode 100644 index 00000000000..d352afc2689 --- /dev/null +++ b/ydb/core/blobstorage/pdisk/ya.make @@ -0,0 +1,67 @@ +LIBRARY() + +PEERDIR( + contrib/libs/lz4 + library/cpp/actors/core + library/cpp/actors/protos + library/cpp/actors/util + library/cpp/actors/wilson + library/cpp/containers/stack_vector + library/cpp/deprecated/atomic + library/cpp/lwtrace + library/cpp/monlib/dynamic_counters/percentile + library/cpp/monlib/service/pages + util + ydb/core/base + ydb/core/base/services + ydb/core/blobstorage/base + ydb/core/blobstorage/crypto + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/lwtrace_probes + ydb/core/control + ydb/core/protos + ydb/core/util + ydb/library/pdisk_io + ydb/library/schlab + ydb/library/schlab/mon + ydb/library/schlab/schine +) + +GENERATE_ENUM_SERIALIZATION(blobstorage_pdisk_state.h) + +SRCS( + blobstorage_pdisk.cpp + blobstorage_pdisk_actor.cpp + blobstorage_pdisk_blockdevice_async.cpp + blobstorage_pdisk_completion_impl.cpp + blobstorage_pdisk_delayed_cost_loop.cpp + blobstorage_pdisk_driveestimator.cpp + blobstorage_pdisk_drivemodel_db.cpp + blobstorage_pdisk_impl.cpp + blobstorage_pdisk_impl_http.cpp + blobstorage_pdisk_impl_log.cpp + blobstorage_pdisk_internal_interface.cpp + blobstorage_pdisk_log_cache.cpp + blobstorage_pdisk_logreader.cpp + blobstorage_pdisk_mon.cpp + blobstorage_pdisk_params.cpp + blobstorage_pdisk_requestimpl.cpp + blobstorage_pdisk_syslogreader.cpp + blobstorage_pdisk_sectorrestorator.cpp + blobstorage_pdisk_tools.cpp + blobstorage_pdisk_util_atomicblockcounter.cpp + blobstorage_pdisk_util_flightcontrol.cpp + blobstorage_pdisk_util_signal_event.cpp + blobstorage_pdisk_writer.cpp + drivedata_serializer.cpp +) + +END() + +RECURSE( + mock +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/storagepoolmon/ut/ya.make b/ydb/core/blobstorage/storagepoolmon/ut/ya.make new file mode 100644 index 00000000000..550f4b729cf --- /dev/null +++ b/ydb/core/blobstorage/storagepoolmon/ut/ya.make @@ -0,0 +1,29 @@ +UNITTEST() + +FORK_SUBTESTS() + +SPLIT_FACTOR(20) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/blobstorage/storagepoolmon + ydb/core/testlib/default + ydb/core/testlib/actors + ydb/core/testlib/basics +) + +SRCS( + storagepoolmon_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/storagepoolmon/ya.make b/ydb/core/blobstorage/storagepoolmon/ya.make new file mode 100644 index 00000000000..cd64acd59d5 --- /dev/null +++ b/ydb/core/blobstorage/storagepoolmon/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + storagepool_counters.h +) + +PEERDIR( + library/cpp/monlib/dynamic_counters + ydb/core/base + ydb/core/blobstorage/base +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/testing/group_overseer/ya.make b/ydb/core/blobstorage/testing/group_overseer/ya.make new file mode 100644 index 00000000000..76c6bbe7924 --- /dev/null +++ b/ydb/core/blobstorage/testing/group_overseer/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + + SRCS( + defs.h + group_overseer.cpp + group_overseer.h + group_state.cpp + group_state.h + ) + + PEERDIR( + ydb/core/base + + contrib/libs/t1ha + ) + +END() diff --git a/ydb/core/blobstorage/testing/ya.make b/ydb/core/blobstorage/testing/ya.make new file mode 100644 index 00000000000..80f18cc7ce1 --- /dev/null +++ b/ydb/core/blobstorage/testing/ya.make @@ -0,0 +1,3 @@ +RECURSE( + group_overseer +) diff --git a/ydb/core/blobstorage/ut_blobstorage/lib/ya.make b/ydb/core/blobstorage/ut_blobstorage/lib/ya.make new file mode 100644 index 00000000000..3d5f123e51c --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/lib/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + +SRCS( + activity.h + common.h + defs.h + env.h + node_warden_mock_bsc.cpp + node_warden_mock.h + node_warden_mock_pipe.cpp + node_warden_mock_state.cpp + node_warden_mock_state.h + node_warden_mock_vdisk.h +) + +PEERDIR( + library/cpp/digest/md5 + library/cpp/testing/unittest + ydb/core/base + ydb/core/blob_depot + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/dsproxy/mock + ydb/core/blobstorage/nodewarden + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/pdisk/mock + ydb/core/blobstorage/vdisk/common + ydb/core/mind + ydb/core/mind/bscontroller + ydb/core/mind/hive + ydb/core/sys_view/service + ydb/core/tx/scheme_board + ydb/core/tx/tx_allocator + ydb/core/tx/mediator + ydb/core/tx/coordinator + ydb/core/tx/scheme_board + ydb/core/util + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ut_blob_depot/ya.make b/ydb/core/blobstorage/ut_blobstorage/ut_blob_depot/ya.make new file mode 100644 index 00000000000..18cc4b51f22 --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ut_blob_depot/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage) + + SRCS( + blob_depot.cpp + blob_depot_test_functions.cpp + blob_depot_event_managers.cpp + ) + + PEERDIR( + ydb/core/blobstorage/ut_blobstorage/lib + ) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ut_blob_depot_fat/ya.make b/ydb/core/blobstorage/ut_blobstorage/ut_blob_depot_fat/ya.make new file mode 100644 index 00000000000..cf97a412857 --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ut_blob_depot_fat/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage) + + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + + SRCS( + blob_depot_fat.cpp + blob_depot_test_functions.cpp + blob_depot_event_managers.cpp + ) + + PEERDIR( + ydb/core/blobstorage/ut_blobstorage/lib + ) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ut_donor/ya.make b/ydb/core/blobstorage/ut_blobstorage/ut_donor/ya.make new file mode 100644 index 00000000000..6932f2c0616 --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ut_donor/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage) + + FORK_SUBTESTS() + + SIZE(MEDIUM) + + TIMEOUT(600) + + SRCS( + donor.cpp + ) + + PEERDIR( + ydb/core/blobstorage/ut_blobstorage/lib + ) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ut_group_reconfiguration/ya.make b/ydb/core/blobstorage/ut_blobstorage/ut_group_reconfiguration/ya.make new file mode 100644 index 00000000000..b4dfedf1104 --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ut_group_reconfiguration/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage) + +FORK_SUBTESTS() + +FORK_SUBTESTS() + +# SIZE(MEDIUM) +# TIMEOUT(600) +SIZE(LARGE) + +TIMEOUT(3600) + +TAG(ya:fat) + +SRCS( + race.cpp +) + +PEERDIR( + ydb/core/blobstorage/ut_blobstorage/lib +) + +REQUIREMENTS( + cpu:4 + ram:32 +) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ut_osiris/ya.make b/ydb/core/blobstorage/ut_blobstorage/ut_osiris/ya.make new file mode 100644 index 00000000000..1d86dc6dd3c --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ut_osiris/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage) + +FORK_SUBTESTS() + +SIZE(LARGE) + +TIMEOUT(3600) + +TAG(ya:fat) + +SRCS( + osiris.cpp +) + +PEERDIR( + ydb/core/blobstorage/ut_blobstorage/lib +) + +REQUIREMENTS( + cpu:4 + ram:32 +) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ut_replication/ya.make b/ydb/core/blobstorage/ut_blobstorage/ut_replication/ya.make new file mode 100644 index 00000000000..ae6c2101bc1 --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ut_replication/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage) + +FORK_SUBTESTS() + +SIZE(LARGE) + +TIMEOUT(3600) + +TAG(ya:fat) + +SRCS( + replication.cpp +) + +PEERDIR( + ydb/core/blobstorage/ut_blobstorage/lib +) + +REQUIREMENTS( + cpu:4 + ram:32 +) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ut_scrub/ya.make b/ydb/core/blobstorage/ut_blobstorage/ut_scrub/ya.make new file mode 100644 index 00000000000..3736fd669e1 --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ut_scrub/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage) + +FORK_SUBTESTS() + +SIZE(LARGE) + +TIMEOUT(3600) + +TAG(ya:fat) + +SRCS( + scrub.cpp +) + +PEERDIR( + ydb/core/blobstorage/ut_blobstorage/lib +) + +REQUIREMENTS( + cpu:4 + ram:32 +) + +END() diff --git a/ydb/core/blobstorage/ut_blobstorage/ya.make b/ydb/core/blobstorage/ut_blobstorage/ya.make new file mode 100644 index 00000000000..0ae92e59249 --- /dev/null +++ b/ydb/core/blobstorage/ut_blobstorage/ya.make @@ -0,0 +1,66 @@ +UNITTEST() + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + assimilation.cpp + block_race.cpp + counting_events.cpp + decommit_3dc.cpp + defrag.cpp + encryption.cpp + extra_block_checks.cpp + gc_quorum_3dc.cpp + group_reconfiguration.cpp + incorrect_queries.cpp + main.cpp + mirror3of4.cpp + sanitize_groups.cpp + snapshots.cpp + space_check.cpp + sync.cpp +) + +IF (BUILD_TYPE == "RELEASE") + SRCS( + big_cluster.cpp + get.cpp + discover.cpp + multiget.cpp + patch.cpp + ) +ELSE () + MESSAGE(WARNING "It takes too much time to run test in DEBUG mode, some tests are skipped") +ENDIF () + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/dsproxy + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/ut_blobstorage/lib + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/scrub +) + +REQUIREMENTS(ram:32) + +END() + +RECURSE_FOR_TESTS( + ut_blob_depot + ut_blob_depot_fat + ut_donor + ut_group_reconfiguration + ut_osiris + ut_replication + ut_scrub +) diff --git a/ydb/core/blobstorage/ut_group/ya.make b/ydb/core/blobstorage/ut_group/ya.make new file mode 100644 index 00000000000..e57a07754b0 --- /dev/null +++ b/ydb/core/blobstorage/ut_group/ya.make @@ -0,0 +1,31 @@ +UNITTEST() + +IF (NOT WITH_VALGRIND) + SRCS( + main.cpp + ) +ENDIF() + +IF (SANITIZER_TYPE) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/actors/interconnect/mock + library/cpp/testing/unittest + ydb/core/blobstorage/crypto + ydb/core/blobstorage/dsproxy + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/pdisk/mock + ydb/core/blobstorage/vdisk + ydb/core/blobstorage/vdisk/common + ydb/core/tx/scheme_board + ydb/core/util +) + +END() diff --git a/ydb/core/blobstorage/ut_mirror3of4/ya.make b/ydb/core/blobstorage/ut_mirror3of4/ya.make new file mode 100644 index 00000000000..bc67d1bd568 --- /dev/null +++ b/ydb/core/blobstorage/ut_mirror3of4/ya.make @@ -0,0 +1,26 @@ +UNITTEST() + +SRCS( + main.cpp +) + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/actors/interconnect/mock + library/cpp/testing/unittest + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/base + ydb/core/blobstorage/dsproxy + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/pdisk/mock + ydb/core/blobstorage/vdisk + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/repl + ydb/core/tx/scheme_board + ydb/core/util +) + +END() diff --git a/ydb/core/blobstorage/ut_pdiskfit/lib/ya.make b/ydb/core/blobstorage/ut_pdiskfit/lib/ya.make new file mode 100644 index 00000000000..e340d863513 --- /dev/null +++ b/ydb/core/blobstorage/ut_pdiskfit/lib/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + basic_test.cpp + objectwithstate.cpp +) + +PEERDIR( + library/cpp/actors/protos + ydb/core/base + ydb/core/blobstorage/pdisk + ydb/library/pdisk_io + library/cpp/deprecated/atomic +) + +END() diff --git a/ydb/core/blobstorage/ut_pdiskfit/pdiskfit/ya.make b/ydb/core/blobstorage/ut_pdiskfit/pdiskfit/ya.make new file mode 100644 index 00000000000..3f1ae992049 --- /dev/null +++ b/ydb/core/blobstorage/ut_pdiskfit/pdiskfit/ya.make @@ -0,0 +1,17 @@ +IF (OS_LINUX) + PROGRAM(pdiskfit) + + SRCS( + pdiskfit.cpp + ) + + PEERDIR( + library/cpp/getopt + library/cpp/string_utils/parse_size + ydb/core/blobstorage + ydb/core/blobstorage/ut_pdiskfit/lib + ydb/core/mon + ) + + END() +ENDIF() diff --git a/ydb/core/blobstorage/ut_pdiskfit/ut/ya.make b/ydb/core/blobstorage/ut_pdiskfit/ut/ya.make new file mode 100644 index 00000000000..6f64babbe77 --- /dev/null +++ b/ydb/core/blobstorage/ut_pdiskfit/ut/ya.make @@ -0,0 +1,24 @@ +IF (OS_LINUX AND NOT WITH_VALGRIND) + UNITTEST() + + TIMEOUT(1200) + + SIZE(LARGE) + + TAG(ya:fat) + + IF (BUILD_TYPE == "RELEASE") + SRCS( + main.cpp + ) + ELSE () + MESSAGE(WARNING "It takes too much time to run test in DEBUG mode, some tests are skipped") + ENDIF () + + PEERDIR( + ydb/core/blobstorage + ydb/core/blobstorage/ut_pdiskfit/lib + ) + + END() +ENDIF() diff --git a/ydb/core/blobstorage/ut_pdiskfit/ya.make b/ydb/core/blobstorage/ut_pdiskfit/ya.make new file mode 100644 index 00000000000..393ceb4877d --- /dev/null +++ b/ydb/core/blobstorage/ut_pdiskfit/ya.make @@ -0,0 +1,8 @@ +RECURSE( + pdiskfit + lib +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/ut_testshard/ya.make b/ydb/core/blobstorage/ut_testshard/ya.make new file mode 100644 index 00000000000..e1c6adef761 --- /dev/null +++ b/ydb/core/blobstorage/ut_testshard/ya.make @@ -0,0 +1,39 @@ +UNITTEST() + + SIZE(MEDIUM) + TIMEOUT(600) + + REQUIREMENTS( + ram:32 + ) + + SRCS( + main.cpp + ) + + PEERDIR( + ydb/core/base + ydb/core/blob_depot + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/dsproxy/mock + ydb/core/blobstorage/nodewarden + ydb/core/blobstorage/pdisk/mock + ydb/core/blobstorage/testing/group_overseer + ydb/core/blobstorage/vdisk/common + ydb/core/mind + ydb/core/mind/bscontroller + ydb/core/mind/hive + ydb/core/sys_view/service + ydb/core/test_tablet + ydb/core/tx/scheme_board + ydb/core/tx/tx_allocator + ydb/core/tx/mediator + ydb/core/tx/coordinator + ydb/core/tx/scheme_board + ydb/core/util + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy + library/cpp/testing/unittest + ) + +END() diff --git a/ydb/core/blobstorage/ut_vdisk/lib/ya.make b/ydb/core/blobstorage/ut_vdisk/lib/ya.make new file mode 100644 index 00000000000..0c6cfc0724e --- /dev/null +++ b/ydb/core/blobstorage/ut_vdisk/lib/ya.make @@ -0,0 +1,69 @@ +LIBRARY() + +SRCS( + astest.h + defs.h + dataset.cpp + dataset.h + helpers.cpp + helpers.h + helpers_impl.h + http_client.cpp + http_client.h + prepare.cpp + prepare.h + setup.h + test_brokendevice.cpp + test_brokendevice.h + test_dbstat.cpp + test_dbstat.h + test_defrag.cpp + test_defrag.h + test_faketablet.cpp + test_faketablet.h + test_gc.cpp + test_gc.h + test_huge.cpp + test_huge.h + test_load.cpp + test_load.h + test_localrecovery.cpp + test_localrecovery.h + test_many.cpp + test_many.h + test_outofspace.cpp + test_outofspace.h + test_repl.cpp + test_repl.h + test_simplebs.cpp + test_simplebs.h + test_synclog.cpp + test_synclog.h + vdisk_mock.cpp + vdisk_mock.h +) + +PEERDIR( + library/cpp/actors/protos + library/cpp/http/io + library/cpp/openssl/io + library/cpp/string_utils/url + library/cpp/testing/unittest + ydb/core/base + ydb/core/blobstorage + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/base + ydb/core/blobstorage/crypto + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/vdisk + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/huge + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/repl + ydb/core/blobstorage/vdisk/skeleton + ydb/core/blobstorage/vdisk/synclog + ydb/core/erasure + ydb/library/pdisk_io +) + +END() diff --git a/ydb/core/blobstorage/ut_vdisk/ya.make b/ydb/core/blobstorage/ut_vdisk/ya.make new file mode 100644 index 00000000000..4106c7e65c2 --- /dev/null +++ b/ydb/core/blobstorage/ut_vdisk/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/blobstorage) + +FORK_SUBTESTS() + +SPLIT_FACTOR(20) + +SIZE(MEDIUM) + +TIMEOUT(600) + +SRCS( + defaults.h + gen_restarts.cpp + gen_restarts.h + huge_migration_ut.cpp + mon_reregister_ut.cpp + vdisk_test.cpp +) + +PEERDIR( + library/cpp/actors/protos + library/cpp/codecs + ydb/core/base + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/ut_vdisk/lib + ydb/core/erasure + ydb/core/scheme + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/blobstorage/ut_vdisk2/ya.make b/ydb/core/blobstorage/ut_vdisk2/ya.make new file mode 100644 index 00000000000..0cc3ad2563b --- /dev/null +++ b/ydb/core/blobstorage/ut_vdisk2/ya.make @@ -0,0 +1,26 @@ +UNITTEST() + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +SRCS( + defs.h + env.h + huge.cpp +) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/pdisk/mock + ydb/core/blobstorage/vdisk + ydb/core/blobstorage/vdisk/common + ydb/core/tx/scheme_board + ydb/library/yql/public/udf/service/stub +) + +END() diff --git a/ydb/core/blobstorage/vdisk/anubis_osiris/ut/ya.make b/ydb/core/blobstorage/vdisk/anubis_osiris/ut/ya.make new file mode 100644 index 00000000000..5edb7567dd7 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/anubis_osiris/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/anubis_osiris) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base +) + +SRCS( + blobstorage_anubis_algo_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/anubis_osiris/ya.make b/ydb/core/blobstorage/vdisk/anubis_osiris/ya.make new file mode 100644 index 00000000000..2a153a458bd --- /dev/null +++ b/ydb/core/blobstorage/vdisk/anubis_osiris/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/vdisk/hulldb/barriers + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/protos +) + +SRCS( + blobstorage_anubis.cpp + blobstorage_anubis_algo.cpp + blobstorage_anubis_osiris.cpp + blobstorage_anubisfinder.cpp + blobstorage_anubisproxy.cpp + blobstorage_anubisrunner.cpp + blobstorage_osiris.cpp + defs.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/common/ut/ya.make b/ydb/core/blobstorage/vdisk/common/ut/ya.make new file mode 100644 index 00000000000..8733f17c326 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/common/ut/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/common) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/groupinfo + ydb/core/erasure +) + +SRCS( + circlebufresize_ut.cpp + circlebufstream_ut.cpp + circlebuf_ut.cpp + memusage_ut.cpp + vdisk_config_ut.cpp + vdisk_lsnmngr_ut.cpp + vdisk_outofspace_ut.cpp + vdisk_pdisk_error_ut.cpp + vdisk_syncneighbors_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/common/ya.make b/ydb/core/blobstorage/vdisk/common/ya.make new file mode 100644 index 00000000000..839716e91e6 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/common/ya.make @@ -0,0 +1,66 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/protos + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/protos + ydb/core/protos +) + +SRCS( + align.h + blobstorage_dblogcutter.cpp + blobstorage_dblogcutter.h + blobstorage_event_filter.cpp + blobstorage_event_filter.h + blobstorage_status.cpp + blobstorage_status.h + blobstorage_vdisk_guids.cpp + blobstorage_vdisk_guids.h + defs.h + disk_part.h + sublog.h + vdisk_config.cpp + vdisk_config.h + vdisk_context.cpp + vdisk_context.h + vdisk_costmodel.cpp + vdisk_costmodel.h + vdisk_dbtype.h + vdisk_defrag.h + vdisk_events.cpp + vdisk_events.h + vdisk_handle_class.cpp + vdisk_handle_class.h + vdisk_histogram_latency.cpp + vdisk_histogram_latency.h + vdisk_histograms.cpp + vdisk_histograms.h + vdisk_hugeblobctx.cpp + vdisk_hugeblobctx.h + vdisk_hulllogctx.h + vdisk_log.cpp + vdisk_log.h + vdisk_lsnmngr.h + vdisk_mon.h + vdisk_mongroups.h + vdisk_outofspace.cpp + vdisk_outofspace.h + vdisk_pdisk_error.h + vdisk_pdiskctx.h + vdisk_private_events.h + vdisk_queues.h + vdisk_recoverylogwriter.cpp + vdisk_recoverylogwriter.h + vdisk_response.cpp + vdisk_response.h + vdisk_syncneighbors.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/defrag/ut/ya.make b/ydb/core/blobstorage/vdisk/defrag/ut/ya.make new file mode 100644 index 00000000000..cb5b07abff3 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/defrag/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/defrag) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/blobstorage/vdisk/defrag + ydb/core/blobstorage/vdisk/hulldb +) + +SRCS( + defrag_actor_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/defrag/ya.make b/ydb/core/blobstorage/vdisk/defrag/ya.make new file mode 100644 index 00000000000..993006f5c1f --- /dev/null +++ b/ydb/core/blobstorage/vdisk/defrag/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb +) + +SRCS( + defrag_actor.cpp + defrag_actor.h + defrag_quantum.cpp + defrag_quantum.h + defrag_rewriter.cpp + defrag_rewriter.h + defrag_search.h + defs.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/handoff/ya.make b/ydb/core/blobstorage/vdisk/handoff/ya.make new file mode 100644 index 00000000000..bb4d322b525 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/handoff/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/protos +) + +SRCS( + defs.h + handoff_basic.cpp + handoff_basic.h + handoff_delegate.cpp + handoff_delegate.h + handoff_map.cpp + handoff_map.h + handoff_mon.cpp + handoff_mon.h + handoff_proxy.cpp + handoff_proxy.h + handoff_synclogproxy.cpp + handoff_synclogproxy.h +) + +END() diff --git a/ydb/core/blobstorage/vdisk/huge/ut/ya.make b/ydb/core/blobstorage/vdisk/huge/ut/ya.make new file mode 100644 index 00000000000..09ee8a70534 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/huge/ut/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/huge) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage + ydb/core/blobstorage/groupinfo + ydb/core/erasure +) + +SRCS( + blobstorage_hullhugedefs_ut.cpp + blobstorage_hullhugeheap_ctx_ut.cpp + blobstorage_hullhugeheap_ut.cpp + blobstorage_hullhugerecovery_ut.cpp + blobstorage_hullhuge_ut.cpp + top_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/huge/ya.make b/ydb/core/blobstorage/vdisk/huge/ya.make new file mode 100644 index 00000000000..b220e0429f6 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/huge/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +PEERDIR( + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb/base +) + +SRCS( + blobstorage_hullhuge.cpp + blobstorage_hullhugedefs.cpp + blobstorage_hullhugedefs.h + blobstorage_hullhuge.h + blobstorage_hullhugeheap.cpp + blobstorage_hullhugeheap.h + blobstorage_hullhugerecovery.cpp + blobstorage_hullhugerecovery.h + booltt.h + defs.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/hulldb/barriers/ut/ya.make b/ydb/core/blobstorage/vdisk/hulldb/barriers/ut/ya.make new file mode 100644 index 00000000000..fa9871455a1 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/barriers/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/hulldb/barriers) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/vdisk/common +) + +SRCS( + barriers_tree_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hulldb/barriers/ya.make b/ydb/core/blobstorage/vdisk/hulldb/barriers/ya.make new file mode 100644 index 00000000000..b8f09031677 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/barriers/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/base + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/protos +) + +SRCS( + barriers_chain.cpp + barriers_chain.h + barriers_essence.cpp + barriers_essence.h + barriers_public.cpp + barriers_public.h + barriers_tree.cpp + barriers_tree.h + defs.h + hullds_cache_barrier.h + hullds_gcessence_defs.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/ut/ya.make b/ydb/core/blobstorage/vdisk/hulldb/base/ut/ya.make new file mode 100644 index 00000000000..8a93c87e7bb --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/base/ut/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/hulldb/base) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb +) + +SRCS( + blobstorage_blob_ut.cpp + blobstorage_hullsatisfactionrank_ut.cpp + blobstorage_hullstorageratio_ut.cpp + hullbase_barrier_ut.cpp + hullds_generic_it_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hulldb/base/ya.make b/ydb/core/blobstorage/vdisk/hulldb/base/ya.make new file mode 100644 index 00000000000..382a0a3cc50 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/base/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +PEERDIR( + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/vdisk/protos +) + +SRCS( + blobstorage_blob.h + blobstorage_hulldefs.cpp + blobstorage_hulldefs.h + blobstorage_hullsatisfactionrank.cpp + blobstorage_hullsatisfactionrank.h + blobstorage_hullstorageratio.h + defs.h + hullbase_barrier.cpp + hullbase_barrier.h + hullbase_block.h + hullbase_logoblob.h + hullds_arena.h + hullds_generic_it.h + hullds_glue.h + hullds_settings.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/hulldb/bulksst_add/ya.make b/ydb/core/blobstorage/vdisk/hulldb/bulksst_add/ya.make new file mode 100644 index 00000000000..e0d22baf00c --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/bulksst_add/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/vdisk/common + ydb/core/protos +) + +SRCS( + hulldb_bulksst_add.cpp + hulldb_bulksst_add.h +) + +END() + diff --git a/ydb/core/blobstorage/vdisk/hulldb/cache_block/ut/ya.make b/ydb/core/blobstorage/vdisk/hulldb/cache_block/ut/ya.make new file mode 100644 index 00000000000..fbd920666c6 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/cache_block/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/hulldb/cache_block) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage + ydb/core/erasure +) + +SRCS( + cache_block_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hulldb/cache_block/ya.make b/ydb/core/blobstorage/vdisk/hulldb/cache_block/ya.make new file mode 100644 index 00000000000..cd789f592ce --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/cache_block/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/protos + ydb/core/protos +) + +SRCS( + cache_block.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/hulldb/compstrat/ut/ya.make b/ydb/core/blobstorage/vdisk/hulldb/compstrat/ut/ya.make new file mode 100644 index 00000000000..d7b49825ab5 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/compstrat/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/hulldb/compstrat) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb + ydb/core/blobstorage/vdisk/hulldb/test +) + +SRCS( + hulldb_compstrat_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hulldb/compstrat/ya.make b/ydb/core/blobstorage/vdisk/hulldb/compstrat/ya.make new file mode 100644 index 00000000000..7b123eb03a7 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/compstrat/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/protos +) + +SRCS( + defs.h + hulldb_compstrat_balance.h + hulldb_compstrat_defs.cpp + hulldb_compstrat_defs.h + hulldb_compstrat_delsst.h + hulldb_compstrat_lazy.h + hulldb_compstrat_promote.h + hulldb_compstrat_ratio.h + hulldb_compstrat_selector.cpp + hulldb_compstrat_selector.h + hulldb_compstrat_space.h + hulldb_compstrat_squeeze.h + hulldb_compstrat_utils.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/hulldb/fresh/ut/ya.make b/ydb/core/blobstorage/vdisk/hulldb/fresh/ut/ya.make new file mode 100644 index 00000000000..a2aa6d07d68 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/fresh/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/hulldb/fresh) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb +) + +SRCS( + fresh_appendix_ut.cpp + fresh_data_ut.cpp + fresh_segment_ut.cpp + snap_vec_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hulldb/fresh/ya.make b/ydb/core/blobstorage/vdisk/hulldb/fresh/ya.make new file mode 100644 index 00000000000..7df5c4cc4c0 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/fresh/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/protos + ydb/core/protos +) + +SRCS( + defs.h + fresh_appendix.cpp + fresh_appendix.h + fresh_data.cpp + fresh_data.h + fresh_datasnap.cpp + fresh_datasnap.h + fresh_segment.cpp + fresh_segment.h + fresh_segment_impl.h + snap_vec.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/ut/ya.make b/ydb/core/blobstorage/vdisk/hulldb/generic/ut/ya.make new file mode 100644 index 00000000000..950a9900ef4 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/hulldb/generic) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb +) + +SRCS( + hullds_sst_it_all_ut.cpp + blobstorage_hullwritesst_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hulldb/generic/ya.make b/ydb/core/blobstorage/vdisk/hulldb/generic/ya.make new file mode 100644 index 00000000000..2fd9dba6c99 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/generic/ya.make @@ -0,0 +1,42 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/fresh + ydb/core/blobstorage/vdisk/protos + ydb/core/protos +) + +SRCS( + blobstorage_hulldatamerger.h + blobstorage_hullmergeits.h + blobstorage_hulloptlsn.cpp + blobstorage_hulloptlsn.h + blobstorage_hullrecmerger.h + blobstorage_hullwritesst.h + defs.h + hulldb_bulksstloaded.h + hulldb_bulksstmngr.cpp + hulldb_bulksstmngr.h + hullds_idx.cpp + hullds_idx.h + hullds_idxsnap.cpp + hullds_idxsnap.h + hullds_idxsnap_it.h + hullds_leveledssts.h + hullds_sst.cpp + hullds_sst.h + hullds_sst_it.h + hullds_sstslice.cpp + hullds_sstslice.h + hullds_sstslice_it.h + hullds_sstvec.cpp + hullds_sstvec.h + hullds_sstvec_it.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/hulldb/recovery/ya.make b/ydb/core/blobstorage/vdisk/hulldb/recovery/ya.make new file mode 100644 index 00000000000..40287afb78c --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/recovery/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb/bulksst_add + ydb/core/protos +) + +SRCS( + hulldb_recovery.cpp + hulldb_recovery.h +) + +END() + diff --git a/ydb/core/blobstorage/vdisk/hulldb/test/ya.make b/ydb/core/blobstorage/vdisk/hulldb/test/ya.make new file mode 100644 index 00000000000..9d9dee630aa --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/test/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/protos +) + +SRCS( + defs.h + testhull_index.h + testhull_index.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hulldb/ya.make b/ydb/core/blobstorage/vdisk/hulldb/ya.make new file mode 100644 index 00000000000..e1b1c72b0eb --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hulldb/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb/barriers + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/compstrat + ydb/core/blobstorage/vdisk/hulldb/fresh + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/blobstorage/vdisk/hulldb/recovery + ydb/core/blobstorage/vdisk/hulldb/bulksst_add + ydb/core/protos +) + +SRCS( + blobstorage_hullgcmap.h + hull_ds_all.h + hull_ds_all_snap.h +) + +END() + +RECURSE( + barriers + base + bulksst_add + cache_block + compstrat + fresh + generic + test + recovery +) diff --git a/ydb/core/blobstorage/vdisk/hullop/hullcompdelete/ya.make b/ydb/core/blobstorage/vdisk/hullop/hullcompdelete/ya.make new file mode 100644 index 00000000000..e39e0b040cb --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hullop/hullcompdelete/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/vdisk/common + ydb/core/protos +) + +SRCS( + blobstorage_hullcompdelete.cpp + blobstorage_hullcompdelete.h +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hullop/ut/ya.make b/ydb/core/blobstorage/vdisk/hullop/ut/ya.make new file mode 100644 index 00000000000..dfd71053574 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hullop/ut/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/hullop) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + REQUIREMENTS( + cpu:4 + ram:16 + ) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/blobstorage/pdisk +) + +SRCS( + blobstorage_hullcompactdeferredqueue_ut.cpp + blobstorage_readbatch_ut.cpp + hullop_delayedresp_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/hullop/ya.make b/ydb/core/blobstorage/vdisk/hullop/ya.make new file mode 100644 index 00000000000..fcf8ebe289e --- /dev/null +++ b/ydb/core/blobstorage/vdisk/hullop/ya.make @@ -0,0 +1,49 @@ +LIBRARY() + +PEERDIR( + ydb/core/blobstorage/vdisk/hulldb/barriers + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/blobstorage/vdisk/hulldb/cache_block + ydb/core/blobstorage/vdisk/hulldb/recovery + ydb/core/blobstorage/vdisk/hulldb/bulksst_add + ydb/core/blobstorage/vdisk/hulldb/compstrat + ydb/core/blobstorage/vdisk/hullop/hullcompdelete + ydb/core/blobstorage/vdisk/handoff + ydb/core/blobstorage/vdisk/synclog + ydb/core/protos +) + +SRCS( + blobstorage_buildslice.h + blobstorage_hull.cpp + blobstorage_hull.h + blobstorage_hullactor.h + blobstorage_hullactor.cpp + blobstorage_hullcommit.h + blobstorage_hullcompactdeferredqueue.h + blobstorage_hullcompact.h + blobstorage_hullcompactworker.h + blobstorage_hullload.h + blobstorage_hulllog.cpp + blobstorage_hulllog.h + blobstorage_hulllogcutternotify.cpp + blobstorage_hulllogcutternotify.h + blobstorage_readbatch.h + defs.h + hullop_compactfreshappendix.cpp + hullop_compactfreshappendix.h + hullop_delayedresp.h + hullop_entryserialize.cpp + hullop_entryserialize.h +) + +END() + +RECURSE( + hullcompdelete +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/ingress/ut/ya.make b/ydb/core/blobstorage/vdisk/ingress/ut/ya.make new file mode 100644 index 00000000000..0e0afcc2fd3 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/ingress/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/ingress) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/erasure +) + +SRCS( + blobstorage_ingress_matrix_ut.cpp + blobstorage_ingress_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/ingress/ya.make b/ydb/core/blobstorage/vdisk/ingress/ya.make new file mode 100644 index 00000000000..f03d3361015 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/ingress/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +PEERDIR( + library/cpp/lwtrace + library/cpp/pop_count + ydb/core/base + ydb/core/protos +) + +SRCS( + blobstorage_ingress.cpp + blobstorage_ingress.h + blobstorage_ingress_matrix.cpp + blobstorage_ingress_matrix.h + defs.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/localrecovery/ya.make b/ydb/core/blobstorage/vdisk/localrecovery/ya.make new file mode 100644 index 00000000000..de3d41ee501 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/localrecovery/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/vdisk/hulldb + ydb/core/protos +) + +SRCS( + defs.h + localrecovery_defs.cpp + localrecovery_defs.h + localrecovery_logreplay.cpp + localrecovery_logreplay.h + localrecovery_public.cpp + localrecovery_public.h + localrecovery_readbulksst.cpp + localrecovery_readbulksst.h +) + +END() diff --git a/ydb/core/blobstorage/vdisk/protos/ya.make b/ydb/core/blobstorage/vdisk/protos/ya.make new file mode 100644 index 00000000000..96fddf1f049 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +IF (OS_WINDOWS) + NO_OPTIMIZE_PY_PROTOS() +ENDIF() + +SRCS( + events.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/blobstorage/vdisk/query/ut/ya.make b/ydb/core/blobstorage/vdisk/query/ut/ya.make new file mode 100644 index 00000000000..31de3c48eb6 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/query/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/query) + +IF (WITH_VALGRIND) + FORK_SUBTESTS() + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + FORK_SUBTESTS() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/blobstorage/vdisk/huge + ydb/core/protos +) + +SRCS( + query_spacetracker_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/query/ya.make b/ydb/core/blobstorage/vdisk/query/ya.make new file mode 100644 index 00000000000..73559971961 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/query/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + +PEERDIR( + library/cpp/streams/bzip2 + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/vdisk/hulldb/barriers + ydb/core/blobstorage/vdisk/hulldb/base +) + +SRCS( + defs.h + assimilation.cpp + assimilation.h + query_barrier.cpp + query_base.h + query_dumpdb.h + query_extr.cpp + query_public.cpp + query_public.h + query_range.cpp + query_readactor.cpp + query_readactor.h + query_readbatch.cpp + query_readbatch.h + query_spacetracker.h + query_statalgo.h + query_statdb.cpp + query_statdb.h + query_stathuge.cpp + query_stathuge.h + query_stattablet.cpp + query_stattablet.h + query_stream.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/repl/ut/ya.make b/ydb/core/blobstorage/vdisk/repl/ut/ya.make new file mode 100644 index 00000000000..aa15d9d4d6e --- /dev/null +++ b/ydb/core/blobstorage/vdisk/repl/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/repl) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage + ydb/core/erasure +) + +SRCS( + blobstorage_hullreplwritesst_ut.cpp + blobstorage_replrecoverymachine_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/repl/ya.make b/ydb/core/blobstorage/vdisk/repl/ya.make new file mode 100644 index 00000000000..b7f5427b3fa --- /dev/null +++ b/ydb/core/blobstorage/vdisk/repl/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb/barriers + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/blobstorage/vdisk/hulldb/bulksst_add + ydb/core/protos +) + +SRCS( + blobstorage_hullrepljob.cpp + blobstorage_hullrepljob.h + blobstorage_hullreplwritesst.h + blobstorage_replbroker.cpp + blobstorage_replbroker.h + blobstorage_repl.cpp + blobstorage_replctx.h + blobstorage_repl.h + blobstorage_replproxy.cpp + blobstorage_replproxy.h + blobstorage_replrecoverymachine.h + defs.h + query_donor.h + repl_quoter.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/scrub/ya.make b/ydb/core/blobstorage/vdisk/scrub/ya.make new file mode 100644 index 00000000000..177303f44bc --- /dev/null +++ b/ydb/core/blobstorage/vdisk/scrub/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + blob_recovery.cpp + blob_recovery.h + blob_recovery_process.cpp + blob_recovery_queue.cpp + blob_recovery_request.cpp + defs.h + restore_corrupted_blob_actor.cpp + restore_corrupted_blob_actor.h + scrub_actor.cpp + scrub_actor.h + scrub_actor_huge.cpp + scrub_actor_huge_blob_merger.h + scrub_actor_impl.h + scrub_actor_mon.cpp + scrub_actor_pdisk.cpp + scrub_actor_snapshot.cpp + scrub_actor_sst.cpp + scrub_actor_sst_blob_merger.h + scrub_actor_unreadable.cpp +) + +PEERDIR( + ydb/core/blobstorage/base + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/skeleton +) + +END() diff --git a/ydb/core/blobstorage/vdisk/skeleton/ut/ya.make b/ydb/core/blobstorage/vdisk/skeleton/ut/ya.make new file mode 100644 index 00000000000..1548f4c24c0 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/skeleton/ut/ya.make @@ -0,0 +1,26 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/skeleton) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/blobstorage + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/skeleton + ydb/core/testlib/default + ydb/core/testlib/actors +) + +SRCS( + skeleton_oos_logic_ut.cpp + skeleton_vpatch_actor_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/blobstorage/vdisk/skeleton/ya.make b/ydb/core/blobstorage/vdisk/skeleton/ya.make new file mode 100644 index 00000000000..b96a726183a --- /dev/null +++ b/ydb/core/blobstorage/vdisk/skeleton/ya.make @@ -0,0 +1,56 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/bulksst_add + ydb/core/blobstorage/vdisk/synclog + ydb/core/protos +) + +SRCS( + defs.h + blobstorage_db.cpp + blobstorage_db.h + blobstorage_monactors.cpp + blobstorage_monactors.h + blobstorage_skeleton.cpp + blobstorage_skeleton.h + blobstorage_skeletonerr.h + blobstorage_skeletonfront.cpp + blobstorage_skeletonfront.h + blobstorage_syncfull.cpp + blobstorage_syncfull.h + blobstorage_syncfullhandler.cpp + blobstorage_syncfullhandler.h + blobstorage_takedbsnap.h + skeleton_block_and_get.cpp + skeleton_block_and_get.h + skeleton_capturevdisklayout.h + skeleton_compactionstate.cpp + skeleton_compactionstate.h + skeleton_events.h + skeleton_loggedrec.cpp + skeleton_loggedrec.h + skeleton_mon_dbmainpage.cpp + skeleton_mon_dbmainpage.h + skeleton_mon_util.h + skeleton_oos_logic.cpp + skeleton_oos_logic.h + skeleton_oos_tracker.cpp + skeleton_oos_tracker.h + skeleton_overload_handler.cpp + skeleton_overload_handler.h + skeleton_vmultiput_actor.cpp + skeleton_vmultiput_actor.h + skeleton_vmovedpatch_actor.cpp + skeleton_vmovedpatch_actor.h + skeleton_vpatch_actor.cpp + skeleton_vpatch_actor.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/syncer/ut/ya.make b/ydb/core/blobstorage/vdisk/syncer/ut/ya.make new file mode 100644 index 00000000000..8844b2aeafd --- /dev/null +++ b/ydb/core/blobstorage/vdisk/syncer/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/syncer) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage +) + +SRCS( + blobstorage_syncer_data_ut.cpp + blobstorage_syncer_localwriter_ut.cpp + blobstorage_syncquorum_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/syncer/ya.make b/ydb/core/blobstorage/vdisk/syncer/ya.make new file mode 100644 index 00000000000..f8fc07b2150 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/syncer/ya.make @@ -0,0 +1,55 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/vdisk/anubis_osiris + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb/base +) + +SRCS( + defs.h + blobstorage_syncer_committer.cpp + blobstorage_syncer_committer.h + blobstorage_syncer.cpp + blobstorage_syncer_data.cpp + blobstorage_syncer_data.h + blobstorage_syncer_dataserdes.h + blobstorage_syncer_defs.h + blobstorage_syncer.h + blobstorage_syncer_localwriter.cpp + blobstorage_syncer_localwriter.h + blobstorage_syncer_recoverlostdata.cpp + blobstorage_syncer_recoverlostdata.h + blobstorage_syncer_recoverlostdata_proxy.cpp + blobstorage_syncer_recoverlostdata_proxy.h + blobstorage_syncer_scheduler.cpp + blobstorage_syncer_scheduler.h + guid_firstrun.cpp + guid_firstrun.h + guid_propagator.cpp + guid_propagator.h + guid_proxybase.h + guid_proxyobtain.cpp + guid_proxyobtain.h + guid_proxywrite.cpp + guid_proxywrite.h + guid_recovery.cpp + guid_recovery.h + syncer_context.h + syncer_job_actor.cpp + syncer_job_actor.h + syncer_job_task.cpp + syncer_job_task.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/synclog/ut/ya.make b/ydb/core/blobstorage/vdisk/synclog/ut/ya.make new file mode 100644 index 00000000000..ee21a0ce5c2 --- /dev/null +++ b/ydb/core/blobstorage/vdisk/synclog/ut/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/core/blobstorage/vdisk/synclog) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/testing/unittest + ydb/core/base + ydb/core/blobstorage +) + +SRCS( + blobstorage_synclogdata_ut.cpp + blobstorage_synclogdsk_ut.cpp + blobstorage_synclogkeeper_ut.cpp + blobstorage_synclogmem_ut.cpp + blobstorage_synclogmsgimpl_ut.cpp + blobstorage_synclogmsgwriter_ut.cpp + codecs_ut.cpp +) + +END() diff --git a/ydb/core/blobstorage/vdisk/synclog/ya.make b/ydb/core/blobstorage/vdisk/synclog/ya.make new file mode 100644 index 00000000000..1b3220bc8ea --- /dev/null +++ b/ydb/core/blobstorage/vdisk/synclog/ya.make @@ -0,0 +1,63 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/blockcodecs + library/cpp/codecs + library/cpp/containers/intrusive_avl_tree + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/hulldb/base + ydb/core/blobstorage/vdisk/hulldb/generic + ydb/core/blobstorage/vdisk/ingress + ydb/core/util +) + +SRCS( + blobstorage_synclog.cpp + blobstorage_synclog.h + blobstorage_synclog_private_events.cpp + blobstorage_synclog_private_events.h + blobstorage_synclog_public_events.h + blobstorage_synclogdata.cpp + blobstorage_synclogdata.h + blobstorage_synclogdsk.cpp + blobstorage_synclogdsk.h + blobstorage_synclogformat.cpp + blobstorage_synclogformat.h + blobstorage_syncloghttp.cpp + blobstorage_syncloghttp.h + blobstorage_synclogkeeper.cpp + blobstorage_synclogkeeper.h + blobstorage_synclogkeeper_committer.cpp + blobstorage_synclogkeeper_committer.h + blobstorage_synclogkeeper_state.cpp + blobstorage_synclogkeeper_state.h + blobstorage_synclogmem.cpp + blobstorage_synclogmem.h + blobstorage_synclogmsgimpl.cpp + blobstorage_synclogmsgimpl.h + blobstorage_synclogmsgreader.cpp + blobstorage_synclogmsgreader.h + blobstorage_synclogmsgwriter.cpp + blobstorage_synclogmsgwriter.h + blobstorage_synclogneighbors.cpp + blobstorage_synclogneighbors.h + blobstorage_synclogreader.cpp + blobstorage_synclogreader.h + blobstorage_synclogrecovery.cpp + blobstorage_synclogrecovery.h + blobstorage_synclogwriteparts.h + defs.h + codecs.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/blobstorage/vdisk/ya.make b/ydb/core/blobstorage/vdisk/ya.make new file mode 100644 index 00000000000..61d0aa1a40b --- /dev/null +++ b/ydb/core/blobstorage/vdisk/ya.make @@ -0,0 +1,48 @@ +LIBRARY() + +SRCS( + defs.h + vdisk_actor.cpp + vdisk_actor.h + vdisk_services.h +) + +PEERDIR( + ydb/core/blobstorage/vdisk/anubis_osiris + ydb/core/blobstorage/vdisk/common + ydb/core/blobstorage/vdisk/defrag + ydb/core/blobstorage/vdisk/handoff + ydb/core/blobstorage/vdisk/huge + ydb/core/blobstorage/vdisk/hulldb + ydb/core/blobstorage/vdisk/hullop + ydb/core/blobstorage/vdisk/ingress + ydb/core/blobstorage/vdisk/localrecovery + ydb/core/blobstorage/vdisk/protos + ydb/core/blobstorage/vdisk/query + ydb/core/blobstorage/vdisk/repl + ydb/core/blobstorage/vdisk/scrub + ydb/core/blobstorage/vdisk/skeleton + ydb/core/blobstorage/vdisk/syncer + ydb/core/blobstorage/vdisk/synclog +) + +END() + +RECURSE( + anubis_osiris + common + defrag + handoff + huge + hulldb + hullop + ingress + localrecovery + protos + query + repl + scrub + skeleton + syncer + synclog +) diff --git a/ydb/core/blobstorage/ya.make b/ydb/core/blobstorage/ya.make new file mode 100644 index 00000000000..807b6abe948 --- /dev/null +++ b/ydb/core/blobstorage/ya.make @@ -0,0 +1,55 @@ +LIBRARY() + +SRCS( + defs.h +) + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/base + ydb/core/blobstorage/crypto + ydb/core/blobstorage/dsproxy + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/incrhuge + ydb/core/blobstorage/lwtrace_probes + ydb/core/blobstorage/nodewarden + ydb/core/blobstorage/other + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/storagepoolmon + ydb/core/blobstorage/vdisk +) + +IF (MSVC) + CFLAGS( + /wd4503 + ) +ENDIF() + +END() + +RECURSE( + backpressure + base + crypto + dsproxy + groupinfo + incrhuge + lwtrace_probes + nodewarden + other + pdisk + storagepoolmon + testing + vdisk +) + +RECURSE_FOR_TESTS( + ut_blobstorage + ut_group + ut_mirror3of4 + ut_pdiskfit + ut_testshard + ut_vdisk + ut_vdisk2 +) diff --git a/ydb/core/blockstore/core/ya.make b/ydb/core/blockstore/core/ya.make new file mode 100644 index 00000000000..9fe00ba62f9 --- /dev/null +++ b/ydb/core/blockstore/core/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/protos +) + +SRCS( + blockstore.cpp +) + +END() diff --git a/ydb/core/blockstore/ya.make b/ydb/core/blockstore/ya.make new file mode 100644 index 00000000000..5c90c36a76d --- /dev/null +++ b/ydb/core/blockstore/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +PEERDIR( + ydb/core/blockstore/core +) + +END() diff --git a/ydb/core/client/metadata/ut/ya.make b/ydb/core/client/metadata/ut/ya.make new file mode 100644 index 00000000000..713c32035d6 --- /dev/null +++ b/ydb/core/client/metadata/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(ydb/core/client/metadata) + +SRCS( + functions_metadata_ut.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/client/metadata/ya.make b/ydb/core/client/metadata/ya.make new file mode 100644 index 00000000000..3890f0e0fb0 --- /dev/null +++ b/ydb/core/client/metadata/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + types_metadata.cpp + functions_metadata.cpp +) + +PEERDIR( + ydb/core/protos + ydb/core/scheme_types + ydb/library/yql/minikql/invoke_builtins +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/client/minikql_compile/ut/ya.make b/ydb/core/client/minikql_compile/ut/ya.make new file mode 100644 index 00000000000..ae2024dbf21 --- /dev/null +++ b/ydb/core/client/minikql_compile/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/client/minikql_compile) + +ALLOCATOR(J) + +SRCS( + yql_expr_minikql_compile_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest + library/cpp/threading/future + ydb/core/client/scheme_cache_lib + ydb/core/client/server + ydb/core/tablet + ydb/core/testlib/default + ydb/library/yql/minikql + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/client/minikql_compile/ya.make b/ydb/core/client/minikql_compile/ya.make new file mode 100644 index 00000000000..c26c4ebfb91 --- /dev/null +++ b/ydb/core/client/minikql_compile/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +SRCS( + compile_context.cpp + compile_context.h + compile_result.cpp + compile_result.h + db_key_resolver.cpp + db_key_resolver.h + mkql_compile_service.cpp + yql_expr_minikql.cpp + yql_expr_minikql.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/threading/future + ydb/core/base + ydb/core/engine + ydb/core/kqp/provider + ydb/core/scheme + ydb/library/yql/ast + ydb/library/yql/core + ydb/library/yql/minikql + ydb/library/yql/providers/common/mkql +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/client/minikql_result_lib/ut/ya.make b/ydb/core/client/minikql_result_lib/ut/ya.make new file mode 100644 index 00000000000..33593f6520d --- /dev/null +++ b/ydb/core/client/minikql_result_lib/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/core/client/minikql_result_lib) + +FORK_SUBTESTS() + +TIMEOUT(300) + +SIZE(MEDIUM) + +SRCS( + converter_ut.cpp + objects_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(network:full ram:13) + +END() diff --git a/ydb/core/client/minikql_result_lib/ya.make b/ydb/core/client/minikql_result_lib/ya.make new file mode 100644 index 00000000000..8f01aa5ce8a --- /dev/null +++ b/ydb/core/client/minikql_result_lib/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + objects.h + objects.cpp + converter.h + converter.cpp +) + +PEERDIR( + contrib/libs/protobuf + ydb/core/protos + ydb/core/scheme + ydb/library/mkql_proto/protos + ydb/public/lib/deprecated/kicli +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/client/scheme_cache_lib/ya.make b/ydb/core/client/scheme_cache_lib/ya.make new file mode 100644 index 00000000000..91d39cf89fd --- /dev/null +++ b/ydb/core/client/scheme_cache_lib/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + yql_db_scheme_resolver.h + yql_db_scheme_resolver.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/actors/core + library/cpp/grpc/client + library/cpp/threading/future + ydb/core/base + ydb/core/client/minikql_compile + ydb/core/protos + ydb/core/scheme + ydb/core/tablet + ydb/core/tx +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/client/server/ut/ya.make b/ydb/core/client/server/ut/ya.make new file mode 100644 index 00000000000..38886218782 --- /dev/null +++ b/ydb/core/client/server/ut/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/core/client/server) + +FORK_SUBTESTS() + +SPLIT_FACTOR(20) + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/testing/gmock_in_unittest + ydb/core/persqueue + ydb/core/tablet_flat + ydb/core/testlib/default + ydb/core/testlib/actors +) + +YQL_LAST_ABI_VERSION() + +SRCS( + msgbus_server_pq_metarequest_ut.cpp +) + +END() diff --git a/ydb/core/client/server/ya.make b/ydb/core/client/server/ya.make new file mode 100644 index 00000000000..b02436d2863 --- /dev/null +++ b/ydb/core/client/server/ya.make @@ -0,0 +1,107 @@ +LIBRARY() + +SRCS( + document_conversion.h + http_ping.cpp + http_ping.h + msgbus_blobstorage_config.cpp + msgbus_bsadm.cpp + msgbus_http_server.h + msgbus_http_server.cpp + msgbus_server.cpp + msgbus_server.h + msgbus_server_cms.cpp + msgbus_server_configdummy.cpp + msgbus_server_console.cpp + msgbus_server_db.cpp + msgbus_server_drain_node.cpp + msgbus_server_fill_node.cpp + msgbus_server_get.cpp + msgbus_server_hive_create_tablet.cpp + msgbus_server_keyvalue.cpp + msgbus_server_persqueue.cpp + msgbus_server_persqueue.h + msgbus_server_pq_metacache.h + msgbus_server_pq_metacache.cpp + msgbus_server_pq_metarequest.h + msgbus_server_pq_metarequest.cpp + msgbus_server_pq_read_session_info.cpp + msgbus_server_resolve_node.cpp + msgbus_server_ic_debug.cpp + msgbus_server_load.cpp + msgbus_server_local_enumerate_tablets.cpp + msgbus_server_local_minikql.cpp + msgbus_server_local_scheme_tx.cpp + msgbus_server_login_request.cpp + msgbus_server_node_registration.cpp + msgbus_server_proxy.cpp + msgbus_server_proxy.h + msgbus_server_request.cpp + msgbus_server_request.h + msgbus_server_scheme_initroot.cpp + msgbus_server_scheme_request.cpp + msgbus_server_sqs.cpp + msgbus_server_tablet_counters.cpp + msgbus_server_tablet_kill.cpp + msgbus_server_tablet_state.cpp + msgbus_server_test_shard_request.cpp + msgbus_server_tracer.cpp + msgbus_server_tracer.h + msgbus_server_tx_request.cpp + msgbus_server_types.cpp + msgbus_server_whoami.cpp + msgbus_servicereq.h + msgbus_tabletreq.h + grpc_server.cpp + grpc_server.h + grpc_proxy_status.h + grpc_proxy_status.cpp +) + +PEERDIR( + library/cpp/actors/helpers + library/cpp/json + library/cpp/messagebus + library/cpp/messagebus/protobuf + library/cpp/monlib/messagebus + library/cpp/protobuf/json + library/cpp/protobuf/util + library/cpp/threading/future + ydb/core/actorlib_impl + ydb/core/base + ydb/core/blobstorage/base + ydb/core/client/metadata + ydb/core/client/scheme_cache_lib + ydb/core/engine + ydb/core/engine/minikql + ydb/core/grpc_services + ydb/core/grpc_services/auth_processor + ydb/core/grpc_services/base + ydb/core/keyvalue + ydb/core/kqp/common + ydb/core/node_whiteboard + ydb/core/persqueue + ydb/core/persqueue/writer + ydb/core/protos + ydb/core/scheme + ydb/core/ydb_convert + ydb/core/ymq/actor + ydb/library/aclib + ydb/library/persqueue/topic_parser + ydb/public/api/protos + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/lib/base + ydb/public/lib/deprecated/client + ydb/public/lib/deprecated/kicli + ydb/services/persqueue_v1 + library/cpp/deprecated/atomic +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/client/ut/ya.make b/ydb/core/client/ut/ya.make new file mode 100644 index 00000000000..dac55784f3c --- /dev/null +++ b/ydb/core/client/ut/ya.make @@ -0,0 +1,45 @@ +UNITTEST_FOR(ydb/core/client) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + REQUIREMENTS( + cpu:4 + ram:32 + ) + TAG(ya:fat) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/client/scheme_cache_lib + ydb/core/tablet_flat/test/libs/rows + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +INCLUDE(${ARCADIA_ROOT}/ydb/tests/supp/ubsan_supp.inc) + +SRCS( + cancel_tx_ut.cpp + client_ut.cpp + flat_ut.cpp + locks_ut.cpp + query_stats_ut.cpp +) + +END() diff --git a/ydb/core/client/ya.make b/ydb/core/client/ya.make new file mode 100644 index 00000000000..9af98a75117 --- /dev/null +++ b/ydb/core/client/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +PEERDIR( + library/cpp/grpc/server + ydb/core/base + ydb/core/client/scheme_cache_lib + ydb/core/client/server + ydb/core/engine + ydb/public/lib/deprecated/kicli +) + +END() + +RECURSE( + metadata + minikql_compile + minikql_result_lib + scheme_cache_lib + server +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/cms/console/ut/ya.make b/ydb/core/cms/console/ut/ya.make new file mode 100644 index 00000000000..2daf90fac99 --- /dev/null +++ b/ydb/core/cms/console/ut/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/cms/console) + +FORK_SUBTESTS() + +TIMEOUT(600) +SIZE(MEDIUM) +REQUIREMENTS(ram:16) + +PEERDIR( + library/cpp/getopt + library/cpp/protobuf/util + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + configs_cache_ut.cpp + configs_dispatcher_ut.cpp + console_ut_tenants.cpp + console_ut_configs.cpp + immediate_controls_configurator_ut.cpp + log_settings_configurator_ut.cpp + modifications_validator_ut.cpp + net_classifier_updater_ut.cpp +) + +END() diff --git a/ydb/core/cms/console/util/ya.make b/ydb/core/cms/console/util/ya.make new file mode 100644 index 00000000000..52af3f8ff6c --- /dev/null +++ b/ydb/core/cms/console/util/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + config_index.cpp + config_index.h + defs.h +) + +PEERDIR( + ydb/core/base + ydb/core/protos +) + +END() diff --git a/ydb/core/cms/console/validators/ut/ya.make b/ydb/core/cms/console/validators/ut/ya.make new file mode 100644 index 00000000000..9850bc1acac --- /dev/null +++ b/ydb/core/cms/console/validators/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(ydb/core/cms/console/validators) + +FORK_SUBTESTS() + +TIMEOUT(600) +SIZE(MEDIUM) + +PEERDIR( + library/cpp/testing/unittest +) + +SRCS( + registry_ut.cpp + validator_bootstrap_ut.cpp + validator_nameservice_ut.cpp + validator_ut_common.h +) + +END() diff --git a/ydb/core/cms/console/validators/ya.make b/ydb/core/cms/console/validators/ya.make new file mode 100644 index 00000000000..47dd443e56f --- /dev/null +++ b/ydb/core/cms/console/validators/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +SRCS( + core_validators.cpp + core_validators.h + registry.cpp + registry.h + validator.cpp + validator.h + validator_bootstrap.cpp + validator_bootstrap.h + validator_nameservice.cpp + validator_nameservice.h +) + +PEERDIR( + ydb/core/base + ydb/core/protos + ydb/core/tablet + ydb/public/api/protos + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/cms/console/ya.make b/ydb/core/cms/console/ya.make new file mode 100644 index 00000000000..722a02e0701 --- /dev/null +++ b/ydb/core/cms/console/ya.make @@ -0,0 +1,108 @@ +LIBRARY() + +SRCS( + config_helpers.cpp + config_helpers.h + configs_cache.cpp + configs_cache.h + configs_config.cpp + configs_config.h + configs_dispatcher.cpp + configs_dispatcher.h + console.cpp + console.h + console_configs_manager.cpp + console_configs_manager.h + console_configs_provider.cpp + console_configs_provider.h + console_configs_subscriber.cpp + console_configs_subscriber.h + console_impl.h + console_tenants_manager.cpp + console_tenants_manager.h + console__add_config_subscription.cpp + console__alter_tenant.cpp + console__replace_yaml_config.cpp + console__set_yaml_config.cpp + console__cleanup_subscriptions.cpp + console__configure.cpp + console__create_tenant.cpp + console__drop_yaml_config.cpp + console__init_scheme.cpp + console__load_state.cpp + console__get_log_tail.cpp + console__get_yaml_config.cpp + console__get_yaml_metadata.cpp + console__log_cleanup.cpp + console__remove_computational_units.cpp + console__remove_config_subscription.cpp + console__remove_config_subscriptions.cpp + console__remove_tenant.cpp + console__remove_tenant_done.cpp + console__remove_tenant_failed.cpp + console__replace_config_subscriptions.cpp + console__revert_pool_state.cpp + console__scheme.h + console__set_config.cpp + console__toggle_config_validator.cpp + console__update_confirmed_subdomain.cpp + console__update_last_provided_config.cpp + console__update_pool_state.cpp + console__update_subdomain_key.cpp + console__update_tenant_state.cpp + console__update_tenant_pool_config.cpp + defs.h + grpc_library_helper.cpp + http.cpp + http.h + immediate_controls_configurator.cpp + immediate_controls_configurator.h + log_settings_configurator.cpp + log_settings_configurator.h + logger.cpp + logger.h + modifications_validator.cpp + modifications_validator.h + net_classifier_updater.cpp + shared_cache_configurator.cpp + shared_cache_configurator.h + tx_processor.cpp + tx_processor.h + util.cpp + util.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/http + ydb/core/actorlib_impl + ydb/core/base + ydb/core/blobstorage + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/cms/console/validators + ydb/core/cms/console/yaml_config + ydb/core/control + ydb/core/engine/minikql + ydb/core/mind + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/util + ydb/library/aclib + ydb/public/api/protos + ydb/public/lib/operation_id +) + +END() + +RECURSE( + util + validators + yaml_config +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/cms/console/yaml_config/ut/ya.make b/ydb/core/cms/console/yaml_config/ut/ya.make new file mode 100644 index 00000000000..709eb049a3a --- /dev/null +++ b/ydb/core/cms/console/yaml_config/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(ydb/core/cms/console/yaml_config) + +SRCS( + console_dumper_ut.cpp + yaml_config_ut.cpp +) + +END() diff --git a/ydb/core/cms/console/yaml_config/ya.make b/ydb/core/cms/console/yaml_config/ya.make new file mode 100644 index 00000000000..8fd2c5c6906 --- /dev/null +++ b/ydb/core/cms/console/yaml_config/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + console_dumper.cpp + console_dumper.h + yaml_config.cpp + yaml_config.h + yaml_config_impl.h +) + +PEERDIR( + contrib/libs/openssl + library/cpp/actors/core + library/cpp/protobuf/json + library/cpp/yaml/fyamlcpp + ydb/core/cms/console/util + ydb/core/protos + ydb/library/yaml_config +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/cms/ut/ya.make b/ydb/core/cms/ut/ya.make new file mode 100644 index 00000000000..b296d314a4e --- /dev/null +++ b/ydb/core/cms/ut/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/cms) + +SPLIT_FACTOR(30) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + cluster_info_ut.cpp + cms_ut.cpp + cms_tenants_ut.cpp + cms_ut_common.cpp + cms_ut_common.h + downtime_ut.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/cms/ut_sentinel/ya.make b/ydb/core/cms/ut_sentinel/ya.make new file mode 100644 index 00000000000..9964a40c2b2 --- /dev/null +++ b/ydb/core/cms/ut_sentinel/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/cms) + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + cms_ut_common.cpp + cms_ut_common.h + sentinel_ut.cpp +) + +END() diff --git a/ydb/core/cms/ya.make b/ydb/core/cms/ya.make new file mode 100644 index 00000000000..83ea42eaff7 --- /dev/null +++ b/ydb/core/cms/ya.make @@ -0,0 +1,142 @@ +LIBRARY() + +SRCS( + audit_log.cpp + base_handler.h + cluster_info.cpp + cluster_info.h + cms.cpp + cms.h + cms_impl.h + cms_state.h + cms_tx_get_log_tail.cpp + cms_tx_init_scheme.cpp + cms_tx_load_state.cpp + cms_tx_log_and_send.cpp + cms_tx_log_cleanup.cpp + cms_tx_process_notification.cpp + cms_tx_reject_notification.cpp + cms_tx_remove_expired_notifications.cpp + cms_tx_remove_permissions.cpp + cms_tx_remove_request.cpp + cms_tx_remove_walle_task.cpp + cms_tx_store_permissions.cpp + cms_tx_store_walle_task.cpp + cms_tx_update_config.cpp + cms_tx_update_downtimes.cpp + defs.h + downtime.h + downtime.cpp + erasure_checkers.h + erasure_checkers.cpp + http.cpp + http.h + info_collector.cpp + info_collector.h + json_proxy.h + json_proxy_config_items.h + json_proxy_config_updates.h + json_proxy_config_validators.h + json_proxy_console_log.h + json_proxy_log.h + json_proxy_operations.h + json_proxy_proto.h + json_proxy_sentinel.h + json_proxy_toggle_config_validator.h + logger.cpp + logger.h + node_checkers.cpp + node_checkers.h + log_formatter.h + pdiskid.h + scheme.h + sentinel.cpp + services.cpp + walle.h + walle_api_handler.cpp + walle_check_task_adapter.cpp + walle_create_task_adapter.cpp + walle_list_tasks_adapter.cpp + walle_remove_task_adapter.cpp +) + +RESOURCE( + ui/index.html cms/ui/index.html + ui/cms.css cms/ui/cms.css + ui/cms.js cms/ui/cms.js + ui/config_dispatcher.css cms/ui/config_dispatcher.css + ui/cms_log.js cms/ui/cms_log.js + ui/console_log.js cms/ui/console_log.js + ui/common.css cms/ui/common.css + ui/common.js cms/ui/common.js + ui/configs.js cms/ui/configs.js + ui/yaml_config.js cms/ui/yaml_config.js + ui/config_forms.js cms/ui/config_forms.js + ui/datashard.css cms/ui/datashard.css + ui/datashard.js cms/ui/datashard.js + ui/datashard_hist.js cms/ui/datashard_hist.js + ui/datashard_info.js cms/ui/datashard_info.js + ui/datashard_op.js cms/ui/datashard_op.js + ui/datashard_ops_list.js cms/ui/datashard_ops_list.js + ui/datashard_rs.js cms/ui/datashard_rs.js + ui/datashard_slow_ops.js cms/ui/datashard_slow_ops.js + ui/enums.js cms/ui/enums.js + ui/ext/bootstrap.min.css cms/ui/ext/bootstrap.min.css + ui/ext/fuzzycomplete.min.css cms/ui/ext/fuzzycomplete.min.css + ui/ext/fuzzycomplete.min.js cms/ui/ext/fuzzycomplete.min.js + ui/ext/fuse.min.js cms/ui/ext/fuse.min.js + ui/ext/document-copy.svg cms/ui/ext/document-copy.svg + ui/ext/unfold-less.svg cms/ui/ext/unfold-less.svg + ui/ext/unfold-more.svg cms/ui/ext/unfold-more.svg + ui/ext/1-circle.svg cms/ui/ext/1-circle.svg + ui/ext/link.svg cms/ui/ext/link.svg + ui/ext/gear.svg cms/ui/ext/gear.svg + ui/ext/require.min.js cms/ui/ext/require.min.js + ui/ext/jquery.min.js cms/ui/ext/jquery.min.js + ui/main.js cms/ui/main.js + ui/configs_dispatcher_main.js cms/ui/configs_dispatcher_main.js + ui/ext/question-circle.svg cms/ui/ext/question-circle.svg + ui/ext/bootstrap.bundle.min.js cms/ui/ext/bootstrap.bundle.min.js + ui/ext/theme.blue.css cms/ui/ext/theme.blue.css + ui/proto_types.js cms/ui/proto_types.js + ui/res/edit.png cms/ui/res/edit.png + ui/res/help.png cms/ui/res/help.png + ui/res/remove.png cms/ui/res/remove.png + ui/validators.js cms/ui/validators.js + ui/sentinel_state.js cms/ui/sentinel_state.js + ui/nanotable.js cms/ui/nanotable.js + ui/sentinel.css cms/ui/sentinel.css +) + +PEERDIR( + library/cpp/actors/core + ydb/core/actorlib_impl + ydb/core/base + ydb/core/blobstorage + ydb/core/blobstorage/base + ydb/core/blobstorage/crypto + ydb/core/engine/minikql + ydb/core/mind + ydb/core/mind/bscontroller + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/protos/out + ydb/core/tablet_flat + ydb/core/tx/datashard + ydb/library/aclib +) + +GENERATE_ENUM_SERIALIZATION(services.h) +GENERATE_ENUM_SERIALIZATION(node_checkers.h) + + +END() + +RECURSE( + console +) + +RECURSE_FOR_TESTS( + ut + ut_sentinel +) diff --git a/ydb/core/control/ut/ya.make b/ydb/core/control/ut/ya.make new file mode 100644 index 00000000000..cace976783e --- /dev/null +++ b/ydb/core/control/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/control) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/testing/unittest + util + ydb/core/base + ydb/core/mind + ydb/core/mon +) + +SRCS( + immediate_control_board_ut.cpp + immediate_control_board_actor_ut.cpp +) + +END() diff --git a/ydb/core/control/ya.make b/ydb/core/control/ya.make new file mode 100644 index 00000000000..1f93e93f799 --- /dev/null +++ b/ydb/core/control/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/dynamic_counters + util + ydb/core/base + ydb/core/mon + ydb/core/node_whiteboard + library/cpp/deprecated/atomic +) + +SRCS( + defs.h + immediate_control_board_actor.cpp + immediate_control_board_actor.h + immediate_control_board_control.cpp + immediate_control_board_control.h + immediate_control_board_impl.cpp + immediate_control_board_impl.h + immediate_control_board_wrapper.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/debug/ya.make b/ydb/core/debug/ya.make new file mode 100644 index 00000000000..107d3c6edf7 --- /dev/null +++ b/ydb/core/debug/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +SRCS( + valgrind_check.h + valgrind_check.cpp +) + +END() diff --git a/ydb/core/debug_tools/ut/ya.make b/ydb/core/debug_tools/ut/ya.make new file mode 100644 index 00000000000..1c971eea8be --- /dev/null +++ b/ydb/core/debug_tools/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST() + + TIMEOUT(60) + SIZE(SMALL) + + PEERDIR( + ydb/core/debug_tools + ) + + SRCS( + main.cpp + ) + +END() diff --git a/ydb/core/debug_tools/ya.make b/ydb/core/debug_tools/ya.make new file mode 100644 index 00000000000..a7ea227d594 --- /dev/null +++ b/ydb/core/debug_tools/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + util +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/discovery/ya.make b/ydb/core/discovery/ya.make new file mode 100644 index 00000000000..66e478564c0 --- /dev/null +++ b/ydb/core/discovery/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + discovery.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/tx/scheme_cache + library/cpp/actors/core +) + +END() diff --git a/ydb/core/docapi/ya.make b/ydb/core/docapi/ya.make new file mode 100644 index 00000000000..917627768e8 --- /dev/null +++ b/ydb/core/docapi/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + traits.cpp +) + +PEERDIR( +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/driver_lib/base_utils/ya.make b/ydb/core/driver_lib/base_utils/ya.make new file mode 100644 index 00000000000..57bb1f1e143 --- /dev/null +++ b/ydb/core/driver_lib/base_utils/ya.make @@ -0,0 +1,25 @@ +LIBRARY(base_utils) + +SRCS( + base_utils.h + format_info.h + format_info.cpp + format_util.h + format_util.cpp + node_by_host.h + node_by_host.cpp +) + +PEERDIR( + library/cpp/deprecated/enum_codegen + library/cpp/grpc/client + ydb/core/blobstorage/pdisk + ydb/core/client/server + ydb/core/driver_lib/cli_config_base + ydb/core/protos + ydb/public/lib/deprecated/client +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/driver_lib/cli_base/ya.make b/ydb/core/driver_lib/cli_base/ya.make new file mode 100644 index 00000000000..8f97652bd55 --- /dev/null +++ b/ydb/core/driver_lib/cli_base/ya.make @@ -0,0 +1,22 @@ +LIBRARY(cli_base) + +SRCS( + cli_cmds_db.cpp + cli_cmds_discovery.cpp + cli_cmds_root.cpp + cli_cmds_whoami.cpp + cli_kicli.cpp +) + +PEERDIR( + ydb/core/driver_lib/cli_config_base + ydb/library/aclib + ydb/public/lib/deprecated/kicli + ydb/public/lib/ydb_cli/common + ydb/public/sdk/cpp/client/resources + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/driver_lib/cli_config_base/ya.make b/ydb/core/driver_lib/cli_config_base/ya.make new file mode 100644 index 00000000000..c776daaa0d9 --- /dev/null +++ b/ydb/core/driver_lib/cli_config_base/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + config_base.h + config_base.cpp +) + +PEERDIR( + library/cpp/deprecated/enum_codegen + ydb/core/util + ydb/public/lib/deprecated/client + ydb/library/yql/minikql +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/driver_lib/cli_utils/ya.make b/ydb/core/driver_lib/cli_utils/ya.make new file mode 100644 index 00000000000..177978e775b --- /dev/null +++ b/ydb/core/driver_lib/cli_utils/ya.make @@ -0,0 +1,67 @@ +LIBRARY(cli_utils) + +SRCS( + cli.cpp + cli.h + cli_actorsystem_perftest.cpp + cli_cmd_config.h + cli_cmd_config.cpp + cli_cmds.h + cli_cmds_admin.cpp + cli_cmds_bs.cpp + cli_cmds_cms.cpp + cli_cmds_config.cpp + cli_cmds_console.cpp + cli_cmds_debug.cpp + cli_cmds_disk.cpp + cli_cmds_genconfig.cpp + cli_cmds_get.cpp + cli_cmds_group.cpp + cli_cmds_node.cpp + cli_cmds_root.cpp + cli_cmds_server.cpp + cli_cmds_tablet.cpp + cli_cmds_tenant.cpp + cli_fakeinitshard.cpp + cli_keyvalue.cpp + cli_persqueue.cpp + cli_persqueue_cluster_discovery.cpp + cli_persqueue_stress.cpp + cli_load.cpp + cli_minikql_compile_and_exec.cpp + cli_mb_trace.cpp + cli_scheme_cache_append.cpp + cli_scheme_initroot.cpp +) + +PEERDIR( + library/cpp/deprecated/enum_codegen + library/cpp/grpc/client + library/cpp/protobuf/json + library/cpp/yson + ydb/core/actorlib_impl + ydb/core/base + ydb/core/blobstorage/pdisk + ydb/core/client/minikql_compile + ydb/core/client/scheme_cache_lib + ydb/core/cms/console/yaml_config + ydb/core/driver_lib/cli_base + ydb/core/engine + ydb/core/erasure + ydb/core/mind/bscontroller + ydb/core/protos + ydb/core/scheme + ydb/library/aclib + ydb/library/folder_service/proto + ydb/library/yaml_config + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/lib/deprecated/client + ydb/public/lib/ydb_cli/common + ydb/public/sdk/cpp/client/ydb_discovery + ydb/public/sdk/cpp/client/ydb_driver +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/driver_lib/run/ya.make b/ydb/core/driver_lib/run/ya.make new file mode 100644 index 00000000000..e29db37d9a0 --- /dev/null +++ b/ydb/core/driver_lib/run/ya.make @@ -0,0 +1,168 @@ +LIBRARY(run) + +IF (PROFILE_MEMORY_ALLOCATIONS) + CFLAGS( + -DPROFILE_MEMORY_ALLOCATIONS + ) +ENDIF() + +SRCS( + config.cpp + config.h + config_parser.cpp + config_parser.h + driver.h + dummy.cpp + dummy.h + factories.h + factories.cpp + kikimr_services_initializers.cpp + kikimr_services_initializers.h + main.h + main.cpp + run.cpp + run.h + service_initializer.cpp + service_initializer.h + cert_auth_props.h + cert_auth_props.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/actors/core + library/cpp/actors/dnsresolver + library/cpp/actors/interconnect + library/cpp/actors/memory_log + library/cpp/actors/prof + library/cpp/actors/protos + library/cpp/actors/util + library/cpp/getopt/small + library/cpp/grpc/client + library/cpp/grpc/server + library/cpp/grpc/server/actors + library/cpp/logger + library/cpp/malloc/api + library/cpp/messagebus + library/cpp/monlib/dynamic_counters + library/cpp/monlib/messagebus + library/cpp/sighandler + library/cpp/string_utils/parse_size + library/cpp/svnversion + ydb/core/actorlib_impl + ydb/core/audit + ydb/core/base + ydb/core/blob_depot + ydb/core/blobstorage + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/nodewarden + ydb/core/blobstorage/other + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/vdisk/common + ydb/core/client/minikql_compile + ydb/core/client/scheme_cache_lib + ydb/core/client/server + ydb/core/cms + ydb/core/cms/console + ydb/core/control + ydb/core/driver_lib/base_utils + ydb/core/driver_lib/cli_config_base + ydb/core/driver_lib/cli_utils + ydb/core/driver_lib/version + ydb/core/formats + ydb/core/fq/libs/init + ydb/core/fq/libs/logs + ydb/core/grpc_services + ydb/core/grpc_services/base + ydb/core/grpc_services/auth_processor + ydb/core/health_check + ydb/core/http_proxy + ydb/core/kesus/proxy + ydb/core/kesus/tablet + ydb/core/keyvalue + ydb/core/kqp + ydb/core/kqp/rm_service + ydb/core/load_test + ydb/core/local_pgwire + ydb/core/log_backend + ydb/core/metering + ydb/core/mind + ydb/core/mind/address_classification + ydb/core/mind/bscontroller + ydb/core/mind/hive + ydb/core/mon + ydb/core/mon_alloc + ydb/core/node_whiteboard + ydb/core/persqueue + ydb/core/protos + ydb/core/public_http + ydb/core/quoter + ydb/core/scheme + ydb/core/scheme_types + ydb/core/security + ydb/core/sys_view/processor + ydb/core/sys_view/service + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/test_tablet + ydb/core/tracing + ydb/core/tx + ydb/core/tx/columnshard + ydb/core/tx/coordinator + ydb/core/tx/conveyor/service + ydb/core/tx/datashard + ydb/core/tx/long_tx_service + ydb/core/tx/long_tx_service/public + ydb/core/tx/mediator + ydb/core/tx/replication/controller + ydb/core/tx/replication/service + ydb/core/tx/scheme_board + ydb/core/tx/schemeshard + ydb/core/tx/sequenceproxy + ydb/core/tx/sequenceshard + ydb/core/tx/time_cast + ydb/core/tx/tx_allocator + ydb/core/tx/tx_proxy + ydb/core/util + ydb/core/viewer + ydb/core/ymq/actor + ydb/core/ymq/http + ydb/library/folder_service + ydb/library/folder_service/proto + ydb/library/pdisk_io + ydb/library/security + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/providers/pq/cm_client + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/base + ydb/public/lib/deprecated/client + ydb/services/auth + ydb/services/cms + ydb/services/dynamic_config + ydb/services/datastreams + ydb/services/discovery + ydb/services/fq + ydb/services/kesus + ydb/services/local_discovery + ydb/services/metadata/ds_table + ydb/services/metadata + ydb/services/bg_tasks/ds_table + ydb/services/bg_tasks + ydb/services/ext_index/service + ydb/services/ext_index/metadata + ydb/services/monitoring + ydb/services/persqueue_cluster_discovery + ydb/services/persqueue_v1 + ydb/services/rate_limiter + ydb/services/ydb +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_ROOT_RELATIVE( + ydb/core + ydb/services +) diff --git a/ydb/core/driver_lib/version/ut/ya.make b/ydb/core/driver_lib/version/ut/ya.make new file mode 100644 index 00000000000..9378ab78d17 --- /dev/null +++ b/ydb/core/driver_lib/version/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(ydb/core/driver_lib/version) + +SRCS(version_ut.cpp) + +PEERDIR( + contrib/libs/protobuf + library/cpp/actors/interconnect + library/cpp/svnversion + ydb/core/protos +) + +END() diff --git a/ydb/core/driver_lib/version/ya.make b/ydb/core/driver_lib/version/ya.make new file mode 100644 index 00000000000..7e6860bc568 --- /dev/null +++ b/ydb/core/driver_lib/version/ya.make @@ -0,0 +1,19 @@ +LIBRARY(version) + +SRCS( + version.cpp + version.h +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/actors/interconnect + library/cpp/svnversion + ydb/core/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/driver_lib/ya.make b/ydb/core/driver_lib/ya.make new file mode 100644 index 00000000000..394fbc079fb --- /dev/null +++ b/ydb/core/driver_lib/ya.make @@ -0,0 +1,8 @@ +RECURSE( + base_utils + cli_base + cli_config_base + cli_utils + run + version +) diff --git a/ydb/core/engine/minikql/ya.make b/ydb/core/engine/minikql/ya.make new file mode 100644 index 00000000000..6b7c76b2105 --- /dev/null +++ b/ydb/core/engine/minikql/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + flat_local_minikql_host.h + flat_local_tx_factory.cpp + minikql_engine_host.cpp + minikql_engine_host.h +) + +PEERDIR( + ydb/core/base + ydb/core/client/minikql_compile + ydb/core/engine + ydb/core/formats + ydb/core/tablet_flat + ydb/library/yql/parser/pg_wrapper/interface +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/engine/ut/ya.make b/ydb/core/engine/ut/ya.make new file mode 100644 index 00000000000..ad85196df68 --- /dev/null +++ b/ydb/core/engine/ut/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/engine) + +ALLOCATOR(J) + +FORK_SUBTESTS() + +TIMEOUT(150) + +SIZE(MEDIUM) + +SRCS( + mkql_engine_flat_host_ut.cpp + mkql_engine_flat_ut.cpp + kikimr_program_builder_ut.cpp + mkql_proto_ut.cpp +) + +PEERDIR( + ydb/core/engine/minikql + ydb/core/kqp/ut/common + ydb/core/tablet_flat/test/libs/table + ydb/library/mkql_proto/ut/helpers + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/engine/ya.make b/ydb/core/engine/ya.make new file mode 100644 index 00000000000..6ab729b8aa6 --- /dev/null +++ b/ydb/core/engine/ya.make @@ -0,0 +1,42 @@ +LIBRARY() + +SRCS( + kikimr_program_builder.cpp + mkql_engine_flat.cpp + mkql_engine_flat_extfunc.cpp + mkql_engine_flat_host.cpp + mkql_keys.cpp + mkql_proto.cpp + mkql_proto.h +) + +PEERDIR( + library/cpp/containers/stack_vector + library/cpp/deprecated/enum_codegen + library/cpp/random_provider + library/cpp/time_provider + ydb/core/base + ydb/core/scheme + ydb/core/tablet + ydb/library/mkql_proto + ydb/library/mkql_proto/protos + ydb/library/mkql_proto/ut/helpers + ydb/public/api/protos + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/public/decimal +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + minikql +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/erasure/ut/ya.make b/ydb/core/erasure/ut/ya.make new file mode 100644 index 00000000000..50ad6c6ccbe --- /dev/null +++ b/ydb/core/erasure/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/core/erasure) + +FORK_SUBTESTS() +SPLIT_FACTOR(30) + +IF (WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/digest/crc32c +) + +SRCS( + erasure_ut.cpp +) + +END() diff --git a/ydb/core/erasure/ut_perf/ya.make b/ydb/core/erasure/ut_perf/ya.make new file mode 100644 index 00000000000..8c785cb5a3e --- /dev/null +++ b/ydb/core/erasure/ut_perf/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(ydb/core/erasure) + +SIZE(SMALL) + +SRCS( + erasure_perf_test.cpp +) + +END() diff --git a/ydb/core/erasure/ut_rope/ya.make b/ydb/core/erasure/ut_rope/ya.make new file mode 100644 index 00000000000..f9aa93a77e5 --- /dev/null +++ b/ydb/core/erasure/ut_rope/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/core/erasure) + +FORK_SUBTESTS() + +SPLIT_FACTOR(30) + +IF (WITH_VALGRIND OR SANITIZER_TYPE == "thread") + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/digest/crc32c + ydb/core/erasure +) + +SRCS( + erasure_rope_ut.cpp +) + +END() diff --git a/ydb/core/erasure/ya.make b/ydb/core/erasure/ya.make new file mode 100644 index 00000000000..b585183a272 --- /dev/null +++ b/ydb/core/erasure/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + erasure.cpp + erasure.h + erasure_rope.cpp + erasure_rope.h + erasure_perf_test.cpp +) + +PEERDIR( + library/cpp/actors/util + library/cpp/containers/stack_vector + library/cpp/digest/crc32c + library/cpp/digest/old_crc + ydb/core/debug +) + +IF (MSVC) + CFLAGS( + /wd4503 + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut + ut_rope + ut_perf +) diff --git a/ydb/core/external_sources/ut/ya.make b/ydb/core/external_sources/ut/ya.make new file mode 100644 index 00000000000..66515b54f3f --- /dev/null +++ b/ydb/core/external_sources/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(ydb/core/external_sources) + +PEERDIR( + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +SRCS( + object_storage_ut.cpp +) + +END() diff --git a/ydb/core/external_sources/ya.make b/ydb/core/external_sources/ya.make new file mode 100644 index 00000000000..27cc4665082 --- /dev/null +++ b/ydb/core/external_sources/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + external_source_factory.cpp + object_storage.cpp +) + +PEERDIR( + library/cpp/scheme + ydb/core/base + ydb/core/protos + ydb/library/yql/providers/s3/path_generator + ydb/public/sdk/cpp/client/ydb_params + ydb/public/sdk/cpp/client/ydb_value +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/filestore/core/ya.make b/ydb/core/filestore/core/ya.make new file mode 100644 index 00000000000..b8242112d6b --- /dev/null +++ b/ydb/core/filestore/core/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/protos +) + +SRCS( + filestore.cpp +) + +END() diff --git a/ydb/core/filestore/ya.make b/ydb/core/filestore/ya.make new file mode 100644 index 00000000000..e8817e293c2 --- /dev/null +++ b/ydb/core/filestore/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +PEERDIR( + ydb/core/filestore/core +) + +END() diff --git a/ydb/core/formats/arrow/common/ya.make b/ydb/core/formats/arrow/common/ya.make new file mode 100644 index 00000000000..bf6f79458a5 --- /dev/null +++ b/ydb/core/formats/arrow/common/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow +) + +SRCS( + validation.cpp +) + +END() diff --git a/ydb/core/formats/arrow/compression/ya.make b/ydb/core/formats/arrow/compression/ya.make new file mode 100644 index 00000000000..420b028e3f2 --- /dev/null +++ b/ydb/core/formats/arrow/compression/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + diff.cpp + object.cpp + parsing.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/formats/arrow + ydb/library/conclusion +) + +END() diff --git a/ydb/core/formats/arrow/dictionary/ya.make b/ydb/core/formats/arrow/dictionary/ya.make new file mode 100644 index 00000000000..a48034f221d --- /dev/null +++ b/ydb/core/formats/arrow/dictionary/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/formats/arrow/simple_builder + ydb/core/formats/arrow/switch +) + +SRCS( + conversion.cpp + object.cpp + diff.cpp +) + +END() diff --git a/ydb/core/formats/arrow/serializer/ya.make b/ydb/core/formats/arrow/serializer/ya.make new file mode 100644 index 00000000000..32c0c0bab6a --- /dev/null +++ b/ydb/core/formats/arrow/serializer/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/formats/arrow/common + library/cpp/actors/core + ydb/core/protos +) + +SRCS( + abstract.cpp + full.cpp + batch_only.cpp + stream.cpp +) + +END() diff --git a/ydb/core/formats/arrow/simple_builder/ya.make b/ydb/core/formats/arrow/simple_builder/ya.make new file mode 100644 index 00000000000..81b8ddf86d7 --- /dev/null +++ b/ydb/core/formats/arrow/simple_builder/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow +) + +SRCS( + filler.cpp + array.cpp + batch.cpp +) + +END() diff --git a/ydb/core/formats/arrow/switch/ya.make b/ydb/core/formats/arrow/switch/ya.make new file mode 100644 index 00000000000..e3736d0b1a8 --- /dev/null +++ b/ydb/core/formats/arrow/switch/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/scheme_types +) + +SRCS( + switch_type.cpp +) + +END() diff --git a/ydb/core/formats/arrow/transformer/ya.make b/ydb/core/formats/arrow/transformer/ya.make new file mode 100644 index 00000000000..3a1c0c4c12a --- /dev/null +++ b/ydb/core/formats/arrow/transformer/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/formats/arrow/dictionary +) + +SRCS( + abstract.cpp + dictionary.cpp + composite.cpp +) + +END() diff --git a/ydb/core/formats/arrow/ut/ya.make b/ydb/core/formats/arrow/ut/ya.make new file mode 100644 index 00000000000..cd2531b9723 --- /dev/null +++ b/ydb/core/formats/arrow/ut/ya.make @@ -0,0 +1,31 @@ +UNITTEST_FOR(ydb/core/formats/arrow) + +SIZE(SMALL) + +PEERDIR( + contrib/libs/apache/arrow + ydb/library/arrow_kernels + ydb/core/base + + # for NYql::NUdf alloc stuff used in binary_json + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +ADDINCL( + ydb/library/arrow_clickhouse +) + +YQL_LAST_ABI_VERSION() + +CFLAGS( + -Wno-unused-parameter +) + +SRCS( + ut_arrow.cpp + ut_program_step.cpp + ut_dictionary.cpp +) + +END() diff --git a/ydb/core/formats/arrow/ya.make b/ydb/core/formats/arrow/ya.make new file mode 100644 index 00000000000..9e58efb807d --- /dev/null +++ b/ydb/core/formats/arrow/ya.make @@ -0,0 +1,52 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/scheme + ydb/core/formats/arrow/serializer + ydb/core/formats/arrow/simple_builder + ydb/core/formats/arrow/dictionary + ydb/core/formats/arrow/transformer + ydb/library/arrow_kernels + ydb/library/binary_json + ydb/library/dynumber +) + +IF (OS_WINDOWS) + ADDINCL( + ydb/library/yql/udfs/common/clickhouse/client/base + ydb/library/arrow_clickhouse + ) +ELSE() + PEERDIR( + ydb/library/arrow_clickhouse + ) + ADDINCL( + ydb/library/arrow_clickhouse + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +SRCS( + arrow_batch_builder.cpp + arrow_helpers.cpp + arrow_filter.cpp + converter.h + converter.cpp + custom_registry.cpp + input_stream.h + merging_sorted_input_stream.cpp + merging_sorted_input_stream.h + one_batch_input_stream.h + sort_cursor.h + program.cpp + ssa_program_optimizer.cpp + size_calcer.cpp +) + +END() diff --git a/ydb/core/formats/ya.make b/ydb/core/formats/ya.make new file mode 100644 index 00000000000..b52fa6edb64 --- /dev/null +++ b/ydb/core/formats/ya.make @@ -0,0 +1,19 @@ +RECURSE( + arrow +) + +LIBRARY() + +PEERDIR( + ydb/core/scheme +) + +YQL_LAST_ABI_VERSION() + +SRCS( + clickhouse_block.h + clickhouse_block.cpp + factory.h +) + +END() diff --git a/ydb/core/fq/libs/actors/logging/ya.make b/ydb/core/fq/libs/actors/logging/ya.make new file mode 100644 index 00000000000..6574054f880 --- /dev/null +++ b/ydb/core/fq/libs/actors/logging/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + log.h +) + +PEERDIR( + library/cpp/actors/core + ydb/core/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/actors/ya.make b/ydb/core/fq/libs/actors/ya.make new file mode 100644 index 00000000000..bb06a77687f --- /dev/null +++ b/ydb/core/fq/libs/actors/ya.make @@ -0,0 +1,98 @@ +LIBRARY() + +SRCS( + clusters_from_connections.cpp + database_resolver.cpp + error.cpp + nodes_health_check.cpp + nodes_manager.cpp + pending_fetcher.cpp + proxy.cpp + proxy_private.cpp + rate_limiter.cpp + rate_limiter_resources.cpp + result_writer.cpp + run_actor.cpp + table_bindings_from_bindings.cpp + task_get.cpp + task_ping.cpp + task_result_write.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/json/yson + library/cpp/monlib/dynamic_counters + library/cpp/random_provider + library/cpp/scheme + library/cpp/string_utils/quote + library/cpp/time_provider + library/cpp/yson + library/cpp/yson/node + ydb/core/base + ydb/core/fq/libs/actors/logging + ydb/core/fq/libs/checkpointing + ydb/core/fq/libs/checkpointing_common + ydb/core/fq/libs/common + ydb/core/fq/libs/compute/common + ydb/core/fq/libs/compute/ydb + ydb/core/fq/libs/control_plane_storage + ydb/core/fq/libs/control_plane_storage/events + ydb/core/fq/libs/db_id_async_resolver_impl + ydb/core/fq/libs/db_schema + ydb/core/fq/libs/events + ydb/core/fq/libs/grpc + ydb/core/fq/libs/private_client + ydb/core/fq/libs/rate_limiter/utils + ydb/core/fq/libs/result_formatter + ydb/core/fq/libs/shared_resources + ydb/core/fq/libs/signer + ydb/core/protos + ydb/library/mkql_proto + ydb/library/security + ydb/library/yql/ast + ydb/library/yql/core/facade + ydb/library/yql/core/services/mounts + ydb/library/yql/dq/integration/transform + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/providers/clickhouse/provider + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/comp_nodes + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/schema/mkql + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/providers/common/udf_resolve + ydb/library/yql/providers/dq/actors + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/counters + ydb/library/yql/providers/dq/provider + ydb/library/yql/providers/dq/provider/exec + ydb/library/yql/providers/dq/worker_manager/interface + ydb/library/yql/providers/pq/cm_client + ydb/library/yql/providers/pq/provider + ydb/library/yql/providers/pq/task_meta + ydb/library/yql/providers/s3/provider + ydb/library/yql/providers/ydb/provider + ydb/library/yql/public/issue + ydb/library/yql/public/issue/protos + ydb/library/yql/sql/settings + ydb/library/yql/utils + ydb/library/yql/utils/actor_log + ydb/public/api/protos + ydb/public/lib/fq + ydb/public/sdk/cpp/client/draft/ydb_query + ydb/public/sdk/cpp/client/ydb_operation + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + logging +) diff --git a/ydb/core/fq/libs/audit/events/ya.make b/ydb/core/fq/libs/audit/events/ya.make new file mode 100644 index 00000000000..3c67e872663 --- /dev/null +++ b/ydb/core/fq/libs/audit/events/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/core/fq/libs/checkpointing_common + ydb/core/fq/libs/control_plane_storage/events + ydb/library/yql/public/issue + ydb/public/api/protos +) + +END() diff --git a/ydb/core/fq/libs/audit/ya.make b/ydb/core/fq/libs/audit/ya.make new file mode 100644 index 00000000000..3976ffc226c --- /dev/null +++ b/ydb/core/fq/libs/audit/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + yq_audit_service.cpp +) + +PEERDIR( + library/cpp/actors/core +) + +END() + +RECURSE( + events +) diff --git a/ydb/core/fq/libs/checkpoint_storage/events/ya.make b/ydb/core/fq/libs/checkpoint_storage/events/ya.make new file mode 100644 index 00000000000..b8edae958a6 --- /dev/null +++ b/ydb/core/fq/libs/checkpoint_storage/events/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/core/fq/libs/checkpointing_common + ydb/core/fq/libs/events + ydb/core/fq/libs/checkpoint_storage/proto + ydb/library/yql/public/issue +) + +END() diff --git a/ydb/core/fq/libs/checkpoint_storage/proto/ya.make b/ydb/core/fq/libs/checkpoint_storage/proto/ya.make new file mode 100644 index 00000000000..8e78eb58c55 --- /dev/null +++ b/ydb/core/fq/libs/checkpoint_storage/proto/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/core/fq/libs/graph_params/proto +) + +SRCS( + graph_description.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/fq/libs/checkpoint_storage/ya.make b/ydb/core/fq/libs/checkpoint_storage/ya.make new file mode 100644 index 00000000000..552012f504d --- /dev/null +++ b/ydb/core/fq/libs/checkpoint_storage/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +SRCS( + gc.cpp + storage_proxy.cpp + storage_service.cpp + ydb_checkpoint_storage.cpp + ydb_state_storage.cpp +) + +PEERDIR( + contrib/libs/fmt + library/cpp/actors/core + ydb/core/fq/libs/actors/logging + ydb/core/fq/libs/control_plane_storage + ydb/core/fq/libs/ydb + ydb/core/fq/libs/checkpoint_storage/events + ydb/core/fq/libs/checkpoint_storage/proto + ydb/core/fq/libs/checkpointing_common + ydb/core/fq/libs/shared_resources + ydb/library/security + ydb/library/yql/dq/actors/compute + ydb/library/yql/dq/proto + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + events + proto +) diff --git a/ydb/core/fq/libs/checkpointing/events/ya.make b/ydb/core/fq/libs/checkpointing/events/ya.make new file mode 100644 index 00000000000..f3bc18b3198 --- /dev/null +++ b/ydb/core/fq/libs/checkpointing/events/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/core/fq/libs/checkpointing_common +) + +END() diff --git a/ydb/core/fq/libs/checkpointing/ut/ya.make b/ydb/core/fq/libs/checkpointing/ut/ya.make new file mode 100644 index 00000000000..460eb3a7d7c --- /dev/null +++ b/ydb/core/fq/libs/checkpointing/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(ydb/core/fq/libs/checkpointing) + +SRCS( + checkpoint_coordinator_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/fq/libs/checkpointing + ydb/core/testlib/actors + ydb/core/testlib/basics/default +) + +SIZE(MEDIUM) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/checkpointing/ya.make b/ydb/core/fq/libs/checkpointing/ya.make new file mode 100644 index 00000000000..f7ddf18a220 --- /dev/null +++ b/ydb/core/fq/libs/checkpointing/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +SRCS( + checkpoint_coordinator.cpp + checkpoint_coordinator.h + checkpoint_id_generator.cpp + checkpoint_id_generator.h + pending_checkpoint.cpp + pending_checkpoint.h + utils.cpp + utils.h +) + +PEERDIR( + library/cpp/actors/core + ydb/core/fq/libs/actors/logging + ydb/core/fq/libs/checkpointing_common + ydb/core/fq/libs/checkpoint_storage/events + ydb/library/yql/dq/actors/compute + ydb/library/yql/dq/proto + ydb/library/yql/dq/state + ydb/library/yql/providers/dq/api/protos +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + events +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/fq/libs/checkpointing_common/ya.make b/ydb/core/fq/libs/checkpointing_common/ya.make new file mode 100644 index 00000000000..503679a014f --- /dev/null +++ b/ydb/core/fq/libs/checkpointing_common/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + defs.cpp +) + +PEERDIR( + ydb/core/fq/libs/graph_params/proto +) + +GENERATE_ENUM_SERIALIZATION(defs.h) + +END() diff --git a/ydb/core/fq/libs/cloud_audit/ya.make b/ydb/core/fq/libs/cloud_audit/ya.make new file mode 100644 index 00000000000..a9896fc68c8 --- /dev/null +++ b/ydb/core/fq/libs/cloud_audit/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + yq_cloud_audit_service.cpp +) + +PEERDIR( + library/cpp/actors/log_backend + library/cpp/unified_agent_client + ydb/core/fq/libs/actors + ydb/core/fq/libs/audit/events + ydb/core/fq/libs/config/protos + ydb/library/folder_service + ydb/library/ycloud/api + ydb/public/api/client/yc_public/events +) + +END() diff --git a/ydb/core/fq/libs/common/ut/ya.make b/ydb/core/fq/libs/common/ut/ya.make new file mode 100644 index 00000000000..31fdd510678 --- /dev/null +++ b/ydb/core/fq/libs/common/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/core/fq/libs/common) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + cache_ut.cpp + entity_id_ut.cpp + rows_proto_splitter_ut.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy + ydb/services/ydb +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/common/ya.make b/ydb/core/fq/libs/common/ya.make new file mode 100644 index 00000000000..f30242480ec --- /dev/null +++ b/ydb/core/fq/libs/common/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +SRCS( + cache.h + compression.cpp + compression.h + debug_info.cpp + entity_id.cpp + entity_id.h + rows_proto_splitter.cpp + rows_proto_splitter.h +) + +PEERDIR( + library/cpp/blockcodecs + ydb/core/fq/libs/control_plane_storage/events + ydb/core/fq/libs/events + ydb/library/yql/providers/common/structured_token + ydb/library/yql/public/issue + ydb/public/api/protos +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/fq/libs/compute/common/ya.make b/ydb/core/fq/libs/compute/common/ya.make new file mode 100644 index 00000000000..5d1482dcf84 --- /dev/null +++ b/ydb/core/fq/libs/compute/common/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + pinger.cpp + run_actor_params.cpp +) + +PEERDIR( + ydb/core/fq/libs/config/protos + ydb/core/fq/libs/grpc + ydb/core/fq/libs/shared_resources + ydb/library/yql/providers/dq/provider +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/compute/ya.make b/ydb/core/fq/libs/compute/ya.make new file mode 100644 index 00000000000..26430cc6926 --- /dev/null +++ b/ydb/core/fq/libs/compute/ya.make @@ -0,0 +1,4 @@ +RECURSE( + common + ydb +) diff --git a/ydb/core/fq/libs/compute/ydb/ya.make b/ydb/core/fq/libs/compute/ydb/ya.make new file mode 100644 index 00000000000..c4f65784190 --- /dev/null +++ b/ydb/core/fq/libs/compute/ydb/ya.make @@ -0,0 +1,37 @@ +LIBRARY() + +SRCS( + actors_factory.cpp + executer_actor.cpp + finalizer_actor.cpp + resources_cleaner_actor.cpp + result_writer_actor.cpp + status_tracker_actor.cpp + stopper_actor.cpp + ydb_connector_actor.cpp + ydb_run_actor.cpp +) + +PEERDIR( + library/cpp/actors/protos + library/cpp/lwtrace/protos + ydb/core/fq/libs/compute/common + ydb/core/fq/libs/config/protos + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/graph_params/proto + ydb/core/fq/libs/grpc + ydb/core/fq/libs/quota_manager/proto + ydb/core/protos + ydb/library/db_pool/protos + ydb/library/yql/core/expr_nodes + ydb/library/yql/dq/expr_nodes + ydb/library/yql/minikql/arrow + ydb/library/yql/providers/dq/api/protos + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/lib/operation_id/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/config/protos/ya.make b/ydb/core/fq/libs/config/protos/ya.make new file mode 100644 index 00000000000..a71cc23aa53 --- /dev/null +++ b/ydb/core/fq/libs/config/protos/ya.make @@ -0,0 +1,38 @@ +PROTO_LIBRARY() + +SRCS( + audit.proto + checkpoint_coordinator.proto + common.proto + compute.proto + control_plane_proxy.proto + control_plane_storage.proto + db_pool.proto + fq_config.proto + gateways.proto + health_config.proto + issue_id.proto + nodes_manager.proto + pending_fetcher.proto + pinger.proto + private_api.proto + private_proxy.proto + quotas_manager.proto + rate_limiter.proto + read_actors_factory.proto + resource_manager.proto + storage.proto + test_connection.proto + token_accessor.proto +) + +PEERDIR( + ydb/library/folder_service/proto + ydb/library/yql/dq/actors/protos + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/s3/proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/fq/libs/config/ya.make b/ydb/core/fq/libs/config/ya.make new file mode 100644 index 00000000000..036264ffe45 --- /dev/null +++ b/ydb/core/fq/libs/config/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + yq_issue.cpp +) + +PEERDIR( + ydb/core/fq/libs/config/protos + ydb/library/yql/public/issue/protos +) + +END() + +RECURSE( + protos +) diff --git a/ydb/core/fq/libs/control_plane_config/events/ya.make b/ydb/core/fq/libs/control_plane_config/events/ya.make new file mode 100644 index 00000000000..0faecbffdab --- /dev/null +++ b/ydb/core/fq/libs/control_plane_config/events/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/events + ydb/core/fq/libs/quota_manager/events +) + +END() diff --git a/ydb/core/fq/libs/control_plane_config/ya.make b/ydb/core/fq/libs/control_plane_config/ya.make new file mode 100644 index 00000000000..8f1171fe0c5 --- /dev/null +++ b/ydb/core/fq/libs/control_plane_config/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +SRCS( + control_plane_config.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/lwtrace/mon + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/fq/libs/common + ydb/core/fq/libs/config + ydb/core/fq/libs/control_plane_config/events + ydb/core/fq/libs/quota_manager + ydb/core/fq/libs/quota_manager/events + ydb/core/fq/libs/rate_limiter/events + ydb/core/fq/libs/ydb + ydb/core/mon + ydb/library/db_pool + ydb/library/security + ydb/library/protobuf_printer + ydb/library/yql/public/issue + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_value +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + events +) diff --git a/ydb/core/fq/libs/control_plane_proxy/events/ya.make b/ydb/core/fq/libs/control_plane_proxy/events/ya.make new file mode 100644 index 00000000000..de7b727d378 --- /dev/null +++ b/ydb/core/fq/libs/control_plane_proxy/events/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/core/fq/libs/control_plane_storage/events + ydb/core/fq/libs/quota_manager/events +) + +END() diff --git a/ydb/core/fq/libs/control_plane_proxy/ut/ya.make b/ydb/core/fq/libs/control_plane_proxy/ut/ya.make new file mode 100644 index 00000000000..11f42c49525 --- /dev/null +++ b/ydb/core/fq/libs/control_plane_proxy/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/fq/libs/control_plane_proxy) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/base + ydb/core/fq/libs/actors/logging + ydb/core/fq/libs/control_plane_storage + ydb/core/fq/libs/test_connection + ydb/core/fq/libs/quota_manager/ut_helpers + ydb/core/fq/libs/rate_limiter/control_plane_service + ydb/core/testlib/default + ydb/library/folder_service + ydb/library/folder_service/mock +) + +YQL_LAST_ABI_VERSION() + +SRCS( + control_plane_proxy_ut.cpp +) + +END() diff --git a/ydb/core/fq/libs/control_plane_proxy/ya.make b/ydb/core/fq/libs/control_plane_proxy/ya.make new file mode 100644 index 00000000000..980fde857fc --- /dev/null +++ b/ydb/core/fq/libs/control_plane_proxy/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +SRCS( + config.cpp + control_plane_proxy.cpp + probes.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/fq/libs/actors/logging + ydb/core/fq/libs/actors + ydb/core/fq/libs/control_plane_config + ydb/core/fq/libs/control_plane_proxy/events + ydb/core/fq/libs/control_plane_storage + ydb/core/fq/libs/rate_limiter/events + ydb/core/mon + ydb/library/folder_service + ydb/library/security + ydb/library/ycloud/api + ydb/library/ycloud/impl +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + events +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/fq/libs/control_plane_storage/events/ya.make b/ydb/core/fq/libs/control_plane_storage/events/ya.make new file mode 100644 index 00000000000..0faecbffdab --- /dev/null +++ b/ydb/core/fq/libs/control_plane_storage/events/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/events + ydb/core/fq/libs/quota_manager/events +) + +END() diff --git a/ydb/core/fq/libs/control_plane_storage/internal/ya.make b/ydb/core/fq/libs/control_plane_storage/internal/ya.make new file mode 100644 index 00000000000..79b57200a72 --- /dev/null +++ b/ydb/core/fq/libs/control_plane_storage/internal/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +SRCS( + nodes_health_check.cpp + rate_limiter_resources.cpp + response_tasks.cpp + task_get.cpp + task_ping.cpp + task_result_write.cpp + utils.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/lwtrace/mon + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/metering + ydb/core/fq/libs/common + ydb/core/fq/libs/config + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/exceptions + ydb/core/fq/libs/quota_manager + ydb/core/fq/libs/quota_manager/events + ydb/core/fq/libs/rate_limiter/events + ydb/core/fq/libs/ydb + ydb/core/mon + ydb/library/protobuf_printer + ydb/library/security + ydb/library/yql/public/issue + ydb/public/lib/fq + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_value +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/control_plane_storage/proto/ya.make b/ydb/core/fq/libs/control_plane_storage/proto/ya.make new file mode 100644 index 00000000000..184b1757d50 --- /dev/null +++ b/ydb/core/fq/libs/control_plane_storage/proto/ya.make @@ -0,0 +1,16 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/core/fq/libs/protos + ydb/library/yql/dq/proto + ydb/library/yql/providers/dq/api/protos + ydb/public/api/protos +) + +SRCS( + yq_internal.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/fq/libs/control_plane_storage/ya.make b/ydb/core/fq/libs/control_plane_storage/ya.make new file mode 100644 index 00000000000..8912d9e9ccf --- /dev/null +++ b/ydb/core/fq/libs/control_plane_storage/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + config.cpp + control_plane_storage_counters.cpp + in_memory_control_plane_storage.cpp + probes.cpp + request_validators.cpp + util.cpp + validators.cpp + ydb_control_plane_storage.cpp + ydb_control_plane_storage_bindings.cpp + ydb_control_plane_storage_connections.cpp + ydb_control_plane_storage_queries.cpp + ydb_control_plane_storage_quotas.cpp +) + +PEERDIR( + library/cpp/lwtrace + library/cpp/protobuf/interop + ydb/core/base + ydb/core/fq/libs/actors/logging + ydb/core/fq/libs/common + ydb/core/fq/libs/config + ydb/core/fq/libs/config/protos + ydb/core/fq/libs/control_plane_storage/events + ydb/core/fq/libs/control_plane_storage/internal + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/db_schema + ydb/core/fq/libs/graph_params/proto + ydb/core/fq/libs/quota_manager/events + ydb/core/fq/libs/shared_resources + ydb/core/fq/libs/ydb + ydb/core/mon + ydb/library/security + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table + ydb/library/db_pool + ydb/library/yql/providers/s3/path_generator + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + events + internal + proto +) diff --git a/ydb/core/fq/libs/db_id_async_resolver_impl/ya.make b/ydb/core/fq/libs/db_id_async_resolver_impl/ya.make new file mode 100644 index 00000000000..364c1ecd51f --- /dev/null +++ b/ydb/core/fq/libs/db_id_async_resolver_impl/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + db_async_resolver_impl.cpp +) + +PEERDIR( + library/cpp/threading/future + ydb/core/fq/libs/events + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/providers/dq/actors +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/db_schema/ya.make b/ydb/core/fq/libs/db_schema/ya.make new file mode 100644 index 00000000000..818f59c5ae7 --- /dev/null +++ b/ydb/core/fq/libs/db_schema/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + db_schema.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_params + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/events/ya.make b/ydb/core/fq/libs/events/ya.make new file mode 100644 index 00000000000..af193e88335 --- /dev/null +++ b/ydb/core/fq/libs/events/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(events.h) + +GENERATE_ENUM_SERIALIZATION(event_ids.h) + +PEERDIR( + library/cpp/actors/core + ydb/core/fq/libs/graph_params/proto + ydb/core/fq/libs/protos + ydb/library/yql/core/facade + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/providers/dq/provider + ydb/library/yql/public/issue + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/exceptions/ya.make b/ydb/core/fq/libs/exceptions/ya.make new file mode 100644 index 00000000000..483a47b8e3f --- /dev/null +++ b/ydb/core/fq/libs/exceptions/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + exceptions.cpp +) + +PEERDIR( + ydb/core/fq/libs/config/protos +) + +END() diff --git a/ydb/core/fq/libs/gateway/ya.make b/ydb/core/fq/libs/gateway/ya.make new file mode 100644 index 00000000000..0bb8aa89e1a --- /dev/null +++ b/ydb/core/fq/libs/gateway/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + empty_gateway.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/dynamic_counters + ydb/core/fq/libs/actors + ydb/core/fq/libs/events + ydb/core/fq/libs/read_rule + ydb/core/fq/libs/shared_resources + ydb/core/fq/libs/tasks_packer + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/public/issue + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/dq/actors + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/pq/proto + ydb/public/api/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/graph_params/proto/ya.make b/ydb/core/fq/libs/graph_params/proto/ya.make new file mode 100644 index 00000000000..b743c878e6a --- /dev/null +++ b/ydb/core/fq/libs/graph_params/proto/ya.make @@ -0,0 +1,14 @@ +PROTO_LIBRARY() + +SRCS( + graph_params.proto +) + +PEERDIR( + ydb/library/yql/dq/proto + ydb/library/yql/providers/dq/api/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/fq/libs/graph_params/ya.make b/ydb/core/fq/libs/graph_params/ya.make new file mode 100644 index 00000000000..4f27b9f52e0 --- /dev/null +++ b/ydb/core/fq/libs/graph_params/ya.make @@ -0,0 +1,3 @@ +RECURSE( + proto +) diff --git a/ydb/core/fq/libs/grpc/ya.make b/ydb/core/fq/libs/grpc/ya.make new file mode 100644 index 00000000000..cef23872f6e --- /dev/null +++ b/ydb/core/fq/libs/grpc/ya.make @@ -0,0 +1,16 @@ +PROTO_LIBRARY() + +GRPC() + +SRCS( + fq_private_v1.proto +) + +PEERDIR( + ydb/public/api/protos + ydb/core/fq/libs/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/fq/libs/health/ya.make b/ydb/core/fq/libs/health/ya.make new file mode 100644 index 00000000000..418528d1c31 --- /dev/null +++ b/ydb/core/fq/libs/health/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + health.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/fq/libs/shared_resources + ydb/core/mon + ydb/public/sdk/cpp/client/ydb_discovery +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/hmac/ut/ya.make b/ydb/core/fq/libs/hmac/ut/ya.make new file mode 100644 index 00000000000..ed217a32ad6 --- /dev/null +++ b/ydb/core/fq/libs/hmac/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(ydb/core/fq/libs/hmac) + +SRCS( + hmac_ut.cpp +) + +PEERDIR( + ydb/core/fq/libs/hmac +) + +END() diff --git a/ydb/core/fq/libs/hmac/ya.make b/ydb/core/fq/libs/hmac/ya.make new file mode 100644 index 00000000000..e811f84eaaf --- /dev/null +++ b/ydb/core/fq/libs/hmac/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + hmac.cpp +) + +PEERDIR( + contrib/libs/openssl + library/cpp/string_utils/base64 +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/fq/libs/init/ya.make b/ydb/core/fq/libs/init/ya.make new file mode 100644 index 00000000000..d371f265615 --- /dev/null +++ b/ydb/core/fq/libs/init/ya.make @@ -0,0 +1,64 @@ +LIBRARY() + +SRCS( + init.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/http + ydb/core/base + ydb/core/fq/libs/actors + ydb/core/fq/libs/audit + ydb/core/fq/libs/checkpoint_storage + ydb/core/fq/libs/checkpointing + ydb/core/fq/libs/cloud_audit + ydb/core/fq/libs/common + ydb/core/fq/libs/control_plane_config + ydb/core/fq/libs/control_plane_proxy + ydb/core/fq/libs/control_plane_storage + ydb/core/fq/libs/events + ydb/core/fq/libs/gateway + ydb/core/fq/libs/health + ydb/core/fq/libs/quota_manager + ydb/core/fq/libs/rate_limiter/control_plane_service + ydb/core/fq/libs/rate_limiter/quoter_service + ydb/core/fq/libs/shared_resources + ydb/core/fq/libs/test_connection + ydb/core/protos + ydb/library/folder_service + ydb/library/folder_service/proto + ydb/library/security + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/utils/actor_log + ydb/library/yql/dq/actors/compute + ydb/library/yql/dq/comp_nodes + ydb/library/yql/dq/transform + ydb/library/yql/providers/clickhouse/actors + ydb/library/yql/providers/common/comp_nodes + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/dq/actors + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/provider + ydb/library/yql/providers/dq/task_runner + ydb/library/yql/providers/dq/worker_manager + ydb/library/yql/providers/dq/worker_manager/interface + ydb/library/yql/providers/pq/async_io + ydb/library/yql/providers/pq/cm_client + ydb/library/yql/providers/pq/gateway/native + ydb/library/yql/providers/pq/provider + ydb/library/yql/providers/s3/actors + ydb/library/yql/providers/s3/proto + ydb/library/yql/providers/s3/provider + ydb/library/yql/providers/solomon/async_io + ydb/library/yql/providers/solomon/gateway + ydb/library/yql/providers/solomon/proto + ydb/library/yql/providers/solomon/provider + ydb/library/yql/providers/ydb/actors + ydb/library/yql/providers/ydb/comp_nodes + ydb/library/yql/providers/ydb/provider +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/logs/ya.make b/ydb/core/fq/libs/logs/ya.make new file mode 100644 index 00000000000..ca8f4cff940 --- /dev/null +++ b/ydb/core/fq/libs/logs/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + log.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/protos + ydb/library/yql/utils/actor_log +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/mock/ya.make b/ydb/core/fq/libs/mock/ya.make new file mode 100644 index 00000000000..301228f45af --- /dev/null +++ b/ydb/core/fq/libs/mock/ya.make @@ -0,0 +1,46 @@ +LIBRARY() + +SRCS( + yql_mock.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/json/yson + library/cpp/monlib/dynamic_counters + library/cpp/random_provider + library/cpp/time_provider + library/cpp/yson + library/cpp/yson/node + ydb/core/base + ydb/core/fq/libs/actors + ydb/core/fq/libs/common + ydb/core/fq/libs/db_schema + ydb/core/fq/libs/shared_resources/interface + ydb/core/protos + ydb/library/mkql_proto + ydb/library/yql/ast + ydb/library/yql/core/facade + ydb/library/yql/core/services/mounts + ydb/library/yql/dq/integration/transform + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/providers/clickhouse/provider + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/comp_nodes + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/schema/mkql + ydb/library/yql/providers/common/udf_resolve + ydb/library/yql/providers/dq/provider + ydb/library/yql/providers/dq/worker_manager/interface + ydb/library/yql/providers/ydb/provider + ydb/library/yql/public/issue + ydb/library/yql/public/issue/protos + ydb/library/yql/sql/settings + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/pretty_printers/ya.make b/ydb/core/fq/libs/pretty_printers/ya.make new file mode 100644 index 00000000000..79e0b67fb50 --- /dev/null +++ b/ydb/core/fq/libs/pretty_printers/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + graph_params_printer.cpp + minikql_program_printer.cpp +) + +PEERDIR( + contrib/libs/protobuf + ydb/core/fq/libs/graph_params/proto + ydb/library/protobuf_printer + ydb/library/yql/minikql + ydb/library/yql/providers/dq/api/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/private_client/ya.make b/ydb/core/fq/libs/private_client/ya.make new file mode 100644 index 00000000000..5d52f451bc8 --- /dev/null +++ b/ydb/core/fq/libs/private_client/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + internal_service.cpp + loopback_service.cpp + private_client.cpp +) + +PEERDIR( + library/cpp/monlib/dynamic_counters + library/cpp/protobuf/json + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/grpc + ydb/core/fq/libs/shared_resources + ydb/core/protos + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/protos/ya.make b/ydb/core/fq/libs/protos/ya.make new file mode 100644 index 00000000000..f53349ac5b8 --- /dev/null +++ b/ydb/core/fq/libs/protos/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/protos + ydb/library/yql/dq/actors/protos +) + +SRCS( + dq_effects.proto + fq_private.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/fq/libs/quota_manager/events/ya.make b/ydb/core/fq/libs/quota_manager/events/ya.make new file mode 100644 index 00000000000..e6368e8dc2c --- /dev/null +++ b/ydb/core/fq/libs/quota_manager/events/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + ydb/core/fq/libs/events + ydb/core/fq/libs/quota_manager/proto +) + +END() diff --git a/ydb/core/fq/libs/quota_manager/proto/ya.make b/ydb/core/fq/libs/quota_manager/proto/ya.make new file mode 100644 index 00000000000..250e053da77 --- /dev/null +++ b/ydb/core/fq/libs/quota_manager/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + quota_internal.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/fq/libs/quota_manager/ut_helpers/ya.make b/ydb/core/fq/libs/quota_manager/ut_helpers/ya.make new file mode 100644 index 00000000000..42c6f4046c6 --- /dev/null +++ b/ydb/core/fq/libs/quota_manager/ut_helpers/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + fake_quota_manager.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/fq/libs/quota_manager/events +) + +END() diff --git a/ydb/core/fq/libs/quota_manager/ya.make b/ydb/core/fq/libs/quota_manager/ya.make new file mode 100644 index 00000000000..07c00e000c8 --- /dev/null +++ b/ydb/core/fq/libs/quota_manager/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + quota_manager.cpp + quota_proxy.cpp +) + +PEERDIR( + library/cpp/monlib/dynamic_counters + library/cpp/protobuf/json + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/quota_manager/events + ydb/core/fq/libs/shared_resources + ydb/core/protos + ydb/public/api/grpc/draft + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + events + proto + ut_helpers +) diff --git a/ydb/core/fq/libs/rate_limiter/control_plane_service/ya.make b/ydb/core/fq/libs/rate_limiter/control_plane_service/ya.make new file mode 100644 index 00000000000..d496f2eab3b --- /dev/null +++ b/ydb/core/fq/libs/rate_limiter/control_plane_service/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + rate_limiter_control_plane_service.cpp + update_limit_actor.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/fq/libs/config/protos + ydb/core/fq/libs/events + ydb/core/fq/libs/quota_manager/events + ydb/core/fq/libs/rate_limiter/events + ydb/core/fq/libs/rate_limiter/utils + ydb/core/fq/libs/shared_resources + ydb/core/fq/libs/ydb + ydb/core/protos + ydb/library/security +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/rate_limiter/events/ya.make b/ydb/core/fq/libs/rate_limiter/events/ya.make new file mode 100644 index 00000000000..32afee079da --- /dev/null +++ b/ydb/core/fq/libs/rate_limiter/events/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + control_plane_events.cpp + data_plane.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/fq/libs/events +) + +END() diff --git a/ydb/core/fq/libs/rate_limiter/quoter_service/ya.make b/ydb/core/fq/libs/rate_limiter/quoter_service/ya.make new file mode 100644 index 00000000000..27df069ec2a --- /dev/null +++ b/ydb/core/fq/libs/rate_limiter/quoter_service/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + quoter_service.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/fq/libs/config/protos + ydb/core/fq/libs/rate_limiter/events + ydb/core/fq/libs/shared_resources + ydb/core/fq/libs/ydb + ydb/core/protos + ydb/library/security +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/rate_limiter/utils/ya.make b/ydb/core/fq/libs/rate_limiter/utils/ya.make new file mode 100644 index 00000000000..3be350870cc --- /dev/null +++ b/ydb/core/fq/libs/rate_limiter/utils/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + path.cpp +) + +END() diff --git a/ydb/core/fq/libs/rate_limiter/ya.make b/ydb/core/fq/libs/rate_limiter/ya.make new file mode 100644 index 00000000000..aaa7ebe1370 --- /dev/null +++ b/ydb/core/fq/libs/rate_limiter/ya.make @@ -0,0 +1,6 @@ +RECURSE( + control_plane_service + events + quoter_service + utils +) diff --git a/ydb/core/fq/libs/read_rule/ya.make b/ydb/core/fq/libs/read_rule/ya.make new file mode 100644 index 00000000000..f55ac8a99ac --- /dev/null +++ b/ydb/core/fq/libs/read_rule/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + read_rule_creator.cpp + read_rule_deleter.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/fq/libs/events + ydb/core/protos + ydb/public/api/protos + ydb/public/lib/operation_id/protos + ydb/public/sdk/cpp/client/ydb_persqueue_core + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/pq/proto +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/result_formatter/ut/ya.make b/ydb/core/fq/libs/result_formatter/ut/ya.make new file mode 100644 index 00000000000..4b40f8cbdc8 --- /dev/null +++ b/ydb/core/fq/libs/result_formatter/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/fq/libs/result_formatter) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + result_formatter_ut.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy + ydb/services/ydb +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/result_formatter/ya.make b/ydb/core/fq/libs/result_formatter/ya.make new file mode 100644 index 00000000000..b88af57b51e --- /dev/null +++ b/ydb/core/fq/libs/result_formatter/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +SRCS( + result_formatter.cpp +) + +PEERDIR( + library/cpp/json + library/cpp/json/yson + ydb/core/engine + ydb/library/yql/ast + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_result + ydb/public/sdk/cpp/client/ydb_value + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/common/schema/mkql +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/fq/libs/shared_resources/interface/ya.make b/ydb/core/fq/libs/shared_resources/interface/ya.make new file mode 100644 index 00000000000..398b6c47b64 --- /dev/null +++ b/ydb/core/fq/libs/shared_resources/interface/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + shared_resources.cpp +) + +PEERDIR( + library/cpp/actors/core +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/shared_resources/ya.make b/ydb/core/fq/libs/shared_resources/ya.make new file mode 100644 index 00000000000..e278b408bd0 --- /dev/null +++ b/ydb/core/fq/libs/shared_resources/ya.make @@ -0,0 +1,33 @@ +LIBRARY() + +SRCS( + db_exec.cpp + shared_resources.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/dynamic_counters + ydb/core/fq/libs/common + ydb/core/fq/libs/config + ydb/core/fq/libs/control_plane_storage/proto + ydb/core/fq/libs/db_schema + ydb/core/fq/libs/events + ydb/core/fq/libs/exceptions + ydb/core/fq/libs/quota_manager/events + ydb/core/fq/libs/shared_resources/interface + ydb/core/protos + ydb/library/db_pool + ydb/library/logger + ydb/library/security + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + interface +) diff --git a/ydb/core/fq/libs/signer/ut/ya.make b/ydb/core/fq/libs/signer/ut/ya.make new file mode 100644 index 00000000000..7c605d61fb4 --- /dev/null +++ b/ydb/core/fq/libs/signer/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(ydb/core/fq/libs/signer) + +SRCS( + signer_ut.cpp +) + +PEERDIR( + ydb/core/fq/libs/signer +) + +END() diff --git a/ydb/core/fq/libs/signer/ya.make b/ydb/core/fq/libs/signer/ya.make new file mode 100644 index 00000000000..a5bfcc143cb --- /dev/null +++ b/ydb/core/fq/libs/signer/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + signer.cpp +) + +PEERDIR( + ydb/core/fq/libs/hmac +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/fq/libs/tasks_packer/ya.make b/ydb/core/fq/libs/tasks_packer/ya.make new file mode 100644 index 00000000000..e8201485b85 --- /dev/null +++ b/ydb/core/fq/libs/tasks_packer/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + tasks_packer.cpp +) + +PEERDIR( + ydb/library/yql/dq/proto + ydb/library/yql/utils +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/libs/test_connection/events/ya.make b/ydb/core/fq/libs/test_connection/events/ya.make new file mode 100644 index 00000000000..237d42c5d5d --- /dev/null +++ b/ydb/core/fq/libs/test_connection/events/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + ydb/core/fq/libs/control_plane_storage/events + ydb/core/fq/libs/events + ydb/library/yql/public/issue/protos + ydb/public/api/protos +) + +END() diff --git a/ydb/core/fq/libs/test_connection/ut/ya.make b/ydb/core/fq/libs/test_connection/ut/ya.make new file mode 100644 index 00000000000..bf33160bd86 --- /dev/null +++ b/ydb/core/fq/libs/test_connection/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(ydb/core/fq/libs/control_plane_proxy) + +PEERDIR( + library/cpp/testing/unittest + ydb/library/yql/sql/pg_dummy + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + test_connection_ut.cpp +) + +END() diff --git a/ydb/core/fq/libs/test_connection/ya.make b/ydb/core/fq/libs/test_connection/ya.make new file mode 100644 index 00000000000..8f6c973b47e --- /dev/null +++ b/ydb/core/fq/libs/test_connection/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +SRCS( + counters.cpp + probes.cpp + test_connection.cpp + test_data_streams.cpp + test_monitoring.cpp + test_object_storage.cpp +) + +PEERDIR( + library/cpp/lwtrace + library/cpp/xml/document + ydb/core/fq/libs/actors + ydb/core/fq/libs/actors/logging + ydb/core/fq/libs/config/protos + ydb/core/fq/libs/control_plane_storage + ydb/core/fq/libs/test_connection/events + ydb/library/yql/providers/pq/cm_client + ydb/library/yql/providers/solomon/async_io +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + events +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/fq/libs/ya.make b/ydb/core/fq/libs/ya.make new file mode 100644 index 00000000000..5327fd0e45b --- /dev/null +++ b/ydb/core/fq/libs/ya.make @@ -0,0 +1,35 @@ +RECURSE( + actors + audit + checkpoint_storage + checkpointing + checkpointing_common + cloud_audit + common + compute + config + control_plane_config + control_plane_proxy + control_plane_storage + db_schema + events + gateway + graph_params + health + hmac + init + logs + mock + pretty_printers + private_client + protos + quota_manager + rate_limiter + read_rule + result_formatter + shared_resources + signer + tasks_packer + test_connection + ydb +) diff --git a/ydb/core/fq/libs/ydb/ya.make b/ydb/core/fq/libs/ydb/ya.make new file mode 100644 index 00000000000..c5ff6e89061 --- /dev/null +++ b/ydb/core/fq/libs/ydb/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + schema.cpp + util.cpp + ydb.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/retry + ydb/core/base + ydb/core/fq/libs/config + ydb/core/fq/libs/events + ydb/library/security + ydb/public/sdk/cpp/client/ydb_coordination + ydb/public/sdk/cpp/client/ydb_rate_limiter + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table +) + +GENERATE_ENUM_SERIALIZATION(ydb.h) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/fq/ya.make b/ydb/core/fq/ya.make new file mode 100644 index 00000000000..0598f6e732d --- /dev/null +++ b/ydb/core/fq/ya.make @@ -0,0 +1,4 @@ +RECURSE( + libs +) + diff --git a/ydb/core/grpc_caching/ya.make b/ydb/core/grpc_caching/ya.make new file mode 100644 index 00000000000..d098d91b962 --- /dev/null +++ b/ydb/core/grpc_caching/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + cached_grpc_request_actor.cpp +) + +PEERDIR( + library/cpp/actors/protos + ydb/core/base +) + +END() diff --git a/ydb/core/grpc_services/auth_processor/ya.make b/ydb/core/grpc_services/auth_processor/ya.make new file mode 100644 index 00000000000..149a7905798 --- /dev/null +++ b/ydb/core/grpc_services/auth_processor/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + dynamic_node_auth_processor.cpp +) + +PEERDIR( + contrib/libs/openssl +) + +END() diff --git a/ydb/core/grpc_services/base/ya.make b/ydb/core/grpc_services/base/ya.make new file mode 100644 index 00000000000..b63565712eb --- /dev/null +++ b/ydb/core/grpc_services/base/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + base_service.h + base.h +) + +PEERDIR( + library/cpp/grpc/server + library/cpp/string_utils/quote + ydb/core/base + ydb/core/grpc_services/counters + ydb/core/grpc_streaming + ydb/public/api/protos + ydb/public/sdk/cpp/client/resources + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/grpc_services/cancelation/protos/ya.make b/ydb/core/grpc_services/cancelation/protos/ya.make new file mode 100644 index 00000000000..7fa104e904f --- /dev/null +++ b/ydb/core/grpc_services/cancelation/protos/ya.make @@ -0,0 +1,14 @@ +PROTO_LIBRARY() + +SRCS( + event.proto +) + +PEERDIR( + library/cpp/actors/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() + diff --git a/ydb/core/grpc_services/cancelation/ya.make b/ydb/core/grpc_services/cancelation/ya.make new file mode 100644 index 00000000000..c6cdd7c1dc5 --- /dev/null +++ b/ydb/core/grpc_services/cancelation/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + cancelation.cpp +) + +PEERDIR( + ydb/core/grpc_services/cancelation/protos + ydb/core/grpc_services/base + ydb/core/protos +) + +END() diff --git a/ydb/core/grpc_services/counters/ya.make b/ydb/core/grpc_services/counters/ya.make new file mode 100644 index 00000000000..d1e9e4a9a13 --- /dev/null +++ b/ydb/core/grpc_services/counters/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + counters.cpp + counters.h + proxy_counters.cpp + proxy_counters.h +) + +PEERDIR( + ydb/core/base + ydb/core/protos + ydb/core/sys_view/service +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/grpc_services/local_rpc/ya.make b/ydb/core/grpc_services/local_rpc/ya.make new file mode 100644 index 00000000000..75abdcefa0f --- /dev/null +++ b/ydb/core/grpc_services/local_rpc/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + local_rpc.h +) + +PEERDIR( + ydb/core/base + ydb/core/grpc_services/base +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/grpc_services/ut/ya.make b/ydb/core/grpc_services/ut/ya.make new file mode 100644 index 00000000000..b3b106f09c3 --- /dev/null +++ b/ydb/core/grpc_services/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/grpc_services) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + rpc_calls_ut.cpp + operation_helpers_ut.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/client/scheme_cache_lib + ydb/core/testlib/default +) + +END() diff --git a/ydb/core/grpc_services/ya.make b/ydb/core/grpc_services/ya.make new file mode 100644 index 00000000000..b415c689061 --- /dev/null +++ b/ydb/core/grpc_services/ya.make @@ -0,0 +1,136 @@ +LIBRARY() + +SRCS( + audit_log.cpp + grpc_endpoint_publish_actor.cpp + grpc_helper.cpp + grpc_mon.cpp + grpc_publisher_service_actor.cpp + grpc_request_proxy.cpp + grpc_request_proxy_simple.cpp + local_rate_limiter.cpp + operation_helpers.cpp + resolve_local_db_table.cpp + rpc_alter_coordination_node.cpp + rpc_alter_table.cpp + rpc_begin_transaction.cpp + rpc_calls.cpp + rpc_cancel_operation.cpp + rpc_cms.cpp + rpc_commit_transaction.cpp + rpc_dynamic_config.cpp + rpc_copy_table.cpp + rpc_copy_tables.cpp + rpc_export.cpp + rpc_create_coordination_node.cpp + rpc_create_session.cpp + rpc_create_table.cpp + rpc_delete_session.cpp + rpc_describe_coordination_node.cpp + rpc_describe_path.cpp + rpc_describe_table.cpp + rpc_describe_table_options.cpp + rpc_drop_coordination_node.cpp + rpc_drop_table.cpp + rpc_discovery.cpp + rpc_execute_data_query.cpp + rpc_execute_scheme_query.cpp + rpc_execute_yql_script.cpp + rpc_explain_yql_script.cpp + rpc_explain_data_query.cpp + rpc_forget_operation.cpp + rpc_fq_internal.cpp + rpc_fq.cpp + rpc_get_operation.cpp + rpc_get_shard_locations.cpp + rpc_import.cpp + rpc_import_data.cpp + rpc_keep_alive.cpp + rpc_kh_describe.cpp + rpc_kh_snapshots.cpp + rpc_kqp_base.cpp + rpc_list_operations.cpp + rpc_login.cpp + rpc_load_rows.cpp + rpc_log_store.cpp + rpc_long_tx.cpp + rpc_node_registration.cpp + rpc_make_directory.cpp + rpc_modify_permissions.cpp + rpc_monitoring.cpp + rpc_prepare_data_query.cpp + rpc_rate_limiter_api.cpp + rpc_read_columns.cpp + rpc_read_table.cpp + rpc_read_rows.cpp + rpc_remove_directory.cpp + rpc_rename_tables.cpp + rpc_rollback_transaction.cpp + rpc_scheme_base.cpp + rpc_stream_execute_scan_query.cpp + rpc_stream_execute_yql_script.cpp + rpc_whoami.cpp + table_settings.cpp + + query/rpc_execute_query.cpp + query/rpc_execute_script.cpp + query/rpc_fetch_script_results.cpp + query/service_query.h +) + +PEERDIR( + contrib/libs/xxhash + library/cpp/cgiparam + library/cpp/digest/old_crc + ydb/core/actorlib_impl + ydb/core/base + ydb/core/control + ydb/core/discovery + ydb/core/engine + ydb/core/formats + ydb/core/fq/libs/actors + ydb/core/fq/libs/control_plane_proxy + ydb/core/fq/libs/control_plane_proxy/events + ydb/core/grpc_services/base + ydb/core/grpc_services/counters + ydb/core/grpc_services/local_rpc + ydb/core/grpc_services/cancelation + ydb/core/grpc_services/auth_processor + ydb/core/health_check + ydb/core/io_formats + ydb/core/kesus/tablet + ydb/core/kqp/common + ydb/core/protos + ydb/core/scheme + ydb/core/sys_view + ydb/core/tx + ydb/core/tx/datashard + ydb/core/tx/sharding + ydb/core/tx/long_tx_service/public + ydb/core/ydb_convert + ydb/library/aclib + ydb/library/binary_json + ydb/library/dynumber + ydb/library/mkql_proto + ydb/library/persqueue/topic_parser + ydb/library/yql/public/types + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/resources + ydb/services/ext_index/common +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + base + counters + local_rpc +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/grpc_streaming/ut/grpc/ya.make b/ydb/core/grpc_streaming/ut/grpc/ya.make new file mode 100644 index 00000000000..fa12a1b9a98 --- /dev/null +++ b/ydb/core/grpc_streaming/ut/grpc/ya.make @@ -0,0 +1,11 @@ +PROTO_LIBRARY() + +GRPC() + +SRCS( + streaming_service.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/grpc_streaming/ut/ya.make b/ydb/core/grpc_streaming/ut/ya.make new file mode 100644 index 00000000000..76b4bcff09b --- /dev/null +++ b/ydb/core/grpc_streaming/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/grpc_streaming) + +FORK_SUBTESTS() + +TIMEOUT(300) + +SIZE(MEDIUM) + +SRCS( + grpc_streaming_ut.cpp +) + +PEERDIR( + library/cpp/grpc/client + ydb/core/grpc_streaming/ut/grpc + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/grpc_streaming/ya.make b/ydb/core/grpc_streaming/ya.make new file mode 100644 index 00000000000..19d9592ed3c --- /dev/null +++ b/ydb/core/grpc_streaming/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + contrib/libs/grpc + library/cpp/actors/core + library/cpp/grpc/server + ydb/core/base +) + +SRCS( + grpc_streaming.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/health_check/ut/ya.make b/ydb/core/health_check/ut/ya.make new file mode 100644 index 00000000000..84c864a2c39 --- /dev/null +++ b/ydb/core/health_check/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/core/health_check) + +FORK_SUBTESTS() + +SIZE(SMALL) + +PEERDIR( + ydb/core/testlib/default +) + +SRCS( + health_check_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/health_check/ya.make b/ydb/core/health_check/ya.make new file mode 100644 index 00000000000..7ad9512caea --- /dev/null +++ b/ydb/core/health_check/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + health_check.cpp + health_check.h +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/blobstorage/base + ydb/library/aclib + ydb/public/api/protos + ydb/public/api/grpc + ydb/library/yql/public/issue/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/http_proxy/ut/ya.make b/ydb/core/http_proxy/ut/ya.make new file mode 100644 index 00000000000..9abb8b9d785 --- /dev/null +++ b/ydb/core/http_proxy/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/http_proxy) + +SIZE(SMALL) + +FORK_SUBTESTS() + +PEERDIR( + contrib/restricted/nlohmann_json + library/cpp/resource + ydb/core/http_proxy + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy + ydb/public/sdk/cpp/client/ydb_types + ydb/services/kesus + ydb/services/persqueue_cluster_discovery +) + +SRCS( + json_proto_conversion_ut.cpp +) + +END() diff --git a/ydb/core/http_proxy/ya.make b/ydb/core/http_proxy/ya.make new file mode 100644 index 00000000000..79cb89148bc --- /dev/null +++ b/ydb/core/http_proxy/ya.make @@ -0,0 +1,53 @@ +LIBRARY() + + +SRCS( + auth_factory.cpp + auth_factory.h + custom_metrics.h + discovery_actor.cpp + discovery_actor.h + events.h + exceptions_mapping.cpp + exceptions_mapping.h + grpc_service.cpp + grpc_service.h + http_req.cpp + http_req.h + http_service.cpp + http_service.h + json_proto_conversion.h + metrics_actor.cpp + metrics_actor.h +) + +PEERDIR( + contrib/restricted/nlohmann_json + library/cpp/actors/http + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/core/grpc_services/local_rpc + ydb/library/yql/public/issue + ydb/library/http_proxy/authorization + ydb/library/http_proxy/error + ydb/library/ycloud/api + ydb/library/ycloud/impl + ydb/library/naming_conventions + ydb/public/sdk/cpp/client/ydb_datastreams + ydb/public/sdk/cpp/client/ydb_persqueue_core + ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs + ydb/public/sdk/cpp/client/iam_private + ydb/services/datastreams + ydb/services/persqueue_v1/actors + ydb/public/api/grpc + ydb/public/api/protos +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/io_formats/ut/ya.make b/ydb/core/io_formats/ut/ya.make new file mode 100644 index 00000000000..7b8ba5f6065 --- /dev/null +++ b/ydb/core/io_formats/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(ydb/core/io_formats) + +SIZE(SMALL) + +PEERDIR( + ydb/core/io_formats + + # for NYql::NUdf alloc stuff used in binary_json + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_csv.cpp +) + +END() diff --git a/ydb/core/io_formats/ya.make b/ydb/core/io_formats/ya.make new file mode 100644 index 00000000000..4838ff96e1b --- /dev/null +++ b/ydb/core/io_formats/ya.make @@ -0,0 +1,30 @@ +RECURSE_FOR_TESTS(ut) + +LIBRARY() + +SRCS( + csv_ydb_dump.cpp + csv_arrow.cpp +) + +CFLAGS( + -Wno-unused-parameter +) + +PEERDIR( + contrib/libs/double-conversion + library/cpp/string_utils/quote + ydb/core/formats/arrow + ydb/core/scheme + ydb/library/binary_json + ydb/library/dynumber + ydb/library/yql/minikql/dom + ydb/library/yql/public/decimal + ydb/library/yql/public/udf + ydb/library/yql/utils + ydb/public/lib/scheme_types +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kafkaproxy/ut/ya.make b/ydb/core/kafkaproxy/ut/ya.make new file mode 100644 index 00000000000..1a384fdd1d4 --- /dev/null +++ b/ydb/core/kafkaproxy/ut/ya.make @@ -0,0 +1,12 @@ +GTEST() + +SRCS( + ut_kafka_functions.cpp + ut_serialization.cpp +) + +PEERDIR( + ydb/core/kafkaproxy +) + +END() diff --git a/ydb/core/kafkaproxy/ya.make b/ydb/core/kafkaproxy/ya.make new file mode 100644 index 00000000000..fb108fb19a7 --- /dev/null +++ b/ydb/core/kafkaproxy/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + kafka_messages.cpp + kafka_messages_int.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/protos + ydb/core/base + ydb/core/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kesus/proxy/ut/ya.make b/ydb/core/kesus/proxy/ut/ya.make new file mode 100644 index 00000000000..1a8fd4ad8a7 --- /dev/null +++ b/ydb/core/kesus/proxy/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/kesus/proxy) + +FORK_SUBTESTS() + +SPLIT_FACTOR(20) + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + ydb/core/testlib/default +) + +SRCS( + proxy_actor_ut.cpp + ut_helpers.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kesus/proxy/ya.make b/ydb/core/kesus/proxy/ya.make new file mode 100644 index 00000000000..f9986d300e9 --- /dev/null +++ b/ydb/core/kesus/proxy/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + events.cpp + proxy.cpp + proxy_actor.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/erasure + ydb/core/kesus/tablet + ydb/core/scheme + ydb/core/tx/scheme_cache + ydb/public/api/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kesus/tablet/quoter_performance_test/ya.make b/ydb/core/kesus/tablet/quoter_performance_test/ya.make new file mode 100644 index 00000000000..f91ae659feb --- /dev/null +++ b/ydb/core/kesus/tablet/quoter_performance_test/ya.make @@ -0,0 +1,19 @@ +PROGRAM() + +SRCDIR(ydb/core/kesus/tablet) + +PEERDIR( + library/cpp/getopt + library/cpp/testing/unittest + ADDINCL ydb/core/kesus/tablet + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + main.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/kesus/tablet/ut/ya.make b/ydb/core/kesus/tablet/ut/ya.make new file mode 100644 index 00000000000..625481dcef4 --- /dev/null +++ b/ydb/core/kesus/tablet/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/kesus/tablet) + +FORK_SUBTESTS() + +SPLIT_FACTOR(20) + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/testing/gmock_in_unittest + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + tablet_ut.cpp + quoter_resource_tree_ut.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/kesus/tablet/ya.make b/ydb/core/kesus/tablet/ya.make new file mode 100644 index 00000000000..cb07d00d898 --- /dev/null +++ b/ydb/core/kesus/tablet/ya.make @@ -0,0 +1,57 @@ +LIBRARY() + +SRCS( + events.cpp + probes.cpp + quoter_resource_tree.cpp + quoter_runtime.cpp + rate_accounting.cpp + schema.cpp + tablet_db.cpp + tablet_html.cpp + tablet_impl.cpp + tablet.cpp + tx_config_get.cpp + tx_config_set.cpp + tx_dummy.cpp + tx_init_schema.cpp + tx_init.cpp + tx_quoter_resource_add.cpp + tx_quoter_resource_delete.cpp + tx_quoter_resource_describe.cpp + tx_quoter_resource_update.cpp + tx_self_check.cpp + tx_semaphore_acquire.cpp + tx_semaphore_create.cpp + tx_semaphore_delete.cpp + tx_semaphore_describe.cpp + tx_semaphore_release.cpp + tx_semaphore_timeout.cpp + tx_semaphore_update.cpp + tx_session_attach.cpp + tx_session_destroy.cpp + tx_session_detach.cpp + tx_session_timeout.cpp + tx_sessions_describe.cpp +) + +PEERDIR( + library/cpp/protobuf/util + ydb/core/actorlib_impl + ydb/core/base + ydb/core/engine/minikql + ydb/core/erasure + ydb/core/metering + ydb/core/protos + ydb/core/tablet_flat +) + +END() + +RECURSE( + quoter_performance_test +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kesus/ut/ya.make b/ydb/core/kesus/ut/ya.make new file mode 100644 index 00000000000..8993c596281 --- /dev/null +++ b/ydb/core/kesus/ut/ya.make @@ -0,0 +1,4 @@ +RECURSE_ROOT_RELATIVE( + ydb/core/kesus/proxy/ut + ydb/core/kesus/tablet/ut +) diff --git a/ydb/core/kesus/ya.make b/ydb/core/kesus/ya.make new file mode 100644 index 00000000000..28de8e577ad --- /dev/null +++ b/ydb/core/kesus/ya.make @@ -0,0 +1,8 @@ +RECURSE( + proxy + tablet +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/keyvalue/protos/ya.make b/ydb/core/keyvalue/protos/ya.make new file mode 100644 index 00000000000..96fddf1f049 --- /dev/null +++ b/ydb/core/keyvalue/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +IF (OS_WINDOWS) + NO_OPTIMIZE_PY_PROTOS() +ENDIF() + +SRCS( + events.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/keyvalue/ut/ya.make b/ydb/core/keyvalue/ut/ya.make new file mode 100644 index 00000000000..5795ae76c54 --- /dev/null +++ b/ydb/core/keyvalue/ut/ya.make @@ -0,0 +1,31 @@ +UNITTEST_FOR(ydb/core/keyvalue) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND OR SANITIZER_TYPE) + TIMEOUT(1800) + SIZE(LARGE) + SPLIT_FACTOR(20) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + SPLIT_FACTOR(10) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + keyvalue_ut.cpp + keyvalue_collector_ut.cpp + keyvalue_storage_read_request_ut.cpp +) + +END() diff --git a/ydb/core/keyvalue/ya.make b/ydb/core/keyvalue/ya.make new file mode 100644 index 00000000000..ebf7ff016ce --- /dev/null +++ b/ydb/core/keyvalue/ya.make @@ -0,0 +1,65 @@ +LIBRARY() + +SRCS( + defs.h + keyvalue_collect_operation.cpp + keyvalue_collect_operation.h + keyvalue_collector.cpp + keyvalue_collector.h + keyvalue_const.h + keyvalue.cpp + keyvalue_data.cpp + keyvalue_data.h + keyvalue_data_header.h + keyvalue_events.h + keyvalue_flat_impl.h + keyvalue.h + keyvalue_helpers.cpp + keyvalue_helpers.h + keyvalue_index_record.cpp + keyvalue_index_record.h + keyvalue_intermediate.cpp + keyvalue_intermediate.h + keyvalue_item_type.h + keyvalue_key_header.h + keyvalue_key_range.h + keyvalue_request_stat.h + keyvalue_request_type.h + keyvalue_scheme_flat.h + keyvalue_simple_db_flat.cpp + keyvalue_simple_db_flat.h + keyvalue_simple_db.h + keyvalue_state.cpp + keyvalue_state.h + keyvalue_state_collect.cpp + keyvalue_storage_read_request.cpp + keyvalue_storage_request.cpp + keyvalue_storage_request.h + keyvalue_stored_state_data.cpp + keyvalue_stored_state_data.h + keyvalue_trash_key_arbitrary.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/protos + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/dsproxy + ydb/core/engine/minikql + ydb/core/keyvalue/protos + ydb/core/protos + ydb/core/tablet_flat + ydb/core/tx + ydb/public/lib/base +) + +END() + +RECURSE( + protos +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kqp/common/compilation/ya.make b/ydb/core/kqp/common/compilation/ya.make new file mode 100644 index 00000000000..08efd5d32fa --- /dev/null +++ b/ydb/core/kqp/common/compilation/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + result.cpp + events.cpp +) + +PEERDIR( + ydb/core/kqp/query_data + ydb/core/kqp/common/simple + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/common/events/ya.make b/ydb/core/kqp/common/events/ya.make new file mode 100644 index 00000000000..da9bd603b25 --- /dev/null +++ b/ydb/core/kqp/common/events/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + process_response.cpp + events.cpp + query.cpp + script_executions.cpp +) + +PEERDIR( + ydb/core/protos + ydb/core/base + ydb/core/grpc_services/base + ydb/core/grpc_services/cancelation + ydb/core/kqp/common/shutdown + ydb/core/kqp/common/compilation + + ydb/library/yql/dq/actors + ydb/public/api/protos + ydb/public/lib/operation_id + + library/cpp/actors/core +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/common/shutdown/ya.make b/ydb/core/kqp/common/shutdown/ya.make new file mode 100644 index 00000000000..17fde9b9b74 --- /dev/null +++ b/ydb/core/kqp/common/shutdown/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + controller.cpp + state.cpp + events.cpp +) + +PEERDIR( + ydb/core/protos + library/cpp/actors/core +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/common/simple/ya.make b/ydb/core/kqp/common/simple/ya.make new file mode 100644 index 00000000000..092fbc213e0 --- /dev/null +++ b/ydb/core/kqp/common/simple/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + helpers.cpp + query_id.cpp + settings.cpp + services.cpp + kqp_event_ids.cpp +) + +PEERDIR( + contrib/libs/protobuf + ydb/core/base + ydb/core/protos + ydb/library/yql/dq/actors + ydb/public/api/protos +) + +END() diff --git a/ydb/core/kqp/common/ya.make b/ydb/core/kqp/common/ya.make new file mode 100644 index 00000000000..ffde67dfcf7 --- /dev/null +++ b/ydb/core/kqp/common/ya.make @@ -0,0 +1,57 @@ +LIBRARY() + +SRCS( + kqp_event_ids.h + kqp_event_impl.cpp + kqp_resolve.cpp + kqp_resolve.h + kqp_ru_calc.cpp + kqp_yql.cpp + kqp_yql.h + kqp_script_executions.cpp + kqp_timeouts.h + kqp_timeouts.cpp + kqp_lwtrace_probes.h + kqp_lwtrace_probes.cpp + kqp_types.h + kqp_types.cpp + kqp.cpp + kqp.h +) + +PEERDIR( + ydb/core/base + ydb/core/engine + ydb/core/kqp/expr_nodes + ydb/core/kqp/common/simple + ydb/core/kqp/common/compilation + ydb/core/kqp/common/events + ydb/core/kqp/common/shutdown + ydb/core/kqp/provider + ydb/core/tx/long_tx_service/public + ydb/core/tx/sharding + ydb/library/yql/dq/expr_nodes + ydb/library/aclib + ydb/library/yql/core/issue + ydb/library/yql/dq/actors + ydb/library/yql/dq/common + ydb/library/yql/parser/pg_wrapper/interface + ydb/public/lib/operation_id + ydb/public/lib/operation_id/protos + ydb/core/grpc_services/cancelation + library/cpp/lwtrace + #library/cpp/lwtrace/protos +) + +YQL_LAST_ABI_VERSION() + +GENERATE_ENUM_SERIALIZATION(kqp_tx_info.h) +GENERATE_ENUM_SERIALIZATION(kqp_yql.h) + +END() + +RECURSE( + compilation + simple + events +) diff --git a/ydb/core/kqp/compile_service/ya.make b/ydb/core/kqp/compile_service/ya.make new file mode 100644 index 00000000000..3fadfdad449 --- /dev/null +++ b/ydb/core/kqp/compile_service/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + kqp_compile_actor.cpp + kqp_compile_service.cpp +) + +PEERDIR( + ydb/core/actorlib_impl + ydb/core/base + ydb/core/kqp/host + ydb/library/yql/providers/common/http_gateway +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/compute_actor/ya.make b/ydb/core/kqp/compute_actor/ya.make new file mode 100644 index 00000000000..a2f59717f2b --- /dev/null +++ b/ydb/core/kqp/compute_actor/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +SRCS( + kqp_compute_actor.cpp + kqp_compute_actor_helpers.cpp + kqp_compute_events.cpp + kqp_compute_state.cpp + kqp_pure_compute_actor.cpp + kqp_scan_compute_stat.cpp + kqp_scan_compute_manager.cpp + kqp_scan_compute_actor.cpp + kqp_scan_fetcher_actor.cpp + kqp_scan_common.cpp + kqp_scan_events.cpp +) + +PEERDIR( + ydb/core/actorlib_impl + ydb/core/base + ydb/core/kqp/runtime + ydb/core/tx/datashard + ydb/core/tx/scheme_cache + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/providers/s3/actors + ydb/library/yql/public/issue +) + +GENERATE_ENUM_SERIALIZATION(kqp_compute_state.h) +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/counters/ya.make b/ydb/core/kqp/counters/ya.make new file mode 100644 index 00000000000..dd0786c24fe --- /dev/null +++ b/ydb/core/kqp/counters/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + kqp_counters.cpp + kqp_counters.h + kqp_db_counters.h +) + +PEERDIR( + ydb/core/base + ydb/core/protos + ydb/core/sys_view/service +) + +END() diff --git a/ydb/core/kqp/executer_actor/ut/ya.make b/ydb/core/kqp/executer_actor/ut/ya.make new file mode 100644 index 00000000000..7e932be17d3 --- /dev/null +++ b/ydb/core/kqp/executer_actor/ut/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + # kqp_executer_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/common + ydb/core/kqp/host + ydb/core/kqp/ut/common + ydb/public/sdk/cpp/client/ydb_proto + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/executer_actor/ya.make b/ydb/core/kqp/executer_actor/ya.make new file mode 100644 index 00000000000..f41bb856362 --- /dev/null +++ b/ydb/core/kqp/executer_actor/ya.make @@ -0,0 +1,48 @@ +LIBRARY() + +SRCS( + kqp_data_executer.cpp + kqp_scan_executer.cpp + kqp_executer_impl.cpp + kqp_executer_stats.cpp + kqp_literal_executer.cpp + kqp_locks_helper.cpp + kqp_partition_helper.cpp + kqp_planner.cpp + kqp_planner_strategy.cpp + kqp_shards_resolver.cpp + kqp_result_channel.cpp + kqp_table_resolver.cpp + kqp_tasks_graph.cpp + kqp_tasks_validate.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/containers/absl_flat_hash + ydb/core/actorlib_impl + ydb/core/base + ydb/core/client/minikql_compile + ydb/core/formats + ydb/core/kqp/common + ydb/core/kqp/query_compiler + ydb/core/kqp/rm_service + ydb/core/kqp/topics + ydb/core/protos + ydb/core/tx/long_tx_service/public + ydb/core/ydb_convert + ydb/library/mkql_proto + ydb/library/mkql_proto/protos + ydb/library/yql/dq/actors/compute + ydb/library/yql/dq/runtime + ydb/library/yql/dq/tasks + ydb/library/yql/providers/common/http_gateway +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kqp/expr_nodes/ya.make b/ydb/core/kqp/expr_nodes/ya.make new file mode 100644 index 00000000000..a18076ebe03 --- /dev/null +++ b/ydb/core/kqp/expr_nodes/ya.make @@ -0,0 +1,50 @@ +LIBRARY() + +SRCS( + kqp_expr_nodes.h + kqp_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/dq/expr_nodes +) + +SRCDIR(ydb/library/yql/core/expr_nodes_gen) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + kqp_expr_nodes.json + kqp_expr_nodes.gen.h + kqp_expr_nodes.decl.inl.h + kqp_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN kqp_expr_nodes.json + OUT kqp_expr_nodes.gen.h + OUT kqp_expr_nodes.decl.inl.h + OUT kqp_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + kqp_expr_nodes.json + kqp_expr_nodes.gen.h + kqp_expr_nodes.decl.inl.h + kqp_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN kqp_expr_nodes.json + OUT kqp_expr_nodes.gen.h + OUT kqp_expr_nodes.decl.inl.h + OUT kqp_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/core/kqp/gateway/actors/ya.make b/ydb/core/kqp/gateway/actors/ya.make new file mode 100644 index 00000000000..2a1b7319b00 --- /dev/null +++ b/ydb/core/kqp/gateway/actors/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + scheme.cpp +) + +PEERDIR( + ydb/core/tx/tx_proxy + ydb/core/kqp/common + ydb/core/kqp/provider + ydb/library/yql/providers/common/gateway + ydb/core/tx/schemeshard + library/cpp/actors/core +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/ya.make b/ydb/core/kqp/gateway/behaviour/tablestore/operations/ya.make new file mode 100644 index 00000000000..ef81ef50a87 --- /dev/null +++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + abstract.cpp + GLOBAL add_column.cpp + GLOBAL alter_column.cpp + GLOBAL drop_column.cpp +) + +PEERDIR( + ydb/services/metadata/manager + ydb/core/formats/arrow/compression + ydb/core/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/ya.make b/ydb/core/kqp/gateway/behaviour/tablestore/ya.make new file mode 100644 index 00000000000..79ceb1a1279 --- /dev/null +++ b/ydb/core/kqp/gateway/behaviour/tablestore/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + manager.cpp + initializer.cpp + GLOBAL behaviour.cpp +) + +PEERDIR( + ydb/services/metadata/initializer + ydb/services/metadata/abstract + ydb/core/kqp/gateway/actors + ydb/core/kqp/gateway/behaviour/tablestore/operations +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/gateway/ya.make b/ydb/core/kqp/gateway/ya.make new file mode 100644 index 00000000000..684bc256ec6 --- /dev/null +++ b/ydb/core/kqp/gateway/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + kqp_gateway.cpp + kqp_ic_gateway.cpp + kqp_metadata_loader.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/actorlib_impl + ydb/core/base + ydb/core/kqp/common + ydb/core/kqp/provider + ydb/core/kqp/query_data + ydb/core/kqp/gateway/actors + ydb/core/kqp/gateway/behaviour/tablestore + ydb/library/yql/providers/result/expr_nodes +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/host/ya.make b/ydb/core/kqp/host/ya.make new file mode 100644 index 00000000000..fc7c1651006 --- /dev/null +++ b/ydb/core/kqp/host/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +SRCS( + kqp_explain_prepared.cpp + kqp_host.cpp + kqp_runner.cpp + kqp_transform.cpp + kqp_type_ann.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/kqp/common + ydb/core/kqp/opt + ydb/core/kqp/provider + ydb/core/tx/long_tx_service/public + ydb/library/yql/ast + ydb/library/yql/core/services + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/sql + ydb/library/yql/core + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/providers/common/udf_resolve + ydb/library/yql/providers/config + ydb/library/yql/providers/result/provider + ydb/library/yql/providers/s3/provider +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/node_service/ut/ya.make b/ydb/core/kqp/node_service/ut/ya.make new file mode 100644 index 00000000000..69825beeb04 --- /dev/null +++ b/ydb/core/kqp/node_service/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/kqp/node_service) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_node_ut.cpp +) + +PEERDIR( + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/node_service/ya.make b/ydb/core/kqp/node_service/ya.make new file mode 100644 index 00000000000..6c9d788df16 --- /dev/null +++ b/ydb/core/kqp/node_service/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + kqp_node_service.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/actorlib_impl + ydb/core/base + ydb/core/cms/console + ydb/core/kqp/common + ydb/core/kqp/counters + ydb/core/mind + ydb/core/protos + ydb/core/tablet + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/common/http_gateway +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kqp/opt/logical/ya.make b/ydb/core/kqp/opt/logical/ya.make new file mode 100644 index 00000000000..8b0b7ad5ab1 --- /dev/null +++ b/ydb/core/kqp/opt/logical/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + kqp_opt_log_effects.cpp + kqp_opt_log_extract.cpp + kqp_opt_log_helpers.cpp + kqp_opt_log_join.cpp + kqp_opt_log_indexes.cpp + kqp_opt_log_ranges.cpp + kqp_opt_log_ranges_predext.cpp + kqp_opt_log_sort.cpp + kqp_opt_log_sqlin.cpp + kqp_opt_log_sqlin_compact.cpp + kqp_opt_log.cpp +) + +PEERDIR( + ydb/core/kqp/common + ydb/library/yql/core/extract_predicate + ydb/library/yql/dq/common + ydb/library/yql/dq/opt +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/opt/peephole/ya.make b/ydb/core/kqp/opt/peephole/ya.make new file mode 100644 index 00000000000..e799f84970c --- /dev/null +++ b/ydb/core/kqp/opt/peephole/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + kqp_opt_peephole_wide_read.cpp + kqp_opt_peephole.cpp +) + +PEERDIR( + ydb/core/kqp/common + ydb/library/naming_conventions + ydb/library/yql/dq/opt +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/opt/physical/effects/ya.make b/ydb/core/kqp/opt/physical/effects/ya.make new file mode 100644 index 00000000000..69eceb85dad --- /dev/null +++ b/ydb/core/kqp/opt/physical/effects/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + kqp_opt_phy_delete_index.cpp + kqp_opt_phy_effects.cpp + kqp_opt_phy_indexes.cpp + kqp_opt_phy_insert_index.cpp + kqp_opt_phy_insert.cpp + kqp_opt_phy_update_index.cpp + kqp_opt_phy_update.cpp + kqp_opt_phy_upsert_index.cpp +) + +PEERDIR( + ydb/core/kqp/common + ydb/library/yql/dq/common + ydb/library/yql/dq/opt +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/opt/physical/ya.make b/ydb/core/kqp/opt/physical/ya.make new file mode 100644 index 00000000000..ad82055d6e9 --- /dev/null +++ b/ydb/core/kqp/opt/physical/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + kqp_opt_phy_build_stage.cpp + kqp_opt_phy_limit.cpp + kqp_opt_phy_olap_agg.cpp + kqp_opt_phy_olap_filter_collection.cpp + kqp_opt_phy_olap_filter.cpp + kqp_opt_phy_precompute.cpp + kqp_opt_phy_sort.cpp + kqp_opt_phy_source.cpp + kqp_opt_phy_helpers.cpp + kqp_opt_phy_stage_float_up.cpp + kqp_opt_phy.cpp +) + +PEERDIR( + ydb/core/kqp/common + ydb/core/kqp/opt/physical/effects + ydb/library/yql/dq/common + ydb/library/yql/dq/opt +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/opt/ya.make b/ydb/core/kqp/opt/ya.make new file mode 100644 index 00000000000..d04d95ec68f --- /dev/null +++ b/ydb/core/kqp/opt/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + kqp_opt.cpp + kqp_opt_build_phy_query.cpp + kqp_opt_build_txs.cpp + kqp_opt_effects.cpp + kqp_opt_kql.cpp + kqp_opt_phase.cpp + kqp_opt_phy_check.cpp + kqp_opt_phy_finalize.cpp + kqp_opt_range_legacy.cpp + kqp_query_blocks_transformer.cpp + kqp_query_plan.cpp +) + +PEERDIR( + ydb/core/kqp/common + ydb/core/kqp/opt/logical + ydb/core/kqp/opt/peephole + ydb/core/kqp/opt/physical + ydb/library/yql/dq/common + ydb/library/yql/dq/opt + ydb/core/kqp/provider +) + +YQL_LAST_ABI_VERSION() + +GENERATE_ENUM_SERIALIZATION(kqp_query_plan.h) + +END() diff --git a/ydb/core/kqp/provider/ut/ya.make b/ydb/core/kqp/provider/ut/ya.make new file mode 100644 index 00000000000..50003233113 --- /dev/null +++ b/ydb/core/kqp/provider/ut/ya.make @@ -0,0 +1,26 @@ +UNITTEST_FOR(ydb/core/kqp/provider) + +SRCS( + yql_kikimr_gateway_ut.cpp +) + +PEERDIR( + ydb/core/client/minikql_result_lib + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +END() diff --git a/ydb/core/kqp/provider/ya.make b/ydb/core/kqp/provider/ya.make new file mode 100644 index 00000000000..c7807553adb --- /dev/null +++ b/ydb/core/kqp/provider/ya.make @@ -0,0 +1,96 @@ +LIBRARY() + +SRCS( + yql_kikimr_datasink.cpp + yql_kikimr_datasource.cpp + yql_kikimr_exec.cpp + yql_kikimr_expr_nodes.h + yql_kikimr_expr_nodes.cpp + yql_kikimr_gateway.h + yql_kikimr_gateway.cpp + yql_kikimr_opt_build.cpp + yql_kikimr_opt.cpp + yql_kikimr_provider.h + yql_kikimr_provider.cpp + yql_kikimr_provider_impl.h + yql_kikimr_results.cpp + yql_kikimr_results.h + yql_kikimr_settings.cpp + yql_kikimr_settings.h + yql_kikimr_type_ann.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/protos + ydb/core/docapi + ydb/core/kqp/query_data + ydb/library/aclib + ydb/library/aclib/protos + ydb/library/binary_json + ydb/library/dynumber + ydb/library/yql/core/services + ydb/library/yql/minikql + ydb/library/yql/public/decimal + ydb/public/lib/scheme_types + ydb/public/sdk/cpp/client/ydb_topic + ydb/library/yql/core/expr_nodes + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/gateway + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/result/expr_nodes + ydb/library/yql/providers/result/provider +) + +YQL_LAST_ABI_VERSION() + +SRCDIR(ydb/library/yql/core/expr_nodes_gen) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_kikimr_expr_nodes.json + yql_kikimr_expr_nodes.gen.h + yql_kikimr_expr_nodes.decl.inl.h + yql_kikimr_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_kikimr_expr_nodes.json + OUT yql_kikimr_expr_nodes.gen.h + OUT yql_kikimr_expr_nodes.decl.inl.h + OUT yql_kikimr_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_kikimr_expr_nodes.json + yql_kikimr_expr_nodes.gen.h + yql_kikimr_expr_nodes.decl.inl.h + yql_kikimr_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_kikimr_expr_nodes.json + OUT yql_kikimr_expr_nodes.gen.h + OUT yql_kikimr_expr_nodes.decl.inl.h + OUT yql_kikimr_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +GENERATE_ENUM_SERIALIZATION(yql_kikimr_provider.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kqp/proxy_service/ut/ya.make b/ydb/core/kqp/proxy_service/ut/ya.make new file mode 100644 index 00000000000..2ff6349dd7d --- /dev/null +++ b/ydb/core/kqp/proxy_service/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/kqp/proxy_service) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +SRCS( + kqp_proxy_ut.cpp +) + +PEERDIR( + ydb/core/kqp/proxy_service + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy + ydb/public/sdk/cpp/client/draft/ydb_query + ydb/public/sdk/cpp/client/ydb_driver + ydb/services/ydb +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/proxy_service/ya.make b/ydb/core/kqp/proxy_service/ya.make new file mode 100644 index 00000000000..96ae9140e6c --- /dev/null +++ b/ydb/core/kqp/proxy_service/ya.make @@ -0,0 +1,39 @@ +LIBRARY() + +SRCS( + kqp_proxy_service.cpp + kqp_proxy_peer_stats_calculator.cpp + kqp_script_executions.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/protobuf/json + ydb/core/actorlib_impl + ydb/core/base + ydb/core/cms/console + ydb/core/kqp/common + ydb/core/kqp/common/events + ydb/core/kqp/counters + ydb/core/kqp/run_script_actor + ydb/core/mind + ydb/core/protos + ydb/core/tx/tx_proxy + ydb/core/tx/scheme_cache + ydb/core/tx/schemeshard + ydb/library/query_actor + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/public/issue + ydb/public/api/protos + ydb/public/lib/operation_id + ydb/public/lib/scheme_types + ydb/public/sdk/cpp/client/ydb_params +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kqp/query_compiler/ya.make b/ydb/core/kqp/query_compiler/ya.make new file mode 100644 index 00000000000..ebed8a8d794 --- /dev/null +++ b/ydb/core/kqp/query_compiler/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + kqp_mkql_compiler.cpp + kqp_olap_compiler.cpp + kqp_query_compiler.cpp +) + +PEERDIR( + ydb/core/formats + ydb/core/kqp/common + ydb/core/protos + ydb/library/mkql_proto + ydb/library/yql/dq/integration + ydb/library/yql/dq/opt + ydb/library/yql/dq/tasks + ydb/library/yql/minikql + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/dq/common +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/query_data/ya.make b/ydb/core/kqp/query_data/ya.make new file mode 100644 index 00000000000..195f4e93abe --- /dev/null +++ b/ydb/core/kqp/query_data/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + kqp_query_data.cpp + kqp_prepared_query.cpp + kqp_predictor.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/actorlib_impl + ydb/core/base + ydb/core/kqp/common/simple + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/proto + ydb/core/kqp/expr_nodes +) + +YQL_LAST_ABI_VERSION() + +END()
\ No newline at end of file diff --git a/ydb/core/kqp/rm_service/ut/ya.make b/ydb/core/kqp/rm_service/ut/ya.make new file mode 100644 index 00000000000..9c259fa0c3d --- /dev/null +++ b/ydb/core/kqp/rm_service/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/kqp/rm_service) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_resource_estimation_ut.cpp + kqp_rm_ut.cpp +) + +PEERDIR( + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/rm_service/ya.make b/ydb/core/kqp/rm_service/ya.make new file mode 100644 index 00000000000..9fc7b2b5f89 --- /dev/null +++ b/ydb/core/kqp/rm_service/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + kqp_resource_tracker.cpp + kqp_resource_estimation.cpp + kqp_rm_service.cpp + kqp_snapshot_manager.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/core/actorlib_impl + ydb/core/base + ydb/core/cms/console + ydb/core/kqp/common + ydb/core/kqp/counters + ydb/core/mind + ydb/core/mon + ydb/core/protos + ydb/core/tablet + ydb/core/node_whiteboard +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kqp/run_script_actor/ya.make b/ydb/core/kqp/run_script_actor/ya.make new file mode 100644 index 00000000000..6996ff272e3 --- /dev/null +++ b/ydb/core/kqp/run_script_actor/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + kqp_run_script_actor.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/core/kqp/common/events + ydb/core/kqp/executer_actor + ydb/public/api/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/runtime/ut/ya.make b/ydb/core/kqp/runtime/ut/ya.make new file mode 100644 index 00000000000..9279dbdc982 --- /dev/null +++ b/ydb/core/kqp/runtime/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/kqp/runtime) + +FORK_SUBTESTS() + +SIZE(MEDIUM) +TIMEOUT(180) + +SRCS( + kqp_spilling_file_ut.cpp + kqp_scan_data_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/basics/default + ydb/library/yql/public/udf/service/exception_policy +) + +END() diff --git a/ydb/core/kqp/runtime/ya.make b/ydb/core/kqp/runtime/ya.make new file mode 100644 index 00000000000..6fb614b70d0 --- /dev/null +++ b/ydb/core/kqp/runtime/ya.make @@ -0,0 +1,50 @@ +LIBRARY() + +SRCS( + kqp_channel_storage.cpp + kqp_compute.cpp + kqp_effects.cpp + kqp_output_stream.cpp + kqp_program_builder.cpp + kqp_read_actor.cpp + kqp_read_table.cpp + kqp_runtime_impl.h + kqp_scan_data.cpp + kqp_scan_data_meta.cpp + kqp_spilling_file.cpp + kqp_stream_lookup_actor.cpp + kqp_stream_lookup_actor.h + kqp_stream_lookup_factory.cpp + kqp_stream_lookup_factory.h + kqp_tasks_runner.cpp + kqp_transport.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/actorlib_impl + ydb/core/base + ydb/core/engine + ydb/core/engine/minikql + ydb/core/formats + ydb/core/kqp/common + ydb/core/protos + ydb/core/scheme + ydb/core/ydb_convert + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/utils + ydb/library/yql/dq/actors/protos + ydb/library/yql/dq/runtime +) + +YQL_LAST_ABI_VERSION() + +GENERATE_ENUM_SERIALIZATION(kqp_spilling.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/kqp/session_actor/ya.make b/ydb/core/kqp/session_actor/ya.make new file mode 100644 index 00000000000..96000729781 --- /dev/null +++ b/ydb/core/kqp/session_actor/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + kqp_response.cpp + kqp_session_actor.cpp + kqp_tx.cpp + kqp_worker_actor.cpp + kqp_worker_common.cpp + kqp_query_state.cpp +) + +PEERDIR( + ydb/core/docapi + ydb/core/kqp/common + ydb/library/yql/providers/common/http_gateway +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/topics/ya.make b/ydb/core/kqp/topics/ya.make new file mode 100644 index 00000000000..fc785296cd1 --- /dev/null +++ b/ydb/core/kqp/topics/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + kqp_topics.cpp + kqp_topics.h +) + +PEERDIR( + ydb/core/base +) + +YQL_LAST_ABI_VERSION() + + +END() diff --git a/ydb/core/kqp/ut/arrow/ya.make b/ydb/core/kqp/ut/arrow/ya.make new file mode 100644 index 00000000000..44bfbecb5ee --- /dev/null +++ b/ydb/core/kqp/ut/arrow/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) +SIZE(MEDIUM) + +SRCS( + kqp_arrow_in_channels_ut.cpp + kqp_types_arrow_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/common/ya.make b/ydb/core/kqp/ut/common/ya.make new file mode 100644 index 00000000000..f7d0b404c9c --- /dev/null +++ b/ydb/core/kqp/ut/common/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + json2_udf.cpp + kqp_ut_common.cpp + kqp_ut_common.h + re2_udf.cpp +) + +PEERDIR( + ydb/core/testlib + ydb/library/yql/public/udf + ydb/library/yql/utils/backtrace + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/draft + ydb/public/sdk/cpp/client/draft/ydb_query + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_topic +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/cost/ya.make b/ydb/core/kqp/ut/cost/ya.make new file mode 100644 index 00000000000..9e6e98a7ecb --- /dev/null +++ b/ydb/core/kqp/ut/cost/ya.make @@ -0,0 +1,31 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +REQUIREMENTS( + ram:32 +) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_cost_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/effects/ya.make b/ydb/core/kqp/ut/effects/ya.make new file mode 100644 index 00000000000..d3b60bda01a --- /dev/null +++ b/ydb/core/kqp/ut/effects/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_effects_ut.cpp + kqp_immediate_effects_ut.cpp + kqp_inplace_update_ut.cpp + kqp_write_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/federated_query/ya.make b/ydb/core/kqp/ut/federated_query/ya.make new file mode 100644 index 00000000000..dd07aecaf6b --- /dev/null +++ b/ydb/core/kqp/ut/federated_query/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/core/kqp) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_federated_query_ut.cpp +) + +PEERDIR( + contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3 + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy + ydb/public/sdk/cpp/client/ydb_operation + ydb/public/sdk/cpp/client/ydb_types/operation +) + +YQL_LAST_ABI_VERSION() + +INCLUDE(${ARCADIA_ROOT}/ydb/tests/tools/s3_recipe/recipe.inc) + +END() diff --git a/ydb/core/kqp/ut/indexes/ya.make b/ydb/core/kqp/ut/indexes/ya.make new file mode 100644 index 00000000000..df5dff67a58 --- /dev/null +++ b/ydb/core/kqp/ut/indexes/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_indexes_ut.cpp + kqp_indexes_multishard_ut.cpp +) + +PEERDIR( + library/cpp/threading/local_executor + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/join/ya.make b/ydb/core/kqp/ut/join/ya.make new file mode 100644 index 00000000000..ee9c559a46e --- /dev/null +++ b/ydb/core/kqp/ut/join/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_flip_join_ut.cpp + kqp_index_lookup_join_ut.cpp + kqp_join_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy + ydb/library/yql/udfs/common/digest +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/olap/ya.make b/ydb/core/kqp/ut/olap/ya.make new file mode 100644 index 00000000000..78e50bf8810 --- /dev/null +++ b/ydb/core/kqp/ut/olap/ya.make @@ -0,0 +1,33 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(100) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_olap_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +IF (SSA_RUNTIME_VERSION) + CFLAGS( + -DSSA_RUNTIME_VERSION=$SSA_RUNTIME_VERSION + ) +ENDIF() + +END() diff --git a/ydb/core/kqp/ut/opt/ya.make b/ydb/core/kqp/ut/opt/ya.make new file mode 100644 index 00000000000..18fede554bc --- /dev/null +++ b/ydb/core/kqp/ut/opt/ya.make @@ -0,0 +1,35 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_agg_ut.cpp + kqp_kv_ut.cpp + kqp_merge_ut.cpp + kqp_ne_ut.cpp + kqp_not_null_ut.cpp + kqp_ranges_ut.cpp + kqp_sort_ut.cpp + kqp_sqlin_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy + ydb/library/yql/udfs/common/re2 +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/perf/ya.make b/ydb/core/kqp/ut/perf/ya.make new file mode 100644 index 00000000000..023845f43c4 --- /dev/null +++ b/ydb/core/kqp/ut/perf/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_query_perf_ut.cpp + kqp_workload_ut.cpp +) + +PEERDIR( + library/cpp/threading/local_executor + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/pg/ya.make b/ydb/core/kqp/ut/pg/ya.make new file mode 100644 index 00000000000..b05c4cfa3c5 --- /dev/null +++ b/ydb/core/kqp/ut/pg/ya.make @@ -0,0 +1,35 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +SRCS( + kqp_pg_ut.cpp +) + +PEERDIR( + ydb/core/kqp/ut/common + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg +) + +ADDINCL( + ydb/library/yql/parser/pg_wrapper/postgresql/src/include +) + +IF (OS_WINDOWS) +CFLAGS( + "-D__thread=__declspec(thread)" + -Dfstat=microsoft_native_fstat + -Dstat=microsoft_native_stat +) +ENDIF() + +NO_COMPILER_WARNINGS() + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/kqp/ut/query/ya.make b/ydb/core/kqp/ut/query/ya.make new file mode 100644 index 00000000000..f0b745ef2ca --- /dev/null +++ b/ydb/core/kqp/ut/query/ya.make @@ -0,0 +1,36 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +REQUIREMENTS( + ram:32 +) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_explain_ut.cpp + kqp_limits_ut.cpp + kqp_params_ut.cpp + kqp_query_ut.cpp + kqp_stats_ut.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_proto + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/scan/ya.make b/ydb/core/kqp/ut/scan/ya.make new file mode 100644 index 00000000000..048d42c76b4 --- /dev/null +++ b/ydb/core/kqp/ut/scan/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_flowcontrol_ut.cpp + kqp_scan_ut.cpp + kqp_split_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/scheme/ya.make b/ydb/core/kqp/ut/scheme/ya.make new file mode 100644 index 00000000000..87d9ffef2c7 --- /dev/null +++ b/ydb/core/kqp/ut/scheme/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_acl_ut.cpp + kqp_scheme_ut.cpp +) + +PEERDIR( + library/cpp/threading/local_executor + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/service/ya.make b/ydb/core/kqp/ut/service/ya.make new file mode 100644 index 00000000000..a5df857c980 --- /dev/null +++ b/ydb/core/kqp/ut/service/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_document_api_ut.cpp + kqp_query_service_ut.cpp + kqp_service_ut.cpp +) + +PEERDIR( + library/cpp/threading/local_executor + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg + ydb/public/sdk/cpp/client/ydb_operation + ydb/public/sdk/cpp/client/ydb_types/operation +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/spilling/ya.make b/ydb/core/kqp/ut/spilling/ya.make new file mode 100644 index 00000000000..806f8591a46 --- /dev/null +++ b/ydb/core/kqp/ut/spilling/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() + +TIMEOUT(600) +SIZE(MEDIUM) + +SRCS( + kqp_scan_spilling_ut.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_proto + ydb/core/kqp + ydb/core/kqp/counters + ydb/core/kqp/host + ydb/core/kqp/provider + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/sysview/ya.make b/ydb/core/kqp/ut/sysview/ya.make new file mode 100644 index 00000000000..b7255fe5726 --- /dev/null +++ b/ydb/core/kqp/ut/sysview/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_sys_col_ut.cpp + kqp_sys_view_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/tx/ya.make b/ydb/core/kqp/ut/tx/ya.make new file mode 100644 index 00000000000..db87f326de0 --- /dev/null +++ b/ydb/core/kqp/ut/tx/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_locks_ut.cpp + kqp_mvcc_ut.cpp + kqp_tx_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ut/ya.make b/ydb/core/kqp/ut/ya.make new file mode 100644 index 00000000000..b09ddb4cfe5 --- /dev/null +++ b/ydb/core/kqp/ut/ya.make @@ -0,0 +1,20 @@ +RECURSE_FOR_TESTS( + arrow + cost + effects + federated_query + indexes + join + olap + opt + perf + pg + query + scan + scheme + service + spilling + sysview + tx + yql +) diff --git a/ydb/core/kqp/ut/yql/ya.make b/ydb/core/kqp/ut/yql/ya.make new file mode 100644 index 00000000000..77593d5518d --- /dev/null +++ b/ydb/core/kqp/ut/yql/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/kqp) + +FORK_SUBTESTS() +SPLIT_FACTOR(50) + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + kqp_pragma_ut.cpp + kqp_scripting_ut.cpp + kqp_yql_ut.cpp +) + +PEERDIR( + ydb/core/kqp + ydb/core/kqp/ut/common + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/kqp/ya.make b/ydb/core/kqp/ya.make new file mode 100644 index 00000000000..e34ec78a290 --- /dev/null +++ b/ydb/core/kqp/ya.make @@ -0,0 +1,78 @@ +LIBRARY() + +SRCS( +) + +PEERDIR( + contrib/libs/apache/arrow + library/cpp/actors/core + library/cpp/actors/helpers + library/cpp/digest/md5 + library/cpp/string_utils/base64 + library/cpp/actors/wilson + ydb/core/actorlib_impl + ydb/core/base + ydb/core/client/minikql_compile + ydb/core/engine + ydb/core/formats + ydb/core/grpc_services/local_rpc + ydb/core/kqp/common + ydb/core/kqp/compile_service + ydb/core/kqp/compute_actor + ydb/core/kqp/counters + ydb/core/kqp/executer_actor + ydb/core/kqp/expr_nodes + ydb/core/kqp/gateway + ydb/core/kqp/host + ydb/core/kqp/node_service + ydb/core/kqp/opt + ydb/core/kqp/provider + ydb/core/kqp/proxy_service + ydb/core/kqp/query_compiler + ydb/core/kqp/rm_service + ydb/core/kqp/runtime + ydb/core/kqp/session_actor + ydb/core/protos + ydb/core/sys_view/service + ydb/core/util + ydb/core/ydb_convert + ydb/library/aclib + ydb/library/yql/core/services/mounts + ydb/library/yql/public/issue + ydb/library/yql/utils/actor_log + ydb/library/yql/utils/log + ydb/public/api/protos + ydb/public/lib/base + ydb/public/lib/operation_id +) + +YQL_LAST_ABI_VERSION() + +RESOURCE( + ydb/core/kqp/kqp_default_settings.txt kqp_default_settings.txt +) + +END() + +RECURSE( + common + compile_service + compute_actor + counters + executer_actor + expr_nodes + gateway + host + node_service + opt + provider + proxy_service + rm_service + run_script_actor + runtime + session_actor +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/load_test/ut_ycsb/ya.make b/ydb/core/load_test/ut_ycsb/ya.make new file mode 100644 index 00000000000..f120fdd6d78 --- /dev/null +++ b/ydb/core/load_test/ut_ycsb/ya.make @@ -0,0 +1,38 @@ +UNITTEST_FOR(ydb/core/load_test) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/load_test + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ../ut_ycsb.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/load_test/ya.make b/ydb/core/load_test/ya.make new file mode 100644 index 00000000000..ae3a85f7d8c --- /dev/null +++ b/ydb/core/load_test/ya.make @@ -0,0 +1,56 @@ +LIBRARY() + +PEERDIR( + contrib/libs/protobuf + library/cpp/histogram/hdr + library/cpp/monlib/dynamic_counters/percentile + library/cpp/monlib/service/pages + ydb/core/base + ydb/core/blobstorage/backpressure + ydb/core/blobstorage/base + ydb/core/blobstorage/pdisk + ydb/core/control + ydb/core/keyvalue + ydb/core/kqp/common + ydb/library/workload + ydb/public/lib/base + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/ydb_proto +) + +SRCS( + aggregated_result.cpp + archive.cpp + config_examples.cpp + keyvalue_write.cpp + kqp.cpp + memory.cpp + pdisk_log.cpp + pdisk_read.cpp + pdisk_write.cpp + service_actor.cpp + group_write.cpp + vdisk_write.cpp + yql_single_query.cpp + + ycsb/actors.h + ycsb/bulk_mkql_upsert.cpp + ycsb/common.h + ycsb/common.cpp + ycsb/defs.h + ycsb/info_collector.h + ycsb/info_collector.cpp + ycsb/kqp_select.cpp + ycsb/kqp_upsert.cpp + ycsb/test_load_actor.cpp + ycsb/test_load_actor.h + ycsb/test_load_read_iterator.cpp +) + +GENERATE_ENUM_SERIALIZATION(percentile.h) + +END() + +RECURSE_FOR_TESTS( + ut_ycsb +) diff --git a/ydb/core/local_pgwire/ya.make b/ydb/core/local_pgwire/ya.make new file mode 100644 index 00000000000..e09e038df24 --- /dev/null +++ b/ydb/core/local_pgwire/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +SRCS( + local_pgwire_connection.cpp + local_pgwire.cpp + local_pgwire.h + local_pgwire_util.h + log_impl.h + pgwire_kqp_proxy.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/library/yql/public/udf + ydb/core/kqp/common/events + ydb/core/kqp/common/simple + ydb/core/kqp/executer_actor + ydb/core/grpc_services + ydb/core/grpc_services/local_rpc + ydb/core/protos + ydb/core/pgproxy + ydb/core/ydb_convert + ydb/public/api/grpc + ydb/public/lib/operation_id/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/log_backend/ya.make b/ydb/core/log_backend/ya.make new file mode 100644 index 00000000000..4a7560f8f52 --- /dev/null +++ b/ydb/core/log_backend/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + log_backend.cpp + log_backend.h + log_backend_build.cpp + log_backend_build.h +) + +PEERDIR( + library/cpp/unified_agent_client + ydb/core/base +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/metering/ut/ya.make b/ydb/core/metering/ut/ya.make new file mode 100644 index 00000000000..ae373b492f8 --- /dev/null +++ b/ydb/core/metering/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(ydb/core/metering) + +SIZE(SMALL) + +SRCS( + stream_ru_calculator_ut.cpp + time_grid_ut.cpp +) + +END() diff --git a/ydb/core/metering/ya.make b/ydb/core/metering/ya.make new file mode 100644 index 00000000000..eb51f69a76b --- /dev/null +++ b/ydb/core/metering/ya.make @@ -0,0 +1,29 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +SRCS( + bill_record.cpp + bill_record.h + metering.cpp + metering.h + stream_ru_calculator.cpp + time_grid.h +) + +GENERATE_ENUM_SERIALIZATION(bill_record.h) + +PEERDIR( + library/cpp/actors/core + library/cpp/json + library/cpp/logger + ydb/core/base +) + +RESOURCE( + ydb/core/kqp/kqp_default_settings.txt kqp_default_settings.txt +) + +END() diff --git a/ydb/core/mind/address_classification/ut/ya.make b/ydb/core/mind/address_classification/ut/ya.make new file mode 100644 index 00000000000..da9b9f9e883 --- /dev/null +++ b/ydb/core/mind/address_classification/ut/ya.make @@ -0,0 +1,29 @@ +UNITTEST_FOR(ydb/core/mind/address_classification) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1200) + SIZE(LARGE) + SPLIT_FACTOR(20) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + REQUIREMENTS(ram:16) +ENDIF() + +PEERDIR( + library/cpp/actors/http + ydb/core/mind/address_classification + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + net_classifier_ut.cpp +) + +END() diff --git a/ydb/core/mind/address_classification/ya.make b/ydb/core/mind/address_classification/ya.make new file mode 100644 index 00000000000..e52aefb18f4 --- /dev/null +++ b/ydb/core/mind/address_classification/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + counters.cpp + net_classifier.cpp +) + +GENERATE_ENUM_SERIALIZATION(net_classifier.h) + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/dynamic_counters + ydb/core/base + ydb/core/cms/console + ydb/core/mon + ydb/core/protos + ydb/core/util +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/mind/bscontroller/ut/ya.make b/ydb/core/mind/bscontroller/ut/ya.make new file mode 100644 index 00000000000..8aee4b7b252 --- /dev/null +++ b/ydb/core/mind/bscontroller/ut/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/core/mind/bscontroller) + +SRCS( + grouper_ut.cpp + group_mapper_ut.cpp + mv_object_map_ut.cpp +) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/actors/util + ydb/core/yql_testlib +) + +END() diff --git a/ydb/core/mind/bscontroller/ut_bscontroller/ya.make b/ydb/core/mind/bscontroller/ut_bscontroller/ya.make new file mode 100644 index 00000000000..025140432bb --- /dev/null +++ b/ydb/core/mind/bscontroller/ut_bscontroller/ya.make @@ -0,0 +1,38 @@ +UNITTEST() + +FORK_SUBTESTS() + +REQUIREMENTS( + cpu:4 + ram:16 +) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + SIZE(LARGE) + TAG(ya:fat) + TIMEOUT(1800) +ELSE() + SIZE(MEDIUM) + TIMEOUT(600) +ENDIF() + +SRCS( + main.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/blobstorage + ydb/core/blobstorage/base + ydb/core/blobstorage/dsproxy/mock + ydb/core/mind/bscontroller + ydb/core/protos + ydb/core/testlib/default + ydb/core/testlib/basics +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(network:full) + +END() diff --git a/ydb/core/mind/bscontroller/ut_selfheal/ya.make b/ydb/core/mind/bscontroller/ut_selfheal/ya.make new file mode 100644 index 00000000000..7a99882d128 --- /dev/null +++ b/ydb/core/mind/bscontroller/ut_selfheal/ya.make @@ -0,0 +1,29 @@ +UNITTEST() + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +SRCS( + main.cpp + self_heal_actor_ut.cpp + defs.h + env.h + events.h + node_warden_mock.h + timer_actor.h + vdisk_mock.h +) + +PEERDIR( + ydb/core/blobstorage/dsproxy/mock + ydb/core/blobstorage/pdisk/mock + ydb/core/mind/bscontroller + ydb/core/tx/scheme_board + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/mind/bscontroller/ya.make b/ydb/core/mind/bscontroller/ya.make new file mode 100644 index 00000000000..b9bf78ca9c5 --- /dev/null +++ b/ydb/core/mind/bscontroller/ya.make @@ -0,0 +1,87 @@ +LIBRARY() + +SRCS( + bsc.cpp + bsc.h + cmds_box.cpp + cmds_drive_status.cpp + cmds_host_config.cpp + cmds_storage_pool.cpp + config_cmd.cpp + config.cpp + config_fit_groups.cpp + config_fit_pdisks.cpp + config.h + defs.h + diff.h + disk_metrics.cpp + drop_donor.cpp + error.h + get_group.cpp + grouper.cpp + grouper.h + group_layout_checker.cpp + group_layout_checker.h + group_mapper.cpp + group_mapper.h + group_metrics_exchange.cpp + group_reconfigure_wipe.cpp + impl.h + indir.h + init_scheme.cpp + layout_helpers.h + layout_helpers.cpp + load_everything.cpp + migrate.cpp + monitoring.cpp + mood.h + mv_object_map.h + node_report.cpp + propose_group_key.cpp + register_node.cpp + request_controller_info.cpp + resources.h + scheme.h + scrub.cpp + select_groups.cpp + select_groups.h + self_heal.cpp + self_heal.h + stat_processor.cpp + stat_processor.h + storage_pool_stat.h + storage_stats_calculator.cpp + sys_view.cpp + sys_view.h + table_merger.h + types.h + update_group_latencies.cpp + update_last_seen_ready.cpp + update_seen_operational.cpp + vdisk_status_tracker.h + virtual_group.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/base/services + ydb/core/blobstorage + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/blob_depot + ydb/core/engine/minikql + ydb/core/protos + ydb/core/sys_view/common + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx/tx_proxy +) + +END() + +RECURSE_FOR_TESTS( + ut + ut_bscontroller + ut_selfheal +) diff --git a/ydb/core/mind/hive/ut/ya.make b/ydb/core/mind/hive/ut/ya.make new file mode 100644 index 00000000000..36823b02ffe --- /dev/null +++ b/ydb/core/mind/hive/ut/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/core/mind/hive) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/actors/helpers + ydb/core/base + ydb/core/mind + ydb/core/mind/hive + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + sequencer_ut.cpp + storage_pool_info_ut.cpp + hive_ut.cpp + hive_impl_ut.cpp +) + +END() diff --git a/ydb/core/mind/hive/ya.make b/ydb/core/mind/hive/ya.make new file mode 100644 index 00000000000..1520ea68b7d --- /dev/null +++ b/ydb/core/mind/hive/ya.make @@ -0,0 +1,100 @@ +LIBRARY() + +SRCS( + balancer.cpp + balancer.h + boot_queue.cpp + boot_queue.h + domain_info.h + drain.cpp + fill.cpp + hive.cpp + hive.h + hive_domains.cpp + hive_domains.h + hive_events.h + hive_impl.cpp + hive_impl.h + hive_log.cpp + hive_log.h + hive_schema.h + hive_statics.cpp + hive_transactions.h + leader_tablet_info.cpp + leader_tablet_info.h + metrics.h + monitoring.cpp + node_info.cpp + node_info.h + sequencer.cpp + sequencer.h + follower_group.h + follower_tablet_info.cpp + follower_tablet_info.h + storage_group_info.cpp + storage_group_info.h + storage_pool_info.cpp + storage_pool_info.h + tablet_info.cpp + tablet_info.h + tx__adopt_tablet.cpp + tx__block_storage_result.cpp + tx__configure_subdomain.cpp + tx__create_tablet.cpp + tx__cut_tablet_history.cpp + tx__delete_tablet.cpp + tx__delete_tablet_result.cpp + tx__disconnect_node.cpp + tx__init_scheme.cpp + tx__kill_node.cpp + tx__load_everything.cpp + tx__lock_tablet.cpp + tx__process_boot_queue.cpp + tx__process_pending_operations.cpp + tx__reassign_groups.cpp + tx__reassign_groups_on_decommit.cpp + tx__register_node.cpp + tx__release_tablets.cpp + tx__release_tablets_reply.cpp + tx__request_tablet_owners.cpp + tx__request_tablet_seq.cpp + tx__response_tablet_seq.cpp + tx__restart_tablet.cpp + tx__seize_tablets.cpp + tx__seize_tablets_reply.cpp + tx__resume_tablet.cpp + tx__start_tablet.cpp + tx__status.cpp + tx__stop_tablet.cpp + tx__switch_drain.cpp + tx__sync_tablets.cpp + tx__tablet_owners_reply.cpp + tx__unlock_tablet.cpp + tx__update_domain.cpp + tx__update_tablet_groups.cpp + tx__update_tablet_metrics.cpp + tx__update_tablet_status.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/json + library/cpp/monlib/dynamic_counters + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/crypto + ydb/core/blobstorage/nodewarden + ydb/core/engine/minikql + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/sys_view/common + ydb/core/tablet + ydb/core/tablet_flat +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/mind/ut/ya.make b/ydb/core/mind/ut/ya.make new file mode 100644 index 00000000000..7f08a634199 --- /dev/null +++ b/ydb/core/mind/ut/ya.make @@ -0,0 +1,40 @@ +UNITTEST_FOR(ydb/core/mind) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + SPLIT_FACTOR(80) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + SPLIT_FACTOR(80) + TIMEOUT(600) + SIZE(MEDIUM) + REQUIREMENTS( + cpu:4 + ram:16 + ) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default +) + +SRCS( + node_broker_ut.cpp + tenant_ut_local.cpp + tenant_ut_pool.cpp + tenant_node_enumeration_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/mind/ut_fat/ya.make b/ydb/core/mind/ut_fat/ya.make new file mode 100644 index 00000000000..0615c97b3c5 --- /dev/null +++ b/ydb/core/mind/ut_fat/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/core/mind) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/crypto + ydb/core/blobstorage/nodewarden + ydb/core/blobstorage/pdisk + ydb/core/blobstorage/vdisk/common + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + blobstorage_node_warden_ut_fat.cpp +) + +END() diff --git a/ydb/core/mind/ya.make b/ydb/core/mind/ya.make new file mode 100644 index 00000000000..c49ee3fe41b --- /dev/null +++ b/ydb/core/mind/ya.make @@ -0,0 +1,85 @@ +LIBRARY() + +SRCS( + configured_tablet_bootstrapper.cpp + configured_tablet_bootstrapper.h + defs.h + dynamic_nameserver.cpp + dynamic_nameserver.h + dynamic_nameserver_impl.h + dynamic_nameserver_mon.cpp + labels_maintainer.cpp + labels_maintainer.h + lease_holder.cpp + lease_holder.h + local.cpp + local.h + node_broker.cpp + node_broker.h + node_broker_impl.h + node_broker__extend_lease.cpp + node_broker__init_scheme.cpp + node_broker__load_state.cpp + node_broker__register_node.cpp + node_broker__scheme.h + node_broker__update_config.cpp + node_broker__update_config_subscription.cpp + node_broker__update_epoch.cpp + table_adapter.h + tenant_node_enumeration.cpp + tenant_node_enumeration.h + tenant_pool.h + tenant_pool.cpp + tenant_slot_broker.cpp + tenant_slot_broker.h + tenant_slot_broker_impl.h + tenant_slot_broker__alter_tenant.cpp + tenant_slot_broker__assign_free_slots.cpp + tenant_slot_broker__check_slot_status.cpp + tenant_slot_broker__init_scheme.cpp + tenant_slot_broker__load_state.cpp + tenant_slot_broker__scheme.h + tenant_slot_broker__update_config.cpp + tenant_slot_broker__update_pool_status.cpp + tenant_slot_broker__update_node_location.cpp + tenant_slot_broker__update_slot_status.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/actorlib_impl + ydb/core/base + ydb/core/blobstorage + ydb/core/blobstorage/crypto + ydb/core/blobstorage/dsproxy/mock + ydb/core/blobstorage/groupinfo + ydb/core/blobstorage/incrhuge + ydb/core/blobstorage/pdisk + ydb/core/engine/minikql + ydb/core/kesus/tablet + ydb/core/keyvalue + ydb/core/mind/bscontroller + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/sys_view/processor + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/test_tablet + ydb/core/tx/replication/controller + ydb/core/tx/scheme_board + ydb/core/tx/scheme_cache + ydb/core/tx/schemeshard +) + +END() + +RECURSE( + address_classification + bscontroller + hive +) + +RECURSE_FOR_TESTS( + ut + ut_fat +) diff --git a/ydb/core/mon/ya.make b/ydb/core/mon/ya.make new file mode 100644 index 00000000000..0fcdd04da92 --- /dev/null +++ b/ydb/core/mon/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + async_http_mon.cpp + async_http_mon.h + mon.cpp + mon.h + sync_http_mon.cpp + sync_http_mon.h + crossref.cpp + crossref.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/lwtrace/mon + library/cpp/string_utils/url + ydb/core/base + ydb/core/protos + ydb/library/aclib +) + +END() diff --git a/ydb/core/mon_alloc/ya.make b/ydb/core/mon_alloc/ya.make new file mode 100644 index 00000000000..b5e1f8f188d --- /dev/null +++ b/ydb/core/mon_alloc/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +IF (PROFILE_MEMORY_ALLOCATIONS) + CFLAGS( + -DPROFILE_MEMORY_ALLOCATIONS + ) +ENDIF() + +SRCS( + monitor.cpp + profiler.cpp + stats.cpp + tcmalloc.cpp +) + +PEERDIR( + contrib/libs/tcmalloc/malloc_extension + library/cpp/actors/core + library/cpp/actors/prof + library/cpp/html/pcdata + library/cpp/lfalloc/alloc_profiler + library/cpp/lfalloc/dbg_info + library/cpp/malloc/api + library/cpp/monlib/service/pages + library/cpp/ytalloc/api + ydb/core/base + ydb/core/control +) + +END() diff --git a/ydb/core/node_whiteboard/ya.make b/ydb/core/node_whiteboard/ya.make new file mode 100644 index 00000000000..84e53475891 --- /dev/null +++ b/ydb/core/node_whiteboard/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + node_whiteboard.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/helpers + library/cpp/actors/interconnect + library/cpp/actors/protos + library/cpp/deprecated/enum_codegen + library/cpp/logger + library/cpp/lwtrace/mon + library/cpp/random_provider + library/cpp/time_provider + ydb/core/base + ydb/core/base/services + ydb/core/blobstorage/base + ydb/core/blobstorage/groupinfo + ydb/core/debug + ydb/core/erasure + ydb/core/protos +) + +END() diff --git a/ydb/core/persqueue/codecs/ut/ya.make b/ydb/core/persqueue/codecs/ut/ya.make new file mode 100644 index 00000000000..3c1bee78174 --- /dev/null +++ b/ydb/core/persqueue/codecs/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(ydb/core/persqueue/codecs) + +FORK_SUBTESTS() + +PEERDIR( +) + +SRCS( + codecs_ut.cpp +) + +END() diff --git a/ydb/core/persqueue/codecs/ya.make b/ydb/core/persqueue/codecs/ya.make new file mode 100644 index 00000000000..fffacc38a7c --- /dev/null +++ b/ydb/core/persqueue/codecs/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + pqv1.cpp +) + +PEERDIR( + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_persqueue_core +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/persqueue/config/ya.make b/ydb/core/persqueue/config/ya.make new file mode 100644 index 00000000000..42b33cd67e3 --- /dev/null +++ b/ydb/core/persqueue/config/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + config.h + config.cpp +) + +PEERDIR( + ydb/core/protos +) + +END() diff --git a/ydb/core/persqueue/events/ya.make b/ydb/core/persqueue/events/ya.make new file mode 100644 index 00000000000..12336932783 --- /dev/null +++ b/ydb/core/persqueue/events/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/keyvalue + ydb/core/protos + ydb/core/tablet + ydb/public/api/protos + ydb/library/persqueue/topic_parser +) + +END() diff --git a/ydb/core/persqueue/partition_key_range/ya.make b/ydb/core/persqueue/partition_key_range/ya.make new file mode 100644 index 00000000000..85b0452aab3 --- /dev/null +++ b/ydb/core/persqueue/partition_key_range/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + partition_key_range.cpp +) + +PEERDIR( + ydb/core/protos + ydb/core/scheme +) + +END() diff --git a/ydb/core/persqueue/ut/common/ya.make b/ydb/core/persqueue/ut/common/ya.make new file mode 100644 index 00000000000..8be2c7c19d8 --- /dev/null +++ b/ydb/core/persqueue/ut/common/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + pq_ut_common.cpp + pq_ut_common.h +) + +PEERDIR( + ydb/core/testlib + ydb/core/persqueue +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/persqueue/ut/slow/ya.make b/ydb/core/persqueue/ut/slow/ya.make new file mode 100644 index 00000000000..071a52f030c --- /dev/null +++ b/ydb/core/persqueue/ut/slow/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/core/persqueue) + +FORK_SUBTESTS() + +SPLIT_FACTOR(20) + +SIZE(LARGE) + +TAG(ya:fat) + +TIMEOUT(3600) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/persqueue/ut/common + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + pq_ut.cpp +) + +END() diff --git a/ydb/core/persqueue/ut/ya.make b/ydb/core/persqueue/ut/ya.make new file mode 100644 index 00000000000..41413c75f82 --- /dev/null +++ b/ydb/core/persqueue/ut/ya.make @@ -0,0 +1,53 @@ +UNITTEST_FOR(ydb/core/persqueue) + +FORK_SUBTESTS() + +SPLIT_FACTOR(40) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + SIZE(LARGE) + TAG(ya:fat) + TIMEOUT(3000) +ELSE() + SIZE(MEDIUM) + TIMEOUT(600) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/persqueue/ut/common + ydb/core/testlib/default + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils +) + +YQL_LAST_ABI_VERSION() + +SRCS( + counters_ut.cpp + pqtablet_mock.cpp + internals_ut.cpp + make_config.cpp + metering_sink_ut.cpp + mirrorer_ut.cpp + pq_ut.cpp + partition_ut.cpp + pqtablet_ut.cpp + quota_tracker_ut.cpp + sourceid_ut.cpp + type_codecs_ut.cpp + user_info_ut.cpp +) + +RESOURCE( + ydb/core/persqueue/ut/resources/counters_datastreams.html counters_datastreams.html + ydb/core/persqueue/ut/resources/counters_pqproxy_firstclass.html counters_pqproxy_firstclass.html + ydb/core/persqueue/ut/resources/counters_topics.html counters_topics.html + + ydb/core/persqueue/ut/resources/counters_pqproxy.html counters_pqproxy.html + + ydb/core/persqueue/ut/resources/counters_labeled.json counters_labeled.json +) + +END() diff --git a/ydb/core/persqueue/writer/ya.make b/ydb/core/persqueue/writer/ya.make new file mode 100644 index 00000000000..6fe2de24813 --- /dev/null +++ b/ydb/core/persqueue/writer/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + source_id_encoding.cpp + metadata_initializers.cpp + writer.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/string_utils/base64 + ydb/core/base + ydb/core/persqueue/events + ydb/core/protos + ydb/public/lib/base +) + +END() diff --git a/ydb/core/persqueue/ya.make b/ydb/core/persqueue/ya.make new file mode 100644 index 00000000000..520b06b0789 --- /dev/null +++ b/ydb/core/persqueue/ya.make @@ -0,0 +1,64 @@ +LIBRARY() + +SRCS( + actor_persqueue_client_iface.h + blob.cpp + cluster_tracker.cpp + event_helpers.cpp + header.cpp + metering_sink.cpp + mirrorer.cpp + mirrorer.h + ownerinfo.cpp + partition_init.cpp + partition_monitoring.cpp + partition_read.cpp + partition_write.cpp + partition.cpp + percentile_counter.cpp + pq.cpp + pq_database.cpp + pq_impl.cpp + pq_l2_cache.cpp + quota_tracker.cpp + read_balancer.cpp + read_speed_limiter.cpp + sourceid.cpp + subscriber.cpp + transaction.cpp + type_codecs_defs.cpp + user_info.cpp + utils.cpp + write_meta.cpp +) + +GENERATE_ENUM_SERIALIZATION(sourceid.h) + +PEERDIR( + library/cpp/actors/core + library/cpp/html/pcdata + library/cpp/json + ydb/core/base + ydb/core/engine/minikql + ydb/core/keyvalue + ydb/core/kqp/common + ydb/core/metering + ydb/core/persqueue/codecs + ydb/core/persqueue/config + ydb/core/persqueue/events + ydb/core/persqueue/partition_key_range + ydb/core/persqueue/writer + ydb/core/protos + ydb/library/logger + ydb/library/persqueue/counter_time_keeper + ydb/library/persqueue/topic_parser + ydb/public/lib/base + ydb/public/sdk/cpp/client/ydb_persqueue_core +) + +END() + +RECURSE_FOR_TESTS( + ut + ut/slow +) diff --git a/ydb/core/pgproxy/ut/ya.make b/ydb/core/pgproxy/ut/ya.make new file mode 100644 index 00000000000..d1f543e9f2a --- /dev/null +++ b/ydb/core/pgproxy/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(ydb/core/pgproxy) + +PEERDIR( + library/cpp/actors/testlib + ydb/core/protos +) + +SRCS( + pg_proxy_ut.cpp +) + +END() diff --git a/ydb/core/pgproxy/ya.make b/ydb/core/pgproxy/ya.make new file mode 100644 index 00000000000..e84082c6627 --- /dev/null +++ b/ydb/core/pgproxy/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + pg_connection.cpp + pg_connection.h + pg_listener.cpp + pg_listener.h + pg_log_impl.h + pg_log.h + pg_proxy_config.h + pg_proxy_events.h + pg_proxy_impl.h + pg_proxy_ssl.h + pg_proxy_types.cpp + pg_proxy_types.h + pg_proxy.cpp + pg_proxy.h + pg_sock64.h + pg_stream.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/protos + ydb/core/base + ydb/core/protos +) + +END() + +RECURSE_FOR_TESTS(ut) diff --git a/ydb/core/protos/out/ya.make b/ydb/core/protos/out/ya.make new file mode 100644 index 00000000000..9f60e91e84d --- /dev/null +++ b/ydb/core/protos/out/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + out.cpp + out_long_tx_service.cpp + out_sequenceshard.cpp +) + +PEERDIR( + ydb/core/protos +) + +END() diff --git a/ydb/core/protos/ya.make b/ydb/core/protos/ya.make new file mode 100644 index 00000000000..d0918753599 --- /dev/null +++ b/ydb/core/protos/ya.make @@ -0,0 +1,154 @@ +PROTO_LIBRARY() + +GRPC() + +IF (OS_WINDOWS) + NO_OPTIMIZE_PY_PROTOS() +ENDIF() + +SRCS( + alloc.proto + base.proto + bind_channel_storage_pool.proto + blob_depot.proto + blob_depot_config.proto + blobstorage.proto + blobstorage_controller.proto + blobstorage_disk.proto + blobstorage_disk_color.proto + blobstorage_pdisk_config.proto + blobstorage_vdisk_config.proto + blobstorage_vdisk_internal.proto + blobstorage_config.proto + blockstore_config.proto + filestore_config.proto + bootstrapper.proto + change_exchange.proto + channel_purpose.proto + cms.proto + config.proto + config_units.proto + console.proto + console_base.proto + console_config.proto + console_tenant.proto + counters_tx_allocator.proto + counters_blob_depot.proto + counters_bs_controller.proto + counters_cms.proto + counters_coordinator.proto + counters_columnshard.proto + counters_datashard.proto + counters_hive.proto + counters_kesus.proto + counters_keyvalue.proto + counters_pq.proto + counters_replication.proto + counters_schemeshard.proto + counters_sequenceshard.proto + counters_sysview_processor.proto + counters_testshard.proto + counters_tx_proxy.proto + counters_mediator.proto + counters.proto + database_basic_sausage_metainfo.proto + datashard_load.proto + drivemodel.proto + export.proto + external_sources.proto + flat_tx_scheme.proto + flat_scheme_op.proto + health.proto + hive.proto + http_config.proto + import.proto + index_builder.proto + issue_id.proto + kesus.proto + kqp_physical.proto + kqp_stats.proto + kqp.proto + labeled_counters.proto + load_test.proto + local.proto + long_tx_service.proto + metrics.proto + minikql_engine.proto + mon.proto + msgbus.proto + msgbus_health.proto + msgbus_kv.proto + msgbus_pq.proto + netclassifier.proto + node_broker.proto + node_limits.proto + profiler.proto + query_stats.proto + replication.proto + resource_broker.proto + scheme_log.proto + scheme_type_metadata.proto + scheme_type_operation.proto + serverless_proxy_config.proto + services.proto + shared_cache.proto + sqs.proto + follower_group.proto + ssa.proto + statestorage.proto + stream.proto + subdomains.proto + table_stats.proto + tablet.proto + tablet_counters.proto + tablet_counters_aggregator.proto + tablet_database.proto + tablet_pipe.proto + tablet_tracing_signals.proto + tablet_tx.proto + tenant_pool.proto + tenant_slot_broker.proto + test_shard.proto + tracing.proto + node_whiteboard.proto + tx.proto + tx_columnshard.proto + tx_datashard.proto + tx_mediator_timecast.proto + tx_proxy.proto + tx_scheme.proto + tx_sequenceshard.proto + type_info.proto + pdiskfit.proto + pqconfig.proto + auth.proto + key.proto + grpc.proto + grpc_pq_old.proto + grpc_status_proxy.proto + ydb_result_set_old.proto + ydb_table_impl.proto + scheme_board.proto + scheme_board_mon.proto + sys_view.proto +) + +GENERATE_ENUM_SERIALIZATION(blobstorage_pdisk_config.pb.h) +GENERATE_ENUM_SERIALIZATION(datashard_load.pb.h) + +PEERDIR( + library/cpp/actors/protos + ydb/core/fq/libs/config/protos + ydb/library/login/protos + ydb/library/mkql_proto/protos + ydb/public/api/protos + ydb/library/yql/core/issue/protos + ydb/library/yql/dq/actors/protos + ydb/library/yql/dq/proto + ydb/library/yql/public/issue/protos + ydb/library/yql/public/types +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/public_http/protos/ya.make b/ydb/core/public_http/protos/ya.make new file mode 100644 index 00000000000..d71b5c9d9ce --- /dev/null +++ b/ydb/core/public_http/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +SRCS( + fq.proto +) + +PEERDIR( + ydb/core/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/public_http/ut/ya.make b/ydb/core/public_http/ut/ya.make new file mode 100644 index 00000000000..57d1d9846b9 --- /dev/null +++ b/ydb/core/public_http/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(ydb/core/public_http) + +SIZE(SMALL) + +SRCS( + http_router_ut.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy + ydb/services/kesus + ydb/services/persqueue_cluster_discovery +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/public_http/ya.make b/ydb/core/public_http/ya.make new file mode 100644 index 00000000000..259f1b48da5 --- /dev/null +++ b/ydb/core/public_http/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + +SRCS( + http_req.cpp + http_req.h + http_router.cpp + http_router.h + http_service.cpp + http_service.h + grpc_request_context_wrapper.cpp + grpc_request_context_wrapper.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/http + library/cpp/protobuf/json + library/cpp/resource + ydb/core/base + ydb/core/fq/libs/result_formatter + ydb/core/grpc_services/local_rpc + ydb/core/http_proxy + ydb/core/protos + ydb/core/public_http/protos + ydb/core/viewer/json + ydb/library/yql/public/issue + ydb/public/sdk/cpp/client/ydb_types + +) + +RESOURCE( + openapi/openapi.yaml resources/openapi.yaml +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/quoter/quoter_service_bandwidth_test/ya.make b/ydb/core/quoter/quoter_service_bandwidth_test/ya.make new file mode 100644 index 00000000000..4852588b071 --- /dev/null +++ b/ydb/core/quoter/quoter_service_bandwidth_test/ya.make @@ -0,0 +1,20 @@ +PROGRAM() + +PEERDIR( + library/cpp/colorizer + library/cpp/getopt + ydb/core/base + ydb/core/kesus/tablet + ydb/core/quoter + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + main.cpp + quota_requester.cpp + server.cpp +) + +END() diff --git a/ydb/core/quoter/ut/ya.make b/ydb/core/quoter/ut/ya.make new file mode 100644 index 00000000000..c30a84758ed --- /dev/null +++ b/ydb/core/quoter/ut/ya.make @@ -0,0 +1,33 @@ +# Disable test on windows until DEVTOOLS-5591 and DEVTOOLS-5388 will be fixed. +IF (NOT OS_WINDOWS) + UNITTEST_FOR(ydb/core/quoter) + + PEERDIR( + library/cpp/testing/gmock_in_unittest + ydb/core/testlib/default + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + kesus_quoter_ut.cpp + quoter_service_ut.cpp + ut_helpers.cpp + ) + + # reserve cpu for speed test + + REQUIREMENTS(cpu:4) + + IF (WITH_VALGRIND) + SIZE(LARGE) + TIMEOUT(2400) + TAG(ya:fat) + SPLIT_FACTOR(20) + ELSE() + SIZE(MEDIUM) + TIMEOUT(600) + ENDIF() + + END() +ENDIF() diff --git a/ydb/core/quoter/ya.make b/ydb/core/quoter/ya.make new file mode 100644 index 00000000000..bfc2f307a98 --- /dev/null +++ b/ydb/core/quoter/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + debug_info.cpp + defs.h + kesus_quoter_proxy.cpp + probes.cpp + quoter_service.cpp + quoter_service.h + quoter_service_impl.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/containers/ring_buffer + ydb/core/base + ydb/core/kesus/tablet + ydb/core/tx/scheme_cache + ydb/core/util + ydb/library/yql/public/issue +) + +END() + +RECURSE( + quoter_service_bandwidth_test +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/scheme/ut/ya.make b/ydb/core/scheme/ut/ya.make new file mode 100644 index 00000000000..20fb7bc617d --- /dev/null +++ b/ydb/core/scheme/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/scheme) + +FORK_SUBTESTS() + +SIZE(SMALL) + +PEERDIR( + ydb/core/scheme + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +SRCS( + scheme_borders_ut.cpp + scheme_tablecell_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/scheme/ya.make b/ydb/core/scheme/ya.make new file mode 100644 index 00000000000..d20674f1237 --- /dev/null +++ b/ydb/core/scheme/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +SRCS( + scheme_borders.cpp + scheme_tablecell.cpp + scheme_tabledefs.cpp + scheme_types_defs.cpp + scheme_type_info.cpp + scheme_types_proto.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/charset + library/cpp/containers/bitseq + library/cpp/deprecated/enum_codegen + library/cpp/yson + ydb/core/base + ydb/core/scheme_types + ydb/core/util + ydb/library/aclib + ydb/library/yql/parser/pg_wrapper/interface + ydb/public/lib/scheme_types +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/scheme_types/ya.make b/ydb/core/scheme_types/ya.make new file mode 100644 index 00000000000..98a13ddf349 --- /dev/null +++ b/ydb/core/scheme_types/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + scheme_type_metadata.cpp + scheme_type_registry.cpp + scheme_types_defs.cpp +) + +PEERDIR( + ydb/public/lib/scheme_types +) + +END() diff --git a/ydb/core/security/ut/ya.make b/ydb/core/security/ut/ya.make new file mode 100644 index 00000000000..d5aab13f605 --- /dev/null +++ b/ydb/core/security/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(ydb/core/security) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ticket_parser_ut.cpp +) + +END() diff --git a/ydb/core/security/ya.make b/ydb/core/security/ya.make new file mode 100644 index 00000000000..58a6e02b13f --- /dev/null +++ b/ydb/core/security/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + login_page.cpp + login_page.h + secure_request.h + ticket_parser_impl.h + ticket_parser.cpp + ticket_parser.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/http + library/cpp/monlib/service/pages + library/cpp/openssl/io + ydb/core/base + ydb/core/protos + ydb/library/ycloud/api + ydb/library/ycloud/impl + ydb/library/aclib + ydb/library/aclib/protos + ydb/library/login + ydb/library/security +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/sys_view/common/ya.make b/ydb/core/sys_view/common/ya.make new file mode 100644 index 00000000000..eda588a20e3 --- /dev/null +++ b/ydb/core/sys_view/common/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + common.h + events.h + keys.h + path.h + scan_actor_base_impl.h + schema.h + schema.cpp + utils.h + processor_scan.h +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/core/tablet_flat + library/cpp/deprecated/atomic +) + +END() diff --git a/ydb/core/sys_view/nodes/ya.make b/ydb/core/sys_view/nodes/ya.make new file mode 100644 index 00000000000..1dec3773bdb --- /dev/null +++ b/ydb/core/sys_view/nodes/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + nodes.h + nodes.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/kqp/runtime + ydb/core/sys_view/common +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/sys_view/partition_stats/ut/ya.make b/ydb/core/sys_view/partition_stats/ut/ya.make new file mode 100644 index 00000000000..757dd234f8c --- /dev/null +++ b/ydb/core/sys_view/partition_stats/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/sys_view/partition_stats) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + partition_stats_ut.cpp +) + +END() diff --git a/ydb/core/sys_view/partition_stats/ya.make b/ydb/core/sys_view/partition_stats/ya.make new file mode 100644 index 00000000000..25f1d4c0cff --- /dev/null +++ b/ydb/core/sys_view/partition_stats/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + partition_stats.h + partition_stats.cpp + top_partitions.h + top_partitions.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/kqp/runtime + ydb/core/sys_view/common +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/sys_view/processor/ya.make b/ydb/core/sys_view/processor/ya.make new file mode 100644 index 00000000000..29bc672d1cf --- /dev/null +++ b/ydb/core/sys_view/processor/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +SRCS( + processor.h + processor.cpp + processor_impl.h + processor_impl.cpp + schema.h + schema.cpp + db_counters.cpp + tx_init.cpp + tx_init_schema.cpp + tx_configure.cpp + tx_collect.cpp + tx_aggregate.cpp + tx_interval_summary.cpp + tx_interval_metrics.cpp + tx_top_partitions.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/engine/minikql + ydb/core/grpc_services/counters + ydb/core/kqp/counters + ydb/core/protos + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx/scheme_cache +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/sys_view/query_stats/ut/ya.make b/ydb/core/sys_view/query_stats/ut/ya.make new file mode 100644 index 00000000000..9ad3289518b --- /dev/null +++ b/ydb/core/sys_view/query_stats/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/sys_view/query_stats) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + query_stats_ut.cpp +) + +END() diff --git a/ydb/core/sys_view/query_stats/ya.make b/ydb/core/sys_view/query_stats/ya.make new file mode 100644 index 00000000000..786fe5b25ed --- /dev/null +++ b/ydb/core/sys_view/query_stats/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + query_metrics.h + query_metrics.cpp + query_stats.h + query_stats.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/kqp/runtime + ydb/core/sys_view/common + ydb/core/sys_view/service +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/sys_view/service/ut/ya.make b/ydb/core/sys_view/service/ut/ya.make new file mode 100644 index 00000000000..e3126cd297e --- /dev/null +++ b/ydb/core/sys_view/service/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(ydb/core/sys_view/service) + +FORK_SUBTESTS() +SIZE(MEDIUM) +TIMEOUT(600) + +PEERDIR( + library/cpp/testing/unittest +) + +SRCS( + query_history_ut.cpp +) + +END() diff --git a/ydb/core/sys_view/service/ya.make b/ydb/core/sys_view/service/ya.make new file mode 100644 index 00000000000..af440357fd4 --- /dev/null +++ b/ydb/core/sys_view/service/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + db_counters.h + db_counters.cpp + ext_counters.h + ext_counters.cpp + query_history.h + query_interval.h + query_interval.cpp + sysview_service.h + sysview_service.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/library/aclib/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/sys_view/storage/ya.make b/ydb/core/sys_view/storage/ya.make new file mode 100644 index 00000000000..1b4d70991c5 --- /dev/null +++ b/ydb/core/sys_view/storage/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + groups.h + groups.cpp + pdisks.h + pdisks.cpp + storage_pools.h + storage_pools.cpp + storage_stats.h + storage_stats.cpp + vslots.h + vslots.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/kqp/runtime + ydb/core/sys_view/common +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/sys_view/tablets/ya.make b/ydb/core/sys_view/tablets/ya.make new file mode 100644 index 00000000000..1d185974462 --- /dev/null +++ b/ydb/core/sys_view/tablets/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + tablets.h + tablets.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/kqp/runtime + ydb/core/sys_view/common +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/sys_view/ut_kqp/ya.make b/ydb/core/sys_view/ut_kqp/ya.make new file mode 100644 index 00000000000..f2d50a5d939 --- /dev/null +++ b/ydb/core/sys_view/ut_kqp/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/sys_view) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/testing/unittest + library/cpp/yson/node + ydb/core/kqp/ut/common + ydb/core/persqueue/ut/common + ydb/core/testlib/default + ydb/public/sdk/cpp/client/draft +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_kqp.cpp + ut_common.cpp + ut_counters.cpp + ut_labeled.cpp +) + +END() diff --git a/ydb/core/sys_view/ya.make b/ydb/core/sys_view/ya.make new file mode 100644 index 00000000000..057a42fc198 --- /dev/null +++ b/ydb/core/sys_view/ya.make @@ -0,0 +1,37 @@ +LIBRARY() + +SRCS( + scan.h + scan.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/kqp/runtime + ydb/core/sys_view/common + ydb/core/sys_view/nodes + ydb/core/sys_view/partition_stats + ydb/core/sys_view/query_stats + ydb/core/sys_view/service + ydb/core/sys_view/storage + ydb/core/sys_view/tablets +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + common + nodes + partition_stats + processor + query_stats + service + storage + tablets +) + +RECURSE_FOR_TESTS( + ut_kqp +) diff --git a/ydb/core/tablet/ut/ya.make b/ydb/core/tablet/ut/ya.make new file mode 100644 index 00000000000..ccd05f5eb90 --- /dev/null +++ b/ydb/core/tablet/ut/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tablet) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +SPLIT_FACTOR(50) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + pipe_tracker_ut.cpp + resource_broker_ut.cpp + tablet_counters_ut.cpp + tablet_counters_aggregator_ut.cpp + tablet_metrics_ut.cpp + tablet_pipe_ut.cpp + tablet_pipecache_ut.cpp + tablet_req_blockbs_ut.cpp + tablet_resolver_ut.cpp +) + +END() diff --git a/ydb/core/tablet/ya.make b/ydb/core/tablet/ya.make new file mode 100644 index 00000000000..81c047e88f4 --- /dev/null +++ b/ydb/core/tablet/ya.make @@ -0,0 +1,82 @@ +LIBRARY() + +SRCS( + bootstrapper.cpp + defs.h + labeled_counters_merger.cpp + labeled_counters_merger.h + labeled_db_counters.cpp + labeled_db_counters.h + node_tablet_monitor.cpp + node_tablet_monitor.h + node_whiteboard.cpp + pipe_tracker.cpp + pipe_tracker.h + resource_broker.cpp + resource_broker.h + resource_broker_impl.h + tablet_counters.cpp + tablet_counters.h + tablet_counters_aggregator.cpp + tablet_counters_aggregator.h + tablet_counters_app.cpp + tablet_counters_app.h + tablet_counters_protobuf.h + tablet_exception.h + tablet_impl.h + tablet_list_renderer.cpp + tablet_list_renderer.h + tablet_metrics.cpp + tablet_metrics.h + tablet_monitoring_proxy.cpp + tablet_monitoring_proxy.h + tablet_pipe_client.cpp + tablet_pipe_client_cache.cpp + tablet_pipe_client_cache.h + tablet_pipe_server.cpp + tablet_pipecache.cpp + tablet_req_blockbs.cpp + tablet_req_delete.cpp + tablet_req_findlatest.cpp + tablet_req_rebuildhistory.cpp + tablet_req_reset.cpp + tablet_req_writelog.cpp + tablet_resolver.cpp + tablet_responsiveness_pinger.cpp + tablet_responsiveness_pinger.h + tablet_setup.h + tablet_sys.cpp + tablet_sys.h + tablet_tracing_signals.cpp + tablet_tracing_signals.h + private/aggregated_counters.cpp + private/aggregated_counters.h + private/labeled_db_counters.cpp + private/labeled_db_counters.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/helpers + library/cpp/actors/protos + library/cpp/actors/util + library/cpp/blockcodecs + library/cpp/deprecated/enum_codegen + library/cpp/yson + ydb/core/base + ydb/core/mon + ydb/core/mon_alloc + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/scheme + ydb/core/sys_view/service + ydb/core/tracing + ydb/core/util + ydb/library/persqueue/topic_parser +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tablet_flat/benchmark/ya.make b/ydb/core/tablet_flat/benchmark/ya.make new file mode 100644 index 00000000000..13de301fdb9 --- /dev/null +++ b/ydb/core/tablet_flat/benchmark/ya.make @@ -0,0 +1,18 @@ +G_BENCHMARK() + +TAG(ya:fat) +SIZE(LARGE) + +SRCS( + b_charge.cpp +) + +PEERDIR( + library/cpp/resource + ydb/core/scheme + ydb/core/tablet_flat/test/libs/exec + ydb/core/tablet_flat/test/libs/table + ydb/core/testlib/default +) + +END() diff --git a/ydb/core/tablet_flat/protos/ya.make b/ydb/core/tablet_flat/protos/ya.make new file mode 100644 index 00000000000..940c1e1fc93 --- /dev/null +++ b/ydb/core/tablet_flat/protos/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + flat_table_part.proto + flat_table_shard.proto +) + +PEERDIR( + contrib/libs/protobuf + ydb/core/protos +) + +END() diff --git a/ydb/core/tablet_flat/test/libs/exec/ya.make b/ydb/core/tablet_flat/test/libs/exec/ya.make new file mode 100644 index 00000000000..2b7e2406437 --- /dev/null +++ b/ydb/core/tablet_flat/test/libs/exec/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS() + +PEERDIR( + ydb/core/base + ydb/core/blobstorage/dsproxy/mock + ydb/core/tablet_flat + ydb/core/testlib/actors +) + +END() diff --git a/ydb/core/tablet_flat/test/libs/rows/ya.make b/ydb/core/tablet_flat/test/libs/rows/ya.make new file mode 100644 index 00000000000..430e3d97e65 --- /dev/null +++ b/ydb/core/tablet_flat/test/libs/rows/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + all.cpp +) + +PEERDIR( + ydb/core/tablet_flat +) + +END() diff --git a/ydb/core/tablet_flat/test/libs/table/model/ya.make b/ydb/core/tablet_flat/test/libs/table/model/ya.make new file mode 100644 index 00000000000..585d3163b28 --- /dev/null +++ b/ydb/core/tablet_flat/test/libs/table/model/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +PEERDIR( + ydb/core/tablet_flat/test/libs/rows +) + +END() diff --git a/ydb/core/tablet_flat/test/libs/table/ya.make b/ydb/core/tablet_flat/test/libs/table/ya.make new file mode 100644 index 00000000000..af4c90078df --- /dev/null +++ b/ydb/core/tablet_flat/test/libs/table/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + misc.cpp +) + +PEERDIR( + ydb/core/tablet_flat/test/libs/rows + ydb/core/tablet_flat/test/libs/table/model + ydb/core/tablet_flat +) + +END() + +RECURSE( + model +) diff --git a/ydb/core/tablet_flat/test/libs/ya.make b/ydb/core/tablet_flat/test/libs/ya.make new file mode 100644 index 00000000000..e1e135d0bde --- /dev/null +++ b/ydb/core/tablet_flat/test/libs/ya.make @@ -0,0 +1,5 @@ +RECURSE( + exec + rows + table +) diff --git a/ydb/core/tablet_flat/test/tool/perf/ya.make b/ydb/core/tablet_flat/test/tool/perf/ya.make new file mode 100644 index 00000000000..f3f33dd82a7 --- /dev/null +++ b/ydb/core/tablet_flat/test/tool/perf/ya.make @@ -0,0 +1,17 @@ +PROGRAM(table-perf) + +SRCS( + colons.cpp + main.cpp +) + +PEERDIR( + ydb/core/tablet_flat/test/libs/table + library/cpp/charset + library/cpp/getopt + ydb/core/tablet_flat + ydb/library/yql/sql/pg_dummy + ydb/library/yql/public/udf/service/exception_policy +) + +END() diff --git a/ydb/core/tablet_flat/test/tool/surg/ya.make b/ydb/core/tablet_flat/test/tool/surg/ya.make new file mode 100644 index 00000000000..f4f34771bc0 --- /dev/null +++ b/ydb/core/tablet_flat/test/tool/surg/ya.make @@ -0,0 +1,14 @@ +PROGRAM() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/getopt + ydb/core/tablet_flat + ydb/library/yql/sql/pg_dummy + ydb/library/yql/public/udf/service/exception_policy +) + +END() diff --git a/ydb/core/tablet_flat/test/tool/ya.make b/ydb/core/tablet_flat/test/tool/ya.make new file mode 100644 index 00000000000..7fd47e7e65c --- /dev/null +++ b/ydb/core/tablet_flat/test/tool/ya.make @@ -0,0 +1,4 @@ +RECURSE( + surg + perf +) diff --git a/ydb/core/tablet_flat/test/ya.make b/ydb/core/tablet_flat/test/ya.make new file mode 100644 index 00000000000..4d8fd556912 --- /dev/null +++ b/ydb/core/tablet_flat/test/ya.make @@ -0,0 +1,4 @@ +RECURSE( + libs + tool +) diff --git a/ydb/core/tablet_flat/ut/ya.make b/ydb/core/tablet_flat/ut/ya.make new file mode 100644 index 00000000000..eb1528e860d --- /dev/null +++ b/ydb/core/tablet_flat/ut/ya.make @@ -0,0 +1,69 @@ +UNITTEST_FOR(ydb/core/tablet_flat) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(2400) + TAG(ya:fat) + SIZE(LARGE) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + datetime_ut.cpp + decimal_ut.cpp + flat_cxx_database_ut.cpp + ut_db_iface.cpp + ut_db_scheme.cpp + flat_executor_ut.cpp + flat_executor_database_ut.cpp + flat_executor_gclogic_ut.cpp + flat_executor_leases_ut.cpp + flat_range_cache_ut.cpp + flat_row_versions_ut.cpp + flat_table_part_ut.cpp + flat_test_db.h + flat_test_db.cpp + flat_test_db_helpers.h + shared_handle_ut.cpp + ut_self.cpp + ut_iterator.cpp + ut_memtable.cpp + ut_sausage.cpp + ut_comp_gen.cpp + ut_comp_shard.cpp + ut_compaction.cpp + ut_compaction_multi.cpp + ut_charge.cpp + ut_part.cpp + ut_part_multi.cpp + ut_proto.cpp + ut_pages.cpp + ut_redo.cpp + ut_rename_table_column.cpp + ut_other.cpp + ut_forward.cpp + ut_screen.cpp + ut_bloom.cpp + ut_slice.cpp + ut_slice_loader.cpp + ut_versions.cpp +) + +RESOURCE( + ../test/data/002_full_part.pages abi/002_full_part.pages + ../test/data/008_basics_db.redo abi/008_basics_db.redo +) + +PEERDIR( + library/cpp/resource + ydb/core/scheme + ydb/core/tablet_flat/test/libs/exec + ydb/core/tablet_flat/test/libs/table + ydb/core/testlib/default + ydb/library/yql/public/udf/service/exception_policy +) + +END() diff --git a/ydb/core/tablet_flat/ut_large/ya.make b/ydb/core/tablet_flat/ut_large/ya.make new file mode 100644 index 00000000000..3c7a98e0908 --- /dev/null +++ b/ydb/core/tablet_flat/ut_large/ya.make @@ -0,0 +1,26 @@ +UNITTEST_FOR(ydb/core/tablet_flat) + +REQUIREMENTS(ram:32) + +IF (WITH_VALGRIND) + TIMEOUT(2400) + TAG(ya:fat) + SIZE(LARGE) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + flat_executor_ut_large.cpp +) + +PEERDIR( + ydb/core/scheme + ydb/core/tablet_flat/test/libs/exec + ydb/core/tablet_flat/test/libs/table + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +END() diff --git a/ydb/core/tablet_flat/ut_pg/ya.make b/ydb/core/tablet_flat/ut_pg/ya.make new file mode 100644 index 00000000000..ba4473520e2 --- /dev/null +++ b/ydb/core/tablet_flat/ut_pg/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tablet_flat) + +FORK_SUBTESTS() + +SRCS( + flat_database_pg_ut.cpp +) + +PEERDIR( + ydb/core/scheme + ydb/core/tablet_flat/test/libs/table + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg +) + +ADDINCL( + ydb/library/yql/parser/pg_wrapper/postgresql/src/include +) + +IF (OS_WINDOWS) +CFLAGS( + "-D__thread=__declspec(thread)" + -Dfstat=microsoft_native_fstat + -Dstat=microsoft_native_stat +) +ENDIF() + +NO_COMPILER_WARNINGS() + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tablet_flat/ut_util/ya.make b/ydb/core/tablet_flat/ut_util/ya.make new file mode 100644 index 00000000000..c06ae56fd2b --- /dev/null +++ b/ydb/core/tablet_flat/ut_util/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(ydb/core/tablet_flat) + +TIMEOUT(600) +SIZE(MEDIUM) + +SRCS( + util_pool_ut.cpp +) + +END() diff --git a/ydb/core/tablet_flat/ya.make b/ydb/core/tablet_flat/ya.make new file mode 100644 index 00000000000..ad1c4fcfe08 --- /dev/null +++ b/ydb/core/tablet_flat/ya.make @@ -0,0 +1,122 @@ +LIBRARY() + +SRCS( + defs.h + flat_boot_lease.cpp + flat_boot_misc.cpp + flat_comp.cpp + flat_comp_create.cpp + flat_comp_gen.cpp + flat_comp_shard.cpp + flat_cxx_database.h + flat_database.cpp + flat_database.h + flat_dbase_scheme.cpp + flat_dbase_apply.cpp + flat_exec_broker.cpp + flat_exec_commit.cpp + flat_exec_commit_mgr.cpp + flat_exec_seat.cpp + flat_executor.cpp + flat_executor.h + flat_executor_bootlogic.cpp + flat_executor_bootlogic.h + flat_executor_borrowlogic.cpp + flat_executor_borrowlogic.h + flat_executor_compaction_logic.cpp + flat_executor_compaction_logic.h + flat_executor_counters.cpp + flat_executor_counters.h + flat_executor_db_mon.cpp + flat_executor_gclogic.cpp + flat_executor_gclogic.h + flat_bio_actor.cpp + flat_executor_snapshot.cpp + flat_executor_tx_env.cpp + flat_executor_tx_env.h + flat_executor_txloglogic.cpp + flat_executor_txloglogic.h + flat_iterator.h + flat_load_blob_queue.cpp + flat_mem_warm.cpp + flat_sausagecache.cpp + flat_sausagecache.h + flat_sausage_meta.cpp + flat_page_label.cpp + flat_part_dump.cpp + flat_part_iter_multi.cpp + flat_part_loader.cpp + flat_part_overlay.cpp + flat_part_outset.cpp + flat_part_slice.cpp + flat_range_cache.cpp + flat_row_versions.cpp + flat_stat_part.cpp + flat_stat_part.h + flat_stat_table.h + flat_stat_table.cpp + flat_store_hotdog.cpp + flat_table.cpp + flat_table.h + flat_table_part.cpp + flat_table_part.h + flat_table_misc.cpp + flat_update_op.h + probes.cpp + shared_handle.cpp + shared_sausagecache.cpp + shared_sausagecache.h + tablet_flat_executor.h + tablet_flat_executor.cpp + tablet_flat_executed.h + tablet_flat_executed.cpp + flat_executor.proto +) + +GENERATE_ENUM_SERIALIZATION(flat_comp_gen.h) + +GENERATE_ENUM_SERIALIZATION(flat_comp_shard.h) + +GENERATE_ENUM_SERIALIZATION(flat_part_loader.h) + +GENERATE_ENUM_SERIALIZATION(flat_executor_compaction_logic.h) + +GENERATE_ENUM_SERIALIZATION(flat_row_eggs.h) + +IF (KIKIMR_TABLET_BORROW_WITHOUT_META) + CFLAGS( + -DKIKIMR_TABLET_BORROW_WITHOUT_META=1 + ) +ENDIF() + +PEERDIR( + contrib/libs/protobuf + library/cpp/containers/absl_flat_hash + library/cpp/containers/intrusive_rb_tree + library/cpp/containers/stack_vector + library/cpp/digest/crc32c + library/cpp/html/pcdata + library/cpp/lwtrace + library/cpp/lwtrace/mon + ydb/core/base + ydb/core/control + ydb/core/protos + ydb/core/tablet + ydb/core/tablet_flat/protos + ydb/library/binary_json + ydb/library/dynumber + ydb/library/mkql_proto/protos +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + test + benchmark + ut + ut_large + ut_pg + ut_util +) diff --git a/ydb/core/test_tablet/ya.make b/ydb/core/test_tablet/ya.make new file mode 100644 index 00000000000..77e264bc22a --- /dev/null +++ b/ydb/core/test_tablet/ya.make @@ -0,0 +1,36 @@ +LIBRARY() + +SRCS( + defs.h + events.h + load_actor_impl.cpp + load_actor_impl.h + load_actor_delete.cpp + load_actor_mon.cpp + load_actor_read_validate.cpp + load_actor_state.cpp + load_actor_write.cpp + processor.h + scheme.h + state_server_interface.cpp + state_server_interface.h + test_shard_context.cpp + test_shard_context.h + test_shard_impl.h + test_shard_mon.cpp + test_tablet.cpp + test_tablet.h + tx_init_scheme.cpp + tx_initialize.cpp + tx_load_everything.cpp +) + +PEERDIR( + contrib/libs/t1ha + library/cpp/digest/md5 + ydb/core/keyvalue + ydb/core/protos + ydb/core/util +) + +END() diff --git a/ydb/core/testlib/actors/ut/ya.make b/ydb/core/testlib/actors/ut/ya.make new file mode 100644 index 00000000000..cf71048c095 --- /dev/null +++ b/ydb/core/testlib/actors/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(ydb/core/testlib/actors) + +FORK_SUBTESTS() +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(300) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/regex/pcre +) + +SRCS( + test_runtime_ut.cpp +) + +END() diff --git a/ydb/core/testlib/actors/ya.make b/ydb/core/testlib/actors/ya.make new file mode 100644 index 00000000000..287a2da512f --- /dev/null +++ b/ydb/core/testlib/actors/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + test_runtime.cpp +) + +PEERDIR( + library/cpp/actors/testlib + library/cpp/testing/unittest + ydb/core/base + ydb/core/mon + ydb/core/mon_alloc + ydb/core/scheme + ydb/core/tablet +) + +IF (GCC) + CFLAGS( + -fno-devirtualize-speculatively + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/testlib/basics/default/ya.make b/ydb/core/testlib/basics/default/ya.make new file mode 100644 index 00000000000..62dfdf80756 --- /dev/null +++ b/ydb/core/testlib/basics/default/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +PEERDIR( + ydb/core/testlib/basics + ydb/library/yql/sql/pg_dummy +) + +END() diff --git a/ydb/core/testlib/basics/ya.make b/ydb/core/testlib/basics/ya.make new file mode 100644 index 00000000000..7f5d67b74c1 --- /dev/null +++ b/ydb/core/testlib/basics/ya.make @@ -0,0 +1,45 @@ +LIBRARY() + +SRCS( + appdata.cpp + helpers.cpp + runtime.cpp + services.cpp +) + +PEERDIR( + library/cpp/actors/dnsresolver + library/cpp/regex/pcre + library/cpp/testing/unittest + ydb/core/base + ydb/core/blobstorage + ydb/core/blobstorage/crypto + ydb/core/blobstorage/nodewarden + ydb/core/blobstorage/pdisk + ydb/core/client/server + ydb/core/formats + ydb/core/mind + ydb/core/node_whiteboard + ydb/core/quoter + ydb/core/tablet_flat + ydb/core/testlib/actors + ydb/core/tx/columnshard + ydb/core/tx/scheme_board + ydb/core/util + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +IF (GCC) + CFLAGS( + -fno-devirtualize-speculatively + ) +ENDIF() + +END() + +RECURSE( + default +) diff --git a/ydb/core/testlib/controllers/ya.make b/ydb/core/testlib/controllers/ya.make new file mode 100644 index 00000000000..954db2fb2dc --- /dev/null +++ b/ydb/core/testlib/controllers/ya.make @@ -0,0 +1,10 @@ +LIBRARY() + +SRCS( + abstract.cpp +) + +PEERDIR( +) + +END() diff --git a/ydb/core/testlib/default/ya.make b/ydb/core/testlib/default/ya.make new file mode 100644 index 00000000000..a730d1b1bfd --- /dev/null +++ b/ydb/core/testlib/default/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +PEERDIR( + ydb/core/testlib + ydb/library/yql/sql/pg_dummy +) + +END() diff --git a/ydb/core/testlib/pg/ya.make b/ydb/core/testlib/pg/ya.make new file mode 100644 index 00000000000..0b062ba7392 --- /dev/null +++ b/ydb/core/testlib/pg/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +PEERDIR( + ydb/core/testlib + ydb/library/yql/sql/pg +) + +END() diff --git a/ydb/core/testlib/ya.make b/ydb/core/testlib/ya.make new file mode 100644 index 00000000000..ebd0cbfdd87 --- /dev/null +++ b/ydb/core/testlib/ya.make @@ -0,0 +1,124 @@ +LIBRARY() + +SRCS( + actor_helpers.cpp + actor_helpers.h + common_helper.cpp + cs_helper.cpp + fake_coordinator.cpp + fake_coordinator.h + fake_scheme_shard.h + minikql_compile.h + mock_pq_metacache.h + tablet_flat_dummy.cpp + tablet_helpers.cpp + tablet_helpers.h + tenant_runtime.cpp + tenant_runtime.h + test_client.cpp + test_client.h + tx_helpers.cpp + tx_helpers.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + library/cpp/grpc/client + library/cpp/grpc/server + library/cpp/grpc/server/actors + library/cpp/regex/pcre + library/cpp/testing/gmock_in_unittest + library/cpp/testing/unittest + ydb/core/driver_lib/run + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/pdisk + ydb/core/client + ydb/core/client/metadata + ydb/core/client/minikql_compile + ydb/core/client/server + ydb/core/cms/console + ydb/core/engine + ydb/core/engine/minikql + ydb/core/formats + ydb/core/fq/libs/init + ydb/core/fq/libs/mock + ydb/core/fq/libs/shared_resources + ydb/core/grpc_services + ydb/core/health_check + ydb/core/kesus/proxy + ydb/core/kesus/tablet + ydb/core/keyvalue + ydb/core/kqp + ydb/core/metering + ydb/core/mind + ydb/core/mind/address_classification + ydb/core/mind/bscontroller + ydb/core/mind/hive + ydb/core/node_whiteboard + ydb/core/persqueue + ydb/core/protos + ydb/core/security + ydb/core/sys_view/processor + ydb/core/sys_view/service + ydb/core/testlib/actors + ydb/core/testlib/controllers + ydb/core/testlib/basics + ydb/core/tx/columnshard + ydb/core/tx/coordinator + ydb/core/tx/long_tx_service + ydb/core/tx/mediator + ydb/core/tx/replication/controller + ydb/core/tx/schemeshard + ydb/core/tx/sequenceproxy + ydb/core/tx/sequenceshard + ydb/core/tx/time_cast + ydb/library/aclib + ydb/library/folder_service/mock + ydb/library/mkql_proto/protos + ydb/library/persqueue/topic_parser + ydb/library/security + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/base + ydb/public/lib/deprecated/kicli + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs + ydb/public/sdk/cpp/client/ydb_table + ydb/services/auth + ydb/services/cms + ydb/services/datastreams + ydb/services/discovery + ydb/services/ext_index/service + ydb/core/tx/conveyor/service + ydb/services/fq + ydb/services/kesus + ydb/services/persqueue_cluster_discovery + ydb/services/persqueue_v1 + ydb/services/rate_limiter + ydb/services/monitoring + ydb/services/metadata/ds_table + ydb/services/bg_tasks/ds_table + ydb/services/bg_tasks + ydb/services/ydb + + ydb/core/http_proxy +) + +YQL_LAST_ABI_VERSION() + +IF (GCC) + CFLAGS( + -fno-devirtualize-speculatively + ) +ENDIF() + +END() + +RECURSE( + actors + basics + default + pg +) diff --git a/ydb/core/tracing/ya.make b/ydb/core/tracing/ya.make new file mode 100644 index 00000000000..a0be10a3e3a --- /dev/null +++ b/ydb/core/tracing/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + http.cpp + tablet_info.cpp + trace.cpp + trace_collection.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/protos +) + +END() diff --git a/ydb/core/tx/balance_coverage/ut/ya.make b/ydb/core/tx/balance_coverage/ut/ya.make new file mode 100644 index 00000000000..4ef1aff5e61 --- /dev/null +++ b/ydb/core/tx/balance_coverage/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/tx/balance_coverage) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE) + TIMEOUT(600) + SIZE(MEDIUM) +ELSE() + TIMEOUT(60) + SIZE(SMALL) +ENDIF() + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default +) + +SRCS( + balance_coverage_builder_ut.cpp +) + +END() diff --git a/ydb/core/tx/balance_coverage/ya.make b/ydb/core/tx/balance_coverage/ya.make new file mode 100644 index 00000000000..0032c1c6e9b --- /dev/null +++ b/ydb/core/tx/balance_coverage/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/protos +) + +SRCS( + balance_coverage_builder.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/columnshard/counters/common/ya.make b/ydb/core/tx/columnshard/counters/common/ya.make new file mode 100644 index 00000000000..51dd3ceabfb --- /dev/null +++ b/ydb/core/tx/columnshard/counters/common/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + agent.cpp + client.cpp + owner.cpp + private.cpp +) + +PEERDIR( + library/cpp/monlib/dynamic_counters + ydb/core/base +) + +END() diff --git a/ydb/core/tx/columnshard/counters/ya.make b/ydb/core/tx/columnshard/counters/ya.make new file mode 100644 index 00000000000..3a333cef8d9 --- /dev/null +++ b/ydb/core/tx/columnshard/counters/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + indexation.cpp + scan.cpp + engine_logs.cpp + blobs_manager.cpp + columnshard.cpp + insert_table.cpp + common_data.cpp +) + +PEERDIR( + library/cpp/monlib/dynamic_counters + ydb/core/tx/columnshard/counters/common + ydb/core/base +) + +END() diff --git a/ydb/core/tx/columnshard/engines/insert_table/ya.make b/ydb/core/tx/columnshard/engines/insert_table/ya.make new file mode 100644 index 00000000000..159fe518878 --- /dev/null +++ b/ydb/core/tx/columnshard/engines/insert_table/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + insert_table.cpp + rt_insertion.cpp + data.cpp + path_info.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/formats/arrow +) + +END() diff --git a/ydb/core/tx/columnshard/engines/predicate/ya.make b/ydb/core/tx/columnshard/engines/predicate/ya.make new file mode 100644 index 00000000000..10d5ff3b45b --- /dev/null +++ b/ydb/core/tx/columnshard/engines/predicate/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + container.cpp + range.cpp + filter.cpp + predicate.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/formats/arrow +) + +END() diff --git a/ydb/core/tx/columnshard/engines/reader/order_control/ya.make b/ydb/core/tx/columnshard/engines/reader/order_control/ya.make new file mode 100644 index 00000000000..000ce6cf45f --- /dev/null +++ b/ydb/core/tx/columnshard/engines/reader/order_control/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + abstract.cpp + not_sorted.cpp + pk_with_limit.cpp + default.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/formats/arrow +) + +END() diff --git a/ydb/core/tx/columnshard/engines/reader/ya.make b/ydb/core/tx/columnshard/engines/reader/ya.make new file mode 100644 index 00000000000..ce362d03b46 --- /dev/null +++ b/ydb/core/tx/columnshard/engines/reader/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +SRCS( + batch.cpp + common.cpp + conveyor_task.cpp + description.cpp + filling_context.cpp + filter_assembler.cpp + granule.cpp + postfilter_assembler.cpp + queue.cpp + read_filter_merger.cpp + read_metadata.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/formats/arrow + ydb/core/tx/columnshard/engines/predicate + ydb/core/tx/columnshard/testlib + ydb/core/tx/program + ydb/core/tx/columnshard/engines/reader/order_control +) + +GENERATE_ENUM_SERIALIZATION(read_metadata.h) +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/columnshard/engines/storage/ya.make b/ydb/core/tx/columnshard/engines/storage/ya.make new file mode 100644 index 00000000000..5997d8aac7c --- /dev/null +++ b/ydb/core/tx/columnshard/engines/storage/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + granule.cpp + storage.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/formats/arrow +) + +END() diff --git a/ydb/core/tx/columnshard/engines/ut/ya.make b/ydb/core/tx/columnshard/engines/ut/ya.make new file mode 100644 index 00000000000..0d7ee35e641 --- /dev/null +++ b/ydb/core/tx/columnshard/engines/ut/ya.make @@ -0,0 +1,37 @@ +UNITTEST_FOR(ydb/core/tx/columnshard/engines) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/base + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx/columnshard/counters + ydb/library/yql/sql/pg_dummy + ydb/library/yql/core/arrow_kernels/request + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_insert_table.cpp + ut_logs_engine.cpp + ut_program.cpp + ydb/core/tx/columnshard/columnshard_ut_common.cpp +) + +END() diff --git a/ydb/core/tx/columnshard/engines/ya.make b/ydb/core/tx/columnshard/engines/ya.make new file mode 100644 index 00000000000..351fe56beca --- /dev/null +++ b/ydb/core/tx/columnshard/engines/ya.make @@ -0,0 +1,43 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +SRCS( + column_engine_logs.cpp + column_engine.cpp + compaction_info.cpp + db_wrapper.cpp + index_info.cpp + indexed_read_data.cpp + index_logic_logs.cpp + filter.cpp + portion_info.cpp + scalars.cpp + tier_info.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/base + ydb/core/formats + ydb/core/protos + ydb/core/scheme + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx/columnshard/engines/reader + ydb/core/tx/columnshard/engines/predicate + ydb/core/tx/columnshard/engines/storage + ydb/core/tx/columnshard/engines/insert_table + ydb/core/formats/arrow/compression + ydb/core/tx/program + + # for NYql::NUdf alloc stuff used in binary_json + ydb/library/yql/public/udf/service/exception_policy +) + +GENERATE_ENUM_SERIALIZATION(portion_info.h) +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/columnshard/testlib/ya.make b/ydb/core/tx/columnshard/testlib/ya.make new file mode 100644 index 00000000000..3747872dee6 --- /dev/null +++ b/ydb/core/tx/columnshard/testlib/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + controller.cpp +) + +PEERDIR( + ydb/core/testlib/controllers + ydb/core/tx/columnshard/engines/reader/order_control +) + +END() diff --git a/ydb/core/tx/columnshard/ut_rw/ya.make b/ydb/core/tx/columnshard/ut_rw/ya.make new file mode 100644 index 00000000000..c57bf410f10 --- /dev/null +++ b/ydb/core/tx/columnshard/ut_rw/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/tx/columnshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/metadata + ydb/core/tx + ydb/public/lib/yson_value +) + +YQL_LAST_ABI_VERSION() + +SRCS( + columnshard_ut_common.cpp + ut_columnshard_read_write.cpp +) + +END() diff --git a/ydb/core/tx/columnshard/ut_schema/ya.make b/ydb/core/tx/columnshard/ut_schema/ya.make new file mode 100644 index 00000000000..bacba02d3d7 --- /dev/null +++ b/ydb/core/tx/columnshard/ut_schema/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/tx/columnshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/metadata + ydb/core/tx + ydb/public/lib/yson_value +) + +YQL_LAST_ABI_VERSION() + +SRCS( + columnshard_ut_common.cpp + ut_columnshard_schema.cpp +) + +END() diff --git a/ydb/core/tx/columnshard/ya.make b/ydb/core/tx/columnshard/ya.make new file mode 100644 index 00000000000..52cc9e0293a --- /dev/null +++ b/ydb/core/tx/columnshard/ya.make @@ -0,0 +1,75 @@ +LIBRARY() + +SRCS( + blob.cpp + blob_cache.cpp + blob_manager.cpp + blob_manager_db.cpp + blob_manager_txs.cpp + columnshard__export.cpp + columnshard__forget.cpp + columnshard__init.cpp + columnshard__notify_tx_completion.cpp + columnshard__plan_step.cpp + columnshard__progress_tx.cpp + columnshard__propose_cancel.cpp + columnshard__propose_transaction.cpp + columnshard__read.cpp + columnshard__read_base.cpp + columnshard__read_blob_ranges.cpp + columnshard__scan.cpp + columnshard__index_scan.cpp + columnshard__stats_scan.cpp + columnshard__write.cpp + columnshard__write_index.cpp + columnshard.cpp + columnshard_impl.cpp + columnshard_common.cpp + columnshard_private_events.cpp + counters.cpp + compaction_actor.cpp + defs.cpp + eviction_actor.cpp + export_actor.cpp + indexing_actor.cpp + read_actor.cpp + write_actor.cpp + tables_manager.cpp +) + +GENERATE_ENUM_SERIALIZATION(columnshard.h) + +PEERDIR( + library/cpp/actors/core + ydb/core/actorlib_impl + ydb/core/base + ydb/core/blobstorage/dsproxy + ydb/core/control + ydb/core/formats + ydb/core/kqp + ydb/core/protos + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx/columnshard/engines + ydb/core/tx/columnshard/counters + ydb/core/tx/tiering + ydb/core/tx/conveyor/usage + ydb/core/tx/long_tx_service/public + ydb/core/util + ydb/public/api/protos + ydb/library/yql/dq/actors/compute + ydb/library/chunks_limiter +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + engines +) + +RECURSE_FOR_TESTS( + ut_rw + ut_schema +) diff --git a/ydb/core/tx/conveyor/service/ya.make b/ydb/core/tx/conveyor/service/ya.make new file mode 100644 index 00000000000..4fd930e019c --- /dev/null +++ b/ydb/core/tx/conveyor/service/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + worker.cpp + service.cpp +) + +PEERDIR( + ydb/core/tx/conveyor/usage + ydb/core/protos +) + +END() diff --git a/ydb/core/tx/conveyor/usage/ya.make b/ydb/core/tx/conveyor/usage/ya.make new file mode 100644 index 00000000000..f902663d1a5 --- /dev/null +++ b/ydb/core/tx/conveyor/usage/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + events.cpp + config.cpp + abstract.cpp + service.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/services/metadata/request +) + +END() diff --git a/ydb/core/tx/coordinator/ut/ya.make b/ydb/core/tx/coordinator/ut/ya.make new file mode 100644 index 00000000000..56751986574 --- /dev/null +++ b/ydb/core/tx/coordinator/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/tx/coordinator) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/testlib/default + ydb/core/tx +) + +YQL_LAST_ABI_VERSION() + +SRCS( + coordinator_ut.cpp +) + +END() diff --git a/ydb/core/tx/coordinator/ya.make b/ydb/core/tx/coordinator/ya.make new file mode 100644 index 00000000000..d72a9c0620a --- /dev/null +++ b/ydb/core/tx/coordinator/ya.make @@ -0,0 +1,43 @@ +LIBRARY() + +SRCS( + coordinator.cpp + coordinator_impl.cpp + coordinator__acquire_read_step.cpp + coordinator__configure.cpp + coordinator__check.cpp + coordinator__init.cpp + coordinator__last_step_subscriptions.cpp + coordinator__mediators_confirmations.cpp + coordinator__monitoring.cpp + coordinator__plan_step.cpp + coordinator__read_step_subscriptions.cpp + coordinator__restart_mediator.cpp + coordinator__restore_transaction.cpp + coordinator__schema.cpp + coordinator__schema_upgrade.cpp + coordinator__stop_guard.cpp + defs.h + mediator_queue.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/helpers + library/cpp/actors/interconnect + ydb/core/actorlib_impl + ydb/core/base + ydb/core/engine/minikql + ydb/core/protos + ydb/core/scheme + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx + ydb/core/util +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/datashard/ut_background_compaction/ya.make b/ydb/core/tx/datashard/ut_background_compaction/ya.make new file mode 100644 index 00000000000..052b6db9386 --- /dev/null +++ b/ydb/core/tx/datashard/ut_background_compaction/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_background_compaction.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_build_index/ya.make b/ydb/core/tx/datashard/ut_build_index/ya.make new file mode 100644 index 00000000000..d5cd4e63093 --- /dev/null +++ b/ydb/core/tx/datashard/ut_build_index/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_build_index.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_change_collector/ya.make b/ydb/core/tx/datashard/ut_change_collector/ya.make new file mode 100644 index 00000000000..b8017e3e030 --- /dev/null +++ b/ydb/core/tx/datashard/ut_change_collector/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(8) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_change_collector.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_change_exchange/ya.make b/ydb/core/tx/datashard/ut_change_exchange/ya.make new file mode 100644 index 00000000000..4aa730b0e46 --- /dev/null +++ b/ydb/core/tx/datashard/ut_change_exchange/ya.make @@ -0,0 +1,42 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(4) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_datastreams + ydb/public/sdk/cpp/client/ydb_topic + ydb/public/sdk/cpp/client/ydb_persqueue_public + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_change_exchange.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_compaction/ya.make b/ydb/core/tx/datashard/ut_compaction/ya.make new file mode 100644 index 00000000000..e815378d790 --- /dev/null +++ b/ydb/core/tx/datashard/ut_compaction/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_compaction.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_erase_rows/ya.make b/ydb/core/tx/datashard/ut_erase_rows/ya.make new file mode 100644 index 00000000000..349636c16ee --- /dev/null +++ b/ydb/core/tx/datashard/ut_erase_rows/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(15) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_erase_rows.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_followers/ya.make b/ydb/core/tx/datashard/ut_followers/ya.make new file mode 100644 index 00000000000..cb5d1eeeb8b --- /dev/null +++ b/ydb/core/tx/datashard/ut_followers/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_followers.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_init/ya.make b/ydb/core/tx/datashard/ut_init/ya.make new file mode 100644 index 00000000000..1cf3ba6247d --- /dev/null +++ b/ydb/core/tx/datashard/ut_init/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_init.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_keys/ya.make b/ydb/core/tx/datashard/ut_keys/ya.make new file mode 100644 index 00000000000..1a7ab2c85bd --- /dev/null +++ b/ydb/core/tx/datashard/ut_keys/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_keys.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_kqp/ya.make b/ydb/core/tx/datashard/ut_kqp/ya.make new file mode 100644 index 00000000000..24550e5db06 --- /dev/null +++ b/ydb/core/tx/datashard/ut_kqp/ya.make @@ -0,0 +1,40 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_kqp.cpp + datashard_ut_kqp_stream_lookup.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_kqp_errors/ya.make b/ydb/core/tx/datashard/ut_kqp_errors/ya.make new file mode 100644 index 00000000000..76203681d51 --- /dev/null +++ b/ydb/core/tx/datashard/ut_kqp_errors/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(3) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_kqp_errors.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_kqp_scan/ya.make b/ydb/core/tx/datashard/ut_kqp_scan/ya.make new file mode 100644 index 00000000000..f486cc9d0a3 --- /dev/null +++ b/ydb/core/tx/datashard/ut_kqp_scan/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(3) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_kqp_scan.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_locks/ya.make b/ydb/core/tx/datashard/ut_locks/ya.make new file mode 100644 index 00000000000..a0b58d29dfa --- /dev/null +++ b/ydb/core/tx/datashard/ut_locks/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(3) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_locks.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_minikql/ya.make b/ydb/core/tx/datashard/ut_minikql/ya.make new file mode 100644 index 00000000000..f9975790ed1 --- /dev/null +++ b/ydb/core/tx/datashard/ut_minikql/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(8) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_minikql.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_minstep/ya.make b/ydb/core/tx/datashard/ut_minstep/ya.make new file mode 100644 index 00000000000..a71ee5df6cd --- /dev/null +++ b/ydb/core/tx/datashard/ut_minstep/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_minstep.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_order/ya.make b/ydb/core/tx/datashard/ut_order/ya.make new file mode 100644 index 00000000000..c8076491ae6 --- /dev/null +++ b/ydb/core/tx/datashard/ut_order/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(40) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_order.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_range_avl_tree/ya.make b/ydb/core/tx/datashard/ut_range_avl_tree/ya.make new file mode 100644 index 00000000000..520f73112c8 --- /dev/null +++ b/ydb/core/tx/datashard/ut_range_avl_tree/ya.make @@ -0,0 +1,37 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + range_avl_tree_ut.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_range_ops/ya.make b/ydb/core/tx/datashard/ut_range_ops/ya.make new file mode 100644 index 00000000000..0962f39335f --- /dev/null +++ b/ydb/core/tx/datashard/ut_range_ops/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_range_ops.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_range_treap/ya.make b/ydb/core/tx/datashard/ut_range_treap/ya.make new file mode 100644 index 00000000000..98d4523b255 --- /dev/null +++ b/ydb/core/tx/datashard/ut_range_treap/ya.make @@ -0,0 +1,37 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + range_treap_ut.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_read_iterator/ya.make b/ydb/core/tx/datashard/ut_read_iterator/ya.make new file mode 100644 index 00000000000..f990ea46885 --- /dev/null +++ b/ydb/core/tx/datashard/ut_read_iterator/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_read_iterator.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_read_table/ya.make b/ydb/core/tx/datashard/ut_read_table/ya.make new file mode 100644 index 00000000000..aeb4341096b --- /dev/null +++ b/ydb/core/tx/datashard/ut_read_table/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_read_table.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_reassign/ya.make b/ydb/core/tx/datashard/ut_reassign/ya.make new file mode 100644 index 00000000000..9eb1e5916c7 --- /dev/null +++ b/ydb/core/tx/datashard/ut_reassign/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_reassign.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_replication/ya.make b/ydb/core/tx/datashard/ut_replication/ya.make new file mode 100644 index 00000000000..df547caf7e2 --- /dev/null +++ b/ydb/core/tx/datashard/ut_replication/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_replication.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_rs/ya.make b/ydb/core/tx/datashard/ut_rs/ya.make new file mode 100644 index 00000000000..dfee371decc --- /dev/null +++ b/ydb/core/tx/datashard/ut_rs/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_rs.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_snapshot/ya.make b/ydb/core/tx/datashard/ut_snapshot/ya.make new file mode 100644 index 00000000000..57af290c3cc --- /dev/null +++ b/ydb/core/tx/datashard/ut_snapshot/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(6) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_snapshot.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_stats/ya.make b/ydb/core/tx/datashard/ut_stats/ya.make new file mode 100644 index 00000000000..bd6dc58ce2e --- /dev/null +++ b/ydb/core/tx/datashard/ut_stats/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_stats.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_upload_rows/ya.make b/ydb/core/tx/datashard/ut_upload_rows/ya.make new file mode 100644 index 00000000000..2180a3f7caf --- /dev/null +++ b/ydb/core/tx/datashard/ut_upload_rows/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_upload_rows.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_volatile/ya.make b/ydb/core/tx/datashard/ut_volatile/ya.make new file mode 100644 index 00000000000..2e318232208 --- /dev/null +++ b/ydb/core/tx/datashard/ut_volatile/ya.make @@ -0,0 +1,41 @@ +UNITTEST_FOR(ydb/core/tx/datashard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_result +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_common_pq.cpp + datashard_ut_common_pq.h + datashard_ut_volatile.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ya.make b/ydb/core/tx/datashard/ya.make new file mode 100644 index 00000000000..a3f9d23b1f8 --- /dev/null +++ b/ydb/core/tx/datashard/ya.make @@ -0,0 +1,300 @@ +LIBRARY() + +SRCS( + alter_cdc_stream_unit.cpp + alter_table_unit.cpp + backup_restore_traits.cpp + backup_unit.cpp + build_and_wait_dependencies_unit.cpp + build_data_tx_out_rs_unit.cpp + build_distributed_erase_tx_out_rs_unit.cpp + build_index.cpp + build_kqp_data_tx_out_rs_unit.cpp + build_scheme_tx_out_rs_unit.cpp + cdc_stream_scan.cpp + change_collector_async_index.cpp + change_collector_base.cpp + change_collector_cdc_stream.cpp + change_collector.cpp + change_exchange.cpp + change_exchange_split.cpp + change_record.cpp + change_record_body_serializer.cpp + change_sender.cpp + change_sender_async_index.cpp + change_sender_cdc_stream.cpp + change_sender_common_ops.cpp + change_sender_monitoring.cpp + check_commit_writes_tx_unit.cpp + check_data_tx_unit.cpp + check_distributed_erase_tx_unit.cpp + check_read_unit.cpp + check_scheme_tx_unit.cpp + check_snapshot_tx_unit.cpp + complete_data_tx_unit.cpp + completed_operations_unit.cpp + conflicts_cache.cpp + create_cdc_stream_unit.cpp + create_persistent_snapshot_unit.cpp + create_table_unit.cpp + create_volatile_snapshot_unit.cpp + datashard__cancel_tx_proposal.cpp + datashard__compact_borrowed.cpp + datashard__compaction.cpp + datashard__cleanup_borrowed.cpp + datashard__cleanup_in_rs.cpp + datashard__cleanup_tx.cpp + datashard__conditional_erase_rows.cpp + datashard__engine_host.cpp + datashard__engine_host.h + datashard__get_state_tx.cpp + datashard__schema_changed.cpp + datashard__migrate_schemeshard.cpp + datashard__init.cpp + datashard__monitoring.cpp + datashard__mon_reset_schema_version.cpp + datashard__op_rows.cpp + datashard__plan_step.cpp + datashard__progress_resend_rs.cpp + datashard__progress_tx.cpp + datashard__propose_tx_base.cpp + datashard__readset.cpp + datashard__read_iterator.cpp + datashard__read_columns.cpp + datashard__s3_download_txs.cpp + datashard__s3_upload_txs.cpp + datashard__kqp_scan.cpp + datashard__snapshot_txs.cpp + datashard__stats.cpp + datashard__store_table_path.cpp + datashard__store_scan_state.cpp + datashard_change_receiving.cpp + datashard_change_sender_activation.cpp + datashard_change_sending.cpp + datashard_counters.cpp + datashard_loans.cpp + datashard_locks_db.cpp + datashard_locks_db.h + datashard_locks.h + datashard_locks.cpp + datashard_split_dst.cpp + datashard_split_src.cpp + datashard_switch_mvcc_state.cpp + datashard_trans_queue.cpp + datashard_trans_queue.h + datashard_outreadset.cpp + datashard_outreadset.h + datashard_active_transaction.cpp + datashard_active_transaction.h + datashard_common_upload.cpp + datashard_direct_transaction.cpp + datashard_direct_transaction.h + datashard_direct_erase.cpp + datashard_direct_upload.cpp + datashard_distributed_erase.cpp + datashard_failpoints.cpp + datashard_failpoints.h + datashard_dep_tracker.cpp + datashard_dep_tracker.h + datashard_pipeline.cpp + datashard_pipeline.h + datashard_s3_downloads.cpp + datashard_s3_uploads.cpp + datashard_s3_upload_rows.cpp + datashard_schema_snapshots.cpp + datashard_snapshots.cpp + datashard_user_db.cpp + datashard_user_db.h + datashard_user_table.cpp + datashard_user_table.h + datashard_impl.h + datashard_kqp_compute.cpp + datashard_kqp_compute.h + datashard_kqp_effects.cpp + datashard_kqp_lookup_table.cpp + datashard_kqp_read_table.cpp + datashard_kqp_upsert_rows.cpp + datashard_kqp_delete_rows.cpp + datashard_kqp.cpp + datashard_kqp.h + datashard_read_operation.h + datashard_repl_apply.cpp + datashard_repl_offsets.cpp + datashard_repl_offsets_client.cpp + datashard_repl_offsets_server.cpp + datashard_subdomain_path_id.cpp + datashard_txs.h + datashard.cpp + datashard.h + defs.h + direct_tx_unit.cpp + drop_cdc_stream_unit.cpp + drop_index_notice_unit.cpp + drop_persistent_snapshot_unit.cpp + drop_table_unit.cpp + drop_volatile_snapshot_unit.cpp + erase_rows_condition.cpp + execute_commit_writes_tx_unit.cpp + execute_data_tx_unit.cpp + execute_distributed_erase_tx_unit.cpp + execute_kqp_data_tx_unit.cpp + execute_kqp_scan_tx_unit.cpp + execution_unit.cpp + execution_unit.h + execution_unit_ctors.h + execution_unit_kind.h + export_common.cpp + export_iface.cpp + export_iface.h + export_scan.cpp + finalize_build_index_unit.cpp + finish_propose_unit.cpp + follower_edge.cpp + initiate_build_index_unit.cpp + key_conflicts.cpp + key_conflicts.h + load_and_wait_in_rs_unit.cpp + load_tx_details_unit.cpp + make_scan_snapshot_unit.cpp + make_snapshot_unit.cpp + move_index_unit.cpp + move_table_unit.cpp + operation.cpp + operation.h + plan_queue_unit.cpp + prepare_data_tx_in_rs_unit.cpp + prepare_distributed_erase_tx_in_rs_unit.cpp + prepare_kqp_data_tx_in_rs_unit.cpp + prepare_scheme_tx_in_rs_unit.cpp + probes.cpp + progress_queue.h + protect_scheme_echoes_unit.cpp + read_op_unit.cpp + read_table_scan.h + read_table_scan.cpp + read_table_scan_unit.cpp + receive_snapshot_cleanup_unit.cpp + receive_snapshot_unit.cpp + remove_lock_change_records.cpp + remove_locks.cpp + range_avl_tree.cpp + range_ops.cpp + range_treap.cpp + read_iterator.h + restore_unit.cpp + setup_sys_locks.h + store_and_send_out_rs_unit.cpp + store_commit_writes_tx_unit.cpp + store_data_tx_unit.cpp + store_distributed_erase_tx_unit.cpp + store_scheme_tx_unit.cpp + store_snapshot_tx_unit.cpp + volatile_tx.cpp + wait_for_plan_unit.cpp + wait_for_stream_clearance_unit.cpp + upload_stats.cpp +) + +GENERATE_ENUM_SERIALIZATION(backup_restore_traits.h) +GENERATE_ENUM_SERIALIZATION(change_exchange.h) +GENERATE_ENUM_SERIALIZATION(change_record.h) +GENERATE_ENUM_SERIALIZATION(datashard.h) +GENERATE_ENUM_SERIALIZATION(datashard_active_transaction.h) +GENERATE_ENUM_SERIALIZATION(datashard_s3_upload.h) +GENERATE_ENUM_SERIALIZATION(execution_unit.h) +GENERATE_ENUM_SERIALIZATION(execution_unit_kind.h) +GENERATE_ENUM_SERIALIZATION(operation.h) + +RESOURCE( + index.html datashard/index.html +) + +PEERDIR( + contrib/libs/zstd + library/cpp/actors/core + library/cpp/containers/absl_flat_hash + library/cpp/containers/stack_vector + library/cpp/digest/md5 + library/cpp/html/pcdata + library/cpp/json + library/cpp/json/yson + library/cpp/lwtrace + library/cpp/lwtrace/mon + library/cpp/monlib/service/pages + library/cpp/string_utils/base64 + library/cpp/string_utils/quote + ydb/core/actorlib_impl + ydb/core/base + ydb/core/engine + ydb/core/engine/minikql + ydb/core/formats + ydb/core/io_formats + ydb/core/kqp/runtime + ydb/core/persqueue/partition_key_range + ydb/core/persqueue/writer + ydb/core/protos + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx/long_tx_service/public + ydb/core/util + ydb/core/wrappers + ydb/core/ydb_convert + ydb/library/aclib + ydb/library/binary_json + ydb/library/dynumber + ydb/library/yql/parser/pg_wrapper/interface + ydb/public/api/protos + ydb/public/lib/deprecated/kicli + ydb/library/yql/dq/actors/compute + ydb/services/lib/sharding + ydb/library/chunks_limiter +) + +YQL_LAST_ABI_VERSION() + +IF (OS_WINDOWS) + CFLAGS( + -DKIKIMR_DISABLE_S3_OPS + ) +ELSE() + SRCS( + export_s3_buffer_raw.cpp + export_s3_buffer_zstd.cpp + export_s3_uploader.cpp + extstorage_usage_config.cpp + import_s3.cpp + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut_background_compaction + ut_build_index + ut_change_collector + ut_change_exchange + ut_compaction + ut_erase_rows + ut_followers + ut_init + ut_keys + ut_kqp + ut_kqp_errors + ut_kqp_scan + ut_locks + ut_minikql + ut_minstep + ut_order + ut_range_avl_tree + ut_range_ops + ut_range_treap + ut_read_iterator + ut_read_table + ut_reassign + ut_replication + ut_rs + ut_snapshot + ut_stats + ut_upload_rows + ut_volatile +) diff --git a/ydb/core/tx/long_tx_service/public/ut/ya.make b/ydb/core/tx/long_tx_service/public/ut/ya.make new file mode 100644 index 00000000000..e14b1dec683 --- /dev/null +++ b/ydb/core/tx/long_tx_service/public/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/core/tx/long_tx_service/public) + +SRCS( + types_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/long_tx_service/public/ya.make b/ydb/core/tx/long_tx_service/public/ya.make new file mode 100644 index 00000000000..83ad8f05ca0 --- /dev/null +++ b/ydb/core/tx/long_tx_service/public/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + events.cpp + lock_handle.cpp + types.cpp +) + +PEERDIR( + library/cpp/cgiparam + library/cpp/lwtrace + library/cpp/uri + ydb/core/base + ydb/core/protos + ydb/core/util + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/long_tx_service/ut/ya.make b/ydb/core/tx/long_tx_service/ut/ya.make new file mode 100644 index 00000000000..71a95548493 --- /dev/null +++ b/ydb/core/tx/long_tx_service/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/core/tx/long_tx_service) + +SRCS( + long_tx_service_ut.cpp +) + +PEERDIR( + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/long_tx_service/ya.make b/ydb/core/tx/long_tx_service/ya.make new file mode 100644 index 00000000000..ebf56aae229 --- /dev/null +++ b/ydb/core/tx/long_tx_service/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +SRCS( + acquire_snapshot_impl.cpp + commit_impl.cpp + long_tx_service.cpp + long_tx_service_impl.cpp + lwtrace_probes.cpp +) + +PEERDIR( + library/cpp/lwtrace + library/cpp/lwtrace/mon + ydb/core/base + ydb/core/tx/columnshard + ydb/core/tx/long_tx_service/public +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + public + ut + public/ut +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/mediator/ya.make b/ydb/core/tx/mediator/ya.make new file mode 100644 index 00000000000..62be88787d5 --- /dev/null +++ b/ydb/core/tx/mediator/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +SRCS( + mediator.cpp + mediator_impl.cpp + mediator__init.cpp + mediator__configure.cpp + mediator__schema.cpp + mediator__schema_upgrade.cpp + tablet_queue.cpp + execute_queue.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/engine/minikql + ydb/core/protos + ydb/core/scheme_types + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx + ydb/core/tx/coordinator + ydb/core/tx/time_cast + ydb/core/util +) + +END() diff --git a/ydb/core/tx/program/ya.make b/ydb/core/tx/program/ya.make new file mode 100644 index 00000000000..53de4b89f26 --- /dev/null +++ b/ydb/core/tx/program/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + registry.cpp + program.cpp +) + +PEERDIR( + ydb/core/formats/arrow + ydb/core/protos + ydb/core/tablet_flat + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/core/arrow_kernels/registry +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/replication/controller/ya.make b/ydb/core/tx/replication/controller/ya.make new file mode 100644 index 00000000000..f19f6ecbcc2 --- /dev/null +++ b/ydb/core/tx/replication/controller/ya.make @@ -0,0 +1,46 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/discovery + ydb/core/engine/minikql + ydb/core/protos + ydb/core/tablet_flat + ydb/core/tx/replication/ydb_proxy + ydb/core/util + ydb/core/ydb_convert +) + +SRCS( + controller.cpp + dst_creator.cpp + dst_remover.cpp + logging.cpp + nodes_manager.cpp + private_events.cpp + replication.cpp + stream_creator.cpp + stream_remover.cpp + sys_params.cpp + target_base.cpp + target_discoverer.cpp + target_table.cpp + target_with_stream.cpp + tenant_resolver.cpp + tx_assign_stream_name.cpp + tx_create_dst_result.cpp + tx_create_replication.cpp + tx_create_stream_result.cpp + tx_discovery_targets_result.cpp + tx_drop_dst_result.cpp + tx_drop_replication.cpp + tx_drop_stream_result.cpp + tx_init.cpp + tx_init_schema.cpp +) + +GENERATE_ENUM_SERIALIZATION(replication.h) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/replication/service/ya.make b/ydb/core/tx/replication/service/ya.make new file mode 100644 index 00000000000..d4994939928 --- /dev/null +++ b/ydb/core/tx/replication/service/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + ydb/core/base +) + +SRCS( + service.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/replication/ut/ya.make b/ydb/core/tx/replication/ut/ya.make new file mode 100644 index 00000000000..5111ece9394 --- /dev/null +++ b/ydb/core/tx/replication/ut/ya.make @@ -0,0 +1,3 @@ +RECURSE( + ../ydb_proxy/ut +) diff --git a/ydb/core/tx/replication/ya.make b/ydb/core/tx/replication/ya.make new file mode 100644 index 00000000000..415f12aff5f --- /dev/null +++ b/ydb/core/tx/replication/ya.make @@ -0,0 +1,9 @@ +RECURSE( + controller + service + ydb_proxy +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/replication/ydb_proxy/ut/ya.make b/ydb/core/tx/replication/ydb_proxy/ut/ya.make new file mode 100644 index 00000000000..5ab140af115 --- /dev/null +++ b/ydb/core/tx/replication/ydb_proxy/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/tx/replication/ydb_proxy) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default + ydb/public/sdk/cpp/client/ydb_topic +) + +SRCS( + ydb_proxy_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/replication/ydb_proxy/ya.make b/ydb/core/tx/replication/ydb_proxy/ya.make new file mode 100644 index 00000000000..27ced7a7376 --- /dev/null +++ b/ydb/core/tx/replication/ydb_proxy/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/protos + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_topic + ydb/public/sdk/cpp/client/ydb_types/credentials + ydb/public/sdk/cpp/client/ydb_types/credentials/login +) + +SRCS( + ydb_proxy.cpp +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/scheme_board/ut_cache/ya.make b/ydb/core/tx/scheme_board/ut_cache/ya.make new file mode 100644 index 00000000000..036c97c0346 --- /dev/null +++ b/ydb/core/tx/scheme_board/ut_cache/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/core/tx/scheme_board) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default + ydb/core/tx/schemeshard + ydb/core/tx/schemeshard/ut_helpers +) + +YQL_LAST_ABI_VERSION() + +SRCS( + cache_ut.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/scheme_board/ut_double_indexed/ya.make b/ydb/core/tx/scheme_board/ut_double_indexed/ya.make new file mode 100644 index 00000000000..e77c87754b5 --- /dev/null +++ b/ydb/core/tx/scheme_board/ut_double_indexed/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/core/tx/scheme_board) + +PEERDIR( + library/cpp/testing/unittest + ydb/library/yql/sql/pg_dummy + ydb/library/yql/public/udf/service/exception_policy +) + +SRCS( + double_indexed_ut.cpp +) + +END() diff --git a/ydb/core/tx/scheme_board/ut_monitoring/ya.make b/ydb/core/tx/scheme_board/ut_monitoring/ya.make new file mode 100644 index 00000000000..b4237932fee --- /dev/null +++ b/ydb/core/tx/scheme_board/ut_monitoring/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/tx/scheme_board) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/actors/core + library/cpp/testing/unittest + ydb/core/testlib/basics/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + monitoring_ut.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/scheme_board/ut_populator/ya.make b/ydb/core/tx/scheme_board/ut_populator/ya.make new file mode 100644 index 00000000000..b9d18ccdce5 --- /dev/null +++ b/ydb/core/tx/scheme_board/ut_populator/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/tx/scheme_board) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default + ydb/core/tx/schemeshard + ydb/core/tx/schemeshard/ut_helpers + ydb/core/tx/tx_allocator +) + +SRCS( + populator_ut.cpp + ut_helpers.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/scheme_board/ut_replica/ya.make b/ydb/core/tx/scheme_board/ut_replica/ya.make new file mode 100644 index 00000000000..0f1e0736728 --- /dev/null +++ b/ydb/core/tx/scheme_board/ut_replica/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/core/tx/scheme_board) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/basics/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + replica_ut.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/scheme_board/ut_subscriber/ya.make b/ydb/core/tx/scheme_board/ut_subscriber/ya.make new file mode 100644 index 00000000000..f32cccd9b28 --- /dev/null +++ b/ydb/core/tx/scheme_board/ut_subscriber/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/core/tx/scheme_board) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +PEERDIR( + library/cpp/actors/interconnect + library/cpp/testing/unittest + ydb/core/testlib/basics/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + subscriber_ut.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/scheme_board/ya.make b/ydb/core/tx/scheme_board/ya.make new file mode 100644 index 00000000000..f3ea8da00f4 --- /dev/null +++ b/ydb/core/tx/scheme_board/ya.make @@ -0,0 +1,36 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/mon + ydb/core/protos + ydb/core/sys_view/common + ydb/core/tx/scheme_cache + ydb/core/util + ydb/library/aclib +) + +SRCS( + cache.cpp + helpers.cpp + load_test.cpp + monitoring.cpp + populator.cpp + replica.cpp + subscriber.cpp + two_part_description.cpp +) + +GENERATE_ENUM_SERIALIZATION(subscriber.h) + +END() + +RECURSE_FOR_TESTS( + ut_cache + ut_double_indexed + ut_monitoring + ut_populator + ut_replica + ut_subscriber +) diff --git a/ydb/core/tx/scheme_cache/ya.make b/ydb/core/tx/scheme_cache/ya.make new file mode 100644 index 00000000000..71c48361874 --- /dev/null +++ b/ydb/core/tx/scheme_cache/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/protos + ydb/core/scheme + ydb/library/aclib +) + +SRCS( + scheme_cache.cpp +) + +GENERATE_ENUM_SERIALIZATION(scheme_cache.h) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_async_index/ya.make b/ydb/core/tx/schemeshard/ut_async_index/ya.make new file mode 100644 index 00000000000..c257972575a --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_async_index/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/testlib/default + ydb/core/tx/schemeshard/ut_helpers +) + +SRCS( + ut_async_index.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_backup/ya.make b/ydb/core/tx/schemeshard/ut_backup/ya.make new file mode 100644 index 00000000000..758608ad2ac --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_backup/ya.make @@ -0,0 +1,36 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(11) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +INCLUDE(${ARCADIA_ROOT}/ydb/tests/supp/ubsan_supp.inc) + +IF (NOT OS_WINDOWS) + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/core/wrappers/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + SRCS( + ut_backup.cpp + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_base/ya.make b/ydb/core/tx/schemeshard/ut_base/ya.make new file mode 100644 index 00000000000..ff632bb14ef --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_base/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + SPLIT_FACTOR(40) +ENDIF() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_base.cpp + ut_info_types.cpp + ut_allocate_pq.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_base_reboots/ya.make b/ydb/core/tx/schemeshard/ut_base_reboots/ya.make new file mode 100644 index 00000000000..f175d6ee0b7 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_base_reboots/ya.make @@ -0,0 +1,36 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_base_reboots.cpp + ut_allocate_reboot_pq.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_bsvolume/ya.make b/ydb/core/tx/schemeshard/ut_bsvolume/ya.make new file mode 100644 index 00000000000..e173be225e6 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_bsvolume/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_bsvolume.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_bsvolume_reboots/ya.make b/ydb/core/tx/schemeshard/ut_bsvolume_reboots/ya.make new file mode 100644 index 00000000000..ec87616f2b8 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_bsvolume_reboots/ya.make @@ -0,0 +1,36 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_bsvolume_reboots.cpp + ) + + REQUIREMENTS(ram:9) + +END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_cdc_stream/ya.make b/ydb/core/tx/schemeshard/ut_cdc_stream/ya.make new file mode 100644 index 00000000000..ef105ce5022 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_cdc_stream/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/testlib/default + ydb/core/tx/schemeshard/ut_helpers + library/cpp/json +) + +SRCS( + ut_cdc_stream.cpp +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:11) + +END() diff --git a/ydb/core/tx/schemeshard/ut_cdc_stream_reboots/ya.make b/ydb/core/tx/schemeshard/ut_cdc_stream_reboots/ya.make new file mode 100644 index 00000000000..40d1d54204f --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_cdc_stream_reboots/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/sql/pg_dummy +) + +SRCS( + ut_cdc_stream_reboots.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_compaction/ya.make b/ydb/core/tx/schemeshard/ut_compaction/ya.make new file mode 100644 index 00000000000..b3baf15da5e --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_compaction/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + ydb/core/cms + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/core/wrappers/ut_helpers +) + +SRCS( + ut_compaction.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_export/ya.make b/ydb/core/tx/schemeshard/ut_export/ya.make new file mode 100644 index 00000000000..c2f18433073 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_export/ya.make @@ -0,0 +1,36 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(11) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +INCLUDE(${ARCADIA_ROOT}/ydb/tests/supp/ubsan_supp.inc) + +IF (NOT OS_WINDOWS) + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/core/wrappers/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + SRCS( + ut_export.cpp + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_export_reboots_s3/ya.make b/ydb/core/tx/schemeshard/ut_export_reboots_s3/ya.make new file mode 100644 index 00000000000..5de4e5b9600 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_export_reboots_s3/ya.make @@ -0,0 +1,35 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(12) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +INCLUDE(${ARCADIA_ROOT}/ydb/tests/supp/ubsan_supp.inc) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/core/wrappers/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +SRCS( + ut_export_reboots_s3.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_external_data_source/ya.make b/ydb/core/tx/schemeshard/ut_external_data_source/ya.make new file mode 100644 index 00000000000..fa6644fce19 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_external_data_source/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_external_data_source.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_external_data_source_reboots/ya.make b/ydb/core/tx/schemeshard/ut_external_data_source_reboots/ya.make new file mode 100644 index 00000000000..a4d90782a71 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_external_data_source_reboots/ya.make @@ -0,0 +1,36 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_external_data_source_reboots.cpp + ) + + REQUIREMENTS(ram:12) + +END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_external_table/ya.make b/ydb/core/tx/schemeshard/ut_external_table/ya.make new file mode 100644 index 00000000000..1d4005d43e7 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_external_table/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_external_table.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_external_table_reboots/ya.make b/ydb/core/tx/schemeshard/ut_external_table_reboots/ya.make new file mode 100644 index 00000000000..50452128225 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_external_table_reboots/ya.make @@ -0,0 +1,36 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_external_table_reboots.cpp + ) + + REQUIREMENTS(ram:12) + +END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_extsubdomain/ya.make b/ydb/core/tx/schemeshard/ut_extsubdomain/ya.make new file mode 100644 index 00000000000..68ee80272d2 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_extsubdomain/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(60) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_extsubdomain.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_extsubdomain_reboots/ya.make b/ydb/core/tx/schemeshard/ut_extsubdomain_reboots/ya.make new file mode 100644 index 00000000000..686524ffcf8 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_extsubdomain_reboots/ya.make @@ -0,0 +1,32 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(300) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_extsubdomain_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_filestore_reboots/ya.make b/ydb/core/tx/schemeshard/ut_filestore_reboots/ya.make new file mode 100644 index 00000000000..f5ed9d29769 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_filestore_reboots/ya.make @@ -0,0 +1,34 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_filestore_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_helpers/ya.make b/ydb/core/tx/schemeshard/ut_helpers/ya.make new file mode 100644 index 00000000000..ca18f396d45 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_helpers/ya.make @@ -0,0 +1,39 @@ +LIBRARY() + +PEERDIR( + library/cpp/testing/unittest + ydb/core/base + ydb/core/blockstore/core + ydb/core/cms/console + ydb/core/engine + ydb/core/engine/minikql + ydb/core/filestore/core + ydb/core/metering + ydb/core/persqueue/ut/common + ydb/core/protos + ydb/core/scheme + ydb/core/tablet_flat + ydb/core/testlib + ydb/core/tx + ydb/core/tx/datashard + ydb/core/tx/schemeshard + ydb/core/tx/tx_allocator + ydb/core/tx/tx_proxy + ydb/public/lib/scheme_types + ydb/public/sdk/cpp/client/ydb_driver +) + +SRCS( + export_reboots_common.cpp + failing_mtpq.cpp + test_env.cpp + test_env.h + ls_checks.cpp + ls_checks.h + helpers.cpp + helpers.h +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_index_build/ya.make b/ydb/core/tx/schemeshard/ut_index_build/ya.make new file mode 100644 index 00000000000..10643c848a6 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_index_build/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/metering + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_index_build.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_index_build_reboots/ya.make b/ydb/core/tx/schemeshard/ut_index_build_reboots/ya.make new file mode 100644 index 00000000000..c83d872fa11 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_index_build_reboots/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + SPLIT_FACTOR(40) +ENDIF() + +TIMEOUT(2400) + +TAG(ya:fat) + +SIZE(LARGE) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +SRCS( + ut_index_build_reboots.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_login/ya.make b/ydb/core/tx/schemeshard/ut_login/ya.make new file mode 100644 index 00000000000..97a4d04776f --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_login/ya.make @@ -0,0 +1,31 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/login + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_login.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_move/ya.make b/ydb/core/tx/schemeshard/ut_move/ya.make new file mode 100644 index 00000000000..5961493d764 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_move/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + SPLIT_FACTOR(40) +ENDIF() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_move.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_move_reboots/ya.make b/ydb/core/tx/schemeshard/ut_move_reboots/ya.make new file mode 100644 index 00000000000..574a334e962 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_move_reboots/ya.make @@ -0,0 +1,35 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_move_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_olap/ya.make b/ydb/core/tx/schemeshard/ut_olap/ya.make new file mode 100644 index 00000000000..ab7fb360ffe --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_olap/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/formats + ydb/core/tx + ydb/core/tx/columnshard + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_olap.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_olap_reboots/ya.make b/ydb/core/tx/schemeshard/ut_olap_reboots/ya.make new file mode 100644 index 00000000000..b3b6cf92649 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_olap_reboots/ya.make @@ -0,0 +1,33 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/columnshard + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_olap_reboots.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_pq/ya.make b/ydb/core/tx/schemeshard/ut_pq/ya.make new file mode 100644 index 00000000000..f10ecb9fd75 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_pq/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +SRCS( + ut_pq.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_pq_reboots/ya.make b/ydb/core/tx/schemeshard/ut_pq_reboots/ya.make new file mode 100644 index 00000000000..e0c1a960f23 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_pq_reboots/ya.make @@ -0,0 +1,35 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_pq_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_reboots/ya.make b/ydb/core/tx/schemeshard/ut_reboots/ya.make new file mode 100644 index 00000000000..c0663cfb160 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_reboots/ya.make @@ -0,0 +1,35 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_replication/ya.make b/ydb/core/tx/schemeshard/ut_replication/ya.make new file mode 100644 index 00000000000..6bd1b3c7207 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_replication/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/sql/pg_dummy +) + +SRCS( + ut_replication.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_replication_reboots/ya.make b/ydb/core/tx/schemeshard/ut_replication_reboots/ya.make new file mode 100644 index 00000000000..a3bfc449ffe --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_replication_reboots/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/sql/pg_dummy +) + +SRCS( + ut_replication_reboots.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_restore/ya.make b/ydb/core/tx/schemeshard/ut_restore/ya.make new file mode 100644 index 00000000000..9dafc9712ac --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_restore/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + contrib/libs/double-conversion + library/cpp/string_utils/quote + ydb/core/kqp/ut/common + ydb/core/tx/schemeshard/ut_helpers + ydb/core/wrappers/ut_helpers + ydb/core/ydb_convert + ydb/library/yql/sql/pg_dummy +) + +SRCS( + ut_restore.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_rtmr/ya.make b/ydb/core/tx/schemeshard/ut_rtmr/ya.make new file mode 100644 index 00000000000..d8d02a1df40 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_rtmr/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_rtmr.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_rtmr_reboots/ya.make b/ydb/core/tx/schemeshard/ut_rtmr_reboots/ya.make new file mode 100644 index 00000000000..e7082f296cb --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_rtmr_reboots/ya.make @@ -0,0 +1,36 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_rtmr_reboots.cpp + ) + + REQUIREMENTS(ram:12) + +END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_ru_calculator/ya.make b/ydb/core/tx/schemeshard/ut_ru_calculator/ya.make new file mode 100644 index 00000000000..cd8262e61e4 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_ru_calculator/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/tx/tx_proxy + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +SRCS( + ut_ru_calculator.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_sequence/ya.make b/ydb/core/tx/schemeshard/ut_sequence/ya.make new file mode 100644 index 00000000000..63d9906e694 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_sequence/ya.make @@ -0,0 +1,33 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/columnshard + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_sequence.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_sequence_reboots/ya.make b/ydb/core/tx/schemeshard/ut_sequence_reboots/ya.make new file mode 100644 index 00000000000..3a9a7ba4f28 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_sequence_reboots/ya.make @@ -0,0 +1,33 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/columnshard + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_sequence_reboots.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_serverless/ya.make b/ydb/core/tx/schemeshard/ut_serverless/ya.make new file mode 100644 index 00000000000..110712b9ef0 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_serverless/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/core/yql_testlib +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_serverless.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_split_merge/ya.make b/ydb/core/tx/schemeshard/ut_split_merge/ya.make new file mode 100644 index 00000000000..bdcd8befb50 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_split_merge/ya.make @@ -0,0 +1,34 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(20) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_split_merge.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_split_merge_reboots/ya.make b/ydb/core/tx/schemeshard/ut_split_merge_reboots/ya.make new file mode 100644 index 00000000000..2f6f511f4dc --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_split_merge_reboots/ya.make @@ -0,0 +1,35 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(20) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_split_merge_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_stats/ya.make b/ydb/core/tx/schemeshard/ut_stats/ya.make new file mode 100644 index 00000000000..33aa47dcafb --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_stats/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + ydb/core/cms + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/core/wrappers/ut_helpers +) + +SRCS( + ut_stats.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_subdomain/ya.make b/ydb/core/tx/schemeshard/ut_subdomain/ya.make new file mode 100644 index 00000000000..1d29db362f5 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_subdomain/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_subdomain.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_subdomain_reboots/ya.make b/ydb/core/tx/schemeshard/ut_subdomain_reboots/ya.make new file mode 100644 index 00000000000..e816743c5cd --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_subdomain_reboots/ya.make @@ -0,0 +1,34 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_subdomain_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ut_topic_splitmerge/ya.make b/ydb/core/tx/schemeshard/ut_topic_splitmerge/ya.make new file mode 100644 index 00000000000..aacc621af49 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_topic_splitmerge/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + SPLIT_FACTOR(40) +ENDIF() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_topic_splitmerge.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_ttl/ya.make b/ydb/core/tx/schemeshard/ut_ttl/ya.make new file mode 100644 index 00000000000..d64623fd938 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_ttl/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/kqp/ut/common + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/sql/pg_dummy +) + +SRCS( + ut_ttl.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_user_attributes/ya.make b/ydb/core/tx/schemeshard/ut_user_attributes/ya.make new file mode 100644 index 00000000000..f0e9cfdf346 --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_user_attributes/ya.make @@ -0,0 +1,36 @@ +UNITTEST_FOR(ydb/core/tx/schemeshard) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/http/io + library/cpp/http/server + library/cpp/svnversion + library/cpp/testing/unittest + ydb/core/base + ydb/core/blockstore/core + ydb/core/engine/minikql + ydb/core/protos + ydb/core/scheme + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/datashard + ydb/core/tx/schemeshard + ydb/core/tx/schemeshard/ut_helpers + ydb/core/util + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_user_attributes.cpp +) + +END() diff --git a/ydb/core/tx/schemeshard/ut_user_attributes_reboots/ya.make b/ydb/core/tx/schemeshard/ut_user_attributes_reboots/ya.make new file mode 100644 index 00000000000..6d363c7cd0b --- /dev/null +++ b/ydb/core/tx/schemeshard/ut_user_attributes_reboots/ya.make @@ -0,0 +1,34 @@ +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/core/tx/schemeshard) + + FORK_SUBTESTS() + + SPLIT_FACTOR(60) + + IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + ENDIF() + + PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/schemeshard/ut_helpers + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + SRCS( + ut_user_attributes_reboots.cpp + ) + + END() +ENDIF() diff --git a/ydb/core/tx/schemeshard/ya.make b/ydb/core/tx/schemeshard/ya.make new file mode 100644 index 00000000000..2a3410b3cbd --- /dev/null +++ b/ydb/core/tx/schemeshard/ya.make @@ -0,0 +1,286 @@ +RECURSE_FOR_TESTS( + ut_async_index + ut_backup + ut_base + ut_base_reboots + ut_bsvolume + ut_bsvolume_reboots + ut_cdc_stream + ut_cdc_stream_reboots + ut_compaction + ut_export + ut_export_reboots_s3 + ut_external_data_source + ut_external_data_source_reboots + ut_external_table + ut_external_table_reboots + ut_extsubdomain + ut_extsubdomain_reboots + ut_filestore_reboots + ut_index_build + ut_index_build_reboots + ut_login + ut_move + ut_move_reboots + ut_olap + ut_olap_reboots + ut_pq + ut_pq_reboots + ut_reboots + ut_replication + ut_replication_reboots + ut_restore + ut_rtmr + ut_rtmr_reboots + ut_ru_calculator + ut_sequence + ut_sequence_reboots + ut_serverless + ut_split_merge + ut_split_merge_reboots + ut_stats + ut_subdomain + ut_subdomain_reboots + ut_topic_splitmerge + ut_ttl + ut_user_attributes + ut_user_attributes_reboots +) + +LIBRARY() + +IF (KIKIMR_ALLOW_SHARDED_COMPACTION) + CFLAGS( + -DKIKIMR_ALLOW_SHARDED_COMPACTION=1 + ) +ENDIF() + +SRCS( + defs.h + schemeshard.cpp + schemeshard__borrowed_compaction.cpp + schemeshard__compaction.cpp + schemeshard__clean_pathes.cpp + schemeshard__conditional_erase.cpp + schemeshard__describe_scheme.cpp + schemeshard__delete_tablet_reply.cpp + schemeshard__find_subdomain_path_id.cpp + schemeshard__fix_bad_paths.cpp + schemeshard__init.cpp + schemeshard__init_populator.cpp + schemeshard__init_root.cpp + schemeshard__init_schema.cpp + schemeshard__serverless_storage_billing.cpp + schemeshard__sync_update_tenants.cpp + schemeshard__login.cpp + schemeshard__monitoring.cpp + schemeshard__notify.cpp + schemeshard__operation.cpp + schemeshard__operation.h + schemeshard__operation_blob_depot.cpp + schemeshard__operation_side_effects.cpp + schemeshard__operation_side_effects.h + schemeshard__operation_memory_changes.cpp + schemeshard__operation_db_changes.cpp + schemeshard__operation_alter_bsv.cpp + schemeshard__operation_alter_extsubdomain.cpp + schemeshard__operation_alter_fs.cpp + schemeshard__operation_alter_index.cpp + schemeshard__operation_alter_kesus.cpp + schemeshard__operation_alter_login.cpp + schemeshard__operation_alter_olap_store.cpp + schemeshard__operation_alter_olap_table.cpp + schemeshard__operation_alter_pq.cpp + schemeshard__operation_alter_solomon.cpp + schemeshard__operation_alter_subdomain.cpp + schemeshard__operation_alter_table.cpp + schemeshard__operation_alter_user_attrs.cpp + schemeshard__operation_assign_bsv.cpp + schemeshard__operation_cancel_tx.cpp + schemeshard__operation_common.cpp + schemeshard__operation_common.h + schemeshard__operation_common_subdomain.h + schemeshard__operation_consistent_copy_tables.cpp + schemeshard__operation_copy_table.cpp + schemeshard__operation_create_backup.cpp + schemeshard__operation_create_bsv.cpp + schemeshard__operation_create_external_data_source.cpp + schemeshard__operation_create_external_table.cpp + schemeshard__operation_create_extsubdomain.cpp + schemeshard__operation_create_fs.cpp + schemeshard__operation_create_index.cpp + schemeshard__operation_create_indexed_table.cpp + schemeshard__operation_create_kesus.cpp + schemeshard__operation_create_lock.cpp + schemeshard__operation_create_olap_store.cpp + schemeshard__operation_create_olap_table.cpp + schemeshard__operation_create_pq.cpp + schemeshard__operation_create_replication.cpp + schemeshard__operation_create_restore.cpp + schemeshard__operation_create_rtmr.cpp + schemeshard__operation_create_sequence.cpp + schemeshard__operation_create_solomon.cpp + schemeshard__operation_create_subdomain.cpp + schemeshard__operation_create_table.cpp + schemeshard__operation_drop_bsv.cpp + schemeshard__operation_drop_external_data_source.cpp + schemeshard__operation_drop_external_table.cpp + schemeshard__operation_drop_extsubdomain.cpp + schemeshard__operation_drop_fs.cpp + schemeshard__operation_drop_indexed_table.cpp + schemeshard__operation_drop_kesus.cpp + schemeshard__operation_drop_lock.cpp + schemeshard__operation_drop_olap_store.cpp + schemeshard__operation_drop_olap_table.cpp + schemeshard__operation_drop_pq.cpp + schemeshard__operation_drop_replication.cpp + schemeshard__operation_drop_sequence.cpp + schemeshard__operation_drop_solomon.cpp + schemeshard__operation_drop_subdomain.cpp + schemeshard__operation_drop_table.cpp + schemeshard__operation_drop_unsafe.cpp + schemeshard__operation_mkdir.cpp + schemeshard__operation_modify_acl.cpp + schemeshard__operation_move_index.cpp + schemeshard__operation_move_table.cpp + schemeshard__operation_move_tables.cpp + schemeshard__operation_move_table_index.cpp + schemeshard__operation_part.cpp + schemeshard__operation_part.h + schemeshard__operation_rmdir.cpp + schemeshard__operation_split_merge.cpp + schemeshard__operation_just_reject.cpp + schemeshard__operation_upgrade_subdomain.cpp + schemeshard__operation_initiate_build_index.cpp + schemeshard__operation_finalize_build_index.cpp + schemeshard__operation_create_build_index.cpp + schemeshard__operation_apply_build_index.cpp + schemeshard__operation_cansel_build_index.cpp + schemeshard__operation_drop_index.cpp + schemeshard__operation_create_cdc_stream.cpp + schemeshard__operation_alter_cdc_stream.cpp + schemeshard__operation_drop_cdc_stream.cpp + schemeshard__operation_allocate_pq.cpp + schemeshard__operation_deallocate_pq.cpp + schemeshard__pq_stats.cpp + schemeshard__publish_to_scheme_board.cpp + schemeshard__state_changed_reply.cpp + schemeshard__table_stats.cpp + schemeshard__table_stats_histogram.cpp + schemeshard__upgrade_schema.cpp + schemeshard__upgrade_access_database.cpp + schemeshard__make_access_database_no_inheritable.cpp + schemeshard_audit_log_fragment.cpp + schemeshard_audit_log.cpp + schemeshard_impl.cpp + schemeshard_impl.h + schemeshard_billing_helpers.cpp + schemeshard_cdc_stream_scan.cpp + schemeshard_domain_links.h + schemeshard_domain_links.cpp + schemeshard_effective_acl.h + schemeshard_effective_acl.cpp + schemeshard_identificators.cpp + schemeshard_info_types.cpp + schemeshard_info_types.h + schemeshard_olap_types.cpp + schemeshard_path_describer.cpp + schemeshard_path_element.cpp + schemeshard_path_element.h + schemeshard_path.cpp + schemeshard_path.h + schemeshard_schema.h + schemeshard_svp_migration.h + schemeshard_svp_migration.cpp + schemeshard_tx_infly.h + schemeshard_tables_storage.cpp + schemeshard_types.cpp + schemeshard_types.h + schemeshard_ui64id.cpp + schemeshard_user_attr_limits.h + schemeshard_utils.cpp + schemeshard_utils.h + schemeshard_export__cancel.cpp + schemeshard_export__create.cpp + schemeshard_export__forget.cpp + schemeshard_export__get.cpp + schemeshard_export__list.cpp + schemeshard_export_flow_proposals.cpp + schemeshard_export.cpp + schemeshard_import__cancel.cpp + schemeshard_import__create.cpp + schemeshard_import__forget.cpp + schemeshard_import__get.cpp + schemeshard_import__list.cpp + schemeshard_import_flow_proposals.cpp + schemeshard_import.cpp + schemeshard_build_index.cpp + schemeshard_build_index__cancel.cpp + schemeshard_build_index__forget.cpp + schemeshard_build_index__list.cpp + schemeshard_build_index__create.cpp + schemeshard_build_index__get.cpp + schemeshard_build_index__progress.cpp + schemeshard_validate_ttl.cpp + operation_queue_timer.h + user_attributes.cpp +) + +GENERATE_ENUM_SERIALIZATION(schemeshard_info_types.h) + +GENERATE_ENUM_SERIALIZATION(schemeshard_types.h) + +GENERATE_ENUM_SERIALIZATION(operation_queue_timer.h) + +PEERDIR( + contrib/libs/protobuf + library/cpp/deprecated/enum_codegen + library/cpp/html/pcdata + library/cpp/json + ydb/core/actorlib_impl + ydb/core/audit + ydb/core/base + ydb/core/blob_depot + ydb/core/blockstore/core + ydb/core/engine + ydb/core/engine/minikql + ydb/core/external_sources + ydb/core/filestore/core + ydb/core/kesus/tablet + ydb/core/metering + ydb/core/persqueue/config + ydb/core/persqueue/events + ydb/core/persqueue/writer + ydb/core/protos + ydb/core/scheme + ydb/core/sys_view/partition_stats + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx + ydb/core/tx/datashard + ydb/core/tx/scheme_board + ydb/core/tx/tx_allocator_client + ydb/core/util + ydb/core/wrappers + ydb/core/ydb_convert + ydb/library/aclib + ydb/library/aclib/protos + ydb/library/login + ydb/library/login/protos + ydb/library/yql/minikql + ydb/services/bg_tasks +) + +YQL_LAST_ABI_VERSION() + +IF (OS_WINDOWS) + SRCS( + schemeshard_import_scheme_getter_fallback.cpp + ) +ELSE() + SRCS( + schemeshard_import_scheme_getter.cpp + ) +ENDIF() + +END() diff --git a/ydb/core/tx/sequenceproxy/public/ya.make b/ydb/core/tx/sequenceproxy/public/ya.make new file mode 100644 index 00000000000..4db3906beda --- /dev/null +++ b/ydb/core/tx/sequenceproxy/public/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + ydb/core/base + ydb/library/aclib + ydb/public/api/protos + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/sequenceproxy/ut/ya.make b/ydb/core/tx/sequenceproxy/ut/ya.make new file mode 100644 index 00000000000..89da6077e1e --- /dev/null +++ b/ydb/core/tx/sequenceproxy/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/core/tx/sequenceproxy) + +SRCS( + sequenceproxy_ut.cpp +) + +PEERDIR( + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/sequenceproxy/ya.make b/ydb/core/tx/sequenceproxy/ya.make new file mode 100644 index 00000000000..4b904b7427b --- /dev/null +++ b/ydb/core/tx/sequenceproxy/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/tx/scheme_cache + ydb/core/tx/sequenceproxy/public + ydb/core/tx/sequenceshard/public +) + +SRCS( + sequenceproxy.cpp + sequenceproxy_allocate.cpp + sequenceproxy_impl.cpp + sequenceproxy_resolve.cpp +) + +END() + +RECURSE( + public + ut +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/sequenceshard/public/ut/ya.make b/ydb/core/tx/sequenceshard/public/ut/ya.make new file mode 100644 index 00000000000..8028d035bff --- /dev/null +++ b/ydb/core/tx/sequenceshard/public/ut/ya.make @@ -0,0 +1,5 @@ +UNITTEST_FOR(ydb/core/tx/sequenceshard/public) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/sequenceshard/public/ya.make b/ydb/core/tx/sequenceshard/public/ya.make new file mode 100644 index 00000000000..6804f8d2c41 --- /dev/null +++ b/ydb/core/tx/sequenceshard/public/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + events.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/protos +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/sequenceshard/ut/ya.make b/ydb/core/tx/sequenceshard/ut/ya.make new file mode 100644 index 00000000000..eaae896b60e --- /dev/null +++ b/ydb/core/tx/sequenceshard/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(ydb/core/tx/sequenceshard) + +PEERDIR( + ydb/core/testlib/default +) + +SRCS( + ut_helpers.cpp + ut_sequenceshard.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/sequenceshard/ya.make b/ydb/core/tx/sequenceshard/ya.make new file mode 100644 index 00000000000..b47e4534140 --- /dev/null +++ b/ydb/core/tx/sequenceshard/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/engine/minikql + ydb/core/erasure + ydb/core/protos + ydb/core/tablet_flat + ydb/core/tx/sequenceshard/public +) + +SRCS( + schema.cpp + sequenceshard.cpp + sequenceshard_impl.cpp + tx_allocate_sequence.cpp + tx_create_sequence.cpp + tx_drop_sequence.cpp + tx_freeze_sequence.cpp + tx_init.cpp + tx_init_schema.cpp + tx_mark_schemeshard_pipe.cpp + tx_redirect_sequence.cpp + tx_restore_sequence.cpp + tx_update_sequence.cpp +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + public +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/sharding/ut/ya.make b/ydb/core/tx/sharding/ut/ya.make new file mode 100644 index 00000000000..7228ceabd87 --- /dev/null +++ b/ydb/core/tx/sharding/ut/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/tiering) + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/core/tx/sharding + ydb/public/lib/yson_value +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_sharding.cpp +) + +END() diff --git a/ydb/core/tx/sharding/ya.make b/ydb/core/tx/sharding/ya.make new file mode 100644 index 00000000000..48780f0ddb9 --- /dev/null +++ b/ydb/core/tx/sharding/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/utils + ydb/library/yql/public/udf + ydb/core/formats + ydb/core/protos +) + +YQL_LAST_ABI_VERSION() + +SRCS( + sharding.cpp + hash.cpp + xx_hash.cpp + unboxed_reader.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +)
\ No newline at end of file diff --git a/ydb/core/tx/tiering/rule/ya.make b/ydb/core/tx/tiering/rule/ya.make new file mode 100644 index 00000000000..70f2715e640 --- /dev/null +++ b/ydb/core/tx/tiering/rule/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + manager.cpp + object.cpp + GLOBAL behaviour.cpp + initializer.cpp + checker.cpp + ss_checker.cpp + GLOBAL ss_fetcher.cpp +) + +PEERDIR( + ydb/services/metadata/abstract + ydb/services/metadata/common + ydb/services/metadata/initializer + ydb/services/bg_tasks/abstract + ydb/core/tx/schemeshard +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/tiering/tier/ya.make b/ydb/core/tx/tiering/tier/ya.make new file mode 100644 index 00000000000..f319e8e28af --- /dev/null +++ b/ydb/core/tx/tiering/tier/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + manager.cpp + object.cpp + initializer.cpp + checker.cpp + GLOBAL behaviour.cpp +) + +PEERDIR( + ydb/services/metadata/initializer + ydb/services/metadata/abstract + ydb/services/metadata/secret + ydb/core/tx/schemeshard +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/tiering/ut/ya.make b/ydb/core/tx/tiering/ut/ya.make new file mode 100644 index 00000000000..47003ede985 --- /dev/null +++ b/ydb/core/tx/tiering/ut/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/tx/tiering) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/metadata + ydb/core/tx + ydb/core/tx/columnshard + ydb/public/lib/yson_value +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_tiers.cpp +) + +END() diff --git a/ydb/core/tx/tiering/ya.make b/ydb/core/tx/tiering/ya.make new file mode 100644 index 00000000000..cb3daf6f8e7 --- /dev/null +++ b/ydb/core/tx/tiering/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + +SRCS( + common.cpp + tier_cleaner.cpp + path_cleaner.cpp + GLOBAL cleaner_task.cpp + manager.cpp + GLOBAL external_data.cpp + snapshot.cpp +) + +IF (OS_WINDOWS) + CFLAGS( + -DKIKIMR_DISABLE_S3_OPS + ) +ELSE() + SRCS( + s3_actor.cpp + ) +ENDIF() + +PEERDIR( + library/cpp/actors/core + library/cpp/json/writer + ydb/core/blobstorage + ydb/core/protos + ydb/core/tx/tiering/rule + ydb/core/tx/tiering/tier + ydb/core/tablet_flat/protos + ydb/core/wrappers + ydb/public/api/protos + ydb/services/bg_tasks/abstract + ydb/services/metadata +) + +END() + +RECURSE_FOR_TESTS( + ut +)
\ No newline at end of file diff --git a/ydb/core/tx/time_cast/ut/ya.make b/ydb/core/tx/time_cast/ut/ya.make new file mode 100644 index 00000000000..1c12551e757 --- /dev/null +++ b/ydb/core/tx/time_cast/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/tx/time_cast) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/core/testlib/default + ydb/core/tx +) + +YQL_LAST_ABI_VERSION() + +SRCS( + time_cast_ut.cpp +) + +END() diff --git a/ydb/core/tx/time_cast/ya.make b/ydb/core/tx/time_cast/ya.make new file mode 100644 index 00000000000..7d2cde83865 --- /dev/null +++ b/ydb/core/tx/time_cast/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + time_cast.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/core/tablet + ydb/core/tx +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/tx_allocator/ut/ya.make b/ydb/core/tx/tx_allocator/ut/ya.make new file mode 100644 index 00000000000..8218702a409 --- /dev/null +++ b/ydb/core/tx/tx_allocator/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/tx/tx_allocator) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/mind + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/tx_allocator +) + +YQL_LAST_ABI_VERSION() + +SRCS( + txallocator_ut.cpp + txallocator_ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/tx_allocator/ya.make b/ydb/core/tx/tx_allocator/ya.make new file mode 100644 index 00000000000..fc3754e90cb --- /dev/null +++ b/ydb/core/tx/tx_allocator/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + txallocator__reserve.cpp + txallocator__scheme.cpp + txallocator_impl.cpp + txallocator.cpp +) + +PEERDIR( + library/cpp/actors/helpers + library/cpp/actors/interconnect + ydb/core/actorlib_impl + ydb/core/base + ydb/core/engine/minikql + ydb/core/protos + ydb/core/tablet + ydb/core/tablet_flat +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/tx_allocator_client/ut/ya.make b/ydb/core/tx/tx_allocator_client/ut/ya.make new file mode 100644 index 00000000000..d4072368278 --- /dev/null +++ b/ydb/core/tx/tx_allocator_client/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/core/tx/tx_allocator_client) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/mind + ydb/core/testlib/default + ydb/core/tx + ydb/core/tx/tx_allocator_client +) + +YQL_LAST_ABI_VERSION() + +SRCS( + actor_client_ut.cpp + ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/tx_allocator_client/ya.make b/ydb/core/tx/tx_allocator_client/ya.make new file mode 100644 index 00000000000..91697c49d95 --- /dev/null +++ b/ydb/core/tx/tx_allocator_client/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/core/protos + ydb/core/tablet + ydb/core/tx/tx_allocator +) + +SRCS( + actor_client.cpp + client.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/tx/tx_proxy/ut_base_tenant/ya.make b/ydb/core/tx/tx_proxy/ut_base_tenant/ya.make new file mode 100644 index 00000000000..c7c3cbe45cf --- /dev/null +++ b/ydb/core/tx/tx_proxy/ut_base_tenant/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/core/tx/tx_proxy) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/testing/unittest + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + proxy_ut.cpp + proxy_ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/tx_proxy/ut_encrypted_storage/ya.make b/ydb/core/tx/tx_proxy/ut_encrypted_storage/ya.make new file mode 100644 index 00000000000..4003bfb1b52 --- /dev/null +++ b/ydb/core/tx/tx_proxy/ut_encrypted_storage/ya.make @@ -0,0 +1,39 @@ +UNITTEST_FOR(ydb/core/tx/tx_proxy) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/testing/unittest + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + encrypted_storage_ut.cpp + proxy_ut_helpers.h + proxy_ut_helpers.cpp +) + +END() diff --git a/ydb/core/tx/tx_proxy/ut_ext_tenant/ya.make b/ydb/core/tx/tx_proxy/ut_ext_tenant/ya.make new file mode 100644 index 00000000000..adfe92847eb --- /dev/null +++ b/ydb/core/tx/tx_proxy/ut_ext_tenant/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/core/tx/tx_proxy) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/testing/unittest + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + proxy_ext_tenant_ut.cpp + proxy_ut_helpers.cpp +) + +REQUIREMENTS(ram:17) + +END() diff --git a/ydb/core/tx/tx_proxy/ut_storage_tenant/ya.make b/ydb/core/tx/tx_proxy/ut_storage_tenant/ya.make new file mode 100644 index 00000000000..3f96dc3f95a --- /dev/null +++ b/ydb/core/tx/tx_proxy/ut_storage_tenant/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/core/tx/tx_proxy) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/testing/unittest + ydb/core/blobstorage + ydb/core/testlib/default + ydb/core/tx + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + storage_tenant_ut.cpp + proxy_ut_helpers.h + proxy_ut_helpers.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/tx_proxy/ya.make b/ydb/core/tx/tx_proxy/ya.make new file mode 100644 index 00000000000..1f1fede7735 --- /dev/null +++ b/ydb/core/tx/tx_proxy/ya.make @@ -0,0 +1,59 @@ +LIBRARY() + +SRCS( + mon.cpp + proxy_impl.cpp + schemereq.cpp + datareq.cpp + describe.cpp + proxy.cpp + read_table_impl.cpp + resolvereq.cpp + snapshotreq.cpp + commitreq.cpp + upload_rows_common_impl.cpp + upload_rows.cpp +) + +GENERATE_ENUM_SERIALIZATION(read_table_impl.h) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/helpers + library/cpp/actors/interconnect + util/draft + ydb/core/actorlib_impl + ydb/core/base + ydb/core/blobstorage/base + ydb/core/docapi + ydb/core/engine + ydb/core/formats + ydb/core/grpc_services + ydb/core/io_formats + ydb/core/protos + ydb/core/scheme + ydb/core/sys_view/common + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/tx + ydb/core/tx/balance_coverage + ydb/core/tx/datashard + ydb/core/tx/scheme_cache + ydb/core/tx/schemeshard + ydb/core/tx/tx_allocator + ydb/core/tx/tx_allocator_client + ydb/library/aclib + ydb/library/mkql_proto/protos + ydb/public/lib/base +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut_base_tenant + ut_encrypted_storage + ut_ext_tenant + ut_storage_tenant +) diff --git a/ydb/core/tx/ya.make b/ydb/core/tx/ya.make new file mode 100644 index 00000000000..d0674c7943c --- /dev/null +++ b/ydb/core/tx/ya.make @@ -0,0 +1,44 @@ +LIBRARY() + +SRCS( + defs.h + message_seqno.h + tx.h + tx.cpp + tx_processing.h + tx_proxy_schemereq.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/persqueue/config + ydb/core/protos + ydb/core/tablet + ydb/core/tablet_flat + ydb/core/util + ydb/library/aclib +) + +END() + +RECURSE( + balance_coverage + columnshard + coordinator + datashard + long_tx_service + mediator + replication + scheme_board + scheme_cache + schemeshard + sequenceproxy + sequenceshard + time_cast + tx_allocator + tx_allocator_client + tx_proxy + tiering + sharding +) diff --git a/ydb/core/util/btree_benchmark/ya.make b/ydb/core/util/btree_benchmark/ya.make new file mode 100644 index 00000000000..4394ae7d7be --- /dev/null +++ b/ydb/core/util/btree_benchmark/ya.make @@ -0,0 +1,14 @@ +Y_BENCHMARK() + +ALLOCATOR(LF) + +PEERDIR( + library/cpp/threading/skip_list + ydb/core/util +) + +SRCS( + main.cpp +) + +END() diff --git a/ydb/core/util/ut/ya.make b/ydb/core/util/ut/ya.make new file mode 100644 index 00000000000..d4982c7bb6a --- /dev/null +++ b/ydb/core/util/ut/ya.make @@ -0,0 +1,52 @@ +UNITTEST_FOR(ydb/core/util) + +FORK_SUBTESTS() +IF (WITH_VALGRIND) + SPLIT_FACTOR(30) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/threading/future +) + +SRCS( + address_classifier_ut.cpp + bits_ut.cpp + btree_cow_ut.cpp + btree_ut.cpp + cache_ut.cpp + circular_queue_ut.cpp + concurrent_rw_hash_ut.cpp + fast_tls_ut.cpp + fragmented_buffer_ut.cpp + hazard_ut.cpp + hyperlog_counter_ut.cpp + interval_set_ut.cpp + intrusive_fixed_hash_set_ut.cpp + intrusive_heap_ut.cpp + intrusive_stack_ut.cpp + lf_stack_ut.cpp + log_priority_mute_checker_ut.cpp + lz4_data_generator_ut.cpp + operation_queue_ut.cpp + operation_queue_priority_ut.cpp + page_map_ut.cpp + queue_inplace_ut.cpp + queue_oneone_inplace_ut.cpp + simple_cache_ut.cpp + stlog_ut.cpp + time_series_vec_ut.cpp + token_bucket_ut.cpp + ulid_ut.cpp + wildcard_ut.cpp +) + +END() diff --git a/ydb/core/util/ya.make b/ydb/core/util/ya.make new file mode 100644 index 00000000000..aa26a5ddcef --- /dev/null +++ b/ydb/core/util/ya.make @@ -0,0 +1,81 @@ +LIBRARY() + +SRCS( + address_classifier.cpp + cache.cpp + cache.h + cache_cache.h + circular_queue.h + concurrent_rw_hash.cpp + concurrent_rw_hash.h + console.cpp + console.h + counted_leaky_bucket.h + defs.h + failure_injection.cpp + failure_injection.h + fast_tls.cpp + format.cpp + format.h + fragmented_buffer.cpp + fragmented_buffer.h + hazard.cpp + hyperlog_counter.cpp + hyperlog_counter.h + interval_set.h + intrusive_fixed_hash_set.h + intrusive_heap.cpp + intrusive_heap.h + intrusive_stack.h + log_priority_mute_checker.h + memory_tracker.cpp + memory_tracker.h + operation_queue.h + page_map.cpp + pb.h + proto_duration.h + queue_inplace.h + queue_oneone_inplace.h + simple_cache.h + single_thread_ic_mock.cpp + single_thread_ic_mock.h + stlog.cpp + stlog.h + templates.h + testactorsys.cpp + testactorsys.h + text.cpp + text.h + time_series_vec.h + token_bucket.h + throughput_meter.h + tuples.h + type_alias.h + ulid.cpp + ulid.h + wildcard.h + yverify_stream.h +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect/mock + library/cpp/actors/util + library/cpp/containers/stack_vector + library/cpp/html/escape + library/cpp/ipmath + library/cpp/json + library/cpp/lwtrace + library/cpp/monlib/dynamic_counters + library/cpp/random_provider + ydb/core/base + ydb/core/protos + library/cpp/deprecated/atomic +) + +END() + +RECURSE_FOR_TESTS( + btree_benchmark + ut +) diff --git a/ydb/core/viewer/json/ut/ya.make b/ydb/core/viewer/json/ut/ya.make new file mode 100644 index 00000000000..450ce3a660c --- /dev/null +++ b/ydb/core/viewer/json/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(ydb/core/viewer/json) + +PEERDIR( + ydb/core/viewer/protos +) + +SRCS( + json_ut.cpp +) + +END() diff --git a/ydb/core/viewer/json/ya.make b/ydb/core/viewer/json/ya.make new file mode 100644 index 00000000000..163d0e15cf8 --- /dev/null +++ b/ydb/core/viewer/json/ya.make @@ -0,0 +1,18 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +SRCS( + json.cpp + json.h +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/string_utils/base64 + ydb/core/viewer/protos +) + +END() diff --git a/ydb/core/viewer/protos/ya.make b/ydb/core/viewer/protos/ya.make new file mode 100644 index 00000000000..0bb08d57334 --- /dev/null +++ b/ydb/core/viewer/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +SRCS( + viewer.proto +) + +PEERDIR( + ydb/core/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/viewer/ut/ya.make b/ydb/core/viewer/ut/ya.make new file mode 100644 index 00000000000..305ff23d21c --- /dev/null +++ b/ydb/core/viewer/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(ydb/core/viewer) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +YQL_LAST_ABI_VERSION() + +SRCS( + viewer_ut.cpp +) + +PEERDIR( + ydb/core/testlib/default +) + +END() diff --git a/ydb/core/viewer/ya.make b/ydb/core/viewer/ya.make new file mode 100644 index 00000000000..fdb89f9cbf4 --- /dev/null +++ b/ydb/core/viewer/ya.make @@ -0,0 +1,282 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +SRCS( + browse_db.h + browse_pq.h + browse.h + counters_hosts.h + json_acl.h + json_blobindexstat.h + json_browse.h + json_bscontrollerinfo.h + json_bsgroupinfo.h + json_cluster.h + json_compute.h + json_config.h + json_content.h + json_counters.h + json_describe.h + json_local_rpc.h + json_getblob.h + json_handlers_vdisk.cpp + json_handlers_viewer.cpp + json_healthcheck.h + json_hiveinfo.h + json_hotkeys.h + json_labeledcounters.h + json_metainfo.h + json_netinfo.h + json_nodeinfo.h + json_nodelist.h + json_nodes.h + json_pdiskinfo.h + json_query.h + json_storage.h + json_sysinfo.h + json_tabletcounters.h + json_tabletinfo.h + json_tenants.h + json_tenantinfo.h + json_topicinfo.h + json_pqconsumerinfo.h + json_vdisk_req.h + json_vdiskinfo.h + json_vdiskstat.h + json_wb_req.h + json_whoami.h + log.h + viewer_request.cpp + viewer_request.h + viewer.cpp + viewer.h + wb_aggregate.cpp + wb_aggregate.h + wb_filter.cpp + wb_filter.h + wb_group.h + wb_merge.cpp + wb_merge.h +) + +IF (NOT EXPORT_CMAKE) + RESOURCE( + monitoring/index.html monitoring/index.html + monitoring/static/css/main.ff5b549d.css monitoring/static/css/main.ff5b549d.css + monitoring/static/favicon.png monitoring/static/favicon.png + monitoring/static/js/1058.3df06184.chunk.js monitoring/static/js/1058.3df06184.chunk.js + monitoring/static/js/1115.1e053b1d.chunk.js monitoring/static/js/1115.1e053b1d.chunk.js + monitoring/static/js/1234.165715d4.chunk.js monitoring/static/js/1234.165715d4.chunk.js + monitoring/static/js/1474.80932b06.chunk.js monitoring/static/js/1474.80932b06.chunk.js + monitoring/static/js/1522.5645047d.chunk.js monitoring/static/js/1522.5645047d.chunk.js + monitoring/static/js/1602.86ed3169.chunk.js monitoring/static/js/1602.86ed3169.chunk.js + monitoring/static/js/1898.a0e4bd43.chunk.js monitoring/static/js/1898.a0e4bd43.chunk.js + monitoring/static/js/2056.b607e590.chunk.js monitoring/static/js/2056.b607e590.chunk.js + monitoring/static/js/2081.bd41025d.chunk.js monitoring/static/js/2081.bd41025d.chunk.js + monitoring/static/js/2119.9f7a5c06.chunk.js monitoring/static/js/2119.9f7a5c06.chunk.js + monitoring/static/js/2174.264d1736.chunk.js monitoring/static/js/2174.264d1736.chunk.js + monitoring/static/js/2205.e7f0b9ab.chunk.js monitoring/static/js/2205.e7f0b9ab.chunk.js + monitoring/static/js/2291.d410fd68.chunk.js monitoring/static/js/2291.d410fd68.chunk.js + monitoring/static/js/2406.180cb966.chunk.js monitoring/static/js/2406.180cb966.chunk.js + monitoring/static/js/245.6db2db52.chunk.js monitoring/static/js/245.6db2db52.chunk.js + monitoring/static/js/248.736ab237.chunk.js monitoring/static/js/248.736ab237.chunk.js + monitoring/static/js/2507.2d9c4b5c.chunk.js monitoring/static/js/2507.2d9c4b5c.chunk.js + monitoring/static/js/254.a91c0bf4.chunk.js monitoring/static/js/254.a91c0bf4.chunk.js + monitoring/static/js/2799.64ec0194.chunk.js monitoring/static/js/2799.64ec0194.chunk.js + monitoring/static/js/2862.29a56bf7.chunk.js monitoring/static/js/2862.29a56bf7.chunk.js + monitoring/static/js/2991.0db887ba.chunk.js monitoring/static/js/2991.0db887ba.chunk.js + monitoring/static/js/3001.b1a75b50.chunk.js monitoring/static/js/3001.b1a75b50.chunk.js + monitoring/static/js/3191.c6dbae35.chunk.js monitoring/static/js/3191.c6dbae35.chunk.js + monitoring/static/js/3254.78ce4d35.chunk.js monitoring/static/js/3254.78ce4d35.chunk.js + monitoring/static/js/3258.248867bd.chunk.js monitoring/static/js/3258.248867bd.chunk.js + monitoring/static/js/3451.774580b7.chunk.js monitoring/static/js/3451.774580b7.chunk.js + monitoring/static/js/371.93a1186d.chunk.js monitoring/static/js/371.93a1186d.chunk.js + monitoring/static/js/3771.0e0bb0f3.chunk.js monitoring/static/js/3771.0e0bb0f3.chunk.js + monitoring/static/js/3883.62a3dee4.chunk.js monitoring/static/js/3883.62a3dee4.chunk.js + monitoring/static/js/4529.eb0068c3.chunk.js monitoring/static/js/4529.eb0068c3.chunk.js + monitoring/static/js/4546.6820709e.chunk.js monitoring/static/js/4546.6820709e.chunk.js + monitoring/static/js/4663.cc239299.chunk.js monitoring/static/js/4663.cc239299.chunk.js + monitoring/static/js/4712.4e557974.chunk.js monitoring/static/js/4712.4e557974.chunk.js + monitoring/static/js/4731.6929d6df.chunk.js monitoring/static/js/4731.6929d6df.chunk.js + monitoring/static/js/4952.58b99bba.chunk.js monitoring/static/js/4952.58b99bba.chunk.js + monitoring/static/js/5012.3afcd232.chunk.js monitoring/static/js/5012.3afcd232.chunk.js + monitoring/static/js/5210.6e07cb51.chunk.js monitoring/static/js/5210.6e07cb51.chunk.js + monitoring/static/js/5215.2d9f2122.chunk.js monitoring/static/js/5215.2d9f2122.chunk.js + monitoring/static/js/5444.f86e47ff.chunk.js monitoring/static/js/5444.f86e47ff.chunk.js + monitoring/static/js/5517.a1034916.chunk.js monitoring/static/js/5517.a1034916.chunk.js + monitoring/static/js/5646.ced0e1ae.chunk.js monitoring/static/js/5646.ced0e1ae.chunk.js + monitoring/static/js/5695.d81b70ca.chunk.js monitoring/static/js/5695.d81b70ca.chunk.js + monitoring/static/js/569.abbf95fd.chunk.js monitoring/static/js/569.abbf95fd.chunk.js + monitoring/static/js/5748.fa2a8e02.chunk.js monitoring/static/js/5748.fa2a8e02.chunk.js + monitoring/static/js/5784.26f46213.chunk.js monitoring/static/js/5784.26f46213.chunk.js + monitoring/static/js/5885.c5ee8345.chunk.js monitoring/static/js/5885.c5ee8345.chunk.js + monitoring/static/js/6060.eb821066.chunk.js monitoring/static/js/6060.eb821066.chunk.js + monitoring/static/js/6135.e49ec940.chunk.js monitoring/static/js/6135.e49ec940.chunk.js + monitoring/static/js/6266.db91261c.chunk.js monitoring/static/js/6266.db91261c.chunk.js + monitoring/static/js/6550.b5e85913.chunk.js monitoring/static/js/6550.b5e85913.chunk.js + monitoring/static/js/6559.41bbd3a3.chunk.js monitoring/static/js/6559.41bbd3a3.chunk.js + monitoring/static/js/6708.5cf2a45c.chunk.js monitoring/static/js/6708.5cf2a45c.chunk.js + monitoring/static/js/6892.3db15360.chunk.js monitoring/static/js/6892.3db15360.chunk.js + monitoring/static/js/698.746436d5.chunk.js monitoring/static/js/698.746436d5.chunk.js + monitoring/static/js/7168.ed7798a9.chunk.js monitoring/static/js/7168.ed7798a9.chunk.js + monitoring/static/js/7478.0bf003df.chunk.js monitoring/static/js/7478.0bf003df.chunk.js + monitoring/static/js/7548.8ef3bbc0.chunk.js monitoring/static/js/7548.8ef3bbc0.chunk.js + monitoring/static/js/758.2eb69c4e.chunk.js monitoring/static/js/758.2eb69c4e.chunk.js + monitoring/static/js/7661.dd104c3c.chunk.js monitoring/static/js/7661.dd104c3c.chunk.js + monitoring/static/js/7664.9f9f696d.chunk.js monitoring/static/js/7664.9f9f696d.chunk.js + monitoring/static/js/7768.2adb4751.chunk.js monitoring/static/js/7768.2adb4751.chunk.js + monitoring/static/js/7953.eb2256ce.chunk.js monitoring/static/js/7953.eb2256ce.chunk.js + monitoring/static/js/8005.9c209154.chunk.js monitoring/static/js/8005.9c209154.chunk.js + monitoring/static/js/805.d67f39bf.chunk.js monitoring/static/js/805.d67f39bf.chunk.js + monitoring/static/js/8206.d2f5a912.chunk.js monitoring/static/js/8206.d2f5a912.chunk.js + monitoring/static/js/8322.c2b160c6.chunk.js monitoring/static/js/8322.c2b160c6.chunk.js + monitoring/static/js/8335.9ed734ba.chunk.js monitoring/static/js/8335.9ed734ba.chunk.js + monitoring/static/js/842.bd21ee9f.chunk.js monitoring/static/js/842.bd21ee9f.chunk.js + monitoring/static/js/8520.616efa9f.chunk.js monitoring/static/js/8520.616efa9f.chunk.js + monitoring/static/js/8558.47b3557b.chunk.js monitoring/static/js/8558.47b3557b.chunk.js + monitoring/static/js/8590.b8446f1d.chunk.js monitoring/static/js/8590.b8446f1d.chunk.js + monitoring/static/js/8794.5ad5fb7d.chunk.js monitoring/static/js/8794.5ad5fb7d.chunk.js + monitoring/static/js/9005.053ddf1a.chunk.js monitoring/static/js/9005.053ddf1a.chunk.js + monitoring/static/js/9011.f3cf1dfe.chunk.js monitoring/static/js/9011.f3cf1dfe.chunk.js + monitoring/static/js/9163.de992e19.chunk.js monitoring/static/js/9163.de992e19.chunk.js + monitoring/static/js/9292.3ccb6509.chunk.js monitoring/static/js/9292.3ccb6509.chunk.js + monitoring/static/js/939.4c5d6b68.chunk.js monitoring/static/js/939.4c5d6b68.chunk.js + monitoring/static/js/9803.e1567af5.chunk.js monitoring/static/js/9803.e1567af5.chunk.js + monitoring/static/js/983.18afe3d6.chunk.js monitoring/static/js/983.18afe3d6.chunk.js + monitoring/static/js/main.8120faa2.js monitoring/static/js/main.8120faa2.js + monitoring/static/media/403.271ae19f0d1101a2c67a904146bbd4d3.svg monitoring/static/media/403.271ae19f0d1101a2c67a904146bbd4d3.svg + monitoring/static/media/403.6367e52f9464706633f52a2488a41958.svg monitoring/static/media/403.6367e52f9464706633f52a2488a41958.svg + monitoring/static/media/codicon.80a4c25b73c1f97077ed.ttf monitoring/static/media/codicon.80a4c25b73c1f97077ed.ttf + monitoring/static/media/thumbsUp.d4a03fbaa64ce85a0045bf8ba77f8e2b.svg monitoring/static/media/thumbsUp.d4a03fbaa64ce85a0045bf8ba77f8e2b.svg + ) +ENDIF() + +RESOURCE( + content/index.html viewer/index.html + content/viewer.js viewer/viewer.js + content/jstree.min.js viewer/jstree.min.js + content/style.min.css viewer/style.min.css + content/throbber.gif viewer/throbber.gif + content/32px.png viewer/32px.png + content/40px.png viewer/40px.png + content/v2/cpu viewer/v2/cpu + content/v2/cpu_view.js viewer/v2/cpu_view.js + content/v2/disk_cell.js viewer/v2/disk_cell.js + content/v2/disk_map.js viewer/v2/disk_map.js + content/v2/index.html viewer/v2/index.html + content/v2/man-green.png viewer/v2/man-green.png + content/v2/man-orange.png viewer/v2/man-orange.png + content/v2/man-red.png viewer/v2/man-red.png + content/v2/man-yellow.png viewer/v2/man-yellow.png + content/v2/net_view.js viewer/v2/net_view.js + content/v2/network viewer/v2/network + content/v2/node_group.js viewer/v2/node_group.js + content/v2/node.js viewer/v2/node.js + content/v2/node_map.js viewer/v2/node_map.js + content/v2/nodes viewer/v2/nodes + content/v2/node_view.js viewer/v2/node_view.js + content/v2/overview viewer/v2/overview + content/v2/overview.js viewer/v2/overview.js + content/v2/pdisk.js viewer/v2/pdisk.js + content/v2/pool_block.js viewer/v2/pool_block.js + content/v2/pool_map.js viewer/v2/pool_map.js + content/v2/runner.html viewer/v2/runner.html + content/v2/stats.js viewer/v2/stats.js + content/v2/storage viewer/v2/storage + content/v2/storage_group.js viewer/v2/storage_group.js + content/v2/storage.js viewer/v2/storage.js + content/v2/storage_view.js viewer/v2/storage_view.js + content/v2/tablet_cell.js viewer/v2/tablet_cell.js + content/v2/tablet_map.js viewer/v2/tablet_map.js + content/v2/tenant.js viewer/v2/tenant.js + content/v2/tenants viewer/v2/tenants + content/v2/tenant_view.js viewer/v2/tenant_view.js + content/v2/throbber.gif viewer/v2/throbber.gif + content/v2/util.js viewer/v2/util.js + content/v2/vdisk.js viewer/v2/vdisk.js + content/v2/viewer.css viewer/v2/viewer.css + content/v2/viewer.js viewer/v2/viewer.js + content/api/css/print.css viewer/api/css/print.css + content/api/css/reset.css viewer/api/css/reset.css + content/api/css/screen.css viewer/api/css/screen.css + content/api/css/style.css viewer/api/css/style.css + content/api/css/typography.css viewer/api/css/typography.css + content/api/fonts/DroidSans-Bold.ttf viewer/api/fonts/DroidSans-Bold.ttf + content/api/fonts/DroidSans.ttf viewer/api/fonts/DroidSans.ttf + content/api/images/collapse.gif viewer/api/images/collapse.gif + content/api/images/expand.gif viewer/api/images/expand.gif + content/api/images/explorer_icons.png viewer/api/images/explorer_icons.png + content/api/images/favicon-16x16.png viewer/api/images/favicon-16x16.png + content/api/images/favicon-32x32.png viewer/api/images/favicon-32x32.png + content/api/images/favicon.ico viewer/api/images/favicon.ico + content/api/images/logo_small.png viewer/api/images/logo_small.png + content/api/images/throbber.gif viewer/api/images/throbber.gif + content/api/index.html viewer/api/index.html + content/api/lang/ca.js viewer/api/lang/ca.js + content/api/lang/en.js viewer/api/lang/en.js + content/api/lang/es.js viewer/api/lang/es.js + content/api/lang/fr.js viewer/api/lang/fr.js + content/api/lang/geo.js viewer/api/lang/geo.js + content/api/lang/it.js viewer/api/lang/it.js + content/api/lang/ja.js viewer/api/lang/ja.js + content/api/lang/ko-kr.js viewer/api/lang/ko-kr.js + content/api/lang/pl.js viewer/api/lang/pl.js + content/api/lang/pt.js viewer/api/lang/pt.js + content/api/lang/ru.js viewer/api/lang/ru.js + content/api/lang/tr.js viewer/api/lang/tr.js + content/api/lang/translator.js viewer/api/lang/translator.js + content/api/lang/zh-cn.js viewer/api/lang/zh-cn.js + content/api/lib/backbone-min.js viewer/api/lib/backbone-min.js + content/api/lib/es5-shim.js viewer/api/lib/es5-shim.js + content/api/lib/handlebars-4.0.5.js viewer/api/lib/handlebars-4.0.5.js + content/api/lib/highlight.9.1.0.pack.js viewer/api/lib/highlight.9.1.0.pack.js + content/api/lib/highlight.9.1.0.pack_extended.js viewer/api/lib/highlight.9.1.0.pack_extended.js + content/api/lib/jquery-1.8.0.min.js viewer/api/lib/jquery-1.8.0.min.js + content/api/lib/jquery.ba-bbq.min.js viewer/api/lib/jquery.ba-bbq.min.js + content/api/lib/jquery.slideto.min.js viewer/api/lib/jquery.slideto.min.js + content/api/lib/jquery.wiggle.min.js viewer/api/lib/jquery.wiggle.min.js + content/api/lib/js-yaml.min.js viewer/api/lib/js-yaml.min.js + content/api/lib/jsoneditor.min.js viewer/api/lib/jsoneditor.min.js + content/api/lib/lodash.min.js viewer/api/lib/lodash.min.js + content/api/lib/marked.js viewer/api/lib/marked.js + content/api/lib/object-assign-pollyfill.js viewer/api/lib/object-assign-pollyfill.js + content/api/lib/sanitize-html.min.js viewer/api/lib/sanitize-html.min.js + content/api/lib/swagger-oauth.js viewer/api/lib/swagger-oauth.js + content/api/swagger-ui.min.js viewer/api/swagger-ui.min.js +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/helpers + library/cpp/archive + library/cpp/mime/types + library/cpp/protobuf/json + ydb/core/base + ydb/core/blobstorage/base + ydb/core/blobstorage/vdisk/common + ydb/core/client/server + ydb/core/grpc_services + ydb/core/grpc_services/local_rpc + ydb/core/health_check + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/scheme + ydb/core/tx/schemeshard + ydb/core/tx/tx_proxy + ydb/core/util + ydb/core/viewer/json + ydb/core/viewer/protos + ydb/library/persqueue/topic_parser + ydb/public/api/protos + ydb/public/lib/deprecated/kicli + ydb/public/lib/json_value + ydb/public/api/grpc + ydb/public/sdk/cpp/client/ydb_types +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/wrappers/events/ya.make b/ydb/core/wrappers/events/ya.make new file mode 100644 index 00000000000..c60d9c08ad2 --- /dev/null +++ b/ydb/core/wrappers/events/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +IF (OS_WINDOWS) + CFLAGS( + -DKIKIMR_DISABLE_S3_WRAPPER + ) +ELSE() + SRCS( + common.cpp + list_objects.cpp + object_exists.cpp + delete_objects.cpp + s3_out.cpp + abstract.cpp + ) + PEERDIR( + contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3 + contrib/libs/curl + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/core/wrappers/ut_helpers + ) +ENDIF() + +END() diff --git a/ydb/core/wrappers/ut/ya.make b/ydb/core/wrappers/ut/ya.make new file mode 100644 index 00000000000..2ff41232294 --- /dev/null +++ b/ydb/core/wrappers/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/core/wrappers) + +FORK_SUBTESTS() + +IF (NOT OS_WINDOWS) + PEERDIR( + library/cpp/actors/core + library/cpp/digest/md5 + library/cpp/testing/unittest + ydb/core/protos + ydb/core/testlib/basics/default + ydb/core/wrappers/ut_helpers + ) + SRCS( + s3_wrapper_ut.cpp + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:12) + +END() diff --git a/ydb/core/wrappers/ut_helpers/ya.make b/ydb/core/wrappers/ut_helpers/ya.make new file mode 100644 index 00000000000..e2187ac651e --- /dev/null +++ b/ydb/core/wrappers/ut_helpers/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +PEERDIR( + library/cpp/digest/md5 + library/cpp/http/server + library/cpp/xml/document + library/cpp/cgiparam +) + +SRCS( + s3_mock.cpp +) + +END() diff --git a/ydb/core/wrappers/ya.make b/ydb/core/wrappers/ya.make new file mode 100644 index 00000000000..8f03f8a450a --- /dev/null +++ b/ydb/core/wrappers/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +IF (OS_WINDOWS) + CFLAGS( + -DKIKIMR_DISABLE_S3_WRAPPER + ) +ELSE() + SRCS( + s3_wrapper.cpp + s3_storage.cpp + s3_storage_config.cpp + abstract.cpp + fake_storage.cpp + fake_storage_config.cpp + ) + PEERDIR( + contrib/libs/aws-sdk-cpp/aws-cpp-sdk-s3 + contrib/libs/curl + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/core/wrappers/ut_helpers + ydb/core/wrappers/events + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut + ut_helpers +) diff --git a/ydb/core/ya.make b/ydb/core/ya.make new file mode 100644 index 00000000000..4547bd33086 --- /dev/null +++ b/ydb/core/ya.make @@ -0,0 +1,63 @@ +RECURSE( + actorlib_impl + base + blobstorage + blob_depot + blockstore + client + cms + control + debug + debug_tools + discovery + docapi + engine + erasure + external_sources + filestore + fq + formats + grpc_caching + grpc_services + grpc_streaming + health_check + http_proxy + io_formats + kafkaproxy + kesus + keyvalue + kqp + load_test + local_pgwire + log_backend + metering + mind + mon + mon_alloc + node_whiteboard + persqueue + pgproxy + protos + public_http + quoter + scheme + scheme_types + security + sys_view + tablet + tablet_flat + test_tablet + tracing + tx + util + viewer + wrappers + ydb_convert + ymq + driver_lib + yql_testlib +) + +RECURSE_FOR_TESTS( + testlib +) diff --git a/ydb/core/ydb_convert/ut/ya.make b/ydb/core/ydb_convert/ut/ya.make new file mode 100644 index 00000000000..766bc2ad443 --- /dev/null +++ b/ydb/core/ydb_convert/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/core/ydb_convert) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + compression_ut.cpp + table_description_ut.cpp + ydb_convert_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest + ydb/core/testlib/default +) + +END() diff --git a/ydb/core/ydb_convert/ya.make b/ydb/core/ydb_convert/ya.make new file mode 100644 index 00000000000..cf06ad50d3f --- /dev/null +++ b/ydb/core/ydb_convert/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +SRCS( + column_families.cpp + compression.cpp + table_settings.cpp + table_description.cpp + table_profiles.cpp + ydb_convert.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/engine + ydb/core/protos + ydb/core/scheme + ydb/core/util + ydb/library/binary_json + ydb/library/dynumber + ydb/library/mkql_proto/protos + ydb/library/yql/minikql/dom + ydb/library/yql/public/udf + ydb/public/api/protos +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/ymq/actor/ut/ya.make b/ydb/core/ymq/actor/ut/ya.make new file mode 100644 index 00000000000..1650f3ceb18 --- /dev/null +++ b/ydb/core/ymq/actor/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST() + +PEERDIR( + contrib/libs/yaml-cpp + ydb/core/mind/address_classification + ydb/core/testlib/default + ydb/core/ymq/actor + ydb/core/ymq/base + ydb/core/ymq/http +) + +SRCS( + attributes_md5_ut.cpp + infly_ut.cpp + message_delay_stats_ut.cpp + sha256_ut.cpp + metering_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/ymq/actor/ya.make b/ydb/core/ymq/actor/ya.make new file mode 100644 index 00000000000..de0df329366 --- /dev/null +++ b/ydb/core/ymq/actor/ya.make @@ -0,0 +1,108 @@ +LIBRARY() + +SRCS( + actor.cpp + auth_factory.cpp + attributes_md5.cpp + cfg.cpp + change_visibility.cpp + count_queues.cpp + cleanup_queue_data.cpp + create_queue.cpp + create_user.cpp + delete_message.cpp + delete_queue.cpp + delete_user.cpp + error.cpp + executor.cpp + fifo_cleanup.cpp + garbage_collector.cpp + get_queue_attributes.cpp + get_queue_url.cpp + index_events_processor.cpp + infly.cpp + log.cpp + list_dead_letter_source_queues.cpp + list_permissions.cpp + list_queues.cpp + list_users.cpp + local_rate_limiter_allocator.cpp + message_delay_stats.cpp + metering.cpp + modify_permissions.cpp + monitoring.cpp + node_tracker.cpp + proxy_actor.cpp + purge.cpp + purge_queue.cpp + queue_leader.cpp + receive_message.cpp + retention.cpp + schema.cpp + sha256.cpp + send_message.cpp + service.cpp + set_queue_attributes.cpp + proxy_service.cpp + queues_list_reader.cpp + queue_schema.cpp + user_settings_names.cpp + user_settings_reader.cpp +) + +PEERDIR( + contrib/libs/openssl + contrib/libs/protobuf + library/cpp/actors/core + library/cpp/containers/intrusive_rb_tree + library/cpp/digest/md5 + library/cpp/grpc/client + library/cpp/logger + library/cpp/lwtrace/mon + library/cpp/monlib/dynamic_counters + library/cpp/monlib/service/pages + library/cpp/scheme + ydb/core/base + ydb/core/client/minikql_compile + ydb/core/engine + ydb/core/kesus/tablet + ydb/core/mind/address_classification + ydb/core/mon + ydb/core/node_whiteboard + ydb/core/protos + ydb/core/tx/scheme_cache + ydb/core/tx/schemeshard + ydb/core/tx/tx_proxy + ydb/core/util + ydb/core/ymq/base + ydb/core/ymq/proto + ydb/core/ymq/queues/common + ydb/core/ymq/queues/fifo + ydb/core/ymq/queues/std + ydb/library/aclib + ydb/library/http_proxy/authorization + ydb/library/http_proxy/error + ydb/library/mkql_proto/protos + ydb/public/lib/scheme_types + ydb/public/lib/value + ydb/public/sdk/cpp/client/ydb_types/credentials + ydb/library/yql/minikql + ydb/public/lib/deprecated/client +) + +YQL_LAST_ABI_VERSION() + +GENERATE_ENUM_SERIALIZATION(events.h) + +GENERATE_ENUM_SERIALIZATION(metering.h) + +GENERATE_ENUM_SERIALIZATION(fifo_cleanup.h) + +GENERATE_ENUM_SERIALIZATION(queue_schema.h) + +END() + +RECURSE_FOR_TESTS( + ut + yc_search_ut +) diff --git a/ydb/core/ymq/actor/yc_search_ut/ya.make b/ydb/core/ymq/actor/yc_search_ut/ya.make new file mode 100644 index 00000000000..621f7da2727 --- /dev/null +++ b/ydb/core/ymq/actor/yc_search_ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST() + +PEERDIR( + ydb/core/testlib/default + ydb/core/ymq/actor +) + +SRCS( + index_events_processor_ut.cpp + test_events_writer.cpp +) + +SIZE(MEDIUM) + +TIMEOUT(300) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/ymq/base/ut/ya.make b/ydb/core/ymq/base/ut/ya.make new file mode 100644 index 00000000000..3af000dd157 --- /dev/null +++ b/ydb/core/ymq/base/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST() + +PEERDIR( + ydb/core/base + ydb/core/ymq/base +) + +SRCS( + action_ut.cpp + counters_ut.cpp + dlq_helpers_ut.cpp + helpers_ut.cpp + secure_protobuf_printer_ut.cpp + queue_attributes_ut.cpp +) + +END() diff --git a/ydb/core/ymq/base/ya.make b/ydb/core/ymq/base/ya.make new file mode 100644 index 00000000000..dcf3c61e820 --- /dev/null +++ b/ydb/core/ymq/base/ya.make @@ -0,0 +1,44 @@ +LIBRARY() + +SRCS( + acl.cpp + action.cpp + counters.cpp + dlq_helpers.cpp + helpers.cpp + probes.cpp + queue_attributes.cpp + queue_id.cpp + run_query.cpp + secure_protobuf_printer.cpp + events_writer_iface.h +) + +GENERATE_ENUM_SERIALIZATION(query_id.h) + +GENERATE_ENUM_SERIALIZATION(cloud_enums.h) + +PEERDIR( + contrib/libs/openssl + library/cpp/cgiparam + library/cpp/ipmath + library/cpp/lwtrace + library/cpp/monlib/dynamic_counters + library/cpp/scheme + library/cpp/string_utils/base64 + ydb/core/base + ydb/core/protos + ydb/core/ymq/proto + ydb/core/kqp/common + ydb/library/aclib + ydb/library/http_proxy/authorization + ydb/library/http_proxy/error + ydb/library/protobuf_printer + ydb/public/lib/scheme_types +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/ymq/client/bin/ya.make b/ydb/core/ymq/client/bin/ya.make new file mode 100644 index 00000000000..f35c7017e34 --- /dev/null +++ b/ydb/core/ymq/client/bin/ya.make @@ -0,0 +1,13 @@ +PROGRAM(sqs) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/getopt + ydb/core/ymq/client/cpp + ydb/core/ymq/proto +) + +END() diff --git a/ydb/core/ymq/client/cpp/ya.make b/ydb/core/ymq/client/cpp/ya.make new file mode 100644 index 00000000000..f839d5ebc4f --- /dev/null +++ b/ydb/core/ymq/client/cpp/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + client.cpp +) + +PEERDIR( + ydb/core/protos + ydb/public/lib/deprecated/client +) + +END() diff --git a/ydb/core/ymq/client/ya.make b/ydb/core/ymq/client/ya.make new file mode 100644 index 00000000000..707bdd5af01 --- /dev/null +++ b/ydb/core/ymq/client/ya.make @@ -0,0 +1,4 @@ +RECURSE( + bin + cpp +) diff --git a/ydb/core/ymq/http/ut/ya.make b/ydb/core/ymq/http/ut/ya.make new file mode 100644 index 00000000000..beeded00abb --- /dev/null +++ b/ydb/core/ymq/http/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + ydb/core/ymq/http +) + +SRCS( + xml_builder_ut.cpp +) + +END() diff --git a/ydb/core/ymq/http/ya.make b/ydb/core/ymq/http/ya.make new file mode 100644 index 00000000000..ff62fe6ebeb --- /dev/null +++ b/ydb/core/ymq/http/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +SRCS( + parser.rl6 + http.cpp + types.cpp + xml.cpp + xml_builder.cpp +) + +PEERDIR( + contrib/libs/libxml + library/cpp/actors/core + library/cpp/cgiparam + library/cpp/http/misc + library/cpp/http/server + library/cpp/protobuf/json + library/cpp/string_utils/base64 + library/cpp/string_utils/quote + library/cpp/string_utils/url + ydb/core/protos + ydb/core/ymq/actor + ydb/core/ymq/base + ydb/library/http_proxy/authorization + ydb/library/http_proxy/error +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/ymq/proto/ya.make b/ydb/core/ymq/proto/ya.make new file mode 100644 index 00000000000..c1f9d26c41b --- /dev/null +++ b/ydb/core/ymq/proto/ya.make @@ -0,0 +1,14 @@ +PROTO_LIBRARY() + +SRCS( + events.proto + records.proto +) + +PEERDIR( + ydb/core/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/core/ymq/queues/common/ya.make b/ydb/core/ymq/queues/common/ya.make new file mode 100644 index 00000000000..8d07a826244 --- /dev/null +++ b/ydb/core/ymq/queues/common/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + queries.cpp + db_queries_maker.cpp +) + +PEERDIR( + ydb/core/ymq/base +) + +END() diff --git a/ydb/core/ymq/queues/fifo/ya.make b/ydb/core/ymq/queues/fifo/ya.make new file mode 100644 index 00000000000..36fa69ba635 --- /dev/null +++ b/ydb/core/ymq/queues/fifo/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + queries.cpp + schema.cpp +) + +PEERDIR( + ydb/core/ymq/base +) + +END() diff --git a/ydb/core/ymq/queues/std/ya.make b/ydb/core/ymq/queues/std/ya.make new file mode 100644 index 00000000000..36fa69ba635 --- /dev/null +++ b/ydb/core/ymq/queues/std/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + queries.cpp + schema.cpp +) + +PEERDIR( + ydb/core/ymq/base +) + +END() diff --git a/ydb/core/ymq/queues/ya.make b/ydb/core/ymq/queues/ya.make new file mode 100644 index 00000000000..1bd482a81f3 --- /dev/null +++ b/ydb/core/ymq/queues/ya.make @@ -0,0 +1,5 @@ +RECURSE( + common + fifo + std +) diff --git a/ydb/core/ymq/ut/ya.make b/ydb/core/ymq/ut/ya.make new file mode 100644 index 00000000000..18731901ff0 --- /dev/null +++ b/ydb/core/ymq/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST() + +SRCS( + queue_id_ut.cpp + params_ut.cpp +) + +PEERDIR( + ydb/core/ymq/base + ydb/core/ymq/http + ydb/library/http_proxy/error +) + +END() diff --git a/ydb/core/ymq/ya.make b/ydb/core/ymq/ya.make new file mode 100644 index 00000000000..42aa5fe5f6b --- /dev/null +++ b/ydb/core/ymq/ya.make @@ -0,0 +1,12 @@ +RECURSE( + actor + base + client + http + queues + proto +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/core/yql_testlib/ya.make b/ydb/core/yql_testlib/ya.make new file mode 100644 index 00000000000..7d8705d7a9c --- /dev/null +++ b/ydb/core/yql_testlib/ya.make @@ -0,0 +1,33 @@ +LIBRARY() + +SRCS( + yql_testlib.cpp + yql_testlib.h +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/regex/pcre + library/cpp/testing/unittest + ydb/core/base + ydb/core/client + ydb/core/client/minikql_compile + ydb/core/client/server + ydb/core/engine + ydb/core/keyvalue + ydb/core/mind + ydb/core/protos + ydb/core/testlib/default + ydb/core/testlib/actors + ydb/core/testlib/basics + ydb/library/yql/core/facade + ydb/library/yql/public/udf + ydb/public/lib/base + ydb/library/yql/core + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/udf_resolve +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/accessor/ya.make b/ydb/library/accessor/ya.make new file mode 100644 index 00000000000..7b9629f0b38 --- /dev/null +++ b/ydb/library/accessor/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +PEERDIR( +) + +SRCS( + accessor.cpp +) + +END() + diff --git a/ydb/library/aclib/protos/ya.make b/ydb/library/aclib/protos/ya.make new file mode 100644 index 00000000000..6d1b66e1595 --- /dev/null +++ b/ydb/library/aclib/protos/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +INCLUDE_TAGS(GO_PROTO) + +SRCS( + aclib.proto +) + +END() diff --git a/ydb/library/aclib/ut/ya.make b/ydb/library/aclib/ut/ya.make new file mode 100644 index 00000000000..0b91627f595 --- /dev/null +++ b/ydb/library/aclib/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(ydb/library/aclib) + +PEERDIR() + +SRCS( + aclib_ut.cpp +) + +END() diff --git a/ydb/library/aclib/ya.make b/ydb/library/aclib/ya.make new file mode 100644 index 00000000000..1e5aa26ea42 --- /dev/null +++ b/ydb/library/aclib/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + contrib/libs/protobuf + library/cpp/protobuf/util + ydb/library/aclib/protos +) + +SRCS( + aclib.cpp + aclib.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/arrow_clickhouse/Columns/ya.make b/ydb/library/arrow_clickhouse/Columns/ya.make new file mode 100644 index 00000000000..38a153683ac --- /dev/null +++ b/ydb/library/arrow_clickhouse/Columns/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow +) + +ADDINCL( + ydb/library/arrow_clickhouse/base + ydb/library/arrow_clickhouse +) + +SRCS( + ColumnsCommon.cpp + ColumnAggregateFunction.cpp +) + +END() diff --git a/ydb/library/arrow_clickhouse/Common/ya.make b/ydb/library/arrow_clickhouse/Common/ya.make new file mode 100644 index 00000000000..8d4e16d580f --- /dev/null +++ b/ydb/library/arrow_clickhouse/Common/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow +) + +ADDINCL( + ydb/library/arrow_clickhouse/base + ydb/library/arrow_clickhouse +) + +SRCS( + Allocator.cpp + PODArray.cpp +) + +END() diff --git a/ydb/library/arrow_clickhouse/DataStreams/ya.make b/ydb/library/arrow_clickhouse/DataStreams/ya.make new file mode 100644 index 00000000000..06a7b0361d7 --- /dev/null +++ b/ydb/library/arrow_clickhouse/DataStreams/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow +) + +ADDINCL( + ydb/library/arrow_clickhouse/base + ydb/library/arrow_clickhouse +) + +SRCS( + AggregatingBlockInputStream.cpp + IBlockInputStream.cpp + MergingAggregatedBlockInputStream.cpp +) + +END() diff --git a/ydb/library/arrow_clickhouse/ut/ya.make b/ydb/library/arrow_clickhouse/ut/ya.make new file mode 100644 index 00000000000..55aa5231c07 --- /dev/null +++ b/ydb/library/arrow_clickhouse/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/library/arrow_clickhouse) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) +TIMEOUT(600) +SIZE(MEDIUM) + +SRCS( + ut_aggregator.cpp +) + +END() diff --git a/ydb/library/arrow_clickhouse/ya.make b/ydb/library/arrow_clickhouse/ya.make new file mode 100644 index 00000000000..e5982a1a308 --- /dev/null +++ b/ydb/library/arrow_clickhouse/ya.make @@ -0,0 +1,35 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + contrib/restricted/cityhash-1.0.2 + + ydb/library/arrow_clickhouse/Common + ydb/library/arrow_clickhouse/Columns + ydb/library/arrow_clickhouse/DataStreams +) + +ADDINCL( + GLOBAL ydb/library/arrow_clickhouse/base + ydb/library/arrow_clickhouse +) + +SRCS( + AggregateFunctions/IAggregateFunction.cpp + Aggregator.cpp + + # used in Common/Allocator + base/common/mremap.cpp +) + +END() + +RECURSE( + Common + Columns + DataStreams +) diff --git a/ydb/library/arrow_kernels/ut/ya.make b/ydb/library/arrow_kernels/ut/ya.make new file mode 100644 index 00000000000..22afc1df9ed --- /dev/null +++ b/ydb/library/arrow_kernels/ut/ya.make @@ -0,0 +1,36 @@ +UNITTEST_FOR(ydb/library/arrow_kernels) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + contrib/libs/apache/arrow +) + +ADDINCL( + ydb/library/arrow_clickhouse +) + +CFLAGS( + -Wno-unused-parameter +) + +SRCS( + ut_common.cpp + ut_arithmetic.cpp + ut_math.cpp + ut_round.cpp +) + +END() diff --git a/ydb/library/arrow_kernels/ya.make b/ydb/library/arrow_kernels/ya.make new file mode 100644 index 00000000000..00b387e8b17 --- /dev/null +++ b/ydb/library/arrow_kernels/ya.make @@ -0,0 +1,16 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow +) + +SRCS( + func_cast.cpp + ut_common.cpp +) + +END() diff --git a/ydb/library/backup/ut/ya.make b/ydb/library/backup/ut/ya.make new file mode 100644 index 00000000000..f0f7f2a205a --- /dev/null +++ b/ydb/library/backup/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(ydb/library/backup) + +SIZE(SMALL) + +TIMEOUT(60) + +SRC(ut.cpp) + +PEERDIR( + library/cpp/string_utils/quote + ydb/library/backup +) + +END() diff --git a/ydb/library/backup/ya.make b/ydb/library/backup/ya.make new file mode 100644 index 00000000000..7b99e14e572 --- /dev/null +++ b/ydb/library/backup/ya.make @@ -0,0 +1,29 @@ +LIBRARY(kikimr_backup) + +PEERDIR( + library/cpp/bucket_quoter + library/cpp/regex/pcre + library/cpp/string_utils/quote + util + ydb/library/dynumber + ydb/public/api/grpc + ydb/public/api/protos + ydb/public/lib/ydb_cli/common + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table +) + +SRCS( + backup.cpp + query_builder.cpp + query_uploader.cpp + util.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/binary_json/ut/ya.make b/ydb/library/binary_json/ut/ya.make new file mode 100644 index 00000000000..4ce301a9e95 --- /dev/null +++ b/ydb/library/binary_json/ut/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/library/binary_json) + +SRCS( + container_ut.cpp + identity_ut.cpp + entry_ut.cpp + test_base.cpp + valid_ut.cpp +) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(2400) + SPLIT_FACTOR(20) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/library/binary_json + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/dom + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/core/issue/protos + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/binary_json/ya.make b/ydb/library/binary_json/ya.make new file mode 100644 index 00000000000..93b3032fd22 --- /dev/null +++ b/ydb/library/binary_json/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +YQL_ABI_VERSION( + 2 + 27 + 0 +) + +PEERDIR( + library/cpp/json + ydb/library/yql/minikql/dom +) + +SRCS( + format.cpp + read.cpp + write.cpp +) + +GENERATE_ENUM_SERIALIZATION(format.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/chunks_limiter/ya.make b/ydb/library/chunks_limiter/ya.make new file mode 100644 index 00000000000..072cc5746bc --- /dev/null +++ b/ydb/library/chunks_limiter/ya.make @@ -0,0 +1,10 @@ +LIBRARY() + +SRCS( + chunks_limiter.cpp +) + +PEERDIR( +) + +END() diff --git a/ydb/library/conclusion/ya.make b/ydb/library/conclusion/ya.make new file mode 100644 index 00000000000..3fcb4c0e9b2 --- /dev/null +++ b/ydb/library/conclusion/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + result.cpp + status.cpp +) + +PEERDIR( +) + +END() diff --git a/ydb/library/db_pool/protos/ya.make b/ydb/library/db_pool/protos/ya.make new file mode 100644 index 00000000000..2270b40ed0a --- /dev/null +++ b/ydb/library/db_pool/protos/ya.make @@ -0,0 +1,11 @@ +PROTO_LIBRARY() + +SRCS( + config.proto +) + +PEERDIR() + +EXCLUDE_TAGS(GO_PROTO) + +END()
\ No newline at end of file diff --git a/ydb/library/db_pool/ya.make b/ydb/library/db_pool/ya.make new file mode 100644 index 00000000000..e40f4f791ce --- /dev/null +++ b/ydb/library/db_pool/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + db_pool.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/monlib/dynamic_counters + ydb/core/protos + ydb/library/db_pool/protos + ydb/library/security + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_table +) + +END() + +RECURSE( + protos +) diff --git a/ydb/library/dynumber/ut/ya.make b/ydb/library/dynumber/ut/ya.make new file mode 100644 index 00000000000..23825b99060 --- /dev/null +++ b/ydb/library/dynumber/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(ydb/library/dynumber) + +SRCS( + dynumber_ut.cpp +) + +PEERDIR( + ydb/library/dynumber +) + +END() diff --git a/ydb/library/dynumber/ya.make b/ydb/library/dynumber/ya.make new file mode 100644 index 00000000000..5d372e0c314 --- /dev/null +++ b/ydb/library/dynumber/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + library/cpp/containers/stack_vector +) + +SRCS( + cast.h + dynumber.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/folder_service/mock/ya.make b/ydb/library/folder_service/mock/ya.make new file mode 100644 index 00000000000..01223f5166d --- /dev/null +++ b/ydb/library/folder_service/mock/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + mock_folder_service_adapter.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/library/folder_service + ydb/library/folder_service/proto +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/folder_service/proto/ya.make b/ydb/library/folder_service/proto/ya.make new file mode 100644 index 00000000000..4c02fd393a8 --- /dev/null +++ b/ydb/library/folder_service/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + config.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/folder_service/ya.make b/ydb/library/folder_service/ya.make new file mode 100644 index 00000000000..45052bf1969 --- /dev/null +++ b/ydb/library/folder_service/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + events.h + folder_service.cpp + folder_service.h +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/library/folder_service/proto +) + +END() + +RECURSE( + mock + proto +) diff --git a/ydb/library/http_proxy/authorization/ut/ya.make b/ydb/library/http_proxy/authorization/ut/ya.make new file mode 100644 index 00000000000..41d5d742943 --- /dev/null +++ b/ydb/library/http_proxy/authorization/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(ydb/library/http_proxy/authorization) + +PEERDIR( + ydb/library/http_proxy/error +) + +SRCS( + auth_helpers_ut.cpp + signature_ut.cpp +) + +END() diff --git a/ydb/library/http_proxy/authorization/ya.make b/ydb/library/http_proxy/authorization/ya.make new file mode 100644 index 00000000000..5d0eb3c30c7 --- /dev/null +++ b/ydb/library/http_proxy/authorization/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + auth_helpers.cpp + signature.cpp +) + +PEERDIR( + contrib/libs/openssl + library/cpp/cgiparam + library/cpp/http/io + library/cpp/http/misc + ydb/library/http_proxy/error +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/http_proxy/error/ya.make b/ydb/library/http_proxy/error/ya.make new file mode 100644 index 00000000000..8751a1a2942 --- /dev/null +++ b/ydb/library/http_proxy/error/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + error.cpp +) + +END() diff --git a/ydb/library/http_proxy/ya.make b/ydb/library/http_proxy/ya.make new file mode 100644 index 00000000000..6137fcc859a --- /dev/null +++ b/ydb/library/http_proxy/ya.make @@ -0,0 +1,4 @@ +RECURSE( + authorization + error +) diff --git a/ydb/library/keys/ut/ya.make b/ydb/library/keys/ut/ya.make new file mode 100644 index 00000000000..b959a927c92 --- /dev/null +++ b/ydb/library/keys/ut/ya.make @@ -0,0 +1,12 @@ +UNITTEST_FOR(ydb/library/keys) +FORK_SUBTESTS() + +SIZE(SMALL) + +PEERDIR() + +SRCS( + default_keys_ut.cpp +) + +END() diff --git a/ydb/library/keys/ya.make b/ydb/library/keys/ya.make new file mode 100644 index 00000000000..884a765eaf6 --- /dev/null +++ b/ydb/library/keys/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + default_keys.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/logger/ya.make b/ydb/library/logger/ya.make new file mode 100644 index 00000000000..4eb705eac07 --- /dev/null +++ b/ydb/library/logger/ya.make @@ -0,0 +1,14 @@ +LIBRARY()
+
+OWNER(g:kikimr)
+
+PEERDIR(
+ library/cpp/actors/core
+ library/cpp/logger
+)
+
+SRCS(
+ actor.cpp
+)
+
+END()
diff --git a/ydb/library/login/protos/ya.make b/ydb/library/login/protos/ya.make new file mode 100644 index 00000000000..3b0ac5ed614 --- /dev/null +++ b/ydb/library/login/protos/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +EXCLUDE_TAGS(GO_PROTO) + +SRCS( + login.proto +) + +END() diff --git a/ydb/library/login/ut/ya.make b/ydb/library/login/ut/ya.make new file mode 100644 index 00000000000..4cc9a1b5595 --- /dev/null +++ b/ydb/library/login/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(ydb/library/login) + +PEERDIR() + +SRCS( + login_ut.cpp +) + +END() diff --git a/ydb/library/login/ya.make b/ydb/library/login/ya.make new file mode 100644 index 00000000000..21a013295ec --- /dev/null +++ b/ydb/library/login/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +PEERDIR( + contrib/libs/jwt-cpp + contrib/libs/protobuf + library/cpp/digest/argonish + library/cpp/json + library/cpp/string_utils/base64 + ydb/library/login/protos +) + +SRCS( + login.cpp + login.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/mkql_proto/protos/ya.make b/ydb/library/mkql_proto/protos/ya.make new file mode 100644 index 00000000000..b1c22f53dd7 --- /dev/null +++ b/ydb/library/mkql_proto/protos/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +GRPC() + +IF (OS_WINDOWS) + NO_OPTIMIZE_PY_PROTOS() +ENDIF() + +SRCS( + minikql.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/mkql_proto/ut/helpers/ya.make b/ydb/library/mkql_proto/ut/helpers/ya.make new file mode 100644 index 00000000000..36cc33b79ba --- /dev/null +++ b/ydb/library/mkql_proto/ut/helpers/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + library/cpp/testing/unittest + contrib/libs/protobuf +) + +YQL_LAST_ABI_VERSION() + +SRCS( + helpers.cpp +) + +END() diff --git a/ydb/library/mkql_proto/ut/ya.make b/ydb/library/mkql_proto/ut/ya.make new file mode 100644 index 00000000000..2da83d8510e --- /dev/null +++ b/ydb/library/mkql_proto/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/library/mkql_proto) + +ALLOCATOR(J) + +FORK_SUBTESTS() + +TIMEOUT(150) + +SIZE(MEDIUM) + +SRCS( + mkql_proto_ut.cpp +) + +PEERDIR( + ydb/library/mkql_proto/ut/helpers + ydb/library/yql/public/udf/service/exception_policy + ydb/core/yql_testlib +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/mkql_proto/ya.make b/ydb/library/mkql_proto/ya.make new file mode 100644 index 00000000000..4d4872d1f45 --- /dev/null +++ b/ydb/library/mkql_proto/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +PEERDIR( + ydb/library/mkql_proto/protos + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/parser/pg_catalog + ydb/library/yql/providers/common/codec + ydb/public/api/protos +) + +SRCS( + mkql_proto.cpp +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/naming_conventions/ut/ya.make b/ydb/library/naming_conventions/ut/ya.make new file mode 100644 index 00000000000..692aa2af727 --- /dev/null +++ b/ydb/library/naming_conventions/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(ydb/library/naming_conventions) + +SRCS( + naming_conventions_ut.cpp +) + +END() diff --git a/ydb/library/naming_conventions/ya.make b/ydb/library/naming_conventions/ya.make new file mode 100644 index 00000000000..109dec97ae1 --- /dev/null +++ b/ydb/library/naming_conventions/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + naming_conventions.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/pdisk_io/protos/ya.make b/ydb/library/pdisk_io/protos/ya.make new file mode 100644 index 00000000000..e654f5f9807 --- /dev/null +++ b/ydb/library/pdisk_io/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +IF (OS_WINDOWS) + NO_OPTIMIZE_PY_PROTOS() +ENDIF() + +SRCS( + sector_map.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/pdisk_io/ya.make b/ydb/library/pdisk_io/ya.make new file mode 100644 index 00000000000..7d65cf7d263 --- /dev/null +++ b/ydb/library/pdisk_io/ya.make @@ -0,0 +1,56 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(aio.h) + +IF (OS_LINUX) + PEERDIR( + contrib/libs/libaio + contrib/libs/liburing + ) + SRCS( + aio_linux.cpp + file_params_linux.cpp + ) +ELSE(OS_LINUX) + SRCS( + aio_mtp.cpp + ) +ENDIF(OS_LINUX) + +IF (OS_DARWIN) + SRCS( + file_params_darwin.cpp + ) +ENDIF(OS_DARWIN) + +IF (OS_WINDOWS) + SRCS( + file_params_win.cpp + ) +ENDIF(OS_WINDOWS) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/wilson + library/cpp/monlib/dynamic_counters + ydb/core/debug + ydb/library/pdisk_io/protos +) + +SRCS( + aio.cpp + aio.h + aio_map.cpp + buffers.cpp + buffers.h + device_type.cpp + device_type.h + drivedata.cpp + drivedata.h + sector_map.cpp + sector_map.h + wcache.cpp + wcache.h +) + +END() diff --git a/ydb/library/persqueue/counter_time_keeper/ya.make b/ydb/library/persqueue/counter_time_keeper/ya.make new file mode 100644 index 00000000000..fe65d4c195f --- /dev/null +++ b/ydb/library/persqueue/counter_time_keeper/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +PEERDIR( + library/cpp/lwtrace/protos + library/cpp/actors/protos + ydb/core/protos +) + +SRCS( + counter_time_keeper.h + counter_time_keeper.cpp +) + +END() diff --git a/ydb/library/persqueue/obfuscate/ya.make b/ydb/library/persqueue/obfuscate/ya.make new file mode 100644 index 00000000000..f374b14e264 --- /dev/null +++ b/ydb/library/persqueue/obfuscate/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +SRCS( + obfuscate.h + obfuscate.cpp +) + +END() diff --git a/ydb/library/persqueue/tests/ya.make b/ydb/library/persqueue/tests/ya.make new file mode 100644 index 00000000000..884012b08b4 --- /dev/null +++ b/ydb/library/persqueue/tests/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS(counters.cpp) + + +PEERDIR( + library/cpp/testing/unittest + library/cpp/http/io + library/cpp/json +) + +END() diff --git a/ydb/library/persqueue/topic_parser/ut/ya.make b/ydb/library/persqueue/topic_parser/ut/ya.make new file mode 100644 index 00000000000..5fc382b5461 --- /dev/null +++ b/ydb/library/persqueue/topic_parser/ut/ya.make @@ -0,0 +1,19 @@ +UNITTEST_FOR(ydb/library/persqueue/topic_parser) + +FORK_SUBTESTS() + +TIMEOUT(30) + +SIZE(SMALL) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/library/persqueue/topic_parser +) + +SRCS( + topic_names_converter_ut.cpp +) + +END() diff --git a/ydb/library/persqueue/topic_parser/ya.make b/ydb/library/persqueue/topic_parser/ya.make new file mode 100644 index 00000000000..ef7675c39ee --- /dev/null +++ b/ydb/library/persqueue/topic_parser/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +PEERDIR( + ydb/core/base + ydb/library/persqueue/topic_parser_public + ydb/public/api/protos +) + +SRCS( + topic_parser.h + topic_parser.cpp + counters.h + counters.cpp + type_definitions.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/persqueue/topic_parser_public/ya.make b/ydb/library/persqueue/topic_parser_public/ya.make new file mode 100644 index 00000000000..8c4eb032533 --- /dev/null +++ b/ydb/library/persqueue/topic_parser_public/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +SRCS( + topic_parser.h + topic_parser.cpp +) + +END() diff --git a/ydb/library/persqueue/ya.make b/ydb/library/persqueue/ya.make new file mode 100644 index 00000000000..52f8dc401ea --- /dev/null +++ b/ydb/library/persqueue/ya.make @@ -0,0 +1,7 @@ +RECURSE( + counter_time_keeper + obfuscate + tests + topic_parser + topic_parser_public +) diff --git a/ydb/library/pretty_types_print/protobuf/ya.make b/ydb/library/pretty_types_print/protobuf/ya.make new file mode 100644 index 00000000000..39008b01ba1 --- /dev/null +++ b/ydb/library/pretty_types_print/protobuf/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + out.cpp +) + +PEERDIR( + contrib/libs/protobuf +) + +END() diff --git a/ydb/library/pretty_types_print/wilson/ya.make b/ydb/library/pretty_types_print/wilson/ya.make new file mode 100644 index 00000000000..41c07b3f7dd --- /dev/null +++ b/ydb/library/pretty_types_print/wilson/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + out.cpp +) + +PEERDIR( + library/cpp/actors/wilson +) + +END() diff --git a/ydb/library/pretty_types_print/ya.make b/ydb/library/pretty_types_print/ya.make new file mode 100644 index 00000000000..957b484f053 --- /dev/null +++ b/ydb/library/pretty_types_print/ya.make @@ -0,0 +1,4 @@ +RECURSE( + protobuf + wilson +) diff --git a/ydb/library/protobuf_printer/ut/ya.make b/ydb/library/protobuf_printer/ut/ya.make new file mode 100644 index 00000000000..3c988ae3b20 --- /dev/null +++ b/ydb/library/protobuf_printer/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(ydb/library/protobuf_printer) + +SRCS( + protobuf_printer_ut.cpp + test_proto.proto +) + +END() diff --git a/ydb/library/protobuf_printer/ya.make b/ydb/library/protobuf_printer/ya.make new file mode 100644 index 00000000000..7ceaeba3302 --- /dev/null +++ b/ydb/library/protobuf_printer/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + hide_field_printer.cpp + size_printer.cpp + stream_helper.cpp + token_field_printer.cpp +) + +PEERDIR( + contrib/libs/protobuf + ydb/library/security + ydb/public/api/protos/annotations +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/query_actor/ut/ya.make b/ydb/library/query_actor/ut/ya.make new file mode 100644 index 00000000000..9a85e97b0f2 --- /dev/null +++ b/ydb/library/query_actor/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(ydb/library/query_actor) + +PEERDIR( + ydb/core/testlib + ydb/library/yql/sql/pg_dummy +) + +SRCS( + query_actor_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/query_actor/ya.make b/ydb/library/query_actor/ya.make new file mode 100644 index 00000000000..7fb76826b3a --- /dev/null +++ b/ydb/library/query_actor/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + query_actor.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/threading/future + ydb/core/base + ydb/core/grpc_services/local_rpc + ydb/library/yql/public/issue + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_params + ydb/public/sdk/cpp/client/ydb_result + ydb/public/sdk/cpp/client/ydb_proto +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/rewrapper/hyperscan/ya.make b/ydb/library/rewrapper/hyperscan/ya.make new file mode 100644 index 00000000000..06c7c67e0ea --- /dev/null +++ b/ydb/library/rewrapper/hyperscan/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + library/cpp/regex/hyperscan + ydb/library/rewrapper +) + +SRCS( + GLOBAL hyperscan.cpp +) + +END() + diff --git a/ydb/library/rewrapper/proto/ya.make b/ydb/library/rewrapper/proto/ya.make new file mode 100644 index 00000000000..20c4abefc93 --- /dev/null +++ b/ydb/library/rewrapper/proto/ya.make @@ -0,0 +1,7 @@ +PROTO_LIBRARY() + +SRCS( + serialization.proto +) + +END() diff --git a/ydb/library/rewrapper/re2/ya.make b/ydb/library/rewrapper/re2/ya.make new file mode 100644 index 00000000000..b715f5332a7 --- /dev/null +++ b/ydb/library/rewrapper/re2/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + contrib/libs/re2 + ydb/library/rewrapper +) + +SRCS( + GLOBAL re2.cpp +) + +END() + diff --git a/ydb/library/rewrapper/ut/ya.make b/ydb/library/rewrapper/ut/ya.make new file mode 100644 index 00000000000..fdc9cd13691 --- /dev/null +++ b/ydb/library/rewrapper/ut/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/library/rewrapper) + +IF(ARCH_X86_64) + SRCS( + hyperscan_ut.cpp + re2_ut.cpp + ) + + PEERDIR( + ydb/library/rewrapper + ydb/library/rewrapper/hyperscan + ydb/library/rewrapper/re2 + ) +ELSE() + SRCS( + re2_ut.cpp + ) + + PEERDIR( + ydb/library/rewrapper + ydb/library/rewrapper/re2 + ) +ENDIF() + +END() diff --git a/ydb/library/rewrapper/ya.make b/ydb/library/rewrapper/ya.make new file mode 100644 index 00000000000..aac73d090ea --- /dev/null +++ b/ydb/library/rewrapper/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + ydb/library/rewrapper/proto +) + +SRCS( + dispatcher.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/schlab/mon/static/css/ya.make b/ydb/library/schlab/mon/static/css/ya.make new file mode 100644 index 00000000000..4efbe68648a --- /dev/null +++ b/ydb/library/schlab/mon/static/css/ya.make @@ -0,0 +1,5 @@ +LIBRARY() + +SRCS() + +END() diff --git a/ydb/library/schlab/mon/static/js/ya.make b/ydb/library/schlab/mon/static/js/ya.make new file mode 100644 index 00000000000..4efbe68648a --- /dev/null +++ b/ydb/library/schlab/mon/static/js/ya.make @@ -0,0 +1,5 @@ +LIBRARY() + +SRCS() + +END() diff --git a/ydb/library/schlab/mon/static/ya.make b/ydb/library/schlab/mon/static/ya.make new file mode 100644 index 00000000000..4efbe68648a --- /dev/null +++ b/ydb/library/schlab/mon/static/ya.make @@ -0,0 +1,5 @@ +LIBRARY() + +SRCS() + +END() diff --git a/ydb/library/schlab/mon/test/ya.make b/ydb/library/schlab/mon/test/ya.make new file mode 100644 index 00000000000..98db9a3fc87 --- /dev/null +++ b/ydb/library/schlab/mon/test/ya.make @@ -0,0 +1,17 @@ +PROGRAM(mon-test) + +RESOURCE( + ../static/schviz-test0.json schlab/schviz-test0.json +) + +SRCS( + test.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/monlib/dynamic_counters + ydb/library/schlab/mon +) + +END() diff --git a/ydb/library/schlab/mon/ya.make b/ydb/library/schlab/mon/ya.make new file mode 100644 index 00000000000..a0dc3acdd3c --- /dev/null +++ b/ydb/library/schlab/mon/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +RESOURCE( + static/css/bootstrap.min.css schlab/css/bootstrap.min.css + static/css/scharm.css schlab/css/scharm.css + static/css/schviz.css schlab/css/schviz.css + static/js/jquery.min.js schlab/js/jquery.min.js + static/js/bootstrap.min.js schlab/js/bootstrap.min.js + static/js/d3-tip-0.8.0-alpha.1.js schlab/js/d3-tip-0.8.0-alpha.1.js + static/js/d3.v4.min.js schlab/js/d3.v4.min.js + static/js/scharm.js schlab/js/scharm.js + static/js/schviz.js schlab/js/schviz.js + static/js/scharm-test0.js schlab/js/scharm-test0.js + static/scharm.html schlab/scharm.html +) + +SRCS( + mon.cpp +) + +PEERDIR( + library/cpp/html/pcdata + library/cpp/monlib/dynamic_counters + library/cpp/resource + ydb/library/schlab/schemu +) + +END() + +RECURSE( + test + static + static/css + static/js +) diff --git a/ydb/library/schlab/probes/ya.make b/ydb/library/schlab/probes/ya.make new file mode 100644 index 00000000000..5d4d6a0d490 --- /dev/null +++ b/ydb/library/schlab/probes/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + library/cpp/lwtrace +) + +SRCS( + probes.cpp + probes.h +) + +END() diff --git a/ydb/library/schlab/protos/ya.make b/ydb/library/schlab/protos/ya.make new file mode 100644 index 00000000000..ee33f586e45 --- /dev/null +++ b/ydb/library/schlab/protos/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + schlab.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/schlab/schemu/ya.make b/ydb/library/schlab/schemu/ya.make new file mode 100644 index 00000000000..0376c63314a --- /dev/null +++ b/ydb/library/schlab/schemu/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + ydb/library/schlab/schine + ydb/library/schlab/schoot +) + +SRCS( + defs.h + schemu.h + schemu.cpp +) + +END() + +RECURSE() diff --git a/ydb/library/schlab/schine/ya.make b/ydb/library/schlab/schine/ya.make new file mode 100644 index 00000000000..1f8dc411b74 --- /dev/null +++ b/ydb/library/schlab/schine/ya.make @@ -0,0 +1,33 @@ +LIBRARY() + +PEERDIR( + library/cpp/containers/stack_vector + library/cpp/lwtrace + library/cpp/lwtrace/mon + ydb/library/schlab/probes +) + +SRCS( + bin_log.h + cbs.h + cbs_bin.h + cbs_state.h + defs.h + job.h + job_kind.h + job_state.h + name_table.h + scheduler.h + schlog.h + schlog_frame.h + cbs.cpp + cbs_bin.cpp + cbs_state.cpp + job.cpp + job_kind.cpp + job_state.cpp + scheduler.cpp + schlog.cpp +) + +END() diff --git a/ydb/library/schlab/schoot/ya.make b/ydb/library/schlab/schoot/ya.make new file mode 100644 index 00000000000..d06962e171c --- /dev/null +++ b/ydb/library/schlab/schoot/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PEERDIR( + library/cpp/containers/stack_vector + library/cpp/protobuf/json + ydb/library/schlab/protos +) + +SRCS( + defs.h + schoot_gen.cpp + schoot_gen.h + schoot_gen_cfg.cpp + schoot_gen_cfg.h +) + +END() + +RECURSE() diff --git a/ydb/library/schlab/ut/ya.make b/ydb/library/schlab/ut/ya.make new file mode 100644 index 00000000000..e602b974b9e --- /dev/null +++ b/ydb/library/schlab/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + ydb/library/schlab/schoot +) + +SRCS( + schlab_ut.cpp +) + +END() diff --git a/ydb/library/schlab/ya.make b/ydb/library/schlab/ya.make new file mode 100644 index 00000000000..7a1cd3095a8 --- /dev/null +++ b/ydb/library/schlab/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +PEERDIR( + ydb/library/schlab/schine +) + +SRCS( + defs.h + schlab_actor.h + schlab_actor.cpp +) + +END() + +RECURSE( + mon + probes + protos + schemu + schine + schoot +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/security/ut/ya.make b/ydb/library/security/ut/ya.make new file mode 100644 index 00000000000..c955535398b --- /dev/null +++ b/ydb/library/security/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST() + +PEERDIR( + ydb/library/security +) + +SRCS( + util_ut.cpp +) + +END() diff --git a/ydb/library/security/ya.make b/ydb/library/security/ya.make new file mode 100644 index 00000000000..f60c59e40d3 --- /dev/null +++ b/ydb/library/security/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + ydb/public/sdk/cpp/client/iam + library/cpp/digest/crc32c + ydb/public/sdk/cpp/client/ydb_types/credentials +) + +SRCS( + util.cpp + ydb_credentials_provider_factory.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/testlib/service_mocks/ya.make b/ydb/library/testlib/service_mocks/ya.make new file mode 100644 index 00000000000..9bf784d56f6 --- /dev/null +++ b/ydb/library/testlib/service_mocks/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + + +SRCS( + access_service_mock.h + datastreams_service_mock.h + folder_service_transitional_mock.h + folder_service_mock.h + iam_token_service_mock.h + service_account_service_mock.h + user_account_service_mock.h +) + +PEERDIR( + ydb/public/api/client/yc_private/servicecontrol + ydb/public/api/grpc/draft + ydb/public/api/client/yc_private/resourcemanager + ydb/public/api/client/yc_private/iam +) + +END() diff --git a/ydb/library/testlib/ut/ya.make b/ydb/library/testlib/ut/ya.make new file mode 100644 index 00000000000..e6ba2ba90f8 --- /dev/null +++ b/ydb/library/testlib/ut/ya.make @@ -0,0 +1,12 @@ +GTEST() + +SIZE(SMALL) + +PEERDIR( +) + +SRCS( + gtest_compat_ut.cpp +) + +END() diff --git a/ydb/library/testlib/ya.make b/ydb/library/testlib/ya.make new file mode 100644 index 00000000000..2b6d2768a9f --- /dev/null +++ b/ydb/library/testlib/ya.make @@ -0,0 +1,7 @@ +RECURSE( + service_mocks +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/uuid/ya.make b/ydb/library/uuid/ya.make new file mode 100644 index 00000000000..15cd576d234 --- /dev/null +++ b/ydb/library/uuid/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + uuid.cpp +) + +END() diff --git a/ydb/library/workload/ya.make b/ydb/library/workload/ya.make new file mode 100644 index 00000000000..c947999b82b --- /dev/null +++ b/ydb/library/workload/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + stock_workload.cpp + kv_workload.cpp + workload_factory.cpp +) + +PEERDIR( + ydb/public/api/protos +) + +END() diff --git a/ydb/library/ya.make b/ydb/library/ya.make new file mode 100644 index 00000000000..04e97cec842 --- /dev/null +++ b/ydb/library/ya.make @@ -0,0 +1,31 @@ +RECURSE( + accessor + aclib + arrow_clickhouse + arrow_kernels + backup + binary_json + chunks_limiter + dynumber + folder_service + http_proxy + keys + login + logger + mkql_proto + naming_conventions + pdisk_io + persqueue + pretty_types_print + protobuf_printer + query_actor + schlab + security + testlib + workload + yaml_config + workload + yaml_config + ycloud + yql +) diff --git a/ydb/library/yaml_config/ya.make b/ydb/library/yaml_config/ya.make new file mode 100644 index 00000000000..dd112dacd1d --- /dev/null +++ b/ydb/library/yaml_config/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRC(yaml_config_parser.cpp) + +PEERDIR( + contrib/libs/protobuf + contrib/libs/yaml-cpp + ydb/core/base + ydb/core/erasure + ydb/core/protos +) + +END() diff --git a/ydb/library/ycloud/api/ya.make b/ydb/library/ycloud/api/ya.make new file mode 100644 index 00000000000..22c91b5d779 --- /dev/null +++ b/ydb/library/ycloud/api/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + access_service.h + folder_service.h + folder_service_transitional.h + iam_token_service.h + user_account_service.h +) + +PEERDIR( + ydb/public/api/client/yc_private/iam + ydb/public/api/client/yc_private/servicecontrol + ydb/public/api/client/yc_private/resourcemanager + library/cpp/actors/core + library/cpp/grpc/client + ydb/core/base + ydb/core/grpc_caching +) + +END() diff --git a/ydb/library/ycloud/impl/ut/ya.make b/ydb/library/ycloud/impl/ut/ya.make new file mode 100644 index 00000000000..d8206463743 --- /dev/null +++ b/ydb/library/ycloud/impl/ut/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/library/ycloud/impl) + +FORK_SUBTESTS() + +TIMEOUT(600) + +SIZE(MEDIUM) + +PEERDIR( + library/cpp/retry + ydb/core/testlib/default +) + +YQL_LAST_ABI_VERSION() + +SRCS( + access_service_ut.cpp + folder_service_ut.cpp + service_account_service_ut.cpp + user_account_service_ut.cpp +) + +REQUIREMENTS(ram:10) + +END() diff --git a/ydb/library/ycloud/impl/ya.make b/ydb/library/ycloud/impl/ya.make new file mode 100644 index 00000000000..5a62430d907 --- /dev/null +++ b/ydb/library/ycloud/impl/ya.make @@ -0,0 +1,39 @@ +RECURSE_FOR_TESTS( + ut +) + +LIBRARY() + +SRCS( + access_service.cpp + access_service.h + folder_service.cpp + folder_service.h + folder_service_transitional.cpp + folder_service_transitional.h + folder_service_adapter.cpp + grpc_service_cache.h + grpc_service_client.h + grpc_service_settings.h + iam_token_service.cpp + iam_token_service.h + mock_access_service.cpp + mock_access_service.h + service_account_service.cpp + service_account_service.h + user_account_service.cpp + user_account_service.h +) + +PEERDIR( + ydb/library/ycloud/api + library/cpp/actors/core + library/cpp/digest/crc32c + library/cpp/grpc/client + library/cpp/json + ydb/core/base + ydb/public/lib/deprecated/client + ydb/public/lib/deprecated/kicli +) + +END() diff --git a/ydb/library/ycloud/ya.make b/ydb/library/ycloud/ya.make new file mode 100644 index 00000000000..4e8844bdc83 --- /dev/null +++ b/ydb/library/ycloud/ya.make @@ -0,0 +1,4 @@ +RECURSE( + api + impl +) diff --git a/ydb/library/yql/ast/serialize/ya.make b/ydb/library/yql/ast/serialize/ya.make new file mode 100644 index 00000000000..dc44566e76b --- /dev/null +++ b/ydb/library/yql/ast/serialize/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + yql_expr_serialize.cpp +) + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/core/issue + ydb/library/yql/minikql +) + +END() diff --git a/ydb/library/yql/ast/ut/ya.make b/ydb/library/yql/ast/ut/ya.make new file mode 100644 index 00000000000..e7eee3f2bcf --- /dev/null +++ b/ydb/library/yql/ast/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/library/yql/ast) + +FORK_SUBTESTS() + +SRCS( + yql_ast_ut.cpp + yql_expr_check_args_ut.cpp + yql_expr_builder_ut.cpp + yql_expr_ut.cpp + yql_type_string_ut.cpp +) + +PEERDIR( +) + +END() diff --git a/ydb/library/yql/ast/ya.make b/ydb/library/yql/ast/ya.make new file mode 100644 index 00000000000..d216bb00070 --- /dev/null +++ b/ydb/library/yql/ast/ya.make @@ -0,0 +1,45 @@ +LIBRARY() + +SRCS( + yql_ast.cpp + yql_ast.h + yql_constraint.cpp + yql_constraint.h + yql_ast_annotation.cpp + yql_ast_annotation.h + yql_ast_escaping.cpp + yql_ast_escaping.h + yql_errors.cpp + yql_errors.h + yql_expr.cpp + yql_expr.h + yql_expr_builder.cpp + yql_expr_builder.h + yql_expr_types.cpp + yql_expr_types.h + yql_gc_nodes.cpp + yql_gc_nodes.h + yql_type_string.cpp + yql_type_string.h +) + +PEERDIR( + library/cpp/colorizer + library/cpp/containers/sorted_vector + library/cpp/containers/stack_vector + library/cpp/deprecated/enum_codegen + library/cpp/enumbitset + library/cpp/string_utils/levenshtein_diff + library/cpp/yson + library/cpp/yson/node + ydb/library/yql/public/udf + ydb/library/yql/utils + ydb/library/yql/core/issue + ydb/library/yql/parser/pg_catalog +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/core/arrow_kernels/registry/ut/ya.make b/ydb/library/yql/core/arrow_kernels/registry/ut/ya.make new file mode 100644 index 00000000000..b61a00c1c1b --- /dev/null +++ b/ydb/library/yql/core/arrow_kernels/registry/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/library/yql/core/arrow_kernels/registry) + +PEERDIR( +) + +YQL_LAST_ABI_VERSION() + +SRCS( + registry_ut.cpp +) + +PEERDIR( + ydb/library/yql/core/arrow_kernels/request + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/udfs/common/url_base +) + +END() diff --git a/ydb/library/yql/core/arrow_kernels/registry/ya.make b/ydb/library/yql/core/arrow_kernels/registry/ya.make new file mode 100644 index 00000000000..65a7314a1a9 --- /dev/null +++ b/ydb/library/yql/core/arrow_kernels/registry/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + registry.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/library/yql/minikql + ydb/library/yql/minikql/computation +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/core/arrow_kernels/request/ya.make b/ydb/library/yql/core/arrow_kernels/request/ya.make new file mode 100644 index 00000000000..03d179915af --- /dev/null +++ b/ydb/library/yql/core/arrow_kernels/request/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + request.cpp +) + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/minikql + ydb/library/yql/providers/common/mkql +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/core/common_opt/ya.make b/ydb/library/yql/core/common_opt/ya.make new file mode 100644 index 00000000000..37bd43f787b --- /dev/null +++ b/ydb/library/yql/core/common_opt/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +SRCS( + yql_co.h + yql_co_extr_members.cpp + yql_flatmap_over_join.cpp + yql_co_finalizers.cpp + yql_co_flow1.cpp + yql_co_flow2.cpp + yql_co_flowidaw1.cpp + yql_co_last.cpp + yql_co_pgselect.cpp + yql_co_pgselect.h + yql_co_simple1.cpp + yql_co_simple2.cpp + yql_co_simple3.cpp + yql_co_transformer.cpp + yql_co_transformer.h +) + +PEERDIR( + ydb/library/yql/core + ydb/library/yql/core/expr_nodes + ydb/library/yql/parser/pg_catalog +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/core/credentials/ya.make b/ydb/library/yql/core/credentials/ya.make new file mode 100644 index 00000000000..df1c6dede4d --- /dev/null +++ b/ydb/library/yql/core/credentials/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + yql_credentials.cpp +) + +END() diff --git a/ydb/library/yql/core/expr_nodes/ya.make b/ydb/library/yql/core/expr_nodes/ya.make new file mode 100644 index 00000000000..5a9ebdda769 --- /dev/null +++ b/ydb/library/yql/core/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_expr_nodes.h + yql_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes_gen + ydb/library/yql/public/udf + ydb/library/yql/core/issue +) + +SRCDIR(ydb/library/yql/core/expr_nodes_gen) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_expr_nodes.json + yql_expr_nodes.gen.h + yql_expr_nodes.decl.inl.h + yql_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_expr_nodes.json + OUT yql_expr_nodes.gen.h + OUT yql_expr_nodes.decl.inl.h + OUT yql_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_expr_nodes.json + yql_expr_nodes.gen.h + yql_expr_nodes.decl.inl.h + yql_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_expr_nodes.json + OUT yql_expr_nodes.gen.h + OUT yql_expr_nodes.decl.inl.h + OUT yql_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/core/expr_nodes_gen/gen/ya.make b/ydb/library/yql/core/expr_nodes_gen/gen/ya.make new file mode 100644 index 00000000000..6f90f8d745d --- /dev/null +++ b/ydb/library/yql/core/expr_nodes_gen/gen/ya.make @@ -0,0 +1,10 @@ +PY3_PROGRAM() + +PY_SRCS(__main__.py) + +PEERDIR( + contrib/python/MarkupSafe + contrib/python/Jinja2 +) + +END() diff --git a/ydb/library/yql/core/expr_nodes_gen/ya.make b/ydb/library/yql/core/expr_nodes_gen/ya.make new file mode 100644 index 00000000000..32d4ee963ad --- /dev/null +++ b/ydb/library/yql/core/expr_nodes_gen/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + yql_expr_nodes_gen.h + yql_expr_nodes_gen.cpp +) + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/public/udf +) + +END() diff --git a/ydb/library/yql/core/extract_predicate/ya.make b/ydb/library/yql/core/extract_predicate/ya.make new file mode 100644 index 00000000000..22a0bcc917c --- /dev/null +++ b/ydb/library/yql/core/extract_predicate/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + extract_predicate_dbg.cpp + extract_predicate_dbg.h + extract_predicate_impl.cpp + extract_predicate_impl.h + extract_predicate.h +) + +PEERDIR( + ydb/library/yql/core/services +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/core/facade/ya.make b/ydb/library/yql/core/facade/ya.make new file mode 100644 index 00000000000..b605006573f --- /dev/null +++ b/ydb/library/yql/core/facade/ya.make @@ -0,0 +1,34 @@ +LIBRARY() + +SRCS( + yql_facade.cpp +) + +PEERDIR( + library/cpp/deprecated/split + library/cpp/random_provider + library/cpp/string_utils/base64 + library/cpp/threading/future + library/cpp/time_provider + library/cpp/yson + library/cpp/yson/node + ydb/library/yql/core/extract_predicate + ydb/library/yql/core/file_storage + ydb/library/yql/core/services + ydb/library/yql/core/credentials + ydb/library/yql/sql + ydb/library/yql/utils/log + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/udf_resolve + ydb/library/yql/providers/common/arrow_resolve + ydb/library/yql/providers/config + ydb/library/yql/providers/result/provider +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/core/file_storage/defs/ya.make b/ydb/library/yql/core/file_storage/defs/ya.make new file mode 100644 index 00000000000..d0bc48f525b --- /dev/null +++ b/ydb/library/yql/core/file_storage/defs/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + downloader.cpp + provider.cpp +) + +PEERDIR( + library/cpp/uri +) + +END() diff --git a/ydb/library/yql/core/file_storage/download/ya.make b/ydb/library/yql/core/file_storage/download/ya.make new file mode 100644 index 00000000000..c692171eb51 --- /dev/null +++ b/ydb/library/yql/core/file_storage/download/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + download_config.cpp + download_stream.cpp +) + +PEERDIR( + ydb/library/yql/core/file_storage/proto + library/cpp/protobuf/util +) + +END() diff --git a/ydb/library/yql/core/file_storage/http_download/proto/ya.make b/ydb/library/yql/core/file_storage/http_download/proto/ya.make new file mode 100644 index 00000000000..36a96300929 --- /dev/null +++ b/ydb/library/yql/core/file_storage/http_download/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + http_download.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/core/file_storage/http_download/ya.make b/ydb/library/yql/core/file_storage/http_download/ya.make new file mode 100644 index 00000000000..ac3dd54102d --- /dev/null +++ b/ydb/library/yql/core/file_storage/http_download/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + http_download.cpp +) + +PEERDIR( + ydb/library/yql/core/file_storage/defs + ydb/library/yql/core/file_storage/download + ydb/library/yql/core/file_storage/proto + ydb/library/yql/core/file_storage/http_download/proto + ydb/library/yql/utils/fetch + ydb/library/yql/utils/log + ydb/library/yql/utils + library/cpp/digest/md5 + library/cpp/http/misc +) + +END() diff --git a/ydb/library/yql/core/file_storage/proto/ya.make b/ydb/library/yql/core/file_storage/proto/ya.make new file mode 100644 index 00000000000..b27669934b4 --- /dev/null +++ b/ydb/library/yql/core/file_storage/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + file_storage.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/core/file_storage/ut/ya.make b/ydb/library/yql/core/file_storage/ut/ya.make new file mode 100644 index 00000000000..8c8ae6e6408 --- /dev/null +++ b/ydb/library/yql/core/file_storage/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/library/yql/core/file_storage) + +SRCS( + file_storage_ut.cpp + sized_cache_ut.cpp + storage_ut.cpp +) + +PEERDIR( + library/cpp/http/server + library/cpp/threading/future + library/cpp/deprecated/atomic + ydb/library/yql/utils/test_http_server +) + +END() diff --git a/ydb/library/yql/core/file_storage/ya.make b/ydb/library/yql/core/file_storage/ya.make new file mode 100644 index 00000000000..646e04b33e6 --- /dev/null +++ b/ydb/library/yql/core/file_storage/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +SRCS( + file_storage_decorator.cpp + file_storage.cpp + file_storage.h + sized_cache.cpp + sized_cache.h + storage.cpp + storage.h + url_meta.cpp + url_meta.h +) + +PEERDIR( + library/cpp/cache + library/cpp/digest/md5 + library/cpp/logger/global + library/cpp/threading/future + library/cpp/protobuf/util + library/cpp/uri + ydb/library/yql/core/file_storage/proto + ydb/library/yql/core/file_storage/defs + ydb/library/yql/core/file_storage/download + ydb/library/yql/core/file_storage/http_download + ydb/library/yql/utils + ydb/library/yql/utils/log + ydb/library/yql/utils/fetch +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/core/issue/protos/ya.make b/ydb/library/yql/core/issue/protos/ya.make new file mode 100644 index 00000000000..14fdac8040c --- /dev/null +++ b/ydb/library/yql/core/issue/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +SRCS( + issue_id.proto +) + +PEERDIR( + ydb/library/yql/public/issue/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/core/issue/ut/ya.make b/ydb/library/yql/core/issue/ut/ya.make new file mode 100644 index 00000000000..8e806d5a5cc --- /dev/null +++ b/ydb/library/yql/core/issue/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(ydb/library/yql/core/issue) + +FORK_SUBTESTS() + +SRCS( + yql_issue_ut.cpp +) + +PEERDIR( +) + +TIMEOUT(300) +SIZE(MEDIUM) + +END() diff --git a/ydb/library/yql/core/issue/ya.make b/ydb/library/yql/core/issue/ya.make new file mode 100644 index 00000000000..536cfbfc002 --- /dev/null +++ b/ydb/library/yql/core/issue/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + yql_issue.cpp +) + +PEERDIR( + library/cpp/resource + contrib/libs/protobuf + ydb/library/yql/public/issue + ydb/library/yql/core/issue/protos +) + +RESOURCE( + ydb/library/yql/core/issue/yql_issue.txt yql_issue.txt +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/core/peephole_opt/ya.make b/ydb/library/yql/core/peephole_opt/ya.make new file mode 100644 index 00000000000..9d951b7e9b9 --- /dev/null +++ b/ydb/library/yql/core/peephole_opt/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + yql_opt_json_peephole_physical.h + yql_opt_json_peephole_physical.cpp + yql_opt_peephole_physical.h + yql_opt_peephole_physical.cpp +) + +PEERDIR( + ydb/library/yql/core + ydb/library/yql/core/common_opt + ydb/library/yql/core/type_ann +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/core/services/mounts/ya.make b/ydb/library/yql/core/services/mounts/ya.make new file mode 100644 index 00000000000..5092ba058e7 --- /dev/null +++ b/ydb/library/yql/core/services/mounts/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + yql_mounts.h + yql_mounts.cpp +) + +PEERDIR( + library/cpp/resource + ydb/library/yql/core/user_data + ydb/library/yql/core +) + +YQL_LAST_ABI_VERSION() + +RESOURCE( + ydb/library/yql/mount/lib/yql/aggregate.yql /lib/yql/aggregate.yql + ydb/library/yql/mount/lib/yql/window.yql /lib/yql/window.yql + ydb/library/yql/mount/lib/yql/id.yql /lib/yql/id.yql + ydb/library/yql/mount/lib/yql/sqr.yql /lib/yql/sqr.yql + ydb/library/yql/mount/lib/yql/core.yql /lib/yql/core.yql +) + +END() diff --git a/ydb/library/yql/core/services/ya.make b/ydb/library/yql/core/services/ya.make new file mode 100644 index 00000000000..45af1e24ff7 --- /dev/null +++ b/ydb/library/yql/core/services/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +SRCS( + yql_eval_expr.cpp + yql_eval_expr.h + yql_eval_params.cpp + yql_eval_params.h + yql_out_transformers.cpp + yql_out_transformers.h + yql_lineage.cpp + yql_lineage.h + yql_plan.cpp + yql_plan.h + yql_transform_pipeline.cpp + yql_transform_pipeline.h +) + +PEERDIR( + library/cpp/string_utils/base64 + library/cpp/yson + ydb/library/yql/ast/serialize + ydb/library/yql/minikql + ydb/library/yql/sql + ydb/library/yql/utils/log + ydb/library/yql/core + ydb/library/yql/core/common_opt + ydb/library/yql/core/peephole_opt + ydb/library/yql/core/type_ann + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/result/expr_nodes +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/core/sql_types/ya.make b/ydb/library/yql/core/sql_types/ya.make new file mode 100644 index 00000000000..0c38562ebca --- /dev/null +++ b/ydb/library/yql/core/sql_types/ya.make @@ -0,0 +1,8 @@ +LIBRARY() + +SRCS( + simple_types.h + simple_types.cpp +) + +END() diff --git a/ydb/library/yql/core/type_ann/ya.make b/ydb/library/yql/core/type_ann/ya.make new file mode 100644 index 00000000000..0b911cab5d6 --- /dev/null +++ b/ydb/library/yql/core/type_ann/ya.make @@ -0,0 +1,40 @@ +LIBRARY() + +SRCS( + type_ann_blocks.cpp + type_ann_blocks.h + type_ann_columnorder.cpp + type_ann_columnorder.h + type_ann_core.cpp + type_ann_core.h + type_ann_expr.cpp + type_ann_expr.h + type_ann_impl.h + type_ann_join.cpp + type_ann_list.cpp + type_ann_list.h + type_ann_pg.cpp + type_ann_pg.h + type_ann_types.cpp + type_ann_types.h + type_ann_wide.cpp + type_ann_wide.h +) + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/minikql + ydb/library/yql/utils + ydb/library/yql/utils/log + ydb/library/yql/core + ydb/library/yql/core/expr_nodes + ydb/library/yql/core/issue + ydb/library/yql/core/issue/protos + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/parser/pg_catalog + ydb/library/yql/parser/pg_wrapper/interface +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/core/user_data/ya.make b/ydb/library/yql/core/user_data/ya.make new file mode 100644 index 00000000000..a73d75bae61 --- /dev/null +++ b/ydb/library/yql/core/user_data/ya.make @@ -0,0 +1,9 @@ +LIBRARY() + +SRCS( + yql_user_data.cpp +) + +GENERATE_ENUM_SERIALIZATION(yql_user_data.h) + +END() diff --git a/ydb/library/yql/core/ya.make b/ydb/library/yql/core/ya.make new file mode 100644 index 00000000000..47ca184f1a7 --- /dev/null +++ b/ydb/library/yql/core/ya.make @@ -0,0 +1,88 @@ +LIBRARY() + +SRCS( + yql_aggregate_expander.cpp + yql_atom_enums.h + yql_callable_transform.cpp + yql_callable_transform.h + yql_csv.cpp + yql_csv.h + yql_data_provider.h + yql_execution.cpp + yql_execution.h + yql_expr_constraint.cpp + yql_expr_constraint.h + yql_expr_csee.cpp + yql_expr_csee.h + yql_expr_optimize.cpp + yql_expr_optimize.h + yql_expr_type_annotation.cpp + yql_expr_type_annotation.h + yql_gc_transformer.cpp + yql_gc_transformer.h + yql_graph_transformer.cpp + yql_graph_transformer.h + yql_holding_file_storage.cpp + yql_holding_file_storage.h + yql_join.cpp + yql_join.h + yql_library_compiler.cpp + yql_opt_proposed_by_data.cpp + yql_opt_proposed_by_data.h + yql_opt_range.cpp + yql_opt_range.h + yql_opt_rewrite_io.cpp + yql_opt_rewrite_io.h + yql_opt_utils.cpp + yql_opt_utils.h + yql_opt_window.cpp + yql_opt_window.h + yql_type_annotation.cpp + yql_type_annotation.h + yql_type_helpers.cpp + yql_type_helpers.h + yql_udf_index.cpp + yql_udf_index.h + yql_udf_index_package_set.cpp + yql_udf_index_package_set.h + yql_udf_resolver.cpp + yql_udf_resolver.h + yql_user_data.cpp + yql_user_data.h + yql_user_data_storage.cpp + yql_user_data_storage.h +) + +PEERDIR( + library/cpp/enumbitset + library/cpp/random_provider + library/cpp/threading/future + library/cpp/time_provider + library/cpp/yson + library/cpp/yson/node + ydb/library/yql/ast + ydb/library/yql/core/file_storage + ydb/library/yql/core/sql_types + ydb/library/yql/core/credentials + ydb/library/yql/minikql + ydb/library/yql/protos + ydb/library/yql/public/udf + ydb/library/yql/public/udf/tz + ydb/library/yql/sql/settings + ydb/library/yql/utils + ydb/library/yql/utils/log + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/proto +) + +GENERATE_ENUM_SERIALIZATION(yql_data_provider.h) + +GENERATE_ENUM_SERIALIZATION(yql_user_data.h) + +GENERATE_ENUM_SERIALIZATION(yql_atom_enums.h) + +GENERATE_ENUM_SERIALIZATION(yql_type_annotation.h) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/dq/actors/compute/ut/ya.make b/ydb/library/yql/dq/actors/compute/ut/ya.make new file mode 100644 index 00000000000..6dfca084a03 --- /dev/null +++ b/ydb/library/yql/dq/actors/compute/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(ydb/library/yql/dq/actors/compute) + +SRCS( + dq_compute_issues_buffer_ut.cpp + dq_source_watermark_tracker_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest + ydb/library/yql/dq/actors + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +END() diff --git a/ydb/library/yql/dq/actors/compute/ya.make b/ydb/library/yql/dq/actors/compute/ya.make new file mode 100644 index 00000000000..7dc8051161e --- /dev/null +++ b/ydb/library/yql/dq/actors/compute/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +SRCS( + dq_async_compute_actor.cpp + dq_compute_actor_async_io_factory.cpp + dq_compute_actor_channels.cpp + dq_compute_actor_checkpoints.cpp + dq_compute_actor_metrics.cpp + dq_compute_actor_stats.cpp + dq_compute_actor_watermarks.cpp + dq_compute_actor.cpp + dq_compute_issues_buffer.cpp + retry_queue.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/protos + ydb/library/yql/dq/common + ydb/library/yql/dq/proto + ydb/library/yql/dq/runtime + ydb/library/yql/dq/tasks + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/dq/actors/protos/ya.make b/ydb/library/yql/dq/actors/protos/ya.make new file mode 100644 index 00000000000..1322584d462 --- /dev/null +++ b/ydb/library/yql/dq/actors/protos/ya.make @@ -0,0 +1,20 @@ +PROTO_LIBRARY() + +SRCS( + dq_events.proto + dq_stats.proto + dq_status_codes.proto +) + +PEERDIR( + library/cpp/actors/protos + ydb/public/api/protos + ydb/library/yql/core/issue/protos + ydb/library/yql/dq/proto + ydb/library/yql/public/issue/protos + ydb/library/yql/public/types +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/dq/actors/task_runner/ya.make b/ydb/library/yql/dq/actors/task_runner/ya.make new file mode 100644 index 00000000000..31f4b0b7907 --- /dev/null +++ b/ydb/library/yql/dq/actors/task_runner/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + events.cpp + task_runner_actor_local.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/library/yql/dq/runtime + ydb/library/yql/dq/common + ydb/library/yql/dq/proto + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/utils/actors + ydb/core/protos +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/dq/actors/ya.make b/ydb/library/yql/dq/actors/ya.make new file mode 100644 index 00000000000..731ece61cdb --- /dev/null +++ b/ydb/library/yql/dq/actors/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +GRPC() + +SRCS( + dq.cpp + dq_events_ids.cpp +) + +PEERDIR( + ydb/library/yql/dq/actors/protos +) + +END() + +RECURSE( + compute + protos + task_runner +) diff --git a/ydb/library/yql/dq/common/ya.make b/ydb/library/yql/dq/common/ya.make new file mode 100644 index 00000000000..6efb62ed746 --- /dev/null +++ b/ydb/library/yql/dq/common/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + ydb/library/mkql_proto/protos +) + +SRCS( + dq_common.cpp + dq_resource_quoter.h + dq_value.cpp +) + +GENERATE_ENUM_SERIALIZATION(dq_common.h) + +END() diff --git a/ydb/library/yql/dq/comp_nodes/ya.make b/ydb/library/yql/dq/comp_nodes/ya.make new file mode 100644 index 00000000000..24d17004a41 --- /dev/null +++ b/ydb/library/yql/dq/comp_nodes/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + ydb/library/yql/dq/actors/compute + ydb/library/yql/minikql/computation + ydb/library/yql/minikql + ydb/library/yql/utils +) + +SRCS( + yql_common_dq_factory.cpp +) + +YQL_LAST_ABI_VERSION() + + +END() + diff --git a/ydb/library/yql/dq/expr_nodes/ya.make b/ydb/library/yql/dq/expr_nodes/ya.make new file mode 100644 index 00000000000..a0726f53fc4 --- /dev/null +++ b/ydb/library/yql/dq/expr_nodes/ya.make @@ -0,0 +1,51 @@ +LIBRARY() + +SRCS( + dq_expr_nodes.h +) + +PEERDIR( + ydb/library/yql/core/expr_nodes +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + dq_expr_nodes.json + dq_expr_nodes.gen.h + dq_expr_nodes.decl.inl.h + dq_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN dq_expr_nodes.json + OUT dq_expr_nodes.gen.h + OUT dq_expr_nodes.decl.inl.h + OUT dq_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + dq_expr_nodes.json + dq_expr_nodes.gen.h + dq_expr_nodes.decl.inl.h + dq_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN dq_expr_nodes.json + OUT dq_expr_nodes.gen.h + OUT dq_expr_nodes.decl.inl.h + OUT dq_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/dq/integration/transform/ya.make b/ydb/library/yql/dq/integration/transform/ya.make new file mode 100644 index 00000000000..e2add2e520c --- /dev/null +++ b/ydb/library/yql/dq/integration/transform/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + yql_dq_task_transform.cpp +) + +PEERDIR( + ydb/library/yql/minikql +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/dq/integration/ya.make b/ydb/library/yql/dq/integration/ya.make new file mode 100644 index 00000000000..f57695f542f --- /dev/null +++ b/ydb/library/yql/dq/integration/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + yql_dq_integration.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/yson + ydb/library/yql/ast + ydb/library/yql/core + ydb/library/yql/dq/tasks +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + transform +) diff --git a/ydb/library/yql/dq/opt/ya.make b/ydb/library/yql/dq/opt/ya.make new file mode 100644 index 00000000000..074847336ab --- /dev/null +++ b/ydb/library/yql/dq/opt/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/core + ydb/library/yql/dq/common + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/integration + ydb/library/yql/dq/proto + ydb/library/yql/dq/type_ann + ydb/library/yql/providers/dq/expr_nodes +) + +SRCS( + dq_opt.cpp + dq_opt_build.cpp + dq_opt_join.cpp + dq_opt_log.cpp + dq_opt_peephole.cpp + dq_opt_phy_finalizing.cpp + dq_opt_phy.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/dq/proto/ya.make b/ydb/library/yql/dq/proto/ya.make new file mode 100644 index 00000000000..8f420a22455 --- /dev/null +++ b/ydb/library/yql/dq/proto/ya.make @@ -0,0 +1,16 @@ +PROTO_LIBRARY() + +PEERDIR( + library/cpp/actors/protos +) + +SRCS( + dq_checkpoint.proto + dq_state_load_plan.proto + dq_tasks.proto + dq_transport.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/dq/runtime/ut/ya.make b/ydb/library/yql/dq/runtime/ut/ya.make new file mode 100644 index 00000000000..82182c7258a --- /dev/null +++ b/ydb/library/yql/dq/runtime/ut/ya.make @@ -0,0 +1,23 @@ +UNITTEST_FOR(ydb/library/yql/dq/runtime) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + dq_arrow_helpers_ut.cpp + dq_output_channel_ut.cpp + ut_helper.cpp +) + +PEERDIR( + library/cpp/testing/unittest + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/dq/runtime/ya.make b/ydb/library/yql/dq/runtime/ya.make new file mode 100644 index 00000000000..ac0d1af1ed1 --- /dev/null +++ b/ydb/library/yql/dq/runtime/ya.make @@ -0,0 +1,42 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/util + ydb/library/mkql_proto + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/public/udf + ydb/library/yql/dq/actors/protos + ydb/library/yql/dq/common + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/type_ann + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/providers/common/schema/mkql + ydb/library/yql/minikql/comp_nodes +) + +SRCS( + dq_arrow_helpers.cpp + dq_async_input.cpp + dq_async_output.cpp + dq_columns_resolve.cpp + dq_compute.cpp + dq_input_channel.cpp + dq_input_producer.cpp + dq_output_channel.cpp + dq_output_consumer.cpp + dq_tasks_runner.cpp + dq_transport.cpp +) + +GENERATE_ENUM_SERIALIZATION(dq_tasks_runner.h) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/dq/state/ut/ya.make b/ydb/library/yql/dq/state/ut/ya.make new file mode 100644 index 00000000000..3da30e1dd45 --- /dev/null +++ b/ydb/library/yql/dq/state/ut/ya.make @@ -0,0 +1,9 @@ +UNITTEST_FOR(ydb/library/yql/dq/state) + +SRCS( + dq_state_load_plan_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/dq/state/ya.make b/ydb/library/yql/dq/state/ya.make new file mode 100644 index 00000000000..8199a91a88a --- /dev/null +++ b/ydb/library/yql/dq/state/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/public/issue + ydb/library/yql/core/issue/protos + ydb/library/yql/dq/proto + ydb/library/yql/providers/pq/proto + ydb/library/yql/providers/pq/task_meta +) + +SRCS( + dq_state_load_plan.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/dq/tasks/ya.make b/ydb/library/yql/dq/tasks/ya.make new file mode 100644 index 00000000000..df1e99753c7 --- /dev/null +++ b/ydb/library/yql/dq/tasks/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/core + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/proto + ydb/library/yql/ast +) + +SRCS( + dq_task_program.cpp +) + + + YQL_LAST_ABI_VERSION() + + +END() diff --git a/ydb/library/yql/dq/transform/ya.make b/ydb/library/yql/dq/transform/ya.make new file mode 100644 index 00000000000..70a2bfdf900 --- /dev/null +++ b/ydb/library/yql/dq/transform/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + ydb/library/yql/dq/integration/transform + ydb/library/yql/minikql/computation + ydb/library/yql/minikql + ydb/library/yql/utils +) + +SRCS( + yql_common_dq_transform.cpp +) + +YQL_LAST_ABI_VERSION() + + +END() diff --git a/ydb/library/yql/dq/type_ann/ya.make b/ydb/library/yql/dq/type_ann/ya.make new file mode 100644 index 00000000000..cb0daa7629e --- /dev/null +++ b/ydb/library/yql/dq/type_ann/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/proto + ydb/library/yql/providers/common/provider +) + +SRCS( + dq_type_ann.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/dq/ya.make b/ydb/library/yql/dq/ya.make new file mode 100644 index 00000000000..45e49415c45 --- /dev/null +++ b/ydb/library/yql/dq/ya.make @@ -0,0 +1,14 @@ +RECURSE( + actors + common + comp_nodes + expr_nodes + integration + opt + proto + runtime + state + tasks + transform + type_ann +) diff --git a/ydb/library/yql/minikql/arrow/ut/ya.make b/ydb/library/yql/minikql/arrow/ut/ya.make new file mode 100644 index 00000000000..8135fe38153 --- /dev/null +++ b/ydb/library/yql/minikql/arrow/ut/ya.make @@ -0,0 +1,25 @@ +UNITTEST_FOR(ydb/library/yql/minikql/arrow) + +TIMEOUT(600) +SIZE(MEDIUM) + +SRCS( + mkql_functions_ut.cpp +) + +PEERDIR( + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +IF (MKQL_RUNTIME_VERSION) + CFLAGS( + -DMKQL_RUNTIME_VERSION=$MKQL_RUNTIME_VERSION + ) +ENDIF() + + +END() diff --git a/ydb/library/yql/minikql/arrow/ya.make b/ydb/library/yql/minikql/arrow/ya.make new file mode 100644 index 00000000000..bc5092a746d --- /dev/null +++ b/ydb/library/yql/minikql/arrow/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + arrow_util.cpp + mkql_functions.cpp + mkql_memory_pool.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/library/yql/minikql + ydb/library/yql/public/udf/arrow +) + +IF (MKQL_RUNTIME_VERSION) + CFLAGS(-DMKQL_RUNTIME_VERSION=$MKQL_RUNTIME_VERSION) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/minikql/benchmark/pack_num/metrics/ya.make b/ydb/library/yql/minikql/benchmark/pack_num/metrics/ya.make new file mode 100644 index 00000000000..3eb15405364 --- /dev/null +++ b/ydb/library/yql/minikql/benchmark/pack_num/metrics/ya.make @@ -0,0 +1,19 @@ +PY2TEST() + +SIZE(LARGE) + +TAG( + ya:force_sandbox + sb:intel_e5_2660v1 + ya:fat +) + +TEST_SRCS( + main.py +) + +DEPENDS( + ydb/library/yql/minikql/benchmark/pack_num +) + +END() diff --git a/ydb/library/yql/minikql/benchmark/pack_num/ya.make b/ydb/library/yql/minikql/benchmark/pack_num/ya.make new file mode 100644 index 00000000000..4f3f84c63d9 --- /dev/null +++ b/ydb/library/yql/minikql/benchmark/pack_num/ya.make @@ -0,0 +1,15 @@ +Y_BENCHMARK() + +ALLOCATOR(B) + +PEERDIR( + ydb/library/yql/minikql + library/cpp/packedtypes +) + +SRCS( + pack.cpp + pack_num_bench.cpp +) + +END() diff --git a/ydb/library/yql/minikql/benchmark/ya.make b/ydb/library/yql/minikql/benchmark/ya.make new file mode 100644 index 00000000000..97c1d2814b1 --- /dev/null +++ b/ydb/library/yql/minikql/benchmark/ya.make @@ -0,0 +1,4 @@ +RECURSE( + pack_num + pack_num/metrics +) diff --git a/ydb/library/yql/minikql/codegen/ut/ya.make b/ydb/library/yql/minikql/codegen/ut/ya.make new file mode 100644 index 00000000000..bc942549b1a --- /dev/null +++ b/ydb/library/yql/minikql/codegen/ut/ya.make @@ -0,0 +1,45 @@ +UNITTEST_FOR(ydb/library/yql/minikql/codegen) + +NO_COMPILER_WARNINGS() + +SRCS( + codegen_ut.cpp +) + +IF (OS_WINDOWS) + LLVM_BC( + fib.cpp + sum_sqr.cpp + sum_sqr2.cpp + str.cpp + 128_bit.cpp + 128_bit_win.ll + NAME Funcs + SYMBOLS + fib + sum_sqr + sum_sqr2 + sum_sqr_128 + sum_sqr_128_ir + str_size + ) +ELSE() + LLVM_BC( + fib.cpp + sum_sqr.cpp + sum_sqr2.cpp + str.cpp + 128_bit.cpp + 128_bit.ll + NAME Funcs + SYMBOLS + fib + sum_sqr + sum_sqr2 + sum_sqr_128 + sum_sqr_128_ir + str_size + ) +ENDIF() + +END() diff --git a/ydb/library/yql/minikql/codegen/ya.make b/ydb/library/yql/minikql/codegen/ya.make new file mode 100644 index 00000000000..fc5ba7756b6 --- /dev/null +++ b/ydb/library/yql/minikql/codegen/ya.make @@ -0,0 +1,41 @@ +LIBRARY() + +SRCS( + codegen.cpp +) + +NO_COMPILER_WARNINGS() + +IF (NOT WINDOWS) + PEERDIR( + contrib/libs/cxxsupp/builtins + ) +ELSE() + PEERDIR( + ydb/library/yql/public/decimal + ) +ENDIF() + +PEERDIR( + contrib/libs/re2 + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Target/X86/Disassembler + contrib/libs/llvm12/lib/Transforms/IPO + contrib/libs/llvm12/lib/Transforms/ObjCARC +) + +IF (OS_LINUX) + PEERDIR( + contrib/libs/llvm12/lib/ExecutionEngine/PerfJITEvents + ) +ENDIF() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/minikql/comp_nodes/ut/ya.make b/ydb/library/yql/minikql/comp_nodes/ut/ya.make new file mode 100644 index 00000000000..a343df3736e --- /dev/null +++ b/ydb/library/yql/minikql/comp_nodes/ut/ya.make @@ -0,0 +1,78 @@ +UNITTEST_FOR(ydb/library/yql/minikql/comp_nodes) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + mkql_test_factory.cpp + mkql_bit_utils_ut.cpp + mkql_block_compress_ut.cpp + mkql_block_skiptake_ut.cpp + mkql_blocks_ut.cpp + mkql_combine_ut.cpp + mkql_condense_ut.cpp + mkql_decimal_ut.cpp + mkql_chain_map_ut.cpp + mkql_chopper_ut.cpp + mkql_filters_ut.cpp + mkql_flatmap_ut.cpp + mkql_fromstring_ut.cpp + mkql_multihopping_saveload_ut.cpp + mkql_multihopping_ut.cpp + mkql_multimap_ut.cpp + mkql_fold_ut.cpp + mkql_heap_ut.cpp + mkql_compare_ut.cpp + mkql_computation_node_ut.cpp + mkql_group_ut.cpp + mkql_dict_ut.cpp + mkql_join_ut.cpp + mkql_join_dict_ut.cpp + mkql_grace_join_ut.cpp + mkql_map_join_ut.cpp + mkql_safe_circular_buffer_ut.cpp + mkql_sort_ut.cpp + mkql_switch_ut.cpp + mkql_todict_ut.cpp + mkql_variant_ut.cpp + mkql_wide_chain_map_ut.cpp + mkql_wide_chopper_ut.cpp + mkql_wide_combine_ut.cpp + mkql_wide_condense_ut.cpp + mkql_wide_filter_ut.cpp + mkql_wide_map_ut.cpp + mkql_wide_nodes_ut.cpp + mkql_wide_stream_ut.cpp + mkql_wide_top_sort_ut.cpp + mkql_listfromrange_ut.cpp + mkql_mapnext_ut.cpp + mkql_rh_hash_ut.cpp +) + +PEERDIR( + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf + ydb/library/yql/public/udf/arrow + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +IF (MKQL_RUNTIME_VERSION) + CFLAGS( + -DMKQL_RUNTIME_VERSION=$MKQL_RUNTIME_VERSION + ) +ENDIF() + +END() diff --git a/ydb/library/yql/minikql/comp_nodes/ya.make b/ydb/library/yql/minikql/comp_nodes/ya.make new file mode 100644 index 00000000000..e3ac58d9a37 --- /dev/null +++ b/ydb/library/yql/minikql/comp_nodes/ya.make @@ -0,0 +1,292 @@ +LIBRARY() + +SRCS( + mkql_addmember.cpp + mkql_addmember.h + mkql_aggrcount.cpp + mkql_aggrcount.h + mkql_append.cpp + mkql_append.h + mkql_apply.cpp + mkql_apply.h + mkql_block_agg.cpp + mkql_block_agg.h + mkql_block_agg_count.cpp + mkql_block_agg_count.h + mkql_block_agg_factory.cpp + mkql_block_agg_factory.h + mkql_block_agg_minmax.cpp + mkql_block_agg_minmax.h + mkql_block_agg_some.cpp + mkql_block_agg_some.h + mkql_block_agg_sum.cpp + mkql_block_agg_sum.h + mkql_block_builder.cpp + mkql_block_builder.h + mkql_block_coalesce.cpp + mkql_block_coalesce.h + mkql_block_if.cpp + mkql_block_if.h + mkql_block_impl.cpp + mkql_block_impl.h + mkql_block_just.cpp + mkql_block_just.h + mkql_block_logical.cpp + mkql_block_logical.h + mkql_block_compress.cpp + mkql_block_compress.h + mkql_block_func.cpp + mkql_block_func.h + mkql_block_reader.cpp + mkql_block_reader.h + mkql_block_skiptake.cpp + mkql_block_skiptake.h + mkql_block_top.cpp + mkql_block_top.h + mkql_block_tuple.cpp + mkql_block_tuple.h + mkql_blocks.cpp + mkql_blocks.h + mkql_callable.cpp + mkql_callable.h + mkql_chain_map.cpp + mkql_chain_map.h + mkql_chain1_map.cpp + mkql_chain1_map.h + mkql_check_args.cpp + mkql_check_args.h + mkql_chopper.cpp + mkql_chopper.h + mkql_coalesce.cpp + mkql_coalesce.h + mkql_collect.cpp + mkql_collect.h + mkql_combine.cpp + mkql_combine.h + mkql_contains.cpp + mkql_contains.h + mkql_decimal_div.cpp + mkql_decimal_div.h + mkql_decimal_mod.cpp + mkql_decimal_mod.h + mkql_decimal_mul.cpp + mkql_decimal_mul.h + mkql_dictitems.cpp + mkql_dictitems.h + mkql_discard.cpp + mkql_discard.h + mkql_element.cpp + mkql_element.h + mkql_ensure.h + mkql_ensure.cpp + mkql_enumerate.cpp + mkql_enumerate.h + mkql_exists.cpp + mkql_exists.h + mkql_extend.cpp + mkql_extend.h + mkql_factories.h + mkql_factory.cpp + mkql_filter.cpp + mkql_filter.h + mkql_flatmap.cpp + mkql_flatmap.h + mkql_flow.cpp + mkql_flow.h + mkql_fold.cpp + mkql_fold.h + mkql_fold1.cpp + mkql_fold1.h + mkql_frombytes.cpp + mkql_frombytes.h + mkql_fromstring.cpp + mkql_fromstring.h + mkql_fromyson.cpp + mkql_fromyson.h + mkql_group.cpp + mkql_group.h + mkql_grace_join.cpp + mkql_grace_join.h + mkql_grace_join_imp.cpp + mkql_grace_join_imp.h + mkql_guess.cpp + mkql_guess.h + mkql_hasitems.cpp + mkql_hasitems.h + mkql_heap.cpp + mkql_heap.h + mkql_hopping.cpp + mkql_hopping.h + mkql_if.cpp + mkql_if.h + mkql_ifpresent.cpp + mkql_ifpresent.h + mkql_invoke.cpp + mkql_invoke.h + mkql_iterable.cpp + mkql_iterable.h + mkql_iterator.cpp + mkql_iterator.h + mkql_join.cpp + mkql_join.h + mkql_join_dict.cpp + mkql_join_dict.h + mkql_lazy_list.cpp + mkql_lazy_list.h + mkql_length.cpp + mkql_length.h + mkql_listfromrange.cpp + mkql_listfromrange.h + mkql_llvm_base.cpp + mkql_logical.cpp + mkql_logical.h + mkql_lookup.cpp + mkql_lookup.h + mkql_map.cpp + mkql_map.h + mkql_mapnext.cpp + mkql_mapnext.h + mkql_map_join.cpp + mkql_map_join.h + mkql_multihopping.cpp + mkql_multihopping.h + mkql_multimap.cpp + mkql_multimap.h + mkql_next_value.cpp + mkql_next_value.h + mkql_nop.cpp + mkql_nop.h + mkql_now.cpp + mkql_now.h + mkql_null.cpp + mkql_null.h + mkql_pickle.cpp + mkql_pickle.h + mkql_prepend.cpp + mkql_prepend.h + mkql_queue.cpp + mkql_queue.h + mkql_random.cpp + mkql_random.h + mkql_range.cpp + mkql_range.h + mkql_reduce.cpp + mkql_reduce.h + mkql_removemember.cpp + mkql_removemember.h + mkql_replicate.cpp + mkql_replicate.h + mkql_reverse.cpp + mkql_reverse.h + mkql_rh_hash.cpp + mkql_rh_hash.h + mkql_round.cpp + mkql_round.h + mkql_safe_circular_buffer.cpp + mkql_safe_circular_buffer.h + mkql_saveload.h + mkql_seq.cpp + mkql_seq.h + mkql_size.cpp + mkql_size.h + mkql_skip.cpp + mkql_skip.h + mkql_sort.cpp + mkql_sort.h + mkql_source.cpp + mkql_source.h + mkql_squeeze_state.cpp + mkql_squeeze_state.h + mkql_squeeze_to_list.cpp + mkql_squeeze_to_list.h + mkql_condense.cpp + mkql_condense.h + mkql_condense1.cpp + mkql_condense1.h + mkql_switch.cpp + mkql_switch.h + mkql_take.cpp + mkql_take.h + mkql_timezone.cpp + mkql_timezone.h + mkql_tobytes.cpp + mkql_tobytes.h + mkql_todict.cpp + mkql_todict.h + mkql_toindexdict.cpp + mkql_toindexdict.h + mkql_tooptional.cpp + mkql_tooptional.h + mkql_tostring.cpp + mkql_tostring.h + mkql_udf.cpp + mkql_udf.h + mkql_unwrap.cpp + mkql_unwrap.h + mkql_varitem.cpp + mkql_varitem.h + mkql_visitall.cpp + mkql_visitall.h + mkql_way.cpp + mkql_way.h + mkql_weakmember.cpp + mkql_weakmember.h + mkql_while.cpp + mkql_while.h + mkql_wide_chain_map.cpp + mkql_wide_chain_map.h + mkql_wide_chopper.cpp + mkql_wide_chopper.h + mkql_wide_combine.cpp + mkql_wide_combine.h + mkql_wide_condense.cpp + mkql_wide_condense.h + mkql_wide_filter.cpp + mkql_wide_filter.h + mkql_wide_map.cpp + mkql_wide_map.h + mkql_wide_top_sort.cpp + mkql_wide_top_sort.h + mkql_withcontext.cpp + mkql_withcontext.h + mkql_zip.cpp + mkql_zip.h +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/library/binary_json + ydb/library/yql/minikql + ydb/library/yql/minikql/arrow + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf/arrow + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/utils + library/cpp/actors/core +) + +NO_COMPILER_WARNINGS() + +IF (NOT MKQL_DISABLE_CODEGEN) + PEERDIR( + ydb/library/yql/minikql/codegen + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Transforms/IPO + ) +ELSE() + CFLAGS( + -DMKQL_DISABLE_CODEGEN + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/minikql/computation/ut/ya.make b/ydb/library/yql/minikql/computation/ut/ya.make new file mode 100644 index 00000000000..ca3e0dc0942 --- /dev/null +++ b/ydb/library/yql/minikql/computation/ut/ya.make @@ -0,0 +1,36 @@ +UNITTEST_FOR(ydb/library/yql/minikql/computation) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + mkql_computation_node_pack_ut.cpp + mkql_computation_node_list_ut.cpp + mkql_computation_node_dict_ut.cpp + mkql_computation_node_graph_saveload_ut.cpp + mkql_computation_pattern_cache_ut.cpp + mkql_validate_ut.cpp + mkql_value_builder_ut.cpp + presort_ut.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + library/cpp/threading/local_executor + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/parser/pg_wrapper + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/dq/proto +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/minikql/computation/ya.make b/ydb/library/yql/minikql/computation/ya.make new file mode 100644 index 00000000000..2a76028da41 --- /dev/null +++ b/ydb/library/yql/minikql/computation/ya.make @@ -0,0 +1,66 @@ +LIBRARY() + +SRCS( + mkql_computation_node.cpp + mkql_computation_node.h + mkql_computation_node_codegen.h + mkql_computation_node_codegen.cpp + mkql_computation_node_graph.cpp + mkql_computation_node_graph_saveload.cpp + mkql_computation_node_graph_saveload.h + mkql_computation_node_holders.cpp + mkql_computation_node_impl.h + mkql_computation_node_impl.cpp + mkql_computation_node_list.h + mkql_computation_node_pack.cpp + mkql_computation_node_pack_impl.cpp + mkql_computation_node_pack.h + mkql_computation_node_pack_impl.h + mkql_custom_list.cpp + mkql_custom_list.h + mkql_validate.cpp + mkql_validate.h + mkql_value_builder.cpp + mkql_value_builder.h + presort.h + presort.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + library/cpp/enumbitset + library/cpp/packedtypes + library/cpp/random_provider + library/cpp/time_provider + ydb/library/yql/minikql + ydb/library/yql/minikql/arrow + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/public/udf + ydb/library/yql/utils + library/cpp/threading/future +) + +IF (NOT MKQL_DISABLE_CODEGEN) + NO_COMPILER_WARNINGS() + PEERDIR( + ydb/library/yql/minikql/codegen + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Transforms/IPO + ) +ELSE() + CFLAGS( + -DMKQL_DISABLE_CODEGEN + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/minikql/datetime/ya.make b/ydb/library/yql/minikql/datetime/ya.make new file mode 100644 index 00000000000..6bbfe601c1c --- /dev/null +++ b/ydb/library/yql/minikql/datetime/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + datetime.cpp +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/computation +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/minikql/dom/ut/ya.make b/ydb/library/yql/minikql/dom/ut/ya.make new file mode 100644 index 00000000000..462ce79f631 --- /dev/null +++ b/ydb/library/yql/minikql/dom/ut/ya.make @@ -0,0 +1,22 @@ +IF (NOT WINDOWS) + UNITTEST_FOR(yql/library/dom) + + SRCS( + yson_ut.cpp + json_ut.cpp + ) + + IF (SANITIZER_TYPE) + SIZE(MEDIUM) + TIMEOUT(600) + ENDIF() + + PEERDIR( + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf/service/exception_policy + ) + + YQL_LAST_ABI_VERSION() + + END() +ENDIF() diff --git a/ydb/library/yql/minikql/dom/ya.make b/ydb/library/yql/minikql/dom/ya.make new file mode 100644 index 00000000000..73648dcf8f4 --- /dev/null +++ b/ydb/library/yql/minikql/dom/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +YQL_ABI_VERSION(2 28 0) + +PEERDIR( + library/cpp/containers/stack_vector + library/cpp/json + library/cpp/yson_pull + ydb/library/yql/public/udf + ydb/library/yql/utils +) + +SRCS( + node.cpp + json.cpp + yson.cpp + make.cpp + peel.cpp + hash.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/minikql/invoke_builtins/ut/ya.make b/ydb/library/yql/minikql/invoke_builtins/ut/ya.make new file mode 100644 index 00000000000..de34900daea --- /dev/null +++ b/ydb/library/yql/minikql/invoke_builtins/ut/ya.make @@ -0,0 +1,27 @@ +UNITTEST_FOR(ydb/library/yql/minikql/invoke_builtins) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + mkql_builtins_ut.cpp +) + +END() diff --git a/ydb/library/yql/minikql/invoke_builtins/ya.make b/ydb/library/yql/minikql/invoke_builtins/ya.make new file mode 100644 index 00000000000..4e33f1b42f2 --- /dev/null +++ b/ydb/library/yql/minikql/invoke_builtins/ya.make @@ -0,0 +1,80 @@ +LIBRARY() + +SRCS( + mkql_builtins.cpp + mkql_builtins.h + mkql_builtins_abs.cpp + mkql_builtins_add.cpp + mkql_builtins_bitand.cpp + mkql_builtins_bitnot.cpp + mkql_builtins_bitor.cpp + mkql_builtins_bitxor.cpp + mkql_builtins_byteat.cpp + mkql_builtins_codegen.cpp + mkql_builtins_concat.cpp + mkql_builtins_convert.cpp + mkql_builtins_countbits.cpp + mkql_builtins_decimal.cpp + mkql_builtins_dec.cpp + mkql_builtins_div.cpp + mkql_builtins_find.cpp + mkql_builtins_impl.h + mkql_builtins_inc.cpp + mkql_builtins_invprestr.cpp + mkql_builtins_max.cpp + mkql_builtins_min.cpp + mkql_builtins_minus.cpp + mkql_builtins_mod.cpp + mkql_builtins_mul.cpp + mkql_builtins_nanvl.cpp + mkql_builtins_plus.cpp + mkql_builtins_rotleft.cpp + mkql_builtins_rotright.cpp + mkql_builtins_shiftleft.cpp + mkql_builtins_shiftright.cpp + mkql_builtins_string_kernels.cpp + mkql_builtins_sub.cpp + mkql_builtins_substring.cpp + mkql_builtins_with.cpp + mkql_builtins_equals.cpp + mkql_builtins_not_equals.cpp + mkql_builtins_less.cpp + mkql_builtins_less_or_equal.cpp + mkql_builtins_greater.cpp + mkql_builtins_greater_or_equal.cpp +) + +PEERDIR( + library/cpp/pop_count + ydb/library/binary_json + ydb/library/yql/minikql + ydb/library/yql/minikql/arrow + ydb/library/yql/minikql/computation + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/public/udf + contrib/libs/apache/arrow +) + +IF (NOT MKQL_DISABLE_CODEGEN) + PEERDIR( + ydb/library/yql/minikql/codegen + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Transforms/IPO + ) +ELSE() + CFLAGS( + -DMKQL_DISABLE_CODEGEN + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/minikql/jsonpath/benchmark/ya.make b/ydb/library/yql/minikql/jsonpath/benchmark/ya.make new file mode 100644 index 00000000000..279fb94a307 --- /dev/null +++ b/ydb/library/yql/minikql/jsonpath/benchmark/ya.make @@ -0,0 +1,21 @@ +Y_BENCHMARK(jsonpath-benchmark) + +PEERDIR( + library/cpp/json + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/dom + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/minikql/jsonpath + ydb/library/yql/public/issue + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + main.cpp +) + +END() diff --git a/ydb/library/yql/minikql/jsonpath/ut/ya.make b/ydb/library/yql/minikql/jsonpath/ut/ya.make new file mode 100644 index 00000000000..2d34544b601 --- /dev/null +++ b/ydb/library/yql/minikql/jsonpath/ut/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/library/yql/minikql/jsonpath) + + + +SRCS( + common_ut.cpp + examples_ut.cpp + lax_ut.cpp + strict_ut.cpp + test_base.cpp + lib_id_ut.cpp +) + +PEERDIR( + library/cpp/json + ydb/library/binary_json + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/dom + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/core/issue/protos + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/minikql/jsonpath/ya.make b/ydb/library/yql/minikql/jsonpath/ya.make new file mode 100644 index 00000000000..de4f2682b6c --- /dev/null +++ b/ydb/library/yql/minikql/jsonpath/ya.make @@ -0,0 +1,57 @@ +LIBRARY() + +YQL_ABI_VERSION( + 2 + 27 + 0 +) + +IF (ARCH_X86_64) + CFLAGS( + -DYDB_REWRAPPER_LIB_ID=kHyperscan + ) + + PEERDIR( + ydb/library/rewrapper/hyperscan + ) + +ELSE() + CFLAGS( + -DYDB_REWRAPPER_LIB_ID=kRe2 + ) + +ENDIF() + +PEERDIR( + contrib/libs/double-conversion + library/cpp/json + ydb/library/rewrapper/re2 + ydb/library/rewrapper + ydb/library/binary_json + ydb/library/yql/minikql/dom + ydb/library/yql/public/issue + ydb/library/yql/public/udf + ydb/library/yql/utils + ydb/library/yql/core/issue/protos + ydb/library/yql/parser/proto_ast + ydb/library/yql/parser/proto_ast/gen/jsonpath +) + +SRCS( + ast_builder.cpp + ast_nodes.cpp + binary.cpp + executor.cpp + jsonpath.cpp + parse_double.cpp + type_check.cpp + value.cpp +) + +GENERATE_ENUM_SERIALIZATION(ast_nodes.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/minikql/perf/alloc/ya.make b/ydb/library/yql/minikql/perf/alloc/ya.make new file mode 100644 index 00000000000..41d22cc2a74 --- /dev/null +++ b/ydb/library/yql/minikql/perf/alloc/ya.make @@ -0,0 +1,16 @@ +PROGRAM() + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +SRCS( + alloc.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/minikql/perf/mt_param/ya.make b/ydb/library/yql/minikql/perf/mt_param/ya.make new file mode 100644 index 00000000000..567dd533296 --- /dev/null +++ b/ydb/library/yql/minikql/perf/mt_param/ya.make @@ -0,0 +1,19 @@ +PROGRAM() + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + mt_param.cpp +) + +END() diff --git a/ydb/library/yql/minikql/perf/packer/ya.make b/ydb/library/yql/minikql/perf/packer/ya.make new file mode 100644 index 00000000000..524bbe09dad --- /dev/null +++ b/ydb/library/yql/minikql/perf/packer/ya.make @@ -0,0 +1,21 @@ +PROGRAM() + +ALLOCATOR(J) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + packer.cpp +) + +END() diff --git a/ydb/library/yql/minikql/perf/param/ya.make b/ydb/library/yql/minikql/perf/param/ya.make new file mode 100644 index 00000000000..7ea037c2a0b --- /dev/null +++ b/ydb/library/yql/minikql/perf/param/ya.make @@ -0,0 +1,19 @@ +PROGRAM() + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + param.cpp +) + +END() diff --git a/ydb/library/yql/minikql/perf/presort/ya.make b/ydb/library/yql/minikql/perf/presort/ya.make new file mode 100644 index 00000000000..931589f73ec --- /dev/null +++ b/ydb/library/yql/minikql/perf/presort/ya.make @@ -0,0 +1,19 @@ +PROGRAM() + +PEERDIR( + library/cpp/presort + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +SRCS( + presort.cpp +) + +END() diff --git a/ydb/library/yql/minikql/ut/ya.make b/ydb/library/yql/minikql/ut/ya.make new file mode 100644 index 00000000000..8635b2b90c4 --- /dev/null +++ b/ydb/library/yql/minikql/ut/ya.make @@ -0,0 +1,40 @@ +UNITTEST_FOR(ydb/library/yql/minikql) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + compact_hash_ut.cpp + mkql_alloc_ut.cpp + mkql_node_builder_ut.cpp + mkql_node_cast_ut.cpp + mkql_node_printer_ut.cpp + mkql_node_ut.cpp + mkql_opt_literal_ut.cpp + mkql_stats_registry_ut.cpp + mkql_string_util_ut.cpp + mkql_type_builder_ut.cpp + mkql_type_ops_ut.cpp + pack_num_ut.cpp + watermark_tracker_ut.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/parser/pg_wrapper + ydb/library/yql/public/udf/service/exception_policy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/minikql/ya.make b/ydb/library/yql/minikql/ya.make new file mode 100644 index 00000000000..fd1ef197f08 --- /dev/null +++ b/ydb/library/yql/minikql/ya.make @@ -0,0 +1,88 @@ +LIBRARY() + +SRCS( + aligned_page_pool.cpp + aligned_page_pool.h + compact_hash.cpp + compact_hash.h + defs.h + mkql_alloc.cpp + mkql_buffer.cpp + mkql_buffer.h + mkql_function_metadata.cpp + mkql_function_metadata.h + mkql_function_registry.cpp + mkql_function_registry.h + mkql_node.cpp + mkql_node.h + mkql_node_builder.cpp + mkql_node_builder.h + mkql_node_cast.cpp + mkql_node_cast.h + mkql_node_printer.cpp + mkql_node_printer.h + mkql_node_serialization.cpp + mkql_node_serialization.h + mkql_node_visitor.cpp + mkql_node_visitor.h + mkql_opt_literal.cpp + mkql_opt_literal.h + mkql_program_builder.cpp + mkql_program_builder.h + mkql_runtime_version.cpp + mkql_runtime_version.h + mkql_stats_registry.cpp + mkql_string_util.cpp + mkql_string_util.h + mkql_terminator.cpp + mkql_terminator.h + mkql_type_builder.cpp + mkql_type_builder.h + mkql_type_ops.cpp + mkql_type_ops.h + mkql_watermark.h + mkql_unboxed_value_stream.cpp + mkql_unboxed_value_stream.h + pack_num.cpp + pack_num.h + primes.cpp + primes.h + watermark_tracker.cpp + watermark_tracker.h +) + +PEERDIR( + contrib/libs/apache/arrow + contrib/libs/cctz/tzdata + library/cpp/actors/util + library/cpp/deprecated/enum_codegen + library/cpp/enumbitset + library/cpp/monlib/dynamic_counters + library/cpp/packedtypes + library/cpp/resource + library/cpp/yson + ydb/library/binary_json + ydb/library/dynumber + ydb/library/yql/minikql/dom + ydb/library/yql/parser/pg_catalog + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/public/udf + ydb/library/yql/public/udf/tz + ydb/library/yql/utils + ydb/library/uuid + ydb/public/lib/scheme_types +) + +IF (MKQL_RUNTIME_VERSION) + CFLAGS( + -DMKQL_RUNTIME_VERSION=$MKQL_RUNTIME_VERSION + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/parser/lexer_common/ut/ya.make b/ydb/library/yql/parser/lexer_common/ut/ya.make new file mode 100644 index 00000000000..112da0f8a49 --- /dev/null +++ b/ydb/library/yql/parser/lexer_common/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/library/yql/parser/lexer_common) + +PEERDIR( + ydb/library/yql/sql/v1/lexer +) + + +SRCS( + hints_ut.cpp + parse_hints_ut.cpp +) + +END() diff --git a/ydb/library/yql/parser/lexer_common/ya.make b/ydb/library/yql/parser/lexer_common/ya.make new file mode 100644 index 00000000000..2ebe809d2a5 --- /dev/null +++ b/ydb/library/yql/parser/lexer_common/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/public/issue +) + +SRCS( + tokens.cpp + lexer.h + hints.cpp + hints.h + parse_hints_impl.cpp + parse_hints_impl.h +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/parser/pg_catalog/ut/ya.make b/ydb/library/yql/parser/pg_catalog/ut/ya.make new file mode 100644 index 00000000000..975962653d2 --- /dev/null +++ b/ydb/library/yql/parser/pg_catalog/ut/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/library/yql/parser/pg_catalog) + +SRCS( + catalog_ut.cpp + catalog_consts_ut.cpp +) + +ADDINCL( + ydb/library/yql/parser/pg_wrapper/postgresql/src/include +) + +PEERDIR( + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/parser/pg_wrapper +) + +YQL_LAST_ABI_VERSION() + +IF (MKQL_RUNTIME_VERSION) + CFLAGS( + -DMKQL_RUNTIME_VERSION=$MKQL_RUNTIME_VERSION + ) +ENDIF() + +END() diff --git a/ydb/library/yql/parser/pg_catalog/ya.make b/ydb/library/yql/parser/pg_catalog/ya.make new file mode 100644 index 00000000000..4357dcf0379 --- /dev/null +++ b/ydb/library/yql/parser/pg_catalog/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_operator.dat pg_operator.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_proc.dat pg_proc.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_type.dat pg_type.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_cast.dat pg_cast.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_aggregate.dat pg_aggregate.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_opfamily.dat pg_opfamily.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_opclass.dat pg_opclass.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_amproc.dat pg_amproc.dat) +RESOURCE(../../../../../contrib/libs/postgresql/src/include/catalog/pg_amop.dat pg_amop.dat) + +SRCS( + catalog.cpp +) + +PEERDIR( + library/cpp/resource +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/parser/pg_wrapper/interface/ya.make b/ydb/library/yql/parser/pg_wrapper/interface/ya.make new file mode 100644 index 00000000000..0bd47444770 --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/interface/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + codec.h + compare.h + comp_factory.h + context.h + interface.h + interface.cpp + pack.h + parser.h + type_desc.h + utils.h +) + +PEERDIR( + util + ydb/library/yql/ast + ydb/library/yql/public/udf + ydb/library/yql/public/udf/arrow +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/parser/pg_wrapper/ut/ya.make b/ydb/library/yql/parser/pg_wrapper/ut/ya.make new file mode 100644 index 00000000000..7e836fed1db --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/ut/ya.make @@ -0,0 +1,43 @@ +UNITTEST_FOR(ydb/library/yql/parser/pg_wrapper) + +TIMEOUT(600) +SIZE(MEDIUM) + +NO_COMPILER_WARNINGS() + +INCLUDE(../cflags.inc) + +SRCS( + codegen_ut.cpp + error_ut.cpp + parser_ut.cpp + sort_ut.cpp + type_cache_ut.cpp + ../../../minikql/comp_nodes/ut/mkql_test_factory.cpp +) + + +ADDINCL( + ydb/library/yql/parser/pg_wrapper/postgresql/src/include +) + +PEERDIR( + ydb/library/yql/minikql/arrow + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/parser/pg_catalog + ydb/library/yql/minikql/codegen + library/cpp/resource +) + +YQL_LAST_ABI_VERSION() + +IF (MKQL_RUNTIME_VERSION) + CFLAGS( + -DMKQL_RUNTIME_VERSION=$MKQL_RUNTIME_VERSION + ) +ENDIF() + +END() diff --git a/ydb/library/yql/parser/pg_wrapper/ya.make b/ydb/library/yql/parser/pg_wrapper/ya.make new file mode 100644 index 00000000000..b7f2bc75b61 --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/ya.make @@ -0,0 +1,135 @@ +LIBRARY() + +PROVIDES( + yql_pg_runtime +) + +YQL_LAST_ABI_VERSION() + +ADDINCL( + contrib/libs/libiconv/include + contrib/libs/lz4 + ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/bootstrap + ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/parser + ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/replication + ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/replication/logical + ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/adt + ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/misc + ydb/library/yql/parser/pg_wrapper/postgresql/src/backend/utils/sort + ydb/library/yql/parser/pg_wrapper/postgresql/src/common + ydb/library/yql/parser/pg_wrapper/postgresql/src/include + contrib/libs/postgresql/src/port +) + +SRCS( + arena_ctx.cpp + arrow.cpp + arrow_impl.cpp + parser.cpp + thread_inits.c + comp_factory.cpp + type_cache.cpp + pg_aggs.cpp + pg_kernels.0.cpp + pg_kernels.1.cpp + pg_kernels.2.cpp + pg_kernels.3.cpp + config.cpp +) + +IF (ARCH_X86_64) + CFLAGS( + -DHAVE__GET_CPUID=1 + -DUSE_SSE42_CRC32C_WITH_RUNTIME_CHECK=1 + ) + SRCS( + postgresql/src/port/pg_crc32c_sse42.c + postgresql/src/port/pg_crc32c_sse42_choose.c + ) +ENDIF() + +# DTCC-950 +NO_COMPILER_WARNINGS() + +INCLUDE(pg_sources.inc) + +IF (NOT OPENSOURCE AND NOT OS_WINDOWS AND NOT SANITIZER_TYPE AND NOT BUILD_TYPE == "DEBUG") +INCLUDE(pg_bc.0.inc) +INCLUDE(pg_bc.1.inc) +INCLUDE(pg_bc.2.inc) +INCLUDE(pg_bc.3.inc) +ELSE() +CFLAGS(-DUSE_SLOW_PG_KERNELS) +ENDIF() + +PEERDIR( + library/cpp/resource + library/cpp/yson + ydb/library/yql/core + ydb/library/yql/minikql/arrow + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/parser/pg_catalog + ydb/library/yql/providers/common/codec + ydb/library/yql/public/issue + ydb/library/yql/public/udf + ydb/library/yql/utils + + contrib/libs/icu + contrib/libs/libc_compat + contrib/libs/libiconv + contrib/libs/libxml + contrib/libs/lz4 + contrib/libs/openssl +) + +INCLUDE(cflags.inc) + +IF (OS_LINUX OR OS_DARWIN) + SRCS( + ../../../../../contrib/libs/postgresql/src/backend/port/posix_sema.c + ../../../../../contrib/libs/postgresql/src/backend/port/sysv_shmem.c + ) +ELSEIF (OS_WINDOWS) + ADDINCL( + contrib/libs/postgresql/src/include/port + contrib/libs/postgresql/src/include/port/win32 + contrib/libs/postgresql/src/include/port/win32_msvc + ) + SRCS( + ../../../../../contrib/libs/postgresql/src/backend/port/win32/crashdump.c + ../../../../../contrib/libs/postgresql/src/backend/port/win32/signal.c + ../../../../../contrib/libs/postgresql/src/backend/port/win32/socket.c + ../../../../../contrib/libs/postgresql/src/backend/port/win32/timer.c + ../../../../../contrib/libs/postgresql/src/backend/port/win32_sema.c + ../../../../../contrib/libs/postgresql/src/backend/port/win32_shmem.c + ../../../../../contrib/libs/postgresql/src/port/dirmod.c + ../../../../../contrib/libs/postgresql/src/port/dlopen.c + ../../../../../contrib/libs/postgresql/src/port/getaddrinfo.c + ../../../../../contrib/libs/postgresql/src/port/getopt.c + ../../../../../contrib/libs/postgresql/src/port/getrusage.c + ../../../../../contrib/libs/postgresql/src/port/gettimeofday.c + ../../../../../contrib/libs/postgresql/src/port/inet_aton.c + ../../../../../contrib/libs/postgresql/src/port/kill.c + ../../../../../contrib/libs/postgresql/src/port/open.c + ../../../../../contrib/libs/postgresql/src/port/pread.c + ../../../../../contrib/libs/postgresql/src/port/pwrite.c + ../../../../../contrib/libs/postgresql/src/port/pwritev.c + ../../../../../contrib/libs/postgresql/src/port/system.c + ../../../../../contrib/libs/postgresql/src/port/win32env.c + ../../../../../contrib/libs/postgresql/src/port/win32error.c + ../../../../../contrib/libs/postgresql/src/port/win32security.c + ../../../../../contrib/libs/postgresql/src/port/win32setlocale.c + ../../../../../contrib/libs/postgresql/src/port/win32stat.c + ) +ENDIF() + +END() + +RECURSE( + interface +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/parser/proto_ast/collect_issues/ya.make b/ydb/library/yql/parser/proto_ast/collect_issues/ya.make new file mode 100644 index 00000000000..6ae65cb4a0c --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/collect_issues/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/public/issue + ydb/library/yql/parser/proto_ast +) + +SRCS( + collect_issues.h +) + +END() diff --git a/ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make b/ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make new file mode 100644 index 00000000000..a78011fbafa --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/gen/jsonpath/ya.make @@ -0,0 +1,48 @@ +PROTO_LIBRARY() + +IF (CPP_PROTO) + SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR}) + SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates) + SET(jsonpath_grammar ${ARCADIA_ROOT}/ydb/library/yql/minikql/jsonpath/JsonPath.g) + + SET(ANTLR_PACKAGE_NAME NJsonPathGenerated) + SET(PROTOBUF_HEADER_PATH ${MODDIR}) + SET(LEXER_PARSER_NAMESPACE NALP) + + + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in ${antlr_templates}/Cpp/Cpp.stg) + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in ${antlr_templates}/protobuf/protobuf.stg) + + RUN_ANTLR( + ${jsonpath_grammar} + -lib . + -fo ${antlr_output} + -language protobuf + IN ${jsonpath_grammar} ${antlr_templates}/protobuf/protobuf.stg + OUT_NOAUTO JsonPathParser.proto + CWD ${antlr_output} + ) + + EXCLUDE_TAGS(GO_PROTO JAVA_PROTO) + + NO_COMPILER_WARNINGS() + + INCLUDE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl) + + RUN_ANTLR( + ${jsonpath_grammar} + -lib . + -fo ${antlr_output} + IN ${jsonpath_grammar} ${antlr_templates}/Cpp/Cpp.stg + OUT JsonPathParser.cpp JsonPathLexer.cpp JsonPathParser.h JsonPathLexer.h + OUTPUT_INCLUDES + JsonPathParser.pb.h + ${STG_INCLUDES} + CWD ${antlr_output} + ) +ENDIF() + +SRCS(JsonPathParser.proto) + + +END() diff --git a/ydb/library/yql/parser/proto_ast/gen/v0/ya.make b/ydb/library/yql/parser/proto_ast/gen/v0/ya.make new file mode 100644 index 00000000000..3c16fddba71 --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/gen/v0/ya.make @@ -0,0 +1,48 @@ +PROTO_LIBRARY() + +EXCLUDE_TAGS(GO_PROTO JAVA_PROTO) + +IF (CPP_PROTO) + + SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR}) + SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates) + SET(sql_grammar ${ARCADIA_ROOT}/ydb/library/yql/sql/v0/SQL.g) + + SET(ANTLR_PACKAGE_NAME NSQLGenerated) + SET(PROTOBUF_HEADER_PATH ${MODDIR}) + SET(LEXER_PARSER_NAMESPACE NALP) + + + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in ${antlr_templates}/Cpp/Cpp.stg) + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in ${antlr_templates}/protobuf/protobuf.stg) + + RUN_ANTLR( + ${sql_grammar} + -lib . + -fo ${antlr_output} + -language protobuf + IN ${sql_grammar} ${antlr_templates}/protobuf/protobuf.stg + OUT_NOAUTO SQLParser.proto + CWD ${antlr_output} + ) + + NO_COMPILER_WARNINGS() + + INCLUDE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl) + + RUN_ANTLR( + ${sql_grammar} + -lib . + -fo ${antlr_output} + IN ${sql_grammar} ${antlr_templates}/Cpp/Cpp.stg + OUT SQLParser.cpp SQLLexer.cpp SQLParser.h SQLLexer.h + OUTPUT_INCLUDES + SQLParser.pb.h + ${STG_INCLUDES} + CWD ${antlr_output} + ) +ENDIF() + +SRCS(SQLParser.proto) + +END() diff --git a/ydb/library/yql/parser/proto_ast/gen/v1/ya.make b/ydb/library/yql/parser/proto_ast/gen/v1/ya.make new file mode 100644 index 00000000000..d756efefea9 --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/gen/v1/ya.make @@ -0,0 +1,44 @@ +LIBRARY() + +PEERDIR ( + ydb/library/yql/parser/proto_ast/gen/v1_proto +) + +SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR}) +SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates) +SET(sql_grammar ${antlr_output}/SQLv1.g) + +SET(ANTLR_PACKAGE_NAME NSQLv1Generated) +SET(PROTOBUF_HEADER_PATH ydb/library/yql/parser/proto_ast/gen/v1_proto) + +SET(LEXER_PARSER_NAMESPACE NALPDefault) + +SET(GRAMMAR_STRING_CORE_SINGLE "\"~(QUOTE_SINGLE | BACKSLASH) | (BACKSLASH .)\"") +SET(GRAMMAR_STRING_CORE_DOUBLE "\"~(QUOTE_DOUBLE | BACKSLASH) | (BACKSLASH .)\"") +SET(GRAMMAR_MULTILINE_COMMENT_CORE "\".\"") + +CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in ${antlr_templates}/Cpp/Cpp.stg) + +IF(EXPORT_CMAKE) + MANUAL_GENERATION(${sql_grammar}) +ELSE() + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/sql/v1/SQLv1.g.in ${sql_grammar}) +ENDIF() + +NO_COMPILER_WARNINGS() + +INCLUDE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl) + +RUN_ANTLR( + ${sql_grammar} + -lib . + -fo ${antlr_output} + IN ${sql_grammar} ${antlr_templates}/Cpp/Cpp.stg + OUT SQLv1Parser.cpp SQLv1Lexer.cpp SQLv1Parser.h SQLv1Lexer.h + OUTPUT_INCLUDES + ${PROTOBUF_HEADER_PATH}/SQLv1Parser.pb.h + ${STG_INCLUDES} + CWD ${antlr_output} +) + +END() diff --git a/ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make b/ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make new file mode 100644 index 00000000000..27572951f0b --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/gen/v1_ansi/ya.make @@ -0,0 +1,44 @@ +LIBRARY() + +PEERDIR ( + ydb/library/yql/parser/proto_ast/gen/v1_proto +) + +SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR}) +SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates) +SET(sql_grammar ${antlr_output}/SQLv1.g) + +SET(ANTLR_PACKAGE_NAME NSQLv1Generated) +SET(PROTOBUF_HEADER_PATH ydb/library/yql/parser/proto_ast/gen/v1_proto) + +SET(LEXER_PARSER_NAMESPACE NALPAnsi) + +SET(GRAMMAR_STRING_CORE_SINGLE "\"~QUOTE_SINGLE | (QUOTE_SINGLE QUOTE_SINGLE)\"") +SET(GRAMMAR_STRING_CORE_DOUBLE "\"~QUOTE_DOUBLE | (QUOTE_DOUBLE QUOTE_DOUBLE)\"") +SET(GRAMMAR_MULTILINE_COMMENT_CORE "\"MULTILINE_COMMENT | .\"") + +CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/Cpp/Cpp.stg.in ${antlr_templates}/Cpp/Cpp.stg) + +IF(EXPORT_CMAKE) + MANUAL_GENERATION(${sql_grammar}) +ELSE() + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/sql/v1/SQLv1.g.in ${sql_grammar}) +ENDIF() + +NO_COMPILER_WARNINGS() + +INCLUDE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl) + +RUN_ANTLR( + ${sql_grammar} + -lib . + -fo ${antlr_output} + IN ${sql_grammar} ${antlr_templates}/Cpp/Cpp.stg + OUT SQLv1Parser.cpp SQLv1Lexer.cpp SQLv1Parser.h SQLv1Lexer.h + OUTPUT_INCLUDES + ${PROTOBUF_HEADER_PATH}/SQLv1Parser.pb.h + ${STG_INCLUDES} + CWD ${antlr_output} +) + +END() diff --git a/ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make b/ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make new file mode 100644 index 00000000000..68188823c32 --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/gen/v1_proto/ya.make @@ -0,0 +1,37 @@ +PROTO_LIBRARY() + +IF (GEN_PROTO) + SET(antlr_output ${ARCADIA_BUILD_ROOT}/${MODDIR}) + SET(antlr_templates ${antlr_output}/org/antlr/codegen/templates) + SET(sql_grammar ${antlr_output}/SQLv1.g) + + SET(ANTLR_PACKAGE_NAME NSQLv1Generated) + + SET(GRAMMAR_STRING_CORE_SINGLE "\"~(QUOTE_SINGLE | BACKSLASH) | (BACKSLASH .)\"") + SET(GRAMMAR_STRING_CORE_DOUBLE "\"~(QUOTE_DOUBLE | BACKSLASH) | (BACKSLASH .)\"") + SET(GRAMMAR_MULTILINE_COMMENT_CORE "\".\"") + + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/protobuf/protobuf.stg.in ${antlr_templates}/protobuf/protobuf.stg) + + IF(EXPORT_CMAKE) + MANUAL_GENERATION(${sql_grammar}) + ELSE() + CONFIGURE_FILE(${ARCADIA_ROOT}/ydb/library/yql/sql/v1/SQLv1.g.in ${sql_grammar}) + ENDIF() + + RUN_ANTLR( + ${sql_grammar} + -lib . + -fo ${antlr_output} + -language protobuf + IN ${sql_grammar} ${antlr_templates}/protobuf/protobuf.stg + OUT_NOAUTO SQLv1Parser.proto + CWD ${antlr_output} + ) +ENDIF() + +SRCS(SQLv1Parser.proto) + +EXCLUDE_TAGS(GO_PROTO JAVA_PROTO) + +END() diff --git a/ydb/library/yql/parser/proto_ast/gen/ya.make b/ydb/library/yql/parser/proto_ast/gen/ya.make new file mode 100644 index 00000000000..72c7ac4da73 --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/gen/ya.make @@ -0,0 +1,6 @@ +RECURSE( + v0 + v1 + v1_proto + jsonpath +) diff --git a/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl b/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl new file mode 100644 index 00000000000..c1f11f9dc9a --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/org/antlr/codegen/templates/ya.make.incl @@ -0,0 +1,13 @@ +SET(STG_INCLUDES + contrib/libs/antlr3_cpp_runtime/include/antlr3.hpp + + util/generic/ptr.h + util/generic/string.h + util/generic/vector.h + util/stream/output.h + util/stream/str.h + + google/protobuf/message.h + + ydb/library/yql/parser/proto_ast/proto_ast.h +) diff --git a/ydb/library/yql/parser/proto_ast/ya.make b/ydb/library/yql/parser/proto_ast/ya.make new file mode 100644 index 00000000000..fb7290cadb5 --- /dev/null +++ b/ydb/library/yql/parser/proto_ast/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + contrib/libs/antlr3_cpp_runtime + contrib/libs/protobuf +) + +SRCS( + proto_ast.cpp +) + +END() + +RECURSE( + gen + collect_issues +) diff --git a/ydb/library/yql/parser/ya.make b/ydb/library/yql/parser/ya.make new file mode 100644 index 00000000000..30748604e09 --- /dev/null +++ b/ydb/library/yql/parser/ya.make @@ -0,0 +1,6 @@ +RECURSE( + lexer_common + pg_catalog + pg_wrapper + proto_ast +) diff --git a/ydb/library/yql/protos/ya.make b/ydb/library/yql/protos/ya.make new file mode 100644 index 00000000000..48a44ec1f8e --- /dev/null +++ b/ydb/library/yql/protos/ya.make @@ -0,0 +1,11 @@ +PROTO_LIBRARY() + +SRCS( + common.proto + yql_mount.proto + clickhouse.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/providers/clickhouse/actors/ya.make b/ydb/library/yql/providers/clickhouse/actors/ya.make new file mode 100644 index 00000000000..6c68d6586fa --- /dev/null +++ b/ydb/library/yql/providers/clickhouse/actors/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + yql_ch_read_actor.cpp + yql_ch_source_factory.cpp +) + +PEERDIR( + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/public/types + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/clickhouse/proto + ydb/library/yql/providers/common/http_gateway +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/clickhouse/expr_nodes/ya.make b/ydb/library/yql/providers/clickhouse/expr_nodes/ya.make new file mode 100644 index 00000000000..3810700ae73 --- /dev/null +++ b/ydb/library/yql/providers/clickhouse/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_clickhouse_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/provider +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_clickhouse_expr_nodes.json + yql_clickhouse_expr_nodes.gen.h + yql_clickhouse_expr_nodes.decl.inl.h + yql_clickhouse_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_clickhouse_expr_nodes.json + OUT yql_clickhouse_expr_nodes.gen.h + OUT yql_clickhouse_expr_nodes.decl.inl.h + OUT yql_clickhouse_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_clickhouse_expr_nodes.json + yql_clickhouse_expr_nodes.gen.h + yql_clickhouse_expr_nodes.decl.inl.h + yql_clickhouse_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_clickhouse_expr_nodes.json + OUT yql_clickhouse_expr_nodes.gen.h + OUT yql_clickhouse_expr_nodes.decl.inl.h + OUT yql_clickhouse_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/clickhouse/proto/ya.make b/ydb/library/yql/providers/clickhouse/proto/ya.make new file mode 100644 index 00000000000..a2a8e946557 --- /dev/null +++ b/ydb/library/yql/providers/clickhouse/proto/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +SRCS( + source.proto + range.proto +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() + diff --git a/ydb/library/yql/providers/clickhouse/provider/ya.make b/ydb/library/yql/providers/clickhouse/provider/ya.make new file mode 100644 index 00000000000..d9639341249 --- /dev/null +++ b/ydb/library/yql/providers/clickhouse/provider/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_clickhouse_datasink.cpp + yql_clickhouse_datasink_execution.cpp + yql_clickhouse_datasink_type_ann.cpp + yql_clickhouse_datasource.cpp + yql_clickhouse_datasource_type_ann.cpp + yql_clickhouse_dq_integration.cpp + yql_clickhouse_io_discovery.cpp + yql_clickhouse_load_meta.cpp + yql_clickhouse_logical_opt.cpp + yql_clickhouse_mkql_compiler.cpp + yql_clickhouse_physical_opt.cpp + yql_clickhouse_provider.cpp + yql_clickhouse_provider.h + yql_clickhouse_provider_impl.h + yql_clickhouse_settings.cpp + yql_clickhouse_settings.h + yql_clickhouse_util.cpp + yql_clickhouse_util.h +) + +YQL_LAST_ABI_VERSION() + +PEERDIR( + library/cpp/json + library/cpp/random_provider + library/cpp/time_provider + ydb/library/yql/ast + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/integration + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/providers/clickhouse/expr_nodes + ydb/library/yql/providers/clickhouse/proto + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/dq + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/expr_nodes +) + +END() diff --git a/ydb/library/yql/providers/clickhouse/ya.make b/ydb/library/yql/providers/clickhouse/ya.make new file mode 100644 index 00000000000..eacab82215a --- /dev/null +++ b/ydb/library/yql/providers/clickhouse/ya.make @@ -0,0 +1,6 @@ +RECURSE( + actors + expr_nodes + provider + proto +) diff --git a/ydb/library/yql/providers/common/activation/ya.make b/ydb/library/yql/providers/common/activation/ya.make new file mode 100644 index 00000000000..67807e9ac81 --- /dev/null +++ b/ydb/library/yql/providers/common/activation/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + yql_activation.cpp +) + +PEERDIR( + ydb/library/yql/providers/common/proto +) + +END() diff --git a/ydb/library/yql/providers/common/arrow/interface/ya.make b/ydb/library/yql/providers/common/arrow/interface/ya.make new file mode 100644 index 00000000000..61f600b471d --- /dev/null +++ b/ydb/library/yql/providers/common/arrow/interface/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + contrib/libs/apache/arrow + library/cpp/threading/future + ydb/library/yql/providers/common/http_gateway +) + +SRCS( + arrow_reader.cpp +) + +END()
\ No newline at end of file diff --git a/ydb/library/yql/providers/common/arrow/ya.make b/ydb/library/yql/providers/common/arrow/ya.make new file mode 100644 index 00000000000..5c032323097 --- /dev/null +++ b/ydb/library/yql/providers/common/arrow/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +YQL_LAST_ABI_VERSION() + +PEERDIR( + ydb/library/yql/providers/common/arrow/interface +) + +SRCS( + arrow_reader_impl.cpp +) + +CFLAGS( + -DARCADIA_BUILD -DUSE_PARQUET +) + +END()
\ No newline at end of file diff --git a/ydb/library/yql/providers/common/arrow_resolve/ya.make b/ydb/library/yql/providers/common/arrow_resolve/ya.make new file mode 100644 index 00000000000..02f7ef75fd1 --- /dev/null +++ b/ydb/library/yql/providers/common/arrow_resolve/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + yql_simple_arrow_resolver.cpp +) + +PEERDIR( + ydb/library/yql/minikql/arrow + ydb/library/yql/public/udf + ydb/library/yql/providers/common/mkql +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/codec/ut/ya.make b/ydb/library/yql/providers/common/codec/ut/ya.make new file mode 100644 index 00000000000..cf8c219546a --- /dev/null +++ b/ydb/library/yql/providers/common/codec/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/library/yql/providers/common/codec) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + yql_json_codec_ut.cpp + yql_restricted_yson_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/codec/ya.make b/ydb/library/yql/providers/common/codec/ya.make new file mode 100644 index 00000000000..4f8792dc07e --- /dev/null +++ b/ydb/library/yql/providers/common/codec/ya.make @@ -0,0 +1,36 @@ +LIBRARY() + +SRCS( + yql_codec.cpp + yql_codec.h + yql_codec_buf.cpp + yql_codec_buf.h + yql_codec_results.cpp + yql_codec_results.h + yql_restricted_yson.cpp + yql_restricted_yson.h + yql_codec_type_flags.cpp + yql_codec_type_flags.h + yql_json_codec.cpp +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/providers/common/mkql + library/cpp/yson/node + library/cpp/yson + library/cpp/json + library/cpp/enumbitset +) + +YQL_LAST_ABI_VERSION() + +GENERATE_ENUM_SERIALIZATION(yql_codec_type_flags.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/common/comp_nodes/ya.make b/ydb/library/yql/providers/common/comp_nodes/ya.make new file mode 100644 index 00000000000..1e8a252bd41 --- /dev/null +++ b/ydb/library/yql/providers/common/comp_nodes/ya.make @@ -0,0 +1,61 @@ +LIBRARY() + +SRCS( + yql_factory.h + yql_factory.cpp + yql_formatcode.h + yql_formatcode.cpp + yql_formattype.cpp + yql_formattype.h + yql_makecode.h + yql_makecode.cpp + yql_maketype.h + yql_maketype.cpp + yql_parsetypehandle.h + yql_parsetypehandle.cpp + yql_position.cpp + yql_position.h + yql_reprcode.h + yql_reprcode.cpp + yql_serializetypehandle.h + yql_serializetypehandle.cpp + yql_splittype.h + yql_splittype.cpp + yql_type_resource.cpp + yql_type_resource.h + yql_typehandle.cpp + yql_typehandle.h + yql_typekind.cpp + yql_typekind.h +) + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/ast/serialize + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/schema/expr +) + +IF (NOT MKQL_DISABLE_CODEGEN) + PEERDIR( + ydb/library/yql/minikql/codegen + contrib/libs/llvm12/lib/IR + contrib/libs/llvm12/lib/ExecutionEngine/MCJIT + contrib/libs/llvm12/lib/Linker + contrib/libs/llvm12/lib/Target/X86 + contrib/libs/llvm12/lib/Target/X86/AsmParser + contrib/libs/llvm12/lib/Transforms/IPO + ) +ELSE() + CFLAGS( + -DMKQL_DISABLE_CODEGEN + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/config/ya.make b/ydb/library/yql/providers/common/config/ya.make new file mode 100644 index 00000000000..024feeecafa --- /dev/null +++ b/ydb/library/yql/providers/common/config/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + yql_configuration_transformer.cpp + yql_dispatch.cpp + yql_setting.h +) + +PEERDIR( + ydb/library/yql/core + ydb/library/yql/core/expr_nodes + ydb/library/yql/ast + ydb/library/yql/providers/common/activation + library/cpp/containers/sorted_vector + library/cpp/string_utils/parse_size + library/cpp/string_utils/levenshtein_diff +) + + + YQL_LAST_ABI_VERSION() + + +END() diff --git a/ydb/library/yql/providers/common/db_id_async_resolver/ya.make b/ydb/library/yql/providers/common/db_id_async_resolver/ya.make new file mode 100644 index 00000000000..2cf88d4759e --- /dev/null +++ b/ydb/library/yql/providers/common/db_id_async_resolver/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + db_async_resolver.h +) + +PEERDIR( + library/cpp/threading/future + ydb/library/yql/public/issue +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/dq/ya.make b/ydb/library/yql/providers/common/dq/ya.make new file mode 100644 index 00000000000..769d0fd727e --- /dev/null +++ b/ydb/library/yql/providers/common/dq/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + yql_dq_integration_impl.cpp +) + +PEERDIR( + ydb/library/yql/dq/integration +) + +END() diff --git a/ydb/library/yql/providers/common/gateway/ya.make b/ydb/library/yql/providers/common/gateway/ya.make new file mode 100644 index 00000000000..c0624a9b7cb --- /dev/null +++ b/ydb/library/yql/providers/common/gateway/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + yql_provider_gateway.h + yql_provider_gateway.cpp +) + +PEERDIR( + library/cpp/threading/future + ydb/library/yql/ast +) + +END() diff --git a/ydb/library/yql/providers/common/http_gateway/mock/ya.make b/ydb/library/yql/providers/common/http_gateway/mock/ya.make new file mode 100644 index 00000000000..522cddc1c9c --- /dev/null +++ b/ydb/library/yql/providers/common/http_gateway/mock/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + yql_http_mock_gateway.cpp +) + +PEERDIR( + ydb/library/yql/providers/common/http_gateway +) + +YQL_LAST_ABI_VERSION() + +END() + diff --git a/ydb/library/yql/providers/common/http_gateway/ut/ya.make b/ydb/library/yql/providers/common/http_gateway/ut/ya.make new file mode 100644 index 00000000000..4d2a4bead4a --- /dev/null +++ b/ydb/library/yql/providers/common/http_gateway/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(ydb/library/yql/providers/common/http_gateway) + +FORK_SUBTESTS() + +SRCS( + yql_dns_gateway_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/http_gateway/ya.make b/ydb/library/yql/providers/common/http_gateway/ya.make new file mode 100644 index 00000000000..7337097175e --- /dev/null +++ b/ydb/library/yql/providers/common/http_gateway/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +SRCS( + yql_http_gateway.cpp + yql_http_default_retry_policy.cpp +) + +PEERDIR( + contrib/libs/curl + library/cpp/actors/prof + library/cpp/monlib/dynamic_counters + library/cpp/retry + ydb/library/yql/providers/common/proto + ydb/library/yql/public/issue + ydb/library/yql/utils/log +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE( + mock +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/common/metrics/protos/ya.make b/ydb/library/yql/providers/common/metrics/protos/ya.make new file mode 100644 index 00000000000..ac7050533bc --- /dev/null +++ b/ydb/library/yql/providers/common/metrics/protos/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + metrics_registry.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/providers/common/metrics/ya.make b/ydb/library/yql/providers/common/metrics/ya.make new file mode 100644 index 00000000000..c40f275be35 --- /dev/null +++ b/ydb/library/yql/providers/common/metrics/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + metrics_registry.cpp + sensors_group.cpp + service_counters.cpp +) + +PEERDIR( + library/cpp/logger/global + library/cpp/monlib/dynamic_counters + ydb/library/yql/providers/common/metrics/protos +) + +END() diff --git a/ydb/library/yql/providers/common/mkql/ya.make b/ydb/library/yql/providers/common/mkql/ya.make new file mode 100644 index 00000000000..c71d2067a02 --- /dev/null +++ b/ydb/library/yql/providers/common/mkql/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +SRCS( + parser.cpp + parser.h + yql_provider_mkql.cpp + yql_provider_mkql.h + yql_type_mkql.cpp + yql_type_mkql.h +) + +PEERDIR( + library/cpp/json + ydb/library/yql/ast + ydb/library/yql/minikql + ydb/library/yql/public/decimal + ydb/library/yql/public/udf + ydb/library/yql/utils + ydb/library/yql/core + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/parser/pg_catalog +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/proto/ya.make b/ydb/library/yql/providers/common/proto/ya.make new file mode 100644 index 00000000000..b4480f31254 --- /dev/null +++ b/ydb/library/yql/providers/common/proto/ya.make @@ -0,0 +1,16 @@ +PROTO_LIBRARY() + +SRCS( + gateways_config.proto + udf_resolver.proto +) + +PEERDIR( + ydb/library/yql/protos +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/common/provider/ya.make b/ydb/library/yql/providers/common/provider/ya.make new file mode 100644 index 00000000000..dc999b8fd19 --- /dev/null +++ b/ydb/library/yql/providers/common/provider/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + yql_data_provider_impl.cpp + yql_data_provider_impl.h + yql_provider.cpp + yql_provider.h + yql_provider_names.h + yql_table_lookup.cpp + yql_table_lookup.h +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/public/udf + ydb/library/yql/sql # fixme + ydb/library/yql/core +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/schema/expr/ya.make b/ydb/library/yql/providers/common/schema/expr/ya.make new file mode 100644 index 00000000000..196bda2a8f7 --- /dev/null +++ b/ydb/library/yql/providers/common/schema/expr/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + yql_expr_schema.cpp +) + +PEERDIR( + library/cpp/yson + library/cpp/yson/node + ydb/library/yql/ast + ydb/library/yql/public/issue + ydb/library/yql/public/udf + ydb/library/yql/utils + ydb/library/yql/providers/common/schema/parser + ydb/library/yql/parser/pg_catalog +) + +END() diff --git a/ydb/library/yql/providers/common/schema/mkql/ya.make b/ydb/library/yql/providers/common/schema/mkql/ya.make new file mode 100644 index 00000000000..12998962d58 --- /dev/null +++ b/ydb/library/yql/providers/common/schema/mkql/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + yql_mkql_schema.cpp +) + +PEERDIR( + library/cpp/yson + library/cpp/yson/node + ydb/library/yql/minikql + ydb/library/yql/public/udf + ydb/library/yql/utils + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/schema/parser + ydb/library/yql/parser/pg_catalog +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/schema/parser/ya.make b/ydb/library/yql/providers/common/schema/parser/ya.make new file mode 100644 index 00000000000..f378750f70e --- /dev/null +++ b/ydb/library/yql/providers/common/schema/parser/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + yql_type_parser.cpp +) + +PEERDIR( + library/cpp/yson/node + library/cpp/yson +) + +END() diff --git a/ydb/library/yql/providers/common/schema/skiff/ya.make b/ydb/library/yql/providers/common/schema/skiff/ya.make new file mode 100644 index 00000000000..94691500d02 --- /dev/null +++ b/ydb/library/yql/providers/common/schema/skiff/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + yql_skiff_schema.cpp +) + +PEERDIR( + library/cpp/yson/node + ydb/library/yql/public/udf + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/schema/parser +) + +END() diff --git a/ydb/library/yql/providers/common/schema/ya.make b/ydb/library/yql/providers/common/schema/ya.make new file mode 100644 index 00000000000..4357f787d5d --- /dev/null +++ b/ydb/library/yql/providers/common/schema/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + yql_schema_utils.cpp +) + +PEERDIR( + library/cpp/yson/node + ydb/library/yql/utils +) + +END() diff --git a/ydb/library/yql/providers/common/structured_token/ut/ya.make b/ydb/library/yql/providers/common/structured_token/ut/ya.make new file mode 100644 index 00000000000..90f62995d53 --- /dev/null +++ b/ydb/library/yql/providers/common/structured_token/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(ydb/library/yql/providers/common/structured_token) + +SRCS( + yql_structured_token_ut.cpp +) + +END() diff --git a/ydb/library/yql/providers/common/structured_token/ya.make b/ydb/library/yql/providers/common/structured_token/ya.make new file mode 100644 index 00000000000..9ef4629445a --- /dev/null +++ b/ydb/library/yql/providers/common/structured_token/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + yql_structured_token.cpp + yql_structured_token.h + yql_token_builder.cpp + yql_token_builder.h +) + +PEERDIR( + library/cpp/json + library/cpp/string_utils/base64 + ydb/library/yql/utils +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/common/token_accessor/client/ya.make b/ydb/library/yql/providers/common/token_accessor/client/ya.make new file mode 100644 index 00000000000..06d10155184 --- /dev/null +++ b/ydb/library/yql/providers/common/token_accessor/client/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + bearer_credentials_provider.cpp + factory.cpp + token_accessor_client.cpp + token_accessor_client_factory.cpp +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/threading/atomic + library/cpp/threading/future + ydb/library/yql/providers/common/structured_token + ydb/library/yql/providers/common/token_accessor/grpc + ydb/public/sdk/cpp/client/ydb_types/credentials +) + +END() diff --git a/ydb/library/yql/providers/common/token_accessor/grpc/ya.make b/ydb/library/yql/providers/common/token_accessor/grpc/ya.make new file mode 100644 index 00000000000..bd150951a5f --- /dev/null +++ b/ydb/library/yql/providers/common/token_accessor/grpc/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +IF (OPENSOURCE) + EXCLUDE_TAGS(GO_PROTO) +ELSE() + INCLUDE_TAGS(GO_PROTO) +ENDIF() + +GRPC() + +SRCS( + token_accessor_pb.proto +) + +END() diff --git a/ydb/library/yql/providers/common/token_accessor/ya.make b/ydb/library/yql/providers/common/token_accessor/ya.make new file mode 100644 index 00000000000..119cbb9c4bb --- /dev/null +++ b/ydb/library/yql/providers/common/token_accessor/ya.make @@ -0,0 +1,4 @@ +RECURSE( + client + grpc +) diff --git a/ydb/library/yql/providers/common/transform/ya.make b/ydb/library/yql/providers/common/transform/ya.make new file mode 100644 index 00000000000..5714a98018f --- /dev/null +++ b/ydb/library/yql/providers/common/transform/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + yql_exec.cpp + yql_lazy_init.cpp + yql_optimize.cpp + yql_visit.cpp +) + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/utils + ydb/library/yql/utils/log + ydb/library/yql/core + ydb/library/yql/core/expr_nodes +) + +END() diff --git a/ydb/library/yql/providers/common/udf_resolve/ya.make b/ydb/library/yql/providers/common/udf_resolve/ya.make new file mode 100644 index 00000000000..92d1bd56f38 --- /dev/null +++ b/ydb/library/yql/providers/common/udf_resolve/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +SRCS( + yql_files_box.cpp + yql_files_box.h + yql_outproc_udf_resolver.cpp + yql_outproc_udf_resolver.h + yql_simple_udf_resolver.cpp + yql_simple_udf_resolver.h + yql_udf_resolver_with_index.cpp + yql_udf_resolver_with_index.h +) + +PEERDIR( + library/cpp/digest/md5 + library/cpp/protobuf/util + ydb/library/yql/core/file_storage + ydb/library/yql/minikql + ydb/library/yql/public/udf + ydb/library/yql/utils + ydb/library/yql/utils/log + ydb/library/yql/core + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/schema/expr +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/ut_helpers/ya.make b/ydb/library/yql/providers/common/ut_helpers/ya.make new file mode 100644 index 00000000000..11efe203cdd --- /dev/null +++ b/ydb/library/yql/providers/common/ut_helpers/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + dq_fake_ca.cpp +) + +PEERDIR( + library/cpp/retry + ydb/core/testlib/basics + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql + ydb/library/yql/providers/common/comp_nodes +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/common/ya.make b/ydb/library/yql/providers/common/ya.make new file mode 100644 index 00000000000..275a09ad198 --- /dev/null +++ b/ydb/library/yql/providers/common/ya.make @@ -0,0 +1,26 @@ +RECURSE( + activation + arrow_resolve + arrow + codec + config + db_id_async_resolver + dq + gateway + http_gateway + metrics + mkql + comp_nodes + proto + provider + schema + schema/expr + schema/mkql + schema/parser + schema/skiff + structured_token + token_accessor + transform + udf_resolve + ut_helpers +) diff --git a/ydb/library/yql/providers/config/ya.make b/ydb/library/yql/providers/config/ya.make new file mode 100644 index 00000000000..eca96c0b979 --- /dev/null +++ b/ydb/library/yql/providers/config/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + yql_config_provider.cpp + yql_config_provider.h +) + +PEERDIR( + library/cpp/json + ydb/library/yql/ast + ydb/library/yql/utils + ydb/library/yql/utils/fetch + ydb/library/yql/utils/log + ydb/library/yql/core + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/activation +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/actors/ut/ya.make b/ydb/library/yql/providers/dq/actors/ut/ya.make new file mode 100644 index 00000000000..1a83037ae6b --- /dev/null +++ b/ydb/library/yql/providers/dq/actors/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/library/yql/providers/dq/actors) + +PEERDIR( + library/cpp/testing/unittest + library/cpp/time_provider + ydb/library/yql/dq/actors + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/dq/actors + ydb/library/yql/public/udf/service/stub +) + +SRCS( + grouped_issues_ut.cpp +) + +END() diff --git a/ydb/library/yql/providers/dq/actors/ya.make b/ydb/library/yql/providers/dq/actors/ya.make new file mode 100644 index 00000000000..7dc1895cf2e --- /dev/null +++ b/ydb/library/yql/providers/dq/actors/ya.make @@ -0,0 +1,58 @@ +LIBRARY() + +SRCS( + compute_actor.cpp + events.cpp + executer_actor.cpp + execution_helpers.cpp + graph_execution_events_actor.cpp + resource_allocator.cpp + task_controller.cpp + worker_actor.cpp + result_aggregator.cpp + result_receiver.cpp + full_result_writer.cpp + proto_builder.cpp + grouped_issues.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/yson + ydb/core/base + ydb/library/mkql_proto + ydb/library/yql/core/services + ydb/library/yql/core/services/mounts + ydb/library/yql/core/user_data + ydb/library/yql/utils/actors + ydb/library/yql/utils/actor_log + ydb/library/yql/utils/backtrace + ydb/library/yql/utils/log + ydb/public/api/protos + ydb/public/lib/yson_value + ydb/library/yql/dq/common + ydb/library/yql/dq/proto + ydb/library/yql/dq/runtime + ydb/library/yql/dq/tasks + ydb/library/yql/utils/failure_injector + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/dq/api/grpc + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/config + ydb/library/yql/providers/dq/counters + ydb/library/yql/providers/dq/interface + ydb/library/yql/providers/dq/planner + ydb/library/yql/providers/dq/task_runner + ydb/library/yql/providers/dq/task_runner_actor + ydb/library/yql/providers/dq/worker_manager + ydb/library/yql/providers/dq/worker_manager/interface +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/dq/api/grpc/ya.make b/ydb/library/yql/providers/dq/api/grpc/ya.make new file mode 100644 index 00000000000..506192652b1 --- /dev/null +++ b/ydb/library/yql/providers/dq/api/grpc/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +GRPC() + +SRCS( + api.proto +) + +PEERDIR( + ydb/library/yql/providers/dq/api/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/providers/dq/api/protos/ya.make b/ydb/library/yql/providers/dq/api/protos/ya.make new file mode 100644 index 00000000000..77c28d5e1f4 --- /dev/null +++ b/ydb/library/yql/providers/dq/api/protos/ya.make @@ -0,0 +1,19 @@ +PROTO_LIBRARY() + +SRCS( + service.proto + dqs.proto + task_command_executor.proto +) + +PEERDIR( + library/cpp/actors/protos + ydb/public/api/protos + ydb/library/yql/dq/actors/protos + ydb/library/yql/dq/proto + ydb/library/yql/providers/common/metrics/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/providers/dq/api/ya.make b/ydb/library/yql/providers/dq/api/ya.make new file mode 100644 index 00000000000..9e2772ca77f --- /dev/null +++ b/ydb/library/yql/providers/dq/api/ya.make @@ -0,0 +1,4 @@ +RECURSE( + grpc + protos +) diff --git a/ydb/library/yql/providers/dq/common/ya.make b/ydb/library/yql/providers/dq/common/ya.make new file mode 100644 index 00000000000..679a13c3e97 --- /dev/null +++ b/ydb/library/yql/providers/dq/common/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +PEERDIR( + library/cpp/string_utils/parse_size + ydb/library/yql/minikql + ydb/library/yql/sql + ydb/library/yql/utils + ydb/library/yql/utils/log + ydb/library/yql/dq/actors +) + +SRCS( + attrs.cpp + yql_dq_common.cpp + yql_dq_settings.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/config/ya.make b/ydb/library/yql/providers/dq/config/ya.make new file mode 100644 index 00000000000..06e522de50e --- /dev/null +++ b/ydb/library/yql/providers/dq/config/ya.make @@ -0,0 +1,14 @@ +PROTO_LIBRARY() + +SRCS( + config.proto +) + +PEERDIR( +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/dq/counters/ya.make b/ydb/library/yql/providers/dq/counters/ya.make new file mode 100644 index 00000000000..acd095ffc56 --- /dev/null +++ b/ydb/library/yql/providers/dq/counters/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/dq/runtime +) + +SRCS( + counters.cpp +) + + + YQL_LAST_ABI_VERSION() + + +END() diff --git a/ydb/library/yql/providers/dq/expr_nodes/ya.make b/ydb/library/yql/providers/dq/expr_nodes/ya.make new file mode 100644 index 00000000000..c49d264458d --- /dev/null +++ b/ydb/library/yql/providers/dq/expr_nodes/ya.make @@ -0,0 +1,51 @@ +LIBRARY() + +SRCS( + dqs_expr_nodes.h +) + +PEERDIR( + ydb/library/yql/core/expr_nodes +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + dqs_expr_nodes.json + dqs_expr_nodes.gen.h + dqs_expr_nodes.decl.inl.h + dqs_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN dqs_expr_nodes.json + OUT dqs_expr_nodes.gen.h + OUT dqs_expr_nodes.decl.inl.h + OUT dqs_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + dqs_expr_nodes.json + dqs_expr_nodes.gen.h + dqs_expr_nodes.decl.inl.h + dqs_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN dqs_expr_nodes.json + OUT dqs_expr_nodes.gen.h + OUT dqs_expr_nodes.decl.inl.h + OUT dqs_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/dq/interface/ya.make b/ydb/library/yql/providers/dq/interface/ya.make new file mode 100644 index 00000000000..fe2f43b0ea8 --- /dev/null +++ b/ydb/library/yql/providers/dq/interface/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + yql_dq_full_result_writer.cpp + yql_dq_task_preprocessor.cpp +) + +PEERDIR( + ydb/library/yql/public/udf +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/mkql/ya.make b/ydb/library/yql/providers/dq/mkql/ya.make new file mode 100644 index 00000000000..1e6ea701e25 --- /dev/null +++ b/ydb/library/yql/providers/dq/mkql/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/core + ydb/library/yql/dq/integration + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/dq/expr_nodes +) + +SRCS( + dqs_mkql_compiler.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/opt/ya.make b/ydb/library/yql/providers/dq/opt/ya.make new file mode 100644 index 00000000000..b1ce4734515 --- /dev/null +++ b/ydb/library/yql/providers/dq/opt/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/transform + ydb/library/yql/utils/log + ydb/library/yql/dq/opt + ydb/library/yql/dq/type_ann + ydb/library/yql/core + ydb/library/yql/core/peephole_opt + ydb/library/yql/core/type_ann + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + library/cpp/yson/node +) + +SRCS( + dqs_opt.cpp + logical_optimize.cpp + physical_optimize.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/planner/ya.make b/ydb/library/yql/providers/dq/planner/ya.make new file mode 100644 index 00000000000..12716da34bd --- /dev/null +++ b/ydb/library/yql/providers/dq/planner/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/core/services + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/dq/integration + ydb/library/yql/dq/opt + ydb/library/yql/dq/tasks + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/dq/mkql + ydb/library/yql/providers/dq/opt +) + +SRCS( + dqs_task_graph.cpp + execution_planner.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/provider/exec/ya.make b/ydb/library/yql/providers/dq/provider/exec/ya.make new file mode 100644 index 00000000000..f82a2ce6d29 --- /dev/null +++ b/ydb/library/yql/providers/dq/provider/exec/ya.make @@ -0,0 +1,36 @@ +LIBRARY() + +SRCS( + yql_dq_exectransformer.cpp + yql_dq_exectransformer.h +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/threading/task_scheduler + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_driver + ydb/library/yql/core + ydb/library/yql/dq/integration + ydb/library/yql/dq/runtime + ydb/library/yql/dq/tasks + ydb/library/yql/dq/type_ann + ydb/library/yql/providers/common/gateway + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/actors + ydb/library/yql/providers/dq/api/grpc + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/counters + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/dq/opt + ydb/library/yql/providers/dq/planner + ydb/library/yql/providers/dq/runtime + ydb/library/yql/providers/result/expr_nodes +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/provider/ut/ya.make b/ydb/library/yql/providers/dq/provider/ut/ya.make new file mode 100644 index 00000000000..b4119f73b49 --- /dev/null +++ b/ydb/library/yql/providers/dq/provider/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/library/yql/providers/dq/provider) + +PEERDIR( + library/cpp/testing/unittest + ydb/library/yql/providers/dq/provider + ydb/library/yql/sql/pg_dummy + ydb/library/yql/public/udf/service/stub +) + +SRCS( + yql_dq_provider_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/provider/ya.make b/ydb/library/yql/providers/dq/provider/ya.make new file mode 100644 index 00000000000..30c5bbb611d --- /dev/null +++ b/ydb/library/yql/providers/dq/provider/ya.make @@ -0,0 +1,62 @@ +LIBRARY() + +SRCS( + yql_dq_control.cpp + yql_dq_control.h + yql_dq_datasink_constraints.cpp + yql_dq_datasink_type_ann.cpp + yql_dq_datasink_type_ann.h + yql_dq_datasource_constraints.cpp + yql_dq_datasource_type_ann.cpp + yql_dq_datasource_type_ann.h + yql_dq_gateway.cpp + yql_dq_gateway.h + yql_dq_provider.cpp + yql_dq_provider.h + yql_dq_datasink.cpp + yql_dq_datasink.h + yql_dq_datasource.cpp + yql_dq_datasource.h + yql_dq_recapture.cpp + yql_dq_recapture.h + yql_dq_statistics_json.cpp + yql_dq_statistics_json.h + yql_dq_validate.cpp +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/threading/task_scheduler + library/cpp/threading/future + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_driver + ydb/library/yql/core + ydb/library/yql/core/issue + ydb/library/yql/utils/backtrace + ydb/library/yql/dq/integration + ydb/library/yql/dq/integration/transform + ydb/library/yql/dq/transform + ydb/library/yql/dq/tasks + ydb/library/yql/dq/type_ann + ydb/library/yql/providers/common/gateway + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/api/grpc + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/config + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/dq/opt + ydb/library/yql/providers/dq/planner + ydb/library/yql/providers/result/expr_nodes + ydb/library/yql/minikql +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/dq/runtime/ya.make b/ydb/library/yql/providers/dq/runtime/ya.make new file mode 100644 index 00000000000..c24fc489c52 --- /dev/null +++ b/ydb/library/yql/providers/dq/runtime/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/utils + ydb/library/yql/utils/log + ydb/library/yql/utils/backtrace + ydb/library/yql/core/expr_nodes + ydb/library/yql/dq/common + ydb/library/yql/dq/integration/transform + ydb/library/yql/dq/runtime + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/counters + ydb/library/yql/providers/dq/task_runner +) + +YQL_LAST_ABI_VERSION() + +SRCS( + file_cache.cpp + task_command_executor.cpp + runtime_data.cpp +) + +END() diff --git a/ydb/library/yql/providers/dq/task_runner/ya.make b/ydb/library/yql/providers/dq/task_runner/ya.make new file mode 100644 index 00000000000..bb15b49c521 --- /dev/null +++ b/ydb/library/yql/providers/dq/task_runner/ya.make @@ -0,0 +1,31 @@ +LIBRARY() + +PEERDIR( + library/cpp/svnversion + library/cpp/threading/task_scheduler + library/cpp/yson/node + ydb/library/yql/dq/integration/transform + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/minikql/invoke_builtins + ydb/library/yql/protos + ydb/library/yql/utils + ydb/library/yql/utils/backtrace + ydb/library/yql/utils/log + ydb/library/yql/dq/proto + ydb/library/yql/dq/runtime + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/counters +) + +YQL_LAST_ABI_VERSION() + +SRCS( + file_cache.cpp + tasks_runner_local.cpp + tasks_runner_proxy.cpp + tasks_runner_pipe.cpp +) + +END() diff --git a/ydb/library/yql/providers/dq/task_runner_actor/ya.make b/ydb/library/yql/providers/dq/task_runner_actor/ya.make new file mode 100644 index 00000000000..5ef4ddafe73 --- /dev/null +++ b/ydb/library/yql/providers/dq/task_runner_actor/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + task_runner_actor.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/library/yql/dq/actors/task_runner + ydb/library/yql/dq/proto + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/runtime # TODO: split runtime/runtime_data + ydb/library/yql/utils/actors + ydb/library/yql/providers/dq/task_runner +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/dq/worker_manager/interface/ya.make b/ydb/library/yql/providers/dq/worker_manager/interface/ya.make new file mode 100644 index 00000000000..cc5ad4b2256 --- /dev/null +++ b/ydb/library/yql/providers/dq/worker_manager/interface/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/interconnect + ydb/library/yql/utils/log + ydb/library/yql/dq/common + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/dq/api/grpc + ydb/library/yql/providers/dq/api/protos +) + +YQL_LAST_ABI_VERSION() + +SET( + SOURCE + events.cpp + worker_info.cpp + counters.cpp +) + +SRCS( + ${SOURCE} +) + +END() diff --git a/ydb/library/yql/providers/dq/worker_manager/ya.make b/ydb/library/yql/providers/dq/worker_manager/ya.make new file mode 100644 index 00000000000..5e7fbb27f0d --- /dev/null +++ b/ydb/library/yql/providers/dq/worker_manager/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + ydb/library/yql/utils/failure_injector + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/gateway + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/dq/api/grpc + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/dq/runtime + ydb/library/yql/providers/dq/task_runner + ydb/library/yql/providers/dq/task_runner_actor + ydb/library/yql/providers/dq/worker_manager/interface +) + +YQL_LAST_ABI_VERSION() + +SRCS( + local_worker_manager.cpp +) + +END() diff --git a/ydb/library/yql/providers/dq/ya.make b/ydb/library/yql/providers/dq/ya.make new file mode 100644 index 00000000000..f4af5913426 --- /dev/null +++ b/ydb/library/yql/providers/dq/ya.make @@ -0,0 +1,18 @@ +RECURSE( + actors + api + common + config + counters + expr_nodes + interface + mkql + opt + planner + provider + provider/exec + runtime + task_runner + task_runner_actor + worker_manager +) diff --git a/ydb/library/yql/providers/function/common/ya.make b/ydb/library/yql/providers/function/common/ya.make new file mode 100644 index 00000000000..55e971b8dd4 --- /dev/null +++ b/ydb/library/yql/providers/function/common/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + dq_function_types.cpp +) + +PEERDIR( +) + +YQL_LAST_ABI_VERSION() + +END()
\ No newline at end of file diff --git a/ydb/library/yql/providers/function/expr_nodes/ya.make b/ydb/library/yql/providers/function/expr_nodes/ya.make new file mode 100644 index 00000000000..beb57d163e3 --- /dev/null +++ b/ydb/library/yql/providers/function/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + dq_function_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + dq_function_expr_nodes.json + dq_function_expr_nodes.gen.h + dq_function_expr_nodes.decl.inl.h + dq_function_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN dq_function_expr_nodes.json + OUT dq_function_expr_nodes.gen.h + OUT dq_function_expr_nodes.decl.inl.h + OUT dq_function_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + dq_function_expr_nodes.json + dq_function_expr_nodes.gen.h + dq_function_expr_nodes.decl.inl.h + dq_function_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN dq_function_expr_nodes.json + OUT dq_function_expr_nodes.gen.h + OUT dq_function_expr_nodes.decl.inl.h + OUT dq_function_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/function/gateway/ya.make b/ydb/library/yql/providers/function/gateway/ya.make new file mode 100644 index 00000000000..74f380bb82d --- /dev/null +++ b/ydb/library/yql/providers/function/gateway/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + dq_function_gateway.cpp +) + +PEERDIR( + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/providers/function/common + library/cpp/threading/future +) + +YQL_LAST_ABI_VERSION() + +END()
\ No newline at end of file diff --git a/ydb/library/yql/providers/function/proto/ya.make b/ydb/library/yql/providers/function/proto/ya.make new file mode 100644 index 00000000000..ebe6acfa4b5 --- /dev/null +++ b/ydb/library/yql/providers/function/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + dq_function.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/providers/function/provider/ya.make b/ydb/library/yql/providers/function/provider/ya.make new file mode 100644 index 00000000000..896a0a5844e --- /dev/null +++ b/ydb/library/yql/providers/function/provider/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +SRCS( + dq_function_load_meta.cpp + dq_function_intent_transformer.cpp + dq_function_provider.cpp + dq_function_datasource.cpp + dq_function_datasink.cpp + dq_function_type_ann.cpp + dq_function_physical_optimize.cpp + dq_function_dq_integration.cpp +) + +PEERDIR( + ydb/library/yql/dq/integration + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/providers/common/dq + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/schema/mkql + ydb/library/yql/providers/function/expr_nodes + ydb/library/yql/providers/function/common + ydb/library/yql/providers/function/gateway + ydb/library/yql/providers/function/proto + ydb/library/yql/core + ydb/library/yql/core/expr_nodes + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/opt +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/function/ya.make b/ydb/library/yql/providers/function/ya.make new file mode 100644 index 00000000000..7f56764da50 --- /dev/null +++ b/ydb/library/yql/providers/function/ya.make @@ -0,0 +1,7 @@ +RECURSE( + common + expr_nodes + gateway + proto + provider +) diff --git a/ydb/library/yql/providers/generic/actors/ya.make b/ydb/library/yql/providers/generic/actors/ya.make new file mode 100644 index 00000000000..31ec4480c9e --- /dev/null +++ b/ydb/library/yql/providers/generic/actors/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + yql_generic_read_actor.cpp + yql_generic_source_factory.cpp +) + +PEERDIR( + ydb/library/yql/dq/actors/compute + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/providers/generic/proto + ydb/library/yql/public/types + ydb/library/yql/providers/generic/connector/libcpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/generic/connector/api/protos/ya.make b/ydb/library/yql/providers/generic/connector/api/protos/ya.make new file mode 100644 index 00000000000..2c92b6c4813 --- /dev/null +++ b/ydb/library/yql/providers/generic/connector/api/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/protos +) + +ONLY_TAGS(CPP_PROTO PY3_PROTO) + +SRCS( + connector.proto +) + +END() diff --git a/ydb/library/yql/providers/generic/connector/api/ya.make b/ydb/library/yql/providers/generic/connector/api/ya.make new file mode 100644 index 00000000000..721fae90b0e --- /dev/null +++ b/ydb/library/yql/providers/generic/connector/api/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +GRPC() + +SRCS( + connector.proto +) + +ONLY_TAGS(CPP_PROTO PY3_PROTO) + +PEERDIR( + ydb/library/yql/providers/generic/connector/api/protos +) + +END() diff --git a/ydb/library/yql/providers/generic/connector/libcpp/cli/ya.make b/ydb/library/yql/providers/generic/connector/libcpp/cli/ya.make new file mode 100644 index 00000000000..96aae628605 --- /dev/null +++ b/ydb/library/yql/providers/generic/connector/libcpp/cli/ya.make @@ -0,0 +1,12 @@ +PROGRAM() + +PEERDIR( + ydb/library/yql/providers/generic/connector/libcpp + ydb/library/yql/utils/log +) + +SRC( + main.cpp +) + +END() diff --git a/ydb/library/yql/providers/generic/connector/libcpp/ya.make b/ydb/library/yql/providers/generic/connector/libcpp/ya.make new file mode 100644 index 00000000000..c94ce96f17e --- /dev/null +++ b/ydb/library/yql/providers/generic/connector/libcpp/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + client_grpc.cpp + client_mock.cpp + error.cpp + utils.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + contrib/libs/grpc + ydb/core/formats/arrow/serializer + ydb/library/yql/ast + ydb/library/yql/public/issue + ydb/library/yql/utils + ydb/library/yql/providers/generic/connector/api +) + +END() + +RECURSE( + cli +) diff --git a/ydb/library/yql/providers/generic/connector/ya.make b/ydb/library/yql/providers/generic/connector/ya.make new file mode 100644 index 00000000000..4c3781fd916 --- /dev/null +++ b/ydb/library/yql/providers/generic/connector/ya.make @@ -0,0 +1,4 @@ +RECURSE( + api + libcpp +) diff --git a/ydb/library/yql/providers/generic/expr_nodes/ya.make b/ydb/library/yql/providers/generic/expr_nodes/ya.make new file mode 100644 index 00000000000..353b4114f32 --- /dev/null +++ b/ydb/library/yql/providers/generic/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_generic_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/provider +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_generic_expr_nodes.json + yql_generic_expr_nodes.gen.h + yql_generic_expr_nodes.decl.inl.h + yql_generic_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_generic_expr_nodes.json + OUT yql_generic_expr_nodes.gen.h + OUT yql_generic_expr_nodes.decl.inl.h + OUT yql_generic_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_generic_expr_nodes.json + yql_generic_expr_nodes.gen.h + yql_generic_expr_nodes.decl.inl.h + yql_generic_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_generic_expr_nodes.json + OUT yql_generic_expr_nodes.gen.h + OUT yql_generic_expr_nodes.decl.inl.h + OUT yql_generic_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/generic/proto/ya.make b/ydb/library/yql/providers/generic/proto/ya.make new file mode 100644 index 00000000000..e757b582b86 --- /dev/null +++ b/ydb/library/yql/providers/generic/proto/ya.make @@ -0,0 +1,19 @@ +PROTO_LIBRARY() + +ONLY_TAGS(CPP_PROTO) + +PEERDIR( + ydb/library/yql/providers/generic/connector/api/protos +) + +SRCS( + range.proto + source.proto +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() + diff --git a/ydb/library/yql/providers/generic/provider/ya.make b/ydb/library/yql/providers/generic/provider/ya.make new file mode 100644 index 00000000000..ae5b7f6bae6 --- /dev/null +++ b/ydb/library/yql/providers/generic/provider/ya.make @@ -0,0 +1,51 @@ +LIBRARY() + +SRCS( + yql_generic_datasink.cpp + yql_generic_datasink_execution.cpp + yql_generic_datasink_type_ann.cpp + yql_generic_datasource.cpp + yql_generic_datasource_type_ann.cpp + yql_generic_dq_integration.cpp + yql_generic_io_discovery.cpp + yql_generic_load_meta.cpp + yql_generic_logical_opt.cpp + yql_generic_mkql_compiler.cpp + yql_generic_physical_opt.cpp + yql_generic_provider.cpp + yql_generic_provider.h + yql_generic_provider_impl.h + yql_generic_settings.cpp + yql_generic_settings.h +) + +YQL_LAST_ABI_VERSION() + +PEERDIR( + library/cpp/json + library/cpp/random_provider + library/cpp/time_provider + ydb/core/fq/libs/result_formatter + ydb/library/yql/ast + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/integration + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/providers/common/dq + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/generic/expr_nodes + ydb/library/yql/providers/generic/proto + ydb/library/yql/providers/generic/connector/libcpp +) + +END() diff --git a/ydb/library/yql/providers/generic/ya.make b/ydb/library/yql/providers/generic/ya.make new file mode 100644 index 00000000000..bef0a197e26 --- /dev/null +++ b/ydb/library/yql/providers/generic/ya.make @@ -0,0 +1,7 @@ +RECURSE( + actors + connector + expr_nodes + provider + proto +) diff --git a/ydb/library/yql/providers/pq/async_io/ya.make b/ydb/library/yql/providers/pq/async_io/ya.make new file mode 100644 index 00000000000..68a4a9d294e --- /dev/null +++ b/ydb/library/yql/providers/pq/async_io/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + dq_pq_meta_extractor.cpp + dq_pq_read_actor.cpp + dq_pq_write_actor.cpp + probes.cpp +) + +PEERDIR( + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/public/types + ydb/library/yql/utils/log + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_core + ydb/public/sdk/cpp/client/ydb_types/credentials + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/pq/proto + ydb/library/yql/providers/pq/common +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/pq/cm_client/ya.make b/ydb/library/yql/providers/pq/cm_client/ya.make new file mode 100644 index 00000000000..cee35e6232c --- /dev/null +++ b/ydb/library/yql/providers/pq/cm_client/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + client.cpp +) + +PEERDIR( + library/cpp/threading/future + ydb/library/yql/public/issue + ydb/public/sdk/cpp/client/ydb_types/credentials +) + +GENERATE_ENUM_SERIALIZATION(client.h) + +END() diff --git a/ydb/library/yql/providers/pq/common/ya.make b/ydb/library/yql/providers/pq/common/ya.make new file mode 100644 index 00000000000..379e598e8f4 --- /dev/null +++ b/ydb/library/yql/providers/pq/common/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + pq_meta_fields.cpp + yql_names.cpp +) + +PEERDIR( + ydb/library/yql/public/types +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/pq/expr_nodes/ya.make b/ydb/library/yql/providers/pq/expr_nodes/ya.make new file mode 100644 index 00000000000..b18f0a613a2 --- /dev/null +++ b/ydb/library/yql/providers/pq/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_pq_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/provider +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_pq_expr_nodes.json + yql_pq_expr_nodes.gen.h + yql_pq_expr_nodes.decl.inl.h + yql_pq_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_pq_expr_nodes.json + OUT yql_pq_expr_nodes.gen.h + OUT yql_pq_expr_nodes.decl.inl.h + OUT yql_pq_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_pq_expr_nodes.json + yql_pq_expr_nodes.gen.h + yql_pq_expr_nodes.decl.inl.h + yql_pq_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_pq_expr_nodes.json + OUT yql_pq_expr_nodes.gen.h + OUT yql_pq_expr_nodes.decl.inl.h + OUT yql_pq_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/pq/gateway/dummy/ya.make b/ydb/library/yql/providers/pq/gateway/dummy/ya.make new file mode 100644 index 00000000000..fa37f1376e2 --- /dev/null +++ b/ydb/library/yql/providers/pq/gateway/dummy/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + yql_pq_dummy_gateway.cpp +) + +PEERDIR( + ydb/library/yql/providers/pq/provider +) + +END() diff --git a/ydb/library/yql/providers/pq/gateway/native/ya.make b/ydb/library/yql/providers/pq/gateway/native/ya.make new file mode 100644 index 00000000000..bd80de45988 --- /dev/null +++ b/ydb/library/yql/providers/pq/gateway/native/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + yql_pq_gateway.cpp + yql_pq_session.cpp +) + +PEERDIR( + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/providers/common/metrics + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/pq/cm_client + ydb/library/yql/providers/pq/provider + ydb/library/yql/utils + ydb/public/sdk/cpp/client/ydb_datastreams + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_core +) + +END() diff --git a/ydb/library/yql/providers/pq/gateway/ya.make b/ydb/library/yql/providers/pq/gateway/ya.make new file mode 100644 index 00000000000..cb348c42b7d --- /dev/null +++ b/ydb/library/yql/providers/pq/gateway/ya.make @@ -0,0 +1,4 @@ +RECURSE( + dummy + native +) diff --git a/ydb/library/yql/providers/pq/proto/ya.make b/ydb/library/yql/providers/pq/proto/ya.make new file mode 100644 index 00000000000..08c5ed9851b --- /dev/null +++ b/ydb/library/yql/providers/pq/proto/ya.make @@ -0,0 +1,11 @@ +PROTO_LIBRARY() + +SRCS( + dq_io.proto + dq_io_state.proto + dq_task_params.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/providers/pq/provider/ya.make b/ydb/library/yql/providers/pq/provider/ya.make new file mode 100644 index 00000000000..4cffe33245c --- /dev/null +++ b/ydb/library/yql/providers/pq/provider/ya.make @@ -0,0 +1,56 @@ +LIBRARY() + +SRCS( + yql_pq_datasink.cpp + yql_pq_datasink_execution.cpp + yql_pq_datasink_io_discovery.cpp + yql_pq_datasink_type_ann.cpp + yql_pq_datasource.cpp + yql_pq_datasource_type_ann.cpp + yql_pq_dq_integration.cpp + yql_pq_io_discovery.cpp + yql_pq_load_meta.cpp + yql_pq_logical_opt.cpp + yql_pq_mkql_compiler.cpp + yql_pq_physical_optimize.cpp + yql_pq_provider.cpp + yql_pq_provider_impl.cpp + yql_pq_settings.cpp + yql_pq_topic_key_parser.cpp + yql_pq_helpers.cpp +) + +PEERDIR( + library/cpp/random_provider + library/cpp/time_provider + ydb/library/yql/ast + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/providers/common/structured_token + ydb/library/yql/public/udf + ydb/public/sdk/cpp/client/ydb_driver + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/integration + ydb/library/yql/dq/opt + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/dq + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/dq/provider/exec + ydb/library/yql/providers/pq/cm_client + ydb/library/yql/providers/pq/common + ydb/library/yql/providers/pq/expr_nodes + ydb/library/yql/providers/pq/proto + ydb/library/yql/providers/result/expr_nodes +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/pq/task_meta/ya.make b/ydb/library/yql/providers/pq/task_meta/ya.make new file mode 100644 index 00000000000..f6cce4fd4a5 --- /dev/null +++ b/ydb/library/yql/providers/pq/task_meta/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + task_meta.cpp +) + +PEERDIR( + ydb/library/yql/providers/dq/api/protos + ydb/library/yql/providers/pq/proto +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/pq/ya.make b/ydb/library/yql/providers/pq/ya.make new file mode 100644 index 00000000000..12e8e1374e8 --- /dev/null +++ b/ydb/library/yql/providers/pq/ya.make @@ -0,0 +1,10 @@ +RECURSE( + async_io + cm_client + common + expr_nodes + gateway + proto + provider + task_meta +) diff --git a/ydb/library/yql/providers/result/expr_nodes/ya.make b/ydb/library/yql/providers/result/expr_nodes/ya.make new file mode 100644 index 00000000000..302cc9cabba --- /dev/null +++ b/ydb/library/yql/providers/result/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_res_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/provider +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_res_expr_nodes.json + yql_res_expr_nodes.gen.h + yql_res_expr_nodes.decl.inl.h + yql_res_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_res_expr_nodes.json + OUT yql_res_expr_nodes.gen.h + OUT yql_res_expr_nodes.decl.inl.h + OUT yql_res_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_res_expr_nodes.json + yql_res_expr_nodes.gen.h + yql_res_expr_nodes.decl.inl.h + yql_res_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_res_expr_nodes.json + OUT yql_res_expr_nodes.gen.h + OUT yql_res_expr_nodes.decl.inl.h + OUT yql_res_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/result/provider/ya.make b/ydb/library/yql/providers/result/provider/ya.make new file mode 100644 index 00000000000..838f14bc6bd --- /dev/null +++ b/ydb/library/yql/providers/result/provider/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + yql_result_provider.cpp + yql_result_provider.h +) + +PEERDIR( + library/cpp/yson/node + ydb/library/yql/ast + ydb/library/yql/utils/log + ydb/library/yql/core + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/codec + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/result/expr_nodes +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/result/ya.make b/ydb/library/yql/providers/result/ya.make new file mode 100644 index 00000000000..14a0d3a7360 --- /dev/null +++ b/ydb/library/yql/providers/result/ya.make @@ -0,0 +1,4 @@ +RECURSE( + expr_nodes + provider +) diff --git a/ydb/library/yql/providers/s3/actors/ya.make b/ydb/library/yql/providers/s3/actors/ya.make new file mode 100644 index 00000000000..5fd5e258ba3 --- /dev/null +++ b/ydb/library/yql/providers/s3/actors/ya.make @@ -0,0 +1,59 @@ +LIBRARY() + +ADDINCL( + ydb/library/yql/udfs/common/clickhouse/client/base + ydb/library/yql/udfs/common/clickhouse/client/base/pcg-random + ydb/library/yql/udfs/common/clickhouse/client/src +) + +YQL_LAST_ABI_VERSION() + +SRCS( + yql_s3_actors_util.cpp + yql_s3_applicator_actor.cpp + yql_s3_sink_factory.cpp + yql_s3_source_factory.cpp + yql_s3_write_actor.cpp +) + +PEERDIR( + contrib/libs/fmt + contrib/libs/poco/Util + library/cpp/actors/http + library/cpp/string_utils/base64 + library/cpp/string_utils/quote + library/cpp/xml/document + ydb/core/fq/libs/events + ydb/library/yql/minikql/computation + ydb/library/yql/public/types + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/providers/common/schema/mkql + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/providers/common/arrow + ydb/library/yql/providers/common/arrow/interface + ydb/library/yql/providers/s3/common + ydb/library/yql/providers/s3/compressors + ydb/library/yql/providers/s3/object_listers + ydb/library/yql/providers/s3/proto + ydb/library/yql/udfs/common/clickhouse/client +) + +IF (CLANG AND NOT WITH_VALGRIND) + + SRCS( + yql_s3_read_actor.cpp + ) + + PEERDIR( + ydb/library/yql/providers/s3/range_helpers + ydb/library/yql/providers/s3/serializations + ) + + CFLAGS ( + -DARCADIA_BUILD -DUSE_PARQUET + ) + +ENDIF() + +END() diff --git a/ydb/library/yql/providers/s3/common/ya.make b/ydb/library/yql/providers/s3/common/ya.make new file mode 100644 index 00000000000..f083f80fa6f --- /dev/null +++ b/ydb/library/yql/providers/s3/common/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + util.cpp +) + +PEERDIR( + ydb/library/yql/public/issue + ydb/library/yql/public/issue/protos +) + +END() diff --git a/ydb/library/yql/providers/s3/compressors/ya.make b/ydb/library/yql/providers/s3/compressors/ya.make new file mode 100644 index 00000000000..bcf616858d1 --- /dev/null +++ b/ydb/library/yql/providers/s3/compressors/ya.make @@ -0,0 +1,38 @@ +LIBRARY() +PEERDIR( + contrib/libs/fmt + contrib/libs/poco/Util + contrib/libs/brotli/dec + contrib/libs/libbz2 + contrib/libs/lz4 + contrib/libs/lzma + contrib/libs/zstd + ydb/library/yql/udfs/common/clickhouse/client +) + +ADDINCL( + ydb/library/yql/udfs/common/clickhouse/client/base + ydb/library/yql/udfs/common/clickhouse/client/base/pcg-random + ydb/library/yql/udfs/common/clickhouse/client/src +) + +IF (CLANG AND NOT WITH_VALGRIND) + SRCS( + brotli.cpp + bzip2.cpp + gz.cpp + factory.cpp + lz4io.cpp + zstd.cpp + xz.cpp + ) +ELSE() + SRCS( + factory.cpp + ) +ENDIF() + +YQL_LAST_ABI_VERSION() + +END() + diff --git a/ydb/library/yql/providers/s3/expr_nodes/ya.make b/ydb/library/yql/providers/s3/expr_nodes/ya.make new file mode 100644 index 00000000000..25b9c7438ec --- /dev/null +++ b/ydb/library/yql/providers/s3/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_s3_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/provider +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_s3_expr_nodes.json + yql_s3_expr_nodes.gen.h + yql_s3_expr_nodes.decl.inl.h + yql_s3_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_s3_expr_nodes.json + OUT yql_s3_expr_nodes.gen.h + OUT yql_s3_expr_nodes.decl.inl.h + OUT yql_s3_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_s3_expr_nodes.json + yql_s3_expr_nodes.gen.h + yql_s3_expr_nodes.decl.inl.h + yql_s3_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_s3_expr_nodes.json + OUT yql_s3_expr_nodes.gen.h + OUT yql_s3_expr_nodes.decl.inl.h + OUT yql_s3_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/s3/object_listers/ut/ya.make b/ydb/library/yql/providers/s3/object_listers/ut/ya.make new file mode 100644 index 00000000000..a9eb2c751a5 --- /dev/null +++ b/ydb/library/yql/providers/s3/object_listers/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(ydb/library/yql/providers/s3/object_listers) + +SRCS( + yql_s3_path_ut.cpp +) + +END() diff --git a/ydb/library/yql/providers/s3/object_listers/ya.make b/ydb/library/yql/providers/s3/object_listers/ya.make new file mode 100644 index 00000000000..9688d5b4169 --- /dev/null +++ b/ydb/library/yql/providers/s3/object_listers/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + yql_s3_list.cpp + yql_s3_path.cpp +) + +GENERATE_ENUM_SERIALIZATION(yql_s3_list.h) + +PEERDIR( + contrib/libs/re2 + library/cpp/string_utils/quote + library/cpp/xml/document + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/utils + ydb/library/yql/utils/threading +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/s3/path_generator/ut/ya.make b/ydb/library/yql/providers/s3/path_generator/ut/ya.make new file mode 100644 index 00000000000..63b514992bd --- /dev/null +++ b/ydb/library/yql/providers/s3/path_generator/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/library/yql/providers/s3/path_generator) + +SRCS( + yql_generate_partitioning_rules_ut.cpp + yql_parse_partitioning_rules_ut.cpp +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/public/udf/service/stub + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/s3/path_generator/ya.make b/ydb/library/yql/providers/s3/path_generator/ya.make new file mode 100644 index 00000000000..0fb93f5456b --- /dev/null +++ b/ydb/library/yql/providers/s3/path_generator/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + yql_s3_path_generator.cpp +) + +PEERDIR( + library/cpp/scheme + ydb/library/yql/minikql/datetime + ydb/library/yql/public/udf +) + +GENERATE_ENUM_SERIALIZATION(yql_s3_path_generator.h) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/s3/proto/ya.make b/ydb/library/yql/providers/s3/proto/ya.make new file mode 100644 index 00000000000..ca0a7b0465b --- /dev/null +++ b/ydb/library/yql/providers/s3/proto/ya.make @@ -0,0 +1,16 @@ +PROTO_LIBRARY() + +SRCS( + range.proto + retry_config.proto + sink.proto + source.proto +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() + + diff --git a/ydb/library/yql/providers/s3/provider/ut/ya.make b/ydb/library/yql/providers/s3/provider/ut/ya.make new file mode 100644 index 00000000000..ffffd526f4c --- /dev/null +++ b/ydb/library/yql/providers/s3/provider/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(ydb/library/yql/providers/s3/provider) + +SRCS( + yql_s3_listing_strategy_ut.cpp +) + +END() diff --git a/ydb/library/yql/providers/s3/provider/ya.make b/ydb/library/yql/providers/s3/provider/ya.make new file mode 100644 index 00000000000..edee219f4a5 --- /dev/null +++ b/ydb/library/yql/providers/s3/provider/ya.make @@ -0,0 +1,66 @@ +LIBRARY() + +SRCS( + yql_s3_datasink.cpp + yql_s3_datasink_execution.cpp + yql_s3_datasink_type_ann.cpp + yql_s3_datasource.cpp + yql_s3_datasource_type_ann.cpp + yql_s3_dq_integration.cpp + yql_s3_exec.cpp + yql_s3_io_discovery.cpp + yql_s3_listing_strategy.cpp + yql_s3_logical_opt.cpp + yql_s3_mkql_compiler.cpp + yql_s3_phy_opt.cpp + yql_s3_provider.cpp + yql_s3_provider_impl.cpp + yql_s3_settings.cpp +) + +PEERDIR( + contrib/libs/re2 + library/cpp/json + library/cpp/protobuf/util + library/cpp/random_provider + library/cpp/retry + library/cpp/time_provider + library/cpp/xml/document + ydb/library/yql/ast + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/integration + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/dq + ydb/library/yql/providers/common/http_gateway + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/common/structured_token + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/result/expr_nodes + ydb/library/yql/providers/s3/common + ydb/library/yql/providers/s3/expr_nodes + ydb/library/yql/providers/s3/object_listers + ydb/library/yql/providers/s3/path_generator + ydb/library/yql/providers/s3/proto + ydb/library/yql/providers/s3/range_helpers + ydb/library/yql/utils + ydb/library/yql/utils/threading +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/s3/range_helpers/ut/ya.make b/ydb/library/yql/providers/s3/range_helpers/ut/ya.make new file mode 100644 index 00000000000..bc8dab1697a --- /dev/null +++ b/ydb/library/yql/providers/s3/range_helpers/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(ydb/library/yql/providers/s3/range_helpers) + +SRCS( + file_tree_builder_ut.cpp + path_list_reader_ut.cpp +) + +PEERDIR( + ydb/library/yql/providers/common/provider +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/s3/range_helpers/ya.make b/ydb/library/yql/providers/s3/range_helpers/ya.make new file mode 100644 index 00000000000..ff9a532e81c --- /dev/null +++ b/ydb/library/yql/providers/s3/range_helpers/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + file_tree_builder.cpp + path_list_reader.cpp +) + +PEERDIR( + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/s3/proto + ydb/library/yql/utils + library/cpp/protobuf/util +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/providers/s3/serializations/ya.make b/ydb/library/yql/providers/s3/serializations/ya.make new file mode 100644 index 00000000000..2a3cbaaa0d4 --- /dev/null +++ b/ydb/library/yql/providers/s3/serializations/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + serialization_interval.cpp +) + +PEERDIR( + ydb/library/yql/udfs/common/clickhouse/client +) + +ADDINCL( + ydb/library/yql/udfs/common/clickhouse/client/base + ydb/library/yql/udfs/common/clickhouse/client/base/pcg-random + ydb/library/yql/udfs/common/clickhouse/client/src +) + +GENERATE_ENUM_SERIALIZATION(serialization_interval.h) + +END() diff --git a/ydb/library/yql/providers/s3/ya.make b/ydb/library/yql/providers/s3/ya.make new file mode 100644 index 00000000000..6408970d3b3 --- /dev/null +++ b/ydb/library/yql/providers/s3/ya.make @@ -0,0 +1,11 @@ +RECURSE( + actors + common + compressors + expr_nodes + path_generator + proto + provider + range_helpers + serializations +) diff --git a/ydb/library/yql/providers/solomon/async_io/ya.make b/ydb/library/yql/providers/solomon/async_io/ya.make new file mode 100644 index 00000000000..4c803283c61 --- /dev/null +++ b/ydb/library/yql/providers/solomon/async_io/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + dq_solomon_write_actor.cpp + metrics_encoder.cpp +) + +PEERDIR( + library/cpp/json/easy_parse + library/cpp/monlib/encode/json + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/public/types + ydb/library/yql/public/udf + ydb/library/yql/utils/log + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/solomon/proto +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/solomon/expr_nodes/ya.make b/ydb/library/yql/providers/solomon/expr_nodes/ya.make new file mode 100644 index 00000000000..467764b079e --- /dev/null +++ b/ydb/library/yql/providers/solomon/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_solomon_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/provider +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_solomon_expr_nodes.json + yql_solomon_expr_nodes.gen.h + yql_solomon_expr_nodes.decl.inl.h + yql_solomon_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_solomon_expr_nodes.json + OUT yql_solomon_expr_nodes.gen.h + OUT yql_solomon_expr_nodes.decl.inl.h + OUT yql_solomon_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_solomon_expr_nodes.json + yql_solomon_expr_nodes.gen.h + yql_solomon_expr_nodes.decl.inl.h + yql_solomon_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_solomon_expr_nodes.json + OUT yql_solomon_expr_nodes.gen.h + OUT yql_solomon_expr_nodes.decl.inl.h + OUT yql_solomon_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/solomon/gateway/ya.make b/ydb/library/yql/providers/solomon/gateway/ya.make new file mode 100644 index 00000000000..79b2defe7df --- /dev/null +++ b/ydb/library/yql/providers/solomon/gateway/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + yql_solomon_gateway.cpp +) + +PEERDIR( + ydb/library/yql/providers/common/gateway + ydb/library/yql/providers/solomon/provider +) + +END() diff --git a/ydb/library/yql/providers/solomon/proto/ya.make b/ydb/library/yql/providers/solomon/proto/ya.make new file mode 100644 index 00000000000..3ec5cc25994 --- /dev/null +++ b/ydb/library/yql/providers/solomon/proto/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + dq_solomon_shard.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/providers/solomon/provider/ya.make b/ydb/library/yql/providers/solomon/provider/ya.make new file mode 100644 index 00000000000..a25ba56b044 --- /dev/null +++ b/ydb/library/yql/providers/solomon/provider/ya.make @@ -0,0 +1,35 @@ +LIBRARY() + +SRCS( + yql_solomon_config.cpp + yql_solomon_datasink_execution.cpp + yql_solomon_datasink_type_ann.cpp + yql_solomon_datasink.cpp + yql_solomon_datasource_execution.cpp + yql_solomon_datasource_type_ann.cpp + yql_solomon_datasource.cpp + yql_solomon_dq_integration.cpp + yql_solomon_io_discovery.cpp + yql_solomon_load_meta.cpp + yql_solomon_physical_optimize.cpp + yql_solomon_provider.cpp +) + +PEERDIR( + library/cpp/actors/protos + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/integration + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/result/expr_nodes + ydb/library/yql/providers/solomon/expr_nodes + ydb/library/yql/providers/solomon/proto + ydb/library/yql/dq/opt +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/solomon/ya.make b/ydb/library/yql/providers/solomon/ya.make new file mode 100644 index 00000000000..579c088007d --- /dev/null +++ b/ydb/library/yql/providers/solomon/ya.make @@ -0,0 +1,7 @@ +RECURSE( + async_io + expr_nodes + gateway + proto + provider +) diff --git a/ydb/library/yql/providers/ya.make b/ydb/library/yql/providers/ya.make new file mode 100644 index 00000000000..394652b4650 --- /dev/null +++ b/ydb/library/yql/providers/ya.make @@ -0,0 +1,13 @@ +RECURSE( + clickhouse + common + config + dq + pq + result + s3 + solomon + ydb + function + generic +) diff --git a/ydb/library/yql/providers/ydb/actors/ya.make b/ydb/library/yql/providers/ydb/actors/ya.make new file mode 100644 index 00000000000..12a2f55edf8 --- /dev/null +++ b/ydb/library/yql/providers/ydb/actors/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + yql_ydb_read_actor.cpp + yql_ydb_source_factory.cpp +) + +PEERDIR( + ydb/core/scheme + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/public/types + ydb/library/yql/utils/log + ydb/public/lib/experimental + ydb/public/sdk/cpp/client/ydb_driver + ydb/library/yql/dq/actors/compute + ydb/library/yql/providers/ydb/proto +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/ydb/comp_nodes/ya.make b/ydb/library/yql/providers/ydb/comp_nodes/ya.make new file mode 100644 index 00000000000..c2b8622bed4 --- /dev/null +++ b/ydb/library/yql/providers/ydb/comp_nodes/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +PEERDIR( + ydb/core/scheme + ydb/library/yql/minikql + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/structured_token + ydb/public/lib/experimental + ydb/public/sdk/cpp/client/ydb_driver + ydb/library/yql/providers/ydb/proto +) + +SRCS( + yql_kik_scan.cpp + yql_ydb_factory.cpp + yql_ydb_dq_transform.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/ydb/expr_nodes/ya.make b/ydb/library/yql/providers/ydb/expr_nodes/ya.make new file mode 100644 index 00000000000..f5cd450febb --- /dev/null +++ b/ydb/library/yql/providers/ydb/expr_nodes/ya.make @@ -0,0 +1,52 @@ +LIBRARY() + +SRCS( + yql_ydb_expr_nodes.cpp +) + +PEERDIR( + ydb/library/yql/core/expr_nodes + ydb/library/yql/providers/common/provider +) + +SRCDIR( + ydb/library/yql/core/expr_nodes_gen +) + +IF(EXPORT_CMAKE) + RUN_PYTHON3( + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/gen/__main__.py + yql_expr_nodes_gen.jnj + yql_ydb_expr_nodes.json + yql_ydb_expr_nodes.gen.h + yql_ydb_expr_nodes.decl.inl.h + yql_ydb_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_ydb_expr_nodes.json + OUT yql_ydb_expr_nodes.gen.h + OUT yql_ydb_expr_nodes.decl.inl.h + OUT yql_ydb_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h + ) +ELSE() + RUN_PROGRAM( + ydb/library/yql/core/expr_nodes_gen/gen + yql_expr_nodes_gen.jnj + yql_ydb_expr_nodes.json + yql_ydb_expr_nodes.gen.h + yql_ydb_expr_nodes.decl.inl.h + yql_ydb_expr_nodes.defs.inl.h + IN yql_expr_nodes_gen.jnj + IN yql_ydb_expr_nodes.json + OUT yql_ydb_expr_nodes.gen.h + OUT yql_ydb_expr_nodes.decl.inl.h + OUT yql_ydb_expr_nodes.defs.inl.h + OUTPUT_INCLUDES + ${ARCADIA_ROOT}/ydb/library/yql/core/expr_nodes_gen/yql_expr_nodes_gen.h + ${ARCADIA_ROOT}/util/generic/hash_set.h +) +ENDIF() + +END() diff --git a/ydb/library/yql/providers/ydb/proto/ya.make b/ydb/library/yql/providers/ydb/proto/ya.make new file mode 100644 index 00000000000..a885940aa11 --- /dev/null +++ b/ydb/library/yql/providers/ydb/proto/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +SRCS( + range.proto + source.proto +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() + diff --git a/ydb/library/yql/providers/ydb/provider/ya.make b/ydb/library/yql/providers/ydb/provider/ya.make new file mode 100644 index 00000000000..3d421926340 --- /dev/null +++ b/ydb/library/yql/providers/ydb/provider/ya.make @@ -0,0 +1,56 @@ +LIBRARY() + +SRCS( + yql_ydb_datasink.cpp + yql_ydb_datasink_execution.cpp + yql_ydb_datasink_type_ann.cpp + yql_ydb_datasource.cpp + yql_ydb_datasource_type_ann.cpp + yql_ydb_dq_integration.cpp + yql_ydb_exec.cpp + yql_ydb_io_discovery.cpp + yql_ydb_load_meta.cpp + yql_ydb_logical_opt.cpp + yql_ydb_physical_opt.cpp + yql_ydb_mkql_compiler.cpp + yql_ydb_provider.cpp + yql_ydb_provider_impl.cpp + yql_ydb_settings.cpp +) + +PEERDIR( + library/cpp/random_provider + library/cpp/time_provider + library/cpp/yson/node + ydb/core/fq/libs/common + ydb/library/yql/ast + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/providers/common/structured_token + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/core + ydb/library/yql/core/type_ann + ydb/library/yql/dq/expr_nodes + ydb/library/yql/dq/integration + ydb/library/yql/providers/common/config + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/providers/common/dq + ydb/library/yql/providers/common/mkql + ydb/library/yql/providers/common/proto + ydb/library/yql/providers/common/provider + ydb/library/yql/providers/common/schema/expr + ydb/library/yql/providers/common/transform + ydb/library/yql/providers/dq/common + ydb/library/yql/providers/dq/expr_nodes + ydb/library/yql/providers/result/expr_nodes + ydb/library/yql/providers/ydb/expr_nodes + ydb/library/yql/providers/ydb/proto + ydb/public/lib/experimental + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/providers/ydb/ya.make b/ydb/library/yql/providers/ydb/ya.make new file mode 100644 index 00000000000..a79e0f4cfcc --- /dev/null +++ b/ydb/library/yql/providers/ydb/ya.make @@ -0,0 +1,7 @@ +RECURSE( + actors + comp_nodes + expr_nodes + proto + provider +) diff --git a/ydb/library/yql/public/decimal/ut/ya.make b/ydb/library/yql/public/decimal/ut/ya.make new file mode 100644 index 00000000000..ed3afffd539 --- /dev/null +++ b/ydb/library/yql/public/decimal/ut/ya.make @@ -0,0 +1,5 @@ +UNITTEST_FOR(ydb/library/yql/public/decimal) + +SRCS(yql_decimal_ut.cpp yql_wide_int_ut.cpp) + +END() diff --git a/ydb/library/yql/public/decimal/ya.make b/ydb/library/yql/public/decimal/ya.make new file mode 100644 index 00000000000..a9c23995b33 --- /dev/null +++ b/ydb/library/yql/public/decimal/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + yql_decimal.h + yql_decimal.cpp + yql_decimal_serialize.h + yql_decimal_serialize.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/public/issue/protos/ya.make b/ydb/library/yql/public/issue/protos/ya.make new file mode 100644 index 00000000000..2451631ea13 --- /dev/null +++ b/ydb/library/yql/public/issue/protos/ya.make @@ -0,0 +1,10 @@ +PROTO_LIBRARY() + +SRCS( + issue_message.proto + issue_severity.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/public/issue/ut/ya.make b/ydb/library/yql/public/issue/ut/ya.make new file mode 100644 index 00000000000..681a0f37180 --- /dev/null +++ b/ydb/library/yql/public/issue/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/library/yql/public/issue) + +FORK_SUBTESTS() + +SRCS( + yql_issue_ut.cpp + yql_issue_manager_ut.cpp + yql_issue_utils_ut.cpp + yql_warning_ut.cpp +) + +PEERDIR( + library/cpp/unicode/normalization +) + +END() diff --git a/ydb/library/yql/public/issue/ya.make b/ydb/library/yql/public/issue/ya.make new file mode 100644 index 00000000000..65441b9531c --- /dev/null +++ b/ydb/library/yql/public/issue/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +SRCS( + yql_issue.cpp + yql_issue_message.cpp + yql_issue_manager.cpp + yql_issue_utils.cpp + yql_warning.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/colorizer + library/cpp/resource + ydb/public/api/protos + ydb/library/yql/public/issue/protos + ydb/library/yql/utils +) + +GENERATE_ENUM_SERIALIZATION(yql_warning.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/public/types/ya.make b/ydb/library/yql/public/types/ya.make new file mode 100644 index 00000000000..33bc862ad8f --- /dev/null +++ b/ydb/library/yql/public/types/ya.make @@ -0,0 +1,9 @@ +PROTO_LIBRARY() + +SRCS( + yql_types.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/library/yql/public/udf/arrow/ya.make b/ydb/library/yql/public/udf/arrow/ya.make new file mode 100644 index 00000000000..eda9328ee7f --- /dev/null +++ b/ydb/library/yql/public/udf/arrow/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + args_dechunker.cpp + udf_arrow_helpers.cpp + bit_util.cpp + util.cpp + block_reader.cpp + block_item.cpp + block_item_comparator.cpp +) + +PEERDIR( + ydb/library/yql/public/udf + contrib/libs/apache/arrow +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/public/udf/service/exception_policy/ya.make b/ydb/library/yql/public/udf/service/exception_policy/ya.make new file mode 100644 index 00000000000..07ae48d61a9 --- /dev/null +++ b/ydb/library/yql/public/udf/service/exception_policy/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PROVIDES(YqlServicePolicy) + +SRCS( + udf_service.cpp +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/public/udf +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/public/udf/service/stub/ya.make b/ydb/library/yql/public/udf/service/stub/ya.make new file mode 100644 index 00000000000..17fe7a7dbd7 --- /dev/null +++ b/ydb/library/yql/public/udf/service/stub/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +PROVIDES(YqlServicePolicy) + +SRCS( + udf_service.cpp +) + +PEERDIR( + ydb/library/yql/public/udf +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/public/udf/service/terminate_policy/ya.make b/ydb/library/yql/public/udf/service/terminate_policy/ya.make new file mode 100644 index 00000000000..07ae48d61a9 --- /dev/null +++ b/ydb/library/yql/public/udf/service/terminate_policy/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +PROVIDES(YqlServicePolicy) + +SRCS( + udf_service.cpp +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/public/udf +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/public/udf/support/ya.make b/ydb/library/yql/public/udf/support/ya.make new file mode 100644 index 00000000000..0e5b0f199b7 --- /dev/null +++ b/ydb/library/yql/public/udf/support/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + udf_support.cpp +) + +PEERDIR( + ydb/library/yql/public/udf +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/public/udf/tz/gen/ya.make b/ydb/library/yql/public/udf/tz/gen/ya.make new file mode 100644 index 00000000000..cb6446554c4 --- /dev/null +++ b/ydb/library/yql/public/udf/tz/gen/ya.make @@ -0,0 +1,15 @@ + +PY3_PROGRAM(tz_gen) + +SRCDIR(ydb/library/yql/public/udf/tz) + +PY_SRCS( + TOP_LEVEL + update.py +) + +PY_MAIN(update) + +END() + + diff --git a/ydb/library/yql/public/udf/tz/ut/ya.make b/ydb/library/yql/public/udf/tz/ut/ya.make new file mode 100644 index 00000000000..c16f76b03b9 --- /dev/null +++ b/ydb/library/yql/public/udf/tz/ut/ya.make @@ -0,0 +1,10 @@ +UNITTEST_FOR(ydb/library/yql/public/udf/tz) + +SRCS( + udf_tz_ut.cpp +) + +PEERDIR( +) + +END() diff --git a/ydb/library/yql/public/udf/tz/ya.make b/ydb/library/yql/public/udf/tz/ya.make new file mode 100644 index 00000000000..b4c33147891 --- /dev/null +++ b/ydb/library/yql/public/udf/tz/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + udf_tz.cpp + udf_tz.h +) + +PEERDIR( +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/public/udf/ut/ya.make b/ydb/library/yql/public/udf/ut/ya.make new file mode 100644 index 00000000000..6e38ca232cd --- /dev/null +++ b/ydb/library/yql/public/udf/ut/ya.make @@ -0,0 +1,16 @@ +UNITTEST_FOR(ydb/library/yql/public/udf) + +SRCS( + udf_counter_ut.cpp + udf_value_ut.cpp + udf_value_builder_ut.cpp +) + +YQL_LAST_ABI_VERSION() + +PEERDIR( + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +END() diff --git a/ydb/library/yql/public/udf/ya.make b/ydb/library/yql/public/udf/ya.make new file mode 100644 index 00000000000..c64ec22c8b3 --- /dev/null +++ b/ydb/library/yql/public/udf/ya.make @@ -0,0 +1,56 @@ +LIBRARY() + +SRCS( + udf_allocator.cpp + udf_allocator.h + udf_counter.cpp + udf_counter.h + udf_data_type.cpp + udf_data_type.h + udf_helpers.cpp + udf_helpers.h + udf_pg_type_description.h + udf_ptr.h + udf_registrator.cpp + udf_registrator.h + udf_static_registry.cpp + udf_static_registry.h + udf_string.cpp + udf_string.h + udf_type_builder.cpp + udf_type_builder.h + udf_type_inspection.cpp + udf_type_inspection.h + udf_type_ops.h + udf_type_printer.cpp + udf_type_printer.h + udf_type_size_check.h + udf_types.cpp + udf_types.h + udf_ut_helpers.h + udf_validate.cpp + udf_validate.h + udf_value.cpp + udf_value.h + udf_value_builder.cpp + udf_value_builder.h + udf_value_inl.h + udf_version.cpp + udf_version.h +) + +PEERDIR( + library/cpp/deprecated/enum_codegen + library/cpp/resource + ydb/library/yql/public/decimal + ydb/library/yql/public/types + library/cpp/deprecated/atomic +) + +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/public/ya.make b/ydb/library/yql/public/ya.make new file mode 100644 index 00000000000..f41406c3bdc --- /dev/null +++ b/ydb/library/yql/public/ya.make @@ -0,0 +1,11 @@ +RECURSE( + decimal + issue + types + udf + udf/arrow + udf/service/exception_policy + udf/service/stub + udf/service/terminate_policy + udf/tz/gen +) diff --git a/ydb/library/yql/sql/pg/ut/ya.make b/ydb/library/yql/sql/pg/ut/ya.make new file mode 100644 index 00000000000..985e682fe71 --- /dev/null +++ b/ydb/library/yql/sql/pg/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/library/yql/sql/pg) + +SRCS( + pg_sql_ut.cpp +) + +PEERDIR( + contrib/libs/fmt + + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql + ydb/library/yql/sql/pg +) + +SIZE(MEDIUM) + +END() diff --git a/ydb/library/yql/sql/pg/ya.make b/ydb/library/yql/sql/pg/ya.make new file mode 100644 index 00000000000..531e41df312 --- /dev/null +++ b/ydb/library/yql/sql/pg/ya.make @@ -0,0 +1,39 @@ +LIBRARY() + +PROVIDES( + yql_pg_sql_translator +) + +PEERDIR( + ydb/library/yql/ast + ydb/library/yql/core + ydb/library/yql/parser/pg_catalog + ydb/library/yql/parser/pg_wrapper + ydb/library/yql/sql/settings +) + +ADDINCL( + ydb/library/yql/parser/pg_wrapper/postgresql/src/include +) + +SRCS( + pg_sql.cpp + utils.cpp +) + +IF (OS_WINDOWS) +CFLAGS( + "-D__thread=__declspec(thread)" + -Dfstat=microsoft_native_fstat + -Dstat=microsoft_native_stat +) +ENDIF() + +NO_COMPILER_WARNINGS() +YQL_LAST_ABI_VERSION() + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/sql/pg_dummy/ya.make b/ydb/library/yql/sql/pg_dummy/ya.make new file mode 100644 index 00000000000..742914bbea0 --- /dev/null +++ b/ydb/library/yql/sql/pg_dummy/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PROVIDES( + yql_pg_sql_translator + yql_pg_runtime +) + +PEERDIR( + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/minikql +) + +SRCS( + pg_sql_dummy.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/sql/settings/ya.make b/ydb/library/yql/sql/settings/ya.make new file mode 100644 index 00000000000..d703c6b7098 --- /dev/null +++ b/ydb/library/yql/sql/settings/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + partitioning.cpp + translation_settings.cpp +) + +PEERDIR( + library/cpp/deprecated/split + library/cpp/json + ydb/library/yql/core/issue + ydb/library/yql/core/issue/protos + ydb/library/yql/utils +) + +END() diff --git a/ydb/library/yql/sql/v0/lexer/ya.make b/ydb/library/yql/sql/v0/lexer/ya.make new file mode 100644 index 00000000000..14466fb7807 --- /dev/null +++ b/ydb/library/yql/sql/v0/lexer/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/core/issue/protos + ydb/library/yql/parser/proto_ast + ydb/library/yql/parser/proto_ast/gen/v0 +) + +SRCS( + lexer.cpp +) + +END() diff --git a/ydb/library/yql/sql/v0/ut/ya.make b/ydb/library/yql/sql/v0/ut/ya.make new file mode 100644 index 00000000000..f26d9a2dda8 --- /dev/null +++ b/ydb/library/yql/sql/v0/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/library/yql/sql/v0) + +SRCS( + sql_ut.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql + ydb/library/yql/sql/pg_dummy +) + +TIMEOUT(300) + +SIZE(MEDIUM) + +END() diff --git a/ydb/library/yql/sql/v0/ya.make b/ydb/library/yql/sql/v0/ya.make new file mode 100644 index 00000000000..826ad664928 --- /dev/null +++ b/ydb/library/yql/sql/v0/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +PEERDIR( + library/cpp/charset + library/cpp/enumbitset + ydb/library/yql/minikql + ydb/library/yql/public/udf + ydb/library/yql/sql/settings + ydb/library/yql/core + ydb/library/yql/core/issue + ydb/library/yql/core/issue/protos + ydb/library/yql/parser/proto_ast + ydb/library/yql/parser/proto_ast/collect_issues + ydb/library/yql/parser/proto_ast/gen/v0 +) + +SRCS( + aggregation.cpp + builtin.cpp + context.cpp + join.cpp + insert.cpp + list_builtin.cpp + node.cpp + select.cpp + sql.cpp + query.cpp +) + +YQL_LAST_ABI_VERSION() + +GENERATE_ENUM_SERIALIZATION(node.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/sql/v1/format/ut/ya.make b/ydb/library/yql/sql/v1/format/ut/ya.make new file mode 100644 index 00000000000..ad0030329d3 --- /dev/null +++ b/ydb/library/yql/sql/v1/format/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(ydb/library/yql/sql/v1/format) + +SRCS( + sql_format_ut.cpp +) + +END() diff --git a/ydb/library/yql/sql/v1/format/ya.make b/ydb/library/yql/sql/v1/format/ya.make new file mode 100644 index 00000000000..d7172083ca2 --- /dev/null +++ b/ydb/library/yql/sql/v1/format/ya.make @@ -0,0 +1,24 @@ +LIBRARY()
+
+OWNER(g:yql)
+
+SRCS(
+ sql_format.cpp
+)
+
+RESOURCE(DONT_PARSE ../SQLv1.g.in SQLv1.g.in)
+
+PEERDIR(
+ ydb/library/yql/parser/lexer_common
+ ydb/library/yql/sql/settings
+ ydb/library/yql/sql/v1/lexer
+ ydb/library/yql/sql/v1/proto_parser
+ library/cpp/protobuf/util
+ library/cpp/resource
+)
+
+END()
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/ydb/library/yql/sql/v1/lexer/ya.make b/ydb/library/yql/sql/v1/lexer/ya.make new file mode 100644 index 00000000000..75abcae1f05 --- /dev/null +++ b/ydb/library/yql/sql/v1/lexer/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/core/issue/protos + ydb/library/yql/parser/proto_ast + ydb/library/yql/parser/proto_ast/gen/v1 + ydb/library/yql/parser/proto_ast/gen/v1_ansi + ydb/library/yql/parser/proto_ast/gen/v1_proto +) + +SRCS( + lexer.cpp +) + +SUPPRESSIONS( + tsan.supp +) + +END() diff --git a/ydb/library/yql/sql/v1/perf/ya.make b/ydb/library/yql/sql/v1/perf/ya.make new file mode 100644 index 00000000000..8b00e4662ac --- /dev/null +++ b/ydb/library/yql/sql/v1/perf/ya.make @@ -0,0 +1,14 @@ +PROGRAM() + +SRCS( + parse.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql + ydb/library/yql/sql/v1 + ydb/library/yql/sql/pg_dummy +) + +END() diff --git a/ydb/library/yql/sql/v1/proto_parser/ya.make b/ydb/library/yql/sql/v1/proto_parser/ya.make new file mode 100644 index 00000000000..d0667167e0f --- /dev/null +++ b/ydb/library/yql/sql/v1/proto_parser/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + ydb/library/yql/utils + + ydb/library/yql/parser/proto_ast + ydb/library/yql/parser/proto_ast/collect_issues + ydb/library/yql/parser/proto_ast/gen/v1 + ydb/library/yql/parser/proto_ast/gen/v1_ansi + ydb/library/yql/parser/proto_ast/gen/v1_proto +) + +SRCS( + proto_parser.cpp +) + +END() diff --git a/ydb/library/yql/sql/v1/ut/ya.make b/ydb/library/yql/sql/v1/ut/ya.make new file mode 100644 index 00000000000..9b30b19e71f --- /dev/null +++ b/ydb/library/yql/sql/v1/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/library/yql/sql/v1) + +SRCS( + sql_ut.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql + ydb/library/yql/sql/pg_dummy +) + +TIMEOUT(300) + +SIZE(MEDIUM) + +END() diff --git a/ydb/library/yql/sql/v1/ya.make b/ydb/library/yql/sql/v1/ya.make new file mode 100644 index 00000000000..aeab18c5b9d --- /dev/null +++ b/ydb/library/yql/sql/v1/ya.make @@ -0,0 +1,50 @@ +LIBRARY() + +PEERDIR( + library/cpp/charset + library/cpp/enumbitset + library/cpp/yson/node + library/cpp/json + ydb/library/yql/core/sql_types + ydb/library/yql/minikql + ydb/library/yql/public/udf + ydb/library/yql/sql/settings + ydb/library/yql/core + ydb/library/yql/core/issue + ydb/library/yql/core/issue/protos + ydb/library/yql/parser/lexer_common + ydb/library/yql/parser/proto_ast + ydb/library/yql/parser/proto_ast/collect_issues + ydb/library/yql/parser/proto_ast/gen/v1 + ydb/library/yql/parser/proto_ast/gen/v1_ansi + ydb/library/yql/parser/proto_ast/gen/v1_proto + ydb/library/yql/parser/pg_catalog + ydb/library/yql/sql/v1/lexer + ydb/library/yql/sql/v1/proto_parser +) + +SRCS( + aggregation.cpp + builtin.cpp + context.cpp + join.cpp + insert.cpp + list_builtin.cpp + node.cpp + select.cpp + sql.cpp + query.cpp + object_processing.cpp +) + +YQL_LAST_ABI_VERSION() + +GENERATE_ENUM_SERIALIZATION(node.h) + +GENERATE_ENUM_SERIALIZATION(sql_call_param.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/sql/ya.make b/ydb/library/yql/sql/ya.make new file mode 100644 index 00000000000..9d4ff1450c5 --- /dev/null +++ b/ydb/library/yql/sql/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +PEERDIR( + library/cpp/deprecated/split + ydb/library/yql/parser/pg_wrapper/interface + ydb/library/yql/sql/settings + ydb/library/yql/sql/v0 + ydb/library/yql/sql/v0/lexer + ydb/library/yql/sql/v1 + ydb/library/yql/sql/v1/format + ydb/library/yql/sql/v1/lexer + ydb/library/yql/sql/v1/proto_parser + ydb/library/yql/utils +) + +SRCS( + cluster_mapping.cpp + sql.cpp +) + +END() + +RECURSE( + pg + pg_dummy +) diff --git a/ydb/library/yql/udfs/common/clickhouse/client/ya.make b/ydb/library/yql/udfs/common/clickhouse/client/ya.make new file mode 100644 index 00000000000..f874768f815 --- /dev/null +++ b/ydb/library/yql/udfs/common/clickhouse/client/ya.make @@ -0,0 +1,443 @@ +IF (CLANG AND NOT WITH_VALGRIND) + YQL_UDF(clickhouse_client_udf) + + YQL_LAST_ABI_VERSION() + + NO_COMPILER_WARNINGS() + + SRCS( + clickhouse_client_udf.cpp + + base/common/DateLUT.cpp + base/common/DateLUTImpl.cpp + base/common/demangle.cpp + base/common/errnoToString.cpp + base/common/getFQDNOrHostName.cpp + base/common/getPageSize.cpp + base/common/getThreadId.cpp + base/common/JSON.cpp + base/common/mremap.cpp + base/common/shift10.cpp + base/common/sleep.cpp + base/common/StringRef.cpp + base/common/getResource.cpp + base/common/preciseExp10.cpp + + src/Common/AlignedBuffer.cpp + src/Common/Allocator.cpp + src/Common/checkStackSize.cpp + src/Common/createHardLink.cpp + src/Common/CurrentMetrics.cpp + src/Common/Epoll.cpp + src/Common/escapeForFileName.cpp + src/Common/formatIPv6.cpp + src/Common/formatReadable.cpp + src/Common/getMultipleKeysFromConfig.cpp + src/Common/getNumberOfPhysicalCPUCores.cpp + src/Common/hasLinuxCapability.cpp + src/Common/hex.cpp + src/Common/isLocalAddress.cpp + src/Common/IntervalKind.cpp + src/Common/parseAddress.cpp + src/Common/ClickHouseRevision.cpp + src/Common/CurrentMemoryTracker.cpp + src/Common/CurrentThread.cpp + src/Common/DNSResolver.cpp + src/Common/Exception.cpp + src/Common/ErrorCodes.cpp + src/Common/FieldVisitorDump.cpp + src/Common/FieldVisitorToString.cpp + src/Common/FieldVisitorWriteBinary.cpp + src/Common/IPv6ToBinary.cpp + src/Common/MemoryTracker.cpp + src/Common/OpenSSLHelpers.cpp + src/Common/PipeFDs.cpp + src/Common/PODArray.cpp + src/Common/ProcfsMetricsProvider.cpp + src/Common/ProfileEvents.cpp + src/Common/quoteString.cpp + src/Common/randomSeed.cpp + src/Common/RemoteHostFilter.cpp + src/Common/setThreadName.cpp + src/Common/TaskStatsInfoGetter.cpp + src/Common/ThreadPool.cpp + src/Common/ThreadProfileEvents.cpp + src/Common/ThreadStatus.cpp + src/Common/Throttler.cpp + src/Common/TimerDescriptor.cpp + src/Common/thread_local_rng.cpp + src/Common/ZooKeeper/IKeeper.cpp + + src/Common/Config/AbstractConfigurationComparison.cpp + + src/Core/BaseSettings.cpp + src/Core/Block.cpp + src/Core/BlockInfo.cpp + src/Core/Field.cpp + src/Core/ColumnWithTypeAndName.cpp + src/Core/NamesAndTypes.cpp + src/Core/Settings.cpp + src/Core/SettingsEnums.cpp + src/Core/SettingsFields.cpp + + src/Formats/FormatFactory.cpp + src/Formats/JSONEachRowUtils.cpp + src/Formats/NativeFormat.cpp + src/Formats/ProtobufReader.cpp + src/Formats/ProtobufWriter.cpp + src/Formats/registerFormats.cpp + src/Formats/verbosePrintString.cpp + + src/AggregateFunctions/AggregateFunctionFactory.cpp + src/AggregateFunctions/AggregateFunctionCombinatorFactory.cpp + src/AggregateFunctions/IAggregateFunction.cpp + + #src/Columns/Collator.cpp + src/Columns/ColumnAggregateFunction.cpp + src/Columns/ColumnArray.cpp + src/Columns/ColumnCompressed.cpp + src/Columns/ColumnConst.cpp + src/Columns/ColumnFunction.cpp + src/Columns/ColumnNullable.cpp + src/Columns/ColumnsCommon.cpp + src/Columns/ColumnString.cpp + src/Columns/ColumnTuple.cpp + src/Columns/ColumnVector.cpp + src/Columns/ColumnDecimal.cpp + src/Columns/ColumnFixedString.cpp + src/Columns/ColumnLowCardinality.cpp + src/Columns/ColumnMap.cpp + src/Columns/FilterDescription.cpp + src/Columns/IColumn.cpp + src/Columns/MaskOperations.cpp + + src/IO/AsynchronousReadBufferFromFile.cpp + src/IO/AsynchronousReadBufferFromFileDescriptor.cpp + src/IO/CompressionMethod.cpp + src/IO/copyData.cpp + src/IO/createReadBufferFromFileBase.cpp + src/IO/DoubleConverter.cpp + src/IO/MMappedFile.cpp + src/IO/MMappedFileDescriptor.cpp + src/IO/MMapReadBufferFromFile.cpp + src/IO/MMapReadBufferFromFileDescriptor.cpp + src/IO/MMapReadBufferFromFileWithCache.cpp + src/IO/OpenedFile.cpp + src/IO/parseDateTimeBestEffort.cpp + src/IO/PeekableReadBuffer.cpp + src/IO/Progress.cpp + src/IO/ReadBufferFromFile.cpp + src/IO/ReadBufferFromFileBase.cpp + src/IO/ReadBufferFromFileDescriptor.cpp + src/IO/ReadBufferFromMemory.cpp + src/IO/ReadBufferFromPocoSocket.cpp + src/IO/readFloatText.cpp + src/IO/ReadHelpers.cpp + src/IO/ReadSettings.cpp + src/IO/SynchronousReader.cpp + src/IO/TimeoutSetter.cpp + src/IO/ThreadPoolReader.cpp + src/IO/UseSSL.cpp + src/IO/WriteHelpers.cpp + src/IO/WriteBufferFromFile.cpp + src/IO/WriteBufferFromFileBase.cpp + src/IO/WriteBufferFromFileDescriptor.cpp + src/IO/WriteBufferFromFileDescriptorDiscardOnFailure.cpp + src/IO/WriteBufferFromPocoSocket.cpp + src/IO/WriteBufferValidUTF8.cpp + + src/Compression/CompressionCodecLZ4.cpp + src/Compression/CompressionCodecMultiple.cpp + src/Compression/CompressionCodecNone.cpp + src/Compression/CompressionFactory.cpp + src/Compression/CompressedReadBuffer.cpp + src/Compression/CompressedReadBufferBase.cpp + src/Compression/CompressedReadBufferFromFile.cpp + src/Compression/CompressedWriteBuffer.cpp + src/Compression/ICompressionCodec.cpp + src/Compression/LZ4_decompress_faster.cpp + + src/DataStreams/BlockStreamProfileInfo.cpp + src/DataStreams/ColumnGathererStream.cpp + src/DataStreams/ExecutionSpeedLimits.cpp + src/DataStreams/IBlockInputStream.cpp + src/DataStreams/materializeBlock.cpp + src/DataStreams/NativeBlockInputStream.cpp + src/DataStreams/NativeBlockOutputStream.cpp + src/DataStreams/SizeLimits.cpp + + src/DataTypes/DataTypeArray.cpp + src/DataTypes/DataTypeDate.cpp + src/DataTypes/DataTypeDateTime.cpp + src/DataTypes/DataTypeEnum.cpp + src/DataTypes/DataTypeFactory.cpp + src/DataTypes/DataTypeFunction.cpp + src/DataTypes/DataTypeNested.cpp + src/DataTypes/DataTypeNothing.cpp + src/DataTypes/DataTypeNullable.cpp + src/DataTypes/DataTypeNumberBase.cpp + src/DataTypes/DataTypesNumber.cpp + src/DataTypes/DataTypeString.cpp + src/DataTypes/DataTypeTuple.cpp + src/DataTypes/DataTypeUUID.cpp + src/DataTypes/DataTypesDecimal.cpp + src/DataTypes/DataTypeDecimalBase.cpp + src/DataTypes/DataTypeLowCardinality.cpp + src/DataTypes/DataTypeMap.cpp + src/DataTypes/DataTypeInterval.cpp + src/DataTypes/DataTypeDate32.cpp + src/DataTypes/DataTypeFixedString.cpp + src/DataTypes/DataTypeDateTime64.cpp + src/DataTypes/DataTypeAggregateFunction.cpp + src/DataTypes/DataTypeCustomGeo.cpp + src/DataTypes/DataTypeCustomIPv4AndIPv6.cpp + src/DataTypes/DataTypeCustomSimpleAggregateFunction.cpp + src/DataTypes/DataTypeLowCardinalityHelpers.cpp + src/DataTypes/EnumValues.cpp + src/DataTypes/IDataType.cpp + src/DataTypes/getLeastSupertype.cpp + src/DataTypes/NestedUtils.cpp + src/DataTypes/registerDataTypeDateTime.cpp + + src/DataTypes/Serializations/ISerialization.cpp + src/DataTypes/Serializations/SerializationArray.cpp + src/DataTypes/Serializations/SerializationDate.cpp + src/DataTypes/Serializations/SerializationDateTime.cpp + src/DataTypes/Serializations/SerializationEnum.cpp + src/DataTypes/Serializations/SerializationNothing.cpp + src/DataTypes/Serializations/SerializationNullable.cpp + src/DataTypes/Serializations/SerializationNumber.cpp + src/DataTypes/Serializations/SerializationString.cpp + src/DataTypes/Serializations/SerializationTuple.cpp + src/DataTypes/Serializations/SerializationTupleElement.cpp + src/DataTypes/Serializations/SerializationUUID.cpp + src/DataTypes/Serializations/SerializationWrapper.cpp + src/DataTypes/Serializations/SerializationDecimal.cpp + src/DataTypes/Serializations/SerializationDecimalBase.cpp + src/DataTypes/Serializations/SerializationMap.cpp + src/DataTypes/Serializations/SerializationLowCardinality.cpp + src/DataTypes/Serializations/SerializationDate32.cpp + src/DataTypes/Serializations/SerializationFixedString.cpp + src/DataTypes/Serializations/SerializationDateTime64.cpp + src/DataTypes/Serializations/SerializationIP.cpp + src/DataTypes/Serializations/SerializationAggregateFunction.cpp + src/DataTypes/Serializations/SerializationCustomSimpleText.cpp + + src/Parsers/ASTAlterQuery.cpp + src/Parsers/ASTAsterisk.cpp + src/Parsers/ASTBackupQuery.cpp + src/Parsers/ASTColumnDeclaration.cpp + src/Parsers/ASTColumnsMatcher.cpp + src/Parsers/ASTColumnsTransformers.cpp + src/Parsers/ASTConstraintDeclaration.cpp + src/Parsers/ASTCreateQuery.cpp + src/Parsers/ASTDatabaseOrNone.cpp + src/Parsers/ASTDictionary.cpp + src/Parsers/ASTDictionaryAttributeDeclaration.cpp + src/Parsers/ASTDropQuery.cpp + src/Parsers/ASTExpressionList.cpp + src/Parsers/ASTFunction.cpp + src/Parsers/ASTFunctionWithKeyValueArguments.cpp + src/Parsers/ASTIdentifier.cpp + src/Parsers/ASTIndexDeclaration.cpp + src/Parsers/ASTKillQueryQuery.cpp + src/Parsers/ASTLiteral.cpp + src/Parsers/ASTNameTypePair.cpp + src/Parsers/ASTOptimizeQuery.cpp + src/Parsers/ASTOrderByElement.cpp + src/Parsers/ASTPartition.cpp + src/Parsers/ASTProjectionDeclaration.cpp + src/Parsers/ASTProjectionSelectQuery.cpp + src/Parsers/ASTQualifiedAsterisk.cpp + src/Parsers/ASTQueryWithOnCluster.cpp + src/Parsers/ASTQueryWithOutput.cpp + src/Parsers/ASTQueryWithTableAndOutput.cpp + src/Parsers/ASTRolesOrUsersSet.cpp + src/Parsers/ASTSelectQuery.cpp + src/Parsers/ASTSelectWithUnionQuery.cpp + src/Parsers/ASTSetQuery.cpp + src/Parsers/ASTSetRoleQuery.cpp + src/Parsers/ASTSettingsProfileElement.cpp + src/Parsers/ASTShowGrantsQuery.cpp + src/Parsers/ASTShowTablesQuery.cpp + src/Parsers/ASTSubquery.cpp + src/Parsers/ASTTablesInSelectQuery.cpp + src/Parsers/ASTTTLElement.cpp + src/Parsers/ASTWindowDefinition.cpp + src/Parsers/ASTWithAlias.cpp + src/Parsers/ASTQueryParameter.cpp + src/Parsers/ASTInsertQuery.cpp + src/Parsers/ASTWithElement.cpp + src/Parsers/ASTSampleRatio.cpp + src/Parsers/ASTSystemQuery.cpp + src/Parsers/ASTUserNameWithHost.cpp + src/Parsers/CommonParsers.cpp + src/Parsers/ExpressionElementParsers.cpp + src/Parsers/ExpressionListParsers.cpp + src/Parsers/formatAST.cpp + src/Parsers/formatSettingName.cpp + src/Parsers/IAST.cpp + src/Parsers/InsertQuerySettingsPushDownVisitor.cpp + src/Parsers/IParserBase.cpp + src/Parsers/Lexer.cpp + src/Parsers/parseDatabaseAndTableName.cpp + src/Parsers/parseIdentifierOrStringLiteral.cpp + src/Parsers/parseIntervalKind.cpp + src/Parsers/parseQuery.cpp + src/Parsers/parseUserName.cpp + src/Parsers/ParserAlterQuery.cpp + src/Parsers/ParserBackupQuery.cpp + src/Parsers/ParserCase.cpp + src/Parsers/ParserCheckQuery.cpp + src/Parsers/ParserCreateQuery.cpp + src/Parsers/ParserDatabaseOrNone.cpp + src/Parsers/ParserDataType.cpp + src/Parsers/ParserDescribeTableQuery.cpp + src/Parsers/ParserDictionary.cpp + src/Parsers/ParserDictionaryAttributeDeclaration.cpp + src/Parsers/ParserDropQuery.cpp + src/Parsers/ParserExplainQuery.cpp + src/Parsers/ParserExternalDDLQuery.cpp + src/Parsers/ParserInsertQuery.cpp + src/Parsers/ParserKillQueryQuery.cpp + src/Parsers/ParserOptimizeQuery.cpp + src/Parsers/ParserPartition.cpp + src/Parsers/ParserProjectionSelectQuery.cpp + src/Parsers/ParserQuery.cpp + src/Parsers/ParserRenameQuery.cpp + src/Parsers/ParserRolesOrUsersSet.cpp + src/Parsers/ParserSelectWithUnionQuery.cpp + src/Parsers/ParserSetQuery.cpp + src/Parsers/ParserSetRoleQuery.cpp + src/Parsers/ParserSettingsProfileElement.cpp + src/Parsers/ParserSelectQuery.cpp + src/Parsers/ParserTablePropertiesQuery.cpp + src/Parsers/ParserTablesInSelectQuery.cpp + src/Parsers/ParserSampleRatio.cpp + src/Parsers/ParserShowGrantsQuery.cpp + src/Parsers/ParserShowPrivilegesQuery.cpp + src/Parsers/ParserShowTablesQuery.cpp + src/Parsers/ParserSystemQuery.cpp + src/Parsers/ParserUnionQueryElement.cpp + src/Parsers/ParserUseQuery.cpp + src/Parsers/ParserUserNameWithHost.cpp + src/Parsers/ParserWatchQuery.cpp + src/Parsers/ParserWithElement.cpp + src/Parsers/queryToString.cpp + src/Parsers/QueryWithOutputSettingsPushDownVisitor.cpp + src/Parsers/TokenIterator.cpp + + src/Processors/Chunk.cpp + src/Processors/ConcatProcessor.cpp + src/Processors/IAccumulatingTransform.cpp + src/Processors/IProcessor.cpp + src/Processors/ISimpleTransform.cpp + src/Processors/ISink.cpp + src/Processors/LimitTransform.cpp + src/Processors/ISource.cpp + src/Processors/Port.cpp + src/Processors/ResizeProcessor.cpp + + src/Processors/Formats/IRowOutputFormat.cpp + src/Processors/Formats/IRowInputFormat.cpp + src/Processors/Formats/IInputFormat.cpp + src/Processors/Formats/IOutputFormat.cpp + src/Processors/Formats/OutputStreamToOutputFormat.cpp + src/Processors/Formats/RowInputFormatWithDiagnosticInfo.cpp + + src/Interpreters/castColumn.cpp + src/Interpreters/ClientInfo.cpp + src/Interpreters/InternalTextLogsQueue.cpp + src/Interpreters/QueryLog.cpp + src/Interpreters/QueryThreadLog.cpp + src/Interpreters/ProfileEventsExt.cpp + src/Interpreters/TablesStatus.cpp + + src/Functions/CastOverloadResolver.cpp + src/Functions/FunctionHelpers.cpp + src/Functions/FunctionsConversion.cpp + src/Functions/IFunction.cpp + src/Functions/FunctionFactory.cpp + src/Functions/extractTimeZoneFromFunctionArguments.cpp + src/Functions/toFixedString.cpp + + src/Processors/Executors/PollingQueue.cpp + + src/Processors/Formats/Impl/ArrowBlockInputFormat.cpp + src/Processors/Formats/Impl/ArrowBufferedStreams.cpp + src/Processors/Formats/Impl/ArrowColumnToCHColumn.cpp + src/Processors/Formats/Impl/AvroRowInputFormat.cpp + src/Processors/Formats/Impl/CHColumnToArrowColumn.cpp + src/Processors/Formats/Impl/CSVRowInputFormat.cpp + src/Processors/Formats/Impl/CSVRowOutputFormat.cpp + src/Processors/Formats/Impl/JSONAsStringRowInputFormat.cpp + src/Processors/Formats/Impl/JSONEachRowRowInputFormat.cpp + src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp + src/Processors/Formats/Impl/ORCBlockInputFormat.cpp + src/Processors/Formats/Impl/ParquetBlockInputFormat.cpp + src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp + src/Processors/Formats/Impl/RawBLOBRowInputFormat.cpp + src/Processors/Formats/Impl/TabSeparatedRowInputFormat.cpp + src/Processors/Formats/Impl/TabSeparatedRowOutputFormat.cpp + src/Processors/Formats/Impl/TSKVRowInputFormat.cpp + src/Processors/Formats/Impl/TSKVRowOutputFormat.cpp + ) + + PEERDIR( + contrib/libs/cctz + contrib/restricted/boost/multi_index + contrib/restricted/boost/program_options + contrib/restricted/cityhash-1.0.2 + contrib/restricted/fast_float + #contrib/libs/icu + contrib/libs/pdqsort + contrib/libs/lz4 + contrib/restricted/dragonbox + contrib/libs/poco/Util + contrib/libs/poco/Net + contrib/libs/poco/NetSSL_OpenSSL + contrib/libs/fmt + contrib/libs/re2 + contrib/libs/apache/arrow + contrib/libs/apache/orc + contrib/libs/apache/avro + ydb/library/yql/minikql/dom + ydb/library/yql/utils + ) + + ADDINCL( + GLOBAL contrib/restricted/dragonbox + contrib/restricted/fast_float/include + #contrib/libs/icu/common + #contrib/libs/icu/i18n + contrib/libs/pdqsort + contrib/libs/lz4 + contrib/libs/apache/arrow/src + contrib/libs/apache/avro + contrib/libs/apache/orc/c++/include + ydb/library/yql/udfs/common/clickhouse/client/base + ydb/library/yql/udfs/common/clickhouse/client/base/pcg-random + ydb/library/yql/udfs/common/clickhouse/client/src + ) + + CFLAGS ( + -DARCADIA_BUILD -DUSE_ARROW=0 -DUSE_PARQUET=1 -DUSE_SNAPPY=1 -DUSE_ORC=0 -DUSE_AVRO=0 -DUSE_UNWIND=0 -DDBMS_VERSION_MAJOR=21 -DDBMS_VERSION_MINOR=18 -DDBMS_VERSION_PATCH=0 + -Wno-unused-parameter + ) + + IF (OS_DARWIN) + CFLAGS( + GLOBAL -DOS_DARWIN + ) + ELSEIF (OS_LINUX) + CFLAGS( + GLOBAL -DOS_LINUX + ) + ENDIF() + + + END() +ELSE() + LIBRARY() + END() +ENDIF() diff --git a/ydb/library/yql/udfs/common/datetime/ya.make b/ydb/library/yql/udfs/common/datetime/ya.make new file mode 100644 index 00000000000..1cbaddbb08c --- /dev/null +++ b/ydb/library/yql/udfs/common/datetime/ya.make @@ -0,0 +1,18 @@ +YQL_UDF(datetime_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + datetime_udf.cpp +) + +PEERDIR( + library/cpp/timezone_conversion + util/draft +) + +END() diff --git a/ydb/library/yql/udfs/common/datetime2/ya.make b/ydb/library/yql/udfs/common/datetime2/ya.make new file mode 100644 index 00000000000..369ddea268b --- /dev/null +++ b/ydb/library/yql/udfs/common/datetime2/ya.make @@ -0,0 +1,21 @@ +YQL_UDF(datetime2_udf) + +YQL_ABI_VERSION( + 2 + 33 + 0 +) + +SRCS( + datetime_udf.cpp +) + +PEERDIR( + util/draft + ydb/library/yql/public/udf/arrow + ydb/library/yql/minikql + ydb/library/yql/minikql/datetime + ydb/library/yql/public/udf/tz +) + +END() diff --git a/ydb/library/yql/udfs/common/digest/ya.make b/ydb/library/yql/udfs/common/digest/ya.make new file mode 100644 index 00000000000..24d9cec833e --- /dev/null +++ b/ydb/library/yql/udfs/common/digest/ya.make @@ -0,0 +1,27 @@ +YQL_UDF(digest_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + digest_udf.cpp +) + +PEERDIR( + contrib/libs/farmhash + contrib/libs/highwayhash + contrib/libs/openssl + contrib/libs/xxhash + library/cpp/digest/argonish + library/cpp/digest/crc32c + library/cpp/digest/md5 + library/cpp/digest/old_crc + library/cpp/digest/sfh +) + +ADDINCL(contrib/libs/highwayhash) + +END() diff --git a/ydb/library/yql/udfs/common/histogram/ya.make b/ydb/library/yql/udfs/common/histogram/ya.make new file mode 100644 index 00000000000..6e20f1eddf2 --- /dev/null +++ b/ydb/library/yql/udfs/common/histogram/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(histogram_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + histogram_udf.cpp +) + +PEERDIR( + library/cpp/histogram/adaptive +) + +END() diff --git a/ydb/library/yql/udfs/common/hyperloglog/ya.make b/ydb/library/yql/udfs/common/hyperloglog/ya.make new file mode 100644 index 00000000000..3d13568e572 --- /dev/null +++ b/ydb/library/yql/udfs/common/hyperloglog/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(hyperloglog_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + hyperloglog_udf.cpp +) + +PEERDIR( + library/cpp/hyperloglog +) + +END() diff --git a/ydb/library/yql/udfs/common/hyperscan/ya.make b/ydb/library/yql/udfs/common/hyperscan/ya.make new file mode 100644 index 00000000000..5f248525bf5 --- /dev/null +++ b/ydb/library/yql/udfs/common/hyperscan/ya.make @@ -0,0 +1,25 @@ +IF (OS_LINUX AND CLANG) + + YQL_UDF(hyperscan_udf) + + YQL_ABI_VERSION( + 2 + 27 + 0 + ) + + SRCS( + hyperscan_udf.cpp + ) + + PEERDIR( + library/cpp/regex/hyperscan + library/cpp/regex/pcre + ) + + END() + +ELSE() + LIBRARY() + END() +ENDIF() diff --git a/ydb/library/yql/udfs/common/ip_base/lib/ya.make b/ydb/library/yql/udfs/common/ip_base/lib/ya.make new file mode 100644 index 00000000000..2d532234dd6 --- /dev/null +++ b/ydb/library/yql/udfs/common/ip_base/lib/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + ip_base_udf.cpp +) + +PEERDIR( + ydb/library/yql/public/udf +) + +END() diff --git a/ydb/library/yql/udfs/common/ip_base/ya.make b/ydb/library/yql/udfs/common/ip_base/ya.make new file mode 100644 index 00000000000..6b472fdc066 --- /dev/null +++ b/ydb/library/yql/udfs/common/ip_base/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(ip_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + ip_base.cpp +) + +PEERDIR( + ydb/library/yql/udfs/common/ip_base/lib +) + +END() diff --git a/ydb/library/yql/udfs/common/json/ya.make b/ydb/library/yql/udfs/common/json/ya.make new file mode 100644 index 00000000000..72f7a26607e --- /dev/null +++ b/ydb/library/yql/udfs/common/json/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(json_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + json_udf.cpp +) + +PEERDIR( + library/cpp/json/easy_parse +) + +END() diff --git a/ydb/library/yql/udfs/common/json2/ya.make b/ydb/library/yql/udfs/common/json2/ya.make new file mode 100644 index 00000000000..ef41074955d --- /dev/null +++ b/ydb/library/yql/udfs/common/json2/ya.make @@ -0,0 +1,19 @@ +YQL_UDF(json2_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + json2_udf.cpp +) + +PEERDIR( + ydb/library/binary_json + ydb/library/yql/minikql/dom + ydb/library/yql/minikql/jsonpath +) + +END() diff --git a/ydb/library/yql/udfs/common/math/lib/ut/ya.make b/ydb/library/yql/udfs/common/math/lib/ut/ya.make new file mode 100644 index 00000000000..84425654a44 --- /dev/null +++ b/ydb/library/yql/udfs/common/math/lib/ut/ya.make @@ -0,0 +1,11 @@ +IF (OS_LINUX) +IF (NOT WITH_VALGRIND) + UNITTEST_FOR(ydb/library/yql/udfs/common/math/lib) + + SRCS( + round_ut.cpp + ) + + END() +ENDIF() +ENDIF() diff --git a/ydb/library/yql/udfs/common/math/lib/ya.make b/ydb/library/yql/udfs/common/math/lib/ya.make new file mode 100644 index 00000000000..54b882a8438 --- /dev/null +++ b/ydb/library/yql/udfs/common/math/lib/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + erfinv.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/udfs/common/math/ya.make b/ydb/library/yql/udfs/common/math/ya.make new file mode 100644 index 00000000000..14f0f2d3b25 --- /dev/null +++ b/ydb/library/yql/udfs/common/math/ya.make @@ -0,0 +1,69 @@ +YQL_UDF(math_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + math_udf.cpp +) + +LLVM_BC( + math_ir.cpp + lib/erfinv.cpp + NAME Math + SYMBOLS + PiIR + EIR + EpsIR + AbsIR + AcosIR + AsinIR + AsinhIR + AtanIR + CbrtIR + CeilIR + CosIR + CoshIR + ErfIR + ErfInvIR + ErfcInvIR + ExpIR + Exp2IR + FabsIR + FloorIR + LgammaIR + RintIR + SinIR + SinhIR + SqrtIR + TanIR + TanhIR + TgammaIR + TruncIR + IsFiniteIR + IsInfIR + IsNaNIR + Atan2IR + FmodIR + HypotIR + RemainderIR + PowIR + LdexpIR + LogIR + Log2IR + Log10IR + SigmoidIR + FuzzyEqualsIR + RoundIR + ModIR + RemIR +) + +PEERDIR( + ydb/library/yql/udfs/common/math/lib +) + +END() diff --git a/ydb/library/yql/udfs/common/pire/ya.make b/ydb/library/yql/udfs/common/pire/ya.make new file mode 100644 index 00000000000..b87ebf9f74c --- /dev/null +++ b/ydb/library/yql/udfs/common/pire/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(pire_udf) + +YQL_ABI_VERSION( + 2 + 27 + 0 +) + +SRCS( + pire_udf.cpp +) + +PEERDIR( + library/cpp/regex/pire +) + +END() diff --git a/ydb/library/yql/udfs/common/re2/ya.make b/ydb/library/yql/udfs/common/re2/ya.make new file mode 100644 index 00000000000..a8269380b88 --- /dev/null +++ b/ydb/library/yql/udfs/common/re2/ya.make @@ -0,0 +1,18 @@ +YQL_UDF(re2_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + re2_udf.cpp +) + +PEERDIR( + contrib/libs/re2 + library/cpp/deprecated/enum_codegen +) + +END() diff --git a/ydb/library/yql/udfs/common/set/ya.make b/ydb/library/yql/udfs/common/set/ya.make new file mode 100644 index 00000000000..1ad272b98fc --- /dev/null +++ b/ydb/library/yql/udfs/common/set/ya.make @@ -0,0 +1,13 @@ +YQL_UDF(set_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + set_udf.cpp +) + +END() diff --git a/ydb/library/yql/udfs/common/stat/static/ya.make b/ydb/library/yql/udfs/common/stat/static/ya.make new file mode 100644 index 00000000000..7e2918f67f4 --- /dev/null +++ b/ydb/library/yql/udfs/common/stat/static/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + static_udf.cpp + stat_udf.h +) + +PEERDIR( + ydb/library/yql/public/udf + library/cpp/tdigest +) + +END() diff --git a/ydb/library/yql/udfs/common/stat/ut/ya.make b/ydb/library/yql/udfs/common/stat/ut/ya.make new file mode 100644 index 00000000000..8ad51e7596a --- /dev/null +++ b/ydb/library/yql/udfs/common/stat/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/library/yql/udfs/common/stat/static) + +SRCS( + ../stat_udf_ut.cpp +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +TIMEOUT(300) + +SIZE(MEDIUM) + +END() diff --git a/ydb/library/yql/udfs/common/stat/ya.make b/ydb/library/yql/udfs/common/stat/ya.make new file mode 100644 index 00000000000..56983c19805 --- /dev/null +++ b/ydb/library/yql/udfs/common/stat/ya.make @@ -0,0 +1,21 @@ +YQL_UDF(stat_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + stat_udf.cpp +) + +PEERDIR( + ydb/library/yql/udfs/common/stat/static +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/udfs/common/string/ya.make b/ydb/library/yql/udfs/common/string/ya.make new file mode 100644 index 00000000000..ec14e593837 --- /dev/null +++ b/ydb/library/yql/udfs/common/string/ya.make @@ -0,0 +1,27 @@ +YQL_UDF(string_udf) + +YQL_ABI_VERSION( + 2 + 33 + 0 +) + +SRCS( + string_udf.cpp +) + +PEERDIR( + ydb/library/yql/public/udf/arrow + library/cpp/charset + library/cpp/deprecated/split + library/cpp/html/pcdata + library/cpp/string_utils/base64 + library/cpp/string_utils/levenshtein_diff + library/cpp/string_utils/quote +) + +TIMEOUT(300) + +SIZE(MEDIUM) + +END() diff --git a/ydb/library/yql/udfs/common/top/ya.make b/ydb/library/yql/udfs/common/top/ya.make new file mode 100644 index 00000000000..f295d338b6d --- /dev/null +++ b/ydb/library/yql/udfs/common/top/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(top_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + top_udf.cpp +) + +PEERDIR( + library/cpp/containers/top_keeper +) + +END() diff --git a/ydb/library/yql/udfs/common/topfreq/static/ya.make b/ydb/library/yql/udfs/common/topfreq/static/ya.make new file mode 100644 index 00000000000..219f3b1e295 --- /dev/null +++ b/ydb/library/yql/udfs/common/topfreq/static/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + static_udf.cpp + topfreq.cpp +) + +PEERDIR( + ydb/library/yql/public/udf +) + +END() diff --git a/ydb/library/yql/udfs/common/topfreq/ut/ya.make b/ydb/library/yql/udfs/common/topfreq/ut/ya.make new file mode 100644 index 00000000000..02fc8c647c7 --- /dev/null +++ b/ydb/library/yql/udfs/common/topfreq/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/library/yql/udfs/common/topfreq/static) + +SRCS( + ../topfreq_udf_ut.cpp +) + +PEERDIR( + ydb/library/yql/minikql + ydb/library/yql/minikql/comp_nodes + ydb/library/yql/minikql/computation + ydb/library/yql/public/udf/service/exception_policy + ydb/library/yql/sql/pg_dummy +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/library/yql/udfs/common/topfreq/ya.make b/ydb/library/yql/udfs/common/topfreq/ya.make new file mode 100644 index 00000000000..c41256b73af --- /dev/null +++ b/ydb/library/yql/udfs/common/topfreq/ya.make @@ -0,0 +1,21 @@ +YQL_UDF(topfreq_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + topfreq_udf.cpp +) + +PEERDIR( + ydb/library/yql/udfs/common/topfreq/static +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/udfs/common/unicode_base/lib/ya.make b/ydb/library/yql/udfs/common/unicode_base/lib/ya.make new file mode 100644 index 00000000000..5153a613417 --- /dev/null +++ b/ydb/library/yql/udfs/common/unicode_base/lib/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +YQL_ABI_VERSION( + 2 + 27 + 0 +) + +SRCS( + unicode_base_udf.cpp +) + +PEERDIR( + library/cpp/deprecated/split + library/cpp/string_utils/levenshtein_diff + library/cpp/unicode/normalization + library/cpp/unicode/set + ydb/library/yql/public/udf + ydb/library/yql/utils +) + +END() diff --git a/ydb/library/yql/udfs/common/unicode_base/ya.make b/ydb/library/yql/udfs/common/unicode_base/ya.make new file mode 100644 index 00000000000..8bfa9fd9679 --- /dev/null +++ b/ydb/library/yql/udfs/common/unicode_base/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(unicode_udf) + +YQL_ABI_VERSION( + 2 + 27 + 0 +) + +SRCS( + unicode_base.cpp +) + +PEERDIR( + ydb/library/yql/udfs/common/unicode_base/lib +) + +END() diff --git a/ydb/library/yql/udfs/common/url_base/lib/ya.make b/ydb/library/yql/udfs/common/url_base/lib/ya.make new file mode 100644 index 00000000000..daba630c6ab --- /dev/null +++ b/ydb/library/yql/udfs/common/url_base/lib/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +YQL_ABI_VERSION( + 2 + 33 + 0 +) + +SRCS( + url_base_udf.cpp + url_parse.cpp + url_query.cpp +) + +PEERDIR( + library/cpp/charset + library/cpp/string_utils/quote + library/cpp/string_utils/url + library/cpp/tld + library/cpp/unicode/punycode + library/cpp/uri + ydb/library/yql/public/udf + ydb/library/yql/public/udf/arrow + contrib/libs/apache/arrow +) + +END() diff --git a/ydb/library/yql/udfs/common/url_base/ya.make b/ydb/library/yql/udfs/common/url_base/ya.make new file mode 100644 index 00000000000..31b529e9689 --- /dev/null +++ b/ydb/library/yql/udfs/common/url_base/ya.make @@ -0,0 +1,18 @@ +YQL_UDF(url_udf) + +YQL_ABI_VERSION( + 2 + 33 + 0 +) + +SRCS( + url_base.cpp +) + +PEERDIR( + ydb/library/yql/public/udf + ydb/library/yql/udfs/common/url_base/lib +) + +END() diff --git a/ydb/library/yql/udfs/common/ya.make b/ydb/library/yql/udfs/common/ya.make new file mode 100644 index 00000000000..511570b1bdc --- /dev/null +++ b/ydb/library/yql/udfs/common/ya.make @@ -0,0 +1,29 @@ +RECURSE( + clickhouse/client + datetime + datetime2 + digest + histogram + hyperloglog + ip_base + json + json2 + math + pire + re2 + set + stat + string + top + topfreq + unicode_base + url_base + yson2 +) + +IF (ARCH_X86_64) + RECURSE( + hyperscan + ) +ENDIF() + diff --git a/ydb/library/yql/udfs/common/yson2/ya.make b/ydb/library/yql/udfs/common/yson2/ya.make new file mode 100644 index 00000000000..d1ddd064b30 --- /dev/null +++ b/ydb/library/yql/udfs/common/yson2/ya.make @@ -0,0 +1,19 @@ +YQL_UDF(yson2_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +SRCS( + yson2_udf.cpp +) + +PEERDIR( + library/cpp/containers/stack_vector + library/cpp/yson_pull + ydb/library/yql/minikql/dom +) + +END() diff --git a/ydb/library/yql/udfs/logs/dsv/ya.make b/ydb/library/yql/udfs/logs/dsv/ya.make new file mode 100644 index 00000000000..15bdf62fc14 --- /dev/null +++ b/ydb/library/yql/udfs/logs/dsv/ya.make @@ -0,0 +1,17 @@ +YQL_UDF(dsv_udf) + +YQL_ABI_VERSION( + 2 + 28 + 0 +) + +PEERDIR( + library/cpp/deprecated/split +) + +SRCS( + dsv_udf.cpp +) + +END() diff --git a/ydb/library/yql/udfs/logs/ya.make b/ydb/library/yql/udfs/logs/ya.make new file mode 100644 index 00000000000..c725c446469 --- /dev/null +++ b/ydb/library/yql/udfs/logs/ya.make @@ -0,0 +1,3 @@ +RECURSE( + dsv +) diff --git a/ydb/library/yql/udfs/ya.make b/ydb/library/yql/udfs/ya.make new file mode 100644 index 00000000000..9a9a58a86ab --- /dev/null +++ b/ydb/library/yql/udfs/ya.make @@ -0,0 +1,4 @@ +RECURSE( + common + logs +) diff --git a/ydb/library/yql/utils/actor_log/ya.make b/ydb/library/yql/utils/actor_log/ya.make new file mode 100644 index 00000000000..2d449bc0f7b --- /dev/null +++ b/ydb/library/yql/utils/actor_log/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + log.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/actors/protos + ydb/core/protos +) + +END() diff --git a/ydb/library/yql/utils/actors/ut/ya.make b/ydb/library/yql/utils/actors/ut/ya.make new file mode 100644 index 00000000000..61b0de6e328 --- /dev/null +++ b/ydb/library/yql/utils/actors/ut/ya.make @@ -0,0 +1,15 @@ +IF (OS_LINUX OR OS_DARWIN) + UNITTEST_FOR(ydb/library/yql/utils/actors) + + SIZE(SMALL) + + SRCS( + http_sender_actor_ut.cpp + ) + + PEERDIR( + ydb/core/testlib/basics/default + ) + + END() +ENDIF() diff --git a/ydb/library/yql/utils/actors/ya.make b/ydb/library/yql/utils/actors/ya.make new file mode 100644 index 00000000000..87f307092d1 --- /dev/null +++ b/ydb/library/yql/utils/actors/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + rich_actor.cpp + http_sender_actor.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/library/yql/providers/common/token_accessor/client + ydb/library/yql/public/types + ydb/library/yql/public/udf + ydb/library/yql/providers/solomon/proto +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/utils/backtrace/fake_llvm_symbolizer/ya.make b/ydb/library/yql/utils/backtrace/fake_llvm_symbolizer/ya.make new file mode 100644 index 00000000000..b41861e8b2a --- /dev/null +++ b/ydb/library/yql/utils/backtrace/fake_llvm_symbolizer/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + fake_llvm_symbolizer.cpp +) + +PEERDIR( + contrib/libs/llvm12/lib/DebugInfo/Symbolize +) + +END() diff --git a/ydb/library/yql/utils/backtrace/ya.make b/ydb/library/yql/utils/backtrace/ya.make new file mode 100644 index 00000000000..6e8584d7726 --- /dev/null +++ b/ydb/library/yql/utils/backtrace/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + backtrace.cpp + symbolize.cpp +) +IF (OS_LINUX AND ARCH_X86_64) + SRCS( + backtrace_in_context.cpp + symbolizer_linux.cpp + ) + PEERDIR( + ydb/library/yql/utils/backtrace/fake_llvm_symbolizer + contrib/libs/libunwind + ) +ELSE() + SRCS( + symbolizer_dummy.cpp + ) +ENDIF() + +PEERDIR( + contrib/libs/llvm12/lib/DebugInfo/Symbolize + library/cpp/deprecated/atomic +) + +END() diff --git a/ydb/library/yql/utils/bindings/ut/ya.make b/ydb/library/yql/utils/bindings/ut/ya.make new file mode 100644 index 00000000000..8c323a83555 --- /dev/null +++ b/ydb/library/yql/utils/bindings/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(ydb/library/yql/utils/bindings) + +SRCS( + utils_ut.cpp +) + +END() diff --git a/ydb/library/yql/utils/bindings/ya.make b/ydb/library/yql/utils/bindings/ya.make new file mode 100644 index 00000000000..f65acbd289b --- /dev/null +++ b/ydb/library/yql/utils/bindings/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +PEERDIR( + library/cpp/json + library/cpp/json/yson + library/cpp/yson + ydb/library/yql/sql/settings + ydb/library/yql/utils +) + +SRCS(utils.cpp) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/utils/failure_injector/ut/ya.make b/ydb/library/yql/utils/failure_injector/ut/ya.make new file mode 100644 index 00000000000..0070de2820f --- /dev/null +++ b/ydb/library/yql/utils/failure_injector/ut/ya.make @@ -0,0 +1,15 @@ +IF (OS_LINUX OR OS_DARWIN) + UNITTEST_FOR(ydb/library/yql/utils/failure_injector) + + SIZE(SMALL) + + SRCS( + failure_injector_ut.cpp + ) + + PEERDIR( + ydb/library/yql/utils/log + ) + + END() +ENDIF() diff --git a/ydb/library/yql/utils/failure_injector/ya.make b/ydb/library/yql/utils/failure_injector/ya.make new file mode 100644 index 00000000000..2941c622e57 --- /dev/null +++ b/ydb/library/yql/utils/failure_injector/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + failure_injector.cpp +) + +PEERDIR( + ydb/library/yql/utils + ydb/library/yql/utils/log +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/utils/fetch/ya.make b/ydb/library/yql/utils/fetch/ya.make new file mode 100644 index 00000000000..a7c3b684c14 --- /dev/null +++ b/ydb/library/yql/utils/fetch/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + fetch.cpp +) + +PEERDIR( + library/cpp/charset + library/cpp/http/io + library/cpp/http/misc + library/cpp/openssl/io + library/cpp/uri + ydb/library/yql/utils/log +) + +END() diff --git a/ydb/library/yql/utils/log/proto/ya.make b/ydb/library/yql/utils/log/proto/ya.make new file mode 100644 index 00000000000..f251cf71c54 --- /dev/null +++ b/ydb/library/yql/utils/log/proto/ya.make @@ -0,0 +1,11 @@ +PROTO_LIBRARY() + +SRCS( + logger_config.proto +) + +IF (NOT PY_PROTOS_FOR) + EXCLUDE_TAGS(GO_PROTO) +ENDIF() + +END() diff --git a/ydb/library/yql/utils/log/ut/ya.make b/ydb/library/yql/utils/log/ut/ya.make new file mode 100644 index 00000000000..60620171fc4 --- /dev/null +++ b/ydb/library/yql/utils/log/ut/ya.make @@ -0,0 +1,8 @@ +UNITTEST_FOR(ydb/library/yql/utils/log) + +SRCS( + log_ut.cpp + tls_backend_ut.cpp +) + +END() diff --git a/ydb/library/yql/utils/log/ya.make b/ydb/library/yql/utils/log/ya.make new file mode 100644 index 00000000000..43a7c28fa93 --- /dev/null +++ b/ydb/library/yql/utils/log/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + context.cpp + log.cpp + profile.cpp + tls_backend.cpp +) + +PEERDIR( + library/cpp/logger + library/cpp/logger/global + library/cpp/deprecated/atomic + ydb/library/yql/utils/log/proto +) + +END() + +RECURSE( + proto +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/utils/test_http_server/ya.make b/ydb/library/yql/utils/test_http_server/ya.make new file mode 100644 index 00000000000..41c6710c5f9 --- /dev/null +++ b/ydb/library/yql/utils/test_http_server/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + test_http_server.cpp +) + +PEERDIR( + library/cpp/http/server + library/cpp/http/misc +) + +END() diff --git a/ydb/library/yql/utils/threading/ya.make b/ydb/library/yql/utils/threading/ya.make new file mode 100644 index 00000000000..d1cd6291a70 --- /dev/null +++ b/ydb/library/yql/utils/threading/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + async_queue.cpp +) + +END() diff --git a/ydb/library/yql/utils/ut/ya.make b/ydb/library/yql/utils/ut/ya.make new file mode 100644 index 00000000000..678fa99327b --- /dev/null +++ b/ydb/library/yql/utils/ut/ya.make @@ -0,0 +1,14 @@ +UNITTEST_FOR(ydb/library/yql/utils) + +SRCS( + fp_bits_ut.cpp + md5_stream_ut.cpp + multi_resource_lock_ut.cpp + parse_double_ut.cpp + range_walker_ut.cpp + retry_ut.cpp + url_builder_ut.cpp + utf8_ut.cpp +) + +END() diff --git a/ydb/library/yql/utils/ya.make b/ydb/library/yql/utils/ya.make new file mode 100644 index 00000000000..f12f0c0f92c --- /dev/null +++ b/ydb/library/yql/utils/ya.make @@ -0,0 +1,62 @@ +LIBRARY() + +SRCS( + bind_in_range.cpp + bind_in_range.h + cast.h + debug_info.cpp + debug_info.h + future_action.cpp + future_action.h + hash.h + hash.cpp + md5_stream.cpp + md5_stream.h + multi_resource_lock.cpp + multi_resource_lock.h + parse_double.cpp + parse_double.h + proc_alive.cpp + proc_alive.h + rand_guid.cpp + rand_guid.h + resetable_setting.h + retry.cpp + retry.h + sort.cpp + sort.h + swap_bytes.cpp + swap_bytes.h + url_builder.cpp + utf8.cpp + yql_panic.cpp + yql_panic.h + yql_paths.cpp + yql_paths.h +) + +PEERDIR( + library/cpp/digest/md5 + library/cpp/messagebus + library/cpp/string_utils/quote + library/cpp/threading/future + library/cpp/deprecated/atomic + contrib/libs/miniselect +) + +END() + +RECURSE( + actor_log + actors + backtrace + bindings + failure_injector + fetch + log + threading +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/library/yql/ya.make b/ydb/library/yql/ya.make new file mode 100644 index 00000000000..94a30b6b957 --- /dev/null +++ b/ydb/library/yql/ya.make @@ -0,0 +1,28 @@ +RECURSE( + ast + core + core/arrow_kernels/request + core/arrow_kernels/registry + core/common_opt + core/credentials + core/expr_nodes + core/expr_nodes_gen + core/extract_predicate + core/facade + core/file_storage + core/issue + core/peephole_opt + core/services + core/sql_types + core/type_ann + core/user_data + dq + minikql + parser + protos + providers + public + sql + udfs + utils +) diff --git a/ydb/public/api/client/ya.make b/ydb/public/api/client/ya.make new file mode 100644 index 00000000000..d45e14c6c52 --- /dev/null +++ b/ydb/public/api/client/ya.make @@ -0,0 +1,4 @@ +RECURSE( + yc_public + yc_private +)
\ No newline at end of file diff --git a/ydb/public/api/client/yc_private/iam/ya.make b/ydb/public/api/client/yc_private/iam/ya.make new file mode 100644 index 00000000000..edf17b1167c --- /dev/null +++ b/ydb/public/api/client/yc_private/iam/ya.make @@ -0,0 +1,28 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/client/yc_private/operation +) + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + iam_token_service_subject.proto + iam_token_service.proto + iam_token.proto + oauth_request.proto + reference.proto + service_account_service.proto + service_account.proto + user_account_service.proto + user_account.proto + yandex_passport_cookie.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_private/operation/ya.make b/ydb/public/api/client/yc_private/operation/ya.make new file mode 100644 index 00000000000..eb08c4536ac --- /dev/null +++ b/ydb/public/api/client/yc_private/operation/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + operation.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_private/resourcemanager/ya.make b/ydb/public/api/client/yc_private/resourcemanager/ya.make new file mode 100644 index 00000000000..0f8699cb0bf --- /dev/null +++ b/ydb/public/api/client/yc_private/resourcemanager/ya.make @@ -0,0 +1,22 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/client/yc_private/operation + ydb/public/api/client/yc_private/servicecontrol +) + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + folder.proto + transitional/folder_service.proto + folder_service.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_private/servicecontrol/ya.make b/ydb/public/api/client/yc_private/servicecontrol/ya.make new file mode 100644 index 00000000000..1820f9a20b9 --- /dev/null +++ b/ydb/public/api/client/yc_private/servicecontrol/ya.make @@ -0,0 +1,16 @@ +PROTO_LIBRARY() + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + access_service.proto + resource.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_private/ya.make b/ydb/public/api/client/yc_private/ya.make new file mode 100644 index 00000000000..ff72c6a0941 --- /dev/null +++ b/ydb/public/api/client/yc_private/ya.make @@ -0,0 +1,7 @@ +RECURSE( + iam + operation + resourcemanager + servicecontrol +) + diff --git a/ydb/public/api/client/yc_public/common/ya.make b/ydb/public/api/client/yc_public/common/ya.make new file mode 100644 index 00000000000..b2315ebf002 --- /dev/null +++ b/ydb/public/api/client/yc_public/common/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + validation.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_public/events/ya.make b/ydb/public/api/client/yc_public/events/ya.make new file mode 100644 index 00000000000..541af44739b --- /dev/null +++ b/ydb/public/api/client/yc_public/events/ya.make @@ -0,0 +1,21 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/client/yc_public/common +) + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + options.proto + common.proto + yq.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_public/iam/ya.make b/ydb/public/api/client/yc_public/iam/ya.make new file mode 100644 index 00000000000..27f4fdb5e30 --- /dev/null +++ b/ydb/public/api/client/yc_public/iam/ya.make @@ -0,0 +1,19 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/client/yc_public/common +) + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + iam_token_service.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_public/logging/ya.make b/ydb/public/api/client/yc_public/logging/ya.make new file mode 100644 index 00000000000..8de279ed0a2 --- /dev/null +++ b/ydb/public/api/client/yc_public/logging/ya.make @@ -0,0 +1,21 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/client/yc_public/common +) + +EXCLUDE_TAGS(GO_PROTO) + +GRPC() +SRCS( + log_entry.proto + log_ingestion_service.proto + log_resource.proto +) + +USE_COMMON_GOOGLE_APIS( + api/annotations +) + +END() + diff --git a/ydb/public/api/client/yc_public/ya.make b/ydb/public/api/client/yc_public/ya.make new file mode 100644 index 00000000000..8205e987c76 --- /dev/null +++ b/ydb/public/api/client/yc_public/ya.make @@ -0,0 +1,7 @@ +RECURSE( + iam + events + logging + common +) + diff --git a/ydb/public/api/grpc/draft/ya.make b/ydb/public/api/grpc/draft/ya.make new file mode 100644 index 00000000000..606b757e01e --- /dev/null +++ b/ydb/public/api/grpc/draft/ya.make @@ -0,0 +1,26 @@ +PROTO_LIBRARY(api-grpc-draft) + +MAVEN_GROUP_ID(com.yandex.ydb) + +GRPC() + +SRCS( + dummy.proto + fq_v1.proto + ydb_clickhouse_internal_v1.proto + ydb_persqueue_v1.proto + ydb_datastreams_v1.proto + ydb_long_tx_v1.proto + ydb_maintenance_v1.proto + ydb_logstore_v1.proto + ydb_query_v1.proto + ydb_dynamic_config_v1.proto +) + +PEERDIR( + ydb/public/api/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/public/api/grpc/ya.make b/ydb/public/api/grpc/ya.make new file mode 100644 index 00000000000..a7e5b601042 --- /dev/null +++ b/ydb/public/api/grpc/ya.make @@ -0,0 +1,30 @@ +PROTO_LIBRARY(api-grpc) + +MAVEN_GROUP_ID(com.yandex.ydb) + +GRPC() + +SRCS( + ydb_federation_discovery_v1.proto + ydb_auth_v1.proto + ydb_cms_v1.proto + ydb_coordination_v1.proto + ydb_discovery_v1.proto + ydb_export_v1.proto + ydb_import_v1.proto + ydb_monitoring_v1.proto + ydb_operation_v1.proto + ydb_rate_limiter_v1.proto + ydb_scheme_v1.proto + ydb_scripting_v1.proto + ydb_table_v1.proto + ydb_topic_v1.proto +) + +PEERDIR( + ydb/public/api/protos +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/public/api/protos/annotations/ya.make b/ydb/public/api/protos/annotations/ya.make new file mode 100644 index 00000000000..7cf7d764e19 --- /dev/null +++ b/ydb/public/api/protos/annotations/ya.make @@ -0,0 +1,10 @@ +PROTO_LIBRARY() + +SRCS( + sensitive.proto + validation.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/public/api/protos/out/ya.make b/ydb/public/api/protos/out/ya.make new file mode 100644 index 00000000000..7fe5618d567 --- /dev/null +++ b/ydb/public/api/protos/out/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + out.cpp +) + +PEERDIR( + ydb/public/api/protos +) + +END() diff --git a/ydb/public/api/protos/ya.make b/ydb/public/api/protos/ya.make new file mode 100644 index 00000000000..a4cecb4a6e9 --- /dev/null +++ b/ydb/public/api/protos/ya.make @@ -0,0 +1,57 @@ +PROTO_LIBRARY(api-protos) + +MAVEN_GROUP_ID(com.yandex.ydb) + +PEERDIR( + ydb/public/api/protos/annotations +) + +SRCS( + draft/datastreams.proto + draft/fq.proto + draft/persqueue_common.proto + draft/persqueue_error_codes.proto + draft/ydb_long_tx.proto + draft/ydb_maintenance.proto + draft/ydb_logstore.proto + draft/ydb_query.proto + draft/ydb_dynamic_config.proto + ydb_federation_discovery.proto + persqueue_error_codes_v1.proto + ydb_auth.proto + ydb_persqueue_v1.proto + ydb_persqueue_cluster_discovery.proto + ydb_clickhouse_internal.proto + ydb_cms.proto + ydb_common.proto + ydb_coordination.proto + ydb_discovery.proto + ydb_export.proto + ydb_formats.proto + ydb_import.proto + ydb_issue_message.proto + ydb_monitoring.proto + ydb_operation.proto + ydb_query_stats.proto + ydb_rate_limiter.proto + ydb_scheme.proto + ydb_scripting.proto + ydb_status_codes.proto + ydb_table.proto + ydb_topic.proto + ydb_value.proto +) + +CPP_PROTO_PLUGIN0(validation ydb/public/lib/validation) + +# .pb.h are only available in C++ variant of PROTO_LIBRARY +IF (MODULE_TAG == "CPP_PROTO") + GENERATE_ENUM_SERIALIZATION(draft/persqueue_common.pb.h) + GENERATE_ENUM_SERIALIZATION(ydb_persqueue_cluster_discovery.pb.h) + GENERATE_ENUM_SERIALIZATION(draft/datastreams.pb.h) + GENERATE_ENUM_SERIALIZATION(ydb_topic.pb.h) +ENDIF() + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/public/api/ya.make b/ydb/public/api/ya.make new file mode 100644 index 00000000000..c2e2c48c48a --- /dev/null +++ b/ydb/public/api/ya.make @@ -0,0 +1,5 @@ +RECURSE( + grpc + protos + client +) diff --git a/ydb/public/lib/base/ya.make b/ydb/public/lib/base/ya.make new file mode 100644 index 00000000000..70c7fb886df --- /dev/null +++ b/ydb/public/lib/base/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + defs.h + msgbus_status.h + msgbus.h + msgbus.cpp +) + +PEERDIR( + library/cpp/deprecated/enum_codegen + library/cpp/messagebus + library/cpp/messagebus/protobuf + ydb/core/protos +) + +END() diff --git a/ydb/public/lib/deprecated/client/ya.make b/ydb/public/lib/deprecated/client/ya.make new file mode 100644 index 00000000000..03fa60c75cd --- /dev/null +++ b/ydb/public/lib/deprecated/client/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + msgbus_client.cpp + msgbus_client.h + msgbus_client_config.h + msgbus_player.cpp + msgbus_player.h + grpc_client.cpp +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/messagebus + ydb/public/lib/base +) + +END() diff --git a/ydb/public/lib/deprecated/kicli/ut/ya.make b/ydb/public/lib/deprecated/kicli/ut/ya.make new file mode 100644 index 00000000000..8f9f230c19e --- /dev/null +++ b/ydb/public/lib/deprecated/kicli/ut/ya.make @@ -0,0 +1,21 @@ +UNITTEST_FOR(ydb/public/lib/deprecated/kicli) + +TIMEOUT(600) + +SIZE(MEDIUM) + +FORK_SUBTESTS() + +PEERDIR( + ydb/core/client + ydb/core/testlib/default + ydb/public/lib/deprecated/kicli +) + +YQL_LAST_ABI_VERSION() + +SRCS( + cpp_ut.cpp +) + +END() diff --git a/ydb/public/lib/deprecated/kicli/ya.make b/ydb/public/lib/deprecated/kicli/ya.make new file mode 100644 index 00000000000..0467ac9fccd --- /dev/null +++ b/ydb/public/lib/deprecated/kicli/ya.make @@ -0,0 +1,38 @@ +LIBRARY() + +# See documentation +# https://wiki.yandex-team.ru/kikimr/techdoc/db/cxxapi/ + +SRCS( + configurator.cpp + dynamic_node.cpp + error.cpp + kicli.h + kikimr.cpp + query.cpp + result.cpp + schema.cpp +) + +PEERDIR( + contrib/libs/grpc + library/cpp/actors/core + library/cpp/threading/future + ydb/core/protos + ydb/library/aclib + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/public/lib/base + ydb/public/lib/deprecated/client + ydb/public/lib/scheme_types + ydb/public/lib/value + ydb/library/yql/public/decimal + ydb/library/yql/public/issue +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/lib/deprecated/ya.make b/ydb/public/lib/deprecated/ya.make new file mode 100644 index 00000000000..84dab1af07b --- /dev/null +++ b/ydb/public/lib/deprecated/ya.make @@ -0,0 +1,4 @@ +RECURSE( + client + kicli +) diff --git a/ydb/public/lib/experimental/ya.make b/ydb/public/lib/experimental/ya.make new file mode 100644 index 00000000000..69e93416945 --- /dev/null +++ b/ydb/public/lib/experimental/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + ydb_clickhouse_internal.cpp + ydb_logstore.cpp +) + +PEERDIR( + ydb/core/scheme + ydb/public/api/grpc/draft + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/lib/fq/ya.make b/ydb/public/lib/fq/ya.make new file mode 100644 index 00000000000..b357a169b3e --- /dev/null +++ b/ydb/public/lib/fq/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + fq.cpp + scope.cpp +) + +PEERDIR( + library/cpp/json + ydb/public/api/grpc/draft + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/lib/idx_test/ut/ya.make b/ydb/public/lib/idx_test/ut/ya.make new file mode 100644 index 00000000000..ac811a55b6e --- /dev/null +++ b/ydb/public/lib/idx_test/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/public/lib/idx_test) + +TIMEOUT(600) + +SIZE(MEDIUM) + +FORK_SUBTESTS() + +PEERDIR( + ydb/public/lib/idx_test +) + +SRCS( + idx_test_data_provider_ut.cpp +) + +END() diff --git a/ydb/public/lib/idx_test/ya.make b/ydb/public/lib/idx_test/ya.make new file mode 100644 index 00000000000..79aad5fce33 --- /dev/null +++ b/ydb/public/lib/idx_test/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +SRCS( + idx_test_checker.cpp + idx_test_common.cpp + idx_test_data_provider.cpp + idx_test_stderr_progress_tracker.cpp + idx_test_loader.cpp + idx_test_upload.cpp +) + +PEERDIR( + library/cpp/string_utils/base64 + ydb/public/sdk/cpp/client/ydb_table +) + +GENERATE_ENUM_SERIALIZATION(idx_test.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/lib/json_value/ut/ya.make b/ydb/public/lib/json_value/ut/ya.make new file mode 100644 index 00000000000..3c85b9cf32d --- /dev/null +++ b/ydb/public/lib/json_value/ut/ya.make @@ -0,0 +1,20 @@ +UNITTEST_FOR(ydb/public/lib/json_value) + +TIMEOUT(600) + +SIZE(MEDIUM) + +FORK_SUBTESTS() + +SRCS( + ydb_json_value_ut.cpp +) + +PEERDIR( + library/cpp/json + library/cpp/testing/unittest + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_params +) + +END() diff --git a/ydb/public/lib/json_value/ya.make b/ydb/public/lib/json_value/ya.make new file mode 100644 index 00000000000..cea6eb52ade --- /dev/null +++ b/ydb/public/lib/json_value/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + ydb_json_value.cpp + ydb_json_value_ut.cpp +) + +PEERDIR( + library/cpp/json/writer + library/cpp/string_utils/base64 + ydb/public/sdk/cpp/client/ydb_result + ydb/public/sdk/cpp/client/ydb_value + ydb/library/uuid +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/lib/jwt/ya.make b/ydb/public/lib/jwt/ya.make new file mode 100644 index 00000000000..c7bb9770641 --- /dev/null +++ b/ydb/public/lib/jwt/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + jwt.cpp + jwt.h +) + +PEERDIR( + contrib/libs/jwt-cpp + library/cpp/json + ydb/public/sdk/cpp/client/impl/ydb_internal/common +) + +END() diff --git a/ydb/public/lib/operation_id/protos/ya.make b/ydb/public/lib/operation_id/protos/ya.make new file mode 100644 index 00000000000..26bd32056e5 --- /dev/null +++ b/ydb/public/lib/operation_id/protos/ya.make @@ -0,0 +1,13 @@ +PROTO_LIBRARY() + +IF (OS_WINDOWS) + NO_OPTIMIZE_PY_PROTOS() +ENDIF() + +SRCS( + operation_id.proto +) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/public/lib/operation_id/ut/ya.make b/ydb/public/lib/operation_id/ut/ya.make new file mode 100644 index 00000000000..a22fd22fba0 --- /dev/null +++ b/ydb/public/lib/operation_id/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/public/lib/operation_id) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + operation_id_ut.cpp +) + +PEERDIR( + library/cpp/testing/unittest +) + +END() diff --git a/ydb/public/lib/operation_id/ya.make b/ydb/public/lib/operation_id/ya.make new file mode 100644 index 00000000000..40d77ec872c --- /dev/null +++ b/ydb/public/lib/operation_id/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + operation_id.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/cgiparam + library/cpp/uri + ydb/public/lib/operation_id/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/lib/scheme_types/ya.make b/ydb/public/lib/scheme_types/ya.make new file mode 100644 index 00000000000..c3eaff3cb71 --- /dev/null +++ b/ydb/public/lib/scheme_types/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + scheme_type_id.h + scheme_type_id.cpp +) + +PEERDIR( + ydb/library/yql/public/types +) + +END() diff --git a/ydb/public/lib/validation/ut/protos/ya.make b/ydb/public/lib/validation/ut/protos/ya.make new file mode 100644 index 00000000000..87c3b1fcd0b --- /dev/null +++ b/ydb/public/lib/validation/ut/protos/ya.make @@ -0,0 +1,15 @@ +PROTO_LIBRARY() + +PEERDIR( + ydb/public/api/protos/annotations +) + +SRCS( + validation_test.proto +) + +CPP_PROTO_PLUGIN0(validation ydb/public/lib/validation) + +EXCLUDE_TAGS(GO_PROTO) + +END() diff --git a/ydb/public/lib/validation/ut/ya.make b/ydb/public/lib/validation/ut/ya.make new file mode 100644 index 00000000000..627a2b795e7 --- /dev/null +++ b/ydb/public/lib/validation/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(ydb/public/lib/validation) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/testing/unittest + ydb/public/lib/validation/ut/protos +) + +SRCS( + ut.cpp +) + +END() diff --git a/ydb/public/lib/validation/ya.make b/ydb/public/lib/validation/ya.make new file mode 100644 index 00000000000..e02d0e35a25 --- /dev/null +++ b/ydb/public/lib/validation/ya.make @@ -0,0 +1,18 @@ +PROGRAM() + +PEERDIR( + contrib/libs/protoc + ydb/public/api/protos/annotations +) + +SRCS( + helpers.cpp + main.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut + ut/protos +) diff --git a/ydb/public/lib/value/ya.make b/ydb/public/lib/value/ya.make new file mode 100644 index 00000000000..c87b3d47106 --- /dev/null +++ b/ydb/public/lib/value/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + value.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/string_utils/base64 + ydb/core/protos + ydb/library/mkql_proto/protos + ydb/public/lib/scheme_types + ydb/public/sdk/cpp/client/ydb_value +) + +END() diff --git a/ydb/public/lib/ya.make b/ydb/public/lib/ya.make new file mode 100644 index 00000000000..8ca9900e5cd --- /dev/null +++ b/ydb/public/lib/ya.make @@ -0,0 +1,15 @@ +RECURSE( + base + deprecated + experimental + fq + idx_test + json_value + jwt + operation_id + scheme_types + validation + value + ydb_cli + yson_value +) diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/ut/ya.make b/ydb/public/lib/ydb_cli/commands/topic_workload/ut/ya.make new file mode 100644 index 00000000000..c27f1907bfe --- /dev/null +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/ut/ya.make @@ -0,0 +1,15 @@ +UNITTEST_FOR(ydb/public/lib/ydb_cli/commands/topic_workload) + +FORK_TESTS() + +SRCS( + topic_workload_params_ut.cpp +) + +PEERDIR( + library/cpp/regex/pcre + library/cpp/getopt/small + ydb/public/lib/ydb_cli/commands/topic_workload +) + +END() diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/ya.make b/ydb/public/lib/ydb_cli/commands/topic_workload/ya.make new file mode 100644 index 00000000000..235b6278780 --- /dev/null +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/ya.make @@ -0,0 +1,39 @@ +LIBRARY(topic_workload) + +SRCS( + topic_workload_clean.cpp + topic_workload_describe.cpp + topic_workload_init.cpp + topic_workload_params.cpp + topic_workload_run_read.cpp + topic_workload_run_write.cpp + topic_workload_run_full.cpp + topic_workload_stats.cpp + topic_workload_stats_collector.cpp + topic_workload_writer.cpp + topic_workload_reader.cpp + topic_workload.cpp +) + +PEERDIR( + ydb/library/yql/public/issue + ydb/library/yql/public/issue/protos + ydb/public/api/grpc + ydb/public/api/protos + ydb/public/api/protos/annotations + ydb/public/lib/operation_id + ydb/public/lib/operation_id/protos + ydb/public/sdk/cpp/client/draft + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_topic + ydb/public/sdk/cpp/client/ydb_types/operation + ydb/public/sdk/cpp/client/ydb_types/status +) + +END() + +RECURSE_FOR_TESTS( + ut +)
\ No newline at end of file diff --git a/ydb/public/lib/ydb_cli/commands/ya.make b/ydb/public/lib/ydb_cli/commands/ya.make new file mode 100644 index 00000000000..741a277b92d --- /dev/null +++ b/ydb/public/lib/ydb_cli/commands/ya.make @@ -0,0 +1,70 @@ +LIBRARY(clicommands) + +SRCS( + interactive/interactive_cli.cpp + interactive/interactive_cli.h + interactive/term_io.cpp + interactive/term_io.h + benchmark_utils.cpp + click_bench.cpp + kv_workload.cpp + stock_workload.cpp + tpch.cpp + ydb_sdk_core_access.cpp + ydb_command.cpp + ydb_profile.cpp + ydb_root_common.cpp + ydb_service_auth.cpp + ydb_service_discovery.cpp + ydb_service_export.cpp + ydb_service_import.cpp + ydb_service_monitoring.cpp + ydb_service_operation.cpp + ydb_service_scheme.cpp + ydb_service_scripting.cpp + ydb_service_topic.cpp + ydb_service_table.cpp + ydb_tools.cpp + ydb_workload.cpp + ydb_yql.cpp +) + +PEERDIR( + library/cpp/histogram/hdr + library/cpp/protobuf/json + library/cpp/regex/pcre + library/cpp/threading/local_executor + ydb/library/backup + ydb/library/workload + ydb/public/lib/operation_id + ydb/public/lib/ydb_cli/common + ydb/public/lib/ydb_cli/commands/topic_workload + ydb/public/lib/ydb_cli/dump + ydb/public/lib/ydb_cli/import + ydb/public/lib/ydb_cli/topic + ydb/public/sdk/cpp/client/draft + ydb/public/sdk/cpp/client/ydb_coordination + ydb/public/sdk/cpp/client/ydb_discovery + ydb/public/sdk/cpp/client/ydb_export + ydb/public/sdk/cpp/client/ydb_import + ydb/public/sdk/cpp/client/ydb_monitoring + ydb/public/sdk/cpp/client/ydb_operation + ydb/public/sdk/cpp/client/ydb_persqueue_public + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_topic + ydb/public/sdk/cpp/client/ydb_types/credentials/login +) + +RESOURCE( + click_bench_queries.sql click_bench_queries.sql + click_bench_schema.sql click_bench_schema.sql + tpch_schema.sql tpch_schema.sql +) + +END() + +RECURSE_FOR_TESTS( + topic_workload/ut +)
\ No newline at end of file diff --git a/ydb/public/lib/ydb_cli/common/ut/ya.make b/ydb/public/lib/ydb_cli/common/ut/ya.make new file mode 100644 index 00000000000..ac830732758 --- /dev/null +++ b/ydb/public/lib/ydb_cli/common/ut/ya.make @@ -0,0 +1,7 @@ +UNITTEST_FOR(ydb/public/lib/ydb_cli/common) + +SRCS( + normalize_path_ut.cpp +) + +END() diff --git a/ydb/public/lib/ydb_cli/common/ya.make b/ydb/public/lib/ydb_cli/common/ya.make new file mode 100644 index 00000000000..f58cd19273c --- /dev/null +++ b/ydb/public/lib/ydb_cli/common/ya.make @@ -0,0 +1,53 @@ +LIBRARY(common) + +SRCS( + aws.cpp + command.cpp + common.cpp + examples.cpp + format.cpp + interactive.cpp + interruptible.cpp + normalize_path.cpp + parameters.cpp + pretty_table.cpp + print_operation.cpp + print_utils.cpp + profile_manager.cpp + progress_bar.cpp + query_stats.cpp + recursive_list.cpp + recursive_remove.cpp + retry_func.cpp + root.cpp + scheme_printers.cpp + tabbed_table.cpp + ydb_updater.cpp + yt.cpp +) + +PEERDIR( + library/cpp/config + library/cpp/getopt + library/cpp/json/writer + library/cpp/yaml/as + ydb/public/lib/json_value + ydb/public/lib/operation_id + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/draft + ydb/public/sdk/cpp/client/ydb_result + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_topic + ydb/public/sdk/cpp/client/ydb_types + ydb/public/sdk/cpp/client/ydb_types/credentials +) + +GENERATE_ENUM_SERIALIZATION(formats.h) +GENERATE_ENUM_SERIALIZATION(parameters.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/lib/ydb_cli/dump/util/ya.make b/ydb/public/lib/ydb_cli/dump/util/ya.make new file mode 100644 index 00000000000..2c62b3b0093 --- /dev/null +++ b/ydb/public/lib/ydb_cli/dump/util/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + util.cpp +) + +PEERDIR( + ydb/public/lib/ydb_cli/common + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_types/status +) + +END() diff --git a/ydb/public/lib/ydb_cli/dump/ya.make b/ydb/public/lib/ydb_cli/dump/ya.make new file mode 100644 index 00000000000..52e170cbfed --- /dev/null +++ b/ydb/public/lib/ydb_cli/dump/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + dump.cpp + dump_impl.cpp + restore_impl.cpp + restore_import_data.cpp + restore_compat.cpp +) + +PEERDIR( + library/cpp/bucket_quoter + library/cpp/string_utils/quote + ydb/library/backup + ydb/public/api/protos + ydb/public/lib/ydb_cli/common + ydb/public/lib/ydb_cli/dump/util + ydb/public/sdk/cpp/client/ydb_proto +) + +END() diff --git a/ydb/public/lib/ydb_cli/import/ya.make b/ydb/public/lib/ydb_cli/import/ya.make new file mode 100644 index 00000000000..79e0d4d92cd --- /dev/null +++ b/ydb/public/lib/ydb_cli/import/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + import.cpp + cli_arrow_helpers.cpp +) + +PEERDIR( + ydb/public/api/protos + ydb/public/lib/ydb_cli/common + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/lib/json_value + contrib/libs/apache/arrow + library/cpp/string_utils/csv +) + +END() diff --git a/ydb/public/lib/ydb_cli/topic/ut/ya.make b/ydb/public/lib/ydb_cli/topic/ut/ya.make new file mode 100644 index 00000000000..564f28c600c --- /dev/null +++ b/ydb/public/lib/ydb_cli/topic/ut/ya.make @@ -0,0 +1,37 @@ +UNITTEST_FOR(ydb/public/lib/ydb_cli/topic) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:32) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + topic_write.h + topic_write.cpp + topic_write_ut.cpp + topic_read_ut.cpp +) + +PEERDIR( + library/cpp/histogram/hdr + library/cpp/threading/local_executor + ydb/core/fq/libs/private_client + ydb/public/sdk/cpp/client/ydb_persqueue_public + ydb/public/lib/experimental + ydb/public/lib/ydb_cli/commands + ydb/public/lib/ydb_cli/common + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/public/lib/ydb_cli/topic/ya.make b/ydb/public/lib/ydb_cli/topic/ya.make new file mode 100644 index 00000000000..5c187fee7ed --- /dev/null +++ b/ydb/public/lib/ydb_cli/topic/ya.make @@ -0,0 +1,21 @@ +LIBRARY(topic) + +SRCS( + topic_read.cpp + topic_write.cpp +) + +PEERDIR( + ydb/public/lib/ydb_cli/common + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_persqueue_public + ydb/public/sdk/cpp/client/ydb_topic +) + +GENERATE_ENUM_SERIALIZATION(topic_metadata_fields.h) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/lib/ydb_cli/ya.make b/ydb/public/lib/ydb_cli/ya.make new file mode 100644 index 00000000000..720d7473b15 --- /dev/null +++ b/ydb/public/lib/ydb_cli/ya.make @@ -0,0 +1,9 @@ + +RECURSE( + commands + common + dump + import + topic +) + diff --git a/ydb/public/lib/yson_value/ya.make b/ydb/public/lib/yson_value/ya.make new file mode 100644 index 00000000000..698e0ba50f1 --- /dev/null +++ b/ydb/public/lib/yson_value/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + ydb_yson_value.cpp +) + +PEERDIR( + library/cpp/yson + library/cpp/yson/node + ydb/public/sdk/cpp/client/ydb_result + ydb/public/sdk/cpp/client/ydb_value + ydb/library/uuid +) + +END() diff --git a/ydb/public/sdk/cpp/client/draft/ut/ya.make b/ydb/public/sdk/cpp/client/draft/ut/ya.make new file mode 100644 index 00000000000..48721096773 --- /dev/null +++ b/ydb/public/sdk/cpp/client/draft/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/draft) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +SRCS( + ydb_scripting_response_headers_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/draft/ya.make b/ydb/public/sdk/cpp/client/draft/ya.make new file mode 100644 index 00000000000..600e0c540b1 --- /dev/null +++ b/ydb/public/sdk/cpp/client/draft/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + ydb_dynamic_config.cpp + ydb_scripting.cpp + ydb_long_tx.cpp +) + +PEERDIR( + ydb/public/api/grpc/draft + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_types/operation + ydb/public/sdk/cpp/client/ydb_value +) + +END() + +RECURSE( + ydb_query +) + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/draft/ydb_query/impl/ya.make b/ydb/public/sdk/cpp/client/draft/ydb_query/impl/ya.make new file mode 100644 index 00000000000..969bcdd7745 --- /dev/null +++ b/ydb/public/sdk/cpp/client/draft/ydb_query/impl/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + exec_query.cpp + exec_query.h +) + +PEERDIR( + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_proto +) + +END() diff --git a/ydb/public/sdk/cpp/client/draft/ydb_query/ya.make b/ydb/public/sdk/cpp/client/draft/ydb_query/ya.make new file mode 100644 index 00000000000..fbb582be470 --- /dev/null +++ b/ydb/public/sdk/cpp/client/draft/ydb_query/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + client.cpp + client.h + query.cpp + query.h + stats.cpp + stats.h + tx.cpp + tx.h +) + +PEERDIR( + ydb/public/sdk/cpp/client/draft/ydb_query/impl + ydb/public/sdk/cpp/client/ydb_common_client + ydb/public/sdk/cpp/client/ydb_types/operation +) + +END() diff --git a/ydb/public/sdk/cpp/client/extensions/discovery_mutator/ut/ya.make b/ydb/public/sdk/cpp/client/extensions/discovery_mutator/ut/ya.make new file mode 100644 index 00000000000..196d35ea479 --- /dev/null +++ b/ydb/public/sdk/cpp/client/extensions/discovery_mutator/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/extensions/discovery_mutator) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_table +) + +SRCS( + discovery_mutator_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/extensions/discovery_mutator/ya.make b/ydb/public/sdk/cpp/client/extensions/discovery_mutator/ya.make new file mode 100644 index 00000000000..a6ac89b95ff --- /dev/null +++ b/ydb/public/sdk/cpp/client/extensions/discovery_mutator/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + discovery_mutator.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_extension +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/extensions/solomon_stats/ya.make b/ydb/public/sdk/cpp/client/extensions/solomon_stats/ya.make new file mode 100644 index 00000000000..ffbd00e3a25 --- /dev/null +++ b/ydb/public/sdk/cpp/client/extensions/solomon_stats/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + pull_client.cpp + pull_connector.cpp +) + +PEERDIR( + library/cpp/monlib/encode/json + library/cpp/monlib/metrics + library/cpp/monlib/service + library/cpp/monlib/service/pages + ydb/public/sdk/cpp/client/ydb_extension +) + +END() diff --git a/ydb/public/sdk/cpp/client/extensions/ya.make b/ydb/public/sdk/cpp/client/extensions/ya.make new file mode 100644 index 00000000000..09720e88fae --- /dev/null +++ b/ydb/public/sdk/cpp/client/extensions/ya.make @@ -0,0 +1,4 @@ +RECURSE( + solomon_stats + discovery_mutator +) diff --git a/ydb/public/sdk/cpp/client/iam/common/ya.make b/ydb/public/sdk/cpp/client/iam/common/ya.make new file mode 100644 index 00000000000..53c177e2ffe --- /dev/null +++ b/ydb/public/sdk/cpp/client/iam/common/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + iam.cpp +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/http/simple + library/cpp/json + library/cpp/threading/atomic + ydb/public/lib/jwt + ydb/public/sdk/cpp/client/ydb_types/credentials +) + +END() + diff --git a/ydb/public/sdk/cpp/client/iam/impl/ya.make b/ydb/public/sdk/cpp/client/iam/impl/ya.make new file mode 100644 index 00000000000..064644d44d8 --- /dev/null +++ b/ydb/public/sdk/cpp/client/iam/impl/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + iam_impl.h +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/http/simple + library/cpp/json + library/cpp/threading/atomic + ydb/public/lib/jwt + ydb/public/sdk/cpp/client/ydb_types/credentials + ydb/public/sdk/cpp/client/iam/common +) + +END() diff --git a/ydb/public/sdk/cpp/client/iam/ya.make b/ydb/public/sdk/cpp/client/iam/ya.make new file mode 100644 index 00000000000..0852846e208 --- /dev/null +++ b/ydb/public/sdk/cpp/client/iam/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + iam.cpp +) + +PEERDIR( + ydb/public/api/client/yc_public/iam + ydb/public/sdk/cpp/client/iam/impl + ydb/public/sdk/cpp/client/iam/common +) + +END() diff --git a/ydb/public/sdk/cpp/client/iam_private/ya.make b/ydb/public/sdk/cpp/client/iam_private/ya.make new file mode 100644 index 00000000000..8711e49bb69 --- /dev/null +++ b/ydb/public/sdk/cpp/client/iam_private/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + iam.cpp +) + +PEERDIR( + ydb/public/api/client/yc_private/iam + ydb/public/sdk/cpp/client/iam/common +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_endpoints/ut/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_endpoints/ut/ya.make new file mode 100644 index 00000000000..dd94b74678d --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_endpoints/ut/ya.make @@ -0,0 +1,18 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/impl/ydb_endpoints) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +SRCS( + endpoints_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_endpoints/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_endpoints/ya.make new file mode 100644 index 00000000000..9272547a305 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_endpoints/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + endpoints.cpp +) + +PEERDIR( + library/cpp/monlib/metrics + ydb/public/api/grpc +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/common/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/common/ya.make new file mode 100644 index 00000000000..582bf152a74 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/common/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + parser.cpp + getenv.cpp + string_helpers.cpp +) + +PEERDIR( + library/cpp/grpc/client + ydb/library/yql/public/issue +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/db_driver_state/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/db_driver_state/ya.make new file mode 100644 index 00000000000..966bc37aca0 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/db_driver_state/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + authenticator.cpp + endpoint_pool.cpp + state.cpp +) + +PEERDIR( + library/cpp/string_utils/quote + library/cpp/threading/future + ydb/public/sdk/cpp/client/impl/ydb_endpoints + ydb/public/sdk/cpp/client/impl/ydb_internal/logger + ydb/public/sdk/cpp/client/impl/ydb_internal/plain_status + ydb/public/sdk/cpp/client/ydb_types/credentials +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/grpc_connections/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/grpc_connections/ya.make new file mode 100644 index 00000000000..09cdb3cd5d1 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/grpc_connections/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + actions.cpp + grpc_connections.cpp +) + +PEERDIR( + ydb/public/api/grpc + ydb/public/api/protos + ydb/public/sdk/cpp/client/impl/ydb_internal/db_driver_state + ydb/public/sdk/cpp/client/impl/ydb_internal/plain_status + ydb/public/sdk/cpp/client/impl/ydb_internal/thread_pool + ydb/public/sdk/cpp/client/impl/ydb_stats + ydb/public/sdk/cpp/client/resources + ydb/public/sdk/cpp/client/ydb_types/exceptions +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/logger/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/logger/ya.make new file mode 100644 index 00000000000..b0599d41444 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/logger/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + log.cpp +) + +PEERDIR( + library/cpp/logger +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/make_request/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/make_request/ya.make new file mode 100644 index 00000000000..4794e82b832 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/make_request/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + make.cpp +) + +PEERDIR( + contrib/libs/protobuf + ydb/public/api/protos +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/plain_status/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/plain_status/ya.make new file mode 100644 index 00000000000..0686f0ce6e2 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/plain_status/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + status.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/grpc/client + ydb/library/yql/public/issue +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/thread_pool/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/thread_pool/ya.make new file mode 100644 index 00000000000..aa626871c6f --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/thread_pool/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + pool.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_internal/value_helpers/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_internal/value_helpers/ya.make new file mode 100644 index 00000000000..2756042b0ae --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_internal/value_helpers/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + helpers.cpp +) + +PEERDIR( + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers +) + +END() diff --git a/ydb/public/sdk/cpp/client/impl/ydb_stats/ya.make b/ydb/public/sdk/cpp/client/impl/ydb_stats/ya.make new file mode 100644 index 00000000000..c97ab7ecb23 --- /dev/null +++ b/ydb/public/sdk/cpp/client/impl/ydb_stats/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + stats.cpp +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/monlib/metrics +) + +END() diff --git a/ydb/public/sdk/cpp/client/resources/ya.make b/ydb/public/sdk/cpp/client/resources/ya.make new file mode 100644 index 00000000000..a80d7b8b766 --- /dev/null +++ b/ydb/public/sdk/cpp/client/resources/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + ydb_resources.cpp + ydb_ca.cpp +) + +RESOURCE( + ydb/public/sdk/cpp/client/resources/ydb_sdk_version.txt ydb_sdk_version.txt + ydb/public/sdk/cpp/client/resources/ydb_root_ca.pem ydb_root_ca.pem +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_common_client/impl/ya.make b/ydb/public/sdk/cpp/client/ydb_common_client/impl/ya.make new file mode 100644 index 00000000000..de7a137e282 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_common_client/impl/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + client.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/impl/ydb_internal/grpc_connections +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_common_client/ya.make b/ydb/public/sdk/cpp/client/ydb_common_client/ya.make new file mode 100644 index 00000000000..71ad2227334 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_common_client/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + settings.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/impl/ydb_internal/common + ydb/public/sdk/cpp/client/ydb_types/credentials +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_coordination/ut/ya.make b/ydb/public/sdk/cpp/client/ydb_coordination/ut/ya.make new file mode 100644 index 00000000000..57b41796c4a --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_coordination/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/ydb_coordination) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + ydb/public/api/grpc +) + +SRCS( + coordination_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_coordination/ya.make b/ydb/public/sdk/cpp/client/ydb_coordination/ya.make new file mode 100644 index 00000000000..eea1383b2ee --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_coordination/ya.make @@ -0,0 +1,25 @@ +LIBRARY() + +SRCS( + coordination.cpp + proto_accessor.cpp +) + +GENERATE_ENUM_SERIALIZATION(coordination.h) + +PEERDIR( + ydb/public/api/grpc + ydb/public/sdk/cpp/client/impl/ydb_internal/make_request + ydb/public/sdk/cpp/client/ydb_common_client + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_types + ydb/public/sdk/cpp/client/ydb_types/status +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/ydb_datastreams/ya.make b/ydb/public/sdk/cpp/client/ydb_datastreams/ya.make new file mode 100644 index 00000000000..842be776f0b --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_datastreams/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + datastreams.cpp +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/string_utils/url + ydb/public/api/grpc/draft + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/impl/ydb_internal/make_request + ydb/public/sdk/cpp/client/ydb_driver +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_discovery/ya.make b/ydb/public/sdk/cpp/client/ydb_discovery/ya.make new file mode 100644 index 00000000000..3f547d5a22d --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_discovery/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + discovery.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_driver/ut/ya.make b/ydb/public/sdk/cpp/client/ydb_driver/ut/ya.make new file mode 100644 index 00000000000..e476cc9fc12 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_driver/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/ydb_driver) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_table +) + +SRCS( + driver_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_driver/ya.make b/ydb/public/sdk/cpp/client/ydb_driver/ya.make new file mode 100644 index 00000000000..94a1bf75578 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_driver/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + driver.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/impl/ydb_internal/common + ydb/public/sdk/cpp/client/impl/ydb_internal/grpc_connections + ydb/public/sdk/cpp/client/resources + ydb/public/sdk/cpp/client/ydb_common_client + ydb/public/sdk/cpp/client/ydb_types/status +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/ydb_export/ya.make b/ydb/public/sdk/cpp/client/ydb_export/ya.make new file mode 100644 index 00000000000..5c5455d84f5 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_export/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + export.cpp +) + +GENERATE_ENUM_SERIALIZATION(export.h) + +PEERDIR( + ydb/public/api/grpc + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_types/operation +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_extension/ya.make b/ydb/public/sdk/cpp/client/ydb_extension/ya.make new file mode 100644 index 00000000000..66f54b43d7e --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_extension/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + extension.cpp +) + +PEERDIR( + library/cpp/monlib/metrics + ydb/public/sdk/cpp/client/ydb_driver +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_import/ya.make b/ydb/public/sdk/cpp/client/ydb_import/ya.make new file mode 100644 index 00000000000..a670ca501bb --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_import/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + import.cpp +) + +GENERATE_ENUM_SERIALIZATION(import.h) + +PEERDIR( + ydb/public/api/grpc + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_types/operation +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_monitoring/ya.make b/ydb/public/sdk/cpp/client/ydb_monitoring/ya.make new file mode 100644 index 00000000000..84eb086311c --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_monitoring/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + monitoring.cpp +) + +GENERATE_ENUM_SERIALIZATION(monitoring.h) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/impl/ydb_internal/make_request + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver +) + +END() + diff --git a/ydb/public/sdk/cpp/client/ydb_operation/ya.make b/ydb/public/sdk/cpp/client/ydb_operation/ya.make new file mode 100644 index 00000000000..15ccb52ff5a --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_operation/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + operation.cpp +) + +PEERDIR( + ydb/public/api/grpc + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/draft/ydb_query + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_export + ydb/public/sdk/cpp/client/ydb_import + ydb/public/sdk/cpp/client/ydb_types/operation +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_params/ut/ya.make b/ydb/public/sdk/cpp/client/ydb_params/ut/ya.make new file mode 100644 index 00000000000..55a97e2c74e --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_params/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/ydb_params) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + ydb/public/lib/yson_value +) + +SRCS( + params_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_params/ya.make b/ydb/public/sdk/cpp/client/ydb_params/ya.make new file mode 100644 index 00000000000..32f82f820b5 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_params/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + params.cpp + impl.cpp +) + +PEERDIR( + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers + ydb/public/sdk/cpp/client/ydb_value +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/ya.make b/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/ya.make new file mode 100644 index 00000000000..7694f10ba83 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/ya.make @@ -0,0 +1,28 @@ +LIBRARY() + +SRCS( + read_session_messages.cpp + common.cpp + write_session.cpp + write_session_impl.cpp + read_session.h + read_session.cpp + persqueue.cpp + persqueue_impl.cpp +) + +PEERDIR( + library/cpp/containers/disjoint_interval_tree + library/cpp/grpc/client + library/cpp/monlib/dynamic_counters + library/cpp/monlib/metrics + library/cpp/string_utils/url + ydb/library/persqueue/obfuscate + ydb/public/api/grpc/draft + ydb/public/sdk/cpp/client/impl/ydb_internal/make_request + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/api/grpc/draft +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/ya.make b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/ya.make new file mode 100644 index 00000000000..f9f083cb728 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + data_plane_helpers.cpp + sdk_test_setup.h + test_utils.h + test_server.h + test_server.cpp + ut_utils.h + ut_utils.cpp +) + +PEERDIR( + library/cpp/grpc/server + library/cpp/testing/unittest + library/cpp/threading/chunk_queue + ydb/core/testlib/default + ydb/library/persqueue/topic_parser_public + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_core + ydb/public/sdk/cpp/client/ydb_persqueue_public + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/with_offset_ranges_mode_ut/ya.make b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/with_offset_ranges_mode_ut/ya.make new file mode 100644 index 00000000000..9467d98cb9f --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/with_offset_ranges_mode_ut/ya.make @@ -0,0 +1,39 @@ +UNITTEST() + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + library/cpp/testing/gmock_in_unittest + ydb/public/lib/json_value + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils +) + +YQL_LAST_ABI_VERSION() + +ENV(PQ_OFFSET_RANGES_MODE="1") + +SRCDIR( + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut + ydb/public/sdk/cpp/client/ydb_persqueue_core +) + +SRCS( + common_ut.cpp + read_session_ut.cpp + basic_usage_ut.cpp + compress_executor_ut.cpp + retry_policy_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ya.make b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ya.make new file mode 100644 index 00000000000..e25c3c46795 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ya.make @@ -0,0 +1,41 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/ydb_persqueue_core) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + library/cpp/testing/gmock_in_unittest + ydb/core/testlib/default + ydb/public/lib/json_value + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_core + ydb/public/sdk/cpp/client/ydb_persqueue_core/impl + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils + ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs +) + +YQL_LAST_ABI_VERSION() + +SRCS( + common_ut.cpp + read_session_ut.cpp + basic_usage_ut.cpp + compress_executor_ut.cpp + compression_ut.cpp + retry_policy_ut.cpp +) + +END() + +RECURSE_FOR_TESTS( + with_offset_ranges_mode_ut +) diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/ya.make b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ya.make new file mode 100644 index 00000000000..0923e420190 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/ya.make @@ -0,0 +1,23 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(ydb/public/sdk/cpp/client/ydb_persqueue_core/persqueue.h) + +SRCS( + persqueue.h +) + +PEERDIR( + library/cpp/retry + ydb/public/sdk/cpp/client/ydb_persqueue_core/impl + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs/ya.make b/ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs/ya.make new file mode 100644 index 00000000000..96644d9f7e6 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + codecs.h + codecs.cpp +) + +PEERDIR( + library/cpp/streams/zstd + ydb/library/yql/public/issue/protos + ydb/public/api/grpc/draft + ydb/public/api/grpc + ydb/public/api/protos +) + +PROVIDES(pq_codecs_2) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_public/ya.make b/ydb/public/sdk/cpp/client/ydb_persqueue_public/ya.make new file mode 100644 index 00000000000..607c1f3b710 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_persqueue_public/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +SRCS( + persqueue.h +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_persqueue_core + ydb/public/sdk/cpp/client/ydb_persqueue_public/codecs +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_proto/ya.make b/ydb/public/sdk/cpp/client/ydb_proto/ya.make new file mode 100644 index 00000000000..337dd4dd9b7 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_proto/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + accessor.cpp +) + +PEERDIR( + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/public/lib/operation_id/protos + ydb/public/sdk/cpp/client/ydb_params + ydb/public/sdk/cpp/client/ydb_value + ydb/library/yql/public/issue/protos +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_rate_limiter/ya.make b/ydb/public/sdk/cpp/client/ydb_rate_limiter/ya.make new file mode 100644 index 00000000000..fd29a5c0ac1 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_rate_limiter/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + rate_limiter.cpp +) + +PEERDIR( + ydb/public/api/grpc + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_result/ut/ya.make b/ydb/public/sdk/cpp/client/ydb_result/ut/ya.make new file mode 100644 index 00000000000..aed10def6b0 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_result/ut/ya.make @@ -0,0 +1,22 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/ydb_result) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +SRCS( + result_ut.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_params +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_result/ya.make b/ydb/public/sdk/cpp/client/ydb_result/ya.make new file mode 100644 index 00000000000..b1b30ac53db --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_result/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + proto_accessor.cpp + result.cpp +) + +PEERDIR( + ydb/public/api/protos + ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers + ydb/public/sdk/cpp/client/ydb_value + ydb/public/sdk/cpp/client/ydb_proto +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/ydb_scheme/ya.make b/ydb/public/sdk/cpp/client/ydb_scheme/ya.make new file mode 100644 index 00000000000..27325372e87 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_scheme/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + scheme.cpp +) + +GENERATE_ENUM_SERIALIZATION(scheme.h) + +PEERDIR( + ydb/public/sdk/cpp/client/impl/ydb_internal/make_request + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_table/impl/ya.make b/ydb/public/sdk/cpp/client/ydb_table/impl/ya.make new file mode 100644 index 00000000000..6aefb9f845c --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_table/impl/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + client_session.cpp + data_query.cpp + readers.cpp + request_migrator.cpp + session_pool.cpp + table_client.cpp +) + +PEERDIR( + library/cpp/threading/future + ydb/public/api/protos + ydb/public/lib/operation_id/protos + ydb/public/sdk/cpp/client/impl/ydb_endpoints + ydb/public/sdk/cpp/client/ydb_table/query_stats + ydb/library/yql/public/issue/protos +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_table/query_stats/ya.make b/ydb/public/sdk/cpp/client/ydb_table/query_stats/ya.make new file mode 100644 index 00000000000..d2310b52143 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_table/query_stats/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + stats.cpp +) + +PEERDIR( + contrib/libs/protobuf + ydb/public/api/protos + ydb/public/sdk/cpp/client/draft/ydb_query +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_table/ya.make b/ydb/public/sdk/cpp/client/ydb_table/ya.make new file mode 100644 index 00000000000..c998ef545a8 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_table/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + table.cpp + proto_accessor.cpp +) + +GENERATE_ENUM_SERIALIZATION(table_enum.h) + +PEERDIR( + ydb/public/api/protos + ydb/public/sdk/cpp/client/impl/ydb_internal/make_request + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_params + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_result + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table/impl + ydb/public/sdk/cpp/client/ydb_table/query_stats + ydb/public/sdk/cpp/client/ydb_types/operation + ydb/public/sdk/cpp/client/ydb_value +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_topic/codecs/ya.make b/ydb/public/sdk/cpp/client/ydb_topic/codecs/ya.make new file mode 100644 index 00000000000..c16eb291841 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_topic/codecs/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + codecs.h + codecs.cpp +) + +PEERDIR( + library/cpp/streams/zstd + ydb/library/yql/public/issue/protos + ydb/public/api/grpc/draft + ydb/public/api/grpc + ydb/public/api/protos +) + +PROVIDES(topic_codecs) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_topic/impl/ya.make b/ydb/public/sdk/cpp/client/ydb_topic/impl/ya.make new file mode 100644 index 00000000000..682cbf65516 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_topic/impl/ya.make @@ -0,0 +1,36 @@ +LIBRARY() + +SRCS( + executor.h + executor.cpp + read_session_event.cpp + counters.cpp + deferred_commit.cpp + event_handlers.cpp + read_session.h + read_session.cpp + write_session.h + write_session.cpp + write_session_impl.h + write_session_impl.cpp + topic_impl.h + topic_impl.cpp + topic.cpp +) + +PEERDIR( + library/cpp/grpc/client + library/cpp/monlib/dynamic_counters + library/cpp/monlib/metrics + library/cpp/string_utils/url + ydb/library/persqueue/obfuscate + ydb/public/api/grpc/draft + ydb/public/api/grpc + ydb/public/sdk/cpp/client/impl/ydb_internal/make_request + ydb/public/sdk/cpp/client/ydb_common_client/impl + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_core/impl + ydb/public/sdk/cpp/client/ydb_proto +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_topic/ut/ya.make b/ydb/public/sdk/cpp/client/ydb_topic/ut/ya.make new file mode 100644 index 00000000000..8fa90c20a7b --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_topic/ut/ya.make @@ -0,0 +1,37 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/ydb_topic) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + library/cpp/testing/gmock_in_unittest + ydb/core/testlib/default + ydb/public/lib/json_value + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/sdk/cpp/client/ydb_persqueue_core + ydb/public/sdk/cpp/client/ydb_persqueue_core/impl + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils + ydb/public/sdk/cpp/client/ydb_topic/codecs + + ydb/public/sdk/cpp/client/ydb_topic + ydb/public/sdk/cpp/client/ydb_topic/impl +) + +YQL_LAST_ABI_VERSION() + +SRCS( + basic_usage_ut.cpp + managed_executor.h + managed_executor.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_topic/ya.make b/ydb/public/sdk/cpp/client/ydb_topic/ya.make new file mode 100644 index 00000000000..2c096421b7f --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_topic/ya.make @@ -0,0 +1,26 @@ +LIBRARY() + +GENERATE_ENUM_SERIALIZATION(ydb/public/sdk/cpp/client/ydb_topic/topic.h) + +SRCS( + topic.h + proto_accessor.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_topic/codecs + + library/cpp/retry + ydb/public/sdk/cpp/client/ydb_topic/impl + ydb/public/sdk/cpp/client/ydb_proto + ydb/public/sdk/cpp/client/ydb_driver + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/client/ydb_types/credentials/login/ya.make b/ydb/public/sdk/cpp/client/ydb_types/credentials/login/ya.make new file mode 100644 index 00000000000..6edc7a3459c --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_types/credentials/login/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + login.cpp +) + +PEERDIR( + ydb/library/login + ydb/public/api/grpc + ydb/public/sdk/cpp/client/ydb_types/status + ydb/public/sdk/cpp/client/impl/ydb_internal/grpc_connections + ydb/library/yql/public/issue +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_types/credentials/ya.make b/ydb/public/sdk/cpp/client/ydb_types/credentials/ya.make new file mode 100644 index 00000000000..1499456b8ff --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_types/credentials/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + credentials.cpp +) + +PEERDIR( + ydb/library/login + ydb/public/api/grpc + ydb/public/sdk/cpp/client/ydb_types/status + ydb/library/yql/public/issue +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_types/exceptions/ya.make b/ydb/public/sdk/cpp/client/ydb_types/exceptions/ya.make new file mode 100644 index 00000000000..499d0b55289 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_types/exceptions/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + exceptions.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers/ya.make b/ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers/ya.make new file mode 100644 index 00000000000..a9c11d5a2c7 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + handlers.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_types/exceptions +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_types/operation/ya.make b/ydb/public/sdk/cpp/client/ydb_types/operation/ya.make new file mode 100644 index 00000000000..aa0c2649b22 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_types/operation/ya.make @@ -0,0 +1,14 @@ +LIBRARY() + +SRCS( + operation.cpp +) + +PEERDIR( + contrib/libs/protobuf + library/cpp/threading/future + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/ydb_types +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_types/status/ya.make b/ydb/public/sdk/cpp/client/ydb_types/status/ya.make new file mode 100644 index 00000000000..ad113654466 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_types/status/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + status.cpp +) + +PEERDIR( + library/cpp/threading/future + ydb/public/sdk/cpp/client/impl/ydb_internal/plain_status + ydb/public/sdk/cpp/client/ydb_types + ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers + ydb/library/yql/public/issue +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_types/ya.make b/ydb/public/sdk/cpp/client/ydb_types/ya.make new file mode 100644 index 00000000000..1f7d73857da --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_types/ya.make @@ -0,0 +1,12 @@ +LIBRARY() + +PEERDIR( + contrib/libs/protobuf + library/cpp/grpc/client + ydb/library/yql/public/issue +) + +GENERATE_ENUM_SERIALIZATION(s3_settings.h) +GENERATE_ENUM_SERIALIZATION(status_codes.h) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_value/ut/ya.make b/ydb/public/sdk/cpp/client/ydb_value/ut/ya.make new file mode 100644 index 00000000000..39d07de7b71 --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_value/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/public/sdk/cpp/client/ydb_value) + +IF (SANITIZER_TYPE) + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +FORK_SUBTESTS() + +PEERDIR( + ydb/public/lib/json_value + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_params +) + +SRCS( + value_ut.cpp +) + +END() diff --git a/ydb/public/sdk/cpp/client/ydb_value/ya.make b/ydb/public/sdk/cpp/client/ydb_value/ya.make new file mode 100644 index 00000000000..e01cffbabff --- /dev/null +++ b/ydb/public/sdk/cpp/client/ydb_value/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + value.cpp +) + +GENERATE_ENUM_SERIALIZATION(value.h) + +PEERDIR( + library/cpp/containers/stack_vector + ydb/public/api/protos + ydb/public/sdk/cpp/client/impl/ydb_internal/value_helpers + ydb/public/sdk/cpp/client/ydb_types/fatal_error_handlers + ydb/library/yql/public/decimal + ydb/library/uuid +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/public/sdk/cpp/examples/basic_example/ya.make b/ydb/public/sdk/cpp/examples/basic_example/ya.make new file mode 100644 index 00000000000..b4bd1b33a81 --- /dev/null +++ b/ydb/public/sdk/cpp/examples/basic_example/ya.make @@ -0,0 +1,14 @@ +PROGRAM() + +SRCS( + main.cpp + basic_example_data.cpp + basic_example.cpp +) + +PEERDIR( + library/cpp/getopt + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/sdk/cpp/examples/bulk_upsert_simple/ya.make b/ydb/public/sdk/cpp/examples/bulk_upsert_simple/ya.make new file mode 100644 index 00000000000..d2ad2b027db --- /dev/null +++ b/ydb/public/sdk/cpp/examples/bulk_upsert_simple/ya.make @@ -0,0 +1,12 @@ +PROGRAM() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/getopt + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/sdk/cpp/examples/pagination/ya.make b/ydb/public/sdk/cpp/examples/pagination/ya.make new file mode 100644 index 00000000000..94bce03191b --- /dev/null +++ b/ydb/public/sdk/cpp/examples/pagination/ya.make @@ -0,0 +1,14 @@ +PROGRAM() + +SRCS( + main.cpp + pagination_data.cpp + pagination.cpp +) + +PEERDIR( + library/cpp/getopt + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/sdk/cpp/examples/secondary_index/ya.make b/ydb/public/sdk/cpp/examples/secondary_index/ya.make new file mode 100644 index 00000000000..7fdce06496a --- /dev/null +++ b/ydb/public/sdk/cpp/examples/secondary_index/ya.make @@ -0,0 +1,19 @@ +PROGRAM() + +SRCS( + main.cpp + secondary_index.cpp + secondary_index_create.cpp + secondary_index_delete.cpp + secondary_index_drop.cpp + secondary_index_generate.cpp + secondary_index_list.cpp + secondary_index_update.cpp +) + +PEERDIR( + library/cpp/getopt + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/sdk/cpp/examples/secondary_index_builtin/ya.make b/ydb/public/sdk/cpp/examples/secondary_index_builtin/ya.make new file mode 100644 index 00000000000..ed9099e8061 --- /dev/null +++ b/ydb/public/sdk/cpp/examples/secondary_index_builtin/ya.make @@ -0,0 +1,18 @@ +PROGRAM() + +SRCS( + main.cpp + secondary_index.cpp + secondary_index_create.cpp + secondary_index_fill.cpp + secondary_index_select.cpp + secondary_index_drop.cpp + secondary_index_select_join.cpp +) + +PEERDIR( + library/cpp/getopt + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/sdk/cpp/examples/topic_reader/eventloop/ya.make b/ydb/public/sdk/cpp/examples/topic_reader/eventloop/ya.make new file mode 100644 index 00000000000..79eea9e9895 --- /dev/null +++ b/ydb/public/sdk/cpp/examples/topic_reader/eventloop/ya.make @@ -0,0 +1,12 @@ +PROGRAM(persqueue_reader_eventloop) + +SRCS( + main.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_topic + library/cpp/getopt +) + +END() diff --git a/ydb/public/sdk/cpp/examples/topic_reader/simple/ya.make b/ydb/public/sdk/cpp/examples/topic_reader/simple/ya.make new file mode 100644 index 00000000000..71006ad8716 --- /dev/null +++ b/ydb/public/sdk/cpp/examples/topic_reader/simple/ya.make @@ -0,0 +1,12 @@ +PROGRAM(simple_persqueue_reader) + +SRCS( + main.cpp +) + +PEERDIR( + ydb/public/sdk/cpp/client/ydb_topic + library/cpp/getopt +) + +END() diff --git a/ydb/public/sdk/cpp/examples/topic_reader/ya.make b/ydb/public/sdk/cpp/examples/topic_reader/ya.make new file mode 100644 index 00000000000..e8da490e565 --- /dev/null +++ b/ydb/public/sdk/cpp/examples/topic_reader/ya.make @@ -0,0 +1,4 @@ +RECURSE( + eventloop + simple +) diff --git a/ydb/public/sdk/cpp/examples/ttl/ya.make b/ydb/public/sdk/cpp/examples/ttl/ya.make new file mode 100644 index 00000000000..c030e09c278 --- /dev/null +++ b/ydb/public/sdk/cpp/examples/ttl/ya.make @@ -0,0 +1,15 @@ +PROGRAM() + +SRCS( + main.cpp + ttl.h + ttl.cpp + util.h +) + +PEERDIR( + library/cpp/getopt + ydb/public/sdk/cpp/client/ydb_table +) + +END() diff --git a/ydb/public/sdk/cpp/examples/ya.make b/ydb/public/sdk/cpp/examples/ya.make new file mode 100644 index 00000000000..2cb41f28d27 --- /dev/null +++ b/ydb/public/sdk/cpp/examples/ya.make @@ -0,0 +1,9 @@ +RECURSE( + basic_example + bulk_upsert_simple + pagination + secondary_index + secondary_index_builtin + topic_reader + ttl +) diff --git a/ydb/public/sdk/cpp/ya.make b/ydb/public/sdk/cpp/ya.make new file mode 100644 index 00000000000..4d6721ba89b --- /dev/null +++ b/ydb/public/sdk/cpp/ya.make @@ -0,0 +1,59 @@ +RECURSE( + client/ydb_types/credentials + client/ydb_discovery + client/ydb_types/status + client/ydb_persqueue_core/ut/with_offset_ranges_mode_ut + client/ydb_types + client/ydb_table + client/ydb_coordination + client/ydb_persqueue_public/codecs + client/ydb_import + client/ydb_driver/ut + client/ydb_driver + client/ydb_persqueue_public + client/ydb_proto + client/ydb_common_client + client/ydb_datastreams + client/ydb_scheme + client/ydb_export + client/ydb_persqueue_core/impl + client/ydb_value/ut + client/ydb_types/fatal_error_handlers + client/ydb_operation + client/ydb_persqueue_core + client/ydb_persqueue_core/ut + client/ydb_topic + client/ydb_topic/codecs + client/ydb_topic/impl + client/ydb_topic/ut + client/ydb_extension + client/ydb_result/ut + client/ydb_params/ut + client/ydb_rate_limiter + client/ydb_coordination/ut + client/ydb_result + client/ydb_types/exceptions + client/ydb_types/operation + client/ydb_params + client/ydb_value + client/ydb_table/impl + client/ydb_common_client/impl + client/ydb_table/query_stats + client/ydb_persqueue_core/ut/ut_utils + client/impl/ydb_internal/grpc_connections + client/impl/ydb_stats + client/impl/ydb_internal/value_helpers + client/impl/ydb_internal/common + client/impl/ydb_endpoints + client/impl/ydb_internal/plain_status + client/impl/ydb_internal/thread_pool + client/impl/ydb_endpoints/ut + client/extensions + client/impl/ydb_internal/logger + client/impl/ydb_internal/make_request + client/resources + client/impl/ydb_internal/db_driver_state + client/draft/ut + client/draft + examples +) diff --git a/ydb/public/sdk/python/ya.make b/ydb/public/sdk/python/ya.make new file mode 100644 index 00000000000..c05e9d4fb9e --- /dev/null +++ b/ydb/public/sdk/python/ya.make @@ -0,0 +1,9 @@ +PY23_LIBRARY() + +IF (PYTHON2) + PEERDIR(ydb/public/sdk/python2) +ELSE() + PEERDIR(ydb/public/sdk/python3) +ENDIF() + +END() diff --git a/ydb/public/sdk/python2/ya.make b/ydb/public/sdk/python2/ya.make new file mode 100644 index 00000000000..8b983ba5c5f --- /dev/null +++ b/ydb/public/sdk/python2/ya.make @@ -0,0 +1,52 @@ +PY2_LIBRARY() + +PY_SRCS( + TOP_LEVEL + ydb/__init__.py + ydb/_apis.py + ydb/_session_impl.py + ydb/_sp_impl.py + ydb/_tx_ctx_impl.py + ydb/_utilities.py + ydb/auth_helpers.py + ydb/connection.py + ydb/convert.py + ydb/credentials.py + ydb/dbapi/__init__.py + ydb/dbapi/connection.py + ydb/dbapi/cursor.py + ydb/dbapi/errors.py + ydb/default_pem.py + ydb/driver.py + ydb/export.py + ydb/iam/__init__.py + ydb/iam/auth.py + ydb/import_client.py + ydb/interceptor.py + ydb/issues.py + ydb/operation.py + ydb/pool.py + ydb/resolver.py + ydb/scheme.py + ydb/scripting.py + ydb/settings.py + ydb/sqlalchemy/__init__.py + ydb/sqlalchemy/types.py + ydb/table.py + ydb/tracing.py + ydb/types.py + ydb/ydb_version.py +) + +PEERDIR( + contrib/deprecated/python/enum34 + contrib/deprecated/python/futures + contrib/python/grpcio + contrib/python/protobuf + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos + +) + +END() diff --git a/ydb/public/sdk/python3/ya.make b/ydb/public/sdk/python3/ya.make new file mode 100644 index 00000000000..3e4fbeb109d --- /dev/null +++ b/ydb/public/sdk/python3/ya.make @@ -0,0 +1,81 @@ +PY3_LIBRARY() + +PY_SRCS( + TOP_LEVEL + ydb/__init__.py + ydb/_apis.py + ydb/_errors.py + ydb/_grpc/__init__.py + ydb/_grpc/common/__init__.py + ydb/_grpc/grpcwrapper/__init__.py + ydb/_grpc/grpcwrapper/common_utils.py + ydb/_grpc/grpcwrapper/ydb_scheme.py + ydb/_grpc/grpcwrapper/ydb_topic.py + ydb/_grpc/grpcwrapper/ydb_topic_public_types.py + ydb/_session_impl.py + ydb/_sp_impl.py + ydb/_topic_common/__init__.py + ydb/_topic_common/common.py + ydb/_topic_common/test_helpers.py + ydb/_topic_reader/__init__.py + ydb/_topic_reader/datatypes.py + ydb/_topic_reader/topic_reader.py + ydb/_topic_reader/topic_reader_asyncio.py + ydb/_topic_reader/topic_reader_sync.py + ydb/_topic_writer/__init__.py + ydb/_topic_writer/topic_writer.py + ydb/_topic_writer/topic_writer_asyncio.py + ydb/_topic_writer/topic_writer_sync.py + ydb/_tx_ctx_impl.py + ydb/_utilities.py + ydb/aio/__init__.py + ydb/aio/_utilities.py + ydb/aio/connection.py + ydb/aio/credentials.py + ydb/aio/driver.py + ydb/aio/iam.py + ydb/aio/pool.py + ydb/aio/resolver.py + ydb/aio/scheme.py + ydb/aio/table.py + ydb/auth_helpers.py + ydb/connection.py + ydb/convert.py + ydb/credentials.py + ydb/dbapi/__init__.py + ydb/dbapi/connection.py + ydb/dbapi/cursor.py + ydb/dbapi/errors.py + ydb/default_pem.py + ydb/driver.py + ydb/export.py + ydb/global_settings.py + ydb/iam/__init__.py + ydb/iam/auth.py + ydb/import_client.py + ydb/interceptor.py + ydb/issues.py + ydb/operation.py + ydb/pool.py + ydb/resolver.py + ydb/scheme.py + ydb/scripting.py + ydb/settings.py + ydb/sqlalchemy/__init__.py + ydb/sqlalchemy/types.py + ydb/table.py + ydb/topic.py + ydb/tracing.py + ydb/types.py + ydb/ydb_version.py +) + +PEERDIR( + contrib/python/grpcio + contrib/python/protobuf + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos +) + +END() diff --git a/ydb/public/sdk/ya.make b/ydb/public/sdk/ya.make new file mode 100644 index 00000000000..0cb53806e95 --- /dev/null +++ b/ydb/public/sdk/ya.make @@ -0,0 +1,6 @@ +RECURSE( + cpp + python + python2 + python3 +) diff --git a/ydb/public/tools/lib/cmds/ya.make b/ydb/public/tools/lib/cmds/ya.make new file mode 100644 index 00000000000..d8ef2f061bd --- /dev/null +++ b/ydb/public/tools/lib/cmds/ya.make @@ -0,0 +1,11 @@ +PY23_LIBRARY() +PY_SRCS( + __init__.py +) + +PEERDIR( + ydb/tests/library + library/python/testing/recipe +) + +END() diff --git a/ydb/public/tools/lib/ya.make b/ydb/public/tools/lib/ya.make new file mode 100644 index 00000000000..ec248c6d850 --- /dev/null +++ b/ydb/public/tools/lib/ya.make @@ -0,0 +1,3 @@ +RECURSE( + cmds +) diff --git a/ydb/public/tools/local_ydb/ya.make b/ydb/public/tools/local_ydb/ya.make new file mode 100644 index 00000000000..f3b0fe403df --- /dev/null +++ b/ydb/public/tools/local_ydb/ya.make @@ -0,0 +1,19 @@ +PY3_PROGRAM(local_ydb) + +IF (OPENSOURCE) + + RESTRICT_LICENSES( + DENY REQUIRE_DISCLOSURE FORBIDDEN PROTESTWARE + # DTCC-553 + EXCEPT contrib/libs/linux-headers + ) + +ENDIF() + +PY_SRCS(__main__.py) + +PEERDIR( + ydb/public/tools/lib/cmds +) + +END() diff --git a/ydb/public/tools/ya.make b/ydb/public/tools/ya.make new file mode 100644 index 00000000000..b21a8cb22a4 --- /dev/null +++ b/ydb/public/tools/ya.make @@ -0,0 +1,5 @@ +RECURSE( + lib + ydb_recipe + local_ydb +) diff --git a/ydb/public/tools/ydb_recipe/recipe.inc b/ydb/public/tools/ydb_recipe/recipe.inc new file mode 100644 index 00000000000..b14c39f62b7 --- /dev/null +++ b/ydb/public/tools/ydb_recipe/recipe.inc @@ -0,0 +1,10 @@ +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +DEPENDS( + ydb/apps/ydbd + ydb/public/tools/ydb_recipe +) + +USE_RECIPE( + ydb/public/tools/ydb_recipe/ydb_recipe --suppress-version-check +) diff --git a/ydb/public/tools/ydb_recipe/ya.make b/ydb/public/tools/ydb_recipe/ya.make new file mode 100644 index 00000000000..a730a5d291e --- /dev/null +++ b/ydb/public/tools/ydb_recipe/ya.make @@ -0,0 +1,15 @@ +PY3_PROGRAM(ydb_recipe) + +SRCDIR( + ydb/public/tools/ydb_recipe +) + +PY_SRCS(__main__.py) + +PEERDIR( + library/python/testing/recipe + library/python/testing/yatest_common + ydb/public/tools/lib/cmds +) + +END() diff --git a/ydb/public/ya.make b/ydb/public/ya.make new file mode 100644 index 00000000000..da126ee98bb --- /dev/null +++ b/ydb/public/ya.make @@ -0,0 +1,6 @@ +RECURSE( + api + lib + sdk + tools +) diff --git a/ydb/services/auth/ya.make b/ydb/services/auth/ya.make new file mode 100644 index 00000000000..66b2f506447 --- /dev/null +++ b/ydb/services/auth/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + library/cpp/lwtrace + ydb/core/grpc_services + ydb/core/protos + ydb/library/login + ydb/public/api/grpc + ydb/public/lib/operation_id +) + +END() diff --git a/ydb/services/bg_tasks/abstract/ya.make b/ydb/services/bg_tasks/abstract/ya.make new file mode 100644 index 00000000000..242c1af4629 --- /dev/null +++ b/ydb/services/bg_tasks/abstract/ya.make @@ -0,0 +1,20 @@ +LIBRARY() + +SRCS( + common.cpp + interface.cpp + scheduler.cpp + activity.cpp + task.cpp + state.cpp +) + +PEERDIR( + ydb/library/accessor + library/cpp/actors/core + ydb/public/api/protos + ydb/services/bg_tasks/protos + ydb/core/base +) + +END() diff --git a/ydb/services/bg_tasks/ds_table/ya.make b/ydb/services/bg_tasks/ds_table/ya.make new file mode 100644 index 00000000000..811905f8b97 --- /dev/null +++ b/ydb/services/bg_tasks/ds_table/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +SRCS( + behaviour.cpp + executor.cpp + interrupt.cpp + task_executor_controller.cpp + executor_controller.cpp + task_executor.cpp + finish_task.cpp + assign_tasks.cpp + fetch_tasks.cpp + config.cpp + add_tasks.cpp + task_enabled.cpp + lock_pinger.cpp + initialization.cpp +) + +PEERDIR( + ydb/library/accessor + library/cpp/actors/core + ydb/public/api/protos + ydb/services/bg_tasks/abstract + ydb/services/metadata/initializer + ydb/core/base + ydb/services/metadata/request +) + +END() diff --git a/ydb/services/bg_tasks/protos/ya.make b/ydb/services/bg_tasks/protos/ya.make new file mode 100644 index 00000000000..06453241a7a --- /dev/null +++ b/ydb/services/bg_tasks/protos/ya.make @@ -0,0 +1,10 @@ +PROTO_LIBRARY() + +SRCS( + container.proto +) + +PEERDIR( +) + +END() diff --git a/ydb/services/bg_tasks/ut/ya.make b/ydb/services/bg_tasks/ut/ya.make new file mode 100644 index 00000000000..13c91f6c8cb --- /dev/null +++ b/ydb/services/bg_tasks/ut/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/services/bg_tasks) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib + ydb/services/bg_tasks + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_table + ydb/services/bg_tasks/abstract + ydb/services/bg_tasks + library/cpp/testing/unittest + ydb/library/yql/parser/pg_wrapper + ydb/library/yql/sql/pg +) + +SRCS( + ut_tasks.cpp + GLOBAL task_emulator.cpp +) + +SIZE(MEDIUM) +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/bg_tasks/ya.make b/ydb/services/bg_tasks/ya.make new file mode 100644 index 00000000000..76dc269b89c --- /dev/null +++ b/ydb/services/bg_tasks/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + service.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/services/metadata/abstract + ydb/services/bg_tasks/abstract + ydb/services/bg_tasks/protos +) + +END() + +RECURSE_FOR_TESTS( + ut +)
\ No newline at end of file diff --git a/ydb/services/cms/ut/ya.make b/ydb/services/cms/ut/ya.make new file mode 100644 index 00000000000..0d169e9f5ee --- /dev/null +++ b/ydb/services/cms/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/services/cms) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + cms_ut.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/grpc/client + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/cms +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/cms/ya.make b/ydb/services/cms/ya.make new file mode 100644 index 00000000000..3e82f8f4a4a --- /dev/null +++ b/ydb/services/cms/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/grpc_services + ydb/core/mind + ydb/library/aclib + ydb/public/api/grpc + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/resources +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/services/datastreams/ut/ya.make b/ydb/services/datastreams/ut/ya.make new file mode 100644 index 00000000000..685b8e91ccc --- /dev/null +++ b/ydb/services/datastreams/ut/ya.make @@ -0,0 +1,26 @@ +UNITTEST_FOR(ydb/services/datastreams) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +TIMEOUT(600) + +SRCS( + datastreams_ut.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/grpc/client + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/datastreams + ydb/public/sdk/cpp/client/ydb_topic +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:11) + +END() diff --git a/ydb/services/datastreams/ya.make b/ydb/services/datastreams/ya.make new file mode 100644 index 00000000000..faed9169024 --- /dev/null +++ b/ydb/services/datastreams/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +SRCS( + datastreams_proxy.cpp + grpc_service.cpp + next_token.cpp + put_records_actor.cpp + shard_iterator.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/base + ydb/core/client/server + ydb/core/grpc_services + ydb/core/mind + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/resources + ydb/public/sdk/cpp/client/ydb_datastreams + ydb/services/lib/actors + ydb/services/lib/sharding + ydb/services/persqueue_v1 + ydb/services/ydb +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/services/discovery/ya.make b/ydb/services/discovery/ya.make new file mode 100644 index 00000000000..e087abc6f09 --- /dev/null +++ b/ydb/services/discovery/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/grpc_services + ydb/core/mind + ydb/public/api/grpc + ydb/public/lib/operation_id +) + +END() diff --git a/ydb/services/dynamic_config/ut/ya.make b/ydb/services/dynamic_config/ut/ya.make new file mode 100644 index 00000000000..90fbc7a9353 --- /dev/null +++ b/ydb/services/dynamic_config/ut/ya.make @@ -0,0 +1,24 @@ +UNITTEST_FOR(ydb/services/dynamic_config) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SIZE(MEDIUM) +ENDIF() + +SRCS( + dynamic_config_ut.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/grpc/client + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/cms +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/dynamic_config/ya.make b/ydb/services/dynamic_config/ya.make new file mode 100644 index 00000000000..3e82f8f4a4a --- /dev/null +++ b/ydb/services/dynamic_config/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/grpc_services + ydb/core/mind + ydb/library/aclib + ydb/public/api/grpc + ydb/public/lib/operation_id + ydb/public/sdk/cpp/client/resources +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/services/ext_index/common/ya.make b/ydb/services/ext_index/common/ya.make new file mode 100644 index 00000000000..ad04870a608 --- /dev/null +++ b/ydb/services/ext_index/common/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( + service.cpp + config.cpp + events.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/public/api/protos + ydb/core/protos + contrib/libs/apache/arrow +) + +END() diff --git a/ydb/services/ext_index/metadata/extractor/ya.make b/ydb/services/ext_index/metadata/extractor/ya.make new file mode 100644 index 00000000000..7d673a81f7c --- /dev/null +++ b/ydb/services/ext_index/metadata/extractor/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + abstract.cpp + GLOBAL city.cpp + container.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + ydb/core/protos + ydb/core/tx/sharding +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/ext_index/metadata/ya.make b/ydb/services/ext_index/metadata/ya.make new file mode 100644 index 00000000000..6284eac2d0e --- /dev/null +++ b/ydb/services/ext_index/metadata/ya.make @@ -0,0 +1,22 @@ +LIBRARY() + +SRCS( + object.cpp + GLOBAL behaviour.cpp + manager.cpp + initializer.cpp + snapshot.cpp + fetcher.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/grpc_services/local_rpc + ydb/core/grpc_services/base + ydb/core/grpc_services + ydb/services/metadata/request + ydb/services/ext_index/metadata/extractor +) + +END() diff --git a/ydb/services/ext_index/service/ya.make b/ydb/services/ext_index/service/ya.make new file mode 100644 index 00000000000..b3966eec803 --- /dev/null +++ b/ydb/services/ext_index/service/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + add_data.cpp + add_index.cpp + executor.cpp + activation.cpp + deleting.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/services/ext_index/metadata + ydb/services/ext_index/common + ydb/library/yql/minikql/jsonpath + ydb/public/api/protos +) + +END() diff --git a/ydb/services/ext_index/ut/ya.make b/ydb/services/ext_index/ut/ya.make new file mode 100644 index 00000000000..bb31f9a38db --- /dev/null +++ b/ydb/services/ext_index/ut/ya.make @@ -0,0 +1,33 @@ +UNITTEST_FOR(ydb/services/ext_index) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/metadata + ydb/services/ext_index + ydb/public/lib/yson_value +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_ext_index.cpp +) + +END() diff --git a/ydb/services/ext_index/ya.make b/ydb/services/ext_index/ya.make new file mode 100644 index 00000000000..2c29168f8a8 --- /dev/null +++ b/ydb/services/ext_index/ya.make @@ -0,0 +1,16 @@ +LIBRARY() + +SRCS( +) + +PEERDIR( + ydb/services/ext_index/metadata + ydb/services/ext_index/service + ydb/services/ext_index/common +) + +END() + +RECURSE( + ut +)
\ No newline at end of file diff --git a/ydb/services/fq/ut_integration/ya.make b/ydb/services/fq/ut_integration/ya.make new file mode 100644 index 00000000000..9f3f25f0a2a --- /dev/null +++ b/ydb/services/fq/ut_integration/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/services/fq) + +FORK_SUBTESTS() + +SIZE(MEDIUM) + +SRCS( + ut_utils.cpp + fq_ut.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/grpc/client + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/fq/libs/control_plane_storage + ydb/core/fq/libs/db_schema + ydb/core/fq/libs/private_client + ydb/core/testlib/default + ydb/library/yql/providers/common/db_id_async_resolver + ydb/library/yql/udfs/common/clickhouse/client + ydb/library/yql/utils + ydb/public/lib/fq + ydb/services/ydb +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:14) + +END() diff --git a/ydb/services/fq/ya.make b/ydb/services/fq/ya.make new file mode 100644 index 00000000000..68429f0bf05 --- /dev/null +++ b/ydb/services/fq/ya.make @@ -0,0 +1,21 @@ +LIBRARY() + +SRCS( + grpc_service.cpp + private_grpc.cpp +) + +PEERDIR( + library/cpp/grpc/server + library/cpp/retry + ydb/core/fq/libs/grpc + ydb/core/grpc_services + ydb/core/grpc_services/base + ydb/library/protobuf_printer +) + +END() + +RECURSE_FOR_TESTS( + ut_integration +) diff --git a/ydb/services/kesus/ya.make b/ydb/services/kesus/ya.make new file mode 100644 index 00000000000..3d330a1f062 --- /dev/null +++ b/ydb/services/kesus/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/base + ydb/core/grpc_services + ydb/core/grpc_streaming + ydb/core/kesus/proxy + ydb/core/kesus/tablet + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/lib/operation_id +) + +END() diff --git a/ydb/services/lib/actors/ya.make b/ydb/services/lib/actors/ya.make new file mode 100644 index 00000000000..19e4db930b9 --- /dev/null +++ b/ydb/services/lib/actors/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + pq_schema_actor.cpp + pq_rl_helpers.cpp +) + +PEERDIR( + library/cpp/grpc/server + library/cpp/digest/md5 + ydb/core/grpc_services + ydb/core/grpc_services/base + ydb/core/metering + ydb/core/mind + ydb/core/protos + ydb/library/persqueue/obfuscate + ydb/library/persqueue/topic_parser + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/lib/jwt + ydb/public/lib/operation_id +) + +END() diff --git a/ydb/services/lib/sharding/ya.make b/ydb/services/lib/sharding/ya.make new file mode 100644 index 00000000000..ffefdc3a3b4 --- /dev/null +++ b/ydb/services/lib/sharding/ya.make @@ -0,0 +1,7 @@ +LIBRARY() + +SRCS( + sharding.cpp +) + +END() diff --git a/ydb/services/lib/ya.make b/ydb/services/lib/ya.make new file mode 100644 index 00000000000..a61677fc9f7 --- /dev/null +++ b/ydb/services/lib/ya.make @@ -0,0 +1,4 @@ +RECURSE( + actors + sharding +) diff --git a/ydb/services/local_discovery/ya.make b/ydb/services/local_discovery/ya.make new file mode 100644 index 00000000000..e087abc6f09 --- /dev/null +++ b/ydb/services/local_discovery/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/grpc_services + ydb/core/mind + ydb/public/api/grpc + ydb/public/lib/operation_id +) + +END() diff --git a/ydb/services/metadata/abstract/ya.make b/ydb/services/metadata/abstract/ya.make new file mode 100644 index 00000000000..892e9b3f443 --- /dev/null +++ b/ydb/services/metadata/abstract/ya.make @@ -0,0 +1,24 @@ +LIBRARY() + +SRCS( + common.cpp + decoder.cpp + fetcher.cpp + kqp_common.cpp + initialization.cpp + parsing.cpp + request_features.cpp +) + +GENERATE_ENUM_SERIALIZATION(kqp_common.h) + +PEERDIR( + ydb/library/accessor + library/cpp/actors/core + ydb/services/metadata/request + ydb/public/api/protos + ydb/core/base + ydb/library/yql/core/expr_nodes +) + +END() diff --git a/ydb/services/metadata/common/ya.make b/ydb/services/metadata/common/ya.make new file mode 100644 index 00000000000..d7f364bbcdd --- /dev/null +++ b/ydb/services/metadata/common/ya.make @@ -0,0 +1,17 @@ +LIBRARY() + +SRCS( + timeout.cpp + ss_dialog.cpp +) + +PEERDIR( + ydb/services/metadata/initializer + ydb/services/metadata/abstract + ydb/services/bg_tasks/abstract + ydb/core/tx/schemeshard +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/metadata/ds_table/ya.make b/ydb/services/metadata/ds_table/ya.make new file mode 100644 index 00000000000..5930b02d86f --- /dev/null +++ b/ydb/services/metadata/ds_table/ya.make @@ -0,0 +1,27 @@ +LIBRARY() + +SRCS( + accessor_refresh.cpp + accessor_subscribe.cpp + accessor_snapshot_simple.cpp + accessor_snapshot_base.cpp + behaviour_registrator_actor.cpp + scheme_describe.cpp + table_exists.cpp + service.cpp + config.cpp + registration.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/services/metadata/common + ydb/core/grpc_services/local_rpc + ydb/core/grpc_services/base + ydb/core/grpc_services + ydb/services/metadata/initializer + ydb/services/metadata/secret +) + +END() diff --git a/ydb/services/metadata/initializer/ut/ya.make b/ydb/services/metadata/initializer/ut/ya.make new file mode 100644 index 00000000000..245359e357c --- /dev/null +++ b/ydb/services/metadata/initializer/ut/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/services/metadata/initializer) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/metadata + ydb/public/lib/yson_value +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_init.cpp +) + +END() diff --git a/ydb/services/metadata/initializer/ya.make b/ydb/services/metadata/initializer/ya.make new file mode 100644 index 00000000000..bc7b34e8dea --- /dev/null +++ b/ydb/services/metadata/initializer/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +SRCS( + accessor_init.cpp + behaviour.cpp + common.cpp + controller.cpp + events.cpp + manager.cpp + object.cpp + snapshot.cpp + initializer.cpp + fetcher.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/grpc_services/local_rpc + ydb/core/grpc_services/base + ydb/core/grpc_services + ydb/services/metadata/request +) + +END() + +RECURSE_FOR_TESTS( + ut +)
\ No newline at end of file diff --git a/ydb/services/metadata/manager/ya.make b/ydb/services/metadata/manager/ya.make new file mode 100644 index 00000000000..1cb934f540d --- /dev/null +++ b/ydb/services/metadata/manager/ya.make @@ -0,0 +1,32 @@ +LIBRARY() + +SRCS( + abstract.cpp + alter.cpp + alter_impl.cpp + table_record.cpp + restore.cpp + modification.cpp + generic_manager.cpp + preparation_controller.cpp + restore_controller.cpp + common.cpp + ydb_value_operator.cpp + modification_controller.cpp + object.cpp +) + +PEERDIR( + ydb/library/accessor + library/cpp/actors/core + ydb/public/api/protos + ydb/core/protos + ydb/services/bg_tasks/abstract + ydb/services/metadata/initializer + ydb/core/base + ydb/services/metadata/request +) + +GENERATE_ENUM_SERIALIZATION(abstract.h) + +END() diff --git a/ydb/services/metadata/request/ya.make b/ydb/services/metadata/request/ya.make new file mode 100644 index 00000000000..3ea26a6de34 --- /dev/null +++ b/ydb/services/metadata/request/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + request_actor.cpp + request_actor_cb.cpp + config.cpp + common.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/grpc_services/local_rpc + ydb/core/grpc_services/base + ydb/core/grpc_services +) + +END() diff --git a/ydb/services/metadata/secret/ut/ya.make b/ydb/services/metadata/secret/ut/ya.make new file mode 100644 index 00000000000..98aa42b6a1c --- /dev/null +++ b/ydb/services/metadata/secret/ut/ya.make @@ -0,0 +1,32 @@ +UNITTEST_FOR(ydb/services/metadata/secret) + +FORK_SUBTESTS() + +SPLIT_FACTOR(60) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/testlib/default + ydb/services/metadata + ydb/public/lib/yson_value +) + +YQL_LAST_ABI_VERSION() + +SRCS( + ut_secret.cpp +) + +END() diff --git a/ydb/services/metadata/secret/ya.make b/ydb/services/metadata/secret/ya.make new file mode 100644 index 00000000000..dbdd1ad45ad --- /dev/null +++ b/ydb/services/metadata/secret/ya.make @@ -0,0 +1,30 @@ +LIBRARY() + +SRCS( + secret.cpp + GLOBAL secret_behaviour.cpp + checker_secret.cpp + access.cpp + GLOBAL access_behaviour.cpp + checker_access.cpp + + manager.cpp + snapshot.cpp + initializer.cpp + fetcher.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/core/base + ydb/core/grpc_services/local_rpc + ydb/core/grpc_services/base + ydb/core/grpc_services + ydb/services/metadata/request +) + +END() + +RECURSE_FOR_TESTS( + ut +)
\ No newline at end of file diff --git a/ydb/services/metadata/ya.make b/ydb/services/metadata/ya.make new file mode 100644 index 00000000000..b6152c0e960 --- /dev/null +++ b/ydb/services/metadata/ya.make @@ -0,0 +1,18 @@ +LIBRARY() + +SRCS( + service.cpp +) + +PEERDIR( + library/cpp/actors/core + ydb/services/metadata/abstract + ydb/services/metadata/manager +) + +END() + +RECURSE( + secret + initializer +)
\ No newline at end of file diff --git a/ydb/services/monitoring/ya.make b/ydb/services/monitoring/ya.make new file mode 100644 index 00000000000..92214aa678b --- /dev/null +++ b/ydb/services/monitoring/ya.make @@ -0,0 +1,15 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/grpc_services + ydb/core/protos + ydb/public/api/grpc + ydb/public/lib/operation_id +) + +END() diff --git a/ydb/services/persqueue_cluster_discovery/cluster_ordering/ut/ya.make b/ydb/services/persqueue_cluster_discovery/cluster_ordering/ut/ya.make new file mode 100644 index 00000000000..13806210e1b --- /dev/null +++ b/ydb/services/persqueue_cluster_discovery/cluster_ordering/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(ydb/services/persqueue_cluster_discovery/cluster_ordering) + +SRCS( + weighed_ordering_ut.cpp +) + +PEERDIR( + ydb/services/persqueue_cluster_discovery/cluster_ordering +) + +END() diff --git a/ydb/services/persqueue_cluster_discovery/cluster_ordering/ya.make b/ydb/services/persqueue_cluster_discovery/cluster_ordering/ya.make new file mode 100644 index 00000000000..20bc43ef9ec --- /dev/null +++ b/ydb/services/persqueue_cluster_discovery/cluster_ordering/ya.make @@ -0,0 +1,11 @@ +LIBRARY() + +SRCS( + weighed_ordering.cpp +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/services/persqueue_cluster_discovery/ut/ya.make b/ydb/services/persqueue_cluster_discovery/ut/ya.make new file mode 100644 index 00000000000..5e527124367 --- /dev/null +++ b/ydb/services/persqueue_cluster_discovery/ut/ya.make @@ -0,0 +1,28 @@ +UNITTEST_FOR(ydb/services/persqueue_cluster_discovery) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:32) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + cluster_discovery_service_ut.cpp +) + +PEERDIR( + library/cpp/actors/http + ydb/core/testlib/default + ydb/public/api/grpc + ydb/services/persqueue_cluster_discovery +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/persqueue_cluster_discovery/ya.make b/ydb/services/persqueue_cluster_discovery/ya.make new file mode 100644 index 00000000000..40d0e4470e0 --- /dev/null +++ b/ydb/services/persqueue_cluster_discovery/ya.make @@ -0,0 +1,29 @@ +LIBRARY() + +SRCS( + cluster_discovery_service.cpp + cluster_discovery_worker.cpp + counters.cpp + grpc_service.cpp +) + +PEERDIR( + ydb/core/base + ydb/core/client/server + ydb/core/grpc_services + ydb/core/mind/address_classification + ydb/core/mon + ydb/core/persqueue + ydb/core/protos + ydb/core/util + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/services/persqueue_cluster_discovery/cluster_ordering +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/services/persqueue_v1/actors/ya.make b/ydb/services/persqueue_v1/actors/ya.make new file mode 100644 index 00000000000..8a72a9599a8 --- /dev/null +++ b/ydb/services/persqueue_v1/actors/ya.make @@ -0,0 +1,46 @@ +LIBRARY() + +PEERDIR( + library/cpp/actors/core + library/cpp/containers/disjoint_interval_tree + ydb/core/base + ydb/core/grpc_services + ydb/core/persqueue + ydb/core/persqueue/events + ydb/core/protos + ydb/core/scheme + ydb/core/tx/scheme_cache + ydb/library/aclib + ydb/library/persqueue/topic_parser + ydb/public/api/protos + ydb/public/lib/base + ydb/services/lib/actors + ydb/services/lib/sharding + ydb/services/metadata +) + +SRCS( + codecs.h + codecs.cpp + commit_offset_actor.h + commit_offset_actor.cpp + events.h + persqueue_utils.h + persqueue_utils.cpp + helpers.h + helpers.cpp + partition_actor.h + partition_actor.cpp + partition_id.h + read_init_auth_actor.h + read_init_auth_actor.cpp + read_info_actor.h + read_info_actor.cpp + read_session_actor.h + write_session_actor.h + schema_actors.h + schema_actors.cpp + update_offsets_in_transaction_actor.cpp +) + +END() diff --git a/ydb/services/persqueue_v1/ut/new_schemecache_ut/ya.make b/ydb/services/persqueue_v1/ut/new_schemecache_ut/ya.make new file mode 100644 index 00000000000..0257117997c --- /dev/null +++ b/ydb/services/persqueue_v1/ut/new_schemecache_ut/ya.make @@ -0,0 +1,38 @@ +UNITTEST_FOR(ydb/services/persqueue_v1) + +FORK_SUBTESTS() + +IF (WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:32) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + persqueue_new_schemecache_ut.cpp + persqueue_common_new_schemecache_ut.cpp + ut/api_test_setup.h + ut/test_utils.h + ut/pq_data_writer.h + ut/rate_limiter_test_setup.h + ut/rate_limiter_test_setup.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + ydb/core/testlib/default + ydb/public/api/grpc + ydb/public/sdk/cpp/client/resources + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils + ydb/public/sdk/cpp/client/ydb_table + ydb/services/persqueue_v1 +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/persqueue_v1/ut/ya.make b/ydb/services/persqueue_v1/ut/ya.make new file mode 100644 index 00000000000..7a66c7a8cdf --- /dev/null +++ b/ydb/services/persqueue_v1/ut/ya.make @@ -0,0 +1,51 @@ +UNITTEST_FOR(ydb/services/persqueue_v1) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:32) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + persqueue_ut.cpp + persqueue_common_ut.cpp + persqueue_compat_ut.cpp + first_class_src_ids_ut.cpp + topic_yql_ut.cpp + + test_utils.h + pq_data_writer.h + api_test_setup.h + rate_limiter_test_setup.h + rate_limiter_test_setup.cpp + functions_executor_wrapper.h + functions_executor_wrapper.cpp + topic_service_ut.cpp + demo_tx.cpp +) + +PEERDIR( + library/cpp/getopt + library/cpp/svnversion + library/cpp/digest/md5 + ydb/core/testlib/default + ydb/library/aclib + ydb/library/persqueue/topic_parser + ydb/public/api/grpc + ydb/public/sdk/cpp/client/ydb_persqueue_core/ut/ut_utils + ydb/public/sdk/cpp/client/ydb_persqueue_public + ydb/public/sdk/cpp/client/ydb_table + ydb/public/sdk/cpp/client/ydb_topic + ydb/public/sdk/cpp/client/ydb_proto + ydb/services/persqueue_v1 +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/persqueue_v1/ya.make b/ydb/services/persqueue_v1/ya.make new file mode 100644 index 00000000000..49ba698b26a --- /dev/null +++ b/ydb/services/persqueue_v1/ya.make @@ -0,0 +1,48 @@ +LIBRARY() + +SRCS( + grpc_pq_read.cpp + grpc_pq_read.h + grpc_pq_schema.cpp + grpc_pq_schema.h + grpc_pq_write.cpp + grpc_pq_write.h + persqueue.cpp + persqueue.h + topic.cpp +) + +PEERDIR( + library/cpp/actors/core + library/cpp/containers/disjoint_interval_tree + library/cpp/grpc/server + ydb/core/base + ydb/core/grpc_services + ydb/core/kqp + ydb/core/persqueue + ydb/core/persqueue/codecs + ydb/core/persqueue/writer + ydb/core/protos + ydb/core/ydb_convert + ydb/library/aclib + ydb/library/persqueue/obfuscate + ydb/library/persqueue/tests + ydb/library/persqueue/topic_parser + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/services/lib/actors + ydb/services/lib/sharding + ydb/services/persqueue_v1/actors +) + +END() + +RECURSE( + actors +) + +RECURSE_FOR_TESTS( + ut + ut/new_schemecache_ut +) diff --git a/ydb/services/rate_limiter/ut/ya.make b/ydb/services/rate_limiter/ut/ya.make new file mode 100644 index 00000000000..5025ae8092b --- /dev/null +++ b/ydb/services/rate_limiter/ut/ya.make @@ -0,0 +1,17 @@ +UNITTEST_FOR(ydb/services/rate_limiter) + +SIZE(MEDIUM) + +SRCS( + rate_limiter_ut.cpp +) + +PEERDIR( + ydb/core/testlib/default + ydb/public/sdk/cpp/client/ydb_coordination + ydb/public/sdk/cpp/client/ydb_rate_limiter +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/rate_limiter/ya.make b/ydb/services/rate_limiter/ya.make new file mode 100644 index 00000000000..ad9ee72c754 --- /dev/null +++ b/ydb/services/rate_limiter/ya.make @@ -0,0 +1,19 @@ +LIBRARY() + +SRCS( + grpc_service.cpp +) + +PEERDIR( + library/cpp/grpc/server + ydb/core/grpc_services + ydb/core/kesus/tablet + ydb/public/api/grpc + ydb/services/ydb +) + +END() + +RECURSE_FOR_TESTS( + ut +) diff --git a/ydb/services/ya.make b/ydb/services/ya.make new file mode 100644 index 00000000000..a62562b1134 --- /dev/null +++ b/ydb/services/ya.make @@ -0,0 +1,19 @@ +RECURSE( + auth + bg_tasks + cms + dynamic_config + datastreams + discovery + fq + kesus + lib + local_discovery + metadata + monitoring + persqueue_cluster_discovery + persqueue_v1 + rate_limiter + ext_index + ydb +) diff --git a/ydb/services/ydb/index_ut/ya.make b/ydb/services/ydb/index_ut/ya.make new file mode 100644 index 00000000000..4c61789bb06 --- /dev/null +++ b/ydb/services/ydb/index_ut/ya.make @@ -0,0 +1,34 @@ +UNITTEST_FOR(ydb/services/ydb) + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + ydb_index_ut.cpp +) + +PEERDIR( + ydb/core/testlib/default + ydb/public/lib/idx_test + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/ydb/sdk_credprovider_ut/ya.make b/ydb/services/ydb/sdk_credprovider_ut/ya.make new file mode 100644 index 00000000000..fcc5fae7e67 --- /dev/null +++ b/ydb/services/ydb/sdk_credprovider_ut/ya.make @@ -0,0 +1,33 @@ +UNITTEST_FOR(ydb/services/ydb) + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SRCS( + dummy_provider_ut.cpp +) + +PEERDIR( + ydb/core/testlib/default + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/services/ydb/sdk_sessions_pool_ut/ya.make b/ydb/services/ydb/sdk_sessions_pool_ut/ya.make new file mode 100644 index 00000000000..a6328d4f024 --- /dev/null +++ b/ydb/services/ydb/sdk_sessions_pool_ut/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/services/ydb) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SPLIT_FACTOR(60) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(300) + SIZE(MEDIUM) +ENDIF() + +SRCS( + sdk_sessions_pool_ut.cpp +) + +PEERDIR( + library/cpp/grpc/client + ydb/core/testlib/default + ydb/core/testlib + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:14) + +END() diff --git a/ydb/services/ydb/sdk_sessions_ut/ya.make b/ydb/services/ydb/sdk_sessions_ut/ya.make new file mode 100644 index 00000000000..1ec6a2495d5 --- /dev/null +++ b/ydb/services/ydb/sdk_sessions_ut/ya.make @@ -0,0 +1,30 @@ +UNITTEST_FOR(ydb/services/ydb) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SPLIT_FACTOR(60) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(300) + SIZE(MEDIUM) +ENDIF() + +SRCS( + sdk_sessions_ut.cpp +) + +PEERDIR( + library/cpp/grpc/client + ydb/core/testlib/default + ydb/core/testlib + ydb/public/sdk/cpp/client/ydb_table +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:14) + +END() diff --git a/ydb/services/ydb/table_split_ut/ya.make b/ydb/services/ydb/table_split_ut/ya.make new file mode 100644 index 00000000000..3a62ecce825 --- /dev/null +++ b/ydb/services/ydb/table_split_ut/ya.make @@ -0,0 +1,48 @@ +UNITTEST_FOR(ydb/services/ydb) + +FORK_SUBTESTS() +SPLIT_FACTOR(7) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(300) + SIZE(MEDIUM) +ENDIF() + +SRCS( + ydb_table_split_ut.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + library/cpp/getopt + library/cpp/grpc/client + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/grpc_services/base + ydb/core/testlib + ydb/library/yql/minikql/dom + ydb/library/yql/minikql/jsonpath + ydb/public/lib/experimental + ydb/public/lib/json_value + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/draft + ydb/public/sdk/cpp/client/ydb_coordination + ydb/public/sdk/cpp/client/ydb_export + ydb/public/sdk/cpp/client/ydb_extension + ydb/public/sdk/cpp/client/ydb_operation + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_monitoring + ydb/services/ydb +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:14) + +END() diff --git a/ydb/services/ydb/ut/ya.make b/ydb/services/ydb/ut/ya.make new file mode 100644 index 00000000000..7d3c20fa4e2 --- /dev/null +++ b/ydb/services/ydb/ut/ya.make @@ -0,0 +1,62 @@ +UNITTEST_FOR(ydb/services/ydb) + +FORK_SUBTESTS() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + SPLIT_FACTOR(60) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(300) + SIZE(MEDIUM) +ENDIF() + +SRCS( + ydb_bulk_upsert_ut.cpp + ydb_bulk_upsert_olap_ut.cpp + ydb_coordination_ut.cpp + ydb_index_table_ut.cpp + ydb_import_ut.cpp + ydb_ut.cpp + ydb_client_certs_ut.cpp + ydb_scripting_ut.cpp + ydb_table_ut.cpp + ydb_stats_ut.cpp + ydb_long_tx_ut.cpp + ydb_logstore_ut.cpp + ydb_olapstore_ut.cpp + ydb_monitoring_ut.cpp + cert_gen.cpp +) + +PEERDIR( + contrib/libs/apache/arrow + library/cpp/getopt + library/cpp/grpc/client + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib/default + ydb/core/grpc_services/base + ydb/core/testlib + ydb/library/yql/minikql/dom + ydb/library/yql/minikql/jsonpath + ydb/public/lib/experimental + ydb/public/lib/json_value + ydb/public/lib/yson_value + ydb/public/sdk/cpp/client/draft + ydb/public/sdk/cpp/client/ydb_coordination + ydb/public/sdk/cpp/client/ydb_export + ydb/public/sdk/cpp/client/ydb_extension + ydb/public/sdk/cpp/client/ydb_operation + ydb/public/sdk/cpp/client/ydb_scheme + ydb/public/sdk/cpp/client/ydb_monitoring + ydb/services/ydb +) + +YQL_LAST_ABI_VERSION() + +REQUIREMENTS(ram:14) + +END() diff --git a/ydb/services/ydb/ya.make b/ydb/services/ydb/ya.make new file mode 100644 index 00000000000..ddc52473174 --- /dev/null +++ b/ydb/services/ydb/ya.make @@ -0,0 +1,46 @@ +LIBRARY() + +SRCS( + ydb_clickhouse_internal.cpp + ydb_dummy.cpp + ydb_export.cpp + ydb_import.cpp + ydb_logstore.cpp + ydb_operation.cpp + ydb_query.cpp + ydb_scheme.cpp + ydb_scripting.cpp + ydb_table.cpp + ydb_long_tx.cpp +) + +PEERDIR( + library/cpp/monlib/encode + library/cpp/uri + ydb/core/base + ydb/core/client + ydb/core/formats + ydb/core/grpc_services + ydb/core/grpc_services/base + ydb/core/grpc_services/auth_processor + ydb/core/grpc_streaming + ydb/core/protos + ydb/core/scheme + ydb/library/aclib + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/library/yql/public/types + contrib/libs/openssl +) + +END() + +RECURSE_FOR_TESTS( + index_ut + sdk_credprovider_ut + sdk_sessions_ut + sdk_sessions_pool_ut + table_split_ut + ut +) diff --git a/ydb/tests/functional/api/ya.make b/ydb/tests/functional/api/ya.make new file mode 100644 index 00000000000..5798336aaf0 --- /dev/null +++ b/ydb/tests/functional/api/ya.make @@ -0,0 +1,37 @@ +PY3TEST() + +SPLIT_FACTOR(30) +FORK_SUBTESTS() +FORK_TEST_FILES() +TIMEOUT(600) +SIZE(MEDIUM) + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test_session_pool.py + test_crud.py + test_indexes.py + test_discovery.py + test_execute_scheme.py + test_insert.py + test_isolation.py + test_public_api.py + test_read_table.py + test_session_grace_shutdown.py +) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + contrib/python/tornado/tornado-4 + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python +) + +REQUIREMENTS(ram:10) + +END() diff --git a/ydb/tests/functional/autoconfig/ya.make b/ydb/tests/functional/autoconfig/ya.make new file mode 100644 index 00000000000..ce5baaec46b --- /dev/null +++ b/ydb/tests/functional/autoconfig/ya.make @@ -0,0 +1,29 @@ +PY3TEST() + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + test_actorsystem.py +) + +REQUIREMENTS( + cpu:4 + ram:16 +) +TIMEOUT(600) +SIZE(MEDIUM) + +SPLIT_FACTOR(20) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + contrib/python/PyHamcrest +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/blobstorage/ya.make b/ydb/tests/functional/blobstorage/ya.make new file mode 100644 index 00000000000..7d240d08017 --- /dev/null +++ b/ydb/tests/functional/blobstorage/ya.make @@ -0,0 +1,42 @@ +PY3TEST() + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + test_pdisk_format_info.py + test_replication.py + test_self_heal.py + test_tablet_channel_migration.py +) + +IF (SANITIZER_TYPE) + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +SPLIT_FACTOR(20) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + contrib/python/PyHamcrest +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/canonical/ya.make b/ydb/tests/functional/canonical/ya.make new file mode 100644 index 00000000000..12503d45705 --- /dev/null +++ b/ydb/tests/functional/canonical/ya.make @@ -0,0 +1,33 @@ +PY3TEST() + +ENV(YDB_TOKEN="root@builtin") +ENV(YDB_ADDITIONAL_LOG_CONFIGS="GRPC_SERVER:DEBUG,TICKET_PARSER:WARN,KQP_COMPILE_ACTOR:DEBUG") +TEST_SRCS( + test_sql.py +) + +TIMEOUT(600) +SIZE(MEDIUM) + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +DEPENDS( + ydb/apps/ydbd +) + + +DATA ( + arcadia/ydb/tests/functional/canonical/canondata + arcadia/ydb/tests/functional/canonical/sql +) + + +PEERDIR( + ydb/tests/library + ydb/tests/oss/canonical + ydb/tests/oss/ydb_sdk_import +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/clickbench/ya.make b/ydb/tests/functional/clickbench/ya.make new file mode 100644 index 00000000000..793c811f08e --- /dev/null +++ b/ydb/tests/functional/clickbench/ya.make @@ -0,0 +1,34 @@ +PY3TEST() + +TEST_SRCS(test.py) + +IF (SANITIZER_TYPE) + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +ENV(YDB_USE_IN_MEMORY_PDISKS=true) +REQUIREMENTS( + ram:32 + cpu:4 +) + +DEPENDS( + ydb/apps/ydb +) + +PEERDIR( + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python + contrib/python/PyHamcrest +) + +INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc) + +FORK_SUBTESTS() +FORK_TEST_FILES() +END() diff --git a/ydb/tests/functional/cms/ya.make b/ydb/tests/functional/cms/ya.make new file mode 100644 index 00000000000..47cc2590e1b --- /dev/null +++ b/ydb/tests/functional/cms/ya.make @@ -0,0 +1,39 @@ +PY3TEST() + +PY_SRCS ( + utils.py +) +TEST_SRCS( + test_cms_erasure.py + test_cms_restart.py + test_cms_state_storage.py +) + +SPLIT_FACTOR(10) +IF (SANITIZER_TYPE == "thread") + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +REQUIREMENTS( + cpu:4 + ram:32 +) + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/cms_config_cache/ya.make b/ydb/tests/functional/cms_config_cache/ya.make new file mode 100644 index 00000000000..39fcf2d69ff --- /dev/null +++ b/ydb/tests/functional/cms_config_cache/ya.make @@ -0,0 +1,24 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + main.py +) + +TIMEOUT(600) + +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + ydb/public/sdk/python +) + +FORK_SUBTESTS() + +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/dynumber/ya.make b/ydb/tests/functional/dynumber/ya.make new file mode 100644 index 00000000000..8393c1fd835 --- /dev/null +++ b/ydb/tests/functional/dynumber/ya.make @@ -0,0 +1,16 @@ +PY3TEST() + +INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc) +TIMEOUT(600) +SIZE(MEDIUM) + +TEST_SRCS( + test_dynumber.py +) + +PEERDIR( + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python +) + +END() diff --git a/ydb/tests/functional/encryption/ya.make b/ydb/tests/functional/encryption/ya.make new file mode 100644 index 00000000000..6e9a92dc4a2 --- /dev/null +++ b/ydb/tests/functional/encryption/ya.make @@ -0,0 +1,23 @@ +PY3TEST() + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + test_encryption.py +) + +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python +) + +REQUIREMENTS(ram:11) + +END() diff --git a/ydb/tests/functional/hive/ya.make b/ydb/tests/functional/hive/ya.make new file mode 100644 index 00000000000..e2751fc7029 --- /dev/null +++ b/ydb/tests/functional/hive/ya.make @@ -0,0 +1,42 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + hive_matchers.py + test_create_tablets.py + test_kill_tablets.py + test_drain.py +) + + +REQUIREMENTS( + cpu:4 + ram:16 +) + +IF (SANITIZER_TYPE == "thread") + TIMEOUT(1200) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + ram:32 + cpu:4 + ) + SPLIT_FACTOR(20) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) + SPLIT_FACTOR(20) +ENDIF() + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/large_serializable/ya.make b/ydb/tests/functional/large_serializable/ya.make new file mode 100644 index 00000000000..6ee57d21963 --- /dev/null +++ b/ydb/tests/functional/large_serializable/ya.make @@ -0,0 +1,32 @@ +IF (NOT SANITIZER_TYPE AND NOT WITH_VALGRIND) +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +ENV(YDB_ERASURE=mirror_3_dc) +ENV(YDB_USE_IN_MEMORY_PDISKS=true) + +TEST_SRCS( + test_serializable.py +) + +REQUIREMENTS( + cpu:4 + ram:32 +) + +TIMEOUT(3600) +SIZE(LARGE) +TAG(ya:fat) + +DEPENDS( + ydb/tests/tools/ydb_serializable + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library +) + + +END() + +ENDIF() diff --git a/ydb/tests/functional/limits/ya.make b/ydb/tests/functional/limits/ya.make new file mode 100644 index 00000000000..70be6e633e7 --- /dev/null +++ b/ydb/tests/functional/limits/ya.make @@ -0,0 +1,24 @@ +PY3TEST() + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + test_schemeshard_limits.py +) + +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python +) + +FORK_TEST_FILES() +FORK_SUBTESTS() + +END() diff --git a/ydb/tests/functional/open_source/ya.make b/ydb/tests/functional/open_source/ya.make new file mode 100644 index 00000000000..c227c0b3157 --- /dev/null +++ b/ydb/tests/functional/open_source/ya.make @@ -0,0 +1,13 @@ +PY3TEST() + +TEST_SRCS( + test_yatest_common.py +) + +SIZE(SMALL) + +PEERDIR( + library/python/testing/yatest_common_standalone +) + +END() diff --git a/ydb/tests/functional/postgresql/common/ya.make b/ydb/tests/functional/postgresql/common/ya.make new file mode 100644 index 00000000000..c354d69518e --- /dev/null +++ b/ydb/tests/functional/postgresql/common/ya.make @@ -0,0 +1,8 @@ +PY3_LIBRARY() + +PY_SRCS( + __init__.py + differ.py +) + +END() diff --git a/ydb/tests/functional/postgresql/ya.make b/ydb/tests/functional/postgresql/ya.make new file mode 100644 index 00000000000..af646ba1f39 --- /dev/null +++ b/ydb/tests/functional/postgresql/ya.make @@ -0,0 +1,28 @@ +PY3TEST() + +DATA( + arcadia/ydb/tests/functional/postgresql/cases + sbr://4298147653=psql +) + +DEPENDS( + ydb/apps/ydbd + ydb/apps/pgwire +) + +ENV(PYTHONWARNINGS="ignore") +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +SIZE(MEDIUM) + +TEST_SRCS( + test_postgres.py +) + +PEERDIR( + library/python/testing/yatest_common + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/tests/functional/postgresql/common +) + +END() diff --git a/ydb/tests/functional/query_cache/ya.make b/ydb/tests/functional/query_cache/ya.make new file mode 100644 index 00000000000..d1e73a20983 --- /dev/null +++ b/ydb/tests/functional/query_cache/ya.make @@ -0,0 +1,23 @@ +PY3TEST() + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + test_query_cache.py +) + +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python +) + +REQUIREMENTS(ram:11) + +END() diff --git a/ydb/tests/functional/rename/ya.make b/ydb/tests/functional/rename/ya.make new file mode 100644 index 00000000000..092eb291beb --- /dev/null +++ b/ydb/tests/functional/rename/ya.make @@ -0,0 +1,41 @@ +PY3TEST() + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +PY_SRCS ( + conftest.py + common.py +) + +TEST_SRCS( + test_rename.py +) + + +REQUIREMENTS( + cpu:4 + ram:16 +) + +FORK_TEST_FILES() + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + FORK_SUBTESTS() + SPLIT_FACTOR(10) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS(ydb/apps/ydbd) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python + contrib/python/tornado/tornado-4 +) + +END() diff --git a/ydb/tests/functional/restarts/ya.make b/ydb/tests/functional/restarts/ya.make new file mode 100644 index 00000000000..e0c19094cfb --- /dev/null +++ b/ydb/tests/functional/restarts/ya.make @@ -0,0 +1,34 @@ +PY3TEST() + +TEST_SRCS( + test_restarts.py +) + +SPLIT_FACTOR(10) +IF (SANITIZER_TYPE == "thread") + TIMEOUT(1800) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +REQUIREMENTS( + cpu:4 + ram:16 +) + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/scheme_shard/ya.make b/ydb/tests/functional/scheme_shard/ya.make new file mode 100644 index 00000000000..1f8853b56ac --- /dev/null +++ b/ydb/tests/functional/scheme_shard/ya.make @@ -0,0 +1,25 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test_copy_ops.py + test_alter_ops.py + test_scheme_shard_operations.py +) + +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/ydb_sdk_import +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/scheme_tests/ya.make b/ydb/tests/functional/scheme_tests/ya.make new file mode 100644 index 00000000000..dfa1b5b75be --- /dev/null +++ b/ydb/tests/functional/scheme_tests/ya.make @@ -0,0 +1,23 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + tablet_scheme_tests.py +) + +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd +) + +DATA( + arcadia/ydb/tests/functional/scheme_tests/canondata +) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/canonical +) + +END() diff --git a/ydb/tests/functional/serializable/ya.make b/ydb/tests/functional/serializable/ya.make new file mode 100644 index 00000000000..8c7363cd5bf --- /dev/null +++ b/ydb/tests/functional/serializable/ya.make @@ -0,0 +1,13 @@ +PY3TEST() + +PEERDIR( + ydb/tests/tools/ydb_serializable/lib + ydb/public/sdk/python +) + +TEST_SRCS(test.py) + +INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc) + +SIZE(MEDIUM) +END() diff --git a/ydb/tests/functional/serverless/ya.make b/ydb/tests/functional/serverless/ya.make new file mode 100644 index 00000000000..d81b0bb8f41 --- /dev/null +++ b/ydb/tests/functional/serverless/ya.make @@ -0,0 +1,28 @@ +PY3TEST() + +TEST_SRCS( + conftest.py + test_serverless.py +) + +FORK_TEST_FILES() +FORK_SUBTESTS() +TIMEOUT(600) + +REQUIREMENTS( + cpu:4 + ram:32 +) +SIZE(MEDIUM) + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +DEPENDS(ydb/apps/ydbd) + +PEERDIR( + contrib/python/tornado/tornado-4 + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python +) + +END() diff --git a/ydb/tests/functional/sqs/common/ya.make b/ydb/tests/functional/sqs/common/ya.make new file mode 100644 index 00000000000..a55b0524279 --- /dev/null +++ b/ydb/tests/functional/sqs/common/ya.make @@ -0,0 +1,56 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test_account_actions.py + test_acl.py + test_counters.py + test_garbage_collection.py + test_multiplexing_tables_format.py + test_ping.py + test_queue_attributes_validation.py + test_queues_managing.py + test_format_without_version.py +) + +IF (SANITIZER_TYPE) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS( + ydb/apps/ydbd + ydb/core/ymq/client/bin +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + ydb/tests/oss/ydb_sdk_import + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +FORK_SUBTESTS() + +# SQS tests are not CPU or disk intensive, +# but they use sleeping for some events, +# so it would be secure to increase split factor. +# This increasing of split factor reduces test time +# to 15-20 seconds. +SPLIT_FACTOR(60) + +END() diff --git a/ydb/tests/functional/sqs/large/ya.make b/ydb/tests/functional/sqs/large/ya.make new file mode 100644 index 00000000000..7f97e2de1bb --- /dev/null +++ b/ydb/tests/functional/sqs/large/ya.make @@ -0,0 +1,41 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test_leader_start_inflight.py +) + +IF (SANITIZER_TYPE) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS( + ydb/apps/ydbd + ydb/core/ymq/client/bin +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +FORK_SUBTESTS() + + +END() diff --git a/ydb/tests/functional/sqs/merge_split_common_table/fifo/ya.make b/ydb/tests/functional/sqs/merge_split_common_table/fifo/ya.make new file mode 100644 index 00000000000..4ab73760c09 --- /dev/null +++ b/ydb/tests/functional/sqs/merge_split_common_table/fifo/ya.make @@ -0,0 +1,40 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test.py +) + + +IF (SANITIZER_TYPE) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS( + ydb/apps/ydbd + ydb/core/ymq/client/bin +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + ydb/tests/functional/sqs/merge_split_common_table + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +END() diff --git a/ydb/tests/functional/sqs/merge_split_common_table/std/ya.make b/ydb/tests/functional/sqs/merge_split_common_table/std/ya.make new file mode 100644 index 00000000000..4ab73760c09 --- /dev/null +++ b/ydb/tests/functional/sqs/merge_split_common_table/std/ya.make @@ -0,0 +1,40 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test.py +) + + +IF (SANITIZER_TYPE) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS( + ydb/apps/ydbd + ydb/core/ymq/client/bin +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + ydb/tests/functional/sqs/merge_split_common_table + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +END() diff --git a/ydb/tests/functional/sqs/merge_split_common_table/ya.make b/ydb/tests/functional/sqs/merge_split_common_table/ya.make new file mode 100644 index 00000000000..ea5f3eaa2a7 --- /dev/null +++ b/ydb/tests/functional/sqs/merge_split_common_table/ya.make @@ -0,0 +1,18 @@ +PY3_LIBRARY() + + +PY_SRCS( + __init__.py + test.py +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + ydb/tests/oss/ydb_sdk_import + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +END() diff --git a/ydb/tests/functional/sqs/messaging/ya.make b/ydb/tests/functional/sqs/messaging/ya.make new file mode 100644 index 00000000000..9eac0bfafc3 --- /dev/null +++ b/ydb/tests/functional/sqs/messaging/ya.make @@ -0,0 +1,49 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test_generic_messaging.py + test_fifo_messaging.py + test_polling.py +) + +IF (SANITIZER_TYPE) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS( + ydb/apps/ydbd + ydb/core/ymq/client/bin +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +FORK_SUBTESTS() + +# SQS tests are not CPU or disk intensive, +# but they use sleeping for some events, +# so it would be secure to increase split factor. +# This increasing of split factor reduces test time +# to 15-20 seconds. +SPLIT_FACTOR(60) + +END() diff --git a/ydb/tests/functional/sqs/multinode/ya.make b/ydb/tests/functional/sqs/multinode/ya.make new file mode 100644 index 00000000000..abdcd32b87a --- /dev/null +++ b/ydb/tests/functional/sqs/multinode/ya.make @@ -0,0 +1,48 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test_multinode_cluster.py + test_recompiles_requests.py +) + +IF (SANITIZER_TYPE) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS( + ydb/apps/ydbd + ydb/core/ymq/client/bin +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +FORK_SUBTESTS() + +# SQS tests are not CPU or disk intensive, +# but they use sleeping for some events, +# so it would be secure to increase split factor. +# This increasing of split factor reduces test time +# to 15-20 seconds. +SPLIT_FACTOR(60) + +END() diff --git a/ydb/tests/functional/sqs/with_quotas/ya.make b/ydb/tests/functional/sqs/with_quotas/ya.make new file mode 100644 index 00000000000..1e67fb51557 --- /dev/null +++ b/ydb/tests/functional/sqs/with_quotas/ya.make @@ -0,0 +1,48 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + +TEST_SRCS( + test_quoting.py +) + +IF (SANITIZER_TYPE) + TIMEOUT(2400) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS( + cpu:4 + ram:32 + ) +ELSE() + REQUIREMENTS( + cpu:4 + ram:16 + ) + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +DEPENDS( + ydb/apps/ydbd + ydb/core/ymq/client/bin +) + +PEERDIR( + ydb/tests/library + ydb/tests/library/sqs + ydb/tests/oss/ydb_sdk_import + contrib/python/xmltodict + contrib/python/boto3 + contrib/python/botocore +) + +FORK_SUBTESTS() + +# SQS tests are not CPU or disk intensive, +# but they use sleeping for some events, +# so it would be secure to increase split factor. +# This increasing of split factor reduces test time +# to 15-20 seconds. +SPLIT_FACTOR(60) + +END() diff --git a/ydb/tests/functional/sqs/ya.make b/ydb/tests/functional/sqs/ya.make new file mode 100644 index 00000000000..237d05d669b --- /dev/null +++ b/ydb/tests/functional/sqs/ya.make @@ -0,0 +1,10 @@ +RECURSE( + common + large + merge_split_common_table/fifo + merge_split_common_table/std + messaging + multinode + with_quotas +) + diff --git a/ydb/tests/functional/suite_tests/ya.make b/ydb/tests/functional/suite_tests/ya.make new file mode 100644 index 00000000000..4aaf44cfcdf --- /dev/null +++ b/ydb/tests/functional/suite_tests/ya.make @@ -0,0 +1,36 @@ +IF (NOT SANITIZER_TYPE AND NOT WITH_VALGRIND) + PY3TEST() + ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") + ENV(USE_IN_MEMORY_PDISKS=true) + TEST_SRCS( + test_base.py + test_postgres.py + test_sql_logic.py + test_stream_query.py + ) + + TIMEOUT(600) + SIZE(MEDIUM) + + DEPENDS( + ydb/apps/ydbd + ) + + DATA ( + arcadia/ydb/tests/functional/suite_tests/postgres + arcadia/ydb/tests/functional/suite_tests/sqllogictest + ) + + PEERDIR( + ydb/tests/library + ydb/tests/oss/canonical + ydb/tests/oss/ydb_sdk_import + ) + + FORK_SUBTESTS() + FORK_TEST_FILES() + + REQUIREMENTS(ram:12) + + END() +ENDIF() diff --git a/ydb/tests/functional/tenants/ya.make b/ydb/tests/functional/tenants/ya.make new file mode 100644 index 00000000000..5ab601aae7f --- /dev/null +++ b/ydb/tests/functional/tenants/ya.make @@ -0,0 +1,29 @@ +PY3TEST() +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TEST_SRCS( + conftest.py + test_db_counters.py + test_dynamic_tenants.py + test_tenants.py + test_storage_config.py + test_system_views.py + test_publish_into_schemeboard_with_common_ssring.py +) + +SPLIT_FACTOR(20) +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS(ydb/apps/ydbd) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python +) + +FORK_SUBTESTS() + +REQUIREMENTS(ram:10) + +END() diff --git a/ydb/tests/functional/ttl/ya.make b/ydb/tests/functional/ttl/ya.make new file mode 100644 index 00000000000..2e186932a51 --- /dev/null +++ b/ydb/tests/functional/ttl/ya.make @@ -0,0 +1,25 @@ +PY3TEST() + +TEST_SRCS( + test_ttl.py +) + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd +) + +PEERDIR( + ydb/tests/library + ydb/tests/oss/ydb_sdk_import + ydb/public/sdk/python + contrib/python/PyHamcrest +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/functional/ya.make b/ydb/tests/functional/ya.make new file mode 100644 index 00000000000..3d13664a7a8 --- /dev/null +++ b/ydb/tests/functional/ya.make @@ -0,0 +1,28 @@ +RECURSE( + api + autoconfig + blobstorage + canonical + clickbench + cms + cms_config_cache + dynumber + encryption + hive + large_serializable + limits + open_source + postgresql + rename + restarts + scheme_shard + scheme_tests + serializable + serverless + sqs + suite_tests + tenants + ttl + ydb_cli + query_cache +) diff --git a/ydb/tests/functional/ydb_cli/ya.make b/ydb/tests/functional/ydb_cli/ya.make new file mode 100644 index 00000000000..01c5fc28708 --- /dev/null +++ b/ydb/tests/functional/ydb_cli/ya.make @@ -0,0 +1,29 @@ +PY3TEST() + +TEST_SRCS( + test_ydb_backup.py + test_ydb_table.py + test_ydb_scripting.py + test_ydb_impex.py +) + +ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") +TIMEOUT(600) +SIZE(MEDIUM) + +DEPENDS( + ydb/apps/ydbd + ydb/apps/ydb +) + +PEERDIR( + contrib/python/pyarrow + ydb/tests/library + ydb/tests/oss/canonical + ydb/tests/oss/ydb_sdk_import +) + +FORK_SUBTESTS() +FORK_TEST_FILES() + +END() diff --git a/ydb/tests/library/sqs/ya.make b/ydb/tests/library/sqs/ya.make new file mode 100644 index 00000000000..4dcae89751d --- /dev/null +++ b/ydb/tests/library/sqs/ya.make @@ -0,0 +1,22 @@ +PY3_LIBRARY() + +PY_SRCS( + __init__.py + matchers.py + tables.py + test_base.py + requests_client.py +) + +IF (NOT PYTHON3) + PEERDIR( + contrib/deprecated/python/enum34 + ) +ENDIF() + +PEERDIR( + ydb/tests/oss/ydb_sdk_import + contrib/python/xmltodict +) + +END() diff --git a/ydb/tests/library/ya.make b/ydb/tests/library/ya.make new file mode 100644 index 00000000000..81b4cc2aed8 --- /dev/null +++ b/ydb/tests/library/ya.make @@ -0,0 +1,105 @@ +PY23_LIBRARY() + +PY_SRCS( + common/__init__.py + common/yatest_common.py + common/composite_assert.py + common/delayed.py + common/cms.py + common/generators.py + common/helpers.py + common/local_db_scheme.py + common/msgbus_types.py + common/protobuf.py + common/protobuf_cms.py + common/protobuf_console.py + common/protobuf_kv.py + common/protobuf_ss.py + common/path_types.py + common/types.py + common/wait_for.py + kv/__init__.py + kv/helpers.py + serializability/__init__.py + serializability/checker.py + harness/__init__.py + harness/blockstore.py + harness/daemon.py + harness/kikimr_client.py + harness/kikimr_node_interface.py + harness/kikimr_monitoring.py + harness/kikimr_cluster_interface.py + harness/kikimr_cluster.py + harness/kikimr_config.py + harness/kikimr_http_client.py + harness/kikimr_port_allocator.py + harness/kikimr_runner.py + harness/param_constants.py + harness/util.py + harness/tls_tools.py + harness/ydb_fixtures.py + matchers/__init__.py + matchers/collection.py + matchers/datashard_matchers.py + matchers/response.py + matchers/response_matchers.py + matchers/scheme_ops.py + matchers/tablets.py + predicates/__init__.py + predicates/blobstorage.py + predicates/tx.py + predicates/hive.py + predicates/executor.py + wardens/__init__.py + wardens/base.py + wardens/datashard.py + wardens/disk.py + wardens/factories.py + wardens/hive.py + wardens/logs.py + wardens/schemeshard.py + nemesis/__init__.py + nemesis/nemesis_core.py + nemesis/nemesis_network.py + nemesis/nemesis_process_killers.py + nemesis/nemesis_time_terrorist.py + nemesis/network/__init__.py + nemesis/network/client.py + nemesis/remote_execution.py + nemesis/safety_warden.py +) + +RESOURCE_FILES( + PREFIX ydb/tests/library/ + harness/resources/default_profile.txt + harness/resources/default_yaml.yml + harness/resources/default_domains.txt +) + +IF (NOT PYTHON3) + PEERDIR( + contrib/deprecated/python/futures + contrib/deprecated/python/enum34 + ) +ENDIF() + +PEERDIR( + contrib/python/PyHamcrest + contrib/python/PyYAML + contrib/python/cryptography + contrib/python/protobuf + contrib/python/pytest + contrib/python/setuptools + contrib/python/six + ydb/public/sdk/python + library/python/svn_version + library/python/testing/yatest_common + ydb/core/protos + ydb/public/api/grpc + ydb/public/api/grpc/draft + ydb/public/api/protos + ydb/tests/oss/canonical + ydb/tests/oss/ydb_sdk_import +) + +END() diff --git a/ydb/tests/oss/canonical/ya.make b/ydb/tests/oss/canonical/ya.make new file mode 100644 index 00000000000..f1600fc979d --- /dev/null +++ b/ydb/tests/oss/canonical/ya.make @@ -0,0 +1,13 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py + conftest.py + canonical.py +) + +PEERDIR( + library/python/testing/yatest_common +) + +END() diff --git a/ydb/tests/oss/launch/ya.make b/ydb/tests/oss/launch/ya.make new file mode 100644 index 00000000000..61ba373fb93 --- /dev/null +++ b/ydb/tests/oss/launch/ya.make @@ -0,0 +1,10 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py + compile_protos.py + generate_test_context.py + launch.py +) + +END() diff --git a/ydb/tests/oss/ya.make b/ydb/tests/oss/ya.make new file mode 100644 index 00000000000..f9bf3f8458a --- /dev/null +++ b/ydb/tests/oss/ya.make @@ -0,0 +1,5 @@ +RECURSE( + canonical + launch + ydb_sdk_import +) diff --git a/ydb/tests/oss/ydb_sdk_import/ya.make b/ydb/tests/oss/ydb_sdk_import/ya.make new file mode 100644 index 00000000000..24cc17d79e8 --- /dev/null +++ b/ydb/tests/oss/ydb_sdk_import/ya.make @@ -0,0 +1,18 @@ +PY23_LIBRARY() + +PY_SRCS( + __init__.py +) + +IF (PYTHON2) + ENV(PYTHON2_YDB_IMPORT='yes') + PEERDIR(ydb/public/sdk/python2) +ELSE() + PEERDIR(ydb/public/sdk/python3) +ENDIF() + +PEERDIR( + ydb/tests/oss/canonical +) + +END() diff --git a/ydb/tests/perf/ya.make b/ydb/tests/perf/ya.make new file mode 100644 index 00000000000..3b9eb67b7de --- /dev/null +++ b/ydb/tests/perf/ya.make @@ -0,0 +1,10 @@ +RECURSE_ROOT_RELATIVE( + ydb/library/yql/minikql/benchmark + ydb/library/yql/minikql/jsonpath/benchmark + ydb/library/yql/minikql/perf/alloc + ydb/library/yql/minikql/perf/mt_param + ydb/library/yql/minikql/perf/packer + ydb/library/yql/minikql/perf/param + ydb/library/yql/minikql/perf/presort + ydb/library/yql/sql/v1/perf +) diff --git a/ydb/tests/supp/ubsan_supp.inc b/ydb/tests/supp/ubsan_supp.inc new file mode 100644 index 00000000000..c1c69e962f8 --- /dev/null +++ b/ydb/tests/supp/ubsan_supp.inc @@ -0,0 +1,13 @@ +DATA( + arcadia/ydb/tests/supp +) + +ENV(YDB_UBSAN_OPTIONS=ydb/tests/supp/ubsan_default.txt) + +DEPENDS( + ydb/tests/supp +) + +USE_RECIPE( + ydb/tests/supp/ydb_supp +) diff --git a/ydb/tests/supp/ya.make b/ydb/tests/supp/ya.make new file mode 100644 index 00000000000..6ac2b35ddcb --- /dev/null +++ b/ydb/tests/supp/ya.make @@ -0,0 +1,12 @@ +PY3_PROGRAM(ydb_supp) + +PY_SRCS(__main__.py) + +PEERDIR( + library/python/testing/recipe + library/python/testing/yatest_common +) + +END() + + diff --git a/ydb/tests/tools/s3_recipe/recipe.inc b/ydb/tests/tools/s3_recipe/recipe.inc new file mode 100644 index 00000000000..896dbd5c5fe --- /dev/null +++ b/ydb/tests/tools/s3_recipe/recipe.inc @@ -0,0 +1,8 @@ +DEPENDS( + contrib/python/moto/bin + ydb/tests/tools/s3_recipe +) + +USE_RECIPE( + ydb/tests/tools/s3_recipe/s3_recipe +) diff --git a/ydb/tests/tools/s3_recipe/ya.make b/ydb/tests/tools/s3_recipe/ya.make new file mode 100644 index 00000000000..10d390f5b65 --- /dev/null +++ b/ydb/tests/tools/s3_recipe/ya.make @@ -0,0 +1,12 @@ +PY3_PROGRAM(s3_recipe) + +PY_SRCS(__main__.py) + +PEERDIR( + contrib/python/requests + library/python/testing/recipe + library/python/testing/yatest_common + library/recipes/common +) + +END() diff --git a/ydb/tests/tools/ya.make b/ydb/tests/tools/ya.make new file mode 100644 index 00000000000..5665022cb82 --- /dev/null +++ b/ydb/tests/tools/ya.make @@ -0,0 +1,5 @@ +RECURSE( + s3_recipe + ydb_serializable + ydb_serializable/replay +) diff --git a/ydb/tests/tools/ydb_serializable/lib/ya.make b/ydb/tests/tools/ydb_serializable/lib/ya.make new file mode 100644 index 00000000000..a0b5200d7b5 --- /dev/null +++ b/ydb/tests/tools/ydb_serializable/lib/ya.make @@ -0,0 +1,10 @@ +PY3_LIBRARY() + +PEERDIR( + ydb/tests/library + ydb/public/sdk/python3 +) + +PY_SRCS(__init__.py) + +END() diff --git a/ydb/tests/tools/ydb_serializable/replay/ya.make b/ydb/tests/tools/ydb_serializable/replay/ya.make new file mode 100644 index 00000000000..61e723a33da --- /dev/null +++ b/ydb/tests/tools/ydb_serializable/replay/ya.make @@ -0,0 +1,9 @@ +PY3_PROGRAM() + +PEERDIR( + ydb/tests/tools/ydb_serializable/lib +) + +PY_SRCS(__main__.py) + +END() diff --git a/ydb/tests/tools/ydb_serializable/ya.make b/ydb/tests/tools/ydb_serializable/ya.make new file mode 100644 index 00000000000..61e723a33da --- /dev/null +++ b/ydb/tests/tools/ydb_serializable/ya.make @@ -0,0 +1,9 @@ +PY3_PROGRAM() + +PEERDIR( + ydb/tests/tools/ydb_serializable/lib +) + +PY_SRCS(__main__.py) + +END() diff --git a/ydb/tests/ya.make b/ydb/tests/ya.make new file mode 100644 index 00000000000..92dd31d1504 --- /dev/null +++ b/ydb/tests/ya.make @@ -0,0 +1,9 @@ +RECURSE( + functional + library + library/sqs + oss + perf + supp + tools +) diff --git a/ydb/ya.make b/ydb/ya.make new file mode 100644 index 00000000000..be04ad0646a --- /dev/null +++ b/ydb/ya.make @@ -0,0 +1,8 @@ +RECURSE( + apps + core + library + public + services + tests +) |